Exemple #1
0
        public string ToCdaXml()
        {
            // *** Generates the CDA xml from the raw document ***

            // *** Create a string builder ***
            StringBuilder sb = new StringBuilder();

            // *** Get the raw document ***
            RawAphpDocument rawDoc = this.ToRawDocument();

            // *** Create serializer ***
            XmlSerializer serializer = new XmlSerializer(typeof(RawAphpDocument));

            // *** Add some xml settings ***
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Encoding        = Encoding.UTF8;
            settings.Indent          = true;
            settings.NewLineHandling = NewLineHandling.Replace;

            // *** Serialize It ***
            using (XmlWriter writer = XmlWriter.Create(sb, settings))
            {
                // *** Add the style sheet processing instruction ***
                writer.WriteProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"CDA.xsl\"");

                serializer.Serialize(writer, rawDoc);
            }

            return(sb.ToString());
        }
Exemple #2
0
        //private static POCD_MT000040ClinicalDocument DeserializeContent(string content)
        //{
        //    POCD_MT000040ClinicalDocument returnDocument = null;

        //    // *** Create a generic CDA serializer ***
        //    XmlSerializer serializer = new XmlSerializer(typeof(POCD_MT000040ClinicalDocument));

        //    // *** Create an xml reader ***
        //    using (XmlReader xmlReader = XmlReader.Create(new StringReader(content)))
        //    {
        //        // *** Check if it can deserialize ***
        //        if (serializer.CanDeserialize(xmlReader))
        //        {
        //            // *** Deserialize ***
        //            returnDocument = (POCD_MT000040ClinicalDocument)serializer.Deserialize(xmlReader);
        //        }
        //    }

        //    return returnDocument;
        //}

        //private static string GetSSN(POCD_MT000040PatientRole patRole)
        //{
        //    string returnVal = "";

        //    // *** SSN ***
        //    if (patRole.id != null)
        //        foreach (II tempII in patRole.id)
        //            if (tempII.root == "2.16.840.1.113883.4.1")
        //                if (!string.IsNullOrWhiteSpace(tempII.extension))
        //                    returnVal = tempII.extension;

        //    return returnVal;
        //}

        //private static DateTime GetDOB(POCD_MT000040Patient pat)
        //{
        //    DateTime returnDOB = DateTime.MinValue;

        //    CultureInfo enUS = new CultureInfo("en-US");

        //    // *** DOB ***
        //    if (pat.birthTime != null)
        //        if (!string.IsNullOrWhiteSpace(pat.birthTime.value))
        //            DateTime.TryParseExact(pat.birthTime.value, "yyyyMMdd", enUS, DateTimeStyles.None, out returnDOB);

        //    return returnDOB;
        //}

        //private static string[] GetName(PN[] pn)
        //{
        //    string[] returnName = new string[] {"",""};

        //    // *** Name ***
        //    if (pn != null)
        //        if (pn.Length > 0)
        //        {
        //            PN name = pn[0];
        //            if (name.Items != null)
        //                if (name.Items.Length > 0)
        //                    foreach (ENXP enxp in name.Items)
        //                        if (enxp.Text != null)
        //                            if (enxp.Text.Length > 0)
        //                            {
        //                                if (enxp is engiven)
        //                                    returnName[0] = enxp.Text[0];
        //                                else if (enxp is enfamily)
        //                                    returnName[1] = enxp.Text[0];
        //                            }
        //        }

        //    return returnName;
        //}

        public static string SerializeAphp(RawAphpDocument rawDoc)
        {
            string returnVal = "";

            // *** Create serializer for specific document ***
            XmlSerializer serializer = new XmlSerializer(typeof(RawAphpDocument));

            returnVal = SerializeIheDoc(serializer, rawDoc);

            return(returnVal);
        }
Exemple #3
0
        public RawAphpDocument ToRawDocument()
        {
            // *** Converts this object to a raw APHP document ***

            RawAphpDocument returnDoc = new RawAphpDocument();

            // *** Get base type ***
            POCD_MT000040ClinicalDocument arg = returnDoc as POCD_MT000040ClinicalDocument;

            // *** Populate from base ***
            arg = this.AddRawDocumentData(arg);

            // *** This is the list of body sections
            List <POCD_MT000040Component3> components = new List <POCD_MT000040Component3>();

            // *** After all sections are added, add as array ***
            POCD_MT000040StructuredBody body = arg.component.Item as POCD_MT000040StructuredBody;

            // *** Add existing ***
            components.AddRange(body.component);

            // *** Add chief complaint ***
            POCD_MT000040Component3 chiefComplaint = this.ChiefComplaint.ToPocdComponent();

            if (chiefComplaint != null)
            {
                components.Add(chiefComplaint);
            }

            // *** Add history of present illness ***
            POCD_MT000040Component3 presentIllness = this.HistoryOfPresentIllness.ToPocdComponent();

            if (presentIllness != null)
            {
                components.Add(presentIllness);
            }

            // *** Add history of past illness ***
            POCD_MT000040Component3 pastIllness = this.HistoryOfPastIllness.ToPocdComponent();

            if (presentIllness != null)
            {
                components.Add(pastIllness);
            }

            // *** Add coded history of infection ***
            POCD_MT000040Component3 infection = this.CodedHistoryOfInfection.ToPocdComponent();

            if (infection != null)
            {
                components.Add(infection);
            }

            // *** Add pregnancy history ***
            POCD_MT000040Component3 pregHist = this.PregnancyHistorySection.ToPocdComponent();

            if (pregHist != null)
            {
                components.Add(pregHist);
            }

            // *** Add coded social history ***
            POCD_MT000040Component3 socialHistory = this.SocialHistory.ToPocdComponent();

            if (socialHistory != null)
            {
                components.Add(socialHistory);
            }

            // *** Add coded family medical history ***
            POCD_MT000040Component3 familyMedicalHistory = this.FamilyMedicalHistory.ToPocdComponent();

            if (familyMedicalHistory != null)
            {
                components.Add(familyMedicalHistory);
            }

            // *** Add review of systems ***
            POCD_MT000040Component3 reviewOfSystems = this.ReviewOfSystems.ToPocdComponent();

            if (reviewOfSystems != null)
            {
                components.Add(reviewOfSystems);
            }

            // *** Add coded physical exam ***
            POCD_MT000040Component3 physicalExam = this.PhysicalExam.ToPocdComponent();

            if (physicalExam != null)
            {
                components.Add(physicalExam);
            }

            body.component = components.ToArray();

            return(returnDoc);
        }