use of org.hl7.fhir.r4.model.Period in project integration-adaptor-111 by nhsconnect.
the class ConsentMapper method extractDataPeriodFromDoc.
private void extractDataPeriodFromDoc(Consent consent, POCDMT000002UK01StructuredBody structuredBody) {
List<POCDMT000002UK01Entry> permissionEntries = getEntriesOfType(structuredBody);
if (permissionEntries.isEmpty()) {
return;
}
for (POCDMT000002UK01Entry permissionEntry : permissionEntries) {
Period dataPeriod = getDataPeriod(permissionEntry);
if (dataPeriod == null) {
continue;
}
consent.setDataPeriod(dataPeriod);
}
}
use of org.hl7.fhir.r4.model.Period 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 org.hl7.fhir.r4.model.Period in project integration-adaptor-111 by nhsconnect.
the class HumanNameMapperTest method shouldMapHumanName.
@Test
public void shouldMapHumanName() {
PN pn = PN.Factory.newInstance();
pn.addNewGiven().set(XmlString.Factory.newValue(GIVEN));
pn.addNewPrefix().set(XmlString.Factory.newValue(PREFIX));
pn.addNewSuffix().set(XmlString.Factory.newValue(SUFFIX));
pn.addNewFamily().set(XmlString.Factory.newValue(FAMILY));
pn.addNewValidTime();
when(periodMapper.mapPeriod(ArgumentMatchers.any())).thenReturn(period);
when(nodeUtil.hasSubNodes(any())).thenReturn(true);
when(itkPersonName.getGivenArray()).thenReturn(pn.getGivenArray());
when(nodeUtil.getNodeValueString(pn.getGivenArray(0))).thenReturn(GIVEN);
when(itkPersonName.getPrefixArray()).thenReturn(pn.getPrefixArray());
when(nodeUtil.getNodeValueString(pn.getPrefixArray(0))).thenReturn(PREFIX);
when(itkPersonName.getSuffixArray()).thenReturn(pn.getSuffixArray());
when(nodeUtil.getNodeValueString(pn.getSuffixArray(0))).thenReturn(SUFFIX);
when(itkPersonName.sizeOfFamilyArray()).thenReturn(1);
when(itkPersonName.getFamilyArray(0)).thenReturn(pn.getFamilyArray(0));
when(nodeUtil.getNodeValueString(pn.getFamilyArray(0))).thenReturn(FAMILY);
when(itkPersonName.isSetValidTime()).thenReturn(true);
HumanName humanName = humanNameMapper.mapHumanName(itkPersonName);
assertThat(humanName.getGivenAsSingleString()).isEqualTo(GIVEN);
assertThat(humanName.getPrefixAsSingleString()).isEqualTo(PREFIX);
assertThat(humanName.getSuffixAsSingleString()).isEqualTo(SUFFIX);
assertThat(humanName.getFamily()).isEqualTo(FAMILY);
assertThat(humanName.getPeriod()).isEqualTo(period);
assertThat(humanName.getUse()).isEqualTo(OFFICIAL);
}
use of org.hl7.fhir.r4.model.Period in project integration-adaptor-111 by nhsconnect.
the class DataEntererMapperTest method shouldMapDataEntererToParticipantComponent.
@Test
public void shouldMapDataEntererToParticipantComponent() {
POCDMT000002UK01DataEnterer dataEnterer = mock(POCDMT000002UK01DataEnterer.class);
POCDMT000002UK01AssignedEntity assignedEntity = mock(POCDMT000002UK01AssignedEntity.class);
TS time = mock(TS.class);
when(dataEnterer.getAssignedEntity()).thenReturn(assignedEntity);
when(dataEnterer.isSetTime()).thenReturn(true);
when(dataEnterer.getTime()).thenReturn(time);
when(dataEnterer.getTypeCode()).thenReturn("CON");
when(practitionerMapper.mapPractitioner(isA(POCDMT000002UK01AssignedEntity.class))).thenReturn(practitioner);
when(periodMapper.mapPeriod(isA(TS.class))).thenReturn(period);
when(resourceUtil.createReference(practitioner)).thenReturn(new Reference(practitioner));
Encounter.EncounterParticipantComponent participantComponent = dataEntererMapper.mapDataEntererIntoParticipantComponent(dataEnterer);
assertThat(participantComponent.getIndividualTarget()).isEqualTo(practitioner);
assertThat(participantComponent.getPeriod()).isEqualTo(period);
assertThat(participantComponent.getType().get(0).getText()).isEqualTo("CON");
}
use of org.hl7.fhir.r4.model.Period 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