Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resourceType last key instead of first in json #63

Open
VictorSaraiva opened this issue Mar 16, 2021 · 5 comments
Open

resourceType last key instead of first in json #63

VictorSaraiva opened this issue Mar 16, 2021 · 5 comments

Comments

@VictorSaraiva
Copy link

  • fhir.resources version: 6.0.0
  • Python version: 3.7
  • Operating System: windows 10

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
Copy link
Owner

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

@VictorSaraiva
Copy link
Author

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
Copy link
Author

Issue can be closed

nazrulworld added a commit to nazrulworld/fhir-parser that referenced this issue Mar 26, 2021
* FHIRAbstractModel::dict and FHIRAbstractModel::json methods have been refactored, also parameter signatures are changed.
* FHIRAbstractModel::ymal's signature also changed.
* update FHIRPrimitiveExtension and Primitive.
nazrulworld added a commit that referenced this issue Mar 26, 2021
* more details changes log yet to done.
nazrulworld added a commit that referenced this issue Mar 26, 2021
- `Issue #51 Help on converting XML to FHIR format.
- `Issue #63  Now JSON output key's sequence is matching with original FHIR specification.
Breaking
- ``FHIRAbstractModel.json()`` and ``FHIRAbstractModel.dict()`` parameters signatures are more FHIR specific and additional parameters are removed (pydantic specific).
@ItayGoren
Copy link
Contributor

ItayGoren commented Mar 30, 2021

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

@nazrulworld
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants