Ejemplo n.º 1
0
        public WebResult DelPreOrder(string orderNo)
        {
            WebResult ret = new WebResult();

            try
            {
                string orderPath = "";
                string imagePath = "";
                orderPath = ConfigurationManager.AppSettings["OrderDir"];
                orderPath = Path.Combine(orderPath, orderNo.Trim() + ".csv");

                imagePath = ConfigurationManager.AppSettings["ImagePath"];
                imagePath = Path.Combine(imagePath, orderNo.Trim());

                PreOrder tmp = ReadCSV(orderPath);

                tmp.Status = 3;

                WriteCSV(tmp, "", "", "", tmp.ImgCnt.ToString(), "");

                if (File.Exists(orderPath))
                {
                    File.Delete(orderPath);
                }

                if (Directory.Exists(imagePath))
                {
                    string[] files = Directory.GetFiles(imagePath);

                    foreach (var file in files)
                    {
                        File.Delete(file);
                    }
                }

                LogControl.WriteLog(LogType.ORE, "DelPreOrder", "【オーダー削除】 オーダーNo:" + orderNo);
            }
            catch (Exception e)
            {
                ret.Result  = false;
                ret.Message = "処理中に障害が発生いたしました。\nシステム管理者にお問い合わせください。";
                LogControl.WriteLog(LogType.ERR, "DelPreOrder", e.Message);
            }
            return(ret);
        }
Ejemplo n.º 2
0
        private PreOrder ReadCSV(string file)
        {
            PreOrder order = new PreOrder();

            string mstPath = "";

            mstPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["MastDir"], "Mast.csv");

            var csvValue = "";

            using (var sr = new System.IO.StreamReader(mstPath, System.Text.Encoding.GetEncoding("Shift-JIS")))
                csvValue = sr.ReadLine();

            var csvCols = csvValue.Replace("\"", "").Split(',');

            using (var sr = new System.IO.StreamReader(file, System.Text.Encoding.GetEncoding("Shift-JIS")))
                csvValue = sr.ReadToEnd();

            var datCols = csvValue.Replace("\",\"", "$").Replace("\"", "").Replace("\r\n", "").Replace("\n", "").Split('$');

            for (int i = 0; i <= 23; i++)
            {
                var key   = "@" + i.ToString().PadLeft(2, '0');
                var index = -1;

                for (int j = 0; j < csvCols.Length; j++)
                {
                    if (csvCols[j] == key)
                    {
                        index = j;
                        break;
                    }
                }

                if (index < 0)
                {
                    continue;
                }

                switch (key)
                {
                case "@00":
                    order.Status = Convert.ToInt32(datCols[index]);
                    break;

                case "@01":
                    order.PatID = datCols[index].Replace(ConfigurationManager.AppSettings["HospCD"], "");
                    break;

                case "@02":
                    order.PatName = datCols[index];
                    break;

                case "@03":
                    order.PatName_H = datCols[index];
                    break;

                case "@04":
                    order.PatName_R = datCols[index];
                    break;

                case "@05":
                    switch (datCols[index])
                    {
                    case "M":
                        order.Sex = 1;
                        break;

                    case "F":
                        order.Sex = 2;
                        break;

                    default:
                        order.Sex = 0;
                        break;
                    }
                    break;

                case "@06":
                    order.BirthDay = datCols[index];
                    break;

                case "@07":
                    order.PatAge = Convert.ToInt32(datCols[index]);
                    break;

                case "@08":
                    order.Date = datCols[index];
                    break;

                case "@09":
                    order.Time = datCols[index];
                    break;

                case "@10":
                    order.Modality = datCols[index];
                    break;

                case "@11":
                    order.IsEmergency = Convert.ToInt32(datCols[index]);
                    break;

                case "@12":
                    order.Comment = datCols[index];
                    break;

                case "@13":
                    order.Recept = datCols[index];
                    break;

                case "@14":
                    order.Contact = datCols[index];
                    break;

                case "@15":
                    break;

                case "@16":
                    break;

                case "@17":
                    order.BodyPart = datCols[index];
                    break;

                case "@18":
                    order.Type = datCols[index];
                    break;

                case "@19":
                    order.ImgCnt = Convert.ToInt32(datCols[index]);
                    break;

                case "@20":
                    order.PastCnt = datCols[index];
                    break;

                case "@21":
                    order.OrderNo = datCols[index].Replace(ConfigurationManager.AppSettings["HospCD"], "");
                    break;

                case "@22":
                    order.Doctor = datCols[index];
                    break;

                case "@23":
                    order.Department = datCols[index];
                    break;
                }
            }


            return(order);
        }
