Beispiel #1
0
        public CustomHealthTypeWrapper(HealthRecordItemCustomBase wrappedInstance, HealthServiceDateTime when)
        {
            wrappedObject = wrappedInstance;
            When          = when;

            if (wrappedInstance != null)
            {
                wrappedInstance.Wrapper = this;
            }
        }
Beispiel #2
0
        public static void PostCustomThing(HealthRecordItemCustomBase thing, HealthServiceDateTime when,
                                           Guid personId, Guid recordId)
        {
            CustomHealthTypeWrapper wrapper = new CustomHealthTypeWrapper(thing, when);

            wrapper.When          = when;
            wrapper.EffectiveDate = when.ToDateTime();

            PostThing(wrapper, personId, recordId);
        }
Beispiel #3
0
        private static JObject TransformThings(ReadOnlyCollection <HealthRecordItemCollection> things, List <Guid> queryOrder)
        {
            JObject output = new JObject();

            HealthRecordItemCollection thingCollection;
            Guid typeId;

            Types.ThingTypeDefinition    hvTypeDefinition;
            EnvTypes.ThingTypeDefinition envTypeDefinition;

            for (int i = 0; i < queryOrder.Count; i++)
            {
                thingCollection = things[i];
                thingCollection.Sort(CompareByTimeAscending);
                typeId = queryOrder[i];

                if (typeId == CustomType.Id) // custom type
                {
                    foreach (EnvTypes.ThingTypeDefinition typeDefinition in EnvTypes.TypeDefinitions.Values)
                    {
                        output[typeDefinition.Label] = new JArray();
                    }

                    foreach (CustomHealthTypeWrapper wrapper in thingCollection)
                    {
                        HealthRecordItemCustomBase item = wrapper.WrappedObject;

                        if (item == null)
                        {
                            continue;
                        }

                        envTypeDefinition = EnvTypes.TypeDefinitions[item.GetType().GUID];

                        ((JArray)output[envTypeDefinition.Label]).Add(envTypeDefinition.Transformation(item));
                    }
                }
                else // HV standard type
                {
                    hvTypeDefinition = Types.TypeDefinitions[typeId];

                    JArray recordArray = new JArray();

                    foreach (HealthRecordItem item in thingCollection)
                    {
                        recordArray.Add(hvTypeDefinition.Transformation(item));
                    }

                    output[hvTypeDefinition.Label] = recordArray;
                }
            }

            return(output);
        }
Beispiel #4
0
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator navigator = typeSpecificXml.CreateNavigator();

            navigator = navigator.SelectSingleNode("app-specific");

            if (navigator == null)
            {
                throw new ArgumentNullException("null navigator");
            }

            XPathNavigator when = navigator.SelectSingleNode("when");

            this.When = new HealthServiceDateTime();
            this.When.ParseXml(when);

            XPathNavigator formatAppid = navigator.SelectSingleNode("format-appid");
            string         appid       = formatAppid.Value;

            XPathNavigator formatTag       = navigator.SelectSingleNode("format-tag");
            string         wrappedTypeName = formatTag.Value;

            if (wrappedTypeName != NullObjectTypeName)
            {
                wrappedObject = (HealthRecordItemCustomBase)CreateObjectByName(wrappedTypeName);

                if (wrappedObject != null)
                {
                    wrappedObject.Wrapper = this;
                    XPathNavigator customType = navigator.SelectSingleNode("CustomType");

                    if (customType != null)
                    {
                        wrappedObject.ParseXml(customType);
                    }
                }
            }
        }