private MDTMeetingVo getLatest(MDTMeetingVo mdtMeeting) { // This is supposed to work only for edit if (mdtMeeting == null || mdtMeeting.getID_MDTMeeting() == null) return null; StringBuilder query = new StringBuilder(); ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); query.append("SELECT mdtMeeting FROM MDTMeeting AS mdtMeeting WHERE mdtMeeting.id <> :MEETING_ID AND mdtMeeting.careContext.id = :CARE_CONTEXT AND "); query.append(" (mdtMeeting.mDTMeetingDate > :MEETING_DATE "); query.append(" OR (mdtMeeting.mDTMeetingDate = :MEETING_DATE AND mdtMeeting.systemInformation.creationDateTime > :CREATION_DATE)) "); query.append(" ORDER BY mdtMeeting.mDTMeetingDate DESC"); paramNames.add("MEETING_ID"); paramValues.add(mdtMeeting.getID_MDTMeeting()); paramNames.add("CARE_CONTEXT"); paramValues.add(mdtMeeting.getCareContext().getID_CareContext()); paramNames.add("MEETING_DATE"); paramValues.add(mdtMeeting.getMDTMeetingDate().getDate()); paramNames.add("CREATION_DATE"); paramValues.add(mdtMeeting.getSystemInformation().getCreationDateTime().getJavaDate()); return MDTMeetingVoAssembler.create((MDTMeeting) getDomainFactory().findFirst(query.toString(), paramNames.toArray(new String[paramNames.size()]), paramValues.toArray())); }
public MDTMeetingVo getMDTMeeting(MDTMeetingRefVo mdtMeeting) { if (mdtMeeting == null || mdtMeeting.getID_MDTMeeting() == null) return null; return MDTMeetingVoAssembler.create((MDTMeeting) getDomainFactory().getDomainObject(MDTMeeting.class, mdtMeeting.getID_MDTMeeting())); }
public MDTMeetingVo save(MDTMeetingVo mdtMeeting, MDTListAndDatesVo mdtList) throws StaleObjectException { if (!mdtMeeting.isValidated()) throw new DomainRuntimeException("MDT Meeting has not beed validated."); if (!mdtList.isValidated()) throw new DomainRuntimeException("MDT List has not been validate."); DomainFactory factory = getDomainFactory(); MDTMeeting domMDTMeeting = MDTMeetingVoAssembler.extractMDTMeeting(factory, mdtMeeting); // Check mdtMeeting to be the latest (if it was already saved) if (mdtMeeting.getID_MDTMeeting() != null) { MDTMeetingVo latest = getLatest(mdtMeeting); if (latest != null) { mdtList.setListPatientisOn(latest.getListPatientisOn()); mdtList.setKeyDates(new KeyDatesVoCollection()); for (KeyDatesVo keyDate : latest.getKeyDates()) { KeyDatesVo date = new KeyDatesVo(); date.setDate(keyDate.getDate()); date.setDateType(keyDate.getDateType()); mdtList.getKeyDates().add(date); } } } MDTListandDates domMDTList = MDTListAndDatesVoAssembler.extractMDTListandDates(factory, mdtList); factory.save(domMDTMeeting); factory.save(domMDTList); return MDTMeetingVoAssembler.create(domMDTMeeting); }
public MDTMeetingVo save(MDTMeetingVo mdtMeeting) throws StaleObjectException { if (!mdtMeeting.isValidated()) throw new DomainRuntimeException("MDT Meeting has not beed validated."); DomainFactory factory = getDomainFactory(); MDTMeeting domMDTMeeting = MDTMeetingVoAssembler.extractMDTMeeting(factory, mdtMeeting); factory.save(domMDTMeeting); return MDTMeetingVoAssembler.create(domMDTMeeting); }