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

APCDAPOV.m

Go to the documentation of this file.
APCDAPOV ; IHS/CMI/LAB - POV LOOKUP ; 13 Feb 2014  2:26 PM
 ;;2.0;IHS PCC SUITE;**10,11,13,20**;MAY 14, 2009;Build 25
 ;
START ;
 S (APCDLOOK,APCDTNQP)=""
 D EN^XBNEW("START1^APCDAPOV","APCDTSKI;APCDLOOK;APCDDATE;APCDTERR;APCDPAT;DFN;APCDTNQP;APCDTPCC;APCDTDIA;APCDVSIT;APCDINAD,APCDTIN9")
 Q
START1 ;EP
 S APCDTPCC="",APCDINPE=1
 I $G(APCDTIN9) S APCDD=$$FMADD^XLFDT($$IMP^AUPNVUTL(30),-2),APCDIMP=1 G LEX
 S APCDD=""
 I $G(APCDINAD) S APCDD=$S($D(APCDDATE):APCDDATE,1:DT) G I
 I $G(APCDVSIT),$D(^AUPNVSIT(APCDVSIT)) D
 .I $P(^AUPNVSIT(APCDVSIT,0),U,7)="H",$$DSCHDATE^APCLV(APCDVSIT)]"" S APCDD=$$DSCHDATE^APCLV(APCDVSIT) Q
 .S APCDD=$P($P(^AUPNVSIT(APCDVSIT,0),U),".")
 I APCDD="" S APCDD=$P($G(APCDDATE),".")
 I APCDD="" S APCDD=DT
 NEW APCDIMP,APCDANS
I ;
 S APCDIMP=$$IMP^AUPNSICD(APCDD)
