SDESCANCELAPPT ;ALB/BLB,ANU,MGD - VISTA SCHEDULING RPCS ;June 17, 2022
;;5.3;Scheduling;**801,804,805,819**;Aug 13, 1993;Build 5
;;Per VHA Directive 6402, this routine should not be modified;
;
CANCELAPPT(SDECY,APPTIEN,STATUS,CANREAS,USER,EAS) ;
;APPTIEN - (required) pointer to SDEC APPOINTMENT file
;STATUS - (required) appointment Status valid values:
; C=CANCELLED BY CLINIC
; PC=CANCELLED BY PATIENT
;CANREAS - (required) pointer to cancel reason file
;USER - (optional) DUZ of user cancelling appt
;EAS - (optional) EAS Tracking Number
N FDA,ERROR,SDAPPT,DATETIME
S ERROR=0
I $G(APPTIEN)="" D ERRLOG^SDESJSON(.SDAPPT,14) S ERROR=1 ; missing appt IEN
I $G(APPTIEN)'="",'$D(^SDEC(409.84,APPTIEN,0)) D ERRLOG^SDESJSON(.SDAPPT,15) S ERROR=1 ; invalid appt IEN
S DATETIME=$$NOW^XLFDT
I $G(STATUS)="" D ERRLOG^SDESJSON(.SDAPPT,38) S ERROR=1 ; missing status
I $G(STATUS)'="" D
.I $G(STATUS)'="C",$G(STATUS)'="PC" D ERRLOG^SDESJSON(.SDAPPT,30) S ERROR=1 ; invalid cancel status
I USER'="" I '$D(^VA(200,+USER,0)) S USER=""
I $G(USER)="" S USER=$G(DUZ)
I $G(CANREAS)="" D ERRLOG^SDESJSON(.SDAPPT,128) S ERROR=1 ; missing cancellation reason
I $G(CANREAS)'="",'$D(^SD(409.2,CANREAS,0)) D ERRLOG^SDESJSON(.SDAPPT,129) S ERROR=1 ; invalid cancellation reason
S EAS=$G(EAS,"")
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
I EAS=-1 D ERRLOG^SDESJSON(.SDAPPT,142) S ERROR=1
;
I '$G(ERROR) D
.S FDA(409.84,APPTIEN_",",.12)=$G(DATETIME)
.S FDA(409.84,APPTIEN_",",.121)=$G(DUZ)
.S FDA(409.84,APPTIEN_",",.17)=$G(STATUS)
.;SD*5.3*804 - Not delete VVS ID when called from SDES CANCEL APPT RPC
.;S FDA(409.84,APPTIEN_",",2)="@" ;patch SD*5.3*796, delete VVS appointment ID if appoinment is cancelled
.S FDA(409.84,APPTIEN_",",.122)=$G(CANREAS)
.S FDA(409.84,APPTIEN_",",100)=$G(EAS)
.D FILE^DIE(,"FDA","ERR")
.S SDAPPT("CancelAppt","Success")=1
D BUILDER
Q
;
BUILDER ;Convert data to JSON
N JSONERR
S JSONERR=""
D ENCODE^SDESJSON(.SDAPPT,.SDECY,.JSONERR)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESCANCELAPPT 2092 printed Oct 16, 2024@18:56:19 Page 2
SDESCANCELAPPT ;ALB/BLB,ANU,MGD - VISTA SCHEDULING RPCS ;June 17, 2022
+1 ;;5.3;Scheduling;**801,804,805,819**;Aug 13, 1993;Build 5
+2 ;;Per VHA Directive 6402, this routine should not be modified;
+3 ;
CANCELAPPT(SDECY,APPTIEN,STATUS,CANREAS,USER,EAS) ;
+1 ;APPTIEN - (required) pointer to SDEC APPOINTMENT file
+2 ;STATUS - (required) appointment Status valid values:
+3 ; C=CANCELLED BY CLINIC
+4 ; PC=CANCELLED BY PATIENT
+5 ;CANREAS - (required) pointer to cancel reason file
+6 ;USER - (optional) DUZ of user cancelling appt
+7 ;EAS - (optional) EAS Tracking Number
+8 NEW FDA,ERROR,SDAPPT,DATETIME
+9 SET ERROR=0
+10 ; missing appt IEN
IF $GET(APPTIEN)=""
DO ERRLOG^SDESJSON(.SDAPPT,14)
SET ERROR=1
+11 ; invalid appt IEN
IF $GET(APPTIEN)'=""
IF '$DATA(^SDEC(409.84,APPTIEN,0))
DO ERRLOG^SDESJSON(.SDAPPT,15)
SET ERROR=1
+12 SET DATETIME=$$NOW^XLFDT
+13 ; missing status
IF $GET(STATUS)=""
DO ERRLOG^SDESJSON(.SDAPPT,38)
SET ERROR=1
+14 IF $GET(STATUS)'=""
Begin DoDot:1
+15 ; invalid cancel status
IF $GET(STATUS)'="C"
IF $GET(STATUS)'="PC"
DO ERRLOG^SDESJSON(.SDAPPT,30)
SET ERROR=1
End DoDot:1
+16 IF USER'=""
IF '$DATA(^VA(200,+USER,0))
SET USER=""
+17 IF $GET(USER)=""
SET USER=$GET(DUZ)
+18 ; missing cancellation reason
IF $GET(CANREAS)=""
DO ERRLOG^SDESJSON(.SDAPPT,128)
SET ERROR=1
+19 ; invalid cancellation reason
IF $GET(CANREAS)'=""
IF '$DATA(^SD(409.2,CANREAS,0))
DO ERRLOG^SDESJSON(.SDAPPT,129)
SET ERROR=1
+20 SET EAS=$GET(EAS,"")
+21 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL(EAS)
+22 IF EAS=-1
DO ERRLOG^SDESJSON(.SDAPPT,142)
SET ERROR=1
+23 ;
+24 IF '$GET(ERROR)
Begin DoDot:1
+25 SET FDA(409.84,APPTIEN_",",.12)=$GET(DATETIME)
+26 SET FDA(409.84,APPTIEN_",",.121)=$GET(DUZ)
+27 SET FDA(409.84,APPTIEN_",",.17)=$GET(STATUS)
+28 ;SD*5.3*804 - Not delete VVS ID when called from SDES CANCEL APPT RPC
+29 ;S FDA(409.84,APPTIEN_",",2)="@" ;patch SD*5.3*796, delete VVS appointment ID if appoinment is cancelled
+30 SET FDA(409.84,APPTIEN_",",.122)=$GET(CANREAS)
+31 SET FDA(409.84,APPTIEN_",",100)=$GET(EAS)
+32 DO FILE^DIE(,"FDA","ERR")
+33 SET SDAPPT("CancelAppt","Success")=1
End DoDot:1
+34 DO BUILDER
+35 QUIT
+36 ;
BUILDER ;Convert data to JSON
+1 NEW JSONERR
+2 SET JSONERR=""
+3 DO ENCODE^SDESJSON(.SDAPPT,.SDECY,.JSONERR)
+4 QUIT