source: FOIAVistA/trunk/r/MEDICINE-MC/MCARAM.m@ 1582

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

initial load of FOIAVistA 6/30/08 version

File size: 4.6 KB
Line 
1MCARAM ;WASH ISC/JKL-MUSE AUTO INSTRUMENT DATA LOAD INTO DHCP ;5/28/96 14:53
2 ;;2.3;Medicine;;09/13/1996
3 ;
4 ;
5START ; Driver for MUSE-run by task manager
6 ; WHERE: LANM,TSK,MCINST,T are required for MCARASE
7 ; LANM = routine name, T and TSK = auto instrument IEN,
8 ; MCINST = auto instrument name
9 ; MCL = data type line number, MCLT = data transmission line number
10 ; MCD = one line of lab data, MCA = array of local data,
11 ; MCE = internal record number of EKG file where data is stored
12 ; MCRD = attempts to read lab data
13 ; MCCD= current data transmission number
14 ; MCPRO= EKG procedure number from Procedure/Subspecialty file
15 N LANM,TSK,MCINST,T,MCL,MCLT,MCA,MCCD,MCCNT,MCE,MCERR,MCRD,MCPRO,MCPRNM
16 N MCS,MCTOT,MCTYPE,MCZ,MCREC
17 S LANM=$T(+0),TSK=$O(^LAB(62.4,"C",LANM,0)),U="^" I TSK="" Q
18 ; Quit if no MUSE data
19 I '$D(^LA(TSK,"I",0)) Q
20 S MCINST=$P(^LAB(62.4,TSK,0),U) D ^MCARASE I 'TSK Q
21 S @TRAP
22 ;initial error condition
23 S MCA("ERR")=0
24 ;get EKG procedure number from Procedure/Subspecialty file
25 S MCPRO=$O(^MCAR(697.2,"C","MCAR(691.5",0))
26 ;print name for ECG procedure, type of transmission
27 S MCPRNM=$$ORPRM(MCPRO),MCTYPE="M"
28 ;delay process until record data is complete
29 D DELPRO
30 ;
31READ S MCRD=0,MCL=0,MCCD=-1,MCA("CONT")="@"
32 I ^LA(TSK,"I",0)'=0 S MCLT=^LA(TSK,"I",0)+1,MCCD=MCLT-1
33 D IN G QUIT
34IN S MCLT=^LA(TSK,"I",0)+1 I '$D(^(MCLT)) S MCRD=MCRD+1 Q:MCRD>6 H 8 G IN
35 S ^LA(TSK,"I",0)=MCLT,MCRD=0,MCERR=0
36 I '$D(MCREC) F MCZ=1:1 D:'$D(^LA(TSK,"I",MCLT+MCZ)) DELPRO I ($D(^LA(TSK,"I",MCLT+MCZ))#2),((^LA(TSK,"I",MCLT+MCZ)["EOR")!(^LA(TSK,"I",MCLT+MCZ)["ERR")!(^LA(TSK,"I",MCLT+MCZ)["BYE")) S MCREC="" Q
37 I '$D(MCA("ERR")) S MCA("ERR")=0
38 ;ignore set if retransmit set of data lines
39 I $D(^LA(TSK,"I",MCLT+3)),^LA(TSK,"I",MCLT+3)=^LA(TSK,"I",MCLT),^LA(TSK,"I",MCLT)?.E1.A.E S MCCD=MCCD+3,^LA(TSK,"I",0)=MCLT+2 G IN
40 ;check for start of transmission-suppressed H
41 I $E(^LA(TSK,"I",MCLT),1,5)="HELLO" S MCCD=MCLT-3
42 ;check for start of transmission-IRM
43 I $E(^LA(TSK,"I",MCLT),1,3)="IRM" S MCCD=MCLT-3
44 ;transfer one line of lab data to local array
45 I MCCD+3=MCLT S MCERR=$$RLAB^MCARAM(.MCA,.MCL,MCLT)
46 ;transmission error
47 I +MCERR=5 K MCA,MCERR,MCREC N MCA,MCERR G IN
48 ;transfer local array data into DHCP
49 ;record successful or unsuccessful data transfer attempt
50 I +MCERR=10 S:$$GRERR^MCARAM7(.MCA)=0 MCERR=$$LDHCP^MCARAM3(.MCA,.MCE) S MCERR=$$KPERR^MCARAM7(.MCA,.MCS) K MCA,MCERR,MCE,MCS,MCREC N MCA,MCERR,MCE,MCS
51 G IN
52 ;
53DELPRO ;delay process until record data is complete
54 S MCCNT=0
55DELP I $D(^LA(TSK,"I")) S MCTOT=^LA(TSK,"I"),MCCNT=MCCNT+1 H 15 I MCTOT=^LA(TSK,"I"),MCCNT<7 G DELP
56 K MCTOT,MCCNT
57 Q
58 ;
59 ;
60OUT S MCLT=^LA(TSK,"O")+1,^("O")=MCLT,^("O",MCLT)=OUT
61 L +^LA("Q") S Q=^LA("Q")+1,^("Q")=Q,^("Q",Q)=TSK L -^LA("Q") Q
62 Q
63 ;
64 ;
65RLAB(MCA,MCL,MCLT) ; Read Lab data and place in local array
66 ; USAGE: S X=$$RLAB^MCARAM(.A,.B,C)
67 ; WHERE: .A=Array into which data is placed
68 ; .B=Data type line number
69 ; C=Data transmission line number
70 ;
71 ;lab data
72 S MCD=^LA(TSK,"I",MCLT)
73 I ($E(MCD,1,5)="HELLO")!($E(MCD,1,3)="EOT") S MCL=0,MCA("CONT")="@",MCCD=MCLT-1 Q 0
74 I $E(MCD,1,3)="BYE" S MCL=0,MCA("CONT")="@",MCCD=MCLT-2 Q 0
75 I $E(MCD,1,3)="IRM" S MCL=0,MCA("CONT")="@",MCCD=MCLT Q 0
76 I $E(MCD,1,3)="EOR" S MCERR="10-End of record" S MCCD=MCLT Q MCERR
77 I $E(MCD,1,3)="ERR" S MCERR="5-Transmission error-expect retry of record" S MCL=0,MCA("CONT")="@",MCCD=MCLT-1 Q MCERR
78 S MCL=MCL+1,MCA("CONT")=$C($A(MCA("CONT"))+1)
79 ;transfer lab data to local
80 I MCL<13 S MCTR=$S(MCL<7:"S MCERR=$$L"_MCL_"^MCARAM1(.MCA,MCD)",MCL=12:"S MCERR=$$L"_MCL_"^MCARAM3(.MCA,MCD)",MCL>6:"S MCERR=$$L"_MCL_"^MCARAM2(.MCA,MCD)") X MCTR S MCCD=MCLT Q:+MCERR>0 MCERR Q 0
81 ;fill diagnosis array
82 I MCL>12 S MCERR=$$DGCT^MCARAM4(.MCA,MCD,MCL),MCCD=MCLT I +MCERR>0 Q MCERR
83 Q 0
84 ;
85TRAP ;entry from MCARASE
86 K ^LA("LOCK",TSK) S T=TSK D SET^MCARASE
87 S ^LA(TSK,"Q")=0 D ERROR^MCARASE
88 G @(U_LANM)
89 ;
90ORPRM(MCPRO) ;Get print name for ECG procedure
91 ;USAGE: S X=$$ORPRM(MCPRO)
92 ;WHERE: X = print name for ECG procedure/subspecialty
93 ; MCPRO = EKG procedure number from Procedure/Subspecialty file
94 I '$D(MCOEON) D ORDER^MCPARAM I '$D(MCOEON) Q ""
95 Q $P(^MCAR(697.2,MCPRO,0),U,8)
96 ;
97HSHAKE ; MUSE dialog, called by LAB which executes HANDSHAKE fld of AI file
98 ; Does checksum on MUSE input, sets OUT to ACK or NAK
99 I IN="BYE" S OUT="" K MCSM Q
100 I IN="HELLO" S T=T-BASE,OUT="ACK" K MCSM
101 I IN?.E1.A.E N MCI S MCSM=0 F MCI=1:1:$L(IN) S MCSM=MCSM+$A(IN,MCI)
102 I IN?1.5N,$D(MCSM) S T=T-BASE S:MCSM'=IN OUT="NAK" S:MCSM=IN OUT="ACK" K MCSM
103 K MCI Q
104QUIT L +^LA(TSK) H 1
105 K ^LA(TSK)
106 L -^LA(TSK)
107 K ^LA("LOCK",TSK)
108 D DQ^%ZTLOAD
109 S:$D(ZTQUEUED) ZTREQ="@" K ZTSK
110 Q
Note: See TracBrowser for help on using the repository browser.