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

BQITNPH.m

Go to the documentation of this file.
BQITNPH ;PRXM/HC/ALA-Nephropathy Definition ; 12 Apr 2006  2:13 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 Q
 ;
DEF(TTGLOB) ;EP -- Nephropathy Definition
 ;Description
 ;  DEF.05 formerly CVDAL.DEF.DX.1
 ;Input
 ;  TTGLOB - Global reference where patients matching high cholesterol
 ;           will be place.  Subscripted by patient IEN.
 ;
 NEW BQREF,BQIRY,TAX,BQGLBT,TDFN,DFN,STOP
 ; Use taxonomy definitions
 S BQREF="BQIRY" K @BQREF
 S TAX="Nephropathy"
 D ARY^BQITUTL(TAX,BQREF)
 S BQGLBT=$NA(^TMP("BQITMP",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
 ;
 ;Creatinine Lab test value check
 NEW CRDATA
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1)
 S TREF=$NA(^TMP("BQITAX",UID)),CRDATA=$NA(^TMP("BQICREAT",UID))
 K @TREF,@CRDATA
 S TMFRAME="T-12M",ENDT=$$DATE^BQIUL1(TMFRAME),STDT=$$DT^XLFDT()
 S DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1),EXDT=""
 F TAX="DM AUDIT CREATININE TAX","BGP CREATININE 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 VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
 .. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
 .. I RESULT<2.0 Q
 .. 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
 .. ; need to be separated by at least 90 days
 .. I '$D(@CRDATA@(DFN,VSDTM)) S @CRDATA@(DFN)=$G(@CRDATA@(DFN))+1
 .. S @CRDATA@(DFN,VSDTM)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
 .. Q
 ;
 S DFN="" F  S DFN=$O(@CRDATA@(DFN)) Q:DFN=""  D
 . I @CRDATA@(DFN)<2 K @CRDATA@(DFN) Q
 . S DATE="",STOP=0
 . NEW DATE1,DATE2
 . F  S DATE=$O(@CRDATA@(DFN,DATE),-1) Q:DATE=""  D  Q:STOP
 .. S DATE1=DATE,DATE2=$O(@CRDATA@(DFN,DATE1),-1) Q:DATE2=""
 .. I $$FMDIFF^XLFDT(DATE1,DATE2,1)<90 Q
 .. S RESULT=$P(@CRDATA@(DFN,DATE1),"^",1)
 .. S VISIT=$P(@CRDATA@(DFN,DATE1),"^",2)
 .. S IEN=$P(@CRDATA@(DFN,DATE1),"^",3)
 .. S RESULT1=$P(@CRDATA@(DFN,DATE2),"^",1)
 .. S VISIT1=$P(@CRDATA@(DFN,DATE2),"^",2)
 .. S IEN1=$P(@CRDATA@(DFN,DATE2),"^",3)
 .. S @BQGLBT@(DFN,"CRITERIA","Nephropathy-Creatinine Value","V",VISIT,IEN)=DATE1_U_U_IEN_U_FREF
 .. I DTDIF'="" S EXDT=$$FMADD^XLFDT(DATE1,DTDIF)
 .. S $P(@BQGLBT@(DFN,"CRITERIA","Nephropathy-Creatinine Value","V",VISIT,IEN),U,2)=EXDT
 .. S @BQGLBT@(DFN,"CRITERIA","Nephropathy-Creatinine Value","V",VISIT1,IEN1)=DATE2_U_U_IEN1_U_FREF
 .. I DTDIF'="" S EXDT=$$FMADD^XLFDT(DATE2,DTDIF)
 .. S $P(@BQGLBT@(DFN,"CRITERIA","Nephropathy-Creatinine Value","V",VISIT1,IEN1),U,2)=EXDT
 .. S TX="Nephropathy-Creatinine Value"
 .. D STOR(DFN,TX)
 .. S STOP=1 ; Criteria has been met for this patient - stop searching
 .. ;I RESULT'<2.0,RESULT1'<2.0 D STOR(DFN,TX)
 ;
 K @BQGLBT
 ;GFR Lab test value check
 NEW GFDATA
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1)
 S TREF=$NA(^TMP("BQITAX",UID)),GFDATA=$NA(^TMP("BQIGFR",UID))
 K @TREF,@GFDATA
 S TMFRAME="T-12M",ENDT=$$DATE^BQIUL1(TMFRAME),STDT=$$DT^XLFDT()
 S DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1),EXDT=""
 F TAX="BGP GPRA ESTIMATED GFR TAX","BGP ESTIMATED GFR LOINC" D BLD^BQITUTL(TAX,TREF)
 ;D BLDSV^BQITUTL(95.3,"33914-3",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 RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
 .. I RESULT>30 Q
 .. 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 @GFDATA@(DFN,VSDTM)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
 .. S @GFDATA@(DFN)=$G(@GFDATA@(DFN))+1
 .. Q
 ;
 S DFN="" F  S DFN=$O(@GFDATA@(DFN)) Q:DFN=""  D
 . I @GFDATA@(DFN)<2 K @GFDATA@(DFN) Q
 . S DATE="",STOP=0
 . NEW DATE1,DATE2
 . F  S DATE=$O(@GFDATA@(DFN,DATE),-1) Q:DATE=""  D  Q:STOP
 .. S DATE1=DATE,DATE2=$O(@GFDATA@(DFN,DATE1),-1) Q:DATE2=""
 .. ; need to be separated by at least 90 days
 .. I $$FMDIFF^XLFDT(DATE1,DATE2,1)<90 Q
 .. S RESULT=$P(@GFDATA@(DFN,DATE1),"^",1)
 .. S VISIT=$P(@GFDATA@(DFN,DATE1),"^",2)
 .. S IEN=$P(@GFDATA@(DFN,DATE1),"^",3)
 .. S RESULT1=$P(@GFDATA@(DFN,DATE2),"^",1)
 .. S VISIT1=$P(@GFDATA@(DFN,DATE2),"^",2)
 .. S IEN1=$P(@GFDATA@(DFN,DATE2),"^",3)
 .. S @BQGLBT@(DFN,"CRITERIA","Nephropathy-GFR Value","V",VISIT,IEN)=DATE1_U_U_IEN_U_FREF
 .. I DTDIF'="" S EXDT=$$FMADD^XLFDT(DATE1,DTDIF)
 .. S $P(@BQGLBT@(DFN,"CRITERIA","Nephropathy-GFR Value","V",VISIT,IEN),U,2)=EXDT
 .. S @BQGLBT@(DFN,"CRITERIA","Nephropathy-GFR Value","V",VISIT1,IEN1)=DATE2_U_U_IEN1_U_FREF
 .. I DTDIF'="" S EXDT=$$FMADD^XLFDT(DATE2,DTDIF)
 .. S $P(@BQGLBT@(DFN,"CRITERIA","Nephropathy-GFR Value","V",VISIT1,IEN1),U,2)=EXDT
 .. S TX="Nephropathy-GFR Value"
 .. D STOR(DFN,"Nephropathy-GFR Value")
 .. S STOP=1 ; Criteria has been met for this patient - stop searching
 .. ;I RESULT'>30,RESULT1'>30 D STOR(DFN,"Nephropathy-GFR Value")
 ;
 K @GFDATA,@CRDATA,@TREF,DFN,RESULT,RESULT1,DATE,DATE1,DATE2
 K TMFRAME,VISIT,VSDTM,ENDT,FREF,GREF,TREF,TAX,TIEN,IEN,TDFN,SDFN,@BQGLBT,IEN,IEN1
 Q
 ;
STOR(SDFN,CRIT) ;  Store the patient's met criteria
 S @TTGLOB@(SDFN)=$G(@TTGLOB@(SDFN))+1
 ;S @TTGLOB@(SDFN,"CRITERIA",CRIT)=""
 M @TTGLOB@(SDFN,"CRITERIA")=@BQGLBT@(SDFN,"CRITERIA")
 Q
 ;
PAT(BTDFN,BTGLOB) ;EP -- Get nephropathy for a patient
 NEW VISIT,VISIT1,BQGLBT,BQDXN,BQREF,FREF,GREF,TREF,TMFRAME,TAX,IEN
 NEW TIEN,RESULT,VSDTM,RESULT1,DATE,DATE1,DATE2,ENDT,STOP
 S BQGLBT=$NA(^TMP("BQITMP",UID))
 S BQDXN=$$GDXN^BQITUTL("Nephropathy")
 S BQREF="BQIRY"
 D GDF^BQITUTL(BQDXN,BQREF)
 I $$PAT^BQITDGN(BQREF,BQGLBT,BTDFN) D STOR^BQITD05(BTDFN,"Risk-Nephropathy",BQGLBT)
 ;
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1)
 S TREF=$NA(^TMP("BQITAX",UID)),CRDATA=$NA(^TMP("BQICREAT",UID))
 K @TREF,@CRDATA
 S TMFRAME="T-12M",ENDT=$$DATE^BQIUL1(TMFRAME),STDT=$$DT^XLFDT()
 S DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1),EXDT=""
 F TAX="DM AUDIT CREATININE TAX","BGP CREATININE LOINC CODES" D BLD^BQITUTL(TAX,TREF)
 S IEN=""
 F  S IEN=$O(@GREF@("AC",BTDFN,IEN)) 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=""
 . S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
 . I RESULT<2.0 Q
 . 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
 . I '$D(@CRDATA@(BTDFN,VSDTM)) S @CRDATA@(BTDFN)=$G(@CRDATA@(BTDFN))+1
 . S @CRDATA@(BTDFN,VSDTM)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
 I $G(@CRDATA@(BTDFN))<2 K @CRDATA@(BTDFN)
 S DATE="",STOP=0
 NEW DATE1,DATE2
 F  S DATE=$O(@CRDATA@(BTDFN,DATE),-1) Q:DATE=""  D  Q:STOP
 . S DATE1=DATE,DATE2=$O(@CRDATA@(BTDFN,DATE1),-1) Q:DATE2=""
 . I $$FMDIFF^XLFDT(DATE1,DATE2,1)<90 Q
 . S RESULT=$P(@CRDATA@(BTDFN,DATE1),"^",1)
 . S VISIT=$P(@CRDATA@(BTDFN,DATE1),"^",2)
 . S IEN=$P(@CRDATA@(BTDFN,DATE1),"^",3)
 . S RESULT1=$P(@CRDATA@(BTDFN,DATE2),"^",1)
 . S VISIT1=$P(@CRDATA@(BTDFN,DATE2),"^",2)
 . S IEN1=$P(@CRDATA@(BTDFN,DATE2),"^",3)
 . S @BQGLBT@(BTDFN,"CRITERIA","Nephropathy-Creatinine Value","V",VISIT,IEN)=DATE1_U_U_IEN_U_FREF
 . I DTDIF'="" S EXDT=$$FMADD^XLFDT(DATE1,DTDIF)
 . S $P(@BQGLBT@(BTDFN,"CRITERIA","Nephropathy-Creatinine Value","V",VISIT,IEN),U,2)=EXDT
 . S @BQGLBT@(BTDFN,"CRITERIA","Nephropathy-Creatinine Value","V",VISIT1,IEN1)=DATE2_U_U_IEN1_U_FREF
 . I DTDIF'="" S EXDT=$$FMADD^XLFDT(DATE2,DTDIF)
 . S $P(@BQGLBT@(BTDFN,"CRITERIA","Nephropathy-Creatinine Value","V",VISIT1,IEN1),U,2)=EXDT
 . S TX="Nephropathy-Creatinine Value"
 . D STOR^BQITD05(BTDFN,"Nephropathy-Creatinine Value",BQGLBT)
 . S STOP=1 ; Criteria has been met - stop searching
 ;
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1)
 S TREF=$NA(^TMP("BQITAX",UID)),GFDATA=$NA(^TMP("BQIGFR",UID))
 K @GFDATA,@TREF
 S TMFRAME="T-12M",ENDT=$$DATE^BQIUL1(TMFRAME),STDT=$$DT^XLFDT()
 S DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1),EXDT=""
 F TAX="BGP GPRA ESTIMATED GFR TAX","BGP ESTIMATED GFR LOINC" D BLD^BQITUTL(TAX,TREF)
 ;D BLDSV^BQITUTL(95.3,"33914-3",TREF)
 S IEN=""
 F  S IEN=$O(@GREF@("AC",BTDFN,IEN)) 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=""
 . S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E") Q:RESULT=""
 . I RESULT<30 Q
 . 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 @GFDATA@(BTDFN,VSDTM)=RESULT_"^"_VISIT_"^"_IEN_"^"_FREF
 . S @GFDATA@(BTDFN)=$G(@GFDATA@(BTDFN))+1
 ;
 I $G(@GFDATA@(BTDFN))<2 K @GFDATA@(BTDFN)
 S DATE="",STOP=0
 NEW DATE1,DATE2
 F  S DATE=$O(@GFDATA@(BTDFN,DATE),-1) Q:DATE=""  D  Q:STOP
 . S DATE1=DATE,DATE2=$O(@GFDATA@(BTDFN,DATE1),-1) Q:DATE2=""
 . ; need to be separated by at least 90 days
 . I $$FMDIFF^XLFDT(DATE1,DATE2,1)<90 Q
 . S RESULT=$P(@GFDATA@(BTDFN,DATE1),"^",1)
 . S VISIT=$P(@GFDATA@(BTDFN,DATE1),"^",2)
 . S IEN=$P(@GFDATA@(BTDFN,DATE1),"^",3)
 . S RESULT1=$P(@GFDATA@(BTDFN,DATE2),"^",1)
 . S VISIT1=$P(@GFDATA@(BTDFN,DATE2),"^",2)
 . S IEN1=$P(@GFDATA@(BTDFN,DATE2),"^",3)
 . S @BQGLBT@(BTDFN,"CRITERIA","Nephropathy-GFR Value","V",VISIT,IEN)=DATE1_U_U_IEN_U_FREF
 . I DTDIF'="" S EXDT=$$FMADD^XLFDT(DATE1,DTDIF)
 . S $P(@BQGLBT@(BTDFN,"CRITERIA","Nephropathy-GFR Value","V",VISIT,IEN),U,2)=EXDT
 . S @BQGLBT@(BTDFN,"CRITERIA","Nephropathy-GFR Value","V",VISIT1,IEN1)=DATE2_U_U_IEN1_U_FREF
 . I DTDIF'="" S EXDT=$$FMADD^XLFDT(DATE2,DTDIF)
 . S $P(@BQGLBT@(BTDFN,"CRITERIA","Nephropathy-GFR Value","V",VISIT1,IEN1),U,2)=EXDT
 . S TX="Nephropathy-GFR Value"
 . D STOR^BQITD05(BTDFN,"Nephropathy-GFR Value",BQGLBT)
 . S STOP=1 ; Criteria has been met - stop searching
 Q