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

APCLCH11.m

Go to the documentation of this file.
APCLCH11 ; IHS/CMI/LAB - community health profile ;
 ;;2.0;IHS PCC SUITE;**7**;MAY 14, 2009
 ;IHS/CMI/LAB - Y2K patch 4
 ;
 ;
START ;
 S APCLBT=$H
 S APCLAGER="0-4;5-9;10-19;20-29;30-39;40-49;50-59;60-69;70-79;80 +;TOTAL"
 S APCLAGEP=" 0-4 ; 5-9 ;10-19;20-29;30-39;40-49;50-59;60-69;70-79;80 +;TOTAL"
 ;table service unit communities
 S X=0 F  S X=$O(^AUTTCOM(X)) Q:X'=+X  I $P(^AUTTCOM(X,0),U,5)=APCLSU S ^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU COMM",X)=""
POP ;community health profile
PAT S APCLDFN=0 F  S APCLDFN=$O(^AUPNPAT(APCLDFN)) Q:APCLDFN'=+APCLDFN  I $D(^DPT(APCLDFN)),$D(^AUPNPAT(APCLDFN,0)),'$P(^DPT(APCLDFN,0),U,19) D KILL^AUPNPAT S Y=APCLDFN D ^AUPNPAT D PROC
 D SET^APCLCH1
 S APCLET=$H
 Q
PROC ;
 Q:'$D(^AUPNPAT(APCLDFN,41,DUZ(2)))  ;no chart at this facility
 I $G(APCLSEAT) Q:'$D(^DIBT(APCLSEAT,1,APCLDFN))
 Q:$$DEMO^APCLUTL(APCLDFN,$G(APCLDEMO))
 I $G(AUPNDOD)]"",AUPNDOD'>APCLBD Q  ;died before time frame
 Q:APCLED<$$DOB^AUPNPAT(APCLDFN)
 S (APCLLCOM,APCLSCOM)=0
 S APCLCOM=$$COMMRES^AUPNPAT(APCLDFN,"E"),APCLCOMI=$$COMMRES^AUPNPAT(APCLDFN,"I")
 Q:APCLCOM=""
 Q:APCLCOM=-1
 I $D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"COMMUNITIES",APCLCOM)) S APCLLCOM=1
 I $D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU COMM",APCLCOMI)) S APCLSCOM=1
 I APCLLCOM D  I 1
 .D SETV^APCLCH1S
 .D LIVREG
 .D DEATHS
 .D BIRTHS
 .D THIRD
 .D AGEDIST
V ;
 I 'APCLLCOM,'APCLSCOM Q  ;not in either communities selected or su
 D INOUTDX
 D SURGPROC
 D DENTAL
 K ^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP")
 Q
LIVREG ;
 S ^("LIVREG")=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"LIVREG")):(+^("LIVREG")+1),1:1)
 Q
 ;
 ;
HADHC ;did the pt have a visit during time frame - count all except Events
 K APCLCH1Y,APCLX,APCLY,APCLER
 ;begin y2k
 ;S APCLX=APCLDFN_"^LAST 50 VISITS ;DURING "_$$FMTE^XLFDT(APCLBD,"2D")_"-"_$$FMTE^XLFDT(APCLED,"2D") S APCLER=$$START1^APCLDF(APCLX,"APCLCH1Y(") ;Y2000
 S APCLX=APCLDFN_"^LAST 50 VISITS ;DURING "_$$FMTE^XLFDT(APCLBD,"5D")_"-"_$$FMTE^XLFDT(APCLED,"5D") S APCLER=$$START1^APCLDF(APCLX,"APCLCH1Y(") ;Y2000
 ;end Y2K
 Q:'$D(APCLCH1Y)
 ;GO THROUGH VISITS AND FIND ONE THAT IS NOT AN E, NOT DELETED OR NO DEP ENTRIES
 S (X,H)=0 F  S X=$O(APCLCH1Y(X)) Q:X'=+X!(H)  I $P(APCLCH1Y(X),U,5),$P(^AUPNVSIT($P(APCLCH1Y(X),U,5),0),U,7)'="E",$P(^(0),U,9),'$P(^(0),U,11),$D(^AUPNVPOV("AD",$P(APCLCH1Y(X),U,5))) S H=1
 I H S ^("HADHC")=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"HADHC")):(+^("HADHC")+1),1:1)
 K H,APCLCH1Y,APCLER,APCLX,APCLY,X
 Q
