Example #1
0
        private IList <DdtJournalDay> GetByQuery(string sql)
        {
            IList <DdtJournalDay> list = new List <DdtJournalDay>();

            using (dynamic connection = connectionFactory.GetConnection())
            {
                Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", sql);

                Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(sql, connection);
                using (DbDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        DdtJournalDay obj = new DdtJournalDay();
                        obj.ObjectId           = reader.IsDBNull(0) ? null : reader.GetString(0);
                        obj.CreationDate       = reader.IsDBNull(1) ? DateTime.MinValue : reader.GetDateTime(1);
                        obj.AdmissionDate      = reader.IsDBNull(2) ? DateTime.MinValue : reader.GetDateTime(2);
                        obj.Doctor             = reader.IsDBNull(3) ? null : reader.GetString(3);
                        obj.Patient            = reader.IsDBNull(4) ? null : reader.GetString(4);
                        obj.HospitalitySession = reader.IsDBNull(5) ? null : reader.GetString(5);
                        obj.ModifyDate         = reader.IsDBNull(6) ? DateTime.MinValue : reader.GetDateTime(6);
                        obj.Name        = reader.IsDBNull(7) ? null : reader.GetString(7);
                        obj.JournalType = reader.IsDBNull(8) ? -1 : reader.GetInt16(8);
                        obj.Diagnosis   = reader.IsDBNull(9) ? null : reader.GetString(9);
                        list.Add(obj);
                    }
                }
            }
            return(list);
        }
Example #2
0
        public string Save(DdtJournalDay obj)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                if (GetById(obj.ObjectId) != null)
                {
                    string sql = "UPDATE ddt_journal_day SET " +
                                 "dsid_hospitality_session = @HospitalitySession, " +
                                 "dsid_patient = @Patient, " +
                                 "dsdt_admission_date = @AdmissionDate, " +
                                 "dsid_doctor = @Doctor, " +
                                 "dsi_journal_type = @JournalType, " +
                                 "dss_diagnosis = @Diagnosis, " +
                                 "dss_name = @Name " +
                                 "WHERE r_object_id = @ObjectId";
                    Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", sql);

                    using (Npgsql.NpgsqlCommand cmd = new Npgsql.NpgsqlCommand(sql, connection))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@HospitalitySession", obj.HospitalitySession);
                        cmd.Parameters.AddWithValue("@Patient", obj.Patient);
                        cmd.Parameters.AddWithValue("@AdmissionDate", obj.AdmissionDate);
                        cmd.Parameters.AddWithValue("@Doctor", obj.Doctor);
                        cmd.Parameters.AddWithValue("@Name", obj.Name == null ? "" : obj.Name);
                        cmd.Parameters.AddWithValue("@JournalType", obj.JournalType);
                        cmd.Parameters.AddWithValue("@Diagnosis", obj.Diagnosis);
                        cmd.Parameters.AddWithValue("@ObjectId", obj.ObjectId);
                        cmd.ExecuteNonQuery();
                    }
                    return(obj.ObjectId);
                }
                else
                {
                    string sql = "INSERT INTO ddt_journal_day(dsid_hospitality_session,dsid_patient,dsdt_admission_date,dsid_doctor,dss_name,dsi_journal_type,dss_diagnosis) " +
                                 "VALUES(@HospitalitySession,@Patient,@AdmissionDate,@Doctor,@Name,@JournalType,@Diagnosis) RETURNING r_object_id";
                    Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", sql);

                    using (Npgsql.NpgsqlCommand cmd = new Npgsql.NpgsqlCommand(sql, connection))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@HospitalitySession", obj.HospitalitySession);
                        cmd.Parameters.AddWithValue("@Patient", obj.Patient);
                        cmd.Parameters.AddWithValue("@AdmissionDate", obj.AdmissionDate);
                        cmd.Parameters.AddWithValue("@Doctor", obj.Doctor);
                        cmd.Parameters.AddWithValue("@Name", obj.Name == null ? "" : obj.Name);
                        cmd.Parameters.AddWithValue("@JournalType", obj.JournalType);
                        cmd.Parameters.AddWithValue("@Diagnosis", obj.Diagnosis == null ? "" : obj.Diagnosis);
                        return((string)cmd.ExecuteScalar());
                    }
                }
            }
        }
