/** * */ public ims.clinical.vo.MedicationOnAdmissionAndChangesLiteVo getMedication(ims.core.admin.vo.CareContextRefVo careContext) { // Check passed care context if (careContext == null || !careContext.getID_CareContextIsNotNull()) throw new DomainRuntimeException("DOMAIN getMedication() - Selected care context is null"); // Build query and parameter to retrieve the record from database String hqlQuery = "from MedicationOnAdmissionAndChanges as meds where meds.careContext.id = :ID"; ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); paramNames.add("ID"); paramValues.add(careContext.getID_CareContext()); // Query database for the record // Create the VO form the record database return MedicationOnAdmissionAndChangesLiteVoAssembler.create((MedicationOnAdmissionAndChanges) getDomainFactory().findFirst(hqlQuery, paramNames, paramValues)); }
/** * */ public MedicationOnAdmissionAndChangesLiteVo saveMedication(MedicationOnAdmissionAndChangesLiteVo medication, EDischargeSTHKSummaryVo dischargeSummary) throws StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException { // Check for null VO passed to save if (medication == null) throw new DomainRuntimeException("DOMAIN saveMedication() - Can not save a null object"); // Check if the VO is validated if (!medication.isValidated()) throw new DomainRuntimeException("DOMAIN saveMedication() - Value object to save is not validated"); // Extract domain object needed DomainFactory domainFactory = getDomainFactory(); MedicationOnAdmissionAndChanges medicationDomObj = MedicationOnAdmissionAndChangesLiteVoAssembler.extractMedicationOnAdmissionAndChanges(domainFactory, medication); // Save domain object domainFactory.save(medicationDomObj); medication = MedicationOnAdmissionAndChangesLiteVoAssembler.create(medicationDomObj); IEDischargeHelper impl = (IEDischargeHelper) getDomainImpl(EDischargeHelper.class); impl.updateSummaryIfRequired(medication, dischargeSummary, getDomainFactory()); // Return a refreshed version of the VO return medication; }