/** * Function used to list all PatientGoals based on a CareContext */ public PatientGoalVoCollection listPatientGoals(CareContextRefVo careContextRef) { // Check for a valid CareContext if (careContextRef == null || !careContextRef.getID_CareContextIsNotNull()) { throw new DomainRuntimeException("Major logical error - Provide a care context to search patient goals"); } // Define filter criteria IMSCriteria criteria = new IMSCriteria(PatientGoal.class, getDomainFactory()); criteria.equal("this.careContext.id", careContextRef.getID_CareContext()); // Return corresponding PatientGoal collection return PatientGoalVoAssembler.createPatientGoalVoCollectionFromPatientGoal(criteria.find()); }
/** * Function used to save a PatientGoal to database */ public PatientGoalVo savePatientGoal(PatientGoalVo patientGoal) throws StaleObjectException, UniqueKeyViolationException { // Check if PatientGoalVo was validated if (patientGoal == null || !patientGoal.isValidated()) { throw new DomainRuntimeException("Logical Error - This PatientGoalVo has not been validated"); } // Extract a domain object from PatientGoalVo DomainFactory factory = getDomainFactory(); PatientGoal domPatientGoalVo = PatientGoalVoAssembler.extractPatientGoal(factory, patientGoal); // Save to database factory.save(domPatientGoalVo); // Return saved PatientGoalVo (with ID from database) return PatientGoalVoAssembler.create(domPatientGoalVo); }
/** * Function used to get a PatientGoal from database */ public PatientGoalVo getPatientGoal(PatientGoalRefVo patientGoalRef) { // If no PatientGoalRefVo is provided or no ID is present return null if (patientGoalRef == null || !patientGoalRef.getID_PatientGoalIsNotNull()) return null; // Return PatientGoal based on ID return PatientGoalVoAssembler.create((PatientGoal) getDomainFactory().getDomainObject(PatientGoal.class, patientGoalRef.getID_PatientGoal())); }