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

BQIRGHPC.m

Go to the documentation of this file.
BQIRGHPC ;GDHSD/HS/ALA-Hep C Care Mgmt ; 18 Apr 2016  11:42 AM
 ;;2.5;ICARE MANAGEMENT SYSTEM;**1**;May 24, 2016;Build 17
 ;
 ;
LBT ;EP - Set up Lab tests
 ; Clean up labs
 NEW DA,IENS,CIEN
 S CIEN=$O(^BQI(90506.5,"B","Hep C","")) I CIEN="" Q
 S DA=0,DA(1)=CIEN
 F  S DA=$O(^BQI(90506.5,CIEN,10,DA)) Q:'DA  D
 . S IENS=$$IENS^DILF(.DA)
 . S BQIUPD(90506.51,IENS,.09)=1
 I $D(BQIUPD) D FILE^DIE("","BQIUPD","ERROR")
 ;
 NEW TAX,TREF
 F TAX="BQI HCV OTHER LAB TESTS" D
 . S TREF=$NA(^TMP("BQIHCVL",$J)) K @TREF
 . D BLD^BQITUTL(TAX,.TREF,"L")
 . D LBR
 ;
 F TAX="BQI HCV BASELINE LAB TESTS" D
 . S TREF=$NA(^TMP("BQIHCVB",$J)) K @TREF
 . D BLD^BQITUTL(TAX,.TREF,"L")
 . D LBB
 Q
 ;
LBR ;EP - Set up lab tests
 NEW BN,CT,CD,DA,IENS,DIC,DESC,PNL,DLAYGO,DIC,X,Y,NM,NAME
 S BN=0
 F  S BN=$O(@TREF@(BN)) Q:'BN  D
 . S NM=$P(^LAB(60,BN,.1),U,1),NAME=$P(^LAB(60,BN,0),"^",1)
 . S PNL=0 I $O(^LAB(60,BN,2,0))'="" S PNL=1
 . S IEN=$O(^BQI(90506.5,CIEN,10,"C",NM,""))
 . I IEN'="" D
 .. S DA(1)=CIEN,DA=IEN,IENS=$$IENS^DILF(.DA)
 .. S BQIUPD(90506.51,IENS,.09)="@"
 .. D FILE^DIE("","BQIUPD","ERROR")
 .. I PNL S DESC(1)="Most recent "_NAME_" panel from V Lab is displayed."
 .. I 'PNL S DESC(1)="Most recent "_NAME_" lab test from V Lab is displayed."
 .. D WP^DIE(90506.51,IENS,4,"","DESC")
 . I IEN="" D
 .. S CT=$P($G(^BQI(90506.5,CIEN,10,0)),U,3),CT=CT+1,LCT=CT
 .. S CD="HC_"_$E("0000",$L(CT),2)_CT
 .. S DA(1)=CIEN,X=CD,DIC="^BQI(90506.5,"_DA(1)_",10,",DIC(0)="L",DLAYGO=90506.51
 .. K DO,DD D FILE^DICN S DA=+Y
 .. S IENS=$$IENS^DILF(.DA)
 .. S BQIUPD(90506.51,IENS,.02)=3,BQIUPD(90506.51,IENS,.03)=NM
 .. S BQIUPD(90506.51,IENS,.04)=BN
 .. S BQIUPD(90506.51,IENS,.06)="O",BQIUPD(90506.51,IENS,.08)="A"
 .. S BQIUPD(90506.51,IENS,5.02)="Current",BQIUPD(90506.51,IENS,5.01)="Lab"
 .. S BQIUPD(90506.51,IENS,3)="D LAB^BQIRGHPC",BQIUPD(90506.51,IENS,1)="S VAL=$$DSP^BQIRGHPC(DFN,CODE)"
 .. D FILE^DIE("","BQIUPD","ERROR")
 .. I PNL S DESC(1)="Most recent "_NAME_" panel from V Lab is displayed."
 .. I 'PNL S DESC(1)="Most recent "_NAME_" lab test from V Lab is displayed."
 .. D WP^DIE(90506.51,IENS,4,"","DESC")
 K @TREF
 Q
 ;
