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.
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 !!