BQITHCH ;PRXM/HC/ALA-High Cholesterol ; 12 Apr 2006 10:09 AM
;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
Q
;
DEF(TTGLOB) ;EP -- High Cholesterol Definition
;Description
; DEF.04 formerly CVDAL.DEF.DX.2
;Input
; TTGLOB - Global reference where patients matching high cholesterol
; will be place. Subscripted by patient IEN.
;
NEW BQREF,BQIRY,TAX,BQGLBT,TDFN
; Use taxonomy definitions
S BQREF="BQIRY" K @BQREF
S TAX="High Cholesterol"
D ARY^BQITUTL(TAX,BQREF)
S BQGLBT=$NA(^TMP("BQITMPH",UID))
K @BQGLBT
D POP^BQITDGN(BQREF,BQGLBT)
S TDFN="" F S TDFN=$O(@BQGLBT@(TDFN)) Q:TDFN="" D
. NEW TX
. S TX="" F S TX=$O(@BQGLBT@(TDFN,"CRITERIA",TX)) Q:TX="" D
.. D STOR(TDFN,TX)
K @BQGLBT
;
;LDL Lab test value check
S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID)) K @TREF
S TMFRAME="T-60M",ENDT=$$DATE^BQIUL1(TMFRAME),STDT=$$DT^XLFDT()
S DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1),EXDT=""
F TAX="DM AUDIT LDL CHOLESTEROL TAX","BGP LDL LOINC CODES" D BLD^BQITUTL(TAX,TREF)
S TIEN="" F S TIEN=$O(@TREF@(TIEN)) Q:TIEN="" D
. S IEN=""
. F S IEN=$O(@GREF@("B",TIEN,IEN),-1) Q:IEN="" D
.. I $G(@GREF@(IEN,0))="" Q
.. S DFN=$$GET1^DIQ(FREF,IEN,.02,"I") Q:DFN=""
.. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
.. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
.. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
.. I $G(TMFRAME)'="",VSDTM<ENDT Q
.. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
.. I RESULT<160 Q
.. S $P(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,1)=VSDTM,TX=TAX
.. S $P(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,3)=IEN_U_FREF
.. I DTDIF'="" S EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
.. I EXDT'="" S $P(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,2)=EXDT
.. D STOR(DFN,"Risk Factor-LDL Lab Test Value")
K @BQGLBT
;
;Total Cholesterol Lab test value check
S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID)) K @TREF
S TMFRAME="T-60M",ENDT=$$DATE^BQIUL1(TMFRAME),STDT=$$DT^XLFDT()
S DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1),EXDT=""
F TAX="DM AUDIT CHOLESTEROL TAX","BGP TOTAL CHOLESTEROL LOINC" D BLD^BQITUTL(TAX,TREF)
S TIEN="" F S TIEN=$O(@TREF@(TIEN)) Q:TIEN="" D
. S IEN=""
. F S IEN=$O(@GREF@("B",TIEN,IEN),-1) Q:IEN="" D
.. I $G(@GREF@(IEN,0))="" Q
.. S DFN=$$GET1^DIQ(FREF,IEN,.02,"I") Q:DFN=""
.. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
.. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
.. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
.. I $G(TMFRAME)'="",VSDTM<ENDT Q
.. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
.. I RESULT'>239 Q
.. ; setting "TOTAL" is used below in determining the non HDL value
.. S @BQGLBT@(DFN,VSDTM,"TOTAL",IEN)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
.. S $P(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,1)=VSDTM,TX=TAX
.. S $P(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,3)=IEN_U_FREF
.. I DTDIF'="" S EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
.. I EXDT'="" S $P(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,2)=EXDT
.. D STOR(DFN,"Risk Factor-Total Cholesterol Value")
;
;HDL Lab Test value check
S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID)) K @TREF
F TAX="DM AUDIT HDL TAX","BGP HDL LOINC CODES" D BLD^BQITUTL(TAX,TREF)
S TIEN="" F S TIEN=$O(@TREF@(TIEN)) Q:TIEN="" D
. S IEN=""
. F S IEN=$O(@GREF@("B",TIEN,IEN)) Q:IEN="" D
.. I $G(@GREF@(IEN,0))="" Q
.. S DFN=$$GET1^DIQ(FREF,IEN,.02,"I") Q:DFN=""
.. S SEX=$$GET1^DIQ(2,DFN,.02,"I")
.. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
.. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
.. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
.. I $G(TMFRAME)'="",VSDTM<ENDT Q
.. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
.. S @BQGLBT@(DFN,VSDTM,"HDL",IEN)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
;
; Check for value of Total minus value of HDL for most recent result
NEW TVISIT,TVIEN,HVISIT,HVIEN
S DFN=""
F S DFN=$O(@BQGLBT@(DFN)) Q:DFN="" D
. S DTM="",QFL=0
. F S DTM=$O(@BQGLBT@(DFN,DTM),-1) Q:DTM="" D Q:QFL
.. S HDL=$D(@BQGLBT@(DFN,DTM,"HDL"))
.. S TOT=$D(@BQGLBT@(DFN,DTM,"TOTAL"))
.. I HDL,TOT D Q:QFL
... S TIEN=$O(@BQGLBT@(DFN,DTM,"TOTAL",""))
... S TOTAL=$P(@BQGLBT@(DFN,DTM,"TOTAL",TIEN),"^",1)
... S TVISIT=$P(@BQGLBT@(DFN,DTM,"TOTAL",TIEN),"^",2)
... S TVIEN=$P(@BQGLBT@(DFN,DTM,"TOTAL",TIEN),"^",3)
... S HIEN=$O(@BQGLBT@(DFN,DTM,"HDL",""))
... S HDL=$P(@BQGLBT@(DFN,DTM,"HDL",HIEN),"^",1)
... S HVISIT=$P(@BQGLBT@(DFN,DTM,"HDL",HIEN),"^",2)
... S HVIEN=$P(@BQGLBT@(DFN,DTM,"HDL",HIEN),"^",3)
... S NHDL=TOTAL-HDL
... I NHDL'>189 Q
... S QFL=1
... S @BQGLBT@(DFN,"CRITERIA","NON HDL","V",TVISIT,TVIEN)=DTM_U_U_TVIEN_U_FREF
... S @BQGLBT@(DFN,"CRITERIA","NON HDL","V",HVISIT,HVIEN)=DTM_U_U_HVIEN_U_FREF
... S TX="NON HDL"
... D STOR(DFN,"Risk Factor-Non HDL")
;
K DFN,DTM,HDL,TOT,IEN,NHDL,SEX,VISIT,VSDTM,TMFRAME,TAX,FREF,GREF
K TIEN,ENDT,BQREF,@BQGLBT,TDFN,SDFN,TOTAL,RESULT,TREF,TIEN,HIEN,TX
Q
;
STOR(SDFN,CRIT) ; Store the patient's met criteria
I $G(@TTGLOB@(SDFN))>2 Q
I $D(@TTGLOB@(SDFN,"CRITERIA",CRIT))>0 Q
S @TTGLOB@(SDFN)=$G(@TTGLOB@(SDFN))+1
M @TTGLOB@(SDFN,"CRITERIA",CRIT,"V")=@BQGLBT@(SDFN,"CRITERIA",TX,"V")
M @TTGLOB@(SDFN,"CRITERIA",CRIT,"P")=@BQGLBT@(SDFN,"CRITERIA",TX,"P")
Q
;
PAT(BTDFN,BTGLOB) ;EP -- Get cholesterol for a patient
NEW BQDXN,BQREF
S BQGLBT=$NA(^TMP("BQITMP",UID)) K @BQGLBT
S BQDXN=$$GDXN^BQITUTL("High Cholesterol")
S BQREF="BQIRY"
D GDF^BQITUTL(BQDXN,BQREF)
I $$PAT^BQITDGN(BQREF,BQGLBT,BTDFN) D
. NEW TX
. S TX=$O(@BQGLBT@(BTDFN,"CRITERIA",""))
. D STOR^BQITD05(BTDFN,TX,BQGLBT)
;
S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID))
K @TREF
S TMFRAME="T-60M",ENDT=$$DATE^BQIUL1(TMFRAME),STDT=$$DT^XLFDT()
S DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1),EXDT=""
F TAX="DM AUDIT LDL CHOLESTEROL TAX","BGP LDL LOINC CODES" D BLD^BQITUTL(TAX,TREF)
S IEN="",QFL=0
F S IEN=$O(@GREF@("AC",BTDFN,IEN),-1) Q:IEN="" D Q:QFL
. S TIEN=$$GET1^DIQ(FREF,IEN,.01,"I") I TIEN="" Q
. I '$D(@TREF@(TIEN)) Q
. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
. I $G(TMFRAME)'="",VSDTM<ENDT Q
. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
. I RESULT'>159 Q
. S $P(@BQGLBT@(BTDFN,"CRITERIA",TAX,"V",VISIT,IEN),U,1)=VSDTM,TX=TAX
. S $P(@BQGLBT@(BTDFN,"CRITERIA",TAX,"V",VISIT,IEN),U,3)=IEN_U_FREF
. I DTDIF'="" S EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
. I EXDT'="" S $P(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,2)=EXDT
. D STOR^BQITD05(BTDFN,TAX,BQGLBT)
. S QFL=1
;
S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID))
K @TREF,@BQGLBT
F TAX="DM AUDIT CHOLESTEROL TAX","BGP TOTAL CHOLESTEROL LOINC" D BLD^BQITUTL(TAX,TREF)
S IEN="",QFL=0
F S IEN=$O(@GREF@("AC",BTDFN,IEN),-1) Q:IEN="" D Q:QFL
. S TIEN=$$GET1^DIQ(FREF,IEN,.01,"I") I TIEN="" Q
. I '$D(@TREF@(TIEN)) Q
. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
. I $G(TMFRAME)'="",VSDTM<ENDT Q
. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
. I RESULT'>239 Q
. S @BQGLBT@(BTDFN,VSDTM,"TOTAL",IEN)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
. S $P(@BQGLBT@(BTDFN,"CRITERIA",TAX,"V",VISIT,IEN),U,1)=VSDTM,TX=TAX
. S $P(@BQGLBT@(BTDFN,"CRITERIA",TAX,"V",VISIT,IEN),U,3)=IEN_U_FREF
. I DTDIF'="" S EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
. I EXDT'="" S $P(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,2)=EXDT
. D STOR^BQITD05(BTDFN,TAX,BQGLBT)
. S QFL=1
. K @BQGLBT@(DFN,"CRITERIA")
;
S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID))
K @TREF
F TAX="DM AUDIT HDL TAX","BGP HDL LOINC CODES" D BLD^BQITUTL(TAX,TREF)
S IEN=""
F S IEN=$O(@GREF@("AC",BTDFN,IEN),-1) Q:IEN="" D
. S TIEN=$$GET1^DIQ(FREF,IEN,.01,"I") I TIEN="" Q
. I '$D(@TREF@(TIEN)) Q
. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
. I $G(TMFRAME)'="",VSDTM<ENDT Q
. S @BQGLBT@(BTDFN,VSDTM,"HDL",IEN)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
;
S DTM="",QFL=0
F S DTM=$O(@BQGLBT@(BTDFN,DTM),-1) Q:DTM="" D Q:QFL
. S HDL=$D(@BQGLBT@(BTDFN,DTM,"HDL"))
. S TOT=$D(@BQGLBT@(BTDFN,DTM,"TOTAL"))
. I HDL,TOT D
.. S TIEN=$O(@BQGLBT@(BTDFN,DTM,"TOTAL",""))
.. S TOTAL=$P(@BQGLBT@(BTDFN,DTM,"TOTAL",TIEN),"^",1)
.. S TVISIT=$P(@BQGLBT@(BTDFN,DTM,"TOTAL",TIEN),"^",2)
.. S TVIEN=$P(@BQGLBT@(BTDFN,DTM,"TOTAL",TIEN),"^",3)
.. S HIEN=$O(@BQGLBT@(BTDFN,DTM,"HDL",""))
.. S HDL=$P(@BQGLBT@(BTDFN,DTM,"HDL",HIEN),"^",1)
.. S HVISIT=$P(@BQGLBT@(BTDFN,DTM,"HDL",HIEN),"^",2)
.. S HVIEN=$P(@BQGLBT@(BTDFN,DTM,"HDL",HIEN),"^",3)
.. S NHDL=TOTAL-HDL
.. I NHDL'>189 Q
.. S @BQGLBT@(BTDFN,"CRITERIA","NON HDL","V",TVISIT,TVIEN)=DTM_U_U_TVIEN_U_FREF
.. S @BQGLBT@(BTDFN,"CRITERIA","NON HDL","V",HVISIT,HVIEN)=DTM_U_U_HVIEN_U_FREF
.. S TX="NON HDL"
.. D STOR^BQITD05(BTDFN,TX,BQGLBT)
.. S QFL=1
K @TREF,@BQGLBT,TIEN,HIEN,TX,HDL,TOT,TOTAL,NHDL,DTM,VISIT,RESULT,VSDTM,TMFRAME
K TAX,FREF,GREF,IEN,TREF,TVISIT,TVIEN,HVISIT,HVIEN
Q
BQITHCH ;PRXM/HC/ALA-High Cholesterol ; 12 Apr 2006 10:09 AM
+1 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
+2 QUIT
+3 ;
DEF(TTGLOB) ;EP -- High Cholesterol Definition
+1 ;Description
+2 ; DEF.04 formerly CVDAL.DEF.DX.2
+3 ;Input
+4 ; TTGLOB - Global reference where patients matching high cholesterol
+5 ; will be place. Subscripted by patient IEN.
+6 ;
+7 NEW BQREF,BQIRY,TAX,BQGLBT,TDFN
+8 ; Use taxonomy definitions
+9 SET BQREF="BQIRY"
KILL @BQREF
+10 SET TAX="High Cholesterol"
+11 DO ARY^BQITUTL(TAX,BQREF)
+12 SET BQGLBT=$NAME(^TMP("BQITMPH",UID))
+13 KILL @BQGLBT
+14 DO POP^BQITDGN(BQREF,BQGLBT)
+15 SET TDFN=""
FOR
SET TDFN=$ORDER(@BQGLBT@(TDFN))
IF TDFN=""
QUIT
Begin DoDot:1
+16 NEW TX
+17 SET TX=""
FOR
SET TX=$ORDER(@BQGLBT@(TDFN,"CRITERIA",TX))
IF TX=""
QUIT
Begin DoDot:2
+18 DO STOR(TDFN,TX)
End DoDot:2
End DoDot:1
+19 KILL @BQGLBT
+20 ;
+21 ;LDL Lab test value check
+22 SET FREF=9000010.09
SET GREF=$$ROOT^DILFD(FREF,"",1)
SET TREF=$NAME(^TMP("BQITAX",UID))
KILL @TREF
+23 SET TMFRAME="T-60M"
SET ENDT=$$DATE^BQIUL1(TMFRAME)
SET STDT=$$DT^XLFDT()
+24 SET DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1)
SET EXDT=""
+25 FOR TAX="DM AUDIT LDL CHOLESTEROL TAX","BGP LDL LOINC CODES"
DO BLD^BQITUTL(TAX,TREF)
+26 SET TIEN=""
FOR
SET TIEN=$ORDER(@TREF@(TIEN))
IF TIEN=""
QUIT
Begin DoDot:1
+27 SET IEN=""
+28 FOR
SET IEN=$ORDER(@GREF@("B",TIEN,IEN),-1)
IF IEN=""
QUIT
Begin DoDot:2
+29 IF $GET(@GREF@(IEN,0))=""
QUIT
+30 SET DFN=$$GET1^DIQ(FREF,IEN,.02,"I")
IF DFN=""
QUIT
+31 SET VISIT=$$GET1^DIQ(FREF,IEN,.03,"I")
IF VISIT=""
QUIT
+32 SET VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1
IF 'VSDTM
QUIT
+33 IF $$GET1^DIQ(9000010,VISIT,.11,"I")=1
QUIT
+34 IF $GET(TMFRAME)'=""
IF VSDTM<ENDT
QUIT
+35 SET RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
IF RESULT=""
QUIT
+36 IF RESULT<160
QUIT
+37 SET $PIECE(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,1)=VSDTM
SET TX=TAX
+38 SET $PIECE(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,3)=IEN_U_FREF
+39 IF DTDIF'=""
SET EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
+40 IF EXDT'=""
SET $PIECE(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,2)=EXDT
+41 DO STOR(DFN,"Risk Factor-LDL Lab Test Value")
End DoDot:2
End DoDot:1
+42 KILL @BQGLBT
+43 ;
+44 ;Total Cholesterol Lab test value check
+45 SET FREF=9000010.09
SET GREF=$$ROOT^DILFD(FREF,"",1)
SET TREF=$NAME(^TMP("BQITAX",UID))
KILL @TREF
+46 SET TMFRAME="T-60M"
SET ENDT=$$DATE^BQIUL1(TMFRAME)
SET STDT=$$DT^XLFDT()
+47 SET DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1)
SET EXDT=""
+48 FOR TAX="DM AUDIT CHOLESTEROL TAX","BGP TOTAL CHOLESTEROL LOINC"
DO BLD^BQITUTL(TAX,TREF)
+49 SET TIEN=""
FOR
SET TIEN=$ORDER(@TREF@(TIEN))
IF TIEN=""
QUIT
Begin DoDot:1
+50 SET IEN=""
+51 FOR
SET IEN=$ORDER(@GREF@("B",TIEN,IEN),-1)
IF IEN=""
QUIT
Begin DoDot:2
+52 IF $GET(@GREF@(IEN,0))=""
QUIT
+53 SET DFN=$$GET1^DIQ(FREF,IEN,.02,"I")
IF DFN=""
QUIT
+54 SET VISIT=$$GET1^DIQ(FREF,IEN,.03,"I")
IF VISIT=""
QUIT
+55 IF $$GET1^DIQ(9000010,VISIT,.11,"I")=1
QUIT
+56 SET VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1
IF 'VSDTM
QUIT
+57 IF $GET(TMFRAME)'=""
IF VSDTM<ENDT
QUIT
+58 SET RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
IF RESULT=""
QUIT
+59 IF RESULT'>239
QUIT
+60 ; setting "TOTAL" is used below in determining the non HDL value
+61 SET @BQGLBT@(DFN,VSDTM,"TOTAL",IEN)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
+62 SET $PIECE(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,1)=VSDTM
SET TX=TAX
+63 SET $PIECE(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,3)=IEN_U_FREF
+64 IF DTDIF'=""
SET EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
+65 IF EXDT'=""
SET $PIECE(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,2)=EXDT
+66 DO STOR(DFN,"Risk Factor-Total Cholesterol Value")
End DoDot:2
End DoDot:1
+67 ;
+68 ;HDL Lab Test value check
+69 SET FREF=9000010.09
SET GREF=$$ROOT^DILFD(FREF,"",1)
SET TREF=$NAME(^TMP("BQITAX",UID))
KILL @TREF
+70 FOR TAX="DM AUDIT HDL TAX","BGP HDL LOINC CODES"
DO BLD^BQITUTL(TAX,TREF)
+71 SET TIEN=""
FOR
SET TIEN=$ORDER(@TREF@(TIEN))
IF TIEN=""
QUIT
Begin DoDot:1
+72 SET IEN=""
+73 FOR
SET IEN=$ORDER(@GREF@("B",TIEN,IEN))
IF IEN=""
QUIT
Begin DoDot:2
+74 IF $GET(@GREF@(IEN,0))=""
QUIT
+75 SET DFN=$$GET1^DIQ(FREF,IEN,.02,"I")
IF DFN=""
QUIT
+76 SET SEX=$$GET1^DIQ(2,DFN,.02,"I")
+77 SET VISIT=$$GET1^DIQ(FREF,IEN,.03,"I")
IF VISIT=""
QUIT
+78 IF $$GET1^DIQ(9000010,VISIT,.11,"I")=1
QUIT
+79 SET VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1
IF 'VSDTM
QUIT
+80 IF $GET(TMFRAME)'=""
IF VSDTM<ENDT
QUIT
+81 SET RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
IF RESULT=""
QUIT
+82 SET @BQGLBT@(DFN,VSDTM,"HDL",IEN)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
End DoDot:2
End DoDot:1
+83 ;
+84 ; Check for value of Total minus value of HDL for most recent result
+85 NEW TVISIT,TVIEN,HVISIT,HVIEN
+86 SET DFN=""
+87 FOR
SET DFN=$ORDER(@BQGLBT@(DFN))
IF DFN=""
QUIT
Begin DoDot:1
+88 SET DTM=""
SET QFL=0
+89 FOR
SET DTM=$ORDER(@BQGLBT@(DFN,DTM),-1)
IF DTM=""
QUIT
Begin DoDot:2
+90 SET HDL=$DATA(@BQGLBT@(DFN,DTM,"HDL"))
+91 SET TOT=$DATA(@BQGLBT@(DFN,DTM,"TOTAL"))
+92 IF HDL
IF TOT
Begin DoDot:3
+93 SET TIEN=$ORDER(@BQGLBT@(DFN,DTM,"TOTAL",""))
+94 SET TOTAL=$PIECE(@BQGLBT@(DFN,DTM,"TOTAL",TIEN),"^",1)
+95 SET TVISIT=$PIECE(@BQGLBT@(DFN,DTM,"TOTAL",TIEN),"^",2)
+96 SET TVIEN=$PIECE(@BQGLBT@(DFN,DTM,"TOTAL",TIEN),"^",3)
+97 SET HIEN=$ORDER(@BQGLBT@(DFN,DTM,"HDL",""))
+98 SET HDL=$PIECE(@BQGLBT@(DFN,DTM,"HDL",HIEN),"^",1)
+99 SET HVISIT=$PIECE(@BQGLBT@(DFN,DTM,"HDL",HIEN),"^",2)
+100 SET HVIEN=$PIECE(@BQGLBT@(DFN,DTM,"HDL",HIEN),"^",3)
+101 SET NHDL=TOTAL-HDL
+102 IF NHDL'>189
QUIT
+103 SET QFL=1
+104 SET @BQGLBT@(DFN,"CRITERIA","NON HDL","V",TVISIT,TVIEN)=DTM_U_U_TVIEN_U_FREF
+105 SET @BQGLBT@(DFN,"CRITERIA","NON HDL","V",HVISIT,HVIEN)=DTM_U_U_HVIEN_U_FREF
+106 SET TX="NON HDL"
+107 DO STOR(DFN,"Risk Factor-Non HDL")
End DoDot:3
IF QFL
QUIT
End DoDot:2
IF QFL
QUIT
End DoDot:1
+108 ;
+109 KILL DFN,DTM,HDL,TOT,IEN,NHDL,SEX,VISIT,VSDTM,TMFRAME,TAX,FREF,GREF
+110 KILL TIEN,ENDT,BQREF,@BQGLBT,TDFN,SDFN,TOTAL,RESULT,TREF,TIEN,HIEN,TX
+111 QUIT
+112 ;
STOR(SDFN,CRIT) ; Store the patient's met criteria
+1 IF $GET(@TTGLOB@(SDFN))>2
QUIT
+2 IF $DATA(@TTGLOB@(SDFN,"CRITERIA",CRIT))>0
QUIT
+3 SET @TTGLOB@(SDFN)=$GET(@TTGLOB@(SDFN))+1
+4 MERGE @TTGLOB@(SDFN,"CRITERIA",CRIT,"V")=@BQGLBT@(SDFN,"CRITERIA",TX,"V")
+5 MERGE @TTGLOB@(SDFN,"CRITERIA",CRIT,"P")=@BQGLBT@(SDFN,"CRITERIA",TX,"P")
+6 QUIT
+7 ;
PAT(BTDFN,BTGLOB) ;EP -- Get cholesterol for a patient
+1 NEW BQDXN,BQREF
+2 SET BQGLBT=$NAME(^TMP("BQITMP",UID))
KILL @BQGLBT
+3 SET BQDXN=$$GDXN^BQITUTL("High Cholesterol")
+4 SET BQREF="BQIRY"
+5 DO GDF^BQITUTL(BQDXN,BQREF)
+6 IF $$PAT^BQITDGN(BQREF,BQGLBT,BTDFN)
Begin DoDot:1
+7 NEW TX
+8 SET TX=$ORDER(@BQGLBT@(BTDFN,"CRITERIA",""))
+9 DO STOR^BQITD05(BTDFN,TX,BQGLBT)
End DoDot:1
+10 ;
+11 SET FREF=9000010.09
SET GREF=$$ROOT^DILFD(FREF,"",1)
SET TREF=$NAME(^TMP("BQITAX",UID))
+12 KILL @TREF
+13 SET TMFRAME="T-60M"
SET ENDT=$$DATE^BQIUL1(TMFRAME)
SET STDT=$$DT^XLFDT()
+14 SET DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1)
SET EXDT=""
+15 FOR TAX="DM AUDIT LDL CHOLESTEROL TAX","BGP LDL LOINC CODES"
DO BLD^BQITUTL(TAX,TREF)
+16 SET IEN=""
SET QFL=0
+17 FOR
SET IEN=$ORDER(@GREF@("AC",BTDFN,IEN),-1)
IF IEN=""
QUIT
Begin DoDot:1
+18 SET TIEN=$$GET1^DIQ(FREF,IEN,.01,"I")
IF TIEN=""
QUIT
+19 IF '$DATA(@TREF@(TIEN))
QUIT
+20 SET VISIT=$$GET1^DIQ(FREF,IEN,.03,"I")
IF VISIT=""
QUIT
+21 IF $$GET1^DIQ(9000010,VISIT,.11,"I")=1
QUIT
+22 SET VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1
IF 'VSDTM
QUIT
+23 IF $GET(TMFRAME)'=""
IF VSDTM<ENDT
QUIT
+24 SET RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
IF RESULT=""
QUIT
+25 IF RESULT'>159
QUIT
+26 SET $PIECE(@BQGLBT@(BTDFN,"CRITERIA",TAX,"V",VISIT,IEN),U,1)=VSDTM
SET TX=TAX
+27 SET $PIECE(@BQGLBT@(BTDFN,"CRITERIA",TAX,"V",VISIT,IEN),U,3)=IEN_U_FREF
+28 IF DTDIF'=""
SET EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
+29 IF EXDT'=""
SET $PIECE(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,2)=EXDT
+30 DO STOR^BQITD05(BTDFN,TAX,BQGLBT)
+31 SET QFL=1
End DoDot:1
IF QFL
QUIT
+32 ;
+33 SET FREF=9000010.09
SET GREF=$$ROOT^DILFD(FREF,"",1)
SET TREF=$NAME(^TMP("BQITAX",UID))
+34 KILL @TREF,@BQGLBT
+35 FOR TAX="DM AUDIT CHOLESTEROL TAX","BGP TOTAL CHOLESTEROL LOINC"
DO BLD^BQITUTL(TAX,TREF)
+36 SET IEN=""
SET QFL=0
+37 FOR
SET IEN=$ORDER(@GREF@("AC",BTDFN,IEN),-1)
IF IEN=""
QUIT
Begin DoDot:1
+38 SET TIEN=$$GET1^DIQ(FREF,IEN,.01,"I")
IF TIEN=""
QUIT
+39 IF '$DATA(@TREF@(TIEN))
QUIT
+40 SET VISIT=$$GET1^DIQ(FREF,IEN,.03,"I")
IF VISIT=""
QUIT
+41 IF $$GET1^DIQ(9000010,VISIT,.11,"I")=1
QUIT
+42 SET VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1
IF 'VSDTM
QUIT
+43 IF $GET(TMFRAME)'=""
IF VSDTM<ENDT
QUIT
+44 SET RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
IF RESULT=""
QUIT
+45 IF RESULT'>239
QUIT
+46 SET @BQGLBT@(BTDFN,VSDTM,"TOTAL",IEN)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
+47 SET $PIECE(@BQGLBT@(BTDFN,"CRITERIA",TAX,"V",VISIT,IEN),U,1)=VSDTM
SET TX=TAX
+48 SET $PIECE(@BQGLBT@(BTDFN,"CRITERIA",TAX,"V",VISIT,IEN),U,3)=IEN_U_FREF
+49 IF DTDIF'=""
SET EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
+50 IF EXDT'=""
SET $PIECE(@BQGLBT@(DFN,"CRITERIA",TAX,"V",VISIT,IEN),U,2)=EXDT
+51 DO STOR^BQITD05(BTDFN,TAX,BQGLBT)
+52 SET QFL=1
+53 KILL @BQGLBT@(DFN,"CRITERIA")
End DoDot:1
IF QFL
QUIT
+54 ;
+55 SET FREF=9000010.09
SET GREF=$$ROOT^DILFD(FREF,"",1)
SET TREF=$NAME(^TMP("BQITAX",UID))
+56 KILL @TREF
+57 FOR TAX="DM AUDIT HDL TAX","BGP HDL LOINC CODES"
DO BLD^BQITUTL(TAX,TREF)
+58 SET IEN=""
+59 FOR
SET IEN=$ORDER(@GREF@("AC",BTDFN,IEN),-1)
IF IEN=""
QUIT
Begin DoDot:1
+60 SET TIEN=$$GET1^DIQ(FREF,IEN,.01,"I")
IF TIEN=""
QUIT
+61 IF '$DATA(@TREF@(TIEN))
QUIT
+62 SET VISIT=$$GET1^DIQ(FREF,IEN,.03,"I")
IF VISIT=""
QUIT
+63 IF $$GET1^DIQ(9000010,VISIT,.11,"I")=1
QUIT
+64 SET RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
IF RESULT=""
QUIT
+65 SET VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1
IF 'VSDTM
QUIT
+66 IF $GET(TMFRAME)'=""
IF VSDTM<ENDT
QUIT
+67 SET @BQGLBT@(BTDFN,VSDTM,"HDL",IEN)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
End DoDot:1
+68 ;
+69 SET DTM=""
SET QFL=0
+70 FOR
SET DTM=$ORDER(@BQGLBT@(BTDFN,DTM),-1)
IF DTM=""
QUIT
Begin DoDot:1
+71 SET HDL=$DATA(@BQGLBT@(BTDFN,DTM,"HDL"))
+72 SET TOT=$DATA(@BQGLBT@(BTDFN,DTM,"TOTAL"))
+73 IF HDL
IF TOT
Begin DoDot:2
+74 SET TIEN=$ORDER(@BQGLBT@(BTDFN,DTM,"TOTAL",""))
+75 SET TOTAL=$PIECE(@BQGLBT@(BTDFN,DTM,"TOTAL",TIEN),"^",1)
+76 SET TVISIT=$PIECE(@BQGLBT@(BTDFN,DTM,"TOTAL",TIEN),"^",2)
+77 SET TVIEN=$PIECE(@BQGLBT@(BTDFN,DTM,"TOTAL",TIEN),"^",3)
+78 SET HIEN=$ORDER(@BQGLBT@(BTDFN,DTM,"HDL",""))
+79 SET HDL=$PIECE(@BQGLBT@(BTDFN,DTM,"HDL",HIEN),"^",1)
+80 SET HVISIT=$PIECE(@BQGLBT@(BTDFN,DTM,"HDL",HIEN),"^",2)
+81 SET HVIEN=$PIECE(@BQGLBT@(BTDFN,DTM,"HDL",HIEN),"^",3)
+82 SET NHDL=TOTAL-HDL
+83 IF NHDL'>189
QUIT
+84 SET @BQGLBT@(BTDFN,"CRITERIA","NON HDL","V",TVISIT,TVIEN)=DTM_U_U_TVIEN_U_FREF
+85 SET @BQGLBT@(BTDFN,"CRITERIA","NON HDL","V",HVISIT,HVIEN)=DTM_U_U_HVIEN_U_FREF
+86 SET TX="NON HDL"
+87 DO STOR^BQITD05(BTDFN,TX,BQGLBT)
+88 SET QFL=1
End DoDot:2
End DoDot:1
IF QFL
QUIT
+89 KILL @TREF,@BQGLBT,TIEN,HIEN,TX,HDL,TOT,TOTAL,NHDL,DTM,VISIT,RESULT,VSDTM,TMFRAME
+90 KILL TAX,FREF,GREF,IEN,TREF,TVISIT,TVIEN,HVISIT,HVIEN
+91 QUIT