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

ORWDPLM1.m

Go to the documentation of this file.
ORWDPLM1 ;PBM/HINES/RMS - DISPLAY LAB DATA IN CPRS ORDERING DIALOG ; 21 Dec 2016  4:46 PM
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**420**;;Build 7
SL Q:'$$GET^XPAR("ALL","OR CPRS LAB DISPLAY ENABLED")  ; param off? - skip
 N DIC,X,Y,ORL50,ORL507,ORL2,ORLNODE,ORLRSLT,FOUND,ORLCRCL,REFRANGE
 S ORL2=+$G(ORVP) I ORL2 G SL2
 S X=$TR($G(VA("PID")),"-"),DIC=2,DIC(0)="M"
 D ^DIC
 Q:Y=-1
 S ORL2=+Y
SL2 S ORL507=+$P($G(^ORD(101.43,OI,0)),U,2) Q:'+ORL507
 S ORL50=0 F  S ORL50=$O(^PSDRUG("ASP",ORL507,ORL50)) Q:'+ORL50!($G(FOUND))  D
 . S ORLNODE=$G(^PSDRUG(ORL50,"CLOZ")) Q:'+ORLNODE
 . I +ORLNODE,$$SCRTEST(+ORLNODE) S ORLRSLT=$$GETSCR(ORL2) S ILST=ILST+1,LST(ILST)="tLAST "_$$GET1^DIQ(60,+ORLNODE,.01)_": "_$P(ORLRSLT,U)
 . I +ORLNODE,'$$SCRTEST(+ORLNODE) S ORLRSLT=$$GETLAB(ORL2,+ORLNODE,+$P(ORLNODE,U,3),$P(ORLNODE,U,2)) S ILST=ILST+1,LST(ILST)="tLAST "_$$GET1^DIQ(60,+ORLNODE,.01)_": "_$P(ORLRSLT,U)
 . I +$P(ORLRSLT,U,2) S LST(ILST)=LST(ILST)_" "_$P(ORLRSLT,U,4)_" ("_$$FMTE^XLFDT($P(ORLRSLT,U,2))_")"
 . I $P(ORLRSLT,U,5)]"" S ILST=ILST+1,LST(ILST)="tREFERENCE RANGE: "_$P(ORLRSLT,U,5)_" "_$P(ORLRSLT,U,4)
 . I +$P(ORLRSLT,U,2) I $$SCRTEST(+ORLNODE) S ORLCRCL=$$CRCL^PSOORUT2(ORL2) I +$P(ORLCRCL,U,2) S ILST=ILST+1,LST(ILST)="tEstimated Creatinine Clearance: "_$P(ORLCRCL,U,2)_" mL/min"
 . S FOUND=1
 Q
 ;
GETSCR(DFN) ;New PBM/RMS 1-29-2016
 ;If lab test is CREATININE, get results using national term
 N OCXTL,OCXTLS,SCR,OCXT,OCXTS,SCRD,PSCR,SCRV
 S OCXTL="" Q:'$$TERMLKUP^ORB31(.OCXTL,"SERUM CREATININE") "No mapped creatinine lab test available"
 S OCXTLS="" Q:'$$TERMLKUP^ORB31(.OCXTLS,"SERUM SPECIMEN") "No mapped serum specimen found"
 S PSCR="^^^^^^0"
 S SCR="",OCXT=0 F  S OCXT=$O(OCXTL(OCXT)) Q:'OCXT  D
 .S OCXTS=0 F  S OCXTS=$O(OCXTLS(OCXTS)) Q:'OCXTS  D
 ..S SCR=$$LOCL^ORQQLR1(DFN,$P(OCXTL(OCXT),U),$P(OCXTLS(OCXTS),U))
 ..I $P(SCR,U,7)>$P(PSCR,U,7) S PSCR=SCR
 S SCR=PSCR,SCRV=$P(SCR,U,3) Q:+$G(SCRV)<.01 "NONE FOUND IN LAST "_$S(+$P(ORLNODE,U,2):$P(ORLNODE,U,2),1:365)_" DAYS"
 S SCRD=$P(SCR,U,7) Q:'$L(SCRD) "NONE FOUND IN LAST "_$S(+$P(ORLNODE,U,2):$P(ORLNODE,U,2),1:365)_" DAYS"
 I $$FMADD^XLFDT(DT,-$P(ORLNODE,U,2))>SCRD Q "NONE FOUND IN LAST "_$S(+$P(ORLNODE,U,2):$P(ORLNODE,U,2),1:365)_" DAYS"  ;Result Before Max Days
 Q $P(SCR,U,3)_U_$P(SCR,U,7)_U_$P(SCR,U,2)_U_$P(SCR,U,4)_U_$P(SCR,U,6)
 ;
SCRTEST(LAB60) ;New PBM/RMS 1-29-2016
 ;Function to check if drug-associated lab test is CREATININE
 N TERM,IEN,OCXTL,ORLSCR
 S TERM=$$TERMLKUP^ORB31(.OCXTL,"SERUM CREATININE")
 S IEN=0
 F  S IEN=$O(OCXTL(IEN)) Q:'+IEN  S ORLSCR(+$G(OCXTL(IEN)))=""
 Q $D(ORLSCR(LAB60))
 ;
GETLAB(DFN,TEST,SPEC,MDAYS) ;CUSTOM LAB LOOKUP API
 N ORLBDT,TESTNAME,RESULT,LNAME,LDATE,UNITS
 N X,X1,X2
 Q:'+$G(TEST) ""
 Q:'+$G(DFN) ""
 S TESTNAME=$P($G(^LAB(60,TEST,0)),U)
 S MDAYS=$G(MDAYS,365)
 S X1=DT,X2=-$G(MDAYS) D C^%DTC
 S ORLBDT=$S(X<DT:X,1:0)
 D RR^LR7OR1(DFN,,ORLBDT,DT,,TEST,,1,$G(SPEC))
 D FORMAT
 I $G(RESULT)']"" Q "NONE FOUND IN LAST "_+$S(+MDAYS:MDAYS,1:365)_" DAYS"_U_U_TESTNAME
 Q RESULT_U_LDATE_U_LNAME_U_UNITS_U_REFRANGE
FORMAT N IDT,LOC,NODE
 S IDT=0 F  S IDT=$O(^TMP("LRRR",$J,DFN,"CH",IDT)) Q:'+IDT  D
 . S LOC=0 F  S LOC=$O(^TMP("LRRR",$J,DFN,"CH",IDT,LOC)) Q:'+LOC  D
 .. S NODE=$G(^TMP("LRRR",$J,DFN,"CH",IDT,LOC))
 .. S RESULT=$P(NODE,U,2)
 .. S UNITS=$P(NODE,U,4)
 .. S LNAME=$P(NODE,U,10)
 .. S REFRANGE=$P(NODE,U,5)
 .. I LNAME']"" S LNAME=$P(NODE,U,15)
 .. S LDATE=9999999-IDT
 Q