Exemplo n.º 1
0
        public void ShowExt1and2SubRecord(dri_phdb driSR, int mzjldid, int type)
        {
            short so1 = driSR.ext1.ecg12.stII;
            short so2 = driSR.ext1.ecg12.stV5;
            short so3 = driSR.ext1.ecg12.stAVL;

            string pathcsv = Path.Combine(Directory.GetCurrentDirectory(), "AS3ExportData.csv");

            ValidateAddData(so1, 0.01, false);
            string s1 = ValidateDataFormatString(so1, 0.01, false);

            ValidateAddData(so2, 0.01, false);
            string s2 = ValidateDataFormatString(so2, 0.01, false);

            ValidateAddData(so3, 0.01, false);
            string s3 = ValidateDataFormatString(so3, 0.01, false);

            short so4  = driSR.ext2.ent.eeg_ent;
            short so5  = driSR.ext2.ent.emg_ent;
            short so6  = driSR.ext2.ent.bsr_ent;
            short so7  = driSR.ext2.eeg_bis.bis;
            short so8  = driSR.ext2.eeg_bis.sr_val;
            short so9  = driSR.ext2.eeg_bis.emg_val;
            short so10 = driSR.ext2.eeg_bis.sqi_val;

            ValidateAddData(so4, 1, true);
            ValidateAddData(so5, 1, true);
            ValidateAddData(so6, 1, true);
            ValidateAddData(so7, 1, true);
            ValidateAddData(so8, 1, true);
            ValidateAddData(so9, 1, true);
            ValidateAddData(so10, 1, true);
            // int fa = dal.insertJianCeData1(mzjldid, so1, so2, so3, so4, so5, so6, so7, so8, so9, so10, so10, so10);

            //ExportInDB(mzjldid);
            //ExportToCSVFile(pathcsv);
            //Console.WriteLine("ST II {0:0.0}mm ST V5 {1:0.0}mm ST aVL {2:0.0}mm", s1, s2, s3);
            //Clear Stringbuilder member last
            m_strBuilder.Clear();
        }
Exemplo n.º 2
0
        public void ReadSubRecords(int mzjldid, int type, string rrc)
        {
            foreach (datex_record_type dx_record in RecordList)
            {
                short[] sroffArray  = { dx_record.hdr.sr_offset1, dx_record.hdr.sr_offset2, dx_record.hdr.sr_offset3, dx_record.hdr.sr_offset4, dx_record.hdr.sr_offset5, dx_record.hdr.sr_offset6, dx_record.hdr.sr_offset7, dx_record.hdr.sr_offset8 };
                byte[]  srtypeArray = { dx_record.hdr.sr_type1, dx_record.hdr.sr_type2, dx_record.hdr.sr_type3, dx_record.hdr.sr_type4, dx_record.hdr.sr_type5, dx_record.hdr.sr_type6, dx_record.hdr.sr_type7, dx_record.hdr.sr_type8 };

                uint     unixtime   = dx_record.hdr.r_time;
                dri_phdb phdata_ptr = new dri_phdb();

                for (int i = 0; i < 8 && (srtypeArray[i] != 0xFF); i++)
                {
                    if (srtypeArray[i] == DataConstants.DRI_PH_DISPL && srtypeArray[i] != 0xFF)
                    {
                        int offset = (int)sroffArray[i];

                        byte[] buffer = new byte[270];
                        for (int j = 0; j < 270; j++)
                        {
                            buffer[j] = dx_record.data[4 + j + offset];
                        }

                        GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

                        /*int uMemlen = buffer.GetLength(0);
                         * IntPtr ptr = Marshal.AllocHGlobal(uMemlen);
                         * Marshal.Copy(buffer, 0, ptr, uMemlen);*/


                        switch (i)
                        {
                        case 0:
                            Marshal.PtrToStructure(handle.AddrOfPinnedObject(), phdata_ptr.basic);
                            //Marshal.PtrToStructure(ptr, phdata_ptr.basic);
                            break;

                        case 1:
                            Marshal.PtrToStructure(handle.AddrOfPinnedObject(), phdata_ptr.ext1);
                            //Marshal.PtrToStructure(ptr, phdata_ptr.ext1);
                            break;

                        case 2:
                            Marshal.PtrToStructure(handle.AddrOfPinnedObject(), phdata_ptr.ext2);
                            //Marshal.PtrToStructure(ptr, phdata_ptr.ext2);
                            break;

                        case 3:
                            Marshal.PtrToStructure(handle.AddrOfPinnedObject(), phdata_ptr.ext3);
                            //Marshal.PtrToStructure(ptr, phdata_ptr.ext3);
                            break;
                        }

                        handle.Free();
                        //Marshal.FreeHGlobal(ptr);
                    }
                }
                // Unix timestamp is seconds past epoch
                DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                //dtDateTime = dtDateTime.AddSeconds(unixtime).ToLocalTime();
                dtDateTime = dtDateTime.AddSeconds(unixtime);

                //Console.WriteLine();
                //Console.WriteLine("Time:{0}", dtDateTime.ToString());
                m_strBuilder.Append(dtDateTime.ToShortDateString());
                m_strBuilder.Append(',');
                m_strBuilder.Append(dtDateTime.ToLongTimeString());
                m_strBuilder.Append(',');

                ShowBasicSubRecord(phdata_ptr, mzjldid, type, rrc);
                ShowExt1and2SubRecord(phdata_ptr, mzjldid, type);
            }
        }
