Changeset 307


Ignore:
Timestamp:
Dec 14, 2008, 2:35:31 PM (16 years ago)
Author:
George Lilly
Message:

improvements to RNF format routines. FILE2CSVC0CRNF to export files to csv

Location:
ccr/trunk/p
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/C0CDIC.m

    r301 r307  
    122122 . ;W C0CZX,!
    123123 . K C0CA,C0CN ; CLEAR OUT THE LAST ONE
    124  . D GETN^C0CRNF("C0CA",170,C0CZX,"ALL") ; GET VARIABLE HASH
     124 . D GETN1^C0CRNF("C0CA",170,C0CZX,"","ALL") ; GET VARIABLE HASH
    125125 . ;ZWR C0CA B ;
    126126 . S C0CN=$$ZVALUE("VARIABLE") ;NAME OF THE VARIABLE
  • ccr/trunk/p/C0CRNF.m

    r304 r307  
    4343 Q
    4444 ;
    45 GETN(GRTN,GFILE,GIEN,GNN) ; GET FIELDS FOR ACCESS BY NAME
     45GETNOLD(GRTN,GFILE,GIEN,GNN) ; GET FIELDS FOR ACCESS BY NAME
    4646 ; GRTN IS PASSED BY NAME
    4747 ;
     
    6969 Q
    7070 ;
    71 GETN2(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
     71GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
    7272 ; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN
    7373 ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
     
    121121 Q
    122122 ;
    123 GETALL(GARTN,GAFILE,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES
     123GETN2(GARTN,GAFILE,GAIDX,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES
    124124 ; GARTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
    125  ; .. FIELD MAP @GARTN@("F","FIELDNAME^FILE^FIELD#")=""
     125 ; .. FIELD MAP @GARTN@("F","FIELDNAME")="FILE;FIELD#"
    126126 ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
    127  ; .. VALUE MAP @GARTN@("V","IEN","FIELDNAME")=VALUE
     127 ; .. VALUE MAP @GARTN@("V","IEN","FIELDNAME","N")=VALUE
     128 ; .. WHERE N IS THE INDEX FOR MULTIPLES.. 1 FOR SINGLE VALUES
    128129 ; .. GARTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
    129130 ; .. IF GANN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
     
    131132 ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
    132133 ; GAFILE IS THE FILE NUMBER TO BE PROCESSED. IT IS PASSED BY VALUE
     134 ; GAIDX IS THE OPTIONAL INDEX TO USE IN THE FILE. IF GAIDX IS "" THE IEN
     135 ; .. OF THE FILE WILL BE USED
    133136 ; GACNT IS THE NUMBER OF RECORDS TO PROCESS. IT IS PASSED BY VALUE
    134137 ; .. IF GARCNT IS NULL, ALL RECORDS ARE PROCESSED
     
    137140 ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
    138141 ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GARFLD AND GARVAL
    139  N GATMP,GAI,GAF
     142 ;N GATMP,GAI,GAF
    140143 S GAF=$$FILEREF(GAFILE) ; GET CLOSED ROOT FOR THE FILE NUMBER GAFILE
     144 I '$D(GAIDX) S GAIDX="" ;DEFAULT
     145 I '$D(GANN) S GANN="" ;DEFAULT ONLY POPULATED FIELDS RETURNED
     146 I GAIDX'="" S GAF=$NA(@GAF@(GAIDX)) ; IF WE ARE USING AN INDEX
    141147 W GAF,!
    142148 W $O(@GAF@(0)) ;
    143149 S GAI=0 ;ITERATOR
    144  ; F  S GAI=$O(@GAF@
     150 F  S GAI=$O(@GAF@(GAI)) Q:GAI=""  D  ;
     151 . D GETN1("GATMP",GAFILE,GAI,GAIDX,GANN) ;GET ONE RECORD
     152 . N GAX S GAX=0
     153 . F  S GAX=$O(GATMP(GAX)) Q:GAX=""  D  ;PULL OUT THE FIELDS
     154 . . D ADDNV(GARTN,GAI,GAX,GATMP(GAX)) ;INSERT THE NAME/VALUE INTO GARTN
     155 Q
     156 ;
     157ADDNV(GNV,GNVN,GNVF,GNVV) ; CREATE AN ELEMENT OF THE MATRIX
     158 ;
     159 S @GNV@("F",GNVF)=$P(GNVV,"^",1)_"^"_$P(GNVV,"^",2) ;NAME=FILE^FIELD#
     160 S @GNV@("V",GNVN,GNVF,1)=$P(GNVV,"^",3) ;SET THE VALUE
     161 Q
     162 ;
     163RNF2CSV(RNRTN,RNIN,RNSTY) ;CONVERTS AN RFN2 GLOBAL TO A CSV FORMAT
     164 ; READY TO WRITE FOR USE WITH EXCEL @RNRTN@(0) IS NUMBER OF LINES
     165 ; RNSTY IS STYLE OF THE OUTPUT -
     166 ; .. "NV"= ROWS ARE NAMES, COLUMNS ARE VALUES
     167 ; .. "VN"= ROWS ARE VALUES, COLUMNS ARE NAMES
     168 ; .. DEFAULT IS "NV" BECAUSE MANY MATRICES HAVE MORE FIELDS THAN VALUES
     169 N RNR,RNC ;ROW ROOT,COL ROOT
     170 N RNI,RNJ,RNX
     171 I '$D(RNSTY) S RNSTY="NV" ;DEFAULT
     172 I RNSTY="NV" D NV(RNRTN,RNIN)  ; INTERNAL SUBROUTINES DEPENDING ON ORIENTATION
     173 E  D VN(RNRTN,RNIN) ;
     174 Q
     175 ;
     176NV(RNRTN,RNIN) ;
     177 S RNR=$NA(@RNIN@("F"))
     178 S RNC=$NA(@RNIN@("V"))
     179 ;S RNY=$P(@RNIN@(0),"^",1) ; FILE NUMBER
     180 S RNX="""FILE"""_"," ; FIRST COLUMN NAME IS "FIELD"
     181 S RNI=""
     182 F  S RNI=$O(@RNC@(RNI)) Q:RNI=""  D  ; FOR EACH COLUMN
     183 . S RNX=RNX_RNI_"," ;ADD THE COLUMM ELEMENT AND A COMMA
     184 S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
     185 D PUSH^GPLXPATH(RNRTN,RNX) ; FIRST LINE CONTAINS COLUMN HEADINGS
     186 S RNI=""
     187 F  S RNI=$O(@RNR@(RNI)) Q:RNI=""  D  ; FOR EACH ROW
     188 . S RNX=""""_RNI_""""_"," ; FIRST ELEMENT ON ROW IS THE FIELD
     189 . S RNJ=""
     190 . F  S RNJ=$O(@RNC@(RNJ)) Q:RNJ=""  D  ; FOR EACH COL
     191 . . I $D(@RNC@(RNJ,RNI,1)) D  ; THIS ROW HAS THIS COLUMN
     192 . . . S RNX=RNX_""""_@RNC@(RNJ,RNI,1)_""""_"," ; ADD THE ELEMENT PLUS A COMMA
     193 . . E  S RNX=RNX_"," ; NUL COLUMN
     194 . S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
     195 . D PUSH^GPLXPATH(RNRTN,RNX)
     196 Q
     197 ;
     198VN(RNRTN,RNIN) ;
     199 S RNR=$NA(@RNIN@("V"))
     200 S RNC=$NA(@RNIN@("F"))
     201 ;S RNY=$P(@RNIN@(0),"^",1) ; FILE NUMBER
     202 S RNX="""FILE"""_"," ; FIRST COLUMN NAME IS "FIELD"
     203 S RNI=""
     204 F  S RNI=$O(@RNC@(RNI)) Q:RNI=""  D  ; FOR EACH COLUMN
     205 . S RNX=RNX_RNI_"," ;ADD THE COLUMM ELEMENT AND A COMMA
     206 S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
     207 D PUSH^GPLXPATH(RNRTN,RNX) ; FIRST LINE CONTAINS COLUMN HEADINGS
     208 S RNI=""
     209 F  S RNI=$O(@RNR@(RNI)) Q:RNI=""  D  ; FOR EACH ROW
     210 . S RNX=""""_RNI_""""_"," ; FIRST ELEMENT ON ROW IS THE FIELD
     211 . S RNJ=""
     212 . F  S RNJ=$O(@RNC@(RNJ)) Q:RNJ=""  D  ; FOR EACH COL
     213 . . I $D(@RNR@(RNI,RNJ,1)) D  ; THIS ROW HAS THIS COLUMN
     214 . . . S RNX=RNX_""""_@RNR@(RNI,RNJ,1)_""""_"," ; ADD THE ELEMENT PLUS A COMMA
     215 . . E  S RNX=RNX_"," ; NUL COLUMN
     216 . S RNX=$E(RNX,1,$L(RNX)-1) ; STRIP OFF THE LAST COMMA
     217 . D PUSH^GPLXPATH(RNRTN,RNX)
     218 Q
     219 ;
     220FILE2CSV(FNUM,FVN) ; WRITES OUT A FILEMAN FILE TO CSV
     221 ;
     222 ;N G1,G2
     223 I '$D(FVN) S FVN="NV" ; DEFAULT ORIENTATION OF CVS FILE
     224 S G1=$NA(^TMP($J,"C0CCSV",1))
     225 S G2=$NA(^TMP($J,"C0CCSV",2))
     226 D GETN2(G1,FNUM) ; GET THE MATRIX
     227 D RNF2CSV(G2,G1,FVN) ; PREPARE THE CVS FILE
     228 K @G1
     229 W $$OUTPUT^GPLXPATH(@G2@(1),"FILE_"_FNUM_".csv",^TMP("GPLCCR","ODIR"))
     230 K @G2
    145231 Q
    146232 ;
     
    150236 S C0CF=^DIC(FNUM,0,"GL") ;OPEN ROOT TO FILE
    151237 S C0CF=$P(C0CF,",",1)_")" ; CLOSE THE ROOT
     238 I C0CF["()" S C0CF=$P(C0CF,"()",1)
    152239 Q C0CF
    153240 ;
  • ccr/trunk/p/C0CRXN.m

    r306 r307  
    4343 . K C0CA,C0CB,C0CC ; CLEAR ARRAYS
    4444 . D FIELDS^C0CRNF("C0CC",176.112) ;GET FIELD NAMES FOR OUTPUT FILE
    45  . D GETN2^C0CRNF("C0CA",176.111,C0CZX,"","ALL") ;GET THE FIELDS
     45 . D GETN1^C0CRNF("C0CA",176.111,C0CZX,"","ALL") ;GET THE FIELDS
    4646 . I $$ZVALUE("MEDIATION CODE")="" D
    4747 . . S NORXN=NORXN+1 ;
     
    5454 . E  D SETFDA("VUID TEXT",$$ZVALUE("VUID TEXT"))
    5555 . . ;ZWR C0CA
    56  . D GETN2^C0CRNF("C0CB",176.001,$$ZVALUE("VUID"),"VUID","ALL")
     56 . D GETN1^C0CRNF("C0CB",176.001,$$ZVALUE("VUID"),"VUID","ALL")
    5757 . I $$ZVALUE("RXCUI","C0CB")'="" D  ; RXNORM FOUND
    5858 . . S RXFOUND=RXFOUND+1
     
    8686 ; CROSS CHECKS THE NATIONAL DRUG FILE AND THE VA MAPPING FILE AGAINST
    8787 ; THE UMLS RXNORM DATABASE
    88  ; IF THE VUID EXISISTS IN ALL THREE FILES, THE RXNORM CODE MATCHES IN 
     88 ; IF THE VUID EXISISTS IN ALL THREE FILES, THE RXNORM CODE MATCHES IN
    8989 ; THE VA MAPPING FILE AND THE TEXT STRINGS ARE THE SAME, THE VUID IS INCLUDED
    9090 ; IN THE FILE BUT NO FLAGS ARE SET
     
    9595 ; IF THE TEXT STRINGS DO NOT MATCH EXACTLY, TXTM=N AND ALL THREE STRINGS
    9696 ; ARE SHOWN; NDF TEXT=NDF TEXT STRING, VA MAP TEXT=VA MAPPING TEXT STRING
    97  ; RXNORM TEXT=RXNORM TEXT STRING 
     97 ; RXNORM TEXT=RXNORM TEXT STRING
    9898 ; THE FILE IS KEYED ON VUID AND WOULD USUALLY BE SORTED BY VUID
    99  ; THE OBJECTIVE IS TO SEE IF NDF (50.68) AND VA MAPPING (176.111) HAVE 
     99 ; THE OBJECTIVE IS TO SEE IF NDF (50.68) AND VA MAPPING (176.111) HAVE
    100100 ; ALL THE VUID CODES THAT ARE IN THE UMLS RXNORM DATABASE
    101101 N C0CFDA,C0CA,C0CB,C0CC,C0CZX ;FDA WORK ARRAY, RNF ARRAYS, AND IEN ITERATOR
     
    112112 . K C0CA,C0CB,C0CC,C0CD ; CLEAR ARRAYS
    113113 . D FIELDS^C0CRNF("C0CC",176.113) ;GET FIELD NAMES FOR OUTPUT FILE
    114  . D GETN2^C0CRNF("C0CA",176.001,C0CZX,"VUID","ALL") ;GET FROM RXNORM FILE
    115  . D GETN2^C0CRNF("C0CB",176.111,C0CZX,"B","ALL") ;GET FROM VA MAPPING FILE
    116  . D GETN2^C0CRNF("C0CD",50.68,C0CZX,"AVUID","ALL") ;GET FROM NDF
     114 . D GETN1^C0CRNF("C0CA",176.001,C0CZX,"VUID","ALL") ;GET FROM RXNORM FILE
     115 . D GETN1^C0CRNF("C0CB",176.111,C0CZX,"B","ALL") ;GET FROM VA MAPPING FILE
     116 . D GETN1^C0CRNF("C0CD",50.68,C0CZX,"AVUID","ALL") ;GET FROM NDF
    117117 . ;D SETFDA("VUID",$$ZVALUE("CODE")) ;SET THE VUID CODE
    118118 . D SETFDA("RXNORM",$$ZVALUE("RXCUI")) ;SET THE RXNORM CODE
     
    134134 . . . S NDFTCNT=NDFTCNT+1 ; INCREMENT MISMATCHED NDF TEXT COUNT
    135135 . . . D SETFDA("TXTM","N") ; SET TEXT MATCH FLAG TO N
    136  . . . D SETFDA("NDF TEXT",$$ZVALUE("NAME","C0CD")) ;POST THE TEXT 
     136 . . . D SETFDA("NDF TEXT",$$ZVALUE("NAME","C0CD")) ;POST THE TEXT
    137137 . E  D  ;
    138138 . . D SETFDA("NDF","N") ;MARK AS MISSING
     
    152152 ; USING THE AVUID INDEX, READS ALL VUID CODES IN ^PSNDF(50.68),
    153153 ; CHECKS TO SEE IF THE CODE IS IN 176.001, AND CREATES A RECORD
    154  ; IN 176.114 
    155  ; THE OBJECTIVE IS TO SEE IF ^PSNDF(50.68) HAS ALL THE VUID CODES IN THE 
     154 ; IN 176.114
     155 ; THE OBJECTIVE IS TO SEE IF ^PSNDF(50.68) HAS ALL THE VUID CODES IN THE
    156156 ; UMLS RXNORM DATABASE AND IF THE TEXT FIELDS MATCH
    157157 ; ALSO CAPTURES THE RXNORM CODE MAPPING
     
    173173 . K C0CA,C0CB,C0CC,C0CD ; CLEAR ARRAYS
    174174 . ;D FIELDS^C0CRNF("C0CC",176.113) ;GET FIELD NAMES FOR OUTPUT FILE
    175  . D GETN2^C0CRNF("C0CA",50.68,C0CZX,"AVUID","ALL") ;GET THE FIELDS
     175 . D GETN1^C0CRNF("C0CA",50.68,C0CZX,"AVUID","ALL") ;GET THE FIELDS
    176176 . I $$ZVALUE("VUID")="" D  ; ERROR, SHOULD NOT HAPPEN
    177177 . . S NOVUID=NOVUID+1 ; FLAG THE ERROR
    178178 . . D PUSH^GPLXPATH("NOVUID",C0CZX) ; RECORD THE VUID
    179  . D GETN2^C0CRNF("C0CD",176.001,C0CZX,"VUID","ALL") ;TRY RXNORM DB
     179 . D GETN1^C0CRNF("C0CD",176.001,C0CZX,"VUID","ALL") ;TRY RXNORM DB
    180180 . I $$ZVALUE("CODE","C0CD")=C0CZX D  ; FOUND IN RXNORM
    181181 . . S VMATCH=VMATCH+1 ; COUNT OF PSNDF VUIDS FOUND IN RXNORM
     
    188188 . . . D PUSH^GPLXPATH("TXTNM",ZV) ; RECORD THE TXT MISMATCH
    189189 . E  S NOMATCH=NOMATCH+1 ; NOT FOUND IN RXNORM
    190  . D GETN2^C0CRNF("C0CB",176.111,C0CZX,"B","ALL") ;TRY TO GET FROM 176.111
     190 . D GETN1^C0CRNF("C0CB",176.111,C0CZX,"B","ALL") ;TRY TO GET FROM 176.111
    191191 . I $$ZVALUE("VUID","C0CB")="" D  ; VUID NOT FOUND
    192192 . . ;W "NOT FOUND: ",C0CZX," ",$$ZVALUE("STR")," ",$$ZVALUE("RXCUI"),!
     
    199199 . . . S ZY=$$ZVALUE("VUID TEXT","C0CB")_"^"_$$ZVALUE("NAME") ;BOTH STRINGS
    200200 . . . W "VA: ",ZY,!
    201  . . . D PUSH^GPLXPATH("NVAM",ZY) ;SAVE IT 
     201 . . . D PUSH^GPLXPATH("NVAM",ZY) ;SAVE IT
    202202 W "MISSING IN MAPPING FILE: ",MISSING,!
    203203 W "FOUND IN MAPPING FILE: ",FOUND,!
     
    217217 . E  D SETFDA("VUID TEXT",$$ZVALUE("VUID TEXT"))
    218218 . . ;ZWR C0CA
    219  . D GETN2^C0CRNF("C0CB",176.001,$$ZVALUE("VUID"),"VUID","ALL")
     219 . D GETN1^C0CRNF("C0CB",176.001,$$ZVALUE("VUID"),"VUID","ALL")
    220220 . I $$ZVALUE("RXCUI","C0CB")'="" D  ; RXNORM FOUND
    221221 . . S RXFOUND=RXFOUND+1
Note: See TracChangeset for help on using the changeset viewer.