Ejemplo n.º 3
0
        public WebResult SetPreOrder(string[] values)
        {
            WebResult ret = new WebResult();

            try
            {
                PreOrder order = new PreOrder();
                string   msg   = "";
                string   msg3  = "";

                List <string> pastIds = new List <string>();

                order.StudyInstanceUID = values[0];
                order.OrderNo          = values[1].Trim();
                order.PatID            = values[2];
                order.PatName          = values[3];
                order.PatName_H        = values[4];
                order.PatAge           = Convert.ToInt32(values[5]);
                order.BirthDay         = values[6];
                order.Modality         = values[7];
                order.Date             = values[8];
                order.Time             = values[9];
                order.BodyPart         = values[10];
                order.Type             = values[11];
                order.ImgCnt           = Convert.ToInt32(values[12]);
                order.IsEmergency      = Convert.ToInt32(values[13]);
                order.Comment          = values[14];
                order.Sex        = Convert.ToInt32(values[15]);
                order.Department = values[16];
                order.Doctor     = values[17];
                msg = values[18];

                string orderPath = "";
                orderPath = ConfigurationManager.AppSettings["OrderDir"];
                orderPath = Path.Combine(orderPath, order.OrderNo + ".csv");

                if (!File.Exists(orderPath))
                {
                    order.Status = 1;
                }
                else
                {
                    order.Status = 2;
                }

                if (values.Length > 19)
                {
                    for (int i = 19; i < values.Length; i++)
                    {
                        pastIds.Add(values[i]);
                    }
                }

                LogControl.WriteLog(LogType.ORE, "SetPreOrder", "【オーダー登録】オーダー番号:" + order.OrderNo + "患者ID:" + order.PatID + " モダリティ:" + order.Modality + " 検査日:" + order.Date);

                Search search = new Search();

                var msg4 = "";

                if (!string.IsNullOrEmpty(msg))
                {
                    msg4 = "比較参照お願いします。(" + msg + ")";
                }

                string cA = order.ImgCnt.ToString();
                string cB = msg;

                if (string.IsNullOrEmpty(msg))
                {
                    msg = order.ImgCnt.ToString();
                }
                else
                {
                    msg = order.ImgCnt.ToString() + "(" + msg + ")";
                }

                WriteCSV(order, msg, msg3, msg4, cA, cB);

                if (order.Status == 1 || order.Status == 2)
                {
                    C_Find.Setting();
                    foreach (var past in pastIds)
                    {
                        DicomQRItem[] studyDatas = null;

                        studyDatas = C_Find.C_FindFromStudy("", "", "", "", past);

                        PreOrder tmp = new PreOrder();

                        tmp = order;

                        for (int i = 0; i < studyDatas.Length; i++)
                        {
                            StudyData tmpStudy = new StudyData();
                            tmpStudy.SetStudy(studyDatas[i].Tags);

                            DicomQRItem[] tmpDat = C_Find.C_FindFromSeries(tmpStudy.UID);
                            tmpStudy.SetSeries(tmpDat);

                            tmp.Date     = tmpStudy.Tags[(uint)Tags.STUDYDATE];
                            tmp.Modality = tmpStudy.Modality;
                        }

                        WriteCSV_Past(tmp, msg, msg3, msg4, cA, cB);
                    }

                    string UIDfile = Path.Combine(ConfigurationManager.AppSettings["UIDDir"], order.OrderNo + ".txt");

                    if (File.Exists(UIDfile))
                    {
                        File.Delete(UIDfile);
                    }

                    using (var sw = new StreamWriter(UIDfile))
                    {
                        sw.WriteLine(order.StudyInstanceUID);
                    }
                }
                ret.Result = true;
            }
            catch (Exception e)
            {
                ret.Result  = false;
                ret.Message = "処理中に障害が発生いたしました。\nシステム管理者にお問い合わせください。";
                LogControl.WriteLog(LogType.ERR, "WebGetList", e.Message);
                LogControl.WriteLog(LogType.ERR, "WebGetList", e.StackTrace);
            }

            return(ret);
        }
