protected override void ReadXmlBase(System.Xml.XmlReader reader) { base.ReadXmlBase(reader); Check.Assert(reader.LocalName == "language", "Expected LocalName is 'language' rather than " + reader.LocalName); this.language = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.language.ReadXml(reader); Check.Assert(reader.LocalName == "encoding", "Expected LocalName is 'encoding' rather than " + reader.LocalName); this.encoding = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.encoding.ReadXml(reader); Check.Assert(reader.LocalName == "subject", "Expected LocalName is 'subject' rather than " + reader.LocalName); string subjectType = RmXmlSerializer.ReadXsiType(reader); this.subject = RmFactory.PartyProxy(subjectType); this.subject.ReadXml(reader); if (reader.LocalName == "provider") { string providerType = RmXmlSerializer.ReadXsiType(reader); this.provider = RmFactory.PartyProxy(providerType); this.provider.ReadXml(reader); } if (reader.LocalName == "other_participations") { this.otherParticipations = new OpenEhr.AssumedTypes.List <Participation>(); do { Participation p = new Participation(); p.ReadXml(reader); this.otherParticipations.Add(p); } while (reader.LocalName == "other_participations"); } if (reader.LocalName == "work_flow_id") { string workFlowIdType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace); // CM: 06/09/10 when workFlowIdType is null or empty, it's type of OBJECT_REF if (string.IsNullOrEmpty(workFlowIdType)) { this.workflowId = new ObjectRef(); } else { this.workflowId = ObjectRef.GetObjectRefByType(workFlowIdType); } this.workflowId.ReadXml(reader); } }
public static bool IsSameRmType(string rmTypeName, IRmType rmObject) { Check.Require(rmObject != null, string.Format(CommonStrings.XMustNotBeNull, "rmObject")); Check.Require(!string.IsNullOrEmpty(rmTypeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "rmTypeName")); string actualTypeName = rmObject.GetRmTypeName(); if (rmTypeName == actualTypeName) { return(true); } Type actualRmType = rmObject.GetType(); while (actualRmType != null && actualRmType != typeof(RmType)) { actualTypeName = RmFactory.GetRmTypeName(actualRmType); if (actualTypeName == rmTypeName) { return(true); } if (actualTypeName != null) { actualRmType = actualRmType.BaseType; } else { actualRmType = null; } } return(false); }
public Composition(DvText name, string archetypeNodeId, Support.Identification.UidBasedId uid, Link[] links, Archetyped archetypeDetails, FeederAudit feederAudit, CodePhrase language, CodePhrase territory, DvCodedText category, EventContext context, Content.ContentItem[] content, PartyProxy composer) : base(name, archetypeNodeId, uid, links, archetypeDetails, feederAudit) { Check.Require(language != null, "language must not be null"); Check.Require(territory != null, "territory must not be null"); Check.Require(category != null, "category must not be null"); Check.Require(composer != null, "composer must not be null"); this.language = language; this.territory = territory; this.category = category; this.context = context; if (this.context != null) { this.context.Parent = this; } if (content != null) { this.content = RmFactory.LocatableList <ContentItem>(this, content); } this.composer = composer; SetAttributeDictionary(); this.CheckInvariants(); }
protected override void ReadXmlBase(System.Xml.XmlReader reader) { base.ReadXmlBase(reader); DesignByContract.Check.Assert(reader.LocalName == "language", "Expected LocalName is 'language', but it is " + reader.LocalName); this.language = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.language.ReadXml(reader); DesignByContract.Check.Assert(reader.LocalName == "territory", "Expected LocalName is 'territory', but it is " + reader.LocalName); this.territory = new OpenEhr.RM.DataTypes.Text.CodePhrase(); this.territory.ReadXml(reader); DesignByContract.Check.Assert(reader.LocalName == "category", "Expected LocalName is 'category', but it is " + reader.LocalName); this.category = new OpenEhr.RM.DataTypes.Text.DvCodedText(); this.category.ReadXml(reader); DesignByContract.Check.Assert(reader.LocalName == "composer", "Expected LocalName is 'composer', but it is " + reader.LocalName); string composerType = RmXmlSerializer.ReadXsiType(reader); this.composer = RmFactory.PartyProxy(composerType); this.composer.ReadXml(reader); if (reader.LocalName == "context") { this.context = new EventContext(); this.context.ReadXml(reader); this.context.Parent = this; } if (reader.LocalName == "content") { OpenEhr.AssumedTypes.Impl.LocatableList <ContentItem> contents = new OpenEhr.AssumedTypes.Impl.LocatableList <ContentItem>(); do { string contentType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace); Check.Assert(!string.IsNullOrEmpty(contentType), "content type must not be null or empty."); ContentItem aContentItem = ContentItem.GetLocatableObjectByType(contentType) as ContentItem; if (aContentItem == null) { throw new InvalidOperationException("Composition contentType must be type of ContentItem: " + contentType); } aContentItem.ReadXml(reader); aContentItem.Parent = this; contents.Add(aContentItem); } while (reader.LocalName == "content" && reader.NodeType == System.Xml.XmlNodeType.Element); this.content = contents; } }
public ItemTable(DvText name, string archetypeNodeId, Support.Identification.UidBasedId uid, Link[] links, Archetyped archetypeDetails, FeederAudit feederAudit, Cluster[] rows) : base(name, archetypeNodeId, uid, links, archetypeDetails, feederAudit) { if (rows != null) { this.rows = RmFactory.LocatableList <Cluster>(this, rows); } SetAttributeDictionary(); CheckInvariants(); }
public Section(DvText name, string archetypeNodeId, Support.Identification.UidBasedId uid, Link[] links, Archetyped archetypeDetails, FeederAudit feederAudit, ContentItem[] items) : base(name, archetypeNodeId, uid, links, archetypeDetails, feederAudit) { if (items != null) { this.items = RmFactory.LocatableList <ContentItem>(this, items); } SetAttributeDictionary(); CheckInvariants(); }
protected override void ReadXmlBase(System.Xml.XmlReader reader) { base.ReadXmlBase(reader); if (reader.LocalName == "attested_view") { this.attestedView = new OpenEhr.RM.DataTypes.Encapsulated.DvMultimedia(); this.attestedView.ReadXml(reader); } if (reader.LocalName == "proof") { this.proof = reader.ReadElementString("proof", RmXmlSerializer.OpenEhrNamespace); reader.MoveToContent(); } if (reader.LocalName == "items") { this.items = new OpenEhr.AssumedTypes.List <OpenEhr.RM.DataTypes.Uri.DvEhrUri>(); do { DataTypes.Uri.DvEhrUri uri = new OpenEhr.RM.DataTypes.Uri.DvEhrUri(); uri.ReadXml(reader); this.items.Add(uri); } while (reader.LocalName == "items"); } if (reader.LocalName != "reason") { throw new ValidationException("Excepted element name is reason, but it is: " + reader.LocalName); } string reasonType = RmXmlSerializer.ReadXsiType(reader); if (!string.IsNullOrEmpty(reasonType)) { this.reason = RmFactory.DataValue(reasonType) as DataTypes.Text.DvText; } else { this.reason = new OpenEhr.RM.DataTypes.Text.DvText(); } this.reason.ReadXml(reader); if (reader.LocalName != "is_pending") { throw new ValidationException("Excepted element name is is_pending, but it is: " + reader.LocalName); } this.isPending = reader.ReadElementContentAsBoolean("is_pending", RmXmlSerializer.OpenEhrNamespace); reader.MoveToContent(); }
protected override void ReadXmlBase(System.Xml.XmlReader reader) { if (reader.LocalName == "lower") { string type = RmXmlSerializer.ReadXsiType(reader); this.lower = RmFactory.DataValue(type) as T; Check.Assert(this.lower != null, "lower must not be null"); this.lower.ReadXml(reader); reader.MoveToContent(); } if (reader.LocalName == "upper") { string type = RmXmlSerializer.ReadXsiType(reader); this.upper = RmFactory.DataValue(type) as T; Check.Assert(this.upper != null, "lower must not be null"); this.upper.ReadXml(reader); reader.MoveToContent(); } if (reader.LocalName == "lower_included") { this.lowerIncluded = reader.ReadElementContentAsBoolean(); this.lowerIncludedSet = true; reader.MoveToContent(); } if (reader.LocalName == "upper_included") { this.upperIncluded = reader.ReadElementContentAsBoolean(); this.upperIncludedSet = true; reader.MoveToContent(); } Check.Assert(reader.LocalName == "lower_unbounded", "localName must be 'lower_unbounded'"); this.lowerUnbounded = reader.ReadElementContentAsBoolean(); this.lowerUnboundedSet = true; reader.MoveToContent(); Check.Assert(reader.LocalName == "upper_unbounded", "localName must be 'upper_unbounded'"); this.upperUnbounded = reader.ReadElementContentAsBoolean(); this.upperUnboundedSet = true; reader.MoveToContent(); CheckInvariants(); }
private void ReadTComplexObject(XmlReader reader, TComplexObject tComplexObject) { Check.Require(tComplexObject != null, string.Format(CommonStrings.XMustNotBeNull, "tComplexObject")); ReadCComplexObject(reader, tComplexObject); // Read default_value if (reader.LocalName == "default_value") { string rmType = ReadXsiType(reader); Check.Assert(!string.IsNullOrEmpty(rmType), "xsi:type should not be null or empty"); DataValue defaultValue = RmFactory.DataValue(rmType); defaultValue.ReadXml(reader); tComplexObject.DefaultValue = defaultValue; } }
internal void ReadXml(System.Xml.XmlReader reader) { reader.ReadStartElement(); reader.MoveToContent(); Check.Require(reader.LocalName == "system_id", "Expected LocalName is 'system_id' rather than " + reader.LocalName); this.systemId = reader.ReadElementString("system_id", RmXmlSerializer.OpenEhrNamespace); if (reader.LocalName == "location") { this.location = new OpenEhr.RM.Common.Generic.PartyIdentified(); this.location.ReadXml(reader); } if (reader.LocalName == "provider") { this.provider = new OpenEhr.RM.Common.Generic.PartyIdentified(); this.provider.ReadXml(reader); } if (reader.LocalName == "subject") { string subjectType = RmXmlSerializer.ReadXsiType(reader); Check.Assert(!string.IsNullOrEmpty(subjectType), "the type of subject must not be null or empty."); this.subject = RmFactory.PartyProxy(subjectType); this.subject.ReadXml(reader); } if (reader.LocalName == "time") { this.time = new OpenEhr.RM.DataTypes.Quantity.DateTime.DvDateTime(); this.time.ReadXml(reader); } if (reader.LocalName == "version_id") { this.versionId = reader.ReadElementString("version_id", RmXmlSerializer.OpenEhrNamespace); } if (!reader.IsStartElement()) { reader.ReadEndElement(); } reader.MoveToContent(); }
public Folder(DvText name, string archetypeNodeId, UidBasedId uid, List <Link> links, Archetyped.Impl.Archetyped archetypeDetails, FeederAudit feederAudit, List <Folder> folders, List <ObjectRef> items) : base(name, archetypeNodeId, uid, links, archetypeDetails, feederAudit) { LocatableList <Folder> locatableList = folders as LocatableList <Folder>; // LocatableList can not be constructed without a parent, hence will not have a parent of this object is it is yet to be constructed Check.Require(locatableList == null, "folders must not be of type LocatableList with another parent"); if (folders != null) { this.folders = RmFactory.List <Folder>(this, folders) as LocatableList <Folder>; } this.items = items; SetAttributeDictionary(); }
public Folder(DvText name, string archetypeNodeId, UidBasedId uid, List <Link> links, Archetyped.Impl.Archetyped archetypeDetails, FeederAudit feederAudit, System.Collections.Generic.IEnumerable <Folder> folders, System.Collections.Generic.IEnumerable <ObjectRef> items) : base(name, archetypeNodeId, uid, links, archetypeDetails, feederAudit) { if (folders != null) { this.folders = RmFactory.List <Folder>(this, folders) as LocatableList <Folder>; } if (items != null) { this.items = new List <ObjectRef>(items); } SetAttributeDictionary(); }
internal void ReadXml(XmlReader reader) { reader.ReadStartElement(); reader.MoveToContent(); Check.Assert(reader.LocalName == "function", "Expected LocalName is 'function' not " + reader.LocalName); string functionType = RmXmlSerializer.ReadXsiType(reader); if (!string.IsNullOrEmpty(functionType)) { this.function = RmFactory.DataValue(functionType) as DataTypes.Text.DvText; } else { this.function = new OpenEhr.RM.DataTypes.Text.DvText(); } this.function.ReadXml(reader); reader.MoveToContent(); Check.Assert(reader.LocalName == "performer", "Expected LocalName is 'performer' not " + reader.LocalName); string performerType = RmXmlSerializer.ReadXsiType(reader); this.performer = RmFactory.PartyProxy(performerType); this.performer.ReadXml(reader); if (reader.LocalName == "time") { this.time = new OpenEhr.RM.DataTypes.Quantity.DvInterval <OpenEhr.RM.DataTypes.Quantity.DateTime.DvDateTime>(); this.time.ReadXml(reader); } Check.Assert(reader.LocalName == "mode", "Expected LocalName is 'mode' not " + reader.LocalName); this.mode = new OpenEhr.RM.DataTypes.Text.DvCodedText(); this.mode.ReadXml(reader); DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement, "Expected endElement of PartyIdentified."); reader.ReadEndElement(); reader.MoveToContent(); }
public static DataValue ReadDataValue(System.Xml.XmlReader reader) { DataValue dataValue = null; string valueType = RmXmlSerializer.ReadXsiType(reader); Check.Assert(!string.IsNullOrEmpty(valueType), "value type must not be null or empty."); switch (valueType) { case "DV_INTERVAL": reader.ReadStartElement(); reader.MoveToContent(); if (reader.LocalName != "lower" && reader.LocalName != "upper") { throw new ApplicationException("interval must have lower or upper element"); } string intervalType = RmXmlSerializer.ReadXsiType(reader); dataValue = CreateInterval(intervalType); dataValue.ReadXmlBase(reader); DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement, "Expected endElement after calling ReadXml"); reader.ReadEndElement(); reader.MoveToContent(); break; default: dataValue = RmFactory.DataValue(valueType); dataValue.ReadXml(reader); break; } DesignByContract.Check.Ensure(dataValue != null, "dataValue must not be null."); return(dataValue); }
protected virtual void ReadXmlBase(System.Xml.XmlReader reader) { Check.Assert(reader.LocalName == "system_id", "Expected LocalName is 'system_id' not " + reader.LocalName); this.systemId = reader.ReadElementString("system_id", RmXmlSerializer.OpenEhrNamespace); reader.MoveToContent(); Check.Assert(reader.LocalName == "committer", "Expected LocalName is 'committer' not " + reader.LocalName); string committerType = RmXmlSerializer.ReadXsiType(reader); this.committer = RmFactory.PartyProxy(committerType); this.committer.ReadXml(reader); Check.Assert(reader.LocalName == "time_committed", "Expected LocalName is 'time_committed' not " + reader.LocalName); this.timeCommitted = new OpenEhr.RM.DataTypes.Quantity.DateTime.DvDateTime(); this.timeCommitted.ReadXml(reader); Check.Assert(reader.LocalName == "change_type", "Expected LocalName is 'change_type' not " + reader.LocalName); this.changeType = new OpenEhr.RM.DataTypes.Text.DvCodedText(); this.changeType.ReadXml(reader); if (reader.LocalName == "description") { string descriptionType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace); if (descriptionType == null) { this.description = new OpenEhr.RM.DataTypes.Text.DvText(); } else { this.description = new OpenEhr.RM.DataTypes.Text.DvCodedText(); } this.description.ReadXml(reader); } }
public History(DvText name, string archetypeNodeId, Support.Identification.UidBasedId uid, Link[] links, Archetyped archetypeDetails, FeederAudit feederAudit, DvDateTime origin, DvDuration period, DvDuration duration, Event <T>[] events, ItemStructure.ItemStructure summary) : base(name, archetypeNodeId, uid, links, archetypeDetails, feederAudit) { this.period = period; this.duration = duration; this.summary = summary; if (this.summary != null) { this.summary.Parent = this; } if (events != null) { this.events = RmFactory.LocatableList <Event <T> >(this, events); } this.origin = origin; SetAttributeDictionary(); CheckInvariants(); }
public Instruction(DvText name, string archetypeNodeId, UidBasedId uid, Link[] links, Archetyped archetypeDetails, FeederAudit feederAudit, CodePhrase language, CodePhrase encoding, PartyProxy subject, PartyProxy proider, Participation[] otherParticipations, ObjectRef workflowId, ItemStructure protocol, ObjectRef guidelineId, DvText narrative, DvDateTime expiryTime, Activity[] activities, DvParsable wfDefinition) : base(name, archetypeNodeId, uid, links, archetypeDetails, feederAudit, language, encoding, subject, proider, otherParticipations, workflowId, protocol, guidelineId) { Check.Require(narrative != null, "narrative must not be null"); this.narrative = narrative; this.expiryTime = expiryTime; if (activities != null) { this.activities = RmFactory.LocatableList <Activity>(this, activities); } this.wfDefinition = wfDefinition; SetAttributeDictionary(); CheckInvariants(); }
internal void ReadXml(System.Xml.XmlReader reader) { reader.ReadStartElement(); reader.MoveToContent(); Check.Assert(reader.LocalName == "meaning", "Expected LocalName is meaning rather than " + reader.LocalName); if (this.meaning == null) { string meaningType = RmXmlSerializer.ReadXsiType(reader); if (meaningType == null) { this.meaning = new DvText(); } else { this.meaning = RmFactory.DataValue(meaningType) as DvText; } } this.meaning.ReadXml(reader); DesignByContract.Check.Assert(reader.LocalName == "range", "Expected LocalName is range rather than " + reader.LocalName); if (this.range == null) { this.range = new DvInterval <T>(); } this.range.ReadXml(reader); if (!reader.IsStartElement()) { reader.ReadEndElement(); } reader.MoveToContent(); this.CheckInvariants(); }
public static void ClassInitialize(TestContext testContext) { factory = new RmFactory(GetSchema()); }
public override bool ValidValue(object dataValue) { Check.Require(dataValue != null, string.Format(CommonStrings.XMustNotBeNull, "dataValue")); IRmType rmType = dataValue as IRmType; Check.Require(rmType != null, string.Format(AmValidationStrings.ValueMustImplementIRmType, dataValue.GetType().ToString())); bool result = true; rmType.Constraint = this; if (!IsSameRmType(rmType)) { result = false; ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.IncorrectRmType, RmTypeName, rmType.GetRmTypeName())); } if (!result || !AnyAllowed()) { OpenEhr.RM.Common.Archetyped.Impl.Locatable locatable = dataValue as OpenEhr.RM.Common.Archetyped.Impl.Locatable; if (locatable != null) { ValidationUtility.PopulateLocatableAttributes(this, locatable); if (Parent != null && ArchetypeNodeId != locatable.ArchetypeNodeId) { result = false; ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.IncorrectNodeId, ArchetypeNodeId, locatable.ArchetypeNodeId)); } } System.ComponentModel.PropertyDescriptorCollection propertyDescriptorCollection = System.ComponentModel.TypeDescriptor.GetProperties(dataValue); if (Attributes != null) { foreach (CAttribute cAttribute in Attributes) { object attributeObject = null; string attributeName = RmFactory.GetOpenEhrV1RmName(cAttribute.RmAttributeName); System.ComponentModel.PropertyDescriptor property = propertyDescriptorCollection.Find(attributeName, true); // if the attributeName is not a class property, it must be a class function. if (property == null) { System.Reflection.MethodInfo method = dataValue.GetType().GetMethod(attributeName); if (method == null) { result = false; ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.UnexpectedAttributeX, attributeName)); continue; } else { attributeObject = method.Invoke(dataValue, null); } } else { attributeObject = property.GetValue(dataValue); } if (attributeObject == null) { if (cAttribute.Existence.Lower > 0) { result = false; ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.TmExpectedConstraintMissing, cAttribute.RmAttributeName)); } } else if (cAttribute.Existence.Upper == 0) { result = false; ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.TmForbiddenConstraint, cAttribute.RmAttributeName)); } else if (!cAttribute.ValidValue(attributeObject)) { result = false; } else { DvCodedText codedText = dataValue as DvCodedText; if (codedText != null && cAttribute.RmAttributeName == "defining_code") { // validate the code string before validating the coded value if (codedText.DefiningCode.TerminologyId.Value == "local") { CObject parentObject = cAttribute.parent; CArchetypeRoot cArchetypeRoot = ValidationUtility.GetCArchetypeRoot(parentObject); if (!cArchetypeRoot.TermDefinitions.HasKey(codedText.DefiningCode.CodeString)) { result = false; string code = codedText.DefiningCode == null ? "" : codedText.DefiningCode.CodeString; ValidationContext.AcceptValidationError(this, string.Format("code {0} is not existing archetype term", code)); } } if (result && !ValidationUtility.ValidValueTermDef(codedText, cAttribute, ValidationContext.TerminologyService)) { result = false; string code = codedText.DefiningCode == null ? "" : codedText.DefiningCode.CodeString; ValidationContext.AcceptValidationError(this, string.Format(AmValidationStrings.TextValueXInvalidForCodeY, codedText.Value, code)); } } } } } } return(result); }
static public ObjectRef ObjectRef(VersionedFolder directory, HierObjectId systemId) { return(RmFactory.ObjectRef(directory.Uid, systemId.Value, typeof(Folder))); }
static public ObjectRef ObjectRef(HierObjectId contributionUid, HierObjectId systemId) { return(new ObjectRef(contributionUid, systemId.Value, RmFactory.GetRmTypeName(typeof(Contribution)))); }