use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Informant12 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.POCDMT000002UK01Informant12 in project integration-adaptor-111 by nhsconnect.
the class EncounterMapper method getEncounterParticipantComponents.
private List<EncounterParticipantComponent> getEncounterParticipantComponents(POCDMT000002UK01ClinicalDocument1 clinicalDocument, List<PractitionerRole> authorPractitionerRoles, Optional<PractitionerRole> responsibleParty, Encounter encounter) {
List<EncounterParticipantComponent> encounterParticipantComponents = stream(clinicalDocument.getParticipantArray()).filter(it -> !PARTCIPANT_TYPE_CODE_REFT.equals(it.getTypeCode())).map(participantMapper::mapEncounterParticipant).collect(Collectors.toList());
if (authorPractitionerRoles.size() > 0) {
authorPractitionerRoles.stream().map(it -> buildParticipantComponent(it, AUTHOR_PARTICIPANT_CODE, AUTHOR_PARTICIPANT_DISPLAY)).forEach(encounterParticipantComponents::add);
}
if (clinicalDocument.sizeOfInformantArray() > 0) {
stream(clinicalDocument.getInformantArray()).map(informantMapper::mapInformantIntoParticipantComponent).filter(Optional::isPresent).map(Optional::get).forEach(encounterParticipantComponents::add);
for (POCDMT000002UK01Informant12 informant : clinicalDocument.getInformantArray()) {
EncounterParticipantComponent encounterParticipantComponent = participantMapper.mapEncounterRelatedPerson(informant, encounter);
encounterParticipantComponents.add(encounterParticipantComponent);
}
}
if (clinicalDocument.isSetDataEnterer()) {
encounterParticipantComponents.add(dataEntererMapper.mapDataEntererIntoParticipantComponent(clinicalDocument.getDataEnterer()));
}
responsibleParty.ifPresent(it -> encounterParticipantComponents.add(buildParticipantComponent(it, RESPONSIBLE_PARTY_PARTICIPANT_CODE, RESPONSIBLE_PARTY_PARTICIPANT_DISPLAY)));
return encounterParticipantComponents;
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Informant12 in project integration-adaptor-111 by nhsconnect.
the class EncounterMapperTest method mockParticipantWithAuthorInformantAndDataEnterer.
private void mockParticipantWithAuthorInformantAndDataEnterer(POCDMT000002UK01ClinicalDocument1 clinicalDocument) {
mockParticipant(clinicalDocument);
POCDMT000002UK01Informant12 informant = mock(POCDMT000002UK01Informant12.class);
POCDMT000002UK01DataEnterer dataEnterer = mock(POCDMT000002UK01DataEnterer.class);
when(clinicalDocument.sizeOfInformantArray()).thenReturn(1);
when(clinicalDocument.getInformantArray()).thenReturn(new POCDMT000002UK01Informant12[] { informant });
when(clinicalDocument.isSetDataEnterer()).thenReturn(true);
when(clinicalDocument.getDataEnterer()).thenReturn(dataEnterer);
when(informantMapper.mapInformantIntoParticipantComponent(any())).thenReturn(Optional.of(encounterParticipantComponent));
when(dataEntererMapper.mapDataEntererIntoParticipantComponent(any())).thenReturn(encounterParticipantComponent);
when(participantMapper.mapEncounterRelatedPerson(any(), any())).thenReturn(encounterParticipantComponent);
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Informant12 in project integration-adaptor-111 by nhsconnect.
the class InformantMapperTest method shouldMapInformantToParticipantComponent.
@Test
public void shouldMapInformantToParticipantComponent() {
POCDMT000002UK01Informant12 informant = mock(POCDMT000002UK01Informant12.class);
POCDMT000002UK01AssignedEntity assignedEntity = mock(POCDMT000002UK01AssignedEntity.class);
when(informant.getTypeCode()).thenReturn("CON");
when(informant.isSetAssignedEntity()).thenReturn(true);
when(informant.getAssignedEntity()).thenReturn(assignedEntity);
when(practitionerMapper.mapPractitioner(isA(POCDMT000002UK01AssignedEntity.class))).thenReturn(practitioner);
when(resourceUtil.createReference(practitioner)).thenReturn(new Reference(practitioner));
Optional<Encounter.EncounterParticipantComponent> participantComponent = informantMapper.mapInformantIntoParticipantComponent(informant);
assertThat(participantComponent.isPresent()).isTrue();
assertThat(participantComponent.get().getIndividualTarget()).isEqualTo(practitioner);
assertThat(participantComponent.get().getType().get(0).getText()).isEqualTo("CON");
}
Aggregations