source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGQPTQ2.m@ 1226

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

initial load of WorldVistAEHR

File size: 6.6 KB
RevLine 
[613]1DGQPTQ2 ; slc/CLA - Functions which return patient lists and list sources pt 2 ;05/05/2004
2 ;;5.3;Registration;**447,598,725**;Aug 13, 1993;Build 12
3CLIN(Y) ; RETURN LIST OF CLINICS
4 N DGLST,IEN,I
5 D GETLST^XPAR(.DGLST,"ALL","DGWD COMMON CLINIC")
6 S I=0 F S I=$O(DGLST(I)) Q:'I D
7 . S IEN=$P(DGLST(I),U,2) I $$ACTLOC^SDWU(IEN)=1 D
8 .. S Y(I)=IEN_U_$P(^SC(IEN,0),U,1)
9 Q
10CLINPTS(Y,CLIN,DGBDATE,DGEDATE) ; RETURN LIST OF PTS W/CLINIC APPT W/IN BEGINNING AND END DATES
11 I +$G(CLIN)<1 S Y(1)="^No clinic identified" Q
12 I $$ACTLOC^SDWU(CLIN)'=1 S Y(1)="^Clinic is inactive or Occasion Of Service" Q
13 N DFN,NAME,I,J,X,DGJ,DGSRV,DGNOWDT,CHKX,CHKIN,MAXAPPTS,DGC,CLNAM
14 S MAXAPPTS=200
15 S DGNOWDT=$$NOW^XLFDT
16 S DGSRV=$G(^VA(200,DUZ,5)) I +DGSRV>0 S DGSRV=$P(DGSRV,U)
17 S DFN=0,I=1
18 I DGBDATE="" S DGBDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(DGSRV)_"^DIV^SYS^PKG","DGLP DEFAULT CLINIC START DATE",1,"E"))
19 I DGEDATE="" S DGEDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(DGSRV)_"^DIV^SYS^PKG","DGLP DEFAULT CLINIC STOP DATE",1,"E"))
20 ;CONVERT DGBDATE AND DGEDATE INTO FILEMAN DATE/TIME
21 D DT^DILF("T",DGBDATE,.DGBDATE,"","")
22 D DT^DILF("T",DGEDATE,.DGEDATE,"","")
23 I (DGBDATE=-1)!(DGEDATE=-1) S Y(1)="^Error in date range." Q
24 S DGEDATE=$P(DGEDATE,".")_.5
25 ;
26 N DGARRAY,SDCNT,SDFN,SAPPT,ASTAT
27 S DGARRAY(1)=DGBDATE_";"_DGEDATE,DGARRAY(2)=CLIN,DGARRAY("FLDS")="1;2;3"
28 S DGARRAY("SORT")="P",SDCNT=$$SDAPI^SDAMA301(.DGARRAY)
29 I SDCNT<0 S X=$$FAPCHK^DGENRPD2 I X'="" S Y(1)=X K ^TMP($J,"SDAMA301") Q
30 S SDFN=0 F S SDFN=$O(^TMP($J,"SDAMA301",SDFN)) Q:'SDFN D
31 .S SAPPT=0 F S SAPPT=$O(^TMP($J,"SDAMA301",SDFN,SAPPT)) Q:'SAPPT D
32 ..S ^TMP($J,"SDAM",SAPPT,SDFN)=SDFN_"^"_^TMP($J,"SDAMA301",SDFN,SAPPT)
33 ;
34 S DGJ=0 F S DGJ=$O(^TMP($J,"SDAM",DGJ)) Q:'DGJ D
35 .S DFN=0 F S DFN=$O(^TMP($J,"SDAM",DGJ,DFN)) Q:'DFN D
36 ..S ASTAT=$P($P(^TMP($J,"SDAM",DGJ,DFN),"^",4),";")
37 ..; quit if appt cancelled or no show:
38 ..I ASTAT'="NT",(ASTAT["C")!(ASTAT["N") Q
39 ..S Y(I)=DFN_"^"_$P(^DPT(DFN,0),"^")_"^"_+CLIN_"^"_DGJ,I=I+1
40 ;
41 I I>MAXAPPTS D ;maximum allowable appointments exceeded
42 .S CLNAM=$P($G(^SC(CLIN,0)),U)
43 .K Y S Y(1)="^CLINIC: "_CLNAM_" - Too many appointments found; please narrow search range."
44 S:'$D(Y) Y(1)="^No appointments."
45 K ^TMP($J,"SDAM"),^TMP($J,"SDAMA301"),SDCNT,DGARRAY,SDFN,SAPPT,ASTAT
46 Q
47CDATRANG(DGY) ; return default start and stop dates for clinics in form start^stop
48 N DGBDATE,DGEDATE,DGSRV
49 S DGSRV=$G(^VA(200,DUZ,5)) I +DGSRV>0 S DGSRV=$P(DGSRV,U)
50 S DGBDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(DGSRV)_"^DIV^SYS^PKG","DGLP DEFAULT CLINIC START DATE",1,"E"))
51 S DGEDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(DGSRV)_"^DIV^SYS^PKG","DGLP DEFAULT CLINIC STOP DATE",1,"E"))
52 S DGBDATE=$S($L($G(DGBDATE)):DGBDATE,1:""),DGEDATE=$S($L($G(DGEDATE)):DGEDATE,1:"")
53 S DGY=$$UP^XLFSTR(DGBDATE)_"^"_$$UP^XLFSTR(DGEDATE)
54 Q
55PTAPPTS(Y,DFN,DGBDATE,DGEDATE,CLIN) ; return appts for a patient between beginning and end dates for a clinic, if no clinic return all appointments
56 ;I +$G(CLIN)<1 S Y(1)="^No clinic identified" Q
57 I +$G(CLIN)>0,$$ACTLOC^SDWU(CLIN)'=1 S Y(1)="^Clinic is inactive or Occasion Of Service" Q
58 N VASD,NUM,CNT,INVDT,INT,EXT,DGSRV S NUM=0,CNT=1
59 I (DGBDATE="")!(DGEDATE="") D ;get user's service and set up entities:
60 .S DGSRV=$G(^VA(200,DUZ,5)) I +DGSRV>0 S DGSRV=$P(DGSRV,U)
61 I DGBDATE="" D
62 .I '$L(CLIN) S DGBDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(DGSRV)_"^DIV^SYS^PKG","DGQQAP SEARCH RANGE START",1,"E"))
63 .S:DGBDATE="" DGBDATE="T" ;default start date across all clinics is today
64 I DGEDATE="" D
65 .I '$L(CLIN) S DGEDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(DGSRV)_"^DIV^SYS^PKG","DGQQAP SEARCH RANGE STOP",1,"E"))
66 .S:DGEDATE="" DGEDATE="T" ;default end date across all clinics is today
67 ;CONVERT DGBDATE AND DGEDATE INTO FILEMAN DATE/TIME
68 D DT^DILF("T",DGBDATE,.DGBDATE,"","")
69 D DT^DILF("T",DGEDATE,.DGEDATE,"","")
70 I (DGBDATE=-1)!(DGEDATE=-1) S Y(1)="^Error in date range." Q
71 S VASD("F")=DGBDATE
72 S VASD("T")=$P(DGEDATE,".")_.5 ;ADD 1/2 DAY TO END DATE
73 I $L($G(CLIN)) S VASD("C",CLIN)=""
74 D SDA^VADPT
75 Q:VAERR=1
76 F S NUM=$O(^UTILITY("VASD",$J,NUM)) Q:'NUM D
77 .S INT=^UTILITY("VASD",$J,NUM,"I"),INVDT=9999999-$P(INT,U)
78 .S EXT=^UTILITY("VASD",$J,NUM,"E")
79 .S Y(CNT)=$P(INT,U)_U_$P(EXT,U,2)_U_$P(EXT,U,3)_U_$P(EXT,U,4)_U_INVDT
80 .S CNT=CNT+1
81 S:+$G(Y(1))<1 Y(1)="^No appointments."
82 K VAERR
83 Q
84PROV(Y) ; RETURN LIST OF PROVIDERS
85 N I,IEN,NAME,TDATE
86 S I=1,NAME=""
87 F S NAME=$O(^VA(200,"B",NAME)) Q:NAME="" S IEN=0,IEN=$O(^(NAME,IEN)) D
88 .Q:$E(NAME)="*"
89 .I $D(^XUSEC("PROVIDER",IEN)),$$ACTIVE^XUSER(IEN) S Y(I)=IEN_"^"_NAME,I=I+1
90 Q
91PROVPTS(Y,PROV) ; RETURN LIST OF PATIENTS LINKED TO A PRIMARY PROVIDER
92 I +$G(PROV)<1 S Y(1)="^No provider identified" Q
93 N DGI,DFN
94 S DGI=1,DFN=0
95 F S DFN=$O(^DPT("APR",PROV,DFN)) Q:DFN'>0 S Y(DGI)=+DFN_"^"_$P(^DPT(+DFN,0),"^"),DGI=DGI+1
96 S:+$G(Y(1))<1 Y(1)="^No patients found."
97 Q
98SPEC(Y) ; RETURN LIST OF TREATING SPECIALTIES
99 N I,NAME,IEN
100 S I=1,NAME=""
101 ;access to DIC(45.7 global granted under DBIA #519:
102 F S NAME=$O(^DIC(45.7,"B",NAME)) Q:NAME="" S IEN=0,IEN=$O(^(NAME,IEN)) I $$ACTIVE^DGACT(45.7,IEN) S Y(I)=IEN_"^"_NAME,I=I+1
103 Q
104SPECPTS(Y,SPEC) ; RETURN LIST OF PATIENTS LINKED TO A TREATING SPECIALTY
105 I +$G(SPEC)<1 S Y(1)="^No specialty identified" Q
106 N DGI,DFN
107 S DGI=1,DFN=0
108 F S DFN=$O(^DPT("ATR",SPEC,DFN)) Q:DFN'>0 S Y(DGI)=+DFN_"^"_$P(^DPT(+DFN,0),"^"),DGI=DGI+1
109 S:+$G(Y(1))<1 Y(1)="^No patients found."
110 Q
111WARD(Y) ; RETURN LIST OF ACTIVE WARDS
112 N I,IEN,NAME,D0
113 S I=1,NAME=""
114 ;access to DIC(42 global granted under DBIA #36:
115 F S NAME=$O(^DIC(42,"B",NAME)) Q:NAME="" S IEN=$O(^(NAME,0)) D
116 . S D0=IEN D WIN^DGPMDDCF
117 . I X=0 S Y(I)=IEN_"^"_NAME,I=I+1
118 Q
119WARDPTS(Y,WARD) ; RETURN LIST OF PATIENTS IN A WARD
120 ; SLC/PKS - Modifications for Room/Bed data on 1/19/2001.
121 I +$G(WARD)<1 S Y(1)="^No ward identified" Q
122 N DGI,DFN,RBDAT
123 S DGI=1,DFN=0
124 ;access to DIC(42 global granted under DBIA #36:
125 S WARD=$P(^DIC(42,WARD,0),"^") ;GET WARD NAME FOR "CN" LOOKUP
126 ; Next section modified 1/19/2001 by PKS:
127 F D Q:DFN'>0
128 .S DFN=$O(^DPT("CN",WARD,DFN)) Q:DFN'>0
129 .S Y(DGI)=+DFN_"^"_$P(^DPT(+DFN,0),"^")
130 .S RBDAT=""
131 .; Add patient room/bed information where data exists:
132 .S RBDAT=$P($G(^DPT(+DFN,.101)),U)
133 .; Assure at least 4 letters for any existing room/bed data:
134 .I RBDAT'="" D ; Any R/B data?
135 ..I $L(RBDAT)<4 D ; Less than 4 now?
136 ...S RBDAT=RBDAT_" " ; Add 3 for safety.
137 ...S RBDAT=$E(RBDAT,1,4) ; Get first 4 only.
138 ...S Y(DGI)=Y(DGI)_U_RBDAT ; Add R/B to string
139 .S DGI=DGI+1 ; Increment counter.
140 ;
141 S:+$G(Y(1))<1 Y(1)="^No patients found."
142 Q
143NLIST(DGQY) ; return a null list
144 S DGQY(1)=""
145 Q
Note: See TracBrowser for help on using the repository browser.