16
十二月

醫學資訊管理-NHIRD Ex1-12/16

   Posted by: admin   in 103(上)醫學資訊管理

//Form1.cs
private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                return;
            textBox1.Text = openFileDialog1.FileName;
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            StreamReader sr = new StreamReader(textBox1.Text);
            StreamWriter sw = new StreamWriter(textBox2.Text);
 
            string line = sr.ReadLine();
            while (line != null)
            {
                NHIRD_CD cd = ParseCDLine(line);
                int pos1 = cd.ACODE_ICD9_1.IndexOf("250");
                int pos2 = cd.ACODE_ICD9_2.IndexOf("250");
                int pos3 = cd.ACODE_ICD9_3.IndexOf("250");
                if (pos1 == 0 || pos2 == 0 || pos3 == 0) 
                    sw.WriteLine(line);
 
                line = sr.ReadLine();
            }
 
        }
        NHIRD_CD ParseCDLine(string line)
        {
            NHIRD_CD cd = new NHIRD_CD();
            if (line.Length == 299)
            {
                cd.FEE_YM = line.Substring(0, 6);
                cd.APPL_TYPE = line.Substring(6, 1);
                cd.HOSP_ID = line.Substring(7, 34);
                cd.APPL_DATE = line.Substring(41, 8);
                cd.CASE_TYPE = line.Substring(49, 2);
                cd.SEQ_NO = line.Substring(51, 6);
 
                cd.CURE_ITEM_NO1 = line.Substring(57, 2);
                cd.CURE_ITEM_NO2 = line.Substring(59, 2);
                cd.CURE_ITEM_NO3 = line.Substring(61, 2);
                cd.CURE_ITEM_NO4 = line.Substring(63, 2);
 
                cd.FUNC_TYPE = line.Substring(65, 2);
                cd.FUNC_DATE = line.Substring(67, 8);
                cd.TREAT_END_DATE = line.Substring(75, 8);
                cd.ID_BIRTHDAY = line.Substring(83, 8);
                cd.ID = line.Substring(91, 32);
 
                cd.CARD_SEQ_NO = line.Substring(123, 2);
                cd.GAVE_KIND = line.Substring(126, 1);
                cd.PART_NO = line.Substring(127, 3);
 
                cd.ACODE_ICD9_1 = line.Substring(130, 5).Trim();
                cd.ACODE_ICD9_2 = line.Substring(135, 5).Trim();
                cd.ACODE_ICD9_3 = line.Substring(140, 5).Trim();
 
                cd.ICD_OP_CODE = line.Substring(145, 4);
                cd.DRUG_DAY = line.Substring(149, 2);
 
                cd.MED_TYPE = line.Substring(151, 1);
                cd.PRSN_ID = line.Substring(152, 32);
                cd.PHAR_ID = line.Substring(184, 32);
 
                cd.DRUG_AMT = line.Substring(216, 8);
                cd.TREAT_AMT = line.Substring(224, 8);
                cd.TREAT_CODE = line.Substring(232, 12);
                cd.DIAG_AMT = line.Substring(244, 8);
 
                cd.DSVC_NO = line.Substring(252, 12).Trim();
                cd.DSVC_AMT = line.Substring(264, 8).Trim();
                cd.BY_PASS_CODE = line.Substring(272, 2).Trim();
                cd.T_AMT = line.Substring(274, 8).Trim();
                cd.PART_AMT = line.Substring(282, 8).Trim();
                cd.T_APPL_AMT = line.Substring(290, 8).Trim();
                cd.ID_SEX = line.Substring(298, 1);
            }
            else if (line.Length == 300)
            {
                int x = 1;
                cd.FEE_YM = line.Substring(0, 6);
                cd.APPL_TYPE = line.Substring(6, 1);
                cd.HOSP_ID = line.Substring(7, 34);
                cd.APPL_DATE = line.Substring(41, 8);
                cd.CASE_TYPE = line.Substring(49, 2);
                cd.SEQ_NO = line.Substring(51, 6);
 
                cd.CURE_ITEM_NO1 = line.Substring(57, 2);
                cd.CURE_ITEM_NO2 = line.Substring(59, 2);
                cd.CURE_ITEM_NO3 = line.Substring(61, 2);
                cd.CURE_ITEM_NO4 = line.Substring(63, 2);
 
                cd.FUNC_TYPE = line.Substring(65, 2);
                cd.FUNC_DATE = line.Substring(67, 8);
                cd.TREAT_END_DATE = line.Substring(75, 8);
                cd.ID_BIRTHDAY = line.Substring(83, 8);
                cd.ID = line.Substring(91, 32);
 
                cd.CARD_SEQ_NO = line.Substring(123, 4);//2->4
                cd.GAVE_KIND = line.Substring(126 + x, 1);
                cd.PART_NO = line.Substring(127 + x, 3);
 
                cd.ACODE_ICD9_1 = line.Substring(130 + x, 5).Trim();
                cd.ACODE_ICD9_2 = line.Substring(135 + x, 5).Trim();
                cd.ACODE_ICD9_3 = line.Substring(140 + x, 5).Trim();
 
                cd.ICD_OP_CODE = line.Substring(145 + x, 4);
                cd.DRUG_DAY = line.Substring(149 + x, 2);
 
                cd.MED_TYPE = line.Substring(151 + x, 1);
                cd.PRSN_ID = line.Substring(152 + x, 32);
                cd.PHAR_ID = line.Substring(184 + x, 32);
 
                cd.DRUG_AMT = line.Substring(216 + x, 8);
                cd.TREAT_AMT = line.Substring(224 + x, 8);
                cd.TREAT_CODE = line.Substring(232 + x, 12);
                cd.DIAG_AMT = line.Substring(244 + x, 8);
 
                cd.DSVC_NO = line.Substring(252 + x, 12).Trim();
                cd.DSVC_AMT = line.Substring(264 + x, 8).Trim();
                cd.BY_PASS_CODE = line.Substring(272 + x, 2).Trim();
                cd.T_AMT = line.Substring(274 + x, 8).Trim();
                cd.PART_AMT = line.Substring(282 + x, 8).Trim();
                cd.T_APPL_AMT = line.Substring(290 + x, 8).Trim();
                cd.ID_SEX = line.Substring(298 + x, 1);
            }
            return cd;
        }
