public string discontinueMed(string orderIen, string duz, string reasonIen) { if (String.IsNullOrEmpty(orderIen)) { return "No order ID"; } if (String.IsNullOrEmpty(duz)) { return "No user ID"; } if (String.IsNullOrEmpty(reasonIen)) { return "No reason ID"; } VistaUserDao userDao = new VistaUserDao(cxn); if (!userDao.hasPermission(duz, new SecurityKey("", "PROVIDER"))) { return "User does not have PROVIDER key"; } VistaOrdersDao orderDao = new VistaOrdersDao(cxn); Order order = orderDao.getOrder(orderIen); if (order == null) { return "No such order"; } string msg = orderDao.validateOrderActionNature(orderIen, "DC", duz, ""); if (msg != "OK") { return msg; } msg = orderDao.getComplexOrderMsg(orderIen); if (msg != "") { return msg; } if (!orderDao.lockOrdersForPatient(cxn.Pid)) { return "Unable to lock orders for patient"; } msg = orderDao.lockOrder(orderIen); if (msg != "OK") { orderDao.unlockOrdersForPatient(); return msg; } // discontinue the order // unlock ? return null; }
internal void releaseOrders(String duz, String locIen, String esig, Order[] orders) { IUserDao userDao = new VistaUserDao(cxn); if (!userDao.hasPermission(duz, new SecurityKey("","PERMISSION"))) { throw new Exception("Order is not being made for a provider"); } if (!lockOrdersForPatient()) { throw new Exception("Unable to lock patient's orders"); } for (int i = 0; i < orders.Length; i++) { string ien = orders[i].Id; string rtn = getComplexOrderMsg(ien); orders[i].ErrMsg = ""; if (rtn != "") { orders[i].ErrMsg = "Complex order message: " + rtn; continue; } rtn = lockOrder(ien); if (rtn != "OK") { orders[i].ErrMsg = "Unable to lock order: " + rtn; continue; } rtn = checkReleaseOrder(orders[i]); if (rtn != "") { orders[i].ErrMsg = "Release order error: " + rtn; continue; } // rtn = validateOrderActionNature(ien); // if (!rtn.equals("OK")) // { // orders[i].setErrMsg("Unable to validate order: " + rtn); // continue; // } } sendOrders(duz, locIen, esig, orders); for (int i = 0; i < orders.Length; i++) { if (!unlockOrder(orders[i].Id)) { orders[i].ErrMsg = "Unable to unlock order"; continue; } } unlockOrdersForPatient(); }