Search in sources :

Example 1 with MockIBundleProvider

use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByStatus.

@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByStatus() {
    TokenAndListParam status = new TokenAndListParam();
    status.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue("active")));
    when(service.searchForAllergies(isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(status)), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, null, null, status, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 2 with MockIBundleProvider

use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByManifestation.

@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByManifestation() {
    TokenAndListParam manifestation = new TokenAndListParam();
    manifestation.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CODED_REACTION_UUID)));
    when(service.searchForAllergies(isNull(), isNull(), isNull(), isNull(), argThat(is(manifestation)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, null, manifestation, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 3 with MockIBundleProvider

use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesBySeverity.

@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesBySeverity() {
    TokenAndListParam severity = new TokenAndListParam();
    severity.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(SEVERITY_CONCEPT_UUID)));
    when(service.searchForAllergies(isNull(), isNull(), isNull(), argThat(is(severity)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, severity, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 4 with MockIBundleProvider

use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldNotAddPatientsToReturnedResultsForEmptyInclude.

@Test
public void searchForAllergies_shouldNotAddPatientsToReturnedResultsForEmptyInclude() {
    HashSet<Include> includes = new HashSet<>();
    when(service.searchForAllergies(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, null, null, null, null, null, null, includes);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.size(), greaterThanOrEqualTo(1));
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
Also used : Include(ca.uhn.fhir.model.api.Include) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) HashSet(java.util.HashSet) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 5 with MockIBundleProvider

use of org.openmrs.module.fhir2.providers.r4.MockIBundleProvider in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByAllergen.

@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByAllergen() {
    TokenAndListParam allergen = new TokenAndListParam();
    allergen.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CODED_ALLERGEN_UUID)));
    when(service.searchForAllergies(isNull(), isNull(), argThat(is(allergen)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, allergen, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)229 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)228 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)178 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)129 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)100 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)67 StringParam (ca.uhn.fhir.rest.param.StringParam)67 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)57 Include (ca.uhn.fhir.model.api.Include)50 HashSet (java.util.HashSet)50 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)47 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)47 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)47 TokenParam (ca.uhn.fhir.rest.param.TokenParam)44 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)43 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)31 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)25 Location (org.hl7.fhir.dstu3.model.Location)16 Location (org.hl7.fhir.r4.model.Location)16 NumberParam (ca.uhn.fhir.rest.param.NumberParam)12