Ejemplo n.º 4
0
        public WebPreOrder WebGetPreOrder(string orderno, string uid)
        {
            WebPreOrder ret = new WebPreOrder();

            try
            {
                DicomQRItem[] studyDatas = null;

                string orderDir = ConfigurationManager.AppSettings["OrderDir"];
                C_Find.Setting();

                studyDatas = C_Find.C_FindFromStudy("", "", "", "", uid);

                PreOrder tmp = new PreOrder();

                for (int i = 0; i < studyDatas.Length; i++)
                {
                    StudyData tmpStudy = new StudyData();
                    tmpStudy.SetStudy(studyDatas[i].Tags);

                    DicomQRItem[] tmpDat = C_Find.C_FindFromSeries(tmpStudy.UID);
                    tmpStudy.SetSeries(tmpDat);


                    if (tmpStudy.Tags.ContainsKey((uint)Tags.ACCSESSIONNO))
                    {
                        tmp.OrderNo = tmpStudy.Tags[(uint)Tags.ACCSESSIONNO].Trim();
                    }
                    else
                    {
                        tmp.OrderNo = tmpStudy.Tags[(uint)Tags.PATIENTID].Trim() + tmpStudy.Tags[(uint)Tags.STUDYDATE].Trim().Substring(2, 6) + tmpStudy.Modality;
                    }

                    if (File.Exists(Path.Combine(orderDir, tmp.OrderNo + ".csv")))
                    {
                        PreOrder past = ReadCSV(Path.Combine(orderDir, tmp.OrderNo + ".csv"));

                        tmp                  = past;
                        tmp.Status           = 2;
                        tmp.StudyInstanceUID = tmpStudy.UID;
                        break;
                    }
                    else
                    {
                        foreach (var dat in tmpDat)
                        {
                            tmpStudy.SetImages(
                                C_Find.C_FindFromImages(
                                    tmpStudy.UID
                                    , dat.Tags[(uint)Tags.SERIES_INSTANCE_UID]
                                    )
                                );
                        }

                        tmp.Status = 0;
                    }


                    tmp.PatID = tmpStudy.Tags[(uint)Tags.PATIENTID].Trim();

                    var nameSep = ConfigurationManager.AppSettings["NameSep"];
                    if (!string.IsNullOrEmpty(nameSep))
                    {
                        var vals = tmpStudy.Tags[(uint)Tags.PATIENTNAME].Trim().Split(nameSep[0]);
                        int nix  = -1;
                        int kix  = -1;

                        if (int.TryParse(ConfigurationManager.AppSettings["NameSep_Kanji"], out nix))
                        {
                            tmp.PatName = vals[nix];
                        }

                        if (int.TryParse(ConfigurationManager.AppSettings["NameSep_Kana"], out kix))
                        {
                            tmp.PatName_H = vals[kix];
                        }
                        else
                        {
                            tmp.PatName_H = tmp.PatName;
                        }
                    }
                    else
                    {
                        tmp.PatName   = tmpStudy.Tags[(uint)Tags.PATIENTNAME].Trim();
                        tmp.PatName_H = tmpStudy.Tags[(uint)Tags.PATIENTNAME].Trim();
                    }

                    if (tmpStudy.Tags.ContainsKey((uint)Tags.SEX))
                    {
                        string dat = tmpStudy.Tags[(uint)Tags.SEX];
                        switch (dat.ToLower().Trim())
                        {
                        case "m":
                        case "male":
                            tmp.Sex = 1;
                            break;

                        case "f":
                        case "femail":
                            tmp.Sex = 2;
                            break;

                        default:
                            tmp.Sex = 0;
                            break;
                        }
                    }
                    else
                    {
                        tmp.Sex = 2;
                    }

                    if (tmpStudy.Tags.ContainsKey((uint)Tags.BIRTHDAY))
                    {
                        tmp.BirthDay = tmpStudy.Tags[(uint)Tags.BIRTHDAY];
                    }

                    tmp.Date = tmpStudy.Tags[(uint)Tags.STUDYDATE];
                    tmp.Time = tmpStudy.Tags[(uint)Tags.STUDYTIME];

                    if (tmpStudy.Tags.ContainsKey((uint)Tags.BODYPART))
                    {
                        tmp.BodyPart = tmpStudy.Tags[(uint)Tags.BODYPART];
                    }
                    tmp.Modality         = tmpStudy.Modality;
                    tmp.StudyInstanceUID = tmpStudy.UID;
                    tmp.ImgCnt           = tmpStudy.Cnt;
                }

                ret.Items  = tmp;
                ret.Result = true;
                C_Find.Client.Close();
                C_Find.Client = new DicomQRClient();
            }
            catch (Exception e)
            {
                ret.Result  = false;
                ret.Message = "処理中に障害が発生いたしました。\nシステム管理者にお問い合わせください。";
                LogControl.WriteLog(LogType.ERR, "WebGetPreOrder", e.Message);
                LogControl.WriteLog(LogType.ERR, "WebGetPreOrder", e.StackTrace);
                C_Find.Client.Close();
                C_Find.Client = new DicomQRClient();
            }

            return(ret);
        }
