source: ccr/trunk/p/C0CRNF.m@ 520

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

formatting for Version 1

File size: 15.0 KB
Line 
1C0CRNF ; CCDCCR/GPL - Reference Name Format (RNF) utilities; 12/6/08
2 ;;1.0;C0C;;May 19, 2009;
3 ;Copyright 2009 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 "This is the Reference Name Format (RNF) Utility Library ",!
21 W !
22 Q
23 ;
24FIELDS(C0CFRTN,C0CF) ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF,
25 ; C0CFRTN IS PASSED BY NAME, C0CF IS PASSED BY VALUE
26 ;
27 N C0CFI,C0CFJ ;INNER LOOP, OUTER LOOP
28 N C0CFN ; FIELD NAME
29 S C0CFI=0 S C0CFJ=C0CF
30 K @C0CFRTN ; CLEAR THE RETURN ARRAY
31 F Q:C0CFJ'[C0CF D ; FOR THE C0CF FILE AND ALL SUBFILES INCLUSIVE
32 . ;W "1: "_C0CFJ," ",C0CFI,!
33 . F S C0CFI=$O(^DD(C0CFJ,C0CFI)) Q:+C0CFI=0 D ; EVERY FIELD
34 . . ;W "2: "_C0CFJ," ",C0CFI,!
35 . . S C0CFN=$P($G(^DD(C0CFJ,C0CFI,0)),"^",1) ;PULL FIELD NAME FROM ^DD
36 . . ;W "N: ",C0CFN,!
37 . . ;I C0CFN="STR" W C0CFN," ",C0CFJ,!
38 . . I $D(@C0CFRTN@(C0CFN)) D ; IS THIS A DUPLICATE?
39 . . . I DEBUG D ;
40 . . . . W "DUPLICATE FOUND! ",C0CFJ," ",C0CFI," ",C0CFN,!,@C0CFRTN@(C0CFN),!
41 . . . S @C0CFRTN@(C0CFN_"_"_C0CFJ)=C0CFJ_"^"_C0CFI
42 . . E S @C0CFRTN@(C0CFN)=C0CFJ_"^"_C0CFI
43 . S C0CFJ=$O(^DD(C0CFJ)) ; NEXT SUBFILE
44 Q
45 ;
46GETNOLD(GRTN,GFILE,GIEN,GNN) ; GET FIELDS FOR ACCESS BY NAME
47 ; GRTN IS PASSED BY NAME
48 ;
49 N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
50 I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)
51 E S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)
52 S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
53 D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP
54 D GETS^DIQ(GFILE,C0CREF,"**","I","C0CTMP")
55 D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
56 S @GRTN@(0)=GFILE_"^RNF1^"_GIEN_"^"_DT_"^"_$J ; STRUCTURE SIGNATURE
57 S (C0CI,C0CJ)=""
58 F S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ="" D ; FOR ALL SUBFILES
59 . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE
60 . F S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI="" D ; ARRAY OF FIELDS
61 . . ;W C0CJ," ",C0CI,!
62 . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
63 . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI) ;
64 . . I C0CVALUE["C0CTMP" S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,1) ;1ST LINE OF WP
65 . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3
66 I C0CNN D ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED
67 . S C0CI=""
68 . F S C0CI=$O(@GRTN@(C0CI)) Q:C0CI="" D ; GO THROUGH THE WHOLE ARRAY
69 . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES
70 Q
71 ;
72GETN(GRTN,GFILE,GREF,GNDX,GNN) ; GET BY NAME ; RETURN A FIELD VALUE MAP
73 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1
74 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
75 ; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN
76 ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
77 ; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")=""
78 ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
79 ; .. VALUE MAP @GRTN@("V","IEN","FIELDNAME")=VALUE
80 ; .. GRTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
81 ; .. IF GNN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
82 ; .. EVEN IF GNN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
83 ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
84 ; IF GREF IS "" THE FIRST RECORD IS OBTAINED
85 ; IF GNDX IS NULL, GREF IS AN IEN FOR THE FILE
86 ; GNDX IS THE INDEX TO USE TO OBTAIN THE IEN
87 ; GREF IS THE VALUE FOR THE INDEX
88 ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
89 ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GRTN
90 ;
91 ;
92 N GIEN,GF
93 S GF=$$FILEREF(GFILE) ;CLOSED FILE REFERENCE FOR FILE NUMBER GFILE
94 I ('$D(GNDX))!(GNDX="") S GIEN=GREF ; IF NO INDEX USED, GREF IS THE IEN
95 E D ; WE ARE USING AN INDEX
96 . ;N ZG
97 . S ZG=$Q(@GF@(GNDX,GREF)) ;ACCESS INDEX
98 . I ZG'="" D ;
99 . . I $QS(ZG,3)=GREF D ; IS GREF IN INDEX?
100 . . . S GIEN=$QS(ZG,4) ; PULL OUT THE IEN
101 . . E S GIEN="" ; NOT FOUND IN INDEX
102 . E S GIEN="" ;
103 ;W "IEN: ",GIEN,!
104 ;N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
105 I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)
106 E S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)
107 S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
108 D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP
109 K C0CTMP
110 D GETS^DIQ(GFILE,C0CREF,"**","IE","C0CTMP")
111 D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
112 S @GRTN@(0)=GFILE_"^RNF1^"_GIEN_"^"_DT_"^"_$J_"^"_DUZ ; STRUCTURE SIGNATURE
113 S (C0CI,C0CJ)=""
114 F S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ="" D ; FOR ALL SUBFILES
115 . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE
116 . F S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI="" D ; ARRAY OF FIELDS
117 . . ;W C0CJ," ",C0CI,!
118 . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
119 . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,"E") ;
120 . . I C0CVALUE["C0CTMP" D ; WP FIELD
121 . . . N ZT,ZWP S ZWP=0 ;ITERATOR
122 . . . S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) ; INIT TO FIRST LINE
123 . . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ; INIT TO FIRST LINE
124 . . . F S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) Q:'ZWP D ;
125 . . . . S ZT=" "_C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ;LINE OF WP
126 . . . . S ZT=$TR(ZT,"^""","|'") ;HACK TO GET RID OF ^ AND " IN TEXT "
127 . . . . S C0CVALUE=C0CVALUE_ZT ;
128 . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3
129 . . S $P(@GRTN@(C0CNAME,"I"),"^",3)=$G(C0CTMP(C0CJ,C0CREF,C0CI,"I"))
130 I C0CNN D ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED
131 . S C0CI=""
132 . F S C0CI=$O(@GRTN@(C0CI)) Q:C0CI="" D ; GO THROUGH THE WHOLE ARRAY
133 . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES
134 Q
135 ;
136GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
137 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1
138 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
139 ; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN
140 ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
141 ; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")=""
142 ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
143 ; .. VALUE MAP @GRTN@("V","IEN","FIELDNAME")=VALUE
144 ; .. GRTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
145 ; .. IF GNN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
146 ; .. EVEN IF GNN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
147 ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
148 ; IF GREF IS "" THE FIRST RECORD IS OBTAINED
149 ; IF GNDX IS NULL, GREF IS AN IEN FOR THE FILE
150 ; GNDX IS THE INDEX TO USE TO OBTAIN THE IEN
151 ; GREF IS THE VALUE FOR THE INDEX
152 ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
153 ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GRTN
154 ;
155 ;
156 N GIEN,GF
157 S GF=$$FILEREF(GFILE) ;CLOSED FILE REFERENCE FOR FILE NUMBER GFILE
158 I ('$D(GNDX))!(GNDX="") S GIEN=GREF ; IF NO INDEX USED, GREF IS THE IEN
159 E D ; WE ARE USING AN INDEX
160 . ;N ZG
161 . S ZG=$Q(@GF@(GNDX,GREF)) ;ACCESS INDEX
162 . I ZG'="" D ;
163 . . I $QS(ZG,3)=GREF D ; IS GREF IN INDEX?
164 . . . S GIEN=$QS(ZG,4) ; PULL OUT THE IEN
165 . . E S GIEN="" ; NOT FOUND IN INDEX
166 . E S GIEN="" ;
167 ;W "IEN: ",GIEN,!
168 ;N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
169 I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)
170 E S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)
171 S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
172 D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP
173 K C0CTMP
174 D GETS^DIQ(GFILE,C0CREF,"**","IE","C0CTMP")
175 D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
176 S @GRTN@(0)=GFILE_"^RNF1^"_GIEN_"^"_DT_"^"_$J_"^"_DUZ ; STRUCTURE SIGNATURE
177 S (C0CI,C0CJ)=""
178 F S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ="" D ; FOR ALL SUBFILES
179 . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE
180 . F S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI="" D ; ARRAY OF FIELDS
181 . . ;W C0CJ," ",C0CI,!
182 . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
183 . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,"E") ;
184 . . I C0CVALUE["C0CTMP" D ; WP FIELD
185 . . . N ZT,ZWP S ZWP=0 ;ITERATOR
186 . . . S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) ; INIT TO FIRST LINE
187 . . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ; INIT TO FIRST LINE
188 . . . F S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) Q:'ZWP D ;
189 . . . . S ZT=" "_C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ;LINE OF WP
190 . . . . S ZT=$TR(ZT,"^""","|'") ;HACK TO GET RID OF ^ AND " IN TEXT "
191 . . . . S C0CVALUE=C0CVALUE_ZT ;
192 . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3
193 . . S $P(@GRTN@(C0CNAME,"I"),"^",3)=$G(C0CTMP(C0CJ,C0CREF,C0CI,"I"))
194 I C0CNN D ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED
195 . S C0CI=""
196 . F S C0CI=$O(@GRTN@(C0CI)) Q:C0CI="" D ; GO THROUGH THE WHOLE ARRAY
197 . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES
198 Q
199 ;
200GETN2(GARTN,GAFILE,GAIDX,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES
201 ; GARTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
202 ; .. FIELD MAP @GARTN@("F","FIELDNAME")="FILE;FIELD#"
203 ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
204 ; .. VALUE MAP @GARTN@("V","IEN","FIELDNAME","N")=VALUE
205 ; .. WHERE N IS THE INDEX FOR MULTIPLES.. 1 FOR SINGLE VALUES
206 ; .. GARTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
207 ; .. IF GANN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
208 ; .. EVEN IF GANN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
209 ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
210 ; GAFILE IS THE FILE NUMBER TO BE PROCESSED. IT IS PASSED BY VALUE
211 ; GAIDX IS THE OPTIONAL INDEX TO USE IN THE FILE. IF GAIDX IS "" THE IEN
212 ; .. OF THE FILE WILL BE USED
213 ; GACNT IS THE NUMBER OF RECORDS TO PROCESS. IT IS PASSED BY VALUE
214 ; .. IF GARCNT IS NULL, ALL RECORDS ARE PROCESSED
215 ; GASTRT IS THE IEN OF THE FIRST RECORD TO PROCESS. IT IS PASSED BY VALUE
216 ; .. IF GARSTART IS NULL, PROCESSING STARTS AT THE FIRST RECORD
217 ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
218 ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GARFLD AND GARVAL
219 ;N GATMP,GAI,GAF
220 S GAF=$$FILEREF(GAFILE) ; GET CLOSED ROOT FOR THE FILE NUMBER GAFILE
221 I '$D(GAIDX) S GAIDX="" ;DEFAULT
222 I '$D(GANN) S GANN="" ;DEFAULT ONLY POPULATED FIELDS RETURNED
223 I GAIDX'="" S GAF=$NA(@GAF@(GAIDX)) ; IF WE ARE USING AN INDEX
224 W GAF,!
225 W $O(@GAF@(0)) ;
226 S GAI=0 ;ITERATOR
227 F S GAI=$O(@GAF@(GAI)) Q:GAI="" D ;
228 . D GETN1("GATMP",GAFILE,GAI,GAIDX,GANN) ;GET ONE RECORD
229 . N GAX S GAX=0
230 . F S GAX=$O(GATMP(GAX)) Q:GAX="" D ;PULL OUT THE FIELDS
231 . . D ADDNV(GARTN,GAI,GAX,GATMP(GAX)) ;INSERT THE NAME/VALUE INTO GARTN
232 Q
233 ;
234ADDNV(GNV,GNVN,GNVF,GNVV) ; CREATE AN ELEMENT OF THE MATRIX
235 ;
236 S @GNV@("F",GNVF)=$P(GNVV,"^",1)_"^"_$P(GNVV,"^",2) ;NAME=FILE^FIELD#
237 S @GNV@("V",GNVN,GNVF,1)=$P(GNVV,"^",3) ;SET THE VALUE
238 Q
239 ;
240RNF2CSV(RNRTN,RNIN,RNSTY) ;CONVERTS AN RFN2 GLOBAL TO A CSV FORMAT
241 ; READY TO WRITE FOR USE WITH EXCEL @RNRTN@(0) IS NUMBER OF LINES
242 ; RNSTY IS STYLE OF THE OUTPUT -
243 ; .. "NV"= ROWS ARE NAMES, COLUMNS ARE VALUES
244 ; .. "VN"= ROWS ARE VALUES, COLUMNS ARE NAMES
245 ; .. DEFAULT IS "NV" BECAUSE MANY MATRICES HAVE MORE FIELDS THAN VALUES
246 N RNR,RNC ;ROW ROOT,COL ROOT
247 N RNI,RNJ,RNX
248 I '$D(RNSTY) S RNSTY="NV" ;DEFAULT
249 I RNSTY="NV" D NV(RNRTN,RNIN) ; INTERNAL SUBROUTINES DEPENDING ON ORIENTATION
250 E D VN(RNRTN,RNIN) ;
251 Q
252 ;
253NV(RNRTN,RNIN) ;
254 S RNR=$NA(@RNIN@("F"))
255 S RNC=$NA(@RNIN@("V"))
256 ;S RNY=$P(@RNIN@(0),"^",1) ; FILE NUMBER
257 S RNX="""FILE"""_"," ; FIRST COLUMN NAME IS "FIELD"
258 S RNI=""
259 F S RNI=$O(@RNC@(RNI)) Q:RNI="" D ; FOR EACH COLUMN
260 . S RNX=RNX_RNI_"," ;ADD THE COLUMM ELEMENT AND A COMMA
261 S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
262 D PUSH^GPLXPATH(RNRTN,RNX) ; FIRST LINE CONTAINS COLUMN HEADINGS
263 S RNI=""
264 F S RNI=$O(@RNR@(RNI)) Q:RNI="" D ; FOR EACH ROW
265 . S RNX=""""_RNI_""""_"," ; FIRST ELEMENT ON ROW IS THE FIELD
266 . S RNJ=""
267 . F S RNJ=$O(@RNC@(RNJ)) Q:RNJ="" D ; FOR EACH COL
268 . . I $D(@RNC@(RNJ,RNI,1)) D ; THIS ROW HAS THIS COLUMN
269 . . . S RNX=RNX_""""_@RNC@(RNJ,RNI,1)_""""_"," ; ADD THE ELEMENT PLUS A COMMA
270 . . E S RNX=RNX_"," ; NUL COLUMN
271 . S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
272 . D PUSH^GPLXPATH(RNRTN,RNX)
273 Q
274 ;
275VN(RNRTN,RNIN) ;
276 S RNR=$NA(@RNIN@("V"))
277 S RNC=$NA(@RNIN@("F"))
278 ;S RNY=$P(@RNIN@(0),"^",1) ; FILE NUMBER
279 S RNX="""FILE"""_"," ; FIRST COLUMN NAME IS "FIELD"
280 S RNI=""
281 F S RNI=$O(@RNC@(RNI)) Q:RNI="" D ; FOR EACH COLUMN
282 . S RNX=RNX_RNI_"," ;ADD THE COLUMM ELEMENT AND A COMMA
283 S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
284 D PUSH^GPLXPATH(RNRTN,RNX) ; FIRST LINE CONTAINS COLUMN HEADINGS
285 S RNI=""
286 F S RNI=$O(@RNR@(RNI)) Q:RNI="" D ; FOR EACH ROW
287 . S RNX=""""_RNI_""""_"," ; FIRST ELEMENT ON ROW IS THE FIELD
288 . S RNJ=""
289 . F S RNJ=$O(@RNC@(RNJ)) Q:RNJ="" D ; FOR EACH COL
290 . . I $D(@RNR@(RNI,RNJ,1)) D ; THIS ROW HAS THIS COLUMN
291 . . . S RNX=RNX_""""_@RNR@(RNI,RNJ,1)_""""_"," ; ADD THE ELEMENT PLUS A COMMA
292 . . E S RNX=RNX_"," ; NUL COLUMN
293 . S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
294 . D PUSH^GPLXPATH(RNRTN,RNX)
295 Q
296 ;
297FILE2CSV(FNUM,FVN) ; WRITES OUT A FILEMAN FILE TO CSV
298 ;
299 ;N G1,G2
300 I '$D(FVN) S FVN="NV" ; DEFAULT ORIENTATION OF CVS FILE
301 S G1=$NA(^TMP($J,"C0CCSV",1))
302 S G2=$NA(^TMP($J,"C0CCSV",2))
303 D GETN2(G1,FNUM) ; GET THE MATRIX
304 D RNF2CSV(G2,G1,FVN) ; PREPARE THE CVS FILE
305 K @G1
306 D FILEOUT(G2,"FILE_"_FNUM_".csv")
307 K @G2
308 Q
309 ;
310FILEOUT(FOARY,FONAM) ; WRITE OUT A FILE
311 ;
312 W $$OUTPUT^GPLXPATH($NA(@FOARY@(1)),FONAM,^TMP("GPLCCR","ODIR"))
313 Q
314 ;
315FILEREF(FNUM) ; EXTRINSIC THAT RETURNS A CLOSED ROOT FOR FILE NUMBER FNUM
316 ;
317 N C0CF
318 S C0CF=^DIC(FNUM,0,"GL") ;OPEN ROOT TO FILE
319 S C0CF=$P(C0CF,",",1)_")" ; CLOSE THE ROOT
320 I C0CF["()" S C0CF=$P(C0CF,"()",1)
321 Q C0CF
322 ;
323SKIP ;
324 N TXT,DIERR
325 S TXT=$$GET1^DIQ(8925,TIUIEN,"2","","TXT")
326 I $D(DIERR) D CLEAN^DILF Q
327 W " report_text:",! ;Progress Note Text
328 N LN S LN=0
329 F S LN=$O(TXT(LN)) Q:'LN D
330 . W " text"_LN_": "_TXT(LN),!
331 . Q
332 Q
333 ;
334ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
335 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF @ZTAB@(ZFN)
336 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
337 I '$D(ZTAB) S ZTAB="C0CA"
338 Q $P(@ZTAB@(ZFN),"^",1)
339ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
340 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF @ZTAB@(ZFN)
341 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
342 I '$D(ZTAB) S ZTAB="C0CA"
343 Q $P(@ZTAB@(ZFN),"^",2)
344ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
345 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF @ZTAB@(ZFN)
346 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
347 I '$D(ZTAB) S ZTAB="C0CA"
348 Q $P($G(@ZTAB@(ZFN)),"^",3)
349 ;
350ZVALUEI(ZFN,ZTAB) ;EXTRINSIC TO RETURN INTERNAL VALUE FOR FIELD NAME PASSED
351 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF @ZTAB@(ZFN)
352 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
353 I '$D(ZTAB) S ZTAB="C0CA"
354 Q $P($G(@ZTAB@(ZFN,"I")),"^",3)
355 ;
Note: See TracBrowser for help on using the repository browser.