/** * */ 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; }
/** * Component interface function used to return current value of the medication (MedicationOnAdmissionAndChangesLiteVo) * CAUTION: Might not be the value stored in the data base (especially if the component is in edit mode) */ public MedicationOnAdmissionAndChangesLiteVo getValue() { return form.getLocalContext().getMedication(); }
private void populateScreenFromData(MedicationOnAdmissionAndChangesLiteVo medication) { // Clear instance controls clearInstanceControls(); // Terminate if the parameter is null if (medication == null) return; // Display the medication // Set the MedicationOnAdmission radio button value if (YesNo.YES.equals(medication.getRecordMedicationOnAdmission())) { form.GroupMedicationOnAdmission().setValue(GroupMedicationOnAdmissionEnumeration.rdoMedicationOnAdmissionYes); } else if (YesNo.NO.equals(medication.getRecordMedicationOnAdmission())) { form.GroupMedicationOnAdmission().setValue(GroupMedicationOnAdmissionEnumeration.rdoMedicationOnAdmissionNo); } else { form.GroupMedicationOnAdmission().setValue(null); } // Set the MedicationOnAdmission text value form.txtMedAdmission().setValue(medication.getMedicationOnAdmission()); // Set the MedicationChanges radio button value if (YesNo.YES.equals(medication.getRecordMedicationChanges())) { form.GroupMedicationChanges().setValue(GroupMedicationChangesEnumeration.rdoMedicationChangesYes); } else if (YesNo.NO.equals(medication.getRecordMedicationChanges())) { form.GroupMedicationChanges().setValue(GroupMedicationChangesEnumeration.rdoMedicationChangesNo); } else { form.GroupMedicationChanges().setValue(null); } // Set the MedicationChanges text value form.txtMedicationChanged().setValue(medication.getMedicationChanges()); // Set the check-box Complete value form.chkComplete().setValue(Boolean.TRUE.equals(medication.getIsComplete())); }