コード例 #1
0
        private void SetRequiredCategory()
        {
            var reqCat = UnitOfWork.Repository <DatasetCategory>().Queryable().SingleOrDefault(dc => dc.Dataset.Id == _dataset.Id && dc.DatasetCategoryName == "Required Information");

            if (reqCat == null)
            {
                // Save category
                reqCat = new DatasetCategory
                {
                    CategoryOrder       = 0,
                    Dataset             = _dataset,
                    DatasetCategoryName = "Required Information",
                    FriendlyName        = "Required Information",
                    Public  = false,
                    System  = true,
                    Acute   = false,
                    Chronic = false
                };

                foreach (DatasetCategory idc in _dataset.DatasetCategories)
                {
                    foreach (DatasetCategoryElement idce in idc.DatasetCategoryElements.Where(i => i.DatasetElement.Field.Mandatory))
                    {
                        var catEle = new DatasetCategoryElement()
                        {
                            Acute = false, Chronic = false, DatasetCategory = reqCat, DatasetElement = idce.DatasetElement,
                        };
                        reqCat.DatasetCategoryElements.Add(catEle);
                    }
                }

                UnitOfWork.Repository <DatasetCategory>().Save(reqCat);
            }
        }
コード例 #2
0
 private bool IsElementChronic(Encounter encounter, DatasetCategoryElement datasetCategoryElement)
 {
     // Encounter type is chronic then element must have chronic selected and patient must have condition
     if (datasetCategoryElement.Chronic)
     {
         return(!encounter.Patient.HasCondition(datasetCategoryElement.DatasetCategoryElementConditions.Select(c => c.Condition).ToList()));
     }
     else
     {
         return(false);
     }
 }
