From be4ee117294b45437eec71d2ee7ae32ff3ce5eef Mon Sep 17 00:00:00 2001 From: sam Date: Fri, 5 Aug 2016 18:35:54 +0000 Subject: [PATCH] Added web service call as an example --- rxnorm/trunk/routines/C0CRXNAD.m | 36 +++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/rxnorm/trunk/routines/C0CRXNAD.m b/rxnorm/trunk/routines/C0CRXNAD.m index 6f2d9e9..97963a5 100644 --- a/rxnorm/trunk/routines/C0CRXNAD.m +++ b/rxnorm/trunk/routines/C0CRXNAD.m @@ -1,7 +1,30 @@ C0CRXNAD ; VEN/SMH - Add a drug to VISTA from RxNorm;2013-04-19 5:39 PM ;;2.5;RXNORM FOR VISTA;;Apr 27, 2016;Build 17 - ; (C) 2013 Sam Habiel - ; Proprietary Code. Don't use if license terms aren't supplied. + ; (C) 2016 Sam Habiel + ; + N X + R "Enter GCNSEQNO (with leading zeros): ",X:DTIME,! + E QUIT + I X="" QUIT + I X="^" QUIT + N URL S URL="https://rxnav.nlm.nih.gov/REST/rxcui.json?idtype=GCN_SEQNO&id="_X + K ^TMP("C0CJSON",$J),^TMP("C0CARR1",$J) + N STATUS S STATUS=$$GETURL^XTHC10(URL,1,$NA(^TMP("C0CJSON",$J))) + I +STATUS'=200 W "ERROR",! QUIT + D DECODE^VPRJSON($NA(^TMP("C0CJSON",$J)),$NA(^TMP("C0CARR1",$J))) + N I F I=0:0 S I=$O(^TMP("C0CARR1",$J,"idGroup","rxnormId",I)) Q:'I D + . N RXN S RXN=^TMP("C0CARR1",$J,"idGroup","rxnormId",I) + . S URL="https://rxnav.nlm.nih.gov/REST/rxcui/{RXN}/property.json?propName=VUID" + . N % S %("{RXN}")=RXN + . S URL=$$REPLACE^XLFSTR(URL,.%) + . K ^TMP("C0CJSON",$J),^TMP("C0CARR2",$J) + . N STATUS S STATUS=$$GETURL^XTHC10(URL,1,$NA(^TMP("C0CJSON",$J))) + . D DECODE^VPRJSON($NA(^TMP("C0CJSON",$J)),$NA(^TMP("C0CARR2",$J))) + . N DONE S DONE=0 + . N J F J=0:0 S J=$O(^TMP("C0CARR2",$J,"propConceptGroup","propConcept",J)) Q:'J D Q:DONE + .. N VAPRDVUID S VAPRDVUID=^TMP("C0CARR2",$J,"propConceptGroup","propConcept",J,"propValue") + .. S DONE=$$ADDDRUG2(RXN,VAPRDVUID) + QUIT ; ADDDRUG(RXN,NDC,BARCODE) ; Public Proc; Add Drug to Drug File ; Input: RXN - RxNorm Semantic Clinical Drug CUI by Value. Required. @@ -13,8 +36,6 @@ ADDDRUG(RXN,NDC,BARCODE) ; Public Proc; Add Drug to Drug File I '$G(RXN) S $EC=",U1," ; Required I $L($G(NDC)),$L(NDC)'=11 S $EC=",U1," ; - N PSSZ S PSSZ=1 ; Needed for the drug file to let me in! - ; ; If RXN refers to a brand drug, get the generic instead. I $$ISBRAND^C0CRXNLK(RXN) S RXN=$$BR2GEN^C0CRXNLK(RXN) W !,"(debug) RxNorm is "_RXN,! @@ -22,6 +43,11 @@ ADDDRUG(RXN,NDC,BARCODE) ; Public Proc; Add Drug to Drug File ; Get first VUID for this RxNorm drug N VUID S VUID=+$$RXN2VUI^C0CRXNLK(RXN) Q:'VUID + G NEXT +ADDDRUG2(RXN,VUID) ; +NEXT ; + N PSSZ S PSSZ=1 ; Needed for the drug file to let me in! + ; W "(debug) VUID for RxNorm CUI "_RXN_" is "_VUID,! ; ; IEN in 50.68 @@ -44,7 +70,7 @@ ADDDRUG(RXN,NDC,BARCODE) ; Public Proc; Add Drug to Drug File . S C0XFDA(50.1,"+2,+1,",1)="Q" ; ; Brand Names - N BNS S BNS=$$RXN2BNS^C0CRXNLK(RXN) ; Brands + N BNS S BNS="" ; S BNS=$$RXN2BNS^C0CRXNLK(RXN) ; Brands I $L(BNS) N I F I=1:1:$L(BNS,U) D . N IENS S IENS=I+2 . S C0XFDA(50.1,"+"_IENS_",+1,",.01)=$$UP^XLFSTR($E($P(BNS,U,I),1,40))