Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        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");
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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");
        }
Ejemplo n.º 8
0
        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"
                            );
        }
Ejemplo n.º 9
0
        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\">&lt;cats tk they&apos;re &gt; humans &amp; dogs 99% of the time/&gt;</name>"
                      , result, true);
        }
Ejemplo n.º 10
0
        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");
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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");
        }
Ejemplo n.º 13
0
        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");
        }
Ejemplo n.º 14
0
        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");
        }
Ejemplo n.º 15
0
        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\">&lt;cats think they&apos;re &gt; humans &amp; dogs 99% of the time/&gt;</name>".Trim(),
                            result.Trim(), "something in text node");
        }
Ejemplo n.º 16
0
        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");
        }
Ejemplo n.º 17
0
        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");
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        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");
        }