Jump to content

Looped 2 dimensional arrays


Recommended Posts

Ok, this will probably only make sense if I post the entire loop that's causing the problem.

The script will find the person's name, and DOB as required and then the correct effective date based on the date of servcie. It's just skipping the section where it's looking for the end date.

I figured that the best way to solve this would be a two dimensional array and populate the fields as needed, then pull the correct column based on the $x and $y values.

The kicker is, the script works perfectly with only one column. Once it has to shift from column 1 to column 2, it starts acting screwy.

This one is giving me a migrane and any assistance would be greatly appreciated. Thanks.

CODE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Example text.

; Variable initialization for use in this example:

Dim $from = "01072005", $to = "01072005", $dob = "11101952"

Dim $dobMon = StringLeft($dob, 2) ; DOB month

Dim $dobDay = StringTrimLeft(StringLeft($dob, 4), 2) ; DOB day

Dim $dobYear = StringRight($dob, 2) ; DOB year

Dim $fname = "JAMES"

Dim $lname = "BROWN SR"

;

; Portion of screen scrape (put this in the clipboard)

; LAST FIRST BIRTH

; NAME NAME DATE

; BROWN SR JAMES 111052

;

; HIST NO. ---------01--------- ---------02---------

; EFFECT. DATE 050115 040801

; END DATE 000000 050115

; PRIM CARE PHY 90000000000XYZ12A345 90000000000XYZ987D54

; SELECTION CODE Q Q

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Dim $counter = 0, $q = 0, $x = 0, $y = 0, $z = 0

Dim $effect[3][3]

Dim $enddate[3][3]

Dim $pcparray[3][1]

Dim $tdate[3]

Dim $fdate[3]

Do

Sleep(10)

Dim $counter = $counter + 1, $q = 0

;~ GetScreen ($c)

$screen = StringStripWS(ClipGet(), 4)

Dim $splitscreen = StringSplit($screen, " ")

; This is for working with the current screen.

While $q < ($splitscreen[0] - 1)

Sleep(10)

$q = $q + 1

Select

Case ($splitscreen[$q] = $fname And $splitscreen[ ($q + 1) ] = $dobMon & $dobDay & StringRight($dobYear, 2)) Or _

($splitscreen[$q] = StringLeft($splitscreen[$q] & $splitscreen[ ($q + 1) ], 9) And _

$splitscreen[ ($q + 2) ] = $dobMon & $dobDay & StringRight($dobYear, 2))

$foundname = 1

;~ MsgBox(0, "", "found name", 5)

Case $splitscreen[$q] = "EFFECT." And $splitscreen[ ($q + 1) ] = "DATE"

; split the from date into something that datenew can work with.

; datenew functions for date calculations. Effective date must be less than from: date of service.

While 1

Sleep(10)

$effect[$x][0] = StringLeft($splitscreen[ ($q + 2 + $x) ], 2) ; year

$effect[$x][1] = StringTrimLeft(StringLeft($splitscreen[ ($q + 2 + $x) ], 4), 2) ; month

$effect[$x][2] = StringRight($splitscreen[ ($q + 2 + $x) ], 2) ; day

If $effect[$x][0] > 90 Then

$effect[$x][0] = "19" & $effect[$x][0]

Else

$effect[$x][0] = "20" & $effect[$x][0]

EndIf

$fdate[0] = StringLeft($from, 2) ; month

$fdate[1] = StringTrimLeft(StringLeft($from, 4), 2) ; day

$fdate[2] = StringRight($from, 4) ; year

MsgBox(0, "Effective Dates", "Month: " & $effect[$x][1] & @LF _

& "Day: " & $effect[$x][2] & @LF & "Year: " & $effect[$x][0]) ;### Debug MSGBOX

MsgBox(0, "From Dates", "Month: " & $fdate[0] & @LF _

& "Day: " & $fdate[1] & @LF & "Year: " & $fdate[2]) ;### Debug MSGBOX

$test = _DateDiff("d", $fdate[2] & "/" & $fdate[0] & "/" & $fdate[1], $effect[$x][0] & "/" & $effect[$x][1] & "/" & $effect[$x][2])

MsgBox(0, "DateDiff", $test)

If StringLen($splitscreen[$q + 2 + $x]) = 6 And StringLeft($test, 1) = "-" Then

$effective = $effect[$x][0] & "/" & $effect[$x][1] & "/" & $effect[$x][2]

MsgBox(262144,'debug line ~146' , '$effective:' & @lf & $effective) ;### Debug MSGBOX

ExitLoop

