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;
}
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);
}
Aggregations