Search in sources :

Example 56 with Period

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);
    }
}
Also used : POCDMT000002UK01Entry(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Entry) Period(org.hl7.fhir.dstu3.model.Period)

Example 57 with Period

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;
}
Also used : IVLTS(uk.nhs.connect.iucds.cda.ucr.IVLTS) POCDMT000002UK01Observation(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Observation) Period(org.hl7.fhir.dstu3.model.Period)

Example 58 with Period

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);
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName) PN(uk.nhs.connect.iucds.cda.ucr.PN) Test(org.junit.jupiter.api.Test)

Example 59 with Period

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");
}
Also used : POCDMT000002UK01DataEnterer(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01DataEnterer) Reference(org.hl7.fhir.dstu3.model.Reference) Encounter(org.hl7.fhir.dstu3.model.Encounter) POCDMT000002UK01AssignedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedEntity) TS(uk.nhs.connect.iucds.cda.ucr.TS) Test(org.junit.jupiter.api.Test)

Example 60 with Period

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

Period (org.hl7.fhir.r4.model.Period)87 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)44 Date (java.util.Date)42 Test (org.junit.Test)42 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)40 Coding (org.hl7.fhir.r4.model.Coding)34 Test (org.junit.jupiter.api.Test)34 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)32 Period (org.hl7.fhir.dstu3.model.Period)30 ArrayList (java.util.ArrayList)29 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)27 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)20 Encounter (org.hl7.fhir.r4.model.Encounter)20 Reference (org.hl7.fhir.r4.model.Reference)20 Patient (org.hl7.fhir.r4.model.Patient)19 Reference (org.hl7.fhir.dstu3.model.Reference)18 HashMap (java.util.HashMap)17 Identifier (org.hl7.fhir.r4.model.Identifier)17 NotImplementedException (org.apache.commons.lang3.NotImplementedException)15 List (java.util.List)14