public TTAMedicationAndPharmacyVo getTTAMedicationAndPharmacy(CareContextRefVo careContextRefvo) { if(careContextRefvo == null) throw new CodingRuntimeException("CareContextRefVo is null"); DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" from TTAMedicationAndPharmacy tta where tta.careContext.id = :careContextId"); ArrayList<String> markers = new ArrayList<String>(); markers.add("careContextId"); ArrayList<Serializable> values = new ArrayList<Serializable>(); values.add(careContextRefvo.getID_CareContext()); List list = factory.find(hql.toString(), markers,values); if(list != null && list.size() > 0) { TTAMedicationAndPharmacyVoCollection voColl = TTAMedicationAndPharmacyVoAssembler.createTTAMedicationAndPharmacyVoCollectionFromTTAMedicationAndPharmacy(list); if(voColl != null && voColl.size() > 0) return voColl.get(0); } return null; }
@Override protected void onBtnSuspendedClick() throws PresentationLogicException { if (form.btnSuspended().getText().equals(SUSPENDED)) { engine.open(form.getForms().Clinical.EDischargePharmacyApprovalSuspendedDialog); } else if (form.btnSuspended().getText().equals(UNSUSPENDED)) //wdev-13848 { // Update the 'Last Updating Pharmacist' field // - will only be updated if the current user is a HCP updateLastUpdatingPharmacist(); TTAMedicationAndPharmacyVo currentRecord = form.getLocalContext().getEditedRecord(); TTAStatusVoCollection statusHistory = currentRecord.getTTAStatusHistory().sort(SortOrder.DESCENDING); TTAStatusVo newStatus = null; for (int i = 0; i < statusHistory.size(); i++) { if (statusHistory.get(i).equals(currentRecord.getCurrentTTAStatus())) continue; else { newStatus = statusHistory.get(i); updateStatus(newStatus.getStatus()); if (save()) { form.getLocalContext().setMedicationStatusToBeSet(EDischargeComponentStatus.EDITABLE); form.btnSuspended().setText(SUSPENDED); manageStatus(form.getLocalContext().getEditedRecord()); } break; } } } }
private void open() { setViewMode(); clearScreen(); TTAMedicationAndPharmacyVo currentRecord = domain.getTTAMedicationAndPharmacy(form.getGlobalContext().Core.getCurrentCareContext()); form.getLocalContext().setEditedRecord(currentRecord); populateScreenFromData(currentRecord); updateButtonsStatus(currentRecord != null ? true : false); updateContextMenuStatus(); manageStatus(currentRecord); }
private void populateScreenFromData(TTAMedicationAndPharmacyVo currentRecord) { if (currentRecord == null) return; if(form.getGlobalContext().Core.getCurrentCareContextIsNotNull()) form.dteEDD().setValue(form.getGlobalContext().Core.getCurrentCareContext().getEstimatedDischargeDate()); form.ccResponsablePharmacist().setValue(currentRecord.getResponsiblePharmacist()); //WDEV-13479 form.decBodyWeight().setValue(currentRecord.getBodyWeightKg()); form.txtClinicalCommentsToPharmacy().setValue(currentRecord.getClinicalCommentsToPharmacy()); form.ccOrderingClin().setValue(currentRecord.getOrderingClinician()); form.dtim1().setValue(currentRecord.getOrderingDateTime()); form.txt2().setValue(currentRecord.getClinicianBleepNo()); //TTA Status if (currentRecord.getCurrentTTAStatusIsNotNull()) { TTAStatusVo currentStatus = currentRecord.getCurrentTTAStatus(); form.getLocalContext().setCurrentStatus(currentStatus); form.txt1().setValue(currentStatus.getStatus().toString()); form.txtRejectionReason().setValue(currentStatus.getReasonForRejection()); } if (currentRecord.getTTAMedicationsIsNotNull() && currentRecord.getTTAMedications().size() > 0) { currentRecord.getTTAMedications().sort(SortOrder.DESCENDING); for (int i = 0; i < currentRecord.getTTAMedications().size(); i++) { addDynamicGridMedicationRow(currentRecord.getTTAMedications().get(i)); } } }
private void updateButtonsStatus(TTAMedicationAndPharmacyVo currentRecord) { form.btnNew().setVisible(currentRecord != null ? false : true); form.btnNew().setEnabled(form.getLocalContext().getIsHcpIsNotNull() && form.getLocalContext().getIsHcp());//WDEV-13536 form.btnEdit().setVisible(currentRecord != null ? true : false); form.btnEdit().setEnabled(Boolean.TRUE.equals(form.getLocalContext().getIsHcp())); // WDEV-13536 updateSubmitTTAButtonStatus(currentRecord); updateStatusHistoryStatus(currentRecord); }
private void open() { setViewMode(); clearScreen(); TTAMedicationAndPharmacyVo currentRecord = domain.getTTAMedicationAndPharmacy(form.getGlobalContext().Core.getCurrentCareContext()); form.getLocalContext().setEditedRecord(currentRecord); populateScreenFromData(currentRecord); updateButtonsStatus(currentRecord); updateContextMenuStatus(); manageStatus(currentRecord); updateStatus(currentRecord!=null&¤tRecord.getCurrentTTAStatus()!=null?currentRecord.getCurrentTTAStatus().getStatus():null); }
@Override protected void onBtnApproveClick() throws PresentationLogicException { form.getContextMenus().Clinical.hideAllEDischargeMedsSthkMenuMenuItems(); form.getContextMenus().Clinical.getEDischargeMedsSthkMenuViewItem().setVisible((form.getMode().equals(FormMode.VIEW) ? true: false) && form.dyngrdMedication().getSelectedRow() != null ? true : false); if (form.btnApprove().getText().equals(APPROVE)) { if (form.dyngrdMedication().getRows().size() == 0) { form.getLocalContext().setPharmApproveConfirmMsgBoxId(engine.showMessage("The medication grid doesn't contain any records!\nAre you sure you want to approve?", "Please confirm", MessageButtons.YESNO, MessageIcon.QUESTION)); return; } // Update the 'Last Updating Pharmacist' field // - will only be updated if the current user is a HCP updateLastUpdatingPharmacist(); doApprove(); } else if (form.btnApprove().getText().equals(UNAPPROVE)) { TTAMedicationAndPharmacyVo currentRecord = form.getLocalContext().getEditedRecord(); TTAStatusVoCollection statusHistory = currentRecord.getTTAStatusHistory().sort(SortOrder.DESCENDING); TTAStatusVo newStatus = null; for (int i = 0; i < statusHistory.size(); i++) { if (statusHistory.get(i).equals(currentRecord.getCurrentTTAStatus())) { continue; } else { if (statusHistory.get(i).getStatus().equals(TTAStatus.SUBMITTED) || statusHistory.get(i).getStatus().equals(TTAStatus.RESUBMITTED)) { newStatus = statusHistory.get(i); updateStatus(newStatus.getStatus()); // Update the 'Last Updating Pharmacist' field // - will only be updated if the current user is a HCP updateLastUpdatingPharmacist(); if (save()) { form.btnApprove().setText(APPROVE); manageStatus(form.getLocalContext().getEditedRecord()); } break; } } } } }
protected void onContextMenuItemClick(int menuItemID, Control sender) throws PresentationLogicException { switch (menuItemID) { case GenForm.ContextMenus.ClinicalNamespace.EDischargeMedsSthkMenu.New: { form.getGlobalContext().Clinical.setEDischargeMeds(null); engine.open(form.getForms().Clinical.EDischargeMedsSthkDialog, new Object[]{EDischargeMedsContextMenu.NEW, new Boolean(true)}); } break; case GenForm.ContextMenus.ClinicalNamespace.EDischargeMedsSthkMenu.Edit: { form.getGlobalContext().Clinical.setEDischargeMeds(form.getLocalContext().getEditedMedicalRecord()); engine.open(form.getForms().Clinical.EDischargeMedsSthkDialog, new Object[]{EDischargeMedsContextMenu.EDIT, new Boolean(true)}); } break; case GenForm.ContextMenus.ClinicalNamespace.EDischargeMedsSthkMenu.Remove: { TTAMedicationAndPharmacyVo currentRecord = form.getLocalContext().getEditedRecord(); if(currentRecord != null && currentRecord.getTTAMedicationsIsNotNull()) { TTAMedicationDetailVoCollection medColl = currentRecord.getTTAMedications(); medColl.remove((TTAMedicationDetailVo)form.dyngrdMedication().getSelectedRow().getValue()); currentRecord.setTTAMedications(medColl); form.getLocalContext().setEditedRecord(currentRecord); } form.dyngrdMedication().getRows().remove(form.dyngrdMedication().getSelectedRow()); // Update the 'Last Updating Pharmacist' field // - will only be updated if the current user is a HCP updateLastUpdatingPharmacist(); updateContextMenuStatus(); } break; case GenForm.ContextMenus.ClinicalNamespace.EDischargeMedsSthkMenu.View: { form.getGlobalContext().Clinical.setEDischargeMeds(form.getLocalContext().getEditedMedicalRecord()); engine.open(form.getForms().Clinical.EDischargeMedsSthkDialog, new Object[]{EDischargeMedsContextMenu.EDIT, new Boolean(true), FormMode.VIEW}); } break; } }
private void updateStatusHistoryStatus(TTAMedicationAndPharmacyVo currentRecord) { form.btnStatusHistory().setEnabled(currentRecord != null && currentRecord.getTTAStatusHistoryIsNotNull() && currentRecord.getTTAStatusHistory().size() > 0); }
private void updateSubmitTTAButtonStatus(TTAMedicationAndPharmacyVo currentRecord) { form.btnSubmitTTA().setEnabled(currentRecord != null && currentRecord.getTTAMedicationsIsNotNull() && currentRecord.getTTAMedications().size() > 0 && form.getLocalContext().getIsHcpIsNotNull() && form.getLocalContext().getIsHcp());//WDEV-13536 }
private void manageStatus(TTAMedicationAndPharmacyVo currentRecord) { if (currentRecord != null) { if (currentRecord.getCurrentTTAStatusIsNotNull()) { //TTAStatus = Draft : users can edit TTA tab if (currentRecord.getCurrentTTAStatus().getStatus().equals(TTAStatus.DRAFT)) { if (currentRecord.getTTAStatusHistoryIsNotNull()) { boolean found = false; for (int i = 0; i < currentRecord.getTTAStatusHistory().size(); i++) { if (currentRecord.getTTAStatusHistory().get(i).getStatusIsNotNull() && (currentRecord.getTTAStatusHistory().get(i).getStatus().equals(TTAStatus.DRAFT) || currentRecord.getTTAStatusHistory().get(i).getStatus().equals(TTAStatus.NOT_REQUIRED))) { continue; } else { found = true; form.getLocalContext().setPharmacyStatusToBeSet(EDischargeComponentStatus.READONLY); form.fireCustomControlValueChanged(); break; } } if (!found) { form.getLocalContext().setPharmacyStatusToBeSet(EDischargeComponentStatus.HIDDEN); } } else form.getLocalContext().setPharmacyStatusToBeSet(EDischargeComponentStatus.HIDDEN); } //TTAStatus = Rejected : users can edit TTA tab else if (currentRecord.getCurrentTTAStatus().getStatus().equals(TTAStatus.REJECTED)) { form.btnEdit().setVisible(true); form.btnEdit().setEnabled(form.getLocalContext().getIsHcpIsNotNull() && form.getLocalContext().getIsHcp());//wdev-13536 form.btnSubmitTTA().setEnabled(currentRecord != null && currentRecord.getTTAMedicationsIsNotNull() && currentRecord.getTTAMedications().size() > 0 && form.getLocalContext().getIsHcpIsNotNull() && form.getLocalContext().getIsHcp());//WDEV-12730, wdev-13536 form.getLocalContext().setPharmacyStatusToBeSet(EDischargeComponentStatus.READONLY); } else if (currentRecord.getCurrentTTAStatus().getStatus().equals(TTAStatus.NOT_REQUIRED)) { form.btnEdit().setVisible(true); form.btnEdit().setEnabled(form.getLocalContext().getIsHcpIsNotNull() && form.getLocalContext().getIsHcp());//wdev-13536 form.btnSubmitTTA().setEnabled(false); form.getContextMenus().Clinical.getEDischargeMedsSthkMenuViewPreviousItem().setVisible(false);//WDEV-11849 form.getContextMenus().Clinical.getEDischargeMedsSthkMenuNewItem().setVisible(false); form.getContextMenus().Clinical.getEDischargeMedsSthkMenuEditItem().setVisible(false); form.getContextMenus().Clinical.getEDischargeMedsSthkMenuRemoveItem().setVisible(false); form.getContextMenus().Clinical.getEDischargeMedsSthkMenuViewItem().setVisible(form.grdOrderDischMedication().getSelectedRow() != null ? true : false); form.getLocalContext().setPharmacyStatusToBeSet(EDischargeComponentStatus.HIDDEN); } else { form.btnEdit().setVisible(false); form.btnSubmitTTA().setEnabled(false); form.getLocalContext().setPharmacyStatusToBeSet(EDischargeComponentStatus.EDITABLE); } } else { form.getLocalContext().setPharmacyStatusToBeSet(EDischargeComponentStatus.HIDDEN); } } else { form.getLocalContext().setPharmacyStatusToBeSet(EDischargeComponentStatus.HIDDEN); } form.fireCustomControlValueChanged(); }
private String[] validateUI(TTAMedicationAndPharmacyVo currentRecord) { ArrayList<String> errors = new ArrayList<String>(); if (form.Group1().getValue().equals(Group1Enumeration.None)) { errors.add("TTA Required is mandatory!"); } else { if(currentRecord != null && currentRecord.getCurrentTTAStatusIsNotNull()) { TTAStatusVo tta = currentRecord.getCurrentTTAStatus(); if (!tta.getStatus().equals(TTAStatus.NOT_REQUIRED)) { if (form.ccOrderingClinician().getValue() == null) { errors.add("Ordering Clinician is mandatory"); } if (form.dtimOrderingDateTime().getValue() == null) { errors.add("Ordering DateTime is mandatory"); } else { if (form.dtimOrderingDateTime().getValue().isGreaterThan(new DateTime())) { errors.add("Ordering DateTime can not be in the future"); } } if (form.txtClinicianBleepNo().getValue() == null) { errors.add("Clinician Bleep No. is mandatory"); } //WDEV-11849 - Start for (int i = 0 ; currentRecord.getTTAMedicationsIsNotNull() && i < currentRecord.getTTAMedications().size(); i++) { TTAMedicationDetailVo detail = currentRecord.getTTAMedications().get(i); if (detail != null) { Float dose = detail.getDoseValue(); MedicationDoseUnit doseUnit = detail.getDoseUnit(); String unitText = detail.getUnitText(); DoseFormIndicator formm = detail.getForm(); MedicationRoute route = detail.getRoute(); //WDEV-11894Integer frequency = detail.getFrequencyValue(); MedicationFrequency frequencyUnit = detail.getFrequencyUnit(); //WDEV-11894Integer duration = detail.getDurationValue(); //WDEV-11894MedicationDuration durationUnit = detail.getDurationUnit(); String clinicianComments = detail.getClinicalCommentsForPharmacy(); if ((dose == null || (doseUnit == null && unitText==null) || formm == null || route == null || frequencyUnit == null ) && clinicianComments == null)//WDEV-11894 { errors.add("Medication: "+(i+1)+" If Dose, Form, Route or Frequency are empty, Additional Prescribing Instructions field become mandatory");//WDEV-11894 } } } //WDEV-11849 - End } } } if (errors.size() > 0) { String[] searchErrors = new String[errors.size()]; errors.toArray(searchErrors); engine.showErrors("Invalid TTA Medication Record", searchErrors); return searchErrors; } return null; }
private void populateScreenFromData(TTAMedicationAndPharmacyVo currentRecord) { if (currentRecord == null) return; if(currentRecord.getCurrentTTAStatusIsNotNull()) { TTAStatusVo tta = currentRecord.getCurrentTTAStatus(); if (tta.getStatus().equals(TTAStatus.NOT_REQUIRED)) form.Group1().setValue(Group1Enumeration.rdoTTAREquiredNo); else form.Group1().setValue(Group1Enumeration.rdoTTARequiredYes); } form.decBodyW().setValue(currentRecord.getBodyWeightKg()); form.ccOrderingClinician().setValue(currentRecord.getOrderingClinician()); form.dtimOrderingDateTime().setValue(currentRecord.getOrderingDateTime()); form.txtClinicianBleepNo().setValue(currentRecord.getClinicianBleepNo()); form.txtClinicialCOmmentsToPharmacy().setValue(currentRecord.getClinicalCommentsToPharmacy()); //TTA Status if (currentRecord.getCurrentTTAStatusIsNotNull()) { TTAStatusVo currentStatus = currentRecord.getCurrentTTAStatus(); form.txtTTAStatus().setValue(currentStatus.getStatus().toString()); if(currentRecord.getCurrentTTAStatus().getStatus().equals(TTAStatus.REJECTED)) { form.txtRejectionReason().setValue(currentStatus.getReasonForRejection()); } } if (currentRecord.getTTAMedicationsIsNotNull() && currentRecord.getTTAMedications().size() > 0) { currentRecord.getTTAMedications().sort(SortOrder.DESCENDING); for (int i = 0; i < currentRecord.getTTAMedications().size(); i++) { addGrdOrderDischMedicationRow(currentRecord.getTTAMedications().get(i)); } } }
@Override protected void onContextMenuItemClick(int menuItemID, Control sender) throws PresentationLogicException { switch (menuItemID) { case GenForm.ContextMenus.ClinicalNamespace.EDischargeMedsSthkMenu.New: { form.getGlobalContext().Clinical.setEDischargeMeds(null); engine.open(form.getForms().Clinical.EDischargeMedsSthkDialog, new Object[]{EDischargeMedsContextMenu.NEW, new Boolean(false), FormMode.EDIT}); } break; case GenForm.ContextMenus.ClinicalNamespace.EDischargeMedsSthkMenu.Edit: { form.getGlobalContext().Clinical.setEDischargeMeds(form.getLocalContext().getEditedMedicalRecord()); engine.open(form.getForms().Clinical.EDischargeMedsSthkDialog, new Object[]{EDischargeMedsContextMenu.EDIT, new Boolean(false), FormMode.EDIT}); } break; case GenForm.ContextMenus.ClinicalNamespace.EDischargeMedsSthkMenu.Remove: { TTAMedicationAndPharmacyVo currentRecord = form.getLocalContext().getEditedRecord(); if(currentRecord != null && currentRecord.getTTAMedicationsIsNotNull()) { TTAMedicationDetailVoCollection medColl = currentRecord.getTTAMedications(); medColl.remove(form.grdOrderDischMedication().getSelectedRow().getValue()); currentRecord.setTTAMedications(medColl); form.getLocalContext().setEditedRecord(currentRecord); } form.grdOrderDischMedication().getRows().remove(form.grdOrderDischMedication().getSelectedRowIndex()); updateContextMenuStatus(); } break; case GenForm.ContextMenus.ClinicalNamespace.EDischargeMedsSthkMenu.View: { form.getGlobalContext().Clinical.setEDischargeMeds(form.getLocalContext().getEditedMedicalRecord()); engine.open(form.getForms().Clinical.EDischargeMedsSthkDialog, new Object[]{EDischargeMedsContextMenu.EDIT, new Boolean(false), FormMode.VIEW}); } break; case GenForm.ContextMenus.ClinicalNamespace.EDischargeMedsSthkMenu.ViewPrevious://WDEV-11849 { engine.open(form.getForms().Clinical.TTAHistoryDialog,new Object[]{form.getLocalContext().getEditedRecord()});//WDEV-11849 } break; } }
private String[] validateUI(TTAMedicationAndPharmacyVo currentRecord) { ArrayList<String> errors = new ArrayList<String>(); if (form.Group1().getValue().equals(Group1Enumeration.None)) { errors.add("TTA Required is mandatory!"); } else { if(currentRecord != null && currentRecord.getCurrentTTAStatusIsNotNull()) { TTAStatusVo tta = currentRecord.getCurrentTTAStatus(); if (!tta.getStatus().equals(TTAStatus.NOT_REQUIRED)) { if (form.ccOrderingClinician().getValue() == null) { errors.add("Ordering Clinician is mandatory"); } if (form.dtimOrderingDateTime().getValue() == null) { errors.add("Ordering DateTime is mandatory"); } else { if (form.dtimOrderingDateTime().getValue().isGreaterThan(new DateTime())) { errors.add("Ordering Date Time cannot be set to a date in the future."); //WDEV-18762 } } if (form.txtClinicianBleepNo().getValue() == null) { errors.add("Clinician Bleep No. is mandatory"); } //WDEV-11849 - Start for (int i = 0 ; currentRecord.getTTAMedicationsIsNotNull() && i < currentRecord.getTTAMedications().size(); i++) { TTAMedicationDetailVo detail = currentRecord.getTTAMedications().get(i); if (detail != null) { Float dose = detail.getDoseValue(); MedicationDoseUnit doseUnit = detail.getDoseUnit(); String unitText = detail.getUnitText(); DoseFormIndicator formm = detail.getForm(); MedicationRoute route = detail.getRoute(); //WDEV-11894Integer frequency = detail.getFrequencyValue(); MedicationFrequency frequencyUnit = detail.getFrequencyUnit(); //WDEV-11894Integer duration = detail.getDurationValue(); //WDEV-11894MedicationDuration durationUnit = detail.getDurationUnit(); String clinicianComments = detail.getClinicalCommentsForPharmacy(); if ((dose == null || (doseUnit == null && unitText==null) || formm == null || route == null || frequencyUnit == null ) && clinicianComments == null)//WDEV-11894 { errors.add("Medication: "+(i+1)+" If Dose, Form, Route or Frequency are empty, Additional Prescribing Instructions field become mandatory");//WDEV-11894 } } } //WDEV-11849 - End } } } if (errors.size() > 0) { String[] searchErrors = new String[errors.size()]; errors.toArray(searchErrors); engine.showErrors("Invalid TTA Medication Record", searchErrors); return searchErrors; } return null; }