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