Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ORWGAPIC

ORWGAPIC.m

Go to the documentation of this file.
  1. ORWGAPIC ; SLC/STAFF - Graph Application Calls - Labs, Meds ;11/1/06 12:49
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243**;Dec 17, 1997;Build 242
  1. ;
  1. AA(IEN) ; $$(ien) -> external display of accession area
  1. Q $P($G(^LRO(68,IEN,0)),U)
  1. ;
  1. AALAB(TEST) ; $$(lab test) -> accession ien^acc name^acc abbrev
  1. N AA,DIV
  1. S TEST=+$G(TEST)
  1. S DIV=+$G(DUZ(2))
  1. S AA=+$P($G(^LAB(60,+TEST,8,DIV,0)),U,2)
  1. I AA Q AA_U_$$ACCLAB(AA)
  1. S AA=+$P($G(^LAB(60,+TEST,8,+$O(^LAB(60,+TEST,8,0)),0)),U,2)
  1. I AA Q AA_U_$$ACCLAB(AA)
  1. Q ""
  1. ;
  1. ACC(DATA) ; API - get accession areas - from ORWGAPI
  1. N CNT,IEN,TMP,RESULT,ZERO
  1. D RETURN^ORWGAPIW(.TMP,.DATA)
  1. S CNT=0
  1. S IEN=0
  1. F S IEN=$O(^LRO(68,IEN)) Q:IEN<1 D
  1. . S ZERO=$G(^LRO(68,IEN,0)) I '$L(ZERO) Q
  1. . S RESULT="68^"_IEN_U_$P(ZERO,U)_U_$P(ZERO,U,11)
  1. . D SETUP^ORWGAPIW(.DATA,RESULT,TMP,.CNT)
  1. Q
  1. ;
  1. ACCLAB(AA) ; $$(accession ien) -> acc name^acc abbrev
  1. N ZERO
  1. S ZERO=$G(^LRO(68,AA,0)) I '$L(ZERO) Q ""
  1. Q "lab - "_$P(ZERO,U)_U_$P(ZERO,U,11)
  1. ;
  1. ADDDRUG(IEN) ; $$(additive) -> drug in 50 else ""
  1. N RESULT K ^TMP($J,"RX")
  1. I '$G(IEN) Q ""
  1. D ZERO^PSS52P6(IEN,,,"RX")
  1. S RESULT=$P($G(^TMP($J,"RX",IEN,1)),U)
  1. K ^TMP($J,"RX")
  1. Q RESULT
  1. ;
  1. BCMAX(DFN) ; $$(dfn) -> 1 if patient has data else 0
  1. Q $O(^PSB(53.79,"B",+$G(DFN),0))>0
  1. ;
  1. DC(IEN) ; $$(ien) -> external display of drug class
  1. N RESULT K ^TMP($J,"RX")
  1. I '$G(IEN) Q ""
  1. D IEN^PSN50P65(IEN,,"RX")
  1. S RESULT=$G(^TMP($J,"RX",IEN,1))
  1. K ^TMP($J,"RX")
  1. Q RESULT
  1. ;
  1. DRGCLASS(DRUG) ; $$(drug) -> drug class^classification
  1. N RESULT K ^TMP($J,"RX")
  1. I '$G(DRUG) Q ""
  1. D DATA^PSS50(DRUG,,,,,"RX")
  1. S RESULT=+$G(^TMP($J,"RX",DRUG,25))
  1. K ^TMP($J,"RX")
  1. Q RESULT_U_"drug - "_$$DC(RESULT)
  1. ;
  1. DRUG(NUM) ; $$(bcma entry) -> drug in 50 else ""
  1. N DONE,DRUG,NUM1
  1. S DONE=0,NUM=+$G(NUM)
  1. S NUM1=0
  1. F S NUM1=$O(^PSB(53.79,NUM,.5,"B",NUM1)) Q:NUM1<1 S DONE=1 Q
  1. I DONE Q NUM1
  1. S DRUG=0
  1. S NUM1=0
  1. F S NUM1=$O(^PSB(53.79,NUM,.6,"B",NUM1)) Q:NUM1<1 D I DONE Q
  1. . S DRUG=$$ADDDRUG(NUM1)
  1. . I DRUG S DONE=1
  1. I DONE Q DRUG
  1. S DRUG=0
  1. S NUM1=0
  1. F S NUM1=$O(^PSB(53.79,NUM,.7,"B",NUM1)) Q:NUM1<1 D I DONE Q
  1. . S DRUG=$$SOLDRUG(NUM1)
  1. . I DRUG S DONE=1
  1. I DONE Q DRUG
  1. Q ""
  1. ;
  1. DRUGC(VALUES) ; API - get drug classes - from ORWGAPI
  1. N CLASS,IEN,NUM,ROOT K VALUES
  1. S NUM=0
  1. S ROOT=$$ROOT^PSN50P65(1)
  1. S CLASS=""
  1. F S CLASS=$O(@ROOT@(CLASS)) Q:CLASS="" D
  1. . S IEN=0
  1. . F S IEN=$O(@ROOT@(CLASS,IEN)) Q:IEN="" D
  1. .. S NUM=NUM+1
  1. .. S VALUES(NUM)="50.605^"_IEN_U_CLASS
  1. M ^TMP("ORWGRPC",$J)=VALUES K VALUES
  1. Q
  1. ;
  1. INSIG(NODE) ; $$(node) -> sig
  1. N SIG,SUB,VALUES K VALUES
  1. S SUB=$P($G(NODE),";",2)
  1. D RXIN(NODE,.VALUES)
  1. S SIG=""
  1. I SUB=5 D
  1. . S SIG=" Give: "_$G(VALUES("MR"))
  1. . S SIG=SIG_" "_$P($G(VALUES("SCH",1,0)),U)
  1. . S SIG=SIG_" "_$P($G(VALUES("SCH",1,0)),U,2)
  1. I SUB="IV" D
  1. . S SIG=" Give: "_$G(VALUES("DO"))
  1. . S SIG=SIG_" "_$$EXT^ORWGAPIX($G(VALUES("START")),55.01,.02)
  1. . S SIG=SIG_" "_$G(VALUES("SCH",1,0))
  1. Q SIG
  1. ;
  1. LAB(ORVALUE,NODE,ITEM) ; from ORWGAPI3
  1. D LRPXRM^LRPXAPI(.ORVALUE,NODE,ITEM,"VSC")
  1. Q
  1. ;
  1. LABNAME(Y) ; $$(item ien) -> item name
  1. I $P(Y,";")="A",$P(Y,";",2)="S" Q $P(Y,".",2,99)
  1. Q $$ITEMNM^LRPXAPIU(Y)
  1. ;
  1. LABSUM(ORDATA,DFN,DATE1,DATE2,ORSUB) ; from ORWGAPID
  1. D EN^LR7OSUM(.ORDATA,DFN,DATE1,DATE2,,80,.ORSUB)
  1. Q
  1. ;
  1. LRDFN(DFN) ; $$(dfn) -> lrdfn
  1. Q $$LRDFN^LRPXAPIU(DFN)
  1. ;
  1. LRIDT(LRDT) ; $$(date) -> inverse date
  1. Q $$LRIDT^LRPXAPIU(LRDT)
  1. ;
  1. NVASIG(NODE) ; $$(node) -> sig on non-va drug
  1. N RESULTS,SIG K RESULTS
  1. I '$L(NODE) Q ""
  1. D RXNVA(NODE,.RESULTS)
  1. S SIG=RESULTS("DOSAGE")
  1. S SIG=SIG_" "_RESULTS("MEDICATION ROUTE")
  1. S SIG=SIG_" "_RESULTS("SCHEDULE")
  1. Q SIG
  1. ;
  1. NVAX(DFN) ; $$(dfn) -> 1 if patient has data else 0
  1. Q $L($O(^PXRMINDX("55NVA","PI",+$G(DFN),"")))>0
  1. ;
  1. POINAME(IEN) ; $$(poi entry) - > name and dosage form else ""
  1. N NAME,RESULT K ^TMP($J,"RX")
  1. I '$G(IEN) Q ""
  1. D ZERO^PSS50P7(IEN,,,"RX")
  1. S NAME=$P($G(^TMP($J,"RX",IEN,.01)),U)
  1. K ^TMP($J,"RX")
  1. I NAME'=" " Q NAME
  1. Q ""
  1. ;
  1. RXIN(NODE,ORVALUE) ; from ORWGAPI3
  1. D OEL^PSJPXRM1(NODE,.ORVALUE)
  1. Q
  1. ;
  1. RXNUM(DFN,RXIEN) ; $$(dfn,prescription ien) -> rx#
  1. N RXNUM K ^TMP($J,"RX")
  1. S RXIEN=+$G(RXIEN)
  1. D RX^PSO52API(DFN,"RX",RXIEN,,0)
  1. S RXNUM=$G(^TMP($J,"RX",DFN,RXIEN,.01))
  1. I $L(RXNUM) S RXNUM=" RX#: "_+RXNUM
  1. K ^TMP($J,"RX")
  1. Q RXNUM
  1. ;
  1. RXNVA(NODE,ORVALUE,XSTART,XSTOP) ; from ORWGAPI1, ORWGAPI3, ORWGAPID
  1. S XSTART=1,XSTOP=1
  1. D NVA^PSOPXRM1(NODE,.ORVALUE)
  1. I '$G(ORVALUE("START DATE")) D
  1. . S ORVALUE("START DATE")=$G(ORVALUE("DOCUMENTED DATE"))
  1. . S XSTART=0
  1. I '$G(ORVALUE("DISCONTINUED DATE")) D
  1. . S XSTOP=0
  1. Q
  1. ;
  1. RXOUT(NODE,ORVALUE) ; from ORWGAPI3
  1. D PSRX^PSOPXRM1(NODE,.ORVALUE)
  1. Q
  1. ;
  1. SIG(DFN,RXIEN) ; $$(dfn,prescription ien) -> sig
  1. N LNUM,SIG K ^TMP($J,"RX")
  1. S RXIEN=+$G(RXIEN)
  1. D RX^PSO52API(DFN,"RX",RXIEN,,"M",,)
  1. S SIG=""
  1. S LNUM=0
  1. F S LNUM=$O(^TMP($J,"RX",DFN,RXIEN,"M",LNUM)) Q:LNUM<1 D
  1. . S SIG=SIG_$G(^TMP($J,"RX",DFN,RXIEN,"M",LNUM,0))_" "
  1. I $L(SIG) S SIG=" Sig: "_$$LOW^ORWGAPIX(SIG)
  1. K ^TMP($J,"RX")
  1. Q SIG
  1. ;
  1. SOLDRUG(IEN) ; $$(iv solution) -> drug in 50 else ""
  1. N RESULT K ^TMP($J,"RX")
  1. I '$G(IEN) Q ""
  1. D ZERO^PSS52P7(IEN,,,"RX")
  1. S RESULT=$P($G(^TMP($J,"RX",IEN,1)),U)
  1. K ^TMP($J,"RX")
  1. Q RESULT
  1. ;
  1. TESTSPEC(DATA) ; from ORWGAPI
  1. N CNT,LINE,TEST,TMP,SPEC
  1. D RETURN^ORWGAPIW(.TMP,.DATA)
  1. S CNT=0
  1. S TEST=0
  1. F S TEST=$O(^LAB(60,TEST)) Q:TEST<1 D
  1. . S SPEC=0
  1. . F S SPEC=$O(^LAB(60,TEST,1,SPEC)) Q:SPEC<1 D
  1. .. S CNT=CNT+1
  1. .. S LINE=TEST_U_$G(^LAB(60,TEST,1,SPEC,0))
  1. .. I $P(LINE,U,3)[$C(34) S $P(LINE,U,3)=$$TRIM^ORWGAPIX($P(LINE,U,3),"LR",$C(34))
  1. .. I $P(LINE,U,4)[$C(34) S $P(LINE,U,4)=$$TRIM^ORWGAPIX($P(LINE,U,4),"LR",$C(34))
  1. .. I TMP S ^TMP(DATA,$J,CNT)=LINE Q
  1. .. S DATA(CNT)=LINE
  1. Q
  1. ;