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

APCHSM02.m

Go to the documentation of this file.
APCHSM02 ; IHS/CMI/LAB -- CONTINUATION OF ROUTINES ;
 ;;2.0;IHS PCC SUITE;**2,7,11,16**;MAY 14, 2009;Build 9
 ;
 ; ******************** SURVEILLANCE - HARD CODE ********************
S(X) ;
 NEW %,C S (C,%)=0 F  S %=$O(APCHSTEX(%)) Q:%'=+%  S C=C+1
 S APCHSTEX(C+1)=X
 Q
SIGMOID ;EP
 G SIGMOID^APCHSM07
 ;
CHOL ;
 X APCHSURX
 Q:'$$INAC^APCHSMU(APCHSITI)  ;is item turned on or off
 S APCHSINT="",APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
 I APCHSCRI S APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT),APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
 I 'APCHSCRI D
 .Q:APCHSAGE>64
 .I APCHSEX="M",APCHSAGE<35 Q
 .I APCHSEX="F",APCHSAGE<45 Q
 .S APCHSINT=(5*365)
 .I APCHSEX="F" S APCHMIN=35
 .I APCHSEX="M" S APCHMIN=45
 S APCHLAST="",APCHNEXT="" K APCHSTEX
 S APCHTAXN=$O(^ATXLAB("B","DM AUDIT CHOLESTEROL TAX",0))
 I APCHSINT,APCHTAXN="" S APCHSTEX(1)="DM AUDIT CHOLESTEROL TAX Taxonomy Missing" D WRITE^APCHSMU X APCHSURX Q
 S APCHICAR=$$LASTCHOL^APCLAPI3(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)
 .D REF
 .D WRITE^APCHSMU
 .X APCHSURX
 .Q
CHOLREG ;regular stuff
 I APCHSINT="" X APCHSURX Q  ;no frequency so skip it
 I APCHLAST="" S APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN)) D  Q
 .D REF
 .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)
 D REF
 D WRITE^APCHSMU
 X APCHSURX
 Q
 ;
GLUCOSE ;EP
 ;add v77.1 as a hit 
 X APCHSURX
 Q:'$$INAC^APCHSMU(APCHSITI)  ;is item turned on or off
 I $$SITECRIT^APCHSMU(APCHSITI) D GLUCSITE Q
 Q:$$AGE^AUPNPAT(APCHSPAT,DT)<18
 S APCHSINT=(3*365)
 S APCHMIN=18
 D GLUCDEF
 Q
GLUCSITE ;
 S APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT),APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT) ;return in APCHSINT the frequency in days for this age/sex
 D GLUCDEF
 Q
GLUCDEF ;
 S APCHLAST="",APCHNEXT="" K APCHSTEX
 S APCHTAXN=$O(^ATXLAB("B","DM AUDIT GLUCOSE TESTS TAX",0))
 I APCHSINT,APCHTAXN="" S APCHSTEX(1)="DM AUDIT GLUCOSE TESTS TAX Taxonomy Missing" D WRITE^APCHSMU X APCHSURX Q
 S APCHICAR=$$LASTGLUC^APCLAPI3(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)
 .D REF
 .D WRITE^APCHSMU
 .X APCHSURX
 .Q
GLUCOSER ;
 I APCHSINT="" X APCHSURX Q  ;no frequency so skip it
 I $$PLTAX^APCHSMU(APCHSPAT,"SURVEILLANCE DIABETES") X APCHSURX Q  ;cancel if DM is on Problem List
 I $$IPLSNO^APCHSMU1(APCHSPAT,"PXRM DIABETES") X APCHSURX Q  ;cancel if pt has snomed htn on pl
 I APCHLAST="" S APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN)) D  Q
 .D REF
 .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)
 D REF
 D WRITE^APCHSMU
 X APCHSURX
 Q
 ;