Exemplo n.º 3
0
        public void ShowBasicSubRecord(dri_phdb driSR, int mzjldid, int type, string rrc)
        {
            short so1 = driSR.basic.ecg.hr;    //心率
            short so2 = driSR.basic.nibp.sys;  //收缩压
            short so3 = driSR.basic.nibp.dia;  //舒张压
            short so4 = driSR.basic.nibp.mean; //平均压
            short so5 = driSR.basic.SpO2.SpO2; //SpO2
            short so6 = driSR.basic.co2.et;    //ETCO2

            string s1 = ValidateDataFormatString(so1, 1, true);

            ValidateAddData(so1, 1, true);
            string s2 = ValidateDataFormatString(so2, 0.01, true);

            ValidateAddData(so2, 0.01, true);
            string s3 = ValidateDataFormatString(so3, 0.01, true);

            ValidateAddData(so3, 0.01, true);
            string s4 = ValidateDataFormatString(so4, 0.01, true);

            ValidateAddData(so4, 0.01, true);
            string s5 = ValidateDataFormatString(so5, 0.01, true);

            ValidateAddData(so5, 0.01, true);
            double et = (so6 * driSR.basic.co2.amb_press);

            ValidateAddData(et, 0.00001, true);
            string s6 = ValidateDataFormatString(et, 0.00001, true);

            int soo1 = int.Parse(s1);
            int soo2 = int.Parse(s2);
            int soo3 = int.Parse(s3);
            int soo4 = int.Parse(s4);
            int soo5 = int.Parse(s5);
            int soo6 = int.Parse(s6);

            short  so7  = driSR.basic.aa.et;
            short  so8  = driSR.basic.aa.fi;
            short  so9  = driSR.basic.aa.mac_sum;
            ushort so10 = driSR.basic.aa.hdr.label_info;

            ValidateAddData(so7, 0.01, false);
            ValidateAddData(so8, 0.01, false);
            ValidateAddData(so9, 0.01, false);

            string s10 = "";

            switch (so10)
            {
            case 0:
                s10 = "Unknown";
                break;

            case 1:
                s10 = "None";
                break;

            case 2:
                s10 = "HAL";
                break;

            case 3:
                s10 = "ENF";
                break;

            case 4:
                s10 = "ISO";
                break;

            case 5:
                s10 = "DES";
                break;

            case 6:
                s10 = "SEV";
                break;
            }

            m_strBuilder.Append(s10);
            m_strBuilder.Append(',');

            double so11 = driSR.basic.o2.fi;
            double so12 = driSR.basic.n2o.fi;
            double so13 = driSR.basic.n2o.et;
            double so14 = driSR.basic.co2.rr;  //呼吸
            float  so15 = driSR.basic.t1.temp; //体温
            float  so16 = driSR.basic.t2.temp;

            double so17 = driSR.basic.p1.hr;
            double so18 = driSR.basic.p1.sys;
            double so19 = driSR.basic.p1.dia;
            double so20 = driSR.basic.p1.mean;
            double so21 = driSR.basic.p2.hr;
            double so22 = driSR.basic.p2.sys;
            double so23 = driSR.basic.p2.dia;
            double so24 = driSR.basic.p2.mean;

            double so25 = driSR.basic.flow_vol.ppeak;
            double so26 = driSR.basic.flow_vol.pplat;
            double so27 = driSR.basic.flow_vol.tv_exp;

            ValidateAddData(so11, 0.01, false);
            ValidateAddData(so12, 0.01, false);
            ValidateAddData(so13, 0.01, false);
            ValidateAddData(so14, 1, false);
            ValidateAddData(so15, 0.01, false);
            ValidateAddData(so16, 0.01, false);
            string s14   = ValidateDataFormatString(so14, 1, true);
            int    soo14 = int.Parse(s14);

            ValidateAddData(so17, 1, true);
            ValidateAddData(so18, 0.01, true);
            ValidateAddData(so19, 0.01, true);
            ValidateAddData(so20, 0.01, true);
            ValidateAddData(so21, 1, true);
            ValidateAddData(so22, 0.01, true);
            ValidateAddData(so23, 0.01, true);
            ValidateAddData(so24, 0.01, true);

            ValidateAddData(so25, 0.01, true);
            ValidateAddData(so26, 0.01, true);
            ValidateAddData(so27, 0.1, true);

            string s9    = ValidateDataFormatString(so9, 0.01, false);
            string s15   = ValidateDataFormatString(so15, 0.01, false);
            string s16   = ValidateDataFormatString(so16, 0.01, false);
            double soo16 = double.Parse(s16);
            string s18   = ValidateDataFormatString(so18, 0.01, true);
            string s19   = ValidateDataFormatString(so19, 0.01, true);
            string s20   = ValidateDataFormatString(so20, 0.01, true);

            int    soo18 = int.Parse(s18);
            int    soo19 = int.Parse(s19);
            int    soo20 = int.Parse(s20);
            string s22   = ValidateDataFormatString(so22, 0.01, true);
            string s23   = ValidateDataFormatString(so23, 0.01, true);
            string s24   = ValidateDataFormatString(so24, 0.01, true);
            int    soo22 = int.Parse(s22);
            int    soo23 = int.Parse(s23);
            int    soo24 = int.Parse(s24);

            if (soo14 <= 0)
            {
                Random rd = new Random();
                soo14 = (int)(rd.Next(14, 20));
            }
            if (soo16 <= 0)
            {
                soo16 = 36.7;
            }
            //DateTime now=DateTime.Parse(DateTime.Now.ToString("yyyy/MM/dd HH:mm"));
            string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

            if (sqlite.selectJianCeData(now, mzjldid, type).Rows.Count == 0)
            {
                int fa = 0;
                if (rrc == null)
                {
                    soo14 = soo5 / 4;

                    //RR =Convert.ToInt32(rrc);
                }//机械值
                else if (rrc.IsNullOrEmpty())//根据氧和赋值
                {
                    soo14 = soo5 / 4;
                }
                else
                {
                    soo14 = Convert.ToInt32(rrc);
                }
                if (soo14 == 0)//根据氧和赋值
                {
                    soo14 = soo5 / 4;
                }
                if (soo18 != 0 && soo19 != 0 && soo20 != 0)
                {
                    if (type == 0)
                    {
                        fa = sqlite.insertJianCeDataMZJLD(mzjldid, soo18, soo19, soo20, soo14, soo1, soo1, soo5, soo6, soo16, soo24, now);
                    }
                    if (type == 1)
                    {
                        fa = sqlite.insertJianCeDataPACU(mzjldid, soo18, soo19, soo20, soo14, soo1, soo1, soo5, soo6, so16, now);
                    }
                }
                else
                {
                    if (type == 0)
                    {
                        fa = sqlite.insertJianCeDataMZJLD(mzjldid, soo2, soo3, soo4, soo14, soo1, soo1, soo5, soo6, soo16, soo24, now);
                    }
                    if (type == 1)
                    {
                        fa = sqlite.insertJianCeDataPACU(mzjldid, soo2, soo3, soo4, soo14, soo1, soo1, soo5, soo6, so16, now);
                    }
                }
            }

            //Console.WriteLine("ECG HR {0:d}/min NIBP {1:d}/{2:d}({3:d})mmHg SpO2 {4:d}% ETCO2 {5:d}mmHg", s1, s2, s3, s4, s5, s6);
            //Console.WriteLine("IBP1 {0:d}/{1:d}({2:d})mmHg IBP2 {3:d}/{4:d}({5:d})mmHg MAC {6} T1 {7}°C T2 {8}°C", s18, s19, s20, s22, s23, s24, s9, s15, s16);
        }
