Esempio n. 1
0
        public void EV_1101_SuppressXsiNilMultiprocessor()
        {
            String expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?><ClinicalDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" classCode=\"DOCCLIN\" moodCode=\"EVN\" xmlns=\"urn:hl7-org:v3\"><author typeCode=\"AUT\" nullFlavor=\"NI\" contextControlCode=\"OP\"><time value=\"20140116103733.292-0500\" /><assignedAuthor classCode=\"ASSIGNED\"><id root=\"2BCF1373-9199-4574-A254-0E7558DE9825\" /></assignedAuthor></author></ClinicalDocument>";

            ClinicalDocument document = new ClinicalDocument();
            Author           a        = new Author();

            a.Time           = (TS)"20140116103733.292-0500";
            a.AssignedAuthor = new AssignedAuthor(SET <II> .CreateSET(Guid.Parse("2BCF1373-9199-4574-A254-0E7558DE9825")));
            document.Author.Add(a);
            a.NullFlavor = NullFlavor.NoInformation;

            XmlIts1Formatter formatter = new XmlIts1Formatter();

            formatter.Settings  = SettingsType.DefaultMultiprocessor;
            formatter.Settings |= SettingsType.SuppressXsiNil | SettingsType.SuppressNullEnforcement;
            formatter.GraphAides.Add(new ClinicalDocumentDatatypeFormatter());
            formatter.ValidateConformance = false;

            StringWriter sw = new StringWriter();

            using (XmlWriter xw = XmlWriter.Create(sw))
            {
                var results = formatter.Graph(xw, document);
                xw.Flush();
                String data = sw.ToString();
                R2SerializationHelper.XmlIsEquivalent(expected, data);
            }
        }
Esempio n. 2
0
        public void EV_1101_DefaultSerializationLegacy()
        {
            String expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?><ClinicalDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" classCode=\"DOCCLIN\" moodCode=\"EVN\" xmlns=\"urn:hl7-org:v3\"><author nullFlavor=\"NI\" xsi:nil=\"true\" /></ClinicalDocument>";

            ClinicalDocument document = new ClinicalDocument();
            Author           a        = new Author();

            a.Time           = DateTime.Now;
            a.AssignedAuthor = new AssignedAuthor(SET <II> .CreateSET(Guid.NewGuid()));
            document.Author.Add(a);
            a.NullFlavor = NullFlavor.NoInformation;
            XmlIts1Formatter formatter = new XmlIts1Formatter();

            formatter.GraphAides.Add(new ClinicalDocumentDatatypeFormatter());
            formatter.ValidateConformance = false;
            formatter.Settings            = SettingsType.DefaultLegacy;

            StringWriter sw = new StringWriter();

            using (XmlWriter xw = XmlWriter.Create(sw))
            {
                formatter.Graph(xw, document);
                xw.Flush();
                String data = sw.ToString();
                R2SerializationHelper.XmlIsEquivalent(expected, data);
            }
        }
Esempio n. 3
0
        public void SetUnionTest01()
        {
            // Create sets
            SET <INT> firstSet  = SET <INT> .CreateSET(1, 2, 3, 4),
                      secondSet = SET <INT> .CreateSET(2, 4, 6);

            // Combine the sets
            SET <INT> resultant = firstSet.Union(secondSet);

            Console.WriteLine("The following SET is a result:");
            foreach (var i in resultant)
            {
                Console.WriteLine(i);
            }

            // output:
            // The following set is a resultant:
            // 1
            // 2
            // 3
            // 4
            // 6

            resultant.NullFlavor = null;
            Assert.IsTrue(resultant.Validate());
        }
Esempio n. 4
0
        /// <summary>
        /// Create custodial data from either a RepositoryDevice or a HealthcareParticipant
        /// </summary>
        private Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.Custodian CreateCustodian(RegistrationEvent registrationEvent, TargetConfiguration configuration)
        {
            ISystemConfigurationService sysConfig = this.Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService;

            var subject = registrationEvent.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf) as Person;
            var iiSet   = new List <II>(CreateIISet(subject.AlternateIdentifiers));

            iiSet.RemoveAll(ii => !configuration.NotificationDomain.Exists(o => o.Domain.Equals(ii.Root)));

            var oidData = sysConfig.OidRegistrar.FindData(iiSet[0].Root);

            if (oidData == null)
            {
                throw new InvalidOperationException("Cannot find notification settings for " + oidData);
            }

            var retVal = new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.Custodian(
                new Everest.RMIM.UV.NE2008.COCT_MT090003UV01.AssignedEntity()
                );

            // Device
            retVal.AssignedEntity.SetAssignedPrincipalChoiceList(
                new Everest.RMIM.UV.NE2008.COCT_MT090303UV01.Device(
                    SET <II> .CreateSET(new II(oidData.Attributes.Find(o => o.Key == "CustodialDeviceId").Value ?? oidData.Oid)),
                    null,
                    oidData.Attributes.Find(o => o.Key == "CustodialDeviceName").Value ?? oidData.Description
                    )
                );
            retVal.AssignedEntity.Id = SET <II> .CreateSET(new II(oidData.Oid));

            return(retVal);
        }
