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

What if elementProperties returns dictionary but not list? #137

Open
tmitanitky opened this issue Dec 5, 2022 · 2 comments
Open

What if elementProperties returns dictionary but not list? #137

tmitanitky opened this issue Dec 5, 2022 · 2 comments
Labels

Comments

@tmitanitky
Copy link

Hi,

Is there any reason that fhirclient.models.fhirabstractbase.FHIRAbstractBase.elementProperties() returns list but not dictionary? As the order of elements has no special meaning in FHIR, there seems to be no necessity to use list and there are some advantages for `using ``dictionary```.

If it returns dictionary, we can easily access information of an specific element of a resource:

from  fhirclient.models.organization import Organization
organization = Organization()
organization.elementProperties()['identifier']
-> ('identifier', 'identifier', fhirclient.models.identifier.Identifier, True, None, False)

(As it could be a breaking change, new function such as *.elementPropertiesDictionary() might be preferred.)

How do you think about this??

Thanks.

@p2-apple
Copy link

p2-apple commented Dec 5, 2022

The list preserves the order of the properties as they are in the spec IIRC.

@tmitanitky
Copy link
Author

tmitanitky commented Dec 6, 2022

Thanks.

FHIR JSON representation saids

Properties can appear in any order.

FHIR XML representations saids

Elements must always appear in the order documented.

They are not consistent. I propose to keep an .elementProperty method that returns an ordered list and to add a method called .elementPropertyDict that returns an unordered dictionary.

I believe the method has advantage for easy access to an specific element of a resource without knowing the order of elements.

@mikix mikix added the question label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants