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