Ejemplo n.º 1
0
        public void R2ADBasicSerializationTest()
        {
            String expectedXml = @"<test xmlns=""urn:hl7-org:v3""><part value=""1050 Wishard Blvd""/><part type=""DEL""/></test>";
            String actualXml   = R2SerializationHelper.SerializeAsString(AD.CreateAD(new ADXP("1050 Wishard Blvd"), new ADXP(null, AddressPartType.Delimiter)));

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Ejemplo n.º 2
0
        public void R2ADBasicPartTypesSerializationTest()
        {
            String expectedXml = @"<test xmlns=""urn:hl7-org:v3""><part type=""AL"" value=""1050 Wishard Blvd""/><part type=""AL"" value=""RG 5th Floor""/><part type=""STA"" value=""Ontario""/></test>";
            String actualXml   = R2SerializationHelper.SerializeAsString(AD.CreateAD(new ADXP("1050 Wishard Blvd", AddressPartType.AddressLine), new ADXP("RG 5th Floor", AddressPartType.AddressLine), new ADXP("Ontario", AddressPartType.State)));

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Ejemplo n.º 3
0
        public void EV_1087Test()
        {
            RelatedPerson person = new RelatedPerson(
                SET <PN> .CreateSET(new PN(EntityNameUse.Legal, "John Smith")),
                SET <TEL> .CreateSET((TEL)"mailto:[email protected]"),
                "F",
                DateTime.Now,
                DateTime.Today,
                SET <AD> .CreateSET(AD.CreateAD(PostalAddressUse.Direct, new ADXP("123 Main Street West, Hamilton, ON"))),
                null);

            person.DeceasedInd = true;

            // This fails
            try
            {
                XmlIts1Formatter fmtr = new XmlIts1Formatter();
                fmtr.Settings = SettingsType.DefaultLegacy;
                fmtr.GraphAides.Add(new DatatypeFormatter());
                StringWriter sw = new StringWriter();
                using (XmlStateWriter writer = new XmlStateWriter(XmlWriter.Create(sw)))
                {
                    writer.WriteStartElement("test", "urn:hl7-org:v3");
                    fmtr.Graph(writer, person);
                    writer.WriteEndElement();
                }
            }
            catch (Exception ex)
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 4
0
        public void R2ADBasicPartTypesParseTest()
        {
            var    adi       = AD.CreateAD(new ADXP("1050 Wishard Blvd", AddressPartType.AddressLine), new ADXP("RG 5th Floor", AddressPartType.AddressLine), new ADXP("Ontario", AddressPartType.State));
            String actualXml = R2SerializationHelper.SerializeAsString(adi);
            var    ad2       = R2SerializationHelper.ParseString <AD>(actualXml);

            Assert.AreEqual(adi, ad2);
        }
Ejemplo n.º 5
0
        public void R2ADBasicParseTest()
        {
            var    adi       = AD.CreateAD(new ADXP("1050 Wishard Blvd"), new ADXP(null, AddressPartType.Delimiter));
            String actualXml = R2SerializationHelper.SerializeAsString(adi);
            var    ad2       = R2SerializationHelper.ParseString <AD>(actualXml);

            Assert.AreEqual(adi, ad2);
        }
Ejemplo n.º 6
0
        public void R2ADNullFlavorSerializationTest()
        {
            String expectedXml = @"<test xmlns=""urn:hl7-org:v3"" nullFlavor=""NI""/>";
            var    adi         = AD.CreateAD(new ADXP("1050 Wishard Blvd", AddressPartType.AddressLine), new ADXP("RG 5th Floor", AddressPartType.AddressLine), new ADXP("Ontario", AddressPartType.State));

            adi.NullFlavor = NullFlavor.NoInformation;
            String actualXml = R2SerializationHelper.SerializeAsString(adi);

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Ejemplo n.º 7
0
        public void FormatPatient()
        {
            // Create a formatter with a graph aide
            XmlIts1Formatter fmtr = new XmlIts1Formatter();

            // Gets or sets a list of aide formatters
            // that assist in the formatting of this instance
            fmtr.GraphAides.Add(new DatatypeFormatter());

            // Format to a string
            StringWriter   sw    = new StringWriter();
            XmlStateWriter xmlSw = new XmlStateWriter(
                XmlWriter.Create(sw, new XmlWriterSettings()
            {
                Indent = true
            })
                );

            // Call our method here...
            var patient = Utils.CreatePatient(
                Guid.NewGuid(),
                EN.CreateEN(EntityNameUse.Legal,
                            new ENXP("John", EntityNamePartType.Given),
                            new ENXP("Smith", EntityNamePartType.Family)
                            ),
                AD.CreateAD(PostalAddressUse.HomeAddress,
                            "123 Main Street West",
                            "Hamilton",
                            "Ontario",
                            "Canada"
                            ),
                "*****@*****.**"
                );

            // Format to the formatter.
            // Details results in a result code
            //  that indicates the outcome of the graph.
            var details = fmtr.Graph(xmlSw, patient);

            // Flush and close
            xmlSw.Close();

            // Output to console
            Console.WriteLine("XML: ");
            Console.WriteLine(sw.ToString());
            Console.WriteLine("Validation:");
            foreach (var dtl in details.Details)
            {
                Console.WriteLine("{0} : {1}", dtl.Type, dtl.Message);
            }
        }
Ejemplo n.º 8
0
        public void R2ADLineLevelParseTest()
        {
            var adi = AD.CreateAD(
                SET <PostalAddressUse> .CreateSET(PostalAddressUse.WorkPlace, PostalAddressUse.Direct),
                new ADXP("1050 W Wishard Blvd", AddressPartType.StreetAddressLine),
                new ADXP("RG 5th floor", AddressPartType.AdditionalLocator),
                new ADXP("Indianapolis", AddressPartType.City),
                new ADXP("IN", AddressPartType.State),
                new ADXP("46240", AddressPartType.PostalCode)
                );
            String actualXml = R2SerializationHelper.SerializeAsString(adi);
            var    ad2       = R2SerializationHelper.ParseString <AD>(actualXml);

            Assert.AreEqual(adi, ad2);
        }
Ejemplo n.º 9
0
        public void R2ADISO3166SerializationTest()
        {
            String expectedXml = @"<test xmlns=""urn:hl7-org:v3""><part type=""STR"" value=""Windsteiner Weg""/><part type=""BNR"" value=""54a""/><part type=""CNT"" code=""DEU"" codeSystem=""1.0.3166.1.2"" value=""D""/></test>";
            var    adi         = AD.CreateAD(
                new ADXP("Windsteiner Weg", AddressPartType.StreetName),
                new ADXP("54a", AddressPartType.BuildingNumber),
                new ADXP("D", AddressPartType.Country)
            {
                CodeSystem = "1.0.3166.1.2", Code = "DEU"
            }
                );
            String actualXml = R2SerializationHelper.SerializeAsString(adi);

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Ejemplo n.º 10
0
        public void R2ADLineLevelSerializationTest()
        {
            String expectedXml = @"<test xmlns=""urn:hl7-org:v3"" use=""WP DIR""><part type=""SAL"" value=""1050 W Wishard Blvd""/><part type=""ADL"" value=""RG 5th floor""/><part type=""CTY"" value=""Indianapolis""/><part type=""STA"" value=""IN""/><part type=""ZIP"" value=""46240""/></test>";
            var    adi         = AD.CreateAD(
                SET <PostalAddressUse> .CreateSET(PostalAddressUse.WorkPlace, PostalAddressUse.Direct),
                new ADXP("1050 W Wishard Blvd", AddressPartType.StreetAddressLine),
                new ADXP("RG 5th floor", AddressPartType.AdditionalLocator),
                new ADXP("Indianapolis", AddressPartType.City),
                new ADXP("IN", AddressPartType.State),
                new ADXP("46240", AddressPartType.PostalCode)
                );
            String actualXml = R2SerializationHelper.SerializeAsString(adi);

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Ejemplo n.º 11
0
        public void R2ADISO3166ParseTest()
        {
            var adi = AD.CreateAD(
                SET <PostalAddressUse> .CreateSET(PostalAddressUse.WorkPlace, PostalAddressUse.Direct),
                new ADXP("Windsteiner Weg", AddressPartType.StreetName),
                new ADXP("54a", AddressPartType.BuildingNumber),
                new ADXP("D", AddressPartType.Country)
            {
                CodeSystem = "1.0.3166.1.2", Code = "DEU"
            }
                );
            String actualXml = R2SerializationHelper.SerializeAsString(adi);
            var    ad2       = R2SerializationHelper.ParseString <AD>(actualXml);

            Assert.AreEqual(adi, ad2);
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            ClinicalDocument cda = new ClinicalDocument();

            cda.MoodCode   = null;
            cda.ClassCode  = null;
            cda.TypeId     = II.CreatePublic("2.16.840.1.113883.1.3", "POCD_HD000040");
            cda.TemplateId = LIST <II> .CreateList(
                new II("2.16.840.1.113883.3.4424.13.10.1.1"),
                new II("2.16.840.1.113883.3.4424.13.10.1.2"),
                new II("2.16.840.1.113883.3.4424.13.10.1.3", "1.1.1"));

            cda.Id = new II("2.16.840.1.113883.3.4424.7.2.1", "2345678")
            {
                Displayable = true
            };
            var pi = new PertinentInformation()
            {
                TemplateId = LIST <II> .CreateList(new II("1.13.2.3"))
            };

            pi.CoveragePlan = new CoveragePlan(new CD <String>("PUBLICPOL", "2.16.840.1.113883.11.19350"));
            pi.CoveragePlan.Code.Qualifier = LIST <CR <String> > .CreateList(
                new CR <String>(
                    new CV <String>("RLEKUD", "1.2.3.4", null, null, "Refundacja ...", null),
                    new CD <String>("IB", "1.2.3.4")
                    )
                );

            //cda.DataEnterer = new MyDataEnterer();
            //cda.PertinentInformation.Add(pi);
            cda.RecordTarget.Add(new RecordTarget {
                PatientRole = new PatientRole()
            });
            cda.RecordTarget[0].PatientRole.Addr = SET <AD> .CreateSET(AD.CreateAD(new ADXPPL("Kiszka", AddressPartType.PostalCode)
            {
                PostCity = "PT"
            }));

            XmlIts1Formatter xftr = new XmlIts1Formatter();

            //xftr.AddFormatterAssembly(Assembly.GetExecutingAssembly());
            xftr.GraphAides.Add(new ClinicalDocumentDatatypeFormatter());
            xftr.ValidateConformance = false;
            xftr.RegisterXSITypeName("POCD_MT000040UV.ClinicalDocument", typeof(ClinicalDocument));
            xftr.Settings |= SettingsType.AlwaysCheckForOverrides;


            using (XmlStateWriter xw = new XmlStateWriter(XmlWriter.Create(Console.Out, new XmlWriterSettings()
            {
                Indent = true
            })))
            {
                xw.WriteStartElement("", "ClinicalDocument", "urn:hl7-org:v3");
                xw.WriteAttributeString("xmlns", "extPL", null, "http://www.csioz.gov.pl/xsd/extPL/r1");
                xw.WriteAttributeString("xmlns", "xsi", null, XmlIts1Formatter.NS_XSI);
                //xw.WriteAttributeString("xsi", "type", XmlIts1Formatter.NS_XSI, "extPL:ClinicalDocument");

                xftr.Graph(xw, cda);
                xw.WriteEndElement();
            }



            PatientData pat = new PatientData()
            {
                Address     = "123 Main Street West",
                City        = "Hamilton",
                DateOfBirth = new DateTime(1995, 04, 03),
                FamilyName  = "Smith",
                Gender      = "F",
                GivenName   = "Sarah",
                Id          = "102-30343",
                OtherIds    = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("2.16.2.3.2.3.2.4", "123-231-435")
                },
                State = "ON"
            };

            PhysicianData aut = new PhysicianData()
            {
                AddressLine   = " 35 King Street West ",
                City          = " Hamilton ",
                OrgId         = " 123 - 1221 ",
                OrgName       = new[] { " Good Health Clinics " },
                PhysicianId   = " 1023433 - ON ",
                PhysicianName = new string[] { " Dr.", " Francis ", " F ", " Family " },
                Postal        = "L0R2A0"
            };

            // var o = Parse(@"C:\temp\schematron\rec.xml");
            // Create the CDA
            //ClinicalDocument doc = CreateAPSDocument(pat, null, aut, DateTime.Now);
            //PrintStructure(doc);

            Console.ReadKey();
        }
        public void BuildPatientTest02()
        {
            // Flag used to verify if the graph result
            // contains details alongside its errors.
            bool noDetails = true;

            // Flag used to verify that the create instance is valid.
            bool valInstance = false;

            // Create a formatter with a graph aide
            XmlIts1Formatter fmtr = new XmlIts1Formatter();

            // Gets or sets a list of aide formatters
            // that assist in the formatting of this instance
            fmtr.GraphAides.Add(new DatatypeFormatter());

            // Format to a string
            StringWriter   sw    = new StringWriter();
            XmlStateWriter xmlSw = new XmlStateWriter(
                XmlWriter.Create(sw, new XmlWriterSettings()
            {
                Indent = true
            })
                );

            // Call our method here with invalid instance identifier.
            var patient = Utils.CreatePatient(
                new II(),
                EN.CreateEN(EntityNameUse.Legal,
                            new ENXP("John", EntityNamePartType.Given),
                            new ENXP("Smith", EntityNamePartType.Family)
                            ),
                AD.CreateAD(PostalAddressUse.HomeAddress,
                            "123 Main Street West",
                            "Hamilton",
                            "Ontario",
                            "Canada"
                            ),
                "*****@*****.**"
                );

            // Format to the formatter
            var result = fmtr.Graph(xmlSw, patient);

            // Flush and close
            xmlSw.Close();

            // Output to console
            Console.WriteLine("XML:");
            Console.WriteLine(sw.ToString());

            // If we get errors, set error catching flag to false and
            // print the details of each error.
            if (result.Details.Count() > 0)
            {
                noDetails = false;
                Console.WriteLine("validation:");
                foreach (var dtl in result.Details)
                {
                    Console.WriteLine("{0} : {1}", dtl.Type, dtl.Message);
                }
            }
            else
            {
                valInstance = true;
            }

            // Assert:  Either there are no errors,
            //          or there are details in the 'details' collection.
            if (noDetails)
            {
                Assert.AreEqual(valInstance, true);
            }
            else if (!valInstance)
            {
                Assert.AreEqual(noDetails, false);
            }
            else
            {
                // Test fails
                Assert.Fail();
            }
        }