SDESUPDRECREQ2 ;ALB/LAB,KML,MGD,RRM,ANU,BWF - VISTA SCHEDULING CREATE EDIT RECALL REQ RPC ;March 06, 2023
;;5.3;Scheduling;**823,842,861,864**;Aug 13, 1993;Build 15
;;Per VHA Directive 6402, this routine should not be modified
;
; Documented API's and Integration Agreements
; --------------------------------------------
; Reference to $$LKUP^XPDKEY is supported by IA #1367
; Reference to OWNSKEY^XUSRB is supported by IA #3277
;
;INPUT:
; RECALLIEN - sent for UPDATE of RECALL REQUEST only(Required for Update) IEN pointer to RECALL REMINDERS
; DFN - (required) DFN Pointer to PATIENT file
; ACCNO - (optional) Accession # (free-text 1-25 characters)
; SDCMT - (optional) COMMENT (free-text 1-80 characters)
; FASTING - (required) FAST/NON-FASTING valid values: FASTING,NON-FASTING,NONE
; APPTP - (required) Test/App pointer or name (.01) to RECALL REMINDERS APPT TYPE file 403.51
; RRPROVIEN - (required) Provider - Pointer to RECALL REMINDERS PROVIDERS file 403.54
; CLINIEN - (required) Clinic pointer to HOSPITAL LOCATION file
; APPTLEN - (optional) Length of Appointment numeric between 10 and 120
; DATE - (required) Recall Date in ISO8601 format (no time). e.g., CCYY-MM-DD
; RECPPDT - (optional) Recall Date (Per patient) in ISO8601 format (no time) e.g., CCYY-MM-DD
; DAPTDT - (optional) Date Reminder Sent in ISO8601 format (no time) e.g., CCYY-MM-DD
; USERIEN - (optional) User Who Entered Recall pointer to NEW PERSON file; default to current user
; SECPDT - (optional) Second Print Date in ISO8601 format (no time) e.g., CCYY-MM-DD
; SDENTDT - (optional) Date recall entered in ISO8601 format e.g., CCYY-MM-DD)
; EAS - (optional) EAS Tracking Number
;
;RETURN:
; Successful Return:
; RETURNJSON = Returns the REQUEST RECALL IEN in JSON formatted string.
; Otherwise, JSON Errors will be returned for any invalid/missing parameters.
;
; 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.
;
; copy of SDESUPDRECREQ
Q
;
CREATERECREQ(RETN,DFN,ACCNO,SDCMT,FASTING,APPTP,RRPROVIEN,CLINIEN,APPTLEN,DATE,RECPPDT,DAPTDT,USERIEN,SECPDT,SDENTDT,EAS) ;CREATE recall request
N ERRORS,SDRECREQ,RECALLIEN,SDCREATE,SDFDA,SDMSG,SDIEN
S RECALLIEN="+1",SDCREATE=1
D VALIDATE(.ERRORS,SDCREATE)
I $O(ERRORS("Error",""))'="" D RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDCREATE) Q
D BLDREC
D UPDATE^DIE("","SDFDA","SDIEN","SDMSG")
I $D(SDMSG) D ERRLOG^SDESJSON(.ERRORS,134),RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDCREATE) Q
S SDRECREQ("RecallReqCreate","IEN")=SDIEN(1)
D BUILDJSON^SDESBUILDJSON(.RETN,.SDRECREQ)
Q
;
UPDRECALLREQ(RETN,RECALLIEN,DFN,ACCNO,SDCMT,FASTING,APPTP,RRPROVIEN,CLINIEN,APPTLEN,DATE,RECPPDT,DAPTDT,USERIEN,SECPDT,EAS) ;update recall request
N ERRORS,SDRECREQ,SDFDA,SDMSG,SDIEN
S SDCREATE=0
D VALIDATE(.ERRORS,SDCREATE)
I $O(ERRORS("Error",""))'="" D RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDCREATE) Q
D BLDREC
D FILE^DIE(,"SDFDA","SDMSG")
I $D(SDMSG) D ERRLOG^SDESJSON(.ERRORS,134),RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDCREATE) Q
S SDRECREQ("RecallReqEdit","IEN")=RECALLIEN
D BUILDJSON^SDESBUILDJSON(.RETN,.SDRECREQ)
Q
;
BLDREC ;build and file record
S SDFDA=$NA(SDFDA(403.5,RECALLIEN_",")) ;recall
S SDFDA(403.5,RECALLIEN_",",.01)=DFN
S:$G(ACCNO)'="" SDFDA(403.5,RECALLIEN_",",2)=$E(ACCNO,1,25)
S:SDCMT'="" SDFDA(403.5,RECALLIEN_",",2.5)=$E(SDCMT,1,80)
S SDFDA(403.5,RECALLIEN_",",2.6)=FASTING
S SDFDA(403.5,RECALLIEN_",",3)=APPTP
S SDFDA(403.5,RECALLIEN_",",4)=RRPROVIEN
S SDFDA(403.5,RECALLIEN_",",4.5)=CLINIEN
S:APPTLEN'="" SDFDA(403.5,RECALLIEN_",",4.7)=APPTLEN
S SDFDA(403.5,RECALLIEN_",",5)=DATE
S:RECPPDT'="" SDFDA(403.5,RECALLIEN_",",5.5)=RECPPDT
S:DAPTDT'="" SDFDA(403.5,RECALLIEN_",",6)=DAPTDT
S SDFDA(403.5,RECALLIEN_",",7)=USERIEN
S:SDCREATE SDFDA(403.5,RECALLIEN_",",7.5)=SDENTDT ;only add if creating new record, cannot edit
S:SECPDT'="" SDFDA(403.5,RECALLIEN_",",8)=SECPDT
S:EAS'="" SDFDA(403.5,RECALLIEN_",",100)=EAS
Q
;
VALIDATE(ERRORS,SDCREATE) ;
D INITINPUTPAR(SDCREATE) ;initialize input parameter
S RECALLIEN=$$VALIDATERECALIEN(.ERRORS,RECALLIEN)
S DFN=$$VALIDATEDFN(.ERRORS,DFN)
S FASTING=$$VALIDATEFASTING(.ERRORS,FASTING)
S APPTP=$$VALIDATEAPPTP(.ERRORS,APPTP)
S RRPROVIEN=$$VALIDATERRPRVIEN(.ERRORS,RRPROVIEN)
S CLINIEN=$$VALIDATECLINIEN(.ERRORS,CLINIEN)
S DATE=$$VALIDATERECALLDT(.ERRORS,DATE)
I $G(SDCREATE) S SDENTDT=$$VALIDATERCDTNTRD(.ERRORS,SDCREATE,SDENTDT)
S APPTLEN=$$VALIDATEAPPTLEN(.ERRORS,APPTLEN)
S RECPPDT=$$VALIDATERECPPDT(.ERRORS,RECPPDT)
S DAPTDT=$$VALIDATEDAPTDT(.ERRORS,DAPTDT)
S USERIEN=$$VALIDATEUSERIEN(.ERRORS,USERIEN)
S SECPDT=$$VALIDATESECPDT(.ERRORS,SECPDT)
S SDCMT=$$VALIDATESDCMT(.ERRORS,SDCMT)
S EAS=$$VALIDATEEAS(.ERRORS,EAS)
Q
;
INITINPUTPAR(SDCREATE) ;Initialized Input Paramaters
S:SDCREATE<1 RECALLIEN=$G(RECALLIEN)
S DFN=$G(DFN)
S ACCNO=$G(ACCNO)
S SDCMT=$G(SDCMT)
S FASTING=$G(FASTING)
S APPTP=$G(APPTP)
S RRPROVIEN=$G(RRPROVIEN)
S CLINIEN=$G(CLINIEN)
S APPTLEN=$G(APPTLEN)
S DATE=$G(DATE)
S RECPPDT=$G(RECPPDT)
S DAPTDT=$G(DAPTDT)
S USERIEN=$G(USERIEN)
S SECPDT=$G(SECPDT)
S SDENTDT=$G(SDENTDT)
S EAS=$G(EAS)
Q
;
VALIDATERECALIEN(ERRORS,RECALLIEN) ;Validate Recall IEN
I $G(RECALLIEN)="" D ERRLOG^SDESJSON(.ERRORS,16) Q RECALLIEN
I (RECALLIEN'="+1")&('$D(^SD(403.5,$G(RECALLIEN)))) D ERRLOG^SDESJSON(.ERRORS,17) Q RECALLIEN
;check that user has the correct security key
I $$KEY(RECALLIEN)>0 D ERRLOG^SDESJSON(.ERRORS,135)
Q RECALLIEN
;
VALIDATEDFN(ERRORS,DFN) ;Validate Patient DFN
I DFN="" D ERRLOG^SDESJSON(.ERRORS,1)
I DFN'="",'$D(^DPT(DFN,0)) D ERRLOG^SDESJSON(.ERRORS,2)
Q DFN
;
VALIDATEFASTING(ERRORS,FASTING) ;Validate Fasting
I FASTING="" D ERRLOG^SDESJSON(.ERRORS,141) Q FASTING
S FASTING=$S($$UP^XLFSTR(FASTING)="FASTING":"f",$$UP^XLFSTR(FASTING)="NON-FASTING":"n",$$UP^XLFSTR(FASTING)="F":"f",$$UP^XLFSTR(FASTING)="N":"n",FASTING="@":"@",1:138)
I FASTING=138 D ERRLOG^SDESJSON(.ERRORS,138)
Q FASTING
;
VALIDATEAPPTP(ERRORS,APPTP) ;Validate Appointment Type
I APPTP="" D ERRLOG^SDESJSON(.ERRORS,139) Q APPTP
I +APPTP,$D(^SD(403.51,APPTP,0)) Q APPTP
I +APPTP,'$D(^SD(403.51,APPTP,0)) D ERRLOG^SDESJSON(.ERRORS,132) Q APPTP
S APPTP=$O(^SD(403.51,"B",APPTP,""))
I APPTP="" D ERRLOG^SDESJSON(.ERRORS,132) Q APPTP
Q APPTP
;
VALIDATERRPRVIEN(ERRORS,RRPROVIEN) ;Validate Recall Provider IEN
I RRPROVIEN="" D ERRLOG^SDESJSON(.ERRORS,137) Q RRPROVIEN
I $G(RRPROVIEN)'="",'$D(^SD(403.54,RRPROVIEN)) D ERRLOG^SDESJSON(.ERRORS,131)
Q RRPROVIEN
;
VALIDATECLINIEN(ERRORS,CLINIEN) ;Validate Clinic IEN
I CLINIEN="" D ERRLOG^SDESJSON(.ERRORS,18) Q CLINIEN
I CLINIEN'="",'$D(^SC(CLINIEN)) D ERRLOG^SDESJSON(.ERRORS,19)
Q CLINIEN
;
VALIDATERECALLDT(ERRORS,RECALLDATE) ;Validate Recall Date
I RECALLDATE="" D ERRLOG^SDESJSON(.ERRORS,140) Q RECALLDATE
I RECALLDATE'="" S RECALLDATE=$$ISOTFM^SDAMUTDT(RECALLDATE)
I RECALLDATE=-1 D ERRLOG^SDESJSON(.ERRORS,133)
Q RECALLDATE
;
VALIDATERCDTNTRD(ERRORS,SDRCREATE,RECDTENTRD) ;Validate Recall Date Entered
I (SDRCREATE)&($G(RECDTENTRD)'="") S RECDTENTRD=$$ISOTFM^SDAMUTDT(RECDTENTRD)
I (RECDTENTRD=-1)!(RECDTENTRD="") S RECDTENTRD=DT ;
Q RECDTENTRD
;
VALIDATEAPPTLEN(ERRORS,LENGTHOFAPPT) ;Validate Length of Appointment
S LENGTHOFAPPT=$G(LENGTHOFAPPT,"") I LENGTHOFAPPT="" Q LENGTHOFAPPT
I '+LENGTHOFAPPT D ERRLOG^SDESJSON(.ERRORS,116) Q LENGTHOFAPPT
I LENGTHOFAPPT'="" S:((+LENGTHOFAPPT<10)!(+LENGTHOFAPPT>120)) LENGTHOFAPPT=""
Q LENGTHOFAPPT
;
VALIDATERECPPDT(ERRORS,RECPPTDT) ;Validate Recall Date Per Patient
S RECPPTDT=$G(RECPPTDT,"") S RECPPTDT=$$ISOTFM^SDAMUTDT(RECPPTDT)
I RECPPTDT=-1 S RECPPTDT="" ;VSE-2396
Q RECPPTDT
;
VALIDATEDAPTDT(ERRORS,DTRMSENT) ;Validate Date Reminder Sent
S DTRMSENT=$G(DTRMSENT,"")
S DTRMSENT=$$ISOTFM^SDAMUTDT(DTRMSENT)
I DTRMSENT=-1 S DTRMSENT="" ;VSE-2396
Q DTRMSENT
;
VALIDATEUSERIEN(ERRORS,USERIEN) ;Validate User IEN
S USERIEN=$G(USERIEN,"")
I USERIEN'?.N S USERIEN=DUZ Q USERIEN
I (USERIEN="")!('$D(^VA(200,+USERIEN))) S USERIEN=DUZ
Q USERIEN
;
VALIDATESECPDT(ERRORS,SECPRNTDT) ;Validate Second Print Date
S SECPRNTDT=$G(SECPRNTDT,"")
I SECPRNTDT'="" S SECPRNTDT=$$ISOTFM^SDAMUTDT(SECPDT)
I SECPRNTDT=-1 S SECPRNTDT="" ;VSE-2396
Q SECPRNTDT
;
VALIDATESDCMT(ERRORS,SDCMT) ;Validate Length of Appointment
S SDCMT=$G(SDCMT,"")
S SDCMT=$TR($G(SDCMT),"^"," ")
Q SDCMT
;
VALIDATEEAS(ERRORS,SDEAS) ;Validate SDEAS
S SDEAS=$G(SDEAS,"")
I $L(SDEAS) S SDEAS=$$EASVALIDATE^SDESUTIL(SDEAS)
I SDEAS=-1 D ERRLOG^SDESJSON(.ERRORS,142)
Q SDEAS
;
RETURNERROR(ERRORS,SDRECREQ,RETN,SDCREATE) ;
M SDRECREQ=ERRORS
D SETEMPTYOBJ(.SDRECREQ,SDCREATE)
D BUILDJSON^SDESBUILDJSON(.RETN,.SDRECREQ)
Q
;
SETEMPTYOBJ(SDRECREQ,SDCREATE) ;Set the object to NULL
I SDCREATE S SDRECREQ("RecallReqCreate","IEN")="" Q
S SDRECREQ("RecallReqEdit","IEN")=""
Q
;
KEY(RECALLIEN) ;check that user has the correct SECURITY KEY
;INPUT:
; RECALLIEN - Pointer to RECALL REMINDERS file 403.5
;RETURN
; 0=User has the correct SECURITY KEY
; 135=error number - user does not have correct security keys
N KEY,KY,RET,SDPRV,SDFLAG
S RET=135
S (SDPRV,KEY,SDFLAG)="" S SDPRV=$P($G(^SD(403.5,+RECALLIEN,0)),U,5) D
.I SDPRV="" S RET=0
.I SDPRV'="" S KEY=$P($G(^SD(403.54,SDPRV,0)),U,7) D
..I KEY="" S RET=0 Q
..N VALUE
..S VALUE=$$LKUP^XPDKEY(KEY) K KY D OWNSKEY^XUSRB(.KY,VALUE,DUZ)
..I $G(KY(0))'=0 S RET=0
Q RET
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESUPDRECREQ2 9766 printed Dec 13, 2024@02:57:51 Page 2
SDESUPDRECREQ2 ;ALB/LAB,KML,MGD,RRM,ANU,BWF - VISTA SCHEDULING CREATE EDIT RECALL REQ RPC ;March 06, 2023
+1 ;;5.3;Scheduling;**823,842,861,864**;Aug 13, 1993;Build 15
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Documented API's and Integration Agreements
+5 ; --------------------------------------------
+6 ; Reference to $$LKUP^XPDKEY is supported by IA #1367
+7 ; Reference to OWNSKEY^XUSRB is supported by IA #3277
+8 ;
+9 ;INPUT:
+10 ; RECALLIEN - sent for UPDATE of RECALL REQUEST only(Required for Update) IEN pointer to RECALL REMINDERS
+11 ; DFN - (required) DFN Pointer to PATIENT file
+12 ; ACCNO - (optional) Accession # (free-text 1-25 characters)
+13 ; SDCMT - (optional) COMMENT (free-text 1-80 characters)
+14 ; FASTING - (required) FAST/NON-FASTING valid values: FASTING,NON-FASTING,NONE
+15 ; APPTP - (required) Test/App pointer or name (.01) to RECALL REMINDERS APPT TYPE file 403.51
+16 ; RRPROVIEN - (required) Provider - Pointer to RECALL REMINDERS PROVIDERS file 403.54
+17 ; CLINIEN - (required) Clinic pointer to HOSPITAL LOCATION file
+18 ; APPTLEN - (optional) Length of Appointment numeric between 10 and 120
+19 ; DATE - (required) Recall Date in ISO8601 format (no time). e.g., CCYY-MM-DD
+20 ; RECPPDT - (optional) Recall Date (Per patient) in ISO8601 format (no time) e.g., CCYY-MM-DD
+21 ; DAPTDT - (optional) Date Reminder Sent in ISO8601 format (no time) e.g., CCYY-MM-DD
+22 ; USERIEN - (optional) User Who Entered Recall pointer to NEW PERSON file; default to current user
+23 ; SECPDT - (optional) Second Print Date in ISO8601 format (no time) e.g., CCYY-MM-DD
+24 ; SDENTDT - (optional) Date recall entered in ISO8601 format e.g., CCYY-MM-DD)
+25 ; EAS - (optional) EAS Tracking Number
+26 ;
+27 ;RETURN:
+28 ; Successful Return:
+29 ; RETURNJSON = Returns the REQUEST RECALL IEN in JSON formatted string.
+30 ; Otherwise, JSON Errors will be returned for any invalid/missing parameters.
+31 ;
+32 ; The parameter list for this RPC must be kept in sync.
+33 ; If you need to add or remove a parameter, ensure that the Remote Procedure File #8994 definition is also updated.
+34 ;
+35 ; copy of SDESUPDRECREQ
+36 QUIT
+37 ;
CREATERECREQ(RETN,DFN,ACCNO,SDCMT,FASTING,APPTP,RRPROVIEN,CLINIEN,APPTLEN,DATE,RECPPDT,DAPTDT,USERIEN,SECPDT,SDENTDT,EAS) ;CREATE recall request
+1 NEW ERRORS,SDRECREQ,RECALLIEN,SDCREATE,SDFDA,SDMSG,SDIEN
+2 SET RECALLIEN="+1"
SET SDCREATE=1
+3 DO VALIDATE(.ERRORS,SDCREATE)
+4 IF $ORDER(ERRORS("Error",""))'=""
DO RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDCREATE)
QUIT
+5 DO BLDREC
+6 DO UPDATE^DIE("","SDFDA","SDIEN","SDMSG")
+7 IF $DATA(SDMSG)
DO ERRLOG^SDESJSON(.ERRORS,134)
DO RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDCREATE)
QUIT
+8 SET SDRECREQ("RecallReqCreate","IEN")=SDIEN(1)
+9 DO BUILDJSON^SDESBUILDJSON(.RETN,.SDRECREQ)
+10 QUIT
+11 ;
UPDRECALLREQ(RETN,RECALLIEN,DFN,ACCNO,SDCMT,FASTING,APPTP,RRPROVIEN,CLINIEN,APPTLEN,DATE,RECPPDT,DAPTDT,USERIEN,SECPDT,EAS) ;update recall request
+1 NEW ERRORS,SDRECREQ,SDFDA,SDMSG,SDIEN
+2 SET SDCREATE=0
+3 DO VALIDATE(.ERRORS,SDCREATE)
+4 IF $ORDER(ERRORS("Error",""))'=""
DO RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDCREATE)
QUIT
+5 DO BLDREC
+6 DO FILE^DIE(,"SDFDA","SDMSG")
+7 IF $DATA(SDMSG)
DO ERRLOG^SDESJSON(.ERRORS,134)
DO RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDCREATE)
QUIT
+8 SET SDRECREQ("RecallReqEdit","IEN")=RECALLIEN
+9 DO BUILDJSON^SDESBUILDJSON(.RETN,.SDRECREQ)
+10 QUIT
+11 ;
BLDREC ;build and file record
+1 ;recall
SET SDFDA=$NAME(SDFDA(403.5,RECALLIEN_","))
+2 SET SDFDA(403.5,RECALLIEN_",",.01)=DFN
+3 if $GET(ACCNO)'=""
SET SDFDA(403.5,RECALLIEN_",",2)=$EXTRACT(ACCNO,1,25)
+4 if SDCMT'=""
SET SDFDA(403.5,RECALLIEN_",",2.5)=$EXTRACT(SDCMT,1,80)
+5 SET SDFDA(403.5,RECALLIEN_",",2.6)=FASTING
+6 SET SDFDA(403.5,RECALLIEN_",",3)=APPTP
+7 SET SDFDA(403.5,RECALLIEN_",",4)=RRPROVIEN
+8 SET SDFDA(403.5,RECALLIEN_",",4.5)=CLINIEN
+9 if APPTLEN'=""
SET SDFDA(403.5,RECALLIEN_",",4.7)=APPTLEN
+10 SET SDFDA(403.5,RECALLIEN_",",5)=DATE
+11 if RECPPDT'=""
SET SDFDA(403.5,RECALLIEN_",",5.5)=RECPPDT
+12 if DAPTDT'=""
SET SDFDA(403.5,RECALLIEN_",",6)=DAPTDT
+13 SET SDFDA(403.5,RECALLIEN_",",7)=USERIEN
+14 ;only add if creating new record, cannot edit
if SDCREATE
SET SDFDA(403.5,RECALLIEN_",",7.5)=SDENTDT
+15 if SECPDT'=""
SET SDFDA(403.5,RECALLIEN_",",8)=SECPDT
+16 if EAS'=""
SET SDFDA(403.5,RECALLIEN_",",100)=EAS
+17 QUIT
+18 ;
VALIDATE(ERRORS,SDCREATE) ;
+1 ;initialize input parameter
DO INITINPUTPAR(SDCREATE)
+2 SET RECALLIEN=$$VALIDATERECALIEN(.ERRORS,RECALLIEN)
+3 SET DFN=$$VALIDATEDFN(.ERRORS,DFN)
+4 SET FASTING=$$VALIDATEFASTING(.ERRORS,FASTING)
+5 SET APPTP=$$VALIDATEAPPTP(.ERRORS,APPTP)
+6 SET RRPROVIEN=$$VALIDATERRPRVIEN(.ERRORS,RRPROVIEN)
+7 SET CLINIEN=$$VALIDATECLINIEN(.ERRORS,CLINIEN)
+8 SET DATE=$$VALIDATERECALLDT(.ERRORS,DATE)
+9 IF $GET(SDCREATE)
SET SDENTDT=$$VALIDATERCDTNTRD(.ERRORS,SDCREATE,SDENTDT)
+10 SET APPTLEN=$$VALIDATEAPPTLEN(.ERRORS,APPTLEN)
+11 SET RECPPDT=$$VALIDATERECPPDT(.ERRORS,RECPPDT)
+12 SET DAPTDT=$$VALIDATEDAPTDT(.ERRORS,DAPTDT)
+13 SET USERIEN=$$VALIDATEUSERIEN(.ERRORS,USERIEN)
+14 SET SECPDT=$$VALIDATESECPDT(.ERRORS,SECPDT)
+15 SET SDCMT=$$VALIDATESDCMT(.ERRORS,SDCMT)
+16 SET EAS=$$VALIDATEEAS(.ERRORS,EAS)
+17 QUIT
+18 ;
INITINPUTPAR(SDCREATE) ;Initialized Input Paramaters
+1 if SDCREATE<1
SET RECALLIEN=$GET(RECALLIEN)
+2 SET DFN=$GET(DFN)
+3 SET ACCNO=$GET(ACCNO)
+4 SET SDCMT=$GET(SDCMT)
+5 SET FASTING=$GET(FASTING)
+6 SET APPTP=$GET(APPTP)
+7 SET RRPROVIEN=$GET(RRPROVIEN)
+8 SET CLINIEN=$GET(CLINIEN)
+9 SET APPTLEN=$GET(APPTLEN)
+10 SET DATE=$GET(DATE)
+11 SET RECPPDT=$GET(RECPPDT)
+12 SET DAPTDT=$GET(DAPTDT)
+13 SET USERIEN=$GET(USERIEN)
+14 SET SECPDT=$GET(SECPDT)
+15 SET SDENTDT=$GET(SDENTDT)
+16 SET EAS=$GET(EAS)
+17 QUIT
+18 ;
VALIDATERECALIEN(ERRORS,RECALLIEN) ;Validate Recall IEN
+1 IF $GET(RECALLIEN)=""
DO ERRLOG^SDESJSON(.ERRORS,16)
QUIT RECALLIEN
+2 IF (RECALLIEN'="+1")&('$DATA(^SD(403.5,$GET(RECALLIEN))))
DO ERRLOG^SDESJSON(.ERRORS,17)
QUIT RECALLIEN
+3 ;check that user has the correct security key
+4 IF $$KEY(RECALLIEN)>0
DO ERRLOG^SDESJSON(.ERRORS,135)
+5 QUIT RECALLIEN
+6 ;
VALIDATEDFN(ERRORS,DFN) ;Validate Patient DFN
+1 IF DFN=""
DO ERRLOG^SDESJSON(.ERRORS,1)
+2 IF DFN'=""
IF '$DATA(^DPT(DFN,0))
DO ERRLOG^SDESJSON(.ERRORS,2)
+3 QUIT DFN
+4 ;
VALIDATEFASTING(ERRORS,FASTING) ;Validate Fasting
+1 IF FASTING=""
DO ERRLOG^SDESJSON(.ERRORS,141)
QUIT FASTING
+2 SET FASTING=$SELECT($$UP^XLFSTR(FASTING)="FASTING":"f",$$UP^XLFSTR(FASTING)="NON-FASTING":"n",$$UP^XLFSTR(FASTING)="F":"f",$$UP^XLFSTR(FASTING)="N":"n",FASTING="@":"@",1:138)
+3 IF FASTING=138
DO ERRLOG^SDESJSON(.ERRORS,138)
+4 QUIT FASTING
+5 ;
VALIDATEAPPTP(ERRORS,APPTP) ;Validate Appointment Type
+1 IF APPTP=""
DO ERRLOG^SDESJSON(.ERRORS,139)
QUIT APPTP
+2 IF +APPTP
IF $DATA(^SD(403.51,APPTP,0))
QUIT APPTP
+3 IF +APPTP
IF '$DATA(^SD(403.51,APPTP,0))
DO ERRLOG^SDESJSON(.ERRORS,132)
QUIT APPTP
+4 SET APPTP=$ORDER(^SD(403.51,"B",APPTP,""))
+5 IF APPTP=""
DO ERRLOG^SDESJSON(.ERRORS,132)
QUIT APPTP
+6 QUIT APPTP
+7 ;
VALIDATERRPRVIEN(ERRORS,RRPROVIEN) ;Validate Recall Provider IEN
+1 IF RRPROVIEN=""
DO ERRLOG^SDESJSON(.ERRORS,137)
QUIT RRPROVIEN
+2 IF $GET(RRPROVIEN)'=""
IF '$DATA(^SD(403.54,RRPROVIEN))
DO ERRLOG^SDESJSON(.ERRORS,131)
+3 QUIT RRPROVIEN
+4 ;
VALIDATECLINIEN(ERRORS,CLINIEN) ;Validate Clinic IEN
+1 IF CLINIEN=""
DO ERRLOG^SDESJSON(.ERRORS,18)
QUIT CLINIEN
+2 IF CLINIEN'=""
IF '$DATA(^SC(CLINIEN))
DO ERRLOG^SDESJSON(.ERRORS,19)
+3 QUIT CLINIEN
+4 ;
VALIDATERECALLDT(ERRORS,RECALLDATE) ;Validate Recall Date
+1 IF RECALLDATE=""
DO ERRLOG^SDESJSON(.ERRORS,140)
QUIT RECALLDATE
+2 IF RECALLDATE'=""
SET RECALLDATE=$$ISOTFM^SDAMUTDT(RECALLDATE)
+3 IF RECALLDATE=-1
DO ERRLOG^SDESJSON(.ERRORS,133)
+4 QUIT RECALLDATE
+5 ;
VALIDATERCDTNTRD(ERRORS,SDRCREATE,RECDTENTRD) ;Validate Recall Date Entered
+1 IF (SDRCREATE)&($GET(RECDTENTRD)'="")
SET RECDTENTRD=$$ISOTFM^SDAMUTDT(RECDTENTRD)
+2 ;
IF (RECDTENTRD=-1)!(RECDTENTRD="")
SET RECDTENTRD=DT
+3 QUIT RECDTENTRD
+4 ;
VALIDATEAPPTLEN(ERRORS,LENGTHOFAPPT) ;Validate Length of Appointment
+1 SET LENGTHOFAPPT=$GET(LENGTHOFAPPT,"")
IF LENGTHOFAPPT=""
QUIT LENGTHOFAPPT
+2 IF '+LENGTHOFAPPT
DO ERRLOG^SDESJSON(.ERRORS,116)
QUIT LENGTHOFAPPT
+3 IF LENGTHOFAPPT'=""
if ((+LENGTHOFAPPT<10)!(+LENGTHOFAPPT>120))
SET LENGTHOFAPPT=""
+4 QUIT LENGTHOFAPPT
+5 ;
VALIDATERECPPDT(ERRORS,RECPPTDT) ;Validate Recall Date Per Patient
+1 SET RECPPTDT=$GET(RECPPTDT,"")
SET RECPPTDT=$$ISOTFM^SDAMUTDT(RECPPTDT)
+2 ;VSE-2396
IF RECPPTDT=-1
SET RECPPTDT=""
+3 QUIT RECPPTDT
+4 ;
VALIDATEDAPTDT(ERRORS,DTRMSENT) ;Validate Date Reminder Sent
+1 SET DTRMSENT=$GET(DTRMSENT,"")
+2 SET DTRMSENT=$$ISOTFM^SDAMUTDT(DTRMSENT)
+3 ;VSE-2396
IF DTRMSENT=-1
SET DTRMSENT=""
+4 QUIT DTRMSENT
+5 ;
VALIDATEUSERIEN(ERRORS,USERIEN) ;Validate User IEN
+1 SET USERIEN=$GET(USERIEN,"")
+2 IF USERIEN'?.N
SET USERIEN=DUZ
QUIT USERIEN
+3 IF (USERIEN="")!('$DATA(^VA(200,+USERIEN)))
SET USERIEN=DUZ
+4 QUIT USERIEN
+5 ;
VALIDATESECPDT(ERRORS,SECPRNTDT) ;Validate Second Print Date
+1 SET SECPRNTDT=$GET(SECPRNTDT,"")
+2 IF SECPRNTDT'=""
SET SECPRNTDT=$$ISOTFM^SDAMUTDT(SECPDT)
+3 ;VSE-2396
IF SECPRNTDT=-1
SET SECPRNTDT=""
+4 QUIT SECPRNTDT
+5 ;
VALIDATESDCMT(ERRORS,SDCMT) ;Validate Length of Appointment
+1 SET SDCMT=$GET(SDCMT,"")
+2 SET SDCMT=$TRANSLATE($GET(SDCMT),"^"," ")
+3 QUIT SDCMT
+4 ;
VALIDATEEAS(ERRORS,SDEAS) ;Validate SDEAS
+1 SET SDEAS=$GET(SDEAS,"")
+2 IF $LENGTH(SDEAS)
SET SDEAS=$$EASVALIDATE^SDESUTIL(SDEAS)
+3 IF SDEAS=-1
DO ERRLOG^SDESJSON(.ERRORS,142)
+4 QUIT SDEAS
+5 ;
RETURNERROR(ERRORS,SDRECREQ,RETN,SDCREATE) ;
+1 MERGE SDRECREQ=ERRORS
+2 DO SETEMPTYOBJ(.SDRECREQ,SDCREATE)
+3 DO BUILDJSON^SDESBUILDJSON(.RETN,.SDRECREQ)
+4 QUIT
+5 ;
SETEMPTYOBJ(SDRECREQ,SDCREATE) ;Set the object to NULL
+1 IF SDCREATE
SET SDRECREQ("RecallReqCreate","IEN")=""
QUIT
+2 SET SDRECREQ("RecallReqEdit","IEN")=""
+3 QUIT
+4 ;
KEY(RECALLIEN) ;check that user has the correct SECURITY KEY
+1 ;INPUT:
+2 ; RECALLIEN - Pointer to RECALL REMINDERS file 403.5
+3 ;RETURN
+4 ; 0=User has the correct SECURITY KEY
+5 ; 135=error number - user does not have correct security keys
+6 NEW KEY,KY,RET,SDPRV,SDFLAG
+7 SET RET=135
+8 SET (SDPRV,KEY,SDFLAG)=""
SET SDPRV=$PIECE($GET(^SD(403.5,+RECALLIEN,0)),U,5)
Begin DoDot:1
+9 IF SDPRV=""
SET RET=0
+10 IF SDPRV'=""
SET KEY=$PIECE($GET(^SD(403.54,SDPRV,0)),U,7)
Begin DoDot:2
+11 IF KEY=""
SET RET=0
QUIT
+12 NEW VALUE
+13 SET VALUE=$$LKUP^XPDKEY(KEY)
KILL KY
DO OWNSKEY^XUSRB(.KY,VALUE,DUZ)
+14 IF $GET(KY(0))'=0
SET RET=0
End DoDot:2
End DoDot:1
+15 QUIT RET
+16 ;