Esempio n. 1
0
        public OrderTO writeSimpleOrderByPolicy(string providerDUZ, string esig, string locationIEN, string orderIEN, string startDate)
        {
            OrderTO result = new OrderTO();

            if (!mySession.ConnectionSet.IsAuthorized)
            {
                result.fault = new FaultTO("Connections not ready for operation", "Need to login?");
            }
            else if (mySession.Patient == null)
            {
                result.fault = new FaultTO("No patient selected. Need to select patient first.");
            }
            else if (String.IsNullOrEmpty(providerDUZ) || string.IsNullOrEmpty(esig) ||
                     String.IsNullOrEmpty(locationIEN) || String.IsNullOrEmpty(startDate))
            {
                result.fault = new FaultTO("Failed to supply required parameters");
            }
            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                Order order = Order.writeSimpleOrderByPolicy(mySession.ConnectionSet.getConnection(mySession.ConnectionSet.BaseSiteId),
                                                             mySession.Patient, providerDUZ, esig, locationIEN, orderIEN,
                                                             gov.va.medora.utils.DateUtils.IsoDateStringToDateTime(startDate));
                return(new OrderTO(order));
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }
            return(result);
        }
Esempio n. 2
0
        public OrderTO discontinueAndSignRadiologyOrder(String patientId, String orderIen, String providerDuz, String locationIen, String reasonIen, String eSig)
        {
            OrderTO result       = new OrderTO();
            String  sessionCheck = MdwsUtils.isAuthorizedConnection(_mySession);

            if (!String.Equals(sessionCheck, "OK", StringComparison.CurrentCultureIgnoreCase))
            {
                result.fault = new FaultTO(sessionCheck);
            }

            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                Order mdo = new RadiologyApi().discontinueAndSignOrder(_mySession.ConnectionSet.BaseConnection, patientId, orderIen, providerDuz, locationIen, reasonIen, eSig);
                result = new OrderTO(mdo);
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }
            return(result);
        }
