use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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"));
}
use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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;
}
Aggregations