/** * WDEV-13587 * Retrieve Hydrotherapy record based on ClinicalContact * Depending on RIE parameter will retrieve RIE or non-RIE record */ public HydrotherapyVo getHydroTherapy(ClinicalContactRefVo voClinicalContact, Boolean modeRIE) { if (voClinicalContact == null) throw new RuntimeException("Cannot get Hidrotherapy record for null Clinical Contact"); StringBuffer query = new StringBuffer("from Hydrotherapy as hyd where hyd.clinicalContact.id = :CCID "); if (Boolean.TRUE.equals(modeRIE)) { query.append(" and hyd.isRIE = 1 order by hyd.systemInformation.creationDateTime desc"); } else { query.append(" and hyd.isRIE is null order by hyd.systemInformation.creationDateTime desc"); } return HydrotherapyVoAssembler.create((Hydrotherapy) getDomainFactory().findFirst(query.toString(), "CCID", voClinicalContact.getID_ClinicalContact())); }
public void saveHydroTherapy(HydrotherapyVo voHydrotherapy) throws StaleObjectException, UniqueKeyViolationException { if(!voHydrotherapy.isValidated()) throw new DomainRuntimeException("This HydroTherapy has not been validated"); //if a new Hydrotherapy record is created check if already exists a Hydrotherapy record for selected clinical contact in the database //must exist only one Hydrotherapy record per clinical contact if(voHydrotherapy.getID_Hydrotherapy() == null) { if(voHydrotherapy.getClinicalContactIsNotNull()) { HydrotherapyVo tempvo = getHydroTherapy(voHydrotherapy.getClinicalContact(), false); if(tempvo != null) throw new DomainRuntimeException("A Hydrotherapy record already exists for selected Clinical Contact."); } } DomainFactory factory = getDomainFactory(); Hydrotherapy doHydro = HydrotherapyVoAssembler.extractHydrotherapy(factory, voHydrotherapy); factory.save(doHydro); }
/** * WDEV-13587 * Get Hydrotherapy record */ public HydrotherapyVo getHydrotherapyById(HydrotherapyRefVo hydroRefVo) { if(hydroRefVo == null || hydroRefVo.getID_Hydrotherapy() == null) throw new DomainRuntimeException("Hydrotherapy ID not provided for get call. "); DomainFactory factory = getDomainFactory(); return HydrotherapyVoAssembler.create((Hydrotherapy) factory.getDomainObject(Hydrotherapy.class, hydroRefVo.getID_Hydrotherapy())); }