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

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

update copyright notice

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