Search in sources :

Example 1 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.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;
        }
    }
}
Also used : IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle)

Example 2 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.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);
}
Also used : BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.dstu3.model.Organization) OrganizationDetails(uk.gov.hscic.model.organization.OrganizationDetails)

Example 3 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.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;
}
Also used : BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) MedicationStatementDetail(uk.gov.hscic.model.medication.MedicationStatementDetail)

Example 4 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.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;
}
Also used : BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Patient(org.hl7.fhir.dstu3.model.Patient) Coverage(org.hl7.fhir.dstu3.model.Coverage) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) HashSet(java.util.HashSet)

Example 5 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.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;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) HashSet(java.util.HashSet)

Aggregations

BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)259 Resource (org.hl7.fhir.r4.model.Resource)167 Test (org.junit.jupiter.api.Test)126 Bundle (org.hl7.fhir.r4.model.Bundle)112 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)96 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)88 ArrayList (java.util.ArrayList)67 Date (java.util.Date)52 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)51 Reference (org.hl7.fhir.r4.model.Reference)51 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)42 Observation (org.hl7.fhir.r4.model.Observation)36 Patient (org.hl7.fhir.r4.model.Patient)36 IOException (java.io.IOException)35 Test (org.junit.Test)35 BundleEntryComponent (org.hl7.fhir.r5.model.Bundle.BundleEntryComponent)34 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)33 Condition (org.hl7.fhir.r4.model.Condition)32 Encounter (org.hl7.fhir.r4.model.Encounter)31 Coding (org.hl7.fhir.r4.model.Coding)29