Esempio n. 5
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();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Creates a patient structure
        /// </summary>
        /// <param name="id">The unique identifier</param>
        /// <param name="name">The name of the patient</param>
        /// <param name="addr">The primary address</param>
        /// <param name="telecom">A primary telecom</param>
        /// <returns>A constructed patient structure</returns>
        public static Patient CreatePatient(
                II id,
                EN name,
                AD addr,
                TEL telecom
            )
        {
            // Instantiate the object
            var retVal = new Patient();

            // Populate address
            retVal.Addr = BAG<AD>.CreateBAG(addr);

            // Confidentiality Code
            retVal.ConfidentialityCode = "N";

            // Effective Time of the types
            // High is populated as "Not Applicable"
            retVal.EffectiveTime = new IVL<TS>(
                (TS)DateTime.Now,
                new TS() { NullFlavor = NullFlavor.NotApplicable }
                );

            // Telecom address
            retVal.Telecom = BAG<TEL>.CreateBAG(telecom);

            // Populate the ID
            retVal.Id = SET<II>.CreateSET(id);

            // Status Code
            retVal.StatusCode = RoleStatus.Active;

            // Return result
            return retVal;
        }
Esempio n. 7
0
        public void R2SETSimpleSerializationTest()
        {
            SET <INT> inti = SET <INT> .CreateSET(1, 2, 3, 4);

            string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""><item value=""1""/><item value=""2""/><item value=""3""/><item value=""4""/></test>";
            string actualXml   = R2SerializationHelper.SerializeAsString(inti);

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
        /// <summary>
        /// Create organization scoper
        /// </summary>
        private MARC.Everest.RMIM.UV.NE2008.COCT_MT150003UV03.Organization CreateOrganization(HealthcareParticipant scoper, List <MARC.Everest.Connectors.IResultDetail> details)
        {
            if (scoper == null)
            {
                return(null);
            }

            PN tName = null;

            if (scoper.LegalName != null)
            {
                tName = CreatePN(scoper.LegalName, details);
            }

            var id = scoper.AlternateIdentifiers.Find(o => o.Domain != this.m_configService.OidRegistrar.GetOid("CR_PID").Oid);

            // Basic return value
            var retVal = new MARC.Everest.RMIM.UV.NE2008.COCT_MT150003UV03.Organization(
                SET <II> .CreateSET(CreateII(id, details)),
                scoper.Type != null ? CreateCD <String>(scoper.Type, details) : null,
                tName != null ? BAG <ON> .CreateBAG(new ON(tName.Use[0], tName.Part)) : null,
                null
                );

            // Find all representatives
            foreach (HealthcareParticipant rep in scoper.FindAllComponents(HealthServiceRecordSiteRoleType.RepresentitiveOf))
            {
                var cp = new MARC.Everest.RMIM.UV.NE2008.COCT_MT150003UV03.ContactParty(
                    CreateIISet(rep.AlternateIdentifiers, details),
                    rep.Type != null ? CreateCD <String>(rep.Type, details) : null,
                    rep.PrimaryAddress != null ? BAG <AD> .CreateBAG(CreateAD(rep.PrimaryAddress, details)) : null,
                    null,
                    null
                    );

                // Add telecoms
                if (rep.TelecomAddresses != null)
                {
                    cp.Telecom = new BAG <TEL>();
                    foreach (var tel in rep.TelecomAddresses)
                    {
                        cp.Telecom.Add(CreateTEL(tel, details));
                    }
                }

                // Person info
                if (rep.Classifier == HealthcareParticipant.HealthcareParticipantType.Person && rep.LegalName != null)
                {
                    cp.ContactPerson = new MARC.Everest.RMIM.UV.NE2008.COCT_MT150003UV03.Person(
                        BAG <EN> .CreateBAG(CreatePN(rep.LegalName, details))
                        );
                }
                retVal.ContactParty.Add(cp);
            }

            return(retVal);
        }
Esempio n. 9
0
        public void R2SETSimpleParseTest()
        {
            SET <INT> inti = SET <INT> .CreateSET(1, 2, 3, 4);

            string    actualXml = R2SerializationHelper.SerializeAsString(inti);
            SET <INT> int2      = R2SerializationHelper.ParseString <SET <INT> >(actualXml);

            Assert.AreEqual(inti, int2);
        }
Esempio n. 10
0
        /// <summary>
        /// Example 69
        /// Creates a patient structure
        /// </summary>
        /// <param name="id">The unique identifier</param>
        /// <param name="name">The name of the patient</param>
        /// <param name="addr">The primary address</param>
        /// <param name="telecom">A primary telecom</param>
        /// <returns>A constructed patient structure</returns>
        public Patient CreatePatient(
            II id,
            EN name,
            AD addr,
            TEL telecom
            )
        {
            try
            {
                // Instantiate the object
                var retVal = new Patient();

                // Populate address
                retVal.Addr = BAG <AD> .CreateBAG(addr);

                // Confidentiality Code
                retVal.ConfidentialityCode = "N";

                // Effective Time of the types
                // High is populated as "Not Applicable"
                retVal.EffectiveTime = new IVL <TS>(
                    (TS)DateTime.Now,
                    new TS()
                {
                    NullFlavor = NullFlavor.NotApplicable
                }
                    );

                // Telecom address
                retVal.Telecom = BAG <TEL> .CreateBAG(telecom);

                // Populate the ID
                retVal.Id = SET <II> .CreateSET(id);

                // Status Code
                retVal.StatusCode = RoleStatus.Active;

                // Set entity choice
                retVal.SetPatientEntityChoiceSubject(
                    new Person()
                {
                    AdministrativeGenderCode = AdministrativeGender.Male,
                    Name      = BAG <EN> .CreateBAG(name),
                    BirthTime = DateTime.Now
                }
                    );

                // cannot return result for unit test purposes
                return(retVal);
            }
            catch
            {
                Console.WriteLine("Unit tests must not return a value, but Patient must be returned..");
                return(new Patient());
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Function will create a component (the body of the CDA)
        /// </summary>
        private static Component2 CreateComponent()
        {
            // Create a component 2 structure, which contains the body of the CDA, set it's type code to COMP and
            // context conduction indicator (any data with context conduction code of AP will be conducted) to true
            var retVal = new Component2(ActRelationshipHasComponent.HasComponent, true);



            // Everest provides methods of creating abstract classes through a series of helper methods,
            // here we're creating an observation for asthma
            var asthma = ClinicalStatement.CreateObservation(
                x_ActMoodDocumentObservation.Eventoccurrence,
                new CD <String>("30049385", "2.16.840.1.113883.6.96", "SNOMED-CT", null, "Asthma", null)
                );

            asthma.StatusCode    = ActStatus.Completed;
            asthma.EffectiveTime = new IVL <TS>(new TS(DateTime.Now, DatePrecision.Year), null); // In Everest, we can create a date with a precision of year which can be interpreted as any time that year
            asthma.Reference.Add(new Reference(x_ActRelationshipExternalReference.SUBJ, ExternalActChoice.CreateExternalObservation(
                                                   SET <II> .CreateSET(new II(Guid.NewGuid())), "CODE", "This is some text")));

            // BodyChoice is a choice of either nonXml content or structured body, how would we know that?
            // Well, whenever a class as a property XChoice and SetXChoice the SetXChoice will contain
            // the options of what XChoice can be set to
            retVal.SetBodyChoice(new StructuredBody()
            {
                Component = new List <Component3>() // We can use type initializers to create the components (sections)
                {
                    // We can create a section for history of present illness
                    new Component3(ActRelationshipHasComponent.HasComponent, true,
                                   new Section()
                    {
                        Code  = new CE <string>("10164-2", "2.16.840.1.113883.6.1"),
                        Title = "History of Present Illness",
                        Text  = new ED("<content styleCode=\"Bold\">This is bold</content>")
                        {
                            Representation = EncapsulatedDataRepresentation.XML
                        }                                                                                                                               // In the CDA ED type, we can use content tags to style the content
                    }),
                    new Component3(ActRelationshipHasComponent.HasComponent, true,
                                   new Section()
                    {
                        Code  = new CE <string>("10153-2", "2.16.840.1.113883.6.1"),
                        Title = "Past Medical History",
                        Text  = "We can also assign an ED directly as a string",
                        Entry = new List <Entry>()                                       // We can also add observations and sub-components
                        {
                            new Entry(x_ActRelationshipEntry.HasComponent, true, asthma) // See where we defined astma above as a clinical statement
                        }
                    })
                }
            });

            return(retVal);
        }
Esempio n. 12
0
        /// <summary>
        /// Create a person name from the specified name set
        /// </summary>
        public PN CreatePN(MARC.HI.EHRS.SVC.Core.DataTypes.NameSet nameSet, List <IResultDetail> dtls)
        {
            PN retVal = new PN();

            try
            {
                if (nameSet.Use == NameSet.NameSetUse.OfficialRecord)
                {
                    retVal.Use = SET <CS <EntityNameUse> > .CreateSET(EntityNameUse.Legal, EntityNameUse.OfficialRecord);
                }
                else if (nameSet.Use != NameSet.NameSetUse.Search)
                {
                    retVal.Use = new SET <CS <EntityNameUse> >((EntityNameUse)Enum.Parse(typeof(EntityNameUse), nameSet.Use.ToString()));
                }
            }
            catch
            {
                throw;
            }

            // Parts
            foreach (var part in nameSet.Parts)
            {
                switch (part.Type)
                {
                case NamePart.NamePartType.Family:
                    retVal.Part.Add(new ENXP(part.Value, EntityNamePartType.Family));
                    break;

                case NamePart.NamePartType.Delimeter:
                    retVal.Part.Add(new ENXP(part.Value, EntityNamePartType.Delimiter));
                    break;

                case NamePart.NamePartType.Given:
                    retVal.Part.Add(new ENXP(part.Value, EntityNamePartType.Given));
                    break;

                case NamePart.NamePartType.Prefix:
                    retVal.Part.Add(new ENXP(part.Value, EntityNamePartType.Prefix));
                    break;

                case NamePart.NamePartType.Suffix:
                    retVal.Part.Add(new ENXP(part.Value, EntityNamePartType.Suffix));
                    break;

                default:
                    retVal.Part.Add(new ENXP(part.Value));
                    dtls.Add(new PersistenceResultDetail(ResultDetailType.Warning, String.Format("Can't represent name part type '{0}' in HL7v3", part.Type), null));
                    break;
                }
            }

            return(retVal);
        }
Esempio n. 13
0
        public void R2SETTypeOverrideSerializationTest()
        {
            SET <IQuantity> inti = SET <IQuantity> .CreateSET(
                (INT)1,
                (REAL)2,
                new PQ(3, "ft"));

            string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""><item xsi:type=""INT"" value=""1""/><item xsi:type=""REAL"" value=""2""/><item xsi:type=""PQ"" value=""3"" unit=""ft""/></test>";
            string actualXml   = R2SerializationHelper.SerializeAsString(inti);

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Esempio n. 14
0
        public void R2SETTypeOverrideParseTest()
        {
            SET <IQuantity> inti = SET <IQuantity> .CreateSET(
                (INT)1,
                (REAL)2,
                new PQ(3, "ft"));

            string          actualXml = R2SerializationHelper.SerializeAsString(inti);
            SET <IQuantity> int2      = R2SerializationHelper.ParseString <SET <IQuantity> >(actualXml);

            Assert.AreEqual(inti, int2);
        }
Esempio n. 15
0
        public void R2SETNestedParseTest()
        {
            SET <IColl> inti = SET <IColl> .CreateSET(
                SET <INT> .CreateSET(1, 2, 3),
                LIST <INT> .CreateList(1, 1, 2),
                BAG <ST> .CreateBAG("1", "2")
                );

            string      actualXml = R2SerializationHelper.SerializeAsString(inti);
            SET <IColl> int2      = R2SerializationHelper.ParseString <SET <IColl> >(actualXml);

            Assert.AreEqual(inti, int2);
        }
Esempio n. 16
0
        public void R2SETNestedSerializationTest()
        {
            SET <IColl> inti = SET <IColl> .CreateSET(
                SET <INT> .CreateSET(1, 2, 3),
                LIST <INT> .CreateList(1, 1, 2),
                BAG <ST> .CreateBAG("1", "2")
                );

            string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""><item xsi:type=""DSET_INT""><item value=""1""/><item value=""2""/><item value=""3""/></item><item xsi:type=""LIST_INT""><item value=""1""/><item value=""1""/><item value=""2""/></item><item xsi:type=""BAG_ST""><item value=""1"" language=""en-US""/><item value=""2"" language=""en-US""/></item></test>";
            string actualXml   = R2SerializationHelper.SerializeAsString(inti);

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Esempio n. 17
0
        /// <summary>
        /// Create patient structure for the person suitable for a create
        /// </summary>
        private Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.Subject2 <Everest.RMIM.UV.NE2008.PRPA_MT201301UV02.Patient> CreatePatient(RegistrationEvent registrationEvent, TargetConfiguration configuration)
        {
            // Get the subject from the list of components
            var subject     = registrationEvent.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf) as Person;
            var masking     = subject.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.FilterOf) as MaskingIndicator;
            var providerOrg = subject.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.PlaceOfEntry | SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.InformantTo) as HealthcareParticipant;

            if (subject == null) // validate
            {
                return(null);
            }

            var iiSet = new List <II>(CreateIISet(subject.AlternateIdentifiers));

            iiSet.RemoveAll(ii => !configuration.NotificationDomain.Exists(o => o.Domain.Equals(ii.Root)));

            // Construct the return value
            var retVal = new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.Subject2 <Everest.RMIM.UV.NE2008.PRPA_MT201301UV02.Patient>(
                new Everest.RMIM.UV.NE2008.PRPA_MT201301UV02.Patient(
                    new SET <II>(iiSet),
                    CreatePerson(subject, configuration),
                    null
                    ));

            // Act as a source?
            // Masking indicator
            if (masking != null)
            {
                retVal.registeredRole.ConfidentialityCode = new SET <CE <string> >(CreateCD <String>(masking.MaskingCode));
            }

            // Provider org
            var oidData = m_configService.OidRegistrar.FindData(iiSet[0].Root);

            if (oidData != null)
            {
                retVal.registeredRole.ProviderOrganization = new Everest.RMIM.UV.NE2008.COCT_MT150003UV03.Organization()
                {
                    Id           = SET <II> .CreateSET(new II(oidData.Oid)),
                    Name         = BAG <ON> .CreateBAG(ON.CreateON(null, new ENXP(oidData.Attributes.Find(o => o.Key == "CustodialOrgName").Value ?? oidData.Description))),
                    ContactParty = new List <Everest.RMIM.UV.NE2008.COCT_MT150003UV03.ContactParty>()
                    {
                        new Everest.RMIM.UV.NE2008.COCT_MT150003UV03.ContactParty()
                        {
                            NullFlavor = NullFlavor.NoInformation
                        }
                    }
                };
            }
            return(retVal);
        }
Esempio n. 18
0
        public void R2CDCETranslationParseTest()
        {
            var cdi = new CE <String>("232323232", "2.16.840.1.113883.6.96")
            {
                OriginalText = new ED("Burnt ear with iron. Burnt other ear calling for ambulance"),
                Translation  = SET <CD <String> > .CreateSET(
                    new CD <String>("burn", "2.16.840.1.113883.19.5.2")
                    )
            };
            string actualXml = R2SerializationHelper.SerializeAsString(cdi);
            var    cd2       = R2SerializationHelper.ParseString <CE <String> >(actualXml);

            Assert.AreEqual(cdi, cd2);
        }
Esempio n. 19
0
        public void R2ONQualifierSerializationTest()
        {
            ON inti = new ON();

            inti.Part.Add(new ENXP("Health Level Seven, "));
            inti.Part.Add(new ENXP("Inc.", EntityNamePartType.Suffix)
            {
                Qualifier = SET <CS <EntityNamePartQualifier> > .CreateSET(EntityNamePartQualifier.LegalStatus)
            });
            string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" flavorId=""EN.ON""><part value=""Health Level Seven, ""/><part type=""TITLE"" value=""Inc."" qualifier=""LS SFX""/></test>";
            string actualXml   = R2SerializationHelper.SerializeAsString(inti);

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Esempio n. 20
0
        public void R2CDCETranslationSerializationTest()
        {
            string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" flavorId=""CD.CE"" code=""232323232"" codeSystem=""2.16.840.1.113883.6.96""><originalText value=""Burnt ear with iron. Burnt other ear calling for ambulance""/><translation code=""burn"" codeSystem=""2.16.840.1.113883.19.5.2""/></test>";
            var    cdi         = new CE <String>("232323232", "2.16.840.1.113883.6.96")
            {
                OriginalText = new ED("Burnt ear with iron. Burnt other ear calling for ambulance"),
                Translation  = SET <CD <String> > .CreateSET(
                    new CD <String>("burn", "2.16.840.1.113883.19.5.2")
                    )
            };
            string actualXml = R2SerializationHelper.SerializeAsString(cdi);

            R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
        }
Esempio n. 21
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);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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);
        }
