private void populateChildCollectionFromGrid(ComplementaryTherapyTreatmentVo voComplementaryTherapy) { if (form.gridTherapy().getValue() == null) return; if (voComplementaryTherapy.getComplementaryTherapy() == null) voComplementaryTherapy.setComplementaryTherapy(new ComplementaryTherapyDetailsVoCollection()); GenForm.gridTherapyRow parentRow = form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentShortVo || form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentVo ? form.gridTherapy().getSelectedRow() : form.gridTherapy().getSelectedRow().getParentRow(); if (parentRow.getRows().size() > 0 ) voComplementaryTherapy.getComplementaryTherapy().clear(); for (int i=0; i < parentRow.getRows().size(); i++) { voComplementaryTherapy.getComplementaryTherapy().add((ComplementaryTherapyDetailsVo) parentRow.getRows().get(i).getValue()); } }
private void expandParentNode(gridTherapyRow selectedRow) { if (selectedRow.getValue() instanceof ComplementaryTherapyTreatmentShortVo == false ) return; form.getLocalContext().setSelectedParentInstance(getParentFromDomain((ComplementaryTherapyTreatmentShortVo) selectedRow.getValue())); if (form.getLocalContext().getSelectedParentInstance() == null ) return; ComplementaryTherapyTreatmentVo voParentInstance = form.getLocalContext().getSelectedParentInstance(); if(voParentInstance.getClinicalContact().getID_ClinicalContact().equals (form.getGlobalContext().Core.getCurrentClinicalContact().getID_ClinicalContact())) { // If this is the Golden Node then we'll colour it golden (ok then beige). form.getLocalContext().setGoldenInstanceFound(new Boolean(true)); form.getLocalContext().setGoldenInstanceSelected(new Boolean(true)); selectedRow.setBackColor(Color.Beige); } if (voParentInstance.getComplementaryTherapy() != null) { selectedRow.setValue(voParentInstance); selectedRow.setExpanded(true); populateChildNodes(selectedRow, voParentInstance.getComplementaryTherapy()); } populateParentInstanceControls(voParentInstance); }
private void populateParentInstanceControls(ComplementaryTherapyTreatmentVo voComplementaryParent) { if(voComplementaryParent != null) { form.ctnTherapy().lyrTherapy().tabHeader().dtimAuthoringDateTime().setValue(voComplementaryParent.getAuthoringDateTime()); if(voComplementaryParent.getAuthoringCPIsNotNull()) form.ctnTherapy().lyrTherapy().tabHeader().qmbAuthoringCP().newRow(voComplementaryParent.getAuthoringCP(), voComplementaryParent.getAuthoringCP().toString()); form.ctnTherapy().lyrTherapy().tabHeader().qmbAuthoringCP().setValue(voComplementaryParent.getAuthoringCP()); } }
private void getSelectedInstance() { //In update mode we can select nodes without displaying anything but the context // menus can change based on what's selected so we need to update them if (form.getMode().equals(FormMode.EDIT)) { updateContextMenusState(); return; } if(form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentVo) { populateParentInstanceControls((ComplementaryTherapyTreatmentVo) form.gridTherapy().getValue()); } else if(form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentShortVo) { form.getLocalContext().setSelectedParentInstance(getParentFromDomain((ComplementaryTherapyTreatmentShortVo) form.gridTherapy().getValue())); populateParentInstanceControls(form.getLocalContext().getSelectedParentInstance()); populateChildNodes(form.gridTherapy().getSelectedRow(),form.getLocalContext().getSelectedParentInstance().getComplementaryTherapy()); form.getLocalContext().setSelectedChildInstance(null); clearChildInstanceControls(); } else if(form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo) { GenForm.gridTherapyRow parentRow = form.gridTherapy().getSelectedRow().getParentRow(); populateParentInstanceControls((ComplementaryTherapyTreatmentVo) parentRow.getValue()); form.getLocalContext().setSelectedParentInstance((ComplementaryTherapyTreatmentVo) parentRow.getValue()); form.getLocalContext().setSelectedChildInstance((ComplementaryTherapyDetailsVo) form.gridTherapy().getValue()); populateChildInstanceControls(form.getLocalContext().getSelectedChildInstance()); } if(form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull()) form.getLocalContext().setGoldenInstanceSelected(new Boolean(form.getLocalContext().getSelectedParentInstance().getClinicalContact().getID_ClinicalContact().equals(form.getGlobalContext().Core.getCurrentClinicalContact().getID_ClinicalContact()))); updateControlsState(); }
private void showHeaderOrDetailsTab() { if (form.getMode().equals(FormMode.VIEW)) { // In view mode just show the selected node if (form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentShortVo) form.ctnTherapy().lyrTherapy().showtabHeader(); else if(form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentVo) form.ctnTherapy().lyrTherapy().showtabHeader(); else if (form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo) form.ctnTherapy().lyrTherapy().showtabDetails(); enableParentControls(false); } else { if (form.getLocalContext().getUpdatingParent().equals(Boolean.TRUE)) form.ctnTherapy().lyrTherapy().showtabHeader(); else form.ctnTherapy().lyrTherapy().showtabDetails(); if (form.getLocalContext().getSelectedParentInstanceIsNotNull() && (form.getLocalContext().getSelectedParentInstance().getID_ComplementaryTherapyTreatmentIsNotNull())) enableParentControls(false); //on update else enableParentControls(true); //new record } }
private boolean newParentNode(ComplementaryTherapyTreatmentVo voNewParent) { if (voNewParent == null) return true; ComplementaryTherapyTreatmentShortVo voParentShort = new ComplementaryTherapyTreatmentShortVo(); voParentShort.setAuthoringCP(form.ctnTherapy().lyrTherapy().tabHeader().qmbAuthoringCP().getValue()); voParentShort.setAuthoringDateTime(form.ctnTherapy().lyrTherapy().tabHeader().dtimAuthoringDateTime().getValue()); voParentShort.setClinicalContact(voNewParent.getClinicalContact()); String[] errors = voParentShort.validate(); if(errors != null && errors.length > 0) { engine.showErrors(errors); return false; } GenForm.gridTherapyRow parentRow = form.gridTherapy().getRows().newRow(); parentRow.setColComplementary(voParentShort.getAuthoringDateTime().toString()+ " - " + voParentShort.getAuthoringCP().toString()); parentRow.setValue(voParentShort); parentRow.setBackColor(Color.Beige); form.getLocalContext().setGoldenInstanceSelected(new Boolean(true)); parentRow.setExpanded(true); form.gridTherapy().setValue(voParentShort); return true; }
private void newParentInstance() { ComplementaryTherapyTreatmentVo voNewParent = new ComplementaryTherapyTreatmentVo(); Hcp voHcp = (Hcp) domain.getHcpUser(); if(voHcp != null) voNewParent.setAuthoringCP(voHcp); voNewParent.setAuthoringDateTime(new DateTime()); voNewParent.setClinicalContact(form.getGlobalContext().Core.getCurrentClinicalContact()); voNewParent.setComplementaryTherapy(new ComplementaryTherapyDetailsVoCollection()); populateParentInstanceControls(voNewParent); form.getLocalContext().setSelectedParentInstance(voNewParent); }
public ComplementaryTherapyTreatmentVo save(ComplementaryTherapyTreatmentVo voComplementaryTherapyTreat) throws StaleObjectException, UniqueKeyViolationException { if(!voComplementaryTherapyTreat.isValidated()) throw new DomainRuntimeException("This Complementary Therapy Treatment has not been validated"); if (voComplementaryTherapyTreat.getID_ComplementaryTherapyTreatment() == null && getComplementaryTherapyByClinicalContact(voComplementaryTherapyTreat.getClinicalContact()) != null) throw new UniqueKeyViolationException("The screen will be refreshed."); DomainFactory factory = getDomainFactory(); ComplementaryTherapyTreatment doComplementary = ComplementaryTherapyTreatmentVoAssembler.extractComplementaryTherapyTreatment(factory, voComplementaryTherapyTreat); factory.save(doComplementary); return ComplementaryTherapyTreatmentVoAssembler.create(doComplementary); }
private ComplementaryTherapyTreatmentVo getComplementaryTherapyByClinicalContact(ClinicalContactRefVo voClinicalContactRef) { if (voClinicalContactRef == null) throw new RuntimeException("Cannot get Complementary Therapy for null Clinical Contact"); StringBuffer query = new StringBuffer("from ComplementaryTherapyTreatment ctt where ctt.clinicalContact.id = :CCID and ctt.isRIE is null"); return ComplementaryTherapyTreatmentVoAssembler.create((ComplementaryTherapyTreatment) getDomainFactory().findFirst(query.toString(), "CCID", voClinicalContactRef.getID_ClinicalContact())); }
/** * WDEV-13581 * Function used to retrieve the Complementary Therapy Treatment record by ID */ public ComplementaryTherapyTreatmentVo getComplementaryTherapy(ComplementaryTherapyTreatmentRefVo complementaryTherapy) { // For null parameter or not saved record return null if (complementaryTherapy == null || !complementaryTherapy.getID_ComplementaryTherapyTreatmentIsNotNull()) return null; return ComplementaryTherapyTreatmentVoAssembler.create((ComplementaryTherapyTreatment) getDomainFactory().getDomainObject(ComplementaryTherapyTreatment.class, complementaryTherapy.getID_ComplementaryTherapyTreatment())); }