LBB ;EP
 NEW BN,CT,CD,DA,IENS,DIC,DESC,PNL,DLAYGO,DIC,X,Y,NM,NAME
 S BN=0
 S CT=$S($G(LCT)'="":LCT,1:$P(^BQI(90506.5,CIEN,10,0),"^",3))
 F  S BN=$O(@TREF@(BN)) Q:'BN  D
 . S NM=$P(^LAB(60,BN,.1),U,1),NAME=$P(^LAB(60,BN,0),"^",1)
 . S PNL=0 I $O(^LAB(60,BN,2,0))'="" S PNL=1
 . S IEN=$O(^BQI(90506.5,CIEN,10,"C",NM,""))
 . I IEN'="" D
 .. S DA(1)=CIEN,DA=IEN,IENS=$$IENS^DILF(.DA)
 .. S BQIUPD(90506.51,IENS,.09)="@"
 .. D FILE^DIE("","BQIUPD","ERROR")
 .. I PNL S DESC(1)="Most recent "_NAME_" panel from V Lab is displayed."
 .. I 'PNL S DESC(1)="Most recent "_NAME_" lab test from V Lab is displayed."
 .. D WP^DIE(90506.51,IENS,4,"","DESC")
 . I IEN="" D
 .. S CT=CT+1
 .. S CD="HC_"_$E("0000",$L(CT),2)_CT
 .. S DA(1)=CIEN,X=CD,DIC="^BQI(90506.5,"_DA(1)_",10,",DIC(0)="L",DLAYGO=90506.51
 .. K DO,DD D FILE^DICN S DA=+Y
 .. S IENS=$$IENS^DILF(.DA)
 .. S BQIUPD(90506.51,IENS,.02)=3,BQIUPD(90506.51,IENS,.03)=NM
 .. S BQIUPD(90506.51,IENS,.04)=BN
 .. S BQIUPD(90506.51,IENS,.06)="O",BQIUPD(90506.51,IENS,.08)="A"
 .. S BQIUPD(90506.51,IENS,5.02)="Baseline",BQIUPD(90506.51,IENS,5.01)="Lab"
 .. S BQIUPD(90506.51,IENS,3)="D LRR^BQIRGHPC",BQIUPD(90506.51,IENS,1)="S VAL=$$DSP^BQIRGHPC(DFN,CODE)"
 .. D FILE^DIE("","BQIUPD","ERROR")
 .. ;I PNL S DESC(1)="Most recent "_NAME_" panel from V Lab is displayed."
 .. I 'PNL D
 ... S DESC(1)="Baseline and most recent "_NAME_" test from V Lab is displayed."
 ... S DESC(2)="Go to Patient View PCC Tab to see full listing of lab tests."
 .. D WP^DIE(90506.51,IENS,4,"","DESC")
 K @TREF
 Q
 ;
LAB ;EP - Pull out HCV lab tests
 NEW LRES,RES,IENS,DA
 S DA(1)=SRIEN,DA=AIEN,IENS=$$IENS^DILF(.DA)
 S FRN=$$GET1^DIQ(90506.51,IENS,.02,"I")
 S FREF=$$PTR^BQIUL2(90506.51,.02,FRN,.02)
 S RREF=$$PTR^BQIUL2(90506.51,.02,FRN,.08)
 S ITM=$$GET1^DIQ(90506.51,IENS,.04,"E")
 S NAM=$$GET1^DIQ(90506.51,IENS,.03,"E")
 S TAX=$$GET1^DIQ(90506.51,IENS,.07,"E")
 ;S LRES=$$ITM^BQICMUTL("",BQDFN,FREF,RREF,ITM,TAX,.TREF)
 S LRES=$$ITM^BQIRGUT1("",BQDFN,FREF,RREF,ITM,TAX,.TREF)
 S VAL="",DATE="",VISIT="",OTHER=""
 I $P(LRES,U,1)=0 S RESULT=0
 I $P(LRES,U,1)'=0 D
 . S RES=$P(LRES,U,7) I RES="" S RES=$P(LRES,U,6)
 . S RESULT=1_U_$P(LRES,U,2)_U_RES
 . S VAL=$P(RESULT,"^",3),DATE=$P(RESULT,"^",2),VISIT=$P(RESULT,"^",4),OTHER=$P(RESULT,"^",5)
 . S VAL=VAL_" ("_$$FMTMDY^BQIUL1(DATE)_")"
 Q
 ;
LRR ;EP
 NEW RESULT,DA,IENS
 S DA(1)=SRIEN,DA=AIEN,IENS=$$IENS^DILF(.DA)
 S ITM=$$GET1^DIQ(90506.51,IENS,.04,"E")
 S RESULT=0,VAL="",DATE="",VISIT="",OTHER=""
 S RESULT=$$LBS(BQDFN,ITM)
 I RESULT S VAL=$P(RESULT,"^",2)
 Q
 ;
LBS(DFN,ITM) ;EP - Pull out baseline and most recent lab
 NEW RVDB,BIEN,RESB,RVDC,CIEN,RESC,DATE,RVDT,VALUE
 S DATE=$P($$FDX^BQITDUTL(DFN,"BKM HEP C DXS",""),"^",1),RVDT=9999999-DATE,VALUE=0
 I $G(DATE)="" S RVDT=$O(^AUPNVLAB("AA",DFN,ITM,""),-1) I RVDT="" Q 0
 S RVDB=$O(^AUPNVLAB("AA",DFN,ITM,RVDT),-1) I RVDB="" S RVDB=RVDT
 S BIEN=$O(^AUPNVLAB("AA",DFN,ITM,RVDB,"")),RESB=""
 I BIEN'="" S RESB=$P($G(^AUPNVLAB(BIEN,0)),"^",4)
 S RVDC=$O(^AUPNVLAB("AA",DFN,ITM,""))
 I RVDC'="" S CIEN=$O(^AUPNVLAB("AA",DFN,ITM,RVDC,"")),RESC=""
 I $G(CIEN)'="" S RESC=$P($G(^AUPNVLAB(CIEN,0)),"^",4)
 S BASE="" I RVDB'="" S BASE="B: "_RESB_" ("_$$FMTMDY^BQIUL1(9999999-RVDB)_")"
 S CURR="" I RVDC'="" S CURR="C: "_RESC_" ("_$$FMTMDY^BQIUL1(9999999-RVDC)_")"
 I BASE'=""!(CURR'="") S VALUE=1_"^"_BASE_$C(10)_$C(13)_CURR
 Q VALUE
 ;
