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

APCM14E3.m

Go to the documentation of this file.
APCM14E3 ; IHS/CMI/LAB - IHS MU ;
 ;;1.0;IHS MU PERFORMANCE REPORTS;**5,6**;MAR 26, 2012;Build 65
 ;;;;;;Build 3
EPRES ;EP - CALCULATE EPRESCRIBING
 ;for each provider or for the facility count all prescriptions that meet criteria and if it is not written it meets numerator
 K ^TMP($J,"PATSRX")
 K APCMRXS
 D TOTRX
 NEW APCMP,N,F
 S (APCMD1,APCMN1)=0
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .I $D(APCM100R(APCMP,APCMTIME)) S F=$P(^APCM14OB(APCMIC,0),U,11) D  G D
 ..D S^APCM14E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she had < 100 prescriptions issued during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
 .I $G(APCMADDQ("ANS",APCMIC,24,APCMP))="No",$G(APCMADDQ("ANS",APCMIC,25,APCMP))="No" S F=$P(^APCM14OB(APCMIC,0),U,11) D
 ..D S^APCM14E1(APCMRPT,APCMIC,"Provider may be eligible for an exclusion on this measure as they not have an onsite pharmacy and do not have a pharmacy within 10 miles accepting electronic prescriptions.",APCMP,APCMRPTT,APCMTIME,F,1)
D .;set denominator value into field
 .S F=$P(^APCM14OB(APCMIC,0),U,8)  ;denom field for this measure
 .S N=$P($G(APCMRXS(APCMP)),U,1)  ;returns # of prescriptions^# not written by nature of order
 .D S^APCM14E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
 .;now set patient list for this provider
 .S P=0 F  S P=$O(^TMP($J,"PATSRX",APCMP,P)) Q:P'=+P  D
 ..;Q:'$P(^TMP($J,"PATSRX",APCMP,P),U,1)
 ..I $P(^TMP($J,"PATSRX",APCMP,P),U,1)=$P(^TMP($J,"PATSRX",APCMP,P),U,2) S APCMVALU="# Prescriptions: "_$P(^TMP($J,"PATSRX",APCMP,P),U,1)_"|||"_" # transmitted electronically: "_+$P(^TMP($J,"PATSRX",APCMP,P),U,2)_"|||1" D  Q
 ...S DFN=P D SETLIST^APCM14E1 Q
 ..S S="",APCMVALU="Not transmitted electronically: "
 ..F  S S=$O(^TMP($J,"PATSRX",APCMP,P,"SCRIPTS",S)) Q:S=""  D
 ...I '$D(^TMP($J,"PATSRX",APCMP,P,"ELEC",S)) D
 ....S APCMVALU=APCMVALU_S_";"
 ..S DFN=P,APCMVALU="# of Prescriptions: "_$P(^TMP($J,"PATSRX",APCMP,P),U,1)_" # transmitted electronically: "_+$P(^TMP($J,"PATSRX",APCMP,P),U,2)_"|||"_APCMVALU,$P(APCMVALU,"|||",3)=0 D SETLIST^APCM14E1
 .;numerator?
 .S F=$P(^APCM14OB(APCMIC,0),U,9)
 .S N=$P($G(APCMRXS(APCMP)),U,2)
 .D S^APCM14E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
 K ^TMP($J,"PATSRX")
 Q
