public CdaRecordTarget ExtractRecordTarget()
        {
            // *** Extract basic patient information from the document content ***

            CdaRecordTarget returnRecordTarget = null;

            if (this.Initialize())
            {
                // *** Check if we have something to work with ***
                if (this.PocdDocument != null)
                {
                    if (this.PocdDocument.recordTarget != null)
                    {
                        if (this.PocdDocument.recordTarget.Length > 0)
                        {
                            // *** Create the return value ***
                            returnRecordTarget = new CdaRecordTarget();

                            // *** Get the first record target ***
                            POCD_MT000040RecordTarget pocdRecordTarget = this.PocdDocument.recordTarget[0];

                            // *** Make sure we have a patient role section ***
                            if (pocdRecordTarget.patientRole != null)
                            {
                                // *** Get the SSN ***
                                returnRecordTarget.SSN = GetSSN(pocdRecordTarget.patientRole);

                                // *** Make sure we have a patient ***
                                if (pocdRecordTarget.patientRole.patient != null)
                                {
                                    // *** Create shortcut for patient ***
                                    POCD_MT000040Patient pat = pocdRecordTarget.patientRole.patient;

                                    // *** Get the date of birth ***
                                    returnRecordTarget.Patient.DateOfBirth = GetDOB(pat);

                                    // *** Get the name ***
                                    string[] name = GetName(pat.name);
                                    returnRecordTarget.Patient.Name.First = name[0];
                                    returnRecordTarget.Patient.Name.Last  = name[1];
                                }
                            }
                        }
                    }
                }
            }

            return(returnRecordTarget);
        }
        public POCD_MT000040RecordTarget ToPocdRecordTarget()
        {
            POCD_MT000040RecordTarget recordTarget = new POCD_MT000040RecordTarget();

            if (this.TemplateIds.Count > 0)
            {
                recordTarget.templateId = this.TemplateIds.ToPocd();
            }

            recordTarget.patientRole = new POCD_MT000040PatientRole();

            // *** SSN ***
            II ssnII = new II()
            {
                extension = this.SSN, root = "2.16.840.1.113883.4.1"
            };

            recordTarget.patientRole.id = new II[] { ssnII };

            // *** Address ***
            if (this.PatientAddressList.Count > 0)
            {
                recordTarget.patientRole.addr = this.PatientAddressList.ToADArray();
            }
            else
            {
                recordTarget.patientRole.addr = new AD[] { new AD()
                                                           {
                                                               nullFlavor = "UNK"
                                                           } }
            };

            // *** Telephone Numbers ***
            List <TEL> telList = new List <TEL>();

            foreach (CdaTelephone number in this.PatientTelephoneList)
            {
                telList.Add(number.ToTEL());
            }
            if (telList.Count > 0)
            {
                recordTarget.patientRole.telecom = telList.ToArray();
            }
            else
            {
                recordTarget.patientRole.telecom = new TEL[] { new TEL()
                                                               {
                                                                   nullFlavor = "UNK"
                                                               } }
            };

            // *** Patient ***
            recordTarget.patientRole.patient = this.Patient.ToPocdPat();

            // *** Provider Organization ***
            recordTarget.patientRole.providerOrganization = this.ProviderOrganization.ToPocdOrganization();

            return(recordTarget);
        }
    }
}
Esempio n. 3
0
        //public abstract string ToCdaXml();

        protected POCD_MT000040ClinicalDocument AddRawDocumentData(POCD_MT000040ClinicalDocument rawDoc)
        {
            // *** Set the realm to US ***
            //rawDoc.realmCode = new List<CS>();
            //rawDoc.realmCode.Add(new CS() { code = "US" });

            // *** All documents will have this type ***
            rawDoc.typeId = new POCD_MT000040InfrastructureRoottypeId()
            {
                root = "2.16.840.1.113883.1.3", extension = "POCD_HD000040"
            };

            // *** Date/Time of Creation ***
            //<effectiveTime value='20000407130000+0500'/>
            rawDoc.effectiveTime = new TS()
            {
                value = DateTime.Now.ToString(RawCdaDocument.CdaDateFormat)
            };

            // *** Confidentiality ***
            //<confidentialityCode code='N' codeSystem='2.16.840.1.113883.5.25'/>
            rawDoc.confidentialityCode = new CE()
            {
                code = "N", codeSystem = "2.16.840.1.113883.5.25"
            };

            // *** Language ***
            //<languageCode code='en-US'/>
            rawDoc.languageCode = new CS()
            {
                code = "en-US"
            };

            // *** Set id ***
            rawDoc.id = new II()
            {
                root = this.DocumentId
            };

            // *** Record Target ***
            POCD_MT000040RecordTarget rt = this.RecordTarget.ToPocdRecordTarget();

            rawDoc.recordTarget = new POCD_MT000040RecordTarget[] { rt };

            // *** Information Recipient ***
            rawDoc.informationRecipient = this.Recipient.ToPocdRecipient();

            // *** Participants ***
            rawDoc.participant = this.Participants.ToPocdParticpantArray();

            // *** Authors ***
            List <POCD_MT000040Author> authorList = new List <POCD_MT000040Author>();

            // *** Device Author ***
            if (!this.DeviceAuthor.IsEmpty)
            {
                POCD_MT000040Author pocdDevAuthor = this.DeviceAuthor.ToPocdAuthor();
                authorList.Add(pocdDevAuthor);
            }

            // *** Author - Current User ***
            POCD_MT000040Author pocdAuthor = this.Author.ToPocdAuthor();

            authorList.Add(pocdAuthor);

            rawDoc.author = authorList.ToArray();

            // *** Custodian ***
            rawDoc.custodian = this.Custodian.ToPocdCustodian();

            // *** Documentation Of ***
            rawDoc.documentationOf = new POCD_MT000040DocumentationOf[] { this.DocumentationOf.ToPocdDocumentationOf() };

            // *** Document Body ***
            rawDoc.component = new POCD_MT000040Component2();
            POCD_MT000040StructuredBody body = new POCD_MT000040StructuredBody();

            // *** Create list of component/sections ***
            List <POCD_MT000040Component3> componentList = new List <POCD_MT000040Component3>();

            // *** Add allergy section ***
            POCD_MT000040Component3 allergySection = this.Allergies.ToPocdComponent();

            if (allergySection != null)
            {
                componentList.Add(allergySection);
            }

            // TODO: Add additional sections here...

            // *** Add the sections/component to body ***
            body.component = componentList.ToArray();

            // *** Add body ***
            rawDoc.component.Item = body;

            return(rawDoc);
        }