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())); }
/** * * @return */ private boolean save() { try { // Populate 'MDT Meeting' record with data from screen MDTMeetingVo mdtMeeting = populateDataFromInstanceControls(form.getLocalContext().getCurrentMDTMeeting()); // Validate records to save and apply UI validation rules String[] errors = mdtMeeting.validate(form.getLocalContext().getMDTListAndDates().validate(validateUIRules())); if (errors != null && errors.length > 0) { errors = cleanUpErrors(errors, "Date is mandatory"); engine.showErrors(errors); return false; } // If a new MDT Meeting record is created or the latest one is saved // then update the MDT List record if (form.getLocalContext().getLatestMDTMeeting() == null || form.getLocalContext().getLatestMDTMeeting().equals(mdtMeeting) || (mdtMeeting.getID_MDTMeeting() == null && mdtMeeting.getMDTMeetingDate() != null && mdtMeeting.getMDTMeetingDate().isGreaterOrEqualThan(form.getLocalContext().getLatestMDTMeeting().getMDTMeetingDate())) ) { form.getLocalContext().setCurrentMDTMeeting(domain.save(mdtMeeting, form.getLocalContext().getMDTListAndDates())); } else { // Attempt to save form.getLocalContext().setCurrentMDTMeeting(domain.save(mdtMeeting)); } return true; } // Treat any exceptions that might arise catch (StaleObjectException e) { engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); e.printStackTrace(); open(); return false; } }
/** * Function used to populate a MDT Meeting instance to controls * @param mdtMeeting */ private void populateInstanceControlsFromData(MDTMeetingVo mdtMeeting) { // Clear instance controls clearInstanceControls(); // Check parameter if (mdtMeeting == null) return; // Populate 'Meeting Date' control form.dteMDTMeetingDate().setValue(mdtMeeting.getMDTMeetingDate()); // Populate MDT List if (mdtMeeting.getListPatientisOn() != null) { form.cmbListMDT().setValue(mdtMeeting.getListPatientisOn()); if (form.cmbListMDT().getValue() == null) { form.cmbListMDT().newRow(mdtMeeting.getListPatientisOn(), mdtMeeting.getListPatientisOn().getText()); form.cmbListMDT().setValue(mdtMeeting.getListPatientisOn()); } } // Populate Key Dates if (mdtMeeting.getKeyDates() != null) { for (KeyDatesVo keyDate : mdtMeeting.getKeyDates()) { if (KeyDateType.NEXTGOALPLANDATE.equals(keyDate.getDateType())) { form.pdtNextGoalPlanDate().setValue(keyDate.getDate()); } if (KeyDateType.PROPOSEDDISCHARGEDATE.equals(keyDate.getDateType())) { form.pdtProposedDischargedDate().setValue(keyDate.getDate()); } } } // Populate 'MDT Meeting Notes' to notes grid for (MDTNotesVo note : mdtMeeting.getMeetingNotes()) { grdNotesSummaryRow noteRow = form.grdNotesSummary().getRows().newRow(); noteRow.setColArea(note.getArea().getText()); replaceSingleLineBreaks(note);//WDEV-17379 noteRow.setColNotes(note.getNotes()); noteRow.setValue(note); } }
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); }
/** * Function used to populate a MDT Meeting instance to controls * @param mdtMeeting */ private void populateInstanceControlsFromData(MDTMeetingVo mdtMeeting) { // Clear instance controls clearInstanceControls(); // Check parameter if (mdtMeeting == null) return; // Populate 'Meeting Date' control form.dteMDTMeetingDate().setValue(mdtMeeting.getMDTMeetingDate()); // Populate MDT List if (mdtMeeting.getListPatientisOn() != null) { form.cmbListMDT().setValue(mdtMeeting.getListPatientisOn()); if (form.cmbListMDT().getValue() == null) { form.cmbListMDT().newRow(mdtMeeting.getListPatientisOn(), mdtMeeting.getListPatientisOn().getText()); form.cmbListMDT().setValue(mdtMeeting.getListPatientisOn()); } } // Populate Key Dates if (mdtMeeting.getKeyDates() != null) { for (KeyDatesVo keyDate : mdtMeeting.getKeyDates()) { if (KeyDateType.NEXTGOALPLANDATE.equals(keyDate.getDateType())) { form.pdtNextGoalPlanDate().setValue(keyDate.getDate()); } if (KeyDateType.PROPOSEDDISCHARGEDATE.equals(keyDate.getDateType())) { form.pdtProposedDischargedDate().setValue(keyDate.getDate()); } } } // Populate 'MDT Meeting Notes' to notes grid for (MDTNotesVo note : mdtMeeting.getMeetingNotes()) { grdNotesSummaryRow noteRow = form.grdNotesSummary().getRows().newRow(); noteRow.setColArea(note.getArea().getText()); replaceSingleLineBreaks(note);//WDEV-17379 if(note.getNotes() != null) noteRow.setColNotes(replaceImsRichText(note.getNotes().toString())); //WDEV-19893 noteRow.setValue(note); } }
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); }