use of org.hl7.fhir.r4b.model.Meta in project synthea by synthetichealth.
the class FhirR4 method device.
/**
* Map the HealthRecord.Device into a FHIR Device 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 device The device to add.
* @return The added Entry.
*/
private static BundleEntryComponent device(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, HealthRecord.Device device) {
Device deviceResource = new Device();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-implantable-device");
deviceResource.setMeta(meta);
}
deviceResource.addUdiCarrier().setDeviceIdentifier(device.deviceIdentifier).setCarrierHRF(device.udi);
deviceResource.setStatus(FHIRDeviceStatus.ACTIVE);
deviceResource.setDistinctIdentifier(device.deviceIdentifier);
if (device.manufacturer != null) {
deviceResource.setManufacturer(device.manufacturer);
}
if (device.model != null) {
deviceResource.setModelNumber(device.model);
}
deviceResource.setManufactureDate(new Date(device.manufactureTime));
deviceResource.setExpirationDate(new Date(device.expirationTime));
deviceResource.setLotNumber(device.lotNumber);
deviceResource.setSerialNumber(device.serialNumber);
deviceResource.addDeviceName().setName(device.codes.get(0).display).setType(DeviceNameType.USERFRIENDLYNAME);
deviceResource.setType(mapCodeToCodeableConcept(device.codes.get(0), SNOMED_URI));
deviceResource.setPatient(new Reference(personEntry.getFullUrl()));
return newEntry(rand, bundle, deviceResource);
}
use of org.hl7.fhir.r4b.model.Meta in project synthea by synthetichealth.
the class FhirR4 method providerLocation.
/**
* Map the Provider into a FHIR Location resource, and add it to the given Bundle.
*
* @param rand Source of randomness to use when generating ids etc
* @param bundle The Bundle to add to
* @param provider The Provider
* @return The added Entry or null if the bundle already contains this provider location
*/
protected static org.hl7.fhir.r4.model.Location providerLocation(RandomNumberGenerator rand, Bundle bundle, Provider provider) {
org.hl7.fhir.r4.model.Location location = new org.hl7.fhir.r4.model.Location();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-location");
location.setMeta(meta);
}
location.setStatus(LocationStatus.ACTIVE);
location.setName(provider.name);
// set telecom
if (provider.phone != null && !provider.phone.isEmpty()) {
ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(provider.phone);
location.addTelecom(contactPoint);
} else if (USE_US_CORE_IG) {
ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue("(555) 555-5555");
location.addTelecom(contactPoint);
}
// set address
Address address = new Address().addLine(provider.address).setCity(provider.city).setPostalCode(provider.zip).setState(provider.state);
if (COUNTRY_CODE != null) {
address.setCountry(COUNTRY_CODE);
}
location.setAddress(address);
LocationPositionComponent position = new LocationPositionComponent();
position.setLatitude(provider.getY());
position.setLongitude(provider.getX());
location.setPosition(position);
location.addIdentifier().setSystem(SYNTHEA_IDENTIFIER).setValue(provider.getResourceLocationID());
Identifier organizationIdentifier = new Identifier().setSystem(SYNTHEA_IDENTIFIER).setValue(provider.getResourceID());
location.setManagingOrganization(new Reference().setIdentifier(organizationIdentifier).setDisplay(provider.name));
return location;
}
use of org.hl7.fhir.r4b.model.Meta in project synthea by synthetichealth.
the class FhirR4 method careGoal.
/**
* Map the JsonObject into a FHIR Goal resource, and add it to the given Bundle.
* @param rand Source of randomness to use when generating ids etc
* @param bundle The Bundle to add to
* @param goalStatus The GoalStatus
* @param goal The JsonObject
* @return The added Entry
*/
private static BundleEntryComponent careGoal(RandomNumberGenerator rand, Bundle bundle, BundleEntryComponent personEntry, long carePlanStart, CodeableConcept goalStatus, JsonObject goal) {
String resourceID = rand.randUUID().toString();
Goal goalResource = new Goal();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-goal");
goalResource.setMeta(meta);
}
goalResource.setLifecycleStatus(GoalLifecycleStatus.ACCEPTED);
goalResource.setAchievementStatus(goalStatus);
goalResource.setId(resourceID);
goalResource.setSubject(new Reference(personEntry.getFullUrl()));
if (goal.has("text")) {
CodeableConcept descriptionCodeableConcept = new CodeableConcept();
descriptionCodeableConcept.setText(goal.get("text").getAsString());
goalResource.setDescription(descriptionCodeableConcept);
} else if (goal.has("codes")) {
CodeableConcept descriptionCodeableConcept = new CodeableConcept();
JsonObject code = goal.get("codes").getAsJsonArray().get(0).getAsJsonObject();
descriptionCodeableConcept.addCoding().setSystem(LOINC_URI).setCode(code.get("code").getAsString()).setDisplay(code.get("display").getAsString());
descriptionCodeableConcept.setText(code.get("display").getAsString());
goalResource.setDescription(descriptionCodeableConcept);
} else if (goal.has("observation")) {
CodeableConcept descriptionCodeableConcept = new CodeableConcept();
// build up our own text from the observation condition, similar to the graphviz logic
JsonObject logic = goal.get("observation").getAsJsonObject();
String[] text = { logic.get("codes").getAsJsonArray().get(0).getAsJsonObject().get("display").getAsString(), logic.get("operator").getAsString(), logic.get("value").getAsString() };
descriptionCodeableConcept.setText(String.join(" ", text));
goalResource.setDescription(descriptionCodeableConcept);
}
goalResource.addTarget().setMeasure(goalResource.getDescription()).setDue(new DateType(new Date(carePlanStart + Utilities.convertTime("days", 30))));
if (goal.has("addresses")) {
for (JsonElement reasonElement : goal.get("addresses").getAsJsonArray()) {
if (reasonElement instanceof JsonObject) {
JsonObject reasonObject = reasonElement.getAsJsonObject();
String reasonCode = reasonObject.get("codes").getAsJsonObject().get("SNOMED-CT").getAsJsonArray().get(0).getAsString();
for (BundleEntryComponent entry : bundle.getEntry()) {
if (entry.getResource().fhirType().equals("Condition")) {
Condition condition = (Condition) entry.getResource();
// Only one element in list
Coding coding = condition.getCode().getCoding().get(0);
if (reasonCode.equals(coding.getCode())) {
goalResource.addAddresses().setReference(entry.getFullUrl());
}
}
}
}
}
}
return newEntry(rand, bundle, goalResource);
}
use of org.hl7.fhir.r4b.model.Meta in project synthea by synthetichealth.
the class FhirStu3 method allergy.
/**
* Map the Condition into a FHIR AllergyIntolerance resource, and add it to the given Bundle.
*
* @param rand Source of randomness to use when generating ids etc
* @param personEntry The Entry for the Person
* @param bundle The Bundle to add to
* @param encounterEntry The current Encounter entry
* @param allergy The Allergy Entry
* @return The added Entry
*/
private static BundleEntryComponent allergy(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, HealthRecord.Entry allergy) {
AllergyIntolerance allergyResource = new AllergyIntolerance();
allergyResource.setAssertedDate(new Date(allergy.start));
if (allergy.stop == 0) {
allergyResource.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
} else {
allergyResource.setClinicalStatus(AllergyIntoleranceClinicalStatus.INACTIVE);
}
allergyResource.setType(AllergyIntoleranceType.ALLERGY);
AllergyIntoleranceCategory category = AllergyIntoleranceCategory.FOOD;
// TODO: allergy categories in GMF
allergyResource.addCategory(category);
allergyResource.setCriticality(AllergyIntoleranceCriticality.LOW);
allergyResource.setVerificationStatus(AllergyIntoleranceVerificationStatus.CONFIRMED);
allergyResource.setPatient(new Reference(personEntry.getFullUrl()));
Code code = allergy.codes.get(0);
allergyResource.setCode(mapCodeToCodeableConcept(code, SNOMED_URI));
if (USE_SHR_EXTENSIONS) {
Meta meta = new Meta();
meta.addProfile(SHR_EXT + "shr-allergy-AllergyIntolerance");
// required fields for AllergyIntolerance profile are:
// verificationStatus, code, patient, assertedDate
allergyResource.setMeta(meta);
}
BundleEntryComponent allergyEntry = newEntry(rand, bundle, allergyResource);
allergy.fullUrl = allergyEntry.getFullUrl();
return allergyEntry;
}
use of org.hl7.fhir.r4b.model.Meta in project camel-spring-boot by apache.
the class FhirMetaIT method testAdd.
@Test
public void testAdd() throws Exception {
// assert no meta
Meta meta = fhirClient.meta().get(Meta.class).fromResource(this.patient.getIdElement()).execute();
assertEquals(0, meta.getTag().size());
Meta inMeta = new Meta();
inMeta.addTag().setSystem("urn:system1").setCode("urn:code1");
final Map<String, Object> headers = new HashMap<>();
// parameter type is org.hl7.fhir.instance.model.api.IBaseMetaType
headers.put("CamelFhir.meta", inMeta);
// parameter type is org.hl7.fhir.instance.model.api.IIdType
headers.put("CamelFhir.id", this.patient.getIdElement());
IBaseMetaType result = requestBodyAndHeaders("direct://ADD", null, headers);
LOG.debug("add: " + result);
assertNotNull(result, "add result");
assertEquals(1, result.getTag().size());
}
Aggregations