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

ABSPOSR1.m

Go to the documentation of this file.
  1. ABSPOSR1 ; IHS/FCS/DRS - silent claim submitter ;
  1. ;;1.0;PHARMACY POINT OF SALE;**48**;JUN 21, 2001;Build 38
  1. ; This routine monitors ^PSRX indexes. As it detects
  1. ; the release of prescriptions and sometimes cancellations, too,
  1. ; it silently submits claims and sometimes reversals, too.
  1. ; Only one of these may run at a time!
  1. Q
  1. STARTME ;EP - enter here to start the background job (by asking Taskman)
  1. ; option ABSP BACKGROUND SCAN START
  1. W !
  1. Q:'$$CHKTYPE(1)
  1. N STATUS S STATUS=$$STATUS
  1. W "The background scanner is now ",$$STATUS,!
  1. I $$RUNNING W "The background scanner job is already running.",!
  1. I STATUS["?" D
  1. . W "But since the status is uncertain, let's stop and restart:",!
  1. . D STOPME
  1. D TASK^ABSPOSR1
  1. W "Taskman will start the background scanner job.",!
  1. Q
  1. STOPME ;EP - enter here to stop the background job
  1. ; option ABSP BACKGROUND SCAN STOP
  1. W !
  1. Q:'$$CHKTYPE(1)
  1. W "Stopping the background scanner job..."
  1. D STOPIT(1)
  1. W !
  1. Q
  1. MYSTATUS ;EP - enter here to inquire of background job's status
  1. ; option ABSP BACKGROUND SCAN STATUS
  1. W !
  1. Q:'$$CHKTYPE(1)
  1. N X S X=$$STATUS
  1. W "Status of POS background job: ",X,!
  1. N DIC,DA,DR,DIQ
  1. S DIC="^ABSP(9002313.99,",DA=1,DR=$T(+0) D EN^DIQ
  1. Q
  1. LOGFILE ;EP -
  1. D LOGFILE1(.3) Q
  1. LOGFILE1(OFFSET) ;EP - enter here to print background job's log file
  1. ; OFFSET = the .3 or .6 or whatever the "+" is for this type
  1. W !,"Print "
  1. I OFFSET=.3 W "background job's"
  1. E I OFFSET=.6 W "back billing"
  1. W " log file",!
  1. I $$CHKTYPE(1) ; just report; don't roadblock with it
  1. N ABSPDATE,PROMPT,DEFAULT
  1. S PROMPT="Print log file for what date? ",DEFAULT=DT
  1. S ABSPDATE=$$DATE^ABSPOSU1(PROMPT,DEFAULT,1,3010101,9999999,"EX")
  1. Q:ABSPDATE<1
  1. N POP D ^%ZIS Q:$G(POP)
  1. N LOGFILE S LOGFILE=ABSPDATE+OFFSET
  1. D PRINTLOG^ABSPOSL(ABSPDATE+OFFSET)
  1. D PRESSANY^ABSPOSU5()
  1. D ^%ZISC
  1. Q
  1. RUNNING() ;
  1. N I,S F I=1:1:10 S S=$$STATUS Q:S="RUNNING" Q:S="STOPPED" H 5
  1. Q S'="STOPPED" ; "REQUESTED STOP" comes back True, like RUNNING
  1. CHKTYPE(ECHO) ; returns True if input type is the background polling job
  1. ; returns False if not
  1. N XI S XI=$$GET1^DIQ(9002313.99,"1,",943,"I")
  1. I XI=2 Q 1 ; yes, background scanner.
  1. ; not background scanner
  1. I $G(ECHO) D
  1. . W "The input method on this POS system is ",$$GET1^DIQ(9002313.99,"1,",943),!
  1. . W "This program is only for use with the background scanner method.",!
  1. Q 0
  1. TASK ;EP -
  1. N X,%DT,Y S X="N",%DT="ST" D ^%DT
  1. D TASKAT(Y)
  1. Q
  1. TASKAT(ZTDTH) ;
  1. N ZTRTN,ZTIO
  1. S ZTRTN="EN^ABSPOSR1",ZTIO=""
  1. D ^%ZTLOAD
  1. Q
  1. STATUS() ; external call to get the status
  1. ; returns "RUNNING" or "STOPPED" or "REQUESTED STOP"
  1. ; maybe with a "?"
  1. N X S X=$$GETFIELD(120.03) S:X="" X=2
  1. ; make sure the lock status is consistent with the numerical status
  1. N Y S Y=$$LOCK I Y D UNLOCK
  1. I X=0 Q "RUNNING"_$S(Y:"?",1:"")
  1. I X=1 Q "REQUESTED STOP"_$S(Y:"?",1:"")
  1. I X=2 Q "STOPPED"_$S(Y:"",1:"?")
  1. Q "?"
  1. STOPIT(ECHO,NOWAIT) ;EP - external call to request that it stop
  1. ; and wait until it is stopped
  1. ; May DO or $$; $$ returns value of stop flag (2 = success)
  1. I $$GETFIELD(120.03)=2 Q ; already stopped
  1. D SETFIELD(120.03,1) ; set the "stop requested" flag
  1. I '$G(NOWAIT) D
  1. . F Q:$$GETFIELD(120.03)=2 D H 5
  1. . . I $G(ECHO) W "." W:$X>74 !
  1. . . ; Handle the case where the job was killed:
  1. . . ; Run flag says its running but the lock says it's not
  1. . . ; So force run flag to say "stopped".
  1. . . I $$STATUS="REQUESTED STOP?" D SETFIELD(120.03,2)
  1. Q:$Q $$GETFIELD(120.03) Q
  1. DELAYSTP(N) H N D STOPIT() Q ; J TEST^ABSPOSR1 for your testing
  1. ;
  1. ; Advice for testing:
  1. ; 0. Init ^ABSP(9002313.99,"ABSPOSR1")=a starting T1 time
  1. ; Just do this once, ever.
  1. ;
  1. ; Then for each time you do testing:
  1. ; 1. DO NEXT^ABSPOSR1(N) ; N = desired number of transactions
  1. ; and it sets T1,T2 so you get N transactions
  1. ; 2. D TEST^ABSPOSR1 to actually run the test.
  1. ; When done, it will update ^ABSP(9002313.99,"ABSPOSR1")
  1. ; to be 1 second past the previous T2 that you used.
  1. ; 3. DO ^ABSPOS (which goes to EN^ABSPOS6A) to watch the results.
  1. ; 4. D LASTLOG^ABSPOSR1 to examine the .3 log and see what's going on
  1. TEST W !,"Running the test - times ",T1,"-",T2,!
  1. I '$$LOCK W "Can't get LOCK",! Q
  1. D INIT^ABSPOSL(.3,1)
  1. D DEFAULTS
  1. D KTESTLST
  1. D WORKLIST^ABSPOSR3(T1,T2,$$TESTLIST)
  1. D PROCESS^ABSPOSR3($$TESTLIST)
  1. D LASTLOG
  1. D UNLOCK
  1. S $P(^ABSP(9002313.99,"ABSPOSR1"),U)=$$TADD^ABSPOSUD(T2,.000001)
  1. Q
  1. KTESTLST K ^ABSPECP($T(+0)_" TESTING") Q
  1. TESTLIST() Q "^ABSPECP("""_$T(+0)_" TESTING"")"
  1. LASTLOG ; tool for test - find and print most recent log file
  1. N X S X=2990000
  1. F S X=$O(^ABSPECP("LOG",X),-1) Q:'X Q:X#1=.3
  1. I 'X W "No log file found",! Q
  1. D PRINTLOG^ABSPOSL(X)
  1. Q
  1. EN ; EP - via Taskman as initiated by START, above
  1. ; main program for background job to stealthily submit claims
  1. ; changes to EN should be mimicked in TEST(), above
  1. I '$$LOCK Q
  1. N RESTART
  1. D SETFIELD(120.01,$J),SETFIELD(120.03,0)
  1. D INIT^ABSPOSL(DT+.3,1)
  1. D LOG("Background claim submitter running as job "_$J)
  1. D DEFAULTS
  1. D MONITOR^ABSPOSR3 ; may set RESTART
  1. D LOG("Background claim submitter job "_$J_" completed.")
  1. D RELSLOT^ABSPOSL
  1. D UNLOCK
  1. I $G(RESTART) D TASK
  1. Q
  1. DEFAULTS ;EP -
  1. I '$$GETFIELD(120.02) D SETFIELD(120.02,"NOW","E") ; last time proc'd
  1. I '$$GETFIELD(120.04) D SETFIELD(120.04,30) ; default interval 30 sec
  1. ; 30 secs is the minimum! you have to allow time for ABSPOSRX
  1. ; to get background jobs started, to create .59 entries, etc.
  1. I '$$GETFIELD(120.05) D SETFIELD(120.05,30) ; reach back more sec
  1. ; but you miss something if they enter it now with a release time
  1. ; of an hour ago, or yesterday
  1. I $$GETFIELD(120.06)="" D SETFIELD(120.06,"AL") ; index for new claims
  1. I $$GETFIELD(120.07)="" D SETFIELD(120.07,"AJ") ; index for canceled
  1. Q
  1. SETFIELD(FIELD,VALUE,FLAGS) ;EP -
  1. N FDA,IENS,MSG,FN S IENS="1,",FN=9002313.99
  1. S FDA(FN,IENS,FIELD)=VALUE
  1. SF1 D FILE^DIE($G(FLAGS),"FDA","MSG")
  1. I $D(MSG) D LOG^ABSPOSL2("SF1^ABSPOSR1",.MSG) ; /IHS/OIT/RAM ; 12 JUN 17 ; AND LOG IT IF AN ERROR OCCURS.
  1. Q:'$D(MSG) ; success
  1. D ZWRITE^ABSPOS("FLAGS","FDA","MSG","FIELD","VALUE")
  1. G SF1:$$IMPOSS^ABSPOSUE("FM","TRI","FILE^DIE failed",,"SETFIELD",$T(+0))
  1. Q
  1. GETFIELD(FIELD) ;EP -
  1. Q $P($G(^ABSP(9002313.99,1,"ABSPOSR1")),U,FIELD-120*100)
  1. LOCK() L +^ABSP(9002313.99,"ABSPOSR1"):0 Q $T
  1. UNLOCK L -^ABSP(9002313.99,"ABSPOSR1") Q
  1. LOG(X) D LOG^ABSPOSL(X) Q