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

HLFNC3.m

Go to the documentation of this file.
  1. HLFNC3 ;AISC/SAW-Continuation of HLFNC, Additional Functions/Calls Used for HL7 Messages ;1/17/95 11:16
  1. ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
  1. BHS(HL,BID,RESULT,SECURITY,MSA) ;Create a BHS Segment for an Outgoing HL7
  1. ;Batch Message
  1. ;
  1. ;This is a subroutine call with parameter passing that returns an HL7
  1. ;Batch Header (BHS) segment in the variable RESULT (and possibly
  1. ;RESULT(1) if the BHS segment is longer than 245 characters). If the
  1. ;required input parameters HL or BID are missing, RESULT is returned
  1. ;equal to null
  1. ;
  1. ;Required Input Parameters
  1. ; HL = The array of values returned by the call to INIT^HLFNC2
  1. ; BID = The Batch Control ID to be included in the BHS segment.
  1. ; The Batch Control ID for the batch is returned by the
  1. ; call to CREATE^HLTF.
  1. ; RESULT = The variable that will be returned to the calling
  1. ; application as described above
  1. ;Optional Input Parameters
  1. ;SECURITY = Security to be included in field #8 of the BHS segment
  1. ; MSA = Three components (separated by the HL7 component separator
  1. ; character) consisting of the first three fields in the
  1. ; MSA segment. This variable is required if the message
  1. ; you are building is a batch acknowledgment
  1. ;
  1. ;Check for required parameters
  1. I '$D(HL)#2!('$D(BID)) Q ""
  1. N X,X1,X2
  1. ;Build BHS segment from HL array variables and other input parameters
  1. S X="BHS"_HL("FS")_HL("ECH")_HL("FS")_HL("SAN")_HL("FS")_HL("SAF")_HL("FS")_$S($D(HL("RAN")):HL("RAN"),1:"")_HL("FS")_$S($D(HL("RAF")):HL("RAF"),1:"")_HL("FS")_$S($D(HL("DTM")):HL("DTM"),1:"")_HL("FS")
  1. S X=X_$S($G(SECURITY)]"":SECURITY,1:"")_HL("FS")_$E(HL("ECH"))_HL("PID")_$E(HL("ECH"))_HL("MTN")_$E(HL("ECH"))_HL("VER")_HL("FS")_HL("FS")_BID
  1. ;If the MSA parameter exists, insert it in pieces 11 and 12 and
  1. ;create new variable X1 if length of X will be greater than 245
  1. I $D(MSA) D
  1. .S $P(X,HL("FS"),12)=$P(MSA,$E(HL("ECH")),2),MSA=$P(MSA,$E(HL("ECH")))_$E(HL("ECH"))_$P(MSA,$E(HL("ECH")),3)
  1. .I $L(X)+$L(MSA)'>245 S $P(X,HL("FS"),10)=MSA Q
  1. .S X1=HL("FS")_$P(X,HL("FS"),11,12),X=$P(X,HL("FS"),1,10)
  1. .S X2=$L(X),X=X_$E(MSA,1,(245-X2)),X1=$E(MSA,(246-X2),245)_X1
  1. .S X2=$L(X) I $L(X2)<245 S X=X_$E(X1,1,(245-X2)),X1=$E(X1,(246-X2),245)
  1. S RESULT=X S:$L($G(X1)) RESULT(1)=X1
  1. Q