Question
· Apr 3, 2019

HL7 HTTP Response Charset

Hello,

currently we have a problem in development with the character set of the response message.

We are transmitting an HL7 message with an operation based on the EnsLib.HL7.Operation.HTTPOperation class.
We have changed this as follows.

Set pMsgIn=$$$NULLOREF, tHttpRequest=##class(%Net.HttpRequest).%New(), tHttpRequest.WriteRawMode=1, tHttpRequest.ContentType="APPLICATION/HL7-V2; charset=UTF-8"

Unfortunately, the ContentType character set is not read correctly in the response.

 

This is the response:


0000 00 15 5d 4b c0 00 00 1a e2 4a 45 00 08 00 45 02 ..]K....JE...E.
0010 02 5a 35 ec 40 00 7f 06 6b a3 0a a8 a0 24 0a a8 .Z5.@...k....$...
0020 a2 98 1f 40 ca 26 7a 13 54 b7 ec 0b fa 9a 50 18 ...@.&z.T.....P.
0030 10 0a a5 3c 00 00 48 54 54 50 2f 31 2e 31 20 32 ...<..HTTP/1.1 2
0040 30 30 20 4f 4b 4b 0d 0a 73 65 74 2d 63 6f 6f 6b 69 00 OK..set-cooki
0050 65 3a 20 73 61 70 2d 75 73 65 72 63 6f 6e 74 65 e: sap-userconte
0060 78 74 3d 73 61 70 2d 63 6c 69 65 6e 74 3d 35 30 xt=sap-client=50
0070 30 3b 20 70 61 74 68 3d 2f 0d 0a 73 65 74 2d 63 0; path=/..set-c
0080 6f 6f 6b 6b 69 65 3a 20 53 41 50 5f 53 45 53 53 49 ookie: SAP_SESSI
0090 4f 4e 4e 49 44 5f 45 4b 53 5f 35 30 30 3d 41 62 69 ONID_EKS_500=Abi
00a0 34 4a 74 72 6d 72 73 39 5f 41 67 6d 68 71 45 79 4Jtrmrs9_AgmhqEy
XXX
00c0 41 46 56 31 52 4f 51 41 25 33 64 3b 20 70 61 74 AFV1ROQA%3d; pat
00d0 68 3d 2f 2f 0d 0a 63 6f 6e 74 65 6e 74 2d 74 79 70 h=/..content type
00e0 65 3a 20 61 70 70 6c 69 63 61 74 69 6f 6e 2f 68 e: application/h
00f0 6c 37 2d 76 32 3b 20 63 68 61 72 73 65 74 3d 55 l7-v2; charset=U
0100 54 46 2d 38 0d 0a 63 6f 6e 74 65 6e 74 2d 6c 65 TF-8..content-le
0110 6e 67 74 68 3a 20 33 33 31 0d 0d 0d 0a 4d 53 48 ngth: 331....MSH
0120 7c 5e 7e 5e 5c 26 7c 53 41 50 2d 49 53 48 7c 35 30 |^~\&|SAP-ISH|50
0130 30 26 35 31 30 30 30 7c 6d 79 4d 65 64 69 73 7c 4b 0&5100|myMedis|K
0140 6c 69 6e 69 6b 75 6d 2d 53 74 75 74 74 67 61 72 linikum-Stuttgar
0150 74 5e 31 2e 32 2e 32 37 36 2e 30 2e 37 36 2e 33 t^1.2.276.0.76.3
0160 2e 31 2e 38 33 5e 49 53 4f 7c 32 30 31 39 30 34 .1.83^ISO|201904
0170 30 33 30 39 35 32 31 33 7c 7c 41 43 4b 5e 4f 31 03095213||ACK^O1
0180 39 5e 41 43 4b 5f 4f 31 39 7c 31 30 30 30 30 30 30 9^ACK_O19|100000
0190 30 30 30 30 30 30 30 30 30 30 35 39 38 30 7c 39 00000000005980|9
01a0 39 39 39 39 7c 32 2e 37 5e 44 45 5e 26 26 49 53 9999|2.7^DE^&&IS
01b0 4f 7c 7c 7c 7c 4e 45 7c 4e 45 7c 44 45 55 7c 55 4e O|||NE|NE|DEU|UN
01c0 49 43 4f 44 45 20 55 54 46 2d 38 7c 44 45 55 5e ICODE UTF-8|DEU^
01d0 5e 48 4c 37 30 33 39 39 7c 7c 0d 4d 53 41 7c 41 ^HL70399||.MSA|A
01e0 45 7c 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 E|1000000000000000
01f0 30 30 30 35 39 38 30 7c 46 65 68 6c 65 72 3a 20 53 005980|Error: S
0200 69 65 68 65 20 44 65 74 61 69 6c 73 21 20 c3 a4 See details! ..
0210 c3 b6 c3 bc c3 84 c3 96 c3 9c 7c 7c 7c 7c 0d 45 52 ..........|||.ER
0220 52 7c 7c 7c 7c 32 30 37 7c 45 7c 36 35 38 7c 4e 46 R||||207|E|658|NF
0230   7c c3 a4 c3 b6 c3 bc c3 84 c3 96 c3 9c 7c 7c 7c   |............|||
0240 7c 7c 0d 45 52 52 7c 7c 7c 32 30 37 7c 45 7c 30 ||.ERR||||207|E|0

