Search in sources :

Example 1 with SupplyDelivery

use of org.hl7.fhir.dstu3.model.SupplyDelivery 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 2 with SupplyDelivery

use of org.hl7.fhir.dstu3.model.SupplyDelivery in project synthea by synthetichealth.

the class FhirR4 method supplyDelivery.

/**
 * Map the JsonObject for a Supply into a FHIR SupplyDelivery and add it to the Bundle.
 *
 * @param rand           Source of randomness to use when generating ids etc
 * @param personEntry    The Person entry.
 * @param bundle         Bundle to add to.
 * @param supply         The supplied object to add.
 * @param encounter      The encounter during which the supplies were delivered
 * @return The added Entry.
 */
private static BundleEntryComponent supplyDelivery(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, HealthRecord.Supply supply, Encounter encounter) {
    SupplyDelivery supplyResource = new SupplyDelivery();
    supplyResource.setStatus(SupplyDeliveryStatus.COMPLETED);
    supplyResource.setPatient(new Reference(personEntry.getFullUrl()));
    CodeableConcept type = new CodeableConcept();
    type.addCoding().setCode("device").setDisplay("Device").setSystem("http://terminology.hl7.org/CodeSystem/supply-item-type");
    supplyResource.setType(type);
    SupplyDeliverySuppliedItemComponent suppliedItem = new SupplyDeliverySuppliedItemComponent();
    suppliedItem.setItem(mapCodeToCodeableConcept(supply.codes.get(0), SNOMED_URI));
    suppliedItem.setQuantity(new Quantity(supply.quantity));
    supplyResource.setSuppliedItem(suppliedItem);
    supplyResource.setOccurrence(convertFhirDateTime(supply.start, true));
    return newEntry(rand, bundle, supplyResource);
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) SupplyDelivery(org.hl7.fhir.r4.model.SupplyDelivery) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) Quantity(org.hl7.fhir.r4.model.Quantity) SupplyDeliverySuppliedItemComponent(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 3 with SupplyDelivery

use of org.hl7.fhir.dstu3.model.SupplyDelivery in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeSupplyDelivery.

protected void composeSupplyDelivery(Complex parent, String parentType, String name, SupplyDelivery element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "SupplyDelivery", name, element, index);
    if (element.hasIdentifier())
        composeIdentifier(t, "SupplyDelivery", "identifier", element.getIdentifier(), -1);
    for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "SupplyDelivery", "basedOn", element.getBasedOn().get(i), i);
    for (int i = 0; i < element.getPartOf().size(); i++) composeReference(t, "SupplyDelivery", "partOf", element.getPartOf().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "SupplyDelivery", "status", element.getStatusElement(), -1);
    if (element.hasPatient())
        composeReference(t, "SupplyDelivery", "patient", element.getPatient(), -1);
    if (element.hasType())
        composeCodeableConcept(t, "SupplyDelivery", "type", element.getType(), -1);
    if (element.hasSuppliedItem())
        composeSupplyDeliverySupplyDeliverySuppliedItemComponent(t, "SupplyDelivery", "suppliedItem", element.getSuppliedItem(), -1);
    if (element.hasOccurrence())
        composeType(t, "SupplyDelivery", "occurrence", element.getOccurrence(), -1);
    if (element.hasSupplier())
        composeReference(t, "SupplyDelivery", "supplier", element.getSupplier(), -1);
    if (element.hasDestination())
        composeReference(t, "SupplyDelivery", "destination", element.getDestination(), -1);
    for (int i = 0; i < element.getReceiver().size(); i++) composeReference(t, "SupplyDelivery", "receiver", element.getReceiver().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 4 with SupplyDelivery

use of org.hl7.fhir.dstu3.model.SupplyDelivery in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeSupplyDelivery.

protected void composeSupplyDelivery(Complex parent, String parentType, String name, SupplyDelivery element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "SupplyDelivery", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "SupplyDelivery", "identifier", element.getIdentifier().get(i), i);
    for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "SupplyDelivery", "basedOn", element.getBasedOn().get(i), i);
    for (int i = 0; i < element.getPartOf().size(); i++) composeReference(t, "SupplyDelivery", "partOf", element.getPartOf().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "SupplyDelivery", "status", element.getStatusElement(), -1);
    if (element.hasPatient())
        composeReference(t, "SupplyDelivery", "patient", element.getPatient(), -1);
    if (element.hasType())
        composeCodeableConcept(t, "SupplyDelivery", "type", element.getType(), -1);
    if (element.hasSuppliedItem())
        composeSupplyDeliverySupplyDeliverySuppliedItemComponent(t, "SupplyDelivery", "suppliedItem", element.getSuppliedItem(), -1);
    if (element.hasOccurrence())
        composeType(t, "SupplyDelivery", "occurrence", element.getOccurrence(), -1);
    if (element.hasSupplier())
        composeReference(t, "SupplyDelivery", "supplier", element.getSupplier(), -1);
    if (element.hasDestination())
        composeReference(t, "SupplyDelivery", "destination", element.getDestination(), -1);
    for (int i = 0; i < element.getReceiver().size(); i++) composeReference(t, "SupplyDelivery", "receiver", element.getReceiver().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 5 with SupplyDelivery

use of org.hl7.fhir.dstu3.model.SupplyDelivery in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeSupplyDeliverySupplyDeliverySuppliedItemComponent.

protected void composeSupplyDeliverySupplyDeliverySuppliedItemComponent(Complex parent, String parentType, String name, SupplyDelivery.SupplyDeliverySuppliedItemComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "suppliedItem", name, element, index);
    if (element.hasQuantity())
        composeQuantity(t, "SupplyDelivery", "quantity", element.getQuantity(), -1);
    if (element.hasItem())
        composeType(t, "SupplyDelivery", "item", element.getItem(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Aggregations

Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)2 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)2 Attachment (org.mitre.synthea.engine.Components.Attachment)2 HealthRecord (org.mitre.synthea.world.concepts.HealthRecord)2 CarePlan (org.mitre.synthea.world.concepts.HealthRecord.CarePlan)2 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)2 ImagingStudy (org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy)2 Medication (org.mitre.synthea.world.concepts.HealthRecord.Medication)2 Observation (org.mitre.synthea.world.concepts.HealthRecord.Observation)2 Procedure (org.mitre.synthea.world.concepts.HealthRecord.Procedure)2 Report (org.mitre.synthea.world.concepts.HealthRecord.Report)2 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)1 Bundle (org.hl7.fhir.dstu3.model.Bundle)1 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 DiagnosticReport (org.hl7.fhir.dstu3.model.DiagnosticReport)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 SimpleQuantity (org.hl7.fhir.dstu3.model.SimpleQuantity)1 SupplyDelivery (org.hl7.fhir.dstu3.model.SupplyDelivery)1 SupplyDeliverySuppliedItemComponent (org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent)1