private void saveObject()
        {
            DdtEpicrisis obj = service.GetDdtEpicrisisService().GetById(objectId);

            if (obj == null)
            {
                obj                    = new DdtEpicrisis();
                obj.Doctor             = hospitalitySession.CuringDoctor;
                obj.HospitalitySession = hospitalitySession.ObjectId;
                obj.Patient            = hospitalitySession.Patient;
            }
            obj.EpicrisisDate = epicrisisDateTxt.Value;
            obj.Diagnosis     = diagnosisTxt.Text;
            obj.EpicrisisType = (int)DdtEpicrisisDsiType.BEFORE_OPERATION;
            objectId          = service.GetDdtEpicrisisService().Save(obj);
            obj.ObjectId      = objectId;

            DataGridViewRowCollection rows = analysisGrid.Rows;

            for (int i = 0; i < rows.Count; i++)
            {
                DataGridViewRow row  = rows[i];
                string          id   = (string)row.Cells[0].Value;
                string          type = (string)row.Cells[1].Value;
                if (service.GetDdtRelationService().GetByParentAndChildIds(objectId, id) == null)
                {
                    DdtRelation rel = new DdtRelation();
                    rel.Child     = id;
                    rel.Parent    = objectId;
                    rel.ChildType = type;
                    service.GetDdtRelationService().Save(rel);
                }
            }
        }
        public string Save(DdtRelation relation)
        {
            using (dynamic connection = connectionFactory.GetConnection())
            {
                if (GetById(relation.ObjectId) != null)
                {
                    string sql = "UPDATE ddt_relation SET " +
                                 "dsid_parent = @Parent, " +
                                 "dsid_child = @Child, " +
                                 "dss_child_type = @ChildType " +
                                 "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("@Parent", relation.Parent);
                        cmd.Parameters.AddWithValue("@Child", relation.Child);
                        cmd.Parameters.AddWithValue("@ChildType", relation.ChildType);
                        cmd.Parameters.AddWithValue("@ObjectId", relation.ObjectId);
                        cmd.ExecuteNonQuery();
                    }
                    return(relation.ObjectId);
                }
                else
                {
                    string sql = "INSERT INTO ddt_relation(dsid_parent,dsid_child,dss_child_type) " +
                                 "VALUES(@Parent,@Child,@ChildType) 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("@Parent", relation.Parent);
                        cmd.Parameters.AddWithValue("@Child", relation.Child);
                        cmd.Parameters.AddWithValue("@ChildType", relation.ChildType);
                        return((string)cmd.ExecuteScalar());
                    }
                }
            }
        }
示例#3
0
        private void initKag(IDbDataService service, DdtJournal kagJournal)
        {
            bool hasKag = false;

            if (kagJournal != null)
            {
                IList <DdtKag> kags = service.GetDdtKagService().GetByParentId(kagJournal.ObjectId);
                DdtKag         kag  = kags.Count > 0 ? kags[0] : null;
                if (kag != null && inspectionObj != null)
                {
                    kagId = kag.ObjectId;
                    DdtRelation relation = new DdtRelation();
                    relation.Parent    = inspectionObj.ObjectId;
                    relation.Child     = kag.ObjectId;
                    relation.ChildType = DdtKag.NAME;

                    DbDataService.GetInstance().GetDdtRelationService().Save(relation);
                    kagContainer.Visible = true;
                    hasKag = true;
                }
            }
        }
        private IList <DdtRelation> Select(string query)
        {
            IList <DdtRelation> list = new List <DdtRelation>();

            using (dynamic connection = connectionFactory.GetConnection())
            {
                Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", query);

                Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(query, connection);
                using (DbDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        DdtRelation obj = new DdtRelation();
                        obj.ObjectId  = reader.IsDBNull(0) ? null : reader.GetString(0);
                        obj.Parent    = reader.IsDBNull(1) ? null : reader.GetString(1);
                        obj.Child     = reader.IsDBNull(2) ? null : reader.GetString(2);
                        obj.ChildType = reader.IsDBNull(3) ? null : reader.GetString(3);
                        list.Add(obj);
                    }
                }
            }
            return(list);
        }
