nazrulworld / fhir.resources

FHIR Resources https://www.hl7.org/fhir/resourcelist.html
https://pypi.org/project/fhir.resources/
Other
372 stars 104 forks source link

resourceType last key instead of first in json #63

Open VictorSaraiva opened 3 years ago

VictorSaraiva commented 3 years ago

Description

I've built a diagnostic report resource but when I print json the resourceType is the last key. I was expecting the resourceType to be the first key. How can I fix this? please

What I Did

from fhir.resources.diagnosticreport import DiagnosticReport
from fhir.resources.identifier import Identifier

diagnosticreport = DiagnosticReport.construct()
diagnosticreport.status = 'final'
identifier = Identifier()
diagnosticreport.identifier = list()
identifier.value = '21-48608871'
diagnosticreport.identifier.append(identifier)
diagnosticreport.issued = '2021-03-05T11:45:33+11:00'

print(diagnosticreport.json())

{"identifier": [{"value": "21-48608871"}], "issued": "2021-03-05T11:45:33+11:00", "status": "final", "resourceType": "DiagnosticReport"}

nazrulworld commented 3 years ago

Unfortunately .json() and .dict() are not following any order. I am also thinking about ordering if possible to implement.

VictorSaraiva commented 3 years ago

Thanks for the quick response. it would have been nice to have the resourceType as the first key, it would have made the json result more readable. I'm closing the ticket.

VictorSaraiva commented 3 years ago

Issue can be closed

ItayGoren commented 3 years ago

@nazrulworld i see you fixed it in ref:ff4e8c3 - did it affect the performance of json and dict?

nazrulworld commented 3 years ago

Honestly speaking, I didn´t any benchmarks yet. Should not downgrade of performance.