コード例 #3
0
        private bool ShouldElementBeDisplayed(Encounter encounter, DatasetCategoryElement datasetCategoryElement)
        {
            if (datasetCategoryElement.Chronic)
            {
                // Does patient have chronic condition
                if (!encounter.Patient.HasCondition(datasetCategoryElement.DatasetCategoryElementConditions.Select(c => c.Condition).ToList()))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
0
        private void MapValuesUsingInstance(DatasetCategoryElement dce, string tag, DatasetInstance sourceInstance)
        {
            var mapping = dce.DestinationMappings.SingleOrDefault(dm => dm.Tag == tag);

            if (mapping != null)
            {
                if (dce.DatasetElement.Field.FieldType.Description != "Table")
                {
                    var sourceValue = mapping.SourceElement != null?sourceInstance.GetInstanceValue(mapping.SourceElement.DatasetElement.ElementName) : "";

                    if (!String.IsNullOrWhiteSpace(sourceValue))
                    {
                        var formattedValue = TranslateSourceValueForElement(mapping, sourceValue);

                        if (!String.IsNullOrWhiteSpace(formattedValue))
                        {
                            SetInstanceValue(dce.DatasetElement, formattedValue);
                        }
                    }
                }
                else
                {
                    // we need to process mapping using sub elements
                    var sourceContexts = sourceInstance.GetInstanceSubValuesContext(mapping.SourceElement.DatasetElement.ElementName);
                    foreach (Guid sourceContext in sourceContexts)
                    {
                        var newContext    = Guid.NewGuid();
                        var subItemValues = sourceInstance.GetInstanceSubValues(mapping.SourceElement.DatasetElement.ElementName, sourceContext);
                        foreach (DatasetMappingSub subMapping in mapping.SubMappings)
                        {
                            var sourceSubValue = subMapping.SourceElement != null?subItemValues.SingleOrDefault(siv => siv.DatasetElementSub.Id == subMapping.SourceElement.Id) : null;

                            if (sourceSubValue != null)
                            {
                                var formattedValue = TranslateSourceValueForSubElement(subMapping, sourceSubValue.InstanceValue);

                                if (!String.IsNullOrWhiteSpace(formattedValue))
                                {
                                    SetInstanceSubValue(subMapping.DestinationElement, formattedValue, newContext);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        protected void btnAddElement_Click(object sender, EventArgs e)
        {
            if (ddlCategory.SelectedValue == "0")
            {
                return;
            }
            ;
            if (ddlElement.SelectedValue == "0")
            {
                return;
            }
            ;

            // Save element
            var datasetCategory = GetDatasetCategory(Convert.ToInt32(ddlCategory.SelectedValue));
            var datasetElement  = GetDatasetElement(Convert.ToInt32(ddlElement.SelectedValue));

            var ele = new DatasetCategoryElement
            {
                DatasetCategory = datasetCategory,
                DatasetElement  = datasetElement,
                FieldOrder      = (short)GetNextElementOrder(datasetCategory)
            };

            UnitOfWork.Repository <DatasetCategoryElement>().Save(ele);

            if (datasetElement.Field.Mandatory)
            {
                // Ensure element is linked to Required Information category
                var reqCat = UnitOfWork.Repository <DatasetCategory>().Queryable().SingleOrDefault(dc => dc.Dataset.Id == _dataset.Id && dc.DatasetCategoryName == "Required Information");
                if (reqCat != null)
                {
                    var catEle = new DatasetCategoryElement()
                    {
                        Acute = false, Chronic = false, DatasetCategory = reqCat, DatasetElement = datasetElement
                    };
                    reqCat.DatasetCategoryElements.Add(catEle);

                    UnitOfWork.Repository <DatasetCategory>().Update(reqCat);
                }
            }

            RenderGrids();
        }
コード例 #6
0
        private void MapValuesUsingEvent(DatasetCategoryElement dce, string tag, PatientClinicalEvent clinicalEvent)
        {
            IExtendable ptExtended = clinicalEvent.Patient;
            IExtendable ceExtended = clinicalEvent;

            if (dce.DestinationMappings.Where(dm => dm.Tag == tag).Count() > 0)
            {
                // Get the value to be translated
                var    mapping     = dce.DestinationMappings.Single(dm => dm.Tag == tag);
                string sourceValue = string.Empty;
                object objectValue;

                if (mapping.MappingType == MappingType.AttributeToElement || mapping.MappingType == MappingType.AttributeToValue)
                {
                    if (!String.IsNullOrWhiteSpace(mapping.PropertyPath) && !String.IsNullOrWhiteSpace(mapping.Property))
                    {
                        switch (mapping.PropertyPath)
                        {
                        case "Patient":
                            objectValue = ptExtended.GetAttributeValue(mapping.Property);
                            sourceValue = objectValue != null?objectValue.ToString() : "";

                            break;

                        case "PatientClinicalEvent":
                            objectValue = ceExtended.GetAttributeValue(mapping.Property);
                            sourceValue = objectValue != null?objectValue.ToString() : "";

                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrWhiteSpace(mapping.Property))
                        {
                            objectValue = ceExtended.GetAttributeValue(mapping.Property);
                            sourceValue = objectValue != null?objectValue.ToString() : "";
                        }
                    }
                }
                else
                {
                    Object src = clinicalEvent;
                    if (mapping.MappingType == MappingType.FirstClassToElement || mapping.MappingType == MappingType.FirstClassToValue)
                    {
                        if (!String.IsNullOrWhiteSpace(mapping.PropertyPath))
                        {
                            switch (mapping.PropertyPath)
                            {
                            case "Patient":
                                src = clinicalEvent.Patient;
                                break;

                            default:
                                break;
                            }
                        }
                        objectValue = src.GetType().GetProperty(mapping.Property).GetValue(src, null);
                        sourceValue = objectValue != null?objectValue.ToString() : "";
                    }
                }

                // Translate the value
                if (!String.IsNullOrWhiteSpace(sourceValue))
                {
                    var formattedValue = TranslateSourceValueForElement(mapping, sourceValue);

                    if (!String.IsNullOrWhiteSpace(formattedValue))
                    {
                        SetInstanceValue(dce.DatasetElement, formattedValue);
                    }
                }
            }
        }