SDES2VALISODTTM ;ALB/BWF - SDES2 VALIDATE ISO DATE/TIMES ;JUL 28, 2023
;;5.3;Scheduling;**853,866**;Aug 13, 1993;Build 22
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
; extrinsic function to validate a date using specific error codes from 409.93
; returns Fileman date if valid or "" if invalid
; DATE - Date/time in ISO Format (required)
; CLINIC - clinic IEN to apply clinic timezone offset (optional)
; REQUIRED - 1 for required - This tells the validator if this field should be required (optional - defaults to not required)
; MISSINGERRORID - The custom error ID for a "Missing" date. If not passed, will default to '45 - Missing date' (optional)
; INVALIDERRORID - The custom error ID for an "Invalid" date. If not passed, will default to '46 - Invalid date' (optional)
; DELERRID - Deletion error ID, when process is trying to delete a required field with '@'
; MISSERRTEXT - Error text to add to the returned 'MISSING' error
; INVALERRTEXT - Error text to add to the returned 'INVALID' error
; DELERRTEXT - Error text to add to the returned 'DELETE' error
;
VALISODTTM(ERRORS,DATETIME,CLINIC,REQUIRED,MISSINGERRID,INVALIDERRID,DELERRID,MISSERRTEXT,INVALERRTEXT,DELERRTEXT) ;
N FMSDATE,MISSINGID,INVALIDID
S MISSINGID=$S($G(MISSINGERRID):MISSINGERRID,$P($G(DATETIME),"T",2)'="":496,1:45)
S INVALIDID=$S($G(INVALIDERRID):INVALIDERRID,$P($G(DATETIME),"T",2)'="":497,1:46)
I '$G(REQUIRED),$G(DATETIME)="" Q ""
I $G(REQUIRED),$G(DATETIME)="" D ERRLOG^SDES2JSON(.ERRORS,MISSINGID,$G(MISSERRTEXT)) Q ""
I $G(REQUIRED),$G(DATETIME)="@" D Q ""
.I $G(DELERRID) D ERRLOG^SDES2JSON(.ERRORS,DELERRID,$G(DELERRTEXT)) Q
.D ERRLOG^SDES2JSON(.ERRORS,229,$G(DELERRTEXT))
S FMSDATE=$$ISOTFM^SDAMUTDT($G(DATETIME),$G(CLINIC))
I FMSDATE<1 D ERRLOG^SDES2JSON(.ERRORS,INVALIDID,$G(INVALERRTEXT)) Q ""
Q FMSDATE
;
; extrinsic function to validate a date/time range
; STARTDTTM (REQUIRED) - Start date or date/time in ISO format
; ENDDTTM (REQUIRED) - End date or date/time in ISO format
; REQUIRED (OPTIONAL) - 1 if the date range is required,
; if required start date/time and end date/time must be passed in or an error will be returned
; CLINIC (OPTIONAL) - Clinic IEN to apply clinic timezone offset
;
VALISODATERANGE(ERRORS,STARTDTTM,ENDDTTM,REQUIRED,CLINIC) ;
N FMSDATE,MISSINGID,INVALIDID,FMSTART,FMEND,ERRORFLAG
I '$G(REQUIRED),('$L($G(STARTDTTM))!('$L($G(ENDDTTM)))) Q ""
I $G(REQUIRED),'$L($G(STARTDTTM)) S ERRORFLAG=1 D ERRLOG^SDES2JSON(.ERRORS,498)
I $G(REQUIRED),'$L($G(ENDDTTM)) S ERRORFLAG=1 D ERRLOG^SDES2JSON(.ERRORS,501)
I $G(ERRORFLAG) Q ""
S FMSTART=$$ISOTFM^SDAMUTDT(STARTDTTM,$G(CLINIC))
I FMSTART<1 S ERRORFLAG=1 D ERRLOG^SDES2JSON(.ERRORS,499)
S FMEND=$$ISOTFM^SDAMUTDT(ENDDTTM,$G(CLINIC))
I FMEND<1 S ERRORFLAG=1 D ERRLOG^SDES2JSON(.ERRORS,502)
I $G(ERRORFLAG) Q ""
I FMEND<FMSTART D ERRLOG^SDES2JSON(.ERRORS,503) Q ""
Q FMSTART_U_FMEND
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2VALISODTTM 2998 printed Dec 13, 2024@02:54:55 Page 2
SDES2VALISODTTM ;ALB/BWF - SDES2 VALIDATE ISO DATE/TIMES ;JUL 28, 2023
+1 ;;5.3;Scheduling;**853,866**;Aug 13, 1993;Build 22
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
+6 ; extrinsic function to validate a date using specific error codes from 409.93
+7 ; returns Fileman date if valid or "" if invalid
+8 ; DATE - Date/time in ISO Format (required)
+9 ; CLINIC - clinic IEN to apply clinic timezone offset (optional)
+10 ; REQUIRED - 1 for required - This tells the validator if this field should be required (optional - defaults to not required)
+11 ; MISSINGERRORID - The custom error ID for a "Missing" date. If not passed, will default to '45 - Missing date' (optional)
+12 ; INVALIDERRORID - The custom error ID for an "Invalid" date. If not passed, will default to '46 - Invalid date' (optional)
+13 ; DELERRID - Deletion error ID, when process is trying to delete a required field with '@'
+14 ; MISSERRTEXT - Error text to add to the returned 'MISSING' error
+15 ; INVALERRTEXT - Error text to add to the returned 'INVALID' error
+16 ; DELERRTEXT - Error text to add to the returned 'DELETE' error
+17 ;
VALISODTTM(ERRORS,DATETIME,CLINIC,REQUIRED,MISSINGERRID,INVALIDERRID,DELERRID,MISSERRTEXT,INVALERRTEXT,DELERRTEXT) ;
+1 NEW FMSDATE,MISSINGID,INVALIDID
+2 SET MISSINGID=$SELECT($GET(MISSINGERRID):MISSINGERRID,$PIECE($GET(DATETIME),"T",2)'="":496,1:45)
+3 SET INVALIDID=$SELECT($GET(INVALIDERRID):INVALIDERRID,$PIECE($GET(DATETIME),"T",2)'="":497,1:46)
+4 IF '$GET(REQUIRED)
IF $GET(DATETIME)=""
QUIT ""
+5 IF $GET(REQUIRED)
IF $GET(DATETIME)=""
DO ERRLOG^SDES2JSON(.ERRORS,MISSINGID,$GET(MISSERRTEXT))
QUIT ""
+6 IF $GET(REQUIRED)
IF $GET(DATETIME)="@"
Begin DoDot:1
+7 IF $GET(DELERRID)
DO ERRLOG^SDES2JSON(.ERRORS,DELERRID,$GET(DELERRTEXT))
QUIT
+8 DO ERRLOG^SDES2JSON(.ERRORS,229,$GET(DELERRTEXT))
End DoDot:1
QUIT ""
+9 SET FMSDATE=$$ISOTFM^SDAMUTDT($GET(DATETIME),$GET(CLINIC))
+10 IF FMSDATE<1
DO ERRLOG^SDES2JSON(.ERRORS,INVALIDID,$GET(INVALERRTEXT))
QUIT ""
+11 QUIT FMSDATE
+12 ;
+13 ; extrinsic function to validate a date/time range
+14 ; STARTDTTM (REQUIRED) - Start date or date/time in ISO format
+15 ; ENDDTTM (REQUIRED) - End date or date/time in ISO format
+16 ; REQUIRED (OPTIONAL) - 1 if the date range is required,
+17 ; if required start date/time and end date/time must be passed in or an error will be returned
+18 ; CLINIC (OPTIONAL) - Clinic IEN to apply clinic timezone offset
+19 ;
VALISODATERANGE(ERRORS,STARTDTTM,ENDDTTM,REQUIRED,CLINIC) ;
+1 NEW FMSDATE,MISSINGID,INVALIDID,FMSTART,FMEND,ERRORFLAG
+2 IF '$GET(REQUIRED)
IF ('$LENGTH($GET(STARTDTTM))!('$LENGTH($GET(ENDDTTM))))
QUIT ""
+3 IF $GET(REQUIRED)
IF '$LENGTH($GET(STARTDTTM))
SET ERRORFLAG=1
DO ERRLOG^SDES2JSON(.ERRORS,498)
+4 IF $GET(REQUIRED)
IF '$LENGTH($GET(ENDDTTM))
SET ERRORFLAG=1
DO ERRLOG^SDES2JSON(.ERRORS,501)
+5 IF $GET(ERRORFLAG)
QUIT ""
+6 SET FMSTART=$$ISOTFM^SDAMUTDT(STARTDTTM,$GET(CLINIC))
+7 IF FMSTART<1
SET ERRORFLAG=1
DO ERRLOG^SDES2JSON(.ERRORS,499)
+8 SET FMEND=$$ISOTFM^SDAMUTDT(ENDDTTM,$GET(CLINIC))
+9 IF FMEND<1
SET ERRORFLAG=1
DO ERRLOG^SDES2JSON(.ERRORS,502)
+10 IF $GET(ERRORFLAG)
QUIT ""
+11 IF FMEND<FMSTART
DO ERRLOG^SDES2JSON(.ERRORS,503)
QUIT ""
+12 QUIT FMSTART_U_FMEND