loops - AHK: Remove Duplicates While Parsing Text Into Array -
i work @ doctors office doing billing, , i've been writing code streamline billing process. must include diagnoses in billing software, copy whole chart, , parse array newlines looking prefix icd-10, , if 2 codes on same line, separates (via comma). before that, removes part (if exists) of chart includes canceled procedures canceled procedures aren't charged. sometimes, multiple of same diagnosis included in chart purpose of ordering procedure (it's automatic), , need add each diagnosis array once.
[...] sendinput, ^a clipboard := sendinput, ^c clipwait blockinput, mousemoveoff lstring := clipboard sleep, 200 ifinstring, lstring, canceled orders { lstringleft := substr(lstring, 1, instr(lstring, "canceled orders")-1) sleep, 20 lstringright := substr(lstring, instr(lstring, "allergies of")) sleep, 20 lstring := sleep, 20 lstring := lstringleft sleep, 20 lstring .= lstringright sleep, 20 } dxarr := [] numdx := 0 loop, parse, lstring, `n if instr(a_loopfield, "icd-10") loop, parse, a_loopfield, `, dxarr[++numdx] := trim(substr(a_loopfield, instr(a_loopfield, ":") + 1), " `t`n`r") [...]
the ideal output for
essential hypertension
icd-9-cm: 401.0
icd-10-cm: i10
essential hypertension chronic kidney disease, stage 3
icd-9-cm: 585.3, 401.0
icd-10-cm: n18.3, i10
is
i10 n18.3
i've been @ several different solutions found on internet, far, they've made mess rather fixing problem. appreciated!
use hash remove duplicates. use code key , dummy value. use "true" below dummy value. duplicate records have same key replace previous key-value pair.
output hash's keys after done parsing input.
dxhash := {} loop, parse, lstring, `n if instr(a_loopfield, "icd-10") loop, parse, a_loopfield, `, dxhash[trim(substr(a_loopfield, instr(a_loopfield, ":") + 1), " `t`n`r")] := true diagnosis,dummy in dxhash send %diagnosis%{space}
Comments
Post a Comment