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 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); }
public ims.emergency.vo.DischargeServicesAndAdviceForDischargePlanningVo getDischargeServiceAndAdvice(ims.core.admin.vo.CareContextRefVo careContext) { if (careContext == null || careContext.getID_CareContext() == null) return null; StringBuilder query = new StringBuilder(); query.append("SELECT discharge FROM DischargeServicesAndAdvice AS discharge LEFT JOIN discharge.attendance AS context "); query.append("WHERE context.id = ").append(careContext.getID_CareContext()); return DischargeServicesAndAdviceForDischargePlanningVoAssembler.create((DischargeServicesAndAdvice) getDomainFactory().findFirst(query.toString())); }