Search in sources :

Example 46 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirR3ResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByPatientGivenName.

@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByPatientGivenName() {
    ReferenceAndListParam patient = new ReferenceAndListParam();
    patient.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("John").setChain(Patient.SP_GIVEN)));
    when(service.searchForAllergies(argThat(is(patient)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForAllergies(patient, null, null, null, null, null, null, null, null, null, null);
    List<AllergyIntolerance> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getId(), equalTo(ALLERGY_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) Test(org.junit.Test)

Example 47 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirR3ResourceProviderTest method getAllergyIntoleranceByUuid_shouldReturnMatchingAllergy.

@Test
public void getAllergyIntoleranceByUuid_shouldReturnMatchingAllergy() {
    when(service.get(ALLERGY_UUID)).thenReturn(allergyIntolerance);
    IdType id = new IdType();
    id.setValue(ALLERGY_UUID);
    AllergyIntolerance allergy = resourceProvider.getAllergyIntoleranceById(id);
    assertThat(allergy, notNullValue());
    assertThat(allergy.getId(), notNullValue());
    assertThat(allergy.getId(), equalTo(ALLERGY_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 48 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirR3ResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByPatientFamilyName.

@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByPatientFamilyName() {
    ReferenceAndListParam patient = new ReferenceAndListParam();
    patient.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("John").setChain(Patient.SP_FAMILY)));
    when(service.searchForAllergies(argThat(is(patient)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForAllergies(patient, null, null, null, null, null, null, null, null, null, null);
    List<AllergyIntolerance> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getId(), equalTo(ALLERGY_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) Test(org.junit.Test)

Example 49 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirR3ResourceProviderTest 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<AllergyIntolerance> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getId(), equalTo(ALLERGY_UUID));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) Test(org.junit.Test)

Example 50 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirR3ResourceProviderTest method searchForAllergies_shouldReturnMatchingBundleOfAllergiesByPatientName.

@Test
public void searchForAllergies_shouldReturnMatchingBundleOfAllergiesByPatientName() {
    ReferenceAndListParam patient = new ReferenceAndListParam();
    patient.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("John Doe").setChain(Patient.SP_NAME)));
    when(service.searchForAllergies(argThat(is(patient)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(allergyIntolerance), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForAllergies(patient, null, null, null, null, null, null, null, null, null, null);
    List<AllergyIntolerance> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getId(), equalTo(ALLERGY_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)158 AllergyIntolerance (org.hl7.fhir.r4.model.AllergyIntolerance)93 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)53 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)53 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)43 AllergyIntolerance (org.hl7.fhir.dstu3.model.AllergyIntolerance)42 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)29 TokenParam (ca.uhn.fhir.rest.param.TokenParam)29 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)26 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)25 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)25 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)23 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)23 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)23 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)21 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)14 InputStream (java.io.InputStream)12 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)12 Date (java.util.Date)10 IdType (org.hl7.fhir.r4.model.IdType)10