FIB(DFN) ;EP - Fibroscan
 NEW TAX,TREF,FREF,TMFRAME,VALUE,VSDTM,BQQN,CT
 S TAX="BQI FIBROSCAN CPT PROC",TREF="BQITREF" K @TREF
 D BLD^BQITUTL(TAX,.TREF)
 S FREF=9000010.18,TMFRAME=""
 S VALUE=$$TAX^BQITRUTL(TMFRAME,TAX,1,DFN,FREF,"","",.TREF)
 I VALUE'=0 D
 . S VALUE="YES"_" ("_$$FMTMDY^BQIUL1($P(VALUE,"^",2))_")^"_$P(VALUE,"^",2)_"^"_$P(VALUE,"^",4)_"^"_$P(VALUE,"^",5)
 I VALUE=0 S VALUE=""
 Q VALUE
 ;
LU(DFN) ;EP - Liver Ultrasound
 NEW TAX,TREF,FREF,TMFRAME,RAD,RIEN,VALUE,N,RVDT,VSDTM,BQQN,CT
 S TAX="BQI LIVER ULTRASOUND CPT",TREF="BQITREF" K @TREF
 D BLD^BQITUTL(TAX,.TREF)
 S FREF=9000010.18,TMFRAME=""
 S VALUE=$$TAX^BQITRUTL(TMFRAME,TAX,1,DFN,FREF,"","",.TREF)
 I VALUE'=0 D
 . S VALUE="YES"_" (CPT: "_$$FMTMDY^BQIUL1($P(VALUE,"^",2))_")^"_$P(VALUE,"^",2)_"^"_$P(VALUE,"^",4)_"^"_$P(VALUE,"^",5)
 I VALUE=0 D
 . S N="",VALUE=""
 . D BLD^BQITUTL(TAX,.TREF)
 . F  S N=$O(@TREF@(N)) Q:N=""  D
 .. I '$D(^RAMIS(71,"D",N)) Q
 .. S RAD="" F  S RAD=$O(^RAMIS(71,"D",N,RAD)) Q:RAD=""  D
 ... I '$D(^AUPNVRAD("AA",DFN,RAD)) Q
 ... S RVDT=$O(^AUPNVRAD("AA",DFN,RAD,"")),RIEN=$O(^AUPNVRAD("AA",DFN,RAD,RVDT,""))
 ... S RVDT=9999999-RVDT
 ... S VALUE="YES"_" (RAD: "_$$FMTMDY^BQIUL1(RVDT)_")^"_RVDT_"^"_$P(^AUPNVRAD(RIEN,0),U,3)_"^"_RIEN
 Q VALUE
 ;
