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

APCHS9A.m

Go to the documentation of this file.
APCHS9A ; IHS/CMI/LAB - PART 9 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS PCC SUITE;**11**;MAY 14, 2009;Build 58
 ;
 ;cmi/anch/maw 8/27/2007 code set versioning in PVCH and SUPPCP
 ;
SUPP ;EP - supplements
 S APCHSFO=0 F  S APCHSFO=$O(^APCHSCTL(APCHSTYP,12,"B",APCHSFO)) Q:APCHSFO'=+APCHSFO!($D(APCHSQIT))  D  Q:$D(APCHSQIT)
 .S APCHSFOR=$O(^APCHSCTL(APCHSTYP,12,"B",APCHSFO,0))
 .S APCHSUPI=$P(^APCHSCTL(APCHSTYP,12,APCHSFOR,0),U,2)
 .Q:APCHSUPI=""
 .Q:'$D(^APCHSUP(APCHSUPI))
 .Q:$G(^APCHSUP(APCHSUPI,11))=""
 .D SUPPCHK
 .Q:'APCHSFOK
 .X ^APCHSUP(APCHSUPI,11)
EOJ ;
 K APCHSFOK,APCHSFOR,APCHSUPI
 Q
SUPPCHK ; <SCREEN>
 I '$O(^APCHSUP(APCHSUPI,13,0)) S APCHSFOK=1 Q
 S APCHSFOK=0
 ;Q:'$O(^AUPNPROB("AC",APCHSPAT,0))
 F APCHSPI=0:0 S APCHSPI=$O(^AUPNPROB("AC",APCHSPAT,APCHSPI)) Q:'APCHSPI  D SUPPCP Q:APCHSFOK
 Q:APCHSFOK
PVCH ;IHS/CMI/LAB - now check for dx in past year per Bill and Charlton by pcp
 K APCHY,APCHV,^TMP($J,"ALL VISITS")
 S APCHSNVN=$S($P($G(^APCHSITE(DUZ(2),11,APCHSUPI,0)),U,2):$P($G(^APCHSITE(DUZ(2),11,APCHSUPI,0)),U,2),1:1)
 S APCHSNYR=$S($P($G(^APCHSITE(DUZ(2),11,APCHSUPI,0)),U,3):$P($G(^APCHSITE(DUZ(2),11,APCHSUPI,0)),U,3),1:1)
 S APCHSNYR=APCHSNYR*365
 S APCHSBD=$$FMADD^XLFDT(DT,-(APCHSNYR))
 S APCHY="^TMP($J,""ALL VISITS"",",%=APCHSPAT_"^ALL VISITS;DURING "_APCHSBD_"-"_$$FMTE^XLFDT(DT),E=$$START1^APCLDF(%,APCHY)
 I '$D(^TMP($J,"ALL VISITS",1)) Q
 S (X,APCHSCNT,APCHSFOK)=0 F  S X=$O(^TMP($J,"ALL VISITS",X)) Q:X'=+X!(APCHSFOK)  S V=$P(^TMP($J,"ALL VISITS",X),U,5) D
 .Q:'$P(^AUPNVSIT(V,0),U,9)
 .Q:$P(^AUPNVSIT(V,0),U,11)
 .Q:"DAHO"'[$P(^AUPNVSIT(V,0),U,7)
 .Q:'$D(^AUPNVPRV("AD",V))
 .Q:'$D(^AUPNVPOV("AD",V))
 .;cmi/anch/maw 8/27/2007 mods for code set versioning
 .;S (D,Y)=0 F  S Y=$O(^AUPNVPOV("AD",V,Y)) Q:Y'=+Y!(D)  S APCHSCM=$P($G(^AUPNVPOV(Y,0)),U) I APCHSCM S APCHSCM=$P($G(^ICD9(APCHSCM,0)),U) I APCHSCM]"" D CHKCODE
 .N APCHSVDT
 .S APCHSVDT=$P(+V,".")
 .S (D,Y)=0 F  S Y=$O(^AUPNVPOV("AD",V,Y)) Q:Y'=+Y!(D)  S APCHSCMX=$P($G(^AUPNVPOV(Y,0)),U) I APCHSCMX S APCHSCM=$P($$ICDDX^ICDEX(APCHSCMX,APCHSVDT),U,2) I APCHSCM]"" D CHKCODE
 .Q:'D
 .;cmi/anch/maw 8/27/2007 end of mods
 .;REMOVED PROVIDER CHECK PER CHRIS LAMER BY EMAIL 09/2008
 .;S Y=$$PRIMPROV^APCLV(V,"F")
 .;Q:'Y
 .;I $P(^DIC(7,Y,9999999),U,1)=39 S APCHSFOK=1 Q
 .;Q:$P($G(^DIC(7,Y,9999999)),U,3)'="Y"
 .S APCHSCNT=APCHSCNT+1
 .I APCHSCNT'<APCHSNVN S APCHSFOK=1
 .Q
 K ^TMP($J,"ALL VISITS"),APCHV,APCHY
 Q
CHKCODE ;
 S D=0
 F APCHSCI=0:0 S APCHSCI=$O(^APCHSUP(APCHSUPI,13,APCHSCI)) Q:'APCHSCI  D CHKCODE1 Q:D
 Q
CHKCODE1 ;
 S D=0
 S APCHSC1=$P(^APCHSUP(APCHSUPI,13,APCHSCI,0),U,1)
 I $E(APCHSC1)="[" S D=$$ICD^ATXAPI(APCHSCMX,$O(^ATXAX("B",$E(APCHSC1,2,99),0)),9) Q
 I APCHSC1["-" S APCHSC2=$P(APCHSC1,"-",2),APCHSC1=$P(APCHSC1,"-",1)
 E  S APCHSC2=APCHSC1
 S APCHSC1=APCHSC1_" ",APCHSC2=APCHSC2_" "
 I APCHSC1'](APCHSCM_" "),(APCHSCM_" ")']APCHSC2 S D=1
 Q
SUPPCP ;
 S APCHSP=^AUPNPROB(APCHSPI,0) Q:$P(APCHSP,U,12)="D"
 S APCHSCM=$P($$ICDDX^ICDEX(+$P(APCHSP,U)),U,2)
 S APCHSCII=+$$ICDDX^ICDEX(+$P(APCHSP,U))
 F APCHSCI=0:0 S APCHSCI=$O(^APCHSUP(APCHSUPI,13,APCHSCI)) Q:'APCHSCI  D SUPPCR Q:APCHSFOK
 Q
SUPPCR S APCHSC1=$P(^APCHSUP(APCHSUPI,13,APCHSCI,0),U)
 I $E(APCHSC1)="[" S APCHSFOK=$$ICD^ATXAPI(APCHSCII,$O(^ATXAX("B",$E(APCHSC1,2,99),0)),9) Q
 I APCHSC1["-" S APCHSC2=$P(APCHSC1,"-",2),APCHSC1=$P(APCHSC1,"-",1)
 E  S APCHSC2=APCHSC1
 S APCHSC1=APCHSC1_" ",APCHSC2=APCHSC2_" "
 I APCHSC1'](APCHSCM_" "),(APCHSCM_" ")']APCHSC2 S APCHSFOK=1
 Q