public void SaveExam(EXA_MedicalApplyHead head, DataTable dt)
        {
            try
            {
                if (frmMedicalApplys.SaveItemData != null && frmMedicalApplys.SaveItemData.Rows.Count > 0)
                {
                    //不能取当前登录科室ID
                    head.ApplyDeptID   = DeptId;// LoginUserInfo.DeptId;
                    head.SystemType    = SystemType;
                    head.PatListID     = PatListID;
                    head.MemberID      = MemberID;
                    head.ApplyDoctorID = LoginUserInfo.EmpId;
                    var retdata = InvokeWcfService(
                        "OPProject.Service",
                        "MedicalApplyController",
                        "SaveExam",
                        (request) =>
                    {
                        request.AddData(head);
                        request.AddData(LoginUserInfo.WorkId);
                        request.AddData(frmMedicalApplys.SaveItemData);
                        if (dt != null)
                        {
                            request.AddData(dt);
                        }
                        else
                        {
                            request.AddData(new DataTable());
                        }
                    });
                    var result = retdata.GetData <int>(0);
                    if (result > 0)
                    {
                        MessageBoxShowSimple("提交成功");
                        switch (SystemType)
                        {
                        case 0:
                            InvokeController("OPProject.UI", "PresManageController", "GetApplyHead", SystemType);
                            break;

                        case 1:
                            InvokeController("IPProject.UI", "OrderManagerController", "GetApplyHead", SystemType);
                            break;
                        }

                        if (string.IsNullOrEmpty(frmMedicalApplys.ApplyHeadID))
                        {
                            frmMedicalApplys.ApplyHeadID = result.ToString();
                        }

                        GetHeadDetail();
                    }
                    else if (result == -1)
                    {
                        MessageBoxEx.Show(retdata.GetData <string>(1));
                    }
                }
                else
                {
                    MessageBoxEx.Show("请至少添加一个项目");
                }
            }
            catch (Exception e)
            {
                MessageBoxEx.Show(e.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 保存医技申请
        /// </summary>
        /// <param name="head">申请头实体</param>
        /// <param name="itemData">项目数据</param>
        /// <param name="dt">明细数据</param>
        /// <returns>申请头id</returns>
        public int SaveMedicalApply(EXA_MedicalApplyHead head, DataTable itemData, DataTable dt)
        {
            DataRow dr = null;

            head.Remark = GetItemName(itemData);
            DeleteData(itemData, dt);
            if (dt != null)
            {
                head.ApplyHeadID = Convert.ToInt32(dt.Rows[0]["ApplyHeadID"].ToString());
            }

            this.BindDb(head);
            head.save();
            int          headid   = head.ApplyHeadID;
            OPD_PresHead presHead = new OPD_PresHead();

            if (head.SystemType == 0)
            {
                if (dt != null)
                {
                    presHead.PresHeadID = Convert.ToInt32(dt.Rows[0]["PresHeadID"].ToString());
                }

                presHead.MemberID  = head.MemberID;
                presHead.PatListID = head.PatListID;
                presHead.PresType  = 4;
                BindDb(presHead);
                int presheadid = presHead.save();
                NewObject <PrescriptionProcess>().UpdatePatCurrentDoctorID(head.PatListID, head.ApplyDoctorID, head.ApplyDeptID);
            }

            for (int i = 0; i < itemData.Rows.Count; i++)
            {
                dr = NewDao <IOPDDao>().GetPresNO().Rows[0];
                int             predetailid = 0;
                OPD_PresDetail  presdetail  = new OPD_PresDetail();
                IPD_OrderRecord orderRecord = new IPD_OrderRecord();
                DataRow         detaildr    = null;
                DataTable       orderdt     = NewDao <IOPDDao>().GetStatID(itemData.Rows[i]["ExamItemID"].ToString());
                if (dt != null)
                {
                    detaildr = dt.Select("ItemID=" + Convert.ToInt32(itemData.Rows[i]["ExamItemID"].ToString())).FirstOrDefault();
                }

                if (head.SystemType == 0)
                {
                    if (detaildr != null)
                    {
                        presdetail.PresDetailID = Convert.ToInt32(detaildr["PresDetailID"]);
                    }

                    if (head.ApplyType == 2)
                    {
                        presdetail.Price        = Convert.ToDecimal(itemData.Rows[i]["Price"].ToString()) * Convert.ToInt32(itemData.Rows[i]["Amount"].ToString());
                        presdetail.ChargeAmount = Convert.ToInt32(itemData.Rows[i]["Amount"].ToString());
                        presdetail.PresAmount   = Convert.ToInt32(itemData.Rows[i]["Amount"].ToString());
                    }
                    else
                    {
                        presdetail.Price        = Convert.ToDecimal(itemData.Rows[i]["Price"].ToString());
                        presdetail.ChargeAmount = 1;
                        presdetail.PresAmount   = 1;
                    }

                    presdetail.DoseNum    = 1;
                    presdetail.PresHeadID = presHead.PresHeadID;
                    presdetail.ItemID     = Convert.ToInt32(itemData.Rows[i]["ExamItemID"].ToString());
                    presdetail.ItemName   = itemData.Rows[i]["ExamItemName"].ToString();
                    presdetail.ExecDeptID = head.ExecuteDeptID;
                    presdetail.StatID     = Convert.ToInt32(orderdt.Rows[0]["StatID"]);
                    if (dr != null)
                    {
                        if (dr["PresNO"] == null || dr["PresNO"].ToString() == string.Empty)
                        {
                            presdetail.PresNO = 1;
                        }
                        else
                        {
                            presdetail.PresNO = Convert.ToInt32(dr["PresNO"]) + 1;
                        }
                    }

                    presdetail.IsEmergency    = 0;
                    presdetail.IsLunacyPosion = 0;
                    presdetail.PresDate       = head.ApplyDate;
                    presdetail.PresDeptID     = head.ApplyDeptID;
                    presdetail.PresDoctorID   = head.ApplyDoctorID;
                    BindDb(presdetail);
                    predetailid = presdetail.save();
                    if (presdetail.PresDetailID > 0)
                    {
                        predetailid = presdetail.PresDetailID;
                    }
                }
                else
                {
                    if (detaildr != null)
                    {
                        orderRecord.OrderID = Convert.ToInt32(detaildr["PresDetailID"]);
                    }

                    DataTable          ipPatlist          = NewDao <IOPDDao>().GetInBedPatient(head.PatListID);
                    SerialNumberSource serialNumberSource = NewObject <SerialNumberSource>();
                    string             groupID            = serialNumberSource.GetSerialNumber(SnType.医嘱组号);
                    orderRecord.GroupID       = Convert.ToInt32(groupID);
                    orderRecord.ExecDeptID    = head.ExecuteDeptID;
                    orderRecord.OrderCategory = 1;
                    orderRecord.CancelFlag    = 0;
                    orderRecord.DeleteFlag    = 0;
                    orderRecord.AstFlag       = -1;
                    orderRecord.DoseNum       = 1;
                    orderRecord.Dosage        = 1;
                    // orderRecord.DosageUnit = itemData.Rows[i][""].ToString();
                    orderRecord.OrderStatus = 1;
                    orderRecord.PatDeptID   = Convert.ToInt32(ipPatlist.Rows[0]["CurrDeptID"]);
                    orderRecord.WardID      = Convert.ToInt32(ipPatlist.Rows[0]["EnterWardID"]);
                    orderRecord.StatID      = Convert.ToInt32(orderdt.Rows[0]["StatID"]);
                    orderRecord.ItemID      = Convert.ToInt32(itemData.Rows[i]["ExamItemID"].ToString());
                    orderRecord.PresDeptID  = head.ApplyDeptID;
                    orderRecord.OrderDoc    = head.ApplyDoctorID;
                    orderRecord.ItemName    = itemData.Rows[i]["ExamItemName"].ToString();
                    orderRecord.Amount      = Convert.ToInt32(itemData.Rows[i]["Amount"].ToString());
                    orderRecord.OrderBdate  = head.CheckDate; //DateTime.Now; 20170418改成检查时间
                    if (head.ApplyType == 2)
                    {
                        orderRecord.ItemPrice = Convert.ToDecimal(itemData.Rows[i]["Price"].ToString()) * Convert.ToInt32(itemData.Rows[i]["Amount"].ToString());
                    }
                    else
                    {
                        orderRecord.ItemPrice = Convert.ToDecimal(itemData.Rows[i]["Price"].ToString());
                    }

                    orderRecord.ItemType  = 4;
                    orderRecord.PatListID = head.PatListID;
                    BindDb(orderRecord);
                    predetailid = orderRecord.save();
                    //插入费用明细
                    FeeItemDataSource feeDataSource = NewObject <FeeItemDataSource>();
                    DataTable         dtDetailItem  = feeDataSource.GetExamItemDetailDt(orderRecord.ItemID);

                    for (int index = 0; index < dtDetailItem.Rows.Count; index++)
                    {
                        int       feeitemId  = Convert.ToInt32(dtDetailItem.Rows[index]["ITEMID"]);
                        DataTable dtDrugItem = NewDao <IOPDDao>().GetFeeItemData(feeitemId);
                        decimal   amount     = Convert.ToDecimal(dtDetailItem.Rows[index]["ItemAmount"]);
                        DataRow[] rows       = dtDrugItem.Select(" ItemID=" + feeitemId);
                        if (rows.Length < 1)
                        {
                            continue;
                        }

                        IP_FeeItemGenerate feeItem = GenerateRecordFee(amount, 1, orderRecord, ipPatlist, rows[0]);
                        feeItem.FeeSource   = 1;
                        feeItem.CalCostMode = 0;
                        this.BindDb(feeItem);
                        feeItem.save();
                    }
                }

                EXA_MedicalApplyDetail detail = new EXA_MedicalApplyDetail();
                if (detaildr != null)
                {
                    detail.ApplyDetailID = Convert.ToInt32(detaildr["ApplyDetailID"]);
                }

                detail.SystemType   = head.SystemType;
                detail.PresDetailID = predetailid;
                detail.ApplyHeadID  = head.ApplyHeadID;
                detail.ItemID       = Convert.ToInt32(itemData.Rows[i]["ExamItemID"].ToString());
                detail.ItemName     = itemData.Rows[i]["ExamItemName"].ToString();
                detail.Price        = Convert.ToDecimal(itemData.Rows[i]["Price"].ToString());
                if (head.ApplyType == 2)
                {
                    detail.Amount   = Convert.ToInt32(itemData.Rows[i]["Amount"].ToString());
                    detail.TotalFee = Convert.ToDecimal(itemData.Rows[i]["Price"].ToString()) * detail.Amount;
                }
                else
                {
                    detail.Amount   = 1;
                    detail.TotalFee = Convert.ToDecimal(itemData.Rows[i]["Price"].ToString());
                }

                BindDb(detail);
                detail.save();
            }

            return(headid);
        }
Esempio n. 3
0
        /// <summary>
        /// 提交事件
        /// </summary>
        /// <param name="sender">控件对象</param>
        /// <param name="e">事件参数</param>
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!IsExcute())
            {
                MessageBoxEx.Show("申请单已收费或确费不能修改");
                return;
            }

            var cbDepts     = GetDeptObj();
            var cbTypes     = GetTypeObj();
            var cbPrints    = GetPrintObj();
            var dgExecItems = GetExamTableObj();

            if (cbDepts.SelectedValue == null)
            {
                MessageBoxEx.Show("请选择科室");
                return;
            }

            if (cbTypes.SelectedValue == null)
            {
                MessageBoxEx.Show("请选择项目类型");
                return;
            }

            if (ExamClass == 2)
            {
                if (string.IsNullOrEmpty(multcbSample.SelectText))//cbSample.Text
                {
                    MessageBoxEx.Show("请选择检验标本");
                    return;
                }
            }

            switch (ExamClass)
            {
            case 1:
                if (string.IsNullOrEmpty(dateTimeCheck.Text))
                {
                    MessageBox.Show("检查时间不能为空!");
                    return;
                }
                else
                {
                    if (DateTime.Compare(Convert.ToDateTime(Convert.ToDateTime(dateTimeCheck.Text).ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString())) < 0)
                    {
                        MessageBox.Show("检查时间不能小于当前时间!");
                        return;
                    }
                }
                break;

            case 2:
                if (string.IsNullOrEmpty(datetimeHY.Text))
                {
                    MessageBox.Show("检查时间不能为空!");
                    return;
                }
                else
                {
                    if (DateTime.Compare(Convert.ToDateTime(Convert.ToDateTime(datetimeHY.Text).ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString())) < 0)
                    {
                        MessageBox.Show("检查时间不能小于当前时间!");
                        return;
                    }
                }
                break;

            case 4:
                if (string.IsNullOrEmpty(dateTimeZL.Text))
                {
                    MessageBox.Show("检查时间不能为空!");
                    return;
                }
                else
                {
                    if (DateTime.Compare(Convert.ToDateTime(Convert.ToDateTime(dateTimeZL.Text).ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString())) < 0)
                    {
                        MessageBox.Show("检查时间不能小于当前时间!");
                        return;
                    }
                }
                break;
            }

            SaveItemData = dgExecItems.DataSource as DataTable;

            EXA_MedicalApplyHead head = new EXA_MedicalApplyHead();
            string content            = string.Empty;

            switch (ExamClass)
            {
            case 1:
                content        = "{\"Digest\":\"" + txtDigest.Text + "\",\"Signs\":\"" + txtSigns.Text + "\",\"Xray\":\"" + txtXray.Text + "\",\"Assay\":\"" + txtAssay.Text + "\",\"Assist\":\"" + txtAssist.Text + "\",\"Part\":\"" + txtPart.Text + "\"}";
                head.ApplyType = 0;
                ApplyType      = "0";
                head.CheckDate = Convert.ToDateTime(dateTimeCheck.Text);
                break;

            case 2:
                //cbSample.SelectedValue  cbSample.Text
                content        = "{\"Goal\":\"" + txtGoal.Text + "\",\"Sample\":\"" + string.Join(",", multcbSample.SelectValue) + "\",\"SampleName\":\"" + multcbSample.SelectText + "\"}";
                head.ApplyType = 1;
                ApplyType      = "1";
                head.CheckDate = Convert.ToDateTime(datetimeHY.Text);
                break;

            case 4:
                head.ApplyType = 2;
                ApplyType      = "2";
                dgExecItemZL.EndEdit();
                head.CheckDate = Convert.ToDateTime(dateTimeZL.Text);
                break;
            }

            head.ApplyContent  = content;
            head.ApplyDate     = DateTime.Now;
            head.ExamTypeID    = Convert.ToInt32(cbTypes.SelectedValue);
            head.ExecuteDeptID = Convert.ToInt32(cbDepts.SelectedValue);
            InvokeController("SaveExam", head, UpdateData);
            SaveClearData();
            if (cbPrints.Checked)
            {
                if (UpdateData != null)
                {
                    InvokeController("PrintData", UpdateData);
                }
                else
                {
                    MessageBoxEx.Show("没有可以打印的数据");
                }
            }

            ApplyHeadID = string.Empty;
            UpdateData  = null;
        }