Esempio n. 24
0
        public void R2ONQualifierParseTest()
        {
            ON inti = new ON()
            {
                Flavor = "EN.ON"
            };

            inti.Part.Add(new ENXP("Health Level Seven, "));
            inti.Part.Add(new ENXP("Inc.", EntityNamePartType.Title)
            {
                Qualifier = SET <CS <EntityNamePartQualifier> > .CreateSET(EntityNamePartQualifier.LegalStatus)
            });
            string actualXml = R2SerializationHelper.SerializeAsString(inti);
            var    int2      = R2SerializationHelper.ParseString <ON>(actualXml);

            Assert.AreEqual(inti, int2);
        }
Esempio n. 25
0
        public static ClinicalDocument CreateAPSDocument(PatientData recordTarget, PatientData father, PhysicianData author, DateTime docDate, params Section[] sections)
        {
            var doc = CreateCDA(
                LIST <II> .CreateList(new II("1.3.6.1.4.1.19376.1.5.3.1.1.2"), new II("1.3.6.1.4.1.19376.1.5.3.1.1.11.2")),
                new CE <String>("57055-6", "2.16.840.1.113883.6.1", "LOINC", null, "Antepartum Summary Note", null),
                "Antepartum Summary",
                docDate,
                recordTarget,
                null,
                null,
                author,
                sections
                );

            // Father of fetus
            if (father != null)
            {
                SET <II> fatherIds = new SET <II>();
                foreach (var id in father.OtherIds)
                {
                    fatherIds.Add(new II(id.Key, id.Value));
                }

                doc.Participant.Add(new Participant1(ParticipationType.IND, ContextControl.OverridingNonpropagating, null, new IVL <TS>(new TS(recordTarget.DateOfBirth, DatePrecision.Year)), null)
                {
                    AssociatedEntity = new AssociatedEntity(RoleClassAssociative.NextOfKin,
                                                            fatherIds,
                                                            new CE <string>("xx - fatherofbaby ", " 2.16.840.1.113883.6.96 ", null, null, " Father of fetus ", null),
                                                            SET <AD> .CreateSET(AD.FromSimpleAddress(PostalAddressUse.HomeAddress, father.Address, null, father.City, father.State, " CA ", null)),
                                                            SET <TEL> .CreateSET(new TEL()
                    {
                        NullFlavor = NullFlavor.NoInformation
                    }),
                                                            new Person(SET <PN> .CreateSET(PN.FromFamilyGiven(EntityNameUse.Legal, father.FamilyName, father.GivenName))),
                                                            null)
                });
            }

            return(doc);
        }
        public void SetIntersectTest01()
        {
            // Create sets
            SET <INT> firstSet  = SET <INT> .CreateSET(1, 2, 3, 4),
                      secondSet = SET <INT> .CreateSET(2, 4, 6);

            // Intersect the sets
            SET <INT> resultant = firstSet.Intersection(secondSet);

            Console.WriteLine("The following integers intersect:");
            foreach (var i in resultant)
            {
                Console.WriteLine(i);
            }

            // output:
            // The following integers intersect:
            // 2
            // 4

            resultant.NullFlavor = null;
            Assert.IsTrue(resultant.Validate());
        }
        public void SETExceptionOps01()
        {
            // Create a set of all integers from 0 to 9
            SET <INT> ints = new SET <INT>(10);

            for (var i = 0; i <= 9; i++)
            {
                ints.Add(i);
            }

            // Get a set of even numbers
            SET <INT> evens = SET <INT> .CreateSET(2, 4, 6, 8);

            // Get a resultant set
            SET <INT> results = ints.Except(evens);

            foreach (var i in results)
            {
                Console.Write(i);
            }

            results.NullFlavor = null;
            Assert.IsTrue(results.Validate());
        }
