Пример #1
0
        public static Archetype Parse(string archetypeXmlString)
        {
            var archetypeInstance = new Archetype();
            using (var textReader = new StringReader(archetypeXmlString))
            {
                archetype archetypeModel = archetype.Load(textReader);

                if (archetypeModel.Content.archetype_id == null || string.IsNullOrEmpty(archetypeModel.Content.archetype_id.value)) throw new ParseException("ArchetypeId cannot be empty");
                if (string.IsNullOrEmpty(archetypeModel.Content.concept)) throw new ParseException("Concept cannot be empty");
                if (archetypeModel.Content.definition == null) throw new ParseException("Definition cannot be empty");
                if (archetypeModel.Content.ontology == null) throw new ParseException("Ontology cannot be empty");

                if (archetypeModel.Content.uid != null)
                    archetypeInstance.Uid = new HierObjectId(archetypeModel.Content.uid.value);

                archetypeInstance.AdlVersion = archetypeModel.Content.adl_version;
                archetypeInstance.Concept = archetypeModel.Content.concept;
                archetypeInstance.ArchetypeId = new ArchetypeId(archetypeModel.Content.archetype_id.value);
                if (archetypeModel.Content.parent_archetype_id != null)
                    archetypeInstance.ParentArchetypeId = new ArchetypeId(archetypeModel.Content.parent_archetype_id.value);

                if (archetypeModel.Content.original_language != null)
                {
                    archetypeInstance.OriginalLanguage = archetypeModel.Content.original_language.Map();
                }
                if (archetypeModel.Content.translations != null)
                {
                    foreach (TRANSLATION_DETAILS translation in archetypeModel.Content.translations)
                    {
                        archetypeInstance.Translations.Add(translation.language.code_string, translation.Map());
                    }
                }
                if (archetypeModel.Content.is_controlled.HasValue)
                    archetypeInstance.IsControlled = archetypeModel.Content.is_controlled.Value;

                if (archetypeModel.Content.description != null)
                    archetypeInstance.Description = archetypeModel.Content.description.Map();

                archetypeInstance.Definition = archetypeModel.Content.definition.Map();
                if (archetypeInstance.Definition.ReferenceModelTypeName != archetypeInstance.ArchetypeId.ReferenceModelEntity)
                    throw new ParseException(string.Format("Archetype definition typename is not consistent: '{0}' <> '{1}'", archetypeInstance.ArchetypeId.ReferenceModelEntity, archetypeInstance.Definition.ReferenceModelTypeName));

                if (archetypeModel.Content.invariants != null)
                {
                    foreach (ASSERTION assertion in archetypeModel.Content.invariants)
                    {
                        archetypeInstance.Invariants.Add(assertion.Map());
                    }
                }

                //TODO: revision history

                archetypeInstance.Ontology = archetypeModel.Content.ontology.Map();
            }

            return archetypeInstance;
        }
Пример #2
0
 public void IdIsProperlyRouted()
 {
     var archetype = new Archetype();
     Assert.IsNullOrEmpty(archetype.Id);
     const string id1 = "openEHR-EHR-CLUSTER.cranial_nerves.v1";
     archetype.Id = id1;
     Assert.AreEqual(id1, archetype.Id);
     const string id2 = "local-EHR-CLUSTER.cranial_nerves.v1";
     archetype.Id = id2;
     Assert.AreEqual(id2, archetype.Id);
 }
Пример #3
0
        public Composition Build(Archetype archetype)
        {
            var composition = new Composition();

            composition.ArchetypeDetails = new Archetyped
                                           	{
                                           		ArchetypeId = new ArchetypeId(archetype.ArchetypeId.Value),
                                           		Version = "1.0.2"
                                           	};
            composition.ArchetypeNodeId = archetype.ArchetypeId.Value;
            composition.Content.Add(GetInstanceOfContentItem(archetype.Definition.ReferenceModelTypeName));

            return composition;
        }
Пример #4
0
 public void ListsAreNotNull()
 {
     var archetype = new Archetype();
     Assert.IsNotNull(archetype.Invariants);
 }
Пример #5
0
 /// <summary>
 /// Saves an archetype to the archetype repository. An existing archetype will not be updated, you should save the archetype as a new version.
 /// </summary>
 /// <param name="archetype">The object form of the archetype.</param>
 public void Save(Archetype archetype)
 {
     if (!_archetypeRepository.Contains(archetype))
     {
         _archetypeRepository.Save(archetype);
     }
     else
     {
         throw new ArgumentException(string.Format("Archetype with id '{0}' already exist. Provide another version for this archetype.", archetype.Id), "archetype");
     }
 }