Changeset 1730 for ccr/trunk/rxnorm/trunk/routines/C0CRXNAD.m
- Timestamp:
- Apr 27, 2016, 7:02:22 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/rxnorm/trunk/routines/C0CRXNAD.m
r1642 r1730 1 C0CRXNAD 2 ;;2.3;RXNORM FOR VISTA;;Jul 22, 2014;Build 10 3 4 5 6 ADDDRUG(RXN,NDC,BARCODE) 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 EX 1 C0CRXNAD ; VEN/SMH - Add a drug to VISTA from RxNorm;2013-04-19 5:39 PM 2 ;;2.5;RXNORM FOR VISTA;;Apr 27, 2016;Build 17 3 ; (C) 2013 Sam Habiel 4 ; Proprietary Code. Don't use if license terms aren't supplied. 5 ; 6 ADDDRUG(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 ; 132 EX QUIT C0XIEN(1)
Note:
See TracChangeset
for help on using the changeset viewer.