因此,我正在为医生办公室进行计费,我们希望三重检查我们给出的流感疫苗实际上已经开始计费。现在,我的AHK检查他们的整个图表是否有像ICD-10 Code Z23这样的密钥,然后检查&#34;流感&#34;。如果它同时找到这两个,它会将患者医疗记录编号添加到65岁或65岁以下的适合年龄的文本文件中。还有10张插槽的纸张,我们手动记录MRN,进行双重检查。我想创建一个脚本来比较三个文件,一个混合MRN文件(65+和<65),如果在混合文件中找到MRN,它应该删除该行。 (我已经在这个主题上进行了一些谷歌搜索,但每个人都建议使用一个库,这只会减慢我的程序。)如果找不到该行,它应该留在主人文件供我审核。我无法弄清楚如何删除线条,更不用说特定的线条了。到目前为止,为了相互检查文件,我有这个。我不是删除行,而是将未开单的数字附加到第四个文本文件,但最终删除会更好。
FILENUM = 1
FILENU = 1
^L::
Loop
{
FileReadLine, MRN, E:\AHK & AHKS\flushot.txt, %LINENUM%
If ErrorLevel
{
break
}
Else
{
Loop
{
FileReadLine, MRNc, E:\AHK & AHKS\Billed65+Flushots.txt, LINENU
StringTrimRight, MRNc, 11
If (MRN != MRNc)
{
LINENU++
Match = 0
}
If (MRN == MRNc)
Match = 1
If ErrorLevel and Match = 0
{
FileAppend, MRN, E:\AHK & AHKS\Unbilledtester.txt
LINENU = 1
}
If (Match = 1)
GoTo Lab2
}
Lab2:
Loop
{
FileReadLine, MRNc, E:\AHK & AHKS\BilledAdultFlushots.txt, LINENU
StringTrimRight, MRNc, 11
If (MRN != MRNc)
{
LINENU++
Match = 0
}
If (MRN == MRNc)
Match = 1
If ErrorLevel and Match = 0
FileAppend, MRN, E:\AHK & AHKS\Unbilledtester.txt
If (Match = 1)
GoTo Lab2
}
LINENUM++
}
}
UPDATE !!!!!!!
好吧,所以我抓住你的代码,我一直试图进行反向检查。在flushot.txt中检查MRNS的成人和高级flushot文本文件的关联数组,如果没有找到,则将它们添加到未开帐单中。下面是我试图改变它的几个尝试,并在flushot.txt中检查成人和高级的MRN,如果没有找到,将它添加到名为notrecorded.txt的文件中,这样我就知道人们有什么flushots和MA谁没有记录(由初级保健提供者)。
FlushotsBilled()
{
Root_Dir := "E:\AHK & AHKS"
fName_Input := "flushot.txt"
fName_Backup := "flushot_old.txt"
fName_Output := "unbilled.txt"
fName_Billed_Adult := "billedAdultFlushots.txt"
fName_Billed_Senior := "billed65+Flushots.txt"
fName_Billed_NR := "notrecorded.txt"
fName_Mixed := "mixrecord.txt"
SetWorkingDir %Root_Dir%
FileDelete, %fName_Output%
AdultFlu := {}
SeniorFlu := {}
GivenFluA := {}
GivenFluB := {}
Mixed := {}
Loop, Read, %fName_Mixed%
Mixed[A_LoopReadLine] := True
Loop, Read, %fName_Billed_Adult%
{
;Loop, Parse, A_LoopReadLine, `t
; AdultFlu[A_LoopField] := True
AdultFlu[A_LoopReadLine] := True
If !Mixed[A_LoopReadLine]
FileAppend, %A_LoopReadLine%`n, %fName_Mixed%
}
Loop, Read, %fName_Billed_Senior%
{
;Loop, Parse, A_LoopReadLine, `t
; SeniorFlu[A_LoopField] := True
SeniorFlu[A_LoopReadLine] := True
If !Mixed[A_LoopReadLine]
FileAppend, %A_LoopReadLine%`n, %fName_Mixed%
}
Loop, Read, %fName_Input% ;check flushot.txt for
If !AdultFlu[SubStr(A_LoopReadLine, 1, InStr(A_LoopReadLine,"`t"))] && !SeniorFlu[SubStr(A_LoopReadLine, 1, InStr(A_LoopReadLine,"`t"))]
;If !AdultFlu[A_LoopReadLine] && !SeniorFlu[A_LoopReadLine] ;flushot is checking the associated arrays
FileAppend, %A_LoopReadLine%`n, %fName_Output% ;if not found, stick it into unbilled.
Loop, Read, %fName_Input%
GivenFluA[A_LoopReadLine] := True
/* Loop, Read, %fName_Billed_Senior%
If !Mixed[A_LoopReadLine]
FileAppend, %A_LoopReadLine%`n, %fName_Mixed%
Loop, Read, %fName_Billed_Adult%
If !Mixed[A_LoopReadLine]
FileAppend, %A_LoopReadLine%`n, %fName_Mixed%
Loop, Read, %fName_Mixed%
Mixed[A_LoopReadLine] := True
*/
Loop, Read, %fName_Mixed%
If !GivenFluA[SubStr(A_LoopReadLine, 1, InStr(A_LoopReadLine,"`t"))] ;a_Loopreadline is a line in mixed. it is looking through flushot.txt for that line, if it's there, it's givenflua's index
Loop, Read, %fName_Billed_NR%
If !GivenFluA[A_LoopReadLine]
FileAppend, %A_LoopReadLine%`n
/*
Loop, Read, %fName_Input% ;read flushot
If Mixed[A_LoopReadLine] Contains A_LoopReadLine ;check to see if each line in flushot is in mixed
GivenFluA[Mixed[A_LoopReadLine]] := True ;Mixed[A_LoopReadLine]
Loop, Read, %fName_Billed_NR%
If !GivenFluA[A_LoopReadLine]
FileAppend GivenFluA[%A_LoopReadLine%], %fName_Billed_NR%
*/
;if readline is in mixed, but not in flushot, check to see if it's in notrecorded, if not, append it
/*
Loop, Read, %fName_Mixed% ;open up the mixed record
IfNotInString, A_LoopReadLine, GivenFluA[A_LoopReadLine] ;see if inside each line, we can find the lines from flushot.txt, if not
;GivenFluB[GivenFluA[A_LoopReadLine]] := True ;if not we give the line from inside flushot to another associative array
GivenFluB[A_LoopReadLine] := True ;lets try this, put the value
Loop, Read, %fName_Mixed%
IfInString, A_LoopReadLine, GivenFluA[A_LoopReadLine]
GivenFluB[A_LoopReadLine]
Loop, Read, %fName_Billed_NR% ;open up not recorded
IfNotInString, A_LoopReadLine, GivenFluB[A_LoopReadLine] ;see if inside each line we can find that line from
FileAppend, %A_LoopReadLine%`n, %fName_Billed_NR%
*/
}
答案 0 :(得分:0)
我认为您通过创建输出文件而不是删除行而走在正确的轨道上。文本文件通常被视为流,而不是固定记录长度的数据文件。删除行很容易出错并且效率不高;你不得不以某种方式压缩文件。
你的文件有多大?如果只有几千名患者,我会将所有内容加载到关联数组中,以便我们可以使用键控查找。
<强>程序强>
^L:: medical_run()
medical_run()
{
root_dir := "E:\AHK & AHKS"
fname_input := "flushot.txt"
fname_backup := "flushot_old.txt"
fname_temp_output := "Unbilledtester.txt"
fname_billed_adult := "billedAdultFlushots.txt"
fname_billed_senior := "billed65+Flushots.txt"
SetWorkingDir %root_dir%
FileDelete %fname_output%
adults := {}
seniors := {}
unmatched := {}
loop READ, %fname_billed_adult%
adults[A_LoopReadLine] := true
loop READ, %fname_billed_senior%
seniors[A_LoopReadLine] := true
loop READ, %fname_input%
if !adults[A_LoopReadLine] && !seniors[A_LoopReadLine]
unmatched[A_LoopReadLine] := true
for code,dummy in unmatched
FileAppend %code%`n, %fname_output%
FileMove %fname_input%, %fname_backup%
FileMove %fname_temp_output%, %fname_input%
}
billedAdultFlushots.txt
101
102
103
104
billed65 + Flushots.txt
205
206
207
208
flushot.txt之前
301
101
103
302
205
301
207
103
303
301
flushot.txt后
301
302
303