SDESCLINPRECAN ;ALB/BWF,MCB - VISTA SCHEDULING RPCS CANCEL CLINIC AVAILABILITY - PRE-CANCELLATION LIST ; August 23, 2022
;;5.3;Scheduling;**824,825,877**;Aug 13, 1993;Build 14
;;Per VHA Directive 6402, this routine should not be modified
;
;
Q ;No Direct Call
; get pre-cancellation list for cancelling clinic availability
PRECANLIST(SDRES,SDCLNIEN,SDFULLPART,SDESBEGDTTM,SDESENDDTTM,SDEAS) ;
; This RPC cancels Clinic availability within a given timeframe for a given clinic.
; Input:
; SDRES [required] - Success or Error message
; SDCLNIEN [required] - The Internal Entry Number (IEN) from the HOSPITAL LOCATION File #44
; SDFULLPART [required] - Full or partial day cancellation ('F' for full, 'P' for partial)
; SDESBEGDTTM [required] - Start date/time in ISO8601 format (CCYY-MM-DDTHH:MM:SS-HH:MM)
; SDESENDDTTM [required] - End Date/time in ISO8601 format (CCYY-MM-DDTHH:MM:SS-HH:MM)
; SDEAS [optional] - Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
;
N FMSDTTM,FMEDDTM,ERRORS,SINC,STARTOFDAY,SDCLNSREC,RESULTS,SDCLNJSON,APPTCHK
S SDCLNIEN=$G(SDCLNIEN),SDFULLPART=$G(SDFULLPART),SDESBEGDTTM=$G(SDESBEGDTTM),SDESENDDTTM=$G(SDESENDDTTM),SDEAS=$G(SDEAS)
; validate the dates first, since we need them to fully validate the clinic
D VALIDATEFULLPART^SDESCCAVAIL(.ERRORS,SDFULLPART)
I $D(ERRORS) S ERRORS("PreCancellationList",1)="" D BUILDJSON^SDESBUILDJSON(.SDRES,.ERRORS) Q
;
S FMSDTTM=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(SDESBEGDTTM),SDCLNIEN,1,9,11)
S FMEDDTM=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(SDESENDDTTM),SDCLNIEN,1,10,12)
I $G(SDESENDDTTM)>$G(SDESENDDTTM) D ERRLOG^SDESJSON(.ERRORS,13)
I $D(ERRORS) S ERRORS("PreCancellationList",1)="" D BUILDJSON^SDESBUILDJSON(.SDRES,.ERRORS) Q
;
S SINC=""
D VALIDATECLINIC^SDESCCAVAIL(.ERRORS,SDCLNIEN,FMSDTTM,FMEDDTM,.SINC,.STARTOFDAY)
D VALIDATEEAS^SDESCCAVAIL(.ERRORS,SDEAS)
I $D(ERRORS) D Q
.S ERRORS("PreCancellationList",1)=""
.D BUILDJSON^SDESBUILDJSON(.SDRES,.ERRORS)
D BLDPRECANLIST(.SDCLNJSON,SDFULLPART,SDCLNIEN,FMSDTTM,FMEDDTM)
; filter out cancelled appointments
S APPTCHK=0 F S APPTCHK=$O(SDCLNJSON("Appointment",APPTCHK)) Q:'APPTCHK D
.I $G(SDCLNJSON("Appointment",APPTCHK,"AppointmentCancelled"))]"" K SDCLNJSON("Appointment",APPTCHK)
M RESULTS("PreCancellationList")=SDCLNJSON
I '$D(RESULTS) S RESULTS("PreCancellationList",1)=""
D BUILDJSON^SDESBUILDJSON(.SDRES,.RESULTS)
Q
; build pre-cancellation list
BLDPRECANLIST(APPTDATA,FULLPART,CLINICIEN,STARTDTTM,ENDDTTM) ;
N APPTDTTM,SFIEN,IENS,DFN,CNT,RETURN
S CNT=0
I FULLPART="F" S ENDDTTM=$P(ENDDTTM,".")_.2359
D GETAPPOINTMENTS^SDESGETAPPTWRAP4(.APPTDATA,CLINICIEN,STARTDTTM,ENDDTTM,1)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESCLINPRECAN 2780 printed Oct 16, 2024@18:56:39 Page 2
SDESCLINPRECAN ;ALB/BWF,MCB - VISTA SCHEDULING RPCS CANCEL CLINIC AVAILABILITY - PRE-CANCELLATION LIST ; August 23, 2022
+1 ;;5.3;Scheduling;**824,825,877**;Aug 13, 1993;Build 14
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ;
+5 ;No Direct Call
QUIT
+6 ; get pre-cancellation list for cancelling clinic availability
PRECANLIST(SDRES,SDCLNIEN,SDFULLPART,SDESBEGDTTM,SDESENDDTTM,SDEAS) ;
+1 ; This RPC cancels Clinic availability within a given timeframe for a given clinic.
+2 ; Input:
+3 ; SDRES [required] - Success or Error message
+4 ; SDCLNIEN [required] - The Internal Entry Number (IEN) from the HOSPITAL LOCATION File #44
+5 ; SDFULLPART [required] - Full or partial day cancellation ('F' for full, 'P' for partial)
+6 ; SDESBEGDTTM [required] - Start date/time in ISO8601 format (CCYY-MM-DDTHH:MM:SS-HH:MM)
+7 ; SDESENDDTTM [required] - End Date/time in ISO8601 format (CCYY-MM-DDTHH:MM:SS-HH:MM)
+8 ; SDEAS [optional] - Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
+9 ;
+10 NEW FMSDTTM,FMEDDTM,ERRORS,SINC,STARTOFDAY,SDCLNSREC,RESULTS,SDCLNJSON,APPTCHK
+11 SET SDCLNIEN=$GET(SDCLNIEN)
SET SDFULLPART=$GET(SDFULLPART)
SET SDESBEGDTTM=$GET(SDESBEGDTTM)
SET SDESENDDTTM=$GET(SDESENDDTTM)
SET SDEAS=$GET(SDEAS)
+12 ; validate the dates first, since we need them to fully validate the clinic
+13 DO VALIDATEFULLPART^SDESCCAVAIL(.ERRORS,SDFULLPART)
+14 IF $DATA(ERRORS)
SET ERRORS("PreCancellationList",1)=""
DO BUILDJSON^SDESBUILDJSON(.SDRES,.ERRORS)
QUIT
+15 ;
+16 SET FMSDTTM=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$GET(SDESBEGDTTM),SDCLNIEN,1,9,11)
+17 SET FMEDDTM=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$GET(SDESENDDTTM),SDCLNIEN,1,10,12)
+18 IF $GET(SDESENDDTTM)>$GET(SDESENDDTTM)
DO ERRLOG^SDESJSON(.ERRORS,13)
+19 IF $DATA(ERRORS)
SET ERRORS("PreCancellationList",1)=""
DO BUILDJSON^SDESBUILDJSON(.SDRES,.ERRORS)
QUIT
+20 ;
+21 SET SINC=""
+22 DO VALIDATECLINIC^SDESCCAVAIL(.ERRORS,SDCLNIEN,FMSDTTM,FMEDDTM,.SINC,.STARTOFDAY)
+23 DO VALIDATEEAS^SDESCCAVAIL(.ERRORS,SDEAS)
+24 IF $DATA(ERRORS)
Begin DoDot:1
+25 SET ERRORS("PreCancellationList",1)=""
+26 DO BUILDJSON^SDESBUILDJSON(.SDRES,.ERRORS)
End DoDot:1
QUIT
+27 DO BLDPRECANLIST(.SDCLNJSON,SDFULLPART,SDCLNIEN,FMSDTTM,FMEDDTM)
+28 ; filter out cancelled appointments
+29 SET APPTCHK=0
FOR
SET APPTCHK=$ORDER(SDCLNJSON("Appointment",APPTCHK))
if 'APPTCHK
QUIT
Begin DoDot:1
+30 IF $GET(SDCLNJSON("Appointment",APPTCHK,"AppointmentCancelled"))]""
KILL SDCLNJSON("Appointment",APPTCHK)
End DoDot:1
+31 MERGE RESULTS("PreCancellationList")=SDCLNJSON
+32 IF '$DATA(RESULTS)
SET RESULTS("PreCancellationList",1)=""
+33 DO BUILDJSON^SDESBUILDJSON(.SDRES,.RESULTS)
+34 QUIT
+35 ; build pre-cancellation list
BLDPRECANLIST(APPTDATA,FULLPART,CLINICIEN,STARTDTTM,ENDDTTM) ;
+1 NEW APPTDTTM,SFIEN,IENS,DFN,CNT,RETURN
+2 SET CNT=0
+3 IF FULLPART="F"
SET ENDDTTM=$PIECE(ENDDTTM,".")_.2359
+4 DO GETAPPOINTMENTS^SDESGETAPPTWRAP4(.APPTDATA,CLINICIEN,STARTDTTM,ENDDTTM,1)
+5 QUIT