REST Json payload order.

1 view
Skip to first unread message

OKB

unread,
Jan 10, 2014, 2:03:24 AM1/10/14
to implem...@openmrs.org
Hello everyone.

For example, when creating an encounter, it always expects the patient to be one of the first two elements in the JSON payload. 
The issue is that with Perl, JSON hashes have a pseudo-random order so sometimes the POST will fail randomly.

Can anyone tell me if the sensitivity to order when posting JSON to the REST module is a bug or expected behavior?

Thanks!

Rafal Korytkowski

unread,
Jan 10, 2014, 12:07:21 PM1/10/14
to implementers
The ordering of fields in json should not matter. Could you give an example of a failing post?


-Rafał


--
OpenMRS Implementers: http://go.openmrs.org/implementers
Post: implem...@openmrs.org
Unsubscribe: implementers...@openmrs.org
Manage your OpenMRS subscriptions at https://id.openmrs.org/

Ope Bakare

unread,
Jan 10, 2014, 5:44:28 PM1/10/14
to implem...@openmrs.org
Absolutely!

This call fails:

{"encounterType":"Vitals","location":"Location One","patient":"1be2147f-5422-443a-9c06-6197a932e103","obs":[{"value":"72.5","concept":"5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}],"encounterDatetime":"2013-11-5"}



To unsubscribe from this group and stop receiving emails from it, send an email to implementers...@openmrs.org.

Lee Breisacher

unread,
Jan 10, 2014, 6:11:36 PM1/10/14
to implem...@openmrs.org
I think the location and encounterType should be guids, not names. Right?

Lee


On 1/10/2014 2:44 PM, Ope Bakare wrote:
Absolutely!

This call fails:

{"encounterType":"Vitals","location":"Location One","patient":"1be2147f-5422-443a-9c06-6197a932e103","obs":[{"value":"72.5","concept":"5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}],"encounterDatetime":"2013-11-5"}


On Jan 10, 2014, at 12:07 PM, Rafal Korytkowski <ra...@openmrs.org> wrote:

The ordering of fields in json should not matter. Could you give an example of a failing post?


-Rafaďż˝


On 10 January 2014 08:03, OKB <o...@bakare.me> wrote:
Hello everyone.

For example, when creating an encounter, it always expects the patient to be one of the first two elements in the JSON payload.ďż˝
The issue is that with Perl, JSON hashes have a pseudo-random order so sometimes the POST will fail randomly.

Can anyone tell me if the sensitivity to order when posting JSON to the REST module is a bug or expected behavior?

Thanks!

--
OpenMRS Implementers: http://go.openmrs.org/implementers
Post: implem...@openmrs.org
Unsubscribe: implementers...@openmrs.org
Manage your OpenMRS subscriptions at https://id.openmrs.org/

--
OpenMRS Implementers: http://go.openmrs.org/implementers
Post: implem...@openmrs.org
Unsubscribe: implementers...@openmrs.org
Manage your OpenMRS subscriptions at https://id.openmrs.org/

To unsubscribe from this group and stop receiving emails from it, send an email to implementers...@openmrs.org.

Ope Bakare

unread,
Jan 10, 2014, 6:13:27 PM1/10/14
to implem...@openmrs.org
It actually works fine if I rearrange it with the patient key in the first 3 positions, the issue is that perl does not guarantee the order of a hash before being transformed into JSON which leads my scripts to fail randomly.

On Jan 10, 2014, at 6:11 PM, Lee Breisacher <leebre...@gmail.com> wrote:

I think the location and encounterType should be guids, not names. Right?

Lee

On 1/10/2014 2:44 PM, Ope Bakare wrote:
Absolutely!

This call fails:

{"encounterType":"Vitals","location":"Location One","patient":"1be2147f-5422-443a-9c06-6197a932e103","obs":[{"value":"72.5","concept":"5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}],"encounterDatetime":"2013-11-5"}


On Jan 10, 2014, at 12:07 PM, Rafal Korytkowski <ra...@openmrs.org> wrote:

The ordering of fields in json should not matter. Could you give an example of a failing post?


-Rafał


On 10 January 2014 08:03, OKB <o...@bakare.me> wrote:
Hello everyone.

For example, when creating an encounter, it always expects the patient to be one of the first two elements in the JSON payload. 

Darius Jazayeri

unread,
Jan 10, 2014, 6:19:06 PM1/10/14
to implementers
I remember discussing a bug like this, though searching my email I can't find a reference.

My recollection is that I thought we needed a way to (in webservices.rest module code, on the server-side) highlight certain fields as being "priority" fields. (I don't remember if we decided to do it this way or not.)

-Darius

Ope Bakare

unread,
Jan 11, 2014, 12:04:06 PM1/11/14
to implem...@openmrs.org, implementers
It certainly appears that would be the right way to do it, since JSON should be unaware of priority and order.

Is there an existing bug report filed for this?

Sent from my iPhone

Darius Jazayeri

unread,
Jan 11, 2014, 12:05:27 PM1/11/14
to implementers

I couldn't find one, but I only searched for a couple of minutes. Can you please try searching more thoroughly for a ticket or making list post about it?

-Darius (by phone)

Reply all
Reply to author
Forward
0 new messages