示例#1
0
        public Transfusion(IDbDataService service, DdtHospital hospitalSession, string transfusionId)
        {
            this.service         = service;
            this.hospitalSession = hospitalSession;
            patient = service.GetDdtPatientService().GetById(hospitalSession.Patient);
            if (!String.IsNullOrEmpty(transfusionId))
            {
                transfusion     = service.GetDdtTransfusionService().GetById(transfusionId);
                ConsiliumId     = transfusion.Consilium;
                BloodAnalysisId = transfusion.BloodAnalysis;
                bloodAnalysis   = service.GetDdtBloodAnalysisService().GetById(transfusion.BloodAnalysis);
            }

            InitializeComponent();
            InitControls();
        }
示例#2
0
 public bool Save()
 {
     if (transfusion == null)
     {
         transfusion = new DdtTransfusion();
     }
     transfusion.Patient            = patient.ObjectId;
     transfusion.HospitalitySession = hospitalSession.ObjectId;
     transfusion.Doctor             = cbDoctor.SelectedValue.ToString();
     transfusion.TransfusionDate    = dtTransfusionDate.Value;
     transfusion.Consent            = GetCheckedRadio(gbConsent)?.Name;
     transfusion.Consilium          = ConsiliumId;
     transfusion.BloodAnalysis      = BloodAnalysisId;
     transfusion.TransfusionMedium  = GetCheckedMediums(gbTransfusionMedium);
     service.GetDdtTransfusionService().Save(transfusion);
     return(true);
 }
示例#3
0
        public DdtTransfusion GetById(string id)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                String sql = String.Format("SELECT " +
                                           "r_object_id, " +
                                           "r_creation_date, " +
                                           "r_modify_date, " +
                                           "dsid_hospitality_session, " +
                                           "dsid_patient, " +
                                           "dsid_doctor, " +
                                           "dsdt_transfusion_date, " +
                                           "dss_consent, " +
                                           "dsid_consilium, " +
                                           "dsid_blood_analysis, " +
                                           "dss_transfusion_medium " +
                                           "FROM ddt_transfusion 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())
                    {
                        DdtTransfusion obj = new DdtTransfusion();
                        obj.ObjectId           = reader.IsDBNull(0) ? null : reader.GetString(0);
                        obj.CreationDate       = reader.IsDBNull(1) ? DateTime.MinValue : reader.GetDateTime(1);
                        obj.ModifyDate         = reader.IsDBNull(2) ? DateTime.MinValue : reader.GetDateTime(2);
                        obj.HospitalitySession = reader.IsDBNull(3) ? null : reader.GetString(3);
                        obj.Patient            = reader.IsDBNull(4) ? null : reader.GetString(4);
                        obj.Doctor             = reader.IsDBNull(5) ? null : reader.GetString(5);
                        obj.TransfusionDate    = reader.IsDBNull(6) ? DateTime.MinValue : reader.GetDateTime(6);
                        obj.Consent            = reader.IsDBNull(7) ? null : reader.GetString(7);
                        obj.Consilium          = reader.IsDBNull(8) ? null : reader.GetString(8);
                        obj.BloodAnalysis      = reader.IsDBNull(9) ? null : reader.GetString(9);
                        obj.TransfusionMedium  = reader.IsDBNull(10) ? null : reader.GetString(10);
                        return(obj);
                    }
                }
            }
            return(null);
        }
