public void newInstance() { String searchString = form.txtMedSearch().getValue(); form.getLocalContext().setMedicationDetails(new MedicationVo()); form.grdMedication().setValue(null); clearInstanceControls(); form.chkIsActive().setValue(true); form.txtMedicationName().setValue(searchString); if (form.grdMedication().getRows().size() > 0) form.txtMedicationName().setValue(null); form.txtMedicationName().setFocus(); form.setMode(FormMode.EDIT); }
public MedicationVo createOrUpdateMedication(MedicationVo value) throws StaleObjectException { if(value == null) throw new CodingRuntimeException("Invalid medication"); if(value.getMedicationName() == null || value.getMedicationName().trim().length() == 0) throw new CodingRuntimeException("Invalid medication name"); MedicationVo existingMedication = getMedicationByName(value.getMedicationName()); if(existingMedication == null) return insertMedication(value); else return existingMedication; }
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); }
private void addMedication(MedicationVo selectedMedication) { if(selectedMedication == null) return; Date date = new Date(); GenForm.grdMedicationRow row = form.grdMedication().getRows().newRow(); row.setcolDrug(selectedMedication.getMedicationName()); row.setcolDate(date); PatientMedicationLiteVo value = new PatientMedicationLiteVo(); value.setMedication(selectedMedication); row.setValue(value); }
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); }
private MedicationVo getMedication() { IDMDValue selection = form.ccDMDSearch().getValue(); if(selection == null) return null; MedicationVo result = new MedicationVo(); result.setMedicationName(selection.getIDMDValueText()); result.setIsActive(true); /* TaxonomyMapCollection taxonomy = new TaxonomyMapCollection(); TaxonomyMap vtm = new TaxonomyMap(); vtm.setTaxonomyName(TaxonomyType.VTM); vtm.setTaxonomyCode(String.valueOf(form.ccDMDSearch().getVTM().getID_VTM())); taxonomy.add(vtm); if(selection.getIDMDValueType() == DMDType.VMP || selection.getIDMDValueType() == DMDType.AMP) { TaxonomyMap vmp = new TaxonomyMap(); vmp.setTaxonomyName(TaxonomyType.VMP); vmp.setTaxonomyCode(String.valueOf(form.ccDMDSearch().getVMP().getID_VMP())); taxonomy.add(vmp); } if(selection.getIDMDValueType() == DMDType.AMP) { TaxonomyMap amp = new TaxonomyMap(); amp.setTaxonomyName(TaxonomyType.AMP); amp.setTaxonomyCode(String.valueOf(form.ccDMDSearch().getAMP().getID_AMP())); taxonomy.add(amp); } result.setTaxonomyMap(taxonomy); */ KeywordVoCollection keywords = new KeywordVoCollection(); String[] keywordStrings = Keywords.generateKeywords(selection.getIDMDValueText()); for(int x = 0; x < keywordStrings.length; x++) { KeywordVo keyword = new KeywordVo(); keyword.setKeyword(keywordStrings[x]); keywords.add(keyword); } result.setKeywords(keywords); return result; }
public MedicationVo createOrUpdateMedication(MedicationVo value) throws StaleObjectException { return new MedicationManagement(getDomainFactory()).createOrUpdateMedication(value); }
public MedicationVo getMedicationByName(String strName) { DomainFactory factory = getDomainFactory(); Medication domMedication = Medication.getMedicationFromMedicationName(factory, strName); return MedicationVoAssembler.create(domMedication); }