use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceTranslatorImplTest method toOpenmrsType_shouldTranslateAllergenTypeDrugCorrectly.
@Test
public void toOpenmrsType_shouldTranslateAllergenTypeDrugCorrectly() {
AllergyIntolerance allergy = new AllergyIntolerance();
allergy.addCategory(AllergyIntolerance.AllergyIntoleranceCategory.MEDICATION);
when(categoryTranslator.toOpenmrsType(allergy.getCategory().get(0).getValue())).thenReturn(AllergenType.DRUG);
allergyIntoleranceTranslator.toOpenmrsType(omrsAllergy, allergy);
assertThat(omrsAllergy, notNullValue());
assertThat(omrsAllergy.getAllergen().getAllergenType(), equalTo(AllergenType.DRUG));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateAllergyIntoleranceCategoryMedicationCorrectly.
@Test
public void toFhirResource_shouldTranslateAllergyIntoleranceCategoryMedicationCorrectly() {
Allergen allergen = new Allergen();
allergen.setAllergenType(AllergenType.DRUG);
omrsAllergy.setAllergen(allergen);
when(categoryTranslator.toFhirResource(omrsAllergy.getAllergen().getAllergenType())).thenReturn(AllergyIntolerance.AllergyIntoleranceCategory.MEDICATION);
AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
assertThat(allergyIntolerance, notNullValue());
assertThat(allergyIntolerance.getCategory().get(0).getValue(), equalTo(AllergyIntolerance.AllergyIntoleranceCategory.MEDICATION));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project elexis-server by elexis.
the class AllergyIntoleranceResourceProvider method createAllergyIntolerance.
@Create
public MethodOutcome createAllergyIntolerance(@ResourceParam AllergyIntolerance allergyIntolerance) {
MethodOutcome outcome = new MethodOutcome();
Optional<IAllergyIntolerance> exists = getTransformer().getLocalObject(allergyIntolerance);
if (exists.isPresent()) {
outcome.setCreated(false);
outcome.setId(new IdType(allergyIntolerance.getId()));
} else {
Optional<IAllergyIntolerance> created = getTransformer().createLocalObject(allergyIntolerance);
if (created.isPresent()) {
outcome.setCreated(true);
outcome.setId(new IdType(created.get().getId()));
} else {
throw new InternalErrorException("Creation failed");
}
}
return outcome;
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project elexis-server by elexis.
the class AllergyIntoleranceResourceProvider method findAllergyIntolerance.
@Search()
public List<AllergyIntolerance> findAllergyIntolerance(@RequiredParam(name = AllergyIntolerance.SP_PATIENT) IdType patientId) {
if (patientId != null && !patientId.isEmpty()) {
Optional<IPatient> patient = modelService.load(patientId.getIdPart(), IPatient.class);
if (patient.isPresent()) {
if (patient.get().isPatient()) {
List<AllergyIntolerance> ret = new ArrayList<>();
List<IAllergyIntolerance> findings = findingsService.getPatientsFindings(patientId.getIdPart(), IAllergyIntolerance.class);
if (findings != null && !findings.isEmpty()) {
for (IAllergyIntolerance iFinding : findings) {
Optional<AllergyIntolerance> fhirAllergyIntolerance = getTransformer().getFhirObject(iFinding);
if (fhirAllergyIntolerance.isPresent()) {
ret.add(fhirAllergyIntolerance.get());
}
}
}
return ret;
}
}
}
return Collections.emptyList();
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method initAllergyIntolerance.
@Before
public void initAllergyIntolerance() {
allergyIntolerance = new AllergyIntolerance();
allergyIntolerance.setId(ALLERGY_UUID);
allergyIntolerance.addCategory(AllergyIntolerance.AllergyIntoleranceCategory.FOOD);
setProvenanceResources(allergyIntolerance);
}
Aggregations