Пример #1
0
        public DdtInspection GetById(string id)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                String sql = String.Format("SELECT dsid_hospitality_session, r_object_id, dsdt_inspection_date, r_modify_date, dss_diagnosis, dss_kateter_placement, r_creation_date, dss_complaints, dss_inspection, dsid_doctor, dss_inspection_result, dsid_patient FROM ddt_inspection 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())
                    {
                        DdtInspection obj = new DdtInspection();
                        obj.HospitalitySession = reader.IsDBNull(0) ? null : reader.GetString(0);
                        obj.ObjectId           = reader.IsDBNull(1) ? null : reader.GetString(1);
                        obj.InspectionDate     = reader.IsDBNull(2) ? DateTime.MinValue : reader.GetDateTime(2);
                        obj.ModifyDate         = reader.IsDBNull(3) ? DateTime.MinValue : reader.GetDateTime(3);
                        obj.Diagnosis          = reader.IsDBNull(4) ? null : reader.GetString(4);
                        obj.KateterPlacement   = reader.IsDBNull(5) ? null : reader.GetString(5);
                        obj.CreationDate       = reader.IsDBNull(6) ? DateTime.MinValue : reader.GetDateTime(6);
                        obj.Complaints         = reader.IsDBNull(7) ? null : reader.GetString(7);
                        obj.Inspection         = reader.IsDBNull(8) ? null : reader.GetString(8);
                        obj.Doctor             = reader.IsDBNull(9) ? null : reader.GetString(9);
                        obj.InspectionResult   = reader.IsDBNull(10) ? null : reader.GetString(10);
                        obj.Patient            = reader.IsDBNull(11) ? null : reader.GetString(11);
                        return(obj);
                    }
                }
            }
            return(null);
        }
Пример #2
0
        public string Save(DdtInspection obj)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                if (GetById(obj.ObjectId) != null)
                {
                    string sql = "UPDATE ddt_inspection SET " +
                                 "dsid_hospitality_session = @HospitalitySession, " +
                                 "dsid_patient = @Patient, " +
                                 "dsid_doctor = @Doctor, " +
                                 "dsdt_inspection_date = @InspectionDate, " +
                                 "dss_diagnosis = @Diagnosis, " +
                                 "dss_complaints = @Complaints, " +
                                 "dss_inspection = @Inspection, " +
                                 "dss_kateter_placement = @KateterPlacement, " +
                                 "dss_inspection_result = @InspectionResult " +
                                 "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("@InspectionDate", obj.InspectionDate);
                        cmd.Parameters.AddWithValue("@Diagnosis", obj.Diagnosis == null ? "" : obj.Diagnosis);
                        cmd.Parameters.AddWithValue("@Complaints", obj.Complaints == null ? "" : obj.Complaints);
                        cmd.Parameters.AddWithValue("@Inspection", obj.Inspection == null ? "" : obj.Inspection);
                        cmd.Parameters.AddWithValue("@KateterPlacement", obj.KateterPlacement == null ? "" : obj.KateterPlacement);
                        cmd.Parameters.AddWithValue("@InspectionResult", obj.InspectionResult == null ? "" : obj.InspectionResult);
                        cmd.Parameters.AddWithValue("@ObjectId", obj.ObjectId);
                        cmd.ExecuteNonQuery();
                    }
                    return(obj.ObjectId);
                }
                else
                {
                    string sql = "INSERT INTO ddt_inspection(dsid_hospitality_session,dsid_patient,dsid_doctor,dsdt_inspection_date,dss_diagnosis,dss_complaints,dss_inspection,dss_kateter_placement,dss_inspection_result) " +
                                 "VALUES(@HospitalitySession,@Patient,@Doctor,@InspectionDate,@Diagnosis,@Complaints,@Inspection,@KateterPlacement,@InspectionResult) 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("@InspectionDate", obj.InspectionDate);
                        cmd.Parameters.AddWithValue("@Diagnosis", obj.Diagnosis == null ? "" : obj.Diagnosis);
                        cmd.Parameters.AddWithValue("@Complaints", obj.Complaints == null ? "" : obj.Complaints);
                        cmd.Parameters.AddWithValue("@Inspection", obj.Inspection == null ? "" : obj.Inspection);
                        cmd.Parameters.AddWithValue("@KateterPlacement", obj.KateterPlacement == null ? "" : obj.KateterPlacement);
                        cmd.Parameters.AddWithValue("@InspectionResult", obj.InspectionResult == null ? "" : obj.InspectionResult);
                        return((string)cmd.ExecuteScalar());
                    }
                }
            }
        }
Пример #3
0
        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>();
            }
            DdtInspection obj = service.GetDdtInspectionService().GetById(objectId);

            values.Add("{date}", obj.InspectionDate.ToShortDateString());
            values.Add("{time}", obj.InspectionDate.ToShortTimeString());
            values.Add("{patient.diagnosis}", obj.Diagnosis);
            values.Add("{complaints}", obj.Complaints);
            values.Add("{inspection}", obj.Inspection);
            values.Add("{kateter}", obj.KateterPlacement);
            values.Add("{result}", obj.InspectionResult);

            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) + "");

            if (!values.ContainsKey("{doctor.who.short}"))
            {
                DdvDoctor doc = service.GetDdvDoctorService().GetById(obj.Doctor);
                values.Add("{doctor.who.short}", doc == null ? "" : doc.ShortName);
            }

            IList <DdvDoctor> heads = service.GetDdvDoctorService().GetByGroupName("cardioreanimation_department_head");

            if (heads.Count != 0)
            {
                DdvDoctor head = heads[0];
                values.Add("{doctor.head.short}", head.ShortName);
            }

            PutAnalysisData(values, service, obj.ObjectId);

            string resultFileName = TemplatesUtils.getTempFileName("Ежедневный осмотр", patient.FullName);

            return(TemplatesUtils.FillTemplate(Directory.GetCurrentDirectory() + "\\Templates\\" + TEMPLATE_FILE_NAME, values, resultFileName));
        }
Пример #4
0
        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);
        }
Пример #5
0
        private void saveInspectionObj(IDbDataService service)
        {
            if (inspectionObj == null)
            {
                inspectionObj                    = new DdtInspection();
                inspectionObj.Doctor             = hospitalitySession.CuringDoctor;
                inspectionObj.HospitalitySession = hospitalitySession.ObjectId;
                inspectionObj.Patient            = hospitalitySession.Patient;
            }

            inspectionObj.Complaints       = getSafeStringValue(complaintsTxt);
            inspectionObj.Diagnosis        = getSafeStringValue(diagnosisTxt);
            inspectionObj.Inspection       = getSafeStringValue(inspectionTxt);
            inspectionObj.InspectionResult = getSafeStringValue(resultTxt);
            inspectionObj.KateterPlacement = getSafeStringValue(kateterPlacementTxt);
            inspectionObj.InspectionDate   = CommonUtils.ConstructDateWIthTime(inspectionDate.Value, inspectionTime.Value);
            string id = service.GetDdtInspectionService().Save(inspectionObj);

            inspectionObj.ObjectId = id;
        }