Ejemplo n.º 1
0
 public frmStoreRecord()
 {
     InitializeComponent();
     Store     = new motStoreRecord(__action);
     __execute = frmMainRecordTester.__execute;
 }
Ejemplo n.º 2
0
        // Do the real work here - call delegates to update UI

        void __parsePioneerRxRecord(XmlDocument __xdoc)
        {
            //__gateway = new motPort();  // Clever way to turn off gateway for testing

            // The interesting parts of PioneerRx XML are:
            //          Pharmacy
            //          Prescribers<Prescriber>
            //          Patient
            //          Facility
            //          Rx

            try
            {
                XmlNode __pharmacy = __xdoc.SelectSingleNode("//Pharmacy");


                motStoreRecord __store = new motStoreRecord("Add", __args.__auto_truncate);

                __store.StoreName     = __pharmacy.SelectSingleNode("PharmacyName").InnerText;
                __store.RxSys_StoreID = __pharmacy.SelectSingleNode("Identification/PioneerRxID").InnerText;
                __store.DEANum        = __pharmacy.SelectSingleNode("Identification/DEA").InnerText;
                __store.Address1      = __pharmacy.SelectSingleNode("//Address/AddressLine1").InnerText;
                __store.Address2      = __pharmacy.SelectSingleNode("//Address/AddressLine2").InnerText;
                __store.City          = __pharmacy.SelectSingleNode("//Address/City").InnerText;
                __store.State         = __pharmacy.SelectSingleNode("//Address/StateCode").InnerText;
                __store.Zip           = __pharmacy.SelectSingleNode("//Address/ZipCode").InnerText;

                XmlNodeList __phone_node_list = __pharmacy.SelectNodes("PhoneNumbers/PhoneNumber");
                foreach (XmlNode __num in __phone_node_list)
                {
                    if (__num["Type"].InnerText.ToLower() == "fax")
                    {
                        __store.Fax = __num["AreaCode"].InnerText + __num["Number"].InnerText;
                    }
                    else
                    {
                        __store.Phone = __num["AreaCode"].InnerText + __num["Number"].InnerText;
                    }
                }

                __store.Write(__gateway);
                __show_common_event("Added Store: " + __store.StoreName);
            }
            catch (Exception ex)
            {
                __show_error_event("Failed writing Store Record: " + ex.Message);
            }

            try
            {
                XmlNodeList __prescribers = __xdoc.SelectNodes("//Prescribers/Prescriber");

                foreach (XmlNode __prescriber in __prescribers)
                {
                    var __doc = new motPrescriberRecord("Add", __args.__auto_truncate);

                    // its odd.  The PrescriberID is writen like this:
                    //      <PresccriberID>
                    //          <GUID/>40DE86C9-FD69-44D7-9DA4-4D2A3194DE49
                    //      </PrescriberID>
                    // and I can't find a way to get at the XPath lets me get the node but no value
                    //__doc.RxSys_DocID = __prescriber.SelectSingleNode("Identification/PrescriberID").ChildNodes[1].InnerText;

                    __doc.RxSys_DocID   = __prescriber.SelectSingleNode("Identification/PrescriberID/GUID").InnerText;
                    __doc.DEA_ID        = __prescriber.SelectSingleNode("Identification/DEA").InnerText;
                    __doc.FirstName     = __prescriber.SelectSingleNode("Name/FirstName").InnerText;
                    __doc.LastName      = __prescriber.SelectSingleNode("Name/LastName").InnerText;
                    __doc.MiddleInitial = __prescriber.SelectSingleNode("Name/MiddleName").InnerText;

                    // We can only take a single address, so just take the first one
                    __doc.Address1   = __prescriber.SelectSingleNode("//Address/AddressLine1").InnerText;
                    __doc.Address2   = __prescriber.SelectSingleNode("//Address/AddressLine2").InnerText;
                    __doc.City       = __prescriber.SelectSingleNode("//Address/City").InnerText;
                    __doc.State      = __prescriber.SelectSingleNode("//Address/StateCode").InnerText;
                    __doc.PostalCode = __prescriber.SelectSingleNode("//Address/City").InnerText;
                    __doc.Specialty  = string.IsNullOrEmpty(__prescriber["PrimarySpecializationID"].InnerText) ? 0 : Convert.ToInt32(__prescriber["PrimarySpecializationID"].InnerText);

                    XmlNodeList __phone_node_list = __prescriber.SelectNodes("PhoneNumbers/PhoneNumber");
                    foreach (XmlNode __num in __phone_node_list)
                    {
                        if (__num["Type"].InnerText.ToLower() == "fax")
                        {
                            __doc.Fax = __num["AreaCode"].InnerText + __num["Number"].InnerText;
                        }
                        else
                        {
                            __doc.Phone = __num["AreaCode"].InnerText + __num["Number"].InnerText;
                        }
                    }

                    __doc.Email     = __prescriber.SelectSingleNode("Email").InnerText;
                    __doc.Comments += __prescriber.SelectSingleNode("Comments/Informational").InnerText + "\n";
                    __doc.Comments += __prescriber.SelectSingleNode("Comments/Critical").InnerText + "\n";
                    __doc.Comments += __prescriber.SelectSingleNode("Comments/PointOfSale").InnerText + "\n";

                    __doc.Write(__gateway);

                    __show_common_event("Added Prescriber: " + __doc.FirstName + " " + __doc.LastName);
                }
            }
            catch (Exception ex)
            {
                __show_error_event("Failed Writing Records: " + ex.Message);
                throw;
            }


            try
            {
                var __patient = __xdoc.SelectSingleNode("//Patient");
                var __pat     = new motPatientRecord("Add", __args.__auto_truncate);
                List <motPrescriptionRecord> __rx_list = new List <motPrescriptionRecord>();

                __pat.RxSys_PatID   = __patient?.SelectSingleNode("//Identification/PatientID/Guid").InnerText;
                __pat.SSN           = __patient?.SelectSingleNode("//Identification/SSN").InnerText;
                __pat.DOB           = __patient?.SelectSingleNode("DateOfBirth/Date").InnerText;
                __pat.FirstName     = __patient?.SelectSingleNode("Name/FirstName").InnerText;
                __pat.LastName      = __patient?.SelectSingleNode("Name/LastName").InnerText;
                __pat.MiddleInitial = __patient?.SelectSingleNode("Name/MiddleName").InnerText;
                __pat.Gender        = __patient?.SelectSingleNode("Gender").InnerText;
                __pat.Height        = string.IsNullOrEmpty(__patient?.SelectSingleNode("HeightInches").InnerText) ? 0 : Convert.ToInt32(__patient?.SelectSingleNode("HeightInches").InnerText);
                __pat.Weight        = string.IsNullOrEmpty(__patient?.SelectSingleNode("WeightOz").InnerText) ? 0 : Convert.ToInt32(__patient?.SelectSingleNode("WeightOz").InnerText);

                // We can only take a single address, so just take the first one
                __pat.Address1 = __patient?.SelectSingleNode("//Address/AddressLine1").InnerText;
                __pat.Address2 = __patient?.SelectSingleNode("//Address/AddressLine2").InnerText;
                __pat.City     = __patient?.SelectSingleNode("//Address/City").InnerText;
                __pat.State    = __patient?.SelectSingleNode("//Address/StateCode").InnerText;
                __pat.Zip      = __patient?.SelectSingleNode("//Address/City").InnerText;

                __pat.Email = __patient?.SelectSingleNode("Email").InnerText;

                __pat.Comments += __patient?.SelectSingleNode("Comments/Informational").InnerText + "\n";
                __pat.Comments += __patient?.SelectSingleNode("Comments/Critical").InnerText + "\n";
                __pat.Comments += __patient?.SelectSingleNode("Comments/PointOfSale").InnerText + "\n";
                __pat.Comments += __patient?.SelectSingleNode("Comments/LastMTMComment").InnerText + "\n";

                XmlNodeList __phone_node_list = __patient?.SelectNodes("PhoneNumbers/PhoneNumber");
                foreach (XmlNode __num in __phone_node_list)
                {
                    if (__num["SequenceNumber"].InnerText == "1")
                    {
                        __pat.Phone1 = __num["AreaCode"].InnerText + __num["Number"].InnerText;
                    }
                    else if (__num["SequenceNumber"].InnerText == "2")
                    {
                        __pat.Phone2 = __num["AreaCode"].InnerText + __num["Number"].InnerText;
                    }
                }

                __pat.RxSys_DocID = __patient?.SelectSingleNode("PatientPrimaryPrescriberID").InnerText;

                XmlNodeList __allergy_node_list = __patient?.SelectNodes("Allergies/Allergy");
                int         i = 1;
                foreach (XmlNode __allergy in __allergy_node_list)
                {
                    __pat.Allergies += string.Format("{0}) {1}, MedID: {2}, IDType: {3}\n", i++, __allergy["Description"].InnerText, __allergy["MedicationID"].InnerText, __allergy["MedicationIDType"].InnerText);
                }

                XmlNodeList __scrip_node_list = __patient?.SelectNodes("OtherMedications/Medication");
                foreach (XmlNode __scrip in __scrip_node_list)
                {
                    var __new_scrip = new motPrescriptionRecord("Add", __args.__auto_truncate);

                    __new_scrip.RxSys_RxNum  = __scrip["RxNumber"].InnerText;
                    __new_scrip.RxSys_DocID  = __scrip["Prescriber"].InnerText;
                    __new_scrip.RxSys_DrugID = __scrip["DrugNDC"].InnerText;
                    __new_scrip.QtyDispensed = __scrip["DaysSupply"].InnerText;
                    __new_scrip.RxStartDate  = __scrip["LastDateFilled"].InnerText;
                    __new_scrip.Refills      = __scrip["RefillsRemaining"].InnerText;

                    __new_scrip.RxSys_PatID = __pat.RxSys_PatID;
                    __new_scrip.RxType      = "0";

                    __rx_list.Add(__new_scrip);
                }

                __pat.Write(__gateway);
                __show_common_event("Added Patient: " + __pat.FirstName + " " + __pat.LastName);
                foreach (motPrescriptionRecord __scp in __rx_list)
                {
                    __scp.Write(__gateway);
                    __show_common_event("Added Scrip: " + __scp.RxSys_RxNum + " for " + __pat.FirstName + " " + __pat.LastName);
                }
            }
            catch (Exception ex)
            {
                __show_error_event("Failed Writing Records: " + ex.Message);
                throw;
            }

            // Facility
            // RX
        }