Help to capture data vertically

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Help to capture data vertically

03 Mar 2018, 07:47

I trying to capture specific fields but getting duplicate/blank lines in txt file.

Here is my script

Code: Select all

F1::

Inputdata = %Clipboard%
Clipboard=

Stringreplace, inputdata, inputdata, ID# (primary insurance), Capture_Pri_ID=, all
Stringreplace, inputdata, inputdata, ID# (secondary Insurance), Capture_Sec_ID=, all
Stringreplace, inputdata, inputdata, Is there a secondary insurance?, Sec_Flag=,all
DataInput := StrReplace(inputdata, "`r`n", "`n")


Loop, parse, DataInput, `n, `r
{

Input := A_LoopField

RegExMatch(input, "i)Patient Name ([^\n]+)", Get_Name)
RegExMatch(input, "i)Address ([^\+]+)", Get_Add)
RegExMatch(input, "i)DOB ([^\n]+)", Get_DOB)
RegExMatch(input, "i)Gender ([^\n]+)", Get_Gender)
RegExMatch(input, "i)Phone ([^\n]+)", Get_Phone)
RegExMatch(input, "i)Primary Insurance ([^\n]+)", Get_Pri_Sub)
RegExMatch(input, "i)Capture_Pri_ID=([^\n]+)", Get_Pri_ID)
RegExMatch(input, "i)Primary Name ([^\n]+)",  Get_Pri_Sub_Name)
RegExMatch(input, "i)Primary DOB ([^\n]+)",  Get_Pri_Sub_DOB)
RegExMatch(input, "i)Pt. Relationship to Primary Member ([^\n]+)", Get_Rel_Pri)
RegExMatch(input, "i)Sec_Flag=([^\n]+)", Get_Sec_Flag)
RegExMatch(input, "i)Secondary Insurance ([^\n]+)", Get_Sec_Name)
RegExMatch(input, "i)Capture_Sec_ID=([^\n]+)", Get_Sec_ID)
RegExMatch(input, "i)Secondary Name ([^\n]+)", Get_Sec_Sub_Name)
RegExMatch(input, "i)Secondary DOB ([^\n]+)", Get_Sec_Sub_DOB)
RegExMatch(input, "i)Pt. Relationship to Secondary Member ([^\n]+)", Get_Rel_Sec)
RegExMatch(input, "i)Date of Service ([^\n]+)", Get_DOS)
RegExMatch(input, "i)Doctor ([^\n]+)", Get_DrName)
RegExMatch(input, "i)Total Patient Paid ([^\n]+)", Get_Copay)
RegExMatch(input, "i)Notes ([^\+]+)", Get_Notes)
RegExMatch(input, "i)Re-submission Comments ([^\n]+)", Get_Resub)

	Get_Name1 = %Get_Name1%
	Get_Add1 = %Get_Add1%
	Get_DOB1 = %Get_DOB1%
	Get_Gender1 = %Get_Gender1%
	Get_Phone1 = %Get_Phone1%
	Get_Pri_Sub1 = %Get_Pri_Sub1%
	Get_Pri_ID1 = %Get_Pri_ID1%
	Get_Pri_Sub_Name1 = %Get_Pri_Sub_Name1%
	Get_Pri_Sub_DOB1 = %Get_Pri_Sub_DOB1%
	Get_Rel_Pri1 = %Get_Rel_Pri1%
	Get_Sec_Flag1 = %Get_Sec_Flag1%
	Get_Sec_Name1 = %Get_Sec_Name1%
	Get_Sec_ID1 = %Get_Sec_ID1%
	Get_Sec_Sub_Name1 = %Get_Sec_Sub_Name1%
	Get_Sec_Sub_DOB1 = %Get_Sec_Sub_DOB1%
	Get_Rel_Sec1 = %Get_Rel_Sec1%
	Get_DOS1 = %Get_DOS1%
	Get_DrName1 = %Get_DrName1%
	Get_Copay1 = %Get_Copay1%
	Get_Notes1 = %Get_Notes1%
	Get_Resub1 = %Get_Resub1%



Stringreplace, Get_Notes1, Get_Notes1, `n, #xxzz, All
Stringreplace, Get_Notes1, Get_Notes1, `r,  #xxzz, All

Stringreplace, New_Note, Get_Notes1, #xxzzProcedures#xxzz, `n, All

Stringsplit, Full_Note, New_Note, `n

Stringreplace, Full_Note1, Full_Note1, #xxzz, %A_Space%, All


StringReplace, Get_Phone1, Get_Phone1, )%A_Space%, )-, All
Stringsplit, Pt_Add, Get_Add1, `n
	
	Pt_Add1 = %Pt_Add1%
	Pt_Add2 = %Pt_Add2%

Stringsplit, Pt_City, Pt_Add2, `,
	
	Pt_City1 = %Pt_City1%
	Pt_City2 = %Pt_City2%

Stringsplit, St_Zip, Pt_City2, %A_Space%

Stringsplit, Pt_Name, Get_Name1, %A_Space%
Stringsplit, Pri_Sub_Name, Get_Pri_Sub_Name1, %A_Space%
Stringsplit, Sec_Sub_Name, Get_Sec_Sub_Name1, %A_Space%


	Sec_Sub_Lname = %Sec_Sub_Name2% %Sec_Sub_Name3%
	
	Sec_Sub_Lname = %Sec_Sub_Lname%
		
	Pri_Sub_Lname = %Pri_Sub_Name2% %Pri_Sub_Name3%
	
	Pri_Sub_Lname = %Pri_Sub_Lname%

	Last_Name = %Pt_Name2% %Pt_Name3%
	
	Last_Name = %Last_Name%

	Full_Name = %Last_Name%, %Pt_Name1%
	
	Pri_Sub_Full_Name = %Pri_Sub_Lname%, %Pri_Sub_Name1%

	Sec_Sub_Full_Name = %Sec_Sub_Lname%, %Sec_Sub_Name1%

	if Full_Name   = `,
	Full_Name =

	if Sec_Sub_Full_Name  = `,
	Sec_Sub_Full_Name=

	if Pri_Sub_Full_Name = `,
	Pri_Sub_Full_Name =

	
	St_Zip1 = %St_Zip1%
	St_Zip2 = %St_Zip2%
	


FileAppend, %Full_Name%`t%Pt_Add1%`t%Pt_City1%`t%St_Zip1%`t%St_Zip2%`t%Get_DOB1%`t%Get_Gender1%`t%Get_Phone1%`t%Get_Pri_Sub1%`t%Get_Pri_ID1%`t%Pri_Sub_Full_Name%`t%Get_Pri_Sub_DOB1%`t%Get_Rel_Pri1%`t%Get_Sec_Flag1%`t%Get_Sec_Name1%`t%Get_Sec_ID1%`t%Sec_Sub_Full_Name%`t%Get_Sec_Sub_DOB1%`t%Get_Rel_Sec1%`t%Get_DOS1%`t%Get_DrName1%`t%Get_Copay1%`t%Full_Note1%`t%Get_Resub1%`n, W:\Ded Hold 2018\Data_Text.txt


Pt_Add1=
Pt_City1=
St_Zip1=
St_Zip2=
Get_DOB1=
Get_Gender1=
Get_Phone1=
Get_Pri_Sub1=
Get_Pri_ID1=
Pri_Sub_Full_Name=
Get_Pri_Sub_DOB1=
Get_Rel_Pri1=
Get_Sec_Flag1=
Get_Sec_Name1=
Get_Sec_ID1=
Sec_Sub_Full_Name=
Get_Sec_Sub_DOB1=
Get_Rel_Sec1=
Get_DOS1=
Get_DrName1=
Get_Copay1=
Full_Note1=
Get_Resub1=
Sec_Sub_Lname=
Pri_Sub_Lname=
Last_Name=
Pri_Sub_Full_Name=
Full_Name=
Sec_Sub_Full_Name=
Pt_Name=
Pt_Add1=
Pt_Add2=
inputdata=

}