示例#4
0
        public string Save(DdtTransfusion obj)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                if (GetById(obj.ObjectId) != null)
                {
                    string sql = "UPDATE ddt_transfusion SET " +
                                 "dsid_hospitality_session = @HospitalitySession, " +
                                 "dsid_patient = @Patient, " +
                                 "dsid_doctor = @Doctor, " +
                                 "dsdt_transfusion_date = @TransfusionDate, " +
                                 "dss_consent = @Consent, " +
                                 "dsid_consilium = @Consilium, " +
                                 "dsid_blood_analysis = @BloodAnalysis, " +
                                 "dss_transfusion_medium = @TransfusionMedium " +
                                 "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("@TransfusionDate", obj.TransfusionDate);
                        cmd.Parameters.AddWithValue("@Consent", obj.Consent == null ? (object)DBNull.Value : obj.Consent);
                        cmd.Parameters.AddWithValue("@Consilium", obj.Consilium == null ? (object)DBNull.Value : obj.Consilium);
                        cmd.Parameters.AddWithValue("@BloodAnalysis", obj.BloodAnalysis == null ? (object)DBNull.Value : obj.BloodAnalysis);
                        cmd.Parameters.AddWithValue("@TransfusionMedium", obj.TransfusionMedium == null ? (object)DBNull.Value : obj.TransfusionMedium);
                        cmd.Parameters.AddWithValue("@ObjectId", obj.ObjectId);
                        cmd.ExecuteNonQuery();
                    }
                    return(obj.ObjectId);
                }
                else
                {
                    string sql = "INSERT INTO ddt_transfusion(" +
                                 "dsid_hospitality_session, " +
                                 "dsid_patient, " +
                                 "dsid_doctor, " +
                                 "dsdt_transfusion_date, " +
                                 "dss_consent, " +
                                 "dsid_consilium, " +
                                 "dsid_blood_analysis, " +
                                 "dss_transfusion_medium " +
                                 ") " +
                                 "VALUES(" +
                                 "@HospitalitySession," +
                                 "@Patient,@Doctor," +
                                 "@TransfusionDate," +
                                 "@Consent," +
                                 "@Consilium," +
                                 "@BloodAnalysis," +
                                 "@TransfusionMedium" +
                                 ") 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("@TransfusionDate", obj.TransfusionDate);
                        cmd.Parameters.AddWithValue("@Consent", obj.Consent == null ? (object)DBNull.Value : obj.Consent);
                        cmd.Parameters.AddWithValue("@Consilium", obj.Consilium == null ? (object)DBNull.Value : obj.Consilium);
                        cmd.Parameters.AddWithValue("@BloodAnalysis", obj.BloodAnalysis == null ? (object)DBNull.Value : obj.BloodAnalysis);
                        cmd.Parameters.AddWithValue("@TransfusionMedium", obj.TransfusionMedium == null ? (object)DBNull.Value : obj.TransfusionMedium);
                        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>();
            }
            DdtTransfusion   transfusion   = service.GetDdtTransfusionService().GetById(objectId);
            DdtHospital      hospital      = service.GetDdtHospitalService().GetById(hospitalitySession);
            DdvPatient       patient       = service.GetDdvPatientService().GetById(hospital.Patient);
            DdtBloodAnalysis bloodAnalysis = service.GetDdtBloodAnalysisService().GetById(transfusion.BloodAnalysis);

            values.Add(@"{name}", patient.FullName);
            values.Add(@"{age}", (DateTime.Now.Year - patient.Birthdate.Year) + "");
            values.Add(@"{historycard}", patient.MedCode);
            values.Add(@"{diagnosis}", hospital.Diagnosis);
            values.Add(@"{blood}", patient.BloodGroup);
            values.Add(@"{rh}", patient.RHFactor);
            values.Add(@"{kell}", patient.Kell);
            values.Add(@"{phenotype}", patient.Phenotype);

            values.Add(@"{indications}", "гемическая гипоксия");
            values.Add(@"{meduim}", transfusion?.TransfusionMedium);
            values.Add(@"{doctor}", GetDoctorInString(service, transfusion?.Doctor));
            values.Add(@"{transfusionDate}", transfusion?.TransfusionDate.ToShortDateString());

            string mediumNames  = "";
            string mediumCounts = "";

            String[] transfusionMediumArray = transfusion.TransfusionMedium.Split(',');
            foreach (String mediumWithCount in transfusionMediumArray)
            {
                String[] mediumArray = mediumWithCount.Split(':');

                string mediumName  = mediumArray[0];
                string mediumCount = mediumArray[1];

                switch (mediumName)
                {
                case "Blood":
                    mediumName = "Кровь";
                    break;

                case "Plasma":
                    mediumName = "Плазма";
                    break;

                case "Albumin":
                    continue;

                case "Platelet":
                    mediumName = "Тромбоцит";
                    break;
                }

                mediumNames  += string.IsNullOrEmpty(mediumNames) ? mediumName : ", " + mediumName;
                mediumCounts += string.IsNullOrEmpty(mediumCounts) ? mediumCount + " дозы" : ", " + mediumCount + " дозы";
            }
            values.Add(@"{mediumNames}", mediumNames);
            values.Add(@"{mediumCounts}", mediumCounts);

            values.Add(@"{Hemog}", bloodAnalysis.Hemoglobin);
            values.Add(@"{Hemat}", "пусто");
            values.Add(@"{aptt}", "пусто");
            values.Add(@"{inr}", "пусто");

            return(TemplatesUtils.FillTemplate(Directory.GetCurrentDirectory() + "\\Templates\\" + TemplateFileName, values));
        }