canvas 0.34.1__py3-none-any.whl → 0.35.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of canvas might be problematic. Click here for more details.
- {canvas-0.34.1.dist-info → canvas-0.35.0.dist-info}/METADATA +1 -1
- {canvas-0.34.1.dist-info → canvas-0.35.0.dist-info}/RECORD +58 -50
- canvas_generated/messages/effects_pb2.py +4 -4
- canvas_generated/messages/effects_pb2.pyi +22 -2
- canvas_generated/messages/events_pb2.py +2 -2
- canvas_generated/messages/events_pb2.pyi +30 -0
- canvas_sdk/base.py +56 -0
- canvas_sdk/commands/base.py +22 -46
- canvas_sdk/commands/commands/adjust_prescription.py +0 -10
- canvas_sdk/commands/commands/allergy.py +0 -1
- canvas_sdk/commands/commands/assess.py +2 -2
- canvas_sdk/commands/commands/change_medication.py +58 -0
- canvas_sdk/commands/commands/close_goal.py +0 -1
- canvas_sdk/commands/commands/diagnose.py +0 -1
- canvas_sdk/commands/commands/exam.py +0 -1
- canvas_sdk/commands/commands/family_history.py +0 -1
- canvas_sdk/commands/commands/follow_up.py +4 -2
- canvas_sdk/commands/commands/goal.py +8 -7
- canvas_sdk/commands/commands/history_present_illness.py +0 -1
- canvas_sdk/commands/commands/imaging_order.py +9 -8
- canvas_sdk/commands/commands/instruct.py +2 -2
- canvas_sdk/commands/commands/lab_order.py +10 -9
- canvas_sdk/commands/commands/medical_history.py +0 -1
- canvas_sdk/commands/commands/medication_statement.py +0 -1
- canvas_sdk/commands/commands/past_surgical_history.py +0 -1
- canvas_sdk/commands/commands/perform.py +3 -2
- canvas_sdk/commands/commands/plan.py +0 -1
- canvas_sdk/commands/commands/prescribe.py +0 -9
- canvas_sdk/commands/commands/refer.py +10 -10
- canvas_sdk/commands/commands/refill.py +0 -9
- canvas_sdk/commands/commands/remove_allergy.py +0 -1
- canvas_sdk/commands/commands/resolve_condition.py +3 -2
- canvas_sdk/commands/commands/review_of_systems.py +0 -1
- canvas_sdk/commands/commands/stop_medication.py +0 -1
- canvas_sdk/commands/commands/structured_assessment.py +0 -1
- canvas_sdk/commands/commands/task.py +0 -4
- canvas_sdk/commands/commands/update_diagnosis.py +8 -6
- canvas_sdk/commands/commands/update_goal.py +0 -1
- canvas_sdk/commands/commands/vitals.py +0 -1
- canvas_sdk/effects/note/__init__.py +10 -0
- canvas_sdk/effects/note/appointment.py +148 -0
- canvas_sdk/effects/note/base.py +129 -0
- canvas_sdk/effects/note/note.py +79 -0
- canvas_sdk/effects/patient/__init__.py +3 -0
- canvas_sdk/effects/patient/base.py +123 -0
- canvas_sdk/utils/http.py +7 -26
- canvas_sdk/utils/metrics.py +192 -0
- canvas_sdk/utils/plugins.py +24 -0
- canvas_sdk/v1/data/__init__.py +4 -0
- canvas_sdk/v1/data/message.py +82 -0
- plugin_runner/load_all_plugins.py +0 -3
- plugin_runner/plugin_runner.py +107 -114
- plugin_runner/sandbox.py +3 -0
- protobufs/canvas_generated/messages/effects.proto +13 -0
- protobufs/canvas_generated/messages/events.proto +16 -0
- settings.py +4 -0
- canvas_sdk/utils/stats.py +0 -74
- {canvas-0.34.1.dist-info → canvas-0.35.0.dist-info}/WHEEL +0 -0
- {canvas-0.34.1.dist-info → canvas-0.35.0.dist-info}/entry_points.txt +0 -0
settings.py
CHANGED
|
@@ -14,6 +14,7 @@ ENV = os.getenv("ENV", "development")
|
|
|
14
14
|
IS_PRODUCTION = ENV == "production"
|
|
15
15
|
IS_PRODUCTION_CUSTOMER = env_to_bool("IS_PRODUCTION_CUSTOMER", IS_PRODUCTION)
|
|
16
16
|
IS_TESTING = env_to_bool("IS_TESTING", "pytest" in sys.argv[0] or sys.argv[0] == "-c")
|
|
17
|
+
IS_SCRIPT = env_to_bool("IS_SCRIPT", "plugin_runner.py" not in sys.argv[0])
|
|
17
18
|
CUSTOMER_IDENTIFIER = os.getenv("CUSTOMER_IDENTIFIER", "local")
|
|
18
19
|
APP_NAME = os.getenv("APP_NAME")
|
|
19
20
|
|
|
@@ -24,6 +25,9 @@ INTEGRATION_TEST_CLIENT_SECRET = os.getenv("INTEGRATION_TEST_CLIENT_SECRET")
|
|
|
24
25
|
GRAPHQL_ENDPOINT = os.getenv("GRAPHQL_ENDPOINT", "http://localhost:8000/plugins-graphql")
|
|
25
26
|
REDIS_ENDPOINT = os.getenv("REDIS_ENDPOINT", f"redis://{APP_NAME}-redis:6379")
|
|
26
27
|
|
|
28
|
+
|
|
29
|
+
METRICS_ENABLED = env_to_bool("PLUGINS_METRICS_ENABLED", not IS_SCRIPT)
|
|
30
|
+
|
|
27
31
|
INSTALLED_APPS = [
|
|
28
32
|
"canvas_sdk.v1",
|
|
29
33
|
]
|
canvas_sdk/utils/stats.py
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
from datetime import timedelta
|
|
2
|
-
from time import time
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
from statsd.defaults.env import statsd as default_statsd_client
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def get_duration_ms(start_time: float) -> int:
|
|
9
|
-
"""Get the duration in milliseconds since the given start time."""
|
|
10
|
-
return int((time() - start_time) * 1000)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
LINE_PROTOCOL_TRANSLATION = str.maketrans(
|
|
14
|
-
{
|
|
15
|
-
",": r"\,",
|
|
16
|
-
"=": r"\=",
|
|
17
|
-
" ": r"\ ",
|
|
18
|
-
":": r"__",
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def tags_to_line_protocol(tags: dict[str, Any]) -> str:
|
|
24
|
-
"""Generate a tags string compatible with the InfluxDB line protocol.
|
|
25
|
-
|
|
26
|
-
See: https://docs.influxdata.com/influxdb/v1.1/write_protocols/line_protocol_tutorial/
|
|
27
|
-
"""
|
|
28
|
-
return ",".join(
|
|
29
|
-
f"{tag_name}={str(tag_value).translate(LINE_PROTOCOL_TRANSLATION)}"
|
|
30
|
-
for tag_name, tag_value in tags.items()
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
STATS_ENABLED = True
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class StatsDClientProxy:
|
|
38
|
-
"""Proxy for a StatsD client."""
|
|
39
|
-
|
|
40
|
-
def __init__(self) -> None:
|
|
41
|
-
self.client = default_statsd_client
|
|
42
|
-
|
|
43
|
-
def gauge(self, metric_name: str, value: float, tags: dict[str, str]) -> None:
|
|
44
|
-
"""Sends a gauge metric to StatsD with properly formatted tags.
|
|
45
|
-
|
|
46
|
-
Args:
|
|
47
|
-
metric_name (str): The name of the metric.
|
|
48
|
-
value (float): The value to report.
|
|
49
|
-
tags (dict[str, str]): Dictionary of tags to attach to the metric.
|
|
50
|
-
"""
|
|
51
|
-
if not STATS_ENABLED:
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
statsd_tags = tags_to_line_protocol(tags)
|
|
55
|
-
self.client.gauge(f"{metric_name},{statsd_tags}", value)
|
|
56
|
-
|
|
57
|
-
def timing(self, metric_name: str, delta: float | timedelta, tags: dict[str, str]) -> None:
|
|
58
|
-
"""Sends a timing metric to StatsD with properly formatted tags.
|
|
59
|
-
|
|
60
|
-
Args:
|
|
61
|
-
metric_name (str): The name of the metric.
|
|
62
|
-
delta (float | timedelta): The value to report.
|
|
63
|
-
tags (dict[str, str]): Dictionary of tags to attach to the metric.
|
|
64
|
-
"""
|
|
65
|
-
if not STATS_ENABLED:
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
statsd_tags = tags_to_line_protocol(tags)
|
|
69
|
-
self.client.timing(f"{metric_name},{statsd_tags}", delta)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
statsd_client = StatsDClientProxy()
|
|
73
|
-
|
|
74
|
-
__exports__ = ()
|
|
File without changes
|
|
File without changes
|