SDESCRTAPPREQVAL ;ALB/JAS - Additional validation for SDESCREATEAPPREQ; FEB 07, 2024
;;5.3;Scheduling;**871**;Aug 13, 1993;Build 13
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
; RPC: SDES CREATE APPT REQ (Continued from SDESCREATEAPPREQ)
;
VALIDATEDFN(ERRORS,DFN) ;
I DFN="" D ERRLOG^SDESJSON(.ERRORS,1) Q 0
I DFN'="",'$D(^DPT(DFN,0)) D ERRLOG^SDESJSON(.ERRORS,2) Q 0
Q 1
;
VALIDATEDATETIME(ERRORS,REQUEST) ;
I $G(REQUEST("CREATE DATE"))="" D Q 1
. S REQUEST("CREATE DATE")=DT
. N NOWDT S NOWDT=$$FMTISO^SDAMUTDT($$NOW^XLFDT) Q:NOWDT=-1
. S REQUEST("CREATE DATE")=$P($$ISOTFM^SDAMUTDT(NOWDT,$G(REQUEST("CLINIC IEN"))),".")
I $G(REQUEST("CREATE DATE"))'="" S REQUEST("CREATE DATE")=$$ISOTFM^SDAMUTDT($G(REQUEST("CREATE DATE")))
I $G(REQUEST("CREATE DATE"))=-1 D ERRLOG^SDESJSON(.ERRORS,49) Q 0
Q 1
;
VALIDATEREQTYPE(ERRORS,REQTYPE) ;
I REQTYPE="" D ERRLOG^SDESJSON(.ERRORS,60) Q 0
I REQTYPE'="",REQTYPE'="APPT",REQTYPE'="MOBILE",REQTYPE'="RTC",REQTYPE'="VETERAN",REQTYPE'="W2VA" D ERRLOG^SDESJSON(.ERRORS,61) Q 0
Q 1
;
STATIONTOINST(ERRORS,STATIONNUM,INSTNAME) ;
N INSTITUTIONIEN
I STATIONNUM="",INSTNAME="" D ERRLOG^SDESJSON(.ERRORS,204) Q 0
I STATIONNUM="",INSTNAME'="" S INSTITUTIONIEN=$$FIND1^DIC(4,"","X",INSTNAME,"B") I 'INSTITUTIONIEN D ERRLOG^SDESJSON(.ERRORS,205) Q 0
I STATIONNUM'="" S INSTITUTIONIEN=$$FIND1^DIC(4,"","X",STATIONNUM,"D") I 'INSTITUTIONIEN D ERRLOG^SDESJSON(.ERRORS,197) Q 0
Q INSTITUTIONIEN
;
VALIDATECLINSTOP(ERRORS,CLINICIEN,STOP,SECSTOP) ;
N RESTYPE
S STOP=$G(STOP),SECSTOP=$G(SECSTOP),REQTYPE=$G(REQTYPE)
I CLINICIEN'="",'$D(^SC(CLINICIEN,0)) D ERRLOG^SDESJSON(.ERRORS,19) Q 0
;
I STOP=900 D ERRLOG^SDESJSON(.ERRORS,273) Q 0
I STOP'="" S STOP=$$FIND1^DIC(40.7,"","X",STOP,"C") I 'STOP D ERRLOG^SDESJSON(.ERRORS,270) Q 0
S RESTYPE=$$GET1^DIQ(40.7,STOP,5,"I")
I STOP'="",RESTYPE'="P",RESTYPE'="E" D ERRLOG^SDESJSON(.ERRORS,287) Q 0
;
I SECSTOP=900 D ERRLOG^SDESJSON(.ERRORS,273) Q 0
I SECSTOP'="" S SECSTOP=$$FIND1^DIC(40.7,"","X",SECSTOP,"C") I 'SECSTOP D ERRLOG^SDESJSON(.ERRORS,271) Q 0
S RESTYPE=$$GET1^DIQ(40.7,SECSTOP,5,"I")
I SECSTOP'="",RESTYPE'="S",RESTYPE'="E" D ERRLOG^SDESJSON(.ERRORS,288) Q 0
;
I SECSTOP'="",STOP="" D ERRLOG^SDESJSON(.ERRORS,234) Q 0
I CLINICIEN="",STOP="" D ERRLOG^SDESJSON(.ERRORS,530) Q 0
I STOP'="",CLINICIEN'="" D ERRLOG^SDESJSON(.ERRORS,202) Q 0
I SECSTOP'="",CLINICIEN'="" D ERRLOG^SDESJSON(.ERRORS,202) Q 0
Q 1
;
VALIDATEREQBY(ERRORS,REQUESTEDBY) ;
I REQUESTEDBY="" D ERRLOG^SDESJSON(.ERRORS,62) Q 0
I REQUESTEDBY'="",REQUESTEDBY'="PATIENT",REQUESTEDBY'="PROVIDER" D ERRLOG^SDESJSON(.ERRORS,198)
S REQUEST("REQUESTED BY")=$S(REQUESTEDBY="PATIENT":2,REQUESTEDBY="PROVIDER":1,1:"")
I $D(ERRORS) Q 0
Q 1
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESCRTAPPREQVAL 2809 printed Dec 13, 2024@02:56:25 Page 2
SDESCRTAPPREQVAL ;ALB/JAS - Additional validation for SDESCREATEAPPREQ; FEB 07, 2024
+1 ;;5.3;Scheduling;**871**;Aug 13, 1993;Build 13
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
+6 ; RPC: SDES CREATE APPT REQ (Continued from SDESCREATEAPPREQ)
+7 ;
VALIDATEDFN(ERRORS,DFN) ;
+1 IF DFN=""
DO ERRLOG^SDESJSON(.ERRORS,1)
QUIT 0
+2 IF DFN'=""
IF '$DATA(^DPT(DFN,0))
DO ERRLOG^SDESJSON(.ERRORS,2)
QUIT 0
+3 QUIT 1
+4 ;
VALIDATEDATETIME(ERRORS,REQUEST) ;
+1 IF $GET(REQUEST("CREATE DATE"))=""
Begin DoDot:1
+2 SET REQUEST("CREATE DATE")=DT
+3 NEW NOWDT
SET NOWDT=$$FMTISO^SDAMUTDT($$NOW^XLFDT)
if NOWDT=-1
QUIT
+4 SET REQUEST("CREATE DATE")=$PIECE($$ISOTFM^SDAMUTDT(NOWDT,$GET(REQUEST("CLINIC IEN"))),".")
End DoDot:1
QUIT 1
+5 IF $GET(REQUEST("CREATE DATE"))'=""
SET REQUEST("CREATE DATE")=$$ISOTFM^SDAMUTDT($GET(REQUEST("CREATE DATE")))
+6 IF $GET(REQUEST("CREATE DATE"))=-1
DO ERRLOG^SDESJSON(.ERRORS,49)
QUIT 0
+7 QUIT 1
+8 ;
VALIDATEREQTYPE(ERRORS,REQTYPE) ;
+1 IF REQTYPE=""
DO ERRLOG^SDESJSON(.ERRORS,60)
QUIT 0
+2 IF REQTYPE'=""
IF REQTYPE'="APPT"
IF REQTYPE'="MOBILE"
IF REQTYPE'="RTC"
IF REQTYPE'="VETERAN"
IF REQTYPE'="W2VA"
DO ERRLOG^SDESJSON(.ERRORS,61)
QUIT 0
+3 QUIT 1
+4 ;
STATIONTOINST(ERRORS,STATIONNUM,INSTNAME) ;
+1 NEW INSTITUTIONIEN
+2 IF STATIONNUM=""
IF INSTNAME=""
DO ERRLOG^SDESJSON(.ERRORS,204)
QUIT 0
+3 IF STATIONNUM=""
IF INSTNAME'=""
SET INSTITUTIONIEN=$$FIND1^DIC(4,"","X",INSTNAME,"B")
IF 'INSTITUTIONIEN
DO ERRLOG^SDESJSON(.ERRORS,205)
QUIT 0
+4 IF STATIONNUM'=""
SET INSTITUTIONIEN=$$FIND1^DIC(4,"","X",STATIONNUM,"D")
IF 'INSTITUTIONIEN
DO ERRLOG^SDESJSON(.ERRORS,197)
QUIT 0
+5 QUIT INSTITUTIONIEN
+6 ;
VALIDATECLINSTOP(ERRORS,CLINICIEN,STOP,SECSTOP) ;
+1 NEW RESTYPE
+2 SET STOP=$GET(STOP)
SET SECSTOP=$GET(SECSTOP)
SET REQTYPE=$GET(REQTYPE)
+3 IF CLINICIEN'=""
IF '$DATA(^SC(CLINICIEN,0))
DO ERRLOG^SDESJSON(.ERRORS,19)
QUIT 0
+4 ;
+5 IF STOP=900
DO ERRLOG^SDESJSON(.ERRORS,273)
QUIT 0
+6 IF STOP'=""
SET STOP=$$FIND1^DIC(40.7,"","X",STOP,"C")
IF 'STOP
DO ERRLOG^SDESJSON(.ERRORS,270)
QUIT 0
+7 SET RESTYPE=$$GET1^DIQ(40.7,STOP,5,"I")
+8 IF STOP'=""
IF RESTYPE'="P"
IF RESTYPE'="E"
DO ERRLOG^SDESJSON(.ERRORS,287)
QUIT 0
+9 ;
+10 IF SECSTOP=900
DO ERRLOG^SDESJSON(.ERRORS,273)
QUIT 0
+11 IF SECSTOP'=""
SET SECSTOP=$$FIND1^DIC(40.7,"","X",SECSTOP,"C")
IF 'SECSTOP
DO ERRLOG^SDESJSON(.ERRORS,271)
QUIT 0
+12 SET RESTYPE=$$GET1^DIQ(40.7,SECSTOP,5,"I")
+13 IF SECSTOP'=""
IF RESTYPE'="S"
IF RESTYPE'="E"
DO ERRLOG^SDESJSON(.ERRORS,288)
QUIT 0
+14 ;
+15 IF SECSTOP'=""
IF STOP=""
DO ERRLOG^SDESJSON(.ERRORS,234)
QUIT 0
+16 IF CLINICIEN=""
IF STOP=""
DO ERRLOG^SDESJSON(.ERRORS,530)
QUIT 0
+17 IF STOP'=""
IF CLINICIEN'=""
DO ERRLOG^SDESJSON(.ERRORS,202)
QUIT 0
+18 IF SECSTOP'=""
IF CLINICIEN'=""
DO ERRLOG^SDESJSON(.ERRORS,202)
QUIT 0
+19 QUIT 1
+20 ;
VALIDATEREQBY(ERRORS,REQUESTEDBY) ;
+1 IF REQUESTEDBY=""
DO ERRLOG^SDESJSON(.ERRORS,62)
QUIT 0
+2 IF REQUESTEDBY'=""
IF REQUESTEDBY'="PATIENT"
IF REQUESTEDBY'="PROVIDER"
DO ERRLOG^SDESJSON(.ERRORS,198)
+3 SET REQUEST("REQUESTED BY")=$SELECT(REQUESTEDBY="PATIENT":2,REQUESTEDBY="PROVIDER":1,1:"")
+4 IF $DATA(ERRORS)
QUIT 0
+5 QUIT 1