Msgbox, Task has been completed

return
and here is data

Code: Select all

Form Name: The ABXZ Group
Submission Time: February 6, 2001 10:10 am
Browser: Chrome 63.0.3239.111 / Windows 8.1
IP Address: XX.XX.XX..XXX.
Unique ID: 00099988
Location: 40121445, Unknown
Date of Service 01/02/1901
Choose One Other: do not bill Customer.
Patient Name DOE JOHNONE
Doctor XXXX, ZZZZ
Address 111 NONE AVE
NONE, NY 12345
Phone (000) 999-9999
DOB 01/01/1801
Gender M
Pt. Relationship to Primary Member Spouse
Primary Name DOE SPOUSE
Primary DOB 01/01/1802
Primary Insurance NEW INSURANCE
ID# (primary insurance) XXX1212454545
Is there a secondary insurance? No
Procedures
Special Services Fundus Photography ST11111
VF-Intermediate RT32232
External Photography VT21454
Choose to open lists Retina
Other (enter code)
Retina Vitreous Strands	H43.31__
Vitreous Strands H43.313
Retina DX connected to Procedure: ST11111
Other Other1
Other2
Other1 H53.143
Other2 H11.153
Other1 DX connected to Procedure: RT32232
Other2 DX connected to Procedure: VT21454
Total Patient Paid 0.00
Form Name: The ABXZ Group
Submission Time: February 6, 2001 10:10 am
Browser: Chrome 63.0.3239.111 / Windows 8.1
IP Address: XX.XX.XX..XXX.
Unique ID: 00099988
Location: 40121445, Unknown
Date of Service 01/02/1902
Choose One EE
Patient Name DOE JOHNTWO
Doctor YYYY, XXXXX
Address 1 NONE ST
NONE, NY 12345
Phone (888) 888-8888
DOB 01/17/1861
Gender M
Pt. Relationship to Primary Member Spouse
Primary Name DOE SPOUSE-TWO
Primary DOB 01/02/1856
Primary Insurance OTHER INSURANCE
ID# (primary insurance) 115455X4540
Is there a secondary insurance? No
Procedures
Eye Exams EP Intermediate VT92014
Refraction ST92015
92014 amt pd 10.00
92015 amt pd 0.00
Special Services Fundus Photography VT92250
VF-Extended ST92083
92250 amt pd 0.00
92083 amt pd 0.00
ICD-10 CM
Choose to open lists Visual Disorders
Other (enter code)
Visual Disorders Presbyopia	H52.4
Presbyopia H52.4
Visual Disorders DX connected to
Procedure:
VT92014, ST92015
Other Other1
Other1 H35.033
Other1 DX connected to Procedure: VT92250, ST92083
Total Patient Paid 10.00
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Re: Help to capture data vertically