TOTRX ;EP - did patient have a RX in file 52 with an issue date
 ;between BD and ED
 ;SET ARRAY APCMRXS to APCMRXS(prov ien)=denom^numer
 NEW ID,C,Y,X,D,S,N,A,B,R,PAT,G
 S C=0,N=0
 S ID=$$FMADD^XLFDT(APCMBDAT,-1)
 F  S ID=$O(^PSRX("AC",ID)) Q:ID'=+ID!(ID>APCMEDAT)  D
 .S X=0 F  S X=$O(^PSRX("AC",ID,X)) Q:X'=+X  D
 ..S R=$P($G(^PSRX(X,0)),U,4)
 ..Q:'R
 ..;I '$D(APCMPRV(R)) Q  ;not a provider of interest
 ..I '$D(APCMRXS(R)) S APCMRXS(R)=""
 ..Q:$$GET1^DIQ(52,X,9999999.28)="YES"  ;MUST NOT BE A DISCHARGE MED
 ..Q:$P($G(^PSRX(X,"STA")),"^")=13
 ..S D=$P(^PSRX(X,0),U,6)
 ..S S=$P($G(^PSDRUG(D,0)),U,3)
 ..Q:S[5
 ..Q:S[4
 ..Q:S[3
 ..Q:S[2
 ..Q:S[1
 ..S S=$P($G(^PSRX(X,3)),U,7)
 ..Q:$$UP^XLFSTR(S)["ADMINISTERED IN CLINIC"
 ..S PAT=$P(^PSRX(X,0),U,2)
 ..;quit if demo patient
 ..Q:$$DEMO^APCLUTL(PAT,$G(APCMDEMO))
 ..S $P(APCMRXS(R),U,1)=$P(APCMRXS(R),U,1)+1,$P(^TMP($J,"PATSRX",R,PAT),U,1)=$P($G(^TMP($J,"PATSRX",R,PAT)),U,1)+1,^TMP($J,"PATSRX",R,PAT,"SCRIPTS",$P(^PSRX(X,0),U,1))=""
 ..;
 ..;now check to see if it has a nature of order not equal to 1-written
 ..S G=0
 ..I $E($P(^PSRX(X,0),U,1))?1N D
 ...S O=$P($G(^PSRX(X,"OR1")),U,2)  ;order number
 ...Q:O=""
 ...S B=$P($G(^OR(100,O,0)),U,6)
 ...Q:B=""
 ...S A=0,G=0 F  S A=$O(^OR(100,O,8,A)) Q:A'=+A!(G)  D
 ....S B=$P($G(^OR(100,O,8,A,0)),U,12)
 ....Q:B=1
 ....Q:B=""
 ....S G=1
 ...S $P(APCMRXS(R),U,2)=$P(APCMRXS(R),U,2)+G,$P(^TMP($J,"PATSRX",R,PAT),U,2)=$P($G(^TMP($J,"PATSRX",R,PAT)),U,2)+G I G S ^TMP($J,"PATSRX",R,PAT,"ELEC",$P(^PSRX(X,0),U,1))=""  ;S N=N+G
 ..S B=0 I $E($P(^PSRX(X,0),U,1))="X" D
 ...S A=0 F  S A=$O(^PSRX(X,"A",A)) Q:A'=+A!(B)  D
 ....I $P(^PSRX(X,"A",A,0),U,5)["E-Prescribe" S B=1
 ....I $P(^PSRX(X,"A",A,0),U,5)["eRx" S B=1
 ...S $P(APCMRXS(R),U,2)=$P(APCMRXS(R),U,2)+B,$P(^TMP($J,"PATSRX",R,PAT),U,2)=$P($G(^TMP($J,"PATSRX",R,PAT)),U,2)+B I B S ^TMP($J,"PATSRX",R,PAT,"ELEC",$P(^PSRX(X,0),U,1))=""
 Q
DDA ;EP - CALCULATE DRUG INTERACTION CHECK MEASURE
 S F=$P(^APCM14OB(APCMIC,0),U,8)
 ;PER Chris Saddler check whole system for each provider
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.002.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.002.H",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 Q
CDS ;EP - CALCULATE CDA MEASURE
 S F=$P(^APCM14OB(APCMIC,0),U,8)
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.010.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.009.H",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 Q
EKC ;EP - CALCULATE EKC MEASURE
 S F=$P(^APCM14OB(APCMIC,0),U,8)
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.013.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.012.H",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 Q
PS ;EP - CALCULATE PS MEASURE
 S F=$P(^APCM14OB(APCMIC,0),U,8)
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.014.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.013.H",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 Q
CQM ;EP - CALCULATE CQM MEASURE
 NEW APCMV
 S F=$P(^APCM14OB(APCMIC,0),U,8)
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .S APCMEP=$$INSTALLD("BGP*11.0*2")
 .I APCMEP="Yes",APCMATTE("S1.015.EP",APCMP)="Yes" S APCMV="Yes"
 .E  S APCMV="No"
 .D S^APCM14E1(APCMRPT,APCMIC,APCMV,APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .S APCMEP=$$INSTALLD("BGP*11.0*3")
 .I APCMEP="Yes",APCMATTE("S1.014.H",APCMP)="Yes" S APCMV="Yes"
 .E  S APCMV="No"
 .D S^APCM14E1(APCMRPT,APCMIC,APCMV,APCMP,APCMRPTT,APCMTIME,F) Q
 Q
DFC ;EP - CALCULATE DFC MEASURE
 ;always a yes
 S F=$P(^APCM14OB(APCMIC,0),U,8)
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .I $D(APCM100R(APCMP,APCMTIME)) S F=$P(^APCM14OB(APCMIC,0),U,11) D S^APCM14E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she had < 100 prescriptions issued during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
 .S F=$P(^APCM14OB(APCMIC,0),U,8) D S^APCM14E1(APCMRPT,APCMIC,"Yes",APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .S F=$P(^APCM14OB(APCMIC,0),U,8) D S^APCM14E1(APCMRPT,APCMIC,"Yes",APCMP,APCMRPTT,APCMTIME,F) Q
 Q
PL ;EP - CALCULATE EKC MEASURE
 S F=$P(^APCM14OB(APCMIC,0),U,8)
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.018.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.018.H",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 Q
IR ;EP - CALCULATE IMM REG OBJECTIVE
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .I APCMATTE("S1.024.EP",APCMP)="N/A" S F=$P(^APCM14OB(APCMIC,0),U,11) D  Q
 ..D S^APCM14E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she has no registry to send immunizations to.",APCMP,APCMRPTT,APCMTIME,F,1)
 .I $D(APCMIMME(APCMP,APCMTIME)) S F=$P(^APCM14OB(APCMIC,0),U,11) D  Q
 ..D S^APCM14E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she had no visits with an immunization administered during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
 .S F=$P(^APCM14OB(APCMIC,0),U,8) D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.024.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .I APCMATTE("S1.022.H",APCMP)="N/A" S F=$P(^APCM14OB(APCMIC,0),U,11) D
 ..D S^APCM14E1(APCMRPT,APCMIC,"Facility is excluded from this measure as it has no registry to send immunizatons to.",APCMP,APCMRPTT,APCMTIME,F,1)
 .I $D(APCMIMME(APCMP,APCMTIME)) S F=$P(^APCM14OB(APCMIC,0),U,11) D
 ..D S^APCM14E1(APCMRPT,APCMIC,"Facility is excluded from this measure it had no visits with an immunization administered during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
 .S F=$P(^APCM14OB(APCMIC,0),U,8) D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.022.H",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 Q
SS ;EP - SYNDROMIC SURV
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .I APCMATTE("S1.025.EP",APCMP)="N/A" S F=$P(^APCM14OB(APCMIC,0),U,11) D
 ..D S^APCM14E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she has no registry to send syndromic surveillance data to.",APCMP,APCMRPTT,APCMTIME,F,1)
 .S F=$P(^APCM14OB(APCMIC,0),U,8)
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.025.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .I APCMATTE("S1.024.H",APCMP)="N/A" S F=$P(^APCM14OB(APCMIC,0),U,11) D
 ..D S^APCM14E1(APCMRPT,APCMIC,"Hospital/CAH is excluded from this measure as it has no registry to send syndromic surveillance data to.",APCMP,APCMRPTT,APCMTIME,F,1)
 .S F=$P(^APCM14OB(APCMIC,0),U,8)
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.024.H",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 Q
SLR ;EP - CALCULATE CDA MEASURE
 S F=$P(^APCM14OB(APCMIC,0),U,8)
 I APCMRPTT=1 S APCMP=0 F  S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP  D
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.010.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 I APCMRPTT=2 S APCMP=APCMFAC  D
 .I APCMATTE("S1.023.H",APCMP)="N/A" S F=$P(^APCM14OB(APCMIC,0),U,11) D
 ..D S^APCM14E1(APCMRPT,APCMIC,"Hospital/CAH is excluded from this measure as it has no Public Health Agency to send lab results to.",APCMP,APCMRPTT,APCMTIME,F,1)
 .S F=$P(^APCM14OB(APCMIC,0),U,8)
 .D S^APCM14E1(APCMRPT,APCMIC,APCMATTE("S1.023.H",APCMP),APCMP,APCMRPTT,APCMTIME,F) Q
 Q
INSTALLD(APCMSTAL) ;EP - Determine if patch APCMSTAL was installed, where
 ; APCLSTAL is the name of the INSTALL.  E.g "AG*6.0*11".
 ;
 NEW APCMY,DIC,X,Y
 S X=$P(APCMSTAL,"*",1)
 S DIC="^DIC(9.4,",DIC(0)="FM",D="C"
 D IX^DIC
 I Y<1 Q 0
 S DIC=DIC_+Y_",22,",X=$P(APCMSTAL,"*",2)
 D ^DIC
 I Y<1 Q 0
 S DIC=DIC_+Y_",""PAH"",",X=$P(APCMSTAL,"*",3)
 D ^DIC
 S APCMY=Y
 Q $S(APCMY<1:"No",1:"Yes")
OCPARA() ;EP
 NEW VALUE,X,Y,Z,ORK
 S VALUE=""
 S (X,Y,Z)=""
 ;first check ORK SYSTEM ENABLE/DISABLE to see that it is Enabled
 S X=$$GET^XPAR("SYS","ORK SYSTEM ENABLE/DISABLE")
 I X'="E" Q "No^ORK SYSTEM ENABLE/DISABLE NOT ENABLED FOR SYSTEM"  ;SYSTEM IS NOT CONFIGURED SO MEASURE NOT MET
 ;check for "DIV"
 S X=$$GET^XPAR("DIV","ORK SYSTEM ENABLE/DISABLE")
 I X="D" Q "No^ORK SYSTEM ENABLE/DISABLE SET TO DISABLED FOR DIVISION"
 ;now check system for ORK EDITABLE BY USER for the 9 items
 F Z=1:1:9 S Y=$T(PAR9+Z) S O=$P(Y,";;",2) S X=$$GET^XPAR("SYS","ORK EDITABLE BY USER",O,"E") I X'="NO" S VALUE=VALUE_"ORK EDITABLE BY USER NOT SET TO NO FOR SYSTEM FOR "_O_" ;"
 ;now check division for ORK EDITABLE BY USER for the 9 items, it can't say "Y"
 F Z=1:1:9 S Y=$T(PAR9+Z) S O=$P(Y,";;",2) S X=$$GET^XPAR("DIV","ORK EDITABLE BY USER",O,"E") I X="YES" S VALUE=VALUE_"ORK EDITABLE BY USER SET TO YES FOR DIVISION FOR "_O_" ;"
 ;now check ORK PROCESSING FLAG for system for the 9 items
 F Z=1:1:9 S Y=$T(PAR9+Z) S O=$P(Y,";;",2) S X=$$GET^XPAR("SYS","ORK PROCESSING FLAG",O) I X'="E" S VALUE=VALUE_"ORK PROCESSING FLAG NOT ENABLED FOR SYSTEM FOR "_O_" ;"
 ;now loop through the parameter file for ORK processing flag, look for an instance of one of the 9, make sure it is set to NO
PAR1 ;
 S Y=$O(^XTV(8989.51,"B","ORK PROCESSING FLAG",0))
 I 'Y S VALUE=VALUE_"MISSING ORK PROCESSING FLAG PARAMETER" G PAR2
 S X=0 F  S X=$O(^XTV(8989.5,X)) Q:X'=+X  D
 .Q:'$D(^XTV(8989.5,X,0))
 .Q:$P(^XTV(8989.5,X,0),U,2)'=Y  ;not ork PROCESSING FLAG
 .Q:$P(^XTV(8989.5,X,0),U)["DIC(9.4"  ;not an entity we want ;IHS/OIT/CLS 02/08/2014
 .;Q:'$$INST($P(^XTV(8989.5,X,0),U,3))  ;not an instance we want
 .Q:'$$INST($$VAL^XBDIQ1(100.8,$P(^XTV(8989.5,X,0),U,3),.01))  ;IHS/OIT/CLS 02/08/2014 per Lori
 .;I $E($P($G(^XTV(8989.5,X,1)),U,1))'="E" S VALUE=VALUE_"ORK PROCESSING FLAG NOT ENABLED FOR "_$P(^XTV(8989.5,X,0),U,3)_" FOR "_$$VAL^XBDIQ1(8989.5,X,.01)_"; "
 .I $E($P($G(^XTV(8989.5,X,1)),U,1))'="E" S VALUE=VALUE_"ORK PROCESSING FLAG NOT ENABLED FOR "_($$VAL^XBDIQ1(100.8,$P(^XTV(8989.5,X,0),U,3),.01))_" FOR "_$$VAL^XBDIQ1(8989.5,X,.01)_"; "  ;IHS/OIT/CLS 02/08/2014 per Lori
 .Q
PAR2 ;
 I VALUE]"" Q "No^"_VALUE
 Q "Yes"
INST(I) ;
 I $G(I)="" Q 0
 I I="ESTIMATED CREATININE CLEARANCE"  Q 1
 I I="ALLERGY-DRUG INTERACTION" Q 1
 I I="ALLERGY-CONTRAST MEDIA INTERACTION" Q 1
 I I="CRITICAL DRUG INTERACTION" Q 1
 I I="RENAL FUNCTIONS OVER AGE 65" Q 1
 I I="GLUCOPHAGE-CONTRAST MEDIA" Q 1
 I I="GLUCOPHAGE-LAB RESULTS" Q 1
 I I="DANGEROUS MEDS FOR PT > 64" Q 1
 I I="NO ALLERGY ASSESSMENT" Q 1
 I I="ALLERGY UNASSESSIBLE" Q 1
 Q 0
PAR9 ;;
 ;;ESTIMATED CREATININE CLEARANCE
 ;;ALLERGY-DRUG INTERACTION
 ;;ALLERGY-CONTRAST MEDIA INTERACTION
 ;;CRITICAL DRUG INTERACTION
 ;;RENAL FUNCTIONS OVER AGE 65
 ;;GLUCOPHAGE-CONTRAST MEDIA
 ;;GLUCOPHAGE-LAB RESULTS
 ;;DANGEROUS MEDS FOR PT > 64
 ;;NO ALLERGY ASSESSMENT
 ;;ALLERGY UNASSESSIBLE
 ;;