Ejemplo n.º 5
0
        public WebPreOrderList WebGetPreList(string patid, string date, string mod, int isCnt)
        {
            WebPreOrderList ret = new WebPreOrderList();

            try
            {
                DicomQRItem[] studyDatas = null;

                List <PreOrder> tmpList  = new List <PreOrder>();
                string          orderDir = ConfigurationManager.AppSettings["OrderDir"];
                C_Find.Setting();

                studyDatas = C_Find.C_FindFromStudy(patid, date, "", mod, "");

                for (int i = 0; i < studyDatas.Length; i++)
                {
                    StudyData tmpStudy = new StudyData();
                    tmpStudy.SetStudy(studyDatas[i].Tags);

                    DicomQRItem[] tmpDat = C_Find.C_FindFromSeries(tmpStudy.UID);
                    tmpStudy.SetSeries(tmpDat);
                    if (isCnt == 1)
                    {
                        foreach (var dat in tmpDat)
                        {
                            tmpStudy.SetImages(
                                C_Find.C_FindFromImages(
                                    tmpStudy.UID
                                    , dat.Tags[(uint)Tags.SERIES_INSTANCE_UID]
                                    )
                                );
                        }
                    }

                    if (tmpStudy.Modality.IndexOf(mod) < 0)
                    {
                        continue;
                    }

                    PreOrder tmp = new PreOrder();

                    if (tmpStudy.Tags.ContainsKey((uint)Tags.ACCSESSIONNO))
                    {
                        tmp.OrderNo = tmpStudy.Tags[(uint)Tags.ACCSESSIONNO].Trim();
                    }
                    else
                    {
                        tmp.OrderNo = tmpStudy.Tags[(uint)Tags.PATIENTID].Trim() + tmpStudy.Tags[(uint)Tags.STUDYDATE].Trim().Substring(2, 6) + tmpStudy.Modality;
                    }

                    if (File.Exists(Path.Combine(orderDir, tmp.OrderNo + ".csv")))
                    {
                        PreOrder past = ReadCSV(Path.Combine(orderDir, tmp.OrderNo + ".csv"));
                        tmp = past;
                    }
                    else
                    {
                        tmp.Status = 0;
                    }

                    tmp.PatID   = tmpStudy.Tags[(uint)Tags.PATIENTID];
                    tmp.PatName = tmpStudy.Tags[(uint)Tags.PATIENTNAME];


                    if (tmpStudy.Tags.ContainsKey((uint)Tags.SEX))
                    {
                        string dat = tmpStudy.Tags[(uint)Tags.SEX];
                        switch (dat.ToLower().Trim())
                        {
                        case "m":
                        case "male":
                            tmp.Sex = 1;
                            break;

                        case "f":
                        case "femail":
                            tmp.Sex = 2;
                            break;

                        default:
                            tmp.Sex = 0;
                            break;
                        }
                    }
                    else
                    {
                        tmp.Sex = 2;
                    }

                    if (tmpStudy.Tags.ContainsKey((uint)Tags.BIRTHDAY))
                    {
                        tmp.BirthDay = tmpStudy.Tags[(uint)Tags.BIRTHDAY];
                    }

                    tmp.Date = tmpStudy.Tags[(uint)Tags.STUDYDATE];
                    tmp.Time = tmpStudy.Tags[(uint)Tags.STUDYTIME];

                    if (tmpStudy.Tags.ContainsKey((uint)Tags.BODYPART))
                    {
                        tmp.BodyPart = tmpStudy.Tags[(uint)Tags.BODYPART];
                    }
                    if (tmpStudy.Tags.ContainsKey((uint)Tags.DESCRIPTION))
                    {
                        tmp.Desc = tmpStudy.Tags[(uint)Tags.DESCRIPTION];
                    }
                    tmp.Modality         = tmpStudy.Modality;
                    tmp.StudyInstanceUID = tmpStudy.UID;
                    tmp.ImgCnt           = tmpStudy.Cnt;
                    tmpList.Add(tmp);
                }

                tmpList.Sort((a, b) => { return(-((a.Date + a.Time).CompareTo((b.Date + b.Time)))); });

                ret.Items  = tmpList.ToArray();
                ret.Result = true;
                C_Find.Client.Close();
                C_Find.Client = new DicomQRClient();
            }
            catch (Exception e)
            {
                ret.Result  = false;
                ret.Message = "処理中に障害が発生いたしました。\nシステム管理者にお問い合わせください。";
                LogControl.WriteLog(LogType.ERR, "WebGetPreList", e.Message);
                LogControl.WriteLog(LogType.ERR, "WebGetPreList", e.StackTrace);
                C_Find.Client.Close();
                C_Find.Client = new DicomQRClient();
            }

            return(ret);
        }
