source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDAMA204.m@ 1361

Last change on this file since 1361 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

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