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

Creating empty Resource Object and setting parameters via setters ? #49

Closed SevKohler closed 3 years ago

SevKohler commented 3 years ago

Is there any option to create an empty Resource Object and set the Parameter via setters ? In the old version this worked as shown below:

diagnostic_report = DiagnosticReport()
diagnostic_report.id = "foobar" 
diagnostic_report.status = "registered"
nazrulworld commented 3 years ago

if you look at the readme.

Example: 5: Construct resource object in python way:

>>> from fhir.resources.organization import Organization
>>> from fhir.resources.address import Address
>>> json_obj = {"resourceType": "Organization",
...     "id": "f001",
...     "active": True,
...     "name": "Acme Corporation",
...     "address": [{"country": "Swizterland"}]
... }

>>> org = Organization.construct()
>>> org.id = "f001"
>>> org.active = True
>>> org.name = "Acme Corporation"
>>> org.address = list()
>>> address = Address.construct()
>>> address.country = "Swizterland"
>>> org.address.append(address)
>>> org.dict() == json_obj
True
SevKohler commented 3 years ago

Thanks, my bad !