Example #1
0
        /// <summary>
        /// Initializes controls
        /// </summary>
        private void Initialize()
        {
            try
            {
                PasswordForm passwordForm = new PasswordForm();
                DialogResult result       = passwordForm.ShowDialog();

                if (result != DialogResult.OK)
                {
                    this.Close();
                }
            }
            catch (Exception)
            {
                this.Close();
            }

            try
            {
                mExporter = new ICSDataExporter();
                mExporter.Initialize();
                mExporter.OnDataExportEvent += new ICSDataExporter.DataExportHandler(HandleDataExportEvent);

                //prompt to set database connection info
                DBInfoForm dbInfoForm = new DBInfoForm();
                dbInfoForm.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to load configuration data." + Environment.NewLine + "Error: " + ex.Message,
                                "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                this.Close();
            }
        }
Example #2
0
        /// <summary>
        /// Creates DBInfo form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDBConn_Click(object sender, EventArgs e)
        {
            DBInfoForm dbInfoForm = new DBInfoForm();

            dbInfoForm.ShowDialog();
            this.Update();
            this.Activate();
        }
Example #3
0
        /// <summary>
        /// Exports data to files.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExportData_Click(object sender, EventArgs e)
        {
            DialogResult result = DialogResult.OK;

            //check if patient is is selected
            if (string.IsNullOrEmpty(PatientID))
            {
                MessageBox.Show("Patient id is required.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                result = DialogResult.Cancel;
            }
            //check if file path is defined
            else if (string.IsNullOrEmpty(txtPath.Text) || !Directory.Exists(txtPath.Text))
            {
                MessageBox.Show("File directory is not valid.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                result = DialogResult.Cancel;
            }
            else if (!DataSource.HaveValidDBConnInfo)
            {
                DBInfoForm dbInfoForm = new DBInfoForm();
                result = dbInfoForm.ShowDialog();
            }

            if (result == DialogResult.OK)
            {
                try
                {
                    //get unique file id
                    string text = GetFileID();
                    if (text != null && text != string.Empty)
                    {
                        mExporter.FilePath  = txtPath.Text;
                        mExporter.PatientId = PatientID;

                        SetButtonState(false);
                        this.Cursor = Cursors.WaitCursor;
                        mExporter.ExportData(text);
                    }
                    else
                    {
                        MessageBox.Show("File ID is required.", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("Failed to export data." + Environment.NewLine + "Error: " + ex.Message,
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Searches for the patient
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, EventArgs e)
        {
            PatientID = string.Empty;

            //list may changes, so clear combobox
            cboPatient.DataSource = null;
            cboPatient.Items.Clear();

            if (!string.IsNullOrEmpty(txtSearch.Text))
            {
                try
                {
                    DialogResult result = DialogResult.OK;

                    if (!DataSource.HaveValidDBConnInfo)
                    {
                        DBInfoForm dbInfoForm = new DBInfoForm();
                        result = dbInfoForm.ShowDialog();
                    }
                    if (result == DialogResult.OK)
                    {
                        //get patient list
                        GetPatientList(out mPatList);

                        if (mPatList != null && mPatList.Count > 0)
                        {
                            cboPatient.DataSource    = mPatList;
                            cboPatient.DisplayMember = "FullName";
                            cboPatient.SelectedIndex = 0;
                        }
                        else
                        {
                            MessageBox.Show("Patient is not found.", "Information",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to load patient data." + Environment.NewLine + "Error: " + ex.Message,
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Search data is required.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #5
0
        private void btnExportWave_Click(object sender, EventArgs e)
        {
            DialogResult result = DialogResult.OK;

            //check if patient is is selected
            if (string.IsNullOrEmpty(PatientID))
            {
                MessageBox.Show("Patient id is required.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                result = DialogResult.Cancel;
            }
            //check if file path is defined
            else if (string.IsNullOrEmpty(txtPath.Text) || !Directory.Exists(txtPath.Text))
            {
                MessageBox.Show("File directory is not valid.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                result = DialogResult.Cancel;
            }
            else if (!DataSource.HaveValidDBConnInfo)
            {
                DBInfoForm dbInfoForm = new DBInfoForm();
                result = dbInfoForm.ShowDialog();
            }

            if (result == DialogResult.OK)
            {
                try
                { //get unique file id
                    string fileID = GetFileID();

                    if (!string.IsNullOrEmpty(fileID))
                    {
                        WaveFormHelper waveFormHelper = new WaveFormHelper();
                        string         path           = txtPath.Text;
                        string         DateTimeValue;
                        DateTime       now     = DateTime.Now;
                        string         dformat = "yyyy-MM-dd_hh-mm-ss-tt";
                        DateTimeValue = now.ToString(dformat);

                        string filePathName = path + "\\" + "WaveformSampleInfo" + "_" + fileID + "_" + DateTimeValue + ".txt";
                        waveFormHelper.FilePath = path;

                        long         startft = 0;
                        long         endft   = 0;
                        StreamWriter writer  = File.AppendText(filePathName);
                        writer.AutoFlush = true;
                        writer.WriteLine("\r\n");
                        writer.WriteLine("\r\n");
                        writer.WriteLine("\r\n");
                        writer.WriteLine("ChannelName\tSampleRate\tStartFT\t\t\t\tEndFT\t\t\t\tSampleCount\r\n");
                        writer.WriteLine("=================================================================================================================");

                        //for each channel
                        //  helper.LoadPatientChannels(mPatID);
                        waveFormHelper.LoadPatientChannels(PatientID, fileID, DateTimeValue);

                        foreach (Object obj in waveFormHelper.PatChannelToChannelType.Keys)
                        {
                            ChannelInformation channelinfo = (ChannelInformation)waveFormHelper.PatChannelToChannelType[obj as string];
                            startft = waveFormHelper.GetPatientStartFt(PatientID, obj as string);
                            endft   = waveFormHelper.GetPatientEndFt(PatientID, obj as string);

                            long samples = waveFormHelper.GetPatientWaveform(PatientID, channelinfo.Rate, startft, endft);

                            writer.WriteLine(string.Format("{0}\t\t{1}\t\t{2}\t\t{3}\t\t{4}", channelinfo.Label, channelinfo.Rate.ToString(),
                                                           startft.ToString(), endft.ToString(), samples.ToString()));
                        }

                        writer.Close();

                        MessageBox.Show("Binary WaveForm data and 'WaveformSampleInfo.txt' files are exported. Check Folder Path Location.",
                                        "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("File ID is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                catch (Exception ex)
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("Failed to export waveform data." + Environment.NewLine + "Error: " + ex.Message,
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }