Search in sources :

Example 46 with Immunization

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

the class FhirEicrGeneratorFromR4 method convertR4FhirBundletoCdaEicr.

public static String convertR4FhirBundletoCdaEicr(R4FhirData data) {
    StringBuilder eICR = new StringBuilder();
    if (data != null) {
        Bundle bundle = data.getData();
        if (bundle != null) {
            List<BundleEntryComponent> entries = bundle.getEntry();
            for (BundleEntryComponent ent : entries) {
                // Populate data ..this can be moved to the APIs where the bundle is getting created.
                if (ent.getResource() instanceof Patient) {
                    logger.info(" Bundle contains Patient ");
                    data.setPatient((Patient) ent.getResource());
                } else if (ent.getResource() instanceof Practitioner) {
                    logger.info(" Bundle contains Practitioner ");
                    data.setPractitioner((Practitioner) ent.getResource());
                } else if (ent.getResource() instanceof Encounter) {
                    logger.info(" Bundle contains Encounter ");
                    data.setEncounter((Encounter) ent.getResource());
                } else if (ent.getResource() instanceof Location) {
                    logger.info(" Bundle contains Location ");
                    data.setLocation((Location) ent.getResource());
                } else if (ent.getResource() instanceof Organization) {
                    logger.info(" Bundle contains Organization ");
                    data.setOrganization((Organization) ent.getResource());
                } else if (ent.getResource() instanceof Condition) {
                    logger.info(" Bundle contains Condition ");
                    data.getConditions().add((Condition) ent.getResource());
                } else if (ent.getResource() instanceof Observation) {
                    logger.info(" Bundle constains Observation ");
                    Observation obs = (Observation) ent.getResource();
                } else if (ent.getResource() instanceof DiagnosticReport) {
                    logger.info(" Bundle contains Diagnostic Report ");
                    data.getDiagReports().add((DiagnosticReport) ent.getResource());
                } else if (ent.getResource() instanceof MedicationStatement) {
                    logger.info(" Bundle contains MedicationStatement ");
                    data.getMedications().add((MedicationStatement) ent.getResource());
                } else if (ent.getResource() instanceof Immunization) {
                    logger.info(" Bundle contains Immunization ");
                    data.getImmunizations().add((Immunization) ent.getResource());
                }
            }
        }
    } else {
        logger.error(" No Fhir Bundle Available to create CDA Documents ");
    }
    return eICR.toString();
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Immunization(org.hl7.fhir.r4.model.Immunization) Organization(org.hl7.fhir.r4.model.Organization) Bundle(org.hl7.fhir.r4.model.Bundle) Patient(org.hl7.fhir.r4.model.Patient) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) Practitioner(org.hl7.fhir.r4.model.Practitioner) 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) Location(org.hl7.fhir.r4.model.Location)

Example 47 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project synthea by synthetichealth.

the class FhirR4 method convertToFHIR.

/**
 * Convert the given Person into a FHIR Bundle of the Patient and the
 * associated entries from their health record.
 *
 * @param person   Person to generate the FHIR JSON for
 * @param stopTime Time the simulation ended
 * @return FHIR Bundle containing the Person's health record
 */
