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

IBCNRHLU.m

Go to the documentation of this file.
  1. IBCNRHLU ;DAOU/DMK - e-Pharmacy HL7 Utilities ;24-MAY-2004
  1. ;;2.0;INTEGRATED BILLING;**251,550**;21-MAR-94;Build 25
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; Description
  1. ;
  1. ; e-Pharmacy HL7 Utilities
  1. ;
  1. ; Entry points:
  1. ; TRAN1 - Convert HL7 special characters (specific)
  1. ; TRAN2 - Convert HL7 special characters (general)
  1. ; ERR - Process HL7 Errors
  1. ; HLT - Receive HL7 e-Pharmacy MFN Message
  1. ; MFK - Send HL7 e-Pharmacy MFK Message
  1. ;
  1. Q
  1. ;
  1. TRAN1(VALUE) ; Convert HL7 special characters
  1. ;
  1. ; Specific to the following standard VistA HL7 application definition
  1. ; HL7 FIELD SEPARATOR = |
  1. ; HL7 ENCODING CHARACTERS = ^~\&
  1. ;
  1. ; Input parameter:
  1. ; VALUE = HL7 message field, component, or subcomponent value
  1. ; Invoked if value contains escape character (\)
  1. ;
  1. ; Output parameter:
  1. ; NEWVALUE = Converted HL7 message field, component, or subcomponent value
  1. ;
  1. N CONVERT,I,LAST,NEWVALUE,S,S3
  1. ;
  1. ; Initialize last string position involing converted special character
  1. S LAST=0
  1. ;
  1. ; Initialize scratch string varaible
  1. S S=""
  1. ;
  1. ; Initialize conversion array
  1. ;
  1. ; | = field separator
  1. ; Transferred as \F\ and converted to |
  1. S CONVERT("\F\")="|"
  1. ;
  1. ; ^ = component separator
  1. ; Transferred as \S\ and NOT converted to ^ (FileMan delimiter)
  1. ;
  1. ; ~ = repetitive separator
  1. ; Transferred as \R\ and converted to ~
  1. S CONVERT("\R\")="~"
  1. ;
  1. ; \ = escape character
  1. ; Transferred as \E\ and converted to \
  1. S CONVERT("\E\")="\"
  1. ;
  1. ; & = subcomponent separator
  1. ; Transferred as \T\ and converted to &
  1. S CONVERT("\T\")="&"
  1. ;
  1. ; Check and covert
  1. F I=1:1:$L(VALUE) D
  1. . S S=S_$E(VALUE,I)
  1. . I (I-3)'<LAST D
  1. .. ;
  1. .. ; Check last 3 characters and convert if necessary
  1. .. S S3=$E(S,$L(S)-2,$L(S))
  1. .. I $D(CONVERT(S3)) D
  1. ... S LAST=I
  1. ... S S=$E(S,1,$L(S)-3)_CONVERT(S3)
  1. S NEWVALUE=S
  1. Q NEWVALUE
  1. ;
  1. TRAN2(VALUE,HLFS,HLECH) ; Convert HL7 special characters
  1. ;
  1. ; General to the following:
  1. ;
  1. ; HL7 Component Separator = $E(HLECH,1)
  1. ; HL7 Repetition Separator = $E(HLECH,2) = $E(HL("ECH"),2)
  1. ; HL7 Escape Character = $E(HLECH,3) = $E(HL("ECH"),3)
  1. ; HL7 Subcomponent = $E(HLECH,4)
  1. ;
  1. ; Invoked if value contains escape character (VALUE[$E(HL("ECH"),3)
  1. ;
  1. ; Expected variable
  1. ; U = "^"
  1. ;
  1. ; Input parameters:
  1. ; VALUE = HL7 message field, component, or subcomponent value
  1. ; HLFS = HL7 field separator = HL7 variable HL("FS")
  1. ; HLECH = HL7 encoding characters = HL7 variable HL("ECH")
  1. ;
  1. ; Output parameter:
  1. ; NEWVALUE = Converted HL7 message field, component, or subcomponent value
  1. ; Quit if any input parameters undefined
  1. I '$D(VALUE)!'$D(HLFS)!'$D(HLECH) Q
  1. ;
  1. N CONVERT,HLEC,I,LAST,NEWVALUE,S,S3
  1. ;
  1. ; Initialize HL7 escape character variable
  1. S HLEC=$E(HLECH,3)
  1. ;
  1. ; Initialize last string position involing converted special character
  1. S LAST=0
  1. ;
  1. ; Initialize scratch string varaible
  1. S S=""
  1. ;
  1. ; Initialize conversion array
  1. ; Do not covert to caret (^) (FileMan delimiter)
  1. ;
  1. ; Field separator
  1. ; Transferred as HLEC_"F"_HLEC and converted to HLFS
  1. S CONVERT(HLEC_"F"_HLEC)=HLFS
  1. ;
  1. ; Component separator
  1. ; Transferred as HLEC_"S"_HLEC and converted to $E(HLECH,1)
  1. I $E(HLECH,1)'=U S CONVERT(HLEC_"S"_HLEC)=$E(HLECH,1)
  1. ;
  1. ; Repetitive separator
  1. ; Transferred as HLEC_"R"_HLEC and converted to $E(HLECH,2)
  1. I $E(HLECH,2)'=U S CONVERT(HLEC_"R"_HLEC)=$E(HLECH,2)
  1. ;
  1. ; Escape character
  1. ; Transferred as HLEC_"E"_HLEC and converted to $E(HLECH,3)
  1. I $E(HLECH,3)'=U S CONVERT(HLEC_"E"_HLEC)=$E(HLECH,3)
  1. ;
  1. ; Subcomponent separator
  1. ; Transferred as HLEC_"T"_HLEC and converted to $E(HLECH,4)
  1. I $E(HLECH,4)'=U S CONVERT(HLEC_"T"_HLEC)=$E(HLECH,4)
  1. ;
  1. ; Check and covert
  1. F I=1:1:$L(VALUE) D
  1. . S S=S_$E(VALUE,I)
  1. . I (I-3)'<LAST D
  1. .. ;
  1. .. ; Check last 3 characters and convert if necessary
  1. .. S S3=$E(S,$L(S)-2,$L(S))
  1. .. I $D(CONVERT(S3)) D
  1. ... S LAST=I
  1. ... S S=$E(S,1,$L(S)-3)_CONVERT(S3)
  1. S NEWVALUE=S
  1. Q NEWVALUE
  1. ;
  1. ERR ; Process HL7 Errors
  1. D ERR^IBCNEHLI
  1. Q
  1. ;
  1. HLT ; Receive HL7 e-Pharmacy MFN Message
  1. D ^IBCNRHLT
  1. Q
  1. ;
  1. MFK ; Send HL7 e-Pharmacy MFK Message
  1. D ^IBCNRMFK
  1. Q