Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        private static ClinicalDocument CreateCDA(LIST <II> templateIds, CE <String> code, ST title, TS docDate, PatientData recordTarget, PatientData motherOfRCT, PatientData fatherOfRCT, PhysicianData author, params Section[] sections)
        {
            // First, we need to create a clinical document
            ClinicalDocument doc = new ClinicalDocument()
            {
                TemplateId          = templateIds,                                                                                  // Identifiers
                Id                  = Guid.NewGuid(),                                                                               // A unique id for the document
                Code                = code,                                                                                         // The code for the document
                Title               = title,                                                                                        //
                TypeId              = new II("2.16.840.1.113883.1.3", "POCD_HD000040"),                                             // This value is static and identifies the HL7 type
                RealmCode           = SET <CS <BindingRealm> > .CreateSET(BindingRealm.UniversalRealmOrContextUsedInEveryInstance), // This is UV some profiles require US
                EffectiveTime       = docDate,
                ConfidentialityCode = x_BasicConfidentialityKind.Normal,                                                            // Confidentiality of data within the CDA
                LanguageCode        = "en-US",                                                                                      // Language of the CDA
            };

            // Next we need to append the RecordTarget to the CDA
            RecordTarget rctPatient = new RecordTarget()
            {
                ContextControlCode = ContextControl.OverridingPropagating,
                PatientRole        = new PatientRole()
                {
                    Id      = CreateIdList(recordTarget.OtherIds),                                                                                                                    // These are "other MRNs" we know about in the CDA
                    Addr    = SET <AD> .CreateSET(AD.FromSimpleAddress(PostalAddressUse.HomeAddress, recordTarget.Address, null, recordTarget.City, recordTarget.State, "CA", null)), // We create the address from parts
                    Patient = new Patient()
                    {
                        Name = SET <PN> .CreateSET(PN.FromFamilyGiven(EntityNameUse.Legal, recordTarget.FamilyName, recordTarget.GivenName)), // PAtient name
                        AdministrativeGenderCode = recordTarget.Gender,                                                                       // GEnder
                        BirthTime = new TS(recordTarget.DateOfBirth, DatePrecision.Day)                                                       // Day of birth
                    }
                }
            };

            // WE also need to add our local identifier (example: from our database/MRN) to the CDA
            // You will need to use your own OID
            rctPatient.PatientRole.Id.Add(new II("1.2.3.4.5.6", recordTarget.Id));

            doc.RecordTarget.Add(rctPatient);

            // We now want to create an author
            Author docAuthor = new Author()
            {
                ContextControlCode = ContextControl.AdditivePropagating,
                Time           = docDate, // When the document was created
                AssignedAuthor = new AssignedAuthor()
                {
                    Id   = SET <II> .CreateSET(new II("1.2.3.4.5.6.1", author.PhysicianId)), // Physician's identifiers (or how we know the physician)
                    Addr = new SET <AD>()
                    {
                        AD.FromSimpleAddress(PostalAddressUse.PhysicalVisit, author.AddressLine, null, author.City, "ON", "CA", author.Postal)
                    },                                                                                                                       // The author's address
                    AssignedAuthorChoice = AuthorChoice.CreatePerson(
                        SET <PN> .CreateSET(PN.FromFamilyGiven(EntityNameUse.Legal, author.PhysicianName[0], author.PhysicianName[1]))       // The author's name
                        ),
                    RepresentedOrganization = new Organization()
                    {
                        Id   = new SET <II>(new II("1.2.3.4.5.6.2", author.OrgId)),                          // Organization the physician represents
                        Name = SET <ON> .CreateSET(new ON(null, new ENXP[] { new ENXP(author.OrgName[0]) })) // The name of the organization
                    }
                }
            };

            doc.Author.Add(docAuthor);


            // The document custodian is the source of truth for the document, i.e. the organization
            // that is responsible for storing/maintaining the document.
            Custodian docCustodian = new Custodian(
                new AssignedCustodian(
                    new CustodianOrganization(
                        SET <II> .CreateSET(new II("2.3.4.5.6.7", "304930-3")),
                        new ON(null, new ENXP[] { new ENXP("ACME Medical Centres") }),
                        null,
                        AD.FromSimpleAddress(PostalAddressUse.PhysicalVisit, "123 Main St.", null, "Hamilton", "ON", "CA", "L0R2A0")
                        )
                    )
                );

            doc.Custodian = docCustodian;


            // If the "mother" of the patient is provided, let's add the mother's data
            if (motherOfRCT != null)
            {
                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,
                                                            CreateIdList(motherOfRCT.OtherIds),
                                                            new CE <string>("MTH", "2.16.840.1.113883.5.111", null, null, "Mother", null),
                                                            SET <AD> .CreateSET(AD.FromSimpleAddress(PostalAddressUse.HomeAddress, motherOfRCT.Address, null, motherOfRCT.City, motherOfRCT.State, "CA", null)),
                                                            SET <TEL> .CreateSET(new TEL()
                    {
                        NullFlavor = NullFlavor.NoInformation
                    }),
                                                            new Person(SET <PN> .CreateSET(PN.FromFamilyGiven(EntityNameUse.Legal, motherOfRCT.FamilyName, motherOfRCT.GivenName))),
                                                            null)
                });
            }

            if (fatherOfRCT != null)
            {
                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,
                                                            CreateIdList(fatherOfRCT.OtherIds),
                                                            new CE <string>("FTH", "2.16.840.1.113883.5.111", null, null, "Father", null),
                                                            SET <AD> .CreateSET(AD.FromSimpleAddress(PostalAddressUse.HomeAddress, fatherOfRCT.Address, null, fatherOfRCT.City, fatherOfRCT.State, "CA", null)),
                                                            SET <TEL> .CreateSET(new TEL()
                    {
                        NullFlavor = NullFlavor.NoInformation
                    }),
                                                            new Person(SET <PN> .CreateSET(PN.FromFamilyGiven(EntityNameUse.Legal, fatherOfRCT.FamilyName, fatherOfRCT.GivenName))),
                                                            null)
                });
            }


            // Next we want to setup the body of the document
            doc.Component = new Component2(
                ActRelationshipHasComponent.HasComponent,
                true,
                new StructuredBody() // This document will be structured document
                );

            // Now we add the sections passed to us
            foreach (var sct in sections)
            {
                doc.Component.GetBodyChoiceIfStructuredBody().Component.Add(new Component3(
                                                                                ActRelationshipHasComponent.HasComponent,
                                                                                true,
                                                                                sct));
            }

            return(doc);
        }