public DdtSerology GetByHospitalSession(string hospitalSession) { using (dynamic connection = connectionFactory.GetConnection()) { String sql = String.Format("SELECT r_object_id, dsdt_analysis_date, dss_blood_type, r_creation_date, dss_kell_ag, dss_phenotype, dss_rw, dsid_doctor, dsid_patient, dss_hbs_ag, dss_anti_hcv, dsid_hospitality_session, r_modify_date, dss_hiv, dss_rhesus_factor FROM ddt_serology WHERE dsid_hospitality_session = '{0}'", hospitalSession); Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", sql); Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(sql, connection); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { DdtSerology obj = new DdtSerology(); obj.ObjectId = reader.IsDBNull(0) ? null : reader.GetString(0); obj.AnalysisDate = reader.IsDBNull(1) ? DateTime.MinValue : reader.GetDateTime(1); obj.BloodType = reader.IsDBNull(2) ? null : reader.GetString(2); obj.CreationDate = reader.IsDBNull(3) ? DateTime.MinValue : reader.GetDateTime(3); obj.KellAg = reader.IsDBNull(4) ? null : reader.GetString(4); obj.Phenotype = reader.IsDBNull(5) ? null : reader.GetString(5); obj.Rw = reader.IsDBNull(6) ? null : reader.GetString(6); obj.Doctor = reader.IsDBNull(7) ? null : reader.GetString(7); obj.Patient = reader.IsDBNull(8) ? null : reader.GetString(8); obj.HbsAg = reader.IsDBNull(9) ? null : reader.GetString(9); obj.AntiHcv = reader.IsDBNull(10) ? null : reader.GetString(10); obj.HospitalitySession = reader.IsDBNull(11) ? null : reader.GetString(11); obj.ModifyDate = reader.IsDBNull(12) ? DateTime.MinValue : reader.GetDateTime(12); obj.Hiv = reader.IsDBNull(13) ? null : reader.GetString(13); obj.RhesusFactor = reader.IsDBNull(14) ? null : reader.GetString(14); return(obj); } } } return(null); }
private void saveBtn_Click(object sender, EventArgs e) { if (!getIsValid()) { MessageBox.Show("Введены не все данные на форме! Обязательные поля выделены жирным шрифтом!", "Предупреждение!", MessageBoxButtons.OK); return; } if (serology == null) { serology = new DdtSerology(); serology.HospitalitySession = hospitalitySession.ObjectId; serology.Doctor = hospitalitySession.CuringDoctor; serology.Patient = hospitalitySession.Patient; } serology.AntiHcv = antiHcvBox.Text; serology.BloodType = bloodTypeBox.Text; serology.HbsAg = hbsAgBox.Text; serology.Hiv = hivBox.Text; serology.KellAg = kellAgBox.Text; serology.Phenotype = phenotypeTxt.Text; serology.RhesusFactor = rhesusFactorBox.Text; serology.Rw = rwBox.Text; serology.AnalysisDate = analysisDate.Value; service.GetDdtSerologyService().Save(serology); Close(); }
public Serology(IDbDataService service, DdtHospital hospitalitySession) { this.service = service; this.hospitalitySession = hospitalitySession; serology = service.GetDdtSerologyService().GetByHospitalSession(hospitalitySession.ObjectId); InitializeComponent(); InitBoxes(); }
public Serology(DdtHospital hospitalitySession) { this.hospitalitySession = hospitalitySession; DataService service = new DataService(); serology = service.queryObject <DdtSerology>(@"select * from ddt_serology where dsid_hospitality_session='" + hospitalitySession.ObjectId + "'"); InitializeComponent(); initBoxes(); }
private void printBtn_Click(object sender, EventArgs e) { int rowCount = patientHistoryGrid.Rows.Count; DdvPatient patient = service.GetDdvPatientService().GetById(hospitalitySession.Patient); List <string> paths = new List <string>(); if (printTitlePage.Checked) { List <string> prePaths = new List <string>(); Dictionary <string, string> titleDict = new Dictionary <string, string>(); titleDict.Add("{mednumber}", patient.MedCode); titleDict.Add("{admission_date}", hospitalitySession.AdmissionDate.ToShortDateString()); titleDict.Add("{leaving_date}", DateTime.Now.ToShortDateString()); titleDict.Add("{med_policy}", patient.Oms); titleDict.Add("{room}", hospitalitySession.RoomCell); titleDict.Add("{daysinhospital}", (DateTime.Now.Year - hospitalitySession.AdmissionDate.Year) + ""); DdtSerology serology = service.GetDdtSerologyService().GetByHospitalSession(hospitalitySession.ObjectId); titleDict.Add("{blood_n}", serology?.BloodType); titleDict.Add("{rhesus}", serology?.RhesusFactor); titleDict.Add("{height}", patient.High + ""); titleDict.Add("{weight}", patient.Weight + ""); titleDict.Add("{patient_full_name}", patient.FullName); titleDict.Add("{sex}", patient.Sex ? "мужской" : "женский"); titleDict.Add("{passport}", patient.PassportSerial + " " + patient.PassportNum + " " + patient.PassportIssuePlace + " " + patient.PassportDate.ToShortDateString()); titleDict.Add("{age}", (DateTime.Now.Year - patient.Birthdate.Year) + ""); titleDict.Add("{birthdate}", patient.Birthdate.ToShortDateString()); titleDict.Add("{address}", patient.Address); DdtAnamnesis firstIspection = service.GetDdtAnamnesisService().GetByHospitalSessionId(hospitalitySession.ObjectId); titleDict.Add("{diagnosis_first}", firstIspection?.Diagnosis); titleDict.Add("{diagnosis_last}", hospitalitySession.Diagnosis); prePaths.Add(TemplatesUtils.FillTemplate(Directory.GetCurrentDirectory() + "\\Templates\\" + "title.docx", titleDict)); paths.Add(TemplatesUtils.MergeFiles(prePaths.ToArray(), true, null)); } foreach (DataGridViewRow row in patientHistoryGrid.Rows) { bool checkd = (bool)row.Cells[0].Value; if (checkd) { ITemplateProcessor te = TemplateProcessorManager.getProcessorByObjectType((string)row.Cells[2].Value); if (te != null) { string pathFile = te.processTemplate(service, hospitalitySession.ObjectId, (string)row.Cells[3].Value, null); paths.Add(pathFile); } } } string resultFileName = TemplatesUtils.getTempFileName("История болезни", patient.FullName); string resultPath = TemplatesUtils.MergeFiles(paths.ToArray(), false, resultFileName); TemplatesUtils.ShowDocument(resultPath); }
private void saveBtn_Click(object sender, EventArgs e) { if (!getIsValid()) { MessageBox.Show("Введены не все данные на форме! Обязательные поля выделены жирным шрифтом!", "Предупреждение!", MessageBoxButtons.OK); return; } DataService service = new DataService(); if (serology == null) { serology = new DdtSerology(); serology.DsidHospitalitySession = hospitalitySession.ObjectId; serology.DsidDoctor = hospitalitySession.DsidCuringDoctor; serology.DsidPatient = hospitalitySession.DsidPatient; } serology.DssAntiHcv = antiHcvBox.Text; serology.DssBloodType = bloodTypeBox.Text; serology.DssHbsAg = hbsAgBox.Text; serology.DssHiv = hivBox.Text; serology.DssKellAg = kellAgBox.Text; serology.DssPhenotype = phenotypeTxt.Text; serology.DssRhesusFactor = rhesusFactorBox.Text; serology.DssRw = rwBox.Text; if (CommonUtils.isBlank(serology.ObjectId)) { service.insertObject <DdtSerology>(serology, DdtSerology.TABLE_NAME); } else { service.updateObject <DdtSerology>(serology, DdtSerology.TABLE_NAME, "r_object_id", serology.ObjectId); } Close(); }
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>(); } DdtEpicrisis obj = service.GetDdtEpicrisisService().GetById(objectId); values.Add("{diagnosis}", obj.Diagnosis); values.Add("{date}", obj.EpicrisisDate.ToShortDateString()); DdvPatient patient = service.GetDdvPatientService().GetById(obj.Patient); values.Add("{patient.initials}", patient == null ? "" : patient.ShortName); values.Add("{patient.age}", patient == null ? "" : (DateTime.Now.Year - patient.Birthdate.Year) + ""); DdtHospital hospital = service.GetDdtHospitalService().GetById(hospitalitySession); values.Add("{patient.admission_date}", hospital.AdmissionDate.ToShortDateString()); DdtAnamnesis anamnesis = service.GetDdtAnamnesisService().GetByHospitalSessionId(hospital.ObjectId); values.Add("{complaints}", anamnesis == null ? " " : anamnesis.Complaints); values.Add("{anamnesis}", anamnesis == null ? " " : anamnesis.AnamnesisMorbi); StringBuilder inspectonBld = new StringBuilder(); inspectonBld.Append(CompileValue("St.Presens", anamnesis?.StPresens)); inspectonBld.Append(CompileValue("Органы дыхания", anamnesis?.RespiratorySystem)); inspectonBld.Append(CompileValue("Сердечно-сосудистая система", anamnesis?.CardiovascularSystem)); inspectonBld.Append(CompileValue("Органы пищеварения", anamnesis?.DigestiveSystem)); values.Add("{inspection}", anamnesis == null ? " " : inspectonBld.ToString()); DdtSerology serology = service.GetDdtSerologyService().GetByHospitalSession(hospital.ObjectId); StringBuilder serologyBld = new StringBuilder(); if (serology != null) { serologyBld.Append(CompileValue("Группа крови", serology.BloodType)); serologyBld.Append(CompileValue("Резус-фактор", serology.RhesusFactor)); serologyBld.Append(CompileValue("RW", serology.Rw)); } values.Add("{serology}", serology == null ? " " : serologyBld.ToString()); PutAnalysisData(values, service, obj.ObjectId); StringBuilder bloodStr = new StringBuilder(); if (serology != null) { bloodStr.Append(CompileValue("KELL-ag", serology.KellAg)); bloodStr.Append(CompileValue("HBs ag", serology.HbsAg)); bloodStr.Append(CompileValue("Anti HCV крови", serology.AntiHcv)); bloodStr.Append(CompileValue("HIV", serology.Hiv)); } if (obj.EpicrisisType == (int)DdtEpicrisisDsiType.TRANSFER) { DdtTransfer transfer = service.GetDdtTransferService().GetByHospitalSession(hospitalitySession); if (transfer != null) { values.Add("{destination}", transfer.Destination); values.Add("{contact}", transfer.Contacts); values.Add("{transport_justification}", transfer.TransferJustification); values.Add("{patient.release_date}", transfer.StartDate.ToShortDateString()); } } else if (obj.EpicrisisType == (int)DdtEpicrisisDsiType.DEATH) { values.Add("{conclusion}", " "); } DdvDoctor doc = service.GetDdvDoctorService().GetById(obj.Doctor); values.Add("{doctor.who.short}", doc.ShortName); DdvDoctor surgery = service.GetDdvDoctorService().GetById(hospital.DutyDoctor); values.Add("{surgery}", surgery?.ShortName + "\n"); DdvDoctor anest = service.GetDdvDoctorService().GetById(hospital.AnesthetistDoctor); values.Add("{anestesiolog}", anest?.ShortName); string resultFileName = TemplatesUtils.getTempFileName("Эпикриз", patient.FullName); return(TemplatesUtils.FillTemplate(Directory.GetCurrentDirectory() + "\\Templates\\" + getTemplateName(obj), values, resultFileName)); }
public void Save(DdtSerology obj) { using (dynamic connection = connectionFactory.GetConnection()) { if (GetById(obj.ObjectId) != null) { string sql = "UPDATE ddt_serology SET " + "dsid_hospitality_session = @HospitalitySession, " + "dsid_patient = @Patient, " + "dsid_doctor = @Doctor, " + "dsdt_analysis_date = @AnalysisDate, " + "dss_blood_type = @BloodType, " + "dss_rhesus_factor = @RhesusFactor, " + "dss_phenotype = @Phenotype, " + "dss_kell_ag = @KellAg, " + "dss_rw = @Rw, " + "dss_hbs_ag = @HbsAg, " + "dss_anti_hcv = @AntiHcv, " + "dss_hiv = @Hiv " + "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("@Doctor", obj.Doctor); cmd.Parameters.AddWithValue("@AnalysisDate", obj.AnalysisDate); cmd.Parameters.AddWithValue("@BloodType", obj.BloodType == null ? "" : obj.BloodType); cmd.Parameters.AddWithValue("@RhesusFactor", obj.RhesusFactor == null ? "" : obj.RhesusFactor); cmd.Parameters.AddWithValue("@Phenotype", obj.Phenotype == null ? "" : obj.Phenotype); cmd.Parameters.AddWithValue("@KellAg", obj.KellAg == null ? "" : obj.KellAg); cmd.Parameters.AddWithValue("@Rw", obj.Rw == null ? "" : obj.Rw); cmd.Parameters.AddWithValue("@HbsAg", obj.HbsAg == null ? "" : obj.HbsAg); cmd.Parameters.AddWithValue("@AntiHcv", obj.AntiHcv == null ? "" : obj.AntiHcv); cmd.Parameters.AddWithValue("@Hiv", obj.Hiv == null ? "" : obj.Hiv); cmd.Parameters.AddWithValue("@ObjectId", obj.ObjectId); cmd.ExecuteNonQuery(); } // return obj.ObjectId; } else { string sql = "INSERT INTO ddt_serology(dsid_hospitality_session,dsid_patient,dsid_doctor,dsdt_analysis_date,dss_blood_type,dss_rhesus_factor,dss_phenotype,dss_kell_ag,dss_rw,dss_hbs_ag,dss_anti_hcv,dss_hiv) " + "VALUES(@HospitalitySession,@Patient,@Doctor,@AnalysisDate,@BloodType,@RhesusFactor,@Phenotype,@KellAg,@Rw,@HbsAg,@AntiHcv,@Hiv) 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("@Doctor", obj.Doctor); cmd.Parameters.AddWithValue("@AnalysisDate", obj.AnalysisDate); cmd.Parameters.AddWithValue("@BloodType", obj.BloodType == null ? "" : obj.BloodType); cmd.Parameters.AddWithValue("@RhesusFactor", obj.RhesusFactor == null ? "" : obj.RhesusFactor); cmd.Parameters.AddWithValue("@Phenotype", obj.Phenotype == null ? "" : obj.Phenotype); cmd.Parameters.AddWithValue("@KellAg", obj.KellAg == null ? "" : obj.KellAg); cmd.Parameters.AddWithValue("@Rw", obj.Rw == null ? "" : obj.Rw); cmd.Parameters.AddWithValue("@HbsAg", obj.HbsAg == null ? "" : obj.HbsAg); cmd.Parameters.AddWithValue("@AntiHcv", obj.AntiHcv == null ? "" : obj.AntiHcv); cmd.Parameters.AddWithValue("@Hiv", obj.Hiv == null ? "" : obj.Hiv); // return (string)cmd.ExecuteScalar(); } } } }