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())));
}
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())));
}
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);
}
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);
}
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);
}
Aggregations