BIRTHS ;
 S DOB=$P(^DPT(APCLDFN,0),U,3)
 Q:DOB=""
 I DOB'<APCLBD,DOB'>APCLED S ^("BIRTHS")=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"BIRTHS")):(+^("BIRTHS")+1),1:1)
 Q
DEATHS ;
 Q:$G(AUPNDOD)=""
 I AUPNDOD'<APCLBD,AUPNDOD'>APCLED S ^("DEATHS")=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"DEATHS")):(+^("DEATHS")+1),1:1)
 Q
AGEDIST ;
 S A=$$AGE^AUPNPAT(DFN,APCLED)
 I A=-1!(A="")!(AUPNSEX="") Q  ;can't use if no sex or DOB/age
 F I=1:1:10 I A'<+$P(APCLAGER,";",I) S T=I
 S $P(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST",AUPNSEX),U,T)=$P(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST",AUPNSEX),U,T)+1
 S $P(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST",AUPNSEX),U,11)=$P(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"AGE DIST",AUPNSEX),U,11)+1
 Q
INOUTDX ;tally inpt and outp dx for su/report
 ;get all visits in time frame for patient
 K ^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP"),APCLY,APCLX
 ;begin Y2K
 ;S APCLY="^XTMP(""APCLCH1"",APCLJOB,APCLBTH,""RP"",APCLCOM,""TEMP"",",APCLX=APCLDFN_"^ALL DIAGNOSIS;DURING "_$$FMTE^XLFDT(APCLBD,"2D")_"-"_$$FMTE^XLFDT(APCLED,"2D") ;Y2000
 S APCLY="^XTMP(""APCLCH1"",APCLJOB,APCLBTH,""RP"",APCLCOM,""TEMP"",",APCLX=APCLDFN_"^ALL DIAGNOSIS;DURING "_$$FMTE^XLFDT(APCLBD,"5D")_"-"_$$FMTE^XLFDT(APCLED,"5D") ;Y2000
 ;end Y2K
 S APCLER=$$START1^APCLDF(APCLX,APCLY)
 Q:'$D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP"))  ;no dxs
 ;go through visits - ignore del/0dep tally
 I APCLLCOM S ^("HADHC")=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"HADHC")):(+^("HADHC")+1),1:1)
 S X=0 F  S X=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP",X)) Q:X'=+X  D
 .S R=^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP",X)
 .S P=+$P(R,U,4),Q=$P(^AUPNVPOV(P,0),U)
 .I $$SC^APCLV($P(R,U,5),"I")="H",APCLLCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","INDX",Q)):^(Q)+1,1:1)
 .I $$SC^APCLV($P(R,U,5),"I")="H",APCLSCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","INDX",Q)):^(Q)+1,1:1)
 .I "AORS"[$$SC^APCLV($P(R,U,5),"I"),APCLLCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","OUTDX",Q)):^(Q)+1,1:1)
 .I "AORS"[$$SC^APCLV($P(R,U,5),"I"),APCLSCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","OUTDX",Q)):^(Q)+1,1:1)
INJ ;
 S X=0 F  S X=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP",X)) Q:X'=+X  D
 .S R=^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP",X)
 .S P=+$P(R,U,4),Q=$P(^AUPNVPOV(P,0),U,9)
 .Q:Q=""
 .I APCLLCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","INJ",Q)):^(Q)+1,1:1)
 .I APCLSCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","INJ",Q)):^(Q)+1,1:1)
 Q
SURGPROC  ;
 K ^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP"),APCLY,APCLX
 ;begin Y2K
 ;S APCLY="^XTMP(""APCLCH1"",APCLJOB,APCLBTH,""RP"",APCLCOM,""TEMP"",",APCLX=APCLDFN_"^ALL PROCEDURES;DURING "_$$FMTE^XLFDT(APCLBD,"2D")_"-"_$$FMTE^XLFDT(APCLED,"2D") ;Y2000
 S APCLY="^XTMP(""APCLCH1"",APCLJOB,APCLBTH,""RP"",APCLCOM,""TEMP"",",APCLX=APCLDFN_"^ALL PROCEDURES;DURING "_$$FMTE^XLFDT(APCLBD,"5D")_"-"_$$FMTE^XLFDT(APCLED,"5D") ;Y2000
 ;end Y2K
 S APCLER=$$START1^APCLDF(APCLX,APCLY)
 Q:'$D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP"))  ;no dxs
 ;go through visits - ignore del/0dep tally
 S X=0 F  S X=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP",X)) Q:X'=+X  D
 .S R=^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP",X)
 .S P=+$P(R,U,4),Q=$P(^AUPNVPRC(P,0),U)
 .I APCLLCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","SURG PROC",Q)):^(Q)+1,1:1)
 .I APCLSCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","SURG PROC",Q)):^(Q)+1,1:1)
 .Q
 Q
DENTAL ;
 K ^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP"),APCLY,APCLX
 ;begin Y2K
 ;S APCLY="^XTMP(""APCLCH1"",APCLJOB,APCLBTH,""RP"",APCLCOM,""TEMP"",",APCLX=APCLDFN_"^ALL ADA;DURING "_$$FMTE^XLFDT(APCLBD,"2D")_"-"_$$FMTE^XLFDT(APCLED,"2D") ;Y2000
 S APCLY="^XTMP(""APCLCH1"",APCLJOB,APCLBTH,""RP"",APCLCOM,""TEMP"",",APCLX=APCLDFN_"^ALL ADA;DURING "_$$FMTE^XLFDT(APCLBD,"5D")_"-"_$$FMTE^XLFDT(APCLED,"5D") ;Y2000
 ;end Y2K
 S APCLER=$$START1^APCLDF(APCLX,APCLY)
 Q:'$D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP"))  ;no dxs
 S X=0 F  S X=$O(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP",X)) Q:X'=+X  D
 .S R=^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"TEMP",X)
 .S P=+$P(R,U,4),Q=$P(^AUPNVDEN(P,0),U)
 .I APCLLCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"REPORT","DENT",Q)):^(Q)+1,1:1)
 .I APCLSCOM S ^(Q)=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"SU","DENT",Q)):^(Q)+1,1:1)
 .Q
 Q
