public virtual void TestUsesForMr2009() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Steve Shaw")); string result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_03), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"L\">Steve Shaw</name>", result, true); this.result.ClearErrors(); personName.Uses.Clear(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.PSEUDONYM); result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_03), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"P\">Steve Shaw</name>", result, true); this.result.ClearErrors(); personName.Uses.Clear(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LICENSE); result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_03), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"C\">Steve Shaw</name>", result, true); this.result.ClearErrors(); personName.Uses.Clear(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.OFFICIAL_REGISTRY); result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_03), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"OR\">Steve Shaw</name>", result, true); }
public virtual void TestFormatValueNonNullWithMultipleUses() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.PSEUDONYM); personName.AddNamePart(new EntityNamePart("Steve Shaw")); string result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"L P\">Steve Shaw</name>", result.Trim(), true); }
public virtual void TestFormatSimpleNoParts() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); string result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"L\"></name>", result, true); }
public virtual void TestFormatSearchNoParts() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); string result = formatter.Format(GetContext("name", "PN.SEARCH", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual("<name use=\"L\"></name>", result.Trim(), "something in text node"); }
public virtual void TestBasicForCeRxWithSimpleName() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Steve Shaw", null)); string result = formatter.Format(GetContext("name", "PN.BASIC", SpecificationVersion.V01R04_3), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name use=\"L\">Steve Shaw</name>", result.Trim(), "something in text node"); }
public virtual void TestBasicForCeRxWithMultipleNameParts() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Steve", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("Shaw", PersonNamePartType.FAMILY)); string result = formatter.Format(GetContext("name", "PN", SpecificationVersion.V01R04_3), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"L\"><given>Steve</given><family>Shaw</family></name>", result, true); }
public virtual void TestUsesForCeRx() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Steve Shaw")); string result = formatter.Format(GetContext("name", "PN.SIMPLE", SpecificationVersion.V01R04_3), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name use=\"L\">Steve Shaw</name>", result.Trim(), "something in text node"); this.result.ClearErrors(); personName.Uses.Clear(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.PSEUDONYM); result = formatter.Format(GetContext("name", "PN.SIMPLE", SpecificationVersion.V01R04_3), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name use=\"P\">Steve Shaw</name>", result.Trim(), "something in text node"); this.result.ClearErrors(); personName.Uses.Clear(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LICENSE); result = formatter.Format(GetContext("name", "PN.SIMPLE", SpecificationVersion.V01R04_3), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual("<name use=\"C\">Steve Shaw</name>", result.Trim(), "something in text node"); this.result.ClearErrors(); personName.Uses.Clear(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.HEALTH_CARD); result = formatter.Format(GetContext("name", "PN.SIMPLE", SpecificationVersion.V01R04_3), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual("<name use=\"HC\">Steve Shaw</name>", result.Trim(), "something in text node"); this.result.ClearErrors(); personName.Uses.Clear(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.OFFICIAL_REGISTRY); result = formatter.Format(GetContext("name", "PN.SIMPLE", SpecificationVersion.V01R04_3), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual("<name use=\"OR\">Steve Shaw</name>", result.Trim(), "something in text node"); }
public virtual void TestFormatValueMaxLengthCeRx() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("123456789012345678901234567890", PersonNamePartType.FAMILY)); string result = formatter.Format(GetContext("name", "PN.BASIC", SpecificationVersion.V01R04_3), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name use=\"L\"><family>123456789012345678901234567890</family></name>", result.Trim(), "something in text node" ); }
public virtual void TestFormatValueReservedXmlChars() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("<cats tk they're > humans & dogs 99% of the time/>")); string result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"L\"><cats tk they're > humans & dogs 99% of the time/></name>" , result, true); }
public virtual void TestFormatValueNonNullWithQualifierMr2009() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Shaw", PersonNamePartType.FAMILY, Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNamePartQualifier .INITIAL)); string result = formatter.Format(GetContext("name", "PN.BASIC", SpecificationVersion.R02_04_03), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name use=\"L\"><family qualifier=\"IN\">Shaw</family></name>", result.Trim(), "something in text node"); }
public virtual void TestFormatValueNonNullWithQualifier() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Shaw", PersonNamePartType.FAMILY, Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNamePartQualifier .BIRTH)); string result = formatter.Format(GetContext("name", "PN", SpecificationVersion.V02R02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"L\"><family qualifier=\"BR\">Shaw</family></name>", result, true); }
public virtual void TestFormatSimpleWithMoreOneNonSimplePart() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Steve Shaw", PersonNamePartType.FAMILY)); string result = formatter.Format(GetContext("name", "PN.SIMPLE", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual("<name use=\"L\"><family>Steve Shaw</family></name>", result.Trim(), "something in text node"); }
public virtual void TestFormatValueInvalidPartType() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("namegoeshere", PersonNamePartType.DELIMITER)); string result = formatter.Format(GetContext("name", "PN.BASIC", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); // part type not allowed Assert.AreEqual("<name use=\"L\"><delimiter>namegoeshere</delimiter></name>", result.Trim(), "something in text node"); }
public virtual void TestFormatValueNonNullWithInvalidQualifierCeRx() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Shaw", PersonNamePartType.FAMILY, Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNamePartQualifier .BIRTH)); string result = formatter.Format(GetContext("name", "PN.BASIC", SpecificationVersion.V01R04_3), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual("<name use=\"L\"><family qualifier=\"BR\">Shaw</family></name>", result.Trim(), "something in text node"); }
public virtual void TestFormatValueReservedXmlCharsTooLong() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("<cats think they're > humans & dogs 99% of the time/>")); string result = formatter.Format(GetContext("name", "PN.SIMPLE", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual("<name use=\"L\"><cats think they're > humans & dogs 99% of the time/></name>".Trim(), result.Trim(), "something in text node"); }
public virtual void TestFormatSimpleWithMoreThanOneSimplePart() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Steve")); personName.AddNamePart(new EntityNamePart("Shaw")); string result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); System.Console.Out.WriteLine(result); Assert.AreEqual("<name use=\"L\">" + SystemUtils.LINE_SEPARATOR + " Steve" + SystemUtils.LINE_SEPARATOR + " Shaw" + SystemUtils .LINE_SEPARATOR + "</name>" + SystemUtils.LINE_SEPARATOR, result, "something in text node"); }
public virtual void TestFormatValueInvalidLength() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("123456789012345678901234567890123456789012345678901", PersonNamePartType.FAMILY )); string result = formatter.Format(GetContext("name", "PN.BASIC", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); // max length + 1 Assert.AreEqual("<name use=\"L\"><family>123456789012345678901234567890123456789012345678901</family></name>", result.Trim (), "something in text node"); }
public virtual void TestFormatSimpleWithTwoNonSimpleParts() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("Steve", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("Shaw", PersonNamePartType.FAMILY)); string result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name use=\"L\">" + SystemUtils.LINE_SEPARATOR + " <given>Steve</given>" + SystemUtils.LINE_SEPARATOR + " <family>Shaw</family>" + SystemUtils.LINE_SEPARATOR + "</name>" + SystemUtils.LINE_SEPARATOR, result, "formatted text node" ); AssertXml("something in text node", "<name use=\"L\"><given>Steve</given><family>Shaw</family></name>", result, true); }
public virtual void TestFormatValueNonNullMultipleNameParts() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("prefix", PersonNamePartType.PREFIX, Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNamePartQualifier .INITIAL)); personName.AddNamePart(new EntityNamePart("given1", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("given2", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("given3", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("given4", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("family", PersonNamePartType.FAMILY)); personName.AddNamePart(new EntityNamePart("suffix", PersonNamePartType.SUFFIX, Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNamePartQualifier .INITIAL)); string result = formatter.Format(GetContext("name", "PN", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("well formed name", "<name use=\"L\"><prefix qualifier=\"IN\">prefix</prefix><given>given1</given><given>given2</given><given>given3</given><given>given4</given><family>family</family><suffix qualifier=\"IN\">suffix</suffix></name>" , result, true); }
public virtual void TestFormatValueTooManyNameParts() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); personName.AddNamePart(new EntityNamePart("prefix", PersonNamePartType.PREFIX, Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNamePartQualifier .INITIAL)); personName.AddNamePart(new EntityNamePart("given1", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("given2", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("given3", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("given4", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("given5", PersonNamePartType.GIVEN)); personName.AddNamePart(new EntityNamePart("family", PersonNamePartType.FAMILY)); personName.AddNamePart(new EntityNamePart("suffix", PersonNamePartType.SUFFIX, Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNamePartQualifier .INITIAL)); string result = formatter.Format(GetContext("name", "PN.BASIC", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); // too many parts Assert.AreEqual("<name use=\"L\"><prefix qualifier=\"IN\">prefix</prefix><given>given1</given><given>given2</given><given>given3</given><given>given4</given><given>given5</given><family>family</family><suffix qualifier=\"IN\">suffix</suffix></name>" , result.Trim(), "well formed name"); }