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

APCLCH1P.m

Go to the documentation of this file.
APCLCH1P ; IHS/CMI/LAB - community health profile print ;
 ;;2.0;IHS PCC SUITE;**7,10,11**;MAY 14, 2009;Build 58
 ;
 ;cmi/anch/maw 9/10/2007 code set versioning in TOP15ODX, TOP15IDX, SURGPROC
 ;
START ;
 S APCLPG=0
 I '$D(^XTMP("APCLCH1",APCLJOB,APCLBTH)) W !!,"NO DATA TO REPORT" G DONE
 D PRN
DONE ;
 D DONE^APCLOSUT
 K ^XTMP("APCLCH1",APCLJOB,APCLBTH)
 Q
PRN ;
 S APCLCOM="" F  S APCLCOM=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM)) Q:APCLCOM=""!($D(APCLQUIT))  D PRINT
 Q
PRINT ;
 D HEAD Q:$D(APCLQUIT)
 W !?5,"There are ",^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"LIVREG")," living patients registered at ",$P(^DIC(4,DUZ(2),0),U),"."
 W !?5,^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"HADHC")," received health care services during this time period."
 I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)
 W !?5,^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"MCRA")," are currently enrolled in Medicare Part A; "
 W ^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"MCRB")," in Medicare Part B; "
 W !?5,^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"MCD")," in Medicaid; and "
 W ^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"PI")," have Private Insurance.",!
 I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)
 W !?5,"There were ",^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"BIRTHS")," births and ",^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"DEATHS")," deaths during this period.",!