FECAL ;EP - called from reminders
 X APCHSURX
 Q:'$$INAC^APCHSMU(APCHSITI)  ;is item turned on or off
 I $$PLTAX^APCHSMU(APCHSPAT,"BGP COLORECTAL CANCER DXS") X APCHSURX Q  ;cancel if cancer on pl
 S APCHSINT="",APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
 I APCHSCRI S APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT),APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
 I 'APCHSCRI D
 .Q:APCHSAGE<50
 .Q:APCHSAGE>75
 .S APCHSINT=(1*365)
 .S APCHMIN=50
 S APCHLAST="",APCHNEXT="" K APCHSTEX
 S APCHTAXN=$O(^ATXLAB("B","BGP GPRA FOB TESTS",0))
 I APCHSINT,APCHTAXN="" S APCHSTEX(1)="BGP GPRA FOB TESTS Taxonomy Missing" D WRITE^APCHSMU X APCHSURX Q
 I APCHSINT,'$O(^ATXLAB(APCHTAXN,21,0)) S APCHSTEX(1)="BGP GPRA FOB TESTS Taxonomy Missing" D WRITE^APCHSMU X APCHSURX Q
 S APCHICAR=$$LASTFOBT^APCLAPI3(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)
 .D REF
 .D WRITE^APCHSMU
 .X APCHSURX
 .Q
FECALREG ;
 I APCHSINT="" X APCHSURX Q  ;no frequency so skip it
 I $$PLTAX^APCHSMU(APCHSPAT,"BGP COLORECTAL CANCER DXS") X APCHSURX Q  ;cancel if cancer on pl
 I $$IPLSNO^APCHSMU1(APCHSPAT,"PXRM COLORECTAL CANCER") X APCHSURX Q
 ;<=== * * * Gary's mod starts here
 ;S APCHSLBE=$$LASTBE^APCLAPI4(APCHSPAT) I $G(APCHSLBE)]"",$$FMDIFF^XLFDT(DT,APCHSLBE)<365 S APCHSTEX(1)="N/A...BARIUM ENEMA "_$$FMTE^XLFDT(APCHSLBE) D  Q
 ;.D REF
 ;.D WRITE^APCHSMU
 ;.X APCHSURX
 ;.Q
 S APCHSLCO=$P($$LASTCOLO^APCLAPI(APCHSPAT),U,1) I $G(APCHSLCO)]"",$$FMDIFF^XLFDT(DT,APCHSLCO)<3650 S APCHSTEX(1)="N/A...COLONOSCOPY "_$$FMTE^XLFDT(APCHSLCO) D  Q
 .D REF
 .D WRITE^APCHSMU
 .X APCHSURX
 .Q
 S APCHSLSI=$P($$LASTFSIG^APCLAPI(APCHSPAT),U,1) I $G(APCHSLSI)]"",$$FMDIFF^XLFDT(DT,APCHSLSI)<(5*365) S APCHSTEX(1)="N/A...SIGMOIDOSCOPY "_$$FMTE^XLFDT(APCHSLSI) D  Q
 .D REF
 .D WRITE^APCHSMU
 .X APCHSURX
 .Q
 ;<==== * * * end of Gary's mod
 I APCHLAST="" S APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN)) D  Q
 .D REF
 .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)
 D REF
 D WRITE^APCHSMU
 X APCHSURX
 Q
 ;
HH ;
 X APCHSURX
 Q:'$$INAC^APCHSMU(APCHSITI)  ;is item turned on or off
 S APCHSINT="",APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
 I APCHSCRI S APCHSINT=$$AGESEX^APCHSMU(APCHSITI,APCHSPAT),APCHMIN=$$MINAGE^APCHSMU(APCHSITI,APCHSPAT)
 I 'APCHSCRI D
 .Q:APCHSAGE>10
 .S APCHSINT=365
 .S APCHSMIN=1
 S APCHLAST="",APCHNEXT="" K APCHSTEX
 S APCHTAXN=$O(^ATXLAB("B","APCH HCT/HGB TESTS",0))
 I APCHSINT,APCHTAXN="" S APCHSTEX(1)="APCH HCT/HGB TESTS Taxonomy Missing" D WRITE^APCHSMU X APCHSURX Q
 I APCHSINT,'$O(^ATXLAB(APCHTAXN,21,0)) S APCHSTEX(1)="APCH HCT/HGB TESTS Taxonomy Missing" D WRITE^APCHSMU X APCHSURX Q
 ;S APCHLAST=$$LASTLAB^APCHSMU(APCHSPAT,,$O(^ATXLAB("B","APCH HCT/HGB TESTS",0)))
 S APCHICAR=$$LASTLAB^APCLAPIU(APCHSPAT,,,,$O(^ATXLAB("B","APCH HCT/HGB TESTS",0)),,,"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 REF
 .D WRITE^APCHSMU
 .X APCHSURX
 .Q
HHREG ;
 I APCHSINT="" X APCHSURX Q
 I 'APCHSCRI D IHSHH Q
 I APCHLAST="" S APCHSTEX(1)=$$DATE^APCHSMU($$DATEAGE^APCHSMU(APCHSPAT,APCHMIN)) D  Q
 .D REF
 .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)
 D REF
 D WRITE^APCHSMU
 X APCHSURX
 Q
 ;
