Search in sources :

Example 41 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeImmunizationImmunizationProtocolAppliedComponent.

protected void composeImmunizationImmunizationProtocolAppliedComponent(Complex parent, String parentType, String name, Immunization.ImmunizationProtocolAppliedComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "protocolApplied", name, element, index);
    if (element.hasSeriesElement())
        composeString(t, "Immunization", "series", element.getSeriesElement(), -1);
    if (element.hasAuthority())
        composeReference(t, "Immunization", "authority", element.getAuthority(), -1);
    for (int i = 0; i < element.getTargetDisease().size(); i++) composeCodeableConcept(t, "Immunization", "targetDisease", element.getTargetDisease().get(i), i);
    if (element.hasDoseNumber())
        composeType(t, "Immunization", "doseNumber", element.getDoseNumber(), -1);
    if (element.hasSeriesDoses())
        composeType(t, "Immunization", "seriesDoses", element.getSeriesDoses(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 42 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project org.hl7.fhir.core by hapifhir.

the class TurtleTests method test_immunization_example.

@Test
public void test_immunization_example() throws FileNotFoundException, IOException, Exception {
    System.out.println("immunization-example.ttl");
    new Turtle().parse(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\immunization-example.ttl"));
}
Also used : Turtle(org.hl7.fhir.dstu3.utils.formats.Turtle) Test(org.junit.jupiter.api.Test)

Example 43 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project fhir-bridge by ehrbase.

the class HistoryOfVaccinationIT method testMapping.

@Override
public void testMapping(String resourcePath, String paragonPath) throws IOException {
    Immunization immunization = (Immunization) super.testFileLoader.loadResource(resourcePath);
    ImpfstatusCompositionConverter impfstatusCompositionConverter = new ImpfstatusCompositionConverter();
    ImpfstatusComposition mappedImpfstatusComposition = impfstatusCompositionConverter.convert(immunization);
    Diff diff = compareCompositions(getJavers(), paragonPath, mappedImpfstatusComposition);
    assertEquals(0, diff.getChanges().size());
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Diff(org.javers.core.diff.Diff) ImpfstatusCompositionConverter(org.ehrbase.fhirbridge.ehr.converter.specific.impfstatus.ImpfstatusCompositionConverter) ImpfstatusComposition(org.ehrbase.fhirbridge.ehr.opt.impfstatuscomposition.ImpfstatusComposition)

Example 44 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project eCRNow by drajer-health.

the class LoadingQueryR4Bundle method createR4Bundle.

public Bundle createR4Bundle(LaunchDetails launchDetails, R4FhirData r4FhirData, Date start, Date end) {
    logger.trace("Initializing FHIR Context for Version:::: {}", launchDetails.getFhirVersion());
    FhirContext context = fhirContextInitializer.getFhirContext(launchDetails.getFhirVersion());
    IGenericClient client = fhirContextInitializer.createClient(context, launchDetails);
    Bundle bundle = r4ResourcesData.getCommonResources(r4FhirData, start, end, launchDetails, client, context);
    Encounter encounter = (Encounter) r4ResourcesData.getResourceFromBundle(bundle, Encounter.class);
    r4ResourcesData.loadPractitionersLocationAndOrganization(context, client, launchDetails, r4FhirData, encounter, bundle, start, end);
    r4ResourcesData.loadMedicationsData(context, client, launchDetails, r4FhirData, encounter, bundle, start, end);
    // Get Pregnancy Observations
    try {
        List<Observation> observationList = r4ResourcesData.getPregnancyObservationData(context, client, launchDetails, r4FhirData, encounter, start, end);
        r4FhirData.setPregnancyObs(observationList);
        for (Observation observation : observationList) {
            BundleEntryComponent observationsEntry = new BundleEntryComponent().setResource(observation);
            bundle.addEntry(observationsEntry);
        }
    } catch (Exception e) {
        logger.error("Error in getting Pregnancy Observation Data", e);
    }
    // Get Travel Observations
    try {
        List<Observation> observationList = r4ResourcesData.getTravelObservationData(context, client, launchDetails, r4FhirData, encounter, start, end);
        r4FhirData.setTravelObs(observationList);
        for (Observation observation : observationList) {
            BundleEntryComponent observationsEntry = new BundleEntryComponent().setResource(observation);
            bundle.addEntry(observationsEntry);
        }
    } catch (Exception e) {
        logger.error("Error in getting Travel Observation Data", e);
    }
    // Get Social History Observations (Occupation)
    try {
        List<Observation> observationList = r4ResourcesData.getSocialHistoryObservationDataOccupation(context, client, launchDetails, r4FhirData, encounter, start, end);
        r4FhirData.setOccupationObs(observationList);
        for (Observation observation : observationList) {
            BundleEntryComponent observationsEntry = new BundleEntryComponent().setResource(observation);
            bundle.addEntry(observationsEntry);
        }
    } catch (Exception e) {
        logger.error("Error in getting Social History Observation(Occupation) Data", e);
    }
    // Get Pregnancy Conditions
    try {
        List<Condition> conditionList = r4ResourcesData.getPregnancyConditions(context, client, launchDetails, r4FhirData, encounter, start, end);
        r4FhirData.setPregnancyConditions(conditionList);
        for (Condition condition : conditionList) {
            BundleEntryComponent conditionEntry = new BundleEntryComponent().setResource(condition);
            bundle.addEntry(conditionEntry);
        }
    } catch (Exception e) {
        logger.error("Error in getting Pregnancy Conditions", e);
    }
    try {
        List<MedicationStatement> medStatementsList = r4ResourcesData.getMedicationStatementData(context, client, launchDetails, r4FhirData, encounter, start, end);
        r4FhirData.setMedications(medStatementsList);
        for (MedicationStatement medStatement : medStatementsList) {
            BundleEntryComponent medStatementEntry = new BundleEntryComponent().setResource(medStatement);
            bundle.addEntry(medStatementEntry);
        }
    } catch (Exception e) {
        logger.error("Error in getting the MedicationStatement Data", e);
    }
    // Add to the bundle
    try {
        List<Immunization> immunizationsList = r4ResourcesData.getImmunizationData(context, client, launchDetails, r4FhirData, encounter, start, end);
        r4FhirData.setImmunizations(immunizationsList);
        for (Immunization immunization : immunizationsList) {
            BundleEntryComponent immunizationEntry = new BundleEntryComponent().setResource(immunization);
            bundle.addEntry(immunizationEntry);
        }
    } catch (Exception e) {
        logger.error("Error in getting the Immunization Data", e);
    }
    // Add to the bundle
    try {
        List<DiagnosticReport> diagnosticReportList = r4ResourcesData.getDiagnosticReportData(context, client, launchDetails, r4FhirData, encounter, start, end);
        r4FhirData.setDiagReports(diagnosticReportList);
        for (DiagnosticReport diagnosticReport : diagnosticReportList) {
            BundleEntryComponent diagnosticReportEntry = new BundleEntryComponent().setResource(diagnosticReport);
            bundle.addEntry(diagnosticReportEntry);
        }
    } catch (Exception e) {
        logger.error("Error in getting the DiagnosticReport Data", e);
    }
    // Setting bundle to FHIR Data
    logger.info("------------------------------CodeableConcept Codes------------------------------\n" + "Encounter Codes Size=====> {} \n" + "Conditions Codes Size=====> {} \n" + "Observation Codes Size=====> {}\n" + "Medication Codes Size=====> {}\n" + "Immunization Codes Size=====> {}\n" + "DiagnosticReport Codes Size=====> {}\n" + "ServiceRequests Codes Size=====> {}", r4FhirData.getR4EncounterCodes().size(), r4FhirData.getR4ConditionCodes().size(), r4FhirData.getR4LabResultCodes().size(), r4FhirData.getR4MedicationCodes().size(), r4FhirData.getR4ImmunizationCodes().size(), r4FhirData.getR4DiagnosticReportCodes().size(), r4FhirData.getR4ServiceRequestCodes().size());
    String fileName = ActionRepo.getInstance().getLogFileDirectory() + "/LoadingQueryR4Bundle-" + launchDetails.getLaunchPatientId() + ".json";
    ApplicationUtils.saveDataToFile(context.newJsonParser().encodeResourceToString(bundle), fileName);
    return bundle;
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) FhirContext(ca.uhn.fhir.context.FhirContext) Immunization(org.hl7.fhir.r4.model.Immunization) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.r4.model.Bundle) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Observation(org.hl7.fhir.r4.model.Observation) Encounter(org.hl7.fhir.r4.model.Encounter) MedicationStatement(org.hl7.fhir.r4.model.MedicationStatement)

Example 45 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project eCRNow by drajer-health.

the class R4ResourcesData method getImmunizationData.

public List<Immunization> getImmunizationData(FhirContext context, IGenericClient client, LaunchDetails launchDetails, R4FhirData r4FhirData, Encounter encounter, Date start, Date end) {
    logger.trace("Get Immunization Data");
    Bundle bundle = (Bundle) resourceData.getResourceByPatientId(launchDetails, client, context, "Immunization");
    List<Immunization> immunizations = new ArrayList<>();
    List<CodeableConcept> immunizationCodes = new ArrayList<>();
    if (bundle != null && bundle.getEntry() != null) {
        // Filter Immunizations based on Encounter Reference
        if (encounter != null && !encounter.getIdElement().getValue().isEmpty()) {
            for (BundleEntryComponent entry : bundle.getEntry()) {
                Immunization immunization = (Immunization) entry.getResource();
                if (!immunization.getEncounter().isEmpty() && immunization.getEncounter().getReferenceElement().getIdPart().equals(encounter.getIdElement().getIdPart())) {
                    immunizations.add(immunization);
                    immunizationCodes.addAll(findImmunizationCodes(immunization));
                }
            }
        // If Encounter Id is not present using start and end dates to filter
        // Immunizations
        } else {
            for (BundleEntryComponent entry : bundle.getEntry()) {
                Immunization immunization = (Immunization) entry.getResource();
                // resource
                if (immunization.getOccurrence().isDateTime() && immunization.getOccurrenceDateTimeType() != null) {
                    if (isResourceWithinDateTime(start, end, immunization.getOccurrenceDateTimeType().dateTimeValue().getValue())) {
                        immunizations.add(immunization);
                        immunizationCodes.addAll(findImmunizationCodes(immunization));
                    }
                } else // If Immunization Date is not present looking for LastUpdatedDate
                {
                    Date lastUpdatedDateTime = immunization.getMeta().getLastUpdated();
                    if (isResourceWithinDateTime(start, end, lastUpdatedDateTime)) {
                        immunizations.add(immunization);
                        immunizationCodes.addAll(findImmunizationCodes(immunization));
                    }
                }
            }
        }
        r4FhirData.setR4ImmunizationCodes(immunizationCodes);
    }
    logger.info("Filtered Immunizations -----------> {}", immunizations.size());
    return immunizations;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ArrayList(java.util.ArrayList) Date(java.util.Date)

Aggregations

Immunization (org.hl7.fhir.r4.model.Immunization)47 Test (org.junit.Test)27 Test (org.junit.jupiter.api.Test)22 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)18 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)15 Resource (org.hl7.fhir.r4.model.Resource)13 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)8 Bundle (org.hl7.fhir.r4.model.Bundle)7 Organization (org.hl7.fhir.r4.model.Organization)7 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)6 Date (java.util.Date)5 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)5 IdType (org.hl7.fhir.r4.model.IdType)5 Observation (org.hl7.fhir.r4.model.Observation)5 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)5 InputStream (java.io.InputStream)4 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)4 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)4 Obs (org.openmrs.Obs)4 FhirContext (ca.uhn.fhir.context.FhirContext)3