- ABSPOSBD ; IHS/FCS/DRS - POS billing - background ; [ 06/22/2001 2:14 PM ]
- ;;1.0;PHARMACY POINT OF SALE;**22,28,32,36**;JUN 21, 2001;Build 38
- ;
- ;IHS/SD/RLT - 09/12/07 - Patch 22
- ; Added code to hold claims from being sent to 3PB if the site
- ; affiliation is IHS and the insurer does not have a tax id.
- ; -----
- ;IHS/OIT/SCR - 09/16/08 - Patch 28
- ; REMOVED code to hold claims being sent to 3PB if the site
- ; affiliation is IHS and the insurer does not have a tax id.
- Q
- SCHEDULE(DELTA) ; EP - schedule it to run again, if needed
- ; DELTA = how many minutes
- L +^TMP("ABSPOSBD","SCHEDULE"):0 Q:'$T
- I '$D(DELTA) S DELTA=$$DELTA
- S DELTA=DELTA*60\1 ; how many seconds
- I DELTA<60 S DELTA=60 ; but not immediately
- N ATTIME S ATTIME=$$TADDNOWS^ABSPOSUD(DELTA)
- N NEXTTIME S NEXTTIME=$$NEXTTIME
- I 'NEXTTIME!(ATTIME<NEXTTIME) D
- . D TASKAT(ATTIME)
- L -^TMP("ABSPOSBD","SCHEDULE")
- Q
- NEXTTIME() ; when is it scheduled to run again?
- N NEXTTIME S NEXTTIME=$P($G(^ABSP(9002313.99,1,"BILLING - NEW")),U)
- I NEXTTIME'>$$NOW^ABSPOS Q 0 ; this time is already past
- Q NEXTTIME ; future
- DELTA() ; delta time until background job runs - in minutes
- N DELTA S DELTA=$P($G(^ABSP(9002313.99,1,"BILLING - NEW")),U,2)
- I 'DELTA S DELTA=15
- I $$DISABLED,DELTA<60 S DELTA=60 ; min 1 hour if it's disabled
- Q DELTA
- DISABLED() Q $P($G(^ABSP(9002313.99,1,"BILLING - NEW")),U,3)=1
- DISABLE ; EP -
- S $P(^ABSP(9002313.99,1,"BILLING - NEW"),U,3)=1 Q
- ENABLE ; EP -
- S $P(^ABSP(9002313.99,1,"BILLING - NEW"),U,3)=0
- D TASKAT()
- Q
- TASKAT(ZTDTH) ;
- I '$D(ZTDTH) S ZTDTH=$$NOW^ABSPOS
- I '$$NEXTTIME!(ZTDTH<$$NEXTTIME) D
- . S $P(^ABSP(9002313.99,1,"BILLING - NEW"),U)=ZTDTH
- N ZTRTN,ZTIO
- S ZTRTN="BACKGR^"_$T(+0),ZTIO=""
- ;ZW ZTDTH,ZTRTN
- D ^%ZTLOAD
- Q
- ANY() Q $O(^ABSPTL("AS",1,0)) ; any need billing?
- ;IHS/OIT/SCR - 9/16/08 - START changes to REMOVE code to hold claims
- ;ANYHOLD() ;
- ;check for any entries in ^ABSPHOLD
- ;quit if no entries
- ;N ANYHOLD
- ;S ANYHOLD=$O(^ABSPHOLD(0))
- ;Q:'ANYHOLD 0
- ;if there are entries check last run
- ;run only once a day when date changes
- ;N RUNDT
- ;S RUNDT=$P($G(^ABSP(9002313.99,1,"BILLING - NEW")),U,8)
- ;Q:RUNDT'=CURRDT 1
- ;Q 0
- ;
- ;IHS/OIT/SCR - 9/16/08 - END changes to REMOVE code to hold claims
- ; LOCK, UNLOCK also used by ABSPOSBX
- LOCK() ;EP -
- L +^TMP("ABSPOSBD","BACKGR"):15 Q $T
- ;
- UNLOCK ;EP -
- L -^TMP("ABSPOSBD","BACKGR") Q
- BACKGR ;
- N CURRDT
- N ABSPBILD ;IHS/OIT/SCR 011210 patch 36
- D NOW^%DTC
- S CURRDT=X
- ;IHS/OIT/SCR 9/16/08 START changes to REMOVE code to hold claims
- ; I '$$ANY&('$$ANYHOLD) Q ; none need billing
- I '$$ANY Q ; none need billing
- ;IHS/OIT/SCR 9/16/08 END changes to REMOVE code to hold claims
- I '$$LOCK Q
- D INIT^ABSPOSL(DT+.2,1)
- I $$ANY D
- . D LOG("Billing job begins")
- . I $$DISABLED D G BACKGR99
- .. D LOG("Disabled; will reschedule.")
- . ;
- . ; Loop: Process the 9002313.57 entries which need billing.
- . ; They are listed in ^ABSPTL("AS",1,*)
- . ; ABSP57 is the variable name expected by POSTING^ABSPOSBB
- . ;
- . N ABSP57 S ABSP57=0
- . F S ABSP57=$O(^ABSPTL("AS",1,ABSP57)) Q:'ABSP57 D
- .. ;D LOG^ABSPOSL("Posting transaction "_ABSP57_".")
- .. ; ;IHS/OIT/SCR 12/24/09 Santa Rosa pre-patch 36 : Before calling the 3PB API, check to
- ..;see if the transaction has NEEDS BILLED flag set - if not, Kill the cross-reference
- ..;START
- ..S ABSPBILD=$P(^ABSPTL(ABSP57,0),"^",16) ;corrupt x-reference causes infinite loop in background process
- ..I ABSPBILD'=1 K ^ABSPTL("AS",1,ABSP57) ;IHS/OIT/SCR 011210 patch 36
- ..I ABSPBILD=1 D
- ...D POSTING^ABSPOSBB ; post the transaction
- ...;IHS/OIT/SCR 062309 patch 32 the condition has to do with HELD claims functionality removed in patch 29
- ...;D:'$D(^ABSPTL("AS",2,ABSP57)) SETFLAG^ABSPOSBC(ABSP57,0) ; clear the "needs billing" flag
- ...D SETFLAG^ABSPOSBC(ABSP57,0) ; clear the "needs billing" flag
- ...Q
- ..Q
- .Q
- ;IHS/OIT/SCR 12/24/09 Santa Rosa pre-patch 36 : Before calling the 3PB API, check to
- ;see if the transaction has information in the .15 field - if so, Kill the cross-reference
- ;END
- ;
- ;IHS/OIT/SCR - 09/16/07 - Patch 28 - START changes to REMOVE code to hold claims
- ;IHS/SD/RLT - 09/12/07 - Patch 22
- ; Loop: Process the held claims in ^ABSPHOLD.
- ; If tax id has been entered send to 3PB.
- ;I $$ANYHOLD D
- ;. D LOG("Holding job begins")
- ;. I $$DISABLED D G BACKGR99
- ;.. D LOG("Disabled; will reschedule.")
- ;. N HOLDCNT S HOLDCNT=0
- ;. N HOLDIEN S HOLDIEN=0
- ;. F S HOLDIEN=$O(^ABSPHOLD(HOLDIEN)) Q:'+HOLDIEN D
- ;.. D CHKHOLD^ABSPOSBH
- ;. S $P(^ABSP(9002313.99,1,"BILLING - NEW"),U,8)=CURRDT
- ;. D LOG^ABSPOSL(HOLDCNT_" 3PB transactions on hold.")
- ;IHS/OIT/SCR - 09/16/07 - Patch 28 - END changes to REMOVE code to hold claims
- ;
- D DONE^ABSPOSL
- ;
- BACKGR99 ;
- D UNLOCK
- I $$ANY D SCHEDULE($S($$DISABLED:60,1:1)) ; in case any slipped in while we were leaving
- Q
- ILCAR ;
- Q
- LOG(X) D LOG^ABSPOSL(X) Q
- PRINTLOG D PRINTLOG^ABSPOSL(DT+.2) Q
- ABSPOSBD ; IHS/FCS/DRS - POS billing - background ; [ 06/22/2001 2:14 PM ]
- +1 ;;1.0;PHARMACY POINT OF SALE;**22,28,32,36**;JUN 21, 2001;Build 38
- +2 ;
- +3 ;IHS/SD/RLT - 09/12/07 - Patch 22
- +4 ; Added code to hold claims from being sent to 3PB if the site
- +5 ; affiliation is IHS and the insurer does not have a tax id.
- +6 ; -----
- +7 ;IHS/OIT/SCR - 09/16/08 - Patch 28
- +8 ; REMOVED code to hold claims being sent to 3PB if the site
- +9 ; affiliation is IHS and the insurer does not have a tax id.
- +10 QUIT
- SCHEDULE(DELTA) ; EP - schedule it to run again, if needed
- +1 ; DELTA = how many minutes
- +2 LOCK +^TMP("ABSPOSBD","SCHEDULE"):0
- IF '$TEST
- QUIT
- +3 IF '$DATA(DELTA)
- SET DELTA=$$DELTA
- +4 ; how many seconds
- SET DELTA=DELTA*60\1
- +5 ; but not immediately
- IF DELTA<60
- SET DELTA=60
- +6 NEW ATTIME
- SET ATTIME=$$TADDNOWS^ABSPOSUD(DELTA)
- +7 NEW NEXTTIME
- SET NEXTTIME=$$NEXTTIME
- +8 IF 'NEXTTIME!(ATTIME<NEXTTIME)
- Begin DoDot:1
- +9 DO TASKAT(ATTIME)
- End DoDot:1
- +10 LOCK -^TMP("ABSPOSBD","SCHEDULE")
- +11 QUIT
- NEXTTIME() ; when is it scheduled to run again?
- +1 NEW NEXTTIME
- SET NEXTTIME=$PIECE($GET(^ABSP(9002313.99,1,"BILLING - NEW")),U)
- +2 ; this time is already past
- IF NEXTTIME'>$$NOW^ABSPOS
- QUIT 0
- +3 ; future
- QUIT NEXTTIME
- DELTA() ; delta time until background job runs - in minutes
- +1 NEW DELTA
- SET DELTA=$PIECE($GET(^ABSP(9002313.99,1,"BILLING - NEW")),U,2)
- +2 IF 'DELTA
- SET DELTA=15
- +3 ; min 1 hour if it's disabled
- IF $$DISABLED
- IF DELTA<60
- SET DELTA=60
- +4 QUIT DELTA
- DISABLED() QUIT $PIECE($GET(^ABSP(9002313.99,1,"BILLING - NEW")),U,3)=1
- DISABLE ; EP -
- +1 SET $PIECE(^ABSP(9002313.99,1,"BILLING - NEW"),U,3)=1
- QUIT
- ENABLE ; EP -
- +1 SET $PIECE(^ABSP(9002313.99,1,"BILLING - NEW"),U,3)=0
- +2 DO TASKAT()
- +3 QUIT
- TASKAT(ZTDTH) ;
- +1 IF '$DATA(ZTDTH)
- SET ZTDTH=$$NOW^ABSPOS
- +2 IF '$$NEXTTIME!(ZTDTH<$$NEXTTIME)
- Begin DoDot:1
- +3 SET $PIECE(^ABSP(9002313.99,1,"BILLING - NEW"),U)=ZTDTH
- End DoDot:1
- +4 NEW ZTRTN,ZTIO
- +5 SET ZTRTN="BACKGR^"_$TEXT(+0)
- SET ZTIO=""
- +6 ;ZW ZTDTH,ZTRTN
- +7 DO ^%ZTLOAD
- +8 QUIT
- ANY() ; any need billing?
- QUIT $ORDER(^ABSPTL("AS",1,0))
- +1 ;IHS/OIT/SCR - 9/16/08 - START changes to REMOVE code to hold claims
- +2 ;ANYHOLD() ;
- +3 ;check for any entries in ^ABSPHOLD
- +4 ;quit if no entries
- +5 ;N ANYHOLD
- +6 ;S ANYHOLD=$O(^ABSPHOLD(0))
- +7 ;Q:'ANYHOLD 0
- +8 ;if there are entries check last run
- +9 ;run only once a day when date changes
- +10 ;N RUNDT
- +11 ;S RUNDT=$P($G(^ABSP(9002313.99,1,"BILLING - NEW")),U,8)
- +12 ;Q:RUNDT'=CURRDT 1
- +13 ;Q 0
- +14 ;
- +15 ;IHS/OIT/SCR - 9/16/08 - END changes to REMOVE code to hold claims
- +16 ; LOCK, UNLOCK also used by ABSPOSBX
- LOCK() ;EP -
- +1 LOCK +^TMP("ABSPOSBD","BACKGR"):15
- QUIT $TEST
- +2 ;
- UNLOCK ;EP -
- +1 LOCK -^TMP("ABSPOSBD","BACKGR")
- QUIT
- BACKGR ;
- +1 NEW CURRDT
- +2 ;IHS/OIT/SCR 011210 patch 36
- NEW ABSPBILD
- +3 DO NOW^%DTC
- +4 SET CURRDT=X
- +5 ;IHS/OIT/SCR 9/16/08 START changes to REMOVE code to hold claims
- +6 ; I '$$ANY&('$$ANYHOLD) Q ; none need billing
- +7 ; none need billing
- IF '$$ANY
- QUIT
- +8 ;IHS/OIT/SCR 9/16/08 END changes to REMOVE code to hold claims
- +9 IF '$$LOCK
- QUIT
- +10 DO INIT^ABSPOSL(DT+.2,1)
- +11 IF $$ANY
- Begin DoDot:1
- +12 DO LOG("Billing job begins")
- +13 IF $$DISABLED
- Begin DoDot:2
- +14 DO LOG("Disabled; will reschedule.")
- End DoDot:2
- GOTO BACKGR99
- +15 ;
- +16 ; Loop: Process the 9002313.57 entries which need billing.
- +17 ; They are listed in ^ABSPTL("AS",1,*)
- +18 ; ABSP57 is the variable name expected by POSTING^ABSPOSBB
- +19 ;
- +20 NEW ABSP57
- SET ABSP57=0
- +21 FOR
- SET ABSP57=$ORDER(^ABSPTL("AS",1,ABSP57))
- IF 'ABSP57
- QUIT
- Begin DoDot:2
- +22 ;D LOG^ABSPOSL("Posting transaction "_ABSP57_".")
- +23 ; ;IHS/OIT/SCR 12/24/09 Santa Rosa pre-patch 36 : Before calling the 3PB API, check to
- +24 ;see if the transaction has NEEDS BILLED flag set - if not, Kill the cross-reference
- +25 ;START
- +26 ;corrupt x-reference causes infinite loop in background process
- SET ABSPBILD=$PIECE(^ABSPTL(ABSP57,0),"^",16)
- +27 ;IHS/OIT/SCR 011210 patch 36
- IF ABSPBILD'=1
- KILL ^ABSPTL("AS",1,ABSP57)
- +28 IF ABSPBILD=1
- Begin DoDot:3
- +29 ; post the transaction
- DO POSTING^ABSPOSBB
- +30 ;IHS/OIT/SCR 062309 patch 32 the condition has to do with HELD claims functionality removed in patch 29
- +31 ;D:'$D(^ABSPTL("AS",2,ABSP57)) SETFLAG^ABSPOSBC(ABSP57,0) ; clear the "needs billing" flag
- +32 ; clear the "needs billing" flag
- DO SETFLAG^ABSPOSBC(ABSP57,0)
- +33 QUIT
- End DoDot:3
- +34 QUIT
- End DoDot:2
- +35 QUIT
- End DoDot:1
- +36 ;IHS/OIT/SCR 12/24/09 Santa Rosa pre-patch 36 : Before calling the 3PB API, check to
- +37 ;see if the transaction has information in the .15 field - if so, Kill the cross-reference
- +38 ;END
- +39 ;
- +40 ;IHS/OIT/SCR - 09/16/07 - Patch 28 - START changes to REMOVE code to hold claims
- +41 ;IHS/SD/RLT - 09/12/07 - Patch 22
- +42 ; Loop: Process the held claims in ^ABSPHOLD.
- +43 ; If tax id has been entered send to 3PB.
- +44 ;I $$ANYHOLD D
- +45 ;. D LOG("Holding job begins")
- +46 ;. I $$DISABLED D G BACKGR99
- +47 ;.. D LOG("Disabled; will reschedule.")
- +48 ;. N HOLDCNT S HOLDCNT=0
- +49 ;. N HOLDIEN S HOLDIEN=0
- +50 ;. F S HOLDIEN=$O(^ABSPHOLD(HOLDIEN)) Q:'+HOLDIEN D
- +51 ;.. D CHKHOLD^ABSPOSBH
- +52 ;. S $P(^ABSP(9002313.99,1,"BILLING - NEW"),U,8)=CURRDT
- +53 ;. D LOG^ABSPOSL(HOLDCNT_" 3PB transactions on hold.")
- +54 ;IHS/OIT/SCR - 09/16/07 - Patch 28 - END changes to REMOVE code to hold claims
- +55 ;
- +56 DO DONE^ABSPOSL
- +57 ;
- BACKGR99 ;
- +1 DO UNLOCK
- +2 ; in case any slipped in while we were leaving
- IF $$ANY
- DO SCHEDULE($SELECT($$DISABLED:60,1:1))
- +3 QUIT
- ILCAR ;
- +1 QUIT
- LOG(X) DO LOG^ABSPOSL(X)
- QUIT
- PRINTLOG DO PRINTLOG^ABSPOSL(DT+.2)
- QUIT