public IList <DdtIssuedMedicine> GetAll()
        {
            IList <DdtIssuedMedicine> list = new List <DdtIssuedMedicine>();

            using (dynamic connection = connectionFactory.GetConnection())
            {
                String sql = "SELECT dsid_med_list, r_object_id, dsid_cure, r_modify_date, r_creation_date FROM ddt_issued_medicine";

                Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", sql);

                Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(sql, connection);
                using (DbDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        DdtIssuedMedicine obj = new DdtIssuedMedicine();
                        obj.MedList      = reader.IsDBNull(0) ? null : reader.GetString(0);
                        obj.ObjectId     = reader.IsDBNull(1) ? null : reader.GetString(1);
                        obj.Cure         = reader.IsDBNull(2) ? null : reader.GetString(2);
                        obj.ModifyDate   = reader.IsDBNull(3) ? DateTime.MinValue : reader.GetDateTime(3);
                        obj.CreationDate = reader.IsDBNull(4) ? DateTime.MinValue : reader.GetDateTime(4);
                        list.Add(obj);
                    }
                }
            }
            return(list);
        }
        public DdtIssuedMedicine GetById(string id)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                String sql = String.Format("SELECT dsid_med_list, r_object_id, dsid_cure, r_modify_date, r_creation_date FROM ddt_issued_medicine 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())
                    {
                        DdtIssuedMedicine obj = new DdtIssuedMedicine();
                        obj.MedList      = reader.IsDBNull(0) ? null : reader.GetString(0);
                        obj.ObjectId     = reader.IsDBNull(1) ? null : reader.GetString(1);
                        obj.Cure         = reader.IsDBNull(2) ? null : reader.GetString(2);
                        obj.ModifyDate   = reader.IsDBNull(3) ? DateTime.MinValue : reader.GetDateTime(3);
                        obj.CreationDate = reader.IsDBNull(4) ? DateTime.MinValue : reader.GetDateTime(4);
                        return(obj);
                    }
                }
            }
            return(null);
        }
Beispiel #3
0
        private void UpdateIssuedMedicineListFromTemplate(string template)
        {
            IList <DdtCure> medicineTemplates = service.GetDdtCureService().GetListByTemplate(template);

            if (patient != null && patient.Sd)
            {
                IList <DdtCure> sdMedTemplate = service.GetDdtCureService().GetListByTemplate("sd");
                foreach (DdtCure cur in sdMedTemplate)
                {
                    medicineTemplates.Add(cur);
                }
                foreach (DdtCure cur in medicineTemplates)
                {
                    if (cur.Name.Equals("Стол ОВД", StringComparison.Ordinal))
                    {
                        medicineTemplates.Remove(cur);
                        break;
                    }
                }
            }

            medicineList.Clear();
            layout.Controls.Clear();

            foreach (DdtCure cure in medicineTemplates)
            {
                DdtIssuedMedicine med = new DdtIssuedMedicine();
                med.Cure = cure.ObjectId;
                AddIssuedMedicine(med, cure);
            }
        }
Beispiel #4
0
        private void UpdateMedicineFromTemplate(string template)
        {
            List <DdtCure> medicineTemplates = service.GetDdtCureService().GetByQuery(@"Select cure.* from ddt_values vv, ddt_cure cure 
                            where vv.dss_name like '" + template + "%' AND vv.dss_value=cure.dss_name");

            foreach (DdtCure cure in medicineTemplates)
            {
                DdtIssuedMedicine med = new DdtIssuedMedicine
                {
                    Cure = cure.ObjectId
                };
                AddIssuedMedicine(med, cure);
            }
        }
Beispiel #5
0
        private void copyFirstMedicineBtn_Click(object sender, EventArgs e)
        {
            DdtIssuedMedicineList medList = service.GetDdtIssuedMedicineListService().GetListByHospitalIdAndParentType(DdtAnamnesis.NAME, hospitalitySession.ObjectId);

            if (medList != null)
            {
                IList <DdtCure> cures = service.GetDdtCureService().GetListByMedicineListId(medList.ObjectId);
                foreach (DdtCure cure in cures)
                {
                    DdtIssuedMedicine med = new DdtIssuedMedicine
                    {
                        Cure = cure.ObjectId
                    };
                    AddIssuedMedicine(med, cure);
                }
            }
        }
Beispiel #6
0
        private void copyJournalMedBtn_Click(object sender, EventArgs e)
        {
            String medListId = service.GetString(@"SELECT medlist.* FROM ddt_issued_medicine_list medlist, ddt_inspection ins WHERE ins.dsid_hospitality_session='" +
                                                 hospitalitySession.ObjectId + "' AND medlist.dsid_parent_id=ins.r_object_id ORDER BY dsdt_inspection_date DESC");

            if (!string.IsNullOrEmpty(medListId))
            {
                IList <DdtCure> cures = service.GetDdtCureService().GetListByMedicineListId(medListId);
                foreach (DdtCure cure in cures)
                {
                    DdtIssuedMedicine med = new DdtIssuedMedicine
                    {
                        Cure = cure.ObjectId
                    };
                    AddIssuedMedicine(med, cure);
                }
            }
        }
Beispiel #7
0
        private void copyYesterdayMedBtn_Click(object sender, EventArgs e)
        {
            String medListId = service.GetString(@"SELECT * FROM ddt_issued_medicine_list  WHERE dsid_hospitality_session='" +
                                                 hospitalitySession.ObjectId + "'   ORDER BY dsdt_issuing_date DESC");

            if (!string.IsNullOrEmpty(medListId))
            {
                List <DdtCure> cures = service.GetDdtCureService().GetByQuery(@"SELECT cures.* FROM " + DdtCure.NAME + " cures, " + DdtIssuedMedicine.NAME +
                                                                              " meds WHERE meds.dsid_med_list='" + medListId + "' AND meds.dsid_cure=cures.r_object_id");
                foreach (DdtCure cure in cures)
                {
                    DdtIssuedMedicine med = new DdtIssuedMedicine
                    {
                        Cure = cure.ObjectId
                    };
                    AddIssuedMedicine(med, cure);
                }
            }
        }
        public string Save(DdtIssuedMedicine obj)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                if (GetById(obj.ObjectId) != null)
                {
                    string sql = "UPDATE ddt_issued_medicine SET " +
                                 "dsid_med_list = @MedList, " +
                                 "dsid_cure = @Cure " +
                                 "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("@MedList", obj.MedList);
                        cmd.Parameters.AddWithValue("@Cure", obj.Cure);
                        cmd.Parameters.AddWithValue("@ObjectId", obj.ObjectId);
                        cmd.ExecuteNonQuery();
                    }
                    return(obj.ObjectId);
                }
                else
                {
                    string sql = "INSERT INTO ddt_issued_medicine(dsid_med_list,dsid_cure) " +
                                 "VALUES(@MedList,@Cure) 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("@MedList", obj.MedList);
                        cmd.Parameters.AddWithValue("@Cure", obj.Cure);
                        obj.ObjectId = (string)cmd.ExecuteScalar();
                        return(obj.ObjectId);
                    }
                }
            }
        }
