public virtual void TestEverythingSpecified() { CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); codedType.Code = CeRxDomainTestValues.CENTIMETRE; codedType.CodeSystemName = "aCodeSystemName"; // Doesn't appear in the output, but shouldn't log an error either codedType.CodeSystemVersion = "aCodeSystemVersion"; codedType.DisplayName = "aDisplayName"; // Doesn't appear in the output, but shouldn't log an error either codedType.SimpleValue = "simpleValue"; codedType.Operator = SetOperator.CONVEX_HULL; codedType.Value = BigDecimal.ONE; codedType.Translation.Add(new CodedTypeR2 <Code>()); codedType.Qualifier.Add(new CodeRole()); EncapsulatedData originalText = new EncapsulatedData(); originalText.Content = "original text not allowed for CS"; codedType.OriginalText = originalText; CS_R2 <Code> cs = new CS_R2Impl <Code>(codedType); string result = new CsR2PropertyFormatter().Format(GetContext("name", "CS"), cs); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(7, this.result.GetHl7Errors().Count); Assert.AreEqual("<name code=\"cm\"/>", StringUtils.Trim(result), "result"); }
public virtual void TestValidFull() { Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(new DateWithPattern(DateUtil.GetDate(2006, 11, 25), "yyyyMMdd"), new DateWithPattern(DateUtil.GetDate(2007, 0, 2), "yyyyMMdd")); CodedTypeR2 <Code> translation1 = new CodedTypeR2 <Code>(); translation1.Code = CeRxDomainTestValues.KILOGRAM; CodedTypeR2 <Code> translation2 = new CodedTypeR2 <Code>(); translation2.Code = CeRxDomainTestValues.FLUID_OUNCE; CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); codedType.Code = CeRxDomainTestValues.CENTIMETRE; codedType.CodeSystemName = "aCodeSystemName"; codedType.CodeSystemVersion = "aCodeSystemVersion"; codedType.DisplayName = "aDisplayName"; codedType.Translation.Add(translation1); codedType.Translation.Add(translation2); codedType.ValidTime = interval; EncapsulatedData originalText = new EncapsulatedData(); originalText.Content = "some original text"; codedType.OriginalText = originalText; string result = new HxitCeR2PropertyFormatter().Format(GetContext("name", "HXIT<CE>"), new CE_R2Impl <Code>(codedType)); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<name code=\"cm\" codeSystem=\"1.2.3.4\" codeSystemName=\"aCodeSystemName\" codeSystemVersion=\"aCodeSystemVersion\" displayName=\"aDisplayName\">" + "<originalText>some original text</originalText>" + "<translation code=\"kg\" codeSystem=\"1.2.3.4\"/>" + "<translation code=\"[foz_br]\" codeSystem=\"1.2.3.4\"/>" + "<validTime><low value=\"20061225\"/><high value=\"20070102\"/></validTime>" + "</name>", StringUtils.Trim(result), true ); }
public virtual void TestValidFull() { CodedTypeR2 <Code> translation1 = new CodedTypeR2 <Code>(); translation1.Code = CeRxDomainTestValues.KILOGRAM; CodedTypeR2 <Code> translation2 = new CodedTypeR2 <Code>(); translation2.Code = CeRxDomainTestValues.FLUID_OUNCE; CodedTypeR2 <Code> translation3 = new CodedTypeR2 <Code>(); translation3.Code = new _Code_62(); translation3.NullFlavorForTranslationOnly = Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.OTHER; CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); codedType.Code = CeRxDomainTestValues.CENTIMETRE; codedType.CodeSystemName = "aCodeSystemName"; codedType.CodeSystemVersion = "aCodeSystemVersion"; codedType.DisplayName = "aDisplayName"; codedType.Translation.Add(translation1); codedType.Translation.Add(translation2); codedType.Translation.Add(translation3); EncapsulatedData originalText = new EncapsulatedData(); originalText.Content = "some original text"; codedType.OriginalText = originalText; string result = new CeR2PropertyFormatter().Format(GetContext("name", "CE"), new CE_R2Impl <Code>(codedType)); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<name code=\"cm\" codeSystem=\"1.2.3.4\" codeSystemName=\"aCodeSystemName\" codeSystemVersion=\"aCodeSystemVersion\" displayName=\"aDisplayName\">" + "<originalText>some original text</originalText>" + "<translation code=\"kg\" codeSystem=\"1.2.3.4\"/>" + "<translation code=\"[foz_br]\" codeSystem=\"1.2.3.4\"/>" + "<translation codeSystem=\"1.2.3.4\" nullFlavor=\"OTH\"/>" + "</name>", StringUtils.Trim(result), true); }
public virtual void TestParseFullWithCdataAndThumbnailOutOfOrder() { XmlNode node = CreateNode("<something representation=\"B64\" compression=\"DF\" mediaType=\"text/plain\">" + "<thumbnail representation=\"TXT\" mediaType=\"text/html\"><reference value=\"https://thumbnail.ca/monograph/WPDM00002197.html\"/>thumbnail text value</thumbnail>" + "<reference value=\"https://pipefq.ehealthsask.ca/monograph/WPDM00002197.html\"/>" + "<![CDATA[" + "Since this is a CDATA section" + "I can use all sorts of reserved characters" + "like > < \" and &" + "or write things like" + "<foo></bar>" + "but my document is still well formed!" + "]]>" + "</something>"); EncapsulatedData value = (EncapsulatedData) new EdElementParser(this.telParser, true).Parse(CreateContext("ED", SpecificationVersion .R02_04_03), node, this.xmlResult).BareValue; Assert.IsFalse(this.xmlResult.IsValid()); Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count); Assert.IsTrue(this.xmlResult.GetHl7Errors()[0].GetMessage().Contains("ED properties appear to be out of order")); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, value.MediaType, "proper media type returned" ); Assert.AreEqual(EdRepresentation.B64, value.Representation, "proper representation returned"); Assert.AreEqual("pipefq.ehealthsask.ca/monograph/WPDM00002197.html", value.ReferenceObj.Address, "proper reference returned" ); Assert.AreEqual("https", value.ReferenceObj.UrlScheme.CodeValue, "proper reference returned"); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.HTML_TEXT, value.Thumbnail.MediaType, "proper thumbnail media type returned" ); Assert.AreEqual(EdRepresentation.TXT, value.Thumbnail.Representation, "proper thumbnail representation returned"); Assert.AreEqual("thumbnail.ca/monograph/WPDM00002197.html", value.Thumbnail.ReferenceObj.Address, "proper thumbnail reference returned" ); Assert.AreEqual("https", value.Thumbnail.ReferenceObj.UrlScheme.CodeValue, "proper thumbnail reference returned"); Assert.AreEqual("thumbnail text value", value.Thumbnail.Content, "proper thumbnail text returned"); Assert.IsTrue(value.Content.StartsWith("Since this is a CDATA"), "proper text returned"); }
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 void TestEverythingSpecified() { CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); codedType.Code = CeRxDomainTestValues.CENTIMETRE; codedType.CodeSystemName = "aCodeSystemName"; codedType.CodeSystemVersion = "aCodeSystemVersion"; codedType.DisplayName = "aDisplayName"; codedType.SimpleValue = "simpleValue"; codedType.Operator = SetOperator.CONVEX_HULL; codedType.Value = BigDecimal.ONE; codedType.Translation.Add(new CodedTypeR2 <Code>()); codedType.Qualifier.Add(new CodeRole()); EncapsulatedData originalText = new EncapsulatedData(); originalText.Content = "some original text"; codedType.OriginalText = originalText; CV_R2 <Code> cv = new CV_R2Impl <Code>(codedType); string result = new CvR2PropertyFormatter().Format(GetContext("name", "CV"), cv); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(5, this.result.GetHl7Errors().Count); AssertXml("result", "<name code=\"cm\" codeSystem=\"1.2.3.4\" codeSystemName=\"aCodeSystemName\" codeSystemVersion=\"aCodeSystemVersion\" displayName=\"aDisplayName\"><originalText>some original text</originalText></name>" , StringUtils.Trim(result), true); }
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()); }
/// <inheritdoc/> public void FromDelimitedString(string delimitedString, Separators separators) { Separators seps = separators ?? new Separators().UsingConfigurationValues(); string[] segments = delimitedString == null ? Array.Empty <string>() : delimitedString.Split(seps.FieldSeparator, StringSplitOptions.None); if (segments.Length > 0) { if (string.Compare(Id, segments[0], true, CultureInfo.CurrentCulture) != 0) { throw new ArgumentException($"{ nameof(delimitedString) } does not begin with the proper segment Id: '{ Id }{ seps.FieldSeparator }'.", nameof(delimitedString)); } } PrimaryKeyValueStf = segments.Length > 1 && segments[1].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[1], false, seps) : null; StaffIdentifierList = segments.Length > 2 && segments[2].Length > 0 ? segments[2].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <ExtendedCompositeIdWithCheckDigit>(x, false, seps)) : null; StaffName = segments.Length > 3 && segments[3].Length > 0 ? segments[3].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <ExtendedPersonName>(x, false, seps)) : null; StaffType = segments.Length > 4 && segments[4].Length > 0 ? segments[4].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <CodedWithExceptions>(x, false, seps)) : null; AdministrativeSex = segments.Length > 5 && segments[5].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[5], false, seps) : null; DateTimeOfBirth = segments.Length > 6 && segments[6].Length > 0 ? segments[6].ToNullableDateTime() : null; ActiveInactiveFlag = segments.Length > 7 && segments[7].Length > 0 ? segments[7] : null; Department = segments.Length > 8 && segments[8].Length > 0 ? segments[8].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <CodedWithExceptions>(x, false, seps)) : null; HospitalServiceStf = segments.Length > 9 && segments[9].Length > 0 ? segments[9].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <CodedWithExceptions>(x, false, seps)) : null; Phone = segments.Length > 10 && segments[10].Length > 0 ? segments[10].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <ExtendedTelecommunicationNumber>(x, false, seps)) : null; OfficeHomeAddressBirthplace = segments.Length > 11 && segments[11].Length > 0 ? segments[11].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <ExtendedAddress>(x, false, seps)) : null; InstitutionActivationDate = segments.Length > 12 && segments[12].Length > 0 ? segments[12].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <DateAndInstitutionName>(x, false, seps)) : null; InstitutionInactivationDate = segments.Length > 13 && segments[13].Length > 0 ? segments[13].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <DateAndInstitutionName>(x, false, seps)) : null; BackupPersonId = segments.Length > 14 && segments[14].Length > 0 ? segments[14].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <CodedWithExceptions>(x, false, seps)) : null; EmailAddress = segments.Length > 15 && segments[15].Length > 0 ? segments[15].Split(seps.FieldRepeatSeparator, StringSplitOptions.None) : null; PreferredMethodOfContact = segments.Length > 16 && segments[16].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[16], false, seps) : null; MaritalStatus = segments.Length > 17 && segments[17].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[17], false, seps) : null; JobTitle = segments.Length > 18 && segments[18].Length > 0 ? segments[18] : null; JobCodeClass = segments.Length > 19 && segments[19].Length > 0 ? TypeSerializer.Deserialize <JobCodeClass>(segments[19], false, seps) : null; EmploymentStatusCode = segments.Length > 20 && segments[20].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[20], false, seps) : null; AdditionalInsuredOnAuto = segments.Length > 21 && segments[21].Length > 0 ? segments[21] : null; DriversLicenseNumberStaff = segments.Length > 22 && segments[22].Length > 0 ? TypeSerializer.Deserialize <DriversLicenseNumber>(segments[22], false, seps) : null; CopyAutoIns = segments.Length > 23 && segments[23].Length > 0 ? segments[23] : null; AutoInsExpires = segments.Length > 24 && segments[24].Length > 0 ? segments[24].ToNullableDateTime() : null; DateLastDmvReview = segments.Length > 25 && segments[25].Length > 0 ? segments[25].ToNullableDateTime() : null; DateNextDmvReview = segments.Length > 26 && segments[26].Length > 0 ? segments[26].ToNullableDateTime() : null; Race = segments.Length > 27 && segments[27].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[27], false, seps) : null; EthnicGroup = segments.Length > 28 && segments[28].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[28], false, seps) : null; ReactivationApprovalIndicator = segments.Length > 29 && segments[29].Length > 0 ? segments[29] : null; Citizenship = segments.Length > 30 && segments[30].Length > 0 ? segments[30].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <CodedWithExceptions>(x, false, seps)) : null; DateTimeOfDeath = segments.Length > 31 && segments[31].Length > 0 ? segments[31].ToNullableDateTime() : null; DeathIndicator = segments.Length > 32 && segments[32].Length > 0 ? segments[32] : null; InstitutionRelationshipTypeCode = segments.Length > 33 && segments[33].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[33], false, seps) : null; InstitutionRelationshipPeriod = segments.Length > 34 && segments[34].Length > 0 ? TypeSerializer.Deserialize <DateTimeRange>(segments[34], false, seps) : null; ExpectedReturnDate = segments.Length > 35 && segments[35].Length > 0 ? segments[35].ToNullableDateTime() : null; CostCenterCode = segments.Length > 36 && segments[36].Length > 0 ? segments[36].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <CodedWithExceptions>(x, false, seps)) : null; GenericClassificationIndicator = segments.Length > 37 && segments[37].Length > 0 ? segments[37] : null; InactiveReasonCode = segments.Length > 38 && segments[38].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[38], false, seps) : null; GenericResourceTypeOrCategory = segments.Length > 39 && segments[39].Length > 0 ? segments[39].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <CodedWithExceptions>(x, false, seps)) : null; Religion = segments.Length > 40 && segments[40].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[40], false, seps) : null; Signature = segments.Length > 41 && segments[41].Length > 0 ? TypeSerializer.Deserialize <EncapsulatedData>(segments[41], false, seps) : null; }
public virtual void TestParseTextNode() { XmlNode node = CreateNode("<something>this is a text node</something>"); EncapsulatedData value = (EncapsulatedData) new EdElementParser(this.telParser, true).Parse(CreateContext("ED", SpecificationVersion .R02_04_03), node, this.xmlResult).BareValue; Assert.IsTrue(this.xmlResult.IsValid()); Assert.AreEqual("this is a text node", value.Content, "signature"); }
public virtual void TestParseTrickyTextNodeThatReallyIsntText() { XmlNode node = CreateNode("<something>this is a text node<br/>with some extra<br/>formatting</something>"); EncapsulatedData value = (EncapsulatedData) new EdElementParser(this.telParser, true).Parse(CreateContext("ED", SpecificationVersion .R02_04_03), node, this.xmlResult).BareValue; Assert.IsTrue(this.xmlResult.IsValid()); Assert.AreEqual("this is a text node<br/>with some extra<br/>formatting", RemoveExtraSpaces(value.Content), "mixed text"); }
public void EncapsulatedDataShouldWriteToSetText() { EncapsulatedData data = new EncapsulatedData("It's Non-Mutable"); WrappedUiWidget widget = new WrappedUiWidget(); data.DisplayValue(widget); Assert.AreEqual("It's Non-Mutable", widget.Text); }
public virtual void TestReferenceForSKBug() { string expectedResult = "<text mediaType=\"text/html\"><reference value=\"https://pipefq.ehealthsask.ca/monograph/WPDM00002197.html\"/></text>"; EncapsulatedData data = new EncapsulatedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.HTML_TEXT, "https://pipefq.ehealthsask.ca/monograph/WPDM00002197.html" , null, null); string result = new EdPropertyFormatter().Format(GetContext("text", "ED.DOCREF"), new EDImpl <EncapsulatedData>(data)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual(expectedResult, ClearPayload(result), "something in text node"); }
public virtual void TestParseTextNodeWithCompression() { XmlNode node = CreateNode("<something mediaType=\"text/plain\" representation=\"B64\">" + TEXT_SIMPLE + "</something>"); EncapsulatedData data = (EncapsulatedData) new EdElementParser().Parse(CreateContext("ED.DOC", SpecificationVersion.V02R02 ), node, this.xmlResult).BareValue; Assert.IsTrue(this.xmlResult.IsValid()); Assert.AreEqual("This is a test", Unencode(System.Text.ASCIIEncoding.ASCII.GetBytes(data.Content)), "content"); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, data.MediaType, "media type"); }
public virtual void TestParseTextNodeNoCompression() { XmlNode node = CreateNode("<something mediaType=\"text/plain\">" + TEXT_SIMPLE_B64 + "</something>"); EncapsulatedData data = (EncapsulatedData) new EdElementParser(this.telParser, true).Parse(CreateContext("ED", SpecificationVersion .V02R02), node, this.xmlResult).BareValue; Assert.IsTrue(this.xmlResult.IsValid()); Assert.AreEqual(TEXT_SIMPLE_B64, data.Content, "content"); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, data.MediaType, "media type"); }
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 TestParseTextNode() { XmlNode node = CreateNode("<something>this is a text node</something>"); EncapsulatedData value = (EncapsulatedData) new EdElementParser().Parse(CreateContext("ED.DOCORREF", SpecificationVersion. R02_04_03), node, this.xmlResult).BareValue; Assert.IsFalse(this.xmlResult.IsValid()); Assert.AreEqual(2, this.xmlResult.GetHl7Errors().Count); // must provide specializationType and mediaType Assert.AreEqual("this is a text node", value.Content, "signature"); }
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 ")); }
private void RenderText(EncapsulatedData text) { if (text == null) { Console.WriteLine("(none)"); } else { Console.WriteLine(text.Content); } }
public virtual void TestMissingReference() { string expectedResult = "<text mediaType=\"text/html\"/>"; EncapsulatedData data = new EncapsulatedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.HTML_TEXT, null , null, null); string result = new EdPropertyFormatter().Format(GetContext("text", "ED.DOCREF"), new EDImpl <EncapsulatedData>(data)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual(expectedResult, ClearPayload(result), "something in text node"); }
public virtual void TestFormatValueReservedXmlChars() { string expectedResult = "<name mediaType=\"text/plain\"><cats think they're > humans & dogs 99% of the time/></name>" + SystemUtils.LINE_SEPARATOR; EncapsulatedData ed = new EncapsulatedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, null , null, System.Text.ASCIIEncoding.ASCII.GetBytes("<cats think they're > humans & dogs 99% of the time/>")); string result = new EdPropertyFormatter().Format(GetContext("name", "ED.DOC"), new EDImpl <EncapsulatedData>(ed)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", expectedResult.Trim(), result.Trim(), true); }
public virtual void TestReferenceWithContent() { string expectedResult = "<text mediaType=\"text/plain\"><reference value=\"https://pipefq.ehealthsask.ca/monograph/WPDM00002197.html\"/>this is some text</text>"; EncapsulatedData data = new EncapsulatedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, "https://pipefq.ehealthsask.ca/monograph/WPDM00002197.html", null, System.Text.ASCIIEncoding.ASCII.GetBytes("this is some text" )); string result = new EdPropertyFormatter().Format(GetContext("text", "ED.DOC"), new EDImpl <EncapsulatedData>(data)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual(expectedResult, ClearPayload(result), "something in text node"); }
public virtual void TestIncorrectMediaTypeFailingConstraint() { EncapsulatedData ed = CreateEd(true, true, Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.HL7_CDA); ConstrainedDatatype constraints = CreateConstraints(true); this.constraintsHandler.HandleConstraints(constraints, ed, this.errorLogger); Assert.IsFalse(this.errors.IsEmpty()); Assert.AreEqual(1, this.errors.Count); Assert.AreEqual(Hl7ErrorCode.CDA_FIXED_CONSTRAINT_MISSING, this.errors[0].GetHl7ErrorCode()); Assert.IsTrue(this.errors[0].GetMessage().Contains(" mediaType ")); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.HL7_CDA, ed.MediaType); }
public virtual void TestParseManyChildTextNodesAllowed() { XmlNode node = CreateNode("<something>" + "<monkey/>" + "<shines/>" + "<through/>" + "</something>"); EncapsulatedData data = (EncapsulatedData) new EdElementParser(this.telParser, true).Parse(CreateContext("ED", SpecificationVersion .V02R02), node, this.xmlResult).BareValue; Assert.IsTrue(this.xmlResult.IsValid()); Assert.IsNotNull(data); Assert.IsNotNull(data.Content); AssertXml("content", "<monkey/>" + Runtime.GetProperty("line.separator") + "<shines/>" + Runtime.GetProperty("line.separator" ) + "<through/>", RemoveExtraSpaces(data.Content)); }
// for newer format of "reference" usage public virtual void DoValidate(EncapsulatedData ed, string specializationType, Hl7BaseVersion baseVersion, string type, string propertyPath, Hl7Errors errors) { Compression compression = ed.Compression; bool hasCompression = (compression != null); int contentSize = (ed.HasContent() ? 1 : 0); string representation = (ed.Representation == null ? null : ed.Representation.Name); bool hasReference = (ed.ReferenceObj != null); DoValidate(specializationType, compression, hasCompression, ed.MediaType, ed.Language, representation, hasReference, ed.HasContent (), contentSize, baseVersion, type, null, propertyPath, errors); }
public virtual void TestEverythingSpecified() { CodedTypeR2 <Code> translation1 = new CodedTypeR2 <Code>(); translation1.Code = CeRxDomainTestValues.KILOGRAM; CodedTypeR2 <Code> translation2 = new CodedTypeR2 <Code>(); translation2.Code = CeRxDomainTestValues.FLUID_OUNCE; CodedTypeR2 <Code> name1 = new CodedTypeR2 <Code>(); name1.Code = CeRxDomainTestValues.CENTIMETRE; CodedTypeR2 <Code> name2 = new CodedTypeR2 <Code>(); name2.Code = Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE; CodedTypeR2 <Code> value1 = new CodedTypeR2 <Code>(); value1.Code = Ca.Infoway.Messagebuilder.Domainvalue.Controlact.ActStatus.NORMAL; CodedTypeR2 <Code> value2 = new CodedTypeR2 <Code>(); value2.Code = Ca.Infoway.Messagebuilder.Domainvalue.Controlact.ActClass.ACT; CodeRole codeRole1 = new CodeRole(name1, value1, true); CodeRole codeRole2 = new CodeRole(name2, value2, true); CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); codedType.Code = CeRxDomainTestValues.CENTIMETRE; codedType.CodeSystemName = "aCodeSystemName"; codedType.CodeSystemVersion = "aCodeSystemVersion"; codedType.DisplayName = "aDisplayName"; codedType.SimpleValue = "simpleValue"; codedType.Operator = SetOperator.CONVEX_HULL; codedType.Value = BigDecimal.ONE; codedType.Operator = SetOperator.INTERSECT; codedType.Qualifier.Add(codeRole1); codedType.Qualifier.Add(codeRole2); codedType.Translation.Add(translation1); codedType.Translation.Add(translation2); codedType.Qty = 1122; EncapsulatedData originalText = new EncapsulatedData(); originalText.Content = "some original text"; codedType.OriginalText = originalText; BXIT <CodedTypeR2 <Code> > sxcm_cd = new BXITImpl <CodedTypeR2 <Code> >(codedType); string result = new BxitCdR2PropertyFormatter().Format(GetContext("name", "BXIT<CD>"), sxcm_cd); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(3, this.result.GetHl7Errors().Count); AssertXml("result", "<name code=\"cm\" codeSystem=\"1.2.3.4\" codeSystemName=\"aCodeSystemName\" codeSystemVersion=\"aCodeSystemVersion\" displayName=\"aDisplayName\" qty=\"1122\">" + "<originalText>some original text</originalText>" + "<qualifier inverted=\"true\"><name code=\"cm\" codeSystem=\"1.2.3.4\"/><value code=\"normal\" codeSystem=\"2.16.840.1.113883.5.14\" displayName=\"Normal\"/></qualifier>" + "<qualifier inverted=\"true\"><name code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\" displayName=\"Male\"/><value code=\"ACT\" codeSystem=\"2.16.840.1.113883.5.6\" displayName=\"Act\"/></qualifier>" + "<translation code=\"kg\" codeSystem=\"1.2.3.4\"/>" + "<translation code=\"[foz_br]\" codeSystem=\"1.2.3.4\"/>" + "</name>" , StringUtils.Trim(result), true); }
public virtual void TestMustHaveOneOfRefOrContentForCerxEdDocOrRef() { XmlNode node = CreateNode("<something mediaType=\"text/plain\"></something>"); EncapsulatedData value = (EncapsulatedData) new EdElementParser().Parse(CreateContext("ED.DOCORREF", SpecificationVersion. V01R04_3), node, this.xmlResult).BareValue; Assert.IsFalse(this.xmlResult.IsValid()); Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count); Assert.IsNull(value.Content, "no text returned"); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, value.MediaType, "proper media type returned" ); Assert.IsNull(value.Reference, "no reference"); }
public virtual void TestParseRepresentationValidTXTWithEscapedValues() { XmlNode node = CreateNode("<something representation=\"TXT\" compression=\"DF\" mediaType=\"text/plain\">text value<br/>with some<br/>escaped characters;</something>" ); EncapsulatedData value = (EncapsulatedData) new EdElementParser(this.telParser, true).Parse(CreateContext("ED", SpecificationVersion .R02_04_03), node, this.xmlResult).BareValue; Assert.IsTrue(this.xmlResult.IsValid()); Assert.AreEqual("text value<br/>with some<br/>escaped characters;", value.Content, "proper text returned"); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, value.MediaType, "proper media type returned" ); Assert.IsNull(value.ReferenceObj, "no reference"); }
public virtual void TestParseTextCommentsCdataAndElements() { XmlNode node = CreateNode("<text>\n" + " this is some text\n"+ " <![CDATA[& this is some > CDATA text]]>\n" + " <!-- with a comment -->\n" + " <table xmlns:fred=\"urn:hl7-org:fred\">\n"+ " <thead>\n"+ " <tr>\n"+ " <th>and some html</th>\n"+ " </tr>\n" + " </thead>\n"+ " </table>\n"+ "</text>\n"); EncapsulatedData value = (EncapsulatedData) new EdElementParser(this.telParser, true).Parse(CreateContext("ED", SpecificationVersion .R02_04_03), node, this.xmlResult).BareValue; Assert.IsTrue(this.xmlResult.IsValid()); AssertXml("mixed text", "this is some text\n" + "\t& this is some > CDATA text\n" + "<!-- with a comment -->\n" + "<table xmlns:fred=\"urn:hl7-org:fred\">\n" + "<thead>\n" + "<tr>\n" + "<th>and some html</th>\n" + "</tr>\n" + "</thead>\n" + "</table>\n", value.Content, false); }
public virtual void TestParseFailsDueToMissingReference() { XmlNode node = CreateNode("<something compression=\"DF\" mediaType=\"text/plain\"/>"); EncapsulatedData value = (EncapsulatedData) new EdElementParser().Parse(CreateContext("ED.DOCREF", SpecificationVersion.R02_04_03 ), node, this.xmlResult).BareValue; Assert.IsFalse(this.xmlResult.IsValid()); Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count); Assert.IsNull(value.Content, "nor text returned"); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, value.MediaType, "proper media type returned" ); Assert.IsNull(value.Reference, "no reference returned"); }
public virtual void TestParseTxtButSentWithB64() { string content = "text value should be b64 encoded"; XmlNode node = CreateNode("<something representation=\"B64\" compression=\"DF\" mediaType=\"text/plain\">" + content + "</something>" ); EncapsulatedData value = (EncapsulatedData) new EdElementParser(this.telParser, true).Parse(CreateContext("ED", SpecificationVersion .R02_04_03), node, this.xmlResult).BareValue; Assert.IsTrue(this.xmlResult.IsValid()); Assert.AreEqual("text value should be b64 encoded", value.Content, "proper text returned"); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, value.MediaType, "proper media type returned" ); Assert.IsNull(value.ReferenceObj, "no reference"); }