Пример #1
0
        protected virtual RESOURCE_DESCRIPTION CloneDescription(openehr.openehr.rm.common.resource.RESOURCE_DESCRIPTION o)
        {
            RESOURCE_DESCRIPTION result = new RESOURCE_DESCRIPTION();

            result.original_author = CloneHashTableAny(o.original_author());

            if (o.other_contributors() != null && o.other_contributors().count() > 0)
            {
                result.other_contributors = new string[o.other_contributors().count()];

                for (int i = 1; i < result.other_contributors.Length; i++)
                {
                    result.other_contributors[i - 1] = (([email protected]_8)o.other_contributors().i_th(i)).to_cil();
                }
            }

            result.lifecycle_state = o.lifecycle_state().to_cil();

            if (o.resource_package_uri() != null)
            {
                result.resource_package_uri = o.resource_package_uri().ToString();
            }

            result.other_details = CloneHashTableAny(o.other_details());

            // 0..1 parent_resource AUTHORED_RESOURCE (does not occur in NHS archetypes, do later)
            //if (o.parent_resource() != null)
            //result.parent_resource = CloneAuthoredResource(o.parent_resource());

            if (o.details().count() > 0)
            {
                RESOURCE_DESCRIPTION_ITEM[] details = new RESOURCE_DESCRIPTION_ITEM[o.details().count()];
                o.details().start();

                for (int i = 1; i <= o.details().count(); i++)
                {
                    openehr.openehr.rm.common.resource.Impl.RESOURCE_DESCRIPTION_ITEM item = o.details().item_for_iteration() as openehr.openehr.rm.common.resource.Impl.RESOURCE_DESCRIPTION_ITEM;
                    details[i - 1]          = new RESOURCE_DESCRIPTION_ITEM();
                    details[i - 1].language = CloneCodePhrase(item.language());

                    if (item.purpose() != null)
                    {
                        details[i - 1].purpose = item.purpose().ToString();
                    }

                    if (item.use() != null)
                    {
                        details[i - 1].use = item.use().ToString();
                    }

                    if (item.misuse() != null)
                    {
                        details[i - 1].misuse = item.misuse().ToString();
                    }

                    if (item.copyright() != null)
                    {
                        details[i - 1].copyright = item.copyright().ToString();
                    }

                    if (item.original_resource_uri() != null && item.original_resource_uri().count() > 0)
                    {
                        result.resource_package_uri = item.original_resource_uri().ToString();
                    }

                    // 0..* other_details StringDictionaryItem
                    //cloneObject.other_details = CloneHashTableAny(item.other_details());

                    if (item.keywords() != null && item.keywords().count() > 0)
                    {
                        string[] keywords = new string[item.keywords().count()];
                        details[i - 1].keywords = keywords;

                        for (int j = 1; j <= keywords.Length; j++)
                        {
                            if (item.keywords().i_th(j) != null)
                            {
                                keywords[j - 1] = item.keywords().i_th(j).ToString();
                            }
                        }
                    }

                    o.details().forth();
                }

                result.details = details;
            }

            return(result);
        }
Пример #2
0
        public static ResourceDescription Map(this RESOURCE_DESCRIPTION resourceDescriptionModel)
        {
            var resourceDescription = new ResourceDescription
            {
                LifecycleState     = resourceDescriptionModel.lifecycle_state,
                ResourcePackageUri = resourceDescriptionModel.resource_package_uri
            };

            if (resourceDescriptionModel.original_author != null)
            {
                foreach (StringDictionaryItem item in resourceDescriptionModel.original_author)
                {
                    resourceDescription.OriginalAuthor.Add(item.id, item.TypedValue);
                }
            }
            if (resourceDescriptionModel.other_contributors != null)
            {
                foreach (string item in resourceDescriptionModel.other_contributors)
                {
                    resourceDescription.OtherContributors.Add(item);
                }
            }
            if (resourceDescriptionModel.other_details != null)
            {
                foreach (StringDictionaryItem item in resourceDescriptionModel.other_details)
                {
                    resourceDescription.OtherDetails.Add(item.id, item.TypedValue);
                }
            }
            if (resourceDescriptionModel.details != null)
            {
                foreach (RESOURCE_DESCRIPTION_ITEM item in resourceDescriptionModel.details)
                {
                    var resourceDescriptionItem = new ResourceDescriptionItem
                    {
                        Copyright = item.copyright,
                        Misuse    = item.misuse,
                        Purpose   = item.purpose,
                        Use       = item.use,
                        Language  = item.language.Map()
                    };
                    if (item.keywords != null)
                    {
                        foreach (string keyword in item.keywords)
                        {
                            resourceDescriptionItem.Keywords.Add(keyword);
                        }
                    }
                    if (item.other_details != null)
                    {
                        foreach (StringDictionaryItem item2 in item.other_details)
                        {
                            resourceDescriptionItem.OtherDetails.Add(item2.id, item2.TypedValue);
                        }
                    }
                    resourceDescription.Details.Add(item.language.code_string, resourceDescriptionItem);
                }
            }

            return(resourceDescription);
        }