2008-12-06 20:50:51 -05:00
|
|
|
C0CRXN ; CCDCCR/GPL - CCR RXN utilities; 12/6/08
|
|
|
|
;;0.1;CCDCCR;nopatch;noreleasedate
|
|
|
|
;Copyright 2008 WorldVistA. Licensed under the terms of the GNU
|
|
|
|
;General Public License See attached copy of the License.
|
|
|
|
;
|
|
|
|
;This program is free software; you can redistribute it and/or modify
|
|
|
|
;it under the terms of the GNU General Public License as published by
|
|
|
|
;the Free Software Foundation; either version 2 of the License, or
|
|
|
|
;(at your option) any later version.
|
|
|
|
;
|
|
|
|
;This program is distributed in the hope that it will be useful,
|
|
|
|
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;GNU General Public License for more details.
|
|
|
|
;
|
|
|
|
;You should have received a copy of the GNU General Public License along
|
|
|
|
;with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
;
|
|
|
|
W "This is the CCR RXNORM Utility Library ",!
|
|
|
|
W !
|
|
|
|
Q
|
|
|
|
;
|
2008-12-08 20:26:07 -05:00
|
|
|
EXPAND ; MAIN ROUTINE TO CREATE THE C0C RXNORM VUID EXPANSION FILE (176.112)
|
|
|
|
; READ EACH RECORD FROM 176.111 AND USE THE VUID TO LOOK UP THE RXNORM
|
|
|
|
; CODE FROM 176.001 (RXNORM CONCEPTS)
|
2008-12-09 17:19:48 -05:00
|
|
|
; POPULATE ALL FIELDS IN 176.112 AND SET "NEW" TO "Y" IF 176.111 DOES NOT
|
2008-12-08 20:26:07 -05:00
|
|
|
; ALREADY HAVE AN RXNORM CODE.
|
|
|
|
; ADD THE RXNORM TEXT FIELD TO EVERY RECORD (NOT PRESENT IN 176.111)
|
2008-12-09 17:19:48 -05:00
|
|
|
; AND COMPARE THE RXNORM TEXT FIELD WITH THE VUID TEXT FIELD, SETTING THE
|
2008-12-08 20:26:07 -05:00
|
|
|
; "DIFFERENT TEXT" FIELD TO "Y" IF THERE ARE DIFFERENCES
|
|
|
|
; USES SUPPORT ROUTINES FROM C0CRNF.m
|
2008-12-10 17:15:44 -05:00
|
|
|
;N C0CFDA,C0CA,C0CB,C0CC,C0CZX ;FDA WORK ARRAY, RNF ARRAYS, AND IEN ITERATOR
|
|
|
|
;N C0CFVA,C0CFRXN ; CLOSED ROOTS FOR SOURCE FILES
|
|
|
|
;N C0CF ; CLOSED ROOT FOR DESTINATION FILE
|
2008-12-08 20:26:07 -05:00
|
|
|
S C0CVA=$$FILEREF^C0CRNF(176.111) ; C0C PHARMACY VA RXNORM MAPPING FILE
|
2008-12-10 17:15:44 -05:00
|
|
|
S C0CFRXN=$$FILEREF^C0CRNF(176.001) ; CLOSED ROOT FOR RXNORM CONCEPT FILE
|
|
|
|
S C0CF=$$FILEREF^C0CRNF(176.112) ; C0C RXNORM VUID MAPPING EXPANSION FILE
|
|
|
|
W C0CVA,C0CFRXN,C0CF,!
|
2008-12-09 17:19:48 -05:00
|
|
|
S C0CZX=0
|
2008-12-10 17:15:44 -05:00
|
|
|
S (HASRXN,NORXN,NOVUID,RXFOUND,RXMATCH,TXTMATCH)=0 ; INITIALIZE COUNTERS
|
2008-12-09 17:19:48 -05:00
|
|
|
F S C0CZX=$O(^C0CCODES(176.111,C0CZX)) Q:+C0CZX=0 D ; FOR EVERY RECORD
|
2008-12-10 17:15:44 -05:00
|
|
|
. K C0CA,C0CB,C0CC ; CLEAR ARRAYS
|
|
|
|
. D FIELDS^C0CRNF("C0CC",176.112) ;GET FIELD NAMES FOR OUTPUT FILE
|
|
|
|
. D GETN2^C0CRNF("C0CA",176.111,C0CZX,"","ALL") ;GET THE FIELDS
|
2008-12-09 17:19:48 -05:00
|
|
|
. I $$ZVALUE("MEDIATION CODE")="" D
|
|
|
|
. . S NORXN=NORXN+1 ;
|
2008-12-10 17:15:44 -05:00
|
|
|
. E D ; PROCESS MEDIATION CODE
|
|
|
|
. . S HASRXN=HASRXN+1
|
|
|
|
. . D SETFDA("MEDIATION CODE",$$ZVALUE("MEDIATION CODE")) ;
|
2008-12-09 17:19:48 -05:00
|
|
|
. I $$ZVALUE("VUID")="" D ; BAD RECORD
|
|
|
|
. . S NOVUID=NOVUID+1
|
2008-12-10 17:15:44 -05:00
|
|
|
. . ;D SETFDA("VUID",$$ZVALUE("VUID"))
|
|
|
|
. E D SETFDA("VUID TEXT",$$ZVALUE("VUID TEXT"))
|
|
|
|
. . ;ZWR C0CA
|
|
|
|
. D GETN2^C0CRNF("C0CB",176.001,$$ZVALUE("VUID"),"VUID","ALL")
|
|
|
|
. I $$ZVALUE("RXCUI","C0CB")'="" D ; RXNORM FOUND
|
|
|
|
. . S RXFOUND=RXFOUND+1
|
|
|
|
. . I $$ZVALUE("MEDIATION CODE")="" D ; THIS IS A NEW CODE
|
|
|
|
. . . D SETFDA("MEDIATION CODE",$$ZVALUE("RXCUI","C0CB"))
|
|
|
|
. . . D SETFDA("NEW","Y") ;FLAG RECORD HAS HAVING NEW RXNORM
|
|
|
|
. . W "RXNORM=",$$ZVALUE("RXCUI","C0CB")," ",$$ZVALUE("STR","C0CB"),!
|
|
|
|
. . W "VUID TEXT: ",$$ZVALUE("VUID TEXT"),!
|
|
|
|
. . I $$ZVALUE("VUID TEXT")=$$ZVALUE("STR","C0CB") S TXTMATCH=TXTMATCH+1
|
|
|
|
. . E D ;
|
|
|
|
. . . D PUSH^GPLXPATH("NOMATCH",$$ZVALUE("VUID TEXT")_"^"_$$ZVALUE("STR","C0CB"))
|
|
|
|
. . . D SETFDA("RXNORM TEXT",$$ZVALUE("STR","C0CB")) ;
|
|
|
|
. . . D SETFDA("DIFFERENT TEXT","Y") ;FLAG RECORD FOR DIFFERENT TEXT
|
|
|
|
. I $$ZVALUE("MEDIATION CODE")=$$ZVALUE("RXCUI","C0CB") D ;
|
|
|
|
. . S RXMATCH=RXMATCH+1
|
|
|
|
. . W "VUID=",$$ZVALUE("VUID")," MATCH RXNORM=",$$ZVALUE("MEDIATION CODE"),!
|
|
|
|
. D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP
|
|
|
|
. S C0CFDA(176.112,"+"_C0CZX_",",.01)=$$ZVALUE("VUID") ; NEW VUID RECORD
|
|
|
|
. D UPDATE^DIE("","C0CFDA")
|
|
|
|
. I $D(^TMP("DIERR",$J)) U $P BREAK
|
2008-12-09 17:19:48 -05:00
|
|
|
W "HAS RXN=",HASRXN,!
|
|
|
|
W "NO RXN=",NORXN,!
|
|
|
|
W "NO VUID=",NOVUID,!
|
2008-12-10 17:15:44 -05:00
|
|
|
W "RXNORM FOUND=",RXFOUND,!
|
|
|
|
W "RXNORM MATCHES:",RXMATCH,!
|
|
|
|
W "TEXT MATCHES:",TXTMATCH,!
|
2008-12-08 20:26:07 -05:00
|
|
|
Q
|
|
|
|
;
|
|
|
|
SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
|
|
|
|
; TO SET TO VALUE C0CSV.
|
|
|
|
; C0CFDA,C0CA,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE
|
|
|
|
; C0CSN,C0CSV ARE PASSED BY VALUE
|
|
|
|
;
|
|
|
|
N C0CSI,C0CSJ
|
2008-12-10 17:15:44 -05:00
|
|
|
S C0CSI=$$ZFILE(C0CSN,"C0CC") ; FILE NUMBER
|
|
|
|
S C0CSJ=$$ZFIELD(C0CSN,"C0CC") ; FIELD NUMBER
|
|
|
|
S C0CFDA(C0CSI,"+"_C0CZX_",",C0CSJ)=C0CSV
|
2008-12-08 20:26:07 -05:00
|
|
|
Q
|
|
|
|
ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
|
|
|
|
; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN)
|
|
|
|
; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
|
|
|
|
I '$D(ZTAB) S ZTAB="C0CA"
|
2008-12-10 17:15:44 -05:00
|
|
|
N ZR
|
|
|
|
I $D(@ZTAB@(ZFN)) S ZR=$P(@ZTAB@(ZFN),"^",1)
|
|
|
|
E S ZR=""
|
|
|
|
Q ZR
|
2008-12-08 20:26:07 -05:00
|
|
|
ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
|
|
|
|
; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN)
|
|
|
|
; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
|
|
|
|
I '$D(ZTAB) S ZTAB="C0CA"
|
2008-12-10 17:15:44 -05:00
|
|
|
N ZR
|
|
|
|
I $D(@ZTAB@(ZFN)) S ZR=$P(@ZTAB@(ZFN),"^",2)
|
|
|
|
E S ZR=""
|
|
|
|
Q ZR
|
|
|
|
;
|
2008-12-08 20:26:07 -05:00
|
|
|
ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
|
|
|
|
; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN)
|
|
|
|
; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
|
|
|
|
I '$D(ZTAB) S ZTAB="C0CA"
|
2008-12-10 17:15:44 -05:00
|
|
|
N ZR
|
|
|
|
I $D(@ZTAB@(ZFN)) S ZR=$P(@ZTAB@(ZFN),"^",3)
|
|
|
|
E S ZR=""
|
|
|
|
Q ZR
|
2008-12-08 20:26:07 -05:00
|
|
|
;
|