using System; using System.Collections.Generic; using System.IO; using System.Text; namespace Ex3 { class Program { static void Main(string[] args) { HashSet<string> setID = new HashSet<string>(); HashSet<string> setDepress = new HashSet<string>(); int count = 0;//計算有幾筆資料 string filename = args[0];//檔案名稱 StreamReader sr = new StreamReader(filename); string line = sr.ReadLine(); while (line != null && line.Length > 1) { string ID = line.Substring(91, 32); string ICD9_1 = line.Substring(131, 5); string ICD9_2 = line.Substring(136, 5); string ICD9_3 = line.Substring(141, 5); string ICD9_T1 = ICD9_1.Substring(0, 3); string ICD9_T2 = ICD9_2.Substring(0, 3); string ICD9_T3 = ICD9_3.Substring(0, 3); string ICD9_F1 = ICD9_1.Substring(0, 4); string ICD9_F2 = ICD9_2.Substring(0, 4); string ICD9_F3 = ICD9_3.Substring(0, 4); if (ICD9_T1 == "491" || ICD9_T1 == "492" || ICD9_T1 == "496" || ICD9_T2 == "491" || ICD9_T2 == "492" || ICD9_T2 == "496" || ICD9_T3 == "491" || ICD9_T3 == "492" || ICD9_T3 == "496") { count++; Console.WriteLine(line); if (!setID.Contains(ID)) setID.Add(ID); } if (setID.Contains(ID)) { if (ICD9_F1 == "2962" || ICD9_F2 == "2962" || ICD9_F3 == "2962" || ICD9_F1 == "2963" || ICD9_F2 == "2963" || ICD9_F3 == "2963" || ICD9_F1 == "3004" || ICD9_F2 == "3004" || ICD9_F3 == "3004" || ICD9_T1 == "311" || ICD9_T1 == "311" || ICD9_T1 == "311") { if (!setDepress.Contains(ID)) setDepress.Add(ID); } } line = sr.ReadLine(); } //Console.WriteLine("Number=" + count ); Console.WriteLine("Number=" + count + " COPD =" + setID.Count + " Depression =" + setDepress.Count); } } }
This entry was posted
on 星期一, 十二月 21st, 2015 at 02:20:15 and is filed under 104(上).
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Leave a reply