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

BKMQQCR4.m

Go to the documentation of this file.
BKMQQCR4 ;PRXM/HC/BWF - BKMV Quality of Care Report; [ 1/19/2005  7:16 PM ] ; 13 Apr 2005  4:47 PM
 ;;2.1;HIV MANAGEMENT SYSTEM;;Feb 07, 2011
 ; Quality of Care Audit Report
 Q
ARVM03 ; EP - ARV Therapy
 ; M.03 TAXONOMIES
 N ARVM03DT,SITETAX,NDCTAX,GLOBAL,TOTPTS,BKMDFN
 S ARVM03DT=$$FMADD^XLFDT(EDATE,-122)
 S SITETAX="BKMV NRTI MEDS"
 S NDCTAX="BKMV NRTI MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""ARVM03"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""ARVM03CNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,ARVM03DT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,ARVM03DT,GLOBAL)
 .; Store Medication refusals in same global as regular Medications.
 .;D REFUSAL^BKMIXX2(BKMDFN,50,SITETAX,EDATE,ARVM03DT,GLOBAL)
 .;D REFUSAL^BKMIXX2(BKMDFN,50,NDCTAX,EDATE,ARVM03DT,GLOBAL)
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM03")) D MEDLP("ARVM03")
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM03")) S @TOTPTS=@TOTPTS+1
 Q
ARVM02 ; EP - ARV Therapy
 ; M.02 TAXONOMIES
 N ARVM02DT,SITETAX,NDCTAX,GLOBAL,TOTPTS,BKMDFN
 S ARVM02DT=$$FMADD^XLFDT(EDATE,-122)
 S SITETAX="BKMV NNRTI MEDS"
 S NDCTAX="BKMV NNRTI MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""ARVM02"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""ARVM02CNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,ARVM02DT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,ARVM02DT,GLOBAL)
 .; Store Medication refusals in same global as regular Medications.
 .;D REFUSAL^BKMIXX2(BKMDFN,50,SITETAX,EDATE,ARVM02DT,GLOBAL)
 .;D REFUSAL^BKMIXX2(BKMDFN,50,NDCTAX,EDATE,ARVM02DT,GLOBAL)
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM02")) D MEDLP("ARVM02")
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM02")) S @TOTPTS=@TOTPTS+1
 Q
ARVM01 ; EP - ARV Therapy
 ; M.01 TAXONOMIES
 N ARVM01DT,SITETAX,NDCTAX,GLOBAL,TOTPTS,BKMDFN
 S ARVM01DT=$$FMADD^XLFDT(EDATE,-122)
 S SITETAX="BKMV MAC PROPH MEDS"
 S NDCTAX="BKMV MAC PROPH MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""ARVM01"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""ARVM01CNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,ARVM01DT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,ARVM01DT,GLOBAL)
 .; Store Medication refusals in same global as regular Medications.
 .;D REFUSAL^BKMIXX2(BKMDFN,50,SITETAX,EDATE,ARVM01DT,GLOBAL)
 .;D REFUSAL^BKMIXX2(BKMDFN,50,NDCTAX,EDATE,ARVM01DT,GLOBAL)
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM01")) D MEDLP("ARVM01")
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM01")) S @TOTPTS=@TOTPTS+1
 Q
ARVM05 ; EP - ARV Therapy
 ; M.05 TAXONOMIES
 N ARVM05DT,SITETAX,NDCTAX,GLOBAL,TOTPTS,BKMDFN
 S ARVM05DT=$$FMADD^XLFDT(EDATE,-122)
 S SITETAX="BKMV PI MEDS"
 S NDCTAX="BKMV PI MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""ARVM05"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""ARVM05CNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,ARVM05DT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,ARVM05DT,GLOBAL)
 .; Store Medication refusals in same global as regular Medications.
 .;D REFUSAL^BKMIXX2(BKMDFN,50,SITETAX,EDATE,ARVM05DT,GLOBAL)
 .;D REFUSAL^BKMIXX2(BKMDFN,50,NDCTAX,EDATE,ARVM05DT,GLOBAL)
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM05")) D MEDLP("ARVM05")
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM05")) S @TOTPTS=@TOTPTS+1
 Q
