Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: AZXZVS

AZXZVS.m

Go to the documentation of this file.
AZXZVS ;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)
 ;DATE OF SERVICE  (APC DATA)
 ;PRIMARY PROVIDER (APC DATA)
 ;MEDICAID NUMBER  (MEDICAID ELIGLBLE)
 ;CHART NUMBER     (APC DATA)
 ;
MAIN ;AZXZVS 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 !!!,"APC Visit Counts by Provider Report..."
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="FQMN" 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^AZXZVS",ZTDESC="APC Visit Counts by Provider" 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) 
 
 ;CHECK TO MAKE SURE REPORT ISN'T ALREADY RUNNING SOMEWHERE ELSE
 I $D(^AZXZTMP2(0)) D ERR Q
 
 ;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
 
 ;SET 0-NODE FOR TMP GLOBAL (^AZXZTMP)
 S ^AZXZTMP2(0)="TMP FILE FOR AZXZVS PROGRAM^NEEDS TO BE DELETED IF A PROGRAM ERROR OCCURS"
 
 F  S INUM2=0,PATNUM=$O(^AAPCRCDS("B",PATNUM))  Q:PATNUM=""  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")
 Q
 
ERR ;THE ^AZXZTMP2 GLOBAL EXISTS (ERROR HAS OCCURRED OR
 ;THE PROGRAM IS CURRENTLY RUNNING ALREADY!!!
 I IO=DEV W @IOF       ;CLEAR SCREEN
 W !!!,"********************************************************************************",!!,"The ""APC Visit Counts by Provider"" report is already currently running."
 W !!,"If you find that the report is not currently running..."
 W !,"please contact the MIS Manager immediately, a program error"
 W !,"may have occured."
 W !!,"********************************************************************************"
 I IO=DEV R !!,"Press return to continue...",RET
 I IO'=DEV W #         ;SEND FORM FEED
 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 GETAPC D GETPVDR S Y=DATE D DD^%DT S DATE=Y D WRITETMP
 Q
 
GETAPC ;RETRIEVE DATA FROM "APC DATA"   
 ;INITIALIZE LOCAL VARIABLES
 S OTHER=0         ;OTHER PROVIDERS?
 S PVDRNUM=$P(^AAPCRCDS(INUM2,0),U,14)  ;PROVIDER NUMBER
 
 ;OTHER PROVIDERS?
 I $D(^AAPCRCDS(INUM2,1,0)) S OTHER=$P(^AAPCRCDS(INUM2,1,0),U,4)
 
 ;SET OTHER PROVIDER NUMBERS
 I OTHER>0 F I=1:1:OTHER S OTHERNUM(I)=$P(^AAPCRCDS(INUM2,1,I,0),U,1)
 Q
 
GETPVDR ;GET THE ACTUAL PROVIDER NAME USING PROVIDER FILE (PVDRNUM)
 ;ALSO, GET THE OTHER PROVIDER NAMES USING PROVIDER FILE.
 S PVDRNAME=$P(^DIC(7,PVDRNUM,0),U,1)
 I OTHER>0 F I=1:1:OTHER S OTHRNAME(I)=$P(^DIC(7,OTHERNUM(I),0),U,1)
 Q
 
WRITETMP ;WRITE DATA OUT TO TEMPORARY GLOBAL (^AZXZTMP2)
 S DFN=DFN+1         ;INTERNAL ENTRY NUMBER (COUNTER)
 ;WRITE PRIMARY PROVIDER TO TMP GLOBAL
 S ^AZXZTMP2(DFN)=PVDRNAME_"^"_PVDRNUM_"^"_PATNUM_"^"_DATE
 S ^AZXZTMP2("B",PVDRNAME,PATNUM,DFN)=""
 
 ;WRITE OTHER PROVIDERS TO TMP GLOBAL
 I OTHER>0 F I=1:1:OTHER S DFN=DFN+1,^AZXZTMP2(DFN)=OTHRNAME(I)_"^"_OTHERNUM(I)_"^"_PATNUM_"^"_DATE
 I OTHER>0 S DFN=DFN-OTHER
 I OTHER>0 F I=1:1:OTHER S DFN=DFN+1,^AZXZTMP2("B",OTHRNAME(I),PATNUM,DFN)=""
 K OTHERNUM,OTHRNAME                 ;KILL OTHERNUM,OTHRNAME ARRAY
 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
 S SUBTOTAL=0  ;SUBTOTAL = SUBTOTAL OF # OF VISITS PER PAGE
 S TOTAL=0     ;TOTAL = TOTAL # OF VISITS PER PROVIDER TYPE
 
 F  S PVDR=$O(^AZXZTMP2("B",PVDR)) Q:PVDR=""   S PAT="" F  S PAT=$O(^AZXZTMP2("B",PVDR,PAT)) Q:PAT=""  S INUM=0 F  S INUM=$O(^AZXZTMP2("B",PVDR,PAT,INUM)) Q:'INUM  D SETVARS D PRINT I RET="^" S PVDR="ZZZZZZZZ" Q
 I RET="",SUBTOTAL W !,?73,"_______",!,?64,"Subtotal:",?73,$J(SUBTOTAL,7,0)
 I RET="",TOTAL S TOTAL=TOTAL+SUBTOTAL W !,?73,"_______",!,?67,"Total:",?73,$J(TOTAL,7,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="") K ^AZXZTMP2 S DFN=0 G MAIN
 
 ;KILL OFF LOCAL AND TEMPORARY VARIABLES
 K ^AZXZTMP2
 Q
 
SETVARS ;SET CURRENT VALUES OF VARIABLES TO PRINT OUT  
 S PVDRNAME=$P(^AZXZTMP2(INUM),U,1)
 S NUM=$P(^AZXZTMP2(INUM),U,2)
 S PVDRNUM=$P(^DIC(7,NUM,9999999),U,1)
 Q
 
PRINT ;PRINT ALL DATA TO DEVICE    
 ;CHECK = ONLY ON FIRST TIME THRU
 I CHECK=1 S PVDRCHK=PVDRNAME,PNUMCHK=PVDRNUM,SITE=$P(^DIC(4,DUZ(2),0),U,1)
 
 ;CLEAR SCREEN IF IO=DEV, 1ST TIME
 I (CHECK=1),(IO=DEV) W @IOF S CHECK=CHECK+1
 
 I COUNTER=1 W !,"********************************************************************************" S PAGE=PAGE+1
 I COUNTER=1 W !,"APC Visit Counts by Provider                From: ",LDATE1,"  To: ",UDATE1,!,SITE,?68,"Page: ",PAGE,!,"********************************************************************************"
 I COUNTER=1 W !!,"Provider Discipline",?40,"Discipline Code",?64,"Number of Visits",! S COUNTER=COUNTER+7
 I PVDRCHK'=PVDRNAME W !,PVDRCHK,?40,PNUMCHK,?73,$J(COUNTER2,7,0) S SUBTOTAL=SUBTOTAL+COUNTER2,COUNTER2=0,COUNTER=COUNTER+1,PVDRCHK=PVDRNAME,PNUMCHK=PVDRNUM
  
 S COUNTER2=COUNTER2+1       ;INCREMENT # OF VISITS COUNTER
 
 I IO=DEV,COUNTER>18 W !,?73,"_______",!,?64,"Subtotal:",?73,$J(SUBTOTAL,7,0) R !,"Press return to continue...",RET S COUNTER=1,TOTAL=TOTAL+SUBTOTAL,SUBTOTAL=0 W @IOF
 I IO'=DEV,COUNTER>57 W !,?73,"_______",!,?64,"Subtotal:",?73,$J(SUBTOTAL,7,0) S COUNTER=1,TOTAL=TOTAL+SUBTOTAL,SUBTOTAL=0 W #
 Q