Exemplo n.º 1
0
        /// <summary>
        /// 根据列表字段为列表创建新行
        /// </summary>
        /// <param name="field">列表字段</param>
        /// <returns></returns>
        public CrfSection AddCrfSectionRow(CrfField field)
        {
            if (!field.ElementType.StartsWith(ConstCamp.ELEMENT_TYPE_TABLE))
            {
                throw new ArgumentException("仅能为列表创建CrfSection");
            }

            int rowIndex = 1;

            if (this.Children.Any(p => p.TableFieldId == field.StudyCrfFieldId))
            {
                rowIndex = this.Children.Where(p => p.TableFieldId == field.StudyCrfFieldId).Max(p => p.RowIndex) + 1;
            }

            CrfSection rowSection = new CrfSection(this, field);

            rowSection.RowIndex = rowIndex;

            // 添加字段
            foreach (CrfField tableField in field.Children)
            {
                rowSection.AddFieldItem(tableField);
            }

            return(rowSection);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 列表行CrfSection构造函数
        /// </summary>
        /// <param name="parentSection"></param>
        /// <param name="field"></param>
        private CrfSection(CrfSection parentSection, CrfField field)
        {
            this.FieldItems = new List <FieldItem>();
            this.Children   = new List <CrfSection>();

            StudyPatientId = parentSection.StudyPatientId;
            CrfId          = parentSection.CrfId;
            VisitId        = parentSection.VisitId;
            StudyId        = parentSection.StudyId;
            StudySiteId    = parentSection.StudySiteId;
            RandomId       = parentSection.RandomId;
            TableFieldId   = field.StudyCrfFieldId;
            RowFieldCode   = field.FieldCode;
            RowTableId     = field.TableId;
            RowFieldId     = field.StudyCrfFieldId;
            CrfType        = CrfSectionType.Row;
            Status         = 0;

            parentSection.Children.Add(this);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据检查套餐代码,添加检查子项列表行
        /// </summary>
        /// <param name="detailsTablefield"></param>
        /// <param name="package"></param>
        /// <returns></returns>
        public IEnumerable <CrfSection> AddInpectionDetailRows(CrfField detailsTablefield, InspectionPackage package)
        {
            List <CrfSection> addedSections = new List <CrfSection>();

            if (detailsTablefield.TableId == ConstCamp.INSPECT_DETAILS_TABLE_ID)
            {
                foreach (InspectionItem item in package.Items)
                {
                    // 为每个检查子项创建一个 CrfSection
                    CrfSection rowSection = this.AddCrfSectionRow(detailsTablefield);
                    addedSections.Add(rowSection);

                    // 字段赋值
                    foreach (FieldItem rfi in rowSection.FieldItems)
                    {
                        switch (rfi.FieldId)
                        {
                        case "Ti_code":
                            rfi.Text  = item.ItemCode;
                            rfi.Value = item.ItemCode;
                            break;

                        case "Ti_name":
                            rfi.Text  = item.ItemName;
                            rfi.Value = item.ItemName;
                            break;

                        case "Ti_minval":
                            rfi.Text  = item.MinValue.HasValue ? item.MinValue.ToString() : "";
                            rfi.Value = item.MinValue.HasValue ? item.MinValue.ToString() : "";
                            break;

                        case "Ti_maxval":
                            rfi.Text  = item.MaxValue.HasValue ? item.MaxValue.ToString() : "";
                            rfi.Value = item.MaxValue.HasValue ? item.MaxValue.ToString() : "";
                            break;

                        case "Ti_unit":
                            rfi.Text  = item.Unit;
                            rfi.Value = item.Unit;
                            break;

                        case "Ti_referencerange":
                            rfi.Text  = item.ReferenceRange;
                            rfi.Value = item.ReferenceRange;
                            break;

                        case "Ti_normalvalue":
                            rfi.Text  = item.NormalValue;
                            rfi.Value = item.NormalValue;
                            break;
                        }
                    }
                }
            }
            else
            {
                throw new ArgumentException($"'{detailsTablefield.FieldName}'不是检查明细表字段");
            }

            return(addedSections);
        }