ARVM09 ; EP - ARV Therapy
 ; M.09 TAXONOMIES
 N ARVM09DT,SITETAX,NDCTAX,GLOBAL,TOTPTS,BKMDFN
 S ARVM09DT=$$FMADD^XLFDT(EDATE,-122)
 S SITETAX="BKMV EI MEDS"
 S NDCTAX="BKMV EI MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""ARVM09"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""ARVM09CNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,ARVM09DT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,ARVM09DT,GLOBAL)
 .; Store Medication refusals in same global as regular Medications.
 .;D REFUSAL^BKMIXX2(BKMDFN,50,SITETAX,EDATE,ARVM09DT,GLOBAL)
 .;D REFUSAL^BKMIXX2(BKMDFN,50,NDCTAX,EDATE,ARVM09DT,GLOBAL)
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM09")) D MEDLP("ARVM09")
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM09")) S @TOTPTS=@TOTPTS+1
 Q
ARVM10 ; EP - ARV Therapy
 ; M.10 TAXONOMIES
 N ARVM10DT,SITETAX,NDCTAX,GLOBAL,TOTPTS,BKMDFN
 S ARVM10DT=$$FMADD^XLFDT(EDATE,-122)
 S SITETAX="BKMV II MEDS"
 S NDCTAX="BKMV II MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""ARVM10"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""ARVM10CNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,ARVM10DT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,ARVM10DT,GLOBAL)
 .; Store Medication refusals in same global as regular Medications.
 .;D REFUSAL^BKMIXX2(BKMDFN,50,SITETAX,EDATE,ARVM10DT,GLOBAL)
 .;D REFUSAL^BKMIXX2(BKMDFN,50,NDCTAX,EDATE,ARVM10DT,GLOBAL)
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM10")) D MEDLP("ARVM10")
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM10")) S @TOTPTS=@TOTPTS+1
 Q
ARVM11 ; EP - ARV Therapy
 ; M.11 TAXONOMIES
 N ARVM11DT,SITETAX,NDCTAX,GLOBAL,TOTPTS,BKMDFN
 S ARVM11DT=$$FMADD^XLFDT(EDATE,-122)
 S SITETAX="BKMV NRTI/NNRTI MEDS"
 S NDCTAX="BKMV NRTI/NNRTI MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""ARVM11"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""ARVM11CNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,ARVM11DT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,ARVM11DT,GLOBAL)
 .; Store Medication refusals in same global as regular Medications.
 .;D REFUSAL^BKMIXX2(BKMDFN,50,SITETAX,EDATE,ARVM11DT,GLOBAL)
 .;D REFUSAL^BKMIXX2(BKMDFN,50,NDCTAX,EDATE,ARVM11DT,GLOBAL)
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM11")) D MEDLP("ARVM11")
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM11")) S @TOTPTS=@TOTPTS+1
 Q
ARVM12 ; EP - ARV Therapy
 ; M.12 TAXONOMIES
 N ARVM12DT,SITETAX,NDCTAX,GLOBAL,TOTPTS,BKMDFN
 S ARVM12DT=$$FMADD^XLFDT(EDATE,-122)
 S SITETAX="BKMV NRTI COMBO MEDS"
 S NDCTAX="BKMV NRTI COMBO MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""ARVM12"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""ARVM12CNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,ARVM12DT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,ARVM12DT,GLOBAL)
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM12")) D MEDLP("ARVM12")
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM12")) S @TOTPTS=@TOTPTS+1
 Q
ARVM13 ; EP - ARV Therapy
 ; M.13 TAXONOMIES
 N ARVM13DT,SITETAX,NDCTAX,GLOBAL,TOTPTS,BKMDFN
 S ARVM13DT=$$FMADD^XLFDT(EDATE,-122)
 S SITETAX="BKMV PI BOOSTER MEDS"
 S NDCTAX="BKMV PI BOOSTER MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""ARVM13"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""ARVM13CNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,ARVM13DT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,ARVM13DT,GLOBAL)
 .; Store Medication refusals in same global as regular Medications.
 .;D REFUSAL^BKMIXX2(BKMDFN,50,SITETAX,EDATE,ARVM13DT,GLOBAL)
 .;D REFUSAL^BKMIXX2(BKMDFN,50,NDCTAX,EDATE,ARVM13DT,GLOBAL)
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM13")) D MEDLP("ARVM13")
 .;
 .I $D(@GLOB@("HIVCHK",BKMDFN,"ARVM13")) S @TOTPTS=@TOTPTS+1
 Q