AGEDIST ;
 I $Y>(IOSL-7) D HEAD Q:$D(APCLQUIT)
 W !?30,"AGE/SEX Distribution as of ",$$FMTE^XLFDT(APCLED),!
 S T=9 F I=1:1 S J=$P(APCLAGEP,";",I) Q:J=""  W ?T,J S T=T+6
 W !?9,$TR($J("",70)," ","-")
 W !?2,"MALE" S T=9 F I=1:1 S J=$P(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST","M"),U,I) Q:J=""  W ?T,$J(J,5) S T=T+6
 W !,"FEMALE" S T=9 F I=1:1 S J=$P(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST","F"),U,I) Q:J=""  W ?T,$J(J,5) S T=T+6
 W !,"UNKNOWN" S T=9 F I=1:1 S J=$P($G(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST","U")),U,I) Q:J=""  W ?T,$J(J,5) S T=T+6
 W !?1,"TOTAL"
 S T=9
 F I=1:1 S J=$P(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST","F"),U,I) Q:J=""  D
 .S J=J+$P(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST","M"),U,I)+$P($G(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST","U")),U,I) W ?T,$J(J,5) S T=T+6
TOP15ODX ;
 I $Y>(IOSL-6) D HEAD Q:$D(APCLQUIT)
 W !!!?5,"The Top 15 Purposes of Direct and Contract Outpatient Visits were:",!
 W ?15,"Both Primary and Secondary Diagnoses are included",!
 W !?5,APCLCOM,?43,$E($P(^AUTTSU(APCLSU,0),U),1,25)," Service Unit",!
 W ?5,$TR($J("",$L(APCLCOM))," ","-"),?43,$TR($J("",35)," ","-"),!
 K APCLR S (APCLX,C)=0 F  S APCLX=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","OUTDXC",APCLX)) Q:APCLX=""!(C>15)!($D(APCLQUIT))  D
 .S APCLY=0 F  S APCLY=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","OUTDXC",APCLX,APCLY)) Q:APCLY'=+APCLY  D
 ..;S C=C+1,APCLR(C)=$E($P(^ICD9(APCLY,0),U,3),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","OUTDXC",APCLX,APCLY)  ;cmi/anch/maw 9/10/2007 orig line
 ..S C=C+1,APCLR(C)=$E($P($$ICDDX^ICDEX(APCLY),U,4),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","OUTDXC",APCLX,APCLY)  ;cmi/anch/maw 9/10/2007 code set versioning
 K APCLS S (APCLX,C)=0 F  S APCLX=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","OUTDXC",APCLX)) Q:APCLX=""!(C>15)!($D(APCLQUIT))  D
 .;S APCLY=0 F  S APCLY=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","OUTDXC",APCLX,APCLY)) Q:APCLY'=+APCLY  S C=C+1,APCLS(C)=$E($P(^ICD9(APCLY,0),U,3),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","OUTDXC",APCLX,APCLY)  ;cmi/anch/maw orig line
 .S APCLY=0 F  S APCLY=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","OUTDXC",APCLX,APCLY)) Q:APCLY'=+APCLY  S C=C+1,APCLS(C)=$E($P($$ICDDX^ICDEX(APCLY),U,4),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","OUTDXC",APCLX,APCLY)  ;cmi/anch/maw csv
 S (APCLX,APCLC)=0 F  S APCLX=$O(APCLR(APCLX)) Q:APCLX'=+APCLX!($D(APCLQUIT))  D
 .I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)  W !,"Top 15 outpatient purpose of visits (cont.)",!
  .W !?5,$P(APCLR(APCLX),U),?33,"(",$P(APCLR(APCLX),U,2),")" S APCLC=APCLX I $D(APCLS(APCLX)) W ?43,$P(APCLS(APCLX),U),?70,"(",$P(APCLS(APCLX),U,2),")"
 S APCLX=C F  S APCLX=$O(APCLS(APCLX)) Q:APCLX'=+APCLX!($D(APCLQUIT))  D
 .I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)  W !,"Top 15 outpatient purpose of visits (cont.)",!
 .W !?43,$P(APCLS(APCLX),U),?70,"(",$P(APCLS(APCLX),U,2),")"
TOP15IDX ;
 I $Y>(IOSL-6) D HEAD Q:$D(APCLQUIT)
 W !!!?5,"The Top 15 Inpatient Diagnoses were:",!
 W !?5,APCLCOM,?43,$E($P(^AUTTSU(APCLSU,0),U),1,25)," Service Unit",!
 W ?5,$TR($J("",$L(APCLCOM))," ","-"),?43,$TR($J("",33)," ","-"),!
 K APCLR S (APCLX,C)=0 F  S APCLX=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","INDXC",APCLX)) Q:APCLX=""!(C>15)!($D(APCLQUIT))!($D(APCLQUIT))  D
 .S APCLY=0 F  S APCLY=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","INDXC",APCLX,APCLY)) Q:APCLY'=+APCLY  D
  ..;S C=C+1,APCLR(C)=$E($P(^ICD9(APCLY,0),U,3),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","INDXC",APCLX,APCLY)  ;cmi/anch/maw 9/10/2007 orig line
  ..S C=C+1,APCLR(C)=$E($P($$ICDDX^ICDEX(APCLY),U,4),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","INDXC",APCLX,APCLY)  ;cmi/anch/maw 9/10/2007 csv
 K APCLS S (APCLX,C)=0 F  S APCLX=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","INDXC",APCLX)) Q:APCLX=""!(C>15)!($D(APCLQUIT))  D
 .;S APCLY=0 F  S APCLY=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","INDXC",APCLX,APCLY)) Q:APCLY'=+APCLY  S C=C+1,APCLS(C)=$E($P(^ICD9(APCLY,0),U,3),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","INDXC",APCLX,APCLY)  ;cmi/anch/maw orig line
 .S APCLY=0 F  S APCLY=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","INDXC",APCLX,APCLY)) Q:APCLY'=+APCLY  S C=C+1,APCLS(C)=$E($P($$ICDDX^ICDEX(APCLY),U,4),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","INDXC",APCLX,APCLY)  ;cmi/anch/maw csv
 S (APCLX,APCLC)=0 F  S APCLX=$O(APCLR(APCLX)) Q:APCLX'=+APCLX!($D(APCLQUIT))  D
 .I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)  W !,"Top 15 inpatient diagnoses (cont.)",!
  .W !?5,$P(APCLR(APCLX),U),?33,"(",$P(APCLR(APCLX),U,2),")" S APCLC=APCLX I $D(APCLS(APCLX)) W ?43,$P(APCLS(APCLX),U),?70,"(",$P(APCLS(APCLX),U,2),")"
 S APCLX=C F  S APCLX=$O(APCLS(APCLX)) Q:APCLX'=+APCLX!($D(APCLQUIT))  D
 .I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)  W !,"Top 15 inpatient diagnoses (cont.)",!
 .W !?43,$P(APCLS(APCLX),U),?70,"(",$P(APCLS(APCLX),U,2),")"