0250   31 36 7c 4e 31 7c c3 a4 c3 b6 c3 bc c3 84 c3 96   16|N1|..........

0260   c3 9c 7c 7c 7c 7c 7c 0d                                               ..|||||.


<HTTP/1.1 200 OK
set-cookie: sap-usercontext=sap-client=500; path=/
set-cookie: SAP_SESSIONID_EKS_500=XXX; path=/
content-type: application/hl7-v2; charset=UTF-8
content-length: 331

MSH|^~\&|SAP-ISH|500&5100|myMedis|Stuttgart Clinic^1.2.276.0.76.3.1.83^ISO|20190403095213|ACK^O19^ACK_O19|100000000000005980|99999|2.7^DE^&&ISO|||NE|NE|DEU|UNICODE UTF-8|DEU^^HL70399|| MSA|AE|10000000000000005980|Error: See details! äöüÃÃÃ||||| ERR|||207|E|658|NF|üÃÃöäÃ||||| ERR|||207|E|016|N1|üÃÃöäÃ||||||| 

The characters for äöüÄÖÜÜ should be transmitted.

In Ensemble looks the message like this

MSH|^~\&|SAP-ISH|500&5100|myMedis|Klinikum-Stuttgart^1.2.276.0.76.3.1.83^ISO|20190403095213||ACK^O19^ACK_O19|10000000000000005980|99999|2.7^DE^&&ISO|||NE|NE|DEU|UNICODE UTF-8|DEU^^HL70399||
MSA|AE|10000000000000005980|Fehler: Siehe Details! ????||
||
ERR|||207|E|658|NF|????||||
||
ERR|||207|E|016|N1|????||||
||

 


Does anyone have an idea to solve this problem?

 

Kind regards 

Armin

Discussion (2)2
Log in or sign up to continue

Have you tried setting "DefCharEncoding" to UTF-8 in the settings for EnsLib.HL7.Operation.HTTPOperation?

Here are the details from the popup-help. Especially note the highlighted line. Using "!UTF-8" will cause the operation to ignore what's in MSH:18 and always use UTF-8.

Default Character Encoding to use when reading or writing HL7 messages.
If MSH field 18 (Character Set) is empty, this encoding will be used. Choices you can use for this setting include:

Native: Use the default character encoding of the installed locale of the IRIS server.
latin1: The ISO Latin1 8-bit encoding. This is the default.
ISO-8859-1: The ISO Latin1 8-bit encoding.
UTF-8: The Unicode 8-bit encoding.
Unicode: The Unicode 16-bit encoding (Little-Endian).
UnicodeBig: The Unicode 16-bit encoding (Big-Endian).
Any other NLS definitions installed on this IRIS server.
@<ttable>: <ttable> means a raw InterSystems character translation table name. A prefix of '@' means to use the named table.
Putting ! before the encoding name will force the use of the named encoding and will ignore any value found in MSH:18.

For "c3 a4 c3 b6 c3 bc c3 84 c3 96 c3 9c"

There are 12 bytes in total, for a UTF-8 encoding, "c3" represents that it starts a two bytes character, so there should be 6 characters in total,

c3 a4
c3 b6
c3 bc
c3 84
c3 96
c3 9c

While length of unreadable character "üÃÃöäÃ" is 9, I don't understand why.

But I have encoutnered a similar issue once, and solution was as beblow, maybe you could try this,

1) set tHttpRequest.ReadRawMode = 1 
2) read the response to a string, let's say "str", convert it, $ZCVT(str, "I","UTF8")