PCP ; EP - PCP Prophylaxis
 N SITETAX,NDCTAX,GLOBAL,BKMDFN,VSTDT,TEST,RESULT,TOTPTS,FOUND
 S SITETAX="BKMV PCP PROPH MEDS"
 S NDCTAX="BKMV PCP PROPH MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""PCP"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""PCPPTCNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .I '$D(@GLOB@("HIVCHK",BKMDFN,"CD4ABS12")) Q
 .S VSTDT=""
 .S FOUND=0
 .; Find earliest CD4 Absolute with results between 50 and 199.
 .F  S VSTDT=$O(@GLOB@("HIVCHK",BKMDFN,"CD4ABS12",VSTDT)) Q:VSTDT=""  D  Q:FOUND
 ..S TEST=""
 ..F  S TEST=$O(@GLOB@("HIVCHK",BKMDFN,"CD4ABS12",VSTDT,TEST)) Q:TEST=""  D  Q:FOUND
 ...S RESULT=$P($G(@GLOB@("HIVCHK",BKMDFN,"CD4ABS12",VSTDT,TEST)),U)
 ...I RESULT="" Q
 ...I RESULT'<200 Q
 ...;I RESULT<50 Q
 ...S FOUND=1
 .I 'FOUND Q
 .; select meds prescribed since the defined CD4 visit
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,VSTDT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,VSTDT,GLOBAL)
 .I $D(@GLOB@("HIVCHK",BKMDFN,"PCP")) S @TOTPTS=@TOTPTS+1
 Q
MAC ; EP - MAC Prophylaxis
 N SITETAX,NDCTAX,GLOBAL,BKMDFN,VSTDT,TEST,RESULT,TOTPTS,FOUND
 S SITETAX="BKMV MAC PROPH MEDS"
 S NDCTAX="BKMV MAC PROPH MED NDCS"
 S GLOBAL=$P(GLOB,")")_",""HIVCHK"",BKMDFN,""MAC"",VSTDT,TEST)"
 S TOTPTS=$P(GLOB,")")_",""HIVCHK"",""MACPTCNT"")"
 S BKMDFN=0,@TOTPTS=0
 F  S BKMDFN=$O(@GLOB@("HIVCHK",BKMDFN)) Q:'BKMDFN  D
 .I '$D(@GLOB@("HIVCHK",BKMDFN,"CD4ABS12")) Q
 .S VSTDT=""
 .S FOUND=0
 .; Find earliest CD4 Absolute with results less than 50.
 .F  S VSTDT=$O(@GLOB@("HIVCHK",BKMDFN,"CD4ABS12",VSTDT)) Q:VSTDT=""  D  Q:FOUND
 ..S TEST=""
 ..F  S TEST=$O(@GLOB@("HIVCHK",BKMDFN,"CD4ABS12",VSTDT,TEST)) Q:TEST=""  D  Q:FOUND
 ...S RESULT=$G(@GLOB@("HIVCHK",BKMDFN,"CD4ABS12",VSTDT,TEST))
 ...I RESULT="" Q
 ...I RESULT'<50 Q
 ...S FOUND=1
 .I 'FOUND Q
 .; select meds prescribed since the defined CD4 visit
 .D MEDTAX^BKMIXX(BKMDFN,SITETAX,EDATE,VSTDT,GLOBAL)
 .D NDCTAX^BKMIXX1(BKMDFN,NDCTAX,EDATE,VSTDT,GLOBAL)
 .I $D(@GLOB@("HIVCHK",BKMDFN,"MAC")) S @TOTPTS=@TOTPTS+1
 Q
 ;
MEDLP(ARV) ; Loop through medications found and determine if they are active
 NEW VSTDT,TEST
 S (VSTDT,TEST)=""
 F  S VSTDT=$O(@GLOB@("HIVCHK",BKMDFN,ARV,VSTDT)) Q:'VSTDT  D
 . F  S TEST=$O(@GLOB@("HIVCHK",BKMDFN,ARV,VSTDT,TEST)) Q:'TEST  D
 .. I '$$ACTMED(TEST) K @GLOB@("HIVCHK",BKMDFN,ARV,VSTDT,TEST)
 Q
 ;
