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

SDES2CRTWALKIN.m

Go to the documentation of this file.
SDES2CRTWALKIN  ;ALB/JAS,JAS - VISTA SCHEDULING WALK-IN RPC ; FEB 15 2024  11:07 AM
 ;;5.3;Scheduling;**869,871**;Aug 13, 1993;Build 13
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ;
 ; RPC: SDES2 CREATE WALKIN APPT
 ;
 ; SDCONTEXT("ACHERON AUDIT ID") = 40 character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action on the calling application.
 ; SDCONTEXT("USER SECID") = The name of the user taking action on the calling application.
 ; SDCONTEXT("PATIENT DFN") = The DFN of the Veteran/user taking action on the calling application.
 ; SDCONTEXT("PATIENT ICN") = The ICN of the Veteran/user taking action on the calling application.
 ;
 ; ** Required Parameters **
 ; PARAMS("APPT START") = APPOINTMENT START TIME - ISO FORMAT
 ; PARAMS("APPT END") = APPOINTMENT END TIME - ISO FORMAT
 ; PARAMS("DFN") = PATIENT ID - Pointer to the PATIENT (#2) file
 ; PARAMS("PATIENT INDICATED DATE") = DESIRED DATE/TIME
 ; PARAMS("CLINIC IEN") = Pointer to the HOSPITAL LOCATION (#44) file
 ; PARAMS("APPOINTMENT TYPE NAME") = APPOINTMENT TYPE NAME
 ; PARAMS("APPT LENGTH") = APPOINTMENT LENGTH
 ; PARAMS("INSTITUTION NAME") = INSTITUTION NAME (OR STATION NUMBER IS REQUIRED)
 ; PARAMS("STATION NUMBER") = STATION NUMBER (OR INSTITUTION NAME IS REQUIRED)
 ;
 ;  * Optional Parameters *
 ; PARAMS("SDNOTE") = NOTE
 ; PARAMS("PATIENT STATUS") = PATIENT STATUS - (N/E) N:NEW E:ESTABLISHED
 ; PARAMS("SDSERVCONN") = SERVICE CONNECTED - YES/NO
 ; PARAMS("SDSERVCONNPERC") = SERVICE CONNECTED PERCENTAGE - 0-100
 ; PARAMS("SDPATELIG") = PATIENT ELIGIBILITY
 ; PARAMS("OVERBOOK") = OVERBOOK
 ; PARAMS("SDCOLLATERAL") = COLLATERAL
 ; PARAMS("VAOS GUID") = VAOS GUID
 ; PARAMS("MODALITY") = MODALITY
 ; PARAMS("STOP CODE") = STOP CODE
 ; PARAMS("SECONDARY STOP CODE") = SECONDARY STOP CODE
 ; PARAMS("PRIORITY GROUP") = PRIORITY GROUP
 ;
CREATEWALKIN(JSONRETURN,SDCONTEXT,PARAMS) ;
 ;
 N X,Y,REQRESULT,REQARRAY,APPTARRAY,APPTRESULT,%,APPOINTMENT,DISPRESULT
 N APPTRETURN,REQRETURN,CHECKIN,DA,DIK,SDERRORS,SDPARAMS,VALRETURN
 ;
 ; Validate SDCONTEXT and PARAMS("APPOINTMENT TYPE NAME")
 ;
 D VALCONTEXT^SDES2VALCONTEXT(.SDERRORS,.SDCONTEXT)
 I $D(SDERRORS) D BUILDERROR(.SDERRORS,.JSONRETURN) Q
 S PARAMS("ORIG USER")=$S($G(SDCONTEXT("USER DUZ"))'="":SDCONTEXT("USER DUZ"),1:DUZ)
 S PARAMS("ACHERON AUDIT ID")=$G(SDCONTEXT("ACHERON AUDIT ID"))
 ;
 S PARAMS("RESOURCE IEN")=$S($G(PARAMS("CLINIC IEN"))="":"",1:$$GETRES^SDESINPUTVALUTL($G(PARAMS("CLINIC IEN")),1))
 D VALFIELD^SDES2VALUTIL(.VALRETURN,.SDERRORS,409.85,8.7,$G(PARAMS("APPOINTMENT TYPE NAME")),1,,181,180)
 I $D(SDERRORS) D BUILDERROR(.SDERRORS,.JSONRETURN) Q
 ;
 D BLDREQARRAY(.REQARRAY,.PARAMS)
 D CREATEREQUEST^SDES2CRTAPREQ(.REQRETURN,.SDCONTEXT,.REQARRAY)
 D DECODE^XLFJSON("REQRETURN","REQRESULT","ERROR")
 I $O(REQRESULT("Error",""))'="" D  Q
 . D BUILDERROR(.REQRESULT,.JSONRETURN)
 ;
 D BLDAPPTARRAY(.APPTARRAY,.PARAMS)
 K TMPJSONRETURN
 D CREATE^SDES2CREATEAPPT(.APPTRETURN,.SDCONTEXT,.APPTARRAY)
 D DECODE^XLFJSON("APPTRETURN","APPTRESULT","ERROR")
 I $O(APPTRESULT("Error",""))'="" D  Q
 . S DIK="^SDEC(409.85,",DA=$G(REQRESULT("Request","IEN")) D ^DIK
 . D BUILDERROR(.APPTRESULT,.JSONRETURN)
 ;
 D DISPOSITIONREQ(.DISPRESULT,.SDCONTEXT,.REQRESULT,.REQUEST)
 ;
 S SDPARAMS("APPOINTMENT IEN")=APPTRESULT("Appointment","IEN")
 S SDPARAMS("CHECKIN DATE TIME")=$$FMTISO^SDAMUTDT($$NOW^XLFDT)
 D CHECKIN^SDES2CHECKIN(.CHECKIN,.SDCONTEXT,.SDPARAMS)
 M APPOINTMENT=REQRESULT
 M APPOINTMENT=APPTRESULT
 D BUILDJSON^SDES2JSON(.JSONRETURN,.APPOINTMENT)
 Q
 ;
SETEMPTYOBJECT(RETURNERROR) ;set the return object into null if an error occur
 S RETURNERROR("Request","IEN")=""
 S RETURNERROR("Appointment","IEN")=""
 Q
 ;
DISPOSITIONREQ(DISPRESULT,SDCONTEXT,REQRESULT,REQUEST) ;
 NEW DISPARAMS
 S DISPARAMS("REQUEST ID")=$G(REQRESULT("Request","IEN"))
 S DISPARAMS("PCMT")=$G(REQUEST("VAOS GUID"))
 S DISPARAMS("DISP")="REMOVED/SCHEDULED-ASSIGNED"
 S DISPARAMS("DISPDT")=$TR($$FMTE^XLFDT($$NOW^XLFDT,"7DZ"),"/","-")
 D DISPOSITION^SDES2ARCLOSE(.DISPRESULT,.SDCONTEXT,.DISPARAMS)
 Q
 ;
BUILDERROR(RESULT,JSONRETURN) ;
 NEW RETURNERROR
 M RETURNERROR=RESULT
 D SETEMPTYOBJECT(.RETURNERROR)
 D BUILDJSON^SDES2JSON(.JSONRETURN,.RETURNERROR)
 Q
 ;
BLDREQARRAY(REQARRAY,PARAMS) ;build the array to call SDES2 CREATE APPT REQ
 N FDA,FDAERR,RETURNIEN
 S REQARRAY("DFN")=$G(PARAMS("DFN"))
 S REQARRAY("CREATE DATE")=$$FMTISO^SDAMUTDT(DT) ;Needs to be in ISO
 S REQARRAY("STATION NUMBER")=$G(PARAMS("STATION NUMBER"))
 S REQARRAY("INSTITUTION NAME")=$G(PARAMS("INSTITUTION NAME"))
 S REQARRAY("CLINIC IEN")=$G(PARAMS("CLINIC IEN"))
 S REQARRAY("REQUEST SUB TYPE")="APPT"
 S REQARRAY("REQUESTED BY")="PATIENT"
 S REQARRAY("PATIENT INDICATED DATE")=$G(PARAMS("PATIENT INDICATED DATE"))
 S REQARRAY("PRIORITY")="ASAP"
 S REQARRAY("PRIORITY GROUP")=$G(PARAMS("PRIORITY GROUP"))
 S REQARRAY("SERVICE CONNECTED")=$G(PARAMS("SDSERVCONN"))
 S REQARRAY("SERVICE CONNECTED PERCENTAGE")=$G(PARAMS("SDSERVCONNPERC"))
 S REQARRAY("STOP CODE")=$G(PARAMS("STOP CODE"))
 S REQARRAY("SECONDARY STOP CODE")=$G(PARAMS("SECONDARY STOP CODE"))
 S REQARRAY("MODALITY")=$G(PARAMS("MODALITY"))
 S REQARRAY("APPOINTMENT TYPE")=$G(PARAMS("APPOINTMENT TYPE NAME"))
 S REQARRAY("PATIENT STATUS")=$G(PARAMS("PATIENT STATUS"))
 S REQARRAY("VAOS GUID")=$G(PARAMS("VAOS GUID"))
 S REQARRAY("EAS")=$G(PARAMS("ACHERON AUDIT ID"))
 S REQARRAY("REQUEST COMMENT")="AUTO-GENERATED WALKIN REQUEST"
 S REQARRAY("MRTC","NEEDED")="NO"
 S REQARRAY("CPRS TIME SENSITIVE")="NO"
 S REQARRAY("CPRS ORDER NUMBER")=0
 S REQARRAY("ORIG USER")=PARAMS("ORIG USER")
 Q
 ;
BLDAPPTARRAY(APPTARRAY,PARAMS) ;Build the appointment array to call SDES2 CREATE APPOINTMENT
 S APPTARRAY("START DATE TIME")=$G(PARAMS("APPT START"))
 S APPTARRAY("END DATE TIME")=$G(PARAMS("APPT END"))
 S APPTARRAY("DFN")=$G(PARAMS("DFN"))
 S APPTARRAY("RESOURCE IEN")=$G(PARAMS("RESOURCE IEN"))
 S APPTARRAY("WALKIN")="y"                                  ;walk-in
 S APPTARRAY("PATIENT INDICATED DATE")=$G(PARAMS("PATIENT INDICATED DATE")) ;this is the CID/PID Date Preferred
 S APPTARRAY("EXTERNAL ID")=""                              ;this is the EXTERNAL ID - (FREE TEXT 1-50), defaulted to NULL since this not needed
 S APPTARRAY("REQUEST TYPE")="A|"_$G(REQRESULT("Request","IEN"))
 S APPTARRAY("PROVIDER IEN")=""
 S APPTARRAY("CLINIC IEN")=$G(PARAMS("CLINIC IEN"))
 S APPTARRAY("NOTE")=$G(PARAMS("SDNOTE"))
 S APPTARRAY("APPOINTMENT TYPE NAME")=$G(PARAMS("APPOINTMENT TYPE NAME"))
 S APPTARRAY("PATIENT STATUS")=$G(PARAMS("PATIENT STATUS"))
 S APPTARRAY("APPOINTMENT LENGTH")=$G(PARAMS("APPT LENGTH"))
 S APPTARRAY("SERVICE CONNECTED")=$G(PARAMS("SDSERVCONN"))
 S APPTARRAY("SERVICE CONNECTED PERCENTAGE")=$G(PARAMS("SDSERVCONNPERC"))
 S APPTARRAY("APPOINTMENT REASON")=$G(PARAMS("SDNOTE"))     ;Appointment reason
 S APPTARRAY("PATIENT ELIGIBILITY")=$G(PARAMS("SDPATELIG")) ;This is PATIENT ELIGIBILITY IEN pointer to DIC(8
 S APPTARRAY("OVERBOOK")=$G(PARAMS("OVERBOOK"))             ;OVERBOOK (0 for no, 1 for yes)
 S APPTARRAY("LAB DATE TIME")=""                            ;LAB DATE/TIME - ISO FORMAT
 S APPTARRAY("XRAY DATE TIME")=""                           ;XRAY DATE/TIME - ISO FORMAT
 S APPTARRAY("EKG DATE TIME")=""                            ;EKG DATE/TIME - ISO FORMAT
 S APPTARRAY("PURPOSE")=4                                   ;Always set to '4' FOR WALKIN
 S APPTARRAY("COLLATERAL")=$G(PARAMS("SDCOLLATERAL"))       ;COLLATERAL - 1 FOR YES
 S APPTARRAY("SCHEDULE REQUEST TYPE")="W"                   ;Always set to 'W' FOR 'NEXT AVAILABLE' APPT.
 S APPTARRAY("NEXT AVAILABLE APPOINTMENT")=0                ;Always set to 0
 S APPTARRAY("FOLLOWUP")=0
 Q
 ;