コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }