public MedicationOverViewVo saveMedicationOverviewVo(MedicationOverViewVo voMedicationOverviewVo, PatientRefVo patientRefVo) throws StaleObjectException { if(voMedicationOverviewVo == null) throw new CodingRuntimeException("Cannot save null value for MedicationOverViewVo"); if (!voMedicationOverviewVo.isValidated()) throw new CodingRuntimeException("Medication Overview has not been validated"); DomainFactory factory = getDomainFactory(); if (voMedicationOverviewVo.getID_MedicationOverview() == null)//Inserting a record { String hql = " from MedicationOverview mv where mv.careContext.id = :contextid and mv.type = :typeId"; List overs = factory.find(hql, new String[]{"contextid", "typeId"}, new Object[]{voMedicationOverviewVo.getCareContext().getID_CareContext(), getDomLookup(voMedicationOverviewVo.getType())}); if(overs.size() != 0) throw new StaleObjectException(null, "A Medication OverView record already exists for this Care Context and Overview Type, the screen will be refreshed."); } MedicationOverview domMed = MedicationOverViewVoAssembler.extractMedicationOverview(factory, voMedicationOverviewVo); factory.save(domMed); return MedicationOverViewVoAssembler.create(domMed); }
public MedicationOverViewVo getMedicationOverView(MedicationOverviewRefVo voRefMedication) { if(voRefMedication == null) throw new DomainRuntimeException("Invalid Medication record to get"); return MedicationOverViewVoAssembler.create((MedicationOverview)getDomainFactory().getDomainObject(MedicationOverview.class, voRefMedication.getID_MedicationOverview())); }