Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Base64EncodeContent for only one HL7 segment

Highlighted

Base64EncodeContent for only one HL7 segment

New Contributor

I have HL7 message coming in and after parsing it I need to convert only one of the segment from base64 to utf-8. The message has all the segments in utf-8 except for one segment which is in base64. How can we apply the conversion for only one segment (attribute) and not the rest; when i passed it to the Base64EncodeContent it complained saying data is not base64.

1 REPLY 1

Re: Base64EncodeContent for only one HL7 segment

Super Collaborator

Hi @bhumi limbu,

On HL7 the segment may have multiple component with separator "^" that may consists of subcomponent separated by "&"

when you have either of (^, &, ~, | ) in your data, its not in truly a stand alone component, such cases we need to split them again ( may be using modify attribute, then we should apply the bese64 decoding

any of the above mentioned characters in data will result in "Invalid character in input stream." while decoding.

Best thing is to test one message before applying the logic in NiFi flow, by manually running the base64 utility through passing the attribute (segment) using base64 -D <<<"<segment value >" should result in proper decoded message value.

## Example Test
[>>> ~ 10:40:40]$base64 <sample.txt

SSBoYXZlIEhMNyBtZXNzYWdlIGNvbWluZyBpbiBhbmQgYWZ0ZXIgcGFyc2luZyBpdCBJIG5lZWQgdG8gY29udmVydCBvbmx5IG9uZSBvZiB0aGUgc2VnbWVudCBmcm9tIGJhc2U2NCB0byB1dGYtOC4gVGhlIG1lc3NhZ2UgaGFzIGFsbCB0aGUgc2VnbWVudHMgaW.....

[>>> ~ 10:40:49]base64 <sample.txt >sample.base64		#Converting into Base64

[>>> ~ 10:40:56]$base64 -D sample.base64			#Decoding from Base64
I have HL7 message coming in and after parsing it I need to convert only one of the segment from base64 to utf-8. The message has all the segments in utf-8 .....

[>>> ~ 10:41:06]$

* please used "-d" instead of "-D" in some linux systems.

Hope this helps !!

Don't have an account?
Coming from Hortonworks? Activate your account here