08 Mar 2018, 11:26

Finally i have find out the solution. so major part has been fixed.

But still looking for help to complete the script. I want to capture colored text. The value could be changed but the format will remain same as "1 alphabet then 2 number then dot. Like H25.04, it could be H25.0444, H25.044TA

I have no idea how to use regexmatch here. Please help me out
Choose to open lists Cataract
Visual Disorders
Other (enter code)
Visual Disorders Presbyopia H52.4
Presbyopia H52.4
Visual Disorders DX connected to
Procedure:
92015
Cataract Posterior Subcapsular H25.04 __
Posterior Subcapsular H25.043
Cataract DX connected to Procedure: 99203
Other Other1
Other1 H15.843
Other1 DX connected to Procedure: 92250, 92082
Total Patient Paid 25.00
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Help to capture data vertically

08 Mar 2018, 12:01

If RegExMatch isn't your cup of tea StrSplit() comes to the rescue. But hey, it's never too late to learn RegEx :mrgreen: :silent: (except for me!)
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Help to capture data vertically

08 Mar 2018, 12:39

This might help:

Code: Select all

string =
(
Choose to open lists Cataract
Visual Disorders
Other (enter code)
Visual Disorders Presbyopia H52.4
Presbyopia H52.4
Visual Disorders DX connected to
Procedure:
92015
Cataract Posterior Subcapsular H25.04 __
Posterior Subcapsular H25.043
Cataract DX connected to Procedure: 99203
Other Other1
Other1 H15.843
Other1 DX connected to Procedure: 92250, 92082
Total Patient Paid 25.00
)
Pos := 1
while (Pos := RegExMatch(string, "O)(\w\d{2}\..*?)\s", Match, Pos) + Match.Len(1))
{
   MsgBox % "|" Match[1] "|"
}
ExitApp
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Re: Help to capture data vertically

12 Mar 2018, 03:13

Thanks, iPhilip.
its working fine but it also capturing other data like "Total Patient Paid 125.00"

I just need to capture a value which has 1 alpha 2 digit then dot. Like H25.0 or H25.144
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Help to capture data vertically

12 Mar 2018, 04:29

Thank you for letting me know. Will you let me know if the version below works for you?

Code: Select all

string =
(
Choose to open lists Cataract
Visual Disorders
Other (enter code)
Visual Disorders Presbyopia H52.4
Presbyopia H52.4
Visual Disorders DX connected to
Procedure:
92015
Cataract Posterior Subcapsular H25.04 __
Posterior Subcapsular H25.043
Cataract DX connected to Procedure: 99203
Other Other1
Other1 H15.843
Other1 DX connected to Procedure: 92250, 92082
Total Patient Paid 125.00
Other1 DX connected to Procedure: 92250, 92082
)
Pos := 1
while (Pos := RegExMatch(string, "O)([a-zA-Z]\d{2}\..*?)\s", Match, Pos) + Match.Len(1))
{
   MsgBox % "|" Match[1] "|"
}
ExitApp
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Re: Help to capture data vertically

