Example #1
0
        private bool checkName()
        {
            bool gotName = false;

            string gName = this.textBox2.Text.Trim();
            if (gName.Length > 1)
            {
                NpgsqlCommand askName = new NpgsqlCommand("Select norm_id from norms where norm_name = '"+gName+"' ;",DBExchange.Inst.connectDb);
              //  DataTable dtName = new DataTable();

                try
                {
                    NpgsqlDataReader readName = askName.ExecuteReader();
                    readName.Read();

                    if (readName.HasRows == true)
                    {
                        gotName = true;
                    }
                    readName.Close();
                }
                catch (Exception exception)
                {
                    Warnings.WarnLog log = new Warnings.WarnLog();
                    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                }

            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Введите название показателя");
            }

            return gotName;
        }
Example #2
0
        private void insertIntoBase()
        {
            try
            {

            short total = Convert.ToInt16( this.textBox1.Text.Trim());
            int s_sum = Convert.ToInt32(this.textBox2.Text.Trim());
            short d_sum = Convert.ToInt16(this.textBox3.Text.Trim());

            short measure = Convert.ToInt16(this.textBox4.Text.Trim());
            int _s = Convert.ToInt32(this.textBox5.Text.Trim());
            short _d = Convert.ToInt16(this.textBox6.Text.Trim());

            string _comm = this.richTextBox1.Text.Trim();

            NpgsqlCommand _command = new NpgsqlCommand("Insert into tumor_size (total, d_sum, s_sum, s, d, measurable, pat_id, rasp_data, got_comment, brain, kidney, skin, bones, bone_marrow, lung, lymphatic, adrenal, os, hepar, lien, other, doc_id) values "
                + "( '" + total + "','" + d_sum + "','" + s_sum + "', '" + _s + "','" + _d + "','" + measure + "','" + this.searchPatientBox1.pIdN + "','" + this.dateTimePicker1.Value + "', :descr ,'" + this.checkedListBox1.GetItemChecked(0)
                + "','" + this.checkedListBox1.GetItemChecked(1) + "','" + this.checkedListBox1.GetItemChecked(2) + "','" + this.checkedListBox1.GetItemChecked(3) + "','" + this.checkedListBox1.GetItemChecked(4) + "','" + this.checkedListBox1.GetItemChecked(5)
                + "','" + this.checkedListBox1.GetItemChecked(6) + "','" + this.checkedListBox1.GetItemChecked(7) + "','" + this.checkedListBox1.GetItemChecked(8) + "','" + this.checkedListBox1.GetItemChecked(9) + "','" + this.checkedListBox1.GetItemChecked(10)
                + "','" + this.checkedListBox1.GetItemChecked(11) + "' , '" + DBExchange.Inst.dbUsrId + "') ;", DBExchange.Inst.connectDb);
                using (_command)
                {
                    _command.Parameters.Add(new NpgsqlParameter("descr", NpgsqlDbType.Text));
                    _command.Parameters[0].Value = _comm;
                }

                _command.ExecuteNonQuery();
                clearForm();
            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
        }
Example #3
0
        private bool changeTypeNow()
        {
            bool written = false;

            int _thisNorLimit = nList[this.comboBox2.SelectedIndex].NormID;

               string  _command = "Update norms set type = '"+ lTypes[this.comboBox3.SelectedIndex].SampleType +"' where norm_id = '"+ _thisNorLimit +"' ;";
               NpgsqlCommand insNorm = new NpgsqlCommand(_command, DBExchange.Inst.connectDb);

                        try
                        {

                            insNorm.ExecuteNonQuery();

                            written = true;
                        }
                        catch
                            (Exception exception)
                        {
                            Warnings.WarnLog log = new Warnings.WarnLog();
                            log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

                        }

            return written;
        }
Example #4
0
        private void createListSelected()
        {
            try
            {
                Documentation.DocumentsList dList = new Documentation.DocumentsList();
            if (checkedListBox1.SelectedItems.Count > 0)
                {

                foreach (int ic in this.checkedListBox1.CheckedIndices)
                    {
                         dList.Add(documentList[ic] );
                //    checkedListBox1.SetItemCheckState(ic, CheckState.Unchecked);
                    }

                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Выберите документы");
                }

            EventHandler<FormParentListEventArgs> handler = this.ParentDocumentsList;

            if (handler != null)
            {
                handler(this, new FormParentListEventArgs (dList));
            }

            }

            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
        }
Example #5
0
        public void writeStep()
        {
            try
            {
                Processing.Treatment.TreatmentStep ts = new Processing.Treatment.TreatmentStep();
                ts.Doctor = DBExchange.Inst.dbUsrId;
                ts.EffectStart = dateTimePicker12.Value;
                ts.EffectStop = dateTimePicker13.Value;
                ts.LineStart = dateTimePicker10.Value;
                ts.LineStop = dateTimePicker11.Value;
                ts.LineName = textBox8.Text;
                ts.ShortComment = textBox10.Text;
                ts.LongComment = richTextBox3.Text;
                ts.Patient = searchPatientBox1.pIdN;

                Processing.Treatment.TreatmentStepDataProcessing tsdp = new Processing.Treatment.TreatmentStepDataProcessing();
                tsdp.writeTreatmentStep(ts);
            }

            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
        }
Example #6
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            try
            {

                writeLabIntoBase();

                FormAddNewLab.ActiveForm.Close();
            }
            catch (Exception exception)
            {
                 Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
        }
Example #7
0
 private void writeThisAe()
 {
     NpgsqlCommand writeAE = new NpgsqlCommand("Insert Into ae_occured (start_ae, stop_ae, sae, ncs, casuality, resolution, actions, pat_id, doc_id, ae_comment) values "+
           "('"+this.dateTimePicker1.Value+"','"+this.dateTimePicker2.Value+"','"+this.checkBox1.Checked+"','"+this.checkBox2.Checked+
           "','"+this.textBox1.Text.Trim()+"','"+this.textBox2.Text.Trim()+"','"+this.textBox3.Text.Trim()+"','"+this.searchPatientBox1.pIdN+"','"
           +DBExchange.Inst.dbUsrId+"','"+this.richTextBox1.Text.Trim()+"') returning ae_id ;", DBExchange.Inst.connectDb);
       try
       {
          long ae_id = writeAE.ExecuteNonQuery();
          NpgsqlCommand updateDocuments = new NpgsqlCommand("Update documents set ae_occured = '"+ae_id+"' where document_number = '"
              +documentList[this.comboBox1.SelectedIndex].Serial+"';",DBExchange.Inst.connectDb);
          updateDocuments.ExecuteNonQuery();
       }
       catch (Exception exception)
       {
           Warnings.WarnLog log = new Warnings.WarnLog();
           log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
       }
 }
        void loadTemplateData(int _template)
        {
            string _command = "Select * from codes_sql_templates where template_id = '"+_template+"' ;";

            try
            {
                NpgsqlDataAdapter getTemplate = new NpgsqlDataAdapter(_command, DBExchange.Inst.connectDb);
                DataTable gt = new DataTable();
                getTemplate.Fill(gt);
                this.richTextBox1.Text = (string)gt.Rows[0]["template_text"];
                this.textBox2.Text = (string)gt.Rows[0]["template_file"];
                this.textBox1.Text = (string)gt.Rows[0]["template_description"];
            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
        }
Example #9
0
        private void writeData()
        {
            if (this.textBox1.Text.Length > 0 && this.textBox2.Text.Length > 0)
            {

                NpgsqlCommand ins = new NpgsqlCommand("insert into codes_sql (code_text, code_change, code_description) values "+
                   " ('" + this.textBox1.Text.Trim() + "','" + this.textBox2.Text.Trim() + "','" + this.textBox3.Text.Trim() + "') ;", DBExchange.Inst.connectDb);
                try
                {
                    ins.ExecuteNonQuery();
                    this.textBox1.Text = "";
                    this.textBox2.Text = "";
                }
                catch (Exception exception)
                {
                    Warnings.WarnLog log = new Warnings.WarnLog();
                    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                }

            }
        }
Example #10
0
        private void getSampleTypes()
        {
            dtSampleType = new DataTable();
            NpgsqlDataAdapter getMes = new NpgsqlDataAdapter("Select txt, code_id from codes where grp = '3' ;", DBExchange.Inst.connectDb);
            try
            {
                getMes.Fill(dtSampleType);
                comboBox1.Items.Clear();
                foreach (DataRow ro in dtSampleType.Rows)
                {
                    comboBox1.Items.Add((string)ro["txt"]);
                }
                comboBox1.Items.Add("Добавить новый тип ...");

            }
            catch (Exception exception)
            {
                 Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
            this.comboBox1.Refresh();
        }
Example #11
0
        //формирует запрос в баззу данных
        private void insCytZ()
        {
            int PatientId = this.searchPatientBox1.pIdN;
            DateTime aDate = DateTime.Now;

            try
            {

                string textZakl = this.richTextBox2.Text.Trim();
                string header = this.textBox12.Text.Trim();

                NpgsqlCommand insRow = new NpgsqlCommand("Insert into treatment_data_surgery (doctor_id, surgery_date, surgery_comment, pat_id, surgery_name) VALUES ('"
                    + DBExchange.Inst.dbUsrId + "','" + aDate + "', '" + textZakl + "','" + PatientId + "','" + header + "');", DBExchange.Inst.connectDb);
                try
                {

                    insRow.ExecuteNonQuery();
                    documWritten = true;
                }
                catch (Exception exception)
                {
                     Warnings.WarnLog log = new Warnings.WarnLog();
                    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

                }

                finally
                {

                }
                clearForm();

            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Выберите пациента");
            }
        }
Example #12
0
        private void insertDataIntoBase()
        {
            NpgsqlCommand insRow = new NpgsqlCommand("Insert into diag_data_survey (date_out, doc_out, pat_id, header, descr) VALUES ('"+this.dateTimePicker1.Value+"', '"+DBExchange.Inst.dbUsrId+"', '"+
            this.searchPatientBox1.pIdN+"', :header_p, :descr_p) ",DBExchange.Inst.connectDb);
            using (insRow)
            {
                insRow.Parameters.Add(new NpgsqlParameter("header_p", NpgsqlDbType.Varchar, 100));
                insRow.Parameters[0].Value = this.headerTextBox1.thisText.Text.Trim();
                insRow.Parameters.Add(new NpgsqlParameter("descr_p", NpgsqlDbType.Text));
                insRow.Parameters[1].Value = this.bodyRichTextBox1.thisText.Text.Trim();
            }
            try
            {

                insRow.ExecuteNonQuery();

            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
        }
Example #13
0
        /// <summary>
        /// Поиск в реестре услуг заданной услуги
        /// </summary>
        /// <param name="searchThis"></param>
        /// <returns></returns>
        public List<string> searchReestrListbyName(string searchThis)
        {
            List<string> getList = new List<string>();
            getReestrTable = new DataTable();
            NpgsqlDataAdapter searchList = new NpgsqlDataAdapter("Select reestr, name, code from reestr where upper(name) like '%"
                + searchThis.ToUpper() + "%' or code like '%" + searchThis.ToUpper() + "%' ", DBExchange.Inst.connectDb);
            try
            {
                searchList.Fill(getReestrTable);
                foreach (DataRow row in getReestrTable.Rows)
                {
                    getList.Add(row["code"].ToString().Trim() + " " + row["name"].ToString().Trim());
                }

            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }

            return getList;
        }
Example #14
0
        private void gotItemUnchecked()
        {
            try
            {
                if (this.checkedListBox1.SelectedIndex >= 0 && NLList.Count > 0)
                {
                    int thisInd = this.checkedListBox1.SelectedIndex;

                        int i = NLList.IndexOf(NLList.Find(o => o.NormLimitId == nList[thisInd].NormID));
                        int labId = (int)dtLabs.Rows[this.comboBoxLabName.SelectedIndex]["code_id"];
                        NpgsqlCommand uncheckItem = new NpgsqlCommand("Update norm_limits set delete_this = true where lab_id = '" + labId + "' and norm_id = '" + nList[thisInd].NormID + "' ;", DBExchange.Inst.connectDb);
                        uncheckItem.ExecuteNonQuery();
                        NLList.RemoveAt(i);
                    }

                //  this.checkedListBox1.SetItemChecked(this.checkedListBox1.SelectedIndex, false);
            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
        }
Example #15
0
        private void gotItemChecked()
        {
            if (NLList.Count == this.checkedListBox1.CheckedItems.Count)
            {
                int thisInd = this.checkedListBox1.SelectedIndex;
                if (thisInd >= 0)
                {

                    Processing.LabTickets.NormLimit nLimit = new Processing.LabTickets.NormLimit();
                    nLimit.NormLimitId = nList[thisInd].NormID;
                    nLimit.NormName = nList[thisInd].NormName;
                    if (NLList == null)
                    {
                        System.Windows.Forms.MessageBox.Show("Выберите лабораторию");
                    }
                    else
                    {
                        int typeId = lTypes[this.comboBoxTypes.SelectedIndex].SampleType;
                        int labId = (int)dtLabs.Rows[this.comboBoxLabName.SelectedIndex]["code_id"];

                        string _to = "";
                        string _values = "";

                        if (this.comboBox1.SelectedIndex >= 0)
                        {
                           short uId = Convert.ToInt16(MTypes[this.comboBox1.SelectedIndex].SampleType);
                            _to += ", unit_id";
                            _values += ", '" + uId + "'";
                        }
                        string insText = nLimit.NormName;
                        if (insText.Length >= 50)
                        {
                            insText = insText.Substring(0, 50);
                        }

                        NpgsqlCommand checkItem = new NpgsqlCommand("Insert Into norm_limits (from_ot, to_do, test_name, lab_id, norm_id, type "+_to+") values ('"
                            + this.dateTimePicker1.Value + "', '" + this.dateTimePicker2.Value + "', '"+ insText +"', '"+labId+"','"+nLimit.NormLimitId+"','"+typeId+"' "+_values+") ;", DBExchange.Inst.connectDb);
                        try
                        {
                            checkItem.ExecuteNonQuery();
                            NLList.Add(nLimit);
                        }
                        catch (Exception exception)
                        {
                            Warnings.WarnLog log = new Warnings.WarnLog();
                            log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

                        }
                    }

                }

                else if (this.checkedListBox1.SelectedIndex == -1)
                { System.Windows.Forms.MessageBox.Show("Выберите показатель из списка"); }
            }
        }
Example #16
0
        private void loadLabNormLimits(int _labID)
        {
            dtLabNorms = new DataTable();

            string _command = "Select test_name_id, test_name from norm_limits where lab_id is null ;";
            string _gType = "";
            if (this.comboBoxTypes.SelectedIndex >= 0)
            {
                int _gotType = lTypes[this.comboBoxTypes.SelectedIndex].SampleType;
                _gType = " and type = '"+_gotType+"'";
            }
            if (_labID == -2)
            {
                _command = "Select test_name_id, test_name from norm_limits ;";
            }

            else
                if (_labID > 0)
                {
                   _command = "Select test_name_id, test_name from norm_limits where lab_id = '" + _labID + "' "+_gType+" ;";
                }

            NpgsqlDataAdapter getNorm = new NpgsqlDataAdapter(_command, DBExchange.Inst.connectDb);
            try
            {
                getNorm.Fill(dtLabNorms);
                checkedListBox1.Items.Clear();
                foreach (DataRow ro in dtLabNorms.Rows)
                {
                    checkedListBox1.Items.Add((string)ro["test_name"]);
                }

            }
            catch (Exception exception)
            {
                 Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
            this.checkedListBox1.Refresh();
        }
Example #17
0
        private void wrtiteData()
        {
            DataTable dwt = new DataTable();

            NpgsqlConnection conn = DBExchange.Inst.connectDb;

            dwt.Columns.Add("ticket_id", System.Type.GetType("System.Int64"));
            dwt.Columns.Add("template_id", System.Type.GetType("System.Int32"));

            int patid = this.searchPatientBox1.pIdN;
            int docin = DBExchange.Inst.dbUsrId;

            int serviceid = rl[this.comboBox1.SelectedIndex].ResearchId;

            string _command = "Insert into ticket_radio (pat_id, doc_in, type_id, date_app, status) values "
               + "('" + patid + "','" + docin + "','" + serviceid + "', '" + this.dateTimePicker1.Value.ToShortDateString() + "', 'false') RETURNING ticket_id ;";
            NpgsqlCommand writeTicket = new NpgsqlCommand(_command, conn);

            DataTable ds = new DataTable();

            NpgsqlDataAdapter da = new NpgsqlDataAdapter("Select ticket_id, template_id from lab_results_radio where ticket_id = (Select max(ticket_id) from lab_results_radio);", conn);

            da.InsertCommand = new NpgsqlCommand("insert into lab_results_radio (ticket_id, template_id ) " +
                                    " values (:a, :b)", conn);

            da.InsertCommand.Parameters.Add(new NpgsqlParameter("a", NpgsqlDbType.Bigint));
            da.InsertCommand.Parameters.Add(new NpgsqlParameter("b", NpgsqlDbType.Integer));

            da.InsertCommand.Parameters[0].Direction = ParameterDirection.Input;
            da.InsertCommand.Parameters[1].Direction = ParameterDirection.Input;

            da.InsertCommand.Parameters[0].SourceColumn = "ticket_id";
            da.InsertCommand.Parameters[1].SourceColumn = "template_id";

            try
            {
                Int64 gotInt6 = (Int64)writeTicket.ExecuteScalar();

                foreach (int i in checkedListBox1.CheckedIndices)
                {
                    DataRow dwtNewRo = dwt.NewRow();
                    dwtNewRo["ticket_id"] = gotInt6;
                    dwtNewRo["template_id"] = zl[i].ZoneId;

                    dwt.Rows.Add(dwtNewRo);
                }

                da.Fill(ds);

                ds = dwt;
                DataTable ds2 = ds.GetChanges();

                da.Update(ds2);

                ds.Merge(ds2);
                ds.AcceptChanges();

                foreach (int i in checkedListBox1.CheckedIndices)
                {
                    checkedListBox1.SetItemChecked(i, false);
                }
                dwt.Clear();

            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
        }
Example #18
0
        private void gotItemUnchecked()
        {
            try
            {
                if (this.checkedListBox1.SelectedIndex != -1 && dtTemplNorms.Rows.Count >0)
                {

                int _thisItem = (int)dtLabNorms.Rows[this.checkedListBox1.SelectedIndex]["test_name_id"];

                    DataRow[] ro = dtTemplNorms.Select("norm_limits_test_id = '" + _thisItem + "'");
                    foreach (DataRow i in ro)
                    {
                        i.Delete();
                    }
                }

              //  this.checkedListBox1.SetItemChecked(this.checkedListBox1.SelectedIndex, false);
            }
            catch (Exception exception)
            {
                 Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
        }
Example #19
0
        /// <summary>
        // Запись диагноза пациента в базу
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void diagDataAddToBase()
        {
            if (this.searchPatientBox1.pIdN >= 0 && comboBoxDiagDescr.SelectedIndex >= 0)
            {
                if (checkPatDiag() == false)
                    {
                        string insCom;
                        string txtCom;
                        if (this.textBox1.Text.Trim().Length > 1)
                        {
                            insCom = ", comment";
                            txtCom = ", '" + this.textBox1.Text.Trim() + "'";
                        }
                        else
                        {
                            insCom = "";
                            txtCom = "";
                        }
                        NpgsqlCommand insPatDiag = new NpgsqlCommand("insert into diag_data (usr_id, pat_id, diag_date, diag, type, main_mark " + insCom + ") "
                        + "values ('" + DBExchange.Inst.dbUsrId + "','" + this.searchPatientBox1.pIdN + "', '" + this.dateTimePicker1.Value.Date + "','" + _tabDiagEnv.diagNumList[comboBoxDiagDescr.SelectedIndex] + "',"
                        + " '" + this.comboBox8.SelectedIndex + "', '" + checkBox1.Checked.ToString().ToLower() + "' " + txtCom + ");", DBExchange.Inst.connectDb);
                        try
                        {
                            insPatDiag.ExecuteNonQuery();
                            System.Windows.Forms.MessageBox.Show("Диагноз добавлен", "Отлично!");
                        }
                        catch (Exception exception)
                        {
                             Warnings.WarnLog log = new Warnings.WarnLog();
                            log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                        }

                    }
                    else
                    {
                         System.Windows.Forms.MessageBox.Show("Диагноз для пациента уже существует.", "Ошибка!!! Такой диагноз установлен");
                    }

                }

            else

               {
                Warnings.WarnMessages ChoPa = new Warnings.WarnMessages();
                ChoPa.warnChoosePatient();
               }
        }
Example #20
0
        private void WriteAnalysisData()
        {
            if (this.textBox1.Text.Trim().Length > 0)
            {
                DateTime Sdate = this.dateTimePicker1.Value;
                string Sname = this.textBox1.Text.Trim();
                int pidn = this.searchPatientBox1.pIdN;
                if (this.comboBox1.SelectedIndex != -1)
                {
                    Int16 Stype = Convert.ToInt16((int)dtSampleType.Rows[this.comboBox1.SelectedIndex]["code_id"]);

                    string _to = "sample_date, sample_name, sample_type, pat_id";
                    string _val = " '" + Sdate + "','" + Sname + "','" + Stype + "','" + pidn + "'";

                    string _writeSample = "";
                    if (this.richTextBox1.Text.Trim().Length > 0)
                    {
                        string Scomment = this.richTextBox1.Text.Trim();

                        _to += " , comment";
                        _val += ",'" + Scomment + "' ";

                    }

                    if (_labImport == true)
                    {
                        _to += ", lab_import";
                        _val += ", '" + _labImport.ToString() + "' ";
                    }

                    string _command = "insert into bio_sample (" + _to + ") VALUES (" + _val + ") RETURNING sample_id;";
                    NpgsqlCommand wSample = new NpgsqlCommand(_command, DBExchange.Inst.connectDb);

                    try
                    {
                        Int64 _gotSample = (Int64)wSample.ExecuteScalar();
                        if (_gotTicket > 0)
                        {
                            _writeSample = "update lab_results set sample_id = '" + _gotSample + "' where ticket_id = '" + _gotTicket + "' ;";
                            NpgsqlCommand uSample = new NpgsqlCommand(_writeSample, DBExchange.Inst.connectDb);
                            uSample.ExecuteNonQuery();
                            string _writeTicket = "update ticket set doc_out = '" + DBExchange.Inst.dbUsrId + "', date_out = '" + Sdate + "' where ticket_id = '" + _gotTicket + "' ; ";
                            NpgsqlCommand uTicket = new NpgsqlCommand(_writeTicket, DBExchange.Inst.connectDb);
                            uTicket.ExecuteNonQuery();
                        }

                        this.richTextBox1.Clear();
                        this.textBox1.Clear();
                        _labImport = false;
                        _gotTicket = 0;
                    }
                    catch (Exception exception)
                    {
                        Warnings.WarnLog log = new Warnings.WarnLog(); log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                    }

                }

                else
                {
                    System.Windows.Forms.MessageBox.Show("Выберите тип образца");
                }

            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Введите название образца");
            }
        }
Example #21
0
        private void writeTemplate()
        {
            try
            {
                if (this.comboBox1.SelectedIndex >= 0)
                {

                    NpgsqlConnection conn = DBExchange.Inst.connectDb;

                    DataTable ds = new DataTable();

                    NpgsqlDataAdapter da = new NpgsqlDataAdapter("Select norm_limits_test_id, template_codes_id, serial_key from lab_template where template_codes_id = '" + _gotTemplateId + "';", conn);

                    da.InsertCommand = new NpgsqlCommand("insert into lab_template (norm_limits_test_id, template_codes_id) values (:a, :b)", conn);
                    da.DeleteCommand = new NpgsqlCommand("Delete from lab_template where serial_key = :a ", conn);

                    da.DeleteCommand.Parameters.Add(new NpgsqlParameter("a", NpgsqlDbType.Integer));
                    da.DeleteCommand.Parameters[0].SourceVersion = DataRowVersion.Original;
                    da.DeleteCommand.Parameters[0].SourceColumn = "serial_key";

                    da.InsertCommand.Parameters.Add(new NpgsqlParameter("a", NpgsqlDbType.Integer));
                    da.InsertCommand.Parameters.Add(new NpgsqlParameter("b", NpgsqlDbType.Integer));

                    da.InsertCommand.Parameters[0].Direction = ParameterDirection.Input;
                    da.InsertCommand.Parameters[1].Direction = ParameterDirection.Input;

                    da.InsertCommand.Parameters[0].SourceColumn = "norm_limits_test_id";
                    da.InsertCommand.Parameters[1].SourceColumn = "template_codes_id";

                    da.Fill(ds);
                    ds = dtTemplNorms;

                    DataTable ds2 = ds.GetChanges();

                    da.Update(ds2);

                    ds.Merge(ds2);
                    ds.AcceptChanges();

                    getTemplateNorms(_gotTemplateId);
                }
            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
        }
Example #22
0
        private void loadLabTemplates(int _thisLab)
        {
            dtLabTemp = new DataTable();

            NpgsqlDataAdapter getLabs = new NpgsqlDataAdapter("Select txt, code_id from codes where grp = '5' and code ='"+_thisLab+"' ;", DBExchange.Inst.connectDb);
            try
            {
                getLabs.Fill(dtLabTemp);
                comboBox1.Items.Clear();
                comboBox1.Text = "";
                foreach (DataRow ro in dtLabTemp.Rows)
                {
                    comboBox1.Items.Add((string)ro["txt"]);
                }
                comboBox1.Items.Add("Добавить новый шаблон ...");

            }
            catch (Exception exception)
            {
                  Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
            this.comboBox1.Refresh();
        }
Example #23
0
        //Запись нормы в базу данных
        private void insertNormIntoBase(string _ul, string _ll)
        {
            bool gotLab = false;
            this.toolStripStatusLabel1.Text = "Подготовка к записи.";
            string _normName = nList[this.checkedListBox1.SelectedIndex].NormName; //this.textBox1.Text.Trim() ;
            int normId = nList[this.checkedListBox1.SelectedIndex].NormID;
            int typeId = -1;
            int labId = -1;
            short uId = -1;
            if (this.comboBox1.SelectedIndex >= 0)
            {
                uId = Convert.ToInt16(MTypes[this.comboBox1.SelectedIndex].SampleType);
            }
            bool gotType = false;
            bool gotComment = false;
            string _command = "";
            string _to;
            string _values;
            string  _gotCode = this.textBoxCode.Text.Trim();

             if (this.comboBoxLabName.SelectedIndex != -1)
                {
                    labId = (int)dtLabs.Rows[this.comboBoxLabName.SelectedIndex]["code_id"];

                    if (checkedListBox1.SelectedIndex == -1)
                        {

                            if (checkNormName(_normName, labId) == false)
                            {
                             _to = "test_name, norm_id, from_ot, to_do ";
                             _values = "'" +_normName + "', '"+normId+"', '" + this.dateTimePicker1.Value + "', '" + this.dateTimePicker2.Value +"'";

                                gotLab = true;
                                _to += ", lab_id";
                                _values += ", '" + labId + "'";

                                //if (this.radioButton3.Checked == false)
                                //{
                                //    _to += ", is_man";
                                //    _values += ",'"+this.radioButton1.Checked+ "'";
                                //}

                                if (this.comboBox1.SelectedIndex >= 0)
                                {
                                    uId = Convert.ToInt16(MTypes[this.comboBox1.SelectedIndex].SampleType);
                                    _to += ", unit_id";
                                    _values += ", '" + uId + "'";
                                }

                                if (this.comboBoxTypes.SelectedIndex != -1)
                                {
                                    typeId = lTypes[this.comboBoxTypes.SelectedIndex].SampleType;
                                    gotType = true;
                                    _to += ", type";
                                    _values += ", '" + typeId + "'";
                                }

                                //if (this.comboBox1.SelectedIndex != -1)
                                //{
                                //    string MeasureId = this.comboBox1.SelectedItem.ToString().Trim(); ;
                                //    int mId = MTypes[this.comboBox1.SelectedIndex].SampleType;
                                //    _to += ", unit_id";
                                //    _values += ", '" + mId + "'";
                                //}

                                //if (this.richTextBox1.Text.Length > 1)
                                //{
                                //    gotComment = true;
                                //    _to += ", comment";
                                //    _values += ", '" + this.richTextBox1.Text.Trim()+"'";
                                //}

                                if (_gotCode.Length >= 1)
                                {

                                    _to += ", test_code";
                                    _values += ", '" + _gotCode + "'";
                                }

                                //     if (this.maskedTextBox1.Text.Length >= 1)
                                //     {
                                //        _to += ", age_from_ot, age_to_do ";
                                //         _values += ", '" + Convert.ToDecimal( maskedTextBox2.Text.ToString()) + "', '" + Convert.ToDecimal( maskedTextBox1.Text.ToString()) + "' ";

                                //     }

                                _command = "insert into norm_limits (" + _to + ") VALUES (" + _values + ") ;";

                            }
                            else
                            {
                                System.Windows.Forms.MessageBox.Show("Такой показатель уже существует в лаборатории");
                                return;

                            }
                        }
                        else
                        {
                            _command = "Update norm_limits set test_name = '"+_normName+"', from_ot = '"+this.dateTimePicker1.Value+"', to_do = '"+this.dateTimePicker2.Value
                                +"', test_code = '"+_gotCode+"', unit_id = '"+uId+"' where test_name_id = '"+gotNormLimit[0].NormID +"' ;";
                        }

                        try
                        {
                            NpgsqlCommand insNorm = new NpgsqlCommand(_command, DBExchange.Inst.connectDb);
                            insNorm.ExecuteNonQuery();
                            //this.textBox1.Text = "";
                            //this.richTextBox1.Text = "";
                            //this.radioButton3.Select();
                            //this.textBox2.Text = "";
                            //this.textBox3.Text = "";
                            this.toolStripStatusLabel1.Text = "Показатель успешно записан в базу.";
                            this.textBoxCode.Text = "";
                            loadNormLimitList();
                            this.checkedListBox1.SelectedIndex = 0;
                       //     this.checkedListBox1.SelectedIndex = 0;
                        }
                        catch
                            (Exception exception)
                        {
                            Warnings.WarnLog log = new Warnings.WarnLog();
                            log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                        }
                   }
              else
                {
                    System.Windows.Forms.MessageBox.Show("Выберите лабораторию");
                }
        }
Example #24
0
        //загружает список услуг по отделению
        private void writeTicketForPatient()
        {
            if (this.searchPatientBox1.patientSet == true)
            {

                NpgsqlCommand insTicket = new NpgsqlCommand("insert into ticket (doc_in, pat_id, service_id) values (" + DBExchange.Inst.dbUsrId + "," + this.searchPatientBox1.pIdN + "," + DBExchange.Inst.tlServiceTable.Rows[this.comboBox9.SelectedIndex]["reestr"] + ") ;", DBExchange.Inst.connectDb);
                try
                {
                    insTicket.ExecuteNonQuery();

                }
                catch (Exception exception)
                {
                     Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                }
                finally { }

            }
        }
Example #25
0
        //Получает нормы для лаборатории
        private void loadNormLimitList()
        {
            try
            {
                NLList = new Processing.LabTickets.NormLimitList();
                foreach (int i in checkedListBox1.CheckedIndices)
                {

                        checkedListBox1.SetItemChecked(i, false);

                }

                if (this.comboBoxLabName.SelectedIndex != -1 && this.comboBoxTypes.SelectedIndex != -1)
                {
                    short _type = Convert.ToInt16(lTypes[comboBoxTypes.SelectedIndex].SampleType);
                    int _lab = (int)dtLabs.Rows[this.comboBoxLabName.SelectedIndex]["code_id"];
                    NLList.loadLabNormLimits(_lab, _type);
                    foreach (Processing.LabTickets.NormLimit i in NLList)
                    {
                        if (nList.Count > 0)
                        {
                            int kL = nList.IndexOf(nList.Find(o => o.NormID == i.NormLimitId));
                            if (kL >= 0)
                            {
                                checkedListBox1.SetItemChecked(kL, true);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
        }
Example #26
0
        private void writeTemplate()
        {
            if (this.richTextBox1.Text.Trim().Length > 2)
            {
                if (this.comboBox3.SelectedIndex != -1)
                {
                    string _template = this.richTextBox1.Text.Trim();
                    Int16 _type = Convert.ToInt16(zl[_SelectedZoneIndex].ZoneId);
                    string _com = "";
                    if (ztl[this.comboBox3.SelectedIndex].TemplateBody == null)
                    {
                        _com = "Insert into zone_template (template, zone_id, doc_in,, method_type) values ('" + _template + "', '" + _type + "', '"
                            + DBExchange.Inst.dbUsrId + "', '" + rl[this.comboBox1.SelectedIndex].ResearchId + "')";
                    }
                    else
                    {
                        _com = "Update zone_template set template = '" + _template + "' , zone_id = '" + _type + "', doc_in = '" + DBExchange.Inst.dbUsrId
                            + "', method_type = '" + rl[this.comboBox1.SelectedIndex].ResearchId + "' where templ_id = '" + ztl[this.comboBox3.SelectedIndex].TemplateId + "'";
                    }

                    NpgsqlCommand _command = new NpgsqlCommand(_com, DBExchange.Inst.connectDb);

                    try
                    {

                        _command.ExecuteNonQuery();
                        int selCom2 = this.comboBox2.SelectedIndex;

                        fillTemplateList();
                        comboBox2.SelectedIndex = selCom2;
                    }
                    catch (Exception exception)
                    {
                        Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Выберите или создайте новый шаблон");
                }
            }
        }
Example #27
0
 private void deleteDiag(int _thisDiag)
 {
     NpgsqlCommand delDi = new NpgsqlCommand("Update diag_data set delete = true where serial = '"+_thisDiag+"' ;",DBExchange.Inst.connectDb);
     try
     {
         delDi.ExecuteNonQuery();
     }
     catch (Exception exception)
     {
         Warnings.WarnLog log = new Warnings.WarnLog();
         log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
     }
 }
Example #28
0
        private void loadLab()
        {
            labList = new Document.SampleType.LabList();
            try
            {
                labList.LabListGet();
                comboBoxLabName.Items.Clear();
                foreach (Document.SampleType.LabItem i in labList )
                {
                    comboBoxLabName.Items.Add(i.SampleName);
                }
                comboBoxLabName.Items.Add("Все показатели");
                comboBoxLabName.Items.Add("Без лаборатории");
                comboBoxLabName.Items.Add("Добавить новую лабораторию ...");

            }
            catch (Exception exception)
            {
                 Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
            this.comboBoxLabName.Refresh();
        }
Example #29
0
        ///Проверка существует ли диагноз в базе
        ///
        private bool checkPatDiag()
        {
            int gotDiag = -1;
                bool isDiag = true;
                NpgsqlCommand getDiag = new NpgsqlCommand("select min(serial) from diag_data  "
                + "where pat_id = '" + this.searchPatientBox1.pIdN + "' and  diag = '" + _tabDiagEnv.diagNumList[comboBoxDiagDescr.SelectedIndex] + "' and type = '"
                + this.comboBox8.SelectedIndex + "' and main_mark = " + checkBox1.Checked.ToString().ToLower() + " and delete = false ;", DBExchange.Inst.connectDb);

                try
                {
                   var getDiagnosis = getDiag.ExecuteScalar();
                   if (Convert.IsDBNull( getDiagnosis) == false )
                   {
                       gotDiag = Convert.ToInt32(getDiagnosis);
                   }
                    if (gotDiag > 0) {isDiag = true;}
                    else
                        isDiag = false;

                }
                catch (Exception exception)
                {
                    Warnings.WarnLog log = new Warnings.WarnLog();
                    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                }
                return isDiag;
        }
Example #30
0
        private void writeLabIntoBase()
        {
            string labName = this.textBox1.Text.Trim();
            if (labName.Length > 1)
            {

                string _code = "";

                switch (gotCase)
                {
                    case 1:
                        _code = "2";
                        break;
                    case 2:
                        _code = "3";
                        break;
                    case 3:
                        _code = "4";
                        break;
                    case 4:
                        _code = "";
                        break;
                    case 5:
                        _code = "5";
                        break;

                }
                NpgsqlCommand insLab = new NpgsqlCommand("Insert into codes (txt, grp) values ( :lab , '"+_code+"') ;", DBExchange.Inst.connectDb);

                if (gotCase == 5)
                {
                    insLab = new NpgsqlCommand("Insert into codes (txt, grp, code) values ( :lab , '" + _code + "', '"+_gotIntAddon+"') ;", DBExchange.Inst.connectDb);

                }
                using (insLab)
                {
                    insLab.Parameters.Add(new NpgsqlParameter("lab", NpgsqlDbType.Text));
                    insLab.Parameters[0].Value = labName;

                }

                try
                {
                    insLab.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                     Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                }

            }
            else
            { System.Windows.Forms.MessageBox.Show("Введите название лаборатории"); }
        }