SURGPROC ;
 I $Y>(IOSL-6) D HEAD Q:$D(APCLQUIT)
 W !!!?5,"The Leading Surgical Procedures were:",!
 W !?5,APCLCOM,?43,$E($P(^AUTTSU(APCLSU,0),U),1,25)," Service Unit",!
 W ?5,$TR($J("",$L(APCLCOM))," ","-"),?43,$TR($J("",33)," ","-"),!
 K APCLR S (APCLX,C)=0 F  S APCLX=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","SURG PROCC",APCLX)) Q:APCLX=""!(C>15)!($D(APCLQUIT))  D
 .S APCLY=0 F  S APCLY=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","SURG PROCC",APCLX,APCLY)) Q:APCLY'=+APCLY  D
 ..;S C=C+1,APCLR(C)=$E($P(^ICD0(APCLY,0),U,4),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","SURG PROCC",APCLX,APCLY)  ;cmi/anch/maw 9/12/2007 orig line
 ..S C=C+1,APCLR(C)=$E($P($$ICDOP^ICDEX(APCLY,,,"I"),U,5),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","SURG PROCC",APCLX,APCLY)  ;cmi/anch/maw 9/12/2007 csv
 K APCLS S (APCLX,C)=0 F  S APCLX=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","SURG PROCC",APCLX)) Q:APCLX=""!(C>15)!($D(APCLQUIT))  D
 .;S APCLY=0 F  S APCLY=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","SURG PROCC",APCLX,APCLY)) Q:APCLY'=+APCLY  S C=C+1,APCLS(C)=$E($P(^ICD0(APCLY,0),U,4),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","SURG PROCC",APCLX,APCLY)  ;cmi/maw orig
 .S APCLY=0 F  S APCLY=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","SURG PROCC",APCLX,APCLY)) Q:APCLY'=+APCLY  S C=C+1,APCLS(C)=$E($P($$ICDOP^ICDEX(APCLY,,,"I"),U,5),1,25)_"^"_^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","SURG PROCC",APCLX,APCLY)  ;maw csv
 S (APCLX,APCLC)=0 F  S APCLX=$O(APCLR(APCLX)) Q:APCLX'=+APCLX!($D(APCLQUIT))  D
 .I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)  W !,"Top 15 surgical procedures (cont.)",!
  .W !?5,$P(APCLR(APCLX),U),?33,"(",$P(APCLR(APCLX),U,2),")" S APCLC=APCLX I $D(APCLS(APCLX)) W ?43,$P(APCLS(APCLX),U),?70,"(",$P(APCLS(APCLX),U,2),")"
 S APCLX=C F  S APCLX=$O(APCLS(APCLX)) Q:APCLX'=+APCLX!($D(APCLQUIT))  D
 .I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)  W !,"Top 15 surgical procedures (cont.)",!
 .W !?43,$P(APCLS(APCLX),U),?70,"(",$P(APCLS(APCLX),U,2),")"
 D EN^APCLCH1S
 Q:$D(APCLQUIT)
 W !!,"End of Report.  This report is based on visit data processed on the ",!,$P(^DIC(4,DUZ(2),0),U)," computer.",!
 Q
 G:'APCLPG HEAD1
 K DIR I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S APCLQUIT="" Q
HEAD1 ;
 W:$D(IOF) @IOF S APCLPG=APCLPG+1
 W !?3,$P(^VA(200,DUZ,0),U,2),?58,$$FMTE^XLFDT(DT),?72,"Page ",APCLPG,!
 W ?21,"*****  COMMUNITY HEALTH PROFILE  *****",!
 W ?25,$$FMTE^XLFDT(APCLBD),"  to  ",$$FMTE^XLFDT(APCLED),!
 I $G(APCLSEAT) W $$CJ^XLFSTR("Search Template of Patients Used: "_$P(^DIBT(APCLSEAT,0),U,1),80),!
 W ?(80-$L(APCLCOM))/2,APCLCOM,!
 Q