1 | GMVCLIN ;HOIFO/YH,FT-RETURNS A LIST OF PATIENTS WITH CLINIC APPOINTMENTS WITHIN A GIVEN PERIOD ;6/24/03 10:32
|
---|
2 | ;;5.0;GEN. MED. REC. - VITALS;**1**;Oct 31, 2002
|
---|
3 | ;
|
---|
4 | ; This routine uses the following IAs:
|
---|
5 | ; #3869 - ^SDAMA202 calls (controlled)
|
---|
6 | ; #10040 - ^SC( references (supported)
|
---|
7 | ; #10103 - ^XLFDT calls (supported)
|
---|
8 | ;
|
---|
9 | CLINPTS(RESULT,CLIN,BDATE) ; GMV CLINIC PT [RPC entry point]
|
---|
10 | ; Return list of patients with clinic appointments within given period
|
---|
11 | ; Input:
|
---|
12 | ; RESULT - array name to return data in
|
---|
13 | ; CLIN - clinic name
|
---|
14 | ; BDATE - TODAY, TOMORROW, YESTERDAY, PAST WEEK, OR PAST MONTH
|
---|
15 | ;
|
---|
16 | ; Output:
|
---|
17 | ; RESULT(n)=DFN^patient name^clinic name^appt date/time (external)^
|
---|
18 | ; SSN^DOB (external)^sex, age^^...^^^^^...
|
---|
19 | ;
|
---|
20 | ; RESULT(1)=contains any error message
|
---|
21 | ;
|
---|
22 | N DFN,EDATE,GMVCLIN,GMVCNT,GMVDT,GMVI,GMVJ,GMVNODE,GMVNOW
|
---|
23 | N GMVOUT,GMVPAT,GMVRESLT,NAME,X
|
---|
24 | K RESULT
|
---|
25 | I '$D(^SC("B",CLIN)) S RESULT(1)="ERROR^No clinic identified" G QCLIN
|
---|
26 | S GMVCLIN=$O(^SC("B",CLIN,0))
|
---|
27 | I GMVCLIN'>0 S RESULT(1)="ERROR^No clinic identified" G QCLIN
|
---|
28 | S GMVNOW=$$NOW^XLFDT,EDATE=$P(GMVNOW,".")_".24"
|
---|
29 | S BDATE=$$UP^XLFSTR(BDATE)
|
---|
30 | S BDATE=$S(BDATE="TODAY":"T",BDATE="TOMORROW":"T+1",BDATE="YESTERDAY":"T-1",BDATE="PAST WEEK":"T-7",BDATE="PAST MONTH":"T-30",1:"")
|
---|
31 | I BDATE="" S RESULT(1)="ERROR^Error in date range." G QCLIN
|
---|
32 | ; convert bdate and edate into fileman date/time
|
---|
33 | D DT^DILF("T",BDATE,.BDATE,"","")
|
---|
34 | I BDATE>EDATE S EDATE=BDATE_".24"
|
---|
35 | ; call scheduling api to get appt data
|
---|
36 | D GETPLIST^SDAMA202(GMVCLIN,"1;4;","R",BDATE,EDATE,.GMVRESLT,"")
|
---|
37 | ; if GMVRESLT < 0, scheduling api returned an error
|
---|
38 | I GMVRESLT<0 D G QCLIN
|
---|
39 | .S RESULT(1)="ERROR"_U_$O(^TMP($J,"SDAMA202","GETPLIST","ERROR",0))
|
---|
40 | .Q
|
---|
41 | ; generate error message if # of appts > 200
|
---|
42 | I $D(^TMP($J,"SDAMA202","GETPLIST",201,0)) D G QCLIN
|
---|
43 | .S RESULT(1)="ERROR^Too many appointments found. Please narrow search."
|
---|
44 | .Q
|
---|
45 | S (GMVCNT,GMVI)=0
|
---|
46 | F S GMVI=$O(^TMP($J,"SDAMA202","GETPLIST",GMVI)) Q:'GMVI D
|
---|
47 | .S GMVNODE=^TMP($J,"SDAMA202","GETPLIST",GMVI,4) ;dfn^patient name
|
---|
48 | .Q:$P(GMVNODE,U,1)=""!($P(GMVNODE,U,2)="")
|
---|
49 | .S DFN=$P(GMVNODE,U,1),NAME=$P(GMVNODE,U,2)
|
---|
50 | .S GMVDT=$P(^TMP($J,"SDAMA202","GETPLIST",GMVI,1),U,1) ;appt date/time
|
---|
51 | .S GMVOUT(NAME,DFN)=DFN_"^"_NAME_"^"_CLIN_"^"_$$FMTE^XLFDT(GMVDT)
|
---|
52 | .S GMVCNT=GMVCNT+1
|
---|
53 | .Q
|
---|
54 | I $D(GMVOUT) D
|
---|
55 | .S GMVI=0,NAME=""
|
---|
56 | .F S NAME=$O(GMVOUT(NAME)) Q:NAME="" D
|
---|
57 | ..S DFN=0
|
---|
58 | ..F S DFN=$O(GMVOUT(NAME,DFN)) Q:'DFN D
|
---|
59 | ...S GMVPAT=""
|
---|
60 | ...D PTINFO^GMVUTL3(.GMVPAT,DFN)
|
---|
61 | ...S GMVI=GMVI+1,RESULT(GMVI)=GMVOUT(NAME,DFN)_"^"_GMVPAT
|
---|
62 | ...Q
|
---|
63 | ..Q
|
---|
64 | .Q
|
---|
65 | QCLIN ; called from above
|
---|
66 | I '$D(RESULT(1)) S RESULT(1)="No patients found"
|
---|
67 | K ^TMP($J,"SDAMA202")
|
---|
68 | Q
|
---|
69 | ;
|
---|