Search in sources :

Example 16 with DiagnosticReport

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldSearchForDiagnosticReportsByMultiplePatientFamilyNameOr.

@Test
public void searchForDiagnosticReports_shouldSearchForDiagnosticReportsByMultiplePatientFamilyNameOr() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam patient = new ReferenceParam();
    patient.setValue(PATIENT_FAMILY_NAME);
    patient.setChain(Patient.SP_FAMILY);
    ReferenceParam badPatient = new ReferenceParam();
    badPatient.setValue(WRONG_PATIENT_FAMILY_NAME);
    badPatient.setChain(Patient.SP_FAMILY);
    referenceParam.addValue(new ReferenceOrListParam().add(patient).add(badPatient));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), greaterThanOrEqualTo(1));
    List<DiagnosticReport> resultList = get(results);
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 17 with DiagnosticReport

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientIdentifierAnd.

@Test
public void searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientIdentifierAnd() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam patient = new ReferenceParam();
    patient.setValue(PATIENT_IDENTIFIER);
    patient.setChain(Patient.SP_IDENTIFIER);
    ReferenceParam badPatient = new ReferenceParam();
    badPatient.setValue(WRONG_PATIENT_IDENTIFIER);
    badPatient.setChain(Patient.SP_IDENTIFIER);
    referenceParam.addValue(new ReferenceOrListParam().add(patient)).addAnd(new ReferenceOrListParam().add(badPatient));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(0));
    List<DiagnosticReport> resultList = get(results);
    assertThat(resultList, empty());
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 18 with DiagnosticReport

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientFamilyNameAnd.

@Test
public void searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientFamilyNameAnd() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam patient = new ReferenceParam();
    patient.setValue(PATIENT_FAMILY_NAME);
    patient.setChain(Patient.SP_FAMILY);
    ReferenceParam badPatient = new ReferenceParam();
    badPatient.setValue(WRONG_PATIENT_FAMILY_NAME);
    badPatient.setChain(Patient.SP_FAMILY);
    referenceParam.addValue(new ReferenceOrListParam().add(patient)).addAnd(new ReferenceOrListParam().add(badPatient));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(0));
    List<DiagnosticReport> resultList = get(results);
    assertThat(resultList, empty());
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 19 with DiagnosticReport

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldAddNotNullPatientToReturnedResults.

@Test
public void searchForDiagnosticReports_shouldAddNotNullPatientToReturnedResults() {
    ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_IDENTIFIER).setChain(Patient.SP_IDENTIFIER)));
    HashSet<Include> includes = new HashSet<>();
    Include include = new Include("DiagnosticReport:patient");
    includes.add(include);
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference).addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes);
    IBundleProvider results = search(theParams);
    assertThat(results.size(), equalTo(2));
    List<IBaseResource> resultList = results.getResources(START_INDEX, END_INDEX);
    assertThat(results, notNullValue());
    // included resource added as part of the result list
    assertThat(resultList.size(), equalTo(3));
    DiagnosticReport returnedDiagnosticReport = (DiagnosticReport) resultList.iterator().next();
    assertThat(resultList, hasItem(allOf(is(instanceOf(Patient.class)), hasProperty("id", equalTo(returnedDiagnosticReport.getSubject().getReferenceElement().getIdPart())))));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) Include(ca.uhn.fhir.model.api.Include) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) HashSet(java.util.HashSet) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 20 with DiagnosticReport

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldHandleComplexQuery.

@Test
public void searchForDiagnosticReports_shouldHandleComplexQuery() {
    TokenAndListParam code = new TokenAndListParam().addAnd(new TokenOrListParam().add(new TokenParam(DIAGNOSTIC_REPORT_CODE)));
    ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME).setChain(Patient.SP_GIVEN)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CODED_SEARCH_HANDLER, code).addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference);
    IBundleProvider diagnosticReports = search(theParams);
    assertThat(diagnosticReports, notNullValue());
    assertThat(diagnosticReports.size(), greaterThanOrEqualTo(1));
    List<DiagnosticReport> resultList = get(diagnosticReports);
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    DiagnosticReport diagnosticReport = resultList.get(0);
    assertThat(diagnosticReport.getCode().getCodingFirstRep().getCode(), equalTo(CONCEPT_UUID));
    assertThat(diagnosticReport.getIdElement().getIdPart(), equalTo(DIAGNOSTIC_REPORT_UUID));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)133 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)115 FhirDiagnosticReport (org.openmrs.module.fhir2.model.FhirDiagnosticReport)65 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)52 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)50 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)42 Test (org.junit.jupiter.api.Test)39 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)39 DiagnosticReport (org.hl7.fhir.dstu3.model.DiagnosticReport)32 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)29 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)28 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)28 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)28 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)19 Reference (org.hl7.fhir.r4.model.Reference)19 Bundle (org.hl7.fhir.r4.model.Bundle)18 Resource (org.hl7.fhir.r4.model.Resource)18 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)16 Include (ca.uhn.fhir.model.api.Include)12 HashSet (java.util.HashSet)12