private ORDERSTATE getOcsOrderAuthorisingState() { if (doesOrderContainInvType(Category.CLINICALIMAGING)) { boolean canAuthoriseClinImaging = engine.hasRight(AppRight.CAN_AUTHORIZE_CLINICAL_IMAGING_ORDERS); if (!canAuthoriseClinImaging) return ORDERSTATE.REQUESTING_AUTHORISATION; } if (doesOrderContainInvType(Category.PATHOLOGY)) { boolean canAuthorisePathology = engine.hasRight(AppRight.CAN_AUTHORIZE_PATHOLOGY_ORDERS); if (!canAuthorisePathology) return ORDERSTATE.REQUESTING_AUTHORISATION; } return ORDERSTATE.AUTHORISING; }
private SpecimenWorkListItemVoCollection saveWorkListItems(DomainFactory factory, SpecimenWorkListItemVoCollection workListitems, HashMap objMap, ORDERSTATE state) throws StaleObjectException { if (workListitems == null) throw new CodingRuntimeException("No workListitems to save - method saveWorkListItems()"); List items = SpecimenWorkListItemVoAssembler.extractSpecimenWorkListItemList(factory, workListitems, null, objMap); Iterator it = items.iterator(); while (it.hasNext()) { SpecimenWorkListItem item = (SpecimenWorkListItem) it.next(); if(state.equals(ORDERSTATE.REQUESTING_AUTHORISATION)) item.setCollectionStatus(getDomLookup(ims.ocrr.vo.lookups.SpecimenCollectionStatus.AWAITING_AUTHORISATION)); factory.save(item); } workListitems = SpecimenWorkListItemVoAssembler.createSpecimenWorkListItemVoCollectionFromSpecimenWorkListItem(items); return workListitems; }
public void authoriseOrder(OcsOrderSessionRefVo voOcsOrderRef) throws StaleObjectException//WDEV-16232 { if(voOcsOrderRef == null) throw new CodingRuntimeException("Order ref is null"); DomainFactory factory = getDomainFactory(); OcsOrderSession doOcsOrder = (OcsOrderSession)factory.getDomainObject(voOcsOrderRef);//WDEV-16232 updateOrder(factory, doOcsOrder, ORDERSTATE.AUTHORISING); }
private void setDefaults(OrderInvestigation doOrderInv, ORDERSTATE state) { //WDEV-13409 - don't authorise individual cancelled investigations if they are part of a valid order if (state != null && state.equals(ORDERSTATE.AUTHORISING)) { if(doOrderInv.getOrdInvCurrentStatus() != null && doOrderInv.getOrdInvCurrentStatus().getOrdInvStatus() != null) { if(doOrderInv.getOrdInvCurrentStatus().getOrdInvStatus().equals(getDomLookup(OrderInvStatus.CANCEL_REQUEST)) || doOrderInv.getOrdInvCurrentStatus().getOrdInvStatus().equals(getDomLookup(OrderInvStatus.CANCELLED))) { return; } } } OrderedInvestigationStatus status = new OrderedInvestigationStatus(); if (this.getSession().getUser() != null) status.setChangeUser(this.getSession().getUser().getUserRealName()); status.setChangeDateTime(new java.util.Date()); status.setProcessedDateTime(new java.util.Date()); if(state.equals(ORDERSTATE.REQUESTING_AUTHORISATION)) { status.setOrdInvStatus(getDomLookup(OrderInvStatus.AWAITING_AUTHORISATION)); status.setStatusReason("Awaiting Authorisation"); } else if (state.equals(ORDERSTATE.AUTHORISING)) { status.setOrdInvStatus(getDomLookup(OrderInvStatus.ORDERED)); status.setStatusReason("Ordered"); } else if (state.equals(ORDERSTATE.CANCELLED)) { status.setOrdInvStatus(getDomLookup(OrderInvStatus.CANCELLED)); status.setStatusReason("Cancelled"); } doOrderInv.setOrdInvCurrentStatus(status); doOrderInv.getOrdInvStatusHistory().add(doOrderInv.getOrdInvCurrentStatus()); }
public void cancelOrder(OcsOrderSessionRefVo voOcsOrderRef) throws StaleObjectException//WDEV-16232 { if(voOcsOrderRef == null) throw new CodingRuntimeException("Order ref is null"); DomainFactory factory = getDomainFactory(); OcsOrderSession doOcsOrder = (OcsOrderSession) factory.getDomainObject(voOcsOrderRef);//WDEV-16232 updateOrder(factory, doOcsOrder, ORDERSTATE.CANCELLED); }
/** * //WDEV-13401 */ private void setOrderButtonText() { String text = ""; ORDERSTATE clinicalImagingState = ORDERSTATE.REQUESTING_AUTHORISATION; boolean canAuthoriseClinImaging = engine.hasRight(AppRight.CAN_AUTHORIZE_CLINICAL_IMAGING_ORDERS); if (canAuthoriseClinImaging == true) clinicalImagingState = ORDERSTATE.AUTHORISING; if (doesOrderContainInvType(Category.CLINICALIMAGING)) { if (clinicalImagingState.equals(ORDERSTATE.REQUESTING_AUTHORISATION)) text = "Request Clinical Imaging Investigation(s) "; else if (clinicalImagingState.equals(ORDERSTATE.AUTHORISING)) text = "Order Clinical Imaging Investigation(s) "; } ORDERSTATE pathState = ORDERSTATE.REQUESTING_AUTHORISATION; boolean canAuthorisePathology = engine.hasRight(AppRight.CAN_AUTHORIZE_PATHOLOGY_ORDERS); if (canAuthorisePathology == true) pathState = ORDERSTATE.AUTHORISING; if (doesOrderContainInvType(Category.PATHOLOGY)) { if (text != "") text += " / "; if (pathState.equals(ORDERSTATE.REQUESTING_AUTHORISATION)) text += "Request Pathology Investigation(s) "; else if (pathState.equals(ORDERSTATE.AUTHORISING)) text += "Order Pathology Investigation(s) "; } // WDEV-13684 if (text == null || text.length() == 0) { text = "Order Investigation(s)"; } form.btnOrder().setText(text); }
private void placeOrder() { ORDERSTATE state = getOcsOrderAuthorisingState(); OcsOrderVo voOcsOrder = form.getLocalContext().getOcsOrder(); populateOrderInstanceData(voOcsOrder); String[] arrErrors = voOcsOrder.validate(validateOcsOrder(voOcsOrder)); if (arrErrors != null) { engine.showErrors(arrErrors); form.getLocalContext().setClosedRounds(null); form.getLocalContext().setWorkListItems(null); return; } SpecimenWorkListItemVoCollection workListItems = form.getLocalContext().getWorkListItems(); try { voOcsOrder = domain.saveOcsOrder(voOcsOrder, workListItems, state, form.getGlobalContext().RefMan.getCatsReferral(), form.getGlobalContext().Rotherham.getAppointmentToLink()); // WDEV-13999 // CARE UK project functionality ONLY if (CARE_UK_UI_ORDER.equals(ConfigFlag.UI.ORDER_ENTRY_UI_TYPE.getValue()) && form.getGlobalContext().OCRR.getOrderInvestigationToAmendIsNotNull()) { // When amending an investigation the appointment linked to it might be: // - cancelled if the modality for the investigation was changed from the one in the investigation to amend // - or associated with the new investigation instead of the old one changeInvestigationAppointment(voOcsOrder, form.getGlobalContext().OCRR.getOrderInvestigationToAmend()); OrderInvestigationForStatusChangeVo investigationToAmendStatus = domain.getOrderInvestigation(form.getGlobalContext().OCRR.getOrderInvestigationToAmend()); // Create new status for investigation to amend OrderedInvestigationStatusVo newStatus = new OrderedInvestigationStatusVo(); newStatus.setOrdInvStatus(OrderInvStatus.AMENDED); newStatus.setChangeDateTime(new DateTime()); newStatus.setChangeUser(engine.getLoggedInUser().getUserRealName() != null ? engine.getLoggedInUser().getUserRealName() : engine.getLoggedInUser().getUsername()); newStatus.setStatusChangeReason(InvestigationStatusChangeReason.AMENDED); newStatus.setStatusReason(InvestigationStatusChangeReason.AMENDED.getText()); newStatus.setProcessedDateTime(new DateTime()); // Set status investigationToAmendStatus.setOrdInvCurrentStatus(newStatus); if (!investigationToAmendStatus.getOrdInvStatusHistoryIsNotNull()) { investigationToAmendStatus.setOrdInvStatusHistory(new OrderedInvestigationStatusVoCollection()); } investigationToAmendStatus.getOrdInvStatusHistory().add(newStatus); domain.updateInvestigationStatus(investigationToAmendStatus); } if ((ConfigFlag.UI.ORDER_ENTRY_UI_TYPE.getValue().equals("CARE_UK") || ConfigFlag.UI.ORDER_ENTRY_UI_TYPE.getValue().equals("UKSH")) && form.getGlobalContext().RefMan.getCatsReferralIsNotNull()) // WDEV-11881 { domain.updateCatsReferralAdditionalInvStatus(form.getGlobalContext().RefMan.getCatsReferral()); } } catch (StaleObjectException e) { if (form.getGlobalContext().RefMan.getCatsReferral() != null) form.getGlobalContext().RefMan.setCatsReferral(domain.getCatsReferralListVo(form.getGlobalContext().RefMan.getCatsReferral()));// wdev-12864 engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); engine.close(DialogResult.CANCEL); return; } processOrder(state, engine.hasRight(AppRight.CAN_AUTHORIZE_CLINICAL_IMAGING_ORDERS), engine.hasRight(AppRight.CAN_AUTHORIZE_PATHOLOGY_ORDERS), voOcsOrder); if (form.getGlobalContext().RefMan.getCatsReferral() != null) form.getGlobalContext().RefMan.setCatsReferral(domain.getCatsReferralListVo(form.getGlobalContext().RefMan.getCatsReferral()));// wdev-12864 }
/** * Remove OrderSpecimens from OrderInvestigation created in error for DFT * @param state */ private void clearOrderSpecimensFromOrderInvestigationsDFT(OcsOrderVo ocsOrder, ORDERSTATE state) { OrderSpecimenVoCollection specimens = new OrderSpecimenVoCollection(); OrderInvestigationRefVoCollection investigationsDFT = new OrderInvestigationRefVoCollection(); for (OrderInvestigationVo investigation : ocsOrder.getInvestigations()) { if (InvEventType.TIME_SERIES.equals(investigation.getInvestigation().getEventType())) { investigation.setSpecimen(null); investigationsDFT.add(investigation); // Do not change the status of Cancelled or Cancel Requests orders if (investigation.getOrdInvCurrentStatus() == null || (!OrderInvStatus.CANCEL_REQUEST.equals(investigation.getOrdInvCurrentStatus().getOrdInvStatus()) && !OrderInvStatus.CANCELLED.equals(investigation.getOrdInvCurrentStatus().getOrdInvStatus()))) { // Set status as requested if (ORDERSTATE.AUTHORISING.equals(state)) { investigation.getOrdInvCurrentStatus().setOrdInvStatus(OrderInvStatus.ORDERED); investigation.setDisplayFlag(OcsDisplayFlag.REQUESTED); } else { investigation.getOrdInvCurrentStatus().setOrdInvStatus(OrderInvStatus.AWAITING_AUTHORISATION); investigation.setDisplayFlag(OcsDisplayFlag.REQUESTED); } } } } for (OrderSpecimenVo specimen : ocsOrder.getSpecimens()) { OrderInvestigationRefVoCollection investigationNonDFT = getNonDFTInvestigation(specimen, investigationsDFT); if (investigationNonDFT != null && investigationNonDFT.size() > 0) { specimen.setInvestigations(investigationNonDFT); specimens.add(specimen); } } ocsOrder.setSpecimens(specimens); }
private void setDefaults(OcsOrderSession doOcsOrder, ORDERSTATE state) { if (doOcsOrder == null || state == null) throw new CodingRuntimeException("Coding Error - Order or state is null"); if(state.equals(ORDERSTATE.CANCELLED)) doOcsOrder.setAuthorisationOrderStatus( getDomLookup(AuthorisationOrderStatus.CANCELLED)); else if(state.equals(ORDERSTATE.REQUESTING_AUTHORISATION)) doOcsOrder.setAuthorisationOrderStatus( getDomLookup(AuthorisationOrderStatus.AWAITING_AUTHORISATION)); else if(state.equals(ORDERSTATE.AUTHORISING)) doOcsOrder.setAuthorisationOrderStatus( getDomLookup(AuthorisationOrderStatus.AUTHORISED)); //defaults Iterator it = doOcsOrder.getInvestigations().iterator(); while (it.hasNext()) { OrderInvestigation doOrderInv = (OrderInvestigation) it.next(); if (OrderInvStatus.CANCEL_REQUEST.getID() != doOrderInv.getOrdInvCurrentStatus().getOrdInvStatus().getId()) //WDEV-16998 { doOrderInv.getOrdInvStatusHistory().add(doOrderInv.getOrdInvCurrentStatus()); doOrderInv.setDisplayTimeSupplied(Boolean.FALSE); // WDEV-3602 doOrderInv.setResponsibleClinician(doOcsOrder.getResponsibleClinician()); doOrderInv.setResponsibleGp(doOcsOrder.getResponsibleGp()); doOrderInv.setPatientClinic(doOcsOrder.getPatientClinic()); doOrderInv.setPatientLocation(doOcsOrder.getPatientLocation()); // WDEV-18165 set ParentLocation dependent on current location if (doOrderInv.getPatientLocation() != null) doOrderInv.setParentLocation(doOrderInv.getPatientLocation().getParentLocation()); else if (doOrderInv.getPatientClinic() != null) doOrderInv.setParentLocation(doOrderInv.getPatientClinic().getClinicLocation()); // If the OrderInvestigation locations are not set, then its outpatient department // so get the parent location from there. if (doOrderInv.getParentLocation() == null && doOcsOrder.getOutpatientDept() != null) doOrderInv.setParentLocation(doOcsOrder.getOutpatientDept().getParentLocation()); } } // doOcsOrder.getSpecimens() //WDEV-7493 for (Object iterable_element : doOcsOrder.getSpecimens()) { OrderSpecimen spec = (OrderSpecimen) iterable_element; String token = "Do not use:" + (Double.valueOf(Math.random()*10000).toString().substring(0,4)); spec.setPlacerOrdNum(token); } //End WDEV-7493 }
private void setDefaults(OrderInvestigation doOrderInv, ORDERSTATE state) { //WDEV-13409 - don't authorise individual cancelled investigations if they are part of a valid order //WDEV-16993 - don't authorise individual investigations already authorised, having ORDERED status if (state != null && state.equals(ORDERSTATE.AUTHORISING)) { if(doOrderInv.getOrdInvCurrentStatus() != null && doOrderInv.getOrdInvCurrentStatus().getOrdInvStatus() != null) { if (getDomLookup(OrderInvStatus.CANCEL_REQUEST).equals(doOrderInv.getOrdInvCurrentStatus().getOrdInvStatus()) || getDomLookup(OrderInvStatus.CANCELLED).equals(doOrderInv.getOrdInvCurrentStatus().getOrdInvStatus()) || getDomLookup(OrderInvStatus.ORDERED).equals(doOrderInv.getOrdInvCurrentStatus().getOrdInvStatus())) { return; } } } OrderedInvestigationStatus status = new OrderedInvestigationStatus(); if (this.getSession().getUser() != null) status.setChangeUser(this.getSession().getUser().getUserRealName()); status.setChangeDateTime(new java.util.Date()); status.setProcessedDateTime(new java.util.Date()); if(state.equals(ORDERSTATE.REQUESTING_AUTHORISATION)) { status.setOrdInvStatus(getDomLookup(OrderInvStatus.AWAITING_AUTHORISATION)); status.setStatusReason("Awaiting Authorisation"); } else if (state.equals(ORDERSTATE.AUTHORISING)) { status.setOrdInvStatus(getDomLookup(OrderInvStatus.ORDERED)); status.setStatusReason("Ordered"); } else if (state.equals(ORDERSTATE.CANCELLED)) { status.setOrdInvStatus(getDomLookup(OrderInvStatus.CANCELLED)); status.setStatusReason("Cancelled"); } doOrderInv.setOrdInvCurrentStatus(status); doOrderInv.getOrdInvStatusHistory().add(doOrderInv.getOrdInvCurrentStatus()); }
private void placeOrder() { ORDERSTATE state = getOcsOrderAuthorisingState(); OcsOrderVo voOcsOrder = form.getLocalContext().getOcsOrder(); populateOrderInstanceData(voOcsOrder); String[] arrErrors = voOcsOrder.validate(validateOcsOrder(voOcsOrder)); if (arrErrors != null) { engine.showErrors(arrErrors); form.getLocalContext().setClosedRounds(null); form.getLocalContext().setWorkListItems(null); return; } SpecimenWorkListItemVoCollection workListItems = form.getLocalContext().getWorkListItems(); try { voOcsOrder = domain.saveOcsOrder(voOcsOrder, workListItems, state, form.getGlobalContext().CareUk.getCatsReferral(), form.getGlobalContext().Rotherham.getAppointmentToLink()); // WDEV-13999 // CARE UK project functionality ONLY if (CARE_UK_UI_ORDER.equals(ConfigFlag.UI.ORDER_ENTRY_UI_TYPE.getValue()) && form.getGlobalContext().OCRR.getOrderInvestigationToAmendIsNotNull()) { // When amending an investigation the appointment linked to it might be: // - cancelled if the modality for the investigation was changed from the one in the investigation to amend // - or associated with the new investigation instead of the old one changeInvestigationAppointment(voOcsOrder, form.getGlobalContext().OCRR.getOrderInvestigationToAmend()); OrderInvestigationForStatusChangeVo investigationToAmendStatus = domain.getOrderInvestigation(form.getGlobalContext().OCRR.getOrderInvestigationToAmend()); // Create new status for investigation to amend OrderedInvestigationStatusVo newStatus = new OrderedInvestigationStatusVo(); newStatus.setOrdInvStatus(OrderInvStatus.AMENDED); newStatus.setChangeDateTime(new DateTime()); newStatus.setChangeUser(engine.getLoggedInUser().getUserRealName() != null ? engine.getLoggedInUser().getUserRealName() : engine.getLoggedInUser().getUsername()); newStatus.setStatusChangeReason(InvestigationStatusChangeReason.AMENDED); newStatus.setStatusReason(InvestigationStatusChangeReason.AMENDED.getText()); newStatus.setProcessedDateTime(new DateTime()); // Set status investigationToAmendStatus.setOrdInvCurrentStatus(newStatus); if (!investigationToAmendStatus.getOrdInvStatusHistoryIsNotNull()) { investigationToAmendStatus.setOrdInvStatusHistory(new OrderedInvestigationStatusVoCollection()); } investigationToAmendStatus.getOrdInvStatusHistory().add(newStatus); domain.updateInvestigationStatus(investigationToAmendStatus); } if ((ConfigFlag.UI.ORDER_ENTRY_UI_TYPE.getValue().equals("CARE_UK") || ConfigFlag.UI.ORDER_ENTRY_UI_TYPE.getValue().equals("UKSH")) && form.getGlobalContext().CareUk.getCatsReferralIsNotNull()) // WDEV-11881 { domain.updateCatsReferralAdditionalInvStatus(form.getGlobalContext().CareUk.getCatsReferral()); } } catch (StaleObjectException e) { if (form.getGlobalContext().CareUk.getCatsReferral() != null) form.getGlobalContext().CareUk.setCatsReferral(domain.getCatsReferralListVo(form.getGlobalContext().CareUk.getCatsReferral()));// wdev-12864 engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); engine.close(DialogResult.CANCEL); return; } processOrder(state, engine.hasRight(AppRight.CAN_AUTHORIZE_CLINICAL_IMAGING_ORDERS), engine.hasRight(AppRight.CAN_AUTHORIZE_PATHOLOGY_ORDERS), voOcsOrder); if (form.getGlobalContext().CareUk.getCatsReferral() != null) form.getGlobalContext().CareUk.setCatsReferral(domain.getCatsReferralListVo(form.getGlobalContext().CareUk.getCatsReferral()));// wdev-12864 }