use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class BloodPressureMapper method mapObservation.
private Observation mapObservation(RCMRMT030101UK04EhrExtract ehrExtract, RCMRMT030101UK04EhrComposition ehrComposition, RCMRMT030101UK04CompoundStatement compoundStatement, Patient patient, List<Encounter> encounters, String practiseCode) {
var observationStatements = getObservationStatementsFromCompoundStatement(compoundStatement);
var id = compoundStatement.getId().get(0);
Observation observation = new Observation().addIdentifier(buildIdentifier(id.getRoot(), practiseCode)).setStatus(ObservationStatus.FINAL).setCode(getCode(compoundStatement.getCode())).setComponent(getComponent(observationStatements)).setComment(getComment(observationStatements, getNarrativeStatementsFromCompoundStatement(compoundStatement))).setSubject(new Reference(patient)).setIssuedElement(getIssued(ehrExtract, ehrComposition)).addPerformer(getParticipantReference(compoundStatement.getParticipant(), ehrComposition));
observation.setId(id.getRoot());
observation.getMeta().getProfile().add(new UriType(META_PROFILE));
addEffective(observation, getEffective(compoundStatement.getEffectiveTime(), compoundStatement.getAvailabilityTime()));
addContextToObservation(observation, encounters, ehrComposition);
return observation;
}
use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class ConsultationListMapper method mapToConsultation.
public ListResource mapToConsultation(RCMRMT030101UK04EhrExtract ehrExtract, Encounter encounter) {
ListResource consultation = new ListResource();
consultation.setStatus(ListStatus.CURRENT).setMode(ListMode.SNAPSHOT).setTitle(getConsultationTitle(encounter.getType())).setCode(CodeableConceptUtils.createCodeableConcept(CONSULTATION_CODE_CODE, LIST_CODE_SYSTEM, CONSULTATION_CODE_DISPLAY, null)).setSubject(encounter.getSubject()).setDateElement(getConsultationDate(encounter.getPeriod(), ehrExtract)).setOrderedBy(CodeableConceptUtils.createCodeableConcept(LIST_ORDERED_BY_CODE, LIST_ORDERED_BY_SYSTEM, LIST_ORDERED_BY_DISPLAY, null)).setEncounter(new Reference(encounter)).setMeta(generateMeta(LIST_META_PROFILE)).setId(getConsultationId(encounter.getId()));
return consultation;
}
use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class DocumentReferenceMapper method mapDocumentReference.
private DocumentReference mapDocumentReference(RCMRMT030101UK04NarrativeStatement narrativeStatement, RCMRMT030101UK04EhrComposition ehrComposition, Patient patient, RCMRMT030101UK04EhrExtract ehrExtract, List<Encounter> encounterList, Organization organization) {
DocumentReference documentReference = new DocumentReference();
var id = narrativeStatement.getReference().get(0).getReferredToExternalDocument().getId().getRoot();
documentReference.addIdentifier(buildIdentifier(id, organization.getIdentifierFirstRep().getValue()));
documentReference.setId(id);
documentReference.getMeta().addProfile(META_PROFILE);
documentReference.setStatus(DocumentReferenceStatus.CURRENT);
documentReference.setType(getType(narrativeStatement));
documentReference.setSubject(new Reference(patient));
documentReference.setIndexedElement(getIndexed(ehrExtract));
documentReference.setDescription(buildDescription(narrativeStatement));
documentReference.setCustodian(new Reference(organization));
getAuthor(narrativeStatement, ehrComposition).ifPresent(documentReference::addAuthor);
if (narrativeStatement.hasAvailabilityTime() && narrativeStatement.getAvailabilityTime().hasValue()) {
documentReference.setCreatedElement(DateFormatUtil.parseToDateTimeType(narrativeStatement.getAvailabilityTime().getValue()));
}
var encounterReference = encounterList.stream().filter(encounter -> encounter.getId().equals(ehrComposition.getId().getRoot())).findFirst().map(Reference::new);
if (encounterReference.isPresent()) {
DocumentReference.DocumentReferenceContextComponent documentReferenceContextComponent = new DocumentReference.DocumentReferenceContextComponent().setEncounter(encounterReference.get());
documentReference.setContext(documentReferenceContextComponent);
}
setContentAttachments(documentReference, narrativeStatement);
return documentReference;
}
use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class ConditionMapperTest method testConditionIsMappedCorrectlyWithContext.
@Test
public void testConditionIsMappedCorrectlyWithContext() {
when(dateTimeMapper.mapDateTime(any())).thenReturn(EHR_EXTRACT_AVAILABILITY_DATETIME);
final List<Encounter> encounters = List.of((Encounter) new Encounter().setId(ENCOUNTER_ID));
final RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtract("linkset_valid.xml");
final List<Condition> conditions = conditionMapper.mapResources(ehrExtract, patient, encounters, PRACTISE_CODE);
assertThat(conditions).isNotEmpty();
assertThat(conditions.get(0).getContext().getResource().getIdElement().getValue()).isEqualTo(ENCOUNTER_ID);
}
use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class ConditionMapperTest method testConditionIsMappedCorrectlyWithNamedStatementRef.
@Test
public void testConditionIsMappedCorrectlyWithNamedStatementRef() {
when(dateTimeMapper.mapDateTime(any(String.class))).thenCallRealMethod();
var codeableConcept = new CodeableConcept().addCoding(new Coding().setDisplay(CODING_DISPLAY));
when(codeableConceptMapper.mapToCodeableConcept(any())).thenReturn(codeableConcept);
final RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtract("linkset_valid_with_reference.xml");
final List<Condition> conditions = conditionMapper.mapResources(ehrExtract, patient, List.of(), PRACTISE_CODE);
conditionMapper.addReferences(buildBundleWithNamedStatementObservation(), conditions, ehrExtract);
assertThat(conditions.get(0).getCode().getCodingFirstRep().getDisplay()).isEqualTo(CODING_DISPLAY);
}
Aggregations