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

APCDAOP.m

Go to the documentation of this file.
APCDAOP ; IHS/CMI/LAB - PROMPT FOR PROCEDURE ;
 ;;2.0;IHS PCC SUITE;**11**;MAY 14, 2009;Build 58
 ;
START ;
 S (APCDLOOK,APCDTNQP)=""
 D EN^XBNEW("START1^APCDAOP","APCDTSKI;APCDLOOK;APCDDATE;APCDTERR;APCDPAT;DFN;APCDTNQP;APCDTPCC;APCDTDIA;APCDVSIT;APCDTIN9")
 Q
START1 ;EP
 S APCDTPCC="",APCDINPE=1,APCDUINP=""
 K APCDTERR,APCDTSKI S APCDLOOK=""
 S APCDCAT=""
 I $G(APCDVSIT) S APCDCAT=$P(^AUPNVSIT(APCDVSIT,0),U,7)
 I APCDCAT="" S APCDCAT="A"
 NEW %,APCDD
 S APCDD=""
 I $G(APCDTIN9) S APCDD=$$FMADD^XLFDT($$IMP^ICDEX(31),-2),APCDIMP=2 G N
 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
 I $P($G(APCDPARM),U,21)="C",$G(APCDCAT)'="H" G CPT
I S APCDIMP=$$IMPOP^AUPNSICD(APCDD)
 ;I APCDIMP=31 G LEX1  ;CALL LEXICON FOR ICD10 ONLY
N K DIR
 ;G LEX1
 K APCDTERR,APCDTSKI S APCDLOOK=""
 S DIR(0)="FO^1:60",DIR("A")=$S($G(APCDTDIA)]"":APCDTDIA,1:"Enter OPERATION/PROCEDURE")
 S DIR("?")=$S(APCDIMP=31:"^D HELPOP^AUPNSICD",1:"^D HELPOP9^AUPNSIC9")
 KILL DA D ^DIR KILL DIR
 I $D(DIRUT) S APCDTSKI=1,APCDLOOK="" G XIT
 I Y="" S APCDTSKI=1,APCDLOOK="" G XIT
 S APCDUINP=Y
 K DIC
 S APCDTNQP=""
 S X=APCDUINP
 I $G(APCDTIN9) X:$D(^DD(9000010.08,.22,12.1)) ^DD(9000010.08,.22,12.1)
 I '$G(APCDTIN9) X:$D(^DD(9000010.08,.01,12.1)) ^DD(9000010.08,.01,12.1)
 S DIC="^ICD0(",DIC(0)="EMQZ",DIC("A")="Enter OPERATION/PROCEDURE: ",DIC("W")="D EN^DDIOL($P($$ICDOP^ICDEX(Y,$S($G(APCDD):APCDD,1:DT),,""I""),U,5)"
 D ^DIC K DIC
 G:Y="" XIT
 I $P(Y,U)=-1,X="" W !!,"Code not selected." S APCDTERR=1,APCDLOOK="" G XIT
 I $P(Y,U)=-1,X="^" S APCDTSKI=1,APCDLOOK="" G N
 I $P(Y,U)=-1 S APCDTERR=1,APCDLOOK="" G N
 S APCDLOOK="`"_+Y,APCDTNQP=$S($E(APCDUINP)="`":"",1:APCDUINP) ;,APCDTNQP=X
XIT K Y,X,DO,D,DD,DIPGM,APCDTPCC
 Q
 ;
CPT ;EP
 S APCDTPCC=""
 X:$D(^DD(9000010.08,.16,12.1)) ^DD(9000010.08,.16,12.1) S DIC="^ICPT(",DIC(0)="AEMQ",DIC("A")="Enter CPT CODE:  " 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 APCDCPT=+Y
 I '$O(^ICPT(+Y,"ICD","B",0)) W !!,$C(7),$C(7),"No ICD Operation Match for that code - notify supervisor.",! S APCDTERR=1,APCDLOOK="",APCDCPT="" G XIT
 S APCDLOOK=$O(^ICPT(+Y,"ICD","B",0))
 I APCDLOOK="" W !!,$C(7),$C(7),"No ICD Operation Match for that code - notify supervisor.",! S APCDTERR=1,APCDLOOK="",APCDCPT="" G XIT
 I $P(^ICD0(APCDLOOK,0),U,9) W !!,$C(7),$C(7),"The ICD Operation code this CPT maps to is INACTIVE (",$P(^ICD0(APCDLOOK,0),U),") - cannot use!",! S APCDTERR="",APCDLOOK="",APCDCPT="" G XIT
 S APCDLOOK="`"_APCDLOOK
 D XIT
 Q
