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

APCLCH21.m

Go to the documentation of this file.
APCLCH21 ; IHS/CMI/LAB - community health profile ;
 ;;2.0;IHS PCC SUITE;**11**;MAY 14, 2009;Build 58
 ;
 ;cmi/anch/maw 9/10/2007 code set versioning in DX
 ;
START ;
 S APCLBT=$H
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^APCLCH2
 S APCLET=$H
 Q
PROC ;
 Q:$$DEMO^APCLUTL(APCLDFN,$G(APCLDEMO))
 I $G(AUPNDOD)]"",AUPNDOD'>APCLBD Q  ;died before time frame
 S APCLCOM=$$COMMRES^AUPNPAT(APCLDFN,"E"),APCLCOMI=$$COMMRES^AUPNPAT(APCLDFN,"I")
 Q:APCLCOMI=""
 Q:APCLCOMI=-1
 Q:'$D(^XTMP("APCLCH2",APCLJOB,APCLBTH,"COMMUNITIES",APCLCOMI))  ;do not use patient if not in a community of interest
 K APCLLOC
 S APCLLFAC=$P(^AUTTCOM(APCLCOMI,0),U,15),APCLLOC(APCLLFAC)=""
 S APCLSFAC=$P(^AUTTCOM(APCLCOMI,0),U,16),APCLLOC(APCLSFAC)=""
 S APCLTFAC=$P(^AUTTCOM(APCLCOMI,0),U,17),APCLLOC(APCLTFAC)=""
 D V
 Q
V ; Run by visit date
 S APCLV=0,APCLBDO=(9999999-APCLBD)_".9999",APCLEDO=(9999999-APCLED),APCLSD=(APCLEDO-1)_".9999"
 F  S APCLSD=$O(^AUPNVSIT("AA",DFN,APCLSD)) Q:APCLSD>APCLBDO!(APCLSD="")  D
 .S APCLV=0 F  S APCLV=$O(^AUPNVSIT("AA",DFN,APCLSD,APCLV)) Q:APCLV'=+APCLV  D
 ..Q:'$P(^AUPNVSIT(APCLV,0),U,9)
 ..Q:$P(^AUPNVSIT(APCLV,0),U,11)
 ..Q:"E"[$P(^AUPNVSIT(APCLV,0),U,7)
 ..Q:'$D(^AUPNVPOV("AD",APCLV))
 ..S APCLVLOC=$P(^AUPNVSIT(APCLV,0),U,6)
 ..Q:'$D(APCLLOC(APCLVLOC))
 ..D DX
 ..Q
 .Q
 Q
DX ;
 S APCLP=0 F  S APCLP=$O(^AUPNVPOV("AD",APCLV,APCLP)) Q:APCLP'=+APCLP  S APCLDX=$P(^AUPNVPOV(APCLP,0),U) D
 .I $P(^AUPNVSIT(APCLV,0),U,7)="H" D  Q
 ..S ^(APCLDX)=$S($D(^XTMP("APCLCH2",APCLJOB,APCLBTH,"DATA",APCLCOMI,APCLVLOC,"INDX",APCLDX)):^(APCLDX)+1,1:1)
 ..;S %=$P(^ICD9(APCLDX,0),U,5) I % S ^(%)=$S($D(^XTMP("APCLCH2",APCLJOB,APCLBTH,"DATA",APCLCOMI,APCLVLOC,"INCAT",%)):^(%)+1,1:1)  ;cmi/anch/maw 9/10/2007 orig line
 ..S %=$P($$ICDDX^ICDEX(APCLDX),U,6) I % S ^(%)=$S($D(^XTMP("APCLCH2",APCLJOB,APCLBTH,"DATA",APCLCOMI,APCLVLOC,"INCAT",%)):^(%)+1,1:1)  ;cmi/anch/maw 9/10/2007 csv
 .I "AORSTC"[$P(^AUPNVSIT(APCLV,0),U,7) D
 ..S ^(APCLDX)=$S($D(^XTMP("APCLCH2",APCLJOB,APCLBTH,"DATA",APCLCOMI,APCLVLOC,"OUTDX",APCLDX)):^(APCLDX)+1,1:1)
 ..;S %=$P(^ICD9(APCLDX,0),U,5) I % S ^(%)=$S($D(^XTMP("APCLCH2",APCLJOB,APCLBTH,"DATA",APCLCOMI,APCLVLOC,"OUTCAT",%)):^(%)+1,1:1)  ;cmi/anch/maw 9/10/2007 orig line
 ..S %=$P($$ICDDX^ICDEX(APCLDX),U,6) I % S ^(%)=$S($D(^XTMP("APCLCH2",APCLJOB,APCLBTH,"DATA",APCLCOMI,APCLVLOC,"OUTCAT",%)):^(%)+1,1:1)  ;cmi/anch/maw 9/10/2007 csv  
 .Q
 Q