Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HLOPBLD1

HLOPBLD1.m

Go to the documentation of this file.
HLOPBLD1 ;ALB/CJM-HL7 - Building segments (CONTINUED) ;02/04/2004
 ;;1.6;HEALTH LEVEL SEVEN;**126**;Oct 13, 1995
 ;
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_$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,@HDR@("RECEIVING APPLICATION"))_FS_$G(@HDR@("RECEIVING FACILITY",1))_CS_$$ESCAPE^HLOPBLD(.HLMSTATE,@HDR@("RECEIVING FACILITY",2))_CS_@HDR@("RECEIVING FACILITY",3)
 S HDR(2)=FS_@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_$G(@HDR@("MESSAGE STRUCTURE"))
 .S:BATCH ID=@HDR@("BATCH CONTROL ID")_$$ESCAPE^HLOPBLD(.HLMSTATE,"-")_$G(HLMSTATE("BATCH","CURRENT MESSAGE"))
 .S:'BATCH ID=@HDR@("MESSAGE CONTROL ID")
 .S HDR(2)=HDR(2)_FS_ID_FS_@HDR@("PROCESSING ID")_CS_$G(@HDR@("PROCESSING MODE"))_FS_$$ESCAPE^HLOPBLD(.HLMSTATE,@HDR@("VERSION"))
 .S HDR(2)=HDR(2)_FS_FS_$G(@HDR@("CONTINUATION POINTER"))_FS_@HDR@("ACCEPT ACK TYPE")_FS_@HDR@("APP ACK TYPE")_FS_$G(@HDR@("COUNTRY"))
 ;
 I TYPE="BHS" D
 .N TEXT
 .S TEXT="PROCESSING ID"_$$ESCAPE^HLOPBLD(.HLMSTATE,"=")_@HDR@("PROCESSING ID")_" "
 .I $L($G(@HDR@("ACCEPT ACK TYPE"))) S TEXT=TEXT_"ACCEPT ACK TYPE"_$$ESCAPE^HLOPBLD(.HLMSTATE,"=")_@HDR@("ACCEPT ACK TYPE")_" "
 .I $L($G(@HDR@("APP ACK TYPE"))) S TEXT=TEXT_"APP ACK TYPE"_$$ESCAPE^HLOPBLD(.HLMSTATE,"=")_@HDR@("APP ACK TYPE")_" "
 .S HDR(2)=HDR(2)_FS_TEXT_FS_FS_@HDR@("BATCH CONTROL ID")_FS_$G(@HDR@("REFERENCE BATCH CONTROL ID"))
 Q