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