Search in sources :

Example 76 with Meta

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);
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Device(org.hl7.fhir.r4.model.Device) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) Date(java.util.Date)

Example 77 with Meta

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;
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Address(org.hl7.fhir.r4.model.Address) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) LocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Identifier(org.hl7.fhir.r4.model.Identifier) Location(org.mitre.synthea.world.geography.Location)

Example 78 with Meta

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);
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Meta(org.hl7.fhir.r4.model.Meta) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) JsonObject(com.google.gson.JsonObject) Date(java.util.Date) Goal(org.hl7.fhir.r4.model.Goal) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.r4.model.Coding) JsonElement(com.google.gson.JsonElement) DateType(org.hl7.fhir.r4.model.DateType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 79 with Meta

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;
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta) AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Reference(org.hl7.fhir.dstu3.model.Reference) AllergyIntoleranceCategory(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Date(java.util.Date)

Example 80 with Meta

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());
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) HashMap(java.util.HashMap) IBaseMetaType(org.hl7.fhir.instance.model.api.IBaseMetaType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) CamelSpringBootTest(org.apache.camel.test.spring.junit5.CamelSpringBootTest)

Aggregations

Meta (org.hl7.fhir.r4.model.Meta)40 HashMap (java.util.HashMap)36 Date (java.util.Date)35 Meta (org.hl7.fhir.dstu3.model.Meta)31 IBaseMetaType (org.hl7.fhir.instance.model.api.IBaseMetaType)28 Reference (org.hl7.fhir.r4.model.Reference)26 JsonObject (javax.json.JsonObject)24 Path (javax.ws.rs.Path)24 Produces (javax.ws.rs.Produces)24 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)20 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)18 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)17 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)17 ArrayList (java.util.ArrayList)16 Coding (org.hl7.fhir.r4.model.Coding)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)15 Test (org.junit.jupiter.api.Test)15 Test (org.junit.Test)14 NotImplementedException (org.apache.commons.lang3.NotImplementedException)13 GET (javax.ws.rs.GET)12