示例#5
0
        private void seeDeeper(Control container, string type)
        {
            if (container == null)
            {
                return;
            }
            ControlCollection coll = container.Controls;
            IEnumerator       it   = coll.GetEnumerator();

            while (it.MoveNext())
            {
                Control control = (Control)it.Current;
                if (control == null)
                {
                    break;
                }
                else if (control is IDocbaseControl)
                {
                    ((IDocbaseControl)control).saveObject(hospitalSession, parentId, parentType);
                    string id = ((IDocbaseControl)control).getObjectId();
                    IDdtRelationService relationService = DbDataService.GetInstance().GetDdtRelationService();
                    if (id != null && parentId != null && parentType != null && relationService.GetByParentAndChildIds(parentId, id) == null)
                    {
                        DdtRelation relation = new DdtRelation();
                        relation.Parent    = parentId;
                        relation.Child     = id;
                        relation.ChildType = type;
                        relationService.Save(relation);
                    }
                }
                else
                {
                    seeDeeper(control, type);
                }
            }
        }
示例#6
0
        public bool Save()
        {
            if (!getIsValid())
            {
                return(false);
            }

            service.GetDdtHospitalService().Save(hospitalitySession);

            DdtJournalDay journalDay = null;

            if (!string.IsNullOrEmpty(journalDayId))
            {
                journalDay = service.GetDdtJournalDayService().GetById(journalDayId);
            }
            else
            {
                journalDay                    = new DdtJournalDay();
                journalDay.JournalType        = 1;
                journalDay.HospitalitySession = hospitalitySession.ObjectId;
                journalDay.Patient            = hospitalitySession.Patient;
                journalDay.JournalType        = (int)DdtJournalDsiType.AfterKag;
                //journal.Complaints = "Жалоб на момент осмотра не предъявляет.";
            }
            journalDay.AdmissionDate = CommonUtils.ConstructDateWIthTime(admissionDateTxt.Value, admissionTimeTxt.Value);
            DdvDoctor doc = (DdvDoctor)journalDocBox.SelectedItem;

            journalDay.Doctor    = doc == null ? hospitalitySession.DutyDoctor : doc.ObjectId;
            journalDay.Diagnosis = afterKagDiagnosisTxt.Text;
            journalDayId         = service.GetDdtJournalDayService().Save(journalDay);

            DdtVariousSpecConcluson cardioVascularConc = service.GetDdtVariousSpecConclusonService().GetByParentId(journalDayId);

            if (cardioVascularConc == null)
            {
                cardioVascularConc        = new DdtVariousSpecConcluson();
                cardioVascularConc.Parent = journalDayId;
            }
            cardioVascularConc.AdmissionDate        = CommonUtils.ConstructDateWIthTime(cardioDate.Value, cardioTime.Value);
            cardioVascularConc.SpecialistConclusion = surgeryInspectationTxt.Text;
            cardioVascularConc.AdditionalInfo1      = chddSurgeryTxt.Text;
            cardioVascularConc.AdditionalInfo3      = adSurgeryTxt.Text;
            cardioVascularConc.AdditionalInfo2      = chssSurgeryTxt.Text;
            cardioVascularConc.AdditionalInfo4      = (string)cardioVascularBox.SelectedValue;
            service.GetDdtVariousSpecConclusonService().Save(cardioVascularConc);

            if (!string.IsNullOrEmpty(kagDiagnosisTxt.Text))
            {
                DdtKag kag = service.GetDdtKagService().GetById(kagId);
                if (kag == null)
                {
                    kag                    = new DdtKag();
                    kag.Doctor             = hospitalitySession.CuringDoctor;
                    kag.HospitalitySession = hospitalitySession.ObjectId;
                    kag.Patient            = hospitalitySession.Patient;
                    DateTime admissionDateTime = CommonUtils.ConstructDateWIthTime(admissionDateTxt.Value, admissionTimeTxt.Value);
                    kag.AnalysisDate = admissionDateTime.AddMinutes(-75);
                    kag.StartTime    = admissionDateTime.AddMinutes(-75);
                    kag.EndTime      = admissionDateTime.AddMinutes(-15);
                    kag.KagAction    = kagDiagnosisTxt.Text;
                    kagId            = service.GetDdtKagService().Save(kag);

                    IDdtRelationService relationService = DbDataService.GetInstance().GetDdtRelationService();
                    if (kagId != null && relationService.GetByParentAndChildIds(journalDayId, kagId) == null)
                    {
                        DdtRelation relation = new DdtRelation();
                        relation.Parent    = journalDayId;
                        relation.Child     = kagId;
                        relation.ChildType = DdtJournal.NAME;
                        relationService.Save(relation);
                    }
                }
            }

            for (int i = 0; i < dutyCardioContainer.Controls.Count; i++)
            {
                JournalKAGControl journalCtrl = (JournalKAGControl)dutyCardioContainer.Controls[i];
                journalCtrl.saveObject(hospitalitySession, journalDayId, DdtJournal.NAME);
            }

            analysisTabControl1.save(journalDayId, DdtJournal.NAME);
            return(true);
        }