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

APCM11CI.m

Go to the documentation of this file.
  1. APCM11CI ;IHS/CMI/LAB - MU REPORT;
  1. ;;1.0;IHS MU PERFORMANCE REPORTS;**1**;MAR 26, 2012
  1. ;
  1. CALCIND ;EP - CALCULATE ALL MEASURES
  1. ;for this patient get all of their visits in the EHR reporting period and save in APCMVSTS for use in all measures
  1. K APCMVSTS,APCMHVTP
  1. D ALLV^APCLAPIU(DFN,APCMBDAT,APCMEDAT,"APCMVSTS")
  1. I APCMRPTT=1 S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
  1. .S APCMHV=$$HADV(DFN,APCMP,APCMBDAT,APCMEDAT,.APCMVSTS)
  1. .I APCMHV S APCMHVTP(APCMP)=APCMHV
  1. ;all measures except attestation and non-patient
  1. I APCMRPTT=2 D
  1. .S APCMHV=$$HADVH(DFN,APCMFAC,APCMBDAT,APCMEDAT,.APCMVSTS) I APCMHV S APCMHVTP(APCMFAC)=APCMHV
  1. .S APCMVDOD=$$VDOD(DFN,APCMFAC,APCMBDAT,APCMEDAT,.APCMVSTS) ;did patient have an H visit with Death as discharge type
  1. S APCMIC=0 F S APCMIC=$O(APCMIND(APCMIC)) Q:APCMIC'=+APCMIC D
  1. .Q:$P(^APCMMUM(APCMIC,0),U,6)="A"
  1. .Q:$P(^APCMMUM(APCMIC,0),U,12)=0
  1. .K APCMSTOP,APCMVAL,APCMVALU,A,B,C,D,E,F,G,H,I,J,K,M,N,O,P,Q,R,S,T,V,W,X,Y,Z
  1. .S APCMVALU=""
  1. .I $D(^APCMMUM(APCMIC,1)) X ^APCMMUM(APCMIC,1)
  1. Q
  1. CALCINDA ;EP - CALCULATE ATTESTATION MEASURES
  1. S APCMIC=0 F S APCMIC=$O(APCMIND(APCMIC)) Q:APCMIC'=+APCMIC D
  1. .;Q:$P(^APCMMUM(APCMIC,0),U,6)="R"
  1. .Q:$P(^APCMMUM(APCMIC,0),U,12)=1
  1. .K APCMSTOP,APCMVAL,APCMVALU,A,B,C,D,E,F,G,H,I,J,K,M,N,O,P,Q,R,S,T,V,W,X,Y,Z,APCMVALU
  1. .K APCMN1,APCMD1
  1. .S APCMVALU=""
  1. .I $D(^APCMMUM(APCMIC,1)) X ^APCMMUM(APCMIC,1)
  1. Q
  1. S1(BQITYP,BQIVAL) ; Return data by patient for iCare into global reference BQIGREF
  1. ;Input Variables
  1. ; BQITYP - Type of value
  1. ; D = Denominator
  1. ; N = Numerator
  1. ; BQIVAL - Value of the type; 0 or 1
  1. ;Assumed variables
  1. ; APCMVALUE - the measure value
  1. ; BQIGREF - global reference where data will be stored temporarily
  1. ; APCMIC - Indicator IEN
  1. ; APCMI - Individual Indicator IEN
  1. ; DFN - Patient IEN
  1. ;
  1. ; If no value of BQIGREF, then it's the regular GPRA report calling the code
  1. ; and nothing needs to be set for iCare.
  1. Q:$G(BQIGREF)=""
  1. ;
  1. ; If no denominator or numerator value, then it doesn't need to be set for iCare
  1. I '$G(BQIVAL) Q
  1. ;
  1. NEW BQITIT,BQILTIT,BQILTIT1,BQILTIT2,BQILTIT3,BQILDTI1,BQILDTI2
  1. NEW BQIDTIT,BQIFTIT,BQITWEN,BQICURR,BQIIDTA,BQIDTA,BQILDTI3
  1. S BQIIDTA=$G(^APCMMUMC(APCMI,0))
  1. S BQIDTA=$G(^APCMMUMC(APCMI,14))
  1. ;
  1. ; Get the Individual Indicator TITLE (1404)
  1. S BQITIT=$P(BQIDTA,U,4)
  1. ;
  1. ; Get the Individual Indicator LINE TITLE 1 (.15)
  1. S BQILTIT1=$P(BQIIDTA,U,15)
  1. I BQILTIT1="" Q
  1. ; Get the Individual Indicator LINE TITLE 2 and 3 (.16,.19)
  1. S BQILTIT2=$P(BQIIDTA,U,16)
  1. S BQILTIT3=$P(BQIIDTA,U,19)
  1. S BQILTIT=BQILTIT1_" "_BQILTIT2_" "_BQILTIT3
  1. ;
  1. ; Get the Individual Indicator LOCAL DENOM TITLE 1, 2, and 3 (.17,.18,.21)
  1. S BQILDTI1=$P(BQIIDTA,U,17)
  1. S BQILDTI2=$P(BQIIDTA,U,18)
  1. S BQILDTI3=$P(BQIIDTA,U,21)
  1. S BQIDTIT=BQILDTI1_" "_BQILDTI2_" "_BQILDTI3
  1. ;
  1. ; Full title is all title fields
  1. S BQIFTIT=BQITIT_" "_BQILTIT_" "_BQIDTIT
  1. S $P(@BQIGREF@(DFN,APCMIC,APCMI),"^",1)=BQIFTIT
  1. ;
  1. ; Get the GOAL 2011 value and the GOAL 06 value
  1. S BQITWEN=$P(BQIDTA,U,3)
  1. S BQICURR=$P(BQIDTA,U,8)
  1. ;
  1. I BQITYP="N" S $P(@BQIGREF@(DFN,APCMIC,APCMI),"^",2)=$G(BQIVAL)
  1. ;
  1. I BQITYP="D" S $P(@BQIGREF@(DFN,APCMIC,APCMI),"^",3)=$G(BQIVAL)
  1. ;
  1. ; Set the Indicator TITLE (.03)
  1. S $P(@BQIGREF@(DFN,APCMIC),U,1)=$P(^APCMMUM(APCMIC,0),U,3)
  1. S $P(@BQIGREF@(DFN,APCMIC),U,2)=$G(APCMVALU)
  1. I BQITWEN'="" S $P(@BQIGREF@(DFN,APCMIC),U,3)=BQITWEN
  1. I BQICURR'="" S $P(@BQIGREF@(DFN,APCMIC),U,4)=BQICURR
  1. Q
  1. HADV(P,R,BD,ED,VSTS) ;EP - had visit of A, O, R, S with provider R in time frame BD-ED
  1. ;PATCH 1 excludes ER and case management clinics
  1. ;patch 1 provider must be primary only
  1. ; so, in summary, the patient must have at least 1 A,O,R,M, non-ER, non-case man visit
  1. ; where this provider is the primary provider
  1. I '$G(P) Q ""
  1. I '$G(R) Q ""
  1. I '$G(BD) Q ""
  1. I '$G(ED) Q ""
  1. I '$D(^AUPNPAT(P,0)) Q ""
  1. I '$D(^VA(200,R,0)) Q ""
  1. NEW V,X,Y,G
  1. S G=""
  1. S X=0 F S X=$O(VSTS(X)) Q:X'=+X!(G) D
  1. .S V=$P(VSTS(X),U,5)
  1. .I '$D(^AUPNVSIT(V,0)) Q
  1. .I $P(^AUPNVSIT(V,0),U,11) Q ;deleted
  1. .I "AOSM"'[$P(^AUPNVSIT(V,0),U,7) Q ;not correct service category
  1. .S C=$$CLINIC^APCLV(V,"C")
  1. .I C=30 Q ;no ER per Carmen patch 1
  1. .I C=77 Q ;no case management clinic 77 per Chris
  1. .I C=76 Q ;no lab
  1. .I C=63 Q ;no radiology
  1. .I C=39 Q ;no pharmacy
  1. .S Y=$$PRIMPROV^APCLV(V,"I")
  1. .I 'Y Q
  1. .I Y'=R Q ;not this provider
  1. .;S Y=0 F S Y=$O(^AUPNVPRV("AD",V,Y)) Q:Y'=+Y!(G) D
  1. .;.I $P($G(^AUPNVPRV(Y,0)),U)'=R Q
  1. .S G=$$VD^APCLV(V)
  1. Q G ;quit on the date of the visit
  1. ;
  1. HADVH(P,R,BD,ED,VSTS) ;EP - had visit H or ER A,O,S,M
  1. I '$G(P) Q ""
  1. I '$G(R) Q ""
  1. I '$G(BD) Q ""
  1. I '$G(ED) Q ""
  1. I '$D(^AUPNPAT(P,0)) Q ""
  1. I '$D(^DIC(4,R,0)) Q ""
  1. NEW V,X,Y,G,C
  1. S G=""
  1. S X=0 F S X=$O(VSTS(X)) Q:X'=+X!(G) D
  1. .S V=$P(VSTS(X),U,5)
  1. .I '$D(^AUPNVSIT(V,0)) Q
  1. .I $P(^AUPNVSIT(V,0),U,11) Q ;deleted
  1. .I $P(^AUPNVSIT(V,0),U,6)'=R Q ;not correct facility
  1. .I $P(^AUPNVSIT(V,0),U,7)="H" S G=$$VD^APCLV(V) Q
  1. .I $P(^AUPNVSIT(V,0),U,7)'="A" Q ;not correct service category
  1. .S C=$$CLINIC^APCLV(V,"C")
  1. .;I C'=80,C'=30 Q
  1. .I C'=30 Q ;per call on Feb. 18 (Hays)
  1. .S G=$$VD^APCLV(V)
  1. Q G ;quit on the date of the visit
  1. VDOD(P,R,BD,ED,VSTS) ;EP - had visit H or ER A,O,S,M
  1. I '$G(P) Q ""
  1. I '$G(R) Q ""
  1. I '$G(BD) Q ""
  1. I '$G(ED) Q ""
  1. I '$D(^AUPNPAT(P,0)) Q ""
  1. I '$D(^DIC(4,R,0)) Q ""
  1. NEW V,X,Y,G,C,H,D
  1. S G=""
  1. S X=0 F S X=$O(VSTS(X)) Q:X'=+X!(G) D
  1. .S V=$P(VSTS(X),U,5)
  1. .I '$D(^AUPNVSIT(V,0)) Q
  1. .I $P(^AUPNVSIT(V,0),U,11) Q ;deleted
  1. .I $P(^AUPNVSIT(V,0),U,6)'=R Q ;not correct facility
  1. .I $P(^AUPNVSIT(V,0),U,7)'="H" Q
  1. .S H=$O(^AUPNVINP("AD",V,0))
  1. .Q:'H
  1. .;get discharge type
  1. .S D=$$VAL^XBDIQ1(9000010.02,H,.06)
  1. .I D["DEATH" S G=V
  1. .;I $$VAL^XBDIQ1(9000010.02,H,6102)="EXPIRED"
  1. Q G ;quit on the date of the visit