Ejemplo n.º 1
0
        public void SXPRSTMixedComponentsFormatting()
        {
            SXPR <RTO <INT, INT> > test = SXPR <RTO <INT, INT> > .CreateSXPR(new IVL <RTO <INT, INT> >(new RTO <INT, INT>(1, 3), new RTO <INT, INT>(2, 3)),
                                                                             new PIVL <RTO <INT, INT> >(
                                                                                 new IVL <RTO <INT, INT> >(new RTO <INT, INT>(2, 3), new RTO <INT, INT>(5, 6)),
                                                                                 new PQ((decimal)1.0, "y")
                                                                                 )
                                                                             //new SXCM<RTO<INT,INT>>(new RTO<INT,INT>(1,2)) { Operator = SetOperator.A },
                                                                             //new IVL<RTO<INT,INT>>(new RTO<INT,INT>(1,2)) { Operator = SetOperator.Intersect
                                                                             );

            StringWriter      sw   = new StringWriter();
            DatatypeFormatter fmtr = new DatatypeFormatter();
            XmlStateWriter    xw   = new XmlStateWriter(XmlWriter.Create(sw));

            xw.WriteStartElement("sxpr");
            fmtr.Graph(xw, test);
            xw.WriteEndElement(); // comp
            xw.Flush();
            Tracer.Trace(sw.ToString());
            StringReader   sr  = new StringReader(sw.ToString());
            XmlStateReader rdr = new XmlStateReader(XmlReader.Create(sr));

            rdr.Read(); rdr.Read();
            var parse = fmtr.Parse(rdr, typeof(SXPR <RTO <INT, INT> >)).Structure as SXPR <RTO <INT, INT> >;

            Assert.AreEqual(parse.Count, test.Count);
            for (int i = 0; i < parse.Count; i++)
            {
                Assert.AreEqual(parse[i].GetType(), test[i].GetType());
            }
        }
Ejemplo n.º 2
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();
            }
        }
        /// <summary>
        /// Serialize as a string
        /// </summary>
        internal static String SerializeAsString(IGraphable graph)
        {
            DatatypeR2Formatter fmtr = new DatatypeR2Formatter();
            StringWriter        sw   = new StringWriter();
            XmlStateWriter      xsw  = new XmlStateWriter(XmlWriter.Create(sw, new XmlWriterSettings()
            {
                Indent = true
            }));

            xsw.WriteStartElement("test", "urn:hl7-org:v3");
            xsw.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
            var result = fmtr.Graph(xsw, graph);

            xsw.WriteEndElement();
            xsw.Flush();
            sw.Flush();
            System.Diagnostics.Trace.WriteLine(sw.ToString());
            Assert.AreEqual(ResultCode.Accepted, result.Code);
            return(sw.ToString());
        }
