Search in sources :

Example 6 with DrugIngredient

use of org.openmrs.DrugIngredient in project openmrs-module-webservices.rest by openmrs.

the class DrugIngredientResource1_11 method save.

/**
 * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object)
 */
@Override
public DrugIngredient save(DrugIngredient newIngredient) {
    // make sure that the ingredient has actually been added to the drug
    boolean needToAdd = true;
    for (DrugIngredient di : newIngredient.getDrug().getIngredients()) {
        if (di.equals(newIngredient)) {
            needToAdd = false;
            break;
        }
    }
    if (needToAdd) {
        newIngredient.getDrug().getIngredients().add(newIngredient);
    }
    Context.getConceptService().saveDrug(newIngredient.getDrug());
    return newIngredient;
}
Also used : DrugIngredient(org.openmrs.DrugIngredient)

Example 7 with DrugIngredient

use of org.openmrs.DrugIngredient in project openmrs-module-webservices.rest by openmrs.

the class DrugIngredientResource1_11Test method newObject.

@Override
public DrugIngredient newObject() {
    DrugIngredient ingredient = new DrugIngredient();
    ingredient.setIngredient(Context.getConceptService().getConcept(3));
    ingredient.setUuid(getUuidProperty());
    ingredient.setStrength(2d);
    ingredient.setUnits(Context.getConceptService().getConcept(8));
    return ingredient;
}
Also used : DrugIngredient(org.openmrs.DrugIngredient)

Aggregations

DrugIngredient (org.openmrs.DrugIngredient)7 Medication (org.hl7.fhir.r4.model.Medication)3 Test (org.junit.Test)2 Concept (org.openmrs.Concept)2 Drug (org.openmrs.Drug)2 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 Optional (java.util.Optional)1 Nonnull (javax.annotation.Nonnull)1 AccessLevel (lombok.AccessLevel)1 Setter (lombok.Setter)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Coding (org.hl7.fhir.r4.model.Coding)1 Extension (org.hl7.fhir.r4.model.Extension)1 StringType (org.hl7.fhir.r4.model.StringType)1 Test (org.junit.jupiter.api.Test)1 FhirConstants (org.openmrs.module.fhir2.FhirConstants)1 ConceptTranslator (org.openmrs.module.fhir2.api.translators.ConceptTranslator)1 MedicationTranslator (org.openmrs.module.fhir2.api.translators.MedicationTranslator)1 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)1