public virtual void TestFormatValueNull() { string result = new PnPropertyFormatter().Format(GetContext("name", "PN.BASIC", SpecificationVersion.R02_04_02), new PNImpl ()); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name nullFlavor=\"NI\"/>", result.Trim(), "named null format"); }
public virtual void TestFormatBasicNoParts() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse.LEGAL); string result = formatter.Format(GetContext("name", "PN.BASIC", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name use=\"L\"></name>", result.Trim(), "something in text node"); }
public virtual void TestFormatValueNonNullNoUse() { PnPropertyFormatter formatter = new PnPropertyFormatter(); PersonName personName = new PersonName(); personName.AddNamePart(new EntityNamePart("Steve Shaw")); 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>Steve Shaw</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 TestFormatValueReservedXmlChars() { PnPropertyFormatter formatter = new PnPropertyFormatter(); 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.SIMPLE", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name use=\"L\"><cats tk they're > humans & dogs 99% of the time/></name>".Trim(), 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 TestFormatValueNonNullWithQualifierMr2009Full() { 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.FULL", SpecificationVersion.R02_04_03), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.AreEqual("<name use=\"L\"><family qualifier=\"BR\">Shaw</family></name>", result.Trim(), "something in text node"); }
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 TestFormatValueNonNullWithMultipleUses() { PnPropertyFormatter formatter = new PnPropertyFormatter(); 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.SIMPLE", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); Assert.IsTrue("<name use=\"P L\">Steve Shaw</name>".Equals(result.Trim()) || "<name use=\"L P\">Steve Shaw</name>".Equals (result.Trim()), "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 TestFormatValueNonNullMultipleNameParts() { 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("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.IsTrue(this.result.IsValid()); Assert.AreEqual("<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.Trim(), "well formed name"); }
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"); }