Ejemplo n.º 6
0
        private void WriteCSV_Past(PreOrder order, string msg1, string msg3, string msg4, string cntA, string cntB)
        {
            string hospCd   = "";
            string hospName = "";

            string mstPath = "";
            string outPath = "";

            hospCd   = ConfigurationManager.AppSettings["HospCD"];
            hospName = ConfigurationManager.AppSettings["HospName"];

            mstPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["MastDir"], "Mast.csv");
            outPath = ConfigurationManager.AppSettings["CsvDir"];

            var csvValue = "";

            using (var sr = new System.IO.StreamReader(mstPath, System.Text.Encoding.GetEncoding("Shift-JIS")))
            {
                csvValue = sr.ReadLine();
            }

            csvValue = csvValue.Replace("@00", order.Status.ToString());
            csvValue = csvValue.Replace("@01", hospCd + order.PatID);
            csvValue = csvValue.Replace("@02", order.PatName);
            csvValue = csvValue.Replace("@03", order.PatName_H);
            csvValue = csvValue.Replace("@04", order.PatName_R);
            switch (order.Sex)
            {
            case 0:
                csvValue = csvValue.Replace("@05", "O");
                break;

            case 1:
                csvValue = csvValue.Replace("@05", "M");
                break;

            case 2:
                csvValue = csvValue.Replace("@05", "F");
                break;
            }

            csvValue = csvValue.Replace("@06", order.BirthDay);
            csvValue = csvValue.Replace("@07", order.PatAge.ToString());
            csvValue = csvValue.Replace("@08", order.Date);
            csvValue = csvValue.Replace("@09", order.Time);
            csvValue = csvValue.Replace("@10", order.Modality);
            csvValue = csvValue.Replace("@11", order.IsEmergency.ToString());
            csvValue = csvValue.Replace("@12", order.Comment);
            csvValue = csvValue.Replace("@13", msg3);
            csvValue = csvValue.Replace("@14", msg4);
            csvValue = csvValue.Replace("@15", hospCd);
            csvValue = csvValue.Replace("@16", hospName);
            csvValue = csvValue.Replace("@17", order.BodyPart);
            csvValue = csvValue.Replace("@18", order.Type);

            csvValue = csvValue.Replace("@19", cntA);

            if (string.IsNullOrEmpty(cntB) || string.IsNullOrEmpty(cntB.Trim()))
            {
                csvValue = csvValue.Replace("@20", "none");
            }
            else
            {
                csvValue = csvValue.Replace("@20", cntB);
            }

            csvValue = csvValue.Replace("@21", hospCd + order.OrderNo);


            var    fileName = hospCd + order.OrderNo + DateTime.Now.ToString("yyyyMMddHHmmssfff");
            string triPath  = ConfigurationManager.AppSettings["ExtraDir_P"];
            string triExt   = ConfigurationManager.AppSettings["ExtraExt_P"];

            using (var sw = new System.IO.StreamWriter(System.IO.Path.Combine(triPath, fileName) + ".csv", false, System.Text.Encoding.GetEncoding("Shift-JIS")))
                sw.WriteLine(csvValue);

            if (!string.IsNullOrEmpty(triExt))
            {
                var dat = System.IO.File.Create(System.IO.Path.Combine(triPath, fileName) + "." + triExt);
                dat.Close();
            }
        }