ICDONE(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=$$P10ONE^LEXU(ALEX,ALEXVDT) Q:ALEX="" ""
 S ALEXICD=$$ICDOP^ICDEX(ALEX,ALEXVDT,31,"E")
 Q:$P(ALEXICD,"^",2)="INVALID CODE" ""
 Q:'$$CHKOP^AUPNSICD($P(ALEXICD,U,1)) ""
 Q 1
LEX1 ;EP - called from input template
 ;reader call to get TEXT for code
 K DIR
 S LEX=""
 K ^TMP("LEXSCH",$J),^TMP("LEXHIT",$J),LEX,^TMP("LEXFND",$J)
 ;I APCDIMP=2 D CONFIG^LEXSET(1,"PL2",$P(APCDD,"."))
 I APCDIMP=31 D CONFIG^LEXSET("10P","10P",$P(APCDD,"."))
 S DIR(0)="FO^1:60",DIR("A")=$S($G(APCDTDIA)]"":APCDTDIA,1:"Enter OPERATION/PROCEDURE")
 S DIR("?")=$S($G(APCDTIN9):"^D HELPOP9^AUPNSIC9",1:"^D HELPOP^AUPNSICH")
 S DIR("??")=$S($G(APCDTIN9):"^D HELPOP9^AUPNSIC9",1:"^D HELPOP^AUPNSICH")
 KILL DA D ^DIR KILL DIR
 I $D(DIRUT) S APCDTSKI=1,APCDLOOK="" G XITL1
 I Y="" S APCDTSKI=1,APCDLOOK="" G XITL1
 S APCDUINP=Y
 S %=""
 I APCDUINP=".9999" S %=+$$ICDOP^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ999"),$P(APCDD,"."),APCDIMP,"E") G LEXN1
 I APCDIMP=31,APCDUINP="ZZZ999" S %=+$$ICDOP^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ999"),$P(APCDD,"."),31,"E") G LEXN1
 I APCDIMP=31,$E(APCDUINP,1,3)="ZZZ" S %=+$$ICDOP^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ999"),$P(APCDD,"."),APCDIMP,"E") G LEXN1
 I $E(APCDUINP,1,7)="UNCODED" S %=+$$ICDOP^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ999"),$P(APCDD,"."),APCDIMP,"E") G LEXN1
 I APCDUINP["UNCODED D" S %=+$$ICDOP^ICDEX($S(APCDIMP=1:".9999",1:"ZZZ999"),$P(APCDD,"."),APCDIMP,"E") G LEXN1
 K ^TMP("LEXSCH",$J),^TMP("LEXHIT",$J),LEX,^TMP("LEXFND",$J)
 ;I APCDIMP=2 D CONFIG^LEXSET(1,"PL2",$P(APCDD,"."))
 I APCDIMP=31 D CONFIG^LEXSET("10P","10P",$P(APCDD,"."))
 S X=APCDUINP
 ;I APCDIMP=2 S DIC("S")=$S('$G(APCDTIN9):"I $$ICDONE^APCDAOP(+Y,LEXVDT)",1:"I $$ICDONE^APCDAOP(+Y,LEXVDT)")
 ;I APCDIMP=31 S DIC("S")="I $$ICDONE^APCDAOP(+Y,LEXVDT)"
 S DIC("A")="Enter OPERATION/PROCEDURE: "
 ;I APCDIMP=2 D LOOK^LEXA(X,1,999,"PL2",$P(APCDD,"."))
 I APCDIMP=31 D LOOK^LEXA(X,"10P",999,"10P",$P(APCDD,"."))
 I 'LEX D  G LEX1
 .S X=0 F  S X=$O(LEX("HLP",X)) Q:X'=+X  W !,LEX("HLP",X)
 ;display all codes and call reader
 S APCDANS=""
 D GETANS^APCDAPOV
 I APCDY="^" W ! G LEX1
 I APCDY="" W ! G LEX1
 I '$G(APCDY) W ! G LEX1
 ;I APCDIMP=2 S Y=$$ICDONE^LEXUTHORTOTHOTHOR($P(^TMP("LEXHIT",$J,APCDY),U,1),$P(APCDD,"."))
 I APCDIMP=31 S Y=$$P10ONE^LEXU($P(^TMP("LEXHIT",$J,APCDY),U,1),$P(APCDD,"."))
 K DO,^TMP("LEXSCH",$J)
 K ^TMP("LEXSCH",$J),^TMP("LEXHIT",$J),LEX,^TMP("LEXFND",$J)
 I $G(Y)="" W !!,"lexicon isn't passing back an ICD code." S APCDTERR=1,APCDLOOK="" G XITL1
 S %=$$ICDOP^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 XITL1
LEXN1 ;
 S APCDLOOK="`"_+%,APCDTNQP=APCDUINP
 W !
XITL1 K Y,X,DO,D,DD,DIPGM,APCDTPCC
 Q
DUAL(APCDDDA,APCDDVS,APCDDDF,APCDDDFE,APCDDDL,APCDDDS) ;EP - CALLED FROM INPUT TEMPLATES
 D EN^XBNEW("ENDUAL^APCDAOP","APCDDDA;APCDDVS;APCDDDF;APCDDDFE;APCDDDL;APCDDDS")
 K APCDDDA
 W !
 Q
ENDUAL ;
 S APCDTIN9=1
 W !!,"For dual coding."
 S APCDTDIA=APCDDDL
 S APCDVSIT=APCDDVS
 S APCDDATE=$$VD^APCLV(APCDDVS)
 ;W !
 I APCDDDS=80.1 D START1^APCDAOP
 I APCDDDS=80 D START1^APCDAPOV
 I APCDLOOK]"" S DIE=APCDDDF,DA=APCDDDA,DR=APCDDDFE_"///"_APCDLOOK D ^DIE K DA,DR,DIE Q
 W !!,"You did not enter an ICD-9 code.",!
 S DIR(0)="Y",DIR("A")="Do you wish to try again",DIR("B")="N" KILL DA D ^DIR KILL DIR
 I 'Y Q
 I $D(DIRUT) Q
 G ENDUAL
TEST ;
 K ^TMP("LEXSCH",$J)
 D CONFIG^LEXSET("10P","10P",DT)
 D LOOK^LEXA("UNCODED","10P",999,"10P",DT)
 Q