/// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception> private void HandlePersonName(XmlToModelResult xmlToModelResult, PersonName result, XmlNodeList childNodes) { foreach (XmlNode childNode in new XmlNodeListIterable(childNodes)) { if (childNode is XmlElement) { XmlElement element = (XmlElement)childNode; string name = NodeUtil.GetLocalOrTagName(element); string value = GetTextValue(element, xmlToModelResult); string qualifierString = GetAttributeValue(element, NAME_PART_TYPE_QUALIFIER); EntityNamePartQualifier qualifier = CodeResolverRegistry.Lookup <EntityNamePartQualifier>(qualifierString); if (StringUtils.IsNotBlank(value)) { result.AddNamePart(new EntityNamePart(value, GetPersonalNamePartType(name), qualifier)); } } else { //GN: Added in fix similar to what was done for AD.BASIC. Issue with XML containing mixture of elements and untyped text nodes. if (IsNonBlankTextNode(childNode)) { // validation will catch if this type does not allow for a free-form name result.AddNamePart(new EntityNamePart(childNode.Value.Trim(), null)); } } } }
public virtual void TestFormatValuePersonName() { EnPropertyFormatter formatter = new EnPropertyFormatter(); PersonName name = new PersonName(); name.AddNamePart(new EntityNamePart("prefix", PersonNamePartType.PREFIX)); name.AddNamePart(new EntityNamePart("given", PersonNamePartType.GIVEN)); Assert.AreEqual("<x xsi:type=\"PN\"><prefix>prefix</prefix><given>given</given></x>", formatter.Format(GetContext("x"), new ENImpl <EntityName>(name)).Trim(), "PersonName uses PN formatter"); }
public virtual void TestFormatSimpleWithMixedParts() { 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", PersonNamePartType.FAMILY)); 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\">Steve<family>Shaw</family></name>", result, true); }
public virtual void TestBasicForCeRxWithSimpleNameInvalidMixedParts() { PnPropertyFormatter formatter = new PnPropertyFormatter(); 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", null)); 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\"><given>Steve</given>Shaw</name>", result.Trim(), "something in text node"); }
public virtual void TestFormatSimpleWithMoreThanOneSimplePart() { PnPropertyFormatter formatter = new PnPropertyFormatter(); 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.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\">SteveShaw</name>", result.Trim(), "something in text node"); }
private static AuthorBean CreateAuthorV01() { AuthorBean result = new AuthorBean(); result.Time = DateUtil.GetDate(2008, 8, 18, 18, 18, 0, 0); result.Id = new Identifier("2.16.840.1.113883.4.267", "EHR ID EXT"); result.SetLicenseNumber(new Identifier("2.16.840.1.113883.4.268", "55555")); // I'm a little unhappy about this. The data setup seems too HL7-y. Would it be better to retain the PersonNameBean and the adaptor? PersonName name = new PersonName(); name.AddNamePart(new EntityNamePart("Jane", PersonNamePartType.GIVEN)); name.AddNamePart(new EntityNamePart("Doe", PersonNamePartType.FAMILY)); result.SetName(name); return(result); }
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"); }
protected CreatedBy_1 CreateAuthor_1() { CreatedBy_1 author = new CreatedBy_1(); author.Time = new PlatformDate(); Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Common.Coct_mt090102ca.HealthcareWorker authorPerson = new Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Common.Coct_mt090102ca.HealthcareWorker(); Identifier healthcareProviderId = new Identifier( "2.16.840.1.113883.3.19.3.163.1.2", "200202888"); PersonName pn = PersonName.CreateFirstNameLastName("Samantha", "Black"); EntityNamePart prefix = new EntityNamePart("Dr.", PersonNamePartType.PREFIX); pn.Uses.Add(EntityNameUse.LEGAL); pn.AddNamePart(prefix); Identifier id = new Identifier("2.16.840.1.113883.3.19.3.163.77.1", "samantha.black"); authorPerson.AssignedPerson = new ActingPerson(); authorPerson.AssignedPerson.AsHealthCareProviderId = healthcareProviderId; authorPerson.AssignedPerson.Name = pn; authorPerson.Id.Add(id); author.AuthorPerson = authorPerson; return(author); }
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 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 TestFormatValueNonNullNoUse() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); PersonName personName = new PersonName(); 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>Steve Shaw</name>", result, true); }
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 TestFormatValueWithDelimiterPartType() { EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); 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", SpecificationVersion.R02_04_02), new PNImpl(personName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name use=\"L\"><delimiter>namegoeshere</delimiter></name>", result, true); }
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 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 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 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 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 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 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 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 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"); }
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); }