Ejemplo n.º 7
0
        private void WriteCSV(PreOrder order, string msg1, string msg2, string msg3, string msg4, string cntA, string cntB)
        {
            string mstPath        = "";
            string outPath        = "";
            string orderPath      = "";
            string outPath_back   = "";
            string orderPath_back = "";

            ServiceIF serv = new ServiceIF();

            HospMst[] hospList;
            HospMst   hospMst = new HospMst();

            serv.GetHospList_Serv(out hospList);

            foreach (var hosp in hospList)
            {
                if (order.HospID == hosp.HospID)
                {
                    hospMst = hosp;
                    break;
                }
            }

            mstPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["MastDir"], hospMst.CD + ".csv");
            outPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["CsvDir"], hospMst.CD);

            string backDef = System.IO.Path.Combine(ConfigurationManager.AppSettings["BackDir"], hospMst.CD);

            backDef = System.IO.Path.Combine(backDef, DateTime.Now.ToString("yyyyMMdd"));

            if (!System.IO.Directory.Exists(backDef))
            {
                System.IO.Directory.CreateDirectory(backDef);
            }

            outPath_back = System.IO.Path.Combine(backDef, "CSV");
            if (!System.IO.Directory.Exists(outPath_back))
            {
                System.IO.Directory.CreateDirectory(outPath_back);
            }


            if (order.IsEmergency == 1)
            {
                orderPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["OrderDir"], "☆緊急☆" + hospMst.Name + "_" + order.OrderID + ".txt");
            }
            else
            {
                orderPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["OrderDir"], "【依頼】" + hospMst.Name + "_" + order.OrderID + ".txt");
            }

            orderPath_back = System.IO.Path.Combine(backDef, System.IO.Path.GetFileName(orderPath));

            var csvValue = "";

            using (var sr = new System.IO.StreamReader(mstPath, System.Text.Encoding.GetEncoding("Shift-JIS")))
            {
                csvValue = sr.ReadLine();
            }

            csvValue = csvValue.Replace("@00", order.PatID);
            csvValue = csvValue.Replace("@01", order.PatName);
            csvValue = csvValue.Replace("@02", order.PatName_H);
            switch (order.Sex)
            {
            case 0:
                csvValue = csvValue.Replace("@03", "O");
                break;

            case 1:
                csvValue = csvValue.Replace("@03", "M");
                break;

            case 2:
                csvValue = csvValue.Replace("@03", "F");
                break;
            }

            csvValue = csvValue.Replace("@04", order.BirthDay);
            csvValue = csvValue.Replace("@05", order.PatAge.ToString());
            csvValue = csvValue.Replace("@06", order.Date);
            csvValue = csvValue.Replace("@07", order.Time);
            csvValue = csvValue.Replace("@08", order.Modality);
            csvValue = csvValue.Replace("@09", order.IsEmergency.ToString());
            csvValue = csvValue.Replace("@10", order.Comment);
