Search in sources :

Example 16 with Annotation

use of org.hl7.fhir.r5.model.Annotation in project summary-care-record-api by NHSDigital.

the class DeviceMapper method mapDevice.

public Device mapDevice(Node deviceHl7) {
    Device deviceFhir = new Device();
    deviceFhir.setId(randomUUID());
    xmlUtils.getOptionalValueByXPath(deviceHl7, ID_EXTENSION_XPATH).ifPresent(id -> deviceFhir.addIdentifier().setValue(id));
    xmlUtils.detachOptionalNodeByXPath(deviceHl7, CODE_ELEMENT_XPATH).ifPresent(code -> deviceFhir.setType(new CodeableConcept(new Coding().setCode(xmlUtils.getValueByXPath(code, CODE_ATTRIBUTE_XPATH)).setDisplay(xmlUtils.getValueByXPath(code, CODE_DISPLAY_XPATH)))));
    addName(deviceHl7, deviceFhir, NAME_XPATH, OTHER);
    addName(deviceHl7, deviceFhir, MANUFACTURER_MODE_NAME_XPATH, MANUFACTURERNAME);
    xmlUtils.detachOptionalNodeByXPath(deviceHl7, DESCRIPTION_XPATH).ifPresent(descNode -> deviceFhir.addNote(new Annotation().setText(descNode.getTextContent())));
    xmlUtils.detachOptionalNodeByXPath(deviceHl7, SOFTWARE_NAME_XPATH).ifPresent(software -> deviceFhir.addVersion(new DeviceVersionComponent().setValue(software.getTextContent())));
    return deviceFhir;
}
Also used : DeviceVersionComponent(org.hl7.fhir.r4.model.Device.DeviceVersionComponent) Coding(org.hl7.fhir.r4.model.Coding) Device(org.hl7.fhir.r4.model.Device) Annotation(org.hl7.fhir.r4.model.Annotation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 17 with Annotation

use of org.hl7.fhir.r5.model.Annotation in project summary-care-record-api by NHSDigital.

the class DiagnosisMapper method map.

@SneakyThrows
public List<Resource> map(Node document) {
    var resources = new ArrayList<Resource>();
    NodeList pertinentNodes = xmlUtils.getNodeListByXPath(document, PERTINENT_CRET_BASE_PATH);
    for (int i = 0; i < pertinentNodes.getLength(); i++) {
        Node pertinentCREType = xmlUtils.getNodeAndDetachFromParent(pertinentNodes, i);
        var pertinentCRETypeCode = xmlUtils.getValueByXPath(pertinentCREType, PERTINENT_CODE_CODE_XPATH);
        var pertinentCRETypeDisplay = xmlUtils.getValueByXPath(pertinentCREType, PERTINENT_CODE_DISPLAY_XPATH);
        NodeList diagnosisNodes = xmlUtils.getNodeListByXPath(pertinentCREType, DIAGNOSIS_BASE_PATH);
        for (int j = 0; j < diagnosisNodes.getLength(); j++) {
            Node node = xmlUtils.getNodeAndDetachFromParent(diagnosisNodes, j);
            CodedEntry entry = codedEntryMapper.getCommonCodedEntryValues(node);
            if (COVID_19_ENTRIES.contains(entry.getCodeValue())) {
                var pertinentSupportingInfo = xmlUtils.getOptionalValueByXPath(node, DIAGNOSIS_PERTINENT_SUPPORTING_INFO_XPATH);
                var condition = new Condition();
                condition.setId(entry.getId());
                condition.addIdentifier().setValue(entry.getId());
                condition.setCode(new CodeableConcept().addCoding(new Coding().setCode(entry.getCodeValue()).setSystem(SNOMED_SYSTEM).setDisplay(entry.getCodeDisplay())));
                setConditionStatus(condition, entry.getStatus());
                condition.addCategory(new CodeableConcept(new Coding().setSystem(SNOMED_SYSTEM).setCode(pertinentCRETypeCode).setDisplay(pertinentCRETypeDisplay)));
                if (entry.getEffectiveTimeHigh().isPresent()) {
                    condition.setOnset(entry.getEffectiveTimeLow().get());
                    condition.setAbatement(entry.getEffectiveTimeHigh().get());
                } else {
                    condition.setOnset(entry.getEffectiveTimeLow().get());
                }
                resources.add(condition);
                pertinentSupportingInfo.map(value -> new Annotation().setText(value)).ifPresent(condition::addNote);
                xmlUtils.getNodesByXPath(node, DIAGNOSIS_PERTINENT_FINDINGS_XPATH).stream().map(it -> xmlUtils.getValueByXPath(it, DIAGNOSIS_PERTINENT_FINDING_ID_XPATH)).map(it -> new Reference(new Observation().setId(it))).map(reference -> new Condition.ConditionEvidenceComponent().addDetail(reference)).forEach(condition::addEvidence);
                mapEncounter(node, condition, resources);
            }
        }
    }
    return resources;
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) SneakyThrows(lombok.SneakyThrows) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) RequiredArgsConstructor(lombok.RequiredArgsConstructor) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Autowired(org.springframework.beans.factory.annotation.Autowired) Condition(org.hl7.fhir.r4.model.Condition) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Encounter(org.hl7.fhir.r4.model.Encounter) Node(org.w3c.dom.Node) CodedEntryMapper(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntryMapper) Observation(org.hl7.fhir.r4.model.Observation) NodeList(org.w3c.dom.NodeList) Period(org.hl7.fhir.r4.model.Period) Resource(org.hl7.fhir.r4.model.Resource) FINISHED(org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) Component(org.springframework.stereotype.Component) List(java.util.List) XmlToFhirMapper.parseDate(uk.nhs.adaptors.scr.mappings.from.hl7.XmlToFhirMapper.parseDate) Coding(org.hl7.fhir.r4.model.Coding) FhirHelper.randomUUID(uk.nhs.adaptors.scr.utils.FhirHelper.randomUUID) Optional(java.util.Optional) XmlUtils(uk.nhs.adaptors.scr.utils.XmlUtils) Annotation(org.hl7.fhir.r4.model.Annotation) CodedEntry(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntry) Reference(org.hl7.fhir.r4.model.Reference) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) Annotation(org.hl7.fhir.r4.model.Annotation) CodedEntry(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntry) Coding(org.hl7.fhir.r4.model.Coding) Observation(org.hl7.fhir.r4.model.Observation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) SneakyThrows(lombok.SneakyThrows)

