Search in sources :

Example 1 with POCDMT000002UK01RelatedEntity

use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RelatedEntity in project integration-adaptor-111 by nhsconnect.

the class ParticipantMapperTest method shouldMapEncounterRelatedPerson.

@Test
public void shouldMapEncounterRelatedPerson() {
    IVLTS time = IVLTS.Factory.newInstance();
    POCDMT000002UK01RelatedEntity relatedEntity = POCDMT000002UK01RelatedEntity.Factory.newInstance();
    relatedEntity.setEffectiveTime(time);
    POCDMT000002UK01Informant12 informant = POCDMT000002UK01Informant12.Factory.newInstance();
    informant.setTypeCode("INF");
    informant.setRelatedEntity(relatedEntity);
    Encounter encounter = new Encounter();
    RelatedPerson relatedPerson = new RelatedPerson();
    relatedPerson.setId(RELATED_PERSON_ID);
    when(relatedPersonMapper.mapRelatedPerson(informant, encounter)).thenReturn(relatedPerson);
    when(periodMapper.mapPeriod(ArgumentMatchers.isA(IVLTS.class))).thenReturn(period);
    when(resourceUtil.createReference(relatedPerson)).thenReturn(new Reference(relatedPerson));
    Encounter.EncounterParticipantComponent participantComponent = participantMapper.mapEncounterRelatedPerson(informant, encounter);
    assertThat(participantComponent.getType().get(0).getText()).isEqualTo("Informant");
    assertThat(participantComponent.getIndividualTarget().getId()).isEqualTo(RELATED_PERSON_ID);
    assertThat(participantComponent.getPeriod()).isEqualTo(period);
}
Also used : IVLTS(uk.nhs.connect.iucds.cda.ucr.IVLTS) POCDMT000002UK01Informant12(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Informant12) POCDMT000002UK01RelatedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RelatedEntity) Reference(org.hl7.fhir.dstu3.model.Reference) Encounter(org.hl7.fhir.dstu3.model.Encounter) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) Test(org.junit.jupiter.api.Test)

Example 2 with POCDMT000002UK01RelatedEntity

use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RelatedEntity in project integration-adaptor-111 by nhsconnect.

the class RelatedPersonMapper method mapRelatedPerson.

public RelatedPerson mapRelatedPerson(POCDMT000002UK01Informant12 informant, Encounter encounter) {
    if (!informant.isSetRelatedEntity()) {
        return null;
    }
    POCDMT000002UK01RelatedEntity relatedEntity = informant.getRelatedEntity();
    RelatedPerson relatedPerson = new RelatedPerson();
    relatedPerson.setIdElement(resourceUtil.newRandomUuid());
    relatedPerson.setActive(true).setPatient(encounter.getSubject()).setGender(UNKNOWN);
    if (relatedEntity.isSetRelatedPerson()) {
        relatedPerson.setName(getHumanNameFromITK(relatedEntity.getRelatedPerson()));
    }
    if (relatedEntity.sizeOfTelecomArray() > 0) {
        relatedPerson.setTelecom(getTelecomFromITK(relatedEntity.getTelecomArray()));
    }
    if (relatedEntity.sizeOfAddrArray() > 0) {
        relatedPerson.setAddress(getAddressesFromITK(relatedEntity.getAddrArray()));
    }
    if (relatedEntity.isSetEffectiveTime()) {
        Period period = new Period();
        if (relatedEntity.getEffectiveTime().isSetLow()) {
            period.setStartElement(DateUtil.parse(relatedEntity.getEffectiveTime().getLow().getValue()));
        }
        if (relatedEntity.getEffectiveTime().isSetHigh()) {
            period.setEndElement(DateUtil.parse(relatedEntity.getEffectiveTime().getHigh().getValue()));
        }
        relatedPerson.setPeriod(period);
    }
    relatedPerson.setPeriod(getPeriod(relatedEntity));
    setRelationship(relatedEntity, relatedPerson);
    markEmergencyContact(relatedEntity.getTelecomArray(), relatedPerson);
    return relatedPerson;
}
Also used : POCDMT000002UK01RelatedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RelatedEntity) Period(org.hl7.fhir.dstu3.model.Period) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson)

Aggregations

RelatedPerson (org.hl7.fhir.dstu3.model.RelatedPerson)2 POCDMT000002UK01RelatedEntity (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RelatedEntity)2 Encounter (org.hl7.fhir.dstu3.model.Encounter)1 Period (org.hl7.fhir.dstu3.model.Period)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 Test (org.junit.jupiter.api.Test)1 IVLTS (uk.nhs.connect.iucds.cda.ucr.IVLTS)1 POCDMT000002UK01Informant12 (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Informant12)1