Пример #1
0
        private async Task PerformMeasurement()
        {
            var sessionSamples = _model.Length * _config.SampleRate;

            for (var i = 0; i < SessionStarts.Count; ++i)
            {
                if (_model.Type == MeasurementType.ECG)
                {
                    var session = new Session(_iotDeviceService, _logger, _config.Samples)
                    {
                        SessionData   = EcgData.Take(sessionSamples).Skip(i * sessionSamples).ToList(),
                        Id            = i + 1,
                        MeasurementId = _model.Id,
                        Type          = MessageType.Ecg
                    };

                    await session.SendPackages();
                }

                var sleepTime = (SessionStarts.ElementAt(i + 1) - DateTime.UtcNow).Milliseconds;
                Thread.Sleep(sleepTime);
            }
        }
Пример #2
0
        private void gc_EcgList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (_dtEcgDataList.Rows.Count <= 0 || gc_PatientManage.Rows.Count <= 0)
            {
                return;
            }

            if (gc_EcgList.CurrentRow != null)
            {
                int index = gc_EcgList.CurrentRow.Index;
                if (gc_PatientManage.CurrentRow != null)
                {
                    DataRow dr = ((DataRowView)gc_PatientManage.CurrentRow.DataBoundItem).Row;

                    string appId = gc_EcgList.Rows[index].Cells["ApplicationID"].Value.ToString();
                    var    pmd   = new PatientMd();
                    #region 心电图分析
                    //心电图分析
                    if (gc_EcgList.Columns[e.ColumnIndex] == EcgAnalisis)
                    {
                        string isQiBo    = dr["IsQiBo"].ToString();
                        string errorLead = _dtEcgDataList.Rows[index]["errorLead"].ToString();
                        pmd.WardshipId  = _dtEcgDataList.Rows[index]["wardshipId"].ToString();
                        pmd.PatientID   = dr["PatientID"].ToString();
                        pmd.PatientName = dr["PatientName"].ToString();
                        pmd.Gender      = dr["Gender"].ToString();
                        pmd.AgeStart    = string.Empty;
                        if (string.IsNullOrEmpty(dr["Birthday"].ToString().Trim()))
                        {
                            pmd.AgeStart = "0";
                        }
                        else
                        {
                            pmd.AgeStart = (Convert.ToDateTime(pmd.WardshipId).Year - Convert.ToDateTime(dr["Birthday"].ToString().Trim()).Year).ToString();
                        }
                        pmd.P_Id = dr["P_Id"].ToString();

                        pmd.AppId = appId;


                        pmd.Pdstatus = _dtEcgDataList.Rows[index]["InterpretationStatus"].ToString();

                        string status  = _dtEcgDataList.Rows[index]["status"].ToString();
                        bool   isApped = true;

                        pmd.LEU         = _dtEcgDataList.Rows[index]["LEU"].ToString();
                        pmd.NIT         = _dtEcgDataList.Rows[index]["NIT"].ToString();
                        pmd.UBG         = _dtEcgDataList.Rows[index]["UBG"].ToString();
                        pmd.PRO         = _dtEcgDataList.Rows[index]["PRO"].ToString();
                        pmd.PH          = _dtEcgDataList.Rows[index]["PH"].ToString();
                        pmd.BLD         = _dtEcgDataList.Rows[index]["BLD"].ToString();
                        pmd.KET         = _dtEcgDataList.Rows[index]["KET"].ToString();
                        pmd.BIL         = _dtEcgDataList.Rows[index]["BIL"].ToString();
                        pmd.GLU         = _dtEcgDataList.Rows[index]["GLU"].ToString();
                        pmd.VC          = _dtEcgDataList.Rows[index]["VC"].ToString();
                        pmd.SG          = _dtEcgDataList.Rows[index]["SG"].ToString();
                        pmd.Mmol        = _dtEcgDataList.Rows[index]["Mmol"].ToString();
                        pmd.Spo2        = _dtEcgDataList.Rows[index]["Spo2"].ToString();
                        pmd.DIA         = _dtEcgDataList.Rows[index]["DIA"].ToString();
                        pmd.SYS         = _dtEcgDataList.Rows[index]["SYS"].ToString();
                        pmd.Temperature = _dtEcgDataList.Rows[index]["Temperature"].ToString();

                        if (status == "1")
                        {
                            isApped = false;
                        }
                        var evf = new EcgViewFrm(pmd, false, isQiBo, isApped, errorLead)
                        {
                            FormBorderStyle = FormBorderStyle.None,
                            WindowState     = FormWindowState.Maximized
                        };
                        evf.ShowDialog();
                    }
                    #endregion

                    #region 远程申请

                    if (gc_EcgList.Columns[e.ColumnIndex] == LongConnect)
                    {
                        var extContract = new ExtContract {
                            Data = new EcgData[1]
                        };
                        var combination = new Combination
                        {
                            LEU         = _dtEcgDataList.Rows[index]["LEU"].ToString(),
                            NIT         = _dtEcgDataList.Rows[index]["NIT"].ToString(),
                            UBG         = _dtEcgDataList.Rows[index]["UBG"].ToString(),
                            PRO         = _dtEcgDataList.Rows[index]["PRO"].ToString(),
                            PH          = _dtEcgDataList.Rows[index]["PH"].ToString(),
                            BLD         = _dtEcgDataList.Rows[index]["BLD"].ToString(),
                            KET         = _dtEcgDataList.Rows[index]["KET"].ToString(),
                            BIL         = _dtEcgDataList.Rows[index]["BIL"].ToString(),
                            GLU         = _dtEcgDataList.Rows[index]["GLU"].ToString(),
                            VC          = _dtEcgDataList.Rows[index]["VC"].ToString(),
                            SG          = _dtEcgDataList.Rows[index]["SG"].ToString(),
                            Mmol        = _dtEcgDataList.Rows[index]["Mmol"].ToString(),
                            Spo2        = _dtEcgDataList.Rows[index]["Spo2"].ToString(),
                            DIA         = _dtEcgDataList.Rows[index]["DIA"].ToString(),
                            SYS         = _dtEcgDataList.Rows[index]["SYS"].ToString(),
                            Temperature = _dtEcgDataList.Rows[index]["Temperature"].ToString()
                        };
                        extContract.Others = combination;
                        var patient = new Patient
                        {
                            PatientID = dr["PatientID"].ToString(), PatientName = dr["PatientName"].ToString(),
                            NewId     = dr["P_Id"].ToString(),
                            IsQiBo    = dr["IsQiBo"].ToString(),
                            Status    = "1"
                        };
                        extContract.God = patient;

                        var    ecgData = new EcgData();
                        string sqli    =
                            "SELECT data_packs.beginTime,pureData,LeadEndTime,data_packs.EcgFilter,data_packs.IsLead,data_packs.PaceLocs FROM data_packs inner join tb_Application on data_packs.ApplicationID=tb_Application.ApplicationID  WHERE  data_packs.applicationID='" +
                            appId + "' and isLead='0' order by beginTime asc limit 1 offset 0";
                        DataTable dtBeginTime = _sqlite.ExcuteSqlite(sqli);
                        if (null != dtBeginTime && dtBeginTime.Rows.Count == 1)
                        {
                            ecgData.BeginTime = dtBeginTime.Rows[0]["beginTime"].ToString();
                            ecgData.EcgFilter = dtBeginTime.Rows[0]["EcgFilter"].ToString();
                            ecgData.IsLead    = "0";
                            ecgData.PaceLocs  = "";

                            if (dtBeginTime.Rows[0]["pureData"] == DBNull.Value)
                            {
                                string ednPathDir = Application.StartupPath + "\\ECG_DATA_NEW" + "\\" + appId + "_" +
                                                    ecgData.IsLead;
                                if (File.Exists(ednPathDir))
                                {
                                    var fs = new FileStream(ednPathDir,
                                                            FileMode.Open,
                                                            FileAccess.Read);
                                    var br = new BinaryReader(fs, Encoding.UTF8);
                                    ecgData.PureData = Convert.ToBase64String(br.ReadBytes((int)fs.Length));
                                    br.Close();
                                    //fs.Close();
                                }
                            }
                        }
                        else
                        {
                            ecgData.BeginTime = DateTime.Now.ToString();
                            ecgData.EcgFilter = "低通:75Hz";
                            ecgData.IsLead    = "0";
                            ecgData.PaceLocs  = "";
                            ecgData.PureData  = null;
                        }
                        extContract.Data[0] = ecgData;

                        var transition = new Transition
                        {
                            ApplicationID  = appId,
                            InptLevel      = ConfigHelper.InterpretationLevel,
                            CommunityOrgID = ConfigHelper.ORGID
                        };

                        if (null != dtBeginTime && dtBeginTime.Rows.Count == 1)
                        {
                            transition.CheckDate            = dtBeginTime.Rows[0]["beginTime"].ToString();
                            transition.GatherCompletionTime = dtBeginTime.Rows[0]["LeadEndTime"].ToString();
                        }
                        else
                        {
                            transition.CheckDate            = DateTime.Now.ToString();
                            transition.GatherCompletionTime = DateTime.Now.ToString();
                        }
                        extContract.Trans = transition;

                        var contract = new Contract
                        {
                            ApplicationDate   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            ApplicationUserID = ConfigHelper.LoginId
                        };
                        switch (ConfigHelper.InterpretationLevel)
                        {
                        case "2":
                            contract.Status = "4";
                            break;

                        case "3":
                            contract.Status = "5";
                            break;

                        default:
                            contract.Status = "3";
                            break;
                        }
                        extContract.Contr = contract;
                        ThreadPool.QueueUserWorkItem(WaitAppData, extContract);
                        UpdateApplicationStatus(appId, "4");
                        SelEcgList(extContract.God.PatientID);
                    }
                    #endregion
                }
            }
        }