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

PRCVUTSC.m

Go to the documentation of this file.
  1. PRCVUTSC ;WOIFO/DST - Convert non-formatted string ; 2/11/03 4:52pm
  1. ;;5.1;IFCAP;**81**;Oct 20, 2000
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. CONV(STR,ACT,SC) ;
  1. ;
  1. ; Initial data for HL7, HL() array, will be used in this routine.
  1. ; Such as HL("ECH"), HL("FS")...
  1. ;
  1. ; Input:
  1. ; STR - A string to be convert
  1. ; ACT - Action, E - from escape sequences to special char
  1. ; C - from special char to escape sequences
  1. ; SC - String of special character used in this HL7 message
  1. ; SC char 1 - Field separator
  1. ; char 2 - Component separator
  1. ; char 3 - Repetition separator
  1. ; char 4 - Escape sequence character
  1. ; char 5 - Subcomponent separator
  1. ;
  1. ; Output:
  1. ; STR1 - A converted string
  1. ;
  1. N LEN,SP,SP1,STR1,PRCVFS,PRCVCS,PRCVRS,PRCVES,PRCVSS
  1. I $L($G(STR))=0!($L($G(ACT))=0) Q ""
  1. S PRCVFS=$E(SC,1)
  1. S PRCVCS=$E(SC,2)
  1. S PRCVRS=$E(SC,3)
  1. S PRCVES=$E(SC,4)
  1. S PRCVSS=$E(SC,5)
  1. S LEN=$L(STR)
  1. I ACT="C" D TOC Q STR1
  1. ;
  1. TOE ; Converted from Escape Sequences to special characters
  1. ; PRCVFS <== \F\ Field separator
  1. ; PRCVCS <== \S\ Component separator
  1. ; PRCVRS <== \R\ Repetition separator
  1. ; PRCVES <== \E\ Escape sequence character
  1. ; PRCVSS <== \T\ Sub-component separator
  1. ;
  1. N I,J,K,LEN1,SE,SE1,SP,STR2
  1. S LEN1=0
  1. S STR1=STR
  1. ;
  1. ; Go through special characters listed in CH and converted, one by one.
  1. ;
  1. F K=1:1 Q:$P($T(CH+K),";;",2)']"" D
  1. . S SE=$P($P($T(CH+K),";;",2),";",2) ; correspond special character
  1. . F I=1:1 S STR2(I)=$P(STR1,SE,I) Q:STR2(I)="" S SE1(I)=SE
  1. . K STR2(I)
  1. . F J=1:1:I-1 S LEN1=LEN1+$L(STR2(J))+$L(SE1(J))
  1. . I LEN1>$L(STR1) K SE1(I-1)
  1. . S LEN1=0
  1. . S SP=$P($P($T(CH+K),";;",2),";",1)
  1. . S STR2=""
  1. . F I=1:1 Q:$G(STR2(I))']"" D
  1. .. S STR2=STR2_STR2(I)
  1. .. S:$D(SE1(I)) STR2=STR2_@SP
  1. . S STR1=STR2
  1. . K SP,STR2
  1. Q STR1
  1. ;
  1. TOC ; Converted from special characters to Escape Sequences
  1. ; PRCVFS ==> \F\ Field separator
  1. ; PRCVCS ==> \S\ Component separator
  1. ; PRCVRS ==> \R\ Repetition separator
  1. ; PRCVES ==> \E\ Escape sequence character
  1. ; PRCVSS ==> \T\ Sub-component separator
  1. ;
  1. N C1,I
  1. S STR1=""
  1. F I=1:1:LEN D
  1. . S C1=$E(STR,I)
  1. . S STR1=STR1_$S(C1=PRCVFS:"\F\",C1=PRCVCS:"\S\",C1=PRCVRS:"\R\",C1=PRCVES:"\E\",C1=PRCVSS:"\T\",1:C1)
  1. . Q
  1. Q
  1. ;
  1. CH ; Convert characters
  1. ;;PRCVFS;\F\;Field separator
  1. ;;PRCVCS;\S\;Component separator
  1. ;;PRCVRS;\R\;Repetition separator
  1. ;;PRCVES;\E\;Escape sequence character
  1. ;;PRCVSS;\T\;Subcomponent separator
  1. ;;