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

APCM24E6.m

Go to the documentation of this file.
  1. APCM24E6 ;IHS/CMI/LAB - IHS MU;
  1. ;;1.0;IHS MU PERFORMANCE REPORTS;**5,6**;MAR 26, 2012;Build 65
  1. ;;;;;;Build 3
  1. ADV ;EP - CALCULATE adv directives
  1. NEW APCMP,APCMZ
  1. S (APCMD1,APCMN1)=0
  1. I APCMRPTT=2 D
  1. .S APCMP=APCMFAC
  1. .I $D(APCMHO65(APCMP,APCMTIME)) S F=$P(^APCM24OB(APCMIC,0),U,11) D Q
  1. ..D S^APCM24E1(APCMRPT,APCMIC,"Hospital is excluded from this measure as it did not admit anyone >=65 during the EHR Reporting Period.",APCMP,APCMRPTT,APCMTIME,F,1) Q
  1. .S APCMZ=$$HASADM65(DFN,APCMP,.APCMVSTS)
  1. .Q:APCMZ="" ;NO ADMISSION
  1. .D ADV1
  1. .Q
  1. Q
  1. HASADM65(P,R,VSTS) ;
  1. NEW X,Y,Z,V,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
  1. .I $P(^AUPNVSIT(V,0),U,7)'="H" Q ;not correct service category
  1. .Q:$P(^AUPNVSIT(V,0),U,6)'=APCMP ;not this facility
  1. .Q:$$AGE^AUPNPAT(P,$$VD^APCLV(V))<65 ;not 65 on date of admission
  1. .S G=$$VD^APCLV(V)
  1. Q G
  1. ADV1 ;
  1. ;set denominator value into field
  1. S F=$P(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
  1. D S^APCM24E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
  1. S APCMVALU="Admission: "_$$DATE^APCM1UTL(APCMZ)_" Age: "_$$AGE^AUPNPAT(DFN,APCMZ)
  1. ;numerator?
  1. S APCMEP=$$HASADV(DFN,APCMEDAT)
  1. S APCMVALU=APCMVALU_"|||"_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
  1. S F=$P(^APCM24OB(APCMIC,0),U,9)
  1. D S^APCM24E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
  1. D SETLIST^APCM24E1
  1. Q
  1. HASADV(P,ED) ;does patient have an ADVANCE DIRECTIVE before end of report period
  1. ;
  1. NEW A,B,C,D,E,X
  1. ;check advance directive file
  1. S E=""
  1. S X=0 F S X=$O(^AUPNADVD(P,11,X)) Q:X'=+X!(E) D
  1. .Q:'$D(^AUPNADVD(P,11,X,0)) ;no zero node?
  1. .S D=$P(^AUPNADVD(P,11,X,0),U,1)
  1. .I D>ED Q ;after report period
  1. .S B=$P(^AUPNADVD(P,11,X,0),U,2)
  1. .Q:B=""
  1. .S E=1_U_"Advance Directives: "_$S(B="Y":"YES",1:"NO")_" entered on "_$$DATE^APCM1UTL(D) Q
  1. I E]"" Q E
  1. ;now check for TIU Note title before ED of A
  1. S X=0 F S X=$O(^AUPNVNOT("AC",P,X)) Q:X'=+X!(E) D
  1. .S B=$$VAL^XBDIQ1(9000010.28,X,.01)
  1. .Q:$$UP^XLFSTR(B)'="ADVANCE DIRECTIVE"
  1. .S D=$$VD^APCLV($P(^AUPNVNOT(X,0),U,3))
  1. .Q:D>ED
  1. .S E=1_U_"Advance Directives: TIU document entered on "_$$DATE^APCM1UTL(D) Q
  1. Q E
  1. MR ;EP - med reconciliation
  1. ;for each provider or for the facility find out if this
  1. ;patient had a er visit or an admission of transferred
  1. ;if so, then check to see if they have m-mr anytime before end of report period
  1. NEW APCMP
  1. S (APCMD1,APCMN1)=0
  1. I APCMRPTT=2 S APCMP=APCMFAC D
  1. .Q:'$D(APCMHVTP(APCMP)) ;no ADMISSIONS/ER TO THIS FACILITY SO SKIP THIS OBJ
  1. .S APCMEP=$$HASMMR(DFN,APCMBDAT,APCMEDAT,APCMP,.APCMVSTS,APCMMETH) ;return # of visits^# w/M-MR
  1. .;set denominator value into field
  1. .S F=$P(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
  1. .D S^APCM24E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
  1. .;numerator?
  1. .S APCMVALU="# of visits: "_$P(APCMEP,U,1)_" - # w/ M-MR: "_+$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,3)_"|||"_$S($P(APCMEP,U,1)=$P(APCMEP,U,2):1,1:0)
  1. .S F=$P(^APCM24OB(APCMIC,0),U,9)
  1. .D S^APCM24E1(APCMRPT,APCMIC,$P(APCMEP,U,2),APCMP,APCMRPTT,APCMTIME,F)
  1. .Q:$P(APCMEP,U,1)=0
  1. .D SETLIST^APCM24E1
  1. Q
  1. HOSER(Z,R) ;EP
  1. I $P(^AUPNVSIT(Z,0),U,6)'=R Q 0 ;not correct facility
  1. I $P(^AUPNVSIT(Z,0),U,7)="H" Q 1
  1. NEW C
  1. I "A"'[$P(^AUPNVSIT(Z,0),U,7) Q 0
  1. S C=$$CLINIC^APCLV(Z,"C")
  1. I C=30 Q 1
  1. ;I C=80 Q 1
  1. Q 0
  1. DSCHDATE(V) ;EP
  1. I 'V Q ""
  1. I '$D(^AUPNVSIT(V)) Q ""
  1. NEW Y,Z,D
  1. S D=""
  1. I $P(^AUPNVSIT(V,0),U,7)="H" D Q D
  1. .S Z=$O(^AUPNVINP("AD",V,0))
  1. .I 'Z S D=$$VD^APCLV(V) Q
  1. .S Y=$P($P(^AUPNVINP(Z,0),U),".")
  1. .S D=Y
  1. S Z=$O(^AUPNVER("AD",V,0))
  1. I 'Z Q $$VD^APCLV(V)
  1. I '$D(^AUPNVER(Z,0)) Q $$VD^APCLV(V)
  1. S Y=$P($P(^AUPNVER(Z,0),U,13),".")
  1. I Y="" Q $$VD^APCLV(V)
  1. Q $P(Y,".")
  1. HASMMR(P,BD,ED,R,VSTS,APCMMETH) ;does patient have a M-MR on each visit?
  1. ;
  1. NEW A,B,C,D,E,X,Y,V,PWH,T,W,Z,Q,EDUC,G,BDD,EDD
  1. ;LOOP THROUGH ALL VISITS AND COUNT VISIT AND M-MR'S
  1. S PWH="0^0"
  1. S X=0 F S X=$O(VSTS(X)) Q:X'=+X D
  1. .S G=0
  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. .Q:$P(^AUPNVSIT(V,0),U,6)'=R
  1. .I APCMMETH="E" D Q:'G
  1. ..I '$$HOSER(V,R) Q ;not correct service category/ER VISIT
  1. ..S G=1
  1. .I APCMMETH="O" Q:"OH"'[$P(^AUPNVSIT(V,0),U,7)
  1. .I $P(^AUPNVSIT(V,0),U,7)="H"!($P(^AUPNVSIT(V,0),U,7)="O") Q:'$$TRANS(V)
  1. .I $$CLINIC^APCLV(V,"C")=30 Q:'$$ERTRANS(V)
  1. .S $P(PWH,U,1)=$P(PWH,U,1)+1
  1. .;V UPDATED REVIEWED SNOMED DURING REPORT PERIOD
  1. .S Z="",B=""
  1. .S W=0 F S W=$O(^AUPNVRUP("AC",P,W)) Q:W'=+W!(Z) D
  1. ..S Y=0 F S Y=$O(^AUPNVRUP(W,26,Y)) Q:Y'=+Y!(Z) D
  1. ...I $P($G(^AUPNVRUP(W,26,Y,0)),U,1)'=428191000124101 Q
  1. ...;getevent date/time (1201)
  1. ...S E=""
  1. ...S D=$P($$GET1^DIQ(9000010.54,W,1201,"I"),".")
  1. ...I D<BD Q
  1. ...I D>ED Q
  1. SN ...S Z=1
  1. ...S B=1 S $P(PWH,U,2)=$P(PWH,U,2)+1
  1. .S $P(PWH,U,3)=$P(PWH,U,3)_$$DATE^APCM1UTL($$VD^APCLV(V))_":"_$S(B:"M-MR",1:"NO M-MR")_";"
  1. .Q
  1. Q PWH
  1. TRANS(%) ;
  1. NEW A
  1. S A=$$ADMTYPE^APCLV(%,"C")
  1. I A="" S A=$O(^DGPM("AVISIT",%,0)) I A S A=$$GET1^DIQ(405,A,.04,"I") I A S A=$$GET1^DIQ(405.1,A,9999999.1)
  1. I A=2 Q 1
  1. I A=3 Q 1
  1. I A=4 Q 1
  1. Q 0
  1. ;
  1. ERTRANS(%) ;
  1. NEW E
  1. S E=$O(^AMERVSIT("AD",%,0))
  1. I 'E Q 0 ;no visit in ER Visit
  1. I '$P($G(^AMERVSIT(E,17)),U,1) Q 0
  1. Q 1
  1. TRANSOUT(%) ;
  1. NEW A
  1. S A=$$DSCHTYPE^APCLV(%,"C")
  1. I A=2 Q 1
  1. Q 0
  1. ;
  1. ERTRANSO(%) ;
  1. NEW E,J
  1. S E=$O(^AMERVSIT("AD",%,0))
  1. I 'E Q 0 ;no visit in ER Visit
  1. S J=$$VAL^XBDIQ1(9009080,E,6.1)
  1. I J="REFERRED TO ANOTHER SERVICE" Q 1
  1. I J="TRANSFER TO ANOTHER FACILITY" Q 1
  1. Q 0
  1. PVCL(N) ;
  1. I '$G(N) Q ""
  1. I '$D(^VA(200,N,0)) Q ""
  1. NEW C,T
  1. S C=$$GET1^DIQ(200,N,53.5,"I")
  1. I C="" Q ""
  1. S C=$P($G(^DIC(7,C,9999999)),U,1)
  1. I C="" Q ""
  1. S T=$O(^APCMMUCN("B","INTERIM STAGE 2 2014",0))
  1. I 'T Q ""
  1. I '$D(^APCMMUCN(T,19,"B",C)) Q ""
  1. Q 1
  1. EN ;EP - CALCULATE ELECTRONIC NOTES
  1. NEW APCMP
  1. S (APCMD1,APCMN1)=0
  1. I APCMRPTT=1 D Q
  1. .S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
  1. ..Q:'$$PVCL(APCMP) ;PROVIDER ISN'T THE RIGHT CLASS CODE
  1. ..Q:'$D(APCMHVTP(APCMP)) ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
  1. ..D EN1
  1. I APCMRPTT=2 D
  1. .S APCMP=APCMFAC
  1. .Q:'$D(APCMHVTP(APCMP))
  1. .D EN1
  1. .Q
  1. Q
  1. EN1 ;set denominator value into field
  1. S F=$P(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
  1. D S^APCM24E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
  1. S APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
  1. ;numerator?
  1. S APCMEP=$$HASEN(DFN,APCMBDAT,APCMEDAT,APCMP)
  1. S APCMVALU=APCMVALU_"|||"_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
  1. S F=$P(^APCM24OB(APCMIC,0),U,9)
  1. D S^APCM24E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
  1. D SETLIST^APCM24E1
  1. Q
  1. HASEN(P,BD,ED,R) ;does patient have a AN ELECTRONIC NOTE?
  1. ;
  1. NEW A,B,C,D,E,T,N,X,Y,G,X
  1. S G=""
  1. ;$o through TIU document file AA xref for this patient
  1. ;find first one with ep as author/signer
  1. ;or ep is co signer and author/signor is a student
  1. ;skip notes with report text ="VistA Imaging - Scanned Document
  1. S T=0 F S T=$O(^TIU(8925,"AA",P,T)) Q:T'=+T!(G) D
  1. .S D=0 F S D=$O(^TIU(8925,"AA",P,T,D)) Q:D'=+D!(G) D
  1. ..S X=0 F S X=$O(^TIU(8925,"AA",P,T,D,X)) Q:X'=+X!(G) D
  1. ...;check report text
  1. ...Q:$$SCAN(X)
  1. ...;ADDED LOGIC PER DONNA AND JOANNE 9/3/2014 TO MAKE SURE NOTE IS WITHIN REPORT PERIOD
  1. ...S Z=$P($$GET1^DIQ(8925,X,1201,"I"),".")
  1. ...Q:Z<BD
  1. ...Q:Z>ED
  1. ...Q:'$$PRVD(X) ;not on of this providers
  1. ...S G=1_U_"Note: "_$$GET1^DIQ(8925,X,1201)
  1. Q G
  1. SCAN(%) ;
  1. NEW A,B,C
  1. S A=0,B="" F S A=$O(^TIU(8925,%,"TEXT",A)) Q:A'=+A S B=B_^TIU(8925,%,"TEXT",A,0)
  1. I $$UP^XLFSTR(B)["VISTA IMAGING - SCANNED DOCUMENT" Q 1
  1. Q 0
  1. PRVD(%) ;
  1. NEW A,S,C,D
  1. S A=$$GET1^DIQ(8925,%,1202,"I") ;AUTHOR
  1. S S=$$GET1^DIQ(8925,%,1502,"I") ;SIGNED BY
  1. ;I A=R,S=R Q 1
  1. I A=S,$$PVCL(A) Q 1
  1. S C=$$GET1^DIQ(8925,%,1508,"I") ;CO SIGNER
  1. I '$$PVCL(C) Q 0
  1. ;I C'=R Q 0
  1. I '$$ISA^USRLM(A,"STUDENT","",$P($$GET1^DIQ(8925,%,1201,"I"),".",1)) Q 0
  1. I '$$ISA^USRLM(S,"STUDENT","",$P($$GET1^DIQ(8925,%,1201,"I"),".",1)) Q 0
  1. Q 1
  1. ;
  1. IMGR ;EP - IMAGING RESULTS
  1. ;for each provider or for the facility count all rad EXAM that meet criteria
  1. K ^TMP($J,"PATSRAD")
  1. K APCMRADS
  1. D IMGR1
  1. K ^TMP($J,"ORDERSPROCESSED")
  1. NEW APCMP,N,F
  1. S (APCMD1,APCMN1)=0
  1. I APCMRPTT=1 S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
  1. .I $P($G(APCMRADS(APCMP)),U,1)<100 S F=$P(^APCM24OB(APCMIC,0),U,11) D
  1. ..D S^APCM24E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she had < 100 Radiology EXAMS during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
  1. DR .;set denominator value into field
  1. .S F=$P(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
  1. .S N=$P($G(APCMRADS(APCMP)),U,1) ;returns # of prescriptions^# not written by nature of order
  1. .D S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
  1. .;now set patient list for this provider
  1. .S P=0 F S P=$O(^TMP($J,"PATSRAD",APCMP,P)) Q:P'=+P D
  1. ..S D=$P(^TMP($J,"PATSRAD",APCMP,P),U,1),N=$P(^TMP($J,"PATSRAD",APCMP,P),U,2) S APCMVALU="# Orders: "_D_"|||"_"# IMAGE: "_N_" # NO IMAGE: "_(D-N)
  1. ..S DFN=P D SETLIST^APCM24E1
  1. .;numerator?
  1. .S F=$P(^APCM24OB(APCMIC,0),U,9)
  1. .S N=$P($G(APCMRADS(APCMP)),U,2)
  1. .D S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
  1. I APCMRPTT=2 D
  1. .S APCMP=APCMFAC
  1. .S F=$P(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
  1. .S N=$P($G(APCMRADS(APCMFAC)),U,1) ;returns # of prescriptions^# not written by nature of order
  1. .D S^APCM24E1(APCMRPT,APCMIC,N,APCMFAC,APCMRPTT,APCMTIME,F)
  1. .;now set patient list for this FACILITY
  1. .S P=0 F S P=$O(^TMP($J,"PATSRAD",APCMFAC,P)) Q:P'=+P D
  1. ..S D=$P(^TMP($J,"PATSRAD",APCMFAC,P),U,1),N=$P(^TMP($J,"PATSRAD",APCMFAC,P),U,2) S APCMVALU="# Orders: "_D_"|||"_"# IMAGE: "_N_" # NO IMAGE: "_(D-N)
  1. ..S DFN=P D SETLIST^APCM24E1
  1. .;numerator?
  1. .S F=$P(^APCM24OB(APCMIC,0),U,9)
  1. .S N=$P($G(APCMRADS(APCMFAC)),U,2)
  1. .D S^APCM24E1(APCMRPT,APCMIC,N,APCMFAC,APCMRPTT,APCMTIME,F)
  1. K ^TMP($J,"PATSRAD"),^TMP($J,"ORDERSPROCESSED"),APCMRADS
  1. Q
  1. IMGR1 ;EP -
  1. ;between BD and ED
  1. ;SET ARRAY APCMRADS to APCMRADS(prov ien)=denom^numer
  1. NEW ID,C,Y,X,D,S,N,A,B,R,PAT,G,IEN,ORPFILE,ORPTST,PATLOC,ORDEB,PATSTA,CN
  1. S ID=$$FMADD^XLFDT(APCMBDAT,-1),ID=ID_".9999"
  1. F S ID=$O(^RADPT("AR",ID)) Q:ID'=+ID!($P(ID,".")>APCMEDAT) D
  1. .S PAT=0 F S PAT=$O(^RADPT("AR",ID,PAT)) Q:PAT'=+PAT D
  1. ..Q:$$DEMO^APCLUTL(PAT,APCMDEMO) ;Quit if demo patient
  1. ..S IEN=0 F S IEN=$O(^RADPT("AR",ID,PAT,IEN)) Q:IEN'=+IEN D
  1. ...S EIEN=0 F S EIEN=$O(^RADPT(PAT,"DT",IEN,"P",EIEN)) Q:EIEN'=+EIEN D
  1. ....;CHECK STATUS, MUST BE EXAMINED OR COMPLETE
  1. ....S S=$$GET1^DIQ(70.03,EIEN_","_IEN_","_PAT,3)
  1. ....I S'="EXAMINED",S'="COMPLETE" Q
  1. ....S G=0
  1. ....I APCMRPTT=1 D
  1. .....S ORPVID=$$GET1^DIQ(70.03,EIEN_","_IEN_","_PAT,14,"I") Q:'$D(APCMPRV(ORPVID)) ;quit if ordering provider doesn't match user selected provider
  1. .....S PATSTA=$$GET1^DIQ(70.03,EIEN_","_IEN_","_PAT,4,"I")
  1. .....Q:PATSTA'="O"
  1. .....S C=""
  1. .....S PATLOC=$$GET1^DIQ(70.03,EIEN_","_IEN_","_PAT,8,"I")
  1. .....I PATLOC,$D(^SC(PATLOC,0)) S C=$P(^SC(PATLOC,0),U,7) I C Q:$P($G(^DIC(40.7,C,0)),U,2)=30 ;IF ER IN HOSP LOC Q
  1. .....S G=1
  1. ....I APCMRPTT=2 D
  1. .....;is provider authorized?
  1. .....S ORPVID=$$GET1^DIQ(70.03,EIEN_","_IEN_","_PAT,14,"I")
  1. .....;Q:'$$ORES^APCM24E9(ORPVID,ID)
  1. .....S PATSTA=$$GET1^DIQ(70.03,EIEN_","_IEN_","_PAT,4,"I")
  1. .....I PATSTA="I" S G=1 Q
  1. .....Q:APCMMETH="O"
  1. .....Q:PATSTA'="O"
  1. .....S C=""
  1. .....S PATLOC=$$GET1^DIQ(70.03,EIEN_","_IEN_","_PAT,8,"I")
  1. .....I PATLOC,$D(^SC(PATLOC,0)) S C=$P(^SC(PATLOC,0),U,7) I C Q:$P($G(^DIC(40.7,C,0)),U,2)'=30 ;IF ER IN HOSP LOC Q
  1. .....S G=1
  1. ....Q:'G
  1. ....;I DUZ=2793 W !,"PAT: ",$P(^DPT(PAT,0),U,1),"DATE: ",$$FMTE^XLFDT(ID)," ORDER: ",ORIEN," NATURE: ",ORORD
  1. ....I APCMRPTT=1 S $P(APCMRADS(ORPVID),U,1)=$P($G(APCMRADS(ORPVID)),U,1)+1,$P(^TMP($J,"PATSRAD",ORPVID,PAT),U,1)=$P($G(^TMP($J,"PATSRAD",ORPVID,PAT)),U,1)+1
  1. ....I APCMRPTT=2 S $P(APCMRADS(APCMFAC),U,1)=$P($G(APCMRADS(APCMFAC)),U,1)+1,$P(^TMP($J,"PATSRAD",APCMFAC,PAT),U,1)=$P($G(^TMP($J,"PATSRAD",APCMFAC,PAT)),U,1)+1
  1. ....;now check to see if it has REPORT TEXT
  1. ....S CN=$$GET1^DIQ(70.03,EIEN_","_IEN_","_PAT,17,"I")
  1. ....I 'CN Q ;no entry in report text file
  1. ....I '$O(^RARPT(CN,2005,0)) Q ;no image
  1. ....I APCMRPTT=1 S $P(APCMRADS(ORPVID),U,2)=$P(APCMRADS(ORPVID),U,2)+1,$P(^TMP($J,"PATSRAD",ORPVID,PAT),U,2)=$P($G(^TMP($J,"PATSRAD",ORPVID,PAT)),U,2)+1
  1. ....I APCMRPTT=2 S $P(APCMRADS(APCMFAC),U,2)=$P($G(APCMRADS(APCMFAC)),U,2)+1,$P(^TMP($J,"PATSRAD",APCMFAC,PAT),U,2)=$P($G(^TMP($J,"PATSRAD",APCMFAC,PAT)),U,2)+1
  1. Q
  1. FH ;EP - FAMILY HX
  1. ;for each provider or for the facility find out if this
  1. ;patient had a visit of A, O, R, S to this provider or facility
  1. ;if so, then check to see if they have FAMILY HX documented anytime before end of report period
  1. NEW APCMP
  1. S (APCMD1,APCMN1)=0
  1. I APCMRPTT=1 D Q
  1. .S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
  1. ..Q:'$D(APCMHVTP(APCMP)) ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
  1. ..D FH1
  1. I APCMRPTT=2 D
  1. .S APCMP=APCMFAC
  1. .Q:'$D(APCMHVTP(APCMP))
  1. .D FH1
  1. .Q
  1. Q
  1. FH1 ;set denominator value into field
  1. S F=$P(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
  1. D S^APCM24E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
  1. S APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
  1. ;numerator?
  1. S APCMEP=$$HASFH(DFN,$$DOB^AUPNPAT(DFN),APCMEDAT)
  1. S APCMVALU=APCMVALU_"|||"_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
  1. S F=$P(^APCM24OB(APCMIC,0),U,9)
  1. D S^APCM24E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
  1. D SETLIST^APCM24E1
  1. Q
  1. HASFH(P,BD,ED) ;does patient have a SMOKING STATUS
  1. ;
  1. NEW A,B,C,D,E,HF
  1. S C=0
  1. S HF=""
  1. ;CHECK AUPNFH
  1. S A=0 F S A=$O(^AUPNFH("AC",P,A)) Q:A'=+A!(HF) D
  1. .Q:'$D(^AUPNFH(A,0))
  1. .Q:$$GET1^DIQ(9000014,A,.03)>ED ;documentd after time period
  1. .S B=$$GET1^DIQ(9000014,A,.03)
  1. .I B'["NATURAL",B'["UNKNOWN" Q
  1. .S HF=1_U_B
  1. I HF Q HF
  1. S A=0 F S A=$O(^AUPNFHR("AA",P,A)) Q:A'=+A!(HF) D
  1. .S B=$P($G(^AUTTRLSH(A,0)),U,1)
  1. .I B'["NATURAL",B'["UNKNOWN" Q
  1. .S HF=1_U_B
  1. Q HF