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

IBDFDE21.m

Go to the documentation of this file.
  1. IBDFDE21 ;ALB/AAS - AICS Data Entry, process selection lists ; 11/22/99 4:35pm
  1. ;;3.0;AUTOMATED INFO COLLECTION SYS;**4,38,23,63**;APR 24, 1997;Build 80
  1. ;
  1. ;
  1. % G ^IBDFDE
  1. ;
  1. SEL(SEL) ; -- Build results array
  1. N IBDX,DSPTXT,IBQUIT,IBDQL,QCNT,IBDQLFR
  1. S IBQUIT=0
  1. ;
  1. S IBDQL=$$QLFR(.RULE,.QLFR)
  1. Q:IBQUIT!(IBDQL="^")
  1. S IBDQLFR=$P(IBDQL,"^",1) D SEL1
  1. ;
  1. F QCNT=2:1 S IBDQLFR=$P(IBDQL,"^",QCNT) Q:IBDQLFR="" D SEL1
  1. Q
  1. ;
  1. SEL1 ; -- build selections
  1. N IBDIMP,IBDIBX
  1. S IBDIMP=$$IMPDATE^IBDUTICD(30)
  1. S IBDIBX=799.9
  1. I DT'<IBDIMP S IBDIBX="R69."
  1. S IBDX=$G(RESULT(0))+1,RESULT(0)=IBDX
  1. I +SEL=SEL S CHOICE=$$CHOICE^IBDFDE2(SEL)
  1. I +SEL'=SEL S CHOICE=SEL
  1. S DISPTXT=$S($P(CHOICE,"^",5)="":$P(CHOICE,"^"),1:$P(CHOICE,"^",5))
  1. W:+$G(QCNT)<2 " ",DISPTXT," ",$S($P(CHOICE,"^",2)'="":$P(CHOICE,"^",2),$P($G(^IBE(357.6,IBDF("PI"),0)),"^")="GMP INPUT CLINIC COMMON PROBLEMS":$$LEX^IBDFDE1($P(CHOICE,"^",3)),1:$P(CHOICE,"^",3))," ",$P(CHOICE,"^",8)_" ",$P(CHOICE,"^",4)
  1. ;
  1. S RESULT(IBDX)=IBDF("PI")_"^"_$P(CHOICE,"^",3)_"^"_DISPTXT_"^"_$P(CHOICE,"^",8)_"^"_$P(CHOICE,"^",6)_"^"_IBDQLFR_"^"_$G(IBDF("IEN"))_"^^"_$P(CHOICE,"^",9)_"^"_$P(CHOICE,"^",2)_"^^"_$P(CHOICE,"^",12)
  1. S IBDPI(IBDF("PI"),IBDX)=RESULT(IBDX)
  1. ;
  1. ; --validate code for active problem list
  1. I $P($G(^IBE(357.6,IBDF("PI"),0)),"^")="PX INPUT PATIENT ACTIVE PROBLEM" D
  1. .N X S X=$P(CHOICE,"^",2) Q:X=""
  1. .I X=IBDIBX W !,$C(7),IOINHI,"Warning: The ICD",$S(DT'<IBDIMP:"10",1:"9")," Diagnosis associated with this problem needs to be updated!",IOINORM Q
  1. .D TESTICD^IBDFN7
  1. .I '$D(X) W !,$C(7),IOINHI,"Warning: The ICD",$S(DT'<IBDIMP:"10",1:"9")," code associated with this problem is inactive.",IOINORM
  1. .;I $D(X) W !,"This is a valid icd9 code"
  1. ;
  1. ; -- send second and third codes if applicable
  1. Q:"PRIMARYSECONDARYADD TO PROBLEM LIST"'[IBDQLFR
  1. N IBDQUAL
  1. S IBDQUAL=$S(IBDQLFR="PRIMARY":"SECONDARY",1:IBDQLFR)
  1. N I,IBDXCD,DISPTXT F I=10,11 I $P(CHOICE,"^",I)]"" D
  1. .S IBDX=$G(RESULT(0))+1,RESULT(0)=IBDX
  1. .S IBDXCD=$P(CHOICE,"^",I)
  1. .N X,Y S X=IBDXCD
  1. .D
  1. ..I $G(X)="" K X S Y="" Q
  1. ..;S:$E(X,$L(X))'=" " X=X_" " ; use ba xref, add space to end for lookup.
  1. ..;S X=$O(^ICD9("BA",X,0))
  1. ..;I 'X S Y=""
  1. ..;E S Y=$P(^ICD9(X,0),"^",3)
  1. ..;S X=$$ICDDX^ICDCODE(X)
  1. ..;get by external code using "DIAG"
  1. ..S X=$$ICDDATA^ICDXCODE("DIAG",X,DT)
  1. ..I +X<1 K X S Y="" Q
  1. ..E S Y=$P(X,U,4)
  1. .S DISPTXT=Y
  1. .S RESULT(IBDX)=IBDF("PI")_"^"_IBDXCD_"^"_DISPTXT_"^"_$P(CHOICE,"^",8)_"^"_$P(CHOICE,"^",6)_"^"_IBDQUAL_"^"_$G(IBDF("IEN"))_"^^"_$P(CHOICE,"^",9)
  1. .S IBDPI(IBDF("PI"),IBDX)=RESULT(IBDX)
  1. ;
  1. ; -- if ans contains - go to modifier routine
  1. I IBDASK="CPT Procedure Code" D MOD^IBDFDE23
  1. I IBDASK="Visit Type (EM) Code" D MOD^IBDFDE23
  1. Q
  1. ;
  1. QLFR(RULE,QLFR) ; -- ask Qualifier from array, impose rules
  1. N I,X,IBDQ,IBDQ1,QCNT,CNT,ANS,IBDI,OVER,X1,X2,NUM
  1. S IBDQ="",CNT=0
  1. ;
  1. ; -- if only 1 qualifier use it
  1. I RULE=1 S IBDQ=$G(QLFR(+$O(QLFR(0)))) W " ",IBDQ G QLFRQ
  1. ;
  1. S IBDI=0
  1. F S IBDI=$O(QLFR(IBDI)) Q:'IBDI S X=$G(QLFR(IBDI)) I X'="" D
  1. .S CNT=CNT+1,X(CNT)=X,X2(X)=X
  1. .I '$D(X1($E(X),1)) S X1($E(X),1)=X Q
  1. .S NUM=$O(X1($E(X),""),-1) S X1($E(X),NUM+1)=X
  1. I CNT=1 S IBDQ=$G(X(CNT)) W " ",IBDQ G QLFRQ
  1. ;
  1. I $D(IBNAQLFR) S ANS=1 S IBDQ=X(ANS) W !,IOINHI,"Using Default Qualifier: "_X(ANS),IOINORM,! Q IBDQ
  1. OVER1 ;
  1. I CNT<1 G QLFRQ
  1. W !,IOINHI," Select a Qualifier",IOINORM
  1. I CNT>1 F I=1:1:CNT I X(I)'="" W !?6,I,?10,X(I)
  1. W !," Choose 1-",CNT,": " R ANS:DTIME
  1. I '$T!($E(ANS,1)="^") S IBDQ="",IBQUIT=1 G QLFRQ
  1. I ANS="" G OVER1
  1. S OVER=0
  1. I $E(ANS,1)="?" D HELP G OVER1
  1. I ANS=+ANS D G:OVER OVER1
  1. .I ANS<1!(ANS>CNT) S OVER=1 Q
  1. .I $G(X(ANS))="" S OVER=1 Q
  1. .S IBDQ=X(ANS) W " ",X(ANS)
  1. .W !
  1. I ANS'=+ANS D G:OVER OVER1
  1. .S ANS1=ANS,QCNT=0,IBDQ1=""
  1. .F IBD=1:1 S ANS=$P(ANS1,",",IBD) Q:ANS=""!OVER D ONEQLFR I 'OVER,IBDQ'="" S QCNT=QCNT+1,$P(IBDQ1,"^",QCNT)=IBDQ
  1. .S IBDQ=IBDQ1
  1. .K QCNT,IBDQ1
  1. ;
  1. QLFRQ Q IBDQ
  1. ;
  1. ONEQLFR ; -- parse qualifiers
  1. S ANS=$$UP^XLFSTR(ANS)
  1. I +ANS=ANS D Q
  1. .I $G(X(ANS))="" W !,"'"_ANS_"' IS NOT A VALID SELECTION, RE-ENTER" S OVER=1 Q
  1. .S IBDQ=X(ANS) W " ",X(ANS)
  1. ;
  1. I $L(ANS)=1,$G(X1(ANS,1))'="",$O(X1(ANS,1))="" S IBDQ=X1(ANS,1) W:ANS=ANS1 $E(X1(ANS,1),2,99) W:ANS'=ANS1 " ",X1(ANS,1) Q
  1. I $G(X2(ANS))'="" S IBDQ=X2(ANS) W " ",X2(ANS) Q
  1. I $L(ANS)=1,$G(X1(ANS,1))'="",$O(X1(ANS,1)) S OVER=1 W " Ambiguous answer, enter the number." Q ;S IBDQ=$$PARTLST("X1",ANS,ANS) W $E(X1(ANS,1),2,99) Q
  1. S OVER=1
  1. Q
  1. ;
  1. LST ; -- List previous selections and selections to choose from.
  1. N I,CNT,IBQUIT,NUM
  1. ;
  1. ; -- list previous selections
  1. D PREVSEL
  1. ;
  1. ; -- list available choices
  1. S (IBQUIT,CNT)=0
  1. S NUM=+$$CHOICE^IBDFDE2(0)
  1. W !!,"Choose from: "
  1. S I=0 F S I=$O(^TMP("IBD-LST",$J,IBDFMIEN,IBDF("PI"),IBDF("IEN"),I)) Q:'I!(IBQUIT) D
  1. .S CHOICE=$$CHOICE^IBDFDE2(I)
  1. .I '$P(CHOICE,"^",7) W !?16,IOINHI,$P(CHOICE,"^"),IOINORM Q
  1. .S CNT=CNT+1,NUMBER(CNT)=I
  1. .W !?3,CNT,?7,$S($P(CHOICE,"^",2)'="":$P(CHOICE,"^",2),1:$P(CHOICE,"^",3)),?16,$P(CHOICE,"^",1)
  1. .I NUM>15,NUM>I,'(CNT#15) D PAUSE^IBDFDE I 'IBQUIT W $C(13),$J("",55),$C(13)
  1. .;I NUM>15,CNT'=NUM,'(CNT#15) D READ I $G(LISTSEL)<1!($G(LISTSEL)>CNT) K LISTSEL
  1. .;I $G(LISTSEL) S SEL=NUMBER(LISTSEL)
  1. Q
  1. ;
  1. PREVSEL ; -- List previous selections
  1. N I,CNT
  1. S CNT=0
  1. ;
  1. ; -- list previous selections
  1. I $D(IBDPI(IBDF("PI")))>1 S I=0 F S I=$O(IBDPI(IBDF("PI"),I)) Q:'I D
  1. .Q:$P(IBDPI(IBDF("PI"),I),"^",7)'=IBDF("IEN") ; not the same list
  1. .S CNT=CNT+1
  1. .W:CNT=1 !!,IOINHI," You have previously selected: ",IOINORM
  1. .W !,?7,$S($P($G(^IBE(357.6,+IBDPI(IBDF("PI"),I),0)),"^")="GMP INPUT CLINIC COMMON PROBLEMS":$$LEX^IBDFDE1($P(IBDPI(IBDF("PI"),I),"^",2)),1:$P(IBDPI(IBDF("PI"),I),"^",2))
  1. .W ?16,$P(IBDPI(IBDF("PI"),I),"^",3),?50,$P(IBDPI(IBDF("PI"),I),"^",6)
  1. W !
  1. Q
  1. ;
  1. DEFAULT ; -- compute default answer
  1. N CNT,SEL,NAME,PIECE,SELAST
  1. S (CNT,SEL,SELAST)=0
  1. S NAME=$P($G(^IBE(357.6,+IBDF("PI"),0)),"^")
  1. S PIECE=$S(NAME["INPUT PROCEDURE CODE":2,NAME["INPUT DIAGNOSIS CODE":2,NAME["INPUT VISIT TYPE":2,1:3)
  1. F S SEL=$O(IBDPI(IBDF("PI"),SEL)) Q:'SEL D
  1. .Q:$P(IBDPI(IBDF("PI"),SEL),"^",7)'=IBDF("IEN") ; not the same list
  1. .S CNT=CNT+1,SELAST=SEL
  1. I $G(SELAST) S DIR("B")=$P(IBDPI(IBDF("PI"),SELAST),"^",PIECE),IBDEFLT(IBDF("PI"))=DIR("B")
  1. D PREVSEL
  1. Q
  1. ;
  1. DEFPROV ; -- find default provider, not on form
  1. N SEL,IBDX
  1. S IBDF("PI")=$O(^IBE(357.6,"B","INPUT PROVIDER",0))
  1. Q:$D(IBDPI(IBDF("PI")))
  1. S SEL=$G(IBDF("PROVIDER")) I 'SEL S SEL=$$PRDEF^IBDFRPC3(IBDF("CLINIC"))
  1. Q:'SEL
  1. S $P(IBDF("PROVIDER PI"),"^",2)=1 ;flag not on form
  1. S IBDX=$G(IBDSEL(0))+1,IBDSEL(0)=IBDX
  1. S IBDSEL(IBDX)=IBDF("PI")_"^"_SEL_"^"_$P($G(^VA(200,+SEL,0)),"^")_"^^^PRIMARY^"
  1. S IBDPI(IBDF("PI"),IBDX)=IBDSEL(IBDX)
  1. W:'$G(IBDF("PROVIDER")) !!,"No Provider Block on form. Using Default Provider from Clinic as Primary.",!
  1. W:$G(IBDF("PROVIDER")) !!,"Using Provider: "
  1. W " ",$P(^VA(200,+SEL,0),"^")," PRIMARY",!
  1. Q
  1. ;
  1. HELP ; --
  1. W !,"You must choose a data qualifier for this item. Enter a number from 1-",CNT,!,"Or enter the first letter, or enter the full name. Enter more than one",!,"qualifier separated by commas (ie 1,2 or P,A).",!
  1. Q
  1. ;
  1. OTHER(IBDX) ; -- allow input of an additional item
  1. N I,J,X,Y,DIR,DIRUT,DUOUT,SEL,SELX,NARR,DIC,DIE,DA,DR,GMPTUN,GMPTSUB,GMPTSHOW,XTLKGLB,XTLKHLP,XTLKKSCH,XTLKSAY,IBDLEX,IBDFILE,IBDIMP,IBDCSYS,IBDX
  1. ;
  1. ; -- strip the cpt code if modifiers are added cpt-mod,mod,mod...
  1. ;
  1. I IBDX["-" S IBDX=$P(IBDX,"-")
  1. I $G(IBDF("LEXICON")) D Q:'$D(IBDLEX)
  1. .I $D(^LEX)>1 S X="LEXSET" X ^%ZOSF("TEST") I $T D CONFIG^LEXSET("ICD","ICD") S IBDLEX=1
  1. .I '$D(IBDLEX) S X="GMPTSET" X ^%ZOSF("TEST") I $T D CONFIG^GMPTSET("GMPL","PL1") S IBDLEX=1
  1. .;D CONFIG^GMPTSET("ICD","ICD") (this is an alternate filter)
  1. S SELX=-1
  1. I '$G(IBDF("OTHER")) G OTHQ
  1. I $L($G(IBDX)) S X=IBDX S DIC(0)="EQMZ"
  1. S DIC("A")="Select Other "_$G(IBDASK)
  1. S DIC=$P(IBDF("OTHER"),"^") I $P(IBDF("OTHER"),"^",2)'="" S DIC("S")=$P(IBDF("OTHER"),"^",2,99)
  1. D ^DIC G OTHQ:+Y<1
  1. K DIC
  1. S SEL=Y
  1. W !!,$C(7),"WARNING: Item selected not from Encounter Form."
  1. ;
  1. I IBDF("PI")=$G(IBDF("PROVIDER PI")) W ! S SELX=$P($G(^VA(200,+Y,0)),"^",1)_"^^"_+Y_"^^^^1" G OTHQ
  1. ;
  1. W "...Entry of Narrative Required!",!
  1. S IBDFILE=+IBDF("OTHER")
  1. S:IBDFILE=81 DIR("B")=$P(Y(0),"^",2)
  1. S:IBDFILE=80 IBDIMP=$$IMPDATE^IBDUTICD(30),IBDCSYS=$S(DT'<IBDIMP:30,1:1),IBDX=$P($$ICDDATA^ICDXCODE(IBDCSYS,+Y,DT),U,4)
  1. S:IBDFILE=80 DIR("B")=$S($L(IBDX)<81:IBDX,1:$P(Y(0),"^",3))
  1. S:IBDFILE=357.69 DIR("B")=$P(Y(0),"^",3)
  1. I IBDFILE>9999999,IBDFILE<10000000 S DIR("B")=$P(Y(0),"^",1)
  1. S DIR(0)="FO^3:80",DIR("A")="Narrative" D ^DIR K DIR G:$G(DIRUT) OTHQ
  1. S NARR=Y
  1. ;
  1. S SELX=$S((IBDFILE<9999999)&(IBDFILE'=757.01):NARR_"^^"_$P(SEL,"^",2)_"^^^^1",1:NARR_"^^"_$P(SEL,"^",1)_"^^^^1")
  1. OTHQ Q $S(SELX=-1:"",1:SELX)
  1. ;
  1. PARTLST(ARY,NEXT,ANS) ; -- input has more than one match, prompt for which one
  1. N I,J,K,N,IBD,ANS2,SEL,CHOICE
  1. S SEL=0
  1. S NEXT=$E(NEXT,1,$L(NEXT)-1)_$C($A($E(NEXT,$L(NEXT)))-1)_"~"
  1. ;
  1. S J=0,K=NEXT F S K=$O(@ARY@(K)) Q:$E(K,1,$L(ANS))'=ANS D
  1. .S N=0 F S N=$O(@ARY@(K,N)) Q:'N D
  1. ..S J=J+1,IBD(J)=@ARY@(K,N),CHOICE=$$CHOICE^IBDFDE2(IBD(J))
  1. ..W !?6,J,?10,$S($P(CHOICE,"^",2)'="":$P(CHOICE,"^",2),1:$P(CHOICE,"^",3)),?20,$P(CHOICE,"^",1),?50," ",$P(CHOICE,"^",8)," ",$P(CHOICE,"^",4)
  1. ;
  1. ASKNUM I J<1 G PARTLQ
  1. W !," Choose 1-",J,": " R ANS2:DTIME
  1. I '$T!($E(ANS2,1)="^")!(ANS2="") S SEL="" G PARTLQ
  1. I $E(ANS2,1)="?" W !,"Enter a number from 1 - ",J G ASKNUM
  1. S ANS2=+ANS2
  1. I ANS2<1!(ANS2>J) G ASKNUM
  1. I $G(IBD(ANS2))="" G ASKNUM
  1. W !
  1. S SEL=$G(IBD(ANS2))
  1. PARTLQ Q SEL
  1. ;
  1. READ ; -- get input from list
  1. N ANS2
  1. G:CNT<1 READQ
  1. W !," Choose 1-",CNT,": " R ANS2:DTIME
  1. I '$T!($E(ANS2,1)="^") S IBQUIT=1 G READQ
  1. I $E(ANS2,1)="?" W !,"Enter a number from 1 - ",CNT," or return to see more." G READ
  1. S ANS2=+ANS2
  1. I ANS2<1!(ANS2>CNT) W $C(7),! G READ
  1. I $G(NUMBER(CNT))="" G READ
  1. W !
  1. READQ Q