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

BQITHCH.m

Go to the documentation of this file.
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