public InterventionsTreatmentsForAttendenceVo save( InterventionsTreatmentsForAttendenceVo record, Boolean addedDuringCoding) throws StaleObjectException { if (record == null) throw new CodingRuntimeException( "Cannot save a null InterventionsTreatmentsForAttendenceVo."); if (!record.isValidated()) throw new CodingRuntimeException("InterventionsTreatmentsForAttendenceVo is not validated."); DomainFactory factory = getDomainFactory(); InterventionsTreatmentsForAttendence doRecord = InterventionsTreatmentsForAttendenceVoAssembler.extractInterventionsTreatmentsForAttendence( factory, record); if (record.getID_InterventionsTreatmentsForAttendence() == null && record.getAttendance() != null) { InterventionsTreatmentsForAttendenceVo staleRecord = getInterventionsTreatmentsForAttendence(record.getAttendance()); if (staleRecord != null) throw new StaleObjectException(doRecord); } factory.save(doRecord); if (!Boolean.TRUE.equals(addedDuringCoding)) { AttendDiagInvTreatStatusVo attendDiagInvTreatStatus = getAttendDiagInvTreatStatus(record.getAttendance()); if (attendDiagInvTreatStatus != null && (Boolean.TRUE.equals(attendDiagInvTreatStatus.getNoTreatments()) || Boolean.TRUE.equals(attendDiagInvTreatStatus.getTreatmentsNotRecorded()))) { attendDiagInvTreatStatus.setNoTreatments(null); attendDiagInvTreatStatus.setTreatmentsNotRecorded(null); AttendDiagInvTreatStatus doAttendDiagInvTreatStatus = AttendDiagInvTreatStatusVoAssembler.extractAttendDiagInvTreatStatus( factory, attendDiagInvTreatStatus); factory.save(doAttendDiagInvTreatStatus); } } return InterventionsTreatmentsForAttendenceVoAssembler.create(doRecord); }