Search in sources :

Example 61 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.

the class RelatedPersonFhirResourceProviderIntegrationTest method shouldReturnSortedAndFilterSearchResultsForRelatedPersonAsXML.

@Test
public void shouldReturnSortedAndFilterSearchResultsForRelatedPersonAsXML() throws Exception {
    MockHttpServletResponse response = get("/RelatedPerson?name=John&_sort=-date").accept(FhirMediaTypes.XML).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, everyItem(hasResource(hasProperty("nameFirstRep", hasProperty("family", containsString("Doe"))))));
    assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("nameFirstRep", hasProperty("givenAsSingleString", containsString("F"))))));
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 62 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson in project integration-adaptor-111 by nhsconnect.

the class RelatedPersonMapperTest method shouldCreateRelatedPersonWhenPatientHasEcTelecom.

@Test
public void shouldCreateRelatedPersonWhenPatientHasEcTelecom() {
    TEL[] telecomArray = createTelecomArray();
    telecomArray[0].setUse(Collections.singletonList("EC"));
    when(clinicalDocumentDocument.getRecordTargetArray(0)).thenReturn(recordTarget);
    when(recordTarget.getPatientRole()).thenReturn(patientRole);
    when(patientRole.getTelecomArray()).thenReturn(telecomArray);
    when(contactPoint.getValue()).thenReturn(TELECOM_VALUE);
    when(contactPointMapper.mapContactPoint(ArgumentMatchers.any())).thenReturn(contactPoint);
    RelatedPerson relatedPerson = relatedPersonMapper.createEmergencyContactRelatedPerson(clinicalDocumentDocument, encounter);
    assertThat(relatedPerson.hasRelationship()).isTrue();
    assertThat(relatedPerson.getRelationship().getCoding().size()).isEqualTo(1);
    assertThat(relatedPerson.getRelationship().getCodingFirstRep().getCode()).isEqualTo("C");
    assertThat(relatedPerson.getRelationship().getCodingFirstRep().getDisplay()).isEqualTo("Emergency Contact");
    assertThat(relatedPerson.getTelecom().get(0).getValue()).isEqualTo(TELECOM_VALUE);
}
Also used : TEL(uk.nhs.connect.iucds.cda.ucr.TEL) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) Test(org.junit.jupiter.api.Test)

Example 63 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson in project integration-adaptor-111 by nhsconnect.

the class RelatedPersonMapperTest method shouldMapRelatedPersonWithTwoCodingsInRelationship.

@Test
public void shouldMapRelatedPersonWithTwoCodingsInRelationship() {
    setup();
    TEL[] telecomArray = createTelecomArray();
    telecomArray[0].setUse(Collections.singletonList("EC"));
    relatedEntity.setTelecomArray(telecomArray);
    informant12.setRelatedEntity(relatedEntity);
    RelatedPerson relatedPerson = relatedPersonMapper.mapRelatedPerson(informant12, encounter);
    assertThat(relatedPerson.hasRelationship()).isTrue();
    assertThat(relatedPerson.getRelationship().getCoding().size()).isEqualTo(2);
}
Also used : TEL(uk.nhs.connect.iucds.cda.ucr.TEL) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) Test(org.junit.jupiter.api.Test)

Example 64 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson 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);
}
Also used : IVLTS(uk.nhs.connect.iucds.cda.ucr.IVLTS) POCDMT000002UK01Informant12(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Informant12) POCDMT000002UK01RelatedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RelatedEntity) Reference(org.hl7.fhir.dstu3.model.Reference) Encounter(org.hl7.fhir.dstu3.model.Encounter) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) Test(org.junit.jupiter.api.Test)

Example 65 with RelatedPerson

use of org.hl7.fhir.r4.model.RelatedPerson in project integration-adaptor-111 by nhsconnect.

the class RelatedPersonMapper method setRelationship.

private void setRelationship(POCDMT000002UK01RelatedEntity relatedEntity, RelatedPerson relatedPerson) {
    if (relatedEntity.isSetCode()) {
        CE code = relatedEntity.getCode();
        Coding coding = new Coding().setCode(code.getCode()).setDisplay(code.getDisplayName()).setSystem(code.getCodeSystem());
        relatedPerson.setRelationship(new CodeableConcept(coding));
    }
}
Also used : CE(uk.nhs.connect.iucds.cda.ucr.CE) Coding(org.hl7.fhir.dstu3.model.Coding) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

Test (org.junit.Test)87 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)54 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)51 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)33 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)29 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)24 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)24 StringParam (ca.uhn.fhir.rest.param.StringParam)24 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)24 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)20 RelatedPerson (org.hl7.fhir.dstu3.model.RelatedPerson)17 Test (org.junit.jupiter.api.Test)17 Resource (org.hl7.fhir.r4.model.Resource)14 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)13 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)12 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)12 Patient (org.hl7.fhir.r4.model.Patient)12 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)11 Identifier (org.hl7.fhir.r4.model.Identifier)10 Reference (org.hl7.fhir.r4.model.Reference)9