Exemplo n.º 4
0
        public void ShowBasicSubRecord(dri_phdb driSR, int mzjldid, int type)
        {
            short so1 = driSR.basic.ecg.hr;    //心率
            short so2 = driSR.basic.nibp.sys;  //收缩压
            short so3 = driSR.basic.nibp.dia;  //舒张压
            short so4 = driSR.basic.nibp.mean; //平均压
            short so5 = driSR.basic.SpO2.SpO2; //SpO2
            short so6 = driSR.basic.co2.et;    //ETCO2

            string s1 = ValidateDataFormatString(so1, 1, true);

            ValidateAddData(so1, 1, true);
            string s2 = ValidateDataFormatString(so2, 0.01, true);

            ValidateAddData(so2, 0.01, true);
            string s3 = ValidateDataFormatString(so3, 0.01, true);

            ValidateAddData(so3, 0.01, true);
            string s4 = ValidateDataFormatString(so4, 0.01, true);

            ValidateAddData(so4, 0.01, true);
            string s5 = ValidateDataFormatString(so5, 0.01, true);

            ValidateAddData(so5, 0.01, true);
            double et = (so6 * driSR.basic.co2.amb_press);

            ValidateAddData(et, 0.00001, true);
            string s6 = ValidateDataFormatString(et, 0.00001, true);

            int soo1 = int.Parse(s1);
            int soo2 = int.Parse(s2);
            int soo3 = int.Parse(s3);
            int soo4 = int.Parse(s4);
            int soo5 = int.Parse(s5);
            int soo6 = int.Parse(s6);

            short  so7  = driSR.basic.aa.et;
            short  so8  = driSR.basic.aa.fi;
            short  so9  = driSR.basic.aa.mac_sum;
            ushort so10 = driSR.basic.aa.hdr.label_info;

            ValidateAddData(so7, 0.01, false);
            ValidateAddData(so8, 0.01, false);
            ValidateAddData(so9, 0.01, false);

            string s10 = "";

            switch (so10)
            {
            case 0:
                s10 = "Unknown";
                break;

            case 1:
                s10 = "None";
                break;

            case 2:
                s10 = "HAL";
                break;

            case 3:
                s10 = "ENF";
                break;

            case 4:
                s10 = "ISO";
                break;

            case 5:
                s10 = "DES";
                break;

            case 6:
                s10 = "SEV";
                break;
            }

            m_strBuilder.Append(s10);
            m_strBuilder.Append(',');

            double so11 = driSR.basic.o2.fi;
            double so12 = driSR.basic.n2o.fi;
            double so13 = driSR.basic.n2o.et;
            double so14 = driSR.basic.co2.rr;  //呼吸
            double so15 = driSR.basic.t1.temp; //体温

            double so16 = Convert.ToDouble(driSR.basic.t2.temp.ToString("f1"));

            double so17 = driSR.basic.p1.hr;
            double so18 = driSR.basic.p1.sys;
            double so19 = driSR.basic.p1.dia;
            double so20 = driSR.basic.p1.mean;
            double so21 = driSR.basic.p2.hr;
            double so22 = driSR.basic.p2.sys;
            double so23 = driSR.basic.p2.dia;
            double so24 = driSR.basic.p2.mean;

            double so25 = driSR.basic.flow_vol.ppeak;
            double so26 = driSR.basic.flow_vol.pplat;
            double so27 = driSR.basic.flow_vol.tv_exp;

            ValidateAddData(so11, 0.01, false);
            ValidateAddData(so12, 0.01, false);
            ValidateAddData(so13, 0.01, false);
            ValidateAddData(so14, 1, false);
            ValidateAddData(so15, 0.01, false);
            ValidateAddData(so16, 0.01, false);
            string s14   = ValidateDataFormatString(so14, 1, true);
            int    soo14 = int.Parse(s14);

            ValidateAddData(so17, 1, true);
            ValidateAddData(so18, 0.01, true);
            ValidateAddData(so19, 0.01, true);
            ValidateAddData(so20, 0.01, true);
            ValidateAddData(so21, 1, true);
            ValidateAddData(so22, 0.01, true);
            ValidateAddData(so23, 0.01, true);
            ValidateAddData(so24, 0.01, true);

            ValidateAddData(so25, 0.01, true);
            ValidateAddData(so26, 0.01, true);
            ValidateAddData(so27, 0.1, true);

            string s9   = ValidateDataFormatString(so9, 0.01, false);
            string s15  = ConvertDataString(so15, 0.01);
            string s16  = ConvertDataString(so16, 0.01);
            double tp16 = double.Parse(s16);
            double tp15 = double.Parse(s15);
            double temp = 0.0;

            if (tp16 > tp15)
            {
                temp = tp16;
                // temp = tp16.ToString("f1");
            }
            else
            {
                temp = tp15;
            }
            //temp = tp15.ToString("f1");
            //double temp = Convert.ToDouble(tempStr);

            if (temp <= 0)
            {
                so16 = 0;
            }


            string s18 = ValidateDataFormatString(so18, 0.01, true);
            string s19 = ValidateDataFormatString(so19, 0.01, true);
            string s20 = ValidateDataFormatString(so20, 0.01, true);

            int    soo18 = int.Parse(s18);
            int    soo19 = int.Parse(s19);
            int    soo20 = int.Parse(s20);
            string s22   = ValidateDataFormatString(so22, 0.01, true);
            string s23   = ValidateDataFormatString(so23, 0.01, true);
            string s24   = ValidateDataFormatString(so24, 0.01, true);

            if (soo14 <= 0)
            {
                Random rd = new Random();
                soo14 = (int)(rd.Next(14, 20));
            }
            MonitorRecord mr = new MonitorRecord();

            mr.MZJLDID = mzjldid;
            mr.SYS     = soo2;
            mr.DIA     = soo3;
            mr.MEAN    = soo4;
            if (soo18 != 0 && soo19 != 0 && soo20 != 0)
            {
                mr.SYS  = soo18;
                mr.DIA  = soo19;
                mr.MEAN = soo20;
            }
            mr.HR    = soo1;
            mr.RR    = soo14;
            mr.Pulse = soo1;
            mr.SPO2  = soo5;
            mr.ETCO2 = soo6;
            mr.TEMP  = temp;
            mr.TOF   = 0;
            mr.BIS   = 0;
            string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

            mr.TIME = now;
            if (sh.selectJianCeData(now, mzjldid, type).Rows.Count == 0)//判断本地数据库中这个时间段这条数据有没
            {
                LogHelp.SaveMonitorLog(DateTime.Now.ToString() +
                                       string.Format(" -- HR {0:d}/min NIBP {1:d}/{2:d}({3:d})mmHg SpO2 {4:d}% ETCO2 {5:d}mmHg T1 {6}°C T2 {7}°C T3 {8}°C T4 {8}°C",
                                                     s1, s2, s3, s4, s5, s6, s15, s16, tp15, tp16),
                                       Application.StartupPath + "\\MonitorLog.txt");
                int fa = 0;
                if (type == 0)
                {
                    fa = sh.insertMonitorRecord(mr);
                }
                //fa = sh.insertJianCeDataMZJLD(mzjldid, soo18, soo19, soo20, soo14, soo1, soo1, soo5, soo6, temp, now); //插入服务器
                if (type == 1)
                {
                    fa = sh.insertMonitorRecord_PACU(mr);
                }
                //fa = sh.insertJianCeDataPACU(mzjldid, soo18, soo19, soo20, soo14, soo1, soo1, soo5, soo6, temp, now);//插入服务器
            }

            //Console.WriteLine("ECG HR {0:d}/min NIBP {1:d}/{2:d}({3:d})mmHg SpO2 {4:d}% ETCO2 {5:d}mmHg", s1, s2, s3, s4, s5, s6);
            //Console.WriteLine("IBP1 {0:d}/{1:d}({2:d})mmHg IBP2 {3:d}/{4:d}({5:d})mmHg MAC {6} T1 {7}°C T2 {8}°C", s18, s19, s20, s22, s23, s24, s9, s15, s16);
        }