- HLFNC1 ;AISC/SAW,JRP-Continuation of HLFNC, Additional Functions/Calls Used for HL7 Messages ;11/30/94 15:01
- ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
- ;This routine is used for the Version 1.5 Interface Only
- HLFLDS(APP,SEG) ;Returns HL7 fields used by a DHCP application for a
- ;specified segment
- ;
- ;This is an extrinsic function call that returns a string containing
- ;a list of HL7 fields separated by uparrows (e.g., 1^2^3)
- ;
- ;Required variables:
- ;APP - the internal entry number of the DHCP application
- ; from file 771
- ;SEG - the name of the HL7 segment for which fields are
- ; to be returned
- ;
- ;Check for required input parameters
- I 'APP!(SEG']"") Q ""
- I '$D(^HL(771,APP,0)) Q ""
- N X S X=$O(^HL(771.3,"B",SEG,0)) I 'X Q ""
- S X=$O(^HL(771,APP,"SEG","B",X,0)) I 'X Q ""
- ;Return string
- Q $TR($G(^HL(771,APP,"SEG",X,"F")),",","^")
- MSH(HLMTN,HLSEC) ;Create an MSH Segment for an Outgoing HL7 Message
- ;
- ;Input : HLMTN - Three to seven character HL7 message type name
- ; HLSEC - Security to be included in field #8 of the segment
- ; (optional - field left blank when not passed)
- ; All variables created by a call to INIT^HLTRANS
- ;
- ;Output : An HL7 MSH segment
- ;
- ;Note : NULL is returned on error/bad input
- ; : Existance of variables from INIT^HLTRANS is assumed
- ;
- ;Check for required parameters
- Q:($G(HLMTN)="") ""
- Q:('$D(HLNDAP0)) ""
- S HLSEC=$G(HLSEC)
- ;Make sure pointer to Message Text file is valid
- Q:('$D(HLDA)) ""
- Q:('$D(^HL(772,HLDA,0))) ""
- ;Declare variables
- N MID,NODE,MSH
- ;Get message ID
- S NODE=$G(^HL(772,HLDA,0))
- S MID=$P(NODE,"^",6)
- Q:(MID="") ""
- ;Build MSH segment
- S MSH="MSH"_HLFS_HLECH_HLFS_HLDAN_HLFS_$P(HLNDAP0,"^",2)
- S MSH=MSH_HLFS_$P(HLNDAP0,"^",1)_HLFS_$P(HLNDAP0,"^",3)_HLFS_HLDT1
- S MSH=MSH_HLFS_HLSEC_HLFS_HLMTN_HLFS_MID_HLFS_HLPID_HLFS_HLVER
- ;Return MSH segment
- Q MSH
- BHS(HLMTN,HLSEC,HLMSA) ;Create a BHS Segment for an Outgoing HL7 Batch Message
- ;
- ;This is an extrinsic function call that returns an HL7 BHS segment
- ;
- ;Input : HLMTN - The three to seven character HL7 message type name
- ; HLSEC - Security to be included in field #8 of the segment
- ; (optional - field left blank when not passed)
- ; HLMSA - Three components (separated by the HL7 component
- ; separator character) consisting of the first
- ; three fields in the MSA segment. This variable is
- ; required if the message you are building is a
- ; batch response.
- ; All variables created by a call to INIT^HLTRANS
- ;
- ;Output : An HL7 BHS segment
- ;
- ;Note : NULL is returned on error/bad input
- ; : Existance of variables from INIT^HLTRANS is assumed
- ;
- ;Check for required parameters
- Q:($G(HLMTN)="") ""
- S HLSEC=$G(HLSEC)
- S HLMSA=$G(HLMSA)
- Q:('$D(HLNDAP0)) ""
- ;Declare variables
- N BHS,FIELD9,FIELD10,TMP,BID,BRID
- ;Get batch ID
- S TMP=$G(^HL(772,HLDA,0))
- S BID=$P(TMP,"^",6)
- Q:(BID="") ""
- ;Build field # 9 (batch name/processing ID/type/version)
- S FIELD9=$E(HLECH)_HLPID_$E(HLECH)_$E(HLMTN,1,3)_$E(HLECH)_HLVER
- ;Build field # 10 (batch comment)
- S FIELD10=""
- I (HLMSA'="") D
- .S FIELD10=$P(HLMSA,$E(HLECH))
- .S TMP=$P(HLMSA,$E(HLECH),3)
- .S:(TMP'="") FIELD10=FIELD10_$E(HLECH)_TMP
- ;Get batch reference ID
- S BRID=""
- S TMP=$P(HLMSA,$E(HLECH),2)
- S:(TMP'="") BRID=TMP
- ;Build BHS segment
- S BHS="BHS"_HLFS_HLECH_HLFS_HLDAN_HLFS_$P(HLNDAP0,"^",2)
- S BHS=BHS_HLFS_$P(HLNDAP0,"^")_HLFS_$P(HLNDAP0,"^",3)_HLFS_HLDT1
- S BHS=BHS_HLFS_HLSEC_HLFS_FIELD9_HLFS_FIELD10_HLFS_BID_HLFS_BRID
- ;Return BHS segment
- Q BHS
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHLFNC1 3719 printed Jan 18, 2025@02:59:25 Page 2
- HLFNC1 ;AISC/SAW,JRP-Continuation of HLFNC, Additional Functions/Calls Used for HL7 Messages ;11/30/94 15:01
- +1 ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
- +2 ;This routine is used for the Version 1.5 Interface Only
- HLFLDS(APP,SEG) ;Returns HL7 fields used by a DHCP application for a
- +1 ;specified segment
- +2 ;
- +3 ;This is an extrinsic function call that returns a string containing
- +4 ;a list of HL7 fields separated by uparrows (e.g., 1^2^3)
- +5 ;
- +6 ;Required variables:
- +7 ;APP - the internal entry number of the DHCP application
- +8 ; from file 771
- +9 ;SEG - the name of the HL7 segment for which fields are
- +10 ; to be returned
- +11 ;
- +12 ;Check for required input parameters
- +13 IF 'APP!(SEG']"")
- QUIT ""
- +14 IF '$DATA(^HL(771,APP,0))
- QUIT ""
- +15 NEW X
- SET X=$ORDER(^HL(771.3,"B",SEG,0))
- IF 'X
- QUIT ""
- +16 SET X=$ORDER(^HL(771,APP,"SEG","B",X,0))
- IF 'X
- QUIT ""
- +17 ;Return string
- +18 QUIT $TRANSLATE($GET(^HL(771,APP,"SEG",X,"F")),",","^")
- MSH(HLMTN,HLSEC) ;Create an MSH Segment for an Outgoing HL7 Message
- +1 ;
- +2 ;Input : HLMTN - Three to seven character HL7 message type name
- +3 ; HLSEC - Security to be included in field #8 of the segment
- +4 ; (optional - field left blank when not passed)
- +5 ; All variables created by a call to INIT^HLTRANS
- +6 ;
- +7 ;Output : An HL7 MSH segment
- +8 ;
- +9 ;Note : NULL is returned on error/bad input
- +10 ; : Existance of variables from INIT^HLTRANS is assumed
- +11 ;
- +12 ;Check for required parameters
- +13 if ($GET(HLMTN)="")
- QUIT ""
- +14 if ('$DATA(HLNDAP0))
- QUIT ""
- +15 SET HLSEC=$GET(HLSEC)
- +16 ;Make sure pointer to Message Text file is valid
- +17 if ('$DATA(HLDA))
- QUIT ""
- +18 if ('$DATA(^HL(772,HLDA,0)))
- QUIT ""
- +19 ;Declare variables
- +20 NEW MID,NODE,MSH
- +21 ;Get message ID
- +22 SET NODE=$GET(^HL(772,HLDA,0))
- +23 SET MID=$PIECE(NODE,"^",6)
- +24 if (MID="")
- QUIT ""
- +25 ;Build MSH segment
- +26 SET MSH="MSH"_HLFS_HLECH_HLFS_HLDAN_HLFS_$PIECE(HLNDAP0,"^",2)
- +27 SET MSH=MSH_HLFS_$PIECE(HLNDAP0,"^",1)_HLFS_$PIECE(HLNDAP0,"^",3)_HLFS_HLDT1
- +28 SET MSH=MSH_HLFS_HLSEC_HLFS_HLMTN_HLFS_MID_HLFS_HLPID_HLFS_HLVER
- +29 ;Return MSH segment
- +30 QUIT MSH
- BHS(HLMTN,HLSEC,HLMSA) ;Create a BHS Segment for an Outgoing HL7 Batch Message
- +1 ;
- +2 ;This is an extrinsic function call that returns an HL7 BHS segment
- +3 ;
- +4 ;Input : HLMTN - The three to seven character HL7 message type name
- +5 ; HLSEC - Security to be included in field #8 of the segment
- +6 ; (optional - field left blank when not passed)
- +7 ; HLMSA - Three components (separated by the HL7 component
- +8 ; separator character) consisting of the first
- +9 ; three fields in the MSA segment. This variable is
- +10 ; required if the message you are building is a
- +11 ; batch response.
- +12 ; All variables created by a call to INIT^HLTRANS
- +13 ;
- +14 ;Output : An HL7 BHS segment
- +15 ;
- +16 ;Note : NULL is returned on error/bad input
- +17 ; : Existance of variables from INIT^HLTRANS is assumed
- +18 ;
- +19 ;Check for required parameters
- +20 if ($GET(HLMTN)="")
- QUIT ""
- +21 SET HLSEC=$GET(HLSEC)
- +22 SET HLMSA=$GET(HLMSA)
- +23 if ('$DATA(HLNDAP0))
- QUIT ""
- +24 ;Declare variables
- +25 NEW BHS,FIELD9,FIELD10,TMP,BID,BRID
- +26 ;Get batch ID
- +27 SET TMP=$GET(^HL(772,HLDA,0))
- +28 SET BID=$PIECE(TMP,"^",6)
- +29 if (BID="")
- QUIT ""
- +30 ;Build field # 9 (batch name/processing ID/type/version)
- +31 SET FIELD9=$EXTRACT(HLECH)_HLPID_$EXTRACT(HLECH)_$EXTRACT(HLMTN,1,3)_$EXTRACT(HLECH)_HLVER
- +32 ;Build field # 10 (batch comment)
- +33 SET FIELD10=""
- +34 IF (HLMSA'="")
- Begin DoDot:1
- +35 SET FIELD10=$PIECE(HLMSA,$EXTRACT(HLECH))
- +36 SET TMP=$PIECE(HLMSA,$EXTRACT(HLECH),3)
- +37 if (TMP'="")
- SET FIELD10=FIELD10_$EXTRACT(HLECH)_TMP
- End DoDot:1
- +38 ;Get batch reference ID
- +39 SET BRID=""
- +40 SET TMP=$PIECE(HLMSA,$EXTRACT(HLECH),2)
- +41 if (TMP'="")
- SET BRID=TMP
- +42 ;Build BHS segment
- +43 SET BHS="BHS"_HLFS_HLECH_HLFS_HLDAN_HLFS_$PIECE(HLNDAP0,"^",2)
- +44 SET BHS=BHS_HLFS_$PIECE(HLNDAP0,"^")_HLFS_$PIECE(HLNDAP0,"^",3)_HLFS_HLDT1
- +45 SET BHS=BHS_HLFS_HLSEC_HLFS_FIELD9_HLFS_FIELD10_HLFS_BID_HLFS_BRID
- +46 ;Return BHS segment
- +47 QUIT BHS