예제 #1
0
        public bool CreateApply(clsLisApplMainVO patientInfo, clsTestApplyItme_VO[] unitItems, bool isSended, out string message)
        {
            bool result = true;

            message = string.Empty;
            dic3to1 = new Dictionary <string, string>();
            try
            {
                if (patientInfo == null)
                {
                    throw new LisCreateApplyException("病人信息为空!(patientInfo==null)");
                }

                if (unitItems == null || unitItems.Length == 0)
                {
                    throw new LisCreateApplyException("该检验申请没有包含有效的申请单元!");
                }

                #region 糖耐量等一个组合或项目可对应多个条形码

                List <string> lstTmp = new List <string>();
                List <clsTestApplyItme_VO> lstPlusExecApplyUnit = new List <clsTestApplyItme_VO>();
                DataTable dtUnit = null;
                DataTable dtTmp  = null;
                clsDomainController_ApplicationManage dclApp = new clsDomainController_ApplicationManage();
                foreach (clsTestApplyItme_VO item in unitItems)
                {
                    if (patientInfo.m_strPatientType == "1")
                    {
                        if (lstTmp.IndexOf(item.m_strOrderID) < 0)
                        {
                            lstTmp.Add(item.m_strOrderID);
                            dtTmp = dclApp.GetOrderDicLisApplyUnitByOrderId(item.m_strOrderID);
                            if (dtTmp != null && dtTmp.Rows.Count > 0)
                            {
                                if (dtUnit == null)
                                {
                                    dtUnit = dtTmp.Clone();
                                }
                                dtUnit.Merge(dtTmp);
                                dtUnit.AcceptChanges();
                            }
                        }
                    }
                    else if (patientInfo.m_strPatientType == "2")
                    {
                        if (lstTmp.IndexOf(item.m_strOutpatRecipeDeID) < 0)
                        {
                            lstTmp.Add(item.m_strOutpatRecipeDeID);
                            dtTmp = dclApp.GetOrderDicLisApplyUnit(item.m_strOutpatRecipeDeID);
                            if (dtTmp != null && dtTmp.Rows.Count > 0)
                            {
                                if (dtUnit == null)
                                {
                                    dtUnit = dtTmp.Clone();
                                }
                                dtUnit.Merge(dtTmp);
                                dtUnit.AcceptChanges();
                            }
                        }
                    }
                }
                string        filterExp    = string.Empty;
                List <string> lstCheck1to3 = new List <string>();
                DataRow[]     drr          = null;
                if (dtUnit != null && dtUnit.Rows.Count > 0)
                {
                    for (int i = 0; i < unitItems.Length; i++)
                    {
                        if (patientInfo.m_strPatientType == "1")
                        {
                            filterExp = string.Format("orderId = '{0}' and mainLisApplyUnitId = '{1}' and isUsed = 0", unitItems[i].m_strOrderID, unitItems[i].m_strItemID);
                        }
                        else if (patientInfo.m_strPatientType == "2")
                        {
                            filterExp = string.Format("orderDicId = '{0}' and mainLisApplyUnitId = '{1}' and isUsed = 0", unitItems[i].m_strOutpatRecipeDeID, unitItems[i].m_strItemID);
                        }
                        drr = dtUnit.Select(filterExp);
                        if (drr != null && drr.Length > 0)
                        {
                            string mainApplyUnitId = unitItems[i].m_strItemID;
                            string plusApplyUnitId = string.Empty;
                            clsTestApplyItme_VO vo = null;
                            string key             = string.Empty;
                            foreach (DataRow dr1 in drr)
                            {
                                plusApplyUnitId = dr1["plusLisApplyUnitId"].ToString();
                                if (patientInfo.m_strPatientType == "1")    // 防止如:糖耐量等1对多申请单元单个删除医嘱后重新生时重复再生成申请单
                                {
                                    key = unitItems[i].m_strOrderID + "|" + plusApplyUnitId;
                                }
                                else if (patientInfo.m_strPatientType == "2")
                                {
                                    key = unitItems[i].m_strOutpatRecipeID + "|" + plusApplyUnitId;
                                }
                                if (lstCheck1to3.IndexOf(key) < 0)
                                {
                                    lstCheck1to3.Add(key);
                                }
                                else
                                {
                                    continue;
                                }

                                if (Convert.ToInt32(dr1["sortNo"]) == 1)
                                {
                                    dr1["isUsed"]              = 1;
                                    unitItems[i].m_strItemID   = plusApplyUnitId;
                                    unitItems[i].m_strItemName = dr1["applyUnitName"].ToString();
                                }
                                else
                                {
                                    vo                       = new clsTestApplyItme_VO();
                                    vo.m_decPrice            = unitItems[i].m_decPrice;
                                    vo.m_decQty              = unitItems[i].m_decQty;
                                    vo.m_decTolPrice         = unitItems[i].m_decTolPrice;
                                    vo.m_strItemID           = plusApplyUnitId;
                                    vo.m_strUsageID          = unitItems[i].m_strUsageID;
                                    vo.m_strItemName         = dr1["applyUnitName"].ToString();
                                    vo.m_strSpec             = unitItems[i].m_strSpec;
                                    vo.m_strSampleId         = unitItems[i].m_strSampleId;
                                    vo.m_strUnit             = unitItems[i].m_strUnit;
                                    vo.m_strOutpatRecipeID   = unitItems[i].m_strOutpatRecipeID;
                                    vo.m_strRowNo            = unitItems[i].m_strRowNo;
                                    vo.m_strOprDeptID        = unitItems[i].m_strOprDeptID;
                                    vo.strPartID             = unitItems[i].strPartID;
                                    vo.m_strOutpatRecipeDeID = unitItems[i].m_strOutpatRecipeDeID;
                                    vo.m_strOrderID          = unitItems[i].m_strOrderID;
                                    vo.m_decDiscount         = unitItems[i].m_decDiscount;
                                    lstPlusExecApplyUnit.Add(vo);
                                }
                                if (dic3to1.ContainsKey(plusApplyUnitId) == false)
                                {
                                    dic3to1.Add(plusApplyUnitId, mainApplyUnitId);
                                }
                            }
                        }
                    }
                }
                #endregion

                string[] arrUnitId = GetDifferentUnits(unitItems);
                if (arrUnitId.Length == 0)
                {
                    throw new LisCreateApplyException("该检验申请没有包含有效的申请单元!");
                }

                m_unitOrder = GetOrderUnitCollection(unitItems);

                m_unitInfo = new ApplyUnitInfo(arrUnitId);

                // 合单判断.获取需要合单的申请单元ID string[]   *** 2018-04-18 很关键 ***
                List <string[]>       applyApplications = SeparateApplication(m_unitInfo.GetUnitIdList());
                clsTestApplyItme_VO[] items;
                // 合单判断.循环分组申请单元,形成一条申请单    *** 2018-04-18 很关键 ***
                foreach (string[] arrUnit in applyApplications)
                {
                    items = GetApplyUnitItems(arrUnit, unitItems);
                    CreateApplyApplication(patientInfo, items, arrUnit, isSended);
                }

                #region 糖耐量等一个组合或项目可对应多个条形码

                if (lstPlusExecApplyUnit.Count > 0)
                {
                    foreach (clsTestApplyItme_VO item in lstPlusExecApplyUnit)
                    {
                        unitItems = new clsTestApplyItme_VO[1] {
                            item
                        };

                        arrUnitId = GetDifferentUnits(unitItems);

                        m_unitOrder = GetOrderUnitCollection(unitItems);

                        m_unitInfo = new ApplyUnitInfo(arrUnitId);

                        applyApplications = SeparateApplication(m_unitInfo.GetUnitIdList());
                        foreach (string[] arrUnit in applyApplications)
                        {
                            items = GetApplyUnitItems(arrUnit, unitItems);
                            CreateApplyApplication(patientInfo, items, arrUnit, isSended);
                        }
                    }
                }
                #endregion

                return(true);
            }
            catch (LisCreateApplyException ex)
            {
                new com.digitalwave.Utility.clsLogText().LogError(ex.Message);
                message = ex.Message;
                result  = false;
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// 删除医嘱
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool DeleteOrder(string orderId, out string message)
        {
            message = string.Empty;
            bool result = true;

            try
            {
                List <clsLisApplMainVO> lstAppMain = new List <clsLisApplMainVO>();
                long lngRes = clsLisServiceSmp.s_obj.m_lngGetApplication(orderId, out lstAppMain);

                if (lstAppMain == null || lstAppMain.Count == 0)
                {
                    // 删除医嘱是为了删除护士采集的申请单,
                    // 所以找不到相关申请单的时候,
                    // 说明医嘱是可以删除的
                    message = string.Format("查找不到医嘱Id{0}相关的申请单!", orderId);
                    return(true);
                }

                List <Dictionary <string, string> > lstDic = new List <Dictionary <string, string> >();
                foreach (clsLisApplMainVO app in lstAppMain)
                {
                    if (!string.IsNullOrEmpty(app.m_strSampleID))
                    {
                        CheckSampleStatus(app.m_strSampleID);
                    }
                    Dictionary <string, string> dic = ParseOrderUnitRelation(app.m_strOrderunitrelation);
                    dic.Remove(orderId);

                    clsLisServiceSmp.s_obj.m_lngDeleteApplication(app.m_strAPPLICATION_ID);
                    lstDic.Add(dic);
                }

                int count = 0;
                foreach (Dictionary <string, string> item in lstDic)
                {
                    count += item.Count;
                }
                if (count == 0)
                {
                    return(true);
                }

                clsTestApplyItme_VO[] unitItems = new clsTestApplyItme_VO[count];
                int i = 0;
                foreach (Dictionary <string, string> dic in lstDic)
                {
                    foreach (KeyValuePair <string, string> pair in dic)
                    {
                        clsTestApplyItme_VO item = new clsTestApplyItme_VO();
                        item.m_strItemID  = pair.Value;
                        item.m_strOrderID = pair.Key;
                        unitItems[i]      = item;

                        i++;
                    }
                }
                clsLisApplMainVO patientInfo = lstAppMain[0];
                patientInfo.m_strChargeInfo   = string.Empty;
                patientInfo.m_strCheckContent = string.Empty;

                CreateApply(patientInfo, unitItems, true, out message);
            }
            catch (Exception ex)
            {
                new com.digitalwave.Utility.clsLogText().LogError(ex.Message);
                message = ex.Message;
                result  = false;
            }
            return(result);
        }