use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceSearchQueryTest method searchForAllergies_shouldSearchForAllergiesByPatientUUID.
@Test
public void searchForAllergies_shouldSearchForAllergiesByPatientUUID() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam allergyParam = new ReferenceParam();
allergyParam.setValue(PATIENT_UUID);
allergyParam.setChain(null);
referenceParam.addValue(new ReferenceOrListParam().add(allergyParam));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getPatient().getReferenceElement().getIdPart(), equalTo(PATIENT_UUID));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceSearchQueryTest method searchForAllergies_shouldHandleComplexQuery.
@Test
public void searchForAllergies_shouldHandleComplexQuery() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam allergyParam = new ReferenceParam();
allergyParam.setValue(PATIENT_UUID);
allergyParam.setChain(null);
referenceParam.addValue(new ReferenceOrListParam().add(allergyParam));
TokenAndListParam status = new TokenAndListParam();
status.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(STATUS)));
TokenAndListParam category = new TokenAndListParam();
category.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CATEGORY_ENVIRONMENT)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam).addParameter(FhirConstants.BOOLEAN_SEARCH_HANDLER, status).addParameter(FhirConstants.CATEGORY_SEARCH_HANDLER, category);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getClinicalStatus().getCodingFirstRep().getCode(), equalTo(STATUS));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getCategory().get(0).getValue(), equalTo(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getPatient().getReferenceElement().getIdPart(), equalTo(PATIENT_UUID));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateDateCreatedToRecordedDate.
@Test
public void toFhirResource_shouldTranslateDateCreatedToRecordedDate() {
omrsAllergy.setDateCreated(new Date());
AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
assertThat(allergyIntolerance, notNullValue());
assertThat(allergyIntolerance.getRecordedDate(), DateMatchers.sameDay(new Date()));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceTranslatorImplTest method toOpenmrsType_shouldTranslateAllergenTypeEnvironmentCorrectly.
@Test
public void toOpenmrsType_shouldTranslateAllergenTypeEnvironmentCorrectly() {
AllergyIntolerance allergy = new AllergyIntolerance();
allergy.addCategory(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT);
when(categoryTranslator.toOpenmrsType(allergy.getCategory().get(0).getValue())).thenReturn(AllergenType.ENVIRONMENT);
allergyIntoleranceTranslator.toOpenmrsType(omrsAllergy, allergy);
assertThat(omrsAllergy, notNullValue());
assertThat(omrsAllergy.getAllergen().getAllergenType(), equalTo(AllergenType.ENVIRONMENT));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldReturnNullNonCodedAllergenIfCodeTextIsNull.
@Test
public void toFhirResource_shouldReturnNullNonCodedAllergenIfCodeTextIsNull() {
omrsAllergy.setAllergen(new Allergen(AllergenType.FOOD, null, null));
AllergyIntolerance allergy = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
assertThat(allergy.getCode(), notNullValue());
assertThat(allergy.getCode().getText(), nullValue());
}
Aggregations