EndIf

$x = $x + 1

WEnd

$foundeffect = 1

MsgBox(0, "", "found first Effective Date " & $splitscreen[ ($q + 2 + $x) ], 5)

;;;; Verified above as working.

;;;; Never selects this case statement, crashes out.

Case $splitscreen[$q] = "END" And $splitscreen[ ($q + 1) ] = "DATE"

; datenew functions for date calculations. End date must be greater than to: date of service.

While 1

Sleep(10)

If $splitscreen[$q + 2 + $y] = "000000" Then

$end = $splitscreen[$q + 2 + $y]

ExitLoop

EndIf

$enddate[$y][0] = StringLeft($splitscreen[ ($q + 2 + $y) ], 2) ; year

$enddate[$y][1] = StringTrimLeft(StringLeft($splitscreen[ ($q + 2 + $y) ], 4), 2) ; month

$enddate[$y][2] = StringRight($splitscreen[ ($q + 2 + $y) ], 2) ; day

If $enddate[$y][0] > 90 Then

$enddate[$y][0] = "19" & $enddate[$y][0]

Else

$enddate[$y][0] = "20" & $enddate[$y][0]

EndIf

$tdate[0] = StringLeft($to, 2) ; month

$tdate[1] = StringTrimLeft(StringLeft($to, 4), 2) ; day

$tdate[2] = StringRight($to, 4) ; year

MsgBox(0, "End Dates", "Month: " & $enddate[$y][1] & @LF _

& "Day: " & $enddate[$y][2] & @LF & "Year: " & $enddate[$y][0]) ;### Debug MSGBOX

MsgBox(0, "To Dates", "Month: " & $tdate[0] & @LF _

& "Day: " & $tdate[1] & @LF & "Year: " & $tdate[2]) ;### Debug MSGBOX

$test = _DateDiff("d", $tdate[2] & "/" & $tdate[0] & "/" & $tdate[1], $enddate[$y][0] & "/" & $enddate[$y][1] & "/" & $enddate[$y][2])

MsgBox(0, "DateDiff", $test)

If StringLen($splitscreen[$q + 2 + $y]) = 6 And StringLeft($test, 1) <> "-" Then

$end = $splitscreen[$q + 2 + $y]

ExitLoop

EndIf

$y = $y + 1

WEnd

$foundend = 1

;~ MsgBox(0, "", "found End Date " & $splitscreen[ ($q + 2 + $y) ], 5)

Case $splitscreen[$q] = "CARE" And $splitscreen[ ($q + 1) ] = "PHY"

While 1

If $splitscreen[ ($q + 2 + $z) ] = "Selection" Then

ExitLoop

Else

$pcparray[$z][0] = $splitscreen[ ($q + 2 + $z) ]

$pcp = $pcparray[$x][0]

EndIf

$z = $z + 1

WEnd

;~ MsgBox(0, "PCP", "Loaded into array. " & $pcp)

ExitLoop

EndSelect

WEnd

If ($foundname = 1 And $foundeffect = 1 And $foundend = 1) Then

ExitLoop

Else

WinActivate($c)

Send("{numpadenter}")

$splitscreen = 0 ; destroy the array and re-make it at top of loop.

EndIf

Until $counter > 9 or ($foundname = 1 And $foundeffect = 1 And $foundend = 1)

NOTE: All information has been changed to conform with HIPAA privacy laws. This is not a real person, effective dates, end dates, or physician number. No Protected Health Information or Personally Identifiable Information will ever be disclosed to anyone at any time.

edit:Corrected the initialization variables and removed a UDF call that is not critical to this example.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

o:)

Ok, I believe I've fixed it.

the problem was in two sections of the Case "End"

1.

If $splitscreen[$q + 2 + $y] = "000000" Then
                  $end = $splitscreen[$q + 2 + $y]
                  ExitLoop
               EndIf

changes to:

If $splitscreen[$q + 2 + $y] = "000000" and $y = $x Then
                  $end = $splitscreen[$q + 2 + $y]
                  ExitLoop
               EndIf

and

2.

If StringLen($splitscreen[$q + 2 + $y]) = 6 And StringLeft($test, 1) <> "-" Then
                     $end = $splitscreen[$q + 2 + $y]
                     ExitLoop
                  EndIf

changes to:

If StringLen($splitscreen[$q + 2 + $y]) = 6 And $test > 0 Then
                  $end = $splitscreen[$q + 2 + $y]
                  ExitLoop
               EndIf

:lmao:

Why is it always the simple stuff that gives the most problems?

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...