Example #3
0
        public bool Save()
        {
            if (journalContainer.Controls.Count == 0)
            {
                return(true);
            }
            DdtJournalDay day         = service.GetDdtJournalDayService().GetById(journalDayId);
            DateTime      journalDate = ((JournalNoKAGControl)journalContainer.Controls[0]).getJournalDateTime();

            //Снчала поищем, нет ли дневников за тот же день?
            if (day == null)
            {
                day          = service.GetDdtJournalDayService().GetForDate(hospitalitySession.ObjectId, journalDate);
                journalDayId = day?.ObjectId;
            }

            if (day == null)
            {
                day                    = new DdtJournalDay();
                day.Doctor             = hospitalitySession.DutyDoctor;
                day.Patient            = hospitalitySession.Patient;
                day.HospitalitySession = hospitalitySession.ObjectId;
                day.JournalType        = (int)DdtJournalDsiType.BeforeKag;
                day.AdmissionDate      = journalDate;
                day.Name               = "Журнал до КАГ за " + journalDate.ToShortDateString();
                journalDayId           = service.GetDdtJournalDayService().Save(day);
            }
            foreach (Control c in journalContainer.Controls)
            {
                CheckBox hide = c.Controls.Find("hideJournalBtn", true).FirstOrDefault() as CheckBox;
                if (!hide.Checked)
                {
                    IDocbaseControl docbaseControl = (IDocbaseControl)c;
                    docbaseControl.saveObject(hospitalitySession, journalDayId, DdtJournalDay.NAME);
                    docbaseControl.getObjectId();
                }
            }
            analysisTabControl1.save(journalDayId, DdtJournalDay.NAME);

            return(true);
        }
        public string processTemplate(IDbDataService service, string hospitalitySession, string objectId, Dictionary <string, string> aditionalValues)
        {
            Dictionary <string, string> values = null;

            if (aditionalValues != null)
            {
                values = new Dictionary <string, string>(aditionalValues);
            }
            else
            {
                values = new Dictionary <string, string>();
            }
            DdtJournalDay day = service.GetDdtJournalDayService().GetById(objectId);

            PutAnalysisData(values, service, objectId);
            DdvDoctor doc = service.GetDdvDoctorService().GetById(day.Doctor);

            values.Add("{doctor.initials}", doc == null ? "" : doc.ShortName);

            IList <DdtKag> kags     = service.GetDdtKagService().GetByParentId(day.ObjectId);
            DdtKag         kag      = kags.Count > 0 ? kags[0] : null;
            string         kagValue = "";

            if (kag != null)
            {
                kagValue += kag.Results == null ? "" : "У пациента по данным КАГ выявлено:" + kag.Results + "\n";
                kagValue += kag.KagManipulation == null ? "" : "Пациенту выполнено:" + kag.KagManipulation + "\n";
                kagValue += kag.KagAction == null ? "" : "Таким образом, у пациента:" + kag.KagAction + "\n";
            }

            List <string> partsPaths = new List <string>();

            if (day.JournalType == (int)DdtJournalDsiType.AfterKag)
            {
                Dictionary <string, string> first          = new Dictionary <string, string>();
                DdtVariousSpecConcluson     cardiovascular = service.GetDdtVariousSpecConclusonService().GetByParentId(objectId);
                DdvDoctor surgeryDoc = service.GetDdvDoctorService().GetById(cardiovascular?.AdditionalInfo4);
                first.Add("{time}", day.AdmissionDate.ToShortTimeString());
                first.Add("{title}", "Осмотр дежурного кардиореаниматолога " + (doc == null ? "" : doc.ShortName) +
                          " совместно с ангиохирургом " + surgeryDoc?.ShortName + ". \n Пациента доставили из рентгеноперационной.");
                first.Add("{complaints}", "Жалоб на момент осмотра не предъявляет.");
                first.Add("{journal}", JournalShuffleUtils.shuffleJournalText());
                first.Add("{on_monitor}", "");
                first.Add("{monitor}", "");
                first.Add("{doctor.initials}", doc == null ? "" : doc.ShortName);

                first.Add("{kag_diagnosis}", kagValue);
                first.Add("{diagnosis}", kag == null ? "Таким образом, у пациента:" + day.Diagnosis : "");
                PutAnalysisData(first, service, null);
                partsPaths.Add(TemplatesUtils.FillTemplate(Directory.GetCurrentDirectory() + "\\Templates\\" + TEMPLATE_FILE_NAME, first));

                Dictionary <string, string> surgeryValues = new Dictionary <string, string>();
                surgeryValues.Add("{time}", cardiovascular.AdmissionDate.ToShortTimeString());
                surgeryValues.Add("{title}", "Осмотр ренгеноваскулярного хирурга " + surgeryDoc?.ShortName + ". \n");
                surgeryValues.Add("{complaints}", "Жалоб на момент осмотра не предъявляет.");
                surgeryValues.Add("{journal}", cardiovascular?.SpecialistConclusion);
                surgeryValues.Add("{on_monitor}", "");
                surgeryValues.Add("{monitor}", " ");
                surgeryValues.Add("{kag_diagnosis}", " ");
                surgeryValues.Add("{diagnosis}", " ");
                surgeryValues.Add("{doctor.initials}", surgeryDoc == null ? "" : surgeryDoc.ShortName);
                PutAnalysisData(surgeryValues, service, null);
                partsPaths.Add(TemplatesUtils.FillTemplate(Directory.GetCurrentDirectory() + "\\Templates\\" + TEMPLATE_FILE_NAME, surgeryValues));
            }

            List <DdtJournal> journals = service.GetDdtJournalService().GetByJournalDayId(objectId);

            for (int i = 0; i < journals.Count; i++)
            {
                Dictionary <string, string> jrnlValues = new Dictionary <string, string>();
                DdtJournal journal = journals[i];
                jrnlValues.Add("{time}", journal.AdmissionDate.ToShortTimeString());
                jrnlValues.Add("{title}", " ");
                jrnlValues.Add("{complaints}", journal.Complaints);
                jrnlValues.Add("{on_monitor}", string.IsNullOrEmpty(journal.Monitor) ? string.Empty : "По монитору: ");
                jrnlValues.Add("{journal}", journal.Journal);
                jrnlValues.Add("{monitor}", string.IsNullOrEmpty(journal.Monitor) ? string.Empty : journal.Monitor);
                DdvDoctor jrnlDoc = service.GetDdvDoctorService().GetById(journal.Doctor);
                jrnlValues.Add("{doctor.initials}", day.JournalType == (int)DdtJournalDsiType.AfterKag || jrnlDoc == null ? doc?.ShortName : jrnlDoc.ShortName);
                if (i == journals.Count - 1)
                {
                    jrnlValues.Add("{kag_diagnosis}", kagValue);
                    jrnlValues.Add("{diagnosis}", String.IsNullOrEmpty(day.Diagnosis) ? "" : "Таким образом, у пациента:" + day.Diagnosis);
                    PutAnalysisData(jrnlValues, service, objectId);
                }
                else
                {
                    jrnlValues.Add("{kag_diagnosis}", " ");
                    jrnlValues.Add("{diagnosis}", " ");
                    PutAnalysisData(jrnlValues, service, null);
                }
                string mainPart = TemplatesUtils.FillTemplate(Directory.GetCurrentDirectory() + "\\Templates\\" + TEMPLATE_FILE_NAME, jrnlValues);
                partsPaths.Add(mainPart);
            }

            DdvPatient patient    = service.GetDdvPatientService().GetById(day.Patient);
            string     resultName = TemplatesUtils.getTempFileName("Журнал", patient.FullName);

            return(TemplatesUtils.MergeFiles(partsPaths.ToArray(), false, resultName));
        }
