Exemple #1
0
 public void InitialiseValues(string tag, DatasetInstance sourceInstance, PatientClinicalEvent clinicalEvent)
 {
     foreach (DatasetCategory dc in Dataset.DatasetCategories)
     {
         foreach (DatasetCategoryElement dce in dc.DatasetCategoryElements)
         {
             // Default using default value
             if (dce.DatasetElement.DefaultValue != null && dce.DatasetElement.DefaultValue != "")
             {
                 SetInstanceValue(dce.DatasetElement, dce.DatasetElement.DefaultValue);
             }
             else
             {
                 // Default using mapped value
                 if (sourceInstance != null)
                 {
                     MapValuesUsingInstance(dce, tag, sourceInstance);
                 }
                 if (clinicalEvent != null)
                 {
                     MapValuesUsingEvent(dce, tag, clinicalEvent);
                 }
             }
         }
     }
 }
Exemple #2
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) : "";

                    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);
                    foreach (Guid sourceContext in sourceContexts)
                    {
                        var newContext    = Guid.NewGuid();
                        var subItemValues = sourceInstance.GetInstanceSubValues(mapping.SourceElement.DatasetElement, 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);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
        public DatasetInstance CreateInstance(int contextId, EncounterTypeWorkPlan encounterTypeWorkPlan)
        {
            var instance = new DatasetInstance
            {
                Dataset = this,
                EncounterTypeWorkPlan = encounterTypeWorkPlan,
                ContextID             = contextId
            };

            // Create table elements automatically
            foreach (DatasetCategory cat in DatasetCategories)
            {
                foreach (DatasetCategoryElement ele in cat.DatasetCategoryElements)
                {
                    if (ele.DatasetElement.Field.FieldType.Description == "Table")
                    {
                        instance.AddInstanceValue(ele.DatasetElement, "<<Table>>");
                    }
                }
            }

            return(instance);
        }
Exemple #4
0
 public DatasetInstanceValue(DatasetElement datasetElement, DatasetInstance datasetInstance, string instanceValue)
     : this()
 {
     this.DatasetElement = datasetElement;
     this.InstanceValue  = instanceValue;
 }