use of uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntry 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 uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntry in project summary-care-record-api by NHSDigital.
the class FindingMapper method mapObservation.
private void mapObservation(ArrayList<Resource> resources, String creTypeCode, String creTypeDisplay, Node node) {
CodedEntry entry = codedEntryMapper.getCommonCodedEntryValues(node);
if (SARS_COV_2_CODE.equals(entry.getCodeValue())) {
var effectiveTimeCentre = xmlUtils.getOptionalValueByXPath(node, EFFECTIVE_TIME_CENTRE_XPATH).map(it -> parseDate(it, DateTimeType.class));
var observation = new Observation();
observation.setId(entry.getId());
observation.setMeta(new Meta().addProfile(UK_CORE_OBSERVATION_META));
observation.addIdentifier(new Identifier().setValue(entry.getId()));
observation.setCode(new CodeableConcept().addCoding(new Coding().setCode(entry.getCodeValue()).setSystem(SNOMED_SYSTEM).setDisplay(entry.getCodeDisplay())));
observation.setStatus(mapStatus(entry.getStatus()));
if (entry.getEffectiveTimeLow().isPresent() || entry.getEffectiveTimeHigh().isPresent()) {
var period = new Period();
entry.getEffectiveTimeLow().ifPresent(period::setStartElement);
entry.getEffectiveTimeHigh().ifPresent(period::setEndElement);
observation.setEffective(period);
} else {
effectiveTimeCentre.ifPresent(observation::setEffective);
}
observation.addCategory(new CodeableConcept(new Coding().setSystem(SNOMED_SYSTEM).setCode(creTypeCode).setDisplay(creTypeDisplay)));
mapEncounter(node, observation, resources);
resources.add(observation);
}
}
Aggregations