IHSHH ;
 Q:APCHSAGE>10
 I APCHLAST="",APCHSAGE<1 S APCHSTEX(1)=$$DATE^APCHSMU($$FMADD^XLFDT(APCHSDOB,365)) D REF,WRITE^APCHSMU X APCHSURX Q
 I APCHLAST="",APCHSAGE>0,APCHSAGE<4 S APCHSTEX(1)=$$DATE^APCHSMU($$FMADD^XLFDT(APCHSDOB,365)) D REF,WRITE^APCHSMU X APCHSURX Q
 I APCHLAST="",APCHSAGE>3 S APCHSTEX(1)=$$DATE^APCHSMU($$FMADD^XLFDT(APCHSDOB,(365*4))) D REF,WRITE^APCHSMU X APCHSURX Q
 S APCHSOLD=$$FMDIFF^XLFDT(APCHLAST,APCHSDOB)
 I APCHSAGE<1,APCHSOLD'>(9*30.5) S APCHSTEX(1)=$$DATE^APCHSMU($$FMADD^XLFDT(APCHSDOB,365)) D REF,WRITE^APCHSMU X APCHSURX Q
 I APCHSAGE>0,APCHSAGE<4,APCHSOLD<(9*30.5) S APCHSTEX(1)=$$DATE^APCHSMU($$FMADD^XLFDT(APCHSDOB,365)) D REF,WRITE^APCHSMU X APCHSURX Q
 I APCHSAGE>3,APCHSOLD<(3*365) S APCHSTEX(1)=$$DATE^APCHSMU($$FMADD^XLFDT(APCHSDOB,(4*365))) D REF,WRITE^APCHSMU X APCHSURX Q
 Q
REF ;EP
 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
 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
DEPOWT ;
 K APCHV
 S V=$$REF^APCHSMU(APCHSPAT,9999999.15,$O(^AUTTEXAM("C","35",0)),APCHLAST)
 I V]"" S X=$P(V,U,3) S APCHV((9999999-X))=$P(V,U,1,2)
 ;now look at AMHREC field
 S APCHC=0,V=""
 S E=9999999-APCHLAST,D=9999999-DT-1_".99" F  S D=$O(^AMHREC("AE",APCHSPAT,D)) Q:D'=+D!($P(D,".")>E)  S V=0 F  S V=$O(^AMHREC("AE",APCHSPAT,D,V)) Q:V'=+V  D
 .S X=$P($G(^AMHREC(V,14)),U,3)
 .I X="" Q  ;no test
 .I $E(X)="U" S APCHV(D)="Unable to Screen DEPRESSION SCREENING ",$P(APCHV(D),U,2)="on "_$$FMTE^XLFDT((9999999-$P(D,".")))
 .I X="REF" S APCHV(D)="Patient Declined DEPRESSION SCREENING ",$P(APCHV(D),U,2)="on "_$$FMTE^XLFDT((9999999-$P(D,".")))
 .Q
 I $O(APCHV(0)) S Y=$O(APCHV(0)) S Z=9999999-Y I Z>APCHLAST S X=$P(APCHV(Y),U) D S(X) S X=$P(APCHV(Y),U,2) I X]"" D S(X)
 D WRITE^APCHSMU
 X APCHSURX
 Q
DEPRESS ;EP - depression screening
 Q:'$$INAC^APCHSMU(APCHSITI)  ;is item turned on or off
 Q:$$LASTDXT^APCLAPIU(APCHSPAT,$$FMADD^XLFDT(DT,-365),DT,"BGP MOOD DISORDERS")
 S APCHLAST="",APCHNEXT="" K APCHSTEX
 S APCHICAR=$$LASTDEPS^APCLAPI(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)
 .D WRITE^APCHSMU
 .X APCHSURX
 .Q
DEPREG ;regular stuff
 S APCHSINT="",APCHSCRI=$$SITECRIT^APCHSMU(APCHSITI)
 I 'APCHSCRI,APCHSAGE>17 S APCHSINT=365,APCHMIN=18
 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 DEPOWT 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 DEPOWT
 Q