source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLOPBLD1.m@ 1683

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

initial load of FOIAVistA 6/30/08 version

File size: 4.1 KB
Line 
1HLOPBLD1 ;ALB/CJM-HL7 - Building segments (CONTINUED) ;10/24/2006
2 ;;1.6;HEALTH LEVEL SEVEN;**126,132**;Oct 13, 1995;Build 6
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5BUILDHDR(HLMSTATE,TYPE,HDR) ;Builds the header segment in 2 lines, line 1 is components 1-6
6 ;Input:
7 ; HLMSTATE("HDR") - (pass by reference, required) These subscripts are used:
8 ; "FIELD SEPARATOR"
9 ; "ENCODING CHARACTERS"
10 ; "SENDING APPLICATION"
11 ; "RECEIVING APPLICATION"
12 ; "RECEIVING FACILITY",1 and ,2 and ,3
13 ; "DT/TM OF MESSAGE"
14 ; "SECURITY"
15 ; "ACCEPT ACK TYPE"
16 ; "APP ACK TYPE"
17 ; "PROCESSING ID"
18 ;
19 ; *MSH ONLY*
20 ; "CONTINUATION POINTER"
21 ; "COUNTRY"
22 ; "EVENT"
23 ; "MESSAGE STRUCTURE"
24 ; "MESSAGE TYPE"
25 ; "PROCESSING MODE"
26 ; "VERSION"
27 ;
28 ; *BHS ONLY*
29 ; "REFERENCE BATCH CONTROL ID"
30 ;
31 ; HLMSTATE("BATCH")
32 ; HLMSTATE("BATCH","CURRENT MESSAGE") - batch messages only
33 ; HLMSTATE("IEN") - ien, file 778
34 ;
35 ; TYPE - must be either "MSH" or "BHS"
36 ;
37 ;Output:
38 ; HLMSTATE("HDR") - these subscripts will be added, unless building an MSH within a batch:
39 ; "SENDING FACILITY",1 and ,2 and ,3
40 ; "PROCESSING ID"
41 ; "MESSAGE CONTROL ID" (MSH ONLY)
42 ; "BATCH CONTROL ID" (BHS ONLY)
43 ; "DT/TM OF MESSAGE"
44 ; HDR (pass by reference) This will return the segment in an array form at HDR(1),HDR(2) (two lines).
45 ;
46 K HDR
47 N SEG,BATCH,LEN,FS,CS
48 ;
49 ;shortcuts
50 S HDR="HLMSTATE(""HDR"")"
51 S BATCH=HLMSTATE("BATCH")
52 S FS=@HDR@("FIELD SEPARATOR")
53 S CS=$E(@HDR@("ENCODING CHARACTERS"),1)
54 ;
55 S HDR(1)=TYPE_FS_@HDR@("ENCODING CHARACTERS")_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("SENDING APPLICATION")))
56 ;
57 ;If building an MSH segment for a batch message, these parameters should already be determined
58 D:(('HLMSTATE("BATCH"))!(TYPE="BHS"))
59 .N PORT
60 .S PORT=$$RTRNPORT^HLOAPP($G(@HDR@("SENDING APPLICATION")))
61 .S:'PORT PORT=HLMSTATE("SYSTEM","PORT")
62 .S @HDR@("SENDING FACILITY",1)=HLMSTATE("SYSTEM","STATION")
63 .S @HDR@("SENDING FACILITY",2)=HLMSTATE("SYSTEM","DOMAIN")_":"_PORT
64 .S @HDR@("SENDING FACILITY",3)="DNS"
65 .;
66 .;create the unique message ids, using the ien from file 778
67 .S:TYPE="BHS" @HDR@("BATCH CONTROL ID")=HLMSTATE("SYSTEM","STATION")_" "_HLMSTATE("IEN")
68 .S:TYPE="MSH" @HDR@("MESSAGE CONTROL ID")=HLMSTATE("SYSTEM","STATION")_" "_HLMSTATE("IEN")
69 .;
70 .S @HDR@("PROCESSING ID")=HLMSTATE("SYSTEM","PROCESSING ID")
71 .S @HDR@("DT/TM OF MESSAGE")=$$HLDATE^HLFNC($$NOW^XLFDT,"TS")
72 ;
73 S HDR(1)=HDR(1)_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("SENDING FACILITY",1)))_CS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("SENDING FACILITY",2)))_CS_"DNS"
74 S HDR(1)=HDR(1)_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("RECEIVING APPLICATION")))
75 S HDR(1)=HDR(1)_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("RECEIVING FACILITY",1)))_CS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("RECEIVING FACILITY",2)))
76 S HDR(1)=HDR(1)_CS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("RECEIVING FACILITY",3)))
77 S HDR(2)=FS_$$ESCAPE^HLOPBLD(.HLMSTATE,@HDR@("DT/TM OF MESSAGE"))_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("SECURITY")))
78 ;
79 I TYPE="MSH" D
80 .N ID
81 .S HDR(2)=HDR(2)_FS_@HDR@("MESSAGE TYPE")_CS_@HDR@("EVENT")_CS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("MESSAGE STRUCTURE")))
82 .S:BATCH ID=@HDR@("BATCH CONTROL ID")_"-"_$G(HLMSTATE("BATCH","CURRENT MESSAGE"))
83 .S:'BATCH ID=@HDR@("MESSAGE CONTROL ID")
84 .S HDR(2)=HDR(2)_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,ID)_FS_@HDR@("PROCESSING ID")_CS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("PROCESSING MODE")))_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,@HDR@("VERSION"))
85 .S HDR(2)=HDR(2)_FS_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("CONTINUATION POINTER")))_FS_@HDR@("ACCEPT ACK TYPE")_FS_@HDR@("APP ACK TYPE")_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("COUNTRY")))
86 ;
87 I TYPE="BHS" D
88 .N TEXT
89 .S TEXT="PROCESSING ID"_"="_@HDR@("PROCESSING ID")_" "
90 .I $L($G(@HDR@("ACCEPT ACK TYPE"))) S TEXT=TEXT_"ACCEPT ACK TYPE"_"="_@HDR@("ACCEPT ACK TYPE")_" "
91 .I $L($G(@HDR@("APP ACK TYPE"))) S TEXT=TEXT_"APP ACK TYPE"_"="_@HDR@("APP ACK TYPE")_" "
92 .S HDR(2)=HDR(2)_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,TEXT)_FS_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,@HDR@("BATCH CONTROL ID"))_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,$G(@HDR@("REFERENCE BATCH CONTROL ID")))
93 Q
Note: See TracBrowser for help on using the repository browser.