[1544] | 1 | C0CRNFRP ; CCDCCR/GPL - Reference Name Format (RNF) RPCs; 12/9/09 ; 5/10/12 2:56pm
|
---|
[1586] | 2 | ;;1.2;CCD/CCR GENERATION UTILITIES;;Oct 30, 2012;Build 50
|
---|
| 3 | ;Copyright 2009 George Lilly.
|
---|
[1544] | 4 | ;
|
---|
[1586] | 5 | ; This program is free software: you can redistribute it and/or modify
|
---|
| 6 | ; it under the terms of the GNU Affero General Public License as
|
---|
| 7 | ; published by the Free Software Foundation, either version 3 of the
|
---|
| 8 | ; License, or (at your option) any later version.
|
---|
[1544] | 9 | ;
|
---|
[1586] | 10 | ; This program is distributed in the hope that it will be useful,
|
---|
| 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | ; GNU Affero General Public License for more details.
|
---|
[1544] | 14 | ;
|
---|
[1586] | 15 | ; You should have received a copy of the GNU Affero General Public License
|
---|
| 16 | ; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
[1544] | 17 | ;
|
---|
| 18 | W "This is the Reference Name Format (RNF) RPC Library ",!
|
---|
| 19 | W !
|
---|
| 20 | Q
|
---|
| 21 | ;
|
---|
| 22 | ;This routine will be mirroring C0CRNF and transform the output
|
---|
| 23 | ;of the tags into an RPC friendly format
|
---|
| 24 | ;The tags will be exactly as they are in C0CRNF
|
---|
| 25 | FIELDS(C0CFRTN,C0CFILE) ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF,
|
---|
| 26 | ;C0CFRTN IS PASSED BY REFERENCE, C0CF IS PASSED BY VALUE
|
---|
| 27 | ;RETURN FORMAT:
|
---|
| 28 | ;^TMP("C0CRNF",$J,0)="NUMBER_OF_RESULTS
|
---|
| 29 | ;^TMP("C0CRNF",$J,I)="FIELD_NAME^FILE_NUMBER^FIELD_NUMBER"
|
---|
| 30 | ;
|
---|
| 31 | ;SAMPLE OUTPUT FROM FIELDS^C0CRNF:
|
---|
| 32 | ;C0CRNFFIELDS("*AMOUNT OF MILITARY RETIREMENT")="2^.3625"
|
---|
| 33 | ;
|
---|
| 34 | ;FORMAT APPEARS TO BE:
|
---|
| 35 | ;VARIABLENAME("FIELD_NAME")="FILE_NUMBER^FIELD_NUMBER"
|
---|
| 36 | ;
|
---|
| 37 | ;SET DEBUG VALUE - REQUIRED - 0=OFF 1=ON
|
---|
| 38 | S DEBUG=0
|
---|
| 39 | ;SET RETURN VALUE
|
---|
| 40 | S C0CFRTN=$NA(^TMP("C0CRNF",$J))
|
---|
| 41 | K @C0CFRTN
|
---|
| 42 | ;RUN WRAPPED CALL
|
---|
| 43 | D FIELDS^C0CRNF("C0CRTN",C0CFILE)
|
---|
| 44 | S J=""
|
---|
| 45 | S I=1
|
---|
| 46 | ;FORMAT RETURN
|
---|
| 47 | F S J=$O(C0CRTN(J)) Q:J="" D ; FOR EACH FIELD IN THE ARRAY
|
---|
| 48 | . S @C0CFRTN@(I)=J_"^"_C0CRTN(J)
|
---|
| 49 | . S I=I+1
|
---|
| 50 | S @C0CFRTN@(0)=I-1
|
---|
| 51 | ;CLEAN UP
|
---|
| 52 | K J,I
|
---|
| 53 | Q
|
---|
| 54 | ;
|
---|
| 55 | GETNOLD(GRTN,GFILE,GIEN,GNN) ; GET FIELDS FOR ACCESS BY NAME
|
---|
| 56 | ; GRTN IS PASSED BY NAME
|
---|
| 57 | ;
|
---|
| 58 | ; OLD TAG DO NOT USE!
|
---|
| 59 | Q
|
---|
| 60 | ;
|
---|
| 61 | GETN(C0CGRTN,GFILE,GREF,GNDX,GNN) ; GET BY NAME ; RETURN A FIELD VALUE MAP
|
---|
| 62 | ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
|
---|
| 63 | ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
|
---|
| 64 | ; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")=""
|
---|
| 65 | ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
|
---|
| 66 | ; .. VALUE MAP @GRTN@("V","IEN","FIELDNAME")=VALUE
|
---|
| 67 | ; .. IF GNN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
|
---|
| 68 | ; .. EVEN IF GNN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
|
---|
| 69 | ; .. NULL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
|
---|
| 70 | ; IF GREF IS "" THE FIRST RECORD IS OBTAINED
|
---|
| 71 | ; IF GNDX IS NULL, GREF IS AN IEN FOR THE FILE
|
---|
| 72 | ; GNDX IS THE INDEX TO USE TO OBTAIN THE IEN
|
---|
| 73 | ; GREF IS THE VALUE FOR THE INDEX
|
---|
| 74 | ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
|
---|
| 75 | ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GRTN
|
---|
| 76 | ;
|
---|
| 77 | ;
|
---|
| 78 | ;RETURN FORMAT:
|
---|
| 79 | ;^TMP("C0CRNF",$J,0)="NUMBER_OF_RESULTS^FILE_NUMBER^RNF1^IEN^CURRENT_DATE^$J^DUZ_$C(30)"
|
---|
| 80 | ;^TMP("C0CRNF",$J,I)="FIELD_NAME^FILE_NUMBER^FIELD_NUMBER^VALUE^INTERNAL_VALUE_$C(30)"
|
---|
| 81 | ;
|
---|
| 82 | ;SAMPLE OUTPUT FROM FIELDS^C0CRNF:
|
---|
| 83 | ;C0CRNFGETN(0)="2^RNF1^5095^3091209^2908^3268"
|
---|
| 84 | ;C0CRNFGETN("1U4N")="2^.0905^H5369"
|
---|
| 85 | ;C0CRNFGETN("1U4N","I")="^^H5369"
|
---|
| 86 | ;C0CRNFGETN("ADDRESS CHANGE DT/TM")="2^.118^OCT 21,2009@08:03:26"
|
---|
| 87 | ;C0CRNFGETN("ADDRESS CHANGE DT/TM","I")="^^3091021.080326"
|
---|
| 88 | ;
|
---|
| 89 | ;FORMAT APPEARS TO BE:
|
---|
| 90 | ;VARIABLENAME(0)="FILE_NUMBER^RNF1^IEN^CURRENT_DATE^$J^DUZ"
|
---|
| 91 | ;VARIABLENAME("FIELD_NAME")="FILE_NUMBER^FIELD_NUMBER^VALUE"
|
---|
| 92 | ;VARIABLENAME("FIELD_NAME","I")="^^INTERNAL_VALUE"
|
---|
| 93 | ;
|
---|
| 94 | ;SET DEBUG VALUE - REQUIRED - 0=OFF 1=ON
|
---|
| 95 | S DEBUG=0
|
---|
| 96 | ;SET RETURN VALUE
|
---|
| 97 | S C0CGRTN=$NA(^TMP("C0CRNF",$J))
|
---|
| 98 | K @C0CGRTN
|
---|
| 99 | ;RUN WRAPPED CALL
|
---|
| 100 | D GETN^C0CRNF("C0CRTN",$G(GFILE),$G(GREF),$G(GNDX),$G(GNN))
|
---|
| 101 | S J=""
|
---|
| 102 | S I=1
|
---|
| 103 | ;FORMAT RETURN
|
---|
| 104 | F S J=$O(C0CRTN(J)) Q:J="" D ; FOR EACH FIELD IN THE ARRAY
|
---|
| 105 | . I J=0 S J=$O(C0CRTN(J)) ; SKIP THE 0 NODE
|
---|
| 106 | . S @C0CGRTN@(I)=J_"^"_C0CRTN(J)_"^" ; GETS THE FIRST LINE
|
---|
| 107 | . ;S J=$O(C0CRTN(J)) ; INCREMENT J SO WE CAN GET THE INTERNAL DATA
|
---|
| 108 | . ;TEST TO SEE IF INTERNAL DATA EXISTS
|
---|
| 109 | . I $D(C0CRTN(J,"I"))=1 D
|
---|
| 110 | . . S @C0CGRTN@(I)=@C0CGRTN@(I)_$P(C0CRTN(J,"I"),U,3) ; GETS THE INTERNAL VALUE PIECE 3
|
---|
| 111 | . S I=I+1
|
---|
| 112 | S @C0CGRTN@(0)=I-1_"^"_C0CRTN(0)
|
---|
| 113 | ;CLEAN UP
|
---|
| 114 | K J,I
|
---|
| 115 | Q
|
---|
| 116 | ;
|
---|
| 117 | GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
|
---|
| 118 | ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1
|
---|
| 119 | ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
|
---|
| 120 | ; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN
|
---|
| 121 | ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
|
---|
| 122 | ; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")=""
|
---|
| 123 | ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
|
---|
| 124 | ; .. VALUE MAP @GRTN@("V","IEN","FIELDNAME")=VALUE
|
---|
| 125 | ; .. GRTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
|
---|
| 126 | ; .. IF GNN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
|
---|
| 127 | ; .. EVEN IF GNN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
|
---|
| 128 | ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
|
---|
| 129 | ; IF GREF IS "" THE FIRST RECORD IS OBTAINED
|
---|
| 130 | ; IF GNDX IS NULL, GREF IS AN IEN FOR THE FILE
|
---|
| 131 | ; GNDX IS THE INDEX TO USE TO OBTAIN THE IEN
|
---|
| 132 | ; GREF IS THE VALUE FOR THE INDEX
|
---|
| 133 | ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
|
---|
| 134 | ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GRTN
|
---|
| 135 | ;
|
---|
| 136 | ;
|
---|
| 137 | N GIEN,GF
|
---|
| 138 | S GF=$$FILEREF(GFILE) ;CLOSED FILE REFERENCE FOR FILE NUMBER GFILE
|
---|
| 139 | I ('$D(GNDX))!(GNDX="") S GIEN=GREF ; IF NO INDEX USED, GREF IS THE IEN
|
---|
| 140 | E D ; WE ARE USING AN INDEX
|
---|
| 141 | . ;N ZG
|
---|
| 142 | . S ZG=$Q(@GF@(GNDX,GREF)) ;ACCESS INDEX
|
---|
| 143 | . I ZG'="" D ;
|
---|
| 144 | . . I $QS(ZG,3)=GREF D ; IS GREF IN INDEX?
|
---|
| 145 | . . . S GIEN=$QS(ZG,4) ; PULL OUT THE IEN
|
---|
| 146 | . . E S GIEN="" ; NOT FOUND IN INDEX
|
---|
| 147 | . E S GIEN="" ;
|
---|
| 148 | ;W "IEN: ",GIEN,!
|
---|
| 149 | ;N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
|
---|
| 150 | I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)
|
---|
| 151 | E S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)
|
---|
| 152 | S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
|
---|
| 153 | D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP
|
---|
| 154 | K C0CTMP
|
---|
| 155 | D GETS^DIQ(GFILE,C0CREF,"**","IE","C0CTMP")
|
---|
| 156 | D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
|
---|
| 157 | S @GRTN@(0)=GFILE_"^RNF1^"_GIEN_"^"_DT_"^"_$J_"^"_DUZ ; STRUCTURE SIGNATURE
|
---|
| 158 | S (C0CI,C0CJ)=""
|
---|
| 159 | F S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ="" D ; FOR ALL SUBFILES
|
---|
| 160 | . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE
|
---|
| 161 | . F S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI="" D ; ARRAY OF FIELDS
|
---|
| 162 | . . ;W C0CJ," ",C0CI,!
|
---|
| 163 | . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
|
---|
| 164 | . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,"E") ;
|
---|
| 165 | . . I C0CVALUE["C0CTMP" D ; WP FIELD
|
---|
| 166 | . . . N ZT,ZWP S ZWP=0 ;ITERATOR
|
---|
| 167 | . . . S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) ; INIT TO FIRST LINE
|
---|
| 168 | . . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ; INIT TO FIRST LINE
|
---|
| 169 | . . . F S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) Q:'ZWP D ;
|
---|
| 170 | . . . . S ZT=" "_C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ;LINE OF WP
|
---|
| 171 | . . . . S ZT=$TR(ZT,"^""","|'") ;HACK TO GET RID OF ^ AND " IN TEXT "
|
---|
| 172 | . . . . S C0CVALUE=C0CVALUE_ZT ;
|
---|
| 173 | . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3
|
---|
| 174 | . . S $P(@GRTN@(C0CNAME,"I"),"^",3)=$G(C0CTMP(C0CJ,C0CREF,C0CI,"I"))
|
---|
| 175 | I C0CNN D ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED
|
---|
| 176 | . S C0CI=""
|
---|
| 177 | . F S C0CI=$O(@GRTN@(C0CI)) Q:C0CI="" D ; GO THROUGH THE WHOLE ARRAY
|
---|
| 178 | . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES
|
---|
| 179 | Q
|
---|
| 180 | ;
|
---|
| 181 | GETN2(GARTN,GAFILE,GAIDX,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES
|
---|
| 182 | ; GARTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
|
---|
| 183 | ; .. FIELD MAP @GARTN@("F","FIELDNAME")="FILE;FIELD#"
|
---|
| 184 | ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
|
---|
| 185 | ; .. VALUE MAP @GARTN@("V","IEN","FIELDNAME","N")=VALUE
|
---|
| 186 | ; .. WHERE N IS THE INDEX FOR MULTIPLES.. 1 FOR SINGLE VALUES
|
---|
| 187 | ; .. GARTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
|
---|
| 188 | ; .. IF GANN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
|
---|
| 189 | ; .. EVEN IF GANN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
|
---|
| 190 | ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
|
---|
| 191 | ; GAFILE IS THE FILE NUMBER TO BE PROCESSED. IT IS PASSED BY VALUE
|
---|
| 192 | ; GAIDX IS THE OPTIONAL INDEX TO USE IN THE FILE. IF GAIDX IS "" THE IEN
|
---|
| 193 | ; .. OF THE FILE WILL BE USED
|
---|
| 194 | ; GACNT IS THE NUMBER OF RECORDS TO PROCESS. IT IS PASSED BY VALUE
|
---|
| 195 | ; .. IF GARCNT IS NULL, ALL RECORDS ARE PROCESSED
|
---|
| 196 | ; GASTRT IS THE IEN OF THE FIRST RECORD TO PROCESS. IT IS PASSED BY VALUE
|
---|
| 197 | ; .. IF GARSTART IS NULL, PROCESSING STARTS AT THE FIRST RECORD
|
---|
| 198 | ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
|
---|
| 199 | ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GARFLD AND GARVAL
|
---|
| 200 | ;N GATMP,GAI,GAF
|
---|
| 201 | S GAF=$$FILEREF(GAFILE) ; GET CLOSED ROOT FOR THE FILE NUMBER GAFILE
|
---|
| 202 | I '$D(GAIDX) S GAIDX="" ;DEFAULT
|
---|
| 203 | I '$D(GANN) S GANN="" ;DEFAULT ONLY POPULATED FIELDS RETURNED
|
---|
| 204 | I GAIDX'="" S GAF=$NA(@GAF@(GAIDX)) ; IF WE ARE USING AN INDEX
|
---|
| 205 | W GAF,!
|
---|
| 206 | W $O(@GAF@(0)) ;
|
---|
| 207 | S GAI=0 ;ITERATOR
|
---|
| 208 | F S GAI=$O(@GAF@(GAI)) Q:GAI="" D ;
|
---|
| 209 | . D GETN1("GATMP",GAFILE,GAI,GAIDX,GANN) ;GET ONE RECORD
|
---|
| 210 | . N GAX S GAX=0
|
---|
| 211 | . F S GAX=$O(GATMP(GAX)) Q:GAX="" D ;PULL OUT THE FIELDS
|
---|
| 212 | . . D ADDNV(GARTN,GAI,GAX,GATMP(GAX)) ;INSERT THE NAME/VALUE INTO GARTN
|
---|
| 213 | Q
|
---|
| 214 | ;
|
---|
| 215 | ADDNV(GNV,GNVN,GNVF,GNVV) ; CREATE AN ELEMENT OF THE MATRIX
|
---|
| 216 | ;
|
---|
| 217 | S @GNV@("F",GNVF)=$P(GNVV,"^",1)_"^"_$P(GNVV,"^",2) ;NAME=FILE^FIELD#
|
---|
| 218 | S @GNV@("V",GNVN,GNVF,1)=$P(GNVV,"^",3) ;SET THE VALUE
|
---|
| 219 | Q
|
---|
| 220 | ;
|
---|
| 221 | RNF2CSV(RNRTN,RNIN,RNSTY) ;CONVERTS AN RFN2 GLOBAL TO A CSV FORMAT
|
---|
| 222 | ; READY TO WRITE FOR USE WITH EXCEL @RNRTN@(0) IS NUMBER OF LINES
|
---|
| 223 | ; RNSTY IS STYLE OF THE OUTPUT -
|
---|
| 224 | ; .. "NV"= ROWS ARE NAMES, COLUMNS ARE VALUES
|
---|
| 225 | ; .. "VN"= ROWS ARE VALUES, COLUMNS ARE NAMES
|
---|
| 226 | ; .. DEFAULT IS "NV" BECAUSE MANY MATRICES HAVE MORE FIELDS THAN VALUES
|
---|
| 227 | N RNR,RNC ;ROW ROOT,COL ROOT
|
---|
| 228 | N RNI,RNJ,RNX
|
---|
| 229 | I '$D(RNSTY) S RNSTY="NV" ;DEFAULT
|
---|
| 230 | I RNSTY="NV" D NV(RNRTN,RNIN) ; INTERNAL SUBROUTINES DEPENDING ON ORIENTATION
|
---|
| 231 | E D VN(RNRTN,RNIN) ;
|
---|
| 232 | Q
|
---|
| 233 | ;
|
---|
| 234 | NV(RNRTN,RNIN) ;
|
---|
| 235 | S RNR=$NA(@RNIN@("F"))
|
---|
| 236 | S RNC=$NA(@RNIN@("V"))
|
---|
| 237 | ;S RNY=$P(@RNIN@(0),"^",1) ; FILE NUMBER
|
---|
| 238 | S RNX="""FILE"""_"," ; FIRST COLUMN NAME IS "FIELD"
|
---|
| 239 | S RNI=""
|
---|
| 240 | F S RNI=$O(@RNC@(RNI)) Q:RNI="" D ; FOR EACH COLUMN
|
---|
| 241 | . S RNX=RNX_RNI_"," ;ADD THE COLUMM ELEMENT AND A COMMA
|
---|
| 242 | S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
|
---|
| 243 | D PUSH^GPLXPATH(RNRTN,RNX) ; FIRST LINE CONTAINS COLUMN HEADINGS
|
---|
| 244 | S RNI=""
|
---|
| 245 | F S RNI=$O(@RNR@(RNI)) Q:RNI="" D ; FOR EACH ROW
|
---|
| 246 | . S RNX=""""_RNI_""""_"," ; FIRST ELEMENT ON ROW IS THE FIELD
|
---|
| 247 | . S RNJ=""
|
---|
| 248 | . F S RNJ=$O(@RNC@(RNJ)) Q:RNJ="" D ; FOR EACH COL
|
---|
| 249 | . . I $D(@RNC@(RNJ,RNI,1)) D ; THIS ROW HAS THIS COLUMN
|
---|
| 250 | . . . S RNX=RNX_""""_@RNC@(RNJ,RNI,1)_""""_"," ; ADD THE ELEMENT PLUS A COMMA
|
---|
| 251 | . . E S RNX=RNX_"," ; NUL COLUMN
|
---|
| 252 | . S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
|
---|
| 253 | . D PUSH^GPLXPATH(RNRTN,RNX)
|
---|
| 254 | Q
|
---|
| 255 | ;
|
---|
| 256 | VN(RNRTN,RNIN) ;
|
---|
| 257 | S RNR=$NA(@RNIN@("V"))
|
---|
| 258 | S RNC=$NA(@RNIN@("F"))
|
---|
| 259 | ;S RNY=$P(@RNIN@(0),"^",1) ; FILE NUMBER
|
---|
| 260 | S RNX="""FILE"""_"," ; FIRST COLUMN NAME IS "FIELD"
|
---|
| 261 | S RNI=""
|
---|
| 262 | F S RNI=$O(@RNC@(RNI)) Q:RNI="" D ; FOR EACH COLUMN
|
---|
| 263 | . S RNX=RNX_RNI_"," ;ADD THE COLUMM ELEMENT AND A COMMA
|
---|
| 264 | S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
|
---|
| 265 | D PUSH^GPLXPATH(RNRTN,RNX) ; FIRST LINE CONTAINS COLUMN HEADINGS
|
---|
| 266 | S RNI=""
|
---|
| 267 | F S RNI=$O(@RNR@(RNI)) Q:RNI="" D ; FOR EACH ROW
|
---|
| 268 | . S RNX=""""_RNI_""""_"," ; FIRST ELEMENT ON ROW IS THE FIELD
|
---|
| 269 | . S RNJ=""
|
---|
| 270 | . F S RNJ=$O(@RNC@(RNJ)) Q:RNJ="" D ; FOR EACH COL
|
---|
| 271 | . . I $D(@RNR@(RNI,RNJ,1)) D ; THIS ROW HAS THIS COLUMN
|
---|
| 272 | . . . S RNX=RNX_""""_@RNR@(RNI,RNJ,1)_""""_"," ; ADD THE ELEMENT PLUS A COMMA
|
---|
| 273 | . . E S RNX=RNX_"," ; NUL COLUMN
|
---|
| 274 | . S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
|
---|
| 275 | . D PUSH^GPLXPATH(RNRTN,RNX)
|
---|
| 276 | Q
|
---|
| 277 | ;
|
---|
| 278 | READCSV(PATH,NAME,GLB) ; READ A CSV FILE IN FROM UNIX TO GLB, PASSED BY NAME
|
---|
| 279 | ;
|
---|
| 280 | Q $$FTG^%ZISH(PATH,NAME,GLB,1)
|
---|
| 281 | ;
|
---|
| 282 | FILE2CSV(FNUM,FVN) ; WRITES OUT A FILEMAN FILE TO CSV
|
---|
| 283 | ;
|
---|
| 284 | ;N G1,G2
|
---|
| 285 | I '$D(FVN) S FVN="NV" ; DEFAULT ORIENTATION OF CVS FILE
|
---|
| 286 | S G1=$NA(^TMP($J,"C0CCSV",1))
|
---|
| 287 | S G2=$NA(^TMP($J,"C0CCSV",2))
|
---|
| 288 | D GETN2(G1,FNUM) ; GET THE MATRIX
|
---|
| 289 | D RNF2CSV(G2,G1,FVN) ; PREPARE THE CVS FILE
|
---|
| 290 | K @G1
|
---|
| 291 | D FILEOUT(G2,"FILE_"_FNUM_".csv")
|
---|
| 292 | K @G2
|
---|
| 293 | Q
|
---|
| 294 | ;
|
---|
| 295 | FILEOUT(FOARY,FONAM) ; WRITE OUT A FILE
|
---|
| 296 | ;
|
---|
| 297 | W $$OUTPUT^GPLXPATH($NA(@FOARY@(1)),FONAM,^TMP("GPLCCR","ODIR"))
|
---|
| 298 | Q
|
---|
| 299 | ;
|
---|
| 300 | FILEREF(FNUM) ; EXTRINSIC THAT RETURNS A CLOSED ROOT FOR FILE NUMBER FNUM
|
---|
| 301 | ;
|
---|
| 302 | N C0CF
|
---|
| 303 | S C0CF=^DIC(FNUM,0,"GL") ;OPEN ROOT TO FILE
|
---|
| 304 | S C0CF=$P(C0CF,",",1)_")" ; CLOSE THE ROOT
|
---|
| 305 | I C0CF["()" S C0CF=$P(C0CF,"()",1)
|
---|
| 306 | Q C0CF
|
---|
| 307 | ;
|
---|
| 308 | SKIP ;
|
---|
| 309 | N TXT,DIERR
|
---|
| 310 | S TXT=$$GET1^DIQ(8925,TIUIEN,"2","","TXT")
|
---|
| 311 | I $D(DIERR) D CLEAN^DILF Q
|
---|
| 312 | W " report_text:",! ;Progress Note Text
|
---|
| 313 | N LN S LN=0
|
---|
| 314 | F S LN=$O(TXT(LN)) Q:'LN D
|
---|
| 315 | . W " text"_LN_": "_TXT(LN),!
|
---|
| 316 | . Q
|
---|
| 317 | Q
|
---|
| 318 | ;
|
---|
| 319 | ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
|
---|
| 320 | ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF @ZTAB@(ZFN)
|
---|
| 321 | ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
|
---|
| 322 | I '$D(ZTAB) S ZTAB="C0CA"
|
---|
| 323 | Q $P(@ZTAB@(ZFN),"^",1)
|
---|
| 324 | ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
|
---|
| 325 | ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF @ZTAB@(ZFN)
|
---|
| 326 | ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
|
---|
| 327 | I '$D(ZTAB) S ZTAB="C0CA"
|
---|
| 328 | Q $P(@ZTAB@(ZFN),"^",2)
|
---|
| 329 | ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
|
---|
| 330 | ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF @ZTAB@(ZFN)
|
---|
| 331 | ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
|
---|
| 332 | I '$D(ZTAB) S ZTAB="C0CA"
|
---|
| 333 | Q $P($G(@ZTAB@(ZFN)),"^",3)
|
---|
| 334 | ;
|
---|
| 335 | ZVALUEI(ZFN,ZTAB) ;EXTRINSIC TO RETURN INTERNAL VALUE FOR FIELD NAME PASSED
|
---|
| 336 | ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF @ZTAB@(ZFN)
|
---|
| 337 | ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
|
---|
| 338 | I '$D(ZTAB) S ZTAB="C0CA"
|
---|
| 339 | Q $P($G(@ZTAB@(ZFN,"I")),"^",3)
|
---|
| 340 | ;
|
---|