source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDAMA202.m@ 1005

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

initial load of WorldVistAEHR

File size: 4.9 KB
Line 
1SDAMA202 ;BPOIFO/ACS-Scheduling Replacement APIs ; 12/13/04 3:15pm
2 ;;5.3;Scheduling;**253,275,283,316,347**;13 Aug 1993
3 ;
4 ;GETPLIST - Returns appointment information for a clinic
5 ;
6 ;** BEFORE USING THE API IN THIS ROUTINE, PLEASE SUBSCRIBE **
7 ;** TO DBIA #3869 **
8 ;
9 ;*******************************************************************
10 ; CHANGE LOG
11 ;
12 ; DATE PATCH DESCRIPTION
13 ;-------- ---------- -----------------------------------------
14 ;09/20/02 SD*5.3*253 ROUTINE COMPLETED
15 ;12/10/02 SD*5.3*275 ADDED PATIENT STATUS FILTER
16 ;07/03/03 SD*5.3*283 REMOVED 'NO ACTION TAKEN' EDIT. REMOVED
17 ; 'GETALLCL' API
18 ;09/16/03 SD*5.3*316 EXCLUDE 'CANCELLED' APPTS. CHECK FOR
19 ; CLINIC MATCH ON ^DPT
20 ;07/26/04 SD*5.3*347 ADDED PATIENT VARIABLE CHECK TO ENSURE THAT
21 ; VALUE RETURNED FROM $$GETPTIEN^SDAMA200 IS
22 ; NOT NULL
23 ; REMOVE DIRECT ACCESS TO DATA. ALL ACCESS
24 ; THROUGH SDAPI ONLY
25 ;********************************************************************
26 ;
27GETPLIST(SDCLIEN,SDFIELDS,SDAPSTAT,SDSTART,SDEND,SDRESULT,SDIOSTAT) ;
28 ;********************************************************************
29 ;
30 ; GET APPOINTMENTS FOR A CLINIC
31 ;
32 ;INPUT
33 ; SDCLIEN Clinic IEN (required)
34 ; SDFIELDS Fields requested (optional)
35 ; SDAPSTAT Appointment Status filter (optional)
36 ; SDSTART Start date/time (optional)
37 ; SDEND End date/time (optional)
38 ; SDRESULT Record count returned here (optional)
39 ; SDIOSTAT Patient Status filter (optional)
40 ;
41 ;OUTPUT
42 ; ^TMP($J,"SDAMA202","GETPLIST",X,Y)=FieldYdata
43 ; where "X" is an incremental appointment counter and
44 ; "Y" is the field number requested
45 ;
46 ;
47 ;********************************************************************
48 N SDAPINAM,SDRTNNAM
49 S SDAPINAM="GETPLIST",SDRTNNAM="SDAMA202",SDRESULT=0
50 K ^TMP($J,SDRTNNAM,SDAPINAM)
51 S SDRESULT=$$VALIDATE^SDAMA200(.SDCLIEN,.SDFIELDS,.SDAPSTAT,.SDSTART,.SDEND,SDAPINAM,SDRTNNAM,.SDIOSTAT)
52 I SDRESULT=-1 Q
53 ;
54 N SDCOUNT,SDNUM,SDTMP,SDI,SDARRAY,SDAPLST,SDX,SDY,SDCI,SDPI,SDTI,SDTR,SDF,SDA,SDR,SDO
55 S (SDNUM,SDCOUNT,SDI)=0,(SDAPLST,SDTMP)=""
56 F SDI="SDFIELDS","SDAPSTAT","SDSTART","SDEND","SDRESULT","SDIOSTAT" S @SDI=$G(@SDI)
57 ; Quit if only status requested is "C"
58 I SDAPSTAT="C"!(SDAPSTAT=";C;") S SDRESULT=0 Q
59 I +SDSTART!(+SDEND) S SDARRAY(1)=SDSTART_";"_SDEND
60 S SDARRAY(2)=SDCLIEN
61 I $L($G(SDAPSTAT))>0 D
62 . ;Remove a leading and a trailing semicolon
63 . I $E(SDAPSTAT,$L(SDAPSTAT))=";" S SDAPSTAT=$E(SDAPSTAT,1,($L(SDAPSTAT)-1))
64 . I $E(SDAPSTAT)=";" S SDAPSTAT=$E(SDAPSTAT,2,$L(SDAPSTAT))
65 . ;IO/Appt Statuses have been validated by SDAMA200 to be I or O/R NT
66 . I $L($G(SDIOSTAT))=1 S SDAPLST=$S(SDIOSTAT="I":"I;",SDIOSTAT="O":SDAPSTAT_";")
67 . I $L($G(SDIOSTAT))'=1,$L($G(SDAPSTAT)) D
68 .. ;Reset appointment status R=R;I N=NS,NSR
69 .. S SDNUM=$L(SDAPSTAT,";") F SDI=1:1:SDNUM D
70 ... S SDTMP=$P(SDAPSTAT,";",SDI) Q:SDTMP="C"
71 ... S SDTMP=$S(SDTMP="R":"R;I",SDTMP="N":"NS;NSR",1:SDTMP)
72 ... S SDAPLST=SDAPLST_SDTMP_";"
73 . ;Remove trailing semicolon
74 . S SDAPLST=$E(SDAPLST,1,($L(SDAPLST)-1))
75 I $L($G(SDAPSTAT))=0 S SDAPLST="R;I;NS;NSR;NT"
76 S SDARRAY(3)=SDAPLST
77 ;Field List Conversion
78 S SDARRAY("FLDS")=""
79 F SDX=1:1 S SDY=$P(SDFIELDS,";",SDX) Q:SDY="" D
80 . I SDY=12,SDFIELDS[3 Q ; if appt. stat. exists, pat. stat. not needed
81 . I SDY=12 S SDY=3
82 . S SDARRAY("FLDS")=SDARRAY("FLDS")_SDY_";"
83 S:$L(SDARRAY("FLDS")) SDARRAY("FLDS")=$E(SDARRAY("FLDS"),1,$L(SDARRAY("FLDS"))-1)
84 I '$L(SDFIELDS) S SDARRAY("FLDS")="1;2;3;4;5;6;7;8;9;10;11"
85 ;
86 ; Setup done, call SDAPI, quit if no appointment (SDCOUNT=0) and return 0
87SDAPI S (SDRESULT,SDCOUNT)=$$SDAPI^SDAMA301(.SDARRAY) I SDCOUNT=0 S SDRESULT=0 Q
88 ;
89 ;If we have an appointment, process it
90 I SDCOUNT>0 S SDA=0,SDCI="" F S SDCI=$O(^TMP($J,"SDAMA301",SDCI)) Q:SDCI="" D
91 . S SDPI="" F S SDPI=$O(^TMP($J,"SDAMA301",SDCI,SDPI)) Q:SDPI="" D
92 .. S SDTI="" F S SDTI=$O(^TMP($J,"SDAMA301",SDCI,SDPI,SDTI)) Q:SDTI="" S SDTR=^(SDTI) D
93 ... S SDA=SDA+1 F SDX=1:1 S SDF=$P(SDFIELDS,";",SDX),SDY=$P(SDTR,"^",SDF) Q:SDF="" D
94 .... I "^1^5^9^11^"[(U_SDF_U) S SDO=SDY D OUT Q
95 .... I "^2^4^8^10^"[(U_SDF_U) S SDO=$TR(SDY,";","^") D OUT Q
96 .... I "^3^6^7^12^"[(U_SDF_U) D @("FLD"_SDF)
97 ; Process errors if any
98 I SDCOUNT<0 D
99 .S SDRESULT=-1,SDX=$O(^TMP($J,"SDAMA301",""))
100 .S SDX=$S(SDX=101:101,SDX=116:116,1:117)
101 .D ERROR^SDAMA200(SDX,SDAPINAM,0,SDRTNNAM) Q
102 K ^TMP($J,"SDAMA301")
103 Q
104FLD3 S SDR=$P(SDY,";",1)
105 S SDO=$S(SDR="I":"R",SDR?1(1"NS",1"NSR"):"N",1:SDR) D OUT
106 Q
107FLD6 S SDO=$G(^TMP($J,"SDAMA301",SDCI,SDPI,SDTI,"C"))
108 D OUT
109 Q
110FLD7 S SDO=$S(SDY="":"N",1:SDY)
111 D OUT
112 Q
113FLD12 S SDR=$P($P(SDTR,U,3),";",1)
114 S SDO=$S(SDR="I":"I",SDR="R":"O",SDR="NT":"O",1:"") D OUT
115 Q
116OUT S ^TMP($J,"SDAMA202","GETPLIST",SDA,SDF)=SDO
117 Q
Note: See TracBrowser for help on using the repository browser.