DVBAB1B ;ALB/SPH - CAPRI UTILITIES ;09/30/2009
 ;;2.7;AMIE;**104,143**;Apr 10, 1995;Build 4
 ;
DPA(LIST,DFN,CHOICE) ;Display Patient Appointments
 
DVBABCNT,CKCHOICE
 
LIST="",DVBABCNT=1,CKCHOICE="A,F,P",DFN=$G(DFN),CHOICE=$G(CHOICE^TMP("DVBAAPPT",$J)
 
DFN="" ^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)="MISSING PATIENT NAME",LIST=$NA(^TMP("DVBAAPPT",$J,DUZ)) Q
 I 
CHOICE="" ^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)="MISSING ALL, PAST, OR FUTURE",LIST=$NA(^TMP("DVBAAPPT",$J,DUZ)) Q
 I 
CKCHOICE'[CHOICE ^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)="INVALID SELECTION",LIST=$NA(^TMP("DVBAAPPT",$J,DUZ)) Q
 I 
CHOICE["A" D
 
.SDT=0
 .
X="T+730" ^%DT
 .
Y<0 ^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)="ERROR IN CALCULATING ENDING DATE RANGE",LIST=$NA(^TMP("DVBAAPPT",$J,DUZ))
 .
EDT=Y+.9
 
CHOICE["F" D
 
.X="T+1" ^%DT
 .
Y<0 ^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)="ERROR IN CALCULATING START DATE RANGE",LIST=$NA(^TMP("DVBAAPPT",$J,DUZ))
 .
SDT=Y
 
.X,Y
 
.X="T+730" ^%DT
 .
Y<0 ^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)="ERROR IN CALCULATING ENDING DATE RANGE",LIST=$NA(^TMP("DVBAAPPT",$J,DUZ))
 .
EDT=Y+.9
 
CHOICE["P" D
 
.X="T" ^%DT
 .
Y<0 ^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)="ERROR IN CALCULATING ENDING DATE RANGE",LIST=$NA(^TMP("DVBAAPPT",$J,DUZ))
 .
EDT=Y+.9
 .
X,Y
 
.SDT=0
 
Q:LIST["ERROR"
 
I $O(^DPT(DFN,"S",SDT))'>0 ^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)="NO APPOINTMENTS FOUND FOR YOUR DATE RANGE",LIST=$NA(^TMP("DVBAAPPT",$J,DUZ)) Q
 F  S 
SDT=$O(^DPT(DFN,"S",SDT)) Q:'SDT!(SDT>EDT)  D
 
.CLN=$P(^DPT(DFN,"S",SDT,0),"^"Q:'CLN
 
.Q:'$D(^SC(CLN,0))
 .
CLN=$P(^SC(CLN,0),"^")
 .
ZZ=$L(CLN)
 .
ZZ<31 D
 
..ZZZ=ZZ:1:30 CLN=CLN_" "
 
.Y=SDT ^DD("DD")
 .
ZZ2=$L(Y)
 .
ZZ2<21 D
 
..ZZZ2=ZZ2:1:20 Y=Y_" "
 
.STATUS=$P(^DPT(DFN,"S",SDT,0),"^",2)
 .
STATUS'="" D
 
..STATUS="N" STATUS="NO-SHOW"
 
..STATUS="C" STATUS="CANCELLED BY CLINIC"
 
..STATUS="CA" STATUS="CANCELLED BY CLINIC & AUTO RE-BOOK"
 
..STATUS="NA" STATUS="NO-SHOW & AUTO-REBOOK"
 
..STATUS="I" STATUS="INPATIENT APPOINTMENT"
 
..STATUS="PC" STATUS="CANCELLED BY PATIENT"
 
..STATUS="PCA" STATUS="CANCELLED BY PATIENT & AUTO RE-BOOK"
 
..STATUS="NT" STATUS="NO ACTION TAKEN"
 
I $D(^DPT(DFN,"S",SDT,"R")) REMARK=$P(^DPT(DFN,"S",SDT,"R"),"^",1) ;ADDED
 
.^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)=CLN_"  "_Y_" "_STATUS,DVBABCNT=DVBABCNT+1
 . 
I $D(REMARK^TMP("DVBAAPPT",$J,DUZ,DVBABCNT)="   Cancellation Remarks: "_REMARK,DVBABCNT=DVBABCNT+1
 . 
I $D(REMARKREMARK
 
.LIST=$NA(^TMP("DVBAAPPT",$J,DUZ))
 
DFN,X,%DT,CLN,CHOICE,Y,SDT,EDT
 
Q
 
;
CHECK(DVBRSLTS,DVBPATCH) ; Checks for KIDS Patch install
 ; RPC: DVBA CHECK PATCH
 ; Input:  DVBPATCH - Patch Number (i.e. DVBA*2.7*142)
 ; Output: Returns "1^Patch Is Installed" on success; 
 ;         otherwise returns "0^Patch Is Not Installed" 
 
DVBX
 
DVBX=$$PATCH^XPDUTL(DVBPATCH)
 
DVBRSLTS=$S(DVBX:"1^Patch Is Installed",1:"0^Patch Is Not Installed")
 
Q