Esempio n. 28
0
        /// <summary>
        /// Create the person portion
        /// </summary>
        private MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Person CreatePerson(Person patient, List <IResultDetail> details)
        {
            var retVal = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Person();

            // Patient names
            if (patient.Names != null)
            {
                retVal.Name = new BAG <PN>();

                foreach (var nam in patient.Names)
                {
                    retVal.Name.Add(CreatePN(nam, details));
                }
            }

            // Create AsOtherIds
            retVal.AsOtherIDs = new List <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.OtherIDs>();
            if (patient.OtherIdentifiers != null)
            {
                foreach (var othId in patient.OtherIdentifiers)
                {
                    var otherIdentifier = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.OtherIDs(
                        SET <II> .CreateSET(CreateII(othId.Value, details)),
                        RoleStatus.Active,
                        null,
                        null);
                    // Any extensions that apply to this?
                    var propertyPath = String.Format("OtherIdentifiers[{0}{1}]", othId.Value.Domain, othId.Value.Identifier);
                    var othAltId     = patient.FindAllExtensions(o => o.Name == "AssigningIdOrganizationExtraId" && o.PropertyPath == propertyPath);
                    var extId        = patient.FindAllExtensions(o => o.Name == "AssigningIdOrganizationId" && o.PropertyPath == propertyPath);
                    var extName      = patient.FindAllExtensions(o => o.Name == "AssigningIdOrganizationName" && o.PropertyPath == propertyPath);
                    var extCode      = patient.FindExtension(o => o.Name == "AssigningIdOrganizationCode" && o.PropertyPath == propertyPath);
                    if (othAltId != null)
                    {
                        foreach (var id in othAltId)
                        {
                            otherIdentifier.Id.Add(CreateII(id.Value as DomainIdentifier, details));
                        }
                    }

                    // Any of the extensions that apply to scoping org applied
                    if (extId != null || extName != null || extCode != null)
                    {
                        // Scoping org
                        otherIdentifier.ScopingOrganization = new MARC.Everest.RMIM.UV.NE2008.COCT_MT150002UV01.Organization(
                            null,
                            extCode != null ? CreateCD <String>(extCode.Value as CodeValue, details) : null,
                            null,
                            null
                            );

                        // Extended identifiers (scoping id org id)
                        if (extId != null)
                        {
                            otherIdentifier.ScopingOrganization.Id = new SET <II>();
                            foreach (var ii in extId)
                            {
                                otherIdentifier.ScopingOrganization.Id.Add(CreateII(ii.Value as DomainIdentifier, details));
                            }
                        }

                        // Extension identifiers for name
                        if (extName != null)
                        {
                            otherIdentifier.ScopingOrganization.Name = new BAG <ON>();
                            foreach (var on in extName)
                            {
                                otherIdentifier.ScopingOrganization.Name.Add(new ON(EntityNameUse.Legal, new ENXP[] { new ENXP(on.Value as String) }));
                            }
                        }
                    }
                    retVal.AsOtherIDs.Add(otherIdentifier);
                }
            }

            return(retVal);
        }