public static Bundle convertToFHIR(Person person, long stopTime) {
    Bundle bundle = new Bundle();
    if (TRANSACTION_BUNDLE) {
        bundle.setType(BundleType.TRANSACTION);
    } else {
        bundle.setType(BundleType.COLLECTION);
    }
    BundleEntryComponent personEntry = basicInfo(person, bundle, stopTime);
    for (Encounter encounter : person.record.encounters) {
        BundleEntryComponent encounterEntry = encounter(person, personEntry, bundle, encounter);
        for (HealthRecord.Entry condition : encounter.conditions) {
            condition(person, personEntry, bundle, encounterEntry, condition);
        }
        for (HealthRecord.Allergy allergy : encounter.allergies) {
            allergy(person, personEntry, bundle, encounterEntry, allergy);
        }
        for (Observation observation : encounter.observations) {
            // Observation resources in v4 don't support Attachments
            if (observation.value instanceof Attachment) {
                media(person, personEntry, bundle, encounterEntry, observation);
            } else {
                observation(person, personEntry, bundle, encounterEntry, observation);
            }
        }
        for (Procedure procedure : encounter.procedures) {
            procedure(person, personEntry, bundle, encounterEntry, procedure);
        }
        for (HealthRecord.Device device : encounter.devices) {
            device(person, personEntry, bundle, device);
        }
        for (HealthRecord.Supply supply : encounter.supplies) {
            supplyDelivery(person, personEntry, bundle, supply, encounter);
        }
        for (Medication medication : encounter.medications) {
            medicationRequest(person, personEntry, bundle, encounterEntry, medication);
        }
        for (HealthRecord.Entry immunization : encounter.immunizations) {
            immunization(person, personEntry, bundle, encounterEntry, immunization);
        }
        for (Report report : encounter.reports) {
            report(person, personEntry, bundle, encounterEntry, report);
        }
        for (CarePlan careplan : encounter.careplans) {
            BundleEntryComponent careTeamEntry = careTeam(person, personEntry, bundle, encounterEntry, careplan);
            carePlan(person, personEntry, bundle, encounterEntry, encounter.provider, careTeamEntry, careplan);
        }
        for (ImagingStudy imagingStudy : encounter.imagingStudies) {
            imagingStudy(person, personEntry, bundle, encounterEntry, imagingStudy);
        }
        if (USE_US_CORE_IG) {
            String clinicalNoteText = ClinicalNoteExporter.export(person, encounter);
            boolean lastNote = (encounter == person.record.encounters.get(person.record.encounters.size() - 1));
            clinicalNote(person, personEntry, bundle, encounterEntry, clinicalNoteText, lastNote);
        }
        // one claim per encounter
        BundleEntryComponent encounterClaim = encounterClaim(person, personEntry, bundle, encounterEntry, encounter.claim);
        explanationOfBenefit(personEntry, bundle, encounterEntry, person, encounterClaim, encounter);
    }
    if (USE_US_CORE_IG) {
        // Add Provenance to the Bundle
        provenance(bundle, person, stopTime);
    }
    return bundle;
}
Also used : DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) Report(org.mitre.synthea.world.concepts.HealthRecord.Report) Bundle(org.hl7.fhir.r4.model.Bundle) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) Attachment(org.mitre.synthea.engine.Components.Attachment) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Observation(org.mitre.synthea.world.concepts.HealthRecord.Observation) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure)

Example 48 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project synthea by synthetichealth.

the class FhirR4 method immunization.

private static BundleEntryComponent immunization(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, HealthRecord.Entry immunization) {
    Immunization immResource = new Immunization();
    if (USE_US_CORE_IG) {
        Meta meta = new Meta();
        meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-immunization");
        immResource.setMeta(meta);
    } else if (USE_SHR_EXTENSIONS) {
        immResource.setMeta(new Meta().addProfile(SHR_EXT + "shr-immunization-ImmunizationGiven"));
        Extension performedContext = new Extension();
        performedContext.setUrl(SHR_EXT + "shr-action-PerformedContext-extension");
        performedContext.addExtension(SHR_EXT + "shr-action-Status-extension", new CodeType("completed"));
        immResource.addExtension(performedContext);
    }
    immResource.setStatus(ImmunizationStatus.COMPLETED);
    immResource.setOccurrence(convertFhirDateTime(immunization.start, true));
    immResource.setVaccineCode(mapCodeToCodeableConcept(immunization.codes.get(0), CVX_URI));
    immResource.setPrimarySource(true);
    immResource.setPatient(new Reference(personEntry.getFullUrl()));
    immResource.setEncounter(new Reference(encounterEntry.getFullUrl()));
    if (USE_US_CORE_IG) {
        org.hl7.fhir.r4.model.Encounter encounterResource = (org.hl7.fhir.r4.model.Encounter) encounterEntry.getResource();
        immResource.setLocation(encounterResource.getLocationFirstRep().getLocation());
    }
    BundleEntryComponent immunizationEntry = newEntry(rand, bundle, immResource);
    immunization.fullUrl = immunizationEntry.getFullUrl();
    return immunizationEntry;
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Immunization(org.hl7.fhir.r4.model.Immunization) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) Extension(org.hl7.fhir.r4.model.Extension) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) CodeType(org.hl7.fhir.r4.model.CodeType) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter)

Example 49 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project synthea by synthetichealth.

the class FhirStu3 method immunization.

