- APCHSM04 ; IHS/CMI/LAB -- CONTINUATION OF ROUTINES ;
- ;;2.0;IHS PCC SUITE;**2,7,11,16**;MAY 14, 2009;Build 9
- ;
- S(X) ;
- NEW %,C S (C,%)=0 F S %=$O(APCHSTEX(%)) Q:%'=+% S C=C+1
- S APCHSTEX(C+1)=X
- Q
- HT ;EP
- X APCHSURX
- Q:'$$INAC^APCHSMU(APCHSITI)
- S APCHLAST="",APCHNEXT="" K APCHSTEX
- S APCHICAR=$$LASTITEM^APCLAPIU(APCHSPAT,"HT","MEASUREMENT",,,"A")
- S APCHLAST=$P(APCHICAR,U,1)
- S APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- I $P(APCHOVR,U)>APCHLAST D Q
- .S X=$$DATE^APCHSMU($P(APCHOVR,U))_" (per "_$P(APCHOVR,U,2)_")" D S(X) S X=$P(APCHOVR,U,3) D S(X)
- .D PRHT
- HTREG ;
- S APCHSINT="",APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- I APCHSCRI S APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT),APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
- I 'APCHSCRI S APCHSINT=365,APCHMIN=0
- I APCHSINT="" X APCHSURX Q
- I 'APCHSCRI D IHSHT Q
- HTREG1 ;
- I APCHLAST="" S APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN)) D PRHT Q
- S APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- I APCHNEXT>DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- I APCHNEXT'>DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- D PRHT
- Q
- ;
- IHSHT ;
- I APCHLAST="" S APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN)) D PRHT Q
- I APCHSAGE>2,APCHSAGE<19 S APCHSINT=365 D HTREG1 Q
- I APCHSAGE>64 S APCHSINT=365 D HTREG1 Q
- I APCHSAGE>18,APCHSAGE<65 D Q
- .S Y=$$FMADD^XLFDT(APCHSDOB,(18*365))
- .I Y<APCHLAST X APCHSURX Q
- .D HTREG1
- .Q
- S APCHDAYS=$$FMDIFF^XLFDT(DT,APCHSDOB)
- I APCHDAYS>0,APCHDAYS<(2*30.5) S APCHSTEX(1)=$$DATE^APCHSMU($$FMADD^XLFDT(APCHSDOB,(2*30.5))) D PRHT Q
- I APCHDAYS'<(2*30.5),APCHDAYS<(4*30.5) S APCHNEXT=$$FMADD^XLFDT(APCHSDOB,(4*30.5)),APCHLDUE=$$FMADD^XLFDT(APCHSDOB,(2*30.5)) D HTT Q
- I APCHDAYS'<(4*30.5),APCHDAYS<(6*30.5) S APCHNEXT=$$FMADD^XLFDT(APCHSDOB,(6*30.5)),APCHLDUE=$$FMADD^XLFDT(APCHSDOB,(4*30.5)) D HTT Q
- I APCHDAYS'<(6*30.5),APCHDAYS<365.25 S APCHNEXT=$$FMADD^XLFDT(APCHSDOB,365.25),APCHLDUE=$$FMADD^XLFDT(APCHSDOB,(6*30.5)) D HTT Q
- I APCHDAYS'<365,APCHDAYS<(18*30.5) S APCHNEXT=$$FMADD^XLFDT(APCHSDOB,(18*30.5)),APCHLDUE=$$FMADD^XLFDT(APCHSDOB,365) D HTT Q
- S APCHNEXT=$$FMADD^XLFDT(APCHSDOB,(2*365)),APCHLDUE=$$FMADD^XLFDT(APCHSDOB,(18*30.5)) D HTT Q
- Q
- HTT ;
- I APCHLDUE>APCHLAST S APCHSTEX(1)=$$DATE^APCHSMU(APCHLDUE) D PRHT Q
- I APCHNEXT<DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT) D PRHT Q
- I APCHNEXT'<DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT) D PRHT Q
- Q
- PRHT ;
- S V=$$REF^APCHSMU(APCHSPAT,9999999.07,$O(^AUTTMSR("B","HT",0)),APCHLAST) I V]"" S X=$P(V,U) D S(X) S X=$P(V,U,2) I X]"" D S(X)
- D WRITE^APCHSMU X APCHSURX
- Q
- ;
- FLU ;EP - influenza
- I $E(DT,4,5)="05"!($E(DT,4,5)="06")!($E(DT,4,5)="07")!($E(DT,4,5)="08") Q ;don't display in summer
- X APCHSURX
- Q:'$$INAC^APCHSMU(APCHSITI)
- S APCHSINT="",APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- I APCHSCRI S APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT),APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
- I 'APCHSCRI I $$FLUIHS(APCHSPAT) S APCHSINT=365,APCHMIN=64 I $$PLTAX^APCHSMU(APCHSPAT,"SURVEILLANCE PNEUMOCOCCAL RISK") S APCHMIN=$$AGE^AUPNPAT(APCHSPAT)
- S APCHLAST="",APCHNEXT="" K APCHSTEX
- S APCHSFLX=$S($$BI^APCHS11C:$O(^AUTTIMM("C",88,"")),1:$O(^AUTTIMM("C",12,""))),APCHIMMC=$S($$BI^APCHS11C:88,1:12)
- S APCHICAR=$$LASTFLU^APCLAPI4(APCHSPAT,,,"A")
- S APCHLAST=$P(APCHICAR,U,1)
- S APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- I $P(APCHOVR,U)>APCHLAST D Q
- .S X=$$DATE^APCHSMU($P(APCHOVR,U))_" (per "_$P(APCHOVR,U,2)_")" D S(X) S X=$P(APCHOVR,U,3) D S(X)
- .S V="" F APCHSC=15,16,88,111 Q:V]"" S APCHSFLX=$O(^AUTTIMM("C",APCHSC,0)) D
- ..S V=$$REF^APCHSMU(APCHSPAT,9999999.14,APCHSFLX,APCHLAST) I V]"" S X=$P(V,U) D S(X) S X=$P(V,U,2) I X]"" D S(X)
- .D WRITE^APCHSMU
- .X APCHSURX
- .Q
- FLUREG ;
- I APCHSINT="" X APCHSURX Q
- I APCHLAST="" S APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN)) D Q
- .S V="" F APCHSC=15,16,88,111 Q:V]"" S APCHSFLX=$O(^AUTTIMM("C",APCHSC,0)) D
- ..S V=$$REF^APCHSMU(APCHSPAT,9999999.14,APCHSFLX,APCHLAST) I V]"" S X=$P(V,U) D S(X) S X=$P(V,U,2) I X]"" D S(X)
- .D WRITE^APCHSMU
- .X APCHSURX
- .Q
- S APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- I APCHNEXT>DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- I APCHNEXT'>DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- S V="" F APCHSC=15,16,88,111 Q:V]"" S APCHSFLX=$O(^AUTTIMM("C",APCHSC,0)) D
- .S V=$$REF^APCHSMU(APCHSPAT,9999999.14,APCHSFLX,APCHLAST) I V]"" S X=$P(V,U) D S(X) S X=$P(V,U,2) I X]"" D S(X)
- D WRITE^APCHSMU
- X APCHSURX
- Q
- ;
- FLUIHS(P) ;
- NEW %,S
- I '$G(P) Q ""
- I $$AGE^AUPNPAT(P,DT)>64 Q 1
- S %=$$FMDIFF^XLFDT(DT,$P(^DPT(P,0),U,3),1)
- I %<180 Q ""
- I $$PLTAX^APCHSMU(APCHSPAT,"SURVEILLANCE PNEUMOCOCCAL RISK") Q 1
- Q ""
- MAMREF ;
- D MAMREF^APCHSMU2
- Q
- MAMWT ;
- D MAMREF
- D WRITE^APCHSMU
- X APCHSURX
- Q
- MAMM ;
- Q:'$$INAC^APCHSMU(APCHSITI)
- Q:APCHSEX'="F"
- S (APCHLAST,APCHNEXT,APCHWHL,APCHWHN,APCHSWHR,APCHICAR,APCHIC,APCHWF)="" K APCHSTEX,APCHX
- S APCHICAR=$$LASTMAM^APCLAPI1(APCHSPAT,,,"A"),APCHWF=$P(APCHICAR,U,5)
- S APCHLAST=$P(APCHICAR,U,1)
- D
- .S X="BWUTL1" X ^%ZOSF("TEST") I '$T Q
- .I '$D(^BWP(APCHSPAT,0)) Q
- .S APCHX=$$BNEED^BWUTL1(APCHSPAT)
- .I APCHX="UNKNOWN" K APCHX Q
- .I APCHX["NO DATE" K APCHX Q
- .S X=$P(APCHX,"by ",2),X=$P(X,")",1)
- .I $E(X)'?1N Q
- .S %DT="" D ^%DT
- .S APCHWHN=Y,APCHSWHR=APCHX
- ;now check against WH, if WH more current then check override, display and quit
- S I=0 ;USE WH OR NOT?
- I APCHWHN]"",APCHLAST]"",APCHLAST<APCHWHN S I=1
- I APCHWHN]"",APCHLAST="" S I=1 ;use wh if have a next and last =""
- I I D Q
- .S APCHNEXT=APCHWHN
- .S APCHSTEX(1)=APCHX
- .S X="(per Women's Health system)" D S(X)
- .S APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- .I $P(APCHOVR,U)>APCHLAST D Q
- ..S X=$$DATE^APCHSMU($P(APCHOVR,U))_" (per "_$P(APCHOVR,U,2)_")" D S(X) S X=$P(APCHOVR,U,3) D S(X)
- .D MAMWT
- .Q
- MAMR ;NOW REGULAR OLD STUFF
- S APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- I $P(APCHOVR,U)>APCHLAST D Q
- .S X=$$DATE^APCHSMU($P(APCHOVR,U))_" (per "_$P(APCHOVR,U,2)_")" D S(X) S X=$P(APCHOVR,U,3) D S(X)
- .D MAMWT
- MAMREG ;regular stuff
- S APCHSINT="",APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- I 'APCHSCRI D
- .Q:APCHSAGE<50
- .Q:APCHSAGE>74
- .S APCHSINT=365
- .S APCHMIN=50
- I APCHSCRI S APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT),APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT) ;return in APCHSINT the frequency in days for this age/sex
- I APCHSINT="" X APCHSURX Q ;no frequency so skip it
- I APCHLAST="" S APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN)) D Q
- .D MAMWT
- S APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- I APCHNEXT>DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- I APCHNEXT'>DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- D MAMWT
- Q
- PAPWT ;
- S APCHTAXN=$O(^ATXLAB("B","BGP PAP SMEAR TAX",0))
- D REF
- ;S V=$$REF^APCHSMU(APCHSPAT,60,$O(^LAB(60,"B","PAP SMEAR",0)),APCHLAST) I V]"" S X=$P(V,U) D S(X) S X=$P(V,U,2) I X]"" D S(X)
- D WRITE^APCHSMU
- X APCHSURX
- Q
- REF ;
- K APCHREF S APCHT=0 F S APCHT=$O(^ATXLAB(APCHTAXN,21,"B",APCHT)) Q:APCHT'=+APCHT D
- .S V=$$REF^APCHSMU(APCHSPAT,60,APCHT,APCHLAST) I V]"" S APCHREF(9999999-$P(V,U,3))=V
- S V=$$REF^APCHSMU(APCHSPAT,60,$O(^LAB(60,"B","PAP SMEAR",0)),APCHLAST) I V]"" S APCHREF(9999999-$P(V,U,3))=V
- I $D(APCHREF) S %=0,%=$O(APCHREF(%)) I % S V=APCHREF(%),X=$P(V,U) D S(X) S X=$P(V,U,2) I X]"" D S(X)
- Q
- PAP ;
- Q:'$$INAC^APCHSMU(APCHSITI) ;is item turned on or off
- Q:APCHSEX'="F" ;females only
- S (APCHLAST,APCHNEXT,APCHWHL,APCHWHN,APCHSWHR,APCHICAR,APCHIC,APCHWF,APCHHPV)="" K APCHSTEX,APCHX
- S APCHICAR=$$LASTPAP^APCLAPI1(APCHSPAT,,,"A")
- S APCHLAST=$P(APCHICAR,U,1),APCHWF=$P(APCHICAR,U,5)
- D
- .S X="BWUTL1" X ^%ZOSF("TEST") I '$T Q
- .I '$D(^BWP(APCHSPAT,0)) Q
- .S APCHX=$$CNEED^BWUTL1(APCHSPAT)
- .I APCHX="UNKNOWN" K APCHX Q
- .I APCHX["NO DATE" K APCHX Q
- .I APCHX'["PAP" S APCHWHN="",APCHSWHR=APCHX Q
- .S APCHY=""
- .I APCHX["by " D
- ..S X=$P(APCHX,"by ",2),X=$P(X,")",1)
- ..I $E(X)'?1N Q
- ..S %DT="" D ^%DT
- ..S APCHY=Y
- .S APCHWHN=APCHY,APCHSWHR=APCHX
- S APCHWHL=APCHLAST
- S I=1
- I APCHSWHR="" S I=0
- I APCHWHN]"",APCHLAST]"",APCHLAST<APCHWHN S I=1
- I I D Q
- .S APCHLAST=APCHWHL,APCHNEXT=APCHWHN
- .S APCHSTEX(1)=APCHSWHR
- .S X="(per Women's Health system)" D S(X)
- .S APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- .I $P(APCHOVR,U)>APCHLAST D Q
- ..S X=$$DATE^APCHSMU($P(APCHOVR,U))_" (per "_$P(APCHOVR,U,2)_")" D S(X) S X=$P(APCHOVR,U,3) D S(X)
- .D PAPWT
- .Q
- S APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- I $P(APCHOVR,U)>APCHLAST D Q
- .S X=$$DATE^APCHSMU($P(APCHOVR,U))_" (per "_$P(APCHOVR,U,2)_")" D S(X) S X=$P(APCHOVR,U,3) D S(X)
- .D PAPWT
- PAPREG ;regular stuff
- S APCHSINT="",APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- I 'APCHSCRI D
- .Q:APCHSAGE<21
- .Q:APCHSAGE>64
- .S APCHSINT=(3*365)
- .S APCHMIN=21
- I APCHSCRI S APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT),APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
- I APCHSINT="" X APCHSURX Q
- ;check for hysterectomy
- I $$HYSTER(APCHSPAT) S APCHSTEX(1)="Patient has had hysterectomy",APCHSTEX(2)="Pap may be needed based on",APCHSTEX(3)="clinical assessment." D PAPWT Q
- I APCHLAST="" S APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN)) D Q
- .D PAPWT
- I APCHSAGE<30 D Q
- .S APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- .I APCHNEXT>DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- .I APCHNEXT'>DT S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- .D PAPWT
- ;30-64
- ;IF HAD PAP IN PAST 3 YRS, DISPLAY NEXT INFO AND DON'T WORRY ABOUT HPV TEST
- I $$FMDIFF^XLFDT(APCHLAST,DT)<(3*365) D Q
- .S APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- .S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- .S APCHSTEX(2)="PAP every 3 years: Next: "_$$DATE^APCHSMU(APCHNEXT)
- .S APCHSTEX(3)="or PAP and high risk HPV test "
- .S APCHSTEX(4)=" every 5 years: Next: "_$$DATE^APCHSMU($$FMADD^XLFDT(APCHLAST,(5*365)))
- .D PAPWT
- ;IF HAD PAP AND HPV IN PAST 5 YRS DISPLAY NEXT PAP+5
- S APCHHPV=$P($$LASTHPV(APCHSPAT),U,2)
- I $$FMDIFF^XLFDT(APCHLAST,DT)<(5*365),$$FMDIFF^XLFDT(APCHLAST,DT)<(5*365) D Q
- .S APCHNEXT=$$FMADD^XLFDT(APCHLAST,(5*365))
- .S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- .S APCHSTEX(2)="PAP every 3 years: Next: "_$$DATE^APCHSMU($$FMADD^XLFDT(APCHLAST,(3*365)))
- .S APCHSTEX(3)="or PAP and high risk HPV test "
- .S APCHSTEX(4)=" every 5 years: Next: "_$$DATE^APCHSMU(APCHNEXT)
- .D PAPWT
- S APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- S APCHSTEX(2)="PAP every 3 years: Next: "_$$DATE^APCHSMU(APCHNEXT)
- S APCHSTEX(3)="PAP and high risk HPV test "
- S APCHSTEX(4)=" every 5 years: Next: "_$$DATE^APCHSMU($$FMADD^XLFDT(APCHLAST,(5*365)))
- D PAPWT
- Q
- HYSTER(P) ;EP has patient had hysterectomy?
- I '$G(P) Q ""
- ;I '$D(^AUPNVPRC("AC",P)) Q ""
- N APCHSVDT
- NEW F,S,C S (F,S)=0 F S F=$O(^AUPNVPRC("AC",P,F)) Q:F'=+F!(S) I $D(^AUPNVPRC(F,0)) S APCHSVDT=$P(+^AUPNVSIT($P(^AUPNVPRC(F,0),U,3),0),"."),C=$P($$ICDOP^ICDEX(+^AUPNVPRC(F,0),APCHSVDT,,"I"),U,1) D
- .S:$$ICD^ATXAPI(C,$O(^ATXAX("B","BGP HYSTERECTOMY PROCEDURES",0)),1) S=1
- I S=1 Q 1
- I $P($$LASTDX^APCHSMU2(P,"BGP HYSTERECTOMY DXS"),U) Q 1 ;had this dx
- S T="HYSTERECTOMY",T=$O(^BWPN("B",T,0))
- I T D I X Q 1
- .S X=$$WH^APCHSMU2(P,$$DOB^AUPNPAT(P),DT,T,1)
- S T=$O(^ATXAX("B","BGP HYSTERECTOMY CPTS",0))
- I T D I X Q 1
- .S X=$$CPT^APCHSMU2(P,$P(^DPT(P,0),U,3),DT,T,1)
- Q ""
- LASTHPV(P) ;EP
- NEW APCHC,APCHLPAP,T,APCHLT,B,D,E,L,X,J,APCH
- S APCHC=""
- S APCHLPAP=""
- S BDATE=$$DOB^AUPNPAT(P)
- S EDATE=DT
- S T=$O(^ATXAX("B","BGP HPV LOINC CODES",0))
- S APCHLT=$O(^ATXLAB("B","BGP HPV TESTS TAX",0))
- S B=9999999-BDATE,E=9999999-EDATE S D=E-1 F S D=$O(^AUPNVLAB("AE",P,D)) Q:D'=+D!(D>B)!(APCHC]"") D
- .S L=0 F S L=$O(^AUPNVLAB("AE",P,D,L)) Q:L'=+L!(APCHC]"") D
- ..S X=0 F S X=$O(^AUPNVLAB("AE",P,D,L,X)) Q:X'=+X!(APCHC]"") D
- ...Q:'$D(^AUPNVLAB(X,0))
- ...S Z=$P(^AUPNVLAB(X,0),U),Z=$P($G(^LAB(60,Z,0)),U) I Z="HPV" S APCHC="1^"_(9999999-D)_"^Lab" Q
- ...I APCHLT,$P(^AUPNVLAB(X,0),U),$D(^ATXLAB(APCHLT,21,"B",$P(^AUPNVLAB(X,0),U))) S APCHC="1^"_(9999999-D)_"^Lab" Q
- ...Q:'T
- ...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
- ...Q:'$$LOINC(J,T)
- ...S APCHC="1^"_(9999999-D)_"^Lab-loinc" Q
- ...Q
- S APCHLPAP=APCHC
- K APCH
- S T="BGP HPV DXS"
- S X=$$LASTDXT^APCLAPIU(P,,,"BGP HPV DXS","D") I X,$P(APCHLPAP,U,2)<X S APCHLPAP="1^"_X_"^HPV POV "
- S T=$O(^ATXAX("B","BGP HPV CPTS",0))
- I T D I X]"",$P(APCHLPAP,U,2)<$P(X,U,1) S APCHLPAP="1^"_$P(X,U)_"^CPT "_$P(X,U,2)
- .S X=$$CPT^APCHSMU2(P,BDATE,EDATE,T,5) I X]"" Q
- Q APCHLPAP
- WW ;EP - WiseWoman reminder - Mike Mosley
- N WWSTAT,APCHLAST,APCHNEXT,APCHSTEX
- Q:'$$INAC^APCHSMU(APCHSITI)
- Q:APCHSEX'="F"
- S (APCHLAST,APCHNEXT)="" K APCHSTEX
- S APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- S WWSTAT=$$GET1^DIQ(9000001,APCHSPAT,1709,"I")
- Q:WWSTAT>1&(WWSTAT<4)
- I $$HASWWP(APCHSPAT) D
- .S APCHLAST=$$WWPDT(APCHSPAT)
- .S APCHNEXT=$$FMADD^XLFDT(APCHLAST,305)
- .I APCHNEXT'>DT S APCHSTEX(1)="MAY BE DUE NOW (WAS DUE "_$$DATE^APCHSMU(APCHNEXT)_")"
- .E S APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- E D
- .S:APCHSAGE>29&(APCHSAGE<65) APCHSTEX(1)="MAY BE DUE NOW"
- D:$D(APCHSTEX) WRITE^APCHSMU
- X APCHSURX
- Q
- WWPDT(DFN) ;
- N IEN,PDT,WWP
- S PDT=0
- Q:'$G(DFN) PDT
- S PDT=0,IEN=$C(1) F S IEN=$O(^BWPCD("C",DFN,IEN),-1) Q:'IEN!PDT D
- .S WWP=$$GET1^DIQ(9002086.1,IEN,4.01,"I")
- .I WWP=1!(WWP=2) S PDT=$$GET1^DIQ(9002086.1,IEN,4.02,"I")
- Q PDT
- ;
- HASWWP(DFN) ;
- N IEN,FLG
- S (FLG,IEN)=0 F S IEN=$O(^BWPCD("C",DFN,IEN)) Q:'IEN!FLG D
- .I $$GET1^DIQ(9002086.1,IEN,4.01,"I")=1 S FLG=1
- Q FLG
- PAPDAYS(P) ;PEP - called from WH to return # of days
- ; from last pap until this patient's next pap is due
- ; 0 = clinical discretion (had hysterectomy)
- ; -1 = patient not eligible for this reminder
- ; return = # days
- I '$G(P) Q -1
- ;is patient eligible for this reminder per specifications in hmr file?
- NEW APCHSITI,APCHSCRI,G
- S APCHSITI=$O(^APCHSURV("B","PAP SMEAR",0))
- S APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- I $$HYSTER(P) Q 0 ;if hysterectomy then clinical discretion
- I 'APCHSCRI D Q G
- .S G=-1
- .Q:$$AGE^AUPNPAT(P,DT)<18
- .S G=(3*365)
- S G=$$AGESEX^APCHSMU(APCHSITI,P),G=$P(G,".")
- I 'G Q -1
- Q G
- MAMDAYS(P) ;PEP - called from WH to return # of days
- ; from last mammogram that the next one is due
- ; -1 = patient not eligible for this reminder
- ; return = # days
- I '$G(P) Q -1
- ;is patient eligible for this reminder per specifications in hmr file?
- NEW APCHSITI,APCHSCRI,G
- S APCHSITI=$O(^APCHSURV("B","MAMMOGRAM",0))
- S APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- I 'APCHSCRI D Q G
- .S G=-1
- .Q:$$AGE^AUPNPAT(P,DT)<50
- .Q:$$AGE^AUPNPAT(P,DT)>69
- .S G=365
- S G=$$AGESEX^APCHSMU(APCHSITI,P),G=$P(G,".")
- I 'G Q -1
- Q G
- LOINC(A,B) ;
- NEW %
- S %=$P($G(^LAB(95.3,A,9999999)),U,2)
- I %]"",$D(^ATXAX(B,21,"B",%)) Q 1
- S %=$P($G(^LAB(95.3,A,0)),U)_"-"_$P($G(^LAB(95.3,A,0)),U,15)
- I $D(^ATXAX(B,21,"B",%)) Q 1
- Q ""
- APCHSM04 ; IHS/CMI/LAB -- CONTINUATION OF ROUTINES ;
- +1 ;;2.0;IHS PCC SUITE;**2,7,11,16**;MAY 14, 2009;Build 9
- +2 ;
- S(X) ;
- +1 NEW %,C
- SET (C,%)=0
- FOR
- SET %=$ORDER(APCHSTEX(%))
- IF %'=+%
- QUIT
- SET C=C+1
- +2 SET APCHSTEX(C+1)=X
- +3 QUIT
- HT ;EP
- +1 XECUTE APCHSURX
- +2 IF '$$INAC^APCHSMU(APCHSITI)
- QUIT
- +3 SET APCHLAST=""
- SET APCHNEXT=""
- KILL APCHSTEX
- +4 SET APCHICAR=$$LASTITEM^APCLAPIU(APCHSPAT,"HT","MEASUREMENT",,,"A")
- +5 SET APCHLAST=$PIECE(APCHICAR,U,1)
- +6 SET APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- +7 IF $PIECE(APCHOVR,U)>APCHLAST
- Begin DoDot:1
- +8 SET X=$$DATE^APCHSMU($PIECE(APCHOVR,U))_" (per "_$PIECE(APCHOVR,U,2)_")"
- DO S(X)
- SET X=$PIECE(APCHOVR,U,3)
- DO S(X)
- +9 DO PRHT
- End DoDot:1
- QUIT
- HTREG ;
- +1 SET APCHSINT=""
- SET APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- +2 IF APCHSCRI
- SET APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT)
- SET APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
- +3 IF 'APCHSCRI
- SET APCHSINT=365
- SET APCHMIN=0
- +4 IF APCHSINT=""
- XECUTE APCHSURX
- QUIT
- +5 IF 'APCHSCRI
- DO IHSHT
- QUIT
- HTREG1 ;
- +1 IF APCHLAST=""
- SET APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN))
- DO PRHT
- QUIT
- +2 SET APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- +3 IF APCHNEXT>DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +4 IF APCHNEXT'>DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +5 DO PRHT
- +6 QUIT
- +7 ;
- IHSHT ;
- +1 IF APCHLAST=""
- SET APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN))
- DO PRHT
- QUIT
- +2 IF APCHSAGE>2
- IF APCHSAGE<19
- SET APCHSINT=365
- DO HTREG1
- QUIT
- +3 IF APCHSAGE>64
- SET APCHSINT=365
- DO HTREG1
- QUIT
- +4 IF APCHSAGE>18
- IF APCHSAGE<65
- Begin DoDot:1
- +5 SET Y=$$FMADD^XLFDT(APCHSDOB,(18*365))
- +6 IF Y<APCHLAST
- XECUTE APCHSURX
- QUIT
- +7 DO HTREG1
- +8 QUIT
- End DoDot:1
- QUIT
- +9 SET APCHDAYS=$$FMDIFF^XLFDT(DT,APCHSDOB)
- +10 IF APCHDAYS>0
- IF APCHDAYS<(2*30.5)
- SET APCHSTEX(1)=$$DATE^APCHSMU($$FMADD^XLFDT(APCHSDOB,(2*30.5)))
- DO PRHT
- QUIT
- +11 IF APCHDAYS'<(2*30.5)
- IF APCHDAYS<(4*30.5)
- SET APCHNEXT=$$FMADD^XLFDT(APCHSDOB,(4*30.5))
- SET APCHLDUE=$$FMADD^XLFDT(APCHSDOB,(2*30.5))
- DO HTT
- QUIT
- +12 IF APCHDAYS'<(4*30.5)
- IF APCHDAYS<(6*30.5)
- SET APCHNEXT=$$FMADD^XLFDT(APCHSDOB,(6*30.5))
- SET APCHLDUE=$$FMADD^XLFDT(APCHSDOB,(4*30.5))
- DO HTT
- QUIT
- +13 IF APCHDAYS'<(6*30.5)
- IF APCHDAYS<365.25
- SET APCHNEXT=$$FMADD^XLFDT(APCHSDOB,365.25)
- SET APCHLDUE=$$FMADD^XLFDT(APCHSDOB,(6*30.5))
- DO HTT
- QUIT
- +14 IF APCHDAYS'<365
- IF APCHDAYS<(18*30.5)
- SET APCHNEXT=$$FMADD^XLFDT(APCHSDOB,(18*30.5))
- SET APCHLDUE=$$FMADD^XLFDT(APCHSDOB,365)
- DO HTT
- QUIT
- +15 SET APCHNEXT=$$FMADD^XLFDT(APCHSDOB,(2*365))
- SET APCHLDUE=$$FMADD^XLFDT(APCHSDOB,(18*30.5))
- DO HTT
- QUIT
- +16 QUIT
- HTT ;
- +1 IF APCHLDUE>APCHLAST
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHLDUE)
- DO PRHT
- QUIT
- +2 IF APCHNEXT<DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- DO PRHT
- QUIT
- +3 IF APCHNEXT'<DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- DO PRHT
- QUIT
- +4 QUIT
- PRHT ;
- +1 SET V=$$REF^APCHSMU(APCHSPAT,9999999.07,$ORDER(^AUTTMSR("B","HT",0)),APCHLAST)
- IF V]""
- SET X=$PIECE(V,U)
- DO S(X)
- SET X=$PIECE(V,U,2)
- IF X]""
- DO S(X)
- +2 DO WRITE^APCHSMU
- XECUTE APCHSURX
- +3 QUIT
- +4 ;
- FLU ;EP - influenza
- +1 ;don't display in summer
- IF $EXTRACT(DT,4,5)="05"!($EXTRACT(DT,4,5)="06")!($EXTRACT(DT,4,5)="07")!($EXTRACT(DT,4,5)="08")
- QUIT
- +2 XECUTE APCHSURX
- +3 IF '$$INAC^APCHSMU(APCHSITI)
- QUIT
- +4 SET APCHSINT=""
- SET APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- +5 IF APCHSCRI
- SET APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT)
- SET APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
- +6 IF 'APCHSCRI
- IF $$FLUIHS(APCHSPAT)
- SET APCHSINT=365
- SET APCHMIN=64
- IF $$PLTAX^APCHSMU(APCHSPAT,"SURVEILLANCE PNEUMOCOCCAL RISK")
- SET APCHMIN=$$AGE^AUPNPAT(APCHSPAT)
- +7 SET APCHLAST=""
- SET APCHNEXT=""
- KILL APCHSTEX
- +8 SET APCHSFLX=$SELECT($$BI^APCHS11C:$O(^AUTTIMM("C",88,"")),1:$ORDER(^AUTTIMM("C",12,"")))
- SET APCHIMMC=$SELECT($$BI^APCHS11C:88,1:12)
- +9 SET APCHICAR=$$LASTFLU^APCLAPI4(APCHSPAT,,,"A")
- +10 SET APCHLAST=$PIECE(APCHICAR,U,1)
- +11 SET APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- +12 IF $PIECE(APCHOVR,U)>APCHLAST
- Begin DoDot:1
- +13 SET X=$$DATE^APCHSMU($PIECE(APCHOVR,U))_" (per "_$PIECE(APCHOVR,U,2)_")"
- DO S(X)
- SET X=$PIECE(APCHOVR,U,3)
- DO S(X)
- +14 SET V=""
- FOR APCHSC=15,16,88,111
- IF V]""
- QUIT
- SET APCHSFLX=$ORDER(^AUTTIMM("C",APCHSC,0))
- Begin DoDot:2
- +15 SET V=$$REF^APCHSMU(APCHSPAT,9999999.14,APCHSFLX,APCHLAST)
- IF V]""
- SET X=$PIECE(V,U)
- DO S(X)
- SET X=$PIECE(V,U,2)
- IF X]""
- DO S(X)
- End DoDot:2
- +16 DO WRITE^APCHSMU
- +17 XECUTE APCHSURX
- +18 QUIT
- End DoDot:1
- QUIT
- FLUREG ;
- +1 IF APCHSINT=""
- XECUTE APCHSURX
- QUIT
- +2 IF APCHLAST=""
- SET APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN))
- Begin DoDot:1
- +3 SET V=""
- FOR APCHSC=15,16,88,111
- IF V]""
- QUIT
- SET APCHSFLX=$ORDER(^AUTTIMM("C",APCHSC,0))
- Begin DoDot:2
- +4 SET V=$$REF^APCHSMU(APCHSPAT,9999999.14,APCHSFLX,APCHLAST)
- IF V]""
- SET X=$PIECE(V,U)
- DO S(X)
- SET X=$PIECE(V,U,2)
- IF X]""
- DO S(X)
- End DoDot:2
- +5 DO WRITE^APCHSMU
- +6 XECUTE APCHSURX
- +7 QUIT
- End DoDot:1
- QUIT
- +8 SET APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- +9 IF APCHNEXT>DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +10 IF APCHNEXT'>DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +11 SET V=""
- FOR APCHSC=15,16,88,111
- IF V]""
- QUIT
- SET APCHSFLX=$ORDER(^AUTTIMM("C",APCHSC,0))
- Begin DoDot:1
- +12 SET V=$$REF^APCHSMU(APCHSPAT,9999999.14,APCHSFLX,APCHLAST)
- IF V]""
- SET X=$PIECE(V,U)
- DO S(X)
- SET X=$PIECE(V,U,2)
- IF X]""
- DO S(X)
- End DoDot:1
- +13 DO WRITE^APCHSMU
- +14 XECUTE APCHSURX
- +15 QUIT
- +16 ;
- FLUIHS(P) ;
- +1 NEW %,S
- +2 IF '$GET(P)
- QUIT ""
- +3 IF $$AGE^AUPNPAT(P,DT)>64
- QUIT 1
- +4 SET %=$$FMDIFF^XLFDT(DT,$PIECE(^DPT(P,0),U,3),1)
- +5 IF %<180
- QUIT ""
- +6 IF $$PLTAX^APCHSMU(APCHSPAT,"SURVEILLANCE PNEUMOCOCCAL RISK")
- QUIT 1
- +7 QUIT ""
- MAMREF ;
- +1 DO MAMREF^APCHSMU2
- +2 QUIT
- MAMWT ;
- +1 DO MAMREF
- +2 DO WRITE^APCHSMU
- +3 XECUTE APCHSURX
- +4 QUIT
- MAMM ;
- +1 IF '$$INAC^APCHSMU(APCHSITI)
- QUIT
- +2 IF APCHSEX'="F"
- QUIT
- +3 SET (APCHLAST,APCHNEXT,APCHWHL,APCHWHN,APCHSWHR,APCHICAR,APCHIC,APCHWF)=""
- KILL APCHSTEX,APCHX
- +4 SET APCHICAR=$$LASTMAM^APCLAPI1(APCHSPAT,,,"A")
- SET APCHWF=$PIECE(APCHICAR,U,5)
- +5 SET APCHLAST=$PIECE(APCHICAR,U,1)
- +6 Begin DoDot:1
- +7 SET X="BWUTL1"
- XECUTE ^%ZOSF("TEST")
- IF '$TEST
- QUIT
- +8 IF '$DATA(^BWP(APCHSPAT,0))
- QUIT
- +9 SET APCHX=$$BNEED^BWUTL1(APCHSPAT)
- +10 IF APCHX="UNKNOWN"
- KILL APCHX
- QUIT
- +11 IF APCHX["NO DATE"
- KILL APCHX
- QUIT
- +12 SET X=$PIECE(APCHX,"by ",2)
- SET X=$PIECE(X,")",1)
- +13 IF $EXTRACT(X)'?1N
- QUIT
- +14 SET %DT=""
- DO ^%DT
- +15 SET APCHWHN=Y
- SET APCHSWHR=APCHX
- End DoDot:1
- +16 ;now check against WH, if WH more current then check override, display and quit
- +17 ;USE WH OR NOT?
- SET I=0
- +18 IF APCHWHN]""
- IF APCHLAST]""
- IF APCHLAST<APCHWHN
- SET I=1
- +19 ;use wh if have a next and last =""
- IF APCHWHN]""
- IF APCHLAST=""
- SET I=1
- +20 IF I
- Begin DoDot:1
- +21 SET APCHNEXT=APCHWHN
- +22 SET APCHSTEX(1)=APCHX
- +23 SET X="(per Women's Health system)"
- DO S(X)
- +24 SET APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- +25 IF $PIECE(APCHOVR,U)>APCHLAST
- Begin DoDot:2
- +26 SET X=$$DATE^APCHSMU($PIECE(APCHOVR,U))_" (per "_$PIECE(APCHOVR,U,2)_")"
- DO S(X)
- SET X=$PIECE(APCHOVR,U,3)
- DO S(X)
- End DoDot:2
- QUIT
- +27 DO MAMWT
- +28 QUIT
- End DoDot:1
- QUIT
- MAMR ;NOW REGULAR OLD STUFF
- +1 SET APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- +2 IF $PIECE(APCHOVR,U)>APCHLAST
- Begin DoDot:1
- +3 SET X=$$DATE^APCHSMU($PIECE(APCHOVR,U))_" (per "_$PIECE(APCHOVR,U,2)_")"
- DO S(X)
- SET X=$PIECE(APCHOVR,U,3)
- DO S(X)
- +4 DO MAMWT
- End DoDot:1
- QUIT
- MAMREG ;regular stuff
- +1 SET APCHSINT=""
- SET APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- +2 IF 'APCHSCRI
- Begin DoDot:1
- +3 IF APCHSAGE<50
- QUIT
- +4 IF APCHSAGE>74
- QUIT
- +5 SET APCHSINT=365
- +6 SET APCHMIN=50
- End DoDot:1
- +7 ;return in APCHSINT the frequency in days for this age/sex
- IF APCHSCRI
- SET APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT)
- SET APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
- +8 ;no frequency so skip it
- IF APCHSINT=""
- XECUTE APCHSURX
- QUIT
- +9 IF APCHLAST=""
- SET APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN))
- Begin DoDot:1
- +10 DO MAMWT
- End DoDot:1
- QUIT
- +11 SET APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- +12 IF APCHNEXT>DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +13 IF APCHNEXT'>DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +14 DO MAMWT
- +15 QUIT
- PAPWT ;
- +1 SET APCHTAXN=$ORDER(^ATXLAB("B","BGP PAP SMEAR TAX",0))
- +2 DO REF
- +3 ;S V=$$REF^APCHSMU(APCHSPAT,60,$O(^LAB(60,"B","PAP SMEAR",0)),APCHLAST) I V]"" S X=$P(V,U) D S(X) S X=$P(V,U,2) I X]"" D S(X)
- +4 DO WRITE^APCHSMU
- +5 XECUTE APCHSURX
- +6 QUIT
- REF ;
- +1 KILL APCHREF
- SET APCHT=0
- FOR
- SET APCHT=$ORDER(^ATXLAB(APCHTAXN,21,"B",APCHT))
- IF APCHT'=+APCHT
- QUIT
- Begin DoDot:1
- +2 SET V=$$REF^APCHSMU(APCHSPAT,60,APCHT,APCHLAST)
- IF V]""
- SET APCHREF(9999999-$PIECE(V,U,3))=V
- End DoDot:1
- +3 SET V=$$REF^APCHSMU(APCHSPAT,60,$ORDER(^LAB(60,"B","PAP SMEAR",0)),APCHLAST)
- IF V]""
- SET APCHREF(9999999-$PIECE(V,U,3))=V
- +4 IF $DATA(APCHREF)
- SET %=0
- SET %=$ORDER(APCHREF(%))
- IF %
- SET V=APCHREF(%)
- SET X=$PIECE(V,U)
- DO S(X)
- SET X=$PIECE(V,U,2)
- IF X]""
- DO S(X)
- +5 QUIT
- PAP ;
- +1 ;is item turned on or off
- IF '$$INAC^APCHSMU(APCHSITI)
- QUIT
- +2 ;females only
- IF APCHSEX'="F"
- QUIT
- +3 SET (APCHLAST,APCHNEXT,APCHWHL,APCHWHN,APCHSWHR,APCHICAR,APCHIC,APCHWF,APCHHPV)=""
- KILL APCHSTEX,APCHX
- +4 SET APCHICAR=$$LASTPAP^APCLAPI1(APCHSPAT,,,"A")
- +5 SET APCHLAST=$PIECE(APCHICAR,U,1)
- SET APCHWF=$PIECE(APCHICAR,U,5)
- +6 Begin DoDot:1
- +7 SET X="BWUTL1"
- XECUTE ^%ZOSF("TEST")
- IF '$TEST
- QUIT
- +8 IF '$DATA(^BWP(APCHSPAT,0))
- QUIT
- +9 SET APCHX=$$CNEED^BWUTL1(APCHSPAT)
- +10 IF APCHX="UNKNOWN"
- KILL APCHX
- QUIT
- +11 IF APCHX["NO DATE"
- KILL APCHX
- QUIT
- +12 IF APCHX'["PAP"
- SET APCHWHN=""
- SET APCHSWHR=APCHX
- QUIT
- +13 SET APCHY=""
- +14 IF APCHX["by "
- Begin DoDot:2
- +15 SET X=$PIECE(APCHX,"by ",2)
- SET X=$PIECE(X,")",1)
- +16 IF $EXTRACT(X)'?1N
- QUIT
- +17 SET %DT=""
- DO ^%DT
- +18 SET APCHY=Y
- End DoDot:2
- +19 SET APCHWHN=APCHY
- SET APCHSWHR=APCHX
- End DoDot:1
- +20 SET APCHWHL=APCHLAST
- +21 SET I=1
- +22 IF APCHSWHR=""
- SET I=0
- +23 IF APCHWHN]""
- IF APCHLAST]""
- IF APCHLAST<APCHWHN
- SET I=1
- +24 IF I
- Begin DoDot:1
- +25 SET APCHLAST=APCHWHL
- SET APCHNEXT=APCHWHN
- +26 SET APCHSTEX(1)=APCHSWHR
- +27 SET X="(per Women's Health system)"
- DO S(X)
- +28 SET APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- +29 IF $PIECE(APCHOVR,U)>APCHLAST
- Begin DoDot:2
- +30 SET X=$$DATE^APCHSMU($PIECE(APCHOVR,U))_" (per "_$PIECE(APCHOVR,U,2)_")"
- DO S(X)
- SET X=$PIECE(APCHOVR,U,3)
- DO S(X)
- End DoDot:2
- QUIT
- +31 DO PAPWT
- +32 QUIT
- End DoDot:1
- QUIT
- +33 SET APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- +34 IF $PIECE(APCHOVR,U)>APCHLAST
- Begin DoDot:1
- +35 SET X=$$DATE^APCHSMU($PIECE(APCHOVR,U))_" (per "_$PIECE(APCHOVR,U,2)_")"
- DO S(X)
- SET X=$PIECE(APCHOVR,U,3)
- DO S(X)
- +36 DO PAPWT
- End DoDot:1
- QUIT
- PAPREG ;regular stuff
- +1 SET APCHSINT=""
- SET APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
- +2 IF 'APCHSCRI
- Begin DoDot:1
- +3 IF APCHSAGE<21
- QUIT
- +4 IF APCHSAGE>64
- QUIT
- +5 SET APCHSINT=(3*365)
- +6 SET APCHMIN=21
- End DoDot:1
- +7 IF APCHSCRI
- SET APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT)
- SET APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
- +8 IF APCHSINT=""
- XECUTE APCHSURX
- QUIT
- +9 ;check for hysterectomy
- +10 IF $$HYSTER(APCHSPAT)
- SET APCHSTEX(1)="Patient has had hysterectomy"
- SET APCHSTEX(2)="Pap may be needed based on"
- SET APCHSTEX(3)="clinical assessment."
- DO PAPWT
- QUIT
- +11 IF APCHLAST=""
- SET APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN))
- Begin DoDot:1
- +12 DO PAPWT
- End DoDot:1
- QUIT
- +13 IF APCHSAGE<30
- Begin DoDot:1
- +14 SET APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- +15 IF APCHNEXT>DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +16 IF APCHNEXT'>DT
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +17 DO PAPWT
- End DoDot:1
- QUIT
- +18 ;30-64
- +19 ;IF HAD PAP IN PAST 3 YRS, DISPLAY NEXT INFO AND DON'T WORRY ABOUT HPV TEST
- +20 IF $$FMDIFF^XLFDT(APCHLAST,DT)<(3*365)
- Begin DoDot:1
- +21 SET APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- +22 SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +23 SET APCHSTEX(2)="PAP every 3 years: Next: "_$$DATE^APCHSMU(APCHNEXT)
- +24 SET APCHSTEX(3)="or PAP and high risk HPV test "
- +25 SET APCHSTEX(4)=" every 5 years: Next: "_$$DATE^APCHSMU($$FMADD^XLFDT(APCHLAST,(5*365)))
- +26 DO PAPWT
- End DoDot:1
- QUIT
- +27 ;IF HAD PAP AND HPV IN PAST 5 YRS DISPLAY NEXT PAP+5
- +28 SET APCHHPV=$PIECE($$LASTHPV(APCHSPAT),U,2)
- +29 IF $$FMDIFF^XLFDT(APCHLAST,DT)<(5*365)
- IF $$FMDIFF^XLFDT(APCHLAST,DT)<(5*365)
- Begin DoDot:1
- +30 SET APCHNEXT=$$FMADD^XLFDT(APCHLAST,(5*365))
- +31 SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +32 SET APCHSTEX(2)="PAP every 3 years: Next: "_$$DATE^APCHSMU($$FMADD^XLFDT(APCHLAST,(3*365)))
- +33 SET APCHSTEX(3)="or PAP and high risk HPV test "
- +34 SET APCHSTEX(4)=" every 5 years: Next: "_$$DATE^APCHSMU(APCHNEXT)
- +35 DO PAPWT
- End DoDot:1
- QUIT
- +36 SET APCHNEXT=$$FMADD^XLFDT(APCHLAST,APCHSINT)
- +37 SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- +38 SET APCHSTEX(2)="PAP every 3 years: Next: "_$$DATE^APCHSMU(APCHNEXT)
- +39 SET APCHSTEX(3)="PAP and high risk HPV test "
- +40 SET APCHSTEX(4)=" every 5 years: Next: "_$$DATE^APCHSMU($$FMADD^XLFDT(APCHLAST,(5*365)))
- +41 DO PAPWT
- +42 QUIT
- HYSTER(P) ;EP has patient had hysterectomy?
- +1 IF '$GET(P)
- QUIT ""
- +2 ;I '$D(^AUPNVPRC("AC",P)) Q ""
- +3 NEW APCHSVDT
- +4 NEW F,S,C
- SET (F,S)=0
- FOR
- SET F=$ORDER(^AUPNVPRC("AC",P,F))
- IF F'=+F!(S)
- QUIT
- IF $DATA(^AUPNVPRC(F,0))
- SET APCHSVDT=$PIECE(+^AUPNVSIT($PIECE(^AUPNVPRC(F,0),U,3),0),".")
- SET C=$PIECE($$ICDOP^ICDEX(+^AUPNVPRC(F,0),APCHSVDT,,"I"),U,1)
- Begin DoDot:1
- +5 IF $$ICD^ATXAPI(C,$ORDER(^ATXAX("B","BGP HYSTERECTOMY PROCEDURES",0)),1)
- SET S=1
- End DoDot:1
- +6 IF S=1
- QUIT 1
- +7 ;had this dx
- IF $PIECE($$LASTDX^APCHSMU2(P,"BGP HYSTERECTOMY DXS"),U)
- QUIT 1
- +8 SET T="HYSTERECTOMY"
- SET T=$ORDER(^BWPN("B",T,0))
- +9 IF T
- Begin DoDot:1
- +10 SET X=$$WH^APCHSMU2(P,$$DOB^AUPNPAT(P),DT,T,1)
- End DoDot:1
- IF X
- QUIT 1
- +11 SET T=$ORDER(^ATXAX("B","BGP HYSTERECTOMY CPTS",0))
- +12 IF T
- Begin DoDot:1
- +13 SET X=$$CPT^APCHSMU2(P,$PIECE(^DPT(P,0),U,3),DT,T,1)
- End DoDot:1
- IF X
- QUIT 1
- +14 QUIT ""
- LASTHPV(P) ;EP
- +1 NEW APCHC,APCHLPAP,T,APCHLT,B,D,E,L,X,J,APCH
- +2 SET APCHC=""
- +3 SET APCHLPAP=""
- +4 SET BDATE=$$DOB^AUPNPAT(P)
- +5 SET EDATE=DT
- +6 SET T=$ORDER(^ATXAX("B","BGP HPV LOINC CODES",0))
- +7 SET APCHLT=$ORDER(^ATXLAB("B","BGP HPV TESTS TAX",0))
- +8 SET B=9999999-BDATE
- SET E=9999999-EDATE
- SET D=E-1
- FOR
- SET D=$ORDER(^AUPNVLAB("AE",P,D))
- IF D'=+D!(D>B)!(APCHC]"")
- QUIT
- Begin DoDot:1
- +9 SET L=0
- FOR
- SET L=$ORDER(^AUPNVLAB("AE",P,D,L))
- IF L'=+L!(APCHC]"")
- QUIT
- Begin DoDot:2
- +10 SET X=0
- FOR
- SET X=$ORDER(^AUPNVLAB("AE",P,D,L,X))
- IF X'=+X!(APCHC]"")
- QUIT
- Begin DoDot:3
- +11 IF '$DATA(^AUPNVLAB(X,0))
- QUIT
- +12 SET Z=$PIECE(^AUPNVLAB(X,0),U)
- SET Z=$PIECE($GET(^LAB(60,Z,0)),U)
- IF Z="HPV"
- SET APCHC="1^"_(9999999-D)_"^Lab"
- QUIT
- +13 IF APCHLT
- IF $PIECE(^AUPNVLAB(X,0),U)
- IF $DATA(^ATXLAB(APCHLT,21,"B",$PIECE(^AUPNVLAB(X,0),U)))
- SET APCHC="1^"_(9999999-D)_"^Lab"
- QUIT
- +14 IF 'T
- QUIT
- +15 SET J=$PIECE($GET(^AUPNVLAB(X,11)),U,13)
- IF J=""
- QUIT
- +16 IF '$$LOINC(J,T)
- QUIT
- +17 SET APCHC="1^"_(9999999-D)_"^Lab-loinc"
- QUIT
- +18 QUIT
- End DoDot:3
- End DoDot:2
- End DoDot:1
- +19 SET APCHLPAP=APCHC
- +20 KILL APCH
- +21 SET T="BGP HPV DXS"
- +22 SET X=$$LASTDXT^APCLAPIU(P,,,"BGP HPV DXS","D")
- IF X
- IF $PIECE(APCHLPAP,U,2)<X
- SET APCHLPAP="1^"_X_"^HPV POV "
- +23 SET T=$ORDER(^ATXAX("B","BGP HPV CPTS",0))
- +24 IF T
- Begin DoDot:1
- +25 SET X=$$CPT^APCHSMU2(P,BDATE,EDATE,T,5)
- IF X]""
- QUIT
- End DoDot:1
- IF X]""
- IF $PIECE(APCHLPAP,U,2)<$PIECE(X,U,1)
- SET APCHLPAP="1^"_$PIECE(X,U)_"^CPT "_$PIECE(X,U,2)
- +26 QUIT APCHLPAP
- WW ;EP - WiseWoman reminder - Mike Mosley
- +1 NEW WWSTAT,APCHLAST,APCHNEXT,APCHSTEX
- +2 IF '$$INAC^APCHSMU(APCHSITI)
- QUIT
- +3 IF APCHSEX'="F"
- QUIT
- +4 SET (APCHLAST,APCHNEXT)=""
- KILL APCHSTEX
- +5 SET APCHOVR=$$OVR^APCHSMU(APCHSPAT,APCHSITI)
- +6 SET WWSTAT=$$GET1^DIQ(9000001,APCHSPAT,1709,"I")
- +7 IF WWSTAT>1&(WWSTAT<4)
- QUIT
- +8 IF $$HASWWP(APCHSPAT)
- Begin DoDot:1
- +9 SET APCHLAST=$$WWPDT(APCHSPAT)
- +10 SET APCHNEXT=$$FMADD^XLFDT(APCHLAST,305)
- +11 IF APCHNEXT'>DT
- SET APCHSTEX(1)="MAY BE DUE NOW (WAS DUE "_$$DATE^APCHSMU(APCHNEXT)_")"
- +12 IF '$TEST
- SET APCHSTEX(1)=$$DATE^APCHSMU(APCHNEXT)
- End DoDot:1
- +13 IF '$TEST
- Begin DoDot:1
- +14 IF APCHSAGE>29&(APCHSAGE<65)
- SET APCHSTEX(1)="MAY BE DUE NOW"
- End DoDot:1
- +15 IF $DATA(APCHSTEX)
- DO WRITE^APCHSMU
- +16 XECUTE APCHSURX
- +17 QUIT
- WWPDT(DFN) ;
- +1 NEW IEN,PDT,WWP
- +2 SET PDT=0
- +3 IF '$GET(DFN)
- QUIT PDT
- +4 SET PDT=0
- SET IEN=$CHAR(1)
- FOR
- SET IEN=$ORDER(^BWPCD("C",DFN,IEN),-1)
- IF 'IEN!PDT
- QUIT
- Begin DoDot:1
- +5 SET WWP=$$GET1^DIQ(9002086.1,IEN,4.01,"I")
- +6 IF WWP=1!(WWP=2)
- SET PDT=$$GET1^DIQ(9002086.1,IEN,4.02,"I")
- End DoDot:1
- +7 QUIT PDT
- +8 ;
- HASWWP(DFN) ;
- +1 NEW IEN,FLG
- +2 SET (FLG,IEN)=0
- FOR
- SET IEN=$ORDER(^BWPCD("C",DFN,IEN))
IF 'IEN!FLG
QUIT
Begin DoDot:1
+3 IF $$GET1^DIQ(9002086.1,IEN,4.01,"I")=1
SET FLG=1
End DoDot:1
+4 QUIT FLG
PAPDAYS(P) ;PEP - called from WH to return # of days
+1 ; from last pap until this patient's next pap is due
+2 ; 0 = clinical discretion (had hysterectomy)
+3 ; -1 = patient not eligible for this reminder
+4 ; return = # days
+5 IF '$GET(P)
QUIT -1
+6 ;is patient eligible for this reminder per specifications in hmr file?
+7 NEW APCHSITI,APCHSCRI,G
+8 SET APCHSITI=$ORDER(^APCHSURV("B","PAP SMEAR",0))
+9 SET APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
+10 ;if hysterectomy then clinical discretion
IF $$HYSTER(P)
QUIT 0
+11 IF 'APCHSCRI
Begin DoDot:1
+12 SET G=-1
+13 IF $$AGE^AUPNPAT(P,DT)<18
QUIT
+14 SET G=(3*365)
End DoDot:1
QUIT G
+15 SET G=$$AGESEX^APCHSMU(APCHSITI,P)
SET G=$PIECE(G,".")
+16 IF 'G
QUIT -1
+17 QUIT G
MAMDAYS(P) ;PEP - called from WH to return # of days
+1 ; from last mammogram that the next one is due
+2 ; -1 = patient not eligible for this reminder
+3 ; return = # days
+4 IF '$GET(P)
QUIT -1
+5 ;is patient eligible for this reminder per specifications in hmr file?
+6 NEW APCHSITI,APCHSCRI,G
+7 SET APCHSITI=$ORDER(^APCHSURV("B","MAMMOGRAM",0))
+8 SET APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
+9 IF 'APCHSCRI
Begin DoDot:1
+10 SET G=-1
+11 IF $$AGE^AUPNPAT(P,DT)<50
QUIT
+12 IF $$AGE^AUPNPAT(P,DT)>69
QUIT
+13 SET G=365
End DoDot:1
QUIT G
+14 SET G=$$AGESEX^APCHSMU(APCHSITI,P)
SET G=$PIECE(G,".")
+15 IF 'G
QUIT -1
+16 QUIT G
LOINC(A,B) ;
+1 NEW %
+2 SET %=$PIECE($GET(^LAB(95.3,A,9999999)),U,2)
+3 IF %]""
IF $DATA(^ATXAX(B,21,"B",%))
QUIT 1
+4 SET %=$PIECE($GET(^LAB(95.3,A,0)),U)_"-"_$PIECE($GET(^LAB(95.3,A,0)),U,15)
+5 IF $DATA(^ATXAX(B,21,"B",%))
QUIT 1
+6 QUIT ""