source: WorldVistAEHR/trunk/r/GENERIC_CODE_SHEET-GEC/GECSTRAN.m@ 1476

Last change on this file since 1476 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.4 KB
Line 
1GECSTRAN ;WISC/RFJ/KLD-transmit a batch ;01 Nov 93
2 ;;2.0;GCS;**13,15,20**;MAR 14, 1995
3 N %,%X,CODE,D,DOMAIN,DA,GECS,GECSBADA,GECSBATC,GECSCODE,GECSDICS,GECSLINE,GECSMAX,GECSMSG,GECSXMY,GECSSYDA,GECSTOTL,GECSXMZ,PRIORITY,X,Y
4 D ^GECSSITE Q:'$G(GECS("SITE"))
5 D BATNOFMS^GECSUSEL Q:'$G(GECS("BATDA"))
6 S GECS("SITECOM")=GECS("SITE")_GECS("SITE1")
7 S GECSDICS="S %=^(0) I $S($P(%,""-"",1)=GECS(""SITECOM"")&($P(^(0),U,6)=GECS(""BATDA"")):1,1:0)"
8 W ! S GECSBADA=$$BATCHSEL^GECSUSEL(GECSDICS) Q:'GECSBADA
9 S GECSBATC=$P($G(^GECS(2101.3,GECSBADA,0)),"^") I GECSBATC="" W !,"CANNOT FIND BATCH NUMBER IN FILE 2101.3." Q
10 ;
11 ; build receiving users for mail messages
12 K GECSXMY
13 S %=0 F S %=$O(^GECS(2101.1,GECS("BATDA"),2,%)) Q:'% S D=$G(^(%,0)) I $P(D,"^",3)=1 D
14 . S DOMAIN=$P($G(^DIC(4.2,+$P(D,"^",2),0)),"^") I DOMAIN'="" S DOMAIN="@"_DOMAIN
15 . S GECSXMY($P(D,"^")_DOMAIN)=""
16 I '$D(GECSXMY) W !,"RECEIVING USERS FOR THIS BATCH TYPE HAVE NOT BEEN ENTERED." Q
17 W !!,"Transmission will be to the following:"
18 S %="" F S %=$O(GECSXMY(%)) Q:%="" W !?5,%
19 ;
20 ;
21RETRY ; if locked, come here to retry transmission
22 S XP="ARE YOU READY TO TRANSMIT THE CODE SHEETS",XH="Enter YES to transmit the code sheets, NO or ^ to exit." W ! I $$YN^GECSUTIL(2)'=1 Q
23 ;
24 ; check lock and lock system
25 S GECSSYDA=$$LOCKSYS^GECSULOC(GECS("SITE")_"-"_GECS("SYSID")_"-TRANSMIT")
26 I 'GECSSYDA W !!,"ANOTHER USER IS TRANSMITTING THE CODE SHEETS, TRY AGAIN IN A MINUTE" G RETRY
27 ;
28 ; check to see if batch has been transmitted, if so quit
29 I $P($G(^GECS(2101.3,GECSBADA,0)),"^",3)'="B" D UNLOCK^GECSULOC(GECSSYDA) Q
30 ;
31 ; get maximum number of code sheets per message
32 S GECSMAX=$P($G(^GECS(2101.1,GECS("BATDA"),0)),"^",3) I 'GECSMAX S GECSMAX=999999999
33 ;
34 ; build priority list
35 K ^TMP($J,"GECSTRAN")
36 S DA=0 F S DA=$O(^GECS(2100,"AB",GECSBATC,DA)) Q:'DA I $O(^GECS(2100,DA,"CODE",0)) S D=$G(^GECS(2100,DA,"TRANS")) I D'="" D
37 . S PRIORITY=$P(D,"^",10) S:'PRIORITY PRIORITY=3
38 . S ^TMP($J,"GECSTRAN",PRIORITY,DA)=""
39 ;
40 ; build messages
41 K ^TMP($J,"GECSTRAN MM")
42 S (GECSMSG,GECSLINE)=1
43 S PRIORITY=0 F S PRIORITY=$O(^TMP($J,"GECSTRAN",PRIORITY)) Q:'PRIORITY S (DA,GECSCODE)=0 F S DA=$O(^TMP($J,"GECSTRAN",PRIORITY,DA)) Q:'DA D
44 . ;
45 . ; umark code sheet for transmission
46 . S $P(^GECS(2100,DA,"TRANS"),"^",2)="" K ^GECS(2100,"AE","Y",DA)
47 . ;
48 . S GECSCODE=GECSCODE+1
49 . I GECSCODE>GECSMAX S GECSMSG=GECSMSG+1,(GECSCODE,GECSLINE)=1
50 . ;
51 . ; special code to create calm header for fee code sheets 994.xx
52 . I $P(GECSBATC,"-",2)="FEN",GECSLINE=1 D
53 . . S %=$P(GECSBATC,"-",4)
54 . . N Y,X
55 . . S Y=DT D DD^%DT
56 . . S ^TMP($J,"GECSTRAN MM",GECSMSG,GECSLINE,0)=$E($G(^GECS(2100,DA,"CODE",1,0)),1,3)_"."_$P(GECSBATC,"-")_".999.01."_$E(DT,4,7)_$E(DT,2,3)_".06"_$E("0000",$L(%)+1,4)_%_".$",GECSLINE=GECSLINE+1
57 . S %=0 F S %=$O(^GECS(2100,DA,"CODE",%)) Q:'% S CODE=$G(^(%,0)) I CODE'="" D
58 . . S ^TMP($J,"GECSTRAN MM",GECSMSG,GECSLINE,0)=CODE,GECSLINE=GECSLINE+1
59 ;
60 S GECSTOTL=GECSMSG
61 ; transmit
62 W !
63 S GECSMSG=0 F S GECSMSG=$O(^TMP($J,"GECSTRAN MM",GECSMSG)) Q:'GECSMSG D
64 . ;create mailman message
65 . W !,"MESSAGE NUMBER: "
66 . S GECSXMZ=$$MAILMSG(GECS("BATCH"),GECSBATC,.GECSXMY,GECSMSG,GECSTOTL)
67 . W GECSXMZ
68 . I 'GECSXMZ Q
69 . ;
70 . ; set message number in batch
71 . D SETMSG(GECSBADA,GECSXMZ)
72 ;
73 ; update file 2101.3
74 D UPDATE(GECSBADA)
75 Q
76 ;
77 ;
78MAILMSG(BATCHNME,BATCHNUM,RECUSERS,MSGNUMBR,TOTALMSG) ; create mailman msg
79 ; batchnme=name of batch
80 ; batchnum=batch number
81 ; recusers()=array of receiving users (same as xmy)
82 ; msgnumbr=this message number
83 ; totalmsg=total number of messages to transmit in all
84 ; returns xmz message number
85 N %,DIC,XCNP,XMDISPI,XMDUZ,XMTEXT,XMY,XMZ
86 ;
87 ; build receiving queue and user array
88 S %="" F S %=$O(RECUSERS(%)) Q:%="" S XMY(%)=""
89 S XMY(DUZ)="",XMDUZ=DUZ
90 ;
91 S XMTEXT="^TMP($J,""GECSTRAN MM"","_MSGNUMBR_",",XMSUB="GECS "_BATCHNME_" # "_BATCHNUM_" (MSG "_MSGNUMBR_" OF "_TOTALMSG_")"
92 K XMZ D ^XMD
93 Q $G(XMZ)
94 ;
95 ;
96UPDATE(DA) ; update file 2101.3 batch as being transmitted
97 N %DT,D,D0,DI,DIC,DIE,DQ,DR,X,Y
98 S (DIC,DIE)="^GECS(2101.3,",DR=".5///T;4///T;5////"_DUZ D ^DIE
99 Q
100 ;
101 ;
102SETMSG(DA,XMZ) ; set message number in batch
103 N %,D0,DD,DIC,DLAYGO,X,Y
104 I '$D(^GECS(2101.3,DA,0)) Q
105 S:'$D(^GECS(2101.3,DA,2,0)) ^(0)="^2101.32^^"
106 S DIC="^GECS(2101.3,"_DA_",2,",DIC(0)="L",DLAYGO=2101.3,X=XMZ D FILE^DICN
107 Q
Note: See TracBrowser for help on using the repository browser.