DVBAB57 ;ALB/KLB - AMIE GUI PENDING 7131 REPORT ;09/7/00
 ;;2.7;AMIE;**35,42,185**;Apr 10, 1995;Build 18
 ;
STRT(MSG,SELDIV,DIV,DVBADLMTR) ;
 
DVBADLMTR=$S(DVBADLMTR=1:",",1:0)
 
RO="N"
 
RONUM=0
 
DIVNUM="",MSGCNT=1
 
^TMP($J),^TMP("CAPRI")
 
RO="Y",RONUM="" MSG(1)="To sort by RO Number, please enter the RO Number."
 
RO="Y",RONUM="" Q
 I 
SELDIV="Y",DIV="" MSG(1)="To sort by Division, please enter the Division."
 
SELDIV="Y",DIV="" Q
 I 
DIV'="" DIVNUM=$O(^DG(40.8,"C",DIV,DIVNUM)),DIVNAM=$S($D(^DG(40.8,+DIVNUM,0)):$P(^(0),"^",1),1:"Unknown Division")
SETUP STM^DVBCUTL4
 
FDT(0)=$$FMTE^XLFDT(DT,"5DZ"),(PG,DVBAQUIT)=0
 
HEAD="PENDING REQUEST REPORT FOR "_$P(^DVB(396.1,1,0),U,1)
 
HEAD2=$S(RO="Y":"FOR REGIONAL OFFICE "_RONUM,1:"ALL REGIONAL OFFICES")
 
HEAD2=HEAD2_$S(SELDIV="Y":", FOR DIVISION "_DIVNAM,1:", ALL DIVISIONS")
 
PROCDT="Processed on: "_FDT(0)
 
QQ=1,NODTA=0
 
I $G(DVBADLMTR)="," D  G DATA
 
^TMP("CAPRI",$J,MSGCNT)=HEAD_$C(13),MSGCNT=MSGCNT+1,^TMP("CAPRI",$J,MSGCNT)=""""_HEAD2_""""_$C(13),MSGCNT=MSGCNT+1,^TMP("CAPRI",$J,MSGCNT)=PROCDT_$C(13)_$C(13),MSGCNT=MSGCNT+1
 . 
^TMP("CAPRI",$J,MSGCNT)=$S(SELDIV="Y":"Division",SELDIV="N":"Original Division",1:"")_DVBADLMTR_"Patient Name"_DVBADLMTR_"SSN"_DVBADLMTR_"Claim no."_DVBADLMTR_"Activity/Admission Date"_DVBADLMTR_"Request Date"_DVBADLMTR
 
^TMP("CAPRI",$J,MSGCNT)=^TMP("CAPRI",$J,MSGCNT)_"** Discharged"_DVBADLMTR_"Elapsed Days"_DVBADLMTR_"Items Pending"_DVBADLMTR_"Requested by Name"_DVBADLMTR_"Requested by Division"_$C(13),MSGCNT=MSGCNT+1
 
I $G(DVBADLMTR)=0 D
 
^TMP("CAPRI",MSGCNT)="Pending 7131 Report"_"^",MSGCNT=MSGCNT+1
 . 
^TMP("CAPRI",MSGCNT)=""_"^",MSGCNT=MSGCNT+1
 . 
^TMP("CAPRI",MSGCNT)=HEAD_"^",MSGCNT=MSGCNT+1
 . 
^TMP("CAPRI",MSGCNT)=HEAD2_"^",MSGCNT=MSGCNT+1
 . 
^TMP("CAPRI",MSGCNT)=PROCDT_"^",MSGCNT=MSGCNT+1
 . 
^TMP("CAPRI",MSGCNT)=""_"^",MSGCNT=MSGCNT+1
DATA REQDTE REQDTE="",CNT=0
 
S:SELDIV="Y" ADIV=DIVNAM
 
J=0:0 REQDTE=$O(^DVB(396,"E",REQDTE)) Q:REQDTE=""  DA=0:0 DA=$O(^DVB(396,"E",REQDTE,DA)) Q:DA=""  I $D(^DVB(396,DA,1)),($P(^DVB(396,DA,1),U,12)="")  D:SELDIV="N" ADIV  MAKUTL
 
