source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLFNC3.m@ 1742

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

initial load of FOIAVistA 6/30/08 version

File size: 2.3 KB
Line 
1HLFNC3 ;AISC/SAW-Continuation of HLFNC, Additional Functions/Calls Used for HL7 Messages ;1/17/95 11:16
2 ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
3BHS(HL,BID,RESULT,SECURITY,MSA) ;Create a BHS Segment for an Outgoing HL7
4 ;Batch Message
5 ;
6 ;This is a subroutine call with parameter passing that returns an HL7
7 ;Batch Header (BHS) segment in the variable RESULT (and possibly
8 ;RESULT(1) if the BHS segment is longer than 245 characters). If the
9 ;required input parameters HL or BID are missing, RESULT is returned
10 ;equal to null
11 ;
12 ;Required Input Parameters
13 ; HL = The array of values returned by the call to INIT^HLFNC2
14 ; BID = The Batch Control ID to be included in the BHS segment.
15 ; The Batch Control ID for the batch is returned by the
16 ; call to CREATE^HLTF.
17 ; RESULT = The variable that will be returned to the calling
18 ; application as described above
19 ;Optional Input Parameters
20 ;SECURITY = Security to be included in field #8 of the BHS segment
21 ; MSA = Three components (separated by the HL7 component separator
22 ; character) consisting of the first three fields in the
23 ; MSA segment. This variable is required if the message
24 ; you are building is a batch acknowledgment
25 ;
26 ;Check for required parameters
27 I '$D(HL)#2!('$D(BID)) Q ""
28 N X,X1,X2
29 ;Build BHS segment from HL array variables and other input parameters
30 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")
31 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
32 ;If the MSA parameter exists, insert it in pieces 11 and 12 and
33 ;create new variable X1 if length of X will be greater than 245
34 I $D(MSA) D
35 .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)
36 .I $L(X)+$L(MSA)'>245 S $P(X,HL("FS"),10)=MSA Q
37 .S X1=HL("FS")_$P(X,HL("FS"),11,12),X=$P(X,HL("FS"),1,10)
38 .S X2=$L(X),X=X_$E(MSA,1,(245-X2)),X1=$E(MSA,(246-X2),245)_X1
39 .S X2=$L(X) I $L(X2)<245 S X=X_$E(X1,1,(245-X2)),X1=$E(X1,(246-X2),245)
40 S RESULT=X S:$L($G(X1)) RESULT(1)=X1
41 Q
Note: See TracBrowser for help on using the repository browser.