349 lines
15 KiB
C#
349 lines
15 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
using EAS.Services;
|
||
using SOH.BLL;
|
||
using SOH.JianYan.YiQi.Base;
|
||
|
||
namespace SOH.JianYan.DEC_Axceed260
|
||
{
|
||
public partial class Axceed260 : SOH.JianYan.YiQi.Base.baseMain
|
||
{
|
||
string _yqbm = "";
|
||
public Axceed260()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void Axceed260_Load(object sender, EventArgs e)
|
||
{
|
||
System.Configuration.Configuration conf = System.Configuration.ConfigurationManager.OpenExeConfiguration(Application.StartupPath + "\\local.ext");
|
||
|
||
if (conf.AppSettings.Settings.AllKeys.Contains("yqbm"))
|
||
{
|
||
_yqbm = conf.AppSettings.Settings["yqbm"].Value;
|
||
}
|
||
conf.Save();
|
||
if (System.IO.File.Exists(Application.StartupPath + "\\SOH.OnLine.exe"))
|
||
{
|
||
System.Diagnostics.Process p = System.Diagnostics.Process.Start(Application.StartupPath + "\\SOH.OnLine.exe");
|
||
Program.ps = p;
|
||
}
|
||
}
|
||
|
||
protected override void decoder()
|
||
{
|
||
|
||
base.decoder();
|
||
string decodefile = Application.StartupPath + "\\raw\\data.txt";
|
||
if (System.IO.File.Exists(decodefile))
|
||
{
|
||
int a = 0;
|
||
string data = "";
|
||
aa:
|
||
try
|
||
{
|
||
FileStream fs = new FileStream(decodefile, FileMode.Open, FileAccess.Read, FileShare.None);
|
||
StreamReader sr = new StreamReader(fs);
|
||
data = sr.ReadToEnd();
|
||
sr.Close();
|
||
sr.Dispose();
|
||
|
||
|
||
}
|
||
catch
|
||
{
|
||
a++;
|
||
if (a > 11)
|
||
goto aa;
|
||
}
|
||
if (data.EndsWith("\u001c\u000d"))
|
||
{
|
||
File.Delete(decodefile);
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
while (data.Length > 0)
|
||
{
|
||
int post = 0;
|
||
post = data.IndexOf("\u001c\u000d");
|
||
if (post < 0)
|
||
return;
|
||
string decdata = data.Substring(0, post + 2);
|
||
decdata = decdata.Replace("\u000b", "");
|
||
decdata = decdata.Replace("\u001c\u000d", "");
|
||
string[] ys = decdata.Split('\u000d');
|
||
DateTime sampledate = DateTime.Now;
|
||
string sampleno = "";
|
||
//ys.Select()
|
||
string msgtype = "";
|
||
string querytime="";
|
||
string queryno="";
|
||
foreach (string y in ys)
|
||
{
|
||
string[] zs = y.Split('|');
|
||
if (zs[0] == "MSH")
|
||
{
|
||
Lis_RiZhi.resultlog(zs[0]);
|
||
if (zs[8] == "ORU^R01")
|
||
{
|
||
//msgid = zs[9];
|
||
msgtype = "sendmsg";
|
||
continue;
|
||
}
|
||
//QRY^Q02
|
||
else if (zs[8]== "QRY^Q02")
|
||
{
|
||
msgtype = "query";
|
||
|
||
continue;
|
||
}
|
||
}
|
||
|
||
if (msgtype == "sendmsg")
|
||
{
|
||
if (zs[0] == "OBR")
|
||
{
|
||
sampleno = zs[2];
|
||
string sj = zs[7];
|
||
sampledate = DateTime.Parse(sj.Substring(0, 4) + "-" + sj.Substring(4, 2) + "-" + sj.Substring(6));
|
||
continue;
|
||
}
|
||
else if (zs[0] == "OBX")
|
||
{
|
||
string tdh, jg;
|
||
tdh = zs[3];
|
||
jg = zs[5];
|
||
if (YiQi.Base.Lis_result.canmodifybyjytm(_yqbm, sampledate, sampleno))
|
||
{
|
||
YiQi.Base.Lis_result.addresult(sampledate, _yqbm, sampleno, tdh, jg);
|
||
}
|
||
}
|
||
}
|
||
else if(msgtype=="query")
|
||
{
|
||
if (zs[0] == "QRD")
|
||
{
|
||
sampleno = zs[8];
|
||
querytime = zs[1];
|
||
queryno = zs[4];
|
||
Lis_RiZhi.resultlog(sampleno);
|
||
Lis_RiZhi.resultlog(querytime);
|
||
Lis_RiZhi.resultlog(queryno);
|
||
|
||
//string sj = zs[7];
|
||
//sampledate = DateTime.Parse(sj.Substring(0, 4) + "-" + sj.Substring(4, 2) + "-" + sj.Substring(6));
|
||
continue;
|
||
}
|
||
}
|
||
continue;
|
||
}
|
||
//接受消息
|
||
if (msgtype == "sendmsg")
|
||
YiQi.Base.Lis_result.calcsample(_yqbm, sampledate.Date, sampleno);
|
||
else if(msgtype=="query")
|
||
{
|
||
if(sampleno.Length!=12)
|
||
{
|
||
Lis_RiZhi.resultlog("条码位数不正确");
|
||
|
||
nosqd();
|
||
}
|
||
else
|
||
{
|
||
var vserver = ServiceContainer.GetService<IJianYan>();
|
||
var yhxx = vserver.getjyyhxxbytm(sampleno);
|
||
if(yhxx == null)
|
||
{
|
||
Lis_RiZhi.resultlog("没有申请单");
|
||
nosqd();
|
||
}
|
||
else
|
||
{
|
||
string lisfile = Application.StartupPath + "\\result";
|
||
if (!Directory.Exists(lisfile))
|
||
{
|
||
Directory.CreateDirectory(lisfile);
|
||
}
|
||
lisfile += "\\lis.txt";
|
||
StreamWriter sw = new StreamWriter(lisfile, false, Encoding.Default);
|
||
/*
|
||
* <SB>MSH|^~\&|||BIOSCIENCE|Axceed 260|20160801114428||QCK^Q02|11|P|2.3.1||||||ASCII|||
|
||
* MSA|AA|11|Message accepted|||0|
|
||
* ERR|0|
|
||
* QAK|SR|OK|
|
||
* <EB><CR>
|
||
*/
|
||
sw.Write("\u000bMSH|^~\\&|||SanCaiNet|SohLis|" + DateTime.Now.ToString("yyyyMMddHHmmss") + "||QCK^Q02|11|P|2.3.1||||||ASCII|||\u000d" +
|
||
"MSA|AA|11|Message accepted|||0|\u000d" +
|
||
"ERR|0|\u000d" +
|
||
"QAK|SR|OK|\u000d" +
|
||
"\u001c\u000d");
|
||
sw.Close();
|
||
Lis_RiZhi.resultlog("\u000bMSH|^~\\&|||SanCaiNet|SohLis|" + DateTime.Now.ToString("yyyyMMddHHmmss") + "||QCK^Q02|11|P|2.3.1||||||ASCII|||\u000d" +
|
||
"MSA|AA|11|Message accepted|||0|\u000d" +
|
||
"ERR|0|\u000d" +
|
||
"QAK|SR|OK|\u000d" +
|
||
"\u001c\u000d");
|
||
Thread.Sleep(300);
|
||
var lisxm = vserver.getjyxmbytm(sampleno,_yqbm);
|
||
Lis_RiZhi.resultlog(lisfile);
|
||
sw = new StreamWriter(lisfile, false, Encoding.Default);
|
||
/*
|
||
MSH|^~\&|||BIOSCIENCE|Axceed 260|20160801114428||DSR^Q03|1|P|2.3.1||||||ASCII|||
|
||
MSH|^~\&|||SanCaiNet|SohLis|20210331104835||DSR^Q03|1|P|2.3.1||||||ASCII|||
|
||
MSA|AA|1|Message accepted|||0|
|
||
ERR|0|
|
||
QAK|SR|OK|
|
||
QRD|20130917114428|D|D|1|||RD|0019|OTH||||
|
||
DSP|1(序号)||1212(住院号)|||
|
||
DSP|2(序号)||27(床号)|||
|
||
DSP|3(序号)||Tommy(病人姓名)|||
|
||
DSP|4(序号)||35(病人年龄)|||
|
||
DSP|5(序号)||SEX_M(病人性别)|||
|
||
DSP|6|||||
|
||
DSP|7|||||
|
||
DSP|8|||||
|
||
DSP|9|||||
|
||
DSP|10|||||
|
||
DSP|11|||||
|
||
DSP|12|||||
|
||
DSP|13|||||
|
||
DSP|14|||||
|
||
DSP|15|||||
|
||
DSP|16|||||
|
||
DSP|17|||||
|
||
DSP|18|||||
|
||
DSP|19|||||
|
||
DSP|20|||||
|
||
DSP|21(序号)||0019(样本条码)|||
|
||
DSP|22(序号)||3(样本编号)|||
|
||
DSP|23|||||
|
||
DSP|24|||||
|
||
DSP|25|||||
|
||
DSP|26(序号)||Ser/PI(样本类型)|||
|
||
DSP|27(序号)||Mary(送检医生)|||
|
||
DSP|28(序号)||Dept1(送检科室)|||
|
||
DSP|29(序号)||100^^^(项目编号)|||
|
||
DSC||
|
||
<EB><CR>
|
||
MSH|^~\&|||SanCaiNet|SohLis|20210331104835||DSR^Q03|11|P|2.3.1||||||ASCII|||
|
||
MSA|AA|11|Message accepted|||0|
|
||
ERR|0|
|
||
QAK|SR|OK|
|
||
QRD|20210331104831|D|D|1|||RD|002117728601|OTH||||DSP|1||21177286|||
|
||
DSP|2|||||
|
||
DSP|3||韩亮|||
|
||
DSP|4||36|||
|
||
DSP|5||SEX_M|||
|
||
DSP|6|||||
|
||
DSP|7|||||
|
||
DSP|8|||||
|
||
DSP|9|||||
|
||
DSP|10|||||
|
||
DSP|11|||||
|
||
DSP|12|||||
|
||
DSP|13|||||
|
||
DSP|14|||||
|
||
DSP|15|||||
|
||
DSP|16|||||
|
||
DSP|17|||||
|
||
DSP|18|||||
|
||
DSP|19|||||
|
||
DSP|20|||||
|
||
DSP|21||002117728601|||
|
||
DSP|22||1|||
|
||
DSP|23|||||
|
||
DSP|24|||||
|
||
DSP|25|||||
|
||
DSP|26||Ser/PI|||
|
||
DSP|27|||||
|
||
DSP|28|||||
|
||
DSP|29||1001^^^|||
|
||
DSP|30||1003^^^|||
|
||
DSC||
|
||
*/
|
||
string reslis ="\u000bMSH|^~\\&|||SanCaiNet|SohLis|" + DateTime.Now.ToString("yyyyMMddHHmmss") + "||DSR^Q03|1|P|2.3.1||||||ASCII|||\u000d" +
|
||
"MSA|AA|1|Message accepted|||0|\u000d" +
|
||
"ERR|0|\u000d" +
|
||
"QAK|SR|OK|\u000d" +
|
||
"QRD|" + querytime + "|D|D|" + queryno + "|||RD|"+sampleno+ "|OTH||||\u000d" +
|
||
"DSP|1||" + yhxx.tm + "|||\u000d" +
|
||
"DSP|2|||||\u000d" +
|
||
"DSP|3||" + yhxx.xm + "|||\u000d" +
|
||
"DSP|4||" + yhxx.nl + "|||\u000d" +
|
||
"DSP|5||" + (yhxx.xb == "男" ? "M" : "F") + "|||\u000d" +
|
||
"DSP|6|||||\u000d" +
|
||
"DSP|7|||||\u000d" +
|
||
"DSP|8|||||\u000d" +
|
||
"DSP|9|||||\u000d" +
|
||
"DSP|10|||||\u000d" +
|
||
"DSP|11|||||\u000d" +
|
||
"DSP|12|||||\u000d" +
|
||
"DSP|13|||||\u000d" +
|
||
"DSP|14|||||\u000d" +
|
||
"DSP|15|||||\u000d" +
|
||
"DSP|16|||||\u000d" +
|
||
"DSP|17|||||\u000d" +
|
||
"DSP|18|||||\u000d" +
|
||
"DSP|19|||||\u000d" +
|
||
"DSP|20|||||\u000d" +
|
||
"DSP|21||" + sampleno + "|||\u000d" +
|
||
"DSP|22||" + yhxx.bbh + "|||\u000d" +
|
||
"DSP|23|||||\u000d" +
|
||
"DSP|24|||||\u000d" +
|
||
"DSP|25|||||\u000d" +
|
||
"DSP|26||Ser/PI|||\u000d" +
|
||
"DSP|27|||||\u000d" +
|
||
"DSP|28|||||\u000d";
|
||
int xh = 29;
|
||
foreach(var xm in lisxm)
|
||
{
|
||
reslis+="DSP|"+xh+"||"+xm.tdh+"^^^|||\u000d";
|
||
xh++;
|
||
}
|
||
reslis += "DSC||\u000d";
|
||
reslis += "\u001c\u000d";
|
||
sw.Write(reslis);
|
||
sw.Close();
|
||
Lis_RiZhi.resultlog(reslis);
|
||
Lis_RiZhi.resultlog("输出成功!");
|
||
}
|
||
}
|
||
}
|
||
data = data.Substring(post + 2);
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
|
||
private void nosqd()
|
||
{
|
||
string lisfile = Application.StartupPath + "\\result";
|
||
if (!Directory.Exists(lisfile))
|
||
{
|
||
Directory.CreateDirectory(lisfile);
|
||
}
|
||
lisfile += "\\lis.txt";
|
||
StreamWriter sw = new StreamWriter(lisfile, false, Encoding.Default);
|
||
sw.Write("\u000bMSH|^~\\&|||SanCaiNet|SohLis|" + DateTime.Now.ToString("yyyyMMddHHmmss") + "||QCK^Q02|11|P|2.3.1||||||ASCII|||\u000d" +
|
||
"MSA|AA|11|Message accepted|||0|\u000d" +
|
||
"ERR|0|\u000d" +
|
||
"QAK|SR|NF|\u000d" +
|
||
"\u001c\u000d");
|
||
sw.Close();
|
||
}
|
||
}
|
||
}
|