protected void Validate(CQuantityItem cQuantityItem) { Invariant(!string.IsNullOrEmpty(cQuantityItem.Units), "cquantityItem.Units must not be null or empty."); }
private void ReadXml(CQuantityItem quantityItem) { Check.Require(quantityItem != null, "quantityItem must not be null."); reader.ReadStartElement(); reader.MoveToContent(); if (reader.LocalName == "magnitude") { quantityItem.Magnitude = new Interval<float>(); this.ReadXml(quantityItem.Magnitude); } if (reader.LocalName == "precision") { quantityItem.Precision = new Interval<int>(); this.ReadXml(quantityItem.Precision); } if(reader.LocalName!="units") throw new InvalidXmlException("units", reader.LocalName); quantityItem.Units = reader.ReadElementContentAsString("units", OpenEhrNamespace); reader.MoveToContent(); reader.ReadEndElement(); reader.MoveToContent(); }
private void WriteXml(CQuantityItem cQuantityItem) { Check.Require(cQuantityItem != null, string.Format(CommonStrings.XMustNotBeNull, "cQuantityItem")); // %HYYKA% // Commented by LMT 05/Apr/2009 EHR-900 because assumption is invalid in case of certain archetypes (eg. EVALUATION.medication in EHR/test repository which doesn't specify any units in the C_QUANTITY_ITEM). //Check.Require(!string.IsNullOrEmpty(cQuantityItem.Units), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "cQuantityItem.Units")); string openEhrPrefix = UseOpenEhrPrefix(writer); if (cQuantityItem.Magnitude != null) { writer.WriteStartElement(openEhrPrefix, "magnitude", OpenEhrNamespace); this.WriteXml(cQuantityItem.Magnitude); writer.WriteEndElement(); } if (cQuantityItem.Precision != null) { writer.WriteStartElement(openEhrPrefix, "precision", OpenEhrNamespace); this.WriteXml(cQuantityItem.Precision); writer.WriteEndElement(); } writer.WriteElementString(openEhrPrefix, "units", OpenEhrNamespace, cQuantityItem.Units); }
private void ReadXml(CDvQuantity cDomainType) { reader.ReadStartElement(); reader.MoveToContent(); this.ReadXmlBase((CObject)cDomainType); if (reader.LocalName == "assumed_value") { DvQuantity assumedValue = new DvQuantity(); assumedValue.ReadXml(reader); cDomainType.AssumedValue = assumedValue; } if (reader.LocalName == "property") { cDomainType.Property = new CodePhrase(); cDomainType.Property.ReadXml(reader); } if (reader.LocalName == "list") { cDomainType.List = new OpenEhr.AssumedTypes.List<CQuantityItem>(); do { CQuantityItem quantityItem = new CQuantityItem(); this.ReadXml(quantityItem); cDomainType.List.Add(quantityItem); } while (reader.LocalName == "list" && reader.NodeType != XmlNodeType.EndElement); Check.Assert(cDomainType.List.Count > 0, "CDvQuantity.List may not be empty."); } reader.ReadEndElement(); reader.MoveToContent(); }