Ejemplo n.º 4
0
        public void SXPRTSMixedComponentsFormatting()
        {
            SXPR <TS> test = SXPR <TS> .CreateSXPR(new IVL <TS>(DateTime.Now, DateTime.Now.AddDays(1)),
                                                   new PIVL <TS>(
                                                       new IVL <TS>(DateTime.Now, DateTime.Now.AddDays(1)),
                                                       new PQ((decimal)1.0, "y")
                                                       ),
                                                   //new SXCM<TS>(DateTime.Now) { Operator = SetOperator.A },
                                                   new IVL <TS>(DateTime.Now) { Operator = SetOperator.Intersect },
                                                   new EIVL <TS>(DomainTimingEventType.BeforeLunch,
                                                                 new IVL <PQ>(
                                                                     new PQ((decimal)1.0, "d")
                                                                     )
                                                                 ) { Operator = SetOperator.Inclusive });

            StringWriter      sw   = new StringWriter();
            DatatypeFormatter fmtr = new DatatypeFormatter();
            XmlStateWriter    xw   = new XmlStateWriter(XmlWriter.Create(sw));

            xw.WriteStartElement("sxpr");
            fmtr.Graph(xw, test);
            xw.WriteEndElement(); // comp
            xw.Flush();
            Tracer.Trace(sw.ToString());
            StringReader   sr  = new StringReader(sw.ToString());
            XmlStateReader rdr = new XmlStateReader(XmlReader.Create(sr));

            rdr.Read(); rdr.Read();
            var parse = fmtr.Parse(rdr, typeof(SXPR <TS>)).Structure as SXPR <TS>;

            Assert.AreEqual(parse.Count, test.Count);
            for (int i = 0; i < parse.Count; i++)
            {
                Assert.AreEqual(parse[i].GetType(), test[i].GetType());
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Serialize query
        /// </summary>
        internal static byte[] SerializeQuery(IGraphable queryByParameter)
        {
            using (XmlIts1Formatter fmtr = new XmlIts1Formatter()
            {
                ValidateConformance = false
            })
            {
                StringBuilder  sb     = new StringBuilder();
                XmlStateWriter writer = new XmlStateWriter(XmlWriter.Create(sb));

                // Write the start element
                writer.WriteStartElement("queryByParameter", "urn:hl7-org:v3");
                fmtr.GraphAides.Add(new DatatypeFormatter()
                {
                    CompatibilityMode = DatatypeFormatterCompatibilityMode.Universal, ValidateConformance = false
                });
                fmtr.Graph(writer, queryByParameter);
                writer.WriteEndElement();
                writer.Close();

                // Return the constructed result
                return(Encoding.ASCII.GetBytes(sb.ToString()));
            }
        }
Ejemplo n.º 6
0
        public void EV_1110_DefaultUniprocessorCustomTypeTest()
        {
            // Load a sample because I don't want to write a full construction method
            ClinicalDocument clinicalDocument = null;

            using (Stream inStream = typeof(EV_1110).Assembly.GetManifestResourceStream("MARC.Everest.Test.Resources.phrDocTesting_140219112155-0500.xml"))
            {
                XmlIts1Formatter fmtr = new XmlIts1Formatter();
                fmtr.ValidateConformance = false;
                fmtr.GraphAides.Add(new ClinicalDocumentDatatypeFormatter());
                var result = fmtr.Parse(XmlReader.Create(inStream), typeof(ClinicalDocument));
                clinicalDocument = result.Structure as ClinicalDocument;
            }

            var observation = new ObservationMyProfile()
            {
                MoodCode          = x_ActMoodDocumentObservation.Eventoccurrence,
                Code              = "3202-20",
                EntryRelationship = new List <EntryRelationship>()
                {
                    new EntryRelationship(x_ActRelationshipEntryRelationship.HasComponent, true)
                    {
                        ClinicalStatement = new ObservationMyProfile()
                    }
                }
            }
            ;


            CascadeNullFlavor(observation.EntryRelationship[0], NullFlavor.Unknown);

            // Cascade a null flavor on one of the entries
            clinicalDocument.Component.GetBodyChoiceIfStructuredBody().Component[1].Section.Entry.Add(new Entry(
                                                                                                          x_ActRelationshipEntry.HasComponent,
                                                                                                          false,
                                                                                                          observation
                                                                                                          ));

            // Cascade a null flavor on one of the entries
            clinicalDocument.Component.GetBodyChoiceIfStructuredBody().Component[2].Section.Entry.Add(new Entry(
                                                                                                          x_ActRelationshipEntry.HasComponent,
                                                                                                          false,
                                                                                                          observation
                                                                                                          ));

            // Cascade a null flavor on one of the entries
            clinicalDocument.Component.GetBodyChoiceIfStructuredBody().Component[3].Section.Entry.Add(new Entry(
                                                                                                          x_ActRelationshipEntry.HasComponent,
                                                                                                          false,
                                                                                                          observation
                                                                                                          ));

            StringWriter sw = new StringWriter();

            using (XmlWriter xw = XmlWriter.Create(sw, new XmlWriterSettings()
            {
                Indent = true
            }))
            {
                XmlIts1Formatter fmtr = new XmlIts1Formatter();
                fmtr.ValidateConformance = false;
                fmtr.GraphAides.Add(new ClinicalDocumentDatatypeFormatter());
                fmtr.Settings  = SettingsType.DefaultUniprocessor;
                fmtr.Settings |= SettingsType.SuppressXsiNil;
                fmtr.Settings |= SettingsType.SuppressNullEnforcement;
                fmtr.Settings |= SettingsType.AlwaysCheckForOverrides;
                fmtr.RegisterXSITypeName("POCD_MT000040.Observation", typeof(MARC.Everest.Test.Regressions.EV_1102.ObservationWithConfidentialityCode));

                using (XmlStateWriter xsw = new XmlStateWriter(xw))
                {
                    xsw.WriteStartElement("hl7", "ClinicalDocument", "urn:hl7-org:v3");
                    xsw.WriteAttributeString("xmlns", "xsi", null, XmlIts1Formatter.NS_XSI);
                    xsw.WriteAttributeString("schemaLocation", XmlIts1Formatter.NS_XSI, @"urn:hl7-org:v3 Schemas/CDA-PITO-E2E.xsd");
                    xsw.WriteAttributeString("xmlns", null, null, @"urn:hl7-org:v3");
                    xsw.WriteAttributeString("xmlns", "hl7", null, @"urn:hl7-org:v3");
                    xsw.WriteAttributeString("xmlns", "e2e", null, @"http://standards.pito.bc.ca/E2E-DTC/cda");
                    xsw.WriteAttributeString("xmlns", "xs", null, @"http://www.w3.org/2001/XMLSchema");


                    IFormatterGraphResult result = fmtr.Graph(xsw, clinicalDocument);
                    foreach (ResultDetail itm in result.Details)
                    {
                        Trace.WriteLine(String.Format("{0}:{1} @ {2}", itm.Type, itm.Message, itm.Location));
                    }
                    xsw.WriteEndElement(); // clinical document
                    xsw.Flush();
                }
            }

            Trace.WriteLine(sw.ToString());
            Regex re = new Regex(@"\<entryRelationship.*/\>");

            if (re.IsMatch(sw.ToString()))
            {
                Assert.Fail("Output of entry relationship is not as expected");
            }
        }
Ejemplo n.º 7
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();
        }