IBEMTSCU ;ALB/RFJ-print billable types for visit copay ;23 Nov 01
;;2.0;INTEGRATED BILLING;**167,177,187,502**;21-MAR-94;Build 1
;;Per VHA Directive 2004-038, this routine should not be modified.
Q
;
EFFDT() ;effect date Visit Copay 2
Q 3021001 ;OCT 1,2002
;
ADD(IBSTOPCD,IBEFFDT,IBBILTYP,IBDESC,IBOVER) ; add a stop code to file 352.5
; ibstopcd = 3 or 6 digit stop code to add
; ibeffdt = effective date, internal fileman form (ex:3011206)
; if effective date is not passed, it uses today (dt)
; ibbiltyp = billable type (B=basic, S=specialty, N=non-billable)
; default is non-billable if a B or S is not passed
; ibdesc = description of stop code
; ibover = if the code belongs to Override table
; returns 1 if added, -#^error if not added
;
N D,D0,DA,DI,DIC,DIE,DLAYGO,DQ,DR,IBDA,X,Y,IBZ
;
; check length of stop code
I '(($L(IBSTOPCD)=3)!($L(IBSTOPCD)=6)) Q "-1^STOP CODE "_IBSTOPCD_" NOT 3 OR 6 CHARACTERS IN LENGTH."
;
; change billable type code to match set of codes in file 352.5
S IBBILTYP=$S(IBBILTYP="B":1,IBBILTYP="S":2,1:0)
;
S (DIC,DIE)="^IBE(352.5,",DIC(0)="L",DLAYGO=352.5
;
; check to see if entry is in the file
S IBDA=$O(^IBE(352.5,"AEFFDT",IBSTOPCD,-IBEFFDT,0))
I IBDA S IBZ=$G(^IBE(352.5,IBDA,0)) D Q 1
. S DR=""
. ; check to see if the correct billable type is set correctly
. I $P(IBZ,"^",3)'=IBBILTYP S DR=".03////"_IBBILTYP_";"
. ; check description
. I $P(IBZ,"^",4)'=$E(IBDESC,1,30) S DR=DR_".04////"_$E(IBDESC,1,30)
. ; if not, change it
. I $L(DR) S DA=IBDA D ^DIE
;
; add entry to file 352.5
S X=IBSTOPCD
S DIC("DR")=".02////"_IBEFFDT_";.03////"_IBBILTYP_";.04////"_$E(IBDESC,1,30)_";"
S:$G(IBOVER)=1 DIC("DR")=DIC("DR")_".05////1;"
D FILE^DICN
Q 1
;
;
DIQ407(DA,DR) ; diq call to retrieve data for dr fields in file 40.7
N D0,DIC,DIQ,DIQ2,YY
K IBSCDATA(40.7,DA)
I $G(DR)="" S DR=".01:4;"
S DIQ(0)="IE",DIC="^DIC(40.7,",DIQ="IBSCDATA" D EN^DIQ1
Q
;
;0 - active
ISINACT(IBCODE) ;
Q:$L(IBCODE)=6 $$INACTIVE($E(IBCODE,1,3))+$$INACTIVE($E(IBCODE,4,6))
Q $$INACTIVE(IBCODE)
;
INACTIVE(IBSTCODE) ; return 1 if inactive in file 40.7
; also, return ibscdata(da for stop code entries in 40.7)
N DA,IBSCDATA,RESULT
;
; default is inactive
S RESULT=1
;
S DA=0 F S DA=$O(^DIC(40.7,"C",IBSTCODE,DA)) Q:'DA D
. D DIQ407(DA,2)
. I 'IBSCDATA(40.7,DA,2,"I") S RESULT=0 Q
. ;IB*502 ticket 862861 only prevent selection if visit date is after the inactive date
. I IBFR<+$G(IBSCDATA(40.7,DA,2,"I")) S RESULT=0
;
Q RESULT
;
;
ASK() ; ask if the user wants to enter a stop code or select a clinic
; return will be what entry point to use
N DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT
S DIR(0)="S^C:Clinic;S:Stop Code" D ^DIR
Q $S(Y="C":"C",Y="S":"S",1:"")
;
ASKSCODE(IBPROMPT) ; ask and return selected stop code from file 352.5
; ibprompt = optional prompt to display
;
N DIC,DILN,I,X,Y,DTOUT,DUOUT,DIRUT,DIROUT
S DIC="^IBE(352.5,",DIC(0)="QEAM"
S DIC("A")="Select OUTPATIENT VISIT STOP CODE: "
I $G(IBPROMPT)'="" S DIC("A")=IBPROMPT
S DIC("S")="I $$STOPSCRN^IBEMTSCU(Y)"
;
W ! D ^DIC
I Y<1 Q -1
Q +Y
;
;
STOPSCRN(IBX) ; screens out so only active and current ones are selectable
;
; if we have no from date, all are selectable
I '$G(IBFR) Q 1
;
N IBZ,IBAX,IBS,IBEFFDT
S IBZ=$G(^IBE(352.5,IBX,0)),IBS=$P(IBZ,"^")
;
; is the effective date for this entry in the future?
I $P(IBZ,"^",2)>IBFR Q 0
;
; get the effective date for stop code and visit date
S IBEFFDT=$O(^IBE(352.5,"AEFFDT",IBS,-(IBFR+.1)))
I 'IBEFFDT Q 0
;
; get the billable entry to compare
S IBAX=$O(^IBE(352.5,"AEFFDT",IBS,IBEFFDT,0))
;
Q $S(IBX=IBAX:1,1:0)
;
ASKSC(IBVISTDT) ; ask for a clinic to look up the stop code
; it will prompt for a clinic selection, and return the stop
; code number in 352.5 associated with the clinic
N DIC,X,Y,IB407,IBEFDT,IBCLIN
S DIC="^SC(",DIC(0)="AEMQZ",DIC("A")="Select CLINIC: ",DIC("S")="I $P(^(0),U,3)=""C""" D ^DIC Q:Y<1 -1
S IBCLIN=+Y
;primary
S IB407=$P(Y(0),"^",7)
S IBCODE1=$$GETCODE(IB407)
; if < eff date
Q:IBVISTDT<$$EFFDT() $$GET3525(+IBCODE1,0,IBVISTDT)
;secondary
; get the secondary stop code value
S IBCODE2=$$GETCRED(IBCLIN)
;return proper IEN of #352.5
Q +$$GET3525(IBCODE1,IBCODE2,IBVISTDT)
;
;
GETTYPE(IBSTOPCD,IBVISTDT) ; lookup billable type
; input ibstopcd = stop code (.01 field entry in file 352.5)
; ibvistdt = visit date in fileman format
;
; returns -1 = stop code/effective date not found or defined
; 0 = non-billable
; 1 = basic rate
; 2 = specialty rate
;
N DA,IBEFFDT,RESULT
;
; get the effective date for stop code and visit date
S IBEFFDT=$O(^IBE(352.5,"AEFFDT",IBSTOPCD,-(IBVISTDT+.1)))
I 'IBEFFDT Q -1
;
; get the billable type
S DA=$O(^IBE(352.5,"AEFFDT",IBSTOPCD,IBEFFDT,0))
I 'DA Q -1
;
; get the billable type
S RESULT=+$P($G(^IBE(352.5,DA,0)),"^",3)
Q RESULT
;
;
GETSC(IBSL,IBVISTDT) ; return the ien of the entry in file 352.5.
; ibsl is the clinic stop code in 409.68. find the matching
; entry in file 352.5. the 352.5 entry is populated in the 350 field
; for reference using the ibstopda variable
; input ibsl = 409.68:ien
N IB407,IBCLIN,IBCODE1,IBCODE2
I $P(IBSL,":")'=409.68 Q ""
;primary
;this is the ien for file 40.7 (dbia402)
S IB407=+$P($G(^SCE(+$P(IBSL,":",2),0)),"^",3)
;get the primary stop code value
S IBCODE1=+$$GETCODE(IB407)
;if < eff date
Q:IBVISTDT<$$EFFDT() $$GET3525(+IBCODE1,0,IBVISTDT)
;secondary
;get clinic(#44) pointer from #409.68
S IBCLIN=+$P($G(^SCE(+$P(IBSL,":",2),0)),"^",4)
;get the secondary stop code value
S IBCODE2=+$$GETCRED(IBCLIN)
;return proper IEN of #352.5
Q $$GET3525(+IBCODE1,+IBCODE2,IBVISTDT)
;
;apply business rules, select appropr. code in #352.5 and return its IEN
;if not found then return ""
GET3525(IBCODE1,IBCODE2,IBVISTDT) ;
Q:+IBCODE1=0 "" ;must be defined as a required field in #44
Q:$L(+IBCODE1)'=3!(IBCODE1<0) ""
I $L(+IBCODE2)'=3!(IBCODE2<0) S IBCODE2=0
N IB6DIG
N IBEFDT1,IBIEN1,IBOVER1,IBTYPE1
N IBEFDT2,IBIEN2,IBOVER2,IBTYPE2
S (IBIEN1,IBIEN2,IBOVER1,IBOVER2)=0
;------ find appropriate ien in file #352.5
S IB6DIG=$S(IBCODE2>0:IBCODE1_IBCODE2,1:IBCODE1)
;in the #352.5 with appropriate eff date?
S IBEFDT1=+$O(^IBE(352.5,"AEFFDT",IB6DIG,-(IBVISTDT+.1)))
;
;A) if found and it is 6 or 3 digit code
I IBEFDT1 D Q:IBIEN1>0 IBIEN1
. ;get the entry in 352.5
. S IBIEN1=+$O(^IBE(352.5,"AEFFDT",IB6DIG,IBEFDT1,0))
;
;B) if not found and it is 3 digit - return nothing, BASIC applies
I +IBCODE2=0 Q ""
;
;C) if not found and it is 6 digit - try each separately
;-- primary code
;in the #352.5 "override" tables with appropriate eff date?
S IBEFDT1=+$O(^IBE(352.5,"AEFFDT",IBCODE1,-(IBVISTDT+.1)))
I IBEFDT1 D
. ;get the entry in 352.5
. S IBIEN1=+$O(^IBE(352.5,"AEFFDT",IBCODE1,IBEFDT1,0))
. Q:IBIEN1=0
. S IBOVER1=+$P($G(^IBE(352.5,IBIEN1,0)),"^",5)
. S IBTYPE1=+$P($G(^IBE(352.5,IBIEN1,0)),"^",3)
;-- secondary code
;in the #352.5 "override" tables with appropriate eff date?
S IBEFDT2=+$O(^IBE(352.5,"AEFFDT",IBCODE2,-(IBVISTDT+.1)))
I IBEFDT2 D
. ;get the entry in 352.5
. S IBIEN2=+$O(^IBE(352.5,"AEFFDT",IBCODE2,IBEFDT2,0))
. Q:IBIEN2=0
. S IBOVER2=+$P($G(^IBE(352.5,IBIEN2,0)),"^",5)
. S IBTYPE2=+$P($G(^IBE(352.5,IBIEN2,0)),"^",3)
;
; If not found in override tables
; - AND primary is not in #352.5 then return nothing, BASIC applies
; - AND primary is in #352.5 then return IBIEN1
I IBOVER1=0,IBOVER2=0 Q $S(IBIEN1>0:IBIEN1,1:"")
;
I IBOVER1=0,IBOVER2'=0 Q +IBIEN2
;
I IBOVER1'=0,IBOVER2=0 Q +IBIEN1
;
; If IBOVER1'=0,IBOVER2'=0
I IBTYPE1=0 Q +IBIEN1 ;NON
I IBTYPE2=0 Q +IBIEN2 ;NON
I IBTYPE1=2 Q +IBIEN1 ;SPEC
I IBTYPE2=2 Q +IBIEN2 ;SPEC
Q +IBIEN1 ;BASIC
;
;
OPT ; perform outpatient copay edits for visits after 11/29/01
; called from IBECEA3
;
; return IBSTOPDA (if selected) to be stored in file 350
K IBSTOPDA,IBANS
;
; ask selection by clinic or stop code
S IBANS=$$ASK I '$L(IBANS) W !!,"Charge NOT added." S IBY=-1 Q
;
; ask clinic stop to calc charges
S IBSTOPDA=+$S(IBANS="S":$$ASKSCODE,1:$$ASKSC(IBFR))
I IBSTOPDA<0 S IBY=-1 W !!,"Charge NOT added." K IBSTOPDA Q
;
; user selected a non-billable clinic stop
I IBSTOPDA>0,'$P($G(^IBE(352.5,IBSTOPDA,0)),"^",3) W !?5,"********** This is a NON-BILLABLE Clinic Stop **********",!?5,"Select an active billable clinic stop or press RETURN to exit." G OPT
; user selected an inactive stop code
I IBSTOPDA>0,$$ISINACT($P($G(^IBE(352.5,IBSTOPDA,0)),"^")) W !?5,"********** This is a INACTIVE Clinic Stop in file #40.7 **********",!?5,"Select an active billable clinic stop or press RETURN to exit." G OPT
; IB*502 prevent selection of Secondary stop codes
I IBSTOPDA>0,$$ISSEC($P($G(^IBE(352.5,IBSTOPDA,0)),"^")) W !?5,"********** This is a SECONDARY Clinic Stop in file #40.7 **********",!?5,"Select an active billable clinic stop or press RETURN to exit." G OPT
; *** get the charge ***
; return IBTO, IBUNIT, IBEVDA, IBCHG for processing in IBECEAU3
N IBDT,IBTYPE,IBX
S (IBDT,IBTO)=IBFR ;visit date
S IBX="O" ;O for outpatient
S IBUNIT=1,IBEVDA="*"
S IBTYPE=1 ;BASIC by default
S:IBSTOPDA>0 IBTYPE=$P(^IBE(352.5,IBSTOPDA,0),"^",3) ;type of charge, basic or specialty
D TYPE^IBAUTL2
I IBY<0 Q
;
W !!,"Charge to be billed under the ",$$TYPE^IBEMTSCR($P($G(^IBE(352.5,IBSTOPDA,0)),"^",3))," Rate --> $",$J(IBCHG,0,2)
Q
;
;Get credit pair (secondary code) from #44
GETCRED(IBCLIN) ;
N IB407
; get credit pair (secondary stop code pointer) from #44
S IB407=+$P($G(^SC(IBCLIN,0)),"^",18)
; if IB407 is defined, get the stop code in IBSCDATA(40.7,IB407,1,"E")
Q $$GETCODE(IB407)
;
GETCODE(IB407) ;
; get the stop code in IBSCDATA(40.7,IB407,1,"E")
N IBCODE,IBSCDATA
S IBCODE=0
I IB407'=0 D DIQ407(IB407,1) D
. I $G(IBSCDATA(40.7,IB407,1,"E"))="" Q
. S IBCODE=+$G(IBSCDATA(40.7,IB407,1,"E"))
. S:$L(+IBCODE)'=3!(IBCODE<0) IBCODE=0
Q IBCODE
;
ISSEC(IBCODE) ;check if the code has secondary restriction type in DSS IB*502
N DA,IBSCDATA,IBRESULT
;
; default OK
S IBRESULT=0
;
S DA=0 F S DA=$O(^DIC(40.7,"C",IBCODE,DA)) Q:'DA D
. D DIQ407(DA,"5:6;")
. I $G(IBSCDATA(40.7,DA,5,"I"))="S" D
.. I $G(IBSCDATA(40.7,DA,6,"I"))<=IBFR S IBRESULT=1
;
Q IBRESULT
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBEMTSCU 10669 printed Oct 16, 2024@18:22:49 Page 2
IBEMTSCU ;ALB/RFJ-print billable types for visit copay ;23 Nov 01
+1 ;;2.0;INTEGRATED BILLING;**167,177,187,502**;21-MAR-94;Build 1
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 QUIT
+4 ;
EFFDT() ;effect date Visit Copay 2
+1 ;OCT 1,2002
QUIT 3021001
+2 ;
ADD(IBSTOPCD,IBEFFDT,IBBILTYP,IBDESC,IBOVER) ; add a stop code to file 352.5
+1 ; ibstopcd = 3 or 6 digit stop code to add
+2 ; ibeffdt = effective date, internal fileman form (ex:3011206)
+3 ; if effective date is not passed, it uses today (dt)
+4 ; ibbiltyp = billable type (B=basic, S=specialty, N=non-billable)
+5 ; default is non-billable if a B or S is not passed
+6 ; ibdesc = description of stop code
+7 ; ibover = if the code belongs to Override table
+8 ; returns 1 if added, -#^error if not added
+9 ;
+10 NEW D,D0,DA,DI,DIC,DIE,DLAYGO,DQ,DR,IBDA,X,Y,IBZ
+11 ;
+12 ; check length of stop code
+13 IF '(($LENGTH(IBSTOPCD)=3)!($LENGTH(IBSTOPCD)=6))
QUIT "-1^STOP CODE "_IBSTOPCD_" NOT 3 OR 6 CHARACTERS IN LENGTH."
+14 ;
+15 ; change billable type code to match set of codes in file 352.5
+16 SET IBBILTYP=$SELECT(IBBILTYP="B":1,IBBILTYP="S":2,1:0)
+17 ;
+18 SET (DIC,DIE)="^IBE(352.5,"
SET DIC(0)="L"
SET DLAYGO=352.5
+19 ;
+20 ; check to see if entry is in the file
+21 SET IBDA=$ORDER(^IBE(352.5,"AEFFDT",IBSTOPCD,-IBEFFDT,0))
+22 IF IBDA
SET IBZ=$GET(^IBE(352.5,IBDA,0))
Begin DoDot:1
+23 SET DR=""
+24 ; check to see if the correct billable type is set correctly
+25 IF $PIECE(IBZ,"^",3)'=IBBILTYP
SET DR=".03////"_IBBILTYP_";"
+26 ; check description
+27 IF $PIECE(IBZ,"^",4)'=$EXTRACT(IBDESC,1,30)
SET DR=DR_".04////"_$EXTRACT(IBDESC,1,30)
+28 ; if not, change it
+29 IF $LENGTH(DR)
SET DA=IBDA
DO ^DIE
End DoDot:1
QUIT 1
+30 ;
+31 ; add entry to file 352.5
+32 SET X=IBSTOPCD
+33 SET DIC("DR")=".02////"_IBEFFDT_";.03////"_IBBILTYP_";.04////"_$EXTRACT(IBDESC,1,30)_";"
+34 if $GET(IBOVER)=1
SET DIC("DR")=DIC("DR")_".05////1;"
+35 DO FILE^DICN
+36 QUIT 1
+37 ;
+38 ;
DIQ407(DA,DR) ; diq call to retrieve data for dr fields in file 40.7
+1 NEW D0,DIC,DIQ,DIQ2,YY
+2 KILL IBSCDATA(40.7,DA)
+3 IF $GET(DR)=""
SET DR=".01:4;"
+4 SET DIQ(0)="IE"
SET DIC="^DIC(40.7,"
SET DIQ="IBSCDATA"
DO EN^DIQ1
+5 QUIT
+6 ;
+7 ;0 - active
ISINACT(IBCODE) ;
+1 if $LENGTH(IBCODE)=6
QUIT $$INACTIVE($EXTRACT(IBCODE,1,3))+$$INACTIVE($EXTRACT(IBCODE,4,6))
+2 QUIT $$INACTIVE(IBCODE)
+3 ;
INACTIVE(IBSTCODE) ; return 1 if inactive in file 40.7
+1 ; also, return ibscdata(da for stop code entries in 40.7)
+2 NEW DA,IBSCDATA,RESULT
+3 ;
+4 ; default is inactive
+5 SET RESULT=1
+6 ;
+7 SET DA=0
FOR
SET DA=$ORDER(^DIC(40.7,"C",IBSTCODE,DA))
if 'DA
QUIT
Begin DoDot:1
+8 DO DIQ407(DA,2)
+9 IF 'IBSCDATA(40.7,DA,2,"I")
SET RESULT=0
QUIT
+10 ;IB*502 ticket 862861 only prevent selection if visit date is after the inactive date
+11 IF IBFR<+$GET(IBSCDATA(40.7,DA,2,"I"))
SET RESULT=0
End DoDot:1
+12 ;
+13 QUIT RESULT
+14 ;
+15 ;
ASK() ; ask if the user wants to enter a stop code or select a clinic
+1 ; return will be what entry point to use
+2 NEW DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT
+3 SET DIR(0)="S^C:Clinic;S:Stop Code"
DO ^DIR
+4 QUIT $SELECT(Y="C":"C",Y="S":"S",1:"")
+5 ;
ASKSCODE(IBPROMPT) ; ask and return selected stop code from file 352.5
+1 ; ibprompt = optional prompt to display
+2 ;
+3 NEW DIC,DILN,I,X,Y,DTOUT,DUOUT,DIRUT,DIROUT
+4 SET DIC="^IBE(352.5,"
SET DIC(0)="QEAM"
+5 SET DIC("A")="Select OUTPATIENT VISIT STOP CODE: "
+6 IF $GET(IBPROMPT)'=""
SET DIC("A")=IBPROMPT
+7 SET DIC("S")="I $$STOPSCRN^IBEMTSCU(Y)"
+8 ;
+9 WRITE !
DO ^DIC
+10 IF Y<1
QUIT -1
+11 QUIT +Y
+12 ;
+13 ;
STOPSCRN(IBX) ; screens out so only active and current ones are selectable
+1 ;
+2 ; if we have no from date, all are selectable
+3 IF '$GET(IBFR)
QUIT 1
+4 ;
+5 NEW IBZ,IBAX,IBS,IBEFFDT
+6 SET IBZ=$GET(^IBE(352.5,IBX,0))
SET IBS=$PIECE(IBZ,"^")
+7 ;
+8 ; is the effective date for this entry in the future?
+9 IF $PIECE(IBZ,"^",2)>IBFR
QUIT 0
+10 ;
+11 ; get the effective date for stop code and visit date
+12 SET IBEFFDT=$ORDER(^IBE(352.5,"AEFFDT",IBS,-(IBFR+.1)))
+13 IF 'IBEFFDT
QUIT 0
+14 ;
+15 ; get the billable entry to compare
+16 SET IBAX=$ORDER(^IBE(352.5,"AEFFDT",IBS,IBEFFDT,0))
+17 ;
+18 QUIT $SELECT(IBX=IBAX:1,1:0)
+19 ;
ASKSC(IBVISTDT) ; ask for a clinic to look up the stop code
+1 ; it will prompt for a clinic selection, and return the stop
+2 ; code number in 352.5 associated with the clinic
+3 NEW DIC,X,Y,IB407,IBEFDT,IBCLIN
+4 SET DIC="^SC("
SET DIC(0)="AEMQZ"
SET DIC("A")="Select CLINIC: "
SET DIC("S")="I $P(^(0),U,3)=""C"""
DO ^DIC
if Y<1
QUIT -1
+5 SET IBCLIN=+Y
+6 ;primary
+7 SET IB407=$PIECE(Y(0),"^",7)
+8 SET IBCODE1=$$GETCODE(IB407)
+9 ; if < eff date
+10 if IBVISTDT<$$EFFDT()
QUIT $$GET3525(+IBCODE1,0,IBVISTDT)
+11 ;secondary
+12 ; get the secondary stop code value
+13 SET IBCODE2=$$GETCRED(IBCLIN)
+14 ;return proper IEN of #352.5
+15 QUIT +$$GET3525(IBCODE1,IBCODE2,IBVISTDT)
+16 ;
+17 ;
GETTYPE(IBSTOPCD,IBVISTDT) ; lookup billable type
+1 ; input ibstopcd = stop code (.01 field entry in file 352.5)
+2 ; ibvistdt = visit date in fileman format
+3 ;
+4 ; returns -1 = stop code/effective date not found or defined
+5 ; 0 = non-billable
+6 ; 1 = basic rate
+7 ; 2 = specialty rate
+8 ;
+9 NEW DA,IBEFFDT,RESULT
+10 ;
+11 ; get the effective date for stop code and visit date
+12 SET IBEFFDT=$ORDER(^IBE(352.5,"AEFFDT",IBSTOPCD,-(IBVISTDT+.1)))
+13 IF 'IBEFFDT
QUIT -1
+14 ;
+15 ; get the billable type
+16 SET DA=$ORDER(^IBE(352.5,"AEFFDT",IBSTOPCD,IBEFFDT,0))
+17 IF 'DA
QUIT -1
+18 ;
+19 ; get the billable type
+20 SET RESULT=+$PIECE($GET(^IBE(352.5,DA,0)),"^",3)
+21 QUIT RESULT
+22 ;
+23 ;
GETSC(IBSL,IBVISTDT) ; return the ien of the entry in file 352.5.
+1 ; ibsl is the clinic stop code in 409.68. find the matching
+2 ; entry in file 352.5. the 352.5 entry is populated in the 350 field
+3 ; for reference using the ibstopda variable
+4 ; input ibsl = 409.68:ien
+5 NEW IB407,IBCLIN,IBCODE1,IBCODE2
+6 IF $PIECE(IBSL,":")'=409.68
QUIT ""
+7 ;primary
+8 ;this is the ien for file 40.7 (dbia402)
+9 SET IB407=+$PIECE($GET(^SCE(+$PIECE(IBSL,":",2),0)),"^",3)
+10 ;get the primary stop code value
+11 SET IBCODE1=+$$GETCODE(IB407)
+12 ;if < eff date
+13 if IBVISTDT<$$EFFDT()
QUIT $$GET3525(+IBCODE1,0,IBVISTDT)
+14 ;secondary
+15 ;get clinic(#44) pointer from #409.68
+16 SET IBCLIN=+$PIECE($GET(^SCE(+$PIECE(IBSL,":",2),0)),"^",4)
+17 ;get the secondary stop code value
+18 SET IBCODE2=+$$GETCRED(IBCLIN)
+19 ;return proper IEN of #352.5
+20 QUIT $$GET3525(+IBCODE1,+IBCODE2,IBVISTDT)
+21 ;
+22 ;apply business rules, select appropr. code in #352.5 and return its IEN
+23 ;if not found then return ""
GET3525(IBCODE1,IBCODE2,IBVISTDT) ;
+1 ;must be defined as a required field in #44
if +IBCODE1=0
QUIT ""
+2 if $LENGTH(+IBCODE1)'=3!(IBCODE1<0)
QUIT ""
+3 IF $LENGTH(+IBCODE2)'=3!(IBCODE2<0)
SET IBCODE2=0
+4 NEW IB6DIG
+5 NEW IBEFDT1,IBIEN1,IBOVER1,IBTYPE1
+6 NEW IBEFDT2,IBIEN2,IBOVER2,IBTYPE2
+7 SET (IBIEN1,IBIEN2,IBOVER1,IBOVER2)=0
+8 ;------ find appropriate ien in file #352.5
+9 SET IB6DIG=$SELECT(IBCODE2>0:IBCODE1_IBCODE2,1:IBCODE1)
+10 ;in the #352.5 with appropriate eff date?
+11 SET IBEFDT1=+$ORDER(^IBE(352.5,"AEFFDT",IB6DIG,-(IBVISTDT+.1)))
+12 ;
+13 ;A) if found and it is 6 or 3 digit code
+14 IF IBEFDT1
Begin DoDot:1
+15 ;get the entry in 352.5
+16 SET IBIEN1=+$ORDER(^IBE(352.5,"AEFFDT",IB6DIG,IBEFDT1,0))
End DoDot:1
if IBIEN1>0
QUIT IBIEN1
+17 ;
+18 ;B) if not found and it is 3 digit - return nothing, BASIC applies
+19 IF +IBCODE2=0
QUIT ""
+20 ;
+21 ;C) if not found and it is 6 digit - try each separately
+22 ;-- primary code
+23 ;in the #352.5 "override" tables with appropriate eff date?
+24 SET IBEFDT1=+$ORDER(^IBE(352.5,"AEFFDT",IBCODE1,-(IBVISTDT+.1)))
+25 IF IBEFDT1
Begin DoDot:1
+26 ;get the entry in 352.5
+27 SET IBIEN1=+$ORDER(^IBE(352.5,"AEFFDT",IBCODE1,IBEFDT1,0))
+28 if IBIEN1=0
QUIT
+29 SET IBOVER1=+$PIECE($GET(^IBE(352.5,IBIEN1,0)),"^",5)
+30 SET IBTYPE1=+$PIECE($GET(^IBE(352.5,IBIEN1,0)),"^",3)
End DoDot:1
+31 ;-- secondary code
+32 ;in the #352.5 "override" tables with appropriate eff date?
+33 SET IBEFDT2=+$ORDER(^IBE(352.5,"AEFFDT",IBCODE2,-(IBVISTDT+.1)))
+34 IF IBEFDT2
Begin DoDot:1
+35 ;get the entry in 352.5
+36 SET IBIEN2=+$ORDER(^IBE(352.5,"AEFFDT",IBCODE2,IBEFDT2,0))
+37 if IBIEN2=0
QUIT
+38 SET IBOVER2=+$PIECE($GET(^IBE(352.5,IBIEN2,0)),"^",5)
+39 SET IBTYPE2=+$PIECE($GET(^IBE(352.5,IBIEN2,0)),"^",3)
End DoDot:1
+40 ;
+41 ; If not found in override tables
+42 ; - AND primary is not in #352.5 then return nothing, BASIC applies
+43 ; - AND primary is in #352.5 then return IBIEN1
+44 IF IBOVER1=0
IF IBOVER2=0
QUIT $SELECT(IBIEN1>0:IBIEN1,1:"")
+45 ;
+46 IF IBOVER1=0
IF IBOVER2'=0
QUIT +IBIEN2
+47 ;
+48 IF IBOVER1'=0
IF IBOVER2=0
QUIT +IBIEN1
+49 ;
+50 ; If IBOVER1'=0,IBOVER2'=0
+51 ;NON
IF IBTYPE1=0
QUIT +IBIEN1
+52 ;NON
IF IBTYPE2=0
QUIT +IBIEN2
+53 ;SPEC
IF IBTYPE1=2
QUIT +IBIEN1
+54 ;SPEC
IF IBTYPE2=2
QUIT +IBIEN2
+55 ;BASIC
QUIT +IBIEN1
+56 ;
+57 ;
OPT ; perform outpatient copay edits for visits after 11/29/01
+1 ; called from IBECEA3
+2 ;
+3 ; return IBSTOPDA (if selected) to be stored in file 350
+4 KILL IBSTOPDA,IBANS
+5 ;
+6 ; ask selection by clinic or stop code
+7 SET IBANS=$$ASK
IF '$LENGTH(IBANS)
WRITE !!,"Charge NOT added."
SET IBY=-1
QUIT
+8 ;
+9 ; ask clinic stop to calc charges
+10 SET IBSTOPDA=+$SELECT(IBANS="S":$$ASKSCODE,1:$$ASKSC(IBFR))
+11 IF IBSTOPDA<0
SET IBY=-1
WRITE !!,"Charge NOT added."
KILL IBSTOPDA
QUIT
+12 ;
+13 ; user selected a non-billable clinic stop
+14 IF IBSTOPDA>0
IF '$PIECE($GET(^IBE(352.5,IBSTOPDA,0)),"^",3)
WRITE !?5,"********** This is a NON-BILLABLE Clinic Stop **********",!?5,"Select an active billable clinic stop or press RETURN to exit."
GOTO OPT
+15 ; user selected an inactive stop code
+16 IF IBSTOPDA>0
IF $$ISINACT($PIECE($GET(^IBE(352.5,IBSTOPDA,0)),"^"))
WRITE !?5,"********** This is a INACTIVE Clinic Stop in file #40.7 **********",!?5,"Select an active billable clinic stop or press RETURN to exit."
GOTO OPT
+17 ; IB*502 prevent selection of Secondary stop codes
+18 IF IBSTOPDA>0
IF $$ISSEC($PIECE($GET(^IBE(352.5,IBSTOPDA,0)),"^"))
WRITE !?5,"********** This is a SECONDARY Clinic Stop in file #40.7 **********",!?5,"Select an active billable clinic stop or press RETURN to exit."
GOTO OPT
+19 ; *** get the charge ***
+20 ; return IBTO, IBUNIT, IBEVDA, IBCHG for processing in IBECEAU3
+21 NEW IBDT,IBTYPE,IBX
+22 ;visit date
SET (IBDT,IBTO)=IBFR
+23 ;O for outpatient
SET IBX="O"
+24 SET IBUNIT=1
SET IBEVDA="*"
+25 ;BASIC by default
SET IBTYPE=1
+26 ;type of charge, basic or specialty
if IBSTOPDA>0
SET IBTYPE=$PIECE(^IBE(352.5,IBSTOPDA,0),"^",3)
+27 DO TYPE^IBAUTL2
+28 IF IBY<0
QUIT
+29 ;
+30 WRITE !!,"Charge to be billed under the ",$$TYPE^IBEMTSCR($PIECE($GET(^IBE(352.5,IBSTOPDA,0)),"^",3))," Rate --> $",$JUSTIFY(IBCHG,0,2)
+31 QUIT
+32 ;
+33 ;Get credit pair (secondary code) from #44
GETCRED(IBCLIN) ;
+1 NEW IB407
+2 ; get credit pair (secondary stop code pointer) from #44
+3 SET IB407=+$PIECE($GET(^SC(IBCLIN,0)),"^",18)
+4 ; if IB407 is defined, get the stop code in IBSCDATA(40.7,IB407,1,"E")
+5 QUIT $$GETCODE(IB407)
+6 ;
GETCODE(IB407) ;
+1 ; get the stop code in IBSCDATA(40.7,IB407,1,"E")
+2 NEW IBCODE,IBSCDATA
+3 SET IBCODE=0
+4 IF IB407'=0
DO DIQ407(IB407,1)
Begin DoDot:1
+5 IF $GET(IBSCDATA(40.7,IB407,1,"E"))=""
QUIT
+6 SET IBCODE=+$GET(IBSCDATA(40.7,IB407,1,"E"))
+7 if $LENGTH(+IBCODE)'=3!(IBCODE<0)
SET IBCODE=0
End DoDot:1
+8 QUIT IBCODE
+9 ;
ISSEC(IBCODE) ;check if the code has secondary restriction type in DSS IB*502
+1 NEW DA,IBSCDATA,IBRESULT
+2 ;
+3 ; default OK
+4 SET IBRESULT=0
+5 ;
+6 SET DA=0
FOR
SET DA=$ORDER(^DIC(40.7,"C",IBCODE,DA))
if 'DA
QUIT
Begin DoDot:1
+7 DO DIQ407(DA,"5:6;")
+8 IF $GET(IBSCDATA(40.7,DA,5,"I"))="S"
Begin DoDot:2
+9 IF $GET(IBSCDATA(40.7,DA,6,"I"))<=IBFR
SET IBRESULT=1
End DoDot:2
End DoDot:1
+10 ;
+11 QUIT IBRESULT
+12 ;