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

GECSSTTM.m

Go to the documentation of this file.
  1. GECSSTTM ;WISC/RFJ-stacker file transmission (multi docs in a msg) ;08 Dec 93
  1. ;;2.0;GCS;**4,5**;MAR 14, 1995
  1. Q
  1. ;
  1. ;
  1. TRANSALL ; transmit code sheets waiting for clock in stack file
  1. ; check for another job transmitting stack code sheets
  1. N DA,GECSFQUE
  1. L +^GECS(2100.1,"ATRANSMIT"):10 I '$T Q
  1. S GECSFQUE=1
  1. K ^TMP($J,"GECSSTTR")
  1. S DA=0 F S DA=$O(^GECS(2100.1,"AS","Q",DA)) Q:'DA D BUILD(DA)
  1. D TRANSMIT^GECSSTTT
  1. K ^TMP($J,"GECSSTTR")
  1. L -^GECS(2100.1,"ATRANSMIT")
  1. S ZTREQ="@"
  1. Q
  1. ;
  1. ;
  1. BUILD(DA) ; build tmp global for stack entry da
  1. ; $g(gecsfaut)=1 for immediate transmissions
  1. I '$D(^GECS(2100.1,DA,0)) Q
  1. L +^GECS(2100.1,DA):10 I '$T Q
  1. ;
  1. N %,BATCHDA,CHECKSUM,DA1,DATA,ENDOFCS,ENDOFMSG,FINDHOLD,GECSFLAG,GECSLPC,HOLDDATE,LINE,SEGMENT,SEQSIZE,SEQUENCE,STACSIZE,X,Y
  1. ;
  1. I $E($G(^GECS(2100.1,DA,10,1,0)),1,3)'="CTL" D SETSTAT^GECSSTAA(DA,"E"),ERROR^GECSSTTR(DA,"Control segment/first line of code sheet missing") L -^GECS(2100.1,DA) Q
  1. ;
  1. S SEGMENT=$P(^GECS(2100.1,DA,0),"^",5)
  1. I SEGMENT="" D SETSTAT^GECSSTAA(DA,"E"),ERROR^GECSSTTR(DA,"Segment not defined for entry") L -^GECS(2100.1,DA) Q
  1. S (ENDOFCS,ENDOFMSG)=""
  1. I $P(SEGMENT,":",2)="FMS" S ENDOFCS="{",ENDOFMSG="}"
  1. ;
  1. S BATCHDA=+$P($G(^GECS(2101.2,+$O(^GECS(2101.2,"B",SEGMENT,0)),0)),"^",4)
  1. I 'BATCHDA D SETSTAT^GECSSTAA(DA,"E"),ERROR^GECSSTTR(DA,"Batch type in file 2101.2 is incorrect") L -^GECS(2100.1,DA) Q
  1. ;
  1. S GECSLPC=$G(^%ZOSF("LPC")) I GECSLPC="" S GECSLPC="S Y="""""
  1. ; for automatically created docs, check checksum and hold date
  1. I $P($G(^GECS(2100.1,DA,0)),"^",6)="A" D I $G(GECSFLAG) L -^GECS(2100.1,DA) Q
  1. . ; check hold date greater than today
  1. . S HOLDDATE=$P($G(^GECS(2100.1,DA,11)),"^",3)
  1. . ; for immediate transmissions, queue code sheet
  1. . I HOLDDATE>DT D:$G(GECSFAUT) SETSTAT^GECSSTAA(DA,"Q") S GECSFLAG=1 Q
  1. . ; compute checksum and find hold date if not defined
  1. . S CHECKSUM=""
  1. . S DA1=0 F S DA1=$O(^GECS(2100.1,DA,10,DA1)) Q:'DA1 S DATA=$G(^(DA1,0)) D Q:$G(GECSFLAG)
  1. . . I 'HOLDDATE I $E($P(DATA,"^"),3)=2!($P(DATA,"^")="AT1") S FINDHOLD=$$HOLDDATE^GECSSTTR(DATA) I FINDHOLD S $P(^GECS(2100.1,DA,11),"^",3)=FINDHOLD,GECSFLAG=1 Q
  1. . . S X=CHECKSUM_DATA X GECSLPC S CHECKSUM=Y
  1. . ; for immediate transmissions, queue code sheet
  1. . I $G(GECSFLAG) D:$G(GECSFAUT) SETSTAT^GECSSTAA(DA,"Q") Q
  1. . ; compare checksums
  1. . S X=$P($G(^GECS(2100.1,DA,11)),"^",2) I X="" Q
  1. . I X'=CHECKSUM D SETSTAT^GECSSTAA(DA,"E"),ERROR^GECSSTTR(DA,"Code sheet has been altered since creation") S GECSFLAG=1
  1. ;
  1. ; change transmission date on ctl segment
  1. S ^GECS(2100.1,DA,10,1,0)=$$CTLDATE^GECSSTTR(^GECS(2100.1,DA,10,1,0))
  1. ;
  1. ; fit code sheet in a sequence number if possible
  1. S STACSIZE=$P($G(^GECS(2100.1,DA,11)),"^")
  1. I STACSIZE>30000 D MULTIPLE L -^GECS(2100.1,DA) Q
  1. S SEQUENCE=0 F S SEQUENCE=$O(^TMP($J,"GECSSTTR","SIZE",SEQUENCE)) Q:'SEQUENCE S SEQSIZE=^(SEQUENCE) I ($P(SEQSIZE,"^")+STACSIZE)<30000,^TMP($J,"GECSSTTR","BATCH",SEQUENCE)=BATCHDA Q
  1. ; create a new sequence
  1. I 'SEQUENCE D SEQUENCE S SEQSIZE="0^0"
  1. ;
  1. ; recompute checksum with new transmission date and time on ctl segment
  1. S LINE=$P(SEQSIZE,"^",2),CHECKSUM=""
  1. S DA1=0 F S DA1=$O(^GECS(2100.1,DA,10,DA1)) Q:'DA1 S DATA=$G(^(DA1,0)) I DATA'="" D
  1. . S LINE=LINE+1,^TMP($J,"GECSSTTR","CS",SEQUENCE,LINE,0)=DATA
  1. . S X=CHECKSUM_DATA X GECSLPC S CHECKSUM=Y
  1. . ; check for last code sheet in stack entry
  1. . I '$O(^GECS(2100.1,DA,10,DA1)),$L($G(ENDOFCS)) D Q
  1. . . I DATA'[ENDOFCS S DATA=DATA_ENDOFCS
  1. . . S ^TMP($J,"GECSSTTR","CS",SEQUENCE,LINE,0)=DATA
  1. ;
  1. ; store new checksum
  1. S $P(^GECS(2100.1,DA,11),"^",2)=CHECKSUM
  1. ;
  1. D ENDSEQ($P(SEQSIZE,"^")+STACSIZE,LINE)
  1. L -^GECS(2100.1,DA)
  1. Q
  1. ;
  1. ;
  1. MULTIPLE ; code sheet is larger than 30k, create multiple msgs
  1. D SEQUENCE
  1. N %,COUNT,SIZE,STRTSEQ,MAILMSGS
  1. S STRTSEQ=SEQUENCE
  1. S MAILMSGS=1,(LINE,SIZE)=0,CHECKSUM=""
  1. S DA1=0 F S DA1=$O(^GECS(2100.1,DA,10,DA1)) Q:'DA1 S DATA=$G(^(DA1,0)) I DATA'="" D
  1. . S LINE=LINE+1,^TMP($J,"GECSSTTR","CS",SEQUENCE,LINE,0)=DATA
  1. . S X=CHECKSUM_DATA X GECSLPC S CHECKSUM=Y
  1. . ; check for last code sheet in stack entry
  1. . I '$O(^GECS(2100.1,DA,10,DA1)),$L($G(ENDOFCS)) D Q
  1. . . I DATA'[ENDOFCS S DATA=DATA_ENDOFCS
  1. . . S ^TMP($J,"GECSSTTR","CS",SEQUENCE,LINE,0)=DATA
  1. . S SIZE=SIZE+$L(DATA)
  1. . I SIZE>30000 D
  1. . . I $L($G(ENDOFMSG)),DATA'[ENDOFMSG S ^TMP($J,"GECSSTTR","CS",SEQUENCE,LINE,0)=DATA_ENDOFMSG
  1. . . D ENDSEQ(SIZE,LINE),SEQUENCE S MAILMSGS=MAILMSGS+1,LINE=2,SIZE=0
  1. ;
  1. ; store new checksum
  1. S $P(^GECS(2100.1,DA,11),"^",2)=CHECKSUM
  1. ;
  1. ; modify sequence count
  1. S DATA=^GECS(2100.1,DA,10,1,0),$P(DATA,"^",13)=$E("000",$L(MAILMSGS)+1,3)_MAILMSGS
  1. S COUNT=1 F %=STRTSEQ:1 Q:'$D(^TMP($J,"GECSSTTR","CS",%)) S $P(DATA,"^",12)=$E("000",$L(COUNT)+1,3)_COUNT,^TMP($J,"GECSSTTR","CS",%,1,0)=DATA,COUNT=COUNT+1
  1. ;
  1. ; send size=30001 to prevent other code sheets from being added
  1. D ENDSEQ(30001,LINE)
  1. Q
  1. ;
  1. ;
  1. ENDSEQ(SIZE,LINE) ; set end sequence control in tmp
  1. ; size=size of code sheet; line=last line of sequence
  1. N %
  1. S ^TMP($J,"GECSSTTR","SIZE",SEQUENCE)=SIZE_"^"_LINE
  1. S ^TMP($J,"GECSSTTR","LIST",SEQUENCE,DA)=""
  1. S ^TMP($J,"GECSSTTR","BATCH",SEQUENCE)=BATCHDA
  1. S %=$G(^TMP($J,"GECSSTTR","SEGS",SEQUENCE)) I %[$P(SEGMENT,":") Q
  1. S ^TMP($J,"GECSSTTR","SEGS",SEQUENCE)=%_$S(%="":"",1:",")_$P(SEGMENT,":")
  1. Q
  1. ;
  1. ;
  1. SEQUENCE ; return next sequence number
  1. S SEQUENCE=$G(^TMP($J,"GECSSTTR","SEQ"))+1,^TMP($J,"GECSSTTR","SEQ")=SEQUENCE
  1. Q