Mixins¶
-
class
fhirbug.models.mixins.
FhirAbstractBaseMixin
[source]¶ Adds additional fhir related functionality to all models. Most importantly, it provides the
.to_fhir()
method that handles the transformation from an SQLAlchemy model to a Fhir resource. User-defined models subclassing this class must implement aFhirMap
nested class.-
classmethod
from_resource
(resource, query=None)[source]¶ Creates and saves a new row from a Fhir.Resource object
-
get_params_dict
(resource, elements=None)[source]¶ Return a dictionary of all valid values this instance can provide for a resource of the type
resource
.Parameters: resource – The class of the resource we wish to create Returns: A dictionary to be used as an argument to initialize a resource instance
-
get_rev_includes
(query)[source]¶ Read the _revincludes that were asked for in the request, query the database to retrieve them and add them to the initial resources
contained
field.Parameters: query ( fhirbug.server.requestparser.FhirRequestQuery
) – AFhirRequestQuery
object holding the current request.Returns: None
-
hide_attributes
(attribute_names=[])[source]¶ Accepts a list of attribute names and marks them as hidden, meaning they will not be included in json representations of this item. Subsequent calls replace the previous attribute list.
Parameters: attribute_names (list) – A list of Fhir attribute names to set as hidden
-
protect_attributes
(attribute_names=[])[source]¶ Accepts a list of attribute names and protects them for the duration of the current operation. Protected attributes can not be changed when creating or editing a resource. Subsequent calls replace the previous attribute list.
Parameters: attribute_names (list) – A list of Fhir attribute names to set as protected
-
classmethod
-
class
fhirbug.models.mixins.
FhirBaseModelMixin
[source]¶ -
Fhir
¶ Wrapper property that initializes an instance of FhirMap.
-
classmethod
get_searcher
(query_string)[source]¶ Return the first search function that matches the provided query string
Parameters: query_string (string) – A query string that is matched against registered field names or regular expressions by existing searchers Returns: function
-
-
fhirbug.models.mixins.
get_pagination_info
(query)[source]¶ Reads item count and offset from the provided
FhirRequestQuery
instance, or the application settings. It makes count obay MAX_BUNDLE_SIZE and calculates which page we are on.Parameters: query (FhirRequestQuery) – The FhirRequestQuery object for this request. Returns: (page, count, prev_offset, next_offset) The number of the page we are on, how many items we should show, the offset of the next page and the offset of the previous page. Return type: (int, int, int, int)