BQITD081 ;APTIV/HC/DB-HIV/AIDS Definition (cont) ; 04 Jun 2008 9:01 AM
;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
; Utilities called by BQITD08
;
Q
;
POV(DFN,GLOB,TMREF,DXOK) ; EP - Process HIV/AIDS POV date logic
;
; At least two POVs ever at least 60 days apart
;
; Input
; DFN - patient whose HIV/AIDS POVs are being examined
; GLOB - Global where data is to be stored
; Structure:
; GLOB(DFN,"CRITERIA",criteria or taxonomy,visit ien)=date/time
; TMREF - Global used to temporarily store diagnoses that may meet the
; POV logic and, if so, will be stored in GLOB
; DXOK - If set to '1', patient meets the POV logic for HIV/AIDS - value
; may be returned (if called by PAT subroutine)
; Variables
; NOK - If set to '1', no diagnoses remaining that will meet the date logic
; LDX - Most recent diagnosis that meets the POV criteria
; FDX - Other diagnosis that must be compared to LDX to determine if they
; meet the date logic
N NOK,LDX,FDX,DX
I $G(@TMREF@(DFN))<2 K @TMREF@(DFN) Q
S DXOK=0,NOK=0
F D Q:DXOK!NOK K @TMREF@(DFN,LDX)
. S LDX=$O(@TMREF@(DFN,"A"),-1) I LDX="" S NOK=1 Q
. S FDX=LDX
. F S FDX=$O(@TMREF@(DFN,FDX),-1) Q:FDX="" D Q:DXOK
.. I $$FMDIFF^XLFDT(LDX,FDX,1)>59 S DXOK=1 D
... ; Delete remaining entries from temporary file
... S DX=""
... F S DX=$O(@TMREF@(DFN,DX)) Q:DX="" I DX'=LDX,DX'=FDX K @TMREF@(DFN,DX)
; Update global with criteria
I DXOK D
. M @GLOB@(DFN)=@TMREF@(DFN)
. NEW IEN,FREF,EXDT
. S VSDT="",EXDT=""
. F S VSDT=$O(@TMREF@(DFN,VSDT)) Q:VSDT="" D
.. S TIEN="" F S TIEN=$O(@TMREF@(DFN,VSDT,TIEN)) Q:TIEN="" D
... S VISIT=$P(@TMREF@(DFN,VSDT,TIEN),U,2),VTYP=$P(@TMREF@(DFN,VSDT,TIEN),U,1)
... S IEN=$P(@TMREF@(DFN,VSDT,TIEN),U,4),FREF=$P(@TMREF@(DFN,VSDT,TIEN),U,5)
... S @GLOB@(DFN,"CRITERIA",TAX,VTYP,VISIT,IEN)=VSDT_U_EXDT_U_IEN_U_FREF
Q
;
CDVL(DFN,GLOB,TMREF,DXOK) ; EP - Process CD4/Viral Load date logic
;
; At least two CD4 or Viral Load lab tests in the past two years
; at least 60 days apart
; Note: one CD4 and one Viral Load lab test in the past two years
; at least 60 days apart also meet this criteria
;
; Input
; DFN - patient whose CD4 and Viral Load lab tests are being examined
; GLOB - Global where data is to be stored
; Structure:
; GLOB(DFN,"CRITERIA",criteria or taxonomy,visit ien)=date/time
; TMREF - Global used to temporarily store diagnoses that may meet the
; POV logic and, if so, will be stored in GLOB
; DXOK - If set to '1', patient meets the lab test logic for HIV/AIDS
; - value may be returned (if called by PAT subroutine)
; Variables
; NOK - If set to '1', no lab tests remaining that will meet the date logic
; LDX - Most recent lab test that meets the POV criteria
; FDX - Other lab test that must be compared to LDX to determine if they
; meet the date logic
N NOK,LDX,FDX,DX,ENDT
I $G(@TMREF@(DFN))<2 K @TMREF@(DFN) Q
S ENDT=$$FMADD^XLFDT(DT,-730) ; Can only be within the past 2 years
S DXOK=0,NOK=0
F D Q:DXOK!NOK K @TMREF@(DFN,LDX)
. S LDX=$O(@TMREF@(DFN,"A"),-1) I LDX<ENDT S NOK=1 Q
. S FDX=LDX
. F S FDX=$O(@TMREF@(DFN,FDX),-1) Q:FDX<ENDT D Q:DXOK
.. I $$FMDIFF^XLFDT(LDX,FDX,1)>59 S DXOK=1 D
... ; Delete remaining entries from temporary file
... S DX=""
... F S DX=$O(@TMREF@(DFN,DX)) Q:DX="" I DX'=LDX,DX'=FDX K @TMREF@(DFN,DX)
; Update global with criteria
I DXOK D
. M @GLOB@(DFN)=@TMREF@(DFN)
. NEW IEN,FREF,EXDT
. S VSDT="",EXDT=""
. F S VSDT=$O(@TMREF@(DFN,VSDT)) Q:VSDT="" D
.. S TIEN="" F S TIEN=$O(@TMREF@(DFN,VSDT,TIEN)) Q:TIEN="" D
... S VISIT=$P(@TMREF@(DFN,VSDT,TIEN),U,2),VTYP=$P(@TMREF@(DFN,VSDT,TIEN),U,1)
... S IEN=$P(@TMREF@(DFN,VSDT,TIEN),U,4),FREF=$P(@TMREF@(DFN,VSDT,TIEN),U,5)
... S @GLOB@(DFN,"CRITERIA",TAX,VTYP,VISIT,IEN)=VSDT_U_EXDT_U_IEN_U_FREF
Q
BQITD081 ;APTIV/HC/DB-HIV/AIDS Definition (cont) ; 04 Jun 2008 9:01 AM
+1 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
+2 ; Utilities called by BQITD08
+3 ;
+4 QUIT
+5 ;
POV(DFN,GLOB,TMREF,DXOK) ; EP - Process HIV/AIDS POV date logic
+1 ;
+2 ; At least two POVs ever at least 60 days apart
+3 ;
+4 ; Input
+5 ; DFN - patient whose HIV/AIDS POVs are being examined
+6 ; GLOB - Global where data is to be stored
+7 ; Structure:
+8 ; GLOB(DFN,"CRITERIA",criteria or taxonomy,visit ien)=date/time
+9 ; TMREF - Global used to temporarily store diagnoses that may meet the
+10 ; POV logic and, if so, will be stored in GLOB
+11 ; DXOK - If set to '1', patient meets the POV logic for HIV/AIDS - value
+12 ; may be returned (if called by PAT subroutine)
+13 ; Variables
+14 ; NOK - If set to '1', no diagnoses remaining that will meet the date logic
+15 ; LDX - Most recent diagnosis that meets the POV criteria
+16 ; FDX - Other diagnosis that must be compared to LDX to determine if they
+17 ; meet the date logic
+18 NEW NOK,LDX,FDX,DX
+19 IF $GET(@TMREF@(DFN))<2
KILL @TMREF@(DFN)
QUIT
+20 SET DXOK=0
SET NOK=0
+21 FOR
Begin DoDot:1
+22 SET LDX=$ORDER(@TMREF@(DFN,"A"),-1)
IF LDX=""
SET NOK=1
QUIT
+23 SET FDX=LDX
+24 FOR
SET FDX=$ORDER(@TMREF@(DFN,FDX),-1)
IF FDX=""
QUIT
Begin DoDot:2
+25 IF $$FMDIFF^XLFDT(LDX,FDX,1)>59
SET DXOK=1
Begin DoDot:3
+26 ; Delete remaining entries from temporary file
+27 SET DX=""
+28 FOR
SET DX=$ORDER(@TMREF@(DFN,DX))
IF DX=""
QUIT
IF DX'=LDX
IF DX'=FDX
KILL @TMREF@(DFN,DX)
End DoDot:3
End DoDot:2
IF DXOK
QUIT
End DoDot:1
IF DXOK!NOK
QUIT
KILL @TMREF@(DFN,LDX)
+29 ; Update global with criteria
+30 IF DXOK
Begin DoDot:1
+31 MERGE @GLOB@(DFN)=@TMREF@(DFN)
+32 NEW IEN,FREF,EXDT
+33 SET VSDT=""
SET EXDT=""
+34 FOR
SET VSDT=$ORDER(@TMREF@(DFN,VSDT))
IF VSDT=""
QUIT
Begin DoDot:2
+35 SET TIEN=""
FOR
SET TIEN=$ORDER(@TMREF@(DFN,VSDT,TIEN))
IF TIEN=""
QUIT
Begin DoDot:3
+36 SET VISIT=$PIECE(@TMREF@(DFN,VSDT,TIEN),U,2)
SET VTYP=$PIECE(@TMREF@(DFN,VSDT,TIEN),U,1)
+37 SET IEN=$PIECE(@TMREF@(DFN,VSDT,TIEN),U,4)
SET FREF=$PIECE(@TMREF@(DFN,VSDT,TIEN),U,5)
+38 SET @GLOB@(DFN,"CRITERIA",TAX,VTYP,VISIT,IEN)=VSDT_U_EXDT_U_IEN_U_FREF
End DoDot:3
End DoDot:2
End DoDot:1
+39 QUIT
+40 ;
CDVL(DFN,GLOB,TMREF,DXOK) ; EP - Process CD4/Viral Load date logic
+1 ;
+2 ; At least two CD4 or Viral Load lab tests in the past two years
+3 ; at least 60 days apart
+4 ; Note: one CD4 and one Viral Load lab test in the past two years
+5 ; at least 60 days apart also meet this criteria
+6 ;
+7 ; Input
+8 ; DFN - patient whose CD4 and Viral Load lab tests are being examined
+9 ; GLOB - Global where data is to be stored
+10 ; Structure:
+11 ; GLOB(DFN,"CRITERIA",criteria or taxonomy,visit ien)=date/time
+12 ; TMREF - Global used to temporarily store diagnoses that may meet the
+13 ; POV logic and, if so, will be stored in GLOB
+14 ; DXOK - If set to '1', patient meets the lab test logic for HIV/AIDS
+15 ; - value may be returned (if called by PAT subroutine)
+16 ; Variables
+17 ; NOK - If set to '1', no lab tests remaining that will meet the date logic
+18 ; LDX - Most recent lab test that meets the POV criteria
+19 ; FDX - Other lab test that must be compared to LDX to determine if they
+20 ; meet the date logic
+21 NEW NOK,LDX,FDX,DX,ENDT
+22 IF $GET(@TMREF@(DFN))<2
KILL @TMREF@(DFN)
QUIT
+23 ; Can only be within the past 2 years
SET ENDT=$$FMADD^XLFDT(DT,-730)
+24 SET DXOK=0
SET NOK=0
+25 FOR
Begin DoDot:1
+26 SET LDX=$ORDER(@TMREF@(DFN,"A"),-1)
IF LDX<ENDT
SET NOK=1
QUIT
+27 SET FDX=LDX
+28 FOR
SET FDX=$ORDER(@TMREF@(DFN,FDX),-1)
IF FDX<ENDT
QUIT
Begin DoDot:2
+29 IF $$FMDIFF^XLFDT(LDX,FDX,1)>59
SET DXOK=1
Begin DoDot:3
+30 ; Delete remaining entries from temporary file
+31 SET DX=""
+32 FOR
SET DX=$ORDER(@TMREF@(DFN,DX))
IF DX=""
QUIT
IF DX'=LDX
IF DX'=FDX
KILL @TMREF@(DFN,DX)
End DoDot:3
End DoDot:2
IF DXOK
QUIT
End DoDot:1
IF DXOK!NOK
QUIT
KILL @TMREF@(DFN,LDX)
+33 ; Update global with criteria
+34 IF DXOK
Begin DoDot:1
+35 MERGE @GLOB@(DFN)=@TMREF@(DFN)
+36 NEW IEN,FREF,EXDT
+37 SET VSDT=""
SET EXDT=""
+38 FOR
SET VSDT=$ORDER(@TMREF@(DFN,VSDT))
IF VSDT=""
QUIT
Begin DoDot:2
+39 SET TIEN=""
FOR
SET TIEN=$ORDER(@TMREF@(DFN,VSDT,TIEN))
IF TIEN=""
QUIT
Begin DoDot:3
+40 SET VISIT=$PIECE(@TMREF@(DFN,VSDT,TIEN),U,2)
SET VTYP=$PIECE(@TMREF@(DFN,VSDT,TIEN),U,1)
+41 SET IEN=$PIECE(@TMREF@(DFN,VSDT,TIEN),U,4)
SET FREF=$PIECE(@TMREF@(DFN,VSDT,TIEN),U,5)
+42 SET @GLOB@(DFN,"CRITERIA",TAX,VTYP,VISIT,IEN)=VSDT_U_EXDT_U_IEN_U_FREF
End DoDot:3
End DoDot:2
End DoDot:1
+43 QUIT