Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDES2APPTCKNSTEP

SDES2APPTCKNSTEP.m

Go to the documentation of this file.
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
 ;