source: ccr/trunk/rxnorm/trunk/routines/C0CRXNAD.m@ 1630

Last change on this file since 1630 was 1630, checked in by Sam Habiel, 10 years ago

Two routines modified: C0CRXNRD and C0CRXNLK.

C0CRXNRD (loader utility):

  • Can now import RxNorm prescribably subset
  • Will import public domain by default except if RESTRICTED is passed to IMPORT as 1 (second parameter).

C0CRXNLK (lookup utilities):

  • FDB Unit Tests don't run if FDB from RxNorm isn't loaded.
  • New API: $$RXN2GCN - Get GCNs from RXNCUI (+UT).
  • New API: $$VUI2GCN - Get VUIDs from GCN (No UT supplied).
  • New API: $$RXN2NDC - Get NDCs for a given RxNorm CUI (+UT).
File size: 4.8 KB
Line 
1C0CRXNAD ; VEN/SMH - Add a drug to VISTA from RxNorm;2013-04-19 5:39 PM
2 ;;2.2;RXNORM FOR VISTA;;Nov 14, 2013;Build 8
3 ; (C) 2013 Sam Habiel
4 ; Proprietary Code. Don't use if license terms aren't supplied.
5 ;
6ADDDRUG(RXN,NDC,BARCODE) ; Public Proc; Add Drug to Drug File
7 ; Input: RXN - RxNorm Semantic Clinical Drug CUI by Value. Required.
8 ; Input: NDC - Drug NDC by Value. Optional. Pass in 11 digit format without dashes.
9 ; Input: BARCODE - Wand Barcode. Optional. Pass exactly as wand reads minus control characters.
10 ; Output: Internal Entry Number
11 ;
12 ; Prelim Checks
13 I '$G(RXN) S $EC=",U1," ; Required
14 I $L($G(NDC)),$L(NDC)'=11 S $EC=",U1,"
15 ;
16 N PSSZ S PSSZ=1 ; Needed for the drug file to let me in!
17 ;
18 ; If RXN refers to a brand drug, get the generic instead.
19 I $$ISBRAND^C0CRXNLK(RXN) S RXN=$$BR2GEN^C0CRXNLK(RXN)
20 W !,"(debug) RxNorm is "_RXN,!
21 ;
22 ; Get first VUID for this RxNorm drug
23 N VUID S VUID=+$$RXN2VUI^C0CRXNLK(RXN)
24 Q:'VUID
25 W "(debug) VUID for RxNorm CUI "_RXN_" is "_VUID,!
26 ;
27 ; IEN in 50.68
28 N C0XVUID ; For Searching Compound Index
29 S C0XVUID(1)=VUID
30 S C0XVUID(2)=1
31 N F5068IEN S F5068IEN=$$FIND1^DIC(50.68,"","XQ",.C0XVUID,"AMASTERVUID")
32 Q:'F5068IEN
33 W "F 50.68 IEN (debug): "_F5068IEN,!
34 ;
35 ; FDA Array
36 N C0XFDA
37 ;
38 ; Name, shortened
39 S C0XFDA(50,"+1,",.01)=$E($$GET1^DIQ(50.68,F5068IEN,.01),1,40)
40 ;
41 ; File BarCode as a Synonym for BCMA
42 I $L($G(BARCODE)) D
43 . S C0XFDA(50.1,"+2,+1,",.01)=BARCODE
44 . S C0XFDA(50.1,"+2,+1,",1)="Q"
45 ;
46 ; Brand Names
47 N BNS S BNS=$$RXN2BNS^C0CRXNLK(RXN) ; Brands
48 I $L(BNS) N I F I=1:1:$L(BNS,U) D
49 . N IENS S IENS=I+2
50 . S C0XFDA(50.1,"+"_IENS_",+1,",.01)=$$UP^XLFSTR($E($P(BNS,U,I),1,40))
51 . S C0XFDA(50.1,"+"_IENS_",+1,",1)="T"
52 ;
53 ; NDC (string)
54 I $G(NDC) S C0XFDA(50,"+1,",31)=$E(NDC,1,5)_"-"_$E(NDC,6,9)_"-"_$E(NDC,10,11)
55 ;
56 ; Dispense Unit (string)
57 S C0XFDA(50,"+1,",14.5)=$$GET1^DIQ(50.68,F5068IEN,"VA DISPENSE UNIT")
58 ;
59 ; National Drug File Entry (pointer to 50.6)
60 S C0XFDA(50,"+1,",20)="`"_$$GET1^DIQ(50.68,F5068IEN,"VA GENERIC NAME","I")
61 ;
62 ; VA Product Name (string)
63 S C0XFDA(50,"+1,",21)=$E($$GET1^DIQ(50.68,F5068IEN,.01),1,70)
64 ;
65 ; PSNDF VA PRODUCT NAME ENTRY (pointer to 50.68)
66 S C0XFDA(50,"+1,",22)="`"_F5068IEN
67 ;
68 ; DEA, SPECIAL HDLG (string)
69 D ; From ^PSNMRG
70 . N CS S CS=$$GET1^DIQ(50.68,F5068IEN,"CS FEDERAL SCHEDULE","I")
71 . S CS=$S(CS?1(1"2n",1"3n"):+CS_"C",+CS=2!(+CS=3)&(CS'["C"):+CS_"A",1:CS)
72 . S C0XFDA(50,"+1,",3)=CS
73 ;
74 ; NATIONAL DRUG CLASS (pointer to 50.605) (triggers VA Classification field)
75 S C0XFDA(50,"+1,",25)="`"_$$GET1^DIQ(50.68,F5068IEN,"PRIMARY VA DRUG CLASS","I")
76 ;
77 ; Right Now, I don't file the following which ^PSNMRG does (cuz I don't need them)
78 ; - Package Size (derived from NDC/UPN file)
79 ; - Package Type (ditto)
80 ; - CMOP ID (from $$PROD2^PSNAPIS)
81 ; - National Formulary Indicator (from 50.68)
82 ;
83 ; Next Step is to kill Old OI if Dosage Form doesn't match
84 ; Won't do that here as it's assumed any drugs that's added is new.
85 ; This happens at ^PSNPSS
86 ;
87 ; Now add drug to drug file, as we need the IEN for the dosages call.
88 N C0XERR,C0XIEN
89 D UPDATE^DIE("E","C0XFDA","C0XIEN","C0XERR")
90 S:$D(C0XERR) $EC=",U1,"
91 ;
92 ; Next Step: Kill off old doses and add new ones.
93 D EN2^PSSUTIL(C0XIEN(1))
94 ;
95 ; Mark uses for the Drug; use the undocumented Silent call in PSSGIU
96 N PSIUDA,PSIUX ; Expected Input variables
97 S PSIUDA=C0XIEN(1),PSIUX="O^Outpatient Pharmacy" D ENS^PSSGIU
98 S PSIUDA=C0XIEN(1),PSIUX="U^Unit Dose" D ENS^PSSGIU
99 S PSIUDA=C0XIEN(1),PSIUX="X^Non-VA Med" D ENS^PSSGIU
100 ;
101 ; Get VA Generic text and VA Product pointer for Orderable Item creation plus dosage form information
102 N VAGENP S VAGENP=$P(^PSDRUG(C0XIEN(1),"ND"),U) ; VA Generic Pointer
103 N VAGEN S VAGEN=$$VAGN^PSNAPIS(VAGENP) ; VA Generic Full name
104 N VAPRODP S VAPRODP=$P(^PSDRUG(C0XIEN(1),"ND"),U,3) ; VA Product Pointer
105 N DOSAGE S DOSAGE=$$PSJDF^PSNAPIS(0,VAPRODP) ; IEN of dose form in 50.606 ^ Text
106 N DOSEPTR S DOSEPTR=$P(DOSAGE,U) ; ditto
107 N DOSEFORM S DOSEFORM=$P(DOSAGE,U,2) ;ditto
108 ;
109 ; Get the (possibly new) Orderable Item Text
110 N VAG40 S VAG40=$E(VAGEN,1,40) ; Max length of .01 field
111 ;
112 ; See if there is an existing orderable item already. If so, populate the Pharmacy Orderable item on drug file.
113 N OI S OI=$O(^PS(50.7,"ADF",VAG40,DOSEPTR,""))
114 ;
115 ; Otherwise, add a new one. (See MCHAN+12^PSSPOIMN)
116 I 'OI D
117 . N C0XFDA,C0XERR
118 . S C0XFDA(50.7,"+1,",.01)=VAG40
119 . S C0XFDA(50.7,"+1,",.02)=DOSEPTR
120 . D UPDATE^DIE("",$NA(C0XFDA),$NA(OI),$NA(C0XERR))
121 . I $D(C0XERR) S $EC=",U1,"
122 . S OI=OI(1) ; For ease of use...
123 . ; Next two statements: See FIN^PSSPOIM1 and MF^PSSDEE.
124 . D EN^PSSPOIDT(OI) ; Update Indexes; activations, etc.
125 . D EN2^PSSHL1(OI,"MUP") ; Send HL7 message to CPRS
126 ;
127 ; Finally, add the orderable Item to the drug file.
128 N C0XFDA,C0XERR S C0XFDA(50,C0XIEN(1)_",",2.1)=OI ; Orderable Item
129 D FILE^DIE("",$NA(C0XFDA),$NA(C0XERR))
130 S:$D(C0XERR) $EC=",U1,"
131 ;
132EX QUIT C0XIEN(1)
Note: See TracBrowser for help on using the repository browser.