Search in sources :

Example 76 with Concept

use of org.openmrs.Concept in project openmrs-core by openmrs.

the class OrderServiceImpl method ensureConceptIsSet.

private void ensureConceptIsSet(Order order) {
    Concept concept = order.getConcept();
    if (concept == null && isDrugOrder(order)) {
        DrugOrder drugOrder = (DrugOrder) order;
        if (drugOrder.getDrug() != null) {
            concept = drugOrder.getDrug().getConcept();
            drugOrder.setConcept(concept);
        }
    }
    if (concept == null) {
        throw new MissingRequiredPropertyException("Order.concept.required");
    }
}
Also used : Concept(org.openmrs.Concept) DrugOrder(org.openmrs.DrugOrder) MissingRequiredPropertyException(org.openmrs.api.MissingRequiredPropertyException)

Example 77 with Concept

use of org.openmrs.Concept in project openmrs-core by openmrs.

the class OrderServiceImpl method getSetMembersOfConceptSetFromGP.

private List<Concept> getSetMembersOfConceptSetFromGP(String globalProperty) {
    String conceptUuid = Context.getAdministrationService().getGlobalProperty(globalProperty);
    Concept concept = Context.getConceptService().getConceptByUuid(conceptUuid);
    if (concept != null && concept.getSet()) {
        return concept.getSetMembers();
    }
    return Collections.emptyList();
}
Also used : Concept(org.openmrs.Concept)

Example 78 with Concept

use of org.openmrs.Concept in project openmrs-core by openmrs.

the class PatientServiceImpl method processDeath.

/**
 * This is the way to establish that a patient has died. In addition to exiting the patient from
 * care (see above), this method will also set the appropriate patient characteristics to
 * indicate that they have died, when they died, etc.
 *
 * @param patient - the patient who has died
 * @param dateDied - the declared date/time of the patient's death
 * @param causeOfDeath - the concept that corresponds with the reason the patient died
 * @param otherReason - in case the causeOfDeath is 'other', a place to store more info
 * @throws APIException
 */
@Override
public void processDeath(Patient patient, Date dateDied, Concept causeOfDeath, String otherReason) throws APIException {
    if (patient != null && dateDied != null && causeOfDeath != null) {
        // set appropriate patient characteristics
        patient.setDead(true);
        patient.setDeathDate(dateDied);
        patient.setCauseOfDeath(causeOfDeath);
        this.savePatient(patient);
        saveCauseOfDeathObs(patient, dateDied, causeOfDeath, otherReason);
        // exit from program
        // first, need to get Concept for "Patient Died"
        String strPatientDied = Context.getAdministrationService().getGlobalProperty("concept.patientDied");
        Concept conceptPatientDied = Context.getConceptService().getConcept(strPatientDied);
        if (conceptPatientDied == null) {
            log.debug("ConceptPatientDied is null");
        }
        exitFromCare(patient, dateDied, conceptPatientDied);
    } else {
        if (patient == null) {
            throw new APIException("Patient.invalid.dead", (Object[]) null);
        }
        if (dateDied == null) {
            throw new APIException("Patient.no.valid.dateDied", (Object[]) null);
        }
        if (causeOfDeath == null) {
            throw new APIException("Patient.no.valid.causeOfDeath", (Object[]) null);
        }
    }
}
Also used : Concept(org.openmrs.Concept) APIException(org.openmrs.api.APIException)

Example 79 with Concept

use of org.openmrs.Concept in project openmrs-core by openmrs.

the class ObsServiceImpl method handleExistingObsWithComplexConcept.

private void handleExistingObsWithComplexConcept(Obs obs) {
    ComplexData complexData = obs.getComplexData();
    Concept concept = obs.getConcept();
    if (null != concept && concept.isComplex() && null != complexData && null != complexData.getData()) {
        // save or update complexData object on this obs
        // this is done before the database save so that the obs.valueComplex
        // can be filled in by the handler.
        ComplexObsHandler handler = getHandler(obs);
        if (null != handler) {
            handler.saveObs(obs);
        } else {
            throw new APIException("unknown.handler", new Object[] { concept });
        }
    }
}
Also used : Concept(org.openmrs.Concept) APIException(org.openmrs.api.APIException) ComplexData(org.openmrs.obs.ComplexData) ComplexObsHandler(org.openmrs.obs.ComplexObsHandler)

Example 80 with Concept

use of org.openmrs.Concept in project openmrs-core by openmrs.

the class ConceptServiceImpl method getDrugs.

/**
 * @see org.openmrs.api.ConceptService#getDrugs(java.lang.String)
 */
@Override
@Transactional(readOnly = true)
public List<Drug> getDrugs(String phrase) {
    List<Drug> drugs = new ArrayList<>();
    // trying to treat search phrase as drug id
    try {
        Integer drugId = Integer.parseInt(phrase);
        Drug targetDrug = Context.getConceptService().getDrug(drugId);
        // if drug was found add it to result
        if (targetDrug != null) {
            drugs.add(targetDrug);
        }
    } catch (NumberFormatException e) {
    // do nothing
    }
    // also try to treat search phrase as drug concept id
    try {
        Integer conceptId = Integer.parseInt(phrase);
        Concept targetConcept = Context.getConceptService().getConcept(conceptId);
        if (targetConcept != null) {
            drugs.addAll(Context.getConceptService().getDrugsByConcept(targetConcept));
        }
    } catch (NumberFormatException e) {
    // do nothing
    }
    drugs.addAll(dao.getDrugs(phrase));
    return drugs;
}
Also used : Drug(org.openmrs.Drug) Concept(org.openmrs.Concept) ArrayList(java.util.ArrayList) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Concept (org.openmrs.Concept)294 Test (org.junit.Test)210 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)176 ConceptName (org.openmrs.ConceptName)62 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)62 Obs (org.openmrs.Obs)49 Date (java.util.Date)48 Patient (org.openmrs.Patient)42 ConceptDescription (org.openmrs.ConceptDescription)33 Locale (java.util.Locale)32 ConceptDatatype (org.openmrs.ConceptDatatype)32 OrderUtilTest (org.openmrs.order.OrderUtilTest)29 ConceptClass (org.openmrs.ConceptClass)27 ArrayList (java.util.ArrayList)26 BindException (org.springframework.validation.BindException)26 DrugOrder (org.openmrs.DrugOrder)25 Encounter (org.openmrs.Encounter)25 Errors (org.springframework.validation.Errors)25 ConceptMapBuilder (org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder)21 Location (org.openmrs.Location)19