LEX ;EP - called from input template
 ;reader call to get TEXT for code
 K DIR
 K ^TMP("LEXSCH",$J)
 I APCDIMP=1 D CONFIG^LEXSET("ICD","ICD",$P(APCDD,"."))
 I APCDIMP=30 D CONFIG^LEXSET("10D","10D",$P(APCDD,"."))
 S DIR(0)="FO^1:60",DIR("A")=$S($G(APCDTDIA)]"":APCDTDIA,1:"Enter PURPOSE OF VISIT")
 S DIR("?")=$S($G(APCDTIN9):"^D HELP9^AUPNSIC9",1:"^D HELP^AUPNSICH")
 S DIR("??")=$S($G(APCDTIN9):"^D HELP9^AUPNSIC9",1:"^D HELP^AUPNSICH")
 KILL DA D ^DIR KILL DIR
 I $D(DIRUT) S APCDTSKI=1,APCDLOOK="" G XITL
 I Y="" S APCDTSKI=1,APCDLOOK="" G XITL
 S APCDUINP=Y
 S %=""
 I APCDUINP=".9999" S %=+$$ICDDX^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ.999"),,APCDIMP,"E") G LEXN
 I APCDIMP=30,APCDUINP="ZZZ.999" S %=+$$ICDDX^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ.999")) G LEXN
 I APCDIMP=30,$E(APCDUINP,1,4)="ZZZ." S %=+$$ICDDX^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ.999")) G LEXN
 I $E(APCDUINP,1,7)="UNCODED" S %=+$$ICDDX^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ.999")) G LEXN
 I APCDUINP["UNCODED D" S %=+$$ICDDX^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ.999")) G LEXN
 K ^TMP("LEXSCH",$J),^TMP("LEXHIT",$J),LEX,^TMP("LEXFND",$J)
 I APCDIMP=1 D CONFIG^LEXSET("ICD","ICD",$P(APCDD,"."))
 I APCDIMP=30 D CONFIG^LEXSET("10D","10D",$P(APCDD,"."))
 S X=APCDUINP
 I APCDIMP=1 S DIC("S")=$S('$G(APCDTIN9):"I $$ICDONE9^APCDAPOV(+Y,LEXVDT)",1:"I $$ICDONE99^APCDAPOV(+Y,LEXVDT)")
 I APCDIMP=30 S DIC("S")="I $$ICDONE1^APCDAPOV(+Y,LEXVDT)"
 S DIC("A")=$S($G(APCDTDIA)]"":APCDTDIA_": ",1:"Enter PURPOSE OF VISIT: ")
 I APCDIMP=1 D LOOK^LEXA(X,"ICD",999,"ICD",$P(APCDD,"."))
 I APCDIMP=30 D LOOK^LEXA(X,"10D",999,"10D",$P(APCDD,"."))
 I 'LEX D  G:%="" LEX G:% LEXN
 .S X=0 F  S X=$O(LEX("HLP",X)) Q:X'=+X  W !,LEX("HLP",X)
 .;now check fileman V2.0 PATCH 20 CR#554
 .W !!,"now trying secondary fileman lookup..."
 .S %="" S X=APCDUINP,DIC="^ICD9(",DIC(0)="MEQ",DIC("S")="D ^AUPNSICD" D ^DIC K DIC
 .S %="" I $P(Y,U)'=-1 S %=+Y
 ;display all codes and call reader
 S APCDANS=""
 D GETANS
 I APCDY="^" W ! D  G:%="" LEX G:% LEXN
 .;now check fileman
 .;W !!,"now trying fileman lookup..."
 .S %="" ;S X=APCDUINP,DIC="^ICD9(",DIC(0)="QME" D ^DIC K DIC
 .;S %="" I $P(Y,U)'=-1 S %=+Y
 I APCDY="" W ! D  G:%="" LEX G:% LEXN
 .;now check fileman
 .;W !!,"now trying fileman lookup..."
 .S %="" ;S X=APCDUINP,DIC="^ICD9(",DIC(0)="MEQ" D ^DIC K DIC
 .;S %="" I $P(Y,U)'=-1 S %=+Y
 I '$G(APCDY) W ! D  G:%="" LEX G:% LEXN
 .;now check fileman
 .;W !!,"now trying fileman lookup..."
 .S %="" ;S X=APCDUINP,DIC="^ICD9(",DIC(0)="MEQ" D ^DIC K DIC
 .;S %="" I $P(Y,U)'=-1 S %=+Y
 I APCDIMP=1 S Y=$$ICDONE^LEXU($P(^TMP("LEXHIT",$J,APCDY),U,1),$P(APCDD,"."))
 I APCDIMP=30 S Y=$$ONE^LEXU($P(^TMP("LEXHIT",$J,APCDY),U,1),$P(APCDD,"."),"10D")
 K DO,^TMP("LEXSCH",$J)
 I $G(Y)="" W !!,"lexicon isn't passing back an ICD code." S APCDTERR=1,APCDLOOK="" G XITL
 S %=$$ICDDX^ICDEX(Y,$P(APCDD,"."),,"E")
 I $P(%,U,1)="-1" W !!,"lexicon isn't passing back an ICD code." S APCDTERR=1,APCDLOOK="" G XITL
LEXN ;
 S APCDLOOK="`"_+%,APCDTNQP=APCDUINP
 W !
XITL K Y,X,DO,D,DD,DIPGM,APCDTPCC
 Q
CAUSE(C,S) ;EP
 ;C IS IEN, S IS CODING SYSTEM
 S C=$P($$ICDDX^ICDEX(C,,,"I"),U,2)
 NEW %
 S %=0
 I S=1 D  Q %
 .I $E(C,1)="E" S %=1 Q
 I $E(C,1)="V" S %=1  ;only codes V00-Y99 per Leslie Racine.
 I $E(C,1)="W" S %=1
 I $E(C,1)="X" S %=1
 I $E(C,1)="Y" S %=1
 Q %
INJ(C,S) ;EP
 NEW %
 S %=""
 I S=1 D  Q %
 .I $E(C,1)="E" S %=0 Q
 .I $E(C,1)="V" S %=0 Q
 .I $P(C,".",1)<800 S %=0 Q
 .S %=1
 I $E(C,1)="S" Q 1
 I $E(C,1)="T",$E(C,2,3)<89 Q 1
 Q 0
ICDONE9(ALEX,ALEXVDT) ;EP - Return one ICD code for an expression
 ;    LEX      IEN of file 757.01
 ;    LEXVDT   Date to use for screening by codes
 N ALEXICD
 S ALEXVDT=$S(+$G(ALEXVDT)>0:ALEXVDT,1:$$DT^XLFDT)
 S ALEX=$$ICDONE^LEXU(ALEX,ALEXVDT) Q:ALEX="" ""
 S ALEXICD=$$ICDDX^ICDEX(ALEX,ALEXVDT,1,"E")
 Q:$P(ALEXICD,"^",2)="INVALID CODE" ""
 Q:'$$CHK^AUPNSICD($P(ALEXICD,U,1)) ""
 Q 1
ICDONE99(ALEX,ALEXVDT) ;EP - Return one ICD code for an expression
 ;    LEX      IEN of file 757.01
 ;    LEXVDT   Date to use for screening by codes
 N ALEXICD
 S ALEXVDT=$S(+$G(ALEXVDT)>0:ALEXVDT,1:$$DT^XLFDT)
 S ALEX=$$ICDONE^LEXU(ALEX,ALEXVDT) Q:ALEX="" ""
 S ALEXICD=$$ICDDX^ICDEX(ALEX,ALEXVDT,1,"E")
 Q:$P(ALEXICD,"^",2)="INVALID CODE" ""
 Q:'$$CHK91^AUPNSIC9($P(ALEXICD,U,1)) ""
 Q 1
ICDONE1(ALEX,ALEXVDT) ;EP - Return one ICD code for an expression
 ;    LEX      IEN of file 757.01
 ;    LEXVDT   Date to use for screening by codes
 N ALEXICD,ALEVXDT,%
 S ALEX=$$ONE^LEXU(ALEX,ALEXVDT,"10D") Q:ALEX="" ""
 S ALEXICD=$$ICDDX^ICDEX(ALEX,ALEXVDT,30,"E")
 Q:$P(ALEXICD,"^",2)="INVALID CODE" ""
 Q:'$$CHK^AUPNSICD($P(ALEXICD,U,1)) ""
 Q 1
TEST10 ;
 K ^TMP("LEXSCH"),^TMP("LEXFND"),LEX("LIST")
 K LEX
 S APCDDATE=DT
 D CONFIG^LEXSET("10D","10D",$S(APCDDATE>3141001:APCDDATE,1:3141001))
 S DIC("S")="I $$ICDONE1^APCDAPOV(+Y,LEXVDT)"
 S APCDDATE=DT
 D LOOK^LEXA("HYPERTENSION","10D",999,"10D",$S(APCDDATE>3141001:APCDDATE,1:3141001))
 ;ZW LEX
 Q
GETANS ;EP - DISPLAY LEX ARRAY
 NEW APCDX,APCDZ,APCDQ,APCDCNT,APCDTOT,Z,MF
 S MF=$P(^TMP("LEXHIT",$J,0),U)
 W !!?5,$P(^TMP("LEXHIT",$J,0),U)," term matches found.",!
 S APCDX=0,APCDY="",APCDQ=0,APCDCNT=0,APCDTOT=0
 F  S APCDX=$O(^TMP("LEXHIT",$J,APCDX)) Q:APCDX'=+APCDX!(APCDY]"")  D
DISP .;display code
 .K ^UTILITY($J,"W")
 .W !?3,APCDX,")"
 .S APCDZ=$P(^TMP("LEXHIT",$J,APCDX),U,2)
 .I APCDZ'["(ICD-" S APCDZ=APCDZ_" (ICD-"_$S(APCDIMP=1:9,1:10)_"-CM "_$$ONE^LEXU($P(^TMP("LEXHIT",$J,APCDX),U,1),LEXVDT,$S(APCDIMP=1:"ICD",1:"10D"))_")"
 .S X=APCDZ,DIWL=0,DIWR=70 D ^DIWP
 .S Z=0 F  S Z=$O(^UTILITY($J,"W",0,Z)) Q:Z'=+Z  W:Z>1 ! W ?9,^UTILITY($J,"W",0,Z,0)
 .; APCDCNT=APCDCNT+1,APCDTOT=APCDTOT+1
 .S APCDCNT=APCDCNT+1,APCDTOT=APCDTOT+1
 .I MF=1 S APCDCNT=1,APCDTOT=1 D READ S:APCDY="" APCDY="^" Q
 .I MF>4,APCDCNT=5!(MF=APCDTOT) D READ S APCDCNT=0 Q
 .I MF<5,MF=APCDX D READ S APCDNT=0 Q:APCDY]""
 .Q
 Q
