Example #1
0
        public bool init(BLPublic.DBOperate _db, string _empCode)
        {
            this.db      = _db;
            this.EmpCode = _empCode;

            this.lstError        = new List <string>();
            this.lstMntCondition = new List <MonitorCondition>();
            this.prepClass       = new Dictionary <int, string>();
            this.tpnValue        = new Dictionary <string, double>();
            this.pntValue        = new Dictionary <string, string>();
            this.ordersValue     = new Dictionary <string, double>();
            this.drugValue       = new Dictionary <int, RecipePrep>();
            this.tpnCal          = new TPNCalculator();
            this.tpnCal.init(_db);

            return(loadConfig());
        }
Example #2
0
        /// <summary>
        /// 显示参数值
        /// </summary>
        private void showContent()
        {
            if (string.IsNullOrWhiteSpace(this.itemCode))
            {
                lblItem.Text = "未指定TPN项目";
                return;
            }

            Dictionary <string, string> itemInfo = new Dictionary <string, string>();

            this.monitor.getTPNItemInfo(this.itemCode, itemInfo);
            if (0 == itemInfo.Count)
            {
                lblItem.Text = "项目" + this.itemCode + "信息丢失";
                return;
            }

            Dictionary <string, string[]> expItems = new Dictionary <string, string[]>(); //计算项目信息[0]对应列下标, [1]单位
            string express = "";

            lblItem.Text = itemInfo["ItemName"];
            express      = itemInfo["Express"];

            ColumnHeader col;

            if (string.IsNullOrWhiteSpace(express))
            {
                lblExpress.Text = "<药品所含量累加>";
                col             = lvDrugs.Columns.Add(itemInfo["ItemName"], 60, HorizontalAlignment.Right);
                col.Tag         = this.itemCode;
                expItems.Add(this.itemCode, new string[] { col.Index.ToString(), itemInfo["Unit"] });
            }
            else
            {
                //替换计算表达式项目名称
                string        expName = express;
                List <string> items   = new List <string>();

                TPNCalculator.getExpressItem(express, items);
                foreach (string itemCode in items)
                {
                    if ("recipe.capacity".Equals(itemCode))
                    {
                        expItems.Add(itemCode, new string[] { "4", "ml" });
                        expName = expName.Replace(itemCode, "医嘱容积");
                    }
                    else if ("patient.weight".Equals(itemCode))
                    {
                        expItems.Add(itemCode, new string[] { "-1", "kg" });
                        expName = expName.Replace(itemCode, "体重");
                    }
                    else
                    {
                        itemInfo.Clear();
                        this.monitor.getTPNItemInfo(itemCode, itemInfo);
                        if (1 <= itemInfo.Count)
                        {
                            expName = expName.Replace(itemCode, itemInfo["ItemName"]);
                            if ("comp".Equals(itemInfo["ItemType"]) || "thing".Equals(itemInfo["ItemType"]))
                            {
                                col     = lvDrugs.Columns.Add(itemInfo["ItemName"], 80, HorizontalAlignment.Right);
                                col.Tag = itemCode;

                                expItems.Add(itemCode, new string[] { col.Index.ToString(), itemInfo["Unit"] });
                            }
                            else
                            {
                                expItems.Add(itemCode, new string[] { "-1", itemInfo["Unit"] });
                            }
                        }
                    }
                }
                lblExpress.Text = expName;
            }

            //计算
            if (this.isMockModel)
            {
                if (!calTPNItemByCheckDrug())
                {
                    return;
                }
            }
            else if (!this.monitor.calculatorOrders(this.recipeID, this.itemCode))
            {
                lblResult.Text = this.monitor.getError();
                return;
            }

            //在医嘱里显示
            double     totalCapacoty = 0;
            RecipePrep info          = null;

            foreach (ListViewItem item in lvDrugs.Items)
            {
                if (null != item.Tag)
                {
                    info = this.monitor.getPrepInfo(((BLPublic.IDCodeItem)item.Tag).ID);
                    if (null != info)
                    {
                        item.SubItems[3].Text = info.Quantity.ToString();
                        if (0 < info.Capacity)
                        {
                            item.SubItems[4].Text = info.Capacity.ToString() + " ml";
                        }
                        else
                        {
                            item.SubItems[4].Text = "-";
                        }

                        totalCapacoty += info.Capacity;

                        for (int i = lvDrugs.Columns.Count - 1; i >= 5; i--)
                        {
                            item.SubItems.Add("-");
                        }

                        string[] tpn;
                        foreach (string key in info.TPNValues.Keys)
                        {
                            if (expItems.ContainsKey(key))
                            {
                                tpn = expItems[key];
                                item.SubItems[Convert.ToInt32(tpn[0])].Text = Math.Round(info.TPNValues[key], 2).ToString() + " " + tpn[1];
                            }
                        }
                    }
                }
            }


            if ("recipe.capacity".Equals(this.itemCode))
            {
                lblResult.Text = totalCapacoty.ToString() + " ml";
            }
            else if ("patient.weight".Equals(this.itemCode))
            {
                lblResult.Text = "0 kg";
            }
            else
            {
                this.monitor.getTPNItemInfo(this.itemCode, itemInfo);
                if (0 < itemInfo.Count)
                {
                    lblResult.Text = itemInfo["Value"] + " " + itemInfo["Unit"];
                }
            }

            //合计
            ListViewItem totalItem = lvDrugs.Items.Add("<合计>");

            for (int i = lvDrugs.Columns.Count - 1; i >= 1; i--)
            {
                totalItem.SubItems.Add("");
            }

            totalItem.SubItems[4].Text = totalCapacoty.ToString() + " ml";

            string expValue   = express;
            double totalValue = 0;

            foreach (KeyValuePair <string, string[]> item in expItems)
            {
                totalValue = 0;

                if ("patient.weight".Equals(item.Key))
                {
                    totalValue = 0;
                }

                else if ("recipe.capacity".Equals(item.Key))
                {
                    totalValue = totalCapacoty;
                }

                else if (0 <= Convert.ToInt32(item.Value[0]))
                {
                    totalValue = getColTotal(Convert.ToInt32(item.Value[0]));
                    totalItem.SubItems[Convert.ToInt32(item.Value[0])].Text = totalValue.ToString() + " " + item.Value[1];
                }
                else if (!string.IsNullOrWhiteSpace(express)) //替换计算表达式项目值
                {
                    this.monitor.getTPNItemInfo(item.Key, itemInfo);
                    if (0 < itemInfo.Count)
                    {
                        totalValue = Math.Round(Convert.ToDouble(itemInfo["Value"]), 2);
                    }
                }

                expValue = expValue.Replace('[' + item.Key + ']', totalValue.ToString());
            }

            lblExpress.Text += "\r\n";
            lblExpress.Text += expValue;

            lvDrugs.Items.Insert(lvDrugs.Items.Count - 1, "");
            lvDrugs.Items.Add("");
        }