AZXZVSIT ;REPORT -AHCCCS VISIT COUNTS BY PROVIDER (APC) [ 05/01/95 1:25 PM ]
;06/02/92 JOHN H. LYNCH
;
;THIS PROGRAM SEARCHES THE MEDICAID ELIGIBLE
;FILE AND PRINTS OUT INFORMATION USING THE PATIENT
;NAME TO PULL INFORMATION FROM THE APC DATA FILE.
;
;PATIENT NAME (MEDICAID ELIGIBLE)
;SSN (APC DATA)
;DATE OF SERVICE (APC DATA)
;PRIMARY PROVIDER (APC DATA)
;MEDICAID NUMBER (MEDICAID ELIGLBLE)
;CHART NUMBER (APC DATA)
;
MAIN ;AZXZVSIT PROGRAM CONTROL
;INITIALIZE LOCAL VARIABLES
;DELETE COMMENT ONLY IF RUNNING THIS ROUTINE IN PROGRAMMER MODE
D ^XBKSET ;INITIALIZE SYSTEM VARIABLES
W @IOF ;CLEAR SCREEN
W !!!,"Visit Counts by Provider Report (APC)..."
LBDATE ;READ USER INPUT ON LOWER BOUND DATE
R !!,"Please enter the Lower Date: ",LDATE
;IF "^" QUIT AND RETURN TO PREVIOUS MENU
I (LDATE="^")!(LDATE="") Q
;IF "?" GIVE HELP AND RETURN TO LDATE PROMPT
I (LDATE="?") W !!,"Enter Lower Boundary Date to search on for report." G LBDATE
I (LDATE="??") W !!,"Enter Lower Boundary Date to search on for report."
I (LDATE="??") W !!,"Date Formats:",?15,"MM/DD/YY",?29,"- STANDARD",!,?15,"T",?29,"- TODAY",!,?15,"T-###",?29,"- TODAY MINUS ### DAYS",!,?15,"NOW",?29,"- CURRENT DATE",!,?15,"MON ##, ####",?29,"- MON DAY, YEAR" G LBDATE
I (LDATE="???") W !!,"Enter Lower Boundary Date to search on for report.",!!,"Date Examples:",?15,"Format",?29,"- Example User Input"
I (LDATE="???") W !!,?15,"MM/DD/YY",?29,"- 01/01/92",!,?15,"T",?29,"- T",!,?15,"T-###",?29,"- T-10",!,?15,"NOW",?29,"- NOW",!,?15,"MON ##, ####",?29,"- SEP 01, 1992" G LBDATE
;CHECK TO SEE IF A VALID DATE HAS BEEN ENTERED
I (LDATE?1.2N0.1"/"1.2N0.1"/"0.4N)!(LDATE?1"T"1"-"1.3N)!(LDATE="T")!(LDATE="NOW")!(LDATE?3A1" "1.2N1","1" "4N) G LBDATE2
W !!,"Illegal date; check format and re-enter lower boundary date.",!,*7
G LBDATE
LBDATE2 ;CONVERT LDATE TO NEW FORMATS
S X=LDATE ;X = DATE TO CONVERT USING ^%DT
D CONVERT ;CONVERT USER DATE TO FILEMAN DATE FORMAT
;DATE FORMAT WAS ILLEGAL
I Y<1 W !!,"Illegal date; check format and re-enter lower boundary date.",!,*7 G LBDATE
S LDATE=Y
S Y=LDATE D DD^%DT S LDATE1=Y ;LDATE1 = DATE IN USER FORMAT
UBDATE ;READ USER INPUT ON UPPER BOUND DATE
R !!,"Please enter the Upper Date: ",UDATE
;IF "^" RETURN TO PREVIOUS PROMPT (LBDATE)
I (UDATE="^")!(UDATE="") G LBDATE
;IF "?" GIVE HELP AND RETURN TO UDATE PROMPT
I (UDATE="?") W !!,"Enter Upper Boundary Date to search on for report." G UBDATE
I (UDATE="??") W !!,"Enter Upper Boundary Date to search on for report."
I (UDATE="??") W !!,"Date Formats:",?15,"MM/DD/YY",?29,"- STANDARD",!,?15,"T",?29,"- TODAY",!,?15,"T-###",?29,"- TODAY MINUS ### DAYS",!,?15,"NOW",?29,"- CURRENT DATE",!,?15,"MON ##, ####",?29,"- MON DAY, YEAR" G UBDATE
I (UDATE="???") W !!,"Enter Upper Boundary Date to search on for report.",!!,"Date Examples:",?15,"Format",?29,"- Example User Input"
I (UDATE="???") W !!,?15,"MM/DD/YY",?29,"- 01/01/92",!,?15,"T",?29,"- T",!,?15,"T-###",?29,"- T-10",!,?15,"NOW",?29,"- NOW",!,?15,"MON ##, ####",?29,"- SEP 01, 1992" G UBDATE
;CHECK TO SEE IF A VALID DATE HAS BEEN ENTERED
I (UDATE?1.2N0.1"/"1.2N0.1"/"0.4N)!(UDATE?1"T"1"-"1.3N)!(UDATE="T")!(UDATE="NOW")!(UDATE?3A1" "1.2N1","1" "4N) G UBDATE2
W !!,"Illegal date; check format and re-enter upper boundary date.",!,*7
G UBDATE
UBDATE2 ;CONVERT UDATE TO NEW FORMATS
S X=UDATE ;X = DATE TO CONVERT USING ^%DT
D CONVERT ;CONVERT USER DATE TO FILEMAN DATE FORMAT
W ! ;GIVE AN EXTRA LINE FEED
;DATE FORMAT WAS ILLEGAL
I Y<1 W !!,"Illegal date; check format and re-enter upper boundary date.",!,*7 G UBDATE
S UDATE=Y
S Y=UDATE D DD^%DT S UDATE1=Y ;UDATE1 = DATE IN USER FORMAT
;CHECK TO SEE IF UDATE > LDATE
I (UDATE<LDATE) W !!,"Upper boundary date must be greater than or equal to lower boundary date.",!,*7 G UBDATE
D GETPNUM ;RETRIEVE DATA FROM MEDICAID ELIGIBLE
;KILL LOCAL VARIABLES
Q
GETPNUM ;RETRIEVE DATA FROM "MEDICAID ELIGIBLE"
;INITIALIZE LOCAL VARIABLES
S DEV=$I ;ORIG. DEVICE
S PATNUM=0 ;PATIENT NUMBER
S INUM2=0
;CALL DEVICE
;IS DEVICE VALID (NO, ABORT REPORT)
;S %ZIS="FQN" D ^%ZIS K %ZIS ;CHECK FOR DEVICE CHARACTERISTICS
;I (IO="")!(IO="^") W !,*7,"No device specified." H 2 G MAIN
;I IO=$I,$D(IO("Q")) R !,"Do you really want me to queue to this device? NO//",YN I ("Nn"[$E(X,1))!(YN="") K IO("Q") G GETPNUM
;I $D(IO("Q")) K IO("Q") S ZTRTN="SETUP^AZXZVSIT",ZTDESC="AHCCCS Visit Counts by Provider (APC)" F G="LDATE","UDATE","LDATE1","UDATE1","PATNUM","INUM2","IO","DEV" S ZTSAVE(G)=""
;I D ^%ZTLOAD Q
;S IOP=IO D ^%ZIS I 'POP G SETUP
;W !,"Device ",IO," busy." G GETPNUM
D ^%ZIS U IO
SETUP ;SETUP FOR CALL FROM TASKMAN (OR DIRECT)
;INITIALIZE LOCAL VARIABLES
S DFN=0 ;INTERNAL ENTRY NUMBER (COUNTER)
S COUNTER=1 ;LINES PER PAGE COUNTER
S COUNTER2=0 ;TOTAL # OF VISITS COUNTER
S PAGE=0 ;INITIALIZE PAGE #
S CHECK=1 ;INITIALIZE CHECK VARIABLE (PVDRCHK=PVDRNAME?)
S RET="" ;RET = IF IO=DEV CHECK FOR "^" TO EXIT
F S INUM=0,INUM2=0,PATNUM=$O(^AUPNMCD("B",PATNUM)) Q:PATNUM="" S INUM=$O(^AUPNMCD("B",PATNUM,INUM)) F S INUM2=$O(^AAPCRCDS("B",PATNUM,INUM2)) Q:INUM2="" D CHKDATE
;CALL GETDATA
D GETDATA ;THE DEVICE DECIDES WHERE THE DATA GOES
;CLOSE DEVICE
X ^%ZIS("C")
;KILL OFF LOCAL AND TEMPORARY VARIABLES
K ^AZXZTMP
Q
CONVERT ;CONVERT USER DATES TO FILEMAN DATE FORMAT
;SET LOCAL VARIABLES
S %DT="EX" ;E=ECHO ANSWER;X=EXACT DATE
D ^%DT ;VALUE RETURNED IN Y
Q
CHKDATE ;CHECK FOR A VALID DATE (WITHIN LDATE & UDATE)
;INITIALIZE LOCAL VARIABLES
S FLAG=0 ;1 = VALID DATE, 0 = INVALID DATE
S DATE=$P(^AAPCRCDS(INUM2,0),U,3)
;SET FLAG=1 IF DATE IS WITHING LDATE & UDATE (DO WRITETMP)
I (DATE>(LDATE-1))&(DATE<(UDATE+1)) S FLAG=1
I FLAG=1 D GETMED D GETAPC D GETPVDR S Y=DATE D DD^%DT S DATE=Y D WRITETMP
Q
GETMED ;GET THE MEDICAID NUMBER FROM "MEDICAID ELIGIBLE"
S MEDNUM=$P(^AUPNMCD(INUM,0),U,3)
Q
GETAPC ;RETRIEVE DATA FROM "APC DATA"
S SSN=$P(^AAPCRCDS(INUM2,0),U,6) ;SOCIAL SECURITY NUMBER
S PVDRNUM=$P(^AAPCRCDS(INUM2,0),U,14) ;PROVIDER NUMBER
S CHARTNUM=$P(^AAPCRCDS(INUM2,0),U,5) ;CHART NUMBER
Q
GETPVDR ;GET THE ACTUAL PROVIDER NAME USING PROVIDER FILE (PVDRNUM)
S PVDRNAME=$P(^DIC(7,PVDRNUM,0),U,1)
Q
WRITETMP ;WRITE DATA OUT TO TEMPORARY GLOBAL (^AZXZTMP)
S DFN=DFN+1 ;INTERNAL ENTRY NUMBER (COUNTER)
S ^AZXZTMP(DFN)=PVDRNAME_"^"_PATNUM_"^"_SSN_"^"_DATE_"^"_MEDNUM_"^"_CHARTNUM
S ^AZXZTMP("B",PVDRNAME,PATNUM,DFN)=""
Q
GETDATA ;GETDATA GATHERS ALL DATA, CALLS PRINT TO PRINT TO DEVICE
;INITIALIZE LOCAL VARIABLES
S PVDR="" ;PVDR = PROVIDER IN "B" CROSS-REF
S PAT="" ;PAT = PATIENT IN "B" CROSS-REF
S INUM=0 ;INUM = INTERNAL ENTRY # IN "B" CROSS-REF
F S PVDR=$O(^AZXZTMP("B",PVDR)) Q:PVDR="" S PAT="" F S PAT=$O(^AZXZTMP("B",PVDR,PAT)) Q:PAT="" S INUM=0 F S INUM=$O(^AZXZTMP("B",PVDR,PAT,INUM)) Q:'INUM D SETVARS D PRINT I RET="^" S PVDR="ZZZZZZZZ" Q
I COUNTER2,RET="" W !!,?49,"Total Number of Visits: ",$J(COUNTER2,6,0),!,"********************************************************************************",!
I IO=DEV,RET="" R !,"Press return to continue...",RET W @IOF R !,"Do you want to print another report? YES//",YN I ("Yy"[$E(X,1))!(YN="") G MAIN
Q
SETVARS ;SET CURRENT VALUES OF VARIABLES TO PRINT OUT
S PVDRNAME=$P(^AZXZTMP(INUM),U,1)
S PATNUM=$P(^AZXZTMP(INUM),U,2)
S SSN=$P(^AZXZTMP(INUM),U,3)
S DATE=$P(^AZXZTMP(INUM),U,4)
S MEDNUM=$P(^AZXZTMP(INUM),U,5)
S CHARTNUM=$P(^AZXZTMP(INUM),U,6)
S SITE=$P(^DIC(4,DUZ(2),0),U,1) ;DUZ(2) = CURRENT FACILITY
Q
PRINT ;PRINT ALL DATA TO DEVICE
I CHECK=1 S PVDRCHK=PVDRNAME ;CHECK = ONLY ON FIRST TIME THRU
I (CHECK=1),(IO=DEV) W @IOF ;CLEAR SCREEN IF IO=DEV, 1ST TIME
I COUNTER=1 W !,"********************************************************************************" S PAGE=PAGE+1
I COUNTER=1 W !,"AHCCCS Visit Counts by Provider (APC) From: ",LDATE1," To: ",UDATE1,!,SITE,?68,"Page: ",PAGE,!,"********************************************************************************" S COUNTER=COUNTER+4
I PVDRCHK'=PVDRNAME W !!,?49,"Total Number of Visits: ",$J(COUNTER2,6,0),!,"********************************************************************************",! S COUNTER2=0,COUNTER=COUNTER+4
I (COUNTER=5)&(CHECK'=1) W !,"Primary Provider: ",PVDRNAME,?73,"(CON'T)" S COUNTER=COUNTER+1
I (PVDRCHK'=PVDRNAME)!(CHECK=1) W !,"Primary Provider: ",PVDRNAME S COUNTER=COUNTER+1
I (COUNTER=6)!(PVDRCHK'=PVDRNAME)!(CHECK=1) W !!,"Patient ","Social Security ","Date of Service ","Medicaid Number ","Chart Number" S CHECK=CHECK+1,COUNTER=COUNTER+2
I (COUNTER=8)!(PVDRCHK'=PVDRNAME) W ! S COUNTER=COUNTER+1,PVDRCHK=PVDRNAME
W !,PATNUM,?9,SSN,?26,DATE,?43,MEDNUM,?61,CHARTNUM S COUNTER=COUNTER+1
S COUNTER2=COUNTER2+1 ;INCREMENT # OF VISITS COUNTER
I IO=DEV,COUNTER>18 R !,"Press return to continue...",RET S COUNTER=1 W @IOF
I IO'=DEV,COUNTER>57 S COUNTER=1 W #
Q
AZXZVSIT ;REPORT -AHCCCS VISIT COUNTS BY PROVIDER (APC) [ 05/01/95 1:25 PM ]
+1 ;06/02/92 JOHN H. LYNCH
+2 ;
+3 ;THIS PROGRAM SEARCHES THE MEDICAID ELIGIBLE
+4 ;FILE AND PRINTS OUT INFORMATION USING THE PATIENT
+5 ;NAME TO PULL INFORMATION FROM THE APC DATA FILE.
+6 ;
+7 ;PATIENT NAME (MEDICAID ELIGIBLE)
+8 ;SSN (APC DATA)
+9 ;DATE OF SERVICE (APC DATA)
+10 ;PRIMARY PROVIDER (APC DATA)
+11 ;MEDICAID NUMBER (MEDICAID ELIGLBLE)
+12 ;CHART NUMBER (APC DATA)
+13 ;
MAIN ;AZXZVSIT PROGRAM CONTROL
+1 ;INITIALIZE LOCAL VARIABLES
+2 +3 ;DELETE COMMENT ONLY IF RUNNING THIS ROUTINE IN PROGRAMMER MODE
+4 ;INITIALIZE SYSTEM VARIABLES
DO ^XBKSET
+5 +6 ;CLEAR SCREEN
WRITE @IOF
+7 WRITE !!!,"Visit Counts by Provider Report (APC)..."
LBDATE ;READ USER INPUT ON LOWER BOUND DATE
+1 READ !!,"Please enter the Lower Date: ",LDATE
+2 ;IF "^" QUIT AND RETURN TO PREVIOUS MENU
+3 IF (LDATE="^")!(LDATE="")
QUIT
+4 +5 ;IF "?" GIVE HELP AND RETURN TO LDATE PROMPT
+6 IF (LDATE="?")
WRITE !!,"Enter Lower Boundary Date to search on for report."
GOTO LBDATE
+7 IF (LDATE="??")
WRITE !!,"Enter Lower Boundary Date to search on for report."
+8 IF (LDATE="??")
WRITE !!,"Date Formats:",?15,"MM/DD/YY",?29,"- STANDARD",!,?15,"T",?29,"- TODAY",!,?15,"T-###",?29,"- TODAY MINUS ### DAYS",!,?15,"NOW",?29,"- CURRENT DATE",!,?15,"MON ##, ####",?29,"- MON DAY, YEAR"
GOTO LBDATE
+9 IF (LDATE="???")
WRITE !!,"Enter Lower Boundary Date to search on for report.",!!,"Date Examples:",?15,"Format",?29,"- Example User Input"
+10 IF (LDATE="???")
WRITE !!,?15,"MM/DD/YY",?29,"- 01/01/92",!,?15,"T",?29,"- T",!,?15,"T-###",?29,"- T-10",!,?15,"NOW",?29,"- NOW",!,?15,"MON ##, ####",?29,"- SEP 01, 1992"
GOTO LBDATE
+11 +12 ;CHECK TO SEE IF A VALID DATE HAS BEEN ENTERED
+13 IF (LDATE?1.2N0.1"/"1.2N0.1"/"0.4N)!(LDATE?1"T"1"-"1.3N)!(LDATE="T")!(LDATE="NOW")!(LDATE?3A1" "1.2N1","1" "4N)
GOTO LBDATE2
+14 WRITE !!,"Illegal date; check format and re-enter lower boundary date.",!,*7
+15 GOTO LBDATE
+16 LBDATE2 ;CONVERT LDATE TO NEW FORMATS
+1 ;X = DATE TO CONVERT USING ^%DT
SET X=LDATE
+2 ;CONVERT USER DATE TO FILEMAN DATE FORMAT
DO CONVERT
+3 ;DATE FORMAT WAS ILLEGAL
+4 IF Y<1
WRITE !!,"Illegal date; check format and re-enter lower boundary date.",!,*7
GOTO LBDATE
+5 SET LDATE=Y
+6 ;LDATE1 = DATE IN USER FORMAT
SET Y=LDATE
DO DD^%DT
SET LDATE1=Y
+7 UBDATE ;READ USER INPUT ON UPPER BOUND DATE
+1 READ !!,"Please enter the Upper Date: ",UDATE
+2 ;IF "^" RETURN TO PREVIOUS PROMPT (LBDATE)
+3 IF (UDATE="^")!(UDATE="")
GOTO LBDATE
+4 ;IF "?" GIVE HELP AND RETURN TO UDATE PROMPT
+5 IF (UDATE="?")
WRITE !!,"Enter Upper Boundary Date to search on for report."
GOTO UBDATE
+6 IF (UDATE="??")
WRITE !!,"Enter Upper Boundary Date to search on for report."
+7 IF (UDATE="??")
WRITE !!,"Date Formats:",?15,"MM/DD/YY",?29,"- STANDARD",!,?15,"T",?29,"- TODAY",!,?15,"T-###",?29,"- TODAY MINUS ### DAYS",!,?15,"NOW",?29,"- CURRENT DATE",!,?15,"MON ##, ####",?29,"- MON DAY, YEAR"
GOTO UBDATE
+8 IF (UDATE="???")
WRITE !!,"Enter Upper Boundary Date to search on for report.",!!,"Date Examples:",?15,"Format",?29,"- Example User Input"
+9 IF (UDATE="???")
WRITE !!,?15,"MM/DD/YY",?29,"- 01/01/92",!,?15,"T",?29,"- T",!,?15,"T-###",?29,"- T-10",!,?15,"NOW",?29,"- NOW",!,?15,"MON ##, ####",?29,"- SEP 01, 1992"
GOTO UBDATE
+10 +11 ;CHECK TO SEE IF A VALID DATE HAS BEEN ENTERED
+12 IF (UDATE?1.2N0.1"/"1.2N0.1"/"0.4N)!(UDATE?1"T"1"-"1.3N)!(UDATE="T")!(UDATE="NOW")!(UDATE?3A1" "1.2N1","1" "4N)
GOTO UBDATE2
+13 WRITE !!,"Illegal date; check format and re-enter upper boundary date.",!,*7
+14 GOTO UBDATE
+15 UBDATE2 ;CONVERT UDATE TO NEW FORMATS
+1 ;X = DATE TO CONVERT USING ^%DT
SET X=UDATE
+2 ;CONVERT USER DATE TO FILEMAN DATE FORMAT
DO CONVERT
+3 ;GIVE AN EXTRA LINE FEED
WRITE !
+4 ;DATE FORMAT WAS ILLEGAL
+5 IF Y<1
WRITE !!,"Illegal date; check format and re-enter upper boundary date.",!,*7
GOTO UBDATE
+6 SET UDATE=Y
+7 ;UDATE1 = DATE IN USER FORMAT
SET Y=UDATE
DO DD^%DT
SET UDATE1=Y
+8 +9 ;CHECK TO SEE IF UDATE > LDATE
+10 IF (UDATE<LDATE)
WRITE !!,"Upper boundary date must be greater than or equal to lower boundary date.",!,*7
GOTO UBDATE
+11 +12 ;RETRIEVE DATA FROM MEDICAID ELIGIBLE
DO GETPNUM
+13 +14 ;KILL LOCAL VARIABLES
+15 QUIT
+16 GETPNUM ;RETRIEVE DATA FROM "MEDICAID ELIGIBLE"
+1 ;INITIALIZE LOCAL VARIABLES
+2 ;ORIG. DEVICE
SET DEV=$IO
+3 ;PATIENT NUMBER
SET PATNUM=0
+4 SET INUM2=0
+5 +6 ;CALL DEVICE
+7 ;IS DEVICE VALID (NO, ABORT REPORT)
+8 ;S %ZIS="FQN" D ^%ZIS K %ZIS ;CHECK FOR DEVICE CHARACTERISTICS
+9 ;I (IO="")!(IO="^") W !,*7,"No device specified." H 2 G MAIN
+10 +11 ;I IO=$I,$D(IO("Q")) R !,"Do you really want me to queue to this device? NO//",YN I ("Nn"[$E(X,1))!(YN="") K IO("Q") G GETPNUM
+12 ;I $D(IO("Q")) K IO("Q") S ZTRTN="SETUP^AZXZVSIT",ZTDESC="AHCCCS Visit Counts by Provider (APC)" F G="LDATE","UDATE","LDATE1","UDATE1","PATNUM","INUM2","IO","DEV" S ZTSAVE(G)=""
+13 ;I D ^%ZTLOAD Q
+14 ;S IOP=IO D ^%ZIS I 'POP G SETUP
+15 ;W !,"Device ",IO," busy." G GETPNUM
+16 DO ^%ZIS
USE IO
+17 SETUP ;SETUP FOR CALL FROM TASKMAN (OR DIRECT)
+1 ;INITIALIZE LOCAL VARIABLES
+2 ;INTERNAL ENTRY NUMBER (COUNTER)
SET DFN=0
+3 ;LINES PER PAGE COUNTER
SET COUNTER=1
+4 ;TOTAL # OF VISITS COUNTER
SET COUNTER2=0
+5 ;INITIALIZE PAGE #
SET PAGE=0
+6 ;INITIALIZE CHECK VARIABLE (PVDRCHK=PVDRNAME?)
SET CHECK=1
+7 ;RET = IF IO=DEV CHECK FOR "^" TO EXIT
SET RET=""
+8 +9 FOR
SET INUM=0
SET INUM2=0
SET PATNUM=$ORDER(^AUPNMCD("B",PATNUM))
IF PATNUM=""
QUIT
SET INUM=$ORDER(^AUPNMCD("B",PATNUM,INUM))
FOR
SET INUM2=$ORDER(^AAPCRCDS("B",PATNUM,INUM2))
IF INUM2=""
QUIT
DO CHKDATE
+10 +11 ;CALL GETDATA
+12 ;THE DEVICE DECIDES WHERE THE DATA GOES
DO GETDATA
+13 +14 ;CLOSE DEVICE
+15 XECUTE ^%ZIS("C")
+16 +17 ;KILL OFF LOCAL AND TEMPORARY VARIABLES
+18 KILL ^AZXZTMP
+19 QUIT
+20 CONVERT ;CONVERT USER DATES TO FILEMAN DATE FORMAT
+1 ;SET LOCAL VARIABLES
+2 ;E=ECHO ANSWER;X=EXACT DATE
SET %DT="EX"
+3 ;VALUE RETURNED IN Y
DO ^%DT
+4 QUIT
+5 CHKDATE ;CHECK FOR A VALID DATE (WITHIN LDATE & UDATE)
+1 ;INITIALIZE LOCAL VARIABLES
+2 ;1 = VALID DATE, 0 = INVALID DATE
SET FLAG=0
+3 SET DATE=$PIECE(^AAPCRCDS(INUM2,0),U,3)
+4 +5 ;SET FLAG=1 IF DATE IS WITHING LDATE & UDATE (DO WRITETMP)
+6 IF (DATE>(LDATE-1))&(DATE<(UDATE+1))
SET FLAG=1
+7 IF FLAG=1
DO GETMED
DO GETAPC
DO GETPVDR
SET Y=DATE
DO DD^%DT
SET DATE=Y
DO WRITETMP
+8 QUIT
+9 GETMED ;GET THE MEDICAID NUMBER FROM "MEDICAID ELIGIBLE"
+1 SET MEDNUM=$PIECE(^AUPNMCD(INUM,0),U,3)
+2 QUIT
+3 GETAPC ;RETRIEVE DATA FROM "APC DATA"
+1 ;SOCIAL SECURITY NUMBER
SET SSN=$PIECE(^AAPCRCDS(INUM2,0),U,6)
+2 ;PROVIDER NUMBER
SET PVDRNUM=$PIECE(^AAPCRCDS(INUM2,0),U,14)
+3 ;CHART NUMBER
SET CHARTNUM=$PIECE(^AAPCRCDS(INUM2,0),U,5)
+4 QUIT
+5 GETPVDR ;GET THE ACTUAL PROVIDER NAME USING PROVIDER FILE (PVDRNUM)
+1 SET PVDRNAME=$PIECE(^DIC(7,PVDRNUM,0),U,1)
+2 QUIT
+3 WRITETMP ;WRITE DATA OUT TO TEMPORARY GLOBAL (^AZXZTMP)
+1 ;INTERNAL ENTRY NUMBER (COUNTER)
SET DFN=DFN+1
+2 SET ^AZXZTMP(DFN)=PVDRNAME_"^"_PATNUM_"^"_SSN_"^"_DATE_"^"_MEDNUM_"^"_CHARTNUM
+3 SET ^AZXZTMP("B",PVDRNAME,PATNUM,DFN)=""
+4 QUIT
+5 GETDATA ;GETDATA GATHERS ALL DATA, CALLS PRINT TO PRINT TO DEVICE
+1 ;INITIALIZE LOCAL VARIABLES
+2 ;PVDR = PROVIDER IN "B" CROSS-REF
SET PVDR=""
+3 ;PAT = PATIENT IN "B" CROSS-REF
SET PAT=""
+4 ;INUM = INTERNAL ENTRY # IN "B" CROSS-REF
SET INUM=0
+5 +6 FOR
SET PVDR=$ORDER(^AZXZTMP("B",PVDR))
IF PVDR=""
QUIT
SET PAT=""
FOR
SET PAT=$ORDER(^AZXZTMP("B",PVDR,PAT))
IF PAT=""
QUIT
SET INUM=0
FOR
SET INUM=$ORDER(^AZXZTMP("B",PVDR,PAT,INUM))
IF 'INUM
QUIT
DO SETVARS
DO PRINT
IF RET="^"
SET PVDR="ZZZZZZZZ"
QUIT
+7 IF COUNTER2
IF RET=""
WRITE !!,?49,"Total Number of Visits: ",$JUSTIFY(COUNTER2,6,0),!,"********************************************************************************",!
+8 IF IO=DEV
IF RET=""
READ !,"Press return to continue...",RET
WRITE @IOF
READ !,"Do you want to print another report? YES//",YN
IF ("Yy"[$EXTRACT(X,1))!(YN="")
GOTO MAIN
+9 QUIT
+10 SETVARS ;SET CURRENT VALUES OF VARIABLES TO PRINT OUT
+1 SET PVDRNAME=$PIECE(^AZXZTMP(INUM),U,1)
+2 SET PATNUM=$PIECE(^AZXZTMP(INUM),U,2)
+3 SET SSN=$PIECE(^AZXZTMP(INUM),U,3)
+4 SET DATE=$PIECE(^AZXZTMP(INUM),U,4)
+5 SET MEDNUM=$PIECE(^AZXZTMP(INUM),U,5)
+6 SET CHARTNUM=$PIECE(^AZXZTMP(INUM),U,6)
+7 ;DUZ(2) = CURRENT FACILITY
SET SITE=$PIECE(^DIC(4,DUZ(2),0),U,1)
+8 QUIT
+9 PRINT ;PRINT ALL DATA TO DEVICE
+1 ;CHECK = ONLY ON FIRST TIME THRU
IF CHECK=1
SET PVDRCHK=PVDRNAME
+2 ;CLEAR SCREEN IF IO=DEV, 1ST TIME
IF (CHECK=1)
IF (IO=DEV)
WRITE @IOF
+3 IF COUNTER=1
WRITE !,"********************************************************************************"
SET PAGE=PAGE+1
+4 IF COUNTER=1
WRITE !,"AHCCCS Visit Counts by Provider (APC) From: ",LDATE1," To: ",UDATE1,!,SITE,?68,"Page: ",PAGE,!,"********************************************************************************"
SET COUNTER=COUNTER+4
+5 IF PVDRCHK'=PVDRNAME
WRITE !!,?49,"Total Number of Visits: ",$JUSTIFY(COUNTER2,6,0),!,"********************************************************************************",!
SET COUNTER2=0
SET COUNTER=COUNTER+4
+6 IF (COUNTER=5)&(CHECK'=1)
WRITE !,"Primary Provider: ",PVDRNAME,?73,"(CON'T)"
SET COUNTER=COUNTER+1
+7 IF (PVDRCHK'=PVDRNAME)!(CHECK=1)
WRITE !,"Primary Provider: ",PVDRNAME
SET COUNTER=COUNTER+1
+8 IF (COUNTER=6)!(PVDRCHK'=PVDRNAME)!(CHECK=1)
WRITE !!,"Patient ","Social Security ","Date of Service ","Medicaid Number ","Chart Number"
SET CHECK=CHECK+1
SET COUNTER=COUNTER+2
+9 IF (COUNTER=8)!(PVDRCHK'=PVDRNAME)
WRITE !
SET COUNTER=COUNTER+1
SET PVDRCHK=PVDRNAME
+10 WRITE !,PATNUM,?9,SSN,?26,DATE,?43,MEDNUM,?61,CHARTNUM
SET COUNTER=COUNTER+1
+11 ;INCREMENT # OF VISITS COUNTER
SET COUNTER2=COUNTER2+1
+12 IF IO=DEV
IF COUNTER>18
READ !,"Press return to continue...",RET
SET COUNTER=1
WRITE @IOF
+13 IF IO'=DEV
IF COUNTER>57
SET COUNTER=1
WRITE #
+14 QUIT