Example 18 with Annotation

use of org.hl7.fhir.r5.model.Annotation in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceTranslatorImplTest method toOpenmrsType_shouldTranslateNoteToComment.

@Test
public void toOpenmrsType_shouldTranslateNoteToComment() {
    AllergyIntolerance allergyIntolerance = new AllergyIntolerance();
    allergyIntolerance.addNote(new Annotation().setText("Test Allergy"));
    allergyIntoleranceTranslator.toOpenmrsType(omrsAllergy, allergyIntolerance);
    assertThat(omrsAllergy, notNullValue());
    assertThat(omrsAllergy.getComment(), equalTo("Test Allergy"));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Annotation(org.hl7.fhir.r4.model.Annotation) Test(org.junit.Test)

Example 19 with Annotation

use of org.hl7.fhir.r5.model.Annotation in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceTranslatorImpl method toFhirResource.

@Override
public AllergyIntolerance toFhirResource(@Nonnull Allergy omrsAllergy) {
    notNull(omrsAllergy, "The Allergy object should not be null");
    AllergyIntolerance allergy = new AllergyIntolerance();
    allergy.setId(omrsAllergy.getUuid());
    if (omrsAllergy.getAllergen() != null) {
        allergy.addCategory(categoryTranslator.toFhirResource(omrsAllergy.getAllergen().getAllergenType()));
    }
    allergy.setClinicalStatus(setClinicalStatus(omrsAllergy.getVoided()));
    allergy.setVerificationStatus(new CodeableConcept().setText("Confirmed").addCoding(new Coding(FhirConstants.ALLERGY_INTOLERANCE_VERIFICATION_STATUS_SYSTEM_URI, "confirmed", "Confirmed")));
    allergy.setPatient(patientReferenceTranslator.toFhirResource(omrsAllergy.getPatient()));
    allergy.setRecorder(practitionerReferenceTranslator.toFhirResource(omrsAllergy.getCreator()));
    allergy.setRecordedDate(omrsAllergy.getDateCreated());
    allergy.getMeta().setLastUpdated(omrsAllergy.getDateChanged());
    allergy.setType(AllergyIntolerance.AllergyIntoleranceType.ALLERGY);
    allergy.addNote(new Annotation().setText(omrsAllergy.getComment()));
    allergy.setCriticality(criticalityTranslator.toFhirResource(severityTranslator.toFhirResource(omrsAllergy.getSeverity())));
    allergy.addReaction(reactionComponentTranslator.toFhirResource(omrsAllergy));
    allergy.setCode(allergy.getReactionFirstRep().getSubstance());
    allergy.addContained(provenanceTranslator.getCreateProvenance(omrsAllergy));
    allergy.addContained(provenanceTranslator.getUpdateProvenance(omrsAllergy));
    return allergy;
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Coding(org.hl7.fhir.r4.model.Coding) Annotation(org.hl7.fhir.r4.model.Annotation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 20 with Annotation

use of org.hl7.fhir.r5.model.Annotation in project openmrs-module-fhir2 by openmrs.

the class MedicationRequestTranslatorImpl method toFhirResource.

@Override
public MedicationRequest toFhirResource(@Nonnull DrugOrder drugOrder) {
    notNull(drugOrder, "The DrugOrder object should not be null");
    MedicationRequest medicationRequest = new MedicationRequest();
    medicationRequest.setId(drugOrder.getUuid());
    medicationRequest.setStatus(statusTranslator.toFhirResource(drugOrder));
    medicationRequest.setMedication(medicationReferenceTranslator.toFhirResource(drugOrder.getDrug()));
    medicationRequest.setPriority(medicationRequestPriorityTranslator.toFhirResource(drugOrder.getUrgency()));
    medicationRequest.setRequester(practitionerReferenceTranslator.toFhirResource(drugOrder.getOrderer()));
    medicationRequest.setEncounter(encounterReferenceTranslator.toFhirResource(drugOrder.getEncounter()));
    medicationRequest.setSubject(patientReferenceTranslator.toFhirResource(drugOrder.getPatient()));
    medicationRequest.setIntent(MedicationRequest.MedicationRequestIntent.ORDER);
    medicationRequest.addNote(new Annotation().setText(drugOrder.getCommentToFulfiller()));
    medicationRequest.addReasonCode(conceptTranslator.toFhirResource(drugOrder.getOrderReason()));
    medicationRequest.addDosageInstruction(dosageTranslator.toFhirResource(drugOrder));
    if (drugOrder.getPreviousOrder() != null && (drugOrder.getAction() == Order.Action.DISCONTINUE || drugOrder.getAction() == Order.Action.REVISE)) {
        medicationRequest.setPriorPrescription(createOrderReference(drugOrder.getPreviousOrder()).setIdentifier(orderIdentifierTranslator.toFhirResource(drugOrder.getPreviousOrder())));
    } else if (drugOrder.getPreviousOrder() != null && drugOrder.getAction() == Order.Action.RENEW) {
        medicationRequest.setBasedOn(Collections.singletonList(createOrderReference(drugOrder.getPreviousOrder()).setIdentifier(orderIdentifierTranslator.toFhirResource(drugOrder.getPreviousOrder()))));
    }
    return medicationRequest;
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Annotation(org.hl7.fhir.r4.model.Annotation)

Aggregations

NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 Trace (com.newrelic.api.agent.Trace)13 Operation (gov.cms.bfd.server.war.Operation)13 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)12 Annotation (org.hl7.fhir.r4.model.Annotation)12 NoResultException (javax.persistence.NoResultException)11 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)9 Annotation (org.hl7.fhir.dstu3.model.Annotation)9 Search (ca.uhn.fhir.rest.annotation.Search)8 OffsetLinkBuilder (gov.cms.bfd.server.war.commons.OffsetLinkBuilder)8 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)8 Read (ca.uhn.fhir.rest.annotation.Read)7 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)7 Patient (org.hl7.fhir.dstu3.model.Patient)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)6 Resource (org.hl7.fhir.r4.model.Resource)6 Test (org.junit.jupiter.api.Test)6