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

PSXARC1.m

Go to the documentation of this file.
  1. PSXARC1 ;BIR/HTW-Gather Data to Archive ;02 Aug 2001 9:57 AM
  1. ;;2.0;CMOP;**26,38**;11 Apr 97
  1. ; Reference to file #200 supported by DBIA 10060
  1. S (LN,PG,CT)=1,(X,LEN,BATCT,RXCT)=0,PAD=" "
  1. TAPEHDR U PSXT W "$$HDR|CMOP MASTER ARCHIVE^"_PSXTAPE
  1. D NOW^%DTC S Y=% X ^DD("DD") K %
  1. U IO(0) W @PSXIOF,?10,"CMOP MASTER DATABASE ARCHIVE",?45,Y
  1. MAIN ;
  1. U IO(0) W !!,"Recording data on tape # ",PSXTAPE,". Write this number on the tape label!!",!!
  1. F ZZZ=0:0 S ZZZ=$O(^TMP("PSX",$J,ZZZ)) Q:'ZZZ D ONE S ^PSX(552.1,I21,-9)=""
  1. U IO(0) W !!,"Total # of Transmissions Archived: ",$G(BATCT)
  1. U IO(0) W !,"Total # of Rx's Archived : ",$G(RXCT)
  1. U IO(0) W !,"Total Bytes Archived : ",$G(T1)+$G(T2)
  1. D NOW^%DTC S Y=% X ^DD("DD")
  1. U IO(0) W !,"Completed: ",Y," Closing Tape Device..."
  1. D ^%ZISC
  1. K I1,LN,LEN,PG,PSXAM,PSXBEE,PSXIOF,PSXPIOF,PSXPIOST,PSXP,PSXT,PSXTBS
  1. K PSXTIOF,PSXTPAR,%MT,Y,Z,Z1,ZPC,ZQ1,ZQ,ZZZ,RXCT,BATCT,T1,T2,%
  1. K %MT,%ZIS,PSXTAPE,C1,CT,I21,I24,PAD,PSXEOT,X,XX,Y,Z
  1. Q
  1. ONE ;GET DATA FROM 552.1
  1. ;** FROM 0,1,2,P NODES **
  1. ;REC=(1)BAT-REF^(2)STATUS^(3)TRANS D/T^(4)REC D/T^(5)CLOSED D/T
  1. ;^(6)PROC D/T^(7)START SEQ^(8)END SEQ^(9)TOT ORD^(10)TOT RX'S
  1. ;^(11)PURGE STAT^(12)RETRANS^(13) BAT-REF^(14)DIV^(15)SITE^(16)SENDER
  1. S I21=$P(^TMP("PSX",$J,ZZZ),"^") Q:$G(I21)']""
  1. F I=1:1:6 S $P(REC,"^",I)=$P(^PSX(552.1,I21,0),"^",I)
  1. S PC=7 F I=1:1:5 S $P(REC,"^",PC)=$P($G(^PSX(552.1,I21,1)),"^",I),PC=PC+1
  1. F I=1:1:2 S $P(REC,"^",PC)=$P($G(^PSX(552.1,I21,2)),"^",I),PC=PC+1
  1. F I=1:1:3 S $P(REC,"^",PC)=$P($G(^PSX(552.1,I21,"P")),"^",I),PC=PC+1
  1. S Z=2 F Z1=1,5,6,7,16,8,9,10,11,19,12,13,2,3,4 D S Z=Z+1
  1. .S Y=$P(REC,"^",Z),$P(REC,"^",Z)=$$EXTERNAL^DILFD(552.1,Z1,"",Y)
  1. .;S Y=$P(REC,"^",Z) I $D(^DD(552.1,Z1,0)) S C=$P(^DD(552.1,Z1,0),U,2) D Y^DIQ S $P(REC,"^",Z)=Y
  1. ;N X,Y S DIC=4,DIC(0)="MNZ",X=+$P(REC,"^",15),X=$E(X,1,3) S:$D(^PSX(552,"D",X)) X=$E(X,2,99) D ^DIC K DIC ;****DOD L1
  1. ;S:($D(Y(0,0))) $P(REC,"^",15)=Y(0,0) K X,Y
  1. N X,Y
  1. S X=+$P(REC,"^",15),AGNCY="VASTANUM" S:$D(^PSX(552,"D",X)) X=$E(X,2,99),AGNCY="DMIS" ;****DOD L1
  1. S X=$$IEN^XUMF(4,AGNCY,X) ;****DOD L1
  1. S:(X) $P(REC,"^",15)=$$GET1^DIQ(4,X,.01) K X,Y ;****DOD L1
  1. S REC="$$REC|"_REC
  1. K PC,Z,C,Y,I
  1. CNODE I '$D(^PSX(552.1,I21,3)) G LBL
  1. F Z=0:0 S Z=$O(^PSX(552.1,I21,3,Z)) Q:'Z S COM(Z)="$$COM|"_$G(^(Z,0))
  1. ; Get labels printed
  1. LBL I '$D(^PSX(552.1,I21,4)) G ACK
  1. S Z1=1,LBL(Z1)="$$LBL|"
  1. S Z=$O(^PSX(552.1,I21,4,0)) I $G(Z)']"" G ACK
  1. LBL1 S Y=$P(^PSX(552.1,I21,4,Z,0),"^") X ^DD("DD")
  1. ;S NAME=$P(^VA(200,$P(^PSX(552.1,I21,4,Z,0),"^",2),0),"^")
  1. S NAME=$$GET1^DIQ(200,$P(^PSX(552.1,I21,4,Z,0),"^",2),.01)
  1. I $L(LBL(Z1))+$L(Y)+$L(NAME)<245 S LBL(Z1)=LBL(Z1)_Y_"^"_NAME_"/"
  1. E S Z1=Z1+1 S LBL(Z1)="$$LBL|"_Y_"^"_NAME_"^"
  1. S Z=$O(^PSX(552.1,I21,4,Z)) I $G(Z)]"" G LBL1
  1. ACK I $D(^PSX(552.1,I21,"ACK")) D
  1. .S ACK="$$ACK|"_$G(^PSX(552.1,I21,"ACK"))
  1. ; W 552.1 data to tape
  1. D PSXAT
  1. BATCH U PSXT W REC S T1=$G(T1)+$L(REC)
  1. I $D(COM)>1 F Z=0:0 S Z=$O(COM(Z)) Q:'Z U PSXT W COM(Z) S T1=$G(T1)+$L(COM(Z))
  1. I $D(LBL)>1 F Z=0:0 S Z=$O(LBL(Z)) Q:'Z U PSXT W LBL(Z) S T1=$G(T1)+$L(LBL(Z))
  1. I $D(ACK)>1 U PSXT W ACK S T1=$G(T1)+$L(ACK)
  1. ;Print 552.1 data
  1. S BATCT=$G(BATCT)+1
  1. ;Disallow further editing of Archived batch
  1. HEADING U IO(0) I $Y>22 W @PSXIOF S PG=1
  1. I $G(PG)=1 U IO(0) W !,"TRANSMISSION #",?20,"TOT ORDERS",?36,"TOT Rx's" S PG=$G(PG)+1
  1. U IO(0) W !,$P($P(REC,"|",2),"^"),?20,$J($P($P(REC,"|",2),"^",9),10),?34,$J($P($P(REC,"|",2),"^",10),10)
  1. K NAME,Y,Z1,Z
  1. ; Get info for 552.4
  1. S I24=$P(^TMP("PSX",$J,ZZZ),"^",2) Q:$G(I24)']""
  1. S C1=1
  1. RX F Z=0:0 S Z=$O(^PSX(552.4,I24,1,Z)) Q:'Z D Q:$G(NEWTAPE)=1
  1. .S REC1=$G(^PSX(552.4,I24,1,Z,0))
  1. .S REC2=$G(^PSX(552.4,I24,1,Z,2))
  1. .S ZZ=2 F Z1=1,2,3,4,5,7,8,.02,9,10,11,12 D S ZZ=ZZ+1
  1. ..S Y=$P(REC1,"^",ZZ),$P(REC1,"^",ZZ)=$$EXTERNAL^DILFD(552.41,Z1,"",Y)
  1. ..;S Y=$P(REC1,"^",ZZ),C=$P(^DD(552.41,Z1,0),U,2) D Y^DIQ S $P(REC1,"^",ZZ)=Y
  1. .S ZZ=1 F Z1=13,14,15,16 D S ZZ=ZZ+1
  1. ..S Y=$P(REC2,"^",ZZ),$P(REC2,"^",ZZ)=$$EXTERNAL^DILFD(552.41,Z1,"",Y)
  1. ..;S Y=$P(REC2,"^",ZZ) I $D(^DD(552.41,Z1,0)) S C=$P(^DD(552.41,Z1,0),U,2) D Y^DIQ S $P(REC2,"^",ZZ)=Y
  1. .F ZLOT=0:0 S ZLOT=$O(^PSX(552.4,I24,1,Z,1,ZLOT)) Q:($G(ZLOT)']"") D
  1. ..S Y=$P($G(^PSX(552.4,I24,1,Z,1,ZLOT,0)),"^",2) X ^DD("DD")
  1. ..S LOT=$G(LOT)_$P($G(^PSX(552.4,I24,1,Z,1,ZLOT,0)),"^")_"^"_Y_"/"
  1. .; I EOT detected, reset batch info and rewrite to new tape
  1. .D PSXAT I $G(NEWTAPE)=1 Q
  1. .U PSXT W "$$RX,"_C1_"|"_REC1 S RXCT=$G(RXCT)+1,T2=$G(T2)+$L(REC1)
  1. .U PSXT W "$$ZX,"_C1_"|"_REC2 S T2=$G(T2)+$L(REC1)
  1. .I $G(LOT)]"" U PSXT W "$$LOT,"_C1_"|"_LOT S T2=$G(T2)+$L(LOT)
  1. .I $G(PSXP)]"" D RX^PSXARC2
  1. .K REC1,REC2,ZZ,ZLOT,LOT,Z1,Y,C S C1=C1+1
  1. I $G(NEWTAPE)=1 K NEWTAPE,Z G BATCH
  1. S ^PSX(552.4,I24,-9)=""
  1. S NAME=$$GET1^DIQ(200,DUZ,.01)
  1. K DD,DO
  1. S DIC="^PSXARC(",DIC("DR")="1////"_PSXTAPE_";2////"_DT_";3////"_NAME
  1. S DIC(0)="MZ",X=$P(^TMP("PSX",$J,ZZZ),"^",3)
  1. D FILE^DICN K DIC,X,NAME,DD,DO
  1. I $G(Y)<0 W !!,"An error has been encountered in the archive file for transmission number ",$P(^TMP("PSX",$J,ZZZ),"^",3)
  1. K REC,COM,LBL,ACK,NAME,Y,Z1,Z
  1. NEWTAPE Q
  1. PSXAT ;CHECK FOR EOT RETURN PSXEOT=1 IF EOT FOUND
  1. U PSXT S PSXEOT=0 X ^%ZOSF("EOT") I Y D EOT S PSXEOT=1
  1. Q
  1. EOT U IO(0) W !!?5,"** End of tape detected **",!?5,"After current tape rewinds, mount next tape" U PSXT W ^%ZOSF("REW")
  1. READ U IO(0) W !?5,"Type <CR> to continue" R XX:DTIME I '$T G READ
  1. S PSXTAPE=$E(PSXTAPE,1,5)_$E(PSXTAPE,6)+1
  1. HDR U PSXT W "$$HDR|CMOP MASTER ARCHIVE^"_PSXTAPE
  1. S NEWTAPE=1
  1. Q