SDESCANCELAPPT44 ;ALB/MGD,KML - CANCEL APPOINTMENT REQUEST IN FILE 44 ;Feb 14,2022
;;5.3;Scheduling;**805,809**;Aug 13, 1993;Build 10
;;Per VHA Directive 6402, this routine should not be modified
;
Q
; RPC: SDES CANCEL APPT #44
ARCANCEL44(RETURN,SDDFN,SDCLNIEN,SDARDTTM) ; Cancel Appointment Request in #44 (VSE-1944)
; INP - Input parameters array
; SDDFN = (Req) DFN Pointer to the PATIENT file #2
; SDCLNIEN = (Req) IEN of Clinic in HOSPITAL LOCATION #44
; SDARDTTM = (Req) Date/Time of Appointment in ISO 8601 extended format (e.g. 2022-01-19T20:15:44)
;
N POP,SDIEN,SDAPTREQ
S POP=0
;
D VALIDATE
I 'POP D UPDATE
D BUILDER
Q
;
VALIDATE ;
S POP=0
;
; Patient DFN
S SDDFN=$G(SDDFN,"")
I SDDFN="" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,1) Q
I SDDFN'="",'$D(^DPT(+SDDFN,0)) S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,2) Q
;
; Clinic IEN
S SDCLNIEN=$G(SDCLNIEN,"")
I SDCLNIEN="" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,18) Q
I '$D(^SC(+SDCLNIEN,0)) S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,19) Q
;
; Date/time of appt - CLINIC TIME ZONE
S SDARDTTM=$G(SDARDTTM,"")
I SDARDTTM="" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,76) Q
S SDARDTTM=$$ISOTFM^SDAMUTDT(SDARDTTM,SDCLNIEN) ;VSE-2396 convert from ISO8601 format to Fileman
I SDARDTTM=-1 S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,77) Q
S SDIEN=$$SCIEN(SDDFN,SDCLNIEN,SDARDTTM)
I $P(SDIEN,U,2)="C" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,52,"Appointment has already been cancelled.") Q
I 'SDIEN S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,52,"Appt Date/Time not found in Clinic for this Patient.") Q
S SDIEN=+SDIEN
Q
;
SCIEN(SDDFN,CLINIC,DATE) ;get the ien for the appointment
; Input -
; SDDFN = PATIENT ien (DFN)
; CLINIC = CLINIC ien
; DATE = Date/time of appointment
; Output - returns ien of appt at 44.003
N X,RESULTS,APPTSTRING
S (RESULTS,X)=0
F S X=$O(^SC(CLINIC,"S",DATE,1,X)) Q:'X D
. S APPTSTRING=$G(^SC(CLINIC,"S",DATE,1,X,0))
. I $P(APPTSTRING,U)=SDDFN,$P(APPTSTRING,U,9)="C" S RESULTS=X_"^C" Q ; APPT is cancelled for the patient
. I $P(APPTSTRING,U)=SDDFN S RESULTS=X
Q RESULTS
;
UPDATE ;Update Appointment for Cancellation
N SDFDA,SDERR
S SDFDA(44.003,SDIEN_","_SDARDTTM_","_SDCLNIEN_",",310)="C"
K SDERR D UPDATE^DIE("","SDFDA","","SDERR")
I $D(SDERR) S SDAPTREQ("Error",1)="Error trying to cancel Appointment in File #44." Q
S SDAPTREQ("Success")="Appointment is successfully cancelled."
Q
;
BUILDER ;Convert data to JSON
N JSONERR
S JSONERR=""
D ENCODE^SDESJSON(.SDAPTREQ,.RETURN,.JSONERR)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESCANCELAPPT44 2562 printed Dec 13, 2024@02:55:56 Page 2
SDESCANCELAPPT44 ;ALB/MGD,KML - CANCEL APPOINTMENT REQUEST IN FILE 44 ;Feb 14,2022
+1 ;;5.3;Scheduling;**805,809**;Aug 13, 1993;Build 10
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ; RPC: SDES CANCEL APPT #44
ARCANCEL44(RETURN,SDDFN,SDCLNIEN,SDARDTTM) ; Cancel Appointment Request in #44 (VSE-1944)
+1 ; INP - Input parameters array
+2 ; SDDFN = (Req) DFN Pointer to the PATIENT file #2
+3 ; SDCLNIEN = (Req) IEN of Clinic in HOSPITAL LOCATION #44
+4 ; SDARDTTM = (Req) Date/Time of Appointment in ISO 8601 extended format (e.g. 2022-01-19T20:15:44)
+5 ;
+6 NEW POP,SDIEN,SDAPTREQ
+7 SET POP=0
+8 ;
+9 DO VALIDATE
+10 IF 'POP
DO UPDATE
+11 DO BUILDER
+12 QUIT
+13 ;
VALIDATE ;
+1 SET POP=0
+2 ;
+3 ; Patient DFN
+4 SET SDDFN=$GET(SDDFN,"")
+5 IF SDDFN=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,1)
QUIT
+6 IF SDDFN'=""
IF '$DATA(^DPT(+SDDFN,0))
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,2)
QUIT
+7 ;
+8 ; Clinic IEN
+9 SET SDCLNIEN=$GET(SDCLNIEN,"")
+10 IF SDCLNIEN=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,18)
QUIT
+11 IF '$DATA(^SC(+SDCLNIEN,0))
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,19)
QUIT
+12 ;
+13 ; Date/time of appt - CLINIC TIME ZONE
+14 SET SDARDTTM=$GET(SDARDTTM,"")
+15 IF SDARDTTM=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,76)
QUIT
+16 ;VSE-2396 convert from ISO8601 format to Fileman
SET SDARDTTM=$$ISOTFM^SDAMUTDT(SDARDTTM,SDCLNIEN)
+17 IF SDARDTTM=-1
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,77)
QUIT
+18 SET SDIEN=$$SCIEN(SDDFN,SDCLNIEN,SDARDTTM)
+19 IF $PIECE(SDIEN,U,2)="C"
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,52,"Appointment has already been cancelled.")
QUIT
+20 IF 'SDIEN
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,52,"Appt Date/Time not found in Clinic for this Patient.")
QUIT
+21 SET SDIEN=+SDIEN
+22 QUIT
+23 ;
SCIEN(SDDFN,CLINIC,DATE) ;get the ien for the appointment
+1 ; Input -
+2 ; SDDFN = PATIENT ien (DFN)
+3 ; CLINIC = CLINIC ien
+4 ; DATE = Date/time of appointment
+5 ; Output - returns ien of appt at 44.003
+6 NEW X,RESULTS,APPTSTRING
+7 SET (RESULTS,X)=0
+8 FOR
SET X=$ORDER(^SC(CLINIC,"S",DATE,1,X))
if 'X
QUIT
Begin DoDot:1
+9 SET APPTSTRING=$GET(^SC(CLINIC,"S",DATE,1,X,0))
+10 ; APPT is cancelled for the patient
IF $PIECE(APPTSTRING,U)=SDDFN
IF $PIECE(APPTSTRING,U,9)="C"
SET RESULTS=X_"^C"
QUIT
+11 IF $PIECE(APPTSTRING,U)=SDDFN
SET RESULTS=X
End DoDot:1
+12 QUIT RESULTS
+13 ;
UPDATE ;Update Appointment for Cancellation
+1 NEW SDFDA,SDERR
+2 SET SDFDA(44.003,SDIEN_","_SDARDTTM_","_SDCLNIEN_",",310)="C"
+3 KILL SDERR
DO UPDATE^DIE("","SDFDA","","SDERR")
+4 IF $DATA(SDERR)
SET SDAPTREQ("Error",1)="Error trying to cancel Appointment in File #44."
QUIT
+5 SET SDAPTREQ("Success")="Appointment is successfully cancelled."
+6 QUIT
+7 ;
BUILDER ;Convert data to JSON
+1 NEW JSONERR
+2 SET JSONERR=""
+3 DO ENCODE^SDESJSON(.SDAPTREQ,.RETURN,.JSONERR)
+4 QUIT