Beispiel #9
0
        private void InitPatientInfo()
        {
            patient = service.GetDdvPatientService().GetById(hospitalSession.Patient);
            if (patient != null)
            {
                patientInitialsLbl.Text = patient.ShortName;
                if (anamnesis == null)
                {
                    if (patient.Sd)
                    {
                        IList <DdtCure> medicineTemplates = service.GetDdtCureService().GetListByTemplate("sd");
                        foreach (DdtCure cure in medicineTemplates)
                        {
                            DdtIssuedMedicine med = new DdtIssuedMedicine();
                            med.Cure = cure.ObjectId;

                            AddIssuedMedicine(med, cure);
                        }
                    }
                }
            }
        }
Beispiel #10
0
        private void AddIssuedMedicine_Click(object sender, EventArgs e)
        {
            DdtIssuedMedicine med = new DdtIssuedMedicine();

            AddIssuedMedicine(med, null);
        }
Beispiel #11
0
        private void AddIssuedMedicine(DdtIssuedMedicine med, DdtCure cure)
        {
            medicineList.Add(med);

            FlowLayoutPanel ll = new FlowLayoutPanel();

            ll.FlowDirection = FlowDirection.LeftToRight;
            ll.Width         = 700;
            ll.AutoSize      = true;
            ll.Padding       = new Padding(0);
            ll.Margin        = new Padding(0);

            ComboBox cureTypeControl = new ComboBox();

            cureTypeControl.Width = 250;
            CommonUtils.InitCureTypeComboboxValues(DbDataService.GetInstance(), cureTypeControl);
            if (cure != null && cure.CureType != null)
            {
                for (int index = 0; index < cureTypeControl.Items.Count; index++)
                {
                    DdtCureType ct = (DdtCureType)cureTypeControl.Items[index];
                    if (ct.ObjectId == cure.CureType)
                    {
                        cureTypeControl.SelectedIndex = index;
                        break;
                    }
                }
            }
            ll.Controls.Add(cureTypeControl);

            ComboBox cureControl = new ComboBox();

            cureControl.Width = 350;

            DdtCureType cureType = (DdtCureType)cureTypeControl.SelectedItem;

            if (cureType != null)
            {
                CommonUtils.InitCureComboboxValuesByTypeId(DbDataService.GetInstance(), cureControl, cureType.ObjectId);
            }

            if (cure != null && cure.ObjectId != null)
            {
                for (int index = 0; index < cureControl.Items.Count; index++)
                {
                    DdtCure c = (DdtCure)cureControl.Items[index];
                    if (c.ObjectId == cure.ObjectId)
                    {
                        cureControl.SelectedIndex = index;
                        break;
                    }
                }
            }
            cureControl.SelectedIndexChanged += delegate(object sender2, EventArgs args)
            {
                DdtCure ddtCure = (DdtCure)cureControl.SelectedItem;
                if (ddtCure != null)
                {
                    med.Cure = ddtCure.ObjectId;
                }
                else
                {
                    med.Cure = null;
                }
            };
            ll.Controls.Add(cureControl);

            cureTypeControl.SelectedIndexChanged += delegate(object sender2, EventArgs args)
            {
                DdtCureType selectedVal = (DdtCureType)cureTypeControl.SelectedItem;
                CommonUtils.InitCureComboboxValuesByTypeId(DbDataService.GetInstance(), cureControl, selectedVal.ObjectId);
            };

            Button remove = new Button
            {
                Image = Properties.Resources.remove,
                Size  = new Size(25, 25),
                UseVisualStyleBackColor = true
            };

            ll.Controls.Add(remove);

            remove.Click += delegate(object sender2, EventArgs args)
            {
                medicineList.Remove(med);
                layout.Controls.Remove(ll);
            };
            layout.Controls.Add(ll);
        }