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

ABSPOS2.m

Go to the documentation of this file.
  1. ABSPOS2 ; IHS/FCS/DRS - POS manager's ScreenMan ;
  1. ;;1.0;PHARMACY POINT OF SALE;;JUN 21, 2001
  1. ;
  1. ; SEE code at tag HELP - is this an entry point we can use?
  1. ;
  1. ; ALL writes of screen lines should be done as follows:
  1. ; IF $$VISIBLE(line) DO WRITE^VALM10(line)
  1. ; Then NODISPLY can be set so that $$VISIBLE always returns FALSE
  1. ;
  1. ; option ABSP MANAGER SCREEN
  1. D EN^ABSPOS2() Q
  1. ;; ;
  1. ERROR D FULL^VALM1 Q ; what's a ^%ZOSF way to ZQUIT ?
  1. EN() ;EP - main entry point for list template ABSP STATISTICS AND MANAGEMENT
  1. ;S $ZT="ERROR^"_$T(+0) ; you lose the stack printout when you do this!
  1. N BASE,CURR,DISP,AVG,DIFF,CHG
  1. ; BASE(*) = base values, from when zeroed things out
  1. ; CURR(*) = current values, from most recent read
  1. ; DIFF(*) = differences
  1. ; CHG(*) = changed value to print, if any
  1. N LOCK S LOCK=1 ; should we lock stats when we fetch?
  1. ;D MYPARAMS
  1. ;D FETCHES(0) ; fetch stats into BASE() and CURR() both
  1. ;D DIFF
  1. ;S ^TMP("ABSPOS2",$J,"FREQ")=30 ;D UPDATE(-1)
  1. I $P($G(^ABSPECX("S",1,0)),U,2)="" D
  1. .N %,%H,%I,X D NOW^%DTC S $P(^ABSPECX("S",1,0),U,2)=%
  1. D EN^VALM("ABSP STATISTICS AND MANAGEMENT")
  1. Q
  1. INIT ; -- init variables and list array
  1. N NODISPLY S NODISPLY=1
  1. D MYPARAMS
  1. D CLEAN^VALM10
  1. S VALMCNT=0 ; 0 lines so far
  1. D LABELS^ABSPOS2C
  1. D HDR
  1. D FETCHES(1) ; set up CURR
  1. D DIFF ; compute DIFF = differences and changed ones go into CHG
  1. D VALUES^ABSPOS2B ; displays whatever's in CHG() and kills it off
  1. Q
  1. FETCHES(B) ;EP - from ABSPOS2A
  1. ; B = 0 to fetch into BASE(...) array, 1 for CURR(...) array
  1. N DST S DST=$S(B=1:"CURR",B=0:"BASE")
  1. S ^TMP("ABSPOS2",$J,"$H",DST)=$H
  1. D FETCH58(DST_"(""COMM"")")
  1. D FETSTAT(DST_"(""STAT"")")
  1. D FETPKTQ(DST_"(""PKTQ"")")
  1. I B=0 D ; if setting BASE values, copy them into CURR
  1. .M CURR=BASE ; copy them into CURR
  1. .S ^TMP("ABSPOS2",$J,"$H","BASE")=$H
  1. Q
  1. DIFF ;EP - from ABSPOS2A
  1. K CHG ; compute DIFF=CURR-BASE differences; set CHG for any changed
  1. N A,B,X S A=""
  1. F S A=$O(CURR(A)) Q:A="" S B="" F S B=$O(CURR(A,B)) Q:B="" D
  1. .S X=CURR(A,B)-$G(BASE(A,B))
  1. .I X'=$G(DIFF(A,B)) S (DIFF(A,B),CHG(A,B))=X
  1. Q
  1. UPD1 ; one update cycle
  1. N A,B,T
  1. D FETCHES(1) ; fetch into CURR array
  1. D DIFF ; compute differences
  1. D VALUES^ABSPOS2B ; compute values and display if changed
  1. Q
  1. HDT(X) ; first convert fileman date-time to $H format, then $$H it
  1. N %H,%T,%Y D H^%DTC S X=$P(X,".",2)
  1. Q $$H(%H_","_($E(X,1,2)*3600+($E(X,3,4)*60)+$E(X,5,6)))
  1. H(H) S:'$D(H) H=$H Q $P(H,",")-58000*86400+$P(H,",",2) ; $$H seconds
  1. FETCH58(DST) ; send DST = closed root of the destination
  1. K @DST
  1. N FN,DIC,DR,DA,DIQ,TMP ; note that DA=1 is hardcoded
  1. S @DST@("$$H")=$$H
  1. S (FN,DIC)=9002313.58,DR="1:10000",DIQ="TMP(",DA=1
  1. I LOCK L +^ABSP(FN):300
  1. D EN^DIQ1
  1. I LOCK L -^ABSP(FN)
  1. M @DST=TMP(FN,1)
  1. S @DST@(2)=$P(^ABSPECX("S",1,0),U,2) ; overwrite w/internal form
  1. S @DST@(2)=$$HDT(@DST@(2))
  1. Q
  1. FETSTAT(DEST) ;EP - from ABSPOSIW
  1. ; send DEST = closed root of the destination
  1. K @DEST
  1. S @DEST@("$$H")=$$H
  1. I LOCK LOCK +^ABSPT
  1. N Q,N,A F Q=0:10:90,19,31,51 D
  1. .S A="" F N=0:1 S A=$O(^ABSPT("AD",Q,A)) Q:A=""
  1. . I Q#10 S @DEST@(Q\10*10)=@DEST@(Q\10*10)+N
  1. . E S @DEST@(Q)=N ; relies on multiples of 10 coming first!
  1. I LOCK LOCK -^ABSPT
  1. Q
  1. FETPKTQ(DEST) ;EP - from ABSPOSIW,ABSPOSRB
  1. ; send DEST = closed root of the destination
  1. ; send LOCK = true if you want to lock all the queues (for exact count)
  1. ; ^ABSPECX("POS",psetien,"C",n) and "R"
  1. ; @DEST@("C",PSetIEN) = packets waiting to send
  1. ; @DEST@("C")=total of all the "C" counts
  1. ; @DEST@("R",PSetIEN) = packets received awaiting receive processing
  1. ; @DEST@("R")=total
  1. K @DEST
  1. S @DEST@("$$H")=$$H,(@DEST@("C"),@DEST@("R"))=0
  1. ; Would need to do similarly for each PSetIEN value too INCOMPLETE
  1. I LOCK LOCK +^ABSPECX("POS")
  1. N A,B,C,N,P,X
  1. S A="" F S A=$O(^ABSPECX("POS",A)) Q:A="" D
  1. .F B="C","R" D
  1. ..S C="" F N=0:1 S C=$O(^ABSPECX("POS",A,B,C)) Q:C=""
  1. ..S @DEST@(B,A)=N
  1. ..S @DEST@(B)=$G(@DEST@(B))+N
  1. I LOCK LOCK -^ABSPECX("POS")
  1. Q
  1. MYPARAMS ;
  1. Q
  1. UPDFREQ() ;I DUZ=9598 Q 5 ; I get it every 5 seconds
  1. Q 15 ; every fifteen seconds is the usual case
  1. ;
  1. CLEARAT() ;
  1. S Y=$P(^ABSPECX("S",1,0),U,2) X ^DD("DD") Q Y
  1. HDR ; -- header code
  1. S VALMHDR(1)="Communications statistics last cleared on "_$$CLEARAT
  1. S XQORM("B")="CU" ; the default is Update Continuously
  1. S XQORM("B")="U1" ; but we'd like to do U1 continuously from top lvl
  1. Q
  1. ;
  1. UPD ;EP - From ABSPOS2A ; Protocol ABSP P2 UPDATE
  1. D UPDATE(1) S VALMBCK="",XQORM("B")="U1" Q ; ABSB RXE POS P2 UPDATE
  1. CONTUPD ; Protocol ABSP P2 CONTINUOUS
  1. W !!!!! D UPDATE(-1) S VALMBCK="" Q ; ABSB RXE POS P2 CONTINUOUS
  1. UPDATE(COUNTER) ; with COUNTER = a count down
  1. N STOP F D Q:$G(STOP)
  1. .D UPD1
  1. .S COUNTER=COUNTER-1 I 'COUNTER S STOP=1 Q
  1. .I '$G(NODISPLY) D
  1. ..D MSG^VALM10("In continuous update mode: press Q to Quit")
  1. ..;I $D(^TMP("XGKEY",$J)) possible interference?
  1. ..N X S X=$$READ^XGKB(1,$$UPDFREQ) D MSG^VALM10(" ")
  1. ..;N X R X#1:^TMP("ABSPOS2",$J,"FREQ") D MSG^VALM10(" ")
  1. ..;I X]"","Qq^^"[X S STOP=1
  1. ..I '$G(DTOUT),X]"","Qq^^"[X S STOP=1
  1. ..N Y F R Y:0 Q:'$T ; clean out typeahead (like mistaken arrow keys)
  1. ..; But if timed out, keep looping and updating
  1. Q
  1. HELP ; -- help code
  1. S X="?" D DISP^XQORM1 W !!
  1. Q
  1. ;
  1. EXIT ; -- exit code
  1. D FULL^VALM1
  1. Q
  1. ;
  1. EXPND ; -- expand code
  1. Q