public DdtVariousSpecConcluson GetById(string id) { using (dynamic connection = connectionFactory.GetConnection()) { String sql = String.Format("SELECT dss_additional_info0, r_object_id, dsb_visible, dss_specialist_type, dss_additional_info2, dss_additional_info1, r_creation_date, dsid_parent, dsdt_admission_date, dss_additional_info4, dss_additional_info3, dss_specialist_conclusion, r_modify_date, dss_parent_type, dsb_additional_bool FROM ddt_various_spec_concluson WHERE r_object_id = '{0}'", id); Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", sql); Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(sql, connection); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { DdtVariousSpecConcluson obj = new DdtVariousSpecConcluson(); obj.AdditionalInfo0 = reader.IsDBNull(0) ? null : reader.GetString(0); obj.ObjectId = reader.IsDBNull(1) ? null : reader.GetString(1); obj.Visible = reader.GetBoolean(2); obj.SpecialistType = reader.IsDBNull(3) ? null : reader.GetString(3); obj.AdditionalInfo2 = reader.IsDBNull(4) ? null : reader.GetString(4); obj.AdditionalInfo1 = reader.IsDBNull(5) ? null : reader.GetString(5); obj.CreationDate = reader.IsDBNull(6) ? DateTime.MinValue : reader.GetDateTime(6); obj.Parent = reader.IsDBNull(7) ? null : reader.GetString(7); obj.AdmissionDate = reader.IsDBNull(8) ? DateTime.MinValue : reader.GetDateTime(8); obj.AdditionalInfo4 = reader.IsDBNull(9) ? null : reader.GetString(9); obj.AdditionalInfo3 = reader.IsDBNull(10) ? null : reader.GetString(10); obj.SpecialistConclusion = reader.IsDBNull(11) ? null : reader.GetString(11); obj.ModifyDate = reader.IsDBNull(12) ? DateTime.MinValue : reader.GetDateTime(12); obj.ParentType = reader.IsDBNull(13) ? null : reader.GetString(13); obj.AdditionalBool = reader.GetBoolean(14); return(obj); } } } return(null); }
public List <DdtVariousSpecConcluson> GetByQuery(string sql) { List <DdtVariousSpecConcluson> list = new List <DdtVariousSpecConcluson>(); 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()) { DdtVariousSpecConcluson obj = new DdtVariousSpecConcluson(); obj.AdditionalInfo0 = reader.IsDBNull(0) ? null : reader.GetString(0); obj.ObjectId = reader.IsDBNull(1) ? null : reader.GetString(1); obj.Visible = reader.GetBoolean(2); obj.SpecialistType = reader.IsDBNull(3) ? null : reader.GetString(3); obj.AdditionalInfo2 = reader.IsDBNull(4) ? null : reader.GetString(4); obj.AdditionalInfo1 = reader.IsDBNull(5) ? null : reader.GetString(5); obj.CreationDate = reader.IsDBNull(6) ? DateTime.MinValue : reader.GetDateTime(6); obj.Parent = reader.IsDBNull(7) ? null : reader.GetString(7); obj.AdmissionDate = reader.IsDBNull(8) ? DateTime.MinValue : reader.GetDateTime(8); obj.AdditionalInfo4 = reader.IsDBNull(9) ? null : reader.GetString(9); obj.AdditionalInfo3 = reader.IsDBNull(10) ? null : reader.GetString(10); obj.SpecialistConclusion = reader.IsDBNull(11) ? null : reader.GetString(11); obj.ModifyDate = reader.IsDBNull(12) ? DateTime.MinValue : reader.GetDateTime(12); obj.ParentType = reader.IsDBNull(13) ? null : reader.GetString(13); obj.AdditionalBool = reader.GetBoolean(14); list.Add(obj); } } } return(list); }
private void initControls(string inspectionObjId) { ControlUtils.InitDoctorsByGroupName(service.GetDdvDoctorService(), cardioDoctorBox, "cardioreanimation_department"); cardioDoctorBox.SelectedValue = hospitalitySession.CuringDoctor; kagContainer.Visible = false; DdvPatient patient = service.GetDdvPatientService().GetById(hospitalitySession.Patient); if (patient != null) { Text += " " + patient.ShortName; } inspectionObj = service.GetDdtInspectionService().GetById(inspectionObjId); DateTime startDate = inspectionObj == null ? DateTime.Now : inspectionObj.InspectionDate; DdtJournal kagJournal = CommonUtils.ResolveKagJournal(service, startDate, hospitalitySession.ObjectId); if (inspectionObj != null) { complaintsTxt.Text = inspectionObj.Complaints; diagnosisTxt.Text = inspectionObj.Diagnosis; inspectionTxt.Text = inspectionObj.Inspection; resultTxt.Text = inspectionObj.InspectionResult; kateterPlacementTxt.Text = inspectionObj.KateterPlacement; } else { if (kagJournal != null) { diagnosisTxt.Text = kagJournal.Diagnosis; DdtVariousSpecConcluson releaseConclusion = service.GetDdtVariousSpecConclusonService().GetByParentId(kagJournal.ObjectId); if (releaseConclusion != null) { inspectionTxt.Text = releaseConclusion.SpecialistConclusion; } } else { diagnosisTxt.Text = hospitalitySession.Diagnosis; } } initKag(service, kagJournal); }
public string Save(DdtVariousSpecConcluson obj) { using (dynamic connection = connectionFactory.GetConnection()) { if (GetById(obj.ObjectId) != null) { string sql = "UPDATE ddt_various_spec_concluson SET " + "dsid_parent = @Parent, " + "dss_parent_type = @ParentType, " + "dsdt_admission_date = @AdmissionDate, " + "dss_specialist_type = @SpecialistType, " + "dss_specialist_conclusion = @SpecialistConclusion, " + "dss_additional_info0 = @AdditionalInfo0, " + "dss_additional_info1 = @AdditionalInfo1, " + "dss_additional_info2 = @AdditionalInfo2, " + "dss_additional_info3 = @AdditionalInfo3, " + "dss_additional_info4 = @AdditionalInfo4, " + "dsb_visible = @Visible, " + "dsb_additional_bool = @AdditionalBool " + "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("@Parent", obj.Parent == null ? "0000000000000000" : obj.Parent); cmd.Parameters.AddWithValue("@ParentType", obj.ParentType == null ? "" : obj.ParentType); cmd.Parameters.AddWithValue("@AdmissionDate", obj.AdmissionDate); cmd.Parameters.AddWithValue("@SpecialistType", obj.SpecialistType == null ? "" : obj.SpecialistType); cmd.Parameters.AddWithValue("@SpecialistConclusion", obj.SpecialistConclusion == null ? "" : obj.SpecialistConclusion); cmd.Parameters.AddWithValue("@AdditionalInfo0", obj.AdditionalInfo0 == null ? "" : obj.AdditionalInfo0); cmd.Parameters.AddWithValue("@AdditionalInfo1", obj.AdditionalInfo1 == null ? "" : obj.AdditionalInfo1); cmd.Parameters.AddWithValue("@AdditionalInfo2", obj.AdditionalInfo2 == null ? "" : obj.AdditionalInfo2); cmd.Parameters.AddWithValue("@AdditionalInfo3", obj.AdditionalInfo3 == null ? "" : obj.AdditionalInfo3); cmd.Parameters.AddWithValue("@AdditionalInfo4", obj.AdditionalInfo4 == null ? "" : obj.AdditionalInfo4); cmd.Parameters.AddWithValue("@Visible", obj.Visible); cmd.Parameters.AddWithValue("@AdditionalBool", obj.AdditionalBool); cmd.Parameters.AddWithValue("@ObjectId", obj.ObjectId); cmd.ExecuteNonQuery(); } return(obj.ObjectId); } else { string sql = "INSERT INTO ddt_various_spec_concluson(dsid_parent,dss_parent_type,dsdt_admission_date,dss_specialist_type,dss_specialist_conclusion,dss_additional_info0,dss_additional_info1,dss_additional_info2,dss_additional_info3,dss_additional_info4,dsb_visible,dsb_additional_bool) " + "VALUES(@Parent,@ParentType,@AdmissionDate,@SpecialistType,@SpecialistConclusion,@AdditionalInfo0,@AdditionalInfo1,@AdditionalInfo2,@AdditionalInfo3,@AdditionalInfo4,@Visible,@AdditionalBool) 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("@Parent", obj.Parent == null ? "0000000000000000" : obj.Parent); cmd.Parameters.AddWithValue("@ParentType", obj.ParentType == null ? "" : obj.ParentType); cmd.Parameters.AddWithValue("@AdmissionDate", obj.AdmissionDate); cmd.Parameters.AddWithValue("@SpecialistType", obj.SpecialistType == null ? "" : obj.SpecialistType); cmd.Parameters.AddWithValue("@SpecialistConclusion", obj.SpecialistConclusion == null ? "" : obj.SpecialistConclusion); cmd.Parameters.AddWithValue("@AdditionalInfo0", obj.AdditionalInfo0 == null ? "" : obj.AdditionalInfo0); cmd.Parameters.AddWithValue("@AdditionalInfo1", obj.AdditionalInfo1 == null ? "" : obj.AdditionalInfo1); cmd.Parameters.AddWithValue("@AdditionalInfo2", obj.AdditionalInfo2 == null ? "" : obj.AdditionalInfo2); cmd.Parameters.AddWithValue("@AdditionalInfo3", obj.AdditionalInfo3 == null ? "" : obj.AdditionalInfo3); cmd.Parameters.AddWithValue("@AdditionalInfo4", obj.AdditionalInfo4 == null ? "" : obj.AdditionalInfo4); cmd.Parameters.AddWithValue("@Visible", obj.Visible); cmd.Parameters.AddWithValue("@AdditionalBool", obj.AdditionalBool); return((string)cmd.ExecuteScalar()); } } } }
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)); }
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; } }
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); }