(ADIV,REQDTE)=""
 
L=0:0 REQDTE=$O(^TMP($J,REQDTE)) Q:REQDTE=""  LVL2LP
 
;
EXIT NODTA=0 MSG(1)="No pending requests found for parameters entered."
 
NODTA>0,$G(DVBADLMTR)=0 MSG=$NA(^TMP("CAPRI"))
 
NODTA>0,$G(DVBADLMTR)="," MSG=$NA(^TMP("CAPRI",$J))
 
;
KILL XRTN=$T(+0)
 
SPM^DVBCUTL4
 
^TMP("DVBA","ADMIT",$J),^TMP($J),DVBAQUIT,SELDIV,DIVNUM,REQDTE,PROCDT,QQ,RO,RONUM,XRTN,CNT,MSGCNT,NODTA
 
LPCNT1,PATDA,DIVNAM,XJ,XI,GDIVPTR,GDIVNUM,GINSTPT,GDIVNAM,GDIV,ADIV,CFLOC,DA,DIV,FDT,HEAD,HEAD2,J,L,PG,DVBADLMTR
 
Q
 
;
LVL2LP  ;  ** 2nd level of the 2nd loop in the DATA tag - search ADIV **
 
J=0:0 ADIV=$O(^TMP($J,REQDTE,ADIV)) Q:ADIV=""  LPLVL3
 
Q
 
;
LPLVL3 ;  **  2nd level of the loop in the LVL2LP tag - search DA **
 
DA=0:0 DA=$O(^TMP($J,REQDTE,ADIV,DA)) Q:DA=""  PRINT^DVBAB67 S:DVBAQUIT=1 ADIV="ZZZZ",DA=999999999,REQDTE=9999999 QQ=1
 
Q
 
;
MAKUTL ;  **  Sort on Request Date to set up a temporary utility global  **
 
PATDA=$P(^DVB(396,DA,0),"^",1)
 
;S REQDTE=$P(^DVB(396,DA,1),"^",1),PATDA=$P(^DVB(396,DA,0),"^",1)
 
CFLOC=$$STATION^DVBAUTL1(PATDA)
 
S:CFLOC=-1 CFLOC=0
 
SELDIV="Y"&(RO="Y"CFLOC=RONUM CHKDIV D:$D(DVBAFNDSETARY
 
SELDIV="Y"&(RO="N"CHKDIV D:$D(DVBAFNDSETARY
 
SELDIV="N"&(RO="Y"CFLOC=RONUM SETARY
 
SELDIV="N"&(RO="N"SETARY
 
DVBAFND
 
QUIT
 
;
SETARY ;  ** Set temporary utility global **
 
^TMP($J,REQDTE,ADIV,DA)=""
 
QUIT
 
;
ADIV ADIV=$S($D(^DVB(396,DA,2)):$P(^(2),U,9),1:""ADIV=$S($D(^DG(40.8,+ADIV,0)):$P(^(0),U,1),1:"Unknown Division")
 
Q
 
;
CHKDIV ;**Check for selected Div
 
FLDVAR
 
I $D(^DVB(396,DA,6)) DO
 
.FLDVAR=7,9,11,13,15,17,19,21,23,26,28 Q:$D(DVBAFND)  DO
 
..($P(^DVB(396,DA,6),U,FLDVAR)=DIVNUMDO
 
...FLDVAR=7 S:$P(^DVB(396,DA,1),U,FLDVAR)="P" DVBAFND=""
 
...FLDVAR'=7 S:$P(^DVB(396,DA,0),U,FLDVAR)="P" DVBAFND=""
 
I $D(^DVB(396,DA,2)),('$D(DVBAFND)) DO  ;**Check Routing Loc Division
 
.I $D(^DVB(396,DA,1)) DO
 
..I $P(^DVB(396,DA,2),U,9)=DIVNUM,($P(^DVB(396,DA,1),U,12)=""DO
 
...DVBAFND=""
 
Q