コード例 #1
0
        public ServiceResponseData IsDrugStore()
        {
            List <IPD_OrderRecord> records    = requestData.GetData <List <IPD_OrderRecord> >(0);
            List <IPD_OrderRecord> errRecords = new List <IPD_OrderRecord>();
            DrugStoreManagement    drugStore  = NewObject <DrugStoreManagement>();

            foreach (IPD_OrderRecord record in records)
            {
                if (record.ItemType == 1)
                {
                    if (drugStore.GetStorage(record.ItemID, record.ExecDeptID) < record.Amount * record.UnitNO)
                    {
                        errRecords.Add(record);
                    }
                }
            }

            responseData.AddData(errRecords);
            return(responseData);
        }
コード例 #2
0
        /// <summary>
        /// 处方保存
        /// </summary>
        /// <param name="curPalist">病人对象</param>
        /// <param name="prescriptions">处方对象</param>
        /// <param name="feeHeadCount">费用头ID</param>
        /// <param name="operatorid">操作员ID</param>
        public void SavePrescription(OP_PatList curPalist, List <Prescription> prescriptions, List <int> feeHeadCount, int operatorid)
        {
            try
            {
                DrugStoreManagement drugManager = NewObject <DrugStoreManagement>();
                DateTime            presdate    = DateTime.Now;
                for (int i = 0; i < feeHeadCount.Count; i++)
                {
                    int groupid = feeHeadCount[i];
                    List <Prescription> presModifyDetails = prescriptions.Where(p => p.PrescGroupID == groupid && p.SubTotalFlag == 0 && p.ModifyFlag == 1).ToList();
                    if (presModifyDetails.Count == 0)
                    {
                        continue;
                    }

                    List <Prescription> presDetails = prescriptions.Where(p => p.PrescGroupID == groupid && p.SubTotalFlag == 0).ToList();
                    if (presDetails.Count > 0)
                    {
                        OP_FeeItemHead feeitemHead = new OP_FeeItemHead();

                        //OP_FeeItemHead赋值
                        SetFeeHeadValue(feeitemHead, presDetails[0], curPalist);
                        feeitemHead.ChargeEmpID = operatorid;
                        decimal roundingMoney = 0;
                        feeitemHead.TotalFee    = NewObject <PrescMoneyCalculate>().GetPrescriptionTotalMoney(presDetails, out roundingMoney);
                        feeitemHead.RoungingFee = roundingMoney;
                        if (feeitemHead.DocPresHeadID > 0)
                        {
                            feeitemHead.PresDate = presDetails[0].DocPresDate;
                        }
                        else
                        {
                            feeitemHead.PresDate = presdate;
                        }

                        feeitemHead.RegFlag = 0;
                        if (feeitemHead.FeeItemHeadID == 0)
                        {
                            feeitemHead.FeeNo = DateTime.Now.Ticks;// Convert.ToDecimal( DateTime.Now.ToString("yyyyMMddHHmmssffff"));// GetTimeStamp();//生成费用流水号
                        }

                        if (Convert.ToInt32(presDetails[0].ItemType) == (int)OP_Enum.ItemType.药品)
                        {
                            if (presDetails[0].StatID == 100)
                            {
                                feeitemHead.PresType = "1";//西药处方
                            }
                            else if (presDetails[0].StatID == 101)
                            {
                                feeitemHead.PresType = "2";//中成药处方
                            }
                            else if (presDetails[0].StatID == 102)
                            {
                                feeitemHead.PresType = "3";//中草药处方
                            }
                        }
                        else
                        {
                            feeitemHead.PresType = "0";//非药品处方
                        }

                        this.BindDb(feeitemHead);
                        feeitemHead.save();

                        for (int j = 0; j < prescriptions.Count; j++)
                        {
                            if (prescriptions[j].PrescGroupID == groupid && prescriptions[j].SubTotalFlag == 0)
                            {
                                OP_FeeItemDetail feeDetail = new OP_FeeItemDetail();

                                //OP_FeeItemDetail赋值
                                SetFeeDetailValue(feeDetail, prescriptions[j], curPalist);
                                if (feeDetail.Amount == 0)
                                {
                                    throw new Exception("【" + feeDetail.ItemName + "】数量为零,请输入一个大于零的数");
                                }

                                if (Convert.ToInt32(feeDetail.ItemType) == (int)ItemType.药品 && prescriptions[j].Selected == 1)
                                {
                                    //判断实时库存
                                    decimal storAmount = drugManager.GetStorage(feeDetail.ItemID, feeitemHead.ExecDeptID);
                                    if (storAmount < feeDetail.Amount)
                                    {
                                        throw new Exception("【" + feeDetail.ItemName + "】库存不足,请重新输入");
                                    }
                                }

                                feeDetail.FeeItemHeadID = feeitemHead.FeeItemHeadID;
                                this.BindDb(feeDetail);
                                feeDetail.save();
                                prescriptions[j].FeeItemHeadID = feeitemHead.FeeItemHeadID;
                                prescriptions[j].PresDetailID  = feeDetail.PresDetailID;
                                prescriptions[j].FeeNo         = feeitemHead.FeeNo;
                                prescriptions[j].ModifyFlag    = 0;
                            }
                        }

                        this.BindDb(curPalist);
                        curPalist.save();
                    }
                }
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
            }
        }