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

ABSPOSBD.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. ;IHS/SD/RLT - 09/12/07 - Patch 22
  1. ; Added code to hold claims from being sent to 3PB if the site
  1. ; affiliation is IHS and the insurer does not have a tax id.
  1. ; -----
  1. ;IHS/OIT/SCR - 09/16/08 - Patch 28
  1. ; REMOVED code to hold claims being sent to 3PB if the site
  1. ; affiliation is IHS and the insurer does not have a tax id.
  1. Q
  1. SCHEDULE(DELTA) ; EP - schedule it to run again, if needed
  1. ; DELTA = how many minutes
  1. L +^TMP("ABSPOSBD","SCHEDULE"):0 Q:'$T
  1. I '$D(DELTA) S DELTA=$$DELTA
  1. S DELTA=DELTA*60\1 ; how many seconds
  1. I DELTA<60 S DELTA=60 ; but not immediately
  1. N ATTIME S ATTIME=$$TADDNOWS^ABSPOSUD(DELTA)
  1. N NEXTTIME S NEXTTIME=$$NEXTTIME
  1. I 'NEXTTIME!(ATTIME<NEXTTIME) D
  1. . D TASKAT(ATTIME)
  1. L -^TMP("ABSPOSBD","SCHEDULE")
  1. Q
  1. NEXTTIME() ; when is it scheduled to run again?
  1. N NEXTTIME S NEXTTIME=$P($G(^ABSP(9002313.99,1,"BILLING - NEW")),U)
  1. I NEXTTIME'>$$NOW^ABSPOS Q 0 ; this time is already past
  1. Q NEXTTIME ; future
  1. DELTA() ; delta time until background job runs - in minutes
  1. N DELTA S DELTA=$P($G(^ABSP(9002313.99,1,"BILLING - NEW")),U,2)
  1. I 'DELTA S DELTA=15
  1. I $$DISABLED,DELTA<60 S DELTA=60 ; min 1 hour if it's disabled
  1. Q DELTA
  1. DISABLED() Q $P($G(^ABSP(9002313.99,1,"BILLING - NEW")),U,3)=1
  1. DISABLE ; EP -
  1. S $P(^ABSP(9002313.99,1,"BILLING - NEW"),U,3)=1 Q
  1. ENABLE ; EP -
  1. S $P(^ABSP(9002313.99,1,"BILLING - NEW"),U,3)=0
  1. D TASKAT()
  1. Q
  1. TASKAT(ZTDTH) ;
  1. I '$D(ZTDTH) S ZTDTH=$$NOW^ABSPOS
  1. I '$$NEXTTIME!(ZTDTH<$$NEXTTIME) D
  1. . S $P(^ABSP(9002313.99,1,"BILLING - NEW"),U)=ZTDTH
  1. N ZTRTN,ZTIO
  1. S ZTRTN="BACKGR^"_$T(+0),ZTIO=""
  1. ;ZW ZTDTH,ZTRTN
  1. D ^%ZTLOAD
  1. Q
  1. ANY() Q $O(^ABSPTL("AS",1,0)) ; any need billing?
  1. ;IHS/OIT/SCR - 9/16/08 - START changes to REMOVE code to hold claims
  1. ;ANYHOLD() ;
  1. ;check for any entries in ^ABSPHOLD
  1. ;quit if no entries
  1. ;N ANYHOLD
  1. ;S ANYHOLD=$O(^ABSPHOLD(0))
  1. ;Q:'ANYHOLD 0
  1. ;if there are entries check last run
  1. ;run only once a day when date changes
  1. ;N RUNDT
  1. ;S RUNDT=$P($G(^ABSP(9002313.99,1,"BILLING - NEW")),U,8)
  1. ;Q:RUNDT'=CURRDT 1
  1. ;Q 0
  1. ;
  1. ;IHS/OIT/SCR - 9/16/08 - END changes to REMOVE code to hold claims
  1. ; LOCK, UNLOCK also used by ABSPOSBX
  1. LOCK() ;EP -
  1. L +^TMP("ABSPOSBD","BACKGR"):15 Q $T
  1. ;
  1. UNLOCK ;EP -
  1. L -^TMP("ABSPOSBD","BACKGR") Q
  1. BACKGR ;
  1. N CURRDT
  1. N ABSPBILD ;IHS/OIT/SCR 011210 patch 36
  1. D NOW^%DTC
  1. S CURRDT=X
  1. ;IHS/OIT/SCR 9/16/08 START changes to REMOVE code to hold claims
  1. ; I '$$ANY&('$$ANYHOLD) Q ; none need billing
  1. I '$$ANY Q ; none need billing
  1. ;IHS/OIT/SCR 9/16/08 END changes to REMOVE code to hold claims
  1. I '$$LOCK Q
  1. D INIT^ABSPOSL(DT+.2,1)
  1. I $$ANY D
  1. . D LOG("Billing job begins")
  1. . I $$DISABLED D G BACKGR99
  1. .. D LOG("Disabled; will reschedule.")
  1. . ;
  1. . ; Loop: Process the 9002313.57 entries which need billing.
  1. . ; They are listed in ^ABSPTL("AS",1,*)
  1. . ; ABSP57 is the variable name expected by POSTING^ABSPOSBB
  1. . ;
  1. . N ABSP57 S ABSP57=0
  1. . F S ABSP57=$O(^ABSPTL("AS",1,ABSP57)) Q:'ABSP57 D
  1. .. ;D LOG^ABSPOSL("Posting transaction "_ABSP57_".")
  1. .. ; ;IHS/OIT/SCR 12/24/09 Santa Rosa pre-patch 36 : Before calling the 3PB API, check to
  1. ..;see if the transaction has NEEDS BILLED flag set - if not, Kill the cross-reference
  1. ..;START
  1. ..S ABSPBILD=$P(^ABSPTL(ABSP57,0),"^",16) ;corrupt x-reference causes infinite loop in background process
  1. ..I ABSPBILD'=1 K ^ABSPTL("AS",1,ABSP57) ;IHS/OIT/SCR 011210 patch 36
  1. ..I ABSPBILD=1 D
  1. ...D POSTING^ABSPOSBB ; post the transaction
  1. ...;IHS/OIT/SCR 062309 patch 32 the condition has to do with HELD claims functionality removed in patch 29
  1. ...;D:'$D(^ABSPTL("AS",2,ABSP57)) SETFLAG^ABSPOSBC(ABSP57,0) ; clear the "needs billing" flag
  1. ...D SETFLAG^ABSPOSBC(ABSP57,0) ; clear the "needs billing" flag
  1. ...Q
  1. ..Q
  1. .Q
  1. ;IHS/OIT/SCR 12/24/09 Santa Rosa pre-patch 36 : Before calling the 3PB API, check to
  1. ;see if the transaction has information in the .15 field - if so, Kill the cross-reference
  1. ;END
  1. ;
  1. ;IHS/OIT/SCR - 09/16/07 - Patch 28 - START changes to REMOVE code to hold claims
  1. ;IHS/SD/RLT - 09/12/07 - Patch 22
  1. ; Loop: Process the held claims in ^ABSPHOLD.
  1. ; If tax id has been entered send to 3PB.
  1. ;I $$ANYHOLD D
  1. ;. D LOG("Holding job begins")
  1. ;. I $$DISABLED D G BACKGR99
  1. ;.. D LOG("Disabled; will reschedule.")
  1. ;. N HOLDCNT S HOLDCNT=0
  1. ;. N HOLDIEN S HOLDIEN=0
  1. ;. F S HOLDIEN=$O(^ABSPHOLD(HOLDIEN)) Q:'+HOLDIEN D
  1. ;.. D CHKHOLD^ABSPOSBH
  1. ;. S $P(^ABSP(9002313.99,1,"BILLING - NEW"),U,8)=CURRDT
  1. ;. D LOG^ABSPOSL(HOLDCNT_" 3PB transactions on hold.")
  1. ;IHS/OIT/SCR - 09/16/07 - Patch 28 - END changes to REMOVE code to hold claims
  1. ;
  1. D DONE^ABSPOSL
  1. ;
  1. BACKGR99 ;
  1. D UNLOCK
  1. I $$ANY D SCHEDULE($S($$DISABLED:60,1:1)) ; in case any slipped in while we were leaving
  1. Q
  1. ILCAR ;
  1. Q
  1. LOG(X) D LOG^ABSPOSL(X) Q
  1. PRINTLOG D PRINTLOG^ABSPOSL(DT+.2) Q