Search in sources :

Example 6 with RCMRMT030101UK04EhrExtract

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;
}
Also used : ParticipantReferenceUtil.getParticipantReference(uk.nhs.adaptors.pss.translator.util.ParticipantReferenceUtil.getParticipantReference) Reference(org.hl7.fhir.dstu3.model.Reference) Observation(org.hl7.fhir.dstu3.model.Observation) ResourceUtil.addContextToObservation(uk.nhs.adaptors.pss.translator.util.ResourceUtil.addContextToObservation) UriType(org.hl7.fhir.dstu3.model.UriType)

Example 7 with RCMRMT030101UK04EhrExtract

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;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ListResource(org.hl7.fhir.dstu3.model.ListResource)

Example 8 with RCMRMT030101UK04EhrExtract

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;
}
Also used : ParticipantReferenceUtil.getParticipantReference(uk.nhs.adaptors.pss.translator.util.ParticipantReferenceUtil.getParticipantReference) Reference(org.hl7.fhir.dstu3.model.Reference) DocumentReference(org.hl7.fhir.dstu3.model.DocumentReference) DocumentReference(org.hl7.fhir.dstu3.model.DocumentReference)

Example 9 with RCMRMT030101UK04EhrExtract

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);
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Encounter(org.hl7.fhir.dstu3.model.Encounter) Test(org.junit.jupiter.api.Test)

Example 10 with RCMRMT030101UK04EhrExtract

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);
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Coding(org.hl7.fhir.dstu3.model.Coding) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Aggregations

RCMRMT030101UK04EhrExtract (org.hl7.v3.RCMRMT030101UK04EhrExtract)19 Reference (org.hl7.fhir.dstu3.model.Reference)13 Test (org.junit.jupiter.api.Test)13 Condition (org.hl7.fhir.dstu3.model.Condition)7 IdType (org.hl7.fhir.dstu3.model.IdType)7 List (java.util.List)5 Encounter (org.hl7.fhir.dstu3.model.Encounter)5 Observation (org.hl7.fhir.dstu3.model.Observation)5 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)4 RCMRMT030101UK04Component2 (org.hl7.v3.RCMRMT030101UK04Component2)4 ArrayList (java.util.ArrayList)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 Specimen (org.hl7.fhir.dstu3.model.Specimen)3 RCMRMT030101UK04EhrComposition (org.hl7.v3.RCMRMT030101UK04EhrComposition)3 Service (org.springframework.stereotype.Service)3 ParticipantReferenceUtil.getParticipantReference (uk.nhs.adaptors.pss.translator.util.ParticipantReferenceUtil.getParticipantReference)3 Coding (org.hl7.fhir.dstu3.model.Coding)2 DateTimeType (org.hl7.fhir.dstu3.model.DateTimeType)2 DiagnosticReport (org.hl7.fhir.dstu3.model.DiagnosticReport)2