Stream: python
Topic: Getting attribute values
Eric Haas (Apr 28 2018 at 19:42):
There is the ValueSet
model as well as ValueSetCompose
, ValueSetComposeInclude
too.
The 'ValueSet' object has no attribute 'ValueSetCompose'
- But is there a way to use a "sub-model" to access attributes values from a class instance. e.g., I have
vs = ValueSet(my_valueset) # instead of compose = vs.compose # is there way to access same data using ValueSetCompose?
Pascal Pfiffner (May 01 2018 at 18:15):
Yes, you can just use properties to access sub-model attributes, is that what you're asking?
import fhirclient.models.valueset as v vs = v.ValueSet() vs.status = "draft" vs.compose = v.ValueSetCompose() vs.compose.inactive = False inc = v.ValueSetComposeInclude() inc.system = "https://example.com" vs.compose.include = [inc] vs.as_json() {'compose': {'inactive': False, 'include': [{'system': 'https://example.com'}]}, 'status': 'draft', 'resourceType': 'ValueSet'}
Eric Haas (May 01 2018 at 18:22):
Actually the other way around. use ValuesetComposeInclude to access a value set instance include element? Pretty sure the answer is no.... since not a sub-model
Pascal Pfiffner (May 01 2018 at 18:26):
Can you make an example? I'm not sure I understand what you want to do.
Eric Haas (May 01 2018 at 18:33):
thank you for the response, but I'm going to drop this question, I can easily do what I need to do with the models.
Last updated: Apr 12 2022 at 19:14 UTC