SDES2APPTYPES ;ALB/TJB - VISTA SCHEDULING SDES2 GET APPOINTMENT TYPES RPC in APPOINTMENT TYPES FILE 409.1 ;October 11, 2023
;;5.3;Scheduling;**864**;Aug 13, 1993;Build 15
;;Per VHA Directive 6402, this routine should not be modified
;
; Documented API's and Integration Agreements
; -------------------------------------------
; Reference to $$GET1^DIQ is supported by IA #2056
; ; Reference to ^DPT( is supported by IAs #7030,7029,1476,10035
;
Q ;No Direct Call
;
; The parameter list for this RPC must be kept in sync.
; If you need to add or remove a parameter, ensure that the Remote Procedure File #8994 definition is also updated.
;
GETAPPTYPES(RETURNJSON,SDCONTEXT,SDPARAM) ;Entry point
;
; 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.
;
; SDPARAM("APP TYPE STATUS")="A|I|B" Appointmet Type Status (optional)
; A - Active Only, I - Inactive only, B - Both Active and Inactive
; Default is Active only
;
;RETURN PARMETER:
;
; Output:
; Successful Return:
; RETURNJSON = Returns the list of Appointment Types from File 409.1 in JSON formatted string.
; Otherwise, JSON Errors will be returned for any invalid/missing parameters.
;
N ERRORS,RETURN ;temp data storage for input validation error
N SDAPPTSTATUS
;
K RETURNJSON ;always kill the return json array
;
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
I $D(ERRORS) S ERRORS("AppointmentTypes",1)="" D BUILDJSON^SDES2JSON(.RETURNJSON,.ERRORS) Q
D INITVAR(.SDPARAM,.SDAPPTSTATUS)
D VALINPUTPARAM(.ERRORS,SDAPPTSTATUS)
I $D(ERRORS) S ERRORS("AppointmentTypes",1)="" D BUILDJSON^SDES2JSON(.RETURNJSON,.ERRORS) Q
;
D APPTYPES(.RETURN,SDAPPTSTATUS) ; Return appropriate entries from APPOINTMENT TYPES FILE 409.1
D BUILDJSON^SDES2JSON(.RETURNJSON,.RETURN)
;
Q
;
INITVAR(PARAM,STATUS) ;
S STATUS=$S($G(PARAM("APP TYPE STATUS"))'="":PARAM("APP TYPE STATUS"),1:"A")
Q
;
VALINPUTPARAM(ERRORS,APPTSTATUS) ;
N T1
I APPTSTATUS="" D ERRLOG^SDES2JSON(.ERRORS,52,"Appointment Type status missing")
I APPTSTATUS'="" S T1=","_APPTSTATUS_","
I ",A,B,I,"']T1 D ERRLOG^SDES2JSON(.ERRORS,52,"Appointment Type status incorrect. Valid values are A, B, I")
Q
;
GETAPTYDFN(RETURNJSON,SDCONTEXT,SDPARAM) ;Entry point
; SDCONTEXT is the same as above
; SDPARAM("DFN")=DFN Patient (File #2) DFN used to show Appointment Types for this Patient (required)
;
;RETURN PARMETER:
; Output:
; Successful Return:
; RETURNJSON = Returns the list of Appointment Types from File 409.1 in JSON formatted string.
; Otherwise, JSON Errors will be returned for any invalid/missing parameters.
;
N ERRORS,RETURN,VRETURN
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
D VALFILEIEN^SDES2VALUTIL(.VRETURN,.ERRORS,2,$G(SDPARAM("DFN")),1,,1,2) ; Validate the Patient (file #2) DFN is correct
I $D(ERRORS) S ERRORS("AppointmentTypes",1)="" D BUILDJSON^SDES2JSON(.RETURNJSON,.ERRORS) Q
D DFNAPPTYPS(.RETURN,$G(SDPARAM("DFN"))) ; Return the active APPOINTMENT TYPES FILE 409.1 entries which the Patient DFN is eligible
D BUILDJSON^SDES2JSON(.RETURNJSON,.RETURN)
Q
;
APPTYPES(RET,APPTSTAT) ; EP for SDEC APPTYPES
;APPTYPES(RET,DFN) external parameter tag is in SDEC
; Return the different appointment types
N APTINACT,APTYIEN,APTYNAME,COUNT
S COUNT=0
S APTYIEN="" F S APTYIEN=$O(^SD(409.1,APTYIEN)) Q:'APTYIEN D
. S APTINACT=$$GET1^DIQ(409.1,APTYIEN,3,"I")
. I APPTSTAT="A" Q:APTINACT ; Quit if the INACTIVE [0;3] Field 3 is set and we want only Active APP TYPES
. I (APPTSTAT'="A")!(APPTSTAT'="B") Q:'APTINACT ; Quit if we only want the INACTIVE APP TYPES
. S COUNT=COUNT+1
. S RET("AppointmentTypes",COUNT,"AppTypeIEN")=APTYIEN
. S RET("AppointmentTypes",COUNT,"AppTypeName")=$$GET1^DIQ(409.1,APTYIEN,.01,"E")
;
Q
;
DFNAPPTYPS(RET,DFN) ; Return all the eligible active APPTYPES for a specific Patient DFN
N APTYDATA,APTYIEN,COUNT,SDEC,DUALELIG,DEFAULTELIG
N VAEL D ELIG^VADPT ; Get Patient Eligibility
S SDEC=$$GET1^DIQ(8,+VAEL(1),4,"I")
S COUNT=0
S APTYIEN=0 F S APTYIEN=$O(^SD(409.1,APTYIEN)) Q:'APTYIEN D
. Q:$$GET1^DIQ(409.1,APTYIEN,3,"I") ; Quit if the INACTIVE [0;3] Field 3 is set
. S DUALELIG=$$GET1^DIQ(409.1,APTYIEN,5,"I")
. S DEFAULTELIG=$$GET1^DIQ(409.1,APTYIEN,6,"I")
. I $S(SDEC["Y":1,1:DUALELIG),$S('DEFAULTELIG:1,$D(VAEL(1,+DEFAULTELIG)):1,+VAEL(1)=DEFAULTELIG:1,1:0) D
.. S COUNT=COUNT+1
.. S RET("AppointmentTypes",COUNT,"AppTypeIEN")=APTYIEN
.. S RET("AppointmentTypes",COUNT,"AppTypeName")=$$GET1^DIQ(409.1,APTYIEN,.01) ; $P(APTYDATA,U)
;
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2APPTYPES 5094 printed Dec 13, 2024@02:53:16 Page 2
SDES2APPTYPES ;ALB/TJB - VISTA SCHEDULING SDES2 GET APPOINTMENT TYPES RPC in APPOINTMENT TYPES FILE 409.1 ;October 11, 2023
+1 ;;5.3;Scheduling;**864**;Aug 13, 1993;Build 15
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Documented API's and Integration Agreements
+5 ; -------------------------------------------
+6 ; Reference to $$GET1^DIQ is supported by IA #2056
+7 ; ; Reference to ^DPT( is supported by IAs #7030,7029,1476,10035
+8 ;
+9 ;No Direct Call
QUIT
+10 ;
+11 ; The parameter list for this RPC must be kept in sync.
+12 ; If you need to add or remove a parameter, ensure that the Remote Procedure File #8994 definition is also updated.
+13 ;
GETAPPTYPES(RETURNJSON,SDCONTEXT,SDPARAM) ;Entry point
+1 ;
+2 ; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
+3 ; SDCONTEXT("PATIENT DFN") = The DFN/IEN of the target patient from the calling application.
+4 ; SDCONTEXT("PATIENT ICN") = The ICN of the target patient from the calling application.
+5 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action in the calling application.
+6 ; SDCONTEXT("USER SECID") = The SECID of the user taking action in the calling application.
+7 ;
+8 ; SDPARAM("APP TYPE STATUS")="A|I|B" Appointmet Type Status (optional)
+9 ; A - Active Only, I - Inactive only, B - Both Active and Inactive
+10 ; Default is Active only
+11 ;
+12 ;RETURN PARMETER:
+13 ;
+14 ; Output:
+15 ; Successful Return:
+16 ; RETURNJSON = Returns the list of Appointment Types from File 409.1 in JSON formatted string.
+17 ; Otherwise, JSON Errors will be returned for any invalid/missing parameters.
+18 ;
+19 ;temp data storage for input validation error
NEW ERRORS,RETURN
+20 NEW SDAPPTSTATUS
+21 ;
+22 ;always kill the return json array
KILL RETURNJSON
+23 ;
+24 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+25 IF $DATA(ERRORS)
SET ERRORS("AppointmentTypes",1)=""
DO BUILDJSON^SDES2JSON(.RETURNJSON,.ERRORS)
QUIT
+26 DO INITVAR(.SDPARAM,.SDAPPTSTATUS)
+27 DO VALINPUTPARAM(.ERRORS,SDAPPTSTATUS)
+28 IF $DATA(ERRORS)
SET ERRORS("AppointmentTypes",1)=""
DO BUILDJSON^SDES2JSON(.RETURNJSON,.ERRORS)
QUIT
+29 ;
+30 ; Return appropriate entries from APPOINTMENT TYPES FILE 409.1
DO APPTYPES(.RETURN,SDAPPTSTATUS)
+31 DO BUILDJSON^SDES2JSON(.RETURNJSON,.RETURN)
+32 ;
+33 QUIT
+34 ;
INITVAR(PARAM,STATUS) ;
+1 SET STATUS=$SELECT($GET(PARAM("APP TYPE STATUS"))'="":PARAM("APP TYPE STATUS"),1:"A")
+2 QUIT
+3 ;
VALINPUTPARAM(ERRORS,APPTSTATUS) ;
+1 NEW T1
+2 IF APPTSTATUS=""
DO ERRLOG^SDES2JSON(.ERRORS,52,"Appointment Type status missing")
+3 IF APPTSTATUS'=""
SET T1=","_APPTSTATUS_","
+4 IF ",A,B,I,"']T1
DO ERRLOG^SDES2JSON(.ERRORS,52,"Appointment Type status incorrect. Valid values are A, B, I")
+5 QUIT
+6 ;
GETAPTYDFN(RETURNJSON,SDCONTEXT,SDPARAM) ;Entry point
+1 ; SDCONTEXT is the same as above
+2 ; SDPARAM("DFN")=DFN Patient (File #2) DFN used to show Appointment Types for this Patient (required)
+3 ;
+4 ;RETURN PARMETER:
+5 ; Output:
+6 ; Successful Return:
+7 ; RETURNJSON = Returns the list of Appointment Types from File 409.1 in JSON formatted string.
+8 ; Otherwise, JSON Errors will be returned for any invalid/missing parameters.
+9 ;
+10 NEW ERRORS,RETURN,VRETURN
+11 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+12 ; Validate the Patient (file #2) DFN is correct
DO VALFILEIEN^SDES2VALUTIL(.VRETURN,.ERRORS,2,$GET(SDPARAM("DFN")),1,,1,2)
+13 IF $DATA(ERRORS)
SET ERRORS("AppointmentTypes",1)=""
DO BUILDJSON^SDES2JSON(.RETURNJSON,.ERRORS)
QUIT
+14 ; Return the active APPOINTMENT TYPES FILE 409.1 entries which the Patient DFN is eligible
DO DFNAPPTYPS(.RETURN,$GET(SDPARAM("DFN")))
+15 DO BUILDJSON^SDES2JSON(.RETURNJSON,.RETURN)
+16 QUIT
+17 ;
APPTYPES(RET,APPTSTAT) ; EP for SDEC APPTYPES
+1 ;APPTYPES(RET,DFN) external parameter tag is in SDEC
+2 ; Return the different appointment types
+3 NEW APTINACT,APTYIEN,APTYNAME,COUNT
+4 SET COUNT=0
+5 SET APTYIEN=""
FOR
SET APTYIEN=$ORDER(^SD(409.1,APTYIEN))
if 'APTYIEN
QUIT
Begin DoDot:1
+6 SET APTINACT=$$GET1^DIQ(409.1,APTYIEN,3,"I")
+7 ; Quit if the INACTIVE [0;3] Field 3 is set and we want only Active APP TYPES
IF APPTSTAT="A"
if APTINACT
QUIT
+8 ; Quit if we only want the INACTIVE APP TYPES
IF (APPTSTAT'="A")!(APPTSTAT'="B")
if 'APTINACT
QUIT
+9 SET COUNT=COUNT+1
+10 SET RET("AppointmentTypes",COUNT,"AppTypeIEN")=APTYIEN
+11 SET RET("AppointmentTypes",COUNT,"AppTypeName")=$$GET1^DIQ(409.1,APTYIEN,.01,"E")
End DoDot:1
+12 ;
+13 QUIT
+14 ;
DFNAPPTYPS(RET,DFN) ; Return all the eligible active APPTYPES for a specific Patient DFN
+1 NEW APTYDATA,APTYIEN,COUNT,SDEC,DUALELIG,DEFAULTELIG
+2 ; Get Patient Eligibility
NEW VAEL
DO ELIG^VADPT
+3 SET SDEC=$$GET1^DIQ(8,+VAEL(1),4,"I")
+4 SET COUNT=0
+5 SET APTYIEN=0
FOR
SET APTYIEN=$ORDER(^SD(409.1,APTYIEN))
if 'APTYIEN
QUIT
Begin DoDot:1
+6 ; Quit if the INACTIVE [0;3] Field 3 is set
if $$GET1^DIQ(409.1,APTYIEN,3,"I")
QUIT
+7 SET DUALELIG=$$GET1^DIQ(409.1,APTYIEN,5,"I")
+8 SET DEFAULTELIG=$$GET1^DIQ(409.1,APTYIEN,6,"I")
+9 IF $SELECT(SDEC["Y":1,1:DUALELIG)
IF $SELECT('DEFAULTELIG:1,$DATA(VAEL(1,+DEFAULTELIG)):1,+VAEL(1)=DEFAULTELIG:1,1:0)
Begin DoDot:2
+10 SET COUNT=COUNT+1
+11 SET RET("AppointmentTypes",COUNT,"AppTypeIEN")=APTYIEN
+12 ; $P(APTYDATA,U)
SET RET("AppointmentTypes",COUNT,"AppTypeName")=$$GET1^DIQ(409.1,APTYIEN,.01)
End DoDot:2
End DoDot:1
+13 ;
+14 QUIT