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

HLTF1.m

Go to the documentation of this file.
  1. HLTF1 ;AISC/SAW/MTC-Process Message Text File Entries (Cont'd) ;10/17/2007 09:43
  1. ;;1.6;HEALTH LEVEL SEVEN;**5,8,22,25,19,78,122**;Oct 13, 1995;Build 14
  1. ;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. MERGE15(ARAYTYPE,MTIEN,SUB1,SUB2) ;Merge Local/Global Array From Application into
  1. ;Message Text File
  1. ;
  1. ;This is a routine call with parameter passing. There are no output
  1. ;parameters returned by this call.
  1. ;
  1. ;** Merges incoming data for v1.5 applications only **
  1. ;
  1. ;Required input parameters
  1. ; MTIEN = The IEN from the Message Text file of the entry to be
  1. ; updated
  1. ; ARAYTYPE = Array type, G for global or L for local
  1. ; SUB1 = The first level subscript of the array. Must be
  1. ; either HLS or HLA
  1. ;Optional input parameter
  1. ; SUB2 = A second subscript associated with the array
  1. ;
  1. ;Check for required parameters
  1. I "GL"'[$G(ARAYTYPE)!($G(SUB1)']"")!('$G(MTIEN)) G MRGE15X
  1. ;
  1. N HLCHAR,HLEVN,HLFS,I,X,X1,X2,X3 S (HLCHAR,HLEVN,X)=0
  1. ;
  1. ;Merge data from a global array with two subscript
  1. I ARAYTYPE="G",$G(SUB2)'="" D
  1. . S X="",I=0
  1. . F S X=$O(^TMP(SUB1,$J,SUB2,X)) Q:'X S I=I+1,X1=^TMP(SUB1,$J,SUB2,X),HLCHAR=HLCHAR+$L(X1) S:$E(X1,1,3)="MSH" HLFS=$E(X1,4),$P(X1,HLFS,8)="",HLEVN=HLEVN+1 S ^HL(772,MTIEN,"IN",I,0)=X1
  1. ;
  1. ;Merge data from a global array with one subscripts
  1. I ARAYTYPE="G",$G(SUB2)="" D
  1. . S X="",I=0
  1. . F S X=$O(^TMP(SUB1,$J,X)) Q:'X S I=I+1,X1=^TMP(SUB1,$J,X),HLCHAR=HLCHAR+$L(X1) S:$E(X1,1,3)="MSH" HLFS=$E(X1,4),$P(X1,HLFS,8)="",HLEVN=HLEVN+1 S ^HL(772,MTIEN,"IN",I,0)=X1
  1. ;
  1. ;Merge data from a local array with one subscript
  1. I ARAYTYPE="L" D
  1. . S X="",I=0
  1. . F S X=$O(HLA(SUB1,X)) Q:'X S I=I+1,X1=HLA(SUB1,X),HLCHAR=HLCHAR+$L(X1) S:$E(X1,1,3)="MSH" HLFS=$E(X1,4),$P(X1,HLFS,8)="",HLEVN=HLEVN+1 S ^HL(772,MTIEN,"IN",I,0)=X1
  1. ;
  1. ;-- update 0 node for message text
  1. S ^HL(772,MTIEN,"IN",0)="^^"_I_"^"_I_"^"_$$DT^XLFDT_"^"
  1. ;
  1. ;File message statistics
  1. D STATS^HLTF0(MTIEN,HLCHAR,HLEVN)
  1. ;
  1. MRGE15X ;-- exit merge
  1. Q
  1. ;
  1. MERGE(ARAYTYPE,MTIEN,SUB1,SUB2) ;Merge Local/Global Array From Application into
  1. ;Message Text File
  1. ;
  1. ;This is a routine call with parameter passing. There are no output
  1. ;parameters returned by this call.
  1. ;
  1. ;Required input parameters
  1. ; MTIEN = The IEN from the Message Text file of the entry to be
  1. ; updated
  1. ; ARAYTYPE = Array type, G for global or L for local
  1. ; SUB1 = The first level subscript of the array. Must be
  1. ; either HLS or HLA
  1. ;Optional input parameter
  1. ; SUB2 = A second subscript associated with the array
  1. ;
  1. ;Check for required parameters
  1. I "GL"'[$G(ARAYTYPE)!($G(SUB1)']"")!('$G(MTIEN)) G MERGEX
  1. ;
  1. N HLCHAR,HLEVN,HLFS,I,X,X1,X2,X3 S (HLCHAR,HLEVN,X)=0
  1. ;
  1. ; patch HL*1.6*122: MPI-client/server
  1. F L +^HL(772,+$G(MTIEN)):10 Q:$T H 1
  1. ;
  1. ;Merge data from a global array with two subscript
  1. I ARAYTYPE="G",$G(SUB2)'="" D
  1. . S X="",I=0
  1. . F S X=$O(^TMP(SUB1,$J,SUB2,X)) Q:'X S I=I+1,X1=^TMP(SUB1,$J,SUB2,X),HLCHAR=HLCHAR+$L(X1) S:$E(X1,1,3)="MSH" HLFS=$E(X1,4),$P(X1,HLFS,8)="",HLEVN=HLEVN+1 S ^HL(772,MTIEN,"IN",I,0)=X1,X2=$D(^TMP(SUB1,$J,SUB2,X)) D
  1. .. I X2=11 S X3="" F S X3=$O(^TMP(SUB1,$J,SUB2,X,X3)) Q:'X3 D
  1. ... S I=I+1,X1=$G(^TMP(SUB1,$J,SUB2,X,X3)),HLCHAR=HLCHAR+$L(X1),^HL(772,MTIEN,"IN",I,0)=X1
  1. .. S I=I+1,^HL(772,MTIEN,"IN",I,0)="" Q
  1. ;
  1. ;Merge data from a global array with one subscripts
  1. I ARAYTYPE="G",$G(SUB2)="" D
  1. . S X="",I=0
  1. . F S X=$O(^TMP(SUB1,$J,X)) Q:'X S I=I+1,X1=^TMP(SUB1,$J,X),HLCHAR=HLCHAR+$L(X1) S:$E(X1,1,3)="MSH" HLFS=$E(X1,4),$P(X1,HLFS,8)="",HLEVN=HLEVN+1 S ^HL(772,MTIEN,"IN",I,0)=X1,X2=$D(^TMP(SUB1,$J,X)) D
  1. .. I X2=11 S X3="" F S X3=$O(^TMP(SUB1,$J,X,X3)) Q:'X3 D
  1. ... S I=I+1,X1=$G(^TMP(SUB1,$J,X,X3)),HLCHAR=HLCHAR+$L(X1),^HL(772,MTIEN,"IN",I,0)=X1
  1. .. S I=I+1,^HL(772,MTIEN,"IN",I,0)="" Q
  1. ;
  1. ;Merge data from a local array with one subscript
  1. I ARAYTYPE="L" D
  1. . S X="",I=0
  1. . F S X=$O(HLA(SUB1,X)) Q:'X S I=I+1,X1=HLA(SUB1,X),HLCHAR=HLCHAR+$L(X1) S:$E(X1,1,3)="MSH" HLFS=$E(X1,4),$P(X1,HLFS,8)="",HLEVN=HLEVN+1 S ^HL(772,MTIEN,"IN",I,0)=X1,X2=$D(HLA(SUB1,X)) D
  1. .. I X2=11 S X3="" F S X3=$O(HLA(SUB1,X,X3)) Q:'X3 D
  1. ... S I=I+1,X1=$G(HLA(SUB1,X,X3)),HLCHAR=HLCHAR+$L(X1),^HL(772,MTIEN,"IN",I,0)=X1
  1. .. S I=I+1,^HL(772,MTIEN,"IN",I,0)="" Q
  1. ;
  1. S:HLEVN=0 HLEVN=1
  1. ;X=ien in file 773 for TCP messages
  1. S X=+$O(^HLMA("B",MTIEN,0))
  1. ;batch message type
  1. I X,$P($G(^HLMA(X,0)),U,5)="B" D BTS
  1. I 'X,$P(^HL(772,MTIEN,0),U,8),$P(^HL(772,$P(^(0),U,8),0),U,14)="B" D BTS
  1. ;
  1. ;-- update 0 node for message text
  1. S ^HL(772,MTIEN,"IN",0)="^^"_I_"^"_I_"^"_$$DT^XLFDT_"^"
  1. ;
  1. ; patch HL*1.6*122: MPI-client/server
  1. L -^HL(772,+$G(MTIEN))
  1. ;
  1. ;File message statistics
  1. D STATS^HLTF0(MTIEN,HLCHAR,HLEVN)
  1. ;
  1. MERGEX ;-- exit merge
  1. Q
  1. ;
  1. BTS ; create batch trailer seg (BTS)
  1. ;HL*1.6*78 to obtain and insert FIELD SEPARATOR, HLFS
  1. N HLFS,HLSAN
  1. S HLFS=$G(HL("FS")) ; obtain from HL array
  1. ; or obtain from sending application; default to "^"
  1. I HLFS="" D S:HLFS="" HLFS="^"
  1. . S HLSAN=$P($G(^HL(772,MTIEN,0)),U,2)
  1. . S:HLSAN HLFS=$G(^HL(771,HLSAN,"FS"))
  1. S I=I+1,^HL(772,MTIEN,"IN",I,0)="BTS"_HLFS_HLEVN,I=I+1,^HL(772,MTIEN,"IN",I,0)=""
  1. Q
  1. ;
  1. MRGINT(MTOUT,MTIN,HDR) ;Merge Internal to Internal Message from the
  1. ; Outbound message in 772 (MTOUT) to an Inbound entry (MTIN). The process
  1. ; will involve Moving the Header and Text into 772.
  1. ;
  1. ;Required input parameters
  1. ; MTOUT= Internal entry number of the Outbound message
  1. ; MTIN = Internal entry number of the Inbound message
  1. ; HDR = Name of the array that contains HL7 Header segment
  1. ; format: HLHDR - Used with indirection to build message in out
  1. ; queue
  1. ; This routine will first take the header information in the array
  1. ; specified by HDR and merge into the Message Text field of file 870.
  1. ; Then it will move the message contained in 772 (MTIEN) into 870.
  1. ;
  1. ;Check for required parameters
  1. I '$G(MTOUT)!('$G(MTIN))!(HDR="") Q
  1. ;
  1. ;-- initilize
  1. N I,X
  1. S I=0
  1. ;
  1. ;-- move header into 772 from HDR array
  1. S X="" F S X=$O(@HDR@(X)) Q:'X D
  1. . S I=I+1,^HL(772,MTIN,"IN",I,0)=@HDR@(X)
  1. S I=I+1,^HL(772,MTIN,"IN",I,0)=""
  1. ;
  1. ;Move data from Message Text (MTOUT) file TO Message Text 772 (MTIN)
  1. S X=0 F S X=$O(^HL(772,MTOUT,"IN",X)) Q:X="" S I=I+1 D
  1. . S ^HL(772,MTIN,"IN",I,0)=$G(^HL(772,MTOUT,"IN",X,0))
  1. ;
  1. ;-- update 0 node of message and format arrays
  1. S ^HL(772,MTIN,"IN",0)="^^"_I_"^"_I_"^"_$$DT^XLFDT_"^"
  1. ;
  1. Q