VistA-ccr/p/C0CRXN.m

81 lines
3.3 KiB
Mathematica
Raw Normal View History

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
;
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)
; POPULATE ALL FIELDS IN 176.112 AND SET "NEW" TO "Y" IF 176.111 DOES NOT
; ALREADY HAVE AN RXNORM CODE.
; ADD THE RXNORM TEXT FIELD TO EVERY RECORD (NOT PRESENT IN 176.111)
; AND COMPARE THE RXNORM TEXT FIELD WITH THE VUID TEXT FIELD, SETTING THE
; "DIFFERENT TEXT" FIELD TO "Y" IF THERE ARE DIFFERENCES
; USES SUPPORT ROUTINES FROM C0CRNF.m
N C0CFDA,C0CA,C0CB,C0CZX ;FDA WORK ARRAY, RNF ARRAYS, AND IEN ITERATOR
N C0CFVA,C0CFRXN ; CLOSED ROOTS FOR SOURCE FILES
N C0CF ; CLOSED ROOT FOR DESTINATION FILE
S C0CVA=$$FILEREF^C0CRNF(176.111) ; C0C PHARMACY VA RXNORM MAPPING FILE
;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,!
S C0CZX=0
S (HASRXN,NORXN,NOVUID)=0 ; INITIALIZE COUNTERS
F S C0CZX=$O(^C0CCODES(176.111,C0CZX)) Q:+C0CZX=0 D ; FOR EVERY RECORD
. D GETN^C0CRNF("C0CA",176.111,C0CZX,"ALL") ;GET THE FIELDS
. I $$ZVALUE("MEDIATION CODE")="" D
. . S NORXN=NORXN+1 ;
. E S HASRXN=HASRXN+1
. I $$ZVALUE("VUID")="" D ; BAD RECORD
. . S NOVUID=NOVUID+1
. . ZWR C0CA
W "HAS RXN=",HASRXN,!
W "NO RXN=",NORXN,!
W "NO VUID=",NOVUID,!
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
S C0CSI=$$ZFILE(C0CSN,"C0CA") ; FILE NUMBER
S C0CSJ=$$ZFIELD(C0CSN,"C0CA") ; FIELD NUMBER
S C0CFDA(C0CZX,C0CSI,C0CZX_",",C0CSJ)=C0CSV
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"
Q $P(@ZTAB@(ZFN),"^",1)
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"
Q $P(@ZTAB@(ZFN),"^",2)
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"
Q $P(@ZTAB@(ZFN),"^",3)
;