private ConstrainedDatatype CreateConstraints(bool referenceMandatory) { // <relationship name="reference" attribute="false" cardinality="1"/> // <relationship name="reference.value" attribute="false" cardinality="1"/> // // <relationship name="reference" attribute="false" cardinality="0-1"/> // <relationship name="reference.value" attribute="false" cardinality="1"/> // // <relationship name="mediaType" attribute="false" cardinality="1" fixedValue="application/dicom"/> // <relationship name="reference" attribute="false" cardinality="1"/> ConstrainedDatatype constraints = new ConstrainedDatatype("MessagePart.relationshipName", "ED"); constraints.SetRestriction(); Relationship referenceConstraint = new Relationship("reference", null, Cardinality.Create(referenceMandatory ? "1" : "0-1" )); constraints.Relationships.Add(referenceConstraint); Relationship referenceValueConstraint = new Relationship("reference.value", null, Cardinality.Create("1")); constraints.Relationships.Add(referenceValueConstraint); Relationship mediaTypeConstraint = new Relationship("mediaType", null, Cardinality.Create("1")); mediaTypeConstraint.FixedValue = "application/dicom"; constraints.Relationships.Add(mediaTypeConstraint); return(constraints); }
private void HandleConstraints(EncapsulatedData ed, ConstrainedDatatype constraints, XmlElement element, Hl7Errors errors ) { ErrorLogger logger = new _ErrorLogger_144(errors, element); this.constraintsHandler.HandleConstraints(constraints, ed, logger); }
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); }
private void HandleConstraints(CodedTypeR2 <Code> codedType, ConstrainedDatatype constraints, string propertyPath, Hl7Errors errors) { ErrorLogger logger = new _ErrorLogger_109(errors, propertyPath); this.constraintsHandler.HandleConstraints(constraints, codedType, logger); }
public virtual void TestFormatWithMissingConstraint() { Relationship rootConstraint = new Relationship(); rootConstraint.Name = "root"; rootConstraint.FixedValue = "1.22.33.44"; Relationship extConstraint = new Relationship(); extConstraint.Name = "extension"; extConstraint.FixedValue = "1223344"; ConstrainedDatatype constraints = new ConstrainedDatatype("iiConstraint", "II"); constraints.Relationships.Add(rootConstraint); constraints.Relationships.Add(extConstraint); string result = new ListR2PropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (this.result, null, "ids", "LIST<II>", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, Cardinality.Create ("0-4"), false, SpecificationVersion.R02_04_03, null, null, null, constraints, false), (BareANY)LISTImpl <ANY <object>, object > .Create <II, Identifier>(typeof(IIImpl), CreateIdentifierList())); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual(ErrorLevel.INFO, this.result.GetHl7Errors()[0].GetHl7ErrorLevel()); Assert.AreEqual(Hl7ErrorCode.CDA_FIXED_CONSTRAINT_PROVIDED, this.result.GetHl7Errors()[0].GetHl7ErrorCode()); Assert.AreEqual("A fixed constraint was added for compliance: root={1.22.33.44},extension={1223344}", this.result.GetHl7Errors ()[0].GetMessage()); AssertXml("non null", "<ids extension=\"123\" root=\"1.2.3\"/>" + "<ids extension=\"256\" root=\"2.5.6\"/>" + "<ids extension=\"1223344\" root=\"1.22.33.44\"/>" , result); }
private void HandleConstraints(EncapsulatedData ed, ConstrainedDatatype constraints, string propertyPath, Hl7Errors errors ) { ErrorLogger logger = new _ErrorLogger_117(errors, propertyPath); this.constraintsHandler.HandleConstraints(constraints, ed, logger); }
private void HandleConstraints(CodedTypeR2 <Code> codedType, ConstrainedDatatype constraints, XmlElement element, Hl7Errors errors) { ErrorLogger logger = new _ErrorLogger_127(errors, element); this.constraintsHandler.HandleConstraints(constraints, codedType, logger); }
// tests only public static ParseContext Create(string type, System.Type returnType, VersionNumber version, TimeZoneInfo dateTimeZone, TimeZoneInfo dateTimeTimeZone, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformance, Cardinality cardinality, CodingStrength strength, Int32?length, ConstrainedDatatype constraints, bool isCda) { return(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Parser.ParseContextImpl(type, returnType, version, dateTimeZone, dateTimeTimeZone , conformance, cardinality, strength, length, constraints, isCda, false)); }
public virtual void HandleConstraints(ConstrainedDatatype constraints, EncapsulatedData ed, ErrorLogger logger) { if (ed == null || constraints == null) { return; } TelecommunicationAddress reference = ed.ReferenceObj; // ignoring any fixed value returned from reference constraints checking this.constraintsHandler.ValidateConstraint("reference", reference == null ? null : "reference", constraints, logger); // just checks if reference provided if (reference != null) { // only check this constraint if a reference has been provided (whether the reference was mandatory or not) string referenceValue = reference.ToString(); this.constraintsHandler.ValidateConstraint("reference.value", referenceValue, constraints, logger); } // checks for actual value string mediaType = ed.MediaType == null ? null : ed.MediaType.CodeValue; string newMediaType = this.constraintsHandler.ValidateConstraint("mediaType", mediaType, constraints, logger); if (!StringUtils.Equals(mediaType, newMediaType)) { x_DocumentMediaType newMediaTypeEnum = Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.Get(newMediaType); if (newMediaTypeEnum != null) { ed.MediaType = newMediaTypeEnum; } } }
public virtual bool HasFixedConstraint(string name, ConstrainedDatatype constraints) { Relationship constrainedRelationship = ObtainConstraint(name, constraints); string fixedConstraint = ObtainFixedValue(constrainedRelationship); return(StringUtils.IsNotBlank(fixedConstraint)); }
private void HandleConstraints(ConstrainedDatatype constraints, Hl7Errors errors, string propertyPath, DateInterval dateInterval ) { ErrorLogger logger = new _ErrorLogger_73(errors, propertyPath); this.constraintsHandler.HandleConstraints(constraints, dateInterval, logger); }
public virtual void TestIvlTsConstraintsInvalid() { XmlToModelResult result = new XmlToModelResult(); XmlNode node = CreateNode("<ivl><low value=\"20120503\"/><high value=\"20120708\"/></ivl>"); 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"))); ParseContext context = ParseContextImpl.Create("IVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel .MANDATORY, Cardinality.Create("1"), constraints, true); BareANY parseResult = this.parser.Parse(context, Arrays.AsList(node), result); 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> expectedIvl = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh ); Assert.IsFalse(result.IsValid()); Assert.AreEqual(2, result.GetHl7Errors().Count); Assert.IsTrue(parseResult is IVLTSCDAR1); DateInterval ivl = (DateInterval)parseResult.BareValue; Assert.AreEqual(expectedIvl, ivl.Interval); }
public virtual void TestParseMissingFixedtemplateIdConstraint() { XmlNode node = CreateNode("<top>" + "<something root=\"1.2.3.4\" extension=\"5678\" />" + "</top>"); ConstrainedDatatype constraints = new ConstrainedDatatype("constraintName.templateId", "II"); Relationship rootConstraint = new Relationship(); rootConstraint.Name = "root"; rootConstraint.FixedValue = "a_fixed_value"; constraints.Relationships.Add(rootConstraint); XmlToModelResult xmlToModelResult = new XmlToModelResult(); BareANY result = new SetR2ElementParser(this.parserR2Registry).Parse(ParseContextImpl.Create("SET<II>", null, SpecificationVersion .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), constraints, false ), AsList(node.ChildNodes), xmlToModelResult); ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet(); Assert.IsFalse(xmlToModelResult.IsValid()); Assert.AreEqual(1, xmlToModelResult.GetHl7Errors().Count, "size"); Assert.AreEqual("Expected to find an identifier with: root={a_fixed_value},extension={null}", xmlToModelResult.GetHl7Errors ()[0].GetMessage()); Assert.AreEqual(Hl7ErrorCode.CDA_TEMPLATEID_FIXED_CONSTRAINT_MISSING, xmlToModelResult.GetHl7Errors()[0].GetHl7ErrorCode( )); Assert.AreEqual(ErrorLevel.WARNING, xmlToModelResult.GetHl7Errors()[0].GetHl7ErrorLevel()); Assert.IsNotNull(rawSet, "null"); Assert.AreEqual(1, rawSet.Count, "size"); IEnumerator <Identifier> iterator = rawSet.GetEnumerator(); if (iterator.MoveNext()) { Assert.AreEqual(new Identifier("1.2.3.4", "5678"), iterator.Current); } }
public virtual void TestParseMatchingFixedNonTemplateIdConstraint() { XmlNode node = CreateNode("<top>" + "<something root=\"1.2.3.4\"/>" + "</top>"); ConstrainedDatatype constraints = new ConstrainedDatatype("constraintName.somethingElse", "II"); Relationship rootConstraint = new Relationship(); rootConstraint.Name = "root"; rootConstraint.FixedValue = "1.2.3.4"; constraints.Relationships.Add(rootConstraint); XmlToModelResult xmlToModelResult = new XmlToModelResult(); BareANY result = new SetR2ElementParser(this.parserR2Registry).Parse(ParseContextImpl.Create("SET<II>", null, SpecificationVersion .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), constraints, false ), AsList(node.ChildNodes), xmlToModelResult); ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet(); Assert.IsTrue(xmlToModelResult.IsValid()); // only has an info message Assert.IsTrue(xmlToModelResult.GetHl7Errors().IsEmpty()); Assert.IsNotNull(rawSet, "null"); Assert.AreEqual(1, rawSet.Count, "size"); IEnumerator <Identifier> iterator = rawSet.GetEnumerator(); if (iterator.MoveNext()) { Assert.AreEqual(new Identifier("1.2.3.4"), iterator.Current); } }
public virtual void TestPassingConstraintsLowHigh() { DateInterval dateInterval = new DateInterval(CreateLowHighInterval(true, true)); ConstrainedDatatype constraints = CreateLowHighConstraints(); this.constraintsHandler.HandleConstraints(constraints, dateInterval, this.errorLogger); Assert.IsTrue(this.errors.IsEmpty()); }
public virtual void TestPassingConstraints() { Identifier identifier = new Identifier("1.2.3.4", "1234"); ConstrainedDatatype constraints = CreateConstraints(false); this.constraintsHandler.HandleConstraints(constraints, identifier, this.errorLogger, true); Assert.IsTrue(this.errors.IsEmpty()); }
public virtual void TestPassingConstraints() { EncapsulatedData ed = CreateEd(true, true, Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.DICOM); ConstrainedDatatype constraints = CreateConstraints(true); this.constraintsHandler.HandleConstraints(constraints, ed, this.errorLogger); Assert.IsTrue(this.errors.IsEmpty()); }
public virtual void TestPassingSimpleValueConstraints() { DateInterval dateInterval = new DateInterval(CreateSimpleValueInterval()); ConstrainedDatatype constraints = CreateSimpleValueConstraints(); this.constraintsHandler.HandleConstraints(constraints, dateInterval, this.errorLogger); Assert.IsTrue(this.errors.IsEmpty()); }
private void HandleConstraints(Code code, ConstrainedDatatype constraints, XmlElement element, Hl7Errors errors) { // only code/codeSystem passed to constraints handler for now (only qualifier and codeSystem are currently checked for constraints) CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(code); ErrorLogger logger = new _ErrorLogger_79(errors, element); this.constraintsHandler.HandleConstraints(constraints, codedType, logger); }
public virtual void TestPassingConstraints() { CodedTypeR2 <Code> codedType = CreateCodedType(); ConstrainedDatatype constraints = CreateConstraints(true); this.constraintsHandler.HandleConstraints(constraints, codedType, this.errorLogger); Assert.IsTrue(this.errors.IsEmpty()); }
public virtual void TestMissingQualifierPassesWhenQualifier0To1() { ConstrainedDatatype constraints = CreateConstraints(false); CodedTypeR2 <Code> codedType = CreateCodedType(); codedType.Qualifier.Clear(); this.constraintsHandler.HandleConstraints(constraints, codedType, this.errorLogger); Assert.IsTrue(this.errors.IsEmpty()); }
public virtual void TestMissingReferenceValuePassesIfReferenceMissingAndNotMandatory() { EncapsulatedData ed = CreateEd(true, false, Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.DICOM); ed.ReferenceObj = null; ConstrainedDatatype constraints = CreateConstraints(false); this.constraintsHandler.HandleConstraints(constraints, ed, this.errorLogger); Assert.IsTrue(this.errors.IsEmpty()); }
public virtual void TestMissingExtensionFailingConstraint() { Identifier identifier = new Identifier("1.2.3.4", (string)null); ConstrainedDatatype constraints = CreateConstraints(false); this.constraintsHandler.HandleConstraints(constraints, identifier, this.errorLogger, false); Assert.IsTrue(this.errors.IsEmpty()); Assert.AreEqual("1.2.3.4", identifier.Root); Assert.AreEqual("1234", identifier.Extension); }
private Relationship ObtainConstraint(string name, ConstrainedDatatype constraints) { Relationship result = null; if (constraints != null) { result = constraints.GetRelationship(name); } return(result); }
public ParseContextImpl(Relationship relationship, ConstrainedDatatype constraints, VersionNumber version, TimeZoneInfo dateTimeZone , TimeZoneInfo dateTimeTimeZone, CodeTypeHandler codeTypeHandler, bool isCda) { this.relationship = relationship; this.constraints = constraints; this.version = version; this.dateTimeZone = dateTimeZone; this.dateTimeTimeZone = dateTimeTimeZone; this.codeTypeHandler = codeTypeHandler; this.isCda = isCda; }
public virtual void TestMissingReferenceValueFailsIfReferenceProvidedAndNotMandatory() { EncapsulatedData ed = CreateEd(true, false, Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.DICOM); ConstrainedDatatype constraints = CreateConstraints(false); this.constraintsHandler.HandleConstraints(constraints, ed, this.errorLogger); Assert.IsFalse(this.errors.IsEmpty()); Assert.AreEqual(1, this.errors.Count); Assert.AreEqual(Hl7ErrorCode.CDA_MANDATORY_CONSTRAINT_MISSING, this.errors[0].GetHl7ErrorCode()); Assert.IsTrue(this.errors[0].GetMessage().Contains(" reference.value ")); }
public virtual void TestMissingQualifierValueCodeAndCodeSystemPasses() { ConstrainedDatatype constraints = CreateConstraints(true); CodedTypeR2 <Code> codedType = CreateCodedType(); codedType.Qualifier[0].Value = new CodedTypeR2 <Code>(); this.constraintsHandler.HandleConstraints(constraints, codedType, this.errorLogger); Assert.IsTrue(this.errors.IsEmpty()); Assert.IsNull(codedType.Qualifier[0].Value.GetCodeValue()); Assert.IsNull(codedType.Qualifier[0].Value.GetCodeSystem()); }
public virtual void TestMissingQualifierNameCodeAndQualifierNameCodeSystem() { ConstrainedDatatype constraints = CreateConstraints(true); CodedTypeR2 <Code> codedType = CreateCodedType(); codedType.Qualifier[0].Name = new CodedTypeR2 <Code>(); this.constraintsHandler.HandleConstraints(constraints, codedType, this.errorLogger); Assert.IsTrue(this.errors.IsEmpty()); Assert.AreEqual("121139", codedType.Qualifier[0].Name.GetCodeValue()); Assert.AreEqual("1.2.840.10008.2.16.4", codedType.Qualifier[0].Name.GetCodeSystem()); }
public virtual ConstrainedDatatype GetConstraints(VersionNumber version, string constrainedType) { foreach (MessageDefinitionService service in services) { ConstrainedDatatype constraints = service.GetConstraints(version, constrainedType); if (constraints != null) { return(constraints); } } return(null); }