コード例 #1
0
        private void runDiagnosticForDate(string aDate)
        {
            intChart = new IntelleChartSpider(propertyFile);

            this.currentStatus = "Retrieving all Patients";
            DateTime thisDate = DateTime.Parse(aDate);
            if (allChartNumbers.ContainsKey(thisDate))
            {
                intChart.getAllPatients(aDate, (string[])allChartNumbers[thisDate]);
            }
 
            this.currentStatus = "Downloading Encounter Forms";
            intChart.downloadEncounter(data["ENCOUNTER_FOLDER"], aDate, this.forceDownload);
            this.currentStatus = "Getting Diagnosis";
            intChart.getDiagnosis(aDate);
            this.currentStatus = "Complete";
            patientDiagnostics = intChart.getPatientsByChartNumber();
            // Open the log file for append and write the log
            StreamWriter sw = new StreamWriter(data["RUN_LOG"], true);
            MemoryStream stream = new MemoryStream();
            bool hasErrors = false;
            foreach (DictionaryEntry ev in patientDiagnostics)
            {
                if (!(bool)((Hashtable)ev.Value)["HasAllDiagnosis"] || (bool)((Hashtable)ev.Value)["HasErrors"])
                {
                    hasErrors = true;
                    break;
                }
            }
            StringWriter tw = new StringWriter();
            Hashtable diagnosticData, errors, patientInfo;
            sw.WriteLine("{0} {1} {2}", DateTime.Now, hasErrors ? "Has Errors" : "Has No Errors", aDate);
            tw.WriteLine(String.Format("{0} {1} {2}", DateTime.Now, hasErrors ? "Has Errors" : "Has No Errors", aDate));
            if (hasErrors)
            {
                foreach (DictionaryEntry ev in patientDiagnostics)
                {
                    patientInfo = (Hashtable)ev.Value;
                    diagnosticData = (Hashtable)patientInfo["Diagnosis"];
                    errors = (Hashtable)patientInfo["Errors"];
                    foreach (DictionaryEntry pv in diagnosticData)
                    {
                        if (!(bool) pv.Value)
                        {
                            sw.WriteLine("{0} {1} {2} {3}", DateTime.Now, patientInfo["ChartNumber"], patientInfo["AppointmentDateTime"], pv.Key);
                            tw.WriteLine("{0} {1} {2} {3}", DateTime.Now, patientInfo["ChartNumber"], patientInfo["AppointmentDateTime"], pv.Key);
                        }
                    }
                    foreach (DictionaryEntry pv in errors)
                    {
                        sw.WriteLine("{0} {1} {2} {3}", DateTime.Now, patientInfo["ChartNumber"], patientInfo["AppointmentDateTime"], pv.Value);
                        tw.WriteLine("{0} {1} {2} {3}", DateTime.Now, patientInfo["ChartNumber"], patientInfo["AppointmentDateTime"], pv.Value);
                    }  
                }
            }
            
            sw.Close();
            diagnosticResults += tw.ToString() + "\n";
        }