ACTMED(VMEDIEN) ;EP - Is this an active medication?
 ;*** only need VMEDIEN - all calls shd be revised ***
 ;
 ; Taken from APCHPMH3 and revised to be a self-contained extrinsic function
 ;
 ; Input:
 ;     VMEDIEN - the V MEDICATION internal entry number
 ;
 ; Output:
 ;     '1' if the rx is currently active
 ;
 NEW VMEDDATA,PSIEN,DCDT,EDATE,EXPDT,RXIEN,STOP,ACT,STAT
 I '$D(^AUPNVMED(VMEDIEN,0)) Q 0
 S VMEDDATA=^AUPNVMED(VMEDIEN,0),PSIEN=$P(VMEDDATA,U,1) I PSIEN="" Q 0
 I '$D(^PSDRUG(PSIEN)) Q 0
 S EDATE=DT ; use only the current date for medications to reduce the risk of a prescribing error
 S DCDT=$P(VMEDDATA,U,8) I DCDT'="",DCDT'>EDATE Q 0 ;date discontinued
 ;
 S EXPDT=""
 ; Get Prescription ien
 S RXIEN=$S($D(^PSRX("APCC",VMEDIEN)):$O(^PSRX("APCC",VMEDIEN,0)),1:0)
 I RXIEN>0,'$D(^PSRX(RXIEN,"STA")) S ACT=0 D  Q ACT
 . ; Is this an expired prescription?
 . S EXPDT=$P($G(^PSRX(RXIEN,2)),U,6)
 . I EXPDT,$$EXPMED(EDATE,EXPDT) Q
 . ; Calculate RX status if V6
 . S STAT=$$RXSTAT(RXIEN,EDATE)
 . I STAT=11 S ACT=1 Q  ; EXPIRED within acceptable timeframe
 . I STAT>10 Q
 . I $P($G(^AUPNVMED(VMEDIEN,11)),U,8)'="" S ACT=1 Q  ; OUTSIDE MEDICATION (AORX mnemonic in the pharmacy package)
 . I STAT=0 S ACT=1 Q  ; ACTIVE
 . I STAT=3 S ACT=1 Q  ; HOLD
 . I STAT=5 S ACT=1 Q  ; SUSPENDED
 ;
 S STAT=$G(^PSRX(RXIEN,"STA")) ;Status is in "STA" node in V 7
 ;
 I STAT=11,'$$EXPMED(RXIEN,EXPDT) Q 1 ;EXPIRED within acceptable timeframe
 I $P($G(^AUPNVMED(VMEDIEN,11)),U,8)'="" Q 1 ; OUTSIDE MEDICATION (AORX mnemonic in the pharmacy package)
 I STAT=0 Q 1 ;ACTIVE
 I STAT=3 Q 1 ;HOLD
 I STAT=5 Q 1 ;SUSPENDED
 Q 0
 ;
RXSTAT(RX,DATE) ; EP - return status of rx
 ;
 ; Taken from APCHPMH3 and revised to be a self-contained extrinsic function
 ;... APCHPMH3 had taken this from the PSOFUNC routine
 ; Note: piece 15 of ^PSRX(RX,0) is not documented in ^DD (probably pre-V 7)
 ;
 ; Input:
 ;     RX   - the PRESCRIPTION internal entry number
 ;     DATE - date against which to compare the prescription expiration date
 ;
 NEW RX0,RX2,J,ST0,ST,ST1
 I $D(^PSRX(RX,"STA")) Q "" ;USING V7
 I RX'>0 Q ""
 S DATE=$G(DATE,DT)
 S RX0=$G(^PSRX(RX,0)),RX2=$G(^PSRX(RX,2))
 S J=RX,ST0=$P(RX0,U,15) I ST0'="" S ST0=+ST0
 I ST0<12 D
 . S ST1=$O(^PS(52.5,"B",J,0)) Q:ST1=""
 . I $D(^PS(52.5,ST1,0)),'$G(^PS(52.5,ST1,"P")) S ST0=5
 I ST0<12,$P(RX2,U,6),$P(RX2,U,6)'>DATE S ST0=11
 Q ST0
 ;
EXPMED(RXIEN,EXPDT) ; Is this an expired prescription?
 ; Chronic medications - greater than 120 days
 ; All other medications - greater than 14 days
 ;
 NEW CHR
 I 'EXPDT Q 0
 S CHR=($$GET1^DIQ(52,RXIEN,9999999.02,"I")="Y")
 I CHR,$$FMDIFF^XLFDT(EXPDT,DT)>120 Q 1
 I 'CHR,$$FMDIFF^XLFDT(EXPDT,DT)>14 Q 1
 Q 0