12 Mar 2018, 05:25

Thanks you so much.

Can we add one more exception here. Actually i don't want to capture value if value has dash. Like H43.31__
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Help to capture data vertically

12 Mar 2018, 13:10

Yes. See if the version below works for you:

Code: Select all

; Allows (a-z upper/lower case character) (digit) (digit) . (any number of a-z upper/lower characters or digits in any order)
; Remove the "i" in the options, i.e. "O)...", to make it match only upper case characters

string =
(
Choose to open lists Cataract
Visual Disorders
Other (enter code)
Visual Disorders Presbyopia H52.4
Presbyopia H52.4
Visual Disorders DX connected to
Procedure:
92015
Cataract Posterior Subcapsular H25.04 __
Cataract Posterior Subcapsular H25.04__
Posterior Subcapsular H25.043
Cataract DX connected to Procedure: 99203
Other Other1
Other1 H15.843
Other1 DX connected to Procedure: 92250, 92082
Total Patient Paid 125.00
Other1 DX connected to Procedure: 92250, 92082
)
Pos := 1
while (Pos := RegExMatch(string, "iO)([A-Z]\d{2}\.[A-Z0-9]*?)\s", Match, Pos) + Match.Len(1))
{
   MsgBox % "|" Match[1] "|"
}
ExitApp
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Re: Help to capture data vertically

19 Mar 2018, 08:42

Sorry to bothering you again.

Can we add one more exception here to prevent duplicate values. Like, if H43.31 are twice or thrice then just capture once.
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Help to capture data vertically

19 Mar 2018, 12:10

No problem. I am happy to help. The script below should work:

Code: Select all

string =
(
Choose to open lists Cataract
Visual Disorders
Other (enter code)
Visual Disorders Presbyopia H52.4
Presbyopia H52.4
Visual Disorders DX connected to
Procedure:
92015
Cataract Posterior Subcapsular H25.04 __
Cataract Posterior Subcapsular H25.04__
Posterior Subcapsular H25.043
Cataract DX connected to Procedure: 99203
Other Other1
Other1 H15.843
Other1 DX connected to Procedure: 92250, 92082
Total Patient Paid 125.00
Other1 DX connected to Procedure: 92250, 92082
)
Pos := 1, Values := ""
while (Pos := RegExMatch(string, "i)([A-Z]\d{2}\.[A-Z0-9]*?)\s", Match, Pos + StrLen(Match1)))
{
   if Match1 not in %Values%
   {
      Values .= Match1 ","  ; Create a comma-separated string of unique values
      MsgBox % "|" Match1 "|"
   }
}
ExitApp
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Re: Help to capture data vertically

26 Mar 2018, 10:10

I can capture right side value but no idea how to capture left side value. Like, below are data sample and i want to capture left and right side values. red color values are unique.
Visual Disorders DX connected to Procedure: 92015, 92310
Retina DX connected to Procedure: 92250
Other1 DX connected to Procedure: 99213, 92285
Other2 DX connected to Procedure: 92082
Cornea DX connected to Procedure: 99213, 92285
Other3 DX connected to Procedure: 92082
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Help to capture data vertically

26 Mar 2018, 12:13

Perhaps:

Code: Select all

string=
(
Visual Disorders DX connected to Procedure: 92015, 92310
Retina DX connected to Procedure: 92250
Other1 DX connected to Procedure: 99213, 92285
Other2 DX connected to Procedure: 92082
Cornea DX connected to Procedure: 99213, 92285
Other3 DX connected to Procedure: 92082
)
msgbox % RegExReplace(string, "\s+DX connected to Procedure:\s+"," " )
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Help to capture data vertically

26 Mar 2018, 13:08

I hope this helps:

Code: Select all

string =
(
Visual Disorders DX connected to Procedure: 92015, 92310
Retina DX connected to Procedure: 92250
Other1 DX connected to Procedure: 99213, 92285
Other2 DX connected to Procedure: 92082
Cornea DX connected to Procedure: 99213, 92285
Other3 DX connected to Procedure: 92082
)
Pos := 1
while (Pos := RegExMatch(string, "\s?(.*?) DX connected to Procedure: (\d*)(, (\d*))?", Match, Pos + StrLen(Match)))
   MsgBox % A_Index "`n" Match1 "`n" Match2 "`n" Match4
