Search in sources :

Example 16 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toOpenmrsType_shouldTranslatePractitionerReferenceToCreator.

@Test
public void toOpenmrsType_shouldTranslatePractitionerReferenceToCreator() {
    Reference practitionerReference = new Reference().setReference(FhirTestConstants.PRACTITIONER + "/" + CREATOR_UUID).setType(FhirTestConstants.PRACTITIONER).setIdentifier(new Identifier().setValue(CREATOR_UUID));
    AllergyIntolerance allergy = new AllergyIntolerance();
    allergy.setRecorder(practitionerReference);
    User user = new User();
    user.setUuid(CREATOR_UUID);
    omrsAllergy.setCreator(user);
    when(practitionerReferenceTranslator.toOpenmrsType(practitionerReference)).thenReturn(user);
    allergyIntoleranceTranslator.toOpenmrsType(omrsAllergy, allergy);
    assertThat(omrsAllergy, notNullValue());
    assertThat(omrsAllergy.getCreator(), is(user));
    assertThat(omrsAllergy.getCreator().getUuid(), is(CREATOR_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Identifier(org.hl7.fhir.r4.model.Identifier) User(org.openmrs.User) Reference(org.hl7.fhir.r4.model.Reference) Test(org.junit.Test)

Example 17 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateAllergyIntoleranceCategoryEnvironmentCorrectly.

@Test
public void toFhirResource_shouldTranslateAllergyIntoleranceCategoryEnvironmentCorrectly() {
    Allergen allergen = new Allergen();
    allergen.setAllergenType(AllergenType.ENVIRONMENT);
    omrsAllergy.setAllergen(allergen);
    when(categoryTranslator.toFhirResource(omrsAllergy.getAllergen().getAllergenType())).thenReturn(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT);
    AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergyIntolerance, notNullValue());
    assertThat(allergyIntolerance.getCategory().get(0).getValue(), equalTo(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Allergen(org.openmrs.Allergen) Test(org.junit.Test)

Example 18 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toOpenmrsType_shouldReturnNullIfNotIsEmpty.

@Test
public void toOpenmrsType_shouldReturnNullIfNotIsEmpty() {
    AllergyIntolerance allergyIntolerance = new AllergyIntolerance();
    allergyIntolerance.setNote(null);
    allergyIntoleranceTranslator.toOpenmrsType(omrsAllergy, allergyIntolerance);
    assertThat(omrsAllergy, notNullValue());
    assertThat(omrsAllergy.getComment(), nullValue());
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.Test)

Example 19 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toOpenmrsType_shouldTranslateAllergenTypeFoodCorrectly.

@Test
public void toOpenmrsType_shouldTranslateAllergenTypeFoodCorrectly() {
    AllergyIntolerance allergy = new AllergyIntolerance();
    allergy.addCategory(AllergyIntolerance.AllergyIntoleranceCategory.FOOD);
    when(categoryTranslator.toOpenmrsType(allergy.getCategory().get(0).getValue())).thenReturn(AllergenType.FOOD);
    allergyIntoleranceTranslator.toOpenmrsType(omrsAllergy, allergy);
    assertThat(omrsAllergy, notNullValue());
    assertThat(omrsAllergy.getAllergen().getAllergenType(), equalTo(AllergenType.FOOD));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.Test)

Example 20 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateCommentToNote.

@Test
public void toFhirResource_shouldTranslateCommentToNote() {
    omrsAllergy.setComment("");
    AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergyIntolerance, notNullValue());
    assertThat(allergyIntolerance.getNote().get(0).getText(), equalTo(""));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) 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