Abstract base class for all FHIR elements. More...
Public Member Functions | |
def | __init__ (self, jsondict=None, strict=True) |
Initializer. More... | |
def | with_json (cls, jsonobj) |
Initialize an element from a JSON dictionary or array. More... | |
def | with_json_and_owner (cls, jsonobj, owner) |
Instantiates by forwarding to with_json() , then remembers the "owner" of the instantiated elements. More... | |
def | elementProperties (self) |
Returns a list of tuples, one tuple for each property that should be serialized, as: ("name", "json_name", type, is_list, "of_many", not_optional) More... | |
def | update_with_json (self, jsondict) |
Update the receiver with data in a JSON dictionary. More... | |
def | as_json (self) |
Serializes to JSON by inspecting elementProperties() and creating a JSON dictionary of all registered properties. More... | |
def | owningResource (self) |
Walks the owner hierarchy and returns the next parent that is a DomainResource instance. More... | |
def | owningBundle (self) |
Walks the owner hierarchy and returns the next parent that is a Bundle instance. More... | |
def | resolvedReference (self, refid) |
Returns the resolved reference with the given id, if it has been resolved already. More... | |
def | didResolveReference (self, refid, resolved) |
Called by FHIRResource when it resolves a reference. More... | |
Abstract base class for all FHIR elements.
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.__init__ | ( | self, | |
jsondict = None , |
|||
strict = True |
|||
) |
Initializer.
If strict is true, raises on errors, otherwise uses logger.warning()
.
:raises: FHIRValidationError on validation errors, unless strict is False :param dict jsondict: A JSON dictionary to use for initialization :param bool strict: If True (the default), invalid variables will raise a TypeError
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.as_json | ( | self | ) |
Serializes to JSON by inspecting elementProperties()
and creating a JSON dictionary of all registered properties.
Checks:
- whether required properties are not None (and lists not empty) - whether not-None properties are of the correct type :raises: FHIRValidationError if properties have the wrong type or if required properties are empty :returns: A validated dict object that can be JSON serialized
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.didResolveReference | ( | self, | |
refid, | |||
resolved | |||
) |
Called by FHIRResource
when it resolves a reference.
Stores the resolved reference into the _resolved
dictionary.
:param refid: The id of the resource that was resolved :param refid: The resolved resource, ready to be cached
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.elementProperties | ( | self | ) |
Returns a list of tuples, one tuple for each property that should be serialized, as: ("name", "json_name", type, is_list, "of_many", not_optional)
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.owningBundle | ( | self | ) |
Walks the owner hierarchy and returns the next parent that is a Bundle
instance.
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.owningResource | ( | self | ) |
Walks the owner hierarchy and returns the next parent that is a DomainResource
instance.
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.resolvedReference | ( | self, | |
refid | |||
) |
Returns the resolved reference with the given id, if it has been resolved already.
If it hasn't, forwards the call to its owner if it has one.
You should probably use resolve()
on the FHIRReference
itself.
:param refid: The id of the resource to resolve :returns: An instance of Resource
, if it was found
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.update_with_json | ( | self, | |
jsondict | |||
) |
Update the receiver with data in a JSON dictionary.
:raises: FHIRValidationError on validation errors :param dict jsondict: The JSON dictionary to use to update the receiver :returns: None on success, a list of errors if there were errors
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.with_json | ( | cls, | |
jsonobj | |||
) |
Initialize an element from a JSON dictionary or array.
If the JSON dictionary has a "resourceType" entry and the specified resource type is not the receiving classes type, uses FHIRElementFactory
to return a correct class instance.
:raises: TypeError on anything but dict or list of dicts :raises: FHIRValidationError if instantiation fails :param jsonobj: A dict or list of dicts to instantiate from :returns: An instance or a list of instances created from JSON data
def fhirclient.models.fhirabstractbase.FHIRAbstractBase.with_json_and_owner | ( | cls, | |
jsonobj, | |||
owner | |||
) |
Instantiates by forwarding to with_json()
, then remembers the "owner" of the instantiated elements.
The "owner" is the resource containing the receiver and is used to resolve contained resources.
:raises: TypeError on anything but dict or list of dicts :raises: FHIRValidationError if instantiation fails :param dict jsonobj: Decoded JSON dictionary (or list thereof) :param FHIRElement owner: The owning parent :returns: An instance or a list of instances created from JSON data