use of org.hl7.fhir.r4.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportSearchQueryTest method getNonNullObsListForSorting.
private List<DiagnosticReport> getNonNullObsListForSorting(SortSpec sort) {
SearchParameterMap theParams = new SearchParameterMap().setSortSpec(sort);
IBundleProvider diagnosticReports = search(theParams);
assertThat(diagnosticReports, notNullValue());
assertThat(diagnosticReports.size(), greaterThanOrEqualTo(1));
List<DiagnosticReport> results = get(diagnosticReports);
assertThat(results, not(empty()));
assertThat(results.size(), greaterThanOrEqualTo(1));
// Remove diagnostic reports with sort parameter value null, to allow comparison while asserting.
if (DiagnosticReport.SP_ISSUED.equals(sort.getParamName())) {
results.removeIf(p -> p.getIssued() == null);
}
return results;
}
use of org.hl7.fhir.r4.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldAddNotNullResultToReturnedResults.
@Test
public void searchForDiagnosticReports_shouldAddNotNullResultToReturnedResults() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(DIAGNOSTIC_REPORT_UUID));
HashSet<Include> includes = new HashSet<>();
Include include = new Include("DiagnosticReport:result");
includes.add(include);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes);
IBundleProvider results = search(theParams);
assertThat(results.size(), equalTo(1));
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(Observation.class)), hasProperty("id", equalTo(returnedDiagnosticReport.getResultFirstRep().getReferenceElement().getIdPart())))));
}
use of org.hl7.fhir.r4.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientUuidAnd.
@Test
public void searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientUuidAnd() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_UUID);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(WRONG_PATIENT_UUID);
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);
List<DiagnosticReport> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of org.hl7.fhir.r4.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldSearchForObsByUuid.
@Test
public void searchForDiagnosticReports_shouldSearchForObsByUuid() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(DIAGNOSTIC_REPORT_UUID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
List<DiagnosticReport> resultList = get(results);
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(DIAGNOSTIC_REPORT_UUID));
}
use of org.hl7.fhir.r4.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class FhirDiagnosticReportServiceImplTest method updateTask_shouldThrowInvalidRequestForUuidMismatch.
@Test(expected = InvalidRequestException.class)
public void updateTask_shouldThrowInvalidRequestForUuidMismatch() {
DiagnosticReport diagnosticReport = new DiagnosticReport();
diagnosticReport.setId(UUID);
service.update(WRONG_UUID, diagnosticReport);
}
Aggregations