use of uk.nhs.connect.iucds.cda.ucr.IVLTS in project integration-adaptor-111 by nhsconnect.
the class ParticipantMapperTest method shouldMapParticipant.
@Test
public void shouldMapParticipant() {
POCDMT000002UK01Participant1 encounterParticipant = mock(POCDMT000002UK01Participant1.class);
POCDMT000002UK01AssociatedEntity associatedEntity = mock(POCDMT000002UK01AssociatedEntity.class);
IVLTS time = mock(IVLTS.class);
when(encounterParticipant.getTypeCode()).thenReturn("CON");
when(encounterParticipant.getAssociatedEntity()).thenReturn(associatedEntity);
when(encounterParticipant.isSetTime()).thenReturn(true);
when(encounterParticipant.getTime()).thenReturn(time);
when(periodMapper.mapPeriod(ArgumentMatchers.isA(IVLTS.class))).thenReturn(period);
when(practitionerMapper.mapPractitioner(ArgumentMatchers.isA(POCDMT000002UK01AssociatedEntity.class))).thenReturn(practitioner);
when(resourceUtil.createReference(practitioner)).thenReturn(new Reference(practitioner));
Encounter.EncounterParticipantComponent participantComponent = participantMapper.mapEncounterParticipant(encounterParticipant);
assertThat(participantComponent.getIndividualTarget()).isEqualTo(practitioner);
assertThat(participantComponent.getPeriod()).isEqualTo(period);
assertThat(participantComponent.getType().get(0).getText()).isEqualTo("CON");
}
use of uk.nhs.connect.iucds.cda.ucr.IVLTS 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.IVLTS in project integration-adaptor-111 by nhsconnect.
the class ConsentMapper method getDataPeriod.
private Period getDataPeriod(POCDMT000002UK01Entry permissionEntry) {
POCDMT000002UK01Observation observation = permissionEntry.getObservation();
if (observation == null || !observation.isSetEffectiveTime()) {
return null;
}
Period dataPeriod = new Period();
IVLTS effectiveTime = observation.getEffectiveTime();
if (effectiveTime.isSetLow()) {
dataPeriod.setStartElement(DateUtil.parse(effectiveTime.getLow().getValue()));
}
if (effectiveTime.isSetHigh()) {
dataPeriod.setEndElement(DateUtil.parse(effectiveTime.getHigh().getValue()));
}
return dataPeriod;
}
use of uk.nhs.connect.iucds.cda.ucr.IVLTS in project integration-adaptor-111 by nhsconnect.
the class EncounterMapperTest method mockEncompassingEncounter.
private void mockEncompassingEncounter() {
IVLTS effectiveTime = mock(IVLTS.class);
when(component1.getEncompassingEncounter()).thenReturn(encompassingEncounter);
when(identifier.getRoot()).thenReturn(ID_ROOT);
when(identifier.getExtension()).thenReturn(ID_EXTENSION);
when(encompassingEncounter.getIdArray()).thenReturn(new II[] { identifier });
when(encompassingEncounter.getEffectiveTime()).thenReturn(effectiveTime);
}
use of uk.nhs.connect.iucds.cda.ucr.IVLTS in project integration-adaptor-111 by nhsconnect.
the class LocationMapperTest method shouldMapOrganizationToLocationComponent.
@Test
public void shouldMapOrganizationToLocationComponent() {
POCDMT000002UK01Organization itkOrganization = mock(POCDMT000002UK01Organization.class);
POCDMT000002UK01OrganizationPartOf partOf = mock(POCDMT000002UK01OrganizationPartOf.class);
IVLTS effectiveTime = mock(IVLTS.class);
when(organizationMapper.mapOrganization(any(POCDMT000002UK01Organization.class))).thenReturn(organization);
when(itkOrganization.isSetAsOrganizationPartOf()).thenReturn(true);
when(itkOrganization.getAsOrganizationPartOf()).thenReturn(partOf);
when(partOf.getEffectiveTime()).thenReturn(effectiveTime);
when(periodMapper.mapPeriod(any())).thenReturn(period);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Encounter.EncounterLocationComponent encounterLocationComponent = locationMapper.mapOrganizationToLocationComponent(itkOrganization);
assertThat(encounterLocationComponent.getLocationTarget().getIdElement().getValue()).isEqualTo(RANDOM_UUID);
assertThat(encounterLocationComponent.getLocationTarget().getManagingOrganizationTarget()).isEqualTo(organization);
assertThat(encounterLocationComponent.getPeriod()).isEqualTo(period);
}
Aggregations