THIRD ;
 S APCLVAL="A" D MCRA
 S APCLVAL="B" D MCRA
 D PI,MCD
 Q
MCRA ;
 Q:'$D(^AUPNMCR(DFN,11))
 K APCLGOT S APCLMDFN=0 F  S APCLMDFN=$O(^AUPNMCR(DFN,11,APCLMDFN)) Q:APCLMDFN'=+APCLMDFN!($D(APCLGOT))  D MCRA2
 Q:'$D(APCLGOT)
 I APCLVAL="A" S ^("MCRA")=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"MCRA")):(+^("MCRA")+1),1:1)
 I APCLVAL="B" S ^("MCRB")=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"MCRB")):(+^("MCRB")+1),1:1)
 Q
 ;
MCRA2 ;
 Q:APCLVAL'[$P(^AUPNMCR(DFN,11,APCLMDFN,0),U,3)
 Q:$P(^AUPNMCR(DFN,11,APCLMDFN,0),U)>APCLBD  ;quit if policy started after the end of time frame
 I $P(^AUPNMCR(DFN,11,APCLMDFN,0),U,2)]"",$P(^(0),U,2)<APCLBD Q  ;quit if policy ended before beginning of time frame
 S APCLGOT=""
 Q
 ;
PI ;
 I $$PI^AUPNPAT(DFN,APCLBD) S ^("PI")=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"PI")):(+^("PI")+1),1:1)
 Q
MCD ;
 I $$MCD^AUPNPAT(DFN,APCLBD) S ^("MCD")=$S($D(^XTMP("APCLCH1",APCLJOB,APCLBTH,"RP",APCLCOM,"MCD")):(+^("MCD")+1),1:1)
 Q