SDES2CKNSTEP ;ALB/ANU - VISTA SCHEDULING RPCS ;DEC 18, 2023
;;5.3;Scheduling;**869**;Aug 13, 1993;Build 13
;;Per VHA Directive 6402, this routine should not be modified;
Q
; INPUT
;
; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
; 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.
; 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.
; SDINPUT("STATUS") = (Required) STATUS, Status to be set in Check-in step status (#409.842) file.
;
SETCKNSTEP(JSON,SDCONTEXT,SDINPUT) ;create new status entry in check-in step status file
N ERRORS,SDRETURN,PARAMETERS,FDA,SDCHECKIN,IEN,ENTRY,SDUSER
;
; Validate SDCONTEXT
;
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
I $D(ERRORS) S ERRORS("CheckInSteps",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
; Validate PARAMS
S PARAMETERS=$$VALPARAMS(.SDINPUT,.ERRORS)
I $D(ERRORS) S ERRORS("CheckInSteps",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
;
S SDUSER=$S(+$G(SDCONTEXT("USER DUZ")):+SDCONTEXT("USER DUZ"),1:$G(DUZ))
S STATUS=$P(PARAMETERS,"^")
D SETCKN(.SDRETURN,STATUS,SDUSER,SDCONTEXT("ACHERON AUDIT ID"))
I '$D(SDRETURN) S SDRETURN("CheckInSteps",1)=""
D BUILDJSON^SDES2JSON(.JSON,.SDRETURN)
Q
;
VALPARAMS(PARAMS,SDERRORS) ; Validate
N STATUS,SDIEN,SDENTRY
;
; Validate Status
S STATUS=$G(PARAMS("STATUS"))
I $G(STATUS)="" D ERRLOG^SDESJSON(.SDERRORS,38) Q 0
I $L(STATUS)<3!($L(STATUS)>30) D ERRLOG^SDESJSON(.SDERRORS,39) Q 0
I STATUS'?.E1A.E!(STATUS?1P.E) D ERRLOG^SDESJSON(.SDERRORS,41) Q 0
;
S SDIEN=0,SDENTRY=""
F S SDIEN=$O(^SDEC(409.842,SDIEN)) Q:'SDIEN!(STATUS=SDENTRY) D
.S SDENTRY=$$GET1^DIQ(409.842,SDIEN,.01,"E")
I STATUS=SDENTRY D ERRLOG^SDESJSON(.SDERRORS,32) Q 0 ; duplicate status entry, will not file
Q:$D(SDERRORS) 0
Q STATUS
;
SETCKN(SDRETURN,STATUS,SDUSER,AUDITID) ;create new status entry in check-in step status file
N FDA,SDCHECKIN,ERR
S FDA(409.842,"+1,",.01)=STATUS
D UPDATE^DIE(,"FDA",,"ERR") K FDA,ERR
I '$D(ERR) S SDRETURN("CheckInSteps","FilingSuccess")=1
I $D(ERR) D ERRLOG^SDESJSON(.SDRETURN,34)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2CKNSTEP 2405 printed Dec 13, 2024@02:53:29 Page 2
SDES2CKNSTEP ;ALB/ANU - VISTA SCHEDULING RPCS ;DEC 18, 2023
+1 ;;5.3;Scheduling;**869**;Aug 13, 1993;Build 13
+2 ;;Per VHA Directive 6402, this routine should not be modified;
+3 QUIT
+4 ; INPUT
+5 ;
+6 ; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
+7 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action in the calling application.
+8 ; SDCONTEXT("USER SECID") = The SECID of the user taking action in the calling application.
+9 ; SDCONTEXT("PATIENT DFN") = The DFN/IEN of the target patient from the calling application.
+10 ; SDCONTEXT("PATIENT ICN") = The ICN of the target patient from the calling application.
+11 ; SDINPUT("STATUS") = (Required) STATUS, Status to be set in Check-in step status (#409.842) file.
+12 ;
SETCKNSTEP(JSON,SDCONTEXT,SDINPUT) ;create new status entry in check-in step status file
+1 NEW ERRORS,SDRETURN,PARAMETERS,FDA,SDCHECKIN,IEN,ENTRY,SDUSER
+2 ;
+3 ; Validate SDCONTEXT
+4 ;
+5 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+6 IF $DATA(ERRORS)
SET ERRORS("CheckInSteps",1)=""
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+7 ; Validate PARAMS
+8 SET PARAMETERS=$$VALPARAMS(.SDINPUT,.ERRORS)
+9 IF $DATA(ERRORS)
SET ERRORS("CheckInSteps",1)=""
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+10 ;
+11 SET SDUSER=$SELECT(+$GET(SDCONTEXT("USER DUZ")):+SDCONTEXT("USER DUZ"),1:$GET(DUZ))
+12 SET STATUS=$PIECE(PARAMETERS,"^")
+13 DO SETCKN(.SDRETURN,STATUS,SDUSER,SDCONTEXT("ACHERON AUDIT ID"))
+14 IF '$DATA(SDRETURN)
SET SDRETURN("CheckInSteps",1)=""
+15 DO BUILDJSON^SDES2JSON(.JSON,.SDRETURN)
+16 QUIT
+17 ;
VALPARAMS(PARAMS,SDERRORS) ; Validate
+1 NEW STATUS,SDIEN,SDENTRY
+2 ;
+3 ; Validate Status
+4 SET STATUS=$GET(PARAMS("STATUS"))
+5 IF $GET(STATUS)=""
DO ERRLOG^SDESJSON(.SDERRORS,38)
QUIT 0
+6 IF $LENGTH(STATUS)<3!($LENGTH(STATUS)>30)
DO ERRLOG^SDESJSON(.SDERRORS,39)
QUIT 0
+7 IF STATUS'?.E1A.E!(STATUS?1P.E)
DO ERRLOG^SDESJSON(.SDERRORS,41)
QUIT 0
+8 ;
+9 SET SDIEN=0
SET SDENTRY=""
+10 FOR
SET SDIEN=$ORDER(^SDEC(409.842,SDIEN))
if 'SDIEN!(STATUS=SDENTRY)
QUIT
Begin DoDot:1
+11 SET SDENTRY=$$GET1^DIQ(409.842,SDIEN,.01,"E")
End DoDot:1
+12 ; duplicate status entry, will not file
IF STATUS=SDENTRY
DO ERRLOG^SDESJSON(.SDERRORS,32)
QUIT 0
+13 if $DATA(SDERRORS)
QUIT 0
+14 QUIT STATUS
+15 ;
SETCKN(SDRETURN,STATUS,SDUSER,AUDITID) ;create new status entry in check-in step status file
+1 NEW FDA,SDCHECKIN,ERR
+2 SET FDA(409.842,"+1,",.01)=STATUS
+3 DO UPDATE^DIE(,"FDA",,"ERR")
KILL FDA,ERR
+4 IF '$DATA(ERR)
SET SDRETURN("CheckInSteps","FilingSuccess")=1
+5 IF $DATA(ERR)
DO ERRLOG^SDESJSON(.SDRETURN,34)
+6 QUIT
+7 ;