SDES2RECLLREQ ; ALB/TJB,TJB - VISTA SCHEDULING CREATE/UPDATE RECALL REQUESTS ; Jun 17, 2024
;;5.3;Scheduling;**866,881**;Aug 13, 1993;Build 10
;;Per VHA Directive 6402, this routine should not be modified
;
Q ;No Direct Call
;
; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
; SDCONTEXT("PATIENT DFN") = The DFN/IEN of the target patient from the calling application.
; SDCONTEXT("PATIENT ICN") = The ICN of the target patient from the calling application.
; SDCONTEXT("USER DUZ") = The DUZ of the user taking action in the calling application.
; SDCONTEXT("USER SECID") = The SECID of the user taking action in the calling application.
;
; SDES2 CREATE RECALL REQUEST:
; SDINPUT("DFN") = POINTER TO PATIENT (#2) FILE (required)
; SDINPUT("ACCESSION NUMBER") = ACCESSION # (FREE TEXT)
; SDINPUT("COMMENT"") = COMMENT (FREE TEXT)
; SDINPUT("FASTING") = Labs: FASTING ; NON-FASTING ; @ - None (required)
; SDINPUT(APPOINTMENT TYPE") = (required)
; Name of the RECALL REMINDERS APPT TYPE (#403.51) FILE
; 1 FOLLOW-UP F
; 4 OTHER O
; 3 SEMI-ANNUAL EXAM SA
; 2 YEARLY EXAM YEAR
; SDINPUT("RECALL PROVIDER IEN") = RECALL PROVIDER - POINTER TO RECALL REMINDERS PROVIDERS (#403.54) FILE (required)
; SDINPUT("CLINIC IEN") = CLINIC POINTER TO HOSPITAL LOCATION (#44) FILE (required)
; SDINPUT("APPOINTMENT LENGTH") = LENGTH OF APPOINTMENT NUMERIC BETWEEN 10 AND 240.
; SDINPUT("RECALL DATE") = Recall date in ISO8601 date format (no time). e.g., CCYY-MM-DD (required)
; SDINPUT(RECALL DATE PER PATIENT") = Recall date (per patient) in ISO8601 date format (no time). e.g., CCYY-MM-DD
; SDINPUT("DATE REMINDER SENT") = Date Reminder was sent in ISO8601 date format (no time). e.g., CCYY-MM-DD
; SDINPUT("SECOND PRINT DATE") = Second print date in ISO8601 date format (no time). e.g., CCYY-MM-DD
; SDINPUT("DATE ENTERED") = Date recall was added. Date is in ISO8601 format (e.g., CCYY-MM-DD)
;
CREATERECREQ(RETN,SDCONTEXT,SDINPUT) ;CREATE recall request
N ERRORS,SDRECREQ,SDFDA,SDMSG,SDIEN
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
I $D(ERRORS) S ERRORS("RecallReqCreate","IEN")="" D BUILDJSON^SDES2JSON(.RETN,.ERRORS) Q
S SDINPUT("RECALL IEN")="+1"
S SDINPUT("DATE ENTERED")=$$VALIDATERCDTNTRD(.ERRORS,$G(SDINPUT("DATE ENTERED")),SDINPUT("RECALL IEN"))
D VALIDATE(.ERRORS,.SDINPUT)
I $O(ERRORS("Error",""))'="" D RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDINPUT("RECALL IEN")) Q
D BLDREC(.SDFDA,.SDINPUT,.SDCONTEXT)
D UPDATE^DIE("","SDFDA","SDIEN","SDMSG")
I $D(SDMSG) D ERRLOG^SDES2JSON(.ERRORS,134),RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDINPUT("RECALL IEN")) Q
S SDRECREQ("RecallReqCreate","IEN")=SDIEN(1)
D BUILDJSON^SDES2JSON(.RETN,.SDRECREQ)
Q
;
; SDES2 EDIT RECALL REQUEST:
; SDINPUT("RECALL IEN") = IEN pointer to RECALL REMINDERS (#403.5) (required)
; SDINPUT("DFN") = POINTER TO PATIENT (#2) FILE (required)
; SDINPUT("ACCESSION NUMBER") = ACCESSION # (FREE TEXT)
; SDINPUT("COMMENT") = COMMENT (FREE TEXT)
; SDINPUT("FASTING") = Labs: FASTING ; NON-FASTING ; @ - None (required)
; SDINPUT("APPOINTMENT TYPE") = (required)
; Name of the RECALL REMINDERS APPT TYPE (#403.51) FILE
; 1 FOLLOW-UP F
; 4 OTHER O
; 3 SEMI-ANNUAL EXAM SA
; 2 YEARLY EXAM YEAR
; SDINPUT("RECALL PROVIDER IEN") = RECALL PROVIDER - POINTER TO RECALL REMINDERS PROVIDERS (#403.54) FILE (required)
; SDINPUT("CLINIC IEN") = CLINIC POINTER TO HOSPITAL LOCATION (#44) FILE (required)
; SDINPUT("APPOINTMENT LENGTH") = LENGTH OF APPOINTMENT NUMERIC BETWEEN 10 AND 240.
; SDINPUT("RECALL DATE") = Recall date in ISO8601 date format (no time). e.g., CCYY-MM-DD (required)
; SDINPUT("RECALL DATE PER PATIENT") = Recall date (per patient) in ISO8601 date format (no time). e.g., CCYY-MM-DD
; SDINPUT("DATE REMINDER SENT") = Date Reminder was sent in ISO8601 date format (no time). e.g., CCYY-MM-DD
; SDINPUT("SECOND PRINT DATE") = Second print date in ISO8601 date format (no time). e.g., CCYY-MM-DD
;
UPDRECALLREQ(RETN,SDCONTEXT,SDINPUT) ;RECALLIEN,DFN,ACCNO,SDCMT,FASTING,APPTP,RRPROVIEN,CLINIEN,APPTLEN,DATE,RECPPDT,DAPTDT,USERIEN,SECPDT,EAS) ;update recall request
N ERRORS,SDRECREQ,SDFDA,SDMSG,SDIEN
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
I $D(ERRORS) S ERRORS("RecallReqEdit","IEN")="" D BUILDJSON^SDES2JSON(.RETN,.ERRORS) Q
D VALIDATE(.ERRORS,.SDINPUT,.SDCONTEXT)
I $O(ERRORS("Error",""))'="" D RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDINPUT("RECALL IEN")) Q
D BLDREC(.SDFDA,.SDINPUT,.SDCONTEXT)
D FILE^DIE(,"SDFDA","SDMSG")
I $D(SDMSG) D ERRLOG^SDES2JSON(.ERRORS,134),RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDINPUT("RECALL IEN")) Q
S SDRECREQ("RecallReqEdit","IEN")=SDINPUT("RECALL IEN")
D BUILDJSON^SDES2JSON(.RETN,.SDRECREQ)
Q
;
BLDREC(SDFDA,SDINPUT,SDCONTEXT) ;build and file record
N RECALLIEN
S RECALLIEN=SDINPUT("RECALL IEN")
S SDFDA=$NA(SDFDA(403.5,RECALLIEN_",")) ;recall
S SDFDA(403.5,RECALLIEN_",",.01)=SDINPUT("DFN")
S:$G(SDINPUT("ACCESSION NUMBER"))'="" SDFDA(403.5,RECALLIEN_",",2)=$E(SDINPUT("ACCESSION NUMBER"),1,25)
S:$G(SDINPUT("COMMENT"))'="" SDFDA(403.5,RECALLIEN_",",2.5)=$E(SDINPUT("COMMENT"),1,80)
S SDFDA(403.5,RECALLIEN_",",2.6)=SDINPUT("FASTING")
S SDFDA(403.5,RECALLIEN_",",3)=SDINPUT("APPOINTMENT TYPE")
S SDFDA(403.5,RECALLIEN_",",4)=SDINPUT("RECALL PROVIDER IEN")
S SDFDA(403.5,RECALLIEN_",",4.5)=SDINPUT("CLINIC IEN")
S:SDINPUT("APPOINTMENT LENGTH")'="" SDFDA(403.5,RECALLIEN_",",4.7)=SDINPUT("APPOINTMENT LENGTH")
S SDFDA(403.5,RECALLIEN_",",5)=SDINPUT("RECALL DATE")
S:$G(SDINPUT("RECALL DATE PER PATIENT"))'="" SDFDA(403.5,RECALLIEN_",",5.5)=SDINPUT("RECALL DATE PER PATIENT")
S:$G(SDINPUT("DATE REMINDER SENT"))'="" SDFDA(403.5,RECALLIEN_",",6)=SDINPUT("DATE REMINDER SENT")
S SDFDA(403.5,RECALLIEN_",",7)=$S($G(SDCONTEXT("USER DUZ"))'="":SDCONTEXT("USER DUZ"),1:DUZ)
S:RECALLIEN="+1" SDFDA(403.5,RECALLIEN_",",7.5)=SDINPUT("DATE ENTERED") ;only add if creating new record, cannot edit
S:$G(SDINPUT("SECOND PRINT DATE"))'="" SDFDA(403.5,RECALLIEN_",",8)=SDINPUT("SECOND PRINT DATE")
S SDFDA(403.5,RECALLIEN_",",100)=$G(SDCONTEXT("ACHERON AUDIT ID"))
Q
;
; SDINPUT("RECALL IEN")
; SDINPUT("DFN")
; SDINPUT("ACCESSION NUMBER")
; SDINPUT("COMMENT")
; SDINPUT("FASTING")
; SDINPUT("APPOINTMENT TYPE")
; SDINPUT("RECALL PROVIDER IEN")
; SDINPUT("CLINIC IEN")
; SDINPUT("APPOINTMENT LENGTH")
; SDINPUT("RECALL DATE")
; SDINPUT("RECALL DATE PER PATIENT")
; SDINPUT("DATE REMINDER SENT")
; SDINPUT("SECOND PRINT DATE")
VALIDATE(ERRORS,SDINPUT,SDCONTEXT) ;
N OLDDFN
S OLDDFN=""
S SDINPUT("RECALL IEN")=$$VALIDATERECALIEN(.ERRORS,$G(SDINPUT("RECALL IEN")),$G(SDCONTEXT("USER DUZ")))
I '$D(ERRORS),SDINPUT("RECALL IEN")'="+1" S OLDDFN=$$GET1^DIQ(403.5,SDINPUT("RECALL IEN"),.01,"I")
S SDINPUT("DFN")=$$VALIDATEDFN(.ERRORS,$G(SDINPUT("DFN")),OLDDFN)
S SDINPUT("FASTING")=$$VALIDATEFASTING(.ERRORS,$G(SDINPUT("FASTING")))
S SDINPUT("APPOINTMENT TYPE")=$$VALIDATEAPPTP(.ERRORS,$G(SDINPUT("APPOINTMENT TYPE")))
S SDINPUT("RECALL PROVIDER IEN")=$$VALIDATERRPRVIEN(.ERRORS,$G(SDINPUT("RECALL PROVIDER IEN")))
S SDINPUT("CLINIC IEN")=$$VALIDATECLINIEN(.ERRORS,$G(SDINPUT("CLINIC IEN")))
S SDINPUT("RECALL DATE")=$$VALIDATERECALLDT(.ERRORS,$G(SDINPUT("RECALL DATE")))
S SDINPUT("APPOINTMENT LENGTH")=$$VALIDATEAPPTLEN(.ERRORS,$G(SDINPUT("APPOINTMENT LENGTH")))
S SDINPUT("RECALL DATE PER PATIENT")=$$VALIDATERECPPDT(.ERRORS,$G(SDINPUT("RECALL DATE PER PATIENT")))
S SDINPUT("DATE REMINDER SENT")=$$VALIDATEDAPTDT(.ERRORS,$G(SDINPUT("DATE REMINDER SENT")))
S SDINPUT("SECOND PRINT DATE")=$$VALIDATESECPDT(.ERRORS,$G(SDINPUT("SECOND PRINT DATE")))
S SDINPUT("COMMENT")=$$VALIDATESDCMT(.ERRORS,$G(SDINPUT("COMMENT")))
S SDINPUT("ACCESSION NUMBER")=$$VALIDATEACCNUM(.ERRORS,$G(SDINPUT("ACCESSION NUMBER")))
Q
;
VALIDATERECALIEN(ERRORS,RECALLIEN,USERDUZ) ;Validate Recall IEN
I $G(RECALLIEN)="" D ERRLOG^SDES2JSON(.ERRORS,16) Q RECALLIEN
I (RECALLIEN'="+1")&('$D(^SD(403.5,$G(RECALLIEN)))) D ERRLOG^SDES2JSON(.ERRORS,17) Q RECALLIEN
;check that user has the correct security key
I $$KEY(RECALLIEN,$G(USERDUZ))>0 D ERRLOG^SDES2JSON(.ERRORS,135)
Q RECALLIEN
;
VALIDATEDFN(ERRORS,DFN,OLDDFN) ;Validate Patient DFN
D VALPATDFN^SDES2VAL2(.ERRORS,$G(DFN),1)
I DFN'="",OLDDFN'="",DFN'=OLDDFN D ERRLOG^SDES2JSON(.ERRORS,2,"Patient ID on Recall doesn't match passed in Patient ID")
Q DFN
;
VALIDATEFASTING(ERRORS,FASTING) ;Validate Fasting
I FASTING="" D ERRLOG^SDES2JSON(.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^SDES2JSON(.ERRORS,138)
Q FASTING
;
VALIDATEAPPTP(ERRORS,APPTP) ;Validate Appointment Type
I APPTP="" D ERRLOG^SDES2JSON(.ERRORS,139) Q APPTP
I +APPTP,$D(^SD(403.51,APPTP,0)) Q APPTP
I +APPTP,'$D(^SD(403.51,APPTP,0)) D ERRLOG^SDES2JSON(.ERRORS,132) Q APPTP
S APPTP=$O(^SD(403.51,"B",APPTP,""))
I APPTP="" D ERRLOG^SDES2JSON(.ERRORS,139) Q APPTP
Q APPTP
;
VALIDATERRPRVIEN(ERRORS,RRPROVIEN) ;Validate Recall Provider IEN
I RRPROVIEN="" D ERRLOG^SDES2JSON(.ERRORS,137) Q RRPROVIEN
I $G(RRPROVIEN)'="",'$D(^SD(403.54,RRPROVIEN)) D ERRLOG^SDES2JSON(.ERRORS,131)
Q RRPROVIEN
;
VALIDATECLINIEN(ERRORS,CLINIEN) ;Validate Clinic IEN
I CLINIEN="" D ERRLOG^SDES2JSON(.ERRORS,18) Q CLINIEN
I CLINIEN'="",'$D(^SC(CLINIEN)) D ERRLOG^SDES2JSON(.ERRORS,19)
Q CLINIEN
;
VALIDATERECALLDT(ERRORS,RECALLDATE) ;Validate Recall Date
I RECALLDATE="" D ERRLOG^SDES2JSON(.ERRORS,140) Q RECALLDATE
I RECALLDATE'="" S RECALLDATE=$$ISOTFM^SDAMUTDT(RECALLDATE)
I RECALLDATE=-1 D ERRLOG^SDES2JSON(.ERRORS,133)
Q RECALLDATE
;
VALIDATERCDTNTRD(ERRORS,RECDTENTRD,RECALLIEN) ;Validate Recall Date Entered
I RECALLIEN'="+1" Q "" ; This is an IEN, so can't edit Recall Date Entered
I ($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^SDES2JSON(.ERRORS,116) Q LENGTHOFAPPT
I LENGTHOFAPPT'="" S:((+LENGTHOFAPPT<10)!(+LENGTHOFAPPT>240)) 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
;
VALIDATESECPDT(ERRORS,SECPRNTDT) ;Validate Second Print Date
S SECPRNTDT=$G(SECPRNTDT,"")
I SECPRNTDT'="" S SECPRNTDT=$$ISOTFM^SDAMUTDT(SECPRNTDT)
I SECPRNTDT=-1 S SECPRNTDT="" ;VSE-2396
Q SECPRNTDT
;
VALIDATESDCMT(ERRORS,SDCMT) ;Validate Comment
S SDCMT=$G(SDCMT,"")
S SDCMT=$TR($G(SDCMT),"^"," ")
Q SDCMT
;
VALIDATEACCNUM(ERRORS,SDACC) ;Validate ACCESSION NUMBER
S SDACC=$G(SDACC,"")
S SDACC=$TR($G(SDACC),"^"," ")
Q SDACC
;
RETURNERROR(ERRORS,SDRECREQ,RETN,REQIEN) ;
M SDRECREQ=ERRORS
D SETEMPTYOBJ(.SDRECREQ,REQIEN)
D BUILDJSON^SDES2JSON(.RETN,.SDRECREQ)
Q
;
SETEMPTYOBJ(SDRECREQ,SDCREATE) ;Set the object to NULL
I SDCREATE="+1" S SDRECREQ("RecallReqCreate","IEN")="" Q
S SDRECREQ("RecallReqEdit","IEN")=""
Q
;
KEY(RECALLIEN,USERDUZ) ;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,$S(USERDUZ'="":USERDUZ,1:DUZ))
..I $G(KY(0))'=0 S RET=0
Q RET
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2RECLLREQ 12434 printed Nov 22, 2024@18:04:29 Page 2
SDES2RECLLREQ ; ALB/TJB,TJB - VISTA SCHEDULING CREATE/UPDATE RECALL REQUESTS ; Jun 17, 2024
+1 ;;5.3;Scheduling;**866,881**;Aug 13, 1993;Build 10
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ;No Direct Call
QUIT
+5 ;
+6 ; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
+7 ; SDCONTEXT("PATIENT DFN") = The DFN/IEN of the target patient from the calling application.
+8 ; SDCONTEXT("PATIENT ICN") = The ICN of the target patient from the calling application.
+9 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action in the calling application.
+10 ; SDCONTEXT("USER SECID") = The SECID of the user taking action in the calling application.
+11 ;
+12 ; SDES2 CREATE RECALL REQUEST:
+13 ; SDINPUT("DFN") = POINTER TO PATIENT (#2) FILE (required)
+14 ; SDINPUT("ACCESSION NUMBER") = ACCESSION # (FREE TEXT)
+15 ; SDINPUT("COMMENT"") = COMMENT (FREE TEXT)
+16 ; SDINPUT("FASTING") = Labs: FASTING ; NON-FASTING ; @ - None (required)
+17 ; SDINPUT(APPOINTMENT TYPE") = (required)
+18 ; Name of the RECALL REMINDERS APPT TYPE (#403.51) FILE
+19 ; 1 FOLLOW-UP F
+20 ; 4 OTHER O
+21 ; 3 SEMI-ANNUAL EXAM SA
+22 ; 2 YEARLY EXAM YEAR
+23 ; SDINPUT("RECALL PROVIDER IEN") = RECALL PROVIDER - POINTER TO RECALL REMINDERS PROVIDERS (#403.54) FILE (required)
+24 ; SDINPUT("CLINIC IEN") = CLINIC POINTER TO HOSPITAL LOCATION (#44) FILE (required)
+25 ; SDINPUT("APPOINTMENT LENGTH") = LENGTH OF APPOINTMENT NUMERIC BETWEEN 10 AND 240.
+26 ; SDINPUT("RECALL DATE") = Recall date in ISO8601 date format (no time). e.g., CCYY-MM-DD (required)
+27 ; SDINPUT(RECALL DATE PER PATIENT") = Recall date (per patient) in ISO8601 date format (no time). e.g., CCYY-MM-DD
+28 ; SDINPUT("DATE REMINDER SENT") = Date Reminder was sent in ISO8601 date format (no time). e.g., CCYY-MM-DD
+29 ; SDINPUT("SECOND PRINT DATE") = Second print date in ISO8601 date format (no time). e.g., CCYY-MM-DD
+30 ; SDINPUT("DATE ENTERED") = Date recall was added. Date is in ISO8601 format (e.g., CCYY-MM-DD)
+31 ;
CREATERECREQ(RETN,SDCONTEXT,SDINPUT) ;CREATE recall request
+1 NEW ERRORS,SDRECREQ,SDFDA,SDMSG,SDIEN
+2 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+3 IF $DATA(ERRORS)
SET ERRORS("RecallReqCreate","IEN")=""
DO BUILDJSON^SDES2JSON(.RETN,.ERRORS)
QUIT
+4 SET SDINPUT("RECALL IEN")="+1"
+5 SET SDINPUT("DATE ENTERED")=$$VALIDATERCDTNTRD(.ERRORS,$GET(SDINPUT("DATE ENTERED")),SDINPUT("RECALL IEN"))
+6 DO VALIDATE(.ERRORS,.SDINPUT)
+7 IF $ORDER(ERRORS("Error",""))'=""
DO RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDINPUT("RECALL IEN"))
QUIT
+8 DO BLDREC(.SDFDA,.SDINPUT,.SDCONTEXT)
+9 DO UPDATE^DIE("","SDFDA","SDIEN","SDMSG")
+10 IF $DATA(SDMSG)
DO ERRLOG^SDES2JSON(.ERRORS,134)
DO RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDINPUT("RECALL IEN"))
QUIT
+11 SET SDRECREQ("RecallReqCreate","IEN")=SDIEN(1)
+12 DO BUILDJSON^SDES2JSON(.RETN,.SDRECREQ)
+13 QUIT
+14 ;
+15 ; SDES2 EDIT RECALL REQUEST:
+16 ; SDINPUT("RECALL IEN") = IEN pointer to RECALL REMINDERS (#403.5) (required)
+17 ; SDINPUT("DFN") = POINTER TO PATIENT (#2) FILE (required)
+18 ; SDINPUT("ACCESSION NUMBER") = ACCESSION # (FREE TEXT)
+19 ; SDINPUT("COMMENT") = COMMENT (FREE TEXT)
+20 ; SDINPUT("FASTING") = Labs: FASTING ; NON-FASTING ; @ - None (required)
+21 ; SDINPUT("APPOINTMENT TYPE") = (required)
+22 ; Name of the RECALL REMINDERS APPT TYPE (#403.51) FILE
+23 ; 1 FOLLOW-UP F
+24 ; 4 OTHER O
+25 ; 3 SEMI-ANNUAL EXAM SA
+26 ; 2 YEARLY EXAM YEAR
+27 ; SDINPUT("RECALL PROVIDER IEN") = RECALL PROVIDER - POINTER TO RECALL REMINDERS PROVIDERS (#403.54) FILE (required)
+28 ; SDINPUT("CLINIC IEN") = CLINIC POINTER TO HOSPITAL LOCATION (#44) FILE (required)
+29 ; SDINPUT("APPOINTMENT LENGTH") = LENGTH OF APPOINTMENT NUMERIC BETWEEN 10 AND 240.
+30 ; SDINPUT("RECALL DATE") = Recall date in ISO8601 date format (no time). e.g., CCYY-MM-DD (required)
+31 ; SDINPUT("RECALL DATE PER PATIENT") = Recall date (per patient) in ISO8601 date format (no time). e.g., CCYY-MM-DD
+32 ; SDINPUT("DATE REMINDER SENT") = Date Reminder was sent in ISO8601 date format (no time). e.g., CCYY-MM-DD
+33 ; SDINPUT("SECOND PRINT DATE") = Second print date in ISO8601 date format (no time). e.g., CCYY-MM-DD
+34 ;
UPDRECALLREQ(RETN,SDCONTEXT,SDINPUT) ;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 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+3 IF $DATA(ERRORS)
SET ERRORS("RecallReqEdit","IEN")=""
DO BUILDJSON^SDES2JSON(.RETN,.ERRORS)
QUIT
+4 DO VALIDATE(.ERRORS,.SDINPUT,.SDCONTEXT)
+5 IF $ORDER(ERRORS("Error",""))'=""
DO RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDINPUT("RECALL IEN"))
QUIT
+6 DO BLDREC(.SDFDA,.SDINPUT,.SDCONTEXT)
+7 DO FILE^DIE(,"SDFDA","SDMSG")
+8 IF $DATA(SDMSG)
DO ERRLOG^SDES2JSON(.ERRORS,134)
DO RETURNERROR(.ERRORS,.SDRECREQ,.RETN,SDINPUT("RECALL IEN"))
QUIT
+9 SET SDRECREQ("RecallReqEdit","IEN")=SDINPUT("RECALL IEN")
+10 DO BUILDJSON^SDES2JSON(.RETN,.SDRECREQ)
+11 QUIT
+12 ;
BLDREC(SDFDA,SDINPUT,SDCONTEXT) ;build and file record
+1 NEW RECALLIEN
+2 SET RECALLIEN=SDINPUT("RECALL IEN")
+3 ;recall
SET SDFDA=$NAME(SDFDA(403.5,RECALLIEN_","))
+4 SET SDFDA(403.5,RECALLIEN_",",.01)=SDINPUT("DFN")
+5 if $GET(SDINPUT("ACCESSION NUMBER"))'=""
SET SDFDA(403.5,RECALLIEN_",",2)=$EXTRACT(SDINPUT("ACCESSION NUMBER"),1,25)
+6 if $GET(SDINPUT("COMMENT"))'=""
SET SDFDA(403.5,RECALLIEN_",",2.5)=$EXTRACT(SDINPUT("COMMENT"),1,80)
+7 SET SDFDA(403.5,RECALLIEN_",",2.6)=SDINPUT("FASTING")
+8 SET SDFDA(403.5,RECALLIEN_",",3)=SDINPUT("APPOINTMENT TYPE")
+9 SET SDFDA(403.5,RECALLIEN_",",4)=SDINPUT("RECALL PROVIDER IEN")
+10 SET SDFDA(403.5,RECALLIEN_",",4.5)=SDINPUT("CLINIC IEN")
+11 if SDINPUT("APPOINTMENT LENGTH")'=""
SET SDFDA(403.5,RECALLIEN_",",4.7)=SDINPUT("APPOINTMENT LENGTH")
+12 SET SDFDA(403.5,RECALLIEN_",",5)=SDINPUT("RECALL DATE")
+13 if $GET(SDINPUT("RECALL DATE PER PATIENT"))'=""
SET SDFDA(403.5,RECALLIEN_",",5.5)=SDINPUT("RECALL DATE PER PATIENT")
+14 if $GET(SDINPUT("DATE REMINDER SENT"))'=""
SET SDFDA(403.5,RECALLIEN_",",6)=SDINPUT("DATE REMINDER SENT")
+15 SET SDFDA(403.5,RECALLIEN_",",7)=$SELECT($GET(SDCONTEXT("USER DUZ"))'="":SDCONTEXT("USER DUZ"),1:DUZ)
+16 ;only add if creating new record, cannot edit
if RECALLIEN="+1"
SET SDFDA(403.5,RECALLIEN_",",7.5)=SDINPUT("DATE ENTERED")
+17 if $GET(SDINPUT("SECOND PRINT DATE"))'=""
SET SDFDA(403.5,RECALLIEN_",",8)=SDINPUT("SECOND PRINT DATE")
+18 SET SDFDA(403.5,RECALLIEN_",",100)=$GET(SDCONTEXT("ACHERON AUDIT ID"))
+19 QUIT
+20 ;
+21 ; SDINPUT("RECALL IEN")
+22 ; SDINPUT("DFN")
+23 ; SDINPUT("ACCESSION NUMBER")
+24 ; SDINPUT("COMMENT")
+25 ; SDINPUT("FASTING")
+26 ; SDINPUT("APPOINTMENT TYPE")
+27 ; SDINPUT("RECALL PROVIDER IEN")
+28 ; SDINPUT("CLINIC IEN")
+29 ; SDINPUT("APPOINTMENT LENGTH")
+30 ; SDINPUT("RECALL DATE")
+31 ; SDINPUT("RECALL DATE PER PATIENT")
+32 ; SDINPUT("DATE REMINDER SENT")
+33 ; SDINPUT("SECOND PRINT DATE")
VALIDATE(ERRORS,SDINPUT,SDCONTEXT) ;
+1 NEW OLDDFN
+2 SET OLDDFN=""
+3 SET SDINPUT("RECALL IEN")=$$VALIDATERECALIEN(.ERRORS,$GET(SDINPUT("RECALL IEN")),$GET(SDCONTEXT("USER DUZ")))
+4 IF '$DATA(ERRORS)
IF SDINPUT("RECALL IEN")'="+1"
SET OLDDFN=$$GET1^DIQ(403.5,SDINPUT("RECALL IEN"),.01,"I")
+5 SET SDINPUT("DFN")=$$VALIDATEDFN(.ERRORS,$GET(SDINPUT("DFN")),OLDDFN)
+6 SET SDINPUT("FASTING")=$$VALIDATEFASTING(.ERRORS,$GET(SDINPUT("FASTING")))
+7 SET SDINPUT("APPOINTMENT TYPE")=$$VALIDATEAPPTP(.ERRORS,$GET(SDINPUT("APPOINTMENT TYPE")))
+8 SET SDINPUT("RECALL PROVIDER IEN")=$$VALIDATERRPRVIEN(.ERRORS,$GET(SDINPUT("RECALL PROVIDER IEN")))
+9 SET SDINPUT("CLINIC IEN")=$$VALIDATECLINIEN(.ERRORS,$GET(SDINPUT("CLINIC IEN")))
+10 SET SDINPUT("RECALL DATE")=$$VALIDATERECALLDT(.ERRORS,$GET(SDINPUT("RECALL DATE")))
+11 SET SDINPUT("APPOINTMENT LENGTH")=$$VALIDATEAPPTLEN(.ERRORS,$GET(SDINPUT("APPOINTMENT LENGTH")))
+12 SET SDINPUT("RECALL DATE PER PATIENT")=$$VALIDATERECPPDT(.ERRORS,$GET(SDINPUT("RECALL DATE PER PATIENT")))
+13 SET SDINPUT("DATE REMINDER SENT")=$$VALIDATEDAPTDT(.ERRORS,$GET(SDINPUT("DATE REMINDER SENT")))
+14 SET SDINPUT("SECOND PRINT DATE")=$$VALIDATESECPDT(.ERRORS,$GET(SDINPUT("SECOND PRINT DATE")))
+15 SET SDINPUT("COMMENT")=$$VALIDATESDCMT(.ERRORS,$GET(SDINPUT("COMMENT")))
+16 SET SDINPUT("ACCESSION NUMBER")=$$VALIDATEACCNUM(.ERRORS,$GET(SDINPUT("ACCESSION NUMBER")))
+17 QUIT
+18 ;
VALIDATERECALIEN(ERRORS,RECALLIEN,USERDUZ) ;Validate Recall IEN
+1 IF $GET(RECALLIEN)=""
DO ERRLOG^SDES2JSON(.ERRORS,16)
QUIT RECALLIEN
+2 IF (RECALLIEN'="+1")&('$DATA(^SD(403.5,$GET(RECALLIEN))))
DO ERRLOG^SDES2JSON(.ERRORS,17)
QUIT RECALLIEN
+3 ;check that user has the correct security key
+4 IF $$KEY(RECALLIEN,$GET(USERDUZ))>0
DO ERRLOG^SDES2JSON(.ERRORS,135)
+5 QUIT RECALLIEN
+6 ;
VALIDATEDFN(ERRORS,DFN,OLDDFN) ;Validate Patient DFN
+1 DO VALPATDFN^SDES2VAL2(.ERRORS,$GET(DFN),1)
+2 IF DFN'=""
IF OLDDFN'=""
IF DFN'=OLDDFN
DO ERRLOG^SDES2JSON(.ERRORS,2,"Patient ID on Recall doesn't match passed in Patient ID")
+3 QUIT DFN
+4 ;
VALIDATEFASTING(ERRORS,FASTING) ;Validate Fasting
+1 IF FASTING=""
DO ERRLOG^SDES2JSON(.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^SDES2JSON(.ERRORS,138)
+4 QUIT FASTING
+5 ;
VALIDATEAPPTP(ERRORS,APPTP) ;Validate Appointment Type
+1 IF APPTP=""
DO ERRLOG^SDES2JSON(.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^SDES2JSON(.ERRORS,132)
QUIT APPTP
+4 SET APPTP=$ORDER(^SD(403.51,"B",APPTP,""))
+5 IF APPTP=""
DO ERRLOG^SDES2JSON(.ERRORS,139)
QUIT APPTP
+6 QUIT APPTP
+7 ;
VALIDATERRPRVIEN(ERRORS,RRPROVIEN) ;Validate Recall Provider IEN
+1 IF RRPROVIEN=""
DO ERRLOG^SDES2JSON(.ERRORS,137)
QUIT RRPROVIEN
+2 IF $GET(RRPROVIEN)'=""
IF '$DATA(^SD(403.54,RRPROVIEN))
DO ERRLOG^SDES2JSON(.ERRORS,131)
+3 QUIT RRPROVIEN
+4 ;
VALIDATECLINIEN(ERRORS,CLINIEN) ;Validate Clinic IEN
+1 IF CLINIEN=""
DO ERRLOG^SDES2JSON(.ERRORS,18)
QUIT CLINIEN
+2 IF CLINIEN'=""
IF '$DATA(^SC(CLINIEN))
DO ERRLOG^SDES2JSON(.ERRORS,19)
+3 QUIT CLINIEN
+4 ;
VALIDATERECALLDT(ERRORS,RECALLDATE) ;Validate Recall Date
+1 IF RECALLDATE=""
DO ERRLOG^SDES2JSON(.ERRORS,140)
QUIT RECALLDATE
+2 IF RECALLDATE'=""
SET RECALLDATE=$$ISOTFM^SDAMUTDT(RECALLDATE)
+3 IF RECALLDATE=-1
DO ERRLOG^SDES2JSON(.ERRORS,133)
+4 QUIT RECALLDATE
+5 ;
VALIDATERCDTNTRD(ERRORS,RECDTENTRD,RECALLIEN) ;Validate Recall Date Entered
+1 ; This is an IEN, so can't edit Recall Date Entered
IF RECALLIEN'="+1"
QUIT ""
+2 IF ($GET(RECDTENTRD)'="")
SET RECDTENTRD=$$ISOTFM^SDAMUTDT(RECDTENTRD)
+3 ;
IF (RECDTENTRD=-1)!(RECDTENTRD="")
SET RECDTENTRD=DT
+4 QUIT RECDTENTRD
+5 ;
VALIDATEAPPTLEN(ERRORS,LENGTHOFAPPT) ;Validate Length of Appointment
+1 SET LENGTHOFAPPT=$GET(LENGTHOFAPPT,"")
IF LENGTHOFAPPT=""
QUIT LENGTHOFAPPT
+2 IF '+LENGTHOFAPPT
DO ERRLOG^SDES2JSON(.ERRORS,116)
QUIT LENGTHOFAPPT
+3 IF LENGTHOFAPPT'=""
if ((+LENGTHOFAPPT<10)!(+LENGTHOFAPPT>240))
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 ;
VALIDATESECPDT(ERRORS,SECPRNTDT) ;Validate Second Print Date
+1 SET SECPRNTDT=$GET(SECPRNTDT,"")
+2 IF SECPRNTDT'=""
SET SECPRNTDT=$$ISOTFM^SDAMUTDT(SECPRNTDT)
+3 ;VSE-2396
IF SECPRNTDT=-1
SET SECPRNTDT=""
+4 QUIT SECPRNTDT
+5 ;
VALIDATESDCMT(ERRORS,SDCMT) ;Validate Comment
+1 SET SDCMT=$GET(SDCMT,"")
+2 SET SDCMT=$TRANSLATE($GET(SDCMT),"^"," ")
+3 QUIT SDCMT
+4 ;
VALIDATEACCNUM(ERRORS,SDACC) ;Validate ACCESSION NUMBER
+1 SET SDACC=$GET(SDACC,"")
+2 SET SDACC=$TRANSLATE($GET(SDACC),"^"," ")
+3 QUIT SDACC
+4 ;
RETURNERROR(ERRORS,SDRECREQ,RETN,REQIEN) ;
+1 MERGE SDRECREQ=ERRORS
+2 DO SETEMPTYOBJ(.SDRECREQ,REQIEN)
+3 DO BUILDJSON^SDES2JSON(.RETN,.SDRECREQ)
+4 QUIT
+5 ;
SETEMPTYOBJ(SDRECREQ,SDCREATE) ;Set the object to NULL
+1 IF SDCREATE="+1"
SET SDRECREQ("RecallReqCreate","IEN")=""
QUIT
+2 SET SDRECREQ("RecallReqEdit","IEN")=""
+3 QUIT
+4 ;
KEY(RECALLIEN,USERDUZ) ;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,$SELECT(USERDUZ'="":USERDUZ,1:DUZ))
+14 IF $GET(KY(0))'=0
SET RET=0
End DoDot:2
End DoDot:1
+15 QUIT RET
+16 ;