//            csvValue = csvValue.Replace("@11", msg + " " + msg3);
            csvValue = csvValue.Replace("@11", msg3);
            csvValue = csvValue.Replace("@12", msg4);
            csvValue = csvValue.Replace("@13", order.IsMail.ToString());
            csvValue = csvValue.Replace("@14", hospMst.CD);
            csvValue = csvValue.Replace("@15", hospMst.Name);
            csvValue = csvValue.Replace("@16", order.BodyPart);
            csvValue = csvValue.Replace("@17", order.Type);

            csvValue = csvValue.Replace("@18", order.OrderID.ToString());

            csvValue = csvValue.Replace("@19", cntA);

            if (string.IsNullOrEmpty(cntB) || string.IsNullOrEmpty(cntB.Trim()))
            {
                csvValue = csvValue.Replace("@20", "none");
            }
            else
            {
                csvValue = csvValue.Replace("@20", cntB);
            }


            var fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff");

            using (var sw = new System.IO.StreamWriter(System.IO.Path.Combine(outPath, fileName) + ".csv", false, System.Text.Encoding.GetEncoding("Shift-JIS")))
            {
                sw.WriteLine(csvValue);
            }

            var dat = System.IO.File.Create(System.IO.Path.Combine(outPath, fileName) + ".txt");

            dat.Close();

            if (!string.IsNullOrEmpty(msg3))
            {
                var checkDir = ConfigurationManager.AppSettings["CheckDir"];
                var idxFile  = System.IO.Path.Combine(checkDir, hospMst.CD + ".txt");
                if (!System.IO.File.Exists(idxFile))
                {
                    msg3 = ConfigurationManager.AppSettings["CheckVal"] + " " + msg3;
                    using (var sw = new System.IO.StreamWriter(idxFile, false, System.Text.Encoding.GetEncoding("Shift-JIS")))
                        sw.Close();
                }
            }

            using (var sw = new System.IO.StreamWriter(orderPath, false, System.Text.Encoding.GetEncoding("Shift-JIS")))
            {
                sw.WriteLine(order.PatID);
                sw.WriteLine("");
                sw.WriteLine("" + order.PatName + "(" + order.PatName_H + ")");
                sw.WriteLine("");
                sw.WriteLine(order.Modality);
                sw.WriteLine("");
                sw.WriteLine(order.Date);
                sw.WriteLine("");
                sw.WriteLine(msg2);
                sw.WriteLine("");
                sw.WriteLine(msg3);
            }

            using (var sw = new System.IO.StreamWriter(System.IO.Path.Combine(outPath_back, fileName) + ".csv", false, System.Text.Encoding.GetEncoding("Shift-JIS")))
            {
                sw.WriteLine(csvValue);
            }
            using (var sw = new System.IO.StreamWriter(orderPath_back, false, System.Text.Encoding.GetEncoding("Shift-JIS")))
            {
                sw.WriteLine(order.PatID);
                sw.WriteLine("");
                sw.WriteLine("" + order.PatName + "(" + order.PatName_H + ")");
                sw.WriteLine("");
                sw.WriteLine(order.Modality);
                sw.WriteLine("");
                sw.WriteLine(order.Date);
                sw.WriteLine("");
                sw.WriteLine(msg2);
                sw.WriteLine("");
                sw.WriteLine(msg3);
            }
        }
