Exemple #1
0
        public DdtTransfer GetByHospitalSession(string hospitalSession)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                String sql = String.Format("SELECT dsid_hospitality_session, r_object_id, dsdt_end_date, r_modify_date, dss_destination, r_creation_date, dss_transfer_justification, dsdt_start_date, dsid_doctor, dsi_type, dss_contacts, dsid_patient FROM ddt_transfer 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())
                    {
                        DdtTransfer obj = new DdtTransfer();
                        obj.HospitalitySession    = reader.IsDBNull(0) ? null : reader.GetString(0);
                        obj.ObjectId              = reader.IsDBNull(1) ? null : reader.GetString(1);
                        obj.EndDate               = reader.IsDBNull(2) ? DateTime.MinValue : reader.GetDateTime(2);
                        obj.ModifyDate            = reader.IsDBNull(3) ? DateTime.MinValue : reader.GetDateTime(3);
                        obj.Destination           = reader.IsDBNull(4) ? null : reader.GetString(4);
                        obj.CreationDate          = reader.IsDBNull(5) ? DateTime.MinValue : reader.GetDateTime(5);
                        obj.TransferJustification = reader.IsDBNull(6) ? null : reader.GetString(6);
                        obj.StartDate             = reader.IsDBNull(7) ? DateTime.MinValue : reader.GetDateTime(7);
                        obj.Doctor   = reader.IsDBNull(8) ? null : reader.GetString(8);
                        obj.Type     = reader.IsDBNull(9) ? -1 : reader.GetInt16(9);
                        obj.Contacts = reader.IsDBNull(10) ? null : reader.GetString(10);
                        obj.Patient  = reader.IsDBNull(11) ? null : reader.GetString(11);
                        return(obj);
                    }
                }
            }
            return(null);
        }
Exemple #2
0
        public string Save(DdtTransfer obj)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                if (GetById(obj.ObjectId) != null)
                {
                    string sql = "UPDATE ddt_transfer SET " +
                                 "dsid_hospitality_session = @HospitalitySession, " +
                                 "dsid_patient = @Patient, " +
                                 "dsid_doctor = @Doctor, " +
                                 "dsdt_start_date = @StartDate, " +
                                 "dsdt_end_date = @EndDate, " +
                                 "dss_destination = @Destination, " +
                                 "dss_contacts = @Contacts, " +
                                 "dss_transfer_justification = @TransferJustification, " +
                                 "dsi_type = @Type " +
                                 "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("@StartDate", obj.StartDate);
                        cmd.Parameters.AddWithValue("@EndDate", obj.EndDate);
                        cmd.Parameters.AddWithValue("@Destination", obj.Destination == null ? "" : obj.Destination);
                        cmd.Parameters.AddWithValue("@Contacts", obj.Contacts == null ? "" : obj.Contacts);
                        cmd.Parameters.AddWithValue("@TransferJustification", obj.TransferJustification == null ? "" : obj.TransferJustification);
                        cmd.Parameters.AddWithValue("@Type", obj.Type);
                        cmd.Parameters.AddWithValue("@ObjectId", obj.ObjectId);
                        cmd.ExecuteNonQuery();
                    }
                    return(obj.ObjectId);
                }
                else
                {
                    string sql = "INSERT INTO ddt_transfer(dsid_hospitality_session,dsid_patient,dsid_doctor,dsdt_start_date,dsdt_end_date,dss_destination,dss_contacts,dss_transfer_justification,dsi_type) " +
                                 "VALUES(@HospitalitySession,@Patient,@Doctor,@StartDate,@EndDate,@Destination,@Contacts,@TransferJustification,@Type) 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("@StartDate", obj.StartDate);
                        cmd.Parameters.AddWithValue("@EndDate", obj.EndDate);
                        cmd.Parameters.AddWithValue("@Destination", obj.Destination == null ? "" : obj.Destination);
                        cmd.Parameters.AddWithValue("@Contacts", obj.Contacts == null ? "" : obj.Contacts);
                        cmd.Parameters.AddWithValue("@TransferJustification", obj.TransferJustification == null ? "" : obj.TransferJustification);
                        cmd.Parameters.AddWithValue("@Type", obj.Type);
                        return((string)cmd.ExecuteScalar());
                    }
                }
            }
        }
Exemple #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>();
            }
            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));
        }