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

BGP8D76.m

Go to the documentation of this file.
BGP8D76 ;IHS/CMI/LAB - MEASURE LOGIC; 
 ;;18.1;IHS CLINICAL REPORTING;;MAY 25, 2018;Build 66
 ;
 ;
TOBCESSD ;EP = tobacco cessaton, gpra dev v18
 I 'BGPACTUP S BGPSTOP=1 Q  ;must be at least user pop
 S (BGPVALUD,BGPVALUE)=""
 S (BGPD1,BGPD2,BGPN1,BGPN2,BGPN3)=0
 K BGPTOBS,BGPTOBL,BGPTOBE,BGPTOBT
 S (BGPTOBSL,BGPTOBLL,BGPTOBEL,BGPTOBTL)=""  ;for last of each
 S (BGPCTU,BGPSMK,BGPSMKL,BGPSMKE,BGPDNV,BGPNMV,BGPGOT,BGPGOTS,BGPGOTL,BGPL,BGPPTU,BGPTU)=""
 ;get all TOBACCO (SMOKING) during report period
 S BGPL=""
 D ALLHF(DFN,BGPBDATE,BGPEDATE,"TOBACCO (SMOKING)","BGPTOBS")
 S X=0 F  S X=$O(BGPTOBS(X)) Q:X'=+X!(BGPSMK)  D
 .S BGPL=X
 .I BGPTOBS(BGPL)["CESSATION" S BGPCTU=1,BGPSMK=1 Q
 .I BGPTOBS(BGPL)["CURRENT SMOKER" S BGPCTU=1,BGPSMK=1 Q
 .I BGPTOBS(BGPL)["HEAVY TOBACCO SMOKER" S BGPCTU=1,BGPSMK=1 Q
 .I BGPTOBS(BGPL)["LIGHT TOBACCO SMOKER" S BGPCTU=1,BGPSMK=1 Q
 I BGPCTU S BGPDNV="USER: "_$P(BGPTOBS(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBS(BGPL),U,1))_")",BGPGOT=1
 I BGPSMK S BGPDNV=BGPDNV_"; SMOKER: "_$P(BGPTOBS(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBS(BGPL),U,1))_")",BGPGOTS=1
SML ;
 S BGPL=""
 D ALLHF(DFN,BGPBDATE,BGPEDATE,"TOBACCO (SMOKELESS - CHEWING/DIP)","BGPTOBL")
 S X=0 F  S X=$O(BGPTOBL(X)) Q:X'=+X!(BGPSMKL)  D
 .S BGPL=X
 .I BGPTOBL(BGPL)["CESSATION" S BGPCTU=1,BGPSMKL=1 Q
 .I BGPTOBL(BGPL)["CURRENT SMOKE" S BGPCTU=1,BGPSMKL=1 Q
 I BGPCTU,'BGPGOT S BGPDNV="USER: "_$P(BGPTOBL(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBL(BGPL),U,1))_")",BGPGOT=1
 I BGPSMKL S BGPDNV=BGPDNV_"; SMOKELESS: "_$P(BGPTOBL(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBL(BGPL),U,1))_")",BGPGOTL=1
ENDS ;
 S BGPL=""
 D ALLHF(DFN,BGPBDATE,BGPEDATE,"ELECTRONIC NICOTINE DELIV SYSTEM (ENDS)","BGPTOBE")
 S X=0 F  S X=$O(BGPTOBE(X)) Q:X'=+X!(BGPSMKE)  D
 .S BGPL=X
 .I BGPTOBE(BGPL)["CESSATION" S BGPCTU=1,BGPSMKE=1 Q
 .I BGPTOBE(BGPL)["CURRENT" S BGPCTU=1,BGPSMKE=1 Q
 I BGPCTU,'BGPGOT S BGPDNV="USER: "_$P(BGPTOBE(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBE(BGPL),U,1))_")",BGPGOT=1
 I BGPSMKE S BGPDNV=BGPDNV_"; ENDS: "_$P(BGPTOBE(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBE(BGPL),U,1))_")"
 ;
PREV ;get last of each before time period.
 S BGPBDX=$$DOB^AUPNPAT(DFN),BGPEDX=$$FMADD^XLFDT(BGPBDATE,-1)
 ;
PSMK I 'BGPSMK D   ;IF NOT A SMOKER GET LAST IN PREVIOUS TIME PERIOD
 .K BGPTOBS
 .S C=$$LASTHF^BGP8D7(DFN,"TOBACCO (SMOKING)",BGPBDX,BGPEDX)
 .I C]"" S BGPTOBS(1)=$P(C,U,3)_"^"_$P(C,U,1)
 .;now recheck all
 .S BGPL=1 I $D(BGPTOBS(1)) D
 ..I BGPTOBS(BGPL)["CESSATION" S BGPPTU=1,BGPSMK=1 Q
 ..I BGPTOBS(BGPL)["CURRENT SMOKER" S BGPPTU=1,BGPSMK=1 Q
 ..I BGPTOBS(BGPL)["HEAVY TOBACCO SMOKER" S BGPPTU=1,BGPSMK=1 Q
 ..I BGPTOBS(BGPL)["LIGHT TOBACCO SMOKER" S BGPPTU=1,BGPSMK=1 Q
 .Q:'BGPSMK
 .I 'BGPCTU,BGPPTU S BGPDNV="USER: "_$P(BGPTOBS(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBS(BGPL),U,1))_")",BGPGOT=1
 .S BGPDNV=BGPDNV_"; SMOKER: "_$P(BGPTOBS(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBS(BGPL),U,1))_")",BGPGOTS=1
PSML ;
 I 'BGPSMKL D
 .K BGPTOBL
 .S C=$$LASTHF^BGP8D7(DFN,"TOBACCO (SMOKELESS - CHEWING/DIP)",BGPBDX,BGPEDX)
 .I C]"" S BGPTOBL(1)=$P(C,U,3)_"^"_$P(C,U,1)
 .S BGPL=1 I $D(BGPTOBL(1)) D
 ..I BGPTOBL(BGPL)["CESSATION" S BGPPTU=1,BGPSMKL=1 Q
 ..I BGPTOBL(BGPL)["CURRENT SMOKE" S BGPPTU=1,BGPSMKL=1 Q
 .Q:'BGPSMKL
 .I BGPPTU,'BGPCTU S BGPDNV="USER: "_$P(BGPTOBL(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBL(BGPL),U,1))_")",BGPGOT=1
 .S BGPDNV=BGPDNV_"; SMOKELESS: "_$P(BGPTOBL(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBL(BGPL),U,1))_")",BGPGOTL=1
PREVENDS ;
 I 'BGPSMKE D
 .K BGPTOBE
 .S C=$$LASTHF^BGP8D7(DFN,"ELECTRONIC NICOTINE DELIV SYSTEM (ENDS)",BGPBDX,BGPEDX)
 .I C]"" S BGPTOBE(1)=$P(C,U,3)_"^"_$P(C,U,1)
 .S BGPL=1 I $D(BGPTOBE(1)) D
 ..I BGPTOBE(BGPL)["CESSATION" S BGPTU=1,BGPSMKE=1 Q
 ..I BGPTOBE(BGPL)["CURRENT" S BGPTU=1,BGPSMKE=1 Q
 .Q:'BGPSMKE
 .I BGPTU,'BGPCTU S BGPDNV="USER: "_$P(BGPTOBE(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBE(BGPL),U,1))_")",BGPGOT=1
 .S BGPDNV=BGPDNV_"; ENDS: "_$P(BGPTOBE(BGPL),U,2)_"("_$$DATE^BGP8UTL($P(BGPTOBE(BGPL),U,1))_")"
 ;
 ;
SET ;
 I BGPCTU!(BGPPTU) S BGPTU=1
 I 'BGPTU S BGPSTOP=1 D KVARS Q  ;not in this denominator at all
 S BGPD1=1  ;UP
 I BGPACTCL S BGPD2=1
 ;
 ;get numerator stuff
 ;BGPN1=tobacco cessation counseling or prescription
 ;BGPN2=quit
 ;BGPN3 - any of them
 S BGPTC1=$$PED^BGP8D711(DFN,BGPBDATE,BGPEDATE,1)
 I $P(BGPTC1,U)]"" S BGPN1=1,BGPN3=1
 ;did they quit?  check each
 ;SMOKER
 S BGPQ=""
 I BGPSMK S X=$$LASTHF^BGP8D7(DFN,"TOBACCO (SMOKING)",$$DOB^AUPNPAT(DFN),BGPEDATE) G:$P(X,U,1)'["PREVIOUS" S2 S BGPQ="QUIT SMOKING: "_$P(X,U,2)_" "_$P(X,U,1)
 I BGPSMKL S X=$$LASTHF^BGP8D7(DFN,"TOBACCO (SMOKELESS - CHEWING/DIP)",$$DOB^AUPNPAT(DFN),BGPEDATE) G:$P(X,U,1)'["PREVIOUS" S2 S BGPQ=BGPQ_$S(BGPQ]"":"; ",1:"")_"QUIT SMOKELESS: "_$P(X,U,2)_" "_$P(X,U,1)
 I BGPSMKE S X=$$LASTHF^BGP8D7(DFN,"ELECTRONIC NICOTINE DELIV SYSTEM (ENDS)",$$DOB^AUPNPAT(DFN),BGPEDATE) G:$P(X,U,1)'["PREVIOUS" S2 S BGPQ=BGPQ_$S(BGPQ]"":"; ",1:"")_"QUIT ENDS: "_$P(X,U,2)_" "_$P(X,U,1)
 S BGPN2=1,BGPN3=1
S2 ;SET BGPVALUE
 S BGPVALUD="UP"_$S(BGPD2:",AC",1:"")_" "_BGPDNV
 D
 .S BGPVALUD=BGPVALUD_"|||"_$S($P(BGPTC1,U):"COUNSEL: "_$$DATE^BGP7UTL($P(BGPTC1,U))_" "_$P(BGPTC1,U,2),1:"")
 .I BGPN2 S BGPVALUD=BGPVALUD_"; "_BGPQ ;_" "_$P(BGPQ,U,3)
KVARS ;
 K BGPTOBS,BGPTOBL,BGPTOBE,BGPTOBT,BGPTOBSL,BGPTOBLL,BGPTOBEL,BGPTOBTL,BGPTU,BGPSMK,BGPSMKL,BGPSMKE,BGPGOT,BGPGOTS,BGPGOTL,BGPL,BGPTU,BGPCTU,BGPPTU
 Q
GETLAST ;
 NEW BGPBDX,BGPEDX,S,T,C,E
 S BGPBDX=$$DOB^AUPNPAT(DFN),BGPEDX=$$FMADD^XLFDT(BGPBDATE,-1)
 S C=$$LASTHF^BGP8D7(DFN,"TOBACCO (SMOKING)",BGPBDX,BGPEDX)
 I C]"" S BGPTOBS(1)=$P(C,U,3)_"^"_$P(C,U,1)
 S C=$$LASTHF^BGP8D7(DFN,"TOBACCO (SMOKELESS - CHEWING/DIP)",BGPBDX,BGPEDX)
 I C]"" S BGPTOBL(1)=$P(C,U,3)_"^"_$P(C,U,1)
 S C=$$LASTHF^BGP8D7(DFN,"ELECTRONIC NICOTINE DELIV SYSTEM (ENDS)",BGPBDX,BGPEDX)
 I C]"" S BGPTOBE(1)=$P(C,U,3)_"^"_$P(C,U,1)
 S C=$$LASTHF^BGP8D7(DFN,"TOBACCO",BGPBDX,BGPEDX)
 I C]"" S BGPTOBT(1)=$P(C,U,3)_"^"_$P(C,U,1)
 Q
ALLHF(P,BD,ED,CAT,RETVAL) ;\
 NEW H,D,C
 S (H,D,C)=0
 S CAT=$O(^AUTTHF("B",CAT,0))
 F  S H=$O(^AUTTHF("AC",CAT,H))  Q:'+H  D
 .Q:'$D(^AUPNVHF("AA",DFN,H))
 .S D="" F  S D=$O(^AUPNVHF("AA",DFN,H,D)) Q:D'=+D  D
 ..Q:(9999999-D)>ED  ;after time frame
 ..Q:(9999999-D)<BD  ;before time frame
 ..S C=C+1
 ..S @RETVAL@(C)=(9999999-$P(D,"."))_"^"_$P(^AUTTHF(H,0),U,1)
 .Q
 Q