public MedicationVo getMedicationByName(String medicationName) { if(medicationName == null || medicationName.trim().length() == 0) throw new CodingRuntimeException("Invalid medication name"); return MedicationVoAssembler.create(Medication.getMedicationFromMedicationName(domain, medicationName)); }
private MedicationVo insertMedication(MedicationVo value) throws StaleObjectException { if(!value.isValidated()) throw new CodingRuntimeException("Medication not validated"); Medication dom = MedicationVoAssembler.extractMedication(domain, value); domain.save(dom); return MedicationVoAssembler.create(dom); }
public MedicationVo saveConfigVo(MedicationVo voMedication) throws StaleObjectException, UniqueKeyViolationException { if (!voMedication.isValidated()) { throw new DomainRuntimeException("This MedicationVo has not been validated"); } DomainFactory factory = getDomainFactory(); voMedication.setMedicationName(voMedication.getMedicationName().trim());//wdev-1336 Medication domMedication = MedicationVoAssembler.extractMedication(factory, voMedication); domMedication.setKeywords(Keywords.setupKeyWords(domMedication.getKeywords(), domMedication.getMedicationName())); try { factory.save(domMedication); } catch (UnqViolationUncheckedException e) { // check which constraint was violated (name/taxononmy map) //name Medication med = Medication.getMedicationFromMedicationName(factory, voMedication.getMedicationName()); if (med != null && med.getId() != null && !(med.getId().equals(voMedication.getID_Medication()))) { throw new UniqueKeyViolationException("Medication record called \"" + voMedication.getMedicationName() + "\" already exists. Duplicates not allowed.", e); } //taxonomy map String dupMessage = Keywords.checkDuplicateTaxonomy(factory, domMedication, voMedication.getTaxonomyMap(), "getMedicationName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); throw (e); } return MedicationVoAssembler.create(domMedication); }
/** * Save a Medication Vo */ public ims.core.vo.MedicationVo saveMedicationVo(ims.core.vo.MedicationVo voMedication) throws ims.domain.exceptions.StaleObjectException, UniqueKeyViolationException { if (!voMedication.isValidated()) { throw new DomainRuntimeException("This MedicationVo has not been validated"); } DomainFactory factory = getDomainFactory(); voMedication.setMedicationName(voMedication.getMedicationName().trim());//wdev-1336 // Bug Fix WDEV-1896 if (!voMedication.getID_MedicationIsNotNull()) { List l = factory.find("from Medication m where upper(m.medicationName) = :medName", new String[]{"medName"}, new Object[]{voMedication.getMedicationName().toUpperCase()}); if (l.size() > 0) throw new UniqueKeyViolationException("Medication record called \"" + voMedication.getMedicationName() + "\" already exists. Duplicates not allowed."); } Medication domMedication = MedicationVoAssembler.extractMedication(factory, voMedication); domMedication.setKeywords(Keywords.setupKeyWords(domMedication.getKeywords(), domMedication.getMedicationName())); try { //WDEV-4212 domMedication.getTaxonomyMap().clear(); domMedication.setTaxonomyMap(TaxonomyMapAssembler.extractTaxonomyMapList(factory, voMedication.getTaxonomyMap())); factory.save(domMedication); } catch (UnqViolationUncheckedException e) { // check which constraint was violated (name/taxononmy map) //name Medication med = Medication.getMedicationFromMedicationName(factory, voMedication.getMedicationName()); if (med != null && med.getId() != null && !(med.getId().equals(voMedication.getID_Medication()))) { throw new UniqueKeyViolationException("Medication record called \"" + voMedication.getMedicationName() + "\" already exists. Duplicates not allowed.", e); } //taxonomy map String dupMessage = Keywords.checkDuplicateTaxonomy(factory, domMedication, voMedication.getTaxonomyMap(), "getMedicationName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); throw (e); } return MedicationVoAssembler.create(domMedication); }
public ims.core.vo.MedicationVo getMedicationVo(MedicationRefVo voMediactionRef) { DomainFactory factory = getDomainFactory(); Medication med = (Medication) factory.getDomainObject(Medication.class, voMediactionRef.getID_Medication()); return (MedicationVoAssembler.create(med)); }
public MedicationVo getMedicationByName(String strName) { DomainFactory factory = getDomainFactory(); Medication domMedication = Medication.getMedicationFromMedicationName(factory, strName); return MedicationVoAssembler.create(domMedication); }