SDEC37 ;ALB/SAT - VISTA SCHEDULING RPCS ;JAN 15, 2016
;;5.3;Scheduling;**627**;Aug 13, 1993;Build 249
;
Q
;
; NS = RETURN NO-SHOW DATA FOR GIVEN PATIENT - RPC
; VAL = return boolean to represent that a clinic allows variable appointment length - RPC
;
;RETURN NO-SHOW DATA FOR GIVEN PATIENT - RPC
NOSHOPAT(SDECY,DFN,SDCL) ;COLLECT NO-SHOW DATA for Patient
;NOSHOPAT(SDECY,DFN,SDCL) external parameter tag is in SDEC
; .SDECY = returned pointer to NO SHOW data
; DFN = patient code - pointer to ^DPT(DFN)
; SDCL = clinic code - pointer to Hospital Location file ^SC
N SDECI,SDBEG,SDEND,NSC,SD2,SDCLN,SDT,SDTN
S SDECI=0
K ^TMP("SDEC",$J)
S SDECY="^TMP(""SDEC"","_$J_")"
S ^TMP("SDEC",$J,0)="T00020ERRORID"_$C(30)
;check for valid patient
I '+DFN D ERR("Invalid Patient ID.") Q
I '$D(^DPT(DFN,0)) D ERR("Invalid Patient ID.") Q
; data header
; TOO_MANY = flag 0=OK; 1=too many no shows
S ^TMP("SDEC",$J,0)="I00020PATIENT_IEN^I00020CLINIC_IEN^I00020TOO_MANY^I00020ALLOWED_NO_SHOWS^I00020TOTAL_NO_SHOWS"_$C(30)
;get allowed number of no shows for clinic
S SDCLN=$G(^SC(SDCL,"SDP"))
;loop thru schedule
S SDEND=DT ;$P($$NOW^XLFDT,".",1)
S SDBEG=$$FMADD^XLFDT(SDEND,-365)
S NSC=0 ;no show counter
S SDT=SDBEG
F S SDT=$O(^DPT(DFN,"S",SDT)) Q:SDT'>0 Q:$P(SDT,".",1)>SDEND D
. S SDTN=^DPT(DFN,"S",SDT,0)
. I ($P(SDTN,U)=SDCL) D
. . S SD2=$P(SDTN,U,2)
. . I SD2["N",$$NOSHOW(DFN,SDT,$P(SDTN,U),SDTN) S NSC=NSC+1
S SDECI=SDECI+1
S ^TMP("SDEC",$J,SDECI)=DFN_U_SDCL_U_($P(SDCLN,U,1)'>NSC)_U_$P(SDCLN,U)_U_NSC
S SDECI=SDECI+1
S ^TMP("SDEC",$J,SDECI)=$C(30)
S SDECI=SDECI+1
S ^TMP("SDEC",$J,SDECI)=$C(31)
Q
;
NOSHOW(DFN,SDT,CIFN,PAT) ;Input: DFN=Patient IFN, SDT=Appointment D/T
; CIFN=Clinic IFN, PAT=Zero node of pat. appt., DA=Clinic appt. IFN
; Output: 1 or 0 for noshow yes/no
N NSQUERY,NS S NS=1,NSQUERY=$$STATUS^SDAM1(DFN,SDT,CIFN,PAT)
I $P(NSQUERY,";",3)["ACTION REQ" S NS=0
NOSHOWQ Q NS
;
CVARAPPT(SDECY,SDCL) ;IS Clinic Variable Appointment Length
;CVARAPPT(SDECY,SDCL) external parameter tag is in SDEC
;return boolean to represent that a clinic allows variable appointment length - RPC
N SDECI,VAL
S SDECI=0
K ^TMP("SDEC",$J)
S SDECY="^TMP(""SDEC"","_$J_")"
S ^TMP("SDEC",$J,0)="T00020ERRORID"_$C(30)
;check for valid clinic ID
I '+SDCL D ERR("Invalid Clinic ID.") Q
I '$D(^SC(SDCL,0)) D ERR("Invalid Clinic ID.") Q
; data header
; VAR_APPT_FLAG = flag 0=Clinic does not Allow Variable Appointment; 1=Clinic Allows Variable Appointment
S ^TMP("SDEC",$J,0)="I00020VAR_APPT_FLAG"_$C(30)
;get VARIABLE APPOINTMENT FLAG for clinic
S VAL=$$GET1^DIQ(44,SDCL_",",1913) ;Variable Appointment Length
S VAL=$S(VAL["YES":1,1:0)
S SDECI=SDECI+1
S ^TMP("SDEC",$J,SDECI)=VAL
S SDECI=SDECI+1
S ^TMP("SDEC",$J,SDECI)=$C(30)
S SDECI=SDECI+1
S ^TMP("SDEC",$J,SDECI)=$C(31)
Q
;
ERROR ;
D ERR("VISTA Error")
Q
;
ERR(SDECERR) ;Error processing
S SDECI=SDECI+1
S ^TMP("SDEC",$J,SDECI)=SDECERR_$C(30)
S SDECI=SDECI+1
S ^TMP("SDEC",$J,SDECI)=$C(31)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDEC37 3140 printed Dec 13, 2024@02:50:32 Page 2
SDEC37 ;ALB/SAT - VISTA SCHEDULING RPCS ;JAN 15, 2016
+1 ;;5.3;Scheduling;**627**;Aug 13, 1993;Build 249
+2 ;
+3 QUIT
+4 ;
+5 ; NS = RETURN NO-SHOW DATA FOR GIVEN PATIENT - RPC
+6 ; VAL = return boolean to represent that a clinic allows variable appointment length - RPC
+7 ;
+8 ;RETURN NO-SHOW DATA FOR GIVEN PATIENT - RPC
NOSHOPAT(SDECY,DFN,SDCL) ;COLLECT NO-SHOW DATA for Patient
+1 ;NOSHOPAT(SDECY,DFN,SDCL) external parameter tag is in SDEC
+2 ; .SDECY = returned pointer to NO SHOW data
+3 ; DFN = patient code - pointer to ^DPT(DFN)
+4 ; SDCL = clinic code - pointer to Hospital Location file ^SC
+5 NEW SDECI,SDBEG,SDEND,NSC,SD2,SDCLN,SDT,SDTN
+6 SET SDECI=0
+7 KILL ^TMP("SDEC",$JOB)
+8 SET SDECY="^TMP(""SDEC"","_$JOB_")"
+9 SET ^TMP("SDEC",$JOB,0)="T00020ERRORID"_$CHAR(30)
+10 ;check for valid patient
+11 IF '+DFN
DO ERR("Invalid Patient ID.")
QUIT
+12 IF '$DATA(^DPT(DFN,0))
DO ERR("Invalid Patient ID.")
QUIT
+13 ; data header
+14 ; TOO_MANY = flag 0=OK; 1=too many no shows
+15 SET ^TMP("SDEC",$JOB,0)="I00020PATIENT_IEN^I00020CLINIC_IEN^I00020TOO_MANY^I00020ALLOWED_NO_SHOWS^I00020TOTAL_NO_SHOWS"_$CHAR(30)
+16 ;get allowed number of no shows for clinic
+17 SET SDCLN=$GET(^SC(SDCL,"SDP"))
+18 ;loop thru schedule
+19 ;$P($$NOW^XLFDT,".",1)
SET SDEND=DT
+20 SET SDBEG=$$FMADD^XLFDT(SDEND,-365)
+21 ;no show counter
SET NSC=0
+22 SET SDT=SDBEG
+23 FOR
SET SDT=$ORDER(^DPT(DFN,"S",SDT))
if SDT'>0
QUIT
if $PIECE(SDT,".",1)>SDEND
QUIT
Begin DoDot:1
+24 SET SDTN=^DPT(DFN,"S",SDT,0)
+25 IF ($PIECE(SDTN,U)=SDCL)
Begin DoDot:2
+26 SET SD2=$PIECE(SDTN,U,2)
+27 IF SD2["N"
IF $$NOSHOW(DFN,SDT,$PIECE(SDTN,U),SDTN)
SET NSC=NSC+1
End DoDot:2
End DoDot:1
+28 SET SDECI=SDECI+1
+29 SET ^TMP("SDEC",$JOB,SDECI)=DFN_U_SDCL_U_($PIECE(SDCLN,U,1)'>NSC)_U_$PIECE(SDCLN,U)_U_NSC
+30 SET SDECI=SDECI+1
+31 SET ^TMP("SDEC",$JOB,SDECI)=$CHAR(30)
+32 SET SDECI=SDECI+1
+33 SET ^TMP("SDEC",$JOB,SDECI)=$CHAR(31)
+34 QUIT
+35 ;
NOSHOW(DFN,SDT,CIFN,PAT) ;Input: DFN=Patient IFN, SDT=Appointment D/T
+1 ; CIFN=Clinic IFN, PAT=Zero node of pat. appt., DA=Clinic appt. IFN
+2 ; Output: 1 or 0 for noshow yes/no
+3 NEW NSQUERY,NS
SET NS=1
SET NSQUERY=$$STATUS^SDAM1(DFN,SDT,CIFN,PAT)
+4 IF $PIECE(NSQUERY,";",3)["ACTION REQ"
SET NS=0
NOSHOWQ QUIT NS
+1 ;
CVARAPPT(SDECY,SDCL) ;IS Clinic Variable Appointment Length
+1 ;CVARAPPT(SDECY,SDCL) external parameter tag is in SDEC
+2 ;return boolean to represent that a clinic allows variable appointment length - RPC
+3 NEW SDECI,VAL
+4 SET SDECI=0
+5 KILL ^TMP("SDEC",$JOB)
+6 SET SDECY="^TMP(""SDEC"","_$JOB_")"
+7 SET ^TMP("SDEC",$JOB,0)="T00020ERRORID"_$CHAR(30)
+8 ;check for valid clinic ID
+9 IF '+SDCL
DO ERR("Invalid Clinic ID.")
QUIT
+10 IF '$DATA(^SC(SDCL,0))
DO ERR("Invalid Clinic ID.")
QUIT
+11 ; data header
+12 ; VAR_APPT_FLAG = flag 0=Clinic does not Allow Variable Appointment; 1=Clinic Allows Variable Appointment
+13 SET ^TMP("SDEC",$JOB,0)="I00020VAR_APPT_FLAG"_$CHAR(30)
+14 ;get VARIABLE APPOINTMENT FLAG for clinic
+15 ;Variable Appointment Length
SET VAL=$$GET1^DIQ(44,SDCL_",",1913)
+16 SET VAL=$SELECT(VAL["YES":1,1:0)
+17 SET SDECI=SDECI+1
+18 SET ^TMP("SDEC",$JOB,SDECI)=VAL
+19 SET SDECI=SDECI+1
+20 SET ^TMP("SDEC",$JOB,SDECI)=$CHAR(30)
+21 SET SDECI=SDECI+1
+22 SET ^TMP("SDEC",$JOB,SDECI)=$CHAR(31)
+23 QUIT
+24 ;
ERROR ;
+1 DO ERR("VISTA Error")
+2 QUIT
+3 ;
ERR(SDECERR) ;Error processing
+1 SET SDECI=SDECI+1
+2 SET ^TMP("SDEC",$JOB,SDECI)=SDECERR_$CHAR(30)
+3 SET SDECI=SDECI+1
+4 SET ^TMP("SDEC",$JOB,SDECI)=$CHAR(31)
+5 QUIT
+6 ;