module filters

Global Variables

  • date_format_map
  • strf_map
  • all_filters

function str_arg

str_arg(val: Any, default: str = '') → str

Return val as an str or default if val is none or empty


function mapping_filter

mapping_filter(_filter: Callable[, Any]) → Callable[, Any]

Raise a FilterValueError if the left value is not mapping-like.


function to_json_string

to_json_string(obj: Any) → str

Serialize the given object to json


function to_array

to_array(obj: Any) → List[Any]

Convert the given object to a list


function match

match(data: str, regex: Any) → List[str]

Find all / match the regex in data


function gzip

gzip(data: str) → str

Compress the string using zlib base64 encoding the output


function sha1_hash

sha1_hash(data: str) → str

Compute the sha1 hash for the string


function add_hyphens_date

add_hyphens_date(dtm: str) → str

Convert the hl7 v2 dtm to a FHIR hl7 v3 dtm with day precision


function format_as_date_time

format_as_date_time(dtm: str) → str

Convert the hl7 v2 dtm to a FHIR hl7 v3 dtm


function now

now(_: str) → str

The current date time in UTC as a FHIR hl7 v3 dtm


function date

date(input: Any, format: Any, environment: Environment) → str

date Format the given input date with the provided format

Compatibility: This filter losely attempts to bridge templates migrating from DotLiquid that use the C# date format codes. This only works for strings that can be parsed to a datetime. The special strings such as today or int values are suppported. Not all possible C# format codes are supported

Args:

  • input (Any): The input date to format
  • format (Any): The format string
  • environment (Environment): The rendering environment

Returns:

  • str: the formatted date

function generate_uuid

generate_uuid(data: str) → str

Generate a UUID using the sha256 hash of the given data string


function get_property

get_property(
    code: str,
    mapping_key: Any,
    property_name: Any = None,
    context: Context
) → str

get_property Get the codified property mapping from the code_mapping global in the supplied context. mapping_key indicates the type of mapping. Mappings may be provided for specific codes and or at a default / global level. Mappings for the code are prefered over the default mappings. In the event a mapping is not available, the original code will be used when property_name is code or display, otherwise, ""

Args:

  • code (str): the codified value
  • mapping_key (Any): the type of mappings
  • property_name (Any): the mapped property to retrieve. Defaults to code.
  • context (Context): the rendering context

Returns:

  • str: the property or ""

function get_first_ccda_sections_by_template_id

get_first_ccda_sections_by_template_id(
    msg: Mapping,
    template_ids: Any
) → Mapping

get_first_ccda_sections_by_template_id Get the sections that match the given template_ids. All matches will be returned

Key/value pairs will be returned where the key is the template_id that matched and the value is the corresponding section

Args:

  • msg (Mapping[Any, Any]): the msg / ccda document to search
  • template_ids (Any): the template_id(s) delimited by | to search the document with

Returns:

  • Mapping[Any, Any]: the sections, otherwise, empty

function get_ccda_section_by_template_id

get_ccda_section_by_template_id(
    msg: Mapping[Any, Any],
    template_id: Any,
    *template_ids: Any
) → Mapping[Any, Any]

get_ccda_section_by_template_id Get the section that matches one of the given template_ids. The first section found will be returned

Args:

  • msg (Mapping[Any, Any]): the msg / ccda document to search
  • template_id (Any): the template_id(s) to search the document with

Returns:

  • Mapping[Any, Any]: the section, otherwise, empty

function batch_render

batch_render(
    batch: Sequence[Any],
    template_name: Any,
    arg_name: Any,
    context: Context
) → str

batch_render Render the given batch data with the supplied template passing the data in the batch as the specified arg / parameter name to the template

This function is similar to {% render template_name for batch as arg_name %}

See https://shopify.dev/docs/api/liquid/tags/render for more information

Args:

  • batch (Sequence): the array to render
  • template_name (Any): the template to use
  • arg_name (Any): the argument / parameter name
  • context (Context): the rendering context

Returns:

  • str: the rendered output

function transform_narrative

transform_narrative(text: str, context: Context) → Mapping

transform_narrative transform the given narrative text

Args:

  • text (str): the text to transform
  • context (Context): the rendering context

Returns:

  • str: the transformed output or an empty dict

function register_filters

register_filters(
    env: Environment,
    filters: Iterable[Tuple[str, Callable[, Any]]],
    replace: bool = False
) → None

register_filters Registers the given filters with the supplied Environment. Will not replace a filter with the same name already registered with the environment.

Args:

  • env (Environment): the environment
  • filters (Iterable[tuple[str, FilterT]]): the filters to register
  • replace (bool, optional): whether to replace existing filters. Defaults to False

This file was automatically generated via lazydocs.