private static BundleEntryComponent immunization(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, HealthRecord.Entry immunization) {
    Immunization immResource = new Immunization();
    immResource.setStatus(ImmunizationStatus.COMPLETED);
    immResource.setDate(new Date(immunization.start));
    immResource.setVaccineCode(mapCodeToCodeableConcept(immunization.codes.get(0), CVX_URI));
    immResource.setNotGiven(false);
    immResource.setPrimarySource(true);
    immResource.setPatient(new Reference(personEntry.getFullUrl()));
    immResource.setEncounter(new Reference(encounterEntry.getFullUrl()));
    if (USE_SHR_EXTENSIONS) {
        immResource.setMeta(new Meta().addProfile(SHR_EXT + "shr-immunization-ImmunizationGiven"));
        // profile requires action-PerformedContext-extension, status, notGiven, vaccineCode, patient,
        // date, primarySource
        Extension performedContext = new Extension();
        performedContext.setUrl(SHR_EXT + "shr-action-PerformedContext-extension");
        performedContext.addExtension(SHR_EXT + "shr-action-Status-extension", new CodeType("completed"));
        immResource.addExtension(performedContext);
    }
    BundleEntryComponent immunizationEntry = newEntry(rand, bundle, immResource);
    immunization.fullUrl = immunizationEntry.getFullUrl();
    return immunizationEntry;
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) Meta(org.hl7.fhir.dstu3.model.Meta) Immunization(org.hl7.fhir.dstu3.model.Immunization) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Reference(org.hl7.fhir.dstu3.model.Reference) CodeType(org.hl7.fhir.dstu3.model.CodeType) Date(java.util.Date)

Example 50 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project synthea by synthetichealth.

the class FhirStu3 method convertToFHIR.

/**
 * Convert the given Person into a FHIR Bundle, containing the Patient and the
 * associated entries from their health record.
 *
 * @param person Person to generate the FHIR from
 * @param stopTime Time the simulation ended
 * @return FHIR Bundle containing the Person's health record.
 */
public static Bundle convertToFHIR(Person person, long stopTime) {
    Bundle bundle = new Bundle();
    if (TRANSACTION_BUNDLE) {
        bundle.setType(BundleType.TRANSACTION);
    } else {
        bundle.setType(BundleType.COLLECTION);
    }
    BundleEntryComponent personEntry = basicInfo(person, bundle, stopTime);
    for (Encounter encounter : person.record.encounters) {
        BundleEntryComponent encounterEntry = encounter(person, personEntry, bundle, encounter);
        for (HealthRecord.Entry condition : encounter.conditions) {
            condition(person, personEntry, bundle, encounterEntry, condition);
        }
        for (HealthRecord.Entry allergy : encounter.allergies) {
            allergy(person, personEntry, bundle, encounterEntry, allergy);
        }
        for (Observation observation : encounter.observations) {
            // Observation resources in stu3 don't support Attachments
            if (observation.value instanceof Attachment) {
                media(person, personEntry, bundle, encounterEntry, observation);
            } else {
                observation(person, personEntry, bundle, encounterEntry, observation);
            }
        }
        for (Procedure procedure : encounter.procedures) {
            procedure(person, personEntry, bundle, encounterEntry, procedure);
        }
        for (Medication medication : encounter.medications) {
            medication(person, personEntry, bundle, encounterEntry, medication);
        }
        for (HealthRecord.Entry immunization : encounter.immunizations) {
            immunization(person, personEntry, bundle, encounterEntry, immunization);
        }
        for (Report report : encounter.reports) {
            report(person, personEntry, bundle, encounterEntry, report);
        }
        for (CarePlan careplan : encounter.careplans) {
            careplan(person, personEntry, bundle, encounterEntry, careplan);
        }
        for (ImagingStudy imagingStudy : encounter.imagingStudies) {
            imagingStudy(person, personEntry, bundle, encounterEntry, imagingStudy);
        }
        for (HealthRecord.Device device : encounter.devices) {
            device(person, personEntry, bundle, device);
        }
        for (HealthRecord.Supply supply : encounter.supplies) {
            supplyDelivery(person, personEntry, bundle, supply, encounter);
        }
        // one claim per encounter
        BundleEntryComponent encounterClaim = encounterClaim(person, personEntry, bundle, encounterEntry, encounter.claim);
        explanationOfBenefit(personEntry, bundle, encounterEntry, person, encounterClaim, encounter);
    }
    return bundle;
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) Report(org.mitre.synthea.world.concepts.HealthRecord.Report) Bundle(org.hl7.fhir.dstu3.model.Bundle) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) Attachment(org.mitre.synthea.engine.Components.Attachment) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Observation(org.mitre.synthea.world.concepts.HealthRecord.Observation) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure)

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