public virtual void TestGetAttributeNameValuePairsForII_BUS_AND_VER_InvalidSpecializationType() { Identifier ii = new Identifier("11.22.33.44", "extensionString"); II iiHl7 = new IIImpl(); iiHl7.DataType = StandardDataType.II_OID; ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.BUS_AND_VER", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(5, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty(), "errors"); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count); Assert.AreEqual("Specialization type must be II.BUS or II.VER; II.BUS will be assumed. Invalid specialization type II.OID" , modelToXmlResult.GetHl7Errors()[0].GetMessage()); AssertKeyValuePairInMap(result, "root", "11.22.33.44"); AssertKeyValuePairInMap(result, "extension", "extensionString"); AssertKeyValuePairInMap(result, "use", "BUS"); AssertKeyValuePairInMap(result, "specializationType", "II.BUS"); AssertKeyValuePairInMap(result, "xsi:type", "II"); }
public virtual void ShouldValidateDocument() { ContainedTemplateValidator validator = new ContainedTemplateValidator(derivedMessageSet.PackageLocations.Values); StringWriter writer = new StringWriter(); using (StreamReader reader = new StreamReader(Ca.Infoway.Messagebuilder.Platform.ResourceLoader.GetResource (typeof(SchematronValidatorTest), "contained-template-test.xml"))) { string line; while ((line = reader.ReadLine()) != null) { writer.Write(line); } } writer.Close(); ModelToXmlResult result = new ModelToXmlResult(); validator.Validate(writer.ToString(), result); Assert.IsFalse(result.IsValid()); Assert.AreEqual(5, result.GetHl7Errors().Count); Assert.AreEqual("Expected [1] instances of template 2.16.840.1.113883.10.20.22.2.6.1, but found 0", result.GetHl7Errors() [0].GetMessage(), "Missing section at document level - message"); Assert.AreEqual("/ClinicalDocument", result.GetHl7Errors()[0].GetPath(), "Missing section at document level - path"); Assert.AreEqual("Expected [1] instances of template 2.16.840.1.113883.10.20.22.2.1.1, but found 2", result.GetHl7Errors() [1].GetMessage(), "Extra section at document level - message"); Assert.AreEqual("/ClinicalDocument", result.GetHl7Errors()[1].GetPath(), "Extra section at document level - path"); Assert.AreEqual("Expected [*] instances of template 2.16.840.1.113883.10.20.22.4.16, but found 0", result.GetHl7Errors()[ 3].GetMessage(), "Missing entry at section level - message"); Assert.AreEqual("/ClinicalDocument/component/structuredBody/component[3]/section", result.GetHl7Errors()[3].GetPath(), "Missing entry at section level - path" ); Assert.AreEqual("Expected [*] instances of template 2.16.840.1.113883.10.20.22.4.4, but found 0", result.GetHl7Errors()[4 ].GetMessage(), "Missing entryRelationship at entry level - message"); Assert.AreEqual("/ClinicalDocument/component/structuredBody/component[1]/section/entry[2]/act", result.GetHl7Errors()[4]. GetPath(), "Missing entryRelationship at entry level - path"); }
private void Validate(StringBuilder buffer, int indentLevel, FormatContext context, bool hasLang, BareANY dataType) { // ST has min length of 1 according to schema, and cannot have both a NF and text // no details on what language strings are allowed ModelToXmlResult result = context.GetModelToXmlResult(); if (dataType.HasNullFlavor()) { if (dataType.BareValue != null) { Hl7Error hl7Error = new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "ST cannot have both a nullFlavour and a text value.", context .GetPropertyPath()); result.AddHl7Error(hl7Error); } } else { if (StringUtils.IsBlank(GetStringValue(dataType))) { Hl7Error hl7Error = new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "ST text value must be provided.", context.GetPropertyPath ()); result.AddHl7Error(hl7Error); } } if (hasLang && StringUtils.IsBlank(GetLanguage(dataType))) { Hl7Error hl7Error = new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "ST language attribute, if provided, can not be blank.", context .GetPropertyPath()); result.AddHl7Error(hl7Error); } }
private void Validate(StringBuilder buffer, int indentLevel, FormatContext context, bool isStLang, BareANY dataType) { // ST.LANG not allowed for CeRx; not checking as this should be controlled by the message set // is ST allowed to be 0 length or only whitespace??? ModelToXmlResult result = context.GetModelToXmlResult(); string language = GetLanguage(dataType); if (isStLang) { if (!STImpl.ALLOWED_LANGUAGES.Contains(language)) { Hl7Error hl7Error = new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, System.String.Format("The language attribute content ({0}) is not an allowed value. Using en-CA instead." , language), context.GetPropertyPath()); result.AddHl7Error(hl7Error); } } else { if (language != null) { Hl7Error hl7Error = new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, System.String.Format("The language attribute ({0}) is not allowed for ST element types" , language), context.GetPropertyPath()); result.AddHl7Error(hl7Error); } } }
public FormatContextImpl(ModelToXmlResult result, string propertyPath, string elementName, string type, string domainType , Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality, bool isSpecializationType, VersionNumber version, TimeZoneInfo dateTimeZone, TimeZoneInfo dateTimeTimeZone, CodingStrength codingStrength, ConstrainedDatatype constraints , bool isCda) { // TM - CDA - modified this case to set isSpecializationType to false (must specifically specify this value if it is required) // TM - CDA - modified this case to set isSpecializationType to false (must specifically specify this value if it is required) // TM - CDA - modified this case to set isSpecializationType to false (must specifically specify this value if it is required) // constraints not automatically passed on // tests only // tests only this.result = result; this.propertyPath = propertyPath; this.elementName = elementName; this.type = type; this.domainType = domainType; this.conformanceLevel = conformanceLevel; this.cardinality = cardinality; this.isSpecializationType = isSpecializationType; this.version = version; this.dateTimeZone = dateTimeZone; this.dateTimeTimeZone = dateTimeTimeZone; this.codingStrength = codingStrength; this.constraints = constraints; this.isCda = isCda; }
public virtual void TestIvlTsWithConstraintsInValid() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate dateLow = DateUtil.GetDate(2012, 4, 3); DateWithPattern dateWithPatternLow = new DateWithPattern(dateLow, "yyyyMMdd"); PlatformDate dateHigh = DateUtil.GetDate(2012, 6, 8); DateWithPattern dateWithPatternHigh = new DateWithPattern(dateHigh, "yyyyMMdd"); Interval <PlatformDate> ivlTs = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh ); DateInterval dateInterval = new DateInterval(ivlTs); BareANY dataType = new IVLTSCDAR1Impl(dateInterval); ConstrainedDatatype constraints = new ConstrainedDatatype("ivl", "IVL<TS>"); constraints.Relationships.Add(new Relationship("low", "TS", Cardinality.Create("0"))); constraints.Relationships.Add(new Relationship("high", "TS", Cardinality.Create("0"))); FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty , "ivl", "IVLTSCDAR1", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), false, SpecificationVersion .R02_04_03, null, null, null, constraints, true); string xml = this.formatter.Format(formatContext, dataType); Assert.IsFalse(result.IsValid()); Assert.AreEqual(2, result.GetHl7Errors().Count); string expected = "<ivl><low value=\"20120503\"/><high value=\"20120708\"/></ivl>"; AssertXml("ivl output", expected, xml, true); }
public CdaModelToXmlResult(ModelToXmlResult result) { this.delegate_ = result; foreach (Hl7Error error in result.GetHl7Errors()) { errors.Add(new TransformError(error)); } }
private void ValidatePhysicalQuantity(PhysicalQuantity physicalQuantity, BareANY bareANY, FormatContext context) { string type = context.Type; ModelToXmlResult errors = context.GetModelToXmlResult(); // nothing to validate for value, based on R2 schema string unitsAsString = (physicalQuantity.Unit == null ? null : physicalQuantity.Unit.CodeValue); this.pqValidationUtils.ValidateUnits(type, unitsAsString, null, context.GetPropertyPath(), errors, true); }
private FormatContextImpl(ModelToXmlResult result, string propertyPath, Relationship relationship, VersionNumber version, TimeZoneInfo dateTimeZone, TimeZoneInfo dateTimeTimeZone, ConstrainedDatatype constraints, bool isCda) { this.result = result; this.propertyPath = propertyPath; this.relationship = relationship; this.version = version; this.dateTimeZone = dateTimeZone; this.dateTimeTimeZone = dateTimeTimeZone; this.constraints = constraints; this.isCda = isCda; }
public virtual void TestGetAttributeNameValuePairsNullValue() { ModelToXmlResult xmlResult = new ModelToXmlResult(); IDictionary <string, string> result = new TsFullDatePropertyFormatterTest.TestableTsFullDatePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", null, null, null, false ), null, new TSImpl()); // a null value for TS elements results in a nullFlavor attribute Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("nullFlavor"), "key as expected"); Assert.AreEqual(AbstractPropertyFormatter.NULL_FLAVOR_NO_INFORMATION, result.SafeGet("nullFlavor"), "value as expected"); Assert.IsTrue(xmlResult.GetHl7Errors().IsEmpty()); }
public virtual void TestGetAttributeNameValuePairsRootNotFilled() { Identifier ii = new Identifier((string)null, "extension"); ModelToXmlResult xmlResult = new ModelToXmlResult(); IIImpl dataType = new IIImpl(ii); dataType.DataType = StandardDataType.II_BUS; new IiPropertyFormatterTest.TestableIiPropertyFormatter().Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (xmlResult, null, "name", "II.BUS", null, null, false), dataType); Assert.IsFalse(xmlResult.IsValid()); Assert.AreEqual(1, xmlResult.GetHl7Errors().Count); Assert.AreEqual("Attribute \"root\" must be specified for II.BUS", xmlResult.GetHl7Errors()[0].GetMessage()); }
private void Validate(FormatContext context, BigDecimal bigDecimal) { ModelToXmlResult modelToXmlResult = context.GetModelToXmlResult(); if (bigDecimal.CompareTo(BigDecimal.ZERO) < 0 || bigDecimal.CompareTo(BigDecimal.ONE) > 0) { RecordValueMustBeBetweenZeroAndOneError(context.GetPropertyPath(), modelToXmlResult); } if (bigDecimal.Scale() > realFormat.GetMaxDecimalPartLength()) { RecordTooManyDigitsToRightOfDecimalError(context.GetPropertyPath(), modelToXmlResult); } }
public virtual void ShouldProduceResultWithNoErrorsWhenNullFlavorSupplied() { // writing test based on RM16399 ModelToXmlResult result = new ModelToXmlResult(); TS ts = new TSImpl(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.ASKED_BUT_UNKNOWN); FormatContext context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, null, "tsValue" , "TS.FULLDATEWITHTIME", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, false, SpecificationVersion.R02_04_02 , null, null, null, false); string xmlOutput = this.formatter.Format(context, ts); Assert.IsTrue(result.IsValid()); Assert.AreEqual("<tsValue nullFlavor=\"ASKU\"/>", xmlOutput.Trim()); }
public virtual void TestGetAttributeNameValuePairsDate() { // used as expected: a date object is passed in PlatformDate calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0); ModelToXmlResult xmlResult = new ModelToXmlResult(); IDictionary <string, string> result = new TsFullDatePropertyFormatterTest.TestableTsFullDatePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS.DATE", null, null , false, SpecificationVersion.R02_04_02, null, null, null, false), calendar, null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual("19990423", result.SafeGet("value"), "value as expected"); Assert.IsTrue(xmlResult.GetHl7Errors().IsEmpty()); }
private void ValidatePhysicalQuantity(FormatContext context, PhysicalQuantity physicalQuantity, BareANY bareANY) { // does not validate originalText here as this section is bypassed when value is a NullFlavor string type = context.Type; ModelToXmlResult errors = context.GetModelToXmlResult(); bool hasNullFlavor = (bareANY == null || bareANY.NullFlavor != null); string quantityAsString = physicalQuantity.Quantity == null ? null : physicalQuantity.Quantity.ToPlainString(); this.pqValidationUtils.ValidateValue(quantityAsString, context.GetVersion(), type, hasNullFlavor, null, context.GetPropertyPath (), errors); string unitsAsString = (physicalQuantity.Unit == null ? null : physicalQuantity.Unit.CodeValue); this.pqValidationUtils.ValidateUnits(type, unitsAsString, null, context.GetPropertyPath(), errors, false); }
public virtual void TestTs() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate date = DateUtil.GetDate(2012, 4, 3); DateWithPattern dateWithPattern = new DateWithPattern(date, "yyyyMMdd"); BareANY dataType = new TSCDAR1Impl(new MbDate(dateWithPattern)); FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty , "date", "TSCDAR1", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), false, SpecificationVersion .R02_04_03, null, null, null, null, true); string xml = this.formatter.Format(formatContext, dataType); Assert.IsTrue(result.IsValid()); Assert.AreEqual("<date value=\"20120503\"/>", xml.Trim()); }
private void Validate(FormatContext context, BigDecimal bigDecimal) { ModelToXmlResult modelToXmlResult = context.GetModelToXmlResult(); string value = bigDecimal.ToString(); string integerPart = value.Contains(".") ? StringUtils.SubstringBefore(value, ".") : value; string decimalPart = value.Contains(".") ? StringUtils.SubstringAfter(value, ".") : string.Empty; if (integerPart.Length > realFormat.GetMaxIntegerPartLength()) { RecordTooManyCharactersToLeftOfDecimalError(context.GetPropertyPath(), modelToXmlResult); } if (decimalPart.Length > realFormat.GetMaxDecimalPartLength()) { RecordTooManyDigitsToRightOfDecimalError(context.GetPropertyPath(), modelToXmlResult); } }
public virtual void TestGetAttributeNameValuePairsForValidII_OID_MR2007() { Identifier ii = new Identifier("11.22.33.44"); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.OID", null, null, false, SpecificationVersion.V02R02, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(modelToXmlResult.GetHl7Errors().IsEmpty(), "no errors"); AssertKeyValuePairInMap(result, "root", "11.22.33.44"); }
public virtual void ShouldValidateDocument() { SchematronValidator validator = new SchematronValidator(derivedMessageSet.SchematronContexts); XmlDocument document = new DocumentFactory().CreateFromStream(Ca.Infoway.Messagebuilder.Platform.ResourceLoader.GetResource (typeof(SchematronValidatorTest), "problems-and-medications.xml")); ModelToXmlResult result = new ModelToXmlResult(); validator.Validate(document, result); Assert.IsFalse(result.IsValid()); Assert.AreEqual(5, result.GetHl7Errors().Count); foreach (Hl7Error error in result.GetHl7Errors()) { System.Console.Out.WriteLine(error.GetMessage()); } }
public virtual void ShouldProduceResultWithFullDateSpecializationType() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate date = DateUtil.GetDate(1999, 3, 23); TS ts = new TSImpl(date); ts.DataType = StandardDataType.TS_FULLDATE; FormatContext context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, null, "tsValue" , "TS.FULLDATEWITHTIME", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); string xmlOutput = this.formatter.Format(context, ts); Assert.IsTrue(result.GetHl7Errors().IsEmpty(), "no errors"); Assert.AreEqual("<tsValue specializationType=\"TS.FULLDATE\" value=\"19990423\" xsi:type=\"TS\"/>", xmlOutput.Trim(), "output as expected" ); }
public virtual void ShouldProduceResultWithMissingSpecializationTypeError() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate date = DateUtil.GetDate(1999, 3, 23, 1, 2, 3, 0); TS ts = new TSImpl(date); FormatContext context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, null, "tsValue" , "TS.FULLDATEWITHTIME", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); string xmlOutput = this.formatter.Format(context, ts); Assert.AreEqual(1, result.GetHl7Errors().Count, "1 error"); Assert.AreEqual("No specializationType provided. Value should be one of TS.FULLDATE / TS.FULLDATETIME / TS.FULLDATEPARTTIME. TS.FULLDATETIME will be assumed." , result.GetHl7Errors()[0].GetMessage()); // avoid having to assess the timezone Assert.IsTrue(xmlOutput.Trim().StartsWith("<tsValue specializationType=\"TS.FULLDATETIME\" value=\"19990423010203.0000")); Assert.IsTrue(xmlOutput.Trim().EndsWith("\" xsi:type=\"TS\"/>")); }
public virtual void ShouldProduceResultWithFullDateTimeSpecializationType() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate date = DateUtil.GetDate(1999, 3, 23, 1, 2, 3, 0); TS ts = new TSImpl(date); ts.DataType = StandardDataType.TS_FULLDATETIME; FormatContext context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, null, "tsValue" , "TS.FULLDATEWITHTIME", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); string xmlOutput = this.formatter.Format(context, ts); // avoid having to assess the timezone Assert.IsTrue(result.GetHl7Errors().IsEmpty(), "no errors"); Assert.IsTrue(xmlOutput.Trim().StartsWith("<tsValue specializationType=\"TS.FULLDATETIME\" value=\"19990423010203.0000")); Assert.IsTrue(xmlOutput.Trim().EndsWith("\" xsi:type=\"TS\"/>")); }
public virtual void TestGetAttributeNameValuePairsForInvalidIIAsOid() { Identifier ii = new Identifier("311.22.33.44"); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiR2PropertyFormatterTest.TestableIiR2PropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(1, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.IsValid(), "one error"); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count, "one error"); AssertKeyValuePairInMap(result, "root", "311.22.33.44"); }
public virtual void TestGetAttributeNameValuePairsForValidIIAsUuid() { UUID randomUUID = UUID.RandomUUID(); Identifier ii = new Identifier(randomUUID.ToString()); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiR2PropertyFormatterTest.TestableIiR2PropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(modelToXmlResult.GetHl7Errors().IsEmpty(), "no errors"); AssertKeyValuePairInMap(result, "root", randomUUID.ToString()); }
public virtual void TestGetAttributeNameValuePairsValidDatePatternMissingTimezone() { // used as expected: a date object is passed in PlatformDate calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0); DateWithPattern dateWithValidPatternMissingTZ = new DateWithPattern(calendar, "yyyyMMddHH"); ModelToXmlResult xmlResult = new ModelToXmlResult(); IDictionary <string, string> result = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS", null, null, false , SpecificationVersion.R02_04_02, null, null, null, false), new MbDate(dateWithValidPatternMissingTZ), null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual("1999042310", result.SafeGet("value"), "value as expected"); // non-R2 formatter would complain about missing TZ; R2 schema does not explicitly state this is true Assert.IsTrue(xmlResult.IsValid()); }
public virtual void TestPivlFrequency() { ModelToXmlResult result = new ModelToXmlResult(); PhysicalQuantity frequencyQuantity = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive .DAY); PeriodicIntervalTimeR2 pivl = new PeriodicIntervalTimeR2(4, frequencyQuantity); BareANY dataType = new PIVLTSCDAR1Impl(pivl); FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty , "pivl", "PIVLTSCDAR1", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), false, SpecificationVersion.R02_04_03, null, null, null, null, true); string xml = this.formatter.Format(formatContext, dataType); Assert.IsTrue(result.IsValid()); string expected = "<pivl><frequency><numerator value=\"4\"/><denominator unit=\"d\" value=\"1\"/></frequency></pivl>"; AssertXml("pivl output", expected, xml, true); }
public virtual void TestGetAttributeNameValuePairsUsingPartTimePattern() { // used as expected: a date object is passed in PlatformDate calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0); DateWithPattern dateWithInvalidPattern = new DateWithPattern(calendar, "yyyyMM"); ModelToXmlResult xmlResult = new ModelToXmlResult(); IDictionary <string, string> result = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS", null, null, false , SpecificationVersion.R02_04_02, null, null, null, false), new MbDate(dateWithInvalidPattern), null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); string expectedValue = "199904"; Assert.AreEqual(expectedValue, result.SafeGet("value"), "value as expected"); Assert.IsTrue(xmlResult.IsValid()); }
public virtual void TestGetAttributeNameValuePairsForInvalidII_TOKEN() { Identifier ii = new Identifier("1.2.3.4"); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.TOKEN", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(1, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty()); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count); Assert.AreEqual("root '1.2.3.4' should be a UUID.", modelToXmlResult.GetHl7Errors()[0].GetMessage()); AssertKeyValuePairInMap(result, "root", "1.2.3.4"); }
public virtual void TestSxcmGetAttributeNameValuePairsDateWithNoOperator() { // used as expected: a date object is passed in PlatformDate calendar1 = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0); TS_R2 ts = new TS_R2Impl(new MbDate(calendar1)); ModelToXmlResult xmlResult = new ModelToXmlResult(); IDictionary <string, string> result = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "SXCM<TS>", null, null , false, SpecificationVersion.R02_04_02, null, null, null, false), new MbDate(calendar1), ts); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(xmlResult.IsValid()); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); string expectedValue = "19990423101112.0000" + GetCurrentTimeZone(calendar1); Assert.AreEqual(expectedValue, result.SafeGet("value"), "value as expected"); }
public virtual void TestGetAttributeNameValuePairsValidDatePatternForCeRxMissingTimezone() { // used as expected: a date object is passed in PlatformDate calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0); DateWithPattern dateWithInvalidPattern = new DateWithPattern(calendar, "yyyyMMddHH"); ModelToXmlResult xmlResult = new ModelToXmlResult(); IDictionary <string, string> result = new TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS.DATETIME", null, null, false, SpecificationVersion.V01R04_3, null, null, null, false), dateWithInvalidPattern, null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); string expectedValue = "1999042310"; Assert.AreEqual(expectedValue, result.SafeGet("value"), "value as expected"); Assert.IsTrue(xmlResult.GetHl7Errors().IsEmpty()); }