Search in sources :

Example 1 with BundleEntryComponent

use of org.hl7.fhir.dstu3.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.dstu3.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.dstu3.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.dstu3.model.Bundle.BundleEntryComponent in project loinc2hpo by monarch-initiative.

the class ObservationDownloader method retrieveObservation.

static List<Observation> retrieveObservation(String loincCode) {
    List<Observation> results = new ArrayList<>();
    Bundle bundle = client.search().forResource(Observation.class).where(new TokenClientParam("code").exactly().systemAndCode(LOINC_SYSTEM, loincCode)).prettyPrint().returnBundle(Bundle.class).execute();
    while (true) {
        for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) {
            Observation observation = (Observation) bundleEntryComponent.getResource();
            results.add(observation);
        }
        if (bundle.getLink(IBaseBundle.LINK_NEXT) != null) {
            bundle = client.loadPage().next(bundle).execute();
        } else {
            break;
        }
    }
    return results;
}
Also used : TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) ArrayList(java.util.ArrayList)

Example 5 with BundleEntryComponent

use of org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent in project loinc2hpo by monarch-initiative.

the class ObservationDownloader method retrievePatient.

static List<Patient> retrievePatient(String given, String family) {
    List<Patient> patients = new ArrayList<>();
    Bundle bundle = client.search().forResource(Patient.class).where(new StringClientParam("given").matches().value(given)).where(new StringClientParam("family").matches().value(family)).prettyPrint().returnBundle(Bundle.class).execute();
    while (true) {
        for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) {
            Patient patient = (Patient) bundleEntryComponent.getResource();
            patients.add(patient);
        }
        if (bundle.getLink(IBaseBundle.LINK_NEXT) != null) {
            bundle = client.loadPage().next(bundle).execute();
        } else {
            break;
        }
    }
    return patients;
}
Also used : StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) ArrayList(java.util.ArrayList)

Aggregations

BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)5 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)3 ArrayList (java.util.ArrayList)2 OrganizationDetails (uk.gov.hscic.model.organization.OrganizationDetails)2 StringClientParam (ca.uhn.fhir.rest.gclient.StringClientParam)1 TokenClientParam (ca.uhn.fhir.rest.gclient.TokenClientParam)1 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 IdType (org.hl7.fhir.dstu3.model.IdType)1 Location (org.hl7.fhir.dstu3.model.Location)1 Organization (org.hl7.fhir.dstu3.model.Organization)1 Practitioner (org.hl7.fhir.dstu3.model.Practitioner)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 Schedule (org.hl7.fhir.dstu3.model.Schedule)1 Slot (org.hl7.fhir.dstu3.model.Slot)1 SlotDetail (uk.gov.hscic.model.appointment.SlotDetail)1 LocationDetails (uk.gov.hscic.model.location.LocationDetails)1