Search in sources :

Example 11 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.

the class ProcedureRequestFhirResourceProviderIntegrationTest method shouldSearchForExistingProcedureRequestsAsJson.

@Test
public void shouldSearchForExistingProcedureRequestsAsJson() throws Exception {
    MockHttpServletResponse response = get("/ProcedureRequest").accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.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(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/ProcedureRequest/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(ProcedureRequest.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
    response = get("/ProcedureRequest?patient.identifier=101-6&encounter=y403fafb-e5e4-42d0-9d11-4f52e89d123r").accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    entries = results.getEntry();
    assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", endsWith(PATIENT_UUID))))));
    assertThat(entries, everyItem(hasResource(hasProperty("context", hasProperty("reference", endsWith(ENCOUNTER_UUID))))));
    assertThat(entries, everyItem(hasResource(validResource())));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 12 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.

the class ProcedureRequestFhirResourceProviderIntegrationTest method shouldSearchForExistingProcedureRequestsAsXML.

@Test
public void shouldSearchForExistingProcedureRequestsAsXML() throws Exception {
    MockHttpServletResponse response = get("/ProcedureRequest").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(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/ProcedureRequest/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(ProcedureRequest.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
    response = get("/ProcedureRequest?patient.identifier=101-6&encounter=y403fafb-e5e4-42d0-9d11-4f52e89d123r").accept(FhirMediaTypes.XML).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    entries = results.getEntry();
    assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", endsWith(PATIENT_UUID))))));
    assertThat(entries, everyItem(hasResource(hasProperty("context", hasProperty("reference", endsWith(ENCOUNTER_UUID))))));
    assertThat(entries, everyItem(hasResource(validResource())));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 13 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project integration-adaptor-111 by nhsconnect.

the class ReferralRequestMapperTest method setup.

@BeforeEach
public void setup() {
    healthcareServiceList = new ArrayList<>();
    healthcareServiceList.add(healthcareService);
    encounter = new Encounter();
    String encounterId = "Encounter/1";
    encounter.setServiceProvider(serviceProviderRef).setSubject(patientRef).setId(encounterId);
    TS ts = TS.Factory.newInstance();
    ts.setValue(AUTHOR_TIME);
    POCDMT000002UK01Author[] authorArray = new POCDMT000002UK01Author[1];
    authorArray[0] = author;
    TS effectiveTime = TS.Factory.newInstance();
    effectiveTime.setValue("20220304");
    when(procedureRequestMapper.mapProcedureRequest(any(), any(), any())).thenReturn(procedureRequest);
    when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
    when(resourceUtil.createReference(encounter)).thenReturn(new Reference(encounter));
    when(resourceUtil.createReference(procedureRequest)).thenReturn(new Reference(procedureRequest));
    when(resourceUtil.createReference(practitioner)).thenReturn(new Reference(practitioner));
    when(author.getTime()).thenReturn(ts);
    when(author.getTypeCode()).thenReturn("AUT");
    when(clinicalDocument.getAuthorArray()).thenReturn(authorArray);
    when(clinicalDocument.getParticipantArray()).thenReturn(new POCDMT000002UK01Participant1[] { participantREFT, participantCALLBCK });
    when(clinicalDocument.getEffectiveTime()).thenReturn(effectiveTime);
    when(participantREFT.getTypeCode()).thenReturn(PARTICIPANT_TYPE_CODE_REFT);
    when(participantCALLBCK.getTypeCode()).thenReturn(PARTICIPANT_TYPE_CODE_CALLBCK);
    when(participantREFT.getAssociatedEntity()).thenReturn(associatedEntity);
    when(practitionerMapper.mapPractitioner(associatedEntity)).thenReturn(practitioner);
    when(periodMapper.mapPeriod(effectiveTime)).thenReturn(occurrence);
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) Encounter(org.hl7.fhir.dstu3.model.Encounter) POCDMT000002UK01Author(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Author) TS(uk.nhs.connect.iucds.cda.ucr.TS) IdType(org.hl7.fhir.dstu3.model.IdType) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project integration-adaptor-111 by nhsconnect.

the class ReferralRequestMapperTest method shouldMapReferralRequest.

@Test
public void shouldMapReferralRequest() {
    ReferralRequest referralRequest = referralRequestMapper.mapReferralRequest(clinicalDocument, encounter, healthcareServiceList, condition, deviceRef);
    assertThat(ReferralRequest.ReferralRequestStatus.ACTIVE).isEqualTo(referralRequest.getStatus());
    assertThat(ReferralRequest.ReferralCategory.PLAN).isEqualTo(referralRequest.getIntent());
    assertThat(ReferralRequest.ReferralPriority.ROUTINE).isEqualTo(referralRequest.getPriority());
    assertThat(referralRequest.getOccurrence()).isEqualTo(occurrence);
    assertThat(referralRequest.getAuthoredOnElement()).isEqualToComparingFieldByField(DateUtil.parse(AUTHOR_TIME));
    assertThat(deviceRef.getReference()).isEqualTo(referralRequest.getRequester().getAgent().getReference());
    assertThat(serviceProviderRef.getReference()).isEqualTo(referralRequest.getRequester().getOnBehalfOf().getReference());
    assertThat(new Reference(encounter).getReference()).isEqualTo(referralRequest.getContext().getReference());
    assertThat(patientRef.getReference()).isEqualTo(referralRequest.getSubject().getReference());
    assertThat(referralRequest.getSupportingInfo().get(0).getResource()).isEqualTo(procedureRequest);
    assertThat(referralRequest.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
    assertThat(referralRequest.getRecipient().get(0).getResource()).isInstanceOf(Practitioner.class);
    verify(practitionerMapper, times(1)).mapPractitioner(associatedEntity);
    verifyNoMoreInteractions(practitionerMapper);
}
Also used : ReferralRequest(org.hl7.fhir.dstu3.model.ReferralRequest) Reference(org.hl7.fhir.dstu3.model.Reference) Test(org.junit.jupiter.api.Test)

Example 15 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project integration-adaptor-111 by nhsconnect.

the class ProcedureRequestMapperTest method patientMapperTest.

@Test
public void patientMapperTest() {
    ProcedureRequest procedureRequest = procedureRequestMapper.mapProcedureRequest(clinicalDocument1, patient, referralRequest);
    assertThat(procedureRequest.getStatus()).isEqualTo(ProcedureRequest.ProcedureRequestStatus.ACTIVE);
    assertThat(procedureRequest.getIntent()).isEqualTo(ProcedureRequest.ProcedureRequestIntent.PLAN);
    assertThat(procedureRequest.getPriority()).isEqualTo(ProcedureRequest.ProcedureRequestPriority.ROUTINE);
    assertThat(procedureRequest.getCode().getCoding().get(0).getDisplay()).isEqualTo(DISPLAY_NAME);
    assertThat(procedureRequest.getCode().getCoding().get(0).getCode()).isEqualTo(CODE);
    assertThat(procedureRequest.getCode().getCoding().get(0).getSystem()).isEqualTo(CODESYSTEM);
    assertThat(procedureRequest.getSubject()).isEqualTo(patient);
    assertThat(procedureRequest.getDoNotPerform()).isEqualTo(false);
    assertThat(procedureRequest.getOccurrence()).isEqualTo(occurrence);
    assertThat(procedureRequest.getReasonReference()).isEqualTo(reasonReferenceList);
    assertThat(procedureRequest.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
}
Also used : ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) Test(org.junit.jupiter.api.Test)

Aggregations

ProcedureRequest (org.hl7.fhir.dstu3.model.ProcedureRequest)23 Test (org.junit.jupiter.api.Test)12 Test (org.junit.Test)10 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)6 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)6 IdType (org.hl7.fhir.dstu3.model.IdType)5 Reference (org.hl7.fhir.dstu3.model.Reference)5 Bundle (org.hl7.fhir.dstu3.model.Bundle)4 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)3 Identifier (org.hl7.fhir.dstu3.model.Identifier)2 Resource (org.hl7.fhir.dstu3.model.Resource)2 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)2 Test (org.testng.annotations.Test)2 SystemRequestDetails (ca.uhn.fhir.jpa.partition.SystemRequestDetails)1 IParser (ca.uhn.fhir.parser.IParser)1 Create (ca.uhn.fhir.rest.annotation.Create)1 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)1 IProcedureRequest (ch.elexis.core.findings.IProcedureRequest)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 URI (java.net.URI)1