use of org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent in project loinc2hpo by monarch-initiative.
the class ObservationDownloader method find20CompleteRecordOfEachType.
static void find20CompleteRecordOfEachType() {
int i = 0;
Bundle bundle = client.search().forResource(Observation.class).prettyPrint().returnBundle(Bundle.class).execute();
while (true) {
for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) {
Observation observation = (Observation) bundleEntryComponent.getResource();
if (isComplte(observation)) {
String completeRecord = jsonParser.encodeResourceToString(observation);
i++;
System.out.println(i + ". Find a complete record: \n" + completeRecord);
}
;
}
if (bundle.getLink(IBaseBundle.LINK_NEXT) != null) {
bundle = client.loadPage().next(bundle).execute();
} else {
break;
}
}
}
use of org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent in project gpconnect-demonstrator by nhsconnect.
the class PopulateSlotBundle method addOrganisation.
/**
* Add OrganizationResource to Bundle
*
* @param organization OrganizationDetails object to add to bundle
* @param bundle Bundle Resource to add organisation to
*/
private void addOrganisation(OrganizationDetails organization, Bundle bundle) {
BundleEntryComponent organizationEntry = new BundleEntryComponent();
Long organizationId = organization.getId();
OrganizationDetails organizationDetails = organizationSearch.findOrganizationDetails(organizationId);
Organization organizationResource = organizationResourceProvider.convertOrganizationDetailsToOrganization(organizationDetails);
organizationEntry.setResource(organizationResource);
// #202 use full urls
// #215 full url removed completely
// organizationEntry.setFullUrl(serverBaseUrl + "Organization/" + organization.getId());
bundle.addEntry(organizationEntry);
}
use of org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent in project gpconnect-demonstrator by nhsconnect.
the class PopulateMedicationBundle method addMedicationBundleEntries.
public Bundle addMedicationBundleEntries(Bundle structuredBundle, PatientDetails patientDetails, Boolean includePrescriptionIssues, Period medicationPeriod, Set<String> practitionerIds, Set<String> orgIds) {
BundleEntryComponent listEntry = new BundleEntryComponent();
List<MedicationStatementDetail> medicationStatements = findMedicationStatements(Long.valueOf(patientDetails.getId()), medicationPeriod);
structuredBundle.addEntry(listEntry.setResource(createListEntry(medicationStatements, patientDetails.getNhsNumber())));
medicationStatements.forEach(medicationStatement -> {
createBundleEntries(medicationStatement, includePrescriptionIssues, patientDetails, practitionerIds, orgIds).forEach(bundleEntry -> structuredBundle.addEntry(bundleEntry));
});
return structuredBundle;
}
use of org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent in project beneficiary-fhir-data by CMSgov.
the class TransformerUtils method addResourcesToBundle.
/**
* @param bundle a {@link Bundle} to add the list of {@link ExplanationOfBenefit} resources to.
* @param resources a list of either {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
* Patient}s, of which a portion will be added to the bundle based on the paging values
* @return Returns a {@link Bundle} of {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
* Patient}s, which may contain multiple matching resources, or may also be empty.
*/
public static Bundle addResourcesToBundle(Bundle bundle, List<IBaseResource> resources) {
Set<String> beneIds = new HashSet<String>();
for (IBaseResource res : resources) {
BundleEntryComponent entry = bundle.addEntry();
entry.setResource((Resource) res);
if (entry.getResource().getResourceType() == ResourceType.ExplanationOfBenefit) {
ExplanationOfBenefit eob = ((ExplanationOfBenefit) entry.getResource());
if (eob != null && eob.getPatient() != null && !Strings.isNullOrEmpty(eob.getPatient().getReference())) {
String reference = eob.getPatient().getReference().replace("Patient/", "");
if (!Strings.isNullOrEmpty(reference)) {
beneIds.add(reference);
}
}
} else if (entry.getResource().getResourceType() == ResourceType.Patient) {
Patient patient = ((Patient) entry.getResource());
if (patient != null && !Strings.isNullOrEmpty(patient.getId())) {
beneIds.add(patient.getId());
}
} else if (entry.getResource().getResourceType() == ResourceType.Coverage) {
Coverage coverage = ((Coverage) entry.getResource());
if (coverage != null && coverage.getBeneficiary() != null && !Strings.isNullOrEmpty(coverage.getBeneficiary().getReference())) {
String reference = coverage.getBeneficiary().getReference().replace("Patient/", "");
if (!Strings.isNullOrEmpty(reference)) {
beneIds.add(reference);
}
}
}
}
logBeneIdToMdc(beneIds);
return bundle;
}
use of org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method addResourcesToBundle.
/**
* @param bundle a {@link Bundle} to add the list of {@link ExplanationOfBenefit} resources to.
* @param resources a list of either {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
* Patient}s, of which a portion will be added to the bundle based on the paging values
* @return Returns a {@link Bundle} of {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
* Patient}s, which may contain multiple matching resources, or may also be empty.
*/
public static Bundle addResourcesToBundle(Bundle bundle, List<IBaseResource> resources) {
Set<String> beneIds = new HashSet<String>();
for (IBaseResource res : resources) {
BundleEntryComponent entry = bundle.addEntry();
entry.setResource((Resource) res);
if (entry.getResource().getResourceType() == ResourceType.ExplanationOfBenefit) {
ExplanationOfBenefit eob = ((ExplanationOfBenefit) entry.getResource());
if (eob != null && eob.getPatient() != null && !Strings.isNullOrEmpty(eob.getPatient().getReference())) {
String reference = eob.getPatient().getReference().replace("Patient/", "");
if (!Strings.isNullOrEmpty(reference)) {
beneIds.add(reference);
}
}
} else if (entry.getResource().getResourceType() == ResourceType.Patient) {
Patient patient = ((Patient) entry.getResource());
if (patient != null && !Strings.isNullOrEmpty(patient.getId())) {
beneIds.add(patient.getId());
}
} else if (entry.getResource().getResourceType() == ResourceType.Coverage) {
Coverage coverage = ((Coverage) entry.getResource());
if (coverage != null && coverage.getBeneficiary() != null && !Strings.isNullOrEmpty(coverage.getBeneficiary().getReference())) {
String reference = coverage.getBeneficiary().getReference().replace("Patient/", "");
if (!Strings.isNullOrEmpty(reference)) {
beneIds.add(reference);
}
}
}
}
logBeneIdToMdc(beneIds);
return bundle;
}
Aggregations