READ ;
 K DIR,DIRUT
 S APCDY=""
 W !
 ;W !,"Type ""^"" to STOP, press ENTER to continue the list or SELECT 1-"_APCDTOT
 S DIR("B")=$S(MF=1:1,1:""),DIR(0)="NO^1:"_APCDTOT_":0"
 S DIR("A")="Type ""^"" to STOP or SELECT 1-"_APCDTOT
 KILL DA D ^DIR W !
 I $D(DIRUT) S APCDY="^"
 I Y="" S APCDY="" Q
 S APCDY=+Y
 Q
OLD ;EP - called from CPV input template
 I $G(APCDTDIA)["PROBLEM" D START^APCDAPRB Q
 S APCDTPCC=""
 X:$D(^DD(9000010.07,.01,12.1)) ^DD(9000010.07,.01,12.1) S DIC="^ICD9(",DIC(0)="AEMQ",DIC("A")="Enter PURPOSE of VISIT: " D ^DIC K DIC
 G:Y="" XIT
 I Y=-1,X=""!(X="^") S APCDTSKI=1,APCDLOOK="" G XIT
 I Y=-1 S APCDTERR=1,APCDLOOK="" G XIT
 S APCDLOOK="`"_+Y,APCDTNQP=X
XIT K Y,X,DO,D,DD,DIPGM,APCDTPCC
 Q
CINJ ;GET CAUSE OF INJURY CODES FROM LEXICON
 K ^TMP("LEXSCH"),^TMP("LEXFND"),LEX("LIST"),LEX
 D CONFIG^LEXSET("10D","10D",DT)
 S DIC("S")="I $$ICDCIJ^APCDAPOV(+Y,LEXVDT)"
 D LOOK^LEXA("FALL","10D",999,"10D",DT)
 Q
ICDCIJ(ALEX,ALEXVDT) ;EP - Return one ICD code for an expression
 ;    LEX      IEN of file 757.01
 ;    LEXVDT   Date to use for screening by codes
 N ALEXICD,ALEVXDT,%
 S ALEX=$$ONE^LEXU(ALEX,DT,"10D") Q:ALEX="" ""
 S ALEXICD=$$ICDDX^ICDEX(ALEX,ALEXVDT)
 Q:$P(ALEXICD,"^",2)="INVALID CODE" ""
 Q:'$$CAUSE($P(ALEXICD,U,2),30) ""
 Q 1
GETICD ;
 S Y=$$ONE^LEXU($P(LEX("LIST",73),U,1),DT,"10D")
 W !,Y
 Q