public ims.emergency.vo.DischargeServicesAndAdviceForDischargePlanningVo save(ims.emergency.vo.DischargeServicesAndAdviceForDischargePlanningVo dischargeServices, InterventionsTreatmentForAdviceLeafletVo intervention) throws ims.domain.exceptions.StaleObjectException { // Check parameter if( dischargeServices == null) throw new CodingRuntimeException("Can not save null record"); // Check for validation if( !dischargeServices.isValidated()) throw new CodingRuntimeException("Can not save record not validated"); DomainFactory factory = getDomainFactory(); // Check for a previously saved record if( dischargeServices.getID_DischargeServicesAndAdvice() == null) { StringBuilder query = new StringBuilder(); query.append("SELECT COUNT(discharge) FROM DischargeServicesAndAdvice AS discharge LEFT JOIN discharge.attendance AS context WHERE context.id = :CONTEXT"); long count = getDomainFactory().countWithHQL(query.toString(), new String[] {"CONTEXT"}, new Object[] {dischargeServices.getAttendance().getID_CareContext()}); if (count > 0) throw new StaleObjectException(null); } // Commit to database DischargeServicesAndAdvice domainRecord = DischargeServicesAndAdviceForDischargePlanningVoAssembler.extractDischargeServicesAndAdvice(factory, dischargeServices); factory.save(domainRecord); //wdev-17075 if( intervention != null ) { InterventionsTreatmentsForAttendence doInterventionsTreatmentsForAttendence = InterventionsTreatmentForAdviceLeafletVoAssembler.extractInterventionsTreatmentsForAttendence(factory, intervention); factory.save(doInterventionsTreatmentsForAttendence); } //----------- // Return saved object return DischargeServicesAndAdviceForDischargePlanningVoAssembler.create(domainRecord); }
public InterventionsTreatmentForAdviceLeafletVo getInterventionsTreatmentsForAttendence(CareContextRefVo careContextRef) { if( careContextRef == null) throw new CodingRuntimeException("CareContextRefVo is null."); DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(); hql.append("select i1_1 from InterventionsTreatmentsForAttendence as i1_1 left join i1_1.attendance as c1_1 where (c1_1.id = :carecontextId) order by i1_1.systemInformation.creationDateTime desc"); List<?> list = factory.find(hql.toString(), new String[] {"carecontextId"}, new Object[] {careContextRef.getID_CareContext()}); if( list != null && list.size() > 0 ) return InterventionsTreatmentForAdviceLeafletVoAssembler.createInterventionsTreatmentForAdviceLeafletVoCollectionFromInterventionsTreatmentsForAttendence(list).get(0); return null; }
public ims.emergency.vo.DischargeServicesAndAdviceForDischargePlanningVo save(ims.emergency.vo.DischargeServicesAndAdviceForDischargePlanningVo dischargeServices, InterventionsTreatmentForAdviceLeafletVo intervention, EmergencyAttendanceForDischargeLetterVo emergencyAttendance) throws ims.domain.exceptions.StaleObjectException //WDEV-19375 { // Check parameter if( dischargeServices == null) throw new CodingRuntimeException("Can not save null record"); // Check for validation if( !dischargeServices.isValidated()) throw new CodingRuntimeException("Can not save record not validated"); DomainFactory factory = getDomainFactory(); if (emergencyAttendance != null) //WDEV-20437 { //WDEV-19375 EmergencyAttendance domainEmergencyAttendance = EmergencyAttendanceForDischargeLetterVoAssembler.extractEmergencyAttendance(factory, emergencyAttendance); factory.save(domainEmergencyAttendance); } //WDEV-19917 MAXIMS_10.1.2.0 Tracking doTracking = getTrackingForAttendance(emergencyAttendance); if (doTracking != null) { doTracking.setSupplementaryLetterStatus(getDomLookup(DischargeLetterStatus.IN_PROGRESS)); factory.save(doTracking); } //WDEV-19917 - end // Check for a previously saved record if( dischargeServices.getID_DischargeServicesAndAdvice() == null) { StringBuilder query = new StringBuilder(); query.append("SELECT COUNT(discharge) FROM DischargeServicesAndAdvice AS discharge LEFT JOIN discharge.attendance AS context WHERE context.id = :CONTEXT"); long count = getDomainFactory().countWithHQL(query.toString(), new String[] {"CONTEXT"}, new Object[] {dischargeServices.getAttendance().getID_CareContext()}); if (count > 0) throw new StaleObjectException(null); } // Commit to database DischargeServicesAndAdvice domainRecord = DischargeServicesAndAdviceForDischargePlanningVoAssembler.extractDischargeServicesAndAdvice(factory, dischargeServices); factory.save(domainRecord); //wdev-17075 if( intervention != null ) { InterventionsTreatmentsForAttendence doInterventionsTreatmentsForAttendence = InterventionsTreatmentForAdviceLeafletVoAssembler.extractInterventionsTreatmentsForAttendence(factory, intervention); factory.save(doInterventionsTreatmentsForAttendence); } //----------- // Return saved object return DischargeServicesAndAdviceForDischargePlanningVoAssembler.create(domainRecord); }