SDES2APPTCKNSTEP ;ALB/ANU,LAB - VISTA SCHEDULING RPC SDES2 SET CHECK-IN STEP ;FEB 5,2024
;;5.3;Scheduling;**869,871**;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("APPOINTMENT IEN") = (Required) APPOINTMENT IEN, Appointment IEN
; SDINPUT("STATUS") = (Required) STATUS, Status to be set in Check-in Step Status (#409.843) file
;
SETAPPTCKNSTEP(JSON,SDCONTEXT,SDINPUT) ;create new status entry in Check-in Step Status (#409.843) file
N ERRORS,SDRETURN,SDUSER
;
; Validate SDCONTEXT
;
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
I $D(ERRORS) S ERRORS("ApptCheckInSteps",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
;
; Validate input parameters
;
D VALIDATE(.ERRORS,.SDINPUT)
I $D(ERRORS) S ERRORS("ApptCheckInSteps",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
S SDUSER=$S(+$G(SDCONTEXT("USER DUZ")):+SDCONTEXT("USER DUZ"),1:$G(DUZ))
D SETAPPTCKN(.SDRETURN,.SDINPUT,SDUSER,.SDCONTEXT)
I '$D(SDRETURN) S SDRETURN("ApptCheckInSteps",1)=""
D BUILDJSON^SDES2JSON(.JSON,.SDRETURN)
Q
;
VALIDATE(ERRORS,SDINPUT) ; validate input parameters
N VALUE,SIEN,STATPOINTER
;
; Validate Appointment IEN
;
D VALFILEIEN^SDES2VALUTIL(,.ERRORS,409.84,$G(SDINPUT("APPOINTMENT IEN")),1,0,14,15)
;
I '$D(ERRORS) D
. I $$GET1^DIQ(409.84,SDINPUT("APPOINTMENT IEN"),.17,"E")["CANCEL" D ERRLOG^SDESJSON(.ERRORS,31) ;appt status is "C" (canceled)
;
; Validate Status
;
D VALFIELD^SDES2VALUTIL(.VALUE,.ERRORS,409.843,.01,$G(SDINPUT("STATUS")),1)
S SDINPUT("STATUS POINTER")=$G(VALUE(409.843,.01,"I")) ;convert to internal value
;
I '$D(ERRORS)&VALUE D
. S SIEN=0,STATPOINTER=0
. F S SIEN=$O(^SDEC(409.84,SDINPUT("APPOINTMENT IEN"),3,SIEN)) Q:'SIEN!(STATPOINTER=SDINPUT("STATUS POINTER")) D
. .S STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_SDINPUT("APPOINTMENT IEN")_",",.01,"I")
. I STATPOINTER=SDINPUT("STATUS POINTER") D ERRLOG^SDESJSON(.ERRORS,32)
Q
;
SETAPPTCKN(SDRETURN,SDINPUT,SDUSER,SDCONTEXT) ; File check-in status and date/time in 409.843,.01/1
N STATPOINTER,SIEN,DATETIME,CHECKINARRAY,SDCHECKIN,SDRETURN1,FILEERROR
N SDPARAM
S DATETIME=$$NOW^XLFDT
;
;update step in status
;
S CHECKINARRAY(409.843,"+1,"_SDINPUT("APPOINTMENT IEN")_",",.01)=SDINPUT("STATUS POINTER")
S CHECKINARRAY(409.843,"+1,"_SDINPUT("APPOINTMENT IEN")_",",1)=DATETIME
D UPDATE^DIE(,"CHECKINARRAY",,"FILEERROR") K CHECKINARRAY
I $D(FILEERROR) D ERRLOG^SDESJSON(.SDRETURN,36) Q
;
;update acheron audit field
;
S CHECKINARRAY(409.84,SDINPUT("APPOINTMENT IEN")_",",100)=$G(SDCONTEXT("ACHERON AUDIT ID"))
D FILE^DIE(,"CHECKINARRAY") K CHECKINARRAY
;
S SDRETURN("ApptCheckInSteps","FilingSuccess")=1
I SDINPUT("STATUS")="E-CHECK-IN COMPLETE" D
. S SDPARAM("APPOINTMENT IEN")=SDINPUT("APPOINTMENT IEN") ; The appointment IEN from the SDES APPOINTMENT (#409.84) file. (required)
. S DATETIME=$$FMTISO^SDAMUTDT($$NOW^XLFDT)
. S SDPARAM("CHECKIN DATE TIME")=DATETIME ; ISO DATE and TIME to check-in the patient (required)
. D CHECKIN^SDES2CHECKIN(.SDRETURN1,.SDCONTEXT,.SDPARAM)
. M SDRETURN("ApptCheckInSteps","Checkin")=SDRETURN1("Checkin")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2APPTCKNSTEP 3682 printed Dec 13, 2024@02:53:13 Page 2
SDES2APPTCKNSTEP ;ALB/ANU,LAB - VISTA SCHEDULING RPC SDES2 SET CHECK-IN STEP ;FEB 5,2024
+1 ;;5.3;Scheduling;**869,871**;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("APPOINTMENT IEN") = (Required) APPOINTMENT IEN, Appointment IEN
+12 ; SDINPUT("STATUS") = (Required) STATUS, Status to be set in Check-in Step Status (#409.843) file
+13 ;
SETAPPTCKNSTEP(JSON,SDCONTEXT,SDINPUT) ;create new status entry in Check-in Step Status (#409.843) file
+1 NEW ERRORS,SDRETURN,SDUSER
+2 ;
+3 ; Validate SDCONTEXT
+4 ;
+5 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+6 IF $DATA(ERRORS)
SET ERRORS("ApptCheckInSteps",1)=""
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+7 ;
+8 ; Validate input parameters
+9 ;
+10 DO VALIDATE(.ERRORS,.SDINPUT)
+11 IF $DATA(ERRORS)
SET ERRORS("ApptCheckInSteps",1)=""
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+12 SET SDUSER=$SELECT(+$GET(SDCONTEXT("USER DUZ")):+SDCONTEXT("USER DUZ"),1:$GET(DUZ))
+13 DO SETAPPTCKN(.SDRETURN,.SDINPUT,SDUSER,.SDCONTEXT)
+14 IF '$DATA(SDRETURN)
SET SDRETURN("ApptCheckInSteps",1)=""
+15 DO BUILDJSON^SDES2JSON(.JSON,.SDRETURN)
+16 QUIT
+17 ;
VALIDATE(ERRORS,SDINPUT) ; validate input parameters
+1 NEW VALUE,SIEN,STATPOINTER
+2 ;
+3 ; Validate Appointment IEN
+4 ;
+5 DO VALFILEIEN^SDES2VALUTIL(,.ERRORS,409.84,$GET(SDINPUT("APPOINTMENT IEN")),1,0,14,15)
+6 ;
+7 IF '$DATA(ERRORS)
Begin DoDot:1
+8 ;appt status is "C" (canceled)
IF $$GET1^DIQ(409.84,SDINPUT("APPOINTMENT IEN"),.17,"E")["CANCEL"
DO ERRLOG^SDESJSON(.ERRORS,31)
End DoDot:1
+9 ;
+10 ; Validate Status
+11 ;
+12 DO VALFIELD^SDES2VALUTIL(.VALUE,.ERRORS,409.843,.01,$GET(SDINPUT("STATUS")),1)
+13 ;convert to internal value
SET SDINPUT("STATUS POINTER")=$GET(VALUE(409.843,.01,"I"))
+14 ;
+15 IF '$DATA(ERRORS)&VALUE
Begin DoDot:1
+16 SET SIEN=0
SET STATPOINTER=0
+17 FOR
SET SIEN=$ORDER(^SDEC(409.84,SDINPUT("APPOINTMENT IEN"),3,SIEN))
if 'SIEN!(STATPOINTER=SDINPUT("STATUS POINTER"))
QUIT
Begin DoDot:2
+18 SET STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_SDINPUT("APPOINTMENT IEN")_",",.01,"I")
End DoDot:2
+19 IF STATPOINTER=SDINPUT("STATUS POINTER")
DO ERRLOG^SDESJSON(.ERRORS,32)
End DoDot:1
+20 QUIT
+21 ;
SETAPPTCKN(SDRETURN,SDINPUT,SDUSER,SDCONTEXT) ; File check-in status and date/time in 409.843,.01/1
+1 NEW STATPOINTER,SIEN,DATETIME,CHECKINARRAY,SDCHECKIN,SDRETURN1,FILEERROR
+2 NEW SDPARAM
+3 SET DATETIME=$$NOW^XLFDT
+4 ;
+5 ;update step in status
+6 ;
+7 SET CHECKINARRAY(409.843,"+1,"_SDINPUT("APPOINTMENT IEN")_",",.01)=SDINPUT("STATUS POINTER")
+8 SET CHECKINARRAY(409.843,"+1,"_SDINPUT("APPOINTMENT IEN")_",",1)=DATETIME
+9 DO UPDATE^DIE(,"CHECKINARRAY",,"FILEERROR")
KILL CHECKINARRAY
+10 IF $DATA(FILEERROR)
DO ERRLOG^SDESJSON(.SDRETURN,36)
QUIT
+11 ;
+12 ;update acheron audit field
+13 ;
+14 SET CHECKINARRAY(409.84,SDINPUT("APPOINTMENT IEN")_",",100)=$GET(SDCONTEXT("ACHERON AUDIT ID"))
+15 DO FILE^DIE(,"CHECKINARRAY")
KILL CHECKINARRAY
+16 ;
+17 SET SDRETURN("ApptCheckInSteps","FilingSuccess")=1
+18 IF SDINPUT("STATUS")="E-CHECK-IN COMPLETE"
Begin DoDot:1
+19 ; The appointment IEN from the SDES APPOINTMENT (#409.84) file. (required)
SET SDPARAM("APPOINTMENT IEN")=SDINPUT("APPOINTMENT IEN")
+20 SET DATETIME=$$FMTISO^SDAMUTDT($$NOW^XLFDT)
+21 ; ISO DATE and TIME to check-in the patient (required)
SET SDPARAM("CHECKIN DATE TIME")=DATETIME
+22 DO CHECKIN^SDES2CHECKIN(.SDRETURN1,.SDCONTEXT,.SDPARAM)
+23 MERGE SDRETURN("ApptCheckInSteps","Checkin")=SDRETURN1("Checkin")
End DoDot:1
+24 QUIT
+25 ;