SDAMA204 ;BPOIFO/NDH-Scheduling Replacement APIs ; 12/13/04 3:16pm
;;5.3;Scheduling;**310,347,1015**;13 Aug 1993;Build 21
;
;PATAPPT - Determines if an appointment exists for a patient.
;
;** BEFORE USING THE API IN THIS ROUTINE, PLEASE SUBSCRIBE **
;** TO DBIA #4216 **
;
;*****************************************************************
; CHANGE LOG
;
; DATE PATCH DESCRIPTION
;-------- ---------- -----------------------------------------
;08/11/03 SD*5.3*310 API PATIENT APPOINTMENT EXISTS
;07/26/04 SD*5.3*347 API Patient Appointment supports distributed
; appointment files (whether actual files are
; located in VistA DB or Oracle DB).
;
;*****************************************************************
;
PATAPPT(SDDFN) ; Check for existence of any appointment for a patient
;
; This API is an extrinsic function that returns 1 of 3 values.
; The API checks for the existence of appointment records.
;
; INPUT SDDFN : Patient's DFN number (required)
;
; OUTPUT 1 : Appointment(s) on file
; 0 : No appointment(s) on file
; -1 : Error
;
; ERROR CODES - 101 : Database is Unavailable
; 102 : Patient ID is required
; 110 : Patient ID must be numeric
; 114 : Invalid Patient ID
; 117 : SDAPI Error
;
; ERROR LOCATION : ^TMP($J,"SDAMA204","PATAPPT","ERROR")
;
; Check for proper parameter and return -1 if bad DFN
;
; Initialize node for error reporting
K ^TMP($J,"SDAMA204","PATAPPT")
N SDARRAY,SDCOUNT,SDX,SDY,DFN,VAERR
;
; Check for no input parameter
I '$D(SDDFN) D Q -1
.D ERROR^SDAMA200(102,"PATAPPT",0,"SDAMA204")
; Check if SDDFN is numeric
I SDDFN'?1.N D Q -1
.D ERROR^SDAMA200(110,"PATAPPT",0,"SDAMA204")
; Check if DFN exists or is 0
S DFN=SDDFN
D DEM^VADPT
I SDDFN=0!VAERR=1 D Q -1
.D ERROR^SDAMA200(114,"PATAPPT",0,"SDAMA204")
D KVAR^VADPT
; Check for patient appointments and return 1 if appointment found
; and 0 if no appointments found.
;
S SDARRAY(4)=DFN,SDARRAY("FLDS")=1,SDARRAY("MAX")=1
S SDCOUNT=$$SDAPI^SDAMA301(.SDARRAY)
I SDCOUNT=0 Q 0 ; No Appt found.
I SDCOUNT=1 K ^TMP($J,"SDAMA301") Q 1 ; Appt(s). found.
; Error Encountered.
I SDCOUNT=-1 D
.S SDX=$O(^TMP($J,"SDAMA301",""))
.S SDX=$S(SDX=101:101,SDX=115:114,SDX=116:114,1:117)
.D ERROR^SDAMA200(SDX,"PATAPPT",0,"SDAMA204")
.K ^TMP($J,"SDAMA301")
Q -1
SDAMA204 ;BPOIFO/NDH-Scheduling Replacement APIs ; 12/13/04 3:16pm
+1 ;;5.3;Scheduling;**310,347,1015**;13 Aug 1993;Build 21
+2 ;
+3 ;PATAPPT - Determines if an appointment exists for a patient.
+4 ;
+5 ;** BEFORE USING THE API IN THIS ROUTINE, PLEASE SUBSCRIBE **
+6 ;** TO DBIA #4216 **
+7 ;
+8 ;*****************************************************************
+9 ; CHANGE LOG
+10 ;
+11 ; DATE PATCH DESCRIPTION
+12 ;-------- ---------- -----------------------------------------
+13 ;08/11/03 SD*5.3*310 API PATIENT APPOINTMENT EXISTS
+14 ;07/26/04 SD*5.3*347 API Patient Appointment supports distributed
+15 ; appointment files (whether actual files are
+16 ; located in VistA DB or Oracle DB).
+17 ;
+18 ;*****************************************************************
+19 ;
PATAPPT(SDDFN) ; Check for existence of any appointment for a patient
+1 ;
+2 ; This API is an extrinsic function that returns 1 of 3 values.
+3 ; The API checks for the existence of appointment records.
+4 ;
+5 ; INPUT SDDFN : Patient's DFN number (required)
+6 ;
+7 ; OUTPUT 1 : Appointment(s) on file
+8 ; 0 : No appointment(s) on file
+9 ; -1 : Error
+10 ;
+11 ; ERROR CODES - 101 : Database is Unavailable
+12 ; 102 : Patient ID is required
+13 ; 110 : Patient ID must be numeric
+14 ; 114 : Invalid Patient ID
+15 ; 117 : SDAPI Error
+16 ;
+17 ; ERROR LOCATION : ^TMP($J,"SDAMA204","PATAPPT","ERROR")
+18 ;
+19 ; Check for proper parameter and return -1 if bad DFN
+20 ;
+21 ; Initialize node for error reporting
+22 KILL ^TMP($JOB,"SDAMA204","PATAPPT")
+23 NEW SDARRAY,SDCOUNT,SDX,SDY,DFN,VAERR
+24 ;
+25 ; Check for no input parameter
+26 IF '$DATA(SDDFN)
Begin DoDot:1
+27 DO ERROR^SDAMA200(102,"PATAPPT",0,"SDAMA204")
End DoDot:1
QUIT -1
+28 ; Check if SDDFN is numeric
+29 IF SDDFN'?1.N
Begin DoDot:1
+30 DO ERROR^SDAMA200(110,"PATAPPT",0,"SDAMA204")
End DoDot:1
QUIT -1
+31 ; Check if DFN exists or is 0
+32 SET DFN=SDDFN
+33 DO DEM^VADPT
+34 IF SDDFN=0!VAERR=1
Begin DoDot:1
+35 DO ERROR^SDAMA200(114,"PATAPPT",0,"SDAMA204")
End DoDot:1
QUIT -1
+36 DO KVAR^VADPT
+37 ; Check for patient appointments and return 1 if appointment found
+38 ; and 0 if no appointments found.
+39 ;
+40 SET SDARRAY(4)=DFN
SET SDARRAY("FLDS")=1
SET SDARRAY("MAX")=1
+41 SET SDCOUNT=$$SDAPI^SDAMA301(.SDARRAY)
+42 ; No Appt found.
IF SDCOUNT=0
QUIT 0
+43 ; Appt(s). found.
IF SDCOUNT=1
KILL ^TMP($JOB,"SDAMA301")
QUIT 1
+44 ; Error Encountered.
+45 IF SDCOUNT=-1
Begin DoDot:1
+46 SET SDX=$ORDER(^TMP($JOB,"SDAMA301",""))
+47 SET SDX=$SELECT(SDX=101:101,SDX=115:114,SDX=116:114,1:117)
+48 DO ERROR^SDAMA200(SDX,"PATAPPT",0,"SDAMA204")
+49 KILL ^TMP($JOB,"SDAMA301")
End DoDot:1
+50 QUIT -1