Example #5
0
        private void editMenu_Click(object sender, EventArgs e)
        {
            IEnumerator it        = patientHistoryGrid.SelectedRows.GetEnumerator();
            string      firstId   = null;
            string      firstType = null;

            if (it.MoveNext())
            {
                DataGridViewRow          row          = (DataGridViewRow)it.Current;
                DataGridViewCell         cell         = row.Cells[3];
                DataGridViewCheckBoxCell checkBoxCell = (DataGridViewCheckBoxCell)row.Cells[0];
                firstId   = cell.Value.ToString();
                firstType = row.Cells[2].Value.ToString();
            }

            Form form = null;

            if (DdtAnamnesis.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new FirstInspection(service, hospitalitySession);
            }
            else if (DdtJournalDay.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                DdtJournalDay journal = service.GetDdtJournalDayService().GetById(firstId);
                if (journal.JournalType == (int)DdtJournalDsiType.AfterKag)
                {
                    form = new JournalAfterKAG(service, hospitalitySession, firstId);
                }
                else
                {
                    form = new JournalBeforeKag(service, hospitalitySession, firstId, -1);
                }
            }
            else if (DdtIssuedMedicineList.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new IssuedMedicine(this.service, hospitalitySession, firstId);
            }
            else if (DdtEgds.NAME.Equals(firstType, StringComparison.Ordinal) || DdtXRay.NAME.Equals(firstType, StringComparison.Ordinal) ||
                     DdtUrineAnalysis.NAME.Equals(firstType, StringComparison.Ordinal) || DdtEkg.NAME.Equals(firstType, StringComparison.Ordinal) ||
                     DdtSpecialistConclusion.NAME.Equals(firstType, StringComparison.Ordinal) || DdtUzi.NAME.Equals(firstType, StringComparison.Ordinal) ||
                     DdtKag.NAME.Equals(firstType, StringComparison.Ordinal) || DdtHolter.NAME.Equals(firstType, StringComparison.Ordinal) ||
                     DdtBloodAnalysis.NAME.Equals(firstType, StringComparison.Ordinal) || DdtHormones.NAME.Equals(firstType, StringComparison.Ordinal) ||
                     DdtCoagulogram.NAME.Equals(firstType, StringComparison.Ordinal) || DdtOncologicMarkers.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new AnalysisContainer(service, hospitalitySession, firstType, firstId);
            }
            else if (DdtConsilium.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new Consilium(service, hospitalitySession, firstId);
            }
            else if (DdtSerology.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new Serology(service, hospitalitySession);
            }
            else if (DdtInspection.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new Inspection(service, hospitalitySession, firstId);
            }
            else if (DdtEpicrisis.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new PreoperativeEpicrisiscs(service, hospitalitySession, firstId);
            }
            else if (DdtHospital.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new PatientAdmission(service, hospitalitySession);
            }
            else if (DdtAlcoProtocol.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new AlcoIntoxication(service, hospitalitySession);
            }
            else if (DdtTransfusion.NAME.Equals(firstType, StringComparison.Ordinal))
            {
                form = new Transfusion(service, hospitalitySession, firstId);
            }

            if (form != null)
            {
                form.ShowDialog();
            }
        }
