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

APCDXPOV.m

Go to the documentation of this file.
APCDXPOV ; IHS/CMI/LAB - POV LOOKUP ;
 ;;2.0;IHS PCC SUITE;**11,20**;MAY 14, 2009;Build 25
 ;
START ;
 S (APCDLOOK,APCDTNQP)=""
 D EN^XBNEW("START1^APCDXPOV","APCDTSKI;APCDTDA;APCDLOOK;APCDDATE;APCDTERR;APCDPAT;DFN;APCDTNQP;APCDTPCC;APCDTDIA;APCDVSIT;APCDINAD;BDGV")
 Q
START1 ;EP
 S APCDTPCC="",APCDINPE=1,APCDD=""
 ;FOR NOW IF ICD9 CALL LEX, AFTER VA SENDS OUT ICD10 LEX JUST D LEX Q
 NEW %,D
 S D=""
 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="",$G(BDGV),$D(^AUPNVSIT(BDGV,0)) D
 .S APCDD=$P($P(^AUPNVSIT(BDGV,0),U),".")
 I APCDD="" S APCDD=DT
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("?")="^D HELPADX^AUPNSICA"
 S DIR("??")="^D HELPADX^AUPNSICA"
 KILL DA
 I $G(APCDTDA),$$VAL^XBDIQ1(9000010.02,APCDTDA,.12)]"" S DIR("B")=$$VAL^XBDIQ1(9000010.02,APCDTDA,.12)
 D ^DIR KILL DIR
 I $D(DIRUT) S APCDTSKI=1,APCDLOOK="" G XITL
 I Y="" S APCDTSKI=1,APCDLOOK="" G XITL
 S APCDUINP=Y
 I APCDUINP=$$VAL^XBDIQ1(9000010.02,APCDTDA,.12) G XITL
 I APCDIMP=1 D CONFIG^LEXSET("ICD","ICD",$P(APCDD,"."))
 I APCDIMP=30 D CONFIG^LEXSET("10D","10D",$P(APCDD,"."))
 S X=APCDUINP
 S %=""
 I X="@" W !!,"Admitting Diagnosis is Required." G LEX
 I APCDUINP=".9999" S %=+$$ICDDX^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ.999")) 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
 I APCDIMP=1 S DIC("S")="I $$ICDONE9^APCDXPOV(+Y,LEXVDT)"
 I APCDIMP=30 S DIC("S")="I $$ICDONE1^APCDXPOV(+Y,LEXVDT)"
 S DIC("A")=$S($G(APCDTDIA)]"":APCDTDIA_": ",1:"Enter Admitting Diagnosis: ")
 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^APCDAPOV
 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,"."),APCDIMP,"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
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^AUPNSICA($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^AUPNSICA($P(ALEXICD,U,1)) ""
 Q 1
EDIT01 ;EP
 D EN^XBNEW("EDIT011^APCDXPOV","APCDTDA;APCDVSIT;APCDPAT;APCDDATE;DFN;AUPNPAT;AUPNVSIT;APCDTTMP;BDGV")
 Q
EDIT011 ;
 K DIE,DA,DR
 ;
1 ;EDIT .12 OF V HOSP
 W !
 K DIR
 S APCDD=""
 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="",$G(BDGV),$D(^AUPNVSIT(BDGV,0)) D
 .S APCDD=$P($P(^AUPNVSIT(BDGV,0),U),".")
 I APCDD="" S APCDD=DT
 S APCDHDAT=APCDD
 ;12
 W !!,"Please Note:  Admitting Diagnosis is Required.",!
 S APCDIMP=$$IMP^AUPNSICD(APCDD)
 S APCDTFIE=".12",APCDTDIA="ADMITTING DX",APCDTDEL="",APCDLOOK="" K APCDINAD
 D LEX
 I $G(APCDTSKI) Q  ;"^" OUT
 I APCDLOOK]"" S DA=APCDTDA,DIE="^AUPNVINP(",DR=".12///"_APCDLOOK D ^DIE K DA,DIE,DR
 I $$VAL^XBDIQ1(9000010.02,APCDTDA,.12)="" G 1
 Q