Exemplo n.º 1
0
        //public static CdaExtractedHeader ExtractDocumentHeader(string documentContent)
        //{
        //    CdaExtractedHeader result = null;

        //    POCD_MT000040ClinicalDocument doc = CdaUtility.DeserializeContent(documentContent);

        //    if (doc != null)
        //    {
        //        result = new CdaExtractedHeader();

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

        //        // *** Document Date/Time ***
        //        if (doc.effectiveTime != null)
        //            if (!string.IsNullOrWhiteSpace(doc.effectiveTime.value))
        //                if (DateTime.TryParseExact(doc.effectiveTime.value, RawCdaDocument.CdaDateFormat, enUS, DateTimeStyles.None, out effectiveTime))
        //                    result.CreationDateTime = effectiveTime;

        //        // *** TODO: Check all document types ***
        //        if (doc.templateId != null)
        //            if (doc.templateId.Length > 0)
        //                foreach (II templateId in doc.templateId)
        //                    if (templateId.root == RawAphpDocument.AphpTemplateId)
        //                        result.DocumentType = IheDocumentType.APHP;

        //        // *** Get document id ***
        //        if (doc.id != null)
        //            result.Id = doc.id.root;

        //        // *** Sender ***
        //        if (doc.recordTarget != null)
        //            if (doc.recordTarget.Length > 0)
        //                if (doc.recordTarget[0].patientRole != null)
        //                    if (doc.recordTarget[0].patientRole.providerOrganization != null)
        //                        if (doc.recordTarget[0].patientRole.providerOrganization.name != null)
        //                            if (doc.recordTarget[0].patientRole.providerOrganization.name[0].Text != null)
        //                                result.Sender = doc.recordTarget[0].patientRole.providerOrganization.name[0].Text[0];

        //        // *** Title ***
        //        if (doc.title != null)
        //            if (doc.title.Text != null)
        //                if (doc.title.Text.Length > 0)
        //                    result.Title = doc.title.Text[0];

        //        // *** Recipient ****
        //        result.IntendedRecipient = ExtractRecipient(doc);

        //    }

        //    return result;
        //}

        //private static string ExtractRecipient(POCD_MT000040ClinicalDocument doc)
        //{
        //    // *** Gets the recipient string from a clinical doc ***

        //    string returnValue = "";

        //    // *** Create a working recipient ***
        //    CdaRecipient tempRecipient = new CdaRecipient();

        //    // *** Check for existence and drill down ***
        //    if (doc.informationRecipient != null)
        //        if (doc.informationRecipient.Length > 0)
        //            if (doc.informationRecipient[0].intendedRecipient != null)
        //            {
        //                // *** Organization***
        //                if (doc.informationRecipient[0].intendedRecipient.receivedOrganization != null)
        //                    if (doc.informationRecipient[0].intendedRecipient.receivedOrganization.name != null)
        //                        if (doc.informationRecipient[0].intendedRecipient.receivedOrganization.name.Length > 0)
        //                            if (doc.informationRecipient[0].intendedRecipient.receivedOrganization.name[0].Text != null)
        //                                tempRecipient.Organization = doc.informationRecipient[0].intendedRecipient.receivedOrganization.name[0].Text[0];

        //                // *** Person Name ***
        //                if (doc.informationRecipient[0].intendedRecipient.informationRecipient != null)
        //                    if (doc.informationRecipient[0].intendedRecipient.informationRecipient.name != null)
        //                    {
        //                        string[] names = GetName(doc.informationRecipient[0].intendedRecipient.informationRecipient.name);
        //                        tempRecipient.FirstName = names[0];
        //                        tempRecipient.LastName = names[1];
        //                    }

        //                // *** Set result ***
        //                returnValue = tempRecipient.ToString();
        //            }

        //    return returnValue;
        //}

        //public static Nullable<IheDocumentType> GetDocumentType(string documentContent)
        //{
        //    Nullable<IheDocumentType> returnVal = null;

        //    // *** Check if the xml for the passed-in content is supported ***

        //    try
        //    {
        //        POCD_MT000040ClinicalDocument clinicalDocument = CdaUtility.DeserializeContent(documentContent);

        //        if (clinicalDocument != null)
        //        {
        //            // TODO: Support proper document type

        //            // *** Look for document template id matching supported ***
        //            // *** For now only APHP, but could be CCD or other IHE template ***

        //            if (clinicalDocument.templateId != null)
        //                if (clinicalDocument.templateId.Length > 0)
        //                    foreach (II templateId in clinicalDocument.templateId)
        //                        switch (templateId.root)
        //                        {
        //                            case RawAphpDocument.AphpTemplateId:
        //                                returnVal = IheDocumentType.APHP;
        //                                break;

        //                            case RawApsDocument.ApsTemplateId:
        //                                returnVal = IheDocumentType.APS;
        //                                break;

        //                            case RawAplDocument.AplTemplateId:
        //                                returnVal = IheDocumentType.APL;
        //                                break;

        //                            case RawApeDocument.ApeTemplateId:
        //                                returnVal = IheDocumentType.APE;
        //                                break;

        //                            case RawPpvsDocument.PpvsTemplateId:
        //                                returnVal = IheDocumentType.PPVS;
        //                                break;

        //                            case RawXdriDocument.XdriTemplateId:
        //                                returnVal = IheDocumentType.XDR_I;
        //                                break;

        //                            case RawNdsDocument.NdsTemplateId:
        //                                returnVal = IheDocumentType.NDS;
        //                                break;

        //                            case RawMdsDocument.MdsTemplateId:
        //                                returnVal = IheDocumentType.MDS;
        //                                break;
        //                        }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        ErrorLogger.Log(ex, "Error Retrieving Document Type");
        //    }

        //    return returnVal;
        //}

        //public static bool DocumentIsSupported(string documentContent)
        //{
        //    // *** Check if the xml for the passed-in content is supported ***

        //    bool returnVal = false;

        //    POCD_MT000040ClinicalDocument clinicalDocument = CdaUtility.DeserializeContent(documentContent);

        //    if (clinicalDocument != null)
        //    {
        //        // TODO: Support proper document type

        //        // *** Look for document template id matching supported ***
        //        // *** For now only APHP, but could be CCD or other IHE template ***

        //        if (clinicalDocument.templateId != null)
        //            if (clinicalDocument.templateId.Length > 0)
        //                foreach (II templateId in clinicalDocument.templateId)
        //                    if (templateId.root == RawAphpDocument.AphpTemplateId)
        //                        returnVal = true;

        //    }

        //    return returnVal;
        //}

        public static string GetDocumentAbbreviation(IheDocumentType iheDocumentType)
        {
            return(DocumentTypeAbbreviation[(int)iheDocumentType]);
        }
Exemplo n.º 2
0
        public static CdaDocumentData Create(string uniqueId, string xmlContent, string patientDfn, IheDocumentType docType, string intendedRecipient, string sender)
        {
            CdaDocumentData returnVal = new CdaDocumentData();

            returnVal.DocumentContent = xmlContent;

            // *** Prepare header ***
            returnVal.Id                = uniqueId;
            returnVal.PatientDfn        = patientDfn;
            returnVal.CreationDateTime  = DateTime.Now;
            returnVal.DocumentType      = docType;
            returnVal.ExchangeDirection = ExchangeDirection.Outbound;
            returnVal.IntendedRecipient = intendedRecipient;

            returnVal.Sender = sender;

            // *** Document Names ****
            string docName = CdaUtility.DocumentTypeName[(int)docType];

            // *** Title is based on sender and name ***
            returnVal.Title = string.Format("{0} {1}", returnVal.Sender, docName);

            return(returnVal);
        }