Esempio n. 29
0
        /// <summary>
        /// Convert the specified patient record to a registration event
        /// </summary>
        internal MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.RegistrationEvent <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient, object> CreateRegistrationEvent(RegistrationEvent res, List <IResultDetail> details)
        {
            // Patient
            var patient = res.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf) as Person;

            if (patient == null)
            {
                return new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.RegistrationEvent <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient, object>()
                       {
                           NullFlavor = NullFlavor.NoInformation
                       }
            }
            ;

            var scoper         = patient.FindComponent(HealthServiceRecordSiteRoleType.PlaceOfEntry | HealthServiceRecordSiteRoleType.InformantTo) as HealthcareParticipant;
            var queryParameter = patient.FindComponent(HealthServiceRecordSiteRoleType.CommentOn | HealthServiceRecordSiteRoleType.ComponentOf) as QueryParameters;
            var mask           = patient.FindComponent(HealthServiceRecordSiteRoleType.FilterOf) as MaskingIndicator;

            var myOidData = this.m_configService.OidRegistrar.GetOid("CR_CID");

            // Return status
            var retVal = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.RegistrationEvent <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient, object>(
                ActStatus.Active,
                new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject2 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient>(
                    new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient(
                        CreateIISet(patient.AlternateIdentifiers, details),
                        ConvertStatus(patient.Status, details),
                        null,
                        new MARC.Everest.RMIM.UV.NE2008.COCT_MT150003UV03.Organization(
                            SET <II> .CreateSET(new II(myOidData.Oid, null)),
                            null,
                            BAG <ON> .CreateBAG(ON.CreateON(null, new ENXP(myOidData.Attributes.Find(o => o.Key == "CustodialOrgName").Value ?? myOidData.Description))),
                            new MARC.Everest.RMIM.UV.NE2008.COCT_MT150003UV03.ContactParty()
            {
                NullFlavor = NullFlavor.NoInformation
            }
                            ),
                        null
                        )
                    )
                );

            // Custodian
            retVal.Custodian = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.Custodian(
                new MARC.Everest.RMIM.UV.NE2008.COCT_MT090003UV01.AssignedEntity(
                    SET <II> .CreateSET(new II(this.m_configService.Custodianship.Id.Domain))
                    )
            {
                RepresentedOrganization = new MARC.Everest.RMIM.UV.NE2008.COCT_MT150003UV03.Organization(
                    SET <II> .CreateSET(new II(this.m_configService.Custodianship.Id.Domain, null)),
                    null,
                    BAG <ON> .CreateBAG(ON.CreateON(null, new ENXP(this.m_configService.Custodianship.Name))),
                    new MARC.Everest.RMIM.UV.NE2008.COCT_MT150003UV03.ContactParty()
                {
                    NullFlavor = NullFlavor.NoInformation
                }
                    )
            }
                );
            retVal.Subject1.registeredRole.SetPatientEntityChoiceSubject(CreatePersonDetail(patient, details));


            // Mask
            if (mask != null)
            {
                retVal.Subject1.registeredRole.ConfidentialityCode = new SET <CE <string> >(
                    CreateCD <String>(mask.MaskingCode, details)
                    );
            }

            if (patient.VipCode != null)
            {
                retVal.Subject1.registeredRole.VeryImportantPersonCode = CreateCD <String>(patient.VipCode, details);
            }

            // Query observation
            if (queryParameter != null)
            {
                retVal.Subject1.registeredRole.SubjectOf1.Add(new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Subject(
                                                                  new MARC.Everest.RMIM.UV.NE2008.PRPA_MT202310UV02.QueryMatchObservation(
                                                                      new CD <string>(queryParameter.MatchingAlgorithm == MatchAlgorithm.Soundex ? "PHCM" : "PTNM", "2.16.840.1.113883.2.20.5.2"),
                                                                      new INT((int)(queryParameter.Confidence * 100))
                                                                      )
                                                                  ));
            }

            return(retVal);
        }
        /// <summary>
        /// Create the response message
        /// </summary>
        public MARC.Everest.Interfaces.IInteraction Create(MARC.Everest.Interfaces.IInteraction request, RegistryQueryResult results, List <IResultDetail> dtls)
        {
            // GEt the config services
            ISystemConfigurationService configService = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService;
            ILocalizationService        localeService = Context.GetService(typeof(ILocalizationService)) as ILocalizationService;

            var retHl7v3 = new List <MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject1 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object> >(results.Results.Count);

            UvDeComponentUtil dCompUtil = new UvDeComponentUtil();

            dCompUtil.Context = this.Context;

            PRPA_IN201309UV02 rqst = request as PRPA_IN201309UV02;

            // Convert results to HL7v3
            foreach (RegistrationEvent res in results.Results)
            {
                var retRec = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject1 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>(
                    false,
                    dCompUtil.CreateRegistrationEventDetail(res, dtls)
                    );
                if (retRec.RegistrationEvent == null)
                {
                    retRec = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject1 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>(
                        false,
                        new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.RegistrationEvent <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>()
                    {
                        NullFlavor = NullFlavor.NoInformation
                    }
                        );
                }
                retHl7v3.Add(retRec);
            }

            if (retHl7v3.Count > 1)
            {
                dtls.Add(new InsufficientRepetitionsResultDetail(ResultDetailType.Warning, localeService.GetString("MSGE06E"), null));
            }

            // Create the response
            PRPA_IN201310UV02 response = new PRPA_IN201310UV02
                                         (
                Guid.NewGuid(),
                DateTime.Now,
                PRPA_IN201310UV02.GetInteractionId(),
                ProcessingID.Production,
                "T",
                AcknowledgementCondition.Never,
                MessageUtil.CreateReceiver(rqst.Sender),
                MessageUtil.CreateSenderUv(new Uri(rqst.Receiver[0].Telecom.Value), configService),
                null
                                         )
            {
                Acknowledgement = new List <MARC.Everest.RMIM.UV.NE2008.MCCI_MT100300UV01.Acknowledgement>()
                {
                    new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100300UV01.Acknowledgement(
                        dtls.Count(a => a.Type == ResultDetailType.Error) == 0 ? AcknowledgementType.ApplicationAcknowledgementAccept : AcknowledgementType.ApplicationAcknowledgementError,
                        new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.TargetMessage(request.Id)
                        )
                }
            };

            response.controlActProcess = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.ControlActProcess <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201307UV02.QueryByParameter, MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>("EVN")
            {
                Id       = SET <II> .CreateSET(new II(configService.Custodianship.Id.Domain, Guid.NewGuid().ToString())),
                Code     = new CD <string>(PRPA_IN201310UV02.GetTriggerEvent().Code, PRPA_IN201310UV02.GetTriggerEvent().CodeSystem),
                QueryAck = new MARC.Everest.RMIM.UV.NE2008.QUQI_MT120001UV01.QueryAck(
                    rqst.controlActProcess.queryByParameter.QueryId,
                    "complete",
                    (AcknowledgementType)response.Acknowledgement[0].TypeCode == AcknowledgementType.ApplicationAcknowledgementError ? QueryResponse.ApplicationError : results.TotalResults == 0 ? QueryResponse.NoDataFound : QueryResponse.DataFound,
                    results.TotalResults,
                    results.Results.Count,
                    results.TotalResults - results.Results.Count - results.StartRecordNumber
                    ),
                queryByParameter = rqst.controlActProcess.queryByParameter
            };

            response.controlActProcess.LanguageCode = MessageUtil.GetDefaultLanguageCode(this.Context);
            if (retHl7v3.Count > 0)
            {
                response.controlActProcess.Subject.Add(retHl7v3[0]);
            }
            return(response);
        }