VPSAPPT2 ;SLOIFO/BT - VPS Appointment RPC;1/16/15 11:55
;;1.0;VA POINT OF SERVICE (KIOSKS);**5**;Jan 16, 2015;Build 31
;;Per VHA Directive 2004-038, this routine should not be modified.
;
; External Reference DBIA#
; ------------------------
; #10035 - ^DPT( references (Supported)
; #4433 - SDAMA301 call (Supported)
Q
;
GETCHG(VPSAPPT,VPSQUEUE) ; VPS GET CHANGED APPOINTMENTS
; This RPC will return the changed appointments on the queue since the last GET^VPSAPPT or GETCHG^VPSAPPT2 invoked
;
; INPUT
; VPSQUEUE : Unique Queue ID represents Vecna Appointment Queue.
; OUTPUT
; VPSAPPT : Name of Global array contains all retrieved appointments
; Output Format:
; ^TMP("VPSAPPT",$J,SEQ)=TODO^APPOINTMENT ID^RECORD FLAG#^FIELD NAME^FIELD VALUE
; TODO : instruct vecna to either Add, delete, update appointment and also notify for any error
; APPOINTMENT ID : represent appointment record in the VPS Appointment queue
; RECORD FLAG# : record flag number for patient (1..n) - use only for record flag field
; FIELD NAME : Field name
; FIELD VALUE : Field value
; Output Samples:
; ^TMP("VPSAPPT",$J,0)=ERR^^^PARAM^error message <--- notify Vecna for parameter error
; ^TMP("VPSAPPT",$J,SEQ)=ERR^99^^ERROR^error message <--- notify Vecna that there is an issue during adding/updating entry #99 to the queue
; ^TMP("VPSAPPT",$J,SEQ)=DEL^110 <--- notify Vecna to delete entry #110 from the queue
; ^TMP("VPSAPPT",$J,SEQ)=ADD^111^^<FIELD NAME>^FIELD VALUE <--- notify Vecna to add entry #111 to the queue with those field values
; ^TMP("VPSAPPT",$J,SEQ)=ADD^111^1^<FLAG FIELD NAME>^FIELD VALUE <--- notify Vecna to add record flag #1 to entry #111 to the queue
; ^TMP("VPSAPPT",$J,SEQ)=UPD^97^^^FIELD NAME^FIELD VALUE <--- notify Vecna to update entry #97 in the queue with those field values
;
; <FIELD NAME> is a member of
; CLINIC IEN^CLINIC NAME^APPT DATE
; DFN^PATIENT NAME^SSN^EMAIL
; APPT TYPE IEN^APPT TYPE NAME^APPT COMMENTS
; APPT STATUS IEN^APPT STATUS NAME^DISPLAYED STATUS
; BAD ADDRESS INDICATOR^BAD ADDRESS NAME
; SENSITIVE,BALANCE,ENROLLMENT STATUS,ENROLLMENT STATUS NAME
; PRE-REGISTRATION DATE CHANGED,ELIGIBILITY STATUS,ELIGIBILITY STATUS NAME
; INELIGIBLE DATE^MEANS TEST STATUS^INSURANCE
; <FLAG FIELD NAME> is a member of (FLAG ORIGINATION^FLAG TYPE^FLAG NAME^FLAG NARRATIVE")
;
S VPSAPPT=$NA(^TMP("VPSAPPT",$J)) K @VPSAPPT
K ^TMP($J,"SDAMA301")
;
I $G(VPSQUEUE)="" D ADDERR^VPSAPPT("ERR^^^PARAM^QUEUE ID IS REQUIRED") QUIT
;
N CNT S CNT=$$POPAPPTS(VPSQUEUE) ;populate result array with new appointment and updated appointments
I CNT D
. D UPDQUEUE(VPSQUEUE) ; add new appointments or update modified appointments
. D RMVAPPTS(VPSQUEUE) ; remove appointments from queue if appointments are no longer exist
;
K ^TMP($J,"SDAMA301")
QUIT
;
POPAPPTS(QUEUEID) ;populate result array with new appointment and updated appointments
; INPUT
; QUEUEID : Unique Queue ID represents Vecna Appointment Queue.
;
; -- get from, through date for the queue.
N QINFO D GETS^DIQ(853.9,QUEUEID_",","1;2","I","QINFO")
N FRMDT S FRMDT=$G(QINFO(853.9,QUEUEID_",",1,"I"))
N THRDT S THRDT=$G(QINFO(853.9,QUEUEID_",",2,"I"))
I 'FRMDT!'THRDT D ADDERR^VPSAPPT("ERR^^^GET^QUEUE has not been initialized.") QUIT 0
;
; -- populate ^TMP($J,"SDAMA301") using supported API given appointment from - through date
QUIT $$POPAPPTS^VPSAPPT(FRMDT,THRDT)
;
UPDQUEUE(QUEUEID) ; add new appointments or update modified appointments
N APPT,APPTINFO,APPTDT,TODO
N CLIEN S CLIEN=0
F S CLIEN=$O(^TMP($J,"SDAMA301",CLIEN)) Q:'CLIEN D
. N DFN S DFN=0
. F S DFN=$O(^TMP($J,"SDAMA301",CLIEN,DFN)) Q:'DFN D:$D(^DPT(DFN,0))
. . S APPTDT=0
. . F S APPTDT=$O(^TMP($J,"SDAMA301",CLIEN,DFN,APPTDT)) Q:'APPTDT D
. . . S APPTINFO=$G(^TMP($J,"SDAMA301",CLIEN,DFN,APPTDT))
. . . K APPT D GETAPPT^VPSAPPT(.APPT,APPTINFO)
. . . S TODO=$$UPDATE(QUEUEID,.APPT) ; update the appointment in temporary storage (File #853.9)
. . . D:TODO'="" ADDTMP^VPSAPPT(TODO,QUEUEID,.APPT) ; add the updated appointment to result array
QUIT
;
UPDATE(QUEUEID,APPT) ; update the appointment in temporary storage (File #853.9)
; INPUT
; QUEUEID : Unique Queue ID represents Vecna Appointment Queue.
; APPTINFO : Extended appointment information for Vecna to display in the queue
; CLINIC IEN^CLINIC NAME^APPT DATE^DFN^PATIENT NAME^SSN^APPT TYPE IEN^APPT TYPE NAME^STATUS IEN^STATUS NAME^PRINTED STATUS
; RETURN
; TODO : "" (no changed - nothing todo)
; : "ADD" (instruct vecna to add the appointment to the queue)
; : "UPD" (instruct vecna to update the appointment in the queue)
; : "ERR" (notify vecna there is error during add/change appointment)
;
N TODO S TODO="" ;nothing is changed
N CLIEN S CLIEN=APPT("CLINIC IEN")
N APPTDT S APPTDT=APPT("APPT DATE/TIME")
N DFN S DFN=APPT("DFN")
N APPTIEN S APPTIEN=$$GETIEN^VPSAPPT(QUEUEID,CLIEN,APPTDT,DFN) ; return the IEN for sub file 853.91 record
;
; -- Not in the queue, add the new appointment
I 'APPTIEN D
. S TODO=$$ADDAPPT^VPSAPPT(QUEUEID,.APPT) ;new appointment
;
; -- update the existing appointment if status or type is changed
I APPTIEN D
. N SAVAPPT S SAVAPPT=$G(^VPS(853.9,QUEUEID,1,APPTIEN,0))
. N CURAPPT S CURAPPT=CLIEN_U_APPTDT_U_DFN_U_APPT("APPT TYPE IEN")_U_APPT("DISPLAYED APPT STATUS")
. I SAVAPPT'=CURAPPT S TODO=$$UPDAPPT(QUEUEID,APPTIEN,CURAPPT) ;update appointment status/type changed
QUIT TODO
;
UPDAPPT(QUEUEID,APPTIEN,APPTINFO) ;update appointment status/type changed
; INPUT
; QUEUEID : Unique Queue ID represents Vecna Appointment Queue.
; APPTIEN : Appointment ien in the queue
; APPTINFO : Appointment information in the queue file 853.9
; CLINIC IEN^APPT DATE^DFN^APPT TYPE IEN^PRINTED STATUS
; RETURN
; TODO : "UPD" (instruct vecna to update the appointment in the queue)
; : "ERR" (notify vecna there is error during add/change appointment)
;
N TODO S TODO="UPD"
N VPSFDA
S VPSFDA(853.91,APPTIEN_","_QUEUEID_",",3)=$P(APPTINFO,U,4) ;appt type ien
S VPSFDA(853.91,APPTIEN_","_QUEUEID_",",4)=$P(APPTINFO,U,5) ;displayed version of appt status name
N VPSERR D FILE^DIE("E","VPSFDA","VPSERR")
I $D(DIERR) S TODO="ERR"_U_VPSERR("DIERR",1,"TEXT",1)
K DIERR,VPSFDA,VPSERR
QUIT TODO
;
RMVAPPTS(QUEUEID) ;remove appointment from queue if appointmentsd are no longer existed
N APPTIEN S APPTIEN=0
F S APPTIEN=$O(^VPS(853.9,QUEUEID,1,APPTIEN)) QUIT:'APPTIEN D
. N APPTINFO S APPTINFO=^VPS(853.9,QUEUEID,1,APPTIEN,0)
. N CLIEN S CLIEN=$P(APPTINFO,U)
. N APPTDT S APPTDT=$P(APPTINFO,U,2)
. N DFN S DFN=$P(APPTINFO,U,3)
. I '$D(^TMP($J,"SDAMA301",CLIEN,DFN,APPTDT)) D
. . D DELAPPT(QUEUEID,APPTIEN) ;delete temp appointment queue to reflect current appointments
. . D ADDDEL(APPTIEN) ;tell vecna to remove the entry
QUIT
;
DELAPPT(QUEUEID,APPTIEN) ;delete temp appointment from the queue to reflect current appointments
; INPUT
; QUEUEID : Unique Queue ID represents Vecna Appointment Queue.
; APPTIEN : Appointment ien in the queue
;
N DA S DA(1)=QUEUEID,DA=APPTIEN
N DIK S DIK="^VPS(853.9,"_DA(1)_",1,"
D ^DIK
K DIK
QUIT
;
ADDDEL(APPTIEN) ;notify vecna to remove the entry from the Vecna's VPS appointment queue
; INPUT
; APPTIEN : Appointment ien in the queue
;
N SEQ S SEQ=$O(^TMP("VPSAPPT",$J," "),-1)+1
S ^TMP("VPSAPPT",$J,SEQ)="DEL"_U_APPTIEN ;save appointment into result global array
QUIT
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVPSAPPT2 7879 printed Nov 22, 2024@17:52:52 Page 2
VPSAPPT2 ;SLOIFO/BT - VPS Appointment RPC;1/16/15 11:55
+1 ;;1.0;VA POINT OF SERVICE (KIOSKS);**5**;Jan 16, 2015;Build 31
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 ; External Reference DBIA#
+5 ; ------------------------
+6 ; #10035 - ^DPT( references (Supported)
+7 ; #4433 - SDAMA301 call (Supported)
+8 QUIT
+9 ;
GETCHG(VPSAPPT,VPSQUEUE) ; VPS GET CHANGED APPOINTMENTS
+1 ; This RPC will return the changed appointments on the queue since the last GET^VPSAPPT or GETCHG^VPSAPPT2 invoked
+2 ;
+3 ; INPUT
+4 ; VPSQUEUE : Unique Queue ID represents Vecna Appointment Queue.
+5 ; OUTPUT
+6 ; VPSAPPT : Name of Global array contains all retrieved appointments
+7 ; Output Format:
+8 ; ^TMP("VPSAPPT",$J,SEQ)=TODO^APPOINTMENT ID^RECORD FLAG#^FIELD NAME^FIELD VALUE
+9 ; TODO : instruct vecna to either Add, delete, update appointment and also notify for any error
+10 ; APPOINTMENT ID : represent appointment record in the VPS Appointment queue
+11 ; RECORD FLAG# : record flag number for patient (1..n) - use only for record flag field
+12 ; FIELD NAME : Field name
+13 ; FIELD VALUE : Field value
+14 ; Output Samples:
+15 ; ^TMP("VPSAPPT",$J,0)=ERR^^^PARAM^error message <--- notify Vecna for parameter error
+16 ; ^TMP("VPSAPPT",$J,SEQ)=ERR^99^^ERROR^error message <--- notify Vecna that there is an issue during adding/updating entry #99 to the queue
+17 ; ^TMP("VPSAPPT",$J,SEQ)=DEL^110 <--- notify Vecna to delete entry #110 from the queue
+18 ; ^TMP("VPSAPPT",$J,SEQ)=ADD^111^^<FIELD NAME>^FIELD VALUE <--- notify Vecna to add entry #111 to the queue with those field values
+19 ; ^TMP("VPSAPPT",$J,SEQ)=ADD^111^1^<FLAG FIELD NAME>^FIELD VALUE <--- notify Vecna to add record flag #1 to entry #111 to the queue
+20 ; ^TMP("VPSAPPT",$J,SEQ)=UPD^97^^^FIELD NAME^FIELD VALUE <--- notify Vecna to update entry #97 in the queue with those field values
+21 ;
+22 ; <FIELD NAME> is a member of
+23 ; CLINIC IEN^CLINIC NAME^APPT DATE
+24 ; DFN^PATIENT NAME^SSN^EMAIL
+25 ; APPT TYPE IEN^APPT TYPE NAME^APPT COMMENTS
+26 ; APPT STATUS IEN^APPT STATUS NAME^DISPLAYED STATUS
+27 ; BAD ADDRESS INDICATOR^BAD ADDRESS NAME
+28 ; SENSITIVE,BALANCE,ENROLLMENT STATUS,ENROLLMENT STATUS NAME
+29 ; PRE-REGISTRATION DATE CHANGED,ELIGIBILITY STATUS,ELIGIBILITY STATUS NAME
+30 ; INELIGIBLE DATE^MEANS TEST STATUS^INSURANCE
+31 ; <FLAG FIELD NAME> is a member of (FLAG ORIGINATION^FLAG TYPE^FLAG NAME^FLAG NARRATIVE")
+32 ;
+33 SET VPSAPPT=$NAME(^TMP("VPSAPPT",$JOB))
KILL @VPSAPPT
+34 KILL ^TMP($JOB,"SDAMA301")
+35 ;
+36 IF $GET(VPSQUEUE)=""
DO ADDERR^VPSAPPT("ERR^^^PARAM^QUEUE ID IS REQUIRED")
QUIT
+37 ;
+38 ;populate result array with new appointment and updated appointments
NEW CNT
SET CNT=$$POPAPPTS(VPSQUEUE)
+39 IF CNT
Begin DoDot:1
+40 ; add new appointments or update modified appointments
DO UPDQUEUE(VPSQUEUE)
+41 ; remove appointments from queue if appointments are no longer exist
DO RMVAPPTS(VPSQUEUE)
End DoDot:1
+42 ;
+43 KILL ^TMP($JOB,"SDAMA301")
+44 QUIT
+45 ;
POPAPPTS(QUEUEID) ;populate result array with new appointment and updated appointments
+1 ; INPUT
+2 ; QUEUEID : Unique Queue ID represents Vecna Appointment Queue.
+3 ;
+4 ; -- get from, through date for the queue.
+5 NEW QINFO
DO GETS^DIQ(853.9,QUEUEID_",","1;2","I","QINFO")
+6 NEW FRMDT
SET FRMDT=$GET(QINFO(853.9,QUEUEID_",",1,"I"))
+7 NEW THRDT
SET THRDT=$GET(QINFO(853.9,QUEUEID_",",2,"I"))
+8 IF 'FRMDT!'THRDT
DO ADDERR^VPSAPPT("ERR^^^GET^QUEUE has not been initialized.")
QUIT 0
+9 ;
+10 ; -- populate ^TMP($J,"SDAMA301") using supported API given appointment from - through date
+11 QUIT $$POPAPPTS^VPSAPPT(FRMDT,THRDT)
+12 ;
UPDQUEUE(QUEUEID) ; add new appointments or update modified appointments
+1 NEW APPT,APPTINFO,APPTDT,TODO
+2 NEW CLIEN
SET CLIEN=0
+3 FOR
SET CLIEN=$ORDER(^TMP($JOB,"SDAMA301",CLIEN))
if 'CLIEN
QUIT
Begin DoDot:1
+4 NEW DFN
SET DFN=0
+5 FOR
SET DFN=$ORDER(^TMP($JOB,"SDAMA301",CLIEN,DFN))
if 'DFN
QUIT
if $DATA(^DPT(DFN,0))
Begin DoDot:2
+6 SET APPTDT=0
+7 FOR
SET APPTDT=$ORDER(^TMP($JOB,"SDAMA301",CLIEN,DFN,APPTDT))
if 'APPTDT
QUIT
Begin DoDot:3
+8 SET APPTINFO=$GET(^TMP($JOB,"SDAMA301",CLIEN,DFN,APPTDT))
+9 KILL APPT
DO GETAPPT^VPSAPPT(.APPT,APPTINFO)
+10 ; update the appointment in temporary storage (File #853.9)
SET TODO=$$UPDATE(QUEUEID,.APPT)
+11 ; add the updated appointment to result array
if TODO'=""
DO ADDTMP^VPSAPPT(TODO,QUEUEID,.APPT)
End DoDot:3
End DoDot:2
End DoDot:1
+12 QUIT
+13 ;
UPDATE(QUEUEID,APPT) ; update the appointment in temporary storage (File #853.9)
+1 ; INPUT
+2 ; QUEUEID : Unique Queue ID represents Vecna Appointment Queue.
+3 ; APPTINFO : Extended appointment information for Vecna to display in the queue
+4 ; CLINIC IEN^CLINIC NAME^APPT DATE^DFN^PATIENT NAME^SSN^APPT TYPE IEN^APPT TYPE NAME^STATUS IEN^STATUS NAME^PRINTED STATUS
+5 ; RETURN
+6 ; TODO : "" (no changed - nothing todo)
+7 ; : "ADD" (instruct vecna to add the appointment to the queue)
+8 ; : "UPD" (instruct vecna to update the appointment in the queue)
+9 ; : "ERR" (notify vecna there is error during add/change appointment)
+10 ;
+11 ;nothing is changed
NEW TODO
SET TODO=""
+12 NEW CLIEN
SET CLIEN=APPT("CLINIC IEN")
+13 NEW APPTDT
SET APPTDT=APPT("APPT DATE/TIME")
+14 NEW DFN
SET DFN=APPT("DFN")
+15 ; return the IEN for sub file 853.91 record
NEW APPTIEN
SET APPTIEN=$$GETIEN^VPSAPPT(QUEUEID,CLIEN,APPTDT,DFN)
+16 ;
+17 ; -- Not in the queue, add the new appointment
+18 IF 'APPTIEN
Begin DoDot:1
+19 ;new appointment
SET TODO=$$ADDAPPT^VPSAPPT(QUEUEID,.APPT)
End DoDot:1
+20 ;
+21 ; -- update the existing appointment if status or type is changed
+22 IF APPTIEN
Begin DoDot:1
+23 NEW SAVAPPT
SET SAVAPPT=$GET(^VPS(853.9,QUEUEID,1,APPTIEN,0))
+24 NEW CURAPPT
SET CURAPPT=CLIEN_U_APPTDT_U_DFN_U_APPT("APPT TYPE IEN")_U_APPT("DISPLAYED APPT STATUS")
+25 ;update appointment status/type changed
IF SAVAPPT'=CURAPPT
SET TODO=$$UPDAPPT(QUEUEID,APPTIEN,CURAPPT)
End DoDot:1
+26 QUIT TODO
+27 ;
UPDAPPT(QUEUEID,APPTIEN,APPTINFO) ;update appointment status/type changed
+1 ; INPUT
+2 ; QUEUEID : Unique Queue ID represents Vecna Appointment Queue.
+3 ; APPTIEN : Appointment ien in the queue
+4 ; APPTINFO : Appointment information in the queue file 853.9
+5 ; CLINIC IEN^APPT DATE^DFN^APPT TYPE IEN^PRINTED STATUS
+6 ; RETURN
+7 ; TODO : "UPD" (instruct vecna to update the appointment in the queue)
+8 ; : "ERR" (notify vecna there is error during add/change appointment)
+9 ;
+10 NEW TODO
SET TODO="UPD"
+11 NEW VPSFDA
+12 ;appt type ien
SET VPSFDA(853.91,APPTIEN_","_QUEUEID_",",3)=$PIECE(APPTINFO,U,4)
+13 ;displayed version of appt status name
SET VPSFDA(853.91,APPTIEN_","_QUEUEID_",",4)=$PIECE(APPTINFO,U,5)
+14 NEW VPSERR
DO FILE^DIE("E","VPSFDA","VPSERR")
+15 IF $DATA(DIERR)
SET TODO="ERR"_U_VPSERR("DIERR",1,"TEXT",1)
+16 KILL DIERR,VPSFDA,VPSERR
+17 QUIT TODO
+18 ;
RMVAPPTS(QUEUEID) ;remove appointment from queue if appointmentsd are no longer existed
+1 NEW APPTIEN
SET APPTIEN=0
+2 FOR
SET APPTIEN=$ORDER(^VPS(853.9,QUEUEID,1,APPTIEN))
if 'APPTIEN
QUIT
Begin DoDot:1
+3 NEW APPTINFO
SET APPTINFO=^VPS(853.9,QUEUEID,1,APPTIEN,0)
+4 NEW CLIEN
SET CLIEN=$PIECE(APPTINFO,U)
+5 NEW APPTDT
SET APPTDT=$PIECE(APPTINFO,U,2)
+6 NEW DFN
SET DFN=$PIECE(APPTINFO,U,3)
+7 IF '$DATA(^TMP($JOB,"SDAMA301",CLIEN,DFN,APPTDT))
Begin DoDot:2
+8 ;delete temp appointment queue to reflect current appointments
DO DELAPPT(QUEUEID,APPTIEN)
+9 ;tell vecna to remove the entry
DO ADDDEL(APPTIEN)
End DoDot:2
End DoDot:1
+10 QUIT
+11 ;
DELAPPT(QUEUEID,APPTIEN) ;delete temp appointment from the queue to reflect current appointments
+1 ; INPUT
+2 ; QUEUEID : Unique Queue ID represents Vecna Appointment Queue.
+3 ; APPTIEN : Appointment ien in the queue
+4 ;
+5 NEW DA
SET DA(1)=QUEUEID
SET DA=APPTIEN
+6 NEW DIK
SET DIK="^VPS(853.9,"_DA(1)_",1,"
+7 DO ^DIK
+8 KILL DIK
+9 QUIT
+10 ;
ADDDEL(APPTIEN) ;notify vecna to remove the entry from the Vecna's VPS appointment queue
+1 ; INPUT
+2 ; APPTIEN : Appointment ien in the queue
+3 ;
+4 NEW SEQ
SET SEQ=$ORDER(^TMP("VPSAPPT",$JOB," "),-1)+1
+5 ;save appointment into result global array
SET ^TMP("VPSAPPT",$JOB,SEQ)="DEL"_U_APPTIEN
+6 QUIT