ExitApp
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Guest

Re: Help to capture data vertically

27 Mar 2018, 02:45

Thanks to help me out but it doesn't work if i have changed the format. like, here i have changed `n to `t. below are new data format.

Choose to open lists Retina Visual Disorders Visual Disorders Myopia H52.1 __ Myopia H52.13 Visual Disorders DX connected to Procedure: 92004, 92015, 92310,92310 Retina Vitreous Floaters H43.39 __ Vitreous Floaters H43.391 Retina DX connected to Procedure: 92250 Total Patient Paid 75.00
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Re: Help to capture data vertically

27 Mar 2018, 02:48

Thanks to help me out. but i doesn't work if i changed the data format. data format could be `t as well. below are new data format.

Choose to open lists Retina Visual Disorders Visual Disorders Myopia H52.1 __ Myopia H52.13 Visual Disorders DX connected to Procedure: 92004, 92015, 92310,92310 Retina Vitreous Floaters H43.39 __ Vitreous Floaters H43.391 Retina DX connected to Procedure: 92250 Total Patient Paid 75.00
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Re: Help to capture data vertically

27 Mar 2018, 10:21

Somehow i have solve tab format issue.
But i want to capture left side value.

Choose to open lists Retina Visual Disorders Visual Disorders Myopia H52.1[`t]Myopia H52.13[`t]Visual Disorders DX connected to Procedure: 92004, 92015, 92310,92310 Retina Vitreous Floaters H43.39[`t]Vitreous Floaters H43.391 Retina DX connected to Procedure: 92250 Total Patient Paid 75.00
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Help to capture data vertically

27 Mar 2018, 12:14

Hi Pardeep,

The version I posted above works when the newlines are replaced by tabs:

Code: Select all

string =
(
Visual Disorders DX connected to Procedure: 92015, 92310	Retina DX connected to Procedure: 92250	Other1 DX connected to Procedure: 99213, 92285	Other2 DX connected to Procedure: 92082	Cornea DX connected to Procedure: 99213, 92285	Other3 DX connected to Procedure: 92082
)
Pos := 1
while (Pos := RegExMatch(string, "\s?(.*?) DX connected to Procedure: (\d*)(, (\d*))?", Match, Pos + StrLen(Match)))
   MsgBox % A_Index "`n" Match1 "`n" Match2 "`n" Match4
ExitApp
I don't understand your new format. Can you specify the input that you are working with (including if entries are separated by tabs or newlines) and the output that you want (what you want and the format, e.g. strings or arrays)?

Thank you.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Pardeep Tariyal
Posts: 61
Joined: 30 Aug 2017, 08:43

Re: Help to capture data vertically

28 Mar 2018, 13:50

New format has some different values which are separated by tab
Choose to open lists Retina Visual Disorders`tVisual Disorders Myopia H52.1`tMyopia H52.13`tVisual Disorders DX connected to Procedure: 92004, 92015, 92310,92310`tRetina Vitreous Floaters H43.39`tVitreous Floaters H43.391`tRetina DX connected to Procedure: 92250 Total Patient Paid 75.00

Please paste above text into notepad then replace `t to actual tab.

Once done you will get the correct format.

Now i want to capture an alphanumeric values along with previous values.

Code: Select all

output
H52.13 `t Visual Disorders `t 92004, 92015, 92310,92310
H43.391 `t Retina `t 92250
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Help to capture data vertically

28 Mar 2018, 15:27

This should work:

Code: Select all

string =
(
Choose to open lists Retina Visual Disorders	Visual Disorders Myopia H52.1	Myopia H52.13	Visual Disorders DX connected to Procedure: 92004, 92015, 92310,92310	Retina Vitreous Floaters H43.39	Vitreous Floaters H43.391	Retina DX connected to Procedure: 92250 Total Patient Paid 75.00
)
Pos := 1
; Seaches for (space) (string comprised of "H"s, digits, and dots) (tab) (string comprised of letters and spaces) (space) ("DX ... Procedure") (space) (string comprised of digits, commas, and spaces)
while (Pos := RegExMatch(string, "i)\s([H\d.]*)\t([A-Z\s]*)\sDX connected to Procedure:\s([\d,\s]*)", Match, Pos + StrLen(Match)))
   MsgBox % Match1 "`t" Match2 "`t" Match3
ExitApp
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, vysmaty and 246 guests