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);
}
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;
}
Aggregations