JSONC

195 views
Skip to first unread message

mwhe...@gmail.com

unread,
Jun 25, 2019, 1:05:48 PM6/25/19
to HAPI FHIR
Hello,

I am trying to access some data directly from the database for my HAPI FHIR server that was built using the hapi-fhir-jpaserver-starter project. I have it configured to run against MySQL.

I think the data I want is in the "hfj_res_ver" table, but I am having trouble accessing the RES_TEXT blob. RES_ENCODING implies that it is JSONC encoded.

Is there anyway that I can access the blob information in RES_TEXT directly within a SQL client (i.e. MySQL workbench)? I'm not really sure where to start since it's hard for me to tell exactly what encoding, encryption, or other functions have been applied to this data. 

This is what I see in mysql workbench:

Untitled.png


Thanks.


James Agnew

unread,
Jun 25, 2019, 1:06:55 PM6/25/19
to mwhe...@gmail.com, HAPI FHIR
The data in that column is GZip encoded, but it should be possible to uncompress it and you'll have standard JSON content.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/396e2d2c-cbf2-4f4b-a203-6a06a765d435%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mwhe...@gmail.com

unread,
Jun 25, 2019, 1:18:34 PM6/25/19
to HAPI FHIR
Thank you so much for the quick reply. Also let me thank you for all the work you've done with HAPI, I think it's great.

Ok, that's what I thought. Thank you for confirming. I tried the "uncompress" option in mysql, but it wasn't working (just get "null" back). I am guessing that I'll have to do this programmatically since it's gzip encoded. From my searching around online, I am not seeing anything built into mysql to perform a gzip.

Thanks!
Mike 


On Tuesday, June 25, 2019 at 1:06:55 PM UTC-4, James Agnew wrote:
The data in that column is GZip encoded, but it should be possible to uncompress it and you'll have standard JSON content.

Cheers,
James

On Tue, Jun 25, 2019 at 1:05 PM <mwhe...@gmail.com> wrote:
Hello,

I am trying to access some data directly from the database for my HAPI FHIR server that was built using the hapi-fhir-jpaserver-starter project. I have it configured to run against MySQL.

I think the data I want is in the "hfj_res_ver" table, but I am having trouble accessing the RES_TEXT blob. RES_ENCODING implies that it is JSONC encoded.

Is there anyway that I can access the blob information in RES_TEXT directly within a SQL client (i.e. MySQL workbench)? I'm not really sure where to start since it's hard for me to tell exactly what encoding, encryption, or other functions have been applied to this data. 

This is what I see in mysql workbench:

Untitled.png


Thanks.


--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi...@googlegroups.com.

mwhe...@gmail.com

unread,
Jun 25, 2019, 1:28:26 PM6/25/19
to HAPI FHIR
For anyone else running into this issue, you can store the data in the database without the gzip compression and you should have direct access to it (not sure how this affects performance so be warned). I was able to add the following to my JpaRestfulServer.java class, right before the "if (fhirVersion == FhirVersionEnum.DSTU2) {" check:

// set database encoding
DaoConfig daoConfig = appCtx.getBean(DaoConfig.class);
daoConfig.setResourceEncoding(ResourceEncodingEnum.JSON);


Now I see my data in plain old JSON format in my mysql database.

This issue helped me figure it out:
Message has been deleted

Muhammad Risky Pahlevi (Levi)

unread,
Feb 6, 2023, 4:36:25 AM2/6/23
to HAPI FHIR
Salaam / Hi,

I am trying to connect the PostgreSQL Database of HAPI FHIR into a data visualization tool called Metabase.

The hfj_res_ver.res_text is of type oid.

Is there a way in PostgreSQL query to get the GZip encoded value and then decompress it? So Metabase can use the JSON object stored in that column and flatten it.

Warm regards,
Levi
Reply all
Reply to author
Forward
0 new messages