Esempio n. 3
0
        public void ReserveOrder(OrderBindingModel model)
        {
            using (var transaction = context.Database.BeginTransaction())
            {
                try
                {
                    var element = new Order
                    {
                        ClientId    = model.ClientId,
                        DateCreate  = DateTime.Now,
                        TotalSum    = model.TotalSum,
                        OrderStatus = OrderStatus.Зарезервирован
                    };

                    context.Orders.Add(element);
                    context.SaveChanges();

                    var groupTOs = model.OrderTOs
                                   .GroupBy(rec => rec.TOId)
                                   .Select(rec => new { TOId = rec.Key, Amount = rec.Sum(r => r.Amount) });

                    foreach (var groupTO in groupTOs)
                    {
                        var orderTO = new OrderTO
                        {
                            OrderId = element.Id,
                            TOId    = groupTO.TOId,
                            Amount  = groupTO.Amount
                        };

                        context.OrderTOs.Add(orderTO);

                        var _TODetails = context.TO_Details.Where(rec => rec.TOId == orderTO.TOId);

                        if (_TODetails.All(rec =>
                                           rec.Amount <= context.Details.FirstOrDefault(r => r.Id == rec.DetailId).Amount))
                        {
                            foreach (var _TODetail in _TODetails)
                            {
                                var detail = context.Details.FirstOrDefault(r => r.Id == _TODetail.DetailId);

                                detail.Amount  -= _TODetail.Amount;
                                detail.Reserve += _TODetail.Amount;
                            }
                        }
                        else
                        {
                            throw new Exception("Недостаточно деталей для резервации");
                        }

                        context.SaveChanges();
                    }
                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }
        }
Esempio n. 4
0
        public long setCreateOrder(OrderTO objOrder, ref int codError, ref string msjError)
        {
            List <OrderTO> objList = new List <OrderTO>();

            try
            {
                using (SqlConnection sql = new SqlConnection(ConnectionString))
                {
                    using (SqlCommand cmd = new SqlCommand("createOrder", sql))
                    {
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;

                        cmd.Parameters.Add("@idUser", SqlDbType.Int).Value     = objOrder.IdUser;
                        cmd.Parameters.Add("@idDelivery", SqlDbType.Int).Value = objOrder.IdDelivery;
                        sql.Open();
                        var ds = new DataSet();
                        var da = new SqlDataAdapter(cmd);

                        da.Fill(ds);

                        if (ds.Tables.Count == 1)
                        {
                            List <ResultTO> error = ds.Tables[0].AsEnumerable()
                                                    .Select(dataRow => new ResultTO
                            {
                                Result = dataRow.Field <int>("result"),
                                Msg    = dataRow.Field <string>("msg")
                            }).ToList();

                            codError = 1;
                            msjError = error.FirstOrDefault().Msg;
                            return(0);
                        }

                        List <ResultTO> results = ds.Tables[1].AsEnumerable()
                                                  .Select(dataRow => new ResultTO
                        {
                            Result = dataRow.Field <int>("result"),
                            Msg    = dataRow.Field <string>("msg")
                        }).ToList();

                        objList = ds.Tables[0].AsEnumerable()
                                  .Select(dataRow => new OrderTO
                        {
                            IdOrder = dataRow.Field <long>("idOrder")
                        }).ToList();
                    }
                }
                return(objList.FirstOrDefault().IdOrder);
            }
            catch (Exception e)
            {
                codError = 0;
                msjError = e.Message;
                return(0);
            }
        }
Esempio n. 5
0
        public IHttpActionResult setCreateOrder(OrderTO ordr)
        {
            int           codError    = 1;
            string        msjError    = "";
            OrderServices objServicio = new OrderServices();
            var           result      = objServicio.setCreateOrder(ordr, ref codError, ref msjError);

            if (codError == 1)
            {
                return(Ok(result));
            }
            return(BadRequest(msjError));
        }
Esempio n. 6
0
        public OrderTO saveNewRadiologyOrder(
            String patientId,
            String duz,
            String locationIEN,
            String dlgDisplayGroupId,
            String orderableItemIen,
            String urgencyCode,
            String modeCode,
            String classCode,
            String contractSharingIen,
            String submitTo,
            String pregnant,
            String isolation,
            String reasonForStudy,
            String clinicalHx,
            String startDateTime,
            String preOpDateTime,
            String modifierIds,
            String eSig,
            String orderCheckOverrideReason)
        {
            OrderTO result = new OrderTO();

            if ("OK" != MdwsUtils.isAuthorizedConnection(_mySession))
            {
                result.fault = new FaultTO("No connection - need to login?");
            }

            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                IList <String> modifierIdList = new List <String>();
                if (!String.IsNullOrEmpty(modifierIds))
                {
                    modifierIdList = new List <String>(StringUtils.split(modifierIds, StringUtils.STICK));
                }

                bool pregnantParsed = false;
                if (!String.IsNullOrEmpty(pregnant) && StringUtils.parseBool(pregnant))
                {
                    pregnantParsed = true;
                }
                bool isolationParsed = false;
                if (!String.IsNullOrEmpty(isolation) && StringUtils.parseBool(isolation))
                {
                    isolationParsed = true;
                }

                DateTime startDtParsed = DateUtils.IsoDateStringToDateTime(startDateTime);
                DateTime preOpDtParsed = DateUtils.IsoDateStringToDateTime(preOpDateTime);

                Order mdo = new RadiologyApi().saveNewOrder(_mySession.ConnectionSet.BaseConnection, patientId, duz, locationIEN, dlgDisplayGroupId, orderableItemIen,
                                                            urgencyCode, modeCode, classCode, contractSharingIen, submitTo, pregnantParsed, isolationParsed, reasonForStudy, clinicalHx, startDtParsed, preOpDtParsed, modifierIdList, eSig, orderCheckOverrideReason);

                result = new OrderTO(mdo);
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return(result);
        }