//NHIRD_CD.cs
public class NHIRD_CD
    {
        public string FEE_YM;
        public string APPL_TYPE;
        public string HOSP_ID;
        public string APPL_DATE;
        public string CASE_TYPE;
        public string SEQ_NO;
 
        public string CURE_ITEM_NO1;
        public string CURE_ITEM_NO2;
        public string CURE_ITEM_NO3;
        public string CURE_ITEM_NO4;
 
        public string FUNC_TYPE;
        public string FUNC_DATE;
        public string TREAT_END_DATE;
 
        public string ID_BIRTHDAY;
        public string ID;
 
        public string CARD_SEQ_NO;
        public string GAVE_KIND;
        public string PART_NO;
 
        public string ACODE_ICD9_1;
        public string ACODE_ICD9_2;
        public string ACODE_ICD9_3;
 
        public string ICD_OP_CODE;
        public string DRUG_DAY;
        public string MED_TYPE;
 
        public string PRSN_ID;
        public string PHAR_ID;
 
        public string DRUG_AMT;
        public string TREAT_AMT;
        public string TREAT_CODE;
        public string DIAG_AMT;
        public string DSVC_NO;
        public string DSVC_AMT;
        public string BY_PASS_CODE;
        public string T_AMT;
        public string PART_AMT;
        public string T_APPL_AMT;
        public string ID_SEX;
    }

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: ,

This entry was posted on 星期二, 十二月 16th, 2014 at 09:45:33 and is filed under 103(上)醫學資訊管理. 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

Name (*)
Mail (will not be published) (*)
URI
Comment