Ignore:
Timestamp:
Jan 3, 2012, 11:45:29 PM (13 years ago)
Author:
George Lilly
Message:

new ohum version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/branches/ohum/p/C0CRNFRP.m

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