Example #6
0
        private void initControls()
        {
            wrongDateWarning.Visible = false;
            CommonUtils.InitRangedItems(chssSurgeryTxt, 40, 200);
            CommonUtils.InitRangedItems(chddSurgeryTxt, 14, 26);

            afterKagDiagnosisTxt.Text = hospitalitySession.Diagnosis;

            CommonUtils.InitDoctorsByGroupComboboxValues(service, journalDocBox, "cardioreanimation_department");
            CommonUtils.InitDoctorsByGroupComboboxValues(service, cardioVascularBox, "xray_department");

            DdvPatient patientView = service.GetDdvPatientService().GetById(hospitalitySession.Patient);

            Text += " " + patientView?.ShortName;

            if (!string.IsNullOrEmpty(journalDayId))
            {
                DdtJournalDay journalDay = service.GetDdtJournalDayService().GetById(journalDayId);
                if (journalDay != null)
                {
                    DdtVariousSpecConcluson cardioVascularConcls = service.GetDdtVariousSpecConclusonService().GetByParentId(journalDayId);
                    surgeryInspectationTxt.Text     = cardioVascularConcls?.SpecialistConclusion;
                    chddSurgeryTxt.Text             = cardioVascularConcls?.AdditionalInfo1;
                    adSurgeryTxt.Text               = cardioVascularConcls?.AdditionalInfo3;
                    chssSurgeryTxt.Text             = cardioVascularConcls?.AdditionalInfo2;
                    cardioDate.Value                = cardioVascularConcls == null ? DateTime.Now : cardioVascularConcls.AdmissionDate;
                    cardioTime.Value                = cardioVascularConcls == null ? DateTime.Now : cardioVascularConcls.AdmissionDate;
                    cardioVascularBox.SelectedValue = cardioVascularConcls?.AdditionalInfo4;

                    admissionTimeTxt.Value      = journalDay.AdmissionDate;
                    admissionDateTxt.Value      = journalDay.AdmissionDate;
                    afterKagDiagnosisTxt.Text   = journalDay.Diagnosis;
                    journalDocBox.SelectedValue = journalDay.Doctor;

                    IList <DdtKag> kags = service.GetDdtKagService().GetByParentId(journalDay.ObjectId);
                    DdtKag         kag  = kags.Count > 0 ? kags[0] : null;
                    if (kag != null)
                    {
                        kagDiagnosisTxt.Text = kag.KagAction;
                        kagId = kag.ObjectId;
                        analysisTabControl1.addAnalisis(DdtKag.NAME, "КАГ", kag.ObjectId);
                    }

                    initCardioConslusions(service);
                }
            }
            else
            {
                //Для нового дневника ставим время через 1 час после приема. если есть КАГ, то через 15 мин после КАГ
                String sql = String.Format("SELECT r_object_id, dsdt_analysis_date, dsdt_end_time, r_creation_date, dsid_parent, dss_kag_manipulation, " +
                                           "dsid_doctor, dsid_patient, dsid_hospitality_session, dsdt_start_time, r_modify_date, dss_parent_type, dss_results, dss_kag_action " +
                                           "FROM ddt_kag WHERE dsid_hospitality_session = '{0}' order by dsdt_analysis_date desc", hospitalitySession.ObjectId);
                IList <DdtKag> kags = service.GetDdtKagService().GetByQuery(sql);
                initKag(kags.Count > 0 ? kags[0] : null);

                getIsValid();

                journalDocBox.SelectedValue     = hospitalitySession.CuringDoctor;
                cardioVascularBox.SelectedValue = hospitalitySession.DutyDoctor;
            }
        }
