SDESREACTVTCLIN ;ALB/RRM - VISTA SCHEDULING REACTIVATE CLINIC RPC in HOSPITAL LOCATION FILE 44 ;July 21, 2022
;;5.3;Scheduling;**823**;Aug 13, 1993;Build 9
;;Per VHA Directive 6402, this routine should not be modified
;
; Documented API's and Integration Agreements
; -------------------------------------------
; Reference to $$GET1^DIQ is supported by IA #2056
; Reference to TURNON^DIAUTL is supported by IA #4397
;
Q ;No Direct Call
;
; The parameter list for this RPC must be kept in sync.
; If you need to add or remove a parameter, ensure that the Remote Procedure File #8994 definition is also updated.
;
REACTIVATECLIN(RETURNJSON,SDCLINICIEN,REACTIVATIONDATE,SDEAS) ;Entry point for SDES REACTIVATE CLINIC RPC
; Input:
; SDCLINICIEN [Required] - The CLINIC IEN from the HOSPITAL LOCATION FILE #44
; REACTIVATIONDATE [Required] - The Clinic reactivation date in ISO FORMAT. It must have been previously inactivated.
; SDEAS [optional] - The Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
;
; Output:
; Successful Return:
; RETURNJSON = Returns the reactivated clinic IEN along with the successful message in JSON formatted string.
; Otherwise, JSON Errors will be returned for any invalid/missing parameters.
;
N ERRORS,RETURNERROR,RETURN ;temp data storage for input validation error
N ISREACTIVATED
;
K RETURNJSON ;always kill the return json array
;
D INITVAR
D VALCLNIENREACTDT(.ERRORS,SDCLINICIEN,REACTIVATIONDATE)
D VALIDATEEAS^SDESINPUTVALUTL(.ERRORS,SDEAS)
I $O(ERRORS("Error",""))'="" D SETERRORRETURN(.ERRORS,.RETURNERROR,.RETURNJSON) Q
D TURNON^DIAUTL(44,2506,"y") ;turn on auditing for REACTIVATE DATE field in the HOSPITAL LOCATION (#44) file
S REACTIVATIONDATE=$$ISOTFM^SDAMUTDT(REACTIVATIONDATE,SDCLINICIEN)
S ISREACTIVATED=$$REACTIVATE(.RETURN,SDCLINICIEN,REACTIVATIONDATE)
I $O(ERRORS("Error",""))'="" D SETERRORRETURN(.ERRORS,.RETURNERROR,.RETURNJSON) Q ;error occured during filing
I ISREACTIVATED D UPDATECLNRES(SDCLINICIEN,REACTIVATIONDATE)
D BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURN)
Q
;
INITVAR ;Initialize input parameter
S SDCLINICIEN=$G(SDCLINICIEN)
S SDEAS=$G(SDEAS)
S REACTIVATIONDATE=$G(REACTIVATIONDATE)
Q
;
REACTIVATE(RETURN,SDCLINICIEN,REACTIVATIONDATE) ;Reactivate Clinic
N SDERR,SDFDA,SDCLNNAME,ISFILED
S ISFILED=0
;Only update the Reactivate Date field if the reacivation passed in is different
I $$GET1^DIQ(44,SDCLINICIEN,2506)'=$P(REACTIVATIONDATE,".") D
. S SDCLNNAME=$$GET1^DIQ(44,SDCLINICIEN,.01)
. I $E(SDCLNNAME,1,2)="ZZ" S SDFDA(44,SDCLINICIEN_",",.01)=$E($$GET1^DIQ(44,SDCLINICIEN,.01),3,32)
. S SDFDA(44,SDCLINICIEN_",",2506)=$P(REACTIVATIONDATE,".")
. D FILE^DIE("","SDFDA","SDERR")
. I $G(SDERR) S ISFILED=0 D ERRLOG^SDESJSON(.ERRORS,239) Q
. S RETURN("Clinic","IEN")=SDCLINICIEN
. S RETURN("Clinic","SuccessMessage")="Clinic is successfully reactivated effective "_$TR($$FMTE^XLFDT(REACTIVATIONDATE,"5DF")," ","0")
. S ISFILED=1
Q ISFILED
;
UPDATECLNRES(SDCLINICIEN,REACTIVATIONDATE) ;Update REACTIVATED DATE/TIME and REACTIVATED BY USER in SDEC RESOURCE File #409.831
N SDRESFDA,SDCLINRES
S SDCLINRES=$$GETRES^SDECUTL(SDCLINICIEN,1)
Q:SDCLINRES=""
S SDRESFDA(409.831,SDCLINRES_",",.025)=$P(REACTIVATIONDATE,".")
S SDRESFDA(409.831,SDCLINRES_",",.026)=DUZ
D FILE^DIE("","SDRESFDA")
Q
;
VALCLNIENREACTDT(ERRORS,CLINICIEN,REACTIVATIONDATE) ;validate Clinic IEN and Reactivation Date (they need to go hand in hand together)
N INACTDT,REACTDT
I CLINICIEN="" D ERRLOG^SDESJSON(.ERRORS,18)
I CLINICIEN'="" D
. I '$D(^SC(CLINICIEN,0)) D ERRLOG^SDESJSON(.ERRORS,19) Q
. I $P(^SC(CLINICIEN,0),"^",3)'="C" D ERRLOG^SDESJSON(.ERRORS,236) Q
. I $S('$D(^SC(CLINICIEN,"I")):1,'$P(^SC(CLINICIEN,"I"),"^",1):1,1:0) D ERRLOG^SDESJSON(.ERRORS,235)
;
I REACTIVATIONDATE="" D ERRLOG^SDESJSON(.ERRORS,240)
I REACTIVATIONDATE'="",$$ISOTFM^SDAMUTDT(REACTIVATIONDATE,SDCLINICIEN)<1 D ERRLOG^SDESJSON(.ERRORS,238) Q
I REACTIVATIONDATE'="" D
. S REACTIVATIONDATE=$$ISOTFM^SDAMUTDT(REACTIVATIONDATE,SDCLINICIEN)
. I REACTIVATIONDATE=-1 D ERRLOG^SDESJSON(.ERRORS,238) Q
. Q:CLINICIEN=""
. Q:'$D(^SC(CLINICIEN,0))
. S INACTDT=$P($G(^SC(CLINICIEN,"I")),"^")
. S REACTDT=$P($G(^SC(CLINICIEN,"I")),"^",2)
. I $P(REACTIVATIONDATE,".")'>$G(INACTDT) D ERRLOG^SDESJSON(.ERRORS,237) Q
. I $$GET1^DIQ(44,CLINICIEN,2506,"I")=$P(REACTIVATIONDATE,".") D Q
. . S ERRORS("Error",1)="Clinic already reactivated effective "_$TR($$FMTE^XLFDT(REACTIVATIONDATE,"5DF")," ","0")
. I $G(REACTDT)>DT D Q
. . S ERRORS("Error",1)="Clinic is inactive as of "_$TR($$FMTE^XLFDT(INACTDT,"5DF")," ","0")
. . S ERRORS("Error",1)=ERRORS("Error",1)_" and is already scheduled to be reactivated as of "_$TR($$FMTE^XLFDT(REACTDT,"5DF")," ","0")
Q
;
SETERRORRETURN(ERRORS,RETURNERROR,RETURNJSON) ;
M RETURNERROR=ERRORS
D SETEMPTYOBJECT(.RETURNERROR) ;set the return object into null if an error occur
D BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURNERROR)
Q
;
SETEMPTYOBJECT(RETURNERROR) ;set the return object into null if an error occur
S RETURNERROR("Clinic","IEN")=""
S RETURNERROR("Clinic","SuccessMessage")=""
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESREACTVTCLIN 5293 printed Dec 13, 2024@02:57:37 Page 2
SDESREACTVTCLIN ;ALB/RRM - VISTA SCHEDULING REACTIVATE CLINIC RPC in HOSPITAL LOCATION FILE 44 ;July 21, 2022
+1 ;;5.3;Scheduling;**823**;Aug 13, 1993;Build 9
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Documented API's and Integration Agreements
+5 ; -------------------------------------------
+6 ; Reference to $$GET1^DIQ is supported by IA #2056
+7 ; Reference to TURNON^DIAUTL is supported by IA #4397
+8 ;
+9 ;No Direct Call
QUIT
+10 ;
+11 ; The parameter list for this RPC must be kept in sync.
+12 ; If you need to add or remove a parameter, ensure that the Remote Procedure File #8994 definition is also updated.
+13 ;
REACTIVATECLIN(RETURNJSON,SDCLINICIEN,REACTIVATIONDATE,SDEAS) ;Entry point for SDES REACTIVATE CLINIC RPC
+1 ; Input:
+2 ; SDCLINICIEN [Required] - The CLINIC IEN from the HOSPITAL LOCATION FILE #44
+3 ; REACTIVATIONDATE [Required] - The Clinic reactivation date in ISO FORMAT. It must have been previously inactivated.
+4 ; SDEAS [optional] - The Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
+5 ;
+6 ; Output:
+7 ; Successful Return:
+8 ; RETURNJSON = Returns the reactivated clinic IEN along with the successful message in JSON formatted string.
+9 ; Otherwise, JSON Errors will be returned for any invalid/missing parameters.
+10 ;
+11 ;temp data storage for input validation error
NEW ERRORS,RETURNERROR,RETURN
+12 NEW ISREACTIVATED
+13 ;
+14 ;always kill the return json array
KILL RETURNJSON
+15 ;
+16 DO INITVAR
+17 DO VALCLNIENREACTDT(.ERRORS,SDCLINICIEN,REACTIVATIONDATE)
+18 DO VALIDATEEAS^SDESINPUTVALUTL(.ERRORS,SDEAS)
+19 IF $ORDER(ERRORS("Error",""))'=""
DO SETERRORRETURN(.ERRORS,.RETURNERROR,.RETURNJSON)
QUIT
+20 ;turn on auditing for REACTIVATE DATE field in the HOSPITAL LOCATION (#44) file
DO TURNON^DIAUTL(44,2506,"y")
+21 SET REACTIVATIONDATE=$$ISOTFM^SDAMUTDT(REACTIVATIONDATE,SDCLINICIEN)
+22 SET ISREACTIVATED=$$REACTIVATE(.RETURN,SDCLINICIEN,REACTIVATIONDATE)
+23 ;error occured during filing
IF $ORDER(ERRORS("Error",""))'=""
DO SETERRORRETURN(.ERRORS,.RETURNERROR,.RETURNJSON)
QUIT
+24 IF ISREACTIVATED
DO UPDATECLNRES(SDCLINICIEN,REACTIVATIONDATE)
+25 DO BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURN)
+26 QUIT
+27 ;
INITVAR ;Initialize input parameter
+1 SET SDCLINICIEN=$GET(SDCLINICIEN)
+2 SET SDEAS=$GET(SDEAS)
+3 SET REACTIVATIONDATE=$GET(REACTIVATIONDATE)
+4 QUIT
+5 ;
REACTIVATE(RETURN,SDCLINICIEN,REACTIVATIONDATE) ;Reactivate Clinic
+1 NEW SDERR,SDFDA,SDCLNNAME,ISFILED
+2 SET ISFILED=0
+3 ;Only update the Reactivate Date field if the reacivation passed in is different
+4 IF $$GET1^DIQ(44,SDCLINICIEN,2506)'=$PIECE(REACTIVATIONDATE,".")
Begin DoDot:1
+5 SET SDCLNNAME=$$GET1^DIQ(44,SDCLINICIEN,.01)
+6 IF $EXTRACT(SDCLNNAME,1,2)="ZZ"
SET SDFDA(44,SDCLINICIEN_",",.01)=$EXTRACT($$GET1^DIQ(44,SDCLINICIEN,.01),3,32)
+7 SET SDFDA(44,SDCLINICIEN_",",2506)=$PIECE(REACTIVATIONDATE,".")
+8 DO FILE^DIE("","SDFDA","SDERR")
+9 IF $GET(SDERR)
SET ISFILED=0
DO ERRLOG^SDESJSON(.ERRORS,239)
QUIT
+10 SET RETURN("Clinic","IEN")=SDCLINICIEN
+11 SET RETURN("Clinic","SuccessMessage")="Clinic is successfully reactivated effective "_$TRANSLATE($$FMTE^XLFDT(REACTIVATIONDATE,"5DF")," ","0")
+12 SET ISFILED=1
End DoDot:1
+13 QUIT ISFILED
+14 ;
UPDATECLNRES(SDCLINICIEN,REACTIVATIONDATE) ;Update REACTIVATED DATE/TIME and REACTIVATED BY USER in SDEC RESOURCE File #409.831
+1 NEW SDRESFDA,SDCLINRES
+2 SET SDCLINRES=$$GETRES^SDECUTL(SDCLINICIEN,1)
+3 if SDCLINRES=""
QUIT
+4 SET SDRESFDA(409.831,SDCLINRES_",",.025)=$PIECE(REACTIVATIONDATE,".")
+5 SET SDRESFDA(409.831,SDCLINRES_",",.026)=DUZ
+6 DO FILE^DIE("","SDRESFDA")
+7 QUIT
+8 ;
VALCLNIENREACTDT(ERRORS,CLINICIEN,REACTIVATIONDATE) ;validate Clinic IEN and Reactivation Date (they need to go hand in hand together)
+1 NEW INACTDT,REACTDT
+2 IF CLINICIEN=""
DO ERRLOG^SDESJSON(.ERRORS,18)
+3 IF CLINICIEN'=""
Begin DoDot:1
+4 IF '$DATA(^SC(CLINICIEN,0))
DO ERRLOG^SDESJSON(.ERRORS,19)
QUIT
+5 IF $PIECE(^SC(CLINICIEN,0),"^",3)'="C"
DO ERRLOG^SDESJSON(.ERRORS,236)
QUIT
+6 IF $SELECT('$DATA(^SC(CLINICIEN,"I")):1,'$PIECE(^SC(CLINICIEN,"I"),"^",1):1,1:0)
DO ERRLOG^SDESJSON(.ERRORS,235)
End DoDot:1
+7 ;
+8 IF REACTIVATIONDATE=""
DO ERRLOG^SDESJSON(.ERRORS,240)
+9 IF REACTIVATIONDATE'=""
IF $$ISOTFM^SDAMUTDT(REACTIVATIONDATE,SDCLINICIEN)<1
DO ERRLOG^SDESJSON(.ERRORS,238)
QUIT
+10 IF REACTIVATIONDATE'=""
Begin DoDot:1
+11 SET REACTIVATIONDATE=$$ISOTFM^SDAMUTDT(REACTIVATIONDATE,SDCLINICIEN)
+12 IF REACTIVATIONDATE=-1
DO ERRLOG^SDESJSON(.ERRORS,238)
QUIT
+13 if CLINICIEN=""
QUIT
+14 if '$DATA(^SC(CLINICIEN,0))
QUIT
+15 SET INACTDT=$PIECE($GET(^SC(CLINICIEN,"I")),"^")
+16 SET REACTDT=$PIECE($GET(^SC(CLINICIEN,"I")),"^",2)
+17 IF $PIECE(REACTIVATIONDATE,".")'>$GET(INACTDT)
DO ERRLOG^SDESJSON(.ERRORS,237)
QUIT
+18 IF $$GET1^DIQ(44,CLINICIEN,2506,"I")=$PIECE(REACTIVATIONDATE,".")
Begin DoDot:2
+19 SET ERRORS("Error",1)="Clinic already reactivated effective "_$TRANSLATE($$FMTE^XLFDT(REACTIVATIONDATE,"5DF")," ","0")
End DoDot:2
QUIT
+20 IF $GET(REACTDT)>DT
Begin DoDot:2
+21 SET ERRORS("Error",1)="Clinic is inactive as of "_$TRANSLATE($$FMTE^XLFDT(INACTDT,"5DF")," ","0")
+22 SET ERRORS("Error",1)=ERRORS("Error",1)_" and is already scheduled to be reactivated as of "_$TRANSLATE($$FMTE^XLFDT(REACTDT,"5DF")," ","0")
End DoDot:2
QUIT
End DoDot:1
+23 QUIT
+24 ;
SETERRORRETURN(ERRORS,RETURNERROR,RETURNJSON) ;
+1 MERGE RETURNERROR=ERRORS
+2 ;set the return object into null if an error occur
DO SETEMPTYOBJECT(.RETURNERROR)
+3 DO BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURNERROR)
+4 QUIT
+5 ;
SETEMPTYOBJECT(RETURNERROR) ;set the return object into null if an error occur
+1 SET RETURNERROR("Clinic","IEN")=""
+2 SET RETURNERROR("Clinic","SuccessMessage")=""
+3 QUIT
+4 ;