IBAECC ;LL/ELZ - LONG TERM CARE CLOCK MAINTANCE ; 05-FEB-02
;;2.0;INTEGRATED BILLING;**176,199,728,729**;21-MAR-94;Build 8
;; Per VHA Directive 10-93-142, this routine should not be modified
;
; this routine will allow users to perform LTC copay clock
; maintance. Every function for the user will be read and evaluated
; before actually filed in the LTC Copay Clock.
;
OPT ; menu option main entry point
;
N ADDED,DFN,DIC,IBCL,IBLTCX,IBLTCZ,IBOPCL,IBSTDT,IBRES,IBX,IBY,VADM,X,Y ; IB*2.0*729
;
; select a patient (screen out patients with no LTC clock and are
; not LTC patients.
OPTA K DIC,X,Y,DFN,IBLTCX ; IB*2.0*729
N DPTNOFZY S DPTNOFZY=1 ;Suppress PATIENT file fuzzy lookups
S DIC="^DPT(",DIC(0)="AEMNQ",DIC("S")="I $$SCREEN^IBAECC(Y)" W ! D ^DIC G:Y<1 EX
S DFN=+Y D DEM^VADPT
;
; is there a clock, if not offer to add
; IB*2.0*728
S ADDED=0
I '$D(^IBA(351.81,"C",DFN)) D G:$G(IBLTCX)<1 OPTA
.W !!,"The patient ",VADM(1)," has no LTC clock on file."
.S IBRES=$$ASKCRU(0) Q:IBRES'>0
.S IBSTDT=$$ASKSTDT(0) Q:IBSTDT'>0 ; start date IB*2.0*728
.; create clock entry
.S IBLTCX=+$$ADDCL^IBAECU(DFN,IBSTDT) S:IBLTCX>0 ADDED=1
.Q
;
I 'ADDED S IBRES=$$ASKCRU(1) D:IBRES=1 G:IBRES'>0 OPTA
.; check for existing open clock
.S IBOPCL=$$FNDOPEN^IBAECU4(DFN) I IBOPCL>0 S IBLTCX=$$OPTB(DFN,IBOPCL,$$GET1^DIQ(351.81,IBOPCL_",",.04,"I"))
.Q
; we get here either if user chose to update esitsing clock or brand new clock was added (there was no existing clock to close)
; choose a clock
I $G(IBLTCX)<1 S IBLTCX=$$ASKCLK^IBAECP(DFN,1) G:$G(IBLTCX)<1 OPTA
;
S IBLTCZ=^IBA(351.81,IBLTCX,0) D DISPLAY,EDIT
G OPTA
;
OPTB(DFN,IBOPCL,IBOEDT,IBDEFDT) ; close existing clock and open the new one, also called from IB CANCEL IB*2.0*728
;
; DFN - patient DFN
; IBOPCL - old clock ien (file 351.81)
; IBOEDT - old clock exp. date (internal)
; IBDEFDT - default start date (optional)
;
; returns 1 if new clock was opened, 0 otherwise
;
N IBLTCX,IBOIENS,IBOSTDTE,IBSTDT,Z
S IBLTCX=0
S IBOIENS=IBOPCL_",",IBOSTDTE=$$GET1^DIQ(351.81,IBOIENS,.03)
W !!,"WARNING!!!"
W !,"Creating a new clock for this patient will close the existing open LTC Clock.",!
I $$ASKYN()'>0 D Q 0 ; ask for confirmation
.W !!,"No new clock created."
.W !,"Existing Clock for the Period starting on ",IBOSTDTE," is still in effect.",!
.D ASKCONT
.Q
S IBSTDT=$$ASKSTDT(+$G(IBDEFDT)) Q:IBSTDT'>0 0 ; start date
I IBSTDT'>IBOEDT D Q 0
.S Z=$$FMTE^XLFDT(IBOEDT)
.W !!,"This patient's existing clock ends on ",Z,"."
.W !!,"Unable to create a new clock for this patient until after ",Z
.W !," at the earliest.",!
.D ASKCONT
.Q
L +^IBA(351.81,IBOPCL):5 I '$T Q 0
D CLOSECLK^IBAECU4(IBOPCL,DFN) ; close old clock
L -^IBA(351.81,IBOPCL)
W !!,"Clock for the Period starting on ",IBOSTDTE," is now closed."
S IBLTCX=+$$ADDCL^IBAECU(DFN,IBSTDT) ; create new clock
I IBLTCX>0 W !,"A new clock starting on ",$$FMTE^XLFDT(IBSTDT)," is now open.",!
D ASKCONT
Q IBLTCX
;
EX ;
D KVAR^VADPT
;
Q
;
ASKYN() ; "do you still wish to continue" prompt IB*2.0*728
;
; returns 1 for "yes", or 0 otherwise
;
N X,Y,DTOUT,DUOUT,DIR,DIROUT,DIRUT
S DIR("A")="Do you still wish to continue? (Y/N): "
S DIR(0)="YAO"
D ^DIR
Q $S(+Y=1:1,1:0)
;
ASKCONT ; "press any key to continue" prompt IB*2.0*728
;
N X,Y,DTOUT,DUOUT,DIR,DIROUT,DIRUT
S DIR("A")="Press any key to continue."
S DIR(0)="EA"
D ^DIR
Q
;
ASKSTDT(DEF) ; prompt for start date IB*2.0*728
;
; DEF - default start date
;
; returns start date or "" for user exit
;
N X,Y,DTOUT,DUOUT,DIR,DIROUT,DIRUT
S DIR("A")="Please specify the clock start date: "
I DEF>0 S DIR("B")=$$FMTE^XLFDT(DEF)
S DIR(0)="DAO^:"_DT
D ^DIR
I $D(DTOUT)!$D(DUOUT)!$D(DIROUT)!$D(DIRUT) Q ""
Q +Y
;
ASKCRU(UFLG) ; prompt for create new / update existing clock IB*2.0*728
;
; UFLG - 1 = prompt for update, 0 = only prompt for creation of a new clock
;
; returns 1 if user chooses to create new clock, 2 if they choose to update existing clock, or "" for user exit
;
N X,Y,DTOUT,DUOUT,DIR,DIROUT,DIRUT
I UFLG D
.S DIR("A")="Create (N)ew Clock or (U)pdate Existing Clock? (N/U): "
.S DIR(0)="SAO^N:Create new clock;U:Update existing clock"
.Q
I 'UFLG D
.S DIR("A")="Create New Clock (Y/N): "
.S DIR(0)="YAO"
.Q
D ^DIR
I $D(DTOUT)!$D(DUOUT) Q ""
Q $S(Y="N":1,Y=1:1,Y="U":2,1:"")
;
DISPLAY ; display clock information
; Temporary
N IBCLK
S IBCLK=IBLTCX
W @IOF
D REPORT^IBAECB1
Q
;
;
EDIT ; edit either start date or free days
N DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT
AGAINE W ! F X=1:1:IOM W "-"
W !,"You can edit Start Date OR Days Not Subject To LTC Copay (Free Days)"
S DIR(0)="SO^S:Start Date;F:Free Days;" D ^DIR Q:$D(DIRUT)
D @$S(Y="S":"START",1:"FREE"),DISPLAY
G AGAINE
Q
;
START ; edit the start date
N DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,IBSTDT,DIE,DA,DR,IBZ
S DIR(0)="D",DIR("B")=$$FMTE^XLFDT($P(IBLTCZ,"^",3))
D ^DIR Q:$D(DIRUT) S IBSTDT=+Y
;
; no change
I IBSTDT=$P(IBLTCZ,"^",3) W !!?10,"No Change !!" H 3 Q
;
; make sure we don't start after a free day
S IBZ=0 F S IBZ=$O(^IBA(351.81,IBLTCX,1,IBZ)) Q:IBZ<1 I $P(^IBA(351.81,IBLTCX,1,IBZ,0),"^",2)<IBSTDT S IBSTDT=0 Q
I 'IBSTDT W !,"You must enter a date that is BEFORE all the Free Days" G START
;
; don't go less that 1 year before earliest free day
S IBZ=0 F S IBZ=$O(^IBA(351.81,IBLTCX,1,IBZ)) Q:IBZ<1 I '$$YR(IBSTDT,$P(^IBA(351.81,IBLTCX,1,IBZ,0),"^",2)) S IBSTDT=0 Q
I 'IBSTDT W !,"You entered a start date greater than 1 year before a Free Day" G START
;
; file new start date and exp date
S DIE="^IBA(351.81,",DA=IBLTCX,DR=".03///^S X=IBSTDT;.04///^S X=$$GETEXPDT^IBAECU4(IBSTDT)" D ^DIE
S IBLTCZ=^IBA(351.81,IBLTCX,0)
;
D LASTED
;
Q
;
FREE ; change the free days
N IBF,IBX,IBC,IBD,IBFREEX,DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,IBOPT,IBFREEZ
N IBCLK,STOP ; IB*2.0*729
S IBCLK=IBLTCX
;
AGAINF ;
D REINDEX
;
S (IBC,IBX)=0 F S IBX=$O(^IBA(351.81,IBLTCX,1,"AC",IBX)) Q:IBX<1 S IBC=IBC+1,IBF(IBX,IBC)=$O(^IBA(351.81,IBLTCX,1,"AC",IBX,0))
;
; display free days
D FRDAYS^IBAECB1
;
; choose add, edit, or delete free day
S DIR(0)="SO^A:Add;E:Edit;D:Delete" D ^DIR Q:$D(DIRUT) S IBOPT=Y
;
; choose which one to change
S STOP=0 I IBOPT'="A" D ; IB*2.0*729
.I 'IBC W ! S DIR(0)="EA",DIR("A")="There are no Free Days to choose from. Press any key to continue." D ^DIR S STOP=1 Q
.S DIR(0)="NO^1:"_IBC_":0" D ^DIR I $D(DIRUT) S STOP=1 Q
.S IBD=0 F S IBD=$O(IBF(IBD)) Q:IBD<1 I $D(IBF(IBD,+Y)) S IBFREEX=IBF(IBD,+Y),IBFREEZ=^IBA(351.81,IBLTCX,1,IBF(IBD,+Y),0) Q
.Q
I STOP Q
;
D @(IBOPT_"FREE")
;
G AGAINF
;
Q
;
AFREE ; add free days
N IBX,IBC,DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,IBDT,DO,DIC,DINUM,DA,DIE,DR
;
; make sure there are not more than 21 already
S (IBX,IBC)=0 F S IBX=$O(^IBA(351.81,IBLTCX,1,IBX)) Q:IBX<1 S IBC=IBC+1
I IBC>20 W !,"Patients are only allowed 21 free days. ",!,VADM(1)," has ",IBC," already." Q
;
; what date do you want to add
AFREEA S IBDT=$$DATE I IBDT<1 Q
;
; is that date already there
D ALREADY G:IBDT<1 AFREEA
;
; is free day before start date or > 1 year out
D BADDT I IBDT<1 G AFREEA
;
; file free day
F IBX=1:1:21 Q:'$D(^IBA(351.81,IBLTCX,1,IBX))
K DO S DIC="^IBA(351.81,"_IBLTCX_",1,",DIC(0)="",X=IBX,DINUM=X,DA(1)=IBLTCX,DIC("DR")=".02///^S X=IBDT" D FILE^DICN
;
W ?40,"... ",$$FMTE^XLFDT(IBDT)," was ",$S(Y>0:"",1:"NOT "),"added."
I Y>0 S DIE="^IBA(351.81,",DA=IBLTCX,DR=".06///"_($P(IBLTCZ,"^",6)-1) D ^DIE S IBLTCZ=^IBA(351.81,IBLTCX,0)
;
D LASTED,REINDEX
;
; allow adding more if they are not all used up.
G:$P(IBLTCZ,"^",6)>0 AFREEA
;
Q
;
EFREE ; edit a free day IBFREEX
N IBDT,DIE,DA,DR
;
; what date do you want to change it to
S IBDT=$$DATE($$FMTE^XLFDT($P(IBFREEZ,"^",2))) I IBDT<1 Q
I IBDT=$P(IBFREEZ,"^",2) W !,"No change" Q
;
; is free day already there
D ALREADY Q:IBDT<1
;
; is free day before start date or > 1 year out
D BADDT Q:IBDT<1
;
; file free day
S DIE="^IBA(351.81,"_IBLTCX_",1,",DA(1)=IBLTCX,DA=IBFREEX,DR=".02///^S X=IBDT" D ^DIE
;
D LASTED,REINDEX
;
Q
;
DFREE ; delete a free day
N %,DA,DIK,DIE,DR
;
; are you sure
F W !,"Are you sure you want to delete this date" S %=2 D YN^DICN Q:%'=0 W !," Answer with 'Yes' or 'No'"
Q:%'=1
;
; delete it
S DIK="^IBA(351.81,"_IBLTCX_",1,",DA(1)=IBLTCX,DA=IBFREEX D ^DIK
S DIE="^IBA(351.81,",DA=IBLTCX,DR=".06///"_($P(IBLTCZ,"^",6)+1) D ^DIE S IBLTCZ=^IBA(351.81,IBLTCX,0)
;
D LASTED,REINDEX
;
Q
;
SCREEN(DFN) ; screen out non-LTC patients
N IBLTCST S IBLTCST=$$LTCST^IBAECU(DFN,DT,1)
Q $S($D(^IBA(351.81,"C",DFN)):1,+IBLTCST=2:1,1:0)
;
ALREADY ; checks to see if the free day is already there
N IBX
S IBX=0 F S IBX=$O(^IBA(351.81,IBLTCX,1,IBX)) Q:IBX<1 I $P(^IBA(351.81,IBLTCX,1,IBX,0),"^",2)=IBDT S IBDT="-1^"_IBDT Q
I IBDT<1 W !!,$$FMTE^XLFDT($P(IBDT,"^",2))," is already on file!"
Q
;
DATE(IBB) ; prompts for date selection (IBB is default)
N DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT
S DIR(0)="DO^:"_DT S:$G(IBB) DIR("B")=IBB D ^DIR
Q +Y
;
BADDT ; checks out IBDT to make sure it is a valid date based upon start date
I IBDT<$P(IBLTCZ,"^",3) W !!,$$FMTE^XLFDT(IBDT)," is less than the clock start date of ",$$FMTE^XLFDT($P(IBLTCZ,"^",3)) S IBDT=0 Q
I '$$YR($P(IBLTCZ,"^",3),IBDT) W !!,$$FMTE^XLFDT(IBDT)," is greater than 1 year pased the clock start date." S IBDT=0 Q
; if date is current month, don't allow
I $E(IBDT,1,5)=$E(DT,1,5) W !!,$$FMTE^XLFDT(IBDT)," is during the current month.",!,"You must allow the montly job to enter this date into the clock." S IBDT=0
Q
;
LASTED ; update last edited by and date fields
N DIE,DR,DA
S DIE="^IBA(351.81,",DA=IBLTCX,DR="4.03////^S X=DUZ;4.04///NOW" D ^DIE
Q
YR(IBCLDT,IBFR) ; is the effective date of the clock too old?
; Input: IBCLDT -- New Clock Effective Date
; IBFR -- Event Date
; Output: 1 -- Effective Date is too old
; 0 -- Not
N IBNUM,IBYR
S IBNUM=$$FMDIFF^XLFDT(IBFR,IBCLDT),IBYR=$E(IBFR,1,3)
Q IBYR#4&(IBNUM<364)!(IBYR#4=0&(IBNUM<365))
;
REINDEX ; this will take a clock and re-index the free days in order
; assumes IBLTCX
N IBX,DIK,DA,X,Y,IBZ
;
; clean out what is there
S IBX=0 F S IBX=$O(^IBA(351.81,IBLTCX,1,IBX)) Q:IBX<1 S IBZ($P(^IBA(351.81,IBLTCX,1,IBX,0),"^",2))="" S DIK="^IBA(351.81,"_IBLTCX_",1,",DA=IBX,DA(1)=IBLTCX D ^DIK
;
; place them back in - in order
S IBZ=0 F IBX=1:1 S IBZ=$O(IBZ(IBZ)) Q:IBZ<1 K DO S DIC="^IBA(351.81,"_IBLTCX_",1,",DIC(0)="",DA(1)=IBLTCX,X=IBX,DINUM=IBX,DIC("DR")=".02////^S X=IBZ" D FILE^DICN
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBAECC 10858 printed Nov 22, 2024@17:16:04 Page 2
IBAECC ;LL/ELZ - LONG TERM CARE CLOCK MAINTANCE ; 05-FEB-02
+1 ;;2.0;INTEGRATED BILLING;**176,199,728,729**;21-MAR-94;Build 8
+2 ;; Per VHA Directive 10-93-142, this routine should not be modified
+3 ;
+4 ; this routine will allow users to perform LTC copay clock
+5 ; maintance. Every function for the user will be read and evaluated
+6 ; before actually filed in the LTC Copay Clock.
+7 ;
OPT ; menu option main entry point
+1 ;
+2 ; IB*2.0*729
NEW ADDED,DFN,DIC,IBCL,IBLTCX,IBLTCZ,IBOPCL,IBSTDT,IBRES,IBX,IBY,VADM,X,Y
+3 ;
+4 ; select a patient (screen out patients with no LTC clock and are
+5 ; not LTC patients.
OPTA ; IB*2.0*729
KILL DIC,X,Y,DFN,IBLTCX
+1 ;Suppress PATIENT file fuzzy lookups
NEW DPTNOFZY
SET DPTNOFZY=1
+2 SET DIC="^DPT("
SET DIC(0)="AEMNQ"
SET DIC("S")="I $$SCREEN^IBAECC(Y)"
WRITE !
DO ^DIC
if Y<1
GOTO EX
+3 SET DFN=+Y
DO DEM^VADPT
+4 ;
+5 ; is there a clock, if not offer to add
+6 ; IB*2.0*728
+7 SET ADDED=0
+8 IF '$DATA(^IBA(351.81,"C",DFN))
Begin DoDot:1
+9 WRITE !!,"The patient ",VADM(1)," has no LTC clock on file."
+10 SET IBRES=$$ASKCRU(0)
if IBRES'>0
QUIT
+11 ; start date IB*2.0*728
SET IBSTDT=$$ASKSTDT(0)
if IBSTDT'>0
QUIT
+12 ; create clock entry
+13 SET IBLTCX=+$$ADDCL^IBAECU(DFN,IBSTDT)
if IBLTCX>0
SET ADDED=1
+14 QUIT
End DoDot:1
if $GET(IBLTCX)<1
GOTO OPTA
+15 ;
+16 IF 'ADDED
SET IBRES=$$ASKCRU(1)
if IBRES=1
Begin DoDot:1
+17 ; check for existing open clock
+18 SET IBOPCL=$$FNDOPEN^IBAECU4(DFN)
IF IBOPCL>0
SET IBLTCX=$$OPTB(DFN,IBOPCL,$$GET1^DIQ(351.81,IBOPCL_",",.04,"I"))
+19 QUIT
End DoDot:1
if IBRES'>0
GOTO OPTA
+20 ; we get here either if user chose to update esitsing clock or brand new clock was added (there was no existing clock to close)
+21 ; choose a clock
+22 IF $GET(IBLTCX)<1
SET IBLTCX=$$ASKCLK^IBAECP(DFN,1)
if $GET(IBLTCX)<1
GOTO OPTA
+23 ;
+24 SET IBLTCZ=^IBA(351.81,IBLTCX,0)
DO DISPLAY
DO EDIT
+25 GOTO OPTA
+26 ;
OPTB(DFN,IBOPCL,IBOEDT,IBDEFDT) ; close existing clock and open the new one, also called from IB CANCEL IB*2.0*728
+1 ;
+2 ; DFN - patient DFN
+3 ; IBOPCL - old clock ien (file 351.81)
+4 ; IBOEDT - old clock exp. date (internal)
+5 ; IBDEFDT - default start date (optional)
+6 ;
+7 ; returns 1 if new clock was opened, 0 otherwise
+8 ;
+9 NEW IBLTCX,IBOIENS,IBOSTDTE,IBSTDT,Z
+10 SET IBLTCX=0
+11 SET IBOIENS=IBOPCL_","
SET IBOSTDTE=$$GET1^DIQ(351.81,IBOIENS,.03)
+12 WRITE !!,"WARNING!!!"
+13 WRITE !,"Creating a new clock for this patient will close the existing open LTC Clock.",!
+14 ; ask for confirmation
IF $$ASKYN()'>0
Begin DoDot:1
+15 WRITE !!,"No new clock created."
+16 WRITE !,"Existing Clock for the Period starting on ",IBOSTDTE," is still in effect.",!
+17 DO ASKCONT
+18 QUIT
End DoDot:1
QUIT 0
+19 ; start date
SET IBSTDT=$$ASKSTDT(+$GET(IBDEFDT))
if IBSTDT'>0
QUIT 0
+20 IF IBSTDT'>IBOEDT
Begin DoDot:1
+21 SET Z=$$FMTE^XLFDT(IBOEDT)
+22 WRITE !!,"This patient's existing clock ends on ",Z,"."
+23 WRITE !!,"Unable to create a new clock for this patient until after ",Z
+24 WRITE !," at the earliest.",!
+25 DO ASKCONT
+26 QUIT
End DoDot:1
QUIT 0
+27 LOCK +^IBA(351.81,IBOPCL):5
IF '$TEST
QUIT 0
+28 ; close old clock
DO CLOSECLK^IBAECU4(IBOPCL,DFN)
+29 LOCK -^IBA(351.81,IBOPCL)
+30 WRITE !!,"Clock for the Period starting on ",IBOSTDTE," is now closed."
+31 ; create new clock
SET IBLTCX=+$$ADDCL^IBAECU(DFN,IBSTDT)
+32 IF IBLTCX>0
WRITE !,"A new clock starting on ",$$FMTE^XLFDT(IBSTDT)," is now open.",!
+33 DO ASKCONT
+34 QUIT IBLTCX
+35 ;
EX ;
+1 DO KVAR^VADPT
+2 ;
+3 QUIT
+4 ;
ASKYN() ; "do you still wish to continue" prompt IB*2.0*728
+1 ;
+2 ; returns 1 for "yes", or 0 otherwise
+3 ;
+4 NEW X,Y,DTOUT,DUOUT,DIR,DIROUT,DIRUT
+5 SET DIR("A")="Do you still wish to continue? (Y/N): "
+6 SET DIR(0)="YAO"
+7 DO ^DIR
+8 QUIT $SELECT(+Y=1:1,1:0)
+9 ;
ASKCONT ; "press any key to continue" prompt IB*2.0*728
+1 ;
+2 NEW X,Y,DTOUT,DUOUT,DIR,DIROUT,DIRUT
+3 SET DIR("A")="Press any key to continue."
+4 SET DIR(0)="EA"
+5 DO ^DIR
+6 QUIT
+7 ;
ASKSTDT(DEF) ; prompt for start date IB*2.0*728
+1 ;
+2 ; DEF - default start date
+3 ;
+4 ; returns start date or "" for user exit
+5 ;
+6 NEW X,Y,DTOUT,DUOUT,DIR,DIROUT,DIRUT
+7 SET DIR("A")="Please specify the clock start date: "
+8 IF DEF>0
SET DIR("B")=$$FMTE^XLFDT(DEF)
+9 SET DIR(0)="DAO^:"_DT
+10 DO ^DIR
+11 IF $DATA(DTOUT)!$DATA(DUOUT)!$DATA(DIROUT)!$DATA(DIRUT)
QUIT ""
+12 QUIT +Y
+13 ;
ASKCRU(UFLG) ; prompt for create new / update existing clock IB*2.0*728
+1 ;
+2 ; UFLG - 1 = prompt for update, 0 = only prompt for creation of a new clock
+3 ;
+4 ; returns 1 if user chooses to create new clock, 2 if they choose to update existing clock, or "" for user exit
+5 ;
+6 NEW X,Y,DTOUT,DUOUT,DIR,DIROUT,DIRUT
+7 IF UFLG
Begin DoDot:1
+8 SET DIR("A")="Create (N)ew Clock or (U)pdate Existing Clock? (N/U): "
+9 SET DIR(0)="SAO^N:Create new clock;U:Update existing clock"
+10 QUIT
End DoDot:1
+11 IF 'UFLG
Begin DoDot:1
+12 SET DIR("A")="Create New Clock (Y/N): "
+13 SET DIR(0)="YAO"
+14 QUIT
End DoDot:1
+15 DO ^DIR
+16 IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT ""
+17 QUIT $SELECT(Y="N":1,Y=1:1,Y="U":2,1:"")
+18 ;
DISPLAY ; display clock information
+1 ; Temporary
+2 NEW IBCLK
+3 SET IBCLK=IBLTCX
+4 WRITE @IOF
+5 DO REPORT^IBAECB1
+6 QUIT
+7 ;
+8 ;
EDIT ; edit either start date or free days
+1 NEW DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT
AGAINE WRITE !
FOR X=1:1:IOM
WRITE "-"
+1 WRITE !,"You can edit Start Date OR Days Not Subject To LTC Copay (Free Days)"
+2 SET DIR(0)="SO^S:Start Date;F:Free Days;"
DO ^DIR
if $DATA(DIRUT)
QUIT
+3 DO @$SELECT(Y="S":"START",1:"FREE")
DO DISPLAY
+4 GOTO AGAINE
+5 QUIT
+6 ;
START ; edit the start date
+1 NEW DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,IBSTDT,DIE,DA,DR,IBZ
+2 SET DIR(0)="D"
SET DIR("B")=$$FMTE^XLFDT($PIECE(IBLTCZ,"^",3))
+3 DO ^DIR
if $DATA(DIRUT)
QUIT
SET IBSTDT=+Y
+4 ;
+5 ; no change
+6 IF IBSTDT=$PIECE(IBLTCZ,"^",3)
WRITE !!?10,"No Change !!"
HANG 3
QUIT
+7 ;
+8 ; make sure we don't start after a free day
+9 SET IBZ=0
FOR
SET IBZ=$ORDER(^IBA(351.81,IBLTCX,1,IBZ))
if IBZ<1
QUIT
IF $PIECE(^IBA(351.81,IBLTCX,1,IBZ,0),"^",2)<IBSTDT
SET IBSTDT=0
QUIT
+10 IF 'IBSTDT
WRITE !,"You must enter a date that is BEFORE all the Free Days"
GOTO START
+11 ;
+12 ; don't go less that 1 year before earliest free day
+13 SET IBZ=0
FOR
SET IBZ=$ORDER(^IBA(351.81,IBLTCX,1,IBZ))
if IBZ<1
QUIT
IF '$$YR(IBSTDT,$PIECE(^IBA(351.81,IBLTCX,1,IBZ,0),"^",2))
SET IBSTDT=0
QUIT
+14 IF 'IBSTDT
WRITE !,"You entered a start date greater than 1 year before a Free Day"
GOTO START
+15 ;
+16 ; file new start date and exp date
+17 SET DIE="^IBA(351.81,"
SET DA=IBLTCX
SET DR=".03///^S X=IBSTDT;.04///^S X=$$GETEXPDT^IBAECU4(IBSTDT)"
DO ^DIE
+18 SET IBLTCZ=^IBA(351.81,IBLTCX,0)
+19 ;
+20 DO LASTED
+21 ;
+22 QUIT
+23 ;
FREE ; change the free days
+1 NEW IBF,IBX,IBC,IBD,IBFREEX,DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,IBOPT,IBFREEZ
+2 ; IB*2.0*729
NEW IBCLK,STOP
+3 SET IBCLK=IBLTCX
+4 ;
AGAINF ;
+1 DO REINDEX
+2 ;
+3 SET (IBC,IBX)=0
FOR
SET IBX=$ORDER(^IBA(351.81,IBLTCX,1,"AC",IBX))
if IBX<1
QUIT
SET IBC=IBC+1
SET IBF(IBX,IBC)=$ORDER(^IBA(351.81,IBLTCX,1,"AC",IBX,0))
+4 ;
+5 ; display free days
+6 DO FRDAYS^IBAECB1
+7 ;
+8 ; choose add, edit, or delete free day
+9 SET DIR(0)="SO^A:Add;E:Edit;D:Delete"
DO ^DIR
if $DATA(DIRUT)
QUIT
SET IBOPT=Y
+10 ;
+11 ; choose which one to change
+12 ; IB*2.0*729
SET STOP=0
IF IBOPT'="A"
Begin DoDot:1
+13 IF 'IBC
WRITE !
SET DIR(0)="EA"
SET DIR("A")="There are no Free Days to choose from. Press any key to continue."
DO ^DIR
SET STOP=1
QUIT
+14 SET DIR(0)="NO^1:"_IBC_":0"
DO ^DIR
IF $DATA(DIRUT)
SET STOP=1
QUIT
+15 SET IBD=0
FOR
SET IBD=$ORDER(IBF(IBD))
if IBD<1
QUIT
IF $DATA(IBF(IBD,+Y))
SET IBFREEX=IBF(IBD,+Y)
SET IBFREEZ=^IBA(351.81,IBLTCX,1,IBF(IBD,+Y),0)
QUIT
+16 QUIT
End DoDot:1
+17 IF STOP
QUIT
+18 ;
+19 DO @(IBOPT_"FREE")
+20 ;
+21 GOTO AGAINF
+22 ;
+23 QUIT
+24 ;
AFREE ; add free days
+1 NEW IBX,IBC,DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,IBDT,DO,DIC,DINUM,DA,DIE,DR
+2 ;
+3 ; make sure there are not more than 21 already
+4 SET (IBX,IBC)=0
FOR
SET IBX=$ORDER(^IBA(351.81,IBLTCX,1,IBX))
if IBX<1
QUIT
SET IBC=IBC+1
+5 IF IBC>20
WRITE !,"Patients are only allowed 21 free days. ",!,VADM(1)," has ",IBC," already."
QUIT
+6 ;
+7 ; what date do you want to add
AFREEA SET IBDT=$$DATE
IF IBDT<1
QUIT
+1 ;
+2 ; is that date already there
+3 DO ALREADY
if IBDT<1
GOTO AFREEA
+4 ;
+5 ; is free day before start date or > 1 year out
+6 DO BADDT
IF IBDT<1
GOTO AFREEA
+7 ;
+8 ; file free day
+9 FOR IBX=1:1:21
if '$DATA(^IBA(351.81,IBLTCX,1,IBX))
QUIT
+10 KILL DO
SET DIC="^IBA(351.81,"_IBLTCX_",1,"
SET DIC(0)=""
SET X=IBX
SET DINUM=X
SET DA(1)=IBLTCX
SET DIC("DR")=".02///^S X=IBDT"
DO FILE^DICN
+11 ;
+12 WRITE ?40,"... ",$$FMTE^XLFDT(IBDT)," was ",$SELECT(Y>0:"",1:"NOT "),"added."
+13 IF Y>0
SET DIE="^IBA(351.81,"
SET DA=IBLTCX
SET DR=".06///"_($PIECE(IBLTCZ,"^",6)-1)
DO ^DIE
SET IBLTCZ=^IBA(351.81,IBLTCX,0)
+14 ;
+15 DO LASTED
DO REINDEX
+16 ;
+17 ; allow adding more if they are not all used up.
+18 if $PIECE(IBLTCZ,"^",6)>0
GOTO AFREEA
+19 ;
+20 QUIT
+21 ;
EFREE ; edit a free day IBFREEX
+1 NEW IBDT,DIE,DA,DR
+2 ;
+3 ; what date do you want to change it to
+4 SET IBDT=$$DATE($$FMTE^XLFDT($PIECE(IBFREEZ,"^",2)))
IF IBDT<1
QUIT
+5 IF IBDT=$PIECE(IBFREEZ,"^",2)
WRITE !,"No change"
QUIT
+6 ;
+7 ; is free day already there
+8 DO ALREADY
if IBDT<1
QUIT
+9 ;
+10 ; is free day before start date or > 1 year out
+11 DO BADDT
if IBDT<1
QUIT
+12 ;
+13 ; file free day
+14 SET DIE="^IBA(351.81,"_IBLTCX_",1,"
SET DA(1)=IBLTCX
SET DA=IBFREEX
SET DR=".02///^S X=IBDT"
DO ^DIE
+15 ;
+16 DO LASTED
DO REINDEX
+17 ;
+18 QUIT
+19 ;
DFREE ; delete a free day
+1 NEW %,DA,DIK,DIE,DR
+2 ;
+3 ; are you sure
+4 FOR
WRITE !,"Are you sure you want to delete this date"
SET %=2
DO YN^DICN
if %'=0
QUIT
WRITE !," Answer with 'Yes' or 'No'"
+5 if %'=1
QUIT
+6 ;
+7 ; delete it
+8 SET DIK="^IBA(351.81,"_IBLTCX_",1,"
SET DA(1)=IBLTCX
SET DA=IBFREEX
DO ^DIK
+9 SET DIE="^IBA(351.81,"
SET DA=IBLTCX
SET DR=".06///"_($PIECE(IBLTCZ,"^",6)+1)
DO ^DIE
SET IBLTCZ=^IBA(351.81,IBLTCX,0)
+10 ;
+11 DO LASTED
DO REINDEX
+12 ;
+13 QUIT
+14 ;
SCREEN(DFN) ; screen out non-LTC patients
+1 NEW IBLTCST
SET IBLTCST=$$LTCST^IBAECU(DFN,DT,1)
+2 QUIT $SELECT($DATA(^IBA(351.81,"C",DFN)):1,+IBLTCST=2:1,1:0)
+3 ;
ALREADY ; checks to see if the free day is already there
+1 NEW IBX
+2 SET IBX=0
FOR
SET IBX=$ORDER(^IBA(351.81,IBLTCX,1,IBX))
if IBX<1
QUIT
IF $PIECE(^IBA(351.81,IBLTCX,1,IBX,0),"^",2)=IBDT
SET IBDT="-1^"_IBDT
QUIT
+3 IF IBDT<1
WRITE !!,$$FMTE^XLFDT($PIECE(IBDT,"^",2))," is already on file!"
+4 QUIT
+5 ;
DATE(IBB) ; prompts for date selection (IBB is default)
+1 NEW DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT
+2 SET DIR(0)="DO^:"_DT
if $GET(IBB)
SET DIR("B")=IBB
DO ^DIR
+3 QUIT +Y
+4 ;
BADDT ; checks out IBDT to make sure it is a valid date based upon start date
+1 IF IBDT<$PIECE(IBLTCZ,"^",3)
WRITE !!,$$FMTE^XLFDT(IBDT)," is less than the clock start date of ",$$FMTE^XLFDT($PIECE(IBLTCZ,"^",3))
SET IBDT=0
QUIT
+2 IF '$$YR($PIECE(IBLTCZ,"^",3),IBDT)
WRITE !!,$$FMTE^XLFDT(IBDT)," is greater than 1 year pased the clock start date."
SET IBDT=0
QUIT
+3 ; if date is current month, don't allow
+4 IF $EXTRACT(IBDT,1,5)=$EXTRACT(DT,1,5)
WRITE !!,$$FMTE^XLFDT(IBDT)," is during the current month.",!,"You must allow the montly job to enter this date into the clock."
SET IBDT=0
+5 QUIT
+6 ;
LASTED ; update last edited by and date fields
+1 NEW DIE,DR,DA
+2 SET DIE="^IBA(351.81,"
SET DA=IBLTCX
SET DR="4.03////^S X=DUZ;4.04///NOW"
DO ^DIE
+3 QUIT
YR(IBCLDT,IBFR) ; is the effective date of the clock too old?
+1 ; Input: IBCLDT -- New Clock Effective Date
+2 ; IBFR -- Event Date
+3 ; Output: 1 -- Effective Date is too old
+4 ; 0 -- Not
+5 NEW IBNUM,IBYR
+6 SET IBNUM=$$FMDIFF^XLFDT(IBFR,IBCLDT)
SET IBYR=$EXTRACT(IBFR,1,3)
+7 QUIT IBYR#4&(IBNUM<364)!(IBYR#4=0&(IBNUM<365))
+8 ;
REINDEX ; this will take a clock and re-index the free days in order
+1 ; assumes IBLTCX
+2 NEW IBX,DIK,DA,X,Y,IBZ
+3 ;
+4 ; clean out what is there
+5 SET IBX=0
FOR
SET IBX=$ORDER(^IBA(351.81,IBLTCX,1,IBX))
if IBX<1
QUIT
SET IBZ($PIECE(^IBA(351.81,IBLTCX,1,IBX,0),"^",2))=""
SET DIK="^IBA(351.81,"_IBLTCX_",1,"
SET DA=IBX
SET DA(1)=IBLTCX
DO ^DIK
+6 ;
+7 ; place them back in - in order
+8 SET IBZ=0
FOR IBX=1:1
SET IBZ=$ORDER(IBZ(IBZ))
if IBZ<1
QUIT
KILL DO
SET DIC="^IBA(351.81,"_IBLTCX_",1,"
SET DIC(0)=""
SET DA(1)=IBLTCX
SET X=IBX
SET DINUM=IBX
SET DIC("DR")=".02////^S X=IBZ"
DO FILE^DICN
+9 QUIT