Ejemplo n.º 8
0
        public WebResult SetPreOrder(string[] values)
        {
            WebResult ret = new WebResult();

            try
            {
                ServiceIF serv  = new ServiceIF();
                PreOrder  order = new PreOrder();
                string    msg   = "";
                string    msg2  = "";
                string    msg3  = "";

                List <string> pastIds = new List <string>();

                order.HospID = Convert.ToInt32(values[0]);
                if (!string.IsNullOrEmpty(values[1]))
                {
                    order.OrderID = Convert.ToInt32(values[1]);
                }
                else
                {
                    order.OrderID = 0;
                }
                order.PatID       = values[2];
                order.PatName     = values[3];
                order.PatName_H   = values[4];
                order.PatAge      = Convert.ToInt32(values[5]);
                order.BirthDay    = values[6];
                order.Modality    = values[7];
                order.Date        = values[8];
                order.Time        = values[9];
                order.BodyPart    = values[10];
                order.Type        = values[11];
                order.ImgCnt      = Convert.ToInt32(values[12]);
                order.IsEmergency = Convert.ToInt32(values[13]);
                order.IsMail      = Convert.ToInt32(values[14]);
                order.Comment     = values[15];
                order.Sex         = Convert.ToInt32(values[16]);
                order.Status      = 1;
                if (values[17] != "")
                {
                    msg2 = "別途依頼票あり";
                }

                if (order.IsMail == 1)
                {
                    msg3 = values[19] + " " + values[18];
                }

                if (values.Length > 20)
                {
                    for (int i = 20; i < values.Length; i++)
                    {
                        pastIds.Add(values[i]);
                    }
                }

                int key = 0;

                serv.SetPatient_Serv(order, out key);
                order.Key = key;

                ResultData inRet = serv.SetPreOrder_Serv(order);

                if (inRet.Result)
                {
                    LogControl.WriteLog(LogType.ORE, "SetPreOrder", "【オーダー登録】 施設ID:" + order.HospID + " 患者ID:" + order.PatID + " モダリティ:" + order.Modality + " 検査日:" + order.Date);

                    OrderTool_Serv.Class.Search search = new OrderTool_Serv.Class.Search();
                    search.PatID = order.PatID;

                    PreOrder[] tmpOrders;

                    serv.GetPreOrder_Serv(search, out tmpOrders);
                    var msg4 = "";
                    foreach (var odr in tmpOrders)
                    {
                        if (pastIds.Contains(odr.OrderID.ToString()))
                        {
                            odr.Status = 2;
                            serv.SetPreOrder_Serv(odr);

                            if (!string.IsNullOrEmpty(msg))
                            {
                                msg  += "、";
                                msg4 += "、";
                            }
                            msg  += odr.Date.Substring(4, 2) + "/" + odr.Date.Substring(6, 2);
                            msg4 += odr.Date.Substring(0, 4) + "/" + odr.Date.Substring(4, 2) + "/" + odr.Date.Substring(6, 2);
                            if (order.Modality != odr.Modality)
                            {
                                msg4 += " ";
                                msg4 += odr.Modality;
                                msg  += " ";
                                msg  += odr.Modality;
                            }
                            msg += " ";
                            msg += odr.ImgCnt.ToString();
                        }
                        else if (order.Date == odr.Date &&
                                 order.Modality == odr.Modality &&
                                 order.PatID == odr.PatID &&
                                 order.Time == odr.Time)
                        {
                            if (order.OrderID == 0)
                            {
                                order.OrderID = odr.OrderID;
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(msg4))
                    {
                        msg4 = "比較参照お願いします。(" + msg4 + ")" + msg2;
                    }
                    else
                    {
                        msg4 = msg2;
                    }

                    string cA = order.ImgCnt.ToString();
                    string cB = msg;

                    if (string.IsNullOrEmpty(msg))
                    {
                        msg = order.ImgCnt.ToString();
                    }
                    else
                    {
                        msg = order.ImgCnt.ToString() + "(" + msg + ")";
                    }

                    WriteCSV(order, msg, msg2, msg3, msg4, cA, cB);

                    ret.Result = inRet.Result;
                }
                else
                {
                    ret.Message = inRet.Message;
                }

                ret.Result = inRet.Result;
            }
            catch (Exception e)
            {
                ret.Result  = false;
                ret.Message = "処理中に障害が発生いたしました。\nシステム管理者にお問い合わせください。";
                LogControl.WriteLog(LogType.ERR, "WebGetList", e.Message);
            }

            return(ret);
        }