Esempio n. 1
0
        /**************************************************************************************************/
        private bool testRequestToAggregator()
        {
            //call the aggregator service; this is a blocking call, up to 60 seconds
            //next line is for testing locally only
            //AggregatorServiceReferenceDev3.Service1Client client = new AggregatorServiceReferenceDev3.Service1Client();
            HraRiskAggregator.Service1Client client = new HraRiskAggregator.Service1Client("WSHttpBinding_IService1");
            client.InnerChannel.OperationTimeout = new TimeSpan(0, 1, 0);  //set the timeout to 1 minute

            try
            {
                //call the aggregator using the licenseID in the config file
                string licID = RiskApps3.Utilities.Configurator.getAggregatorLicenseID();

                //block here 'till get a reply or timeout
                return client.HeartBeat(licID);
            }
            catch (Exception e)  //exceptioned out on Aggregator web service call; likely due to timeout
            {
                return false;
            }
        }
Esempio n. 2
0
        public void RecalculateRisk()
        {
            //Assembly.LoadFrom("C:\\HRA\\Dev\\RiskAppCoreProjects\\RiskClinicApp\\bin\\Debug\\RiskAppCore.dll");

            if (Configurator.useAggregatorService())
            {

                //new way
                //Serialize the FH
                this.LoadFullObject(); //needed to ensure patient object is complete, including ObGynHx, etc.
                RiskApps3.Model.PatientRecord.FHx.FamilyHistory theFH = this.owningFHx;

                bool dcis_found = false;
                bool dcisAsCancer = true;
                foreach (Person p in this.FHx)
                {
                    foreach (ClincalObservation co in p.PMH.Observations)
                    {
                        if (string.Compare(co.riskMeaning, "DCIS", true) == 0)
                        {
                            dcis_found = true;
                        }
                    }
                }

                if (dcis_found  && !bSilent)    // added silent mode jdg 9/1/15
                {
                    DialogResult dr = MessageBox.Show("Would you like to consider DCIS a cancer diagnosis for BRCAPRO and Tyrer-Cuzick model calculations?  DCIS WILL be considered as cancer for use with the Myriad, Claus and Gail models.", "BRCAPRO Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.No)
                    {
                        dcisAsCancer = false;
                    }
                }
                else
                {
                    if (dcis_found && bSilent)
                    {
                        // to use or not to use?  that is the question.
                        // And the answer is... YES.
                        dcisAsCancer = true;    // though it defaulted to this anyway, as it turns out
                    }
                }

                string fhAsString = TransformUtils.DataContractSerializeObject<RiskApps3.Model.PatientRecord.FHx.FamilyHistory>(theFH);

                //transform it
                XmlDocument inDOM = new XmlDocument();
                inDOM.LoadXml(fhAsString);
                if (String.IsNullOrEmpty(toolsPath))
                {
                    toolsPath = RiskApps3.Utilities.Configurator.getNodeValue("Globals", "ToolsPath"); // @"C:\Program Files\riskappsv2\tools\";
                }
                if (String.IsNullOrEmpty(strServiceBinding))
                {
                    strServiceBinding = "WSHttpBinding_IService1";
                }
                XmlDocument resultXmlDoc = TransformUtils.performTransform(inDOM, toolsPath, @"hra_to_ccd_remove_namespaces.xsl");
                XmlDocument hl7FHData;
                if (dcis_found && dcisAsCancer)
                {
                    //only do this when calling the RiskAggravator Service; we don't want to change the actual diseases in the object model
                    hl7FHData = TransformUtils.performTransformWith2Params(resultXmlDoc, toolsPath, @"hra_serialized_to_hl7.xsl", "dcisAsCancer", "1", "deIdentify", "1");

                }
                else
                {
                    hl7FHData = TransformUtils.performTransformWithParam(resultXmlDoc, toolsPath, @"hra_serialized_to_hl7.xsl", "deIdentify", "1");
                }

                //Insert Clinic Name and Institution Name into HL7
                //Get the first (and only) text node
                XmlNode theFirstTextNode = hl7FHData.SelectSingleNode("(//FamilyHistory/text)[1]");
                //and replace its contents with the clinic name and institution names
                theFirstTextNode.InnerText = " Current User:  ; " + BCDB2.Instance.GetClinicAndInstitutionNames(apptid);

                bool dump = Configurator.getConfigBool("WriteAggregatorFiles");

                //convert to string
                string hl7Request = convertXMLDocToString(hl7FHData);
                if (dump)
                {
                    File.WriteAllText("AggregatorRequest.xml", hl7Request);
                }

                //call the aggregator servicethis is a blocking call, up to 60 seconds
                //AggregatorServiceReference2.Service1Client client = new AggregatorServiceReference2.Service1Client();
                //next line is for testing locally only
                //AggregatorServiceReferenceDev3.Service1Client client = new AggregatorServiceReferenceDev3.Service1Client();
                HraRiskAggregator.Service1Client client = new HraRiskAggregator.Service1Client(strServiceBinding);
                client.InnerChannel.OperationTimeout = new TimeSpan(0, 1, 0);  //set the timeout to 1 minute

                string hl7Reply = "";
                try
                {
                    // old way:
                    // hl7Reply = client.GetRiskData(hl7Request);
                    //

                    //call the aggregator using the licenseID in the config file
                    string licID = Configurator.getAggregatorLicenseID();
                    hl7Reply = client.GetRiskDataWithDetails(hl7Request, licID);

                    //if we make it here, the synchronous web service call completed successfully
                    if (dump)
                    {
                        File.WriteAllText("AggregatorReply.xml", hl7Reply);
                    }

                    RP.ClearRP();

                    //Use an XPath navigator to retrieve the XML results into the object model
                    StringReader sr = new StringReader(hl7Reply);
                    XmlTextReader tx = new XmlTextReader(sr);
                    XPathDocument docNav = new XPathDocument(tx);
                    XPathNavigator nav = docNav.CreateNavigator();

                    //get BMRS requestId, effectiveTime, and top level messages from HL7 reply
                    XPathNavigator bmrsInfo = nav.SelectSingleNode("//pedigreeAnalysisResults[id/@extension][1]");
                    if (bmrsInfo != null)
                    {
                        RP.BMRS_RequestId = Convert.ToInt64(bmrsInfo.Evaluate("string(id/@extension)").ToString());
                        string hl7effTime = bmrsInfo.Evaluate("string(effectiveTime/@value)").ToString();
                        string[] formats = {"yyyyMMddHHmmss", "yyyyMMddHHmm", "yyyyMMddHH", "yyyyMMdd"};
                        DateTime dateValue;
                        if (DateTime.TryParseExact(hl7effTime, formats, null, System.Globalization.DateTimeStyles.None, out dateValue))
                            RP.BMRS_EffectiveTime = dateValue;
                        else
                            RP.BMRS_EffectiveTime = null;
                        RP.BMRS_Messages = bmrsInfo.Evaluate("string(text)").ToString().Trim();
                    }

                    processBrcaProHL7Scores(nav);
                    processMmrProHL7Scores(nav);
                    processTyrerCuzickHL7Scores(nav);
                    processTyrerCuzickv7HL7Scores(nav);
                    processMyriadHL7Score(nav);
                    processClausHL7Scores(nav);
                    processGailHL7Scores(nav);
                    processCCRATHL7Scores(nav);
                    processPREMMScores(nav);
                    //invoke sp_RunNCCN if appropriate
                    BCDB2.Instance.ExecuteNonQuery("EXEC sp_RunNCCN @apptid='" + apptid + "'");
                    RP.NCCNGuideline.BackgroundListLoad();

                    HraModelChangedEventArgs args = new HraModelChangedEventArgs(null);

                    //since we know we have new risk scores, persist 'em
                    foreach (Person p in FHx.Relatives)
                    {
                        p.RP.PersistFullObject(args);
                    }

                }
                catch (Exception e)  //exceptioned out on web service call; likely due to timeout
                {
                    if (dump)
                    {
                        File.WriteAllText("AggregatorReply.xml", e.Message);
                    }
                    //Configurator.aggregatorActive = false;
                    //updateServiceStatusOnMainForm(false);
                    //doThisWhenNotUsingAggregator();
                }

            } //end of if block for using Aggregator Service
            else
            {
                doThisWhenNotUsingAggregator();
            }

            BCDB2.Instance.ExecuteNonQuery("EXEC sp_3_populateBigQueue @unitnum='"+unitnum+"'");

            //RunCdsForm cds = new RunCdsForm();
            //cds.apptid = apptid;
            //cds.unitnum = unitnum;

            //cds.ShowDialog();

            //cdsBreastOvary.LoadObject();
        }