Ejemplo n.º 1
0
        public Task <int> SubmitForm(OrdersExecLogEntity entity, string keyValue)
        {
            var claimsIdentity = _httpContext.HttpContext.User.Identity as ClaimsIdentity;

            claimsIdentity.CheckArgumentIsNull(nameof(claimsIdentity));
            var claim = claimsIdentity?.FindFirst(t => t.Type == ClaimTypes.NameIdentifier);

            if (!string.IsNullOrEmpty(keyValue))
            {
                entity.Modify(keyValue);
                entity.F_LastModifyUserId = claim?.Value;
                return(_service.UpdateAsync(entity));
            }
            else
            {
                entity.Create();
                entity.F_CreatorUserId = claim?.Value;
                return(_service.InsertAsync(entity));
            }
        }
Ejemplo n.º 2
0
        public async Task ExecOrder(string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                var list = new List <OrdersExecLogEntity>();
                var user = await _usersService.GetCurrentUserAsync();

                //var claimsIdentity = _httpContext.HttpContext.User.Identity as ClaimsIdentity;
                //claimsIdentity.CheckArgumentIsNull(nameof(claimsIdentity));
                //var claim = claimsIdentity?.FindFirst(t => t.Type == ClaimTypes.Name));
                foreach (var item in keyValue.ToJArrayObject())
                {
                    string   id = string.Empty;
                    DateTime date;
                    try
                    {
                        id = item.Value <string>("id");
                        if (!DateTime.TryParse(item.Value <string>("date"), out date))
                        {
                            date = DateTime.Now;
                        }
                    }
                    catch
                    {
                        return;
                    }
                    var order = await _service.FindEntityAsync(id);

                    if (order == null)
                    {
                        return;
                    }
                    order.F_NurseOperatorTime = date;
                    order.F_Nurse             = user.F_RealName;//
                    await UpdateForm(order);

                    //claim = claimsIdentity?.FindFirst(t => t.Type == ClaimTypes.NameIdentifier));
                    //添加执行日志
                    var logEntity = new OrdersExecLogEntity
                    {
                        F_Oid                 = order.F_Id,
                        F_Pid                 = order.F_Pid,
                        F_VisitDate           = order.F_VisitDate,
                        F_VisitNo             = order.F_VisitNo,
                        F_OrderType           = order.F_OrderType,
                        F_OrderStartTime      = order.F_OrderStartTime,
                        F_OrderStopTime       = order.F_OrderStopTime,
                        F_OrderCode           = order.F_OrderCode,
                        F_OrderText           = order.F_OrderText,
                        F_OrderSpec           = order.F_OrderSpec,
                        F_OrderUnitAmount     = order.F_OrderUnitAmount,
                        F_OrderUnitSpec       = order.F_OrderUnitSpec,
                        F_OrderAmount         = order.F_OrderAmount,
                        F_OrderFrequency      = order.F_OrderFrequency,
                        F_OrderAdministration = order.F_OrderAdministration,
                        F_IsTemporary         = order.F_IsTemporary,
                        F_Doctor              = order.F_Doctor,
                        F_DoctorOrderTime     = order.F_DoctorOrderTime,
                        F_DoctorAuditTime     = order.F_DoctorAuditTime,
                        F_Nurse               = order.F_Nurse,
                        F_NurseId             = user.F_Id,
                        F_NurseOperatorTime   = order.F_NurseOperatorTime,
                        F_Memo                = order.F_Memo
                    };
                    logEntity.Create();
                    logEntity.F_CreatorUserId = user.F_Id;
                    list.Add(logEntity);
                }
                if (list.Count > 0)
                {
                    await _execService.InsertAsync(list);
                }
            }

            return;
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ExecOrder([FromBody] ExecOrderInput input)
        {
            //await _ordersApp.ExecOrder(keyValue);
            //计费
            //var jArr = keyValue.ToJArrayObject();

            //if (jArr.Count == 0)
            //{
            //    return BadRequest("未选择医嘱");
            //}

            var c = (from r in input.items
                     join o in await _ordersApp.GetList() on r.id equals o.F_Id
                     select new
            {
                o.F_Nurse,
                o.F_NurseOperatorTime,
                o.F_OrderAdministration,
                o.F_OrderAmount,
                o.F_OrderCode,
                o.F_OrderFrequency,
                o.F_OrderSpec,
                o.F_OrderText,
                o.F_OrderType,
                o.F_OrderUnitAmount,
                o.F_OrderUnitSpec,
                o.F_Pid
            }).ToList();

            var patient = await _patientApp.GetForm(c.FirstOrDefault()?.F_Pid);

            var user = await _usersService.GetCurrentUserAsync();

            var date  = DateTime.Now;
            var drugs = (from r in c
                         where r.F_OrderType == "药疗"
                         select r).ToList();

            if (drugs.Count > 0)
            {
                //DrugsApp drugsApp = new DrugsApp();
                //StorageApp storageApp = new StorageApp();
                foreach (var item in drugs)
                {
                    //var sl = item.F_OrderAmount.ToFloat(2) * 100  / item.F_OrderUnitAmount.ToFloat(2) * 100;
                    //int i = (int)sl;
                    var fz    = (item.F_OrderAmount.ToFloat(4) * 10000).ToInt();
                    var fm    = (item.F_OrderUnitAmount.ToFloat(4) * 10000).ToInt();
                    int count = fz % fm == 0 ? fz / fm : fz / fm + 1;  //非整数倍  数量追加1
                    var dict  = await _drugsApp.GetForm(item.F_OrderCode);

                    //计费
                    await _billingApp.SubmitForm(new BillingEntity
                    {
                        F_Amount          = count,
                        F_BillingDateTime = date,
                        F_BillingPerson   = user.F_RealName,
                        F_BillingPersonId = user.F_Id,
                        F_Charges         = dict.F_Charges,
                        F_Costs           = (dict.F_Charges * count).ToFloat(2),
                        F_DialylisNo      = patient.F_DialysisNo,
                        F_Pid             = patient.F_Id,
                        F_PGender         = patient.F_Gender,
                        F_PName           = patient.F_Name,
                        F_ItemClass       = "药品",
                        F_ItemCode        = dict.F_DrugCode,
                        F_ItemId          = dict.F_Id,
                        F_ItemName        = dict.F_DrugName,
                        F_ItemSpec        = dict.F_DrugSpec,
                        F_ItemSpell       = dict.F_DrugSpell,
                        F_ItemUnit        = dict.F_DrugUnit,
                        F_Supplier        = dict.F_DrugSupplier,
                        F_EnabledMark     = true,
                        F_IsAcct          = false
                    }, new object());

                    //减库存
                    var storage = await _storageApp.GetFormByItemId(item.F_OrderCode);

                    if (storage != null)
                    {
                        storage.F_Amount -= count;
                        await _storageApp.UpdateForm(storage);
                    }
                }
            }

            var treatments = (from r in c
                              where r.F_OrderType == "治疗"
                              select r).ToList();

            if (treatments.Count > 0)
            {
                //TreatmentApp treatmentApp = new TreatmentApp();
                foreach (var item in treatments)
                {
                    var dict = await _treatmentApp.GetForm(item.F_OrderCode);

                    var amount = item.F_OrderAmount.ToFloat(2);
                    //计费
                    await _billingApp.SubmitForm(new BillingEntity
                    {
                        F_Amount          = amount,
                        F_BillingDateTime = date,
                        F_BillingPerson   = user.F_RealName,
                        F_BillingPersonId = user.F_Id,
                        F_Charges         = dict.F_Charges,
                        F_Costs           = (dict.F_Charges *amount).ToFloat(2),
                        F_DialylisNo      = patient.F_DialysisNo,
                        F_Pid             = patient.F_Id,
                        F_PGender         = patient.F_Gender,
                        F_PName           = patient.F_Name,
                        F_ItemClass       = "诊疗",
                        F_ItemCode        = dict.F_TreatmentCode,
                        F_ItemId          = dict.F_Id,
                        F_ItemName        = dict.F_TreatmentName,
                        F_ItemSpec        = dict.F_TreatmentSpec,
                        F_ItemSpell       = dict.F_TreatmentSpell,
                        F_ItemUnit        = dict.F_TreatmentUnit,
                        F_EnabledMark     = true,
                        F_IsAcct          = false
                    }, new object());
                }
            }

            //添加执行历史记录
            foreach (var item in input.items)
            {
                var order = await _ordersApp.GetForm(item.id);

                if (order == null)
                {
                    continue;
                }
                order.F_NurseOperatorTime = item.operateTime?.ToDate() ?? DateTime.Now;
                order.F_Nurse             = user.F_RealName;//
                await _ordersApp.UpdateForm(order);

                //claim = claimsIdentity?.FindFirst(t => t.Type == ClaimTypes.NameIdentifier));
                //添加执行日志
                var logEntity = new OrdersExecLogEntity
                {
                    F_Oid                 = order.F_Id,
                    F_Pid                 = order.F_Pid,
                    F_VisitDate           = order.F_VisitDate,
                    F_VisitNo             = order.F_VisitNo,
                    F_OrderType           = order.F_OrderType,
                    F_OrderStartTime      = order.F_OrderStartTime,
                    F_OrderStopTime       = order.F_OrderStopTime,
                    F_OrderCode           = order.F_OrderCode,
                    F_OrderText           = order.F_OrderText,
                    F_OrderSpec           = order.F_OrderSpec,
                    F_OrderUnitAmount     = order.F_OrderUnitAmount,
                    F_OrderUnitSpec       = order.F_OrderUnitSpec,
                    F_OrderAmount         = order.F_OrderAmount,
                    F_OrderFrequency      = order.F_OrderFrequency,
                    F_OrderAdministration = order.F_OrderAdministration,
                    F_IsTemporary         = order.F_IsTemporary,
                    F_Doctor              = order.F_Doctor,
                    F_DoctorOrderTime     = order.F_DoctorOrderTime,
                    F_DoctorAuditTime     = order.F_DoctorAuditTime,
                    F_Nurse               = order.F_Nurse,
                    F_NurseId             = user.F_Id,
                    F_NurseOperatorTime   = order.F_NurseOperatorTime,
                    F_Memo                = order.F_Memo
                };
                logEntity.Create();
                logEntity.F_CreatorUserId = user.F_Id;
                await _ordersExecLogApp.InsertForm(logEntity);
            }

            return(Ok("执行成功"));
        }