HLB(BQDFN,STVW) ;EP
 NEW FREF,TMFRAME,VALUE,TAX,RES,HCODE
 S TMFRAME="",VALUE="",ITM=""
 S HCODE=$P(^BQI(90506.1,STVW,0),"^",1)
 I HCODE="HCANTI" S TAX="BQI HCV ANTIBODY TAX",FREF=9000010.09,RREF=60
 I HCODE="HCAST" S TAX="DM AUDIT AST TAX",FREF=9000010.09,RREF=60
 I HCODE="HCALT" S TAX="DM AUDIT ALT TAX",FREF=9000010.09,RREF=60
 I HCODE="HCPLAT" S TAX="BQI PLATELET TAX",FREF=9000010.09,RREF=60
 I HCODE="HCVIRAL" S TAX="BQI HCV VIRAL LOAD TAX",FREF=9000010.09,RREF=60
 I HCODE="HCGENO" S TAX="BQI HEP C GENOTYPE TESTS",FREF=9000010.09,RREF=60
 I HCODE="HCHIV" S TAX="BGP HIV TEST TAX",FREF=9000010.09,RREF=60
 I HCODE="HCRNA" S TAX="BQI HCV RNA TAX",FREF=9000010.09,RREF=60
 ;S VALUE=$$TAX^BQITRUTL(TMFRAME,TAX,1,BQDFN,FREF,"","",.TREF)
 S VALUE=$$ITM^BQIRGUT1($G(TMFRAME),$G(BQDFN),$G(FREF),$G(RREF),$G(ITM),TAX,.TREF)
 I FREF=9000010.09 D
 . I VALUE=0 S VALUE="" Q
 . S RES=$P(VALUE,"^",6)_" ("_$$FMTMDY^BQIUL1($P(VALUE,"^",2))_")"
 . S VALUE=RES_"^"_$P(VALUE,"^",2)_"^"_$P(VALUE,"^",4)_"^"_$P(VALUE,"^",5)
 Q VALUE
 ;
DSP(ASDFN,CODE) ; EP - Display Care Mgmt field
 NEW VALUE,RESULT,ASPIEN,CRIEN,CMSN,LINK
 S CRIEN=$O(^BQIPAT(ASDFN,60,"B",CRN,"")) I CRIEN="" Q ""
 S ASPIEN="",VALUE="",HOVER="",LINK="",RESULT=""
 F  S ASPIEN=$O(^BQIPAT(ASDFN,60,CRIEN,1,"B",CODE,ASPIEN)) Q:ASPIEN=""  D
 . S VALUE=$P($G(^BQIPAT(ASDFN,60,CRIEN,1,ASPIEN,0)),U,2)
 . S HOVER=$P($G(^BQIPAT(ASDFN,60,CRIEN,1,ASPIEN,0)),U,5),HOVER=""
 . S LINK=$P($G(^BQIPAT(ASDFN,60,CRIEN,1,ASPIEN,0)),U,4)
 I VALUE'="" S RESULT=VALUE_$C(26)_HOVER_$C(26)_LINK
 E  S RESULT=VALUE
 Q RESULT