Example #7
0
        public bool Save()
        {
            if (!getIsValid())
            {
                return(false);
            }

            service.GetDdtHospitalService().Save(hospitalitySession);

            DdtJournalDay journalDay = null;

            if (!string.IsNullOrEmpty(journalDayId))
            {
                journalDay = service.GetDdtJournalDayService().GetById(journalDayId);
            }
            else
            {
                journalDay                    = new DdtJournalDay();
                journalDay.JournalType        = 1;
                journalDay.HospitalitySession = hospitalitySession.ObjectId;
                journalDay.Patient            = hospitalitySession.Patient;
                journalDay.JournalType        = (int)DdtJournalDsiType.AfterKag;
                //journal.Complaints = "Жалоб на момент осмотра не предъявляет.";
            }
            journalDay.AdmissionDate = CommonUtils.ConstructDateWIthTime(admissionDateTxt.Value, admissionTimeTxt.Value);
            DdvDoctor doc = (DdvDoctor)journalDocBox.SelectedItem;

            journalDay.Doctor    = doc == null ? hospitalitySession.DutyDoctor : doc.ObjectId;
            journalDay.Diagnosis = afterKagDiagnosisTxt.Text;
            journalDayId         = service.GetDdtJournalDayService().Save(journalDay);

            DdtVariousSpecConcluson cardioVascularConc = service.GetDdtVariousSpecConclusonService().GetByParentId(journalDayId);

            if (cardioVascularConc == null)
            {
                cardioVascularConc        = new DdtVariousSpecConcluson();
                cardioVascularConc.Parent = journalDayId;
            }
            cardioVascularConc.AdmissionDate        = CommonUtils.ConstructDateWIthTime(cardioDate.Value, cardioTime.Value);
            cardioVascularConc.SpecialistConclusion = surgeryInspectationTxt.Text;
            cardioVascularConc.AdditionalInfo1      = chddSurgeryTxt.Text;
            cardioVascularConc.AdditionalInfo3      = adSurgeryTxt.Text;
            cardioVascularConc.AdditionalInfo2      = chssSurgeryTxt.Text;
            cardioVascularConc.AdditionalInfo4      = (string)cardioVascularBox.SelectedValue;
            service.GetDdtVariousSpecConclusonService().Save(cardioVascularConc);

            if (!string.IsNullOrEmpty(kagDiagnosisTxt.Text))
            {
                DdtKag kag = service.GetDdtKagService().GetById(kagId);
                if (kag == null)
                {
                    kag                    = new DdtKag();
                    kag.Doctor             = hospitalitySession.CuringDoctor;
                    kag.HospitalitySession = hospitalitySession.ObjectId;
                    kag.Patient            = hospitalitySession.Patient;
                    DateTime admissionDateTime = CommonUtils.ConstructDateWIthTime(admissionDateTxt.Value, admissionTimeTxt.Value);
                    kag.AnalysisDate = admissionDateTime.AddMinutes(-75);
                    kag.StartTime    = admissionDateTime.AddMinutes(-75);
                    kag.EndTime      = admissionDateTime.AddMinutes(-15);
                    kag.KagAction    = kagDiagnosisTxt.Text;
                    kagId            = service.GetDdtKagService().Save(kag);

                    IDdtRelationService relationService = DbDataService.GetInstance().GetDdtRelationService();
                    if (kagId != null && relationService.GetByParentAndChildIds(journalDayId, kagId) == null)
                    {
                        DdtRelation relation = new DdtRelation();
                        relation.Parent    = journalDayId;
                        relation.Child     = kagId;
                        relation.ChildType = DdtJournal.NAME;
                        relationService.Save(relation);
                    }
                }
            }

            for (int i = 0; i < dutyCardioContainer.Controls.Count; i++)
            {
                JournalKAGControl journalCtrl = (JournalKAGControl)dutyCardioContainer.Controls[i];
                journalCtrl.saveObject(hospitalitySession, journalDayId, DdtJournal.NAME);
            }

            analysisTabControl1.save(journalDayId, DdtJournal.NAME);
            return(true);
        }