User bio
I have a background in electrical engineering ad have been active as software engineer and architect for the past 35 years. Since 2010 I am active in healthcare interoperability, for VitalHealth and Philips. In June 2022 I joined InterSystems.
Member since Jun 22, 2022
Posts:
Replies:
Yes, although the Python code does deal with an actual collection object :)
/// Python reorder FHIR properties
ClassMethod PyFHIRResourceReOrder(resource As %String) As %String [ Language = python ]
{
import json
from collections import OrderedDict
result = json.loads(resource, object_pairs_hook=OrderedDict)
result.move_to_end("extension", last = False)
result.move_to_end("meta", last = False)
result.move_to_end("id", last = False)
result.move_to_end("resourceType", last = False)
return json.dumps(result)
}
This Python code is what I ended up with. It re-orders the properties "resourceType", "id", "meta" and "extension" to be at the start
Followers:
Theo has no followers yet.
Following:
Theo has not followed anybody yet.
Global Masters badges:


Thanks, Julius, that is really helpful!!
I have implemented the part of the method that I needed as follows:
/// Move FHIR resourceproperties in the followin order: /// - resourceType /// - id /// - meta /// - extension ClassMethod FHIROrderResourceProperties(resource As %DynamicObject) As %DynamicObject { #dim order as %DynamicArray = [ "resourceType", "id", "meta", "extension" ] #dim newObject as %DynamicObject = {} for index = 0:1:order.%Size() - 1 { set element = order.%Get(index) set done(element) = 1 if $EXTRACT(resource.%GetTypeOf(element), 1, 2) '= "un" { do newObject.%Set(element, resource.%Get(element)) } } set iterator = resource.%GetIterator() while iterator.%GetNext(.element, .value) { if '$DATA(done(element)) { do newObject.%Set(element, value) } } return newObject }