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));
}
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));
}
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());
}
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));
}
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(""));
}
Aggregations