Search in sources :

Example 1 with SupplyDelivery

use of ca.uhn.fhir.model.dstu2.resource.SupplyDelivery in project synthea by synthetichealth.

the class FhirDstu2 method convertToFHIR.

/**
 * Convert the given Person into a FHIR Bundle with the Patient and the
 * associated entries from their health record.
 *
 * @param person Person to generate the FHIR Bundle
 * @param stopTime Time the simulation ended
 * @return String containing a 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(BundleTypeEnum.TRANSACTION);
    } else {
        bundle.setType(BundleTypeEnum.COLLECTION);
    }
    Entry personEntry = basicInfo(person, bundle, stopTime);
    for (Encounter encounter : person.record.encounters) {
        Entry 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
        encounterClaim(person, personEntry, bundle, encounterEntry, encounter.claim);
    }
    return bundle;
}
Also used : Report(org.mitre.synthea.world.concepts.HealthRecord.Report) DiagnosticReport(ca.uhn.fhir.model.dstu2.resource.DiagnosticReport) Bundle(ca.uhn.fhir.model.dstu2.resource.Bundle) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) Attachment(org.mitre.synthea.engine.Components.Attachment) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) 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 ca.uhn.fhir.model.dstu2.resource.SupplyDelivery in project synthea by synthetichealth.

the class FhirDstu2 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 Entry supplyDelivery(RandomNumberGenerator rand, Entry personEntry, Bundle bundle, HealthRecord.Supply supply, Encounter encounter) {
    SupplyDelivery supplyResource = new SupplyDelivery();
    supplyResource.setStatus(SupplyDeliveryStatusEnum.DELIVERED);
    supplyResource.setPatient(new ResourceReferenceDt(personEntry.getFullUrl()));
    CodeableConceptDt type = new CodeableConceptDt();
    type.addCoding().setCode("device").setDisplay("Device").setSystem("http://hl7.org/fhir/supply-item-type");
    supplyResource.setType(type);
    // super hackish -- there's no "code" field available here, just a reference to a Device
    // so for now just put some text in the reference
    ResourceReferenceDt suppliedItem = new ResourceReferenceDt();
    Code code = supply.codes.get(0);
    suppliedItem.setDisplay("SNOMED[" + code.code + "]: " + code.display);
    supplyResource.setSuppliedItem(suppliedItem);
    supplyResource.setQuantity(new SimpleQuantityDt(supply.quantity));
    supplyResource.setTime((DateTimeDt) convertFhirDateTime(supply.start, true));
    return newEntry(rand, bundle, supplyResource);
}
Also used : ResourceReferenceDt(ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt) CodeableConceptDt(ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt) SupplyDelivery(ca.uhn.fhir.model.dstu2.resource.SupplyDelivery) SimpleQuantityDt(ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt) Code(org.mitre.synthea.world.concepts.HealthRecord.Code)

Aggregations

CodeableConceptDt (ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt)1 ResourceReferenceDt (ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt)1 SimpleQuantityDt (ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt)1 Bundle (ca.uhn.fhir.model.dstu2.resource.Bundle)1 Entry (ca.uhn.fhir.model.dstu2.resource.Bundle.Entry)1 DiagnosticReport (ca.uhn.fhir.model.dstu2.resource.DiagnosticReport)1 SupplyDelivery (ca.uhn.fhir.model.dstu2.resource.SupplyDelivery)1 Attachment (org.mitre.synthea.engine.Components.Attachment)1 HealthRecord (org.mitre.synthea.world.concepts.HealthRecord)1 CarePlan (org.mitre.synthea.world.concepts.HealthRecord.CarePlan)1 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)1 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)1 ImagingStudy (org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy)1 Medication (org.mitre.synthea.world.concepts.HealthRecord.Medication)1 Observation (org.mitre.synthea.world.concepts.HealthRecord.Observation)1 Procedure (org.mitre.synthea.world.concepts.HealthRecord.Procedure)1 Report (org.mitre.synthea.world.concepts.HealthRecord.Report)1