source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLCSDR1.m@ 1614

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

initial load of FOIAVistA 6/30/08 version

File size: 4.5 KB
Line 
1HLCSDR1 ;ALB/RJS - HYBRID LOWER LAYER PROTOCOL 2.2 - 9/13/94 ;08/22/2001 10:16
2 ;;1.6;HEALTH LEVEL SEVEN;**2,22,27,30,34,62**;Oct 13, 1995
3 ;
4 ;This is an implemetation of the HL7 Hybrid Low Layer Protocol
5 ;
6START(HLDP,HLRETPRM,HLDREAD,HLDWRITE,HLDSTRT,HLDEND,HLDVER,HLDBSIZE) ;
7 N HLIND0,HLIND1,HLTRANS,HLCHK,HLACKBLK,HLDOUT0,HLDOUT1,X,HLRETRY
8 N HLNXST,HLLINE,HLNAK,HLTVV,HLWFLG,HLC1,HLC2
9 ;S X=10 X ^%ZOSF("PRIORITY")
10 ; above line commented-out patch 27, sys mgr will set as needed
11 S HLWFLG=1
12 ;
131 ; Look to see if there is anything to read in
14 I $D(HLTRACE) S HLNXST=1 D TRACE^HLCSDR2
15 D:$P(^HLCS(870,HLDP,0),U,5)'="IDLE" MONITOR^HLCSDR2("IDLE",5,HLDP)
16 S X=$$READ^HLCSUTL(HLDREAD,HLDBSIZE,.HLTRANS) D TRANS^HLCSDR2(X,.HLTRANS),INITIZE^HLCSDR2
17 I HLTRANS="VT" G TVV
18 I HLTRANS'="TIMEOUT" G 1
19 I 'HLWFLG D PUSH^HLCSQUE(HLDOUT0,HLDOUT1),MONITOR^HLCSDR2("P",2,HLDOUT0,HLDOUT1,"OUT"),MONITOR^HLCSDR2("TIMEOUT",5,HLDP)
20 G 14
21 ;
22TVV ;Read in tvv
23 I $D(HLTRACE) S HLNXST="TVV" D TRACE^HLCSDR2
24 D MONITOR^HLCSDR2("READING",5,HLDP)
25 S X=$$READ^HLCSUTL(HLDREAD,HLDBSIZE,.HLTRANS) D TRANS^HLCSDR2(X,.HLTRANS)
26 I $L(X)'=3!(HLTRANS'="CR") G 1
27 S HLNAK=$E(X),HLTVV=X,X=$C(HLDSTRT)_X_$C(13) D CHKSUM^HLCSDR2
28 I HLNAK="D" D G:HLIND0'<0 2 D MONITOR^HLCSDR2(100,19,HLDP) G EXIT
29 . S HLIND0=$$ENQUEUE^HLCSQUE(HLDP,"IN"),HLIND1=$P(HLIND0,U,2),HLIND0=+HLIND0
30 . D MONITOR^HLCSDR2(HLTVV,4,HLDP,HLIND1,"IN")
31 I HLNAK="N" S X=HLTVV K ^TMP("HLCSDR1",$J,HLDP) D SETNODE2^HLCSDR2 G 9
32 S HLTRANS="G" D MONITOR^HLCSDR2(105,19,HLDP) G 5
33 ;
342 ; Read in message
35 I $D(HLTRACE) S HLNXST=2 D TRACE^HLCSDR2
36 D MONITOR^HLCSDR2("READING",5,HLDP)
37 S X=$$READ^HLCSUTL(HLDREAD,HLDBSIZE,.HLTRANS) D TRANS^HLCSDR2(X,.HLTRANS)
38 I HLTRANS="CR" D SETNODE^HLCSDR2(HLIND0,HLIND1,HLTRANS) S X=X_$C(13) D CHKSUM^HLCSDR2 G 2
39 I HLTRANS="LONGLINE" D SETNODE^HLCSDR2(HLIND0,HLIND1,HLTRANS),CHKSUM^HLCSDR2 G 2
40 I HLTRANS="TIMEOUT" S HLTRANS="G" D MONITOR^HLCSDR2(106,19,HLDP) G 5
41 I HLTRANS="FS" G 3
42 G 2
43 ;
443 ; Check for Validity of data
45 I $D(HLTRACE) S HLNXST=3 D TRACE^HLCSDR2
46 D MONITOR^HLCSDR2("VALIDATE",5,HLDP)
47 S HLCHK=$E(X,$L(X)-7,$L(X)),X=$E(X,1,$L(X)-8)
48 S HLTRANS=$$VALID1^HLCSDR2("INCOMING MESSAGE",HLCHK,HLIND0,HLIND1)
49 I HLTRANS="VALID" G 4
50 D MONITOR^HLCSDR2(107,19,HLDP) G 5
51 ;
524 ; Valid message.
53 I $D(HLTRACE) S HLNXST=4 D TRACE^HLCSDR2
54 D MONITOR^HLCSDR2("DONE",5,HLDP),MONITOR^HLCSDR2("A",3,HLDP,HLIND1,"IN"),MONITOR^HLCSDR2("P",2,HLDP,HLIND1,"IN")
55 D INITIZE^HLCSDR2 G 6
56 ;
575 ; Send NAK When This State is Reached
58 I $D(HLTRACE) S HLNXST=5 D TRACE^HLCSDR2
59 D MONITOR^HLCSDR2("NAK",5,HLDP),MONITOR^HLCSDR2(HLTRANS,3,HLDP,HLIND1,"IN"),MONITOR^HLCSDR2("P",2,HLDP,HLIND1,"IN")
60 D NAK^HLCSDR2(HLTRANS)
61 D INITIZE^HLCSDR2 G 1
62 ;
636 ;Check "OUT" queue
64 I $D(HLTRACE) S HLNXST=6 D TRACE^HLCSDR2
65 S HLDOUT0=$$DEQUEUE^HLCSQUE(HLDP,"OUT")
66 I +HLDOUT0<0 G 1
67 S HLDOUT1=$P(HLDOUT0,U,2),HLDOUT0=+HLDOUT0,HLRETRY=-1 G 7
68 ;
697 ; Send Data to other Application
70 I HLRETRY=HLRETPRM D MONITOR^HLCSDR2(103,19,HLDP),MONITOR^HLCSDR2("G",3,HLDP,HLDOUT1,"OUT"),MONITOR^HLCSDR2("D",2,HLDP,HLDOUT1,"OUT") G 14
71 I $D(HLTRACE) S HLNXST=7 D TRACE^HLCSDR2
72 D MONITOR^HLCSDR2("WRITING",5,HLDP)
73 D WRITE^HLCSDR2(HLDOUT0,HLDOUT1)
74 ; set message status to 'done'
75 D MONITOR^HLCSDR2("D",2,HLDP,HLDOUT1,"OUT") G 1
76 ;
779 ; Read in Neg Acknowledgement message
78 I $D(HLTRACE) S HLNXST=9 D TRACE^HLCSDR2
79 S X=$$READ^HLCSUTL(HLDWRITE,HLDBSIZE,.HLTRANS) D TRANS^HLCSDR2(X,.HLTRANS),MONITOR^HLCSDR2("READ ACK",5,HLDP)
80 I HLTRANS="CR" D SETNODE2^HLCSDR2 S X=X_$C(13) D CHKSUM^HLCSDR2 G 9
81 I HLTRANS="FS" G 10
82 I HLTRANS="LONGLINE" D SETNODE2^HLCSDR2,CHKSUM^HLCSDR2
83 S HLRETRY=HLRETRY+1 D MONITOR^HLCSDR2("P",2,HLDP,HLDOUT1,"OUT") G 7
84 ;
8510 ; Check Validity of Neg Acknowledgement
86 I $D(HLTRACE) S HLNXST=10 D TRACE^HLCSDR2
87 D MONITOR^HLCSDR2("VALIDATE NACK",5,HLDP)
88 S HLCHK=$E(X,$L(X)-7,$L(X)),X=$E(X,1,$L(X)-8)
89 S HLTRANS=$$VALID1^HLCSDR2("LLP-NACK",HLCHK)
90 I HLTRANS="VALID" G 12
91 S HLRETRY=HLRETRY+1 D MONITOR^HLCSDR2("P",2,HLDP,HLDOUT1,"OUT") G 7
92 ;
9312 ; Process Negative Acknowlegement
94 I $D(HLTRACE) S HLNXST=12 D TRACE^HLCSDR2
95 S HLACKBLK=$E(^TMP("HLCSDR1",$J,HLDP,2))
96 D MONITOR^HLCSDR2($S("^B^C^X^"[(U_HLACKBLK_U):HLACKBLK,1:"G"),3,HLDP,HLDOUT1,"OUT")
97 S HLRETRY=HLRETRY+1 D MONITOR^HLCSDR2("P",2,HLDP,HLDOUT1,"OUT") G 7
98 ;
9914 ; Make sure we should still be running
100 I $D(HLTRACE) S HLNXST=14 D TRACE^HLCSDR2
101 I $P($G(^HLCS(870,HLDP,0)),U,15)=1 G EXIT ; Shutdown receiver
102 I $D(HLTRACE) U IO(0) W !,"Type Q to Quit: " R X:1 I "^Q^q^"[(U_X_U) S $P(^HLCS(870,HLDP,0),U,15)=1 G EXIT ; Shutdown receiver
103 G 6
104 ;
105EXIT ;
106 D MONITOR^HLCSDR2("SHUTDOWN",5,HLDP)
107 Q
Note: See TracBrowser for help on using the repository browser.