source: ccr/trunk/p/C0CRPMS.m@ 1432

Last change on this file since 1432 was 404, checked in by George Lilly, 16 years ago

update copyright notice

File size: 4.1 KB
Line 
1C0CRPMS ; CCDCCR/GPL - CCR/CCD PROCESSING FOR RPMS ;1/14/09 14:33
2 ;;0.1;CCDCCR;;JUL 16,2008;Build 7
3 ;Copyright 2008 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 W "NO ENTRY FROM TOP",!
21 Q
22 ;
23DISPLAY ; RUN THE PCC DISPLAY ROUTINE
24 D ^APCDDISP
25 Q
26 ;
27VTYPES ;
28 D GETN2^C0CRNF("G1",9999999.07)
29 ZWR G1
30 Q
31 ;
32VISITS(C0CDFN,C0CCNT) ;LIST VISIT DATES FOR PATIENT DFN
33 ; C0CCNT IS A LIMIT ON HOW MANY VISITS TO DISPLAY ; DEFAULTS TO ALL
34 I '$D(C0CCNT) S C0CCNT=999999999
35 N G,GN
36 S G="" S GN=0
37 F S G=$O(^AUPNVSIT("AA",C0CDFN,G)) Q:(G="")!(GN>C0CCNT) D ;
38 . S GN=GN+1
39 . W $$FMDTOUTC^C0CUTIL(9999999-G),!
40 Q
41 ;
42VISITS2(C0CDFN,C0CCNT) ;SECOND VERSION USING NEXTV
43 ;
44 N C0CG,GN
45 S C0CG=""
46 S GN=0
47 I '$D(C0CCNT) S C0CCNT=99999999
48 F S C0CG=$$NEXTV(C0CDFN,C0CG) Q:(C0CG="")!(GN'<C0CCNT) D ;
49 . S GN=GN+1
50 . W $$FMDTOUTC^C0CUTIL(C0CG),!
51 Q
52 ;
53NEXTV(C0CDFN,C0CVDT) ;EXTRINSIC WHICH RETURNS THE NEXT VISIT DATE
54 ;FOR PATIENT C0CDFN IN REVERSE TIME ORDER; PASS "" TO GET THE MOST
55 ; RECENT VISIT
56 N G
57 S G=C0CVDT
58 I G'="" S G=9999999-C0CVDT ;INVERT FOR INDEX
59 S G=$O(^AUPNVSIT("AA",C0CDFN,G))
60 I G="" Q ""
61 E Q 9999999-G
62 ;
63GETV(C0CDFN,C0CVDT) ; GET VISIT USING DATE C0CVDT . IF C0CVDT IS NULL,
64 ; GET MOST RECENT VISIT
65 N C0CG
66 I '$D(C0CVDT) S C0CVDT=$$NEXTV(C0CDFN,"")
67 S APCDVLDT=C0CVDT
68 S APCDPAT=C0CDFN
69 D ^APCDVLK
70 D ^APCDVD
71 ;K APCDCLN,APCDCAT,APCDDATE,APCDLOC,APCDVSIT,APCDLOOK,APCDTYPE
72 Q
73 ;
74GETNV(C0CDFN) ;GET MANY VISITS
75 ;
76 S APCDPAT=C0CDFN ;
77 N C0CG S C0CG=""
78 F S C0CG=$$NEXTV(C0CDFN,C0CG) Q:C0CG="" D ; LOOP BACKWARD THROUGH VISITS
79 . W C0CG," ",$$FMDTOUTC^C0CUTIL(C0CG),!
80 . S APCDVLDT=C0CG
81 . D ^APCDVLK
82 . D ^APCDVD
83 . K APCDCLN,APCDCAT,APCDDATE,APCDLOC,APCDVSIT,APCDLOOK,APCDTYPE
84 Q
85 ;
86GETTBL(C0CTBL) ; SCAN FOR AND DISPLAY PATIENTS IN A RIMTBL, PASSED BY VALUE
87 ;
88 N ZG S ZG=$NA(^TMP("GPLRIM","RIMTBL","PATS",C0CTBL))
89 N C0CG S C0CG=""
90 N C0CQ S C0CQ=0
91 F S C0CG=$O(@ZG@(C0CG),-1) Q:(C0CG="") D ;
92 . W "PAT: ",C0CG,!
93 . D GETNV^C0CRPMS(C0CG)
94 . K X R X
95 . I X="Q" S C0CQ=1 ; QUIT IF Q
96 Q
97 ;
98CMPDRG ; COMPARE THE DRUG FILE TO THE VA VUID MAPPING FILE FOR MATCHES
99 ;
100 S C0CZI=0 ;
101 F S C0CZI=$O(^C0CDRUG("V",C0CZI)) Q:C0CZI="" D ;ALL DRUGS IN RPMS DRUG FILE
102 . S C0CZJ="" ; FOR EVERY FIELD AND SUBFIELD IN THE DRUG FILE
103 . ;W "C0CZI:",C0CZI
104 . F S C0CZJ=$O(^C0CDRUG("V",C0CZI,C0CZJ)) Q:C0CZJ="" D ;
105 . . ;W " C0CZJ:",C0CZJ
106 . . N C0CZN,C0CZV ;
107 . . S C0CZN=^C0CDRUG("V",C0CZI,C0CZJ,1) ; EVERY FIELD VALUE
108 . . ;W " C0CZN:",C0CZN,!
109 . . D GETN1^C0CRNF("C0CZV",176.112,C0CZN,"C") ;LOOK IN C XREF
110 . . I $D(C0CZV) D ;FOUND A MATCH
111 . . . S C0CVO="FOUND:^"_C0CZI_"^"_C0CZJ_"^"_C0CZN
112 . . . S C0CVO=C0CVO_"^RXNORM:^"_$$ZVALUE^C0CRNF("MEDIATION CODE","C0CZV")
113 . . . D PUSH^GPLXPATH("^C0CZRX",C0CVO)
114 . . . W C0CVO,!
115 Q
116 ;
117CMPDRG2 ; COMPARE THE DRUG FILE TO THE VA VUID MAPPING FILE FOR MATCHES
118 ;
119 S C0CZI=0 ;
120 F S C0CZI=$O(^C0CDRUG("V",C0CZI)) Q:C0CZI="" D ;ALL DRUGS IN RPMS DRUG FILE
121 . S C0CZJ="" ; FOR EVERY FIELD AND SUBFIELD IN THE DRUG FILE
122 . W "C0CZI:",C0CZI
123 . F S C0CZJ=$O(^C0CDRUG("V",C0CZI,C0CZJ)) Q:C0CZJ="" D ;
124 . . W " C0CZJ:",C0CZJ
125 . . N C0CZN,C0CZV ;
126 . . S C0CZN=^C0CDRUG("V",C0CZI,C0CZJ,1) ; EVERY FIELD VALUE
127 . . W " C0CZN:",C0CZN,!
128 . . D GETN1^C0CRNF("C0CZV",176.112,C0CZN,"C") ;LOOK IN C XREF
129 . . I $D(C0CZV) D ;FOUND A MATCH
130 . . . W "FOUND: ",C0CZI," ",C0CZJ," ",C0CZN
131 . . . W " VUID:",$$ZVALUE^C0CRNF("VUID","C0CZV"),!
132 Q
133 ;
Note: See TracBrowser for help on using the repository browser.