canvas 0.33.0__py3-none-any.whl → 0.34.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.33.0.dist-info → canvas-0.34.0.dist-info}/METADATA +2 -1
- canvas-0.34.0.dist-info/RECORD +272 -0
- canvas_sdk/__init__.py +3 -0
- canvas_sdk/commands/__init__.py +1 -1
- canvas_sdk/commands/base.py +3 -0
- canvas_sdk/commands/commands/__init__.py +1 -0
- canvas_sdk/commands/commands/adjust_prescription.py +3 -0
- canvas_sdk/commands/commands/allergy.py +7 -0
- canvas_sdk/commands/commands/assess.py +2 -0
- canvas_sdk/commands/commands/close_goal.py +3 -0
- canvas_sdk/commands/commands/diagnose.py +3 -0
- canvas_sdk/commands/commands/exam.py +3 -0
- canvas_sdk/commands/commands/family_history.py +3 -0
- canvas_sdk/commands/commands/follow_up.py +3 -0
- canvas_sdk/commands/commands/goal.py +3 -0
- canvas_sdk/commands/commands/history_present_illness.py +3 -0
- canvas_sdk/commands/commands/imaging_order.py +3 -0
- canvas_sdk/commands/commands/instruct.py +3 -0
- canvas_sdk/commands/commands/lab_order.py +3 -0
- canvas_sdk/commands/commands/medical_history.py +3 -0
- canvas_sdk/commands/commands/medication_statement.py +2 -0
- canvas_sdk/commands/commands/past_surgical_history.py +3 -0
- canvas_sdk/commands/commands/perform.py +3 -0
- canvas_sdk/commands/commands/plan.py +3 -0
- canvas_sdk/commands/commands/prescribe.py +8 -0
- canvas_sdk/commands/commands/questionnaire/__init__.py +3 -13
- canvas_sdk/commands/commands/questionnaire/question.py +10 -0
- canvas_sdk/commands/commands/reason_for_visit.py +3 -0
- canvas_sdk/commands/commands/refer.py +3 -0
- canvas_sdk/commands/commands/refill.py +3 -0
- canvas_sdk/commands/commands/remove_allergy.py +3 -0
- canvas_sdk/commands/commands/resolve_condition.py +3 -0
- canvas_sdk/commands/commands/review_of_systems.py +3 -0
- canvas_sdk/commands/commands/stop_medication.py +3 -0
- canvas_sdk/commands/commands/structured_assessment.py +3 -0
- canvas_sdk/commands/commands/task.py +7 -0
- canvas_sdk/commands/commands/update_diagnosis.py +3 -0
- canvas_sdk/commands/commands/update_goal.py +3 -0
- canvas_sdk/commands/commands/vitals.py +3 -0
- canvas_sdk/commands/constants.py +8 -0
- canvas_sdk/effects/__init__.py +1 -1
- canvas_sdk/effects/banner_alert/__init__.py +1 -1
- canvas_sdk/effects/banner_alert/add_banner_alert.py +3 -0
- canvas_sdk/effects/banner_alert/remove_banner_alert.py +3 -0
- canvas_sdk/effects/base.py +7 -0
- canvas_sdk/effects/billing_line_item/__init__.py +5 -1
- canvas_sdk/effects/billing_line_item/add_billing_line_item.py +3 -0
- canvas_sdk/effects/billing_line_item/remove_billing_line_item.py +3 -0
- canvas_sdk/effects/billing_line_item/update_billing_line_item.py +3 -0
- canvas_sdk/effects/launch_modal.py +3 -0
- canvas_sdk/effects/patient_chart_summary_configuration.py +3 -0
- canvas_sdk/effects/patient_portal/__init__.py +1 -0
- canvas_sdk/effects/patient_portal/application_configuration.py +3 -0
- canvas_sdk/effects/patient_portal/form_result.py +3 -0
- canvas_sdk/effects/patient_portal_menu_configuration.py +3 -0
- canvas_sdk/effects/patient_profile_configuration.py +5 -1
- canvas_sdk/effects/protocol_card/__init__.py +1 -1
- canvas_sdk/effects/protocol_card/protocol_card.py +6 -0
- canvas_sdk/effects/questionnaire_result.py +3 -0
- canvas_sdk/effects/send_invite.py +3 -0
- canvas_sdk/effects/show_button.py +3 -0
- canvas_sdk/effects/simple_api.py +9 -0
- canvas_sdk/effects/surescripts/__init__.py +2 -2
- canvas_sdk/effects/surescripts/surescripts_messages.py +7 -0
- canvas_sdk/effects/task/__init__.py +6 -1
- canvas_sdk/effects/task/task.py +8 -0
- canvas_sdk/effects/update_user.py +3 -0
- canvas_sdk/effects/widgets/__init__.py +1 -1
- canvas_sdk/effects/widgets/portal_widget.py +3 -0
- canvas_sdk/events/__init__.py +6 -1
- canvas_sdk/events/base.py +3 -0
- canvas_sdk/handlers/__init__.py +1 -1
- canvas_sdk/handlers/action_button.py +6 -0
- canvas_sdk/handlers/application.py +3 -0
- canvas_sdk/handlers/base.py +3 -0
- canvas_sdk/handlers/cron_task.py +3 -0
- canvas_sdk/handlers/simple_api/__init__.py +3 -2
- canvas_sdk/handlers/simple_api/api.py +26 -1
- canvas_sdk/handlers/simple_api/exceptions.py +10 -0
- canvas_sdk/handlers/simple_api/security.py +21 -5
- canvas_sdk/handlers/simple_api/tools.py +9 -0
- canvas_sdk/protocols/__init__.py +1 -1
- canvas_sdk/protocols/base.py +3 -0
- canvas_sdk/protocols/clinical_quality_measure.py +6 -1
- canvas_sdk/protocols/timeframe.py +3 -0
- canvas_sdk/questionnaires/__init__.py +1 -1
- canvas_sdk/questionnaires/utils.py +7 -0
- canvas_sdk/templates/__init__.py +1 -1
- canvas_sdk/templates/utils.py +3 -0
- canvas_sdk/utils/__init__.py +1 -1
- canvas_sdk/utils/http.py +94 -35
- canvas_sdk/utils/plugins.py +4 -0
- canvas_sdk/utils/stats.py +11 -0
- canvas_sdk/v1/__init__.py +1 -0
- canvas_sdk/v1/apps.py +3 -0
- canvas_sdk/v1/data/__init__.py +2 -2
- canvas_sdk/v1/data/allergy_intolerance.py +3 -0
- canvas_sdk/v1/data/appointment.py +7 -0
- canvas_sdk/v1/data/assessment.py +3 -0
- canvas_sdk/v1/data/banner_alert.py +3 -0
- canvas_sdk/v1/data/base.py +3 -0
- canvas_sdk/v1/data/billing.py +7 -0
- canvas_sdk/v1/data/care_team.py +7 -0
- canvas_sdk/v1/data/command.py +3 -0
- canvas_sdk/v1/data/common.py +18 -0
- canvas_sdk/v1/data/condition.py +7 -0
- canvas_sdk/v1/data/coverage.py +14 -0
- canvas_sdk/v1/data/detected_issue.py +3 -0
- canvas_sdk/v1/data/device.py +3 -0
- canvas_sdk/v1/data/imaging.py +7 -0
- canvas_sdk/v1/data/lab.py +16 -0
- canvas_sdk/v1/data/medication.py +3 -0
- canvas_sdk/v1/data/note.py +9 -0
- canvas_sdk/v1/data/observation.py +9 -0
- canvas_sdk/v1/data/organization.py +3 -0
- canvas_sdk/v1/data/patient.py +18 -2
- canvas_sdk/v1/data/practicelocation.py +7 -0
- canvas_sdk/v1/data/protocol_override.py +7 -0
- canvas_sdk/v1/data/questionnaire.py +16 -3
- canvas_sdk/v1/data/reason_for_visit.py +3 -0
- canvas_sdk/v1/data/staff.py +3 -0
- canvas_sdk/v1/data/task.py +12 -0
- canvas_sdk/v1/data/team.py +8 -1
- canvas_sdk/v1/data/user.py +3 -0
- canvas_sdk/v1/models.py +2 -0
- canvas_sdk/value_set/__init__.py +1 -0
- canvas_sdk/value_set/_utilities.py +16 -0
- canvas_sdk/value_set/custom.py +4 -0
- canvas_sdk/value_set/hcc2018.py +3 -0
- canvas_sdk/value_set/v2022/__init__.py +1 -0
- canvas_sdk/value_set/v2022/adverse_event.py +3 -0
- canvas_sdk/value_set/v2022/allergy.py +5 -0
- canvas_sdk/value_set/v2022/assessment.py +5 -0
- canvas_sdk/value_set/v2022/communication.py +5 -0
- canvas_sdk/value_set/v2022/condition.py +5 -0
- canvas_sdk/value_set/v2022/device.py +5 -0
- canvas_sdk/value_set/v2022/diagnostic_study.py +5 -0
- canvas_sdk/value_set/v2022/encounter.py +5 -0
- canvas_sdk/value_set/v2022/immunization.py +5 -0
- canvas_sdk/value_set/v2022/individual_characteristic.py +5 -0
- canvas_sdk/value_set/v2022/intervention.py +5 -0
- canvas_sdk/value_set/v2022/laboratory_test.py +5 -0
- canvas_sdk/value_set/v2022/medication.py +5 -0
- canvas_sdk/value_set/v2022/physical_exam.py +5 -0
- canvas_sdk/value_set/v2022/procedure.py +5 -0
- canvas_sdk/value_set/v2022/symptom.py +3 -0
- canvas_sdk/value_set/value_set.py +9 -0
- canvas_sdk/views/__init__.py +1 -0
- logger/__init__.py +2 -0
- logger/logger.py +3 -0
- plugin_runner/aws_headers.py +1 -1
- plugin_runner/load_all_plugins.py +202 -0
- plugin_runner/plugin_runner.py +21 -24
- plugin_runner/sandbox.py +497 -115
- settings.py +5 -2
- canvas-0.33.0.dist-info/RECORD +0 -366
- canvas_cli/apps/auth/tests.py +0 -155
- canvas_cli/apps/plugin/tests.py +0 -85
- canvas_cli/conftest.py +0 -28
- canvas_cli/tests.py +0 -217
- canvas_cli/utils/context/tests.py +0 -131
- canvas_cli/utils/print/tests.py +0 -69
- canvas_cli/utils/urls/tests.py +0 -12
- canvas_cli/utils/validators/tests.py +0 -37
- canvas_sdk/commands/tests/protocol/__init__.py +0 -0
- canvas_sdk/commands/tests/protocol/tests.py +0 -83
- canvas_sdk/commands/tests/schema/__init__.py +0 -0
- canvas_sdk/commands/tests/schema/tests.py +0 -108
- canvas_sdk/commands/tests/test_base_command.py +0 -81
- canvas_sdk/commands/tests/test_utils.py +0 -375
- canvas_sdk/commands/tests/unit/__init__.py +0 -0
- canvas_sdk/commands/tests/unit/tests.py +0 -278
- canvas_sdk/effects/banner_alert/tests.py +0 -288
- canvas_sdk/effects/protocol_card/tests.py +0 -191
- canvas_sdk/questionnaires/tests/__init__.py +0 -0
- canvas_sdk/questionnaires/tests/test_utils.py +0 -74
- canvas_sdk/templates/tests/__init__.py +0 -0
- canvas_sdk/templates/tests/test_utils.py +0 -43
- canvas_sdk/tests/__init__.py +0 -0
- canvas_sdk/tests/handlers/__init__.py +0 -0
- canvas_sdk/tests/handlers/test_simple_api.py +0 -1167
- canvas_sdk/utils/tests.py +0 -72
- canvas_sdk/value_set/tests/test_value_sets.py +0 -72
- plugin_runner/tests/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/example_plugin/CANVAS_MANIFEST.json +0 -29
- plugin_runner/tests/fixtures/plugins/example_plugin/README.md +0 -12
- plugin_runner/tests/fixtures/plugins/example_plugin/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/example_plugin/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/example_plugin/protocols/my_protocol.py +0 -18
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/CANVAS_MANIFEST.json +0 -38
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/README.md +0 -11
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/protocols/my_protocol.py +0 -33
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/templates/__init__.py +0 -3
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/templates/base.py +0 -6
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/utils/__init__.py +0 -5
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/utils/base.py +0 -4
- plugin_runner/tests/fixtures/plugins/test_load_questionnaire/CANVAS_MANIFEST.json +0 -52
- plugin_runner/tests/fixtures/plugins/test_load_questionnaire/README.md +0 -11
- plugin_runner/tests/fixtures/plugins/test_load_questionnaire/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_load_questionnaire/protocols/my_protocol.py +0 -39
- plugin_runner/tests/fixtures/plugins/test_load_questionnaire/questionnaires/example_questionnaire.yml +0 -61
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/CANVAS_MANIFEST.json +0 -29
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/README.md +0 -12
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/other_module/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/other_module/base.py +0 -10
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/protocols/my_protocol.py +0 -18
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/CANVAS_MANIFEST.json +0 -29
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/README.md +0 -12
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/other_module/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/other_module/base.py +0 -10
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/protocols/my_protocol.py +0 -18
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/CANVAS_MANIFEST.json +0 -29
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/README.md +0 -12
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/other_module/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/other_module/base.py +0 -3
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/protocols/my_protocol.py +0 -18
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/CANVAS_MANIFEST.json +0 -29
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/README.md +0 -12
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/other_module/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/other_module/base.py +0 -6
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/protocols/my_protocol.py +0 -18
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/CANVAS_MANIFEST.json +0 -29
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/README.md +0 -12
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/other_module/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/other_module/base.py +0 -8
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/protocols/my_protocol.py +0 -18
- plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/CANVAS_MANIFEST.json +0 -29
- plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/README.md +0 -12
- plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/other_module/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/other_module/base.py +0 -3
- plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/protocols/my_protocol.py +0 -18
- plugin_runner/tests/fixtures/plugins/test_render_template/CANVAS_MANIFEST.json +0 -47
- plugin_runner/tests/fixtures/plugins/test_render_template/README.md +0 -11
- plugin_runner/tests/fixtures/plugins/test_render_template/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_render_template/protocols/my_protocol.py +0 -43
- plugin_runner/tests/fixtures/plugins/test_render_template/templates/template.html +0 -10
- plugin_runner/tests/fixtures/plugins/test_simple_api/CANVAS_MANIFEST.json +0 -47
- plugin_runner/tests/fixtures/plugins/test_simple_api/README.md +0 -11
- plugin_runner/tests/fixtures/plugins/test_simple_api/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_simple_api/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_simple_api/protocols/my_protocol.py +0 -43
- plugin_runner/tests/test_application.py +0 -65
- plugin_runner/tests/test_plugin_installer.py +0 -127
- plugin_runner/tests/test_plugin_runner.py +0 -388
- plugin_runner/tests/test_sandbox.py +0 -137
- {canvas-0.33.0.dist-info → canvas-0.34.0.dist-info}/WHEEL +0 -0
- {canvas-0.33.0.dist-info → canvas-0.34.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
from pydantic import ValidationError
|
|
5
|
-
|
|
6
|
-
from canvas_sdk.commands import (
|
|
7
|
-
AssessCommand,
|
|
8
|
-
DiagnoseCommand,
|
|
9
|
-
GoalCommand,
|
|
10
|
-
HistoryOfPresentIllnessCommand,
|
|
11
|
-
MedicationStatementCommand,
|
|
12
|
-
PlanCommand,
|
|
13
|
-
PrescribeCommand,
|
|
14
|
-
QuestionnaireCommand,
|
|
15
|
-
ReasonForVisitCommand,
|
|
16
|
-
StopMedicationCommand,
|
|
17
|
-
UpdateGoalCommand,
|
|
18
|
-
)
|
|
19
|
-
from canvas_sdk.commands.base import _BaseCommand
|
|
20
|
-
from canvas_sdk.effects.protocol_card import ProtocolCard, Recommendation
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def test_apply_method_succeeds_with_patient_id_and_key() -> None:
|
|
24
|
-
"""Test that the apply method succeeds with all required fields."""
|
|
25
|
-
p = ProtocolCard(patient_id="uuid", key="something-unique")
|
|
26
|
-
applied = p.apply()
|
|
27
|
-
assert (
|
|
28
|
-
applied.payload
|
|
29
|
-
== '{"patient": "uuid", "patient_filter": null, "key": "something-unique", "data": {"title": "", "narrative": "", "recommendations": [], "status": "due", "feedback_enabled": false, "due_in": -1}}'
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def test_apply_method_raises_error_without_patient_id_and_key() -> None:
|
|
34
|
-
"""Test that the apply method raises an error when missing required fields."""
|
|
35
|
-
p = ProtocolCard()
|
|
36
|
-
|
|
37
|
-
with pytest.raises(ValidationError) as e:
|
|
38
|
-
p.apply()
|
|
39
|
-
err_msg = repr(e.value)
|
|
40
|
-
|
|
41
|
-
assert "2 validation errors for ProtocolCard" in err_msg
|
|
42
|
-
assert (
|
|
43
|
-
"Field 'patient_id' or 'patient_filter' is required to apply a ProtocolCard [type=missing, input_value=None, input_type=NoneType]"
|
|
44
|
-
in err_msg
|
|
45
|
-
)
|
|
46
|
-
assert (
|
|
47
|
-
"Field 'key' is required to apply a ProtocolCard [type=missing, input_value=None, input_type=NoneType]"
|
|
48
|
-
in err_msg
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
@pytest.mark.parametrize(
|
|
53
|
-
"init_params,rec1_params,rec2_params",
|
|
54
|
-
[
|
|
55
|
-
(
|
|
56
|
-
{
|
|
57
|
-
"key": "link_rec",
|
|
58
|
-
"patient_id": "patientuuid",
|
|
59
|
-
"title": "This is a test!",
|
|
60
|
-
"narrative": "we should only expect a link and a button",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"title": "this is a link",
|
|
64
|
-
"button": "click this",
|
|
65
|
-
"href": "https://canvasmedical.com/",
|
|
66
|
-
},
|
|
67
|
-
{"title": "second link", "button": "don't click this", "href": "https://google.com/"},
|
|
68
|
-
),
|
|
69
|
-
(
|
|
70
|
-
{
|
|
71
|
-
"key": "command_rec",
|
|
72
|
-
"patient_id": "patientuuid",
|
|
73
|
-
"title": "This is a test for command recommendations!",
|
|
74
|
-
"narrative": "we should only expect buttons to insert commands",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"title": "this is a command",
|
|
78
|
-
"button": "click this",
|
|
79
|
-
"command": "updategoal",
|
|
80
|
-
"context": {"progress": "none"},
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"title": "another command",
|
|
84
|
-
"button": "hypertension",
|
|
85
|
-
"command": "diagnose",
|
|
86
|
-
"context": {"background": "stuff"},
|
|
87
|
-
},
|
|
88
|
-
),
|
|
89
|
-
(
|
|
90
|
-
{
|
|
91
|
-
"patient_id": "patientuuid",
|
|
92
|
-
"key": "command_rec_with_coding_filter",
|
|
93
|
-
"title": "This is a test for command recommendations with coding filters!",
|
|
94
|
-
"narrative": "we should only expect buttons to insert commands",
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"title": "hypertension",
|
|
98
|
-
"button": "diagnose",
|
|
99
|
-
"command": "diagnose",
|
|
100
|
-
"context": {"background": "hey", "icd10_code": "I10"},
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"title": "fake medication",
|
|
104
|
-
"button": "prescribe",
|
|
105
|
-
"command": "prescribe",
|
|
106
|
-
"context": {"sig": "1pobid"},
|
|
107
|
-
},
|
|
108
|
-
),
|
|
109
|
-
],
|
|
110
|
-
)
|
|
111
|
-
def test_add_recommendations(
|
|
112
|
-
init_params: dict[Any, Any], rec1_params: dict[Any, Any], rec2_params: dict[Any, Any]
|
|
113
|
-
) -> None:
|
|
114
|
-
"""Test that the add_recommendation method adds recommendations to the ProtocolCard."""
|
|
115
|
-
p = ProtocolCard(**init_params)
|
|
116
|
-
p.add_recommendation(**rec1_params)
|
|
117
|
-
p.recommendations.append(Recommendation(**rec2_params))
|
|
118
|
-
assert p.values == {
|
|
119
|
-
"title": init_params["title"],
|
|
120
|
-
"narrative": init_params["narrative"],
|
|
121
|
-
"recommendations": [
|
|
122
|
-
{
|
|
123
|
-
"title": rec1_params.get("title"),
|
|
124
|
-
"button": rec1_params.get("button"),
|
|
125
|
-
"href": rec1_params.get("href"),
|
|
126
|
-
"command": {"type": rec1_params["command"]} if "command" in rec1_params else {},
|
|
127
|
-
"context": rec1_params.get("context", {}),
|
|
128
|
-
"key": 0,
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"title": rec2_params.get("title"),
|
|
132
|
-
"button": rec2_params.get("button"),
|
|
133
|
-
"href": rec2_params.get("href"),
|
|
134
|
-
"command": {"type": rec2_params["command"]} if "command" in rec2_params else {},
|
|
135
|
-
"context": rec2_params.get("context", {}),
|
|
136
|
-
"key": 1,
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
"status": "due",
|
|
140
|
-
"due_in": -1,
|
|
141
|
-
"feedback_enabled": False,
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
@pytest.mark.parametrize(
|
|
146
|
-
"Command,init_params",
|
|
147
|
-
[
|
|
148
|
-
(AssessCommand, {}),
|
|
149
|
-
(DiagnoseCommand, {"icd10_code": "I10"}),
|
|
150
|
-
(GoalCommand, {}),
|
|
151
|
-
(HistoryOfPresentIllnessCommand, {}),
|
|
152
|
-
(MedicationStatementCommand, {"fdb_code": "fakeroo"}),
|
|
153
|
-
(PlanCommand, {}),
|
|
154
|
-
(PrescribeCommand, {"fdb_code": "fake"}),
|
|
155
|
-
(QuestionnaireCommand, {}),
|
|
156
|
-
(ReasonForVisitCommand, {}),
|
|
157
|
-
(StopMedicationCommand, {}),
|
|
158
|
-
(UpdateGoalCommand, {}),
|
|
159
|
-
],
|
|
160
|
-
)
|
|
161
|
-
def test_add_recommendations_from_commands(
|
|
162
|
-
Command: type[_BaseCommand], init_params: dict[str, str]
|
|
163
|
-
) -> None:
|
|
164
|
-
"""Test that the add_recommendation method adds recommendations from commands to the ProtocolCard."""
|
|
165
|
-
cmd = Command(**init_params)
|
|
166
|
-
p = ProtocolCard(patient_id="uuid", key="commands")
|
|
167
|
-
p.recommendations.append(cmd.recommend())
|
|
168
|
-
p.recommendations.append(cmd.recommend(title="hello", button="click"))
|
|
169
|
-
p.add_recommendation(
|
|
170
|
-
title="yeehaw", button="click here", command=cmd.Meta.key.lower(), context=init_params
|
|
171
|
-
)
|
|
172
|
-
|
|
173
|
-
rec1, rec2, rec3 = p.values["recommendations"]
|
|
174
|
-
assert rec1["title"] == ""
|
|
175
|
-
assert rec1["button"] == cmd.constantized_key().lower().replace("_", " ")
|
|
176
|
-
assert rec1["href"] is None
|
|
177
|
-
assert rec1["context"] == cmd.values
|
|
178
|
-
assert rec1["command"]["type"] == cmd.Meta.key.lower()
|
|
179
|
-
|
|
180
|
-
assert rec2["title"] == "hello"
|
|
181
|
-
assert rec2["button"] == "click"
|
|
182
|
-
assert rec2["href"] is None
|
|
183
|
-
assert rec2["context"] == cmd.values
|
|
184
|
-
assert rec2["command"]["type"] == cmd.Meta.key.lower()
|
|
185
|
-
|
|
186
|
-
assert rec3["title"] == "yeehaw"
|
|
187
|
-
assert rec3["button"] == "click here"
|
|
188
|
-
assert rec3["href"] is None
|
|
189
|
-
assert rec3["command"]["type"] == cmd.Meta.key.lower()
|
|
190
|
-
for k, v in init_params.items():
|
|
191
|
-
assert rec3["context"][k] == v
|
|
File without changes
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
import yaml
|
|
6
|
-
|
|
7
|
-
from canvas_sdk.effects import Effect
|
|
8
|
-
from canvas_sdk.events import Event, EventRequest, EventType
|
|
9
|
-
from canvas_sdk.questionnaires import questionnaire_from_yaml
|
|
10
|
-
from plugin_runner.plugin_runner import LOADED_PLUGINS
|
|
11
|
-
from settings import PLUGIN_DIRECTORY
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@pytest.mark.parametrize("install_test_plugin", ["test_load_questionnaire"], indirect=True)
|
|
15
|
-
def test_from_yaml_valid_questionnaire(install_test_plugin: Path, load_test_plugins: None) -> None:
|
|
16
|
-
"""Test that the from_yaml function loads a valid questionnaire."""
|
|
17
|
-
plugin = LOADED_PLUGINS[
|
|
18
|
-
"test_load_questionnaire:test_load_questionnaire.protocols.my_protocol:ValidQuestionnaire"
|
|
19
|
-
]
|
|
20
|
-
result: list[Effect] = plugin["class"](Event(EventRequest(type=EventType.UNKNOWN))).compute()
|
|
21
|
-
|
|
22
|
-
assert (
|
|
23
|
-
yaml.load(
|
|
24
|
-
(
|
|
25
|
-
Path(PLUGIN_DIRECTORY)
|
|
26
|
-
/ "test_load_questionnaire/questionnaires/example_questionnaire.yml"
|
|
27
|
-
)
|
|
28
|
-
.resolve()
|
|
29
|
-
.read_text(),
|
|
30
|
-
Loader=yaml.SafeLoader,
|
|
31
|
-
).items()
|
|
32
|
-
<= json.loads(result[0].payload).items()
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@pytest.mark.parametrize("install_test_plugin", ["test_load_questionnaire"], indirect=True)
|
|
37
|
-
def test_from_yaml_invalid_questionnaire(
|
|
38
|
-
install_test_plugin: Path, load_test_plugins: None
|
|
39
|
-
) -> None:
|
|
40
|
-
"""Test that the from_yaml function raises an error for invalid questionnaires."""
|
|
41
|
-
plugin = LOADED_PLUGINS[
|
|
42
|
-
"test_load_questionnaire:test_load_questionnaire.protocols.my_protocol:InvalidQuestionnaire"
|
|
43
|
-
]
|
|
44
|
-
with pytest.raises(FileNotFoundError):
|
|
45
|
-
plugin["class"](Event(EventRequest(type=EventType.UNKNOWN))).compute()
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@pytest.mark.parametrize("install_test_plugin", ["test_load_questionnaire"], indirect=True)
|
|
49
|
-
def test_from_yaml_forbidden_questionnaire(
|
|
50
|
-
install_test_plugin: Path, load_test_plugins: None
|
|
51
|
-
) -> None:
|
|
52
|
-
"""Test that the from_yaml function raises an error for a questionnaire outside plugin package."""
|
|
53
|
-
plugin = LOADED_PLUGINS[
|
|
54
|
-
"test_load_questionnaire:test_load_questionnaire.protocols.my_protocol:ForbiddenQuestionnaire"
|
|
55
|
-
]
|
|
56
|
-
with pytest.raises(PermissionError):
|
|
57
|
-
plugin["class"](Event(EventRequest(type=EventType.UNKNOWN))).compute()
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def test_from_yaml_non_plugin_caller() -> None:
|
|
61
|
-
"""Test that the from_yaml function returns None when called outside a plugin."""
|
|
62
|
-
assert questionnaire_from_yaml("questionnaires/example_questionnaire.yml") is None
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
@pytest.mark.parametrize("install_test_plugin", ["test_load_questionnaire"], indirect=True)
|
|
66
|
-
def test_from_yaml_sets_default_values(install_test_plugin: Path) -> None:
|
|
67
|
-
"""Test that the from_yaml function sets default values for properties."""
|
|
68
|
-
globals()["__is_plugin__"] = True
|
|
69
|
-
globals()["__name__"] = "test_load_questionnaire"
|
|
70
|
-
|
|
71
|
-
definition = questionnaire_from_yaml("questionnaires/example_questionnaire.yml")
|
|
72
|
-
|
|
73
|
-
assert definition is not None
|
|
74
|
-
assert definition["display_results_in_social_history_section"] is False
|
|
File without changes
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from canvas_sdk.effects import Effect
|
|
6
|
-
from canvas_sdk.events import Event, EventRequest, EventType
|
|
7
|
-
from plugin_runner.plugin_runner import LOADED_PLUGINS
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@pytest.mark.parametrize("install_test_plugin", ["test_render_template"], indirect=True)
|
|
11
|
-
def test_render_to_string_valid_template(
|
|
12
|
-
install_test_plugin: Path, load_test_plugins: None
|
|
13
|
-
) -> None:
|
|
14
|
-
"""Test that the render_to_string function loads and renders a valid template."""
|
|
15
|
-
plugin = LOADED_PLUGINS[
|
|
16
|
-
"test_render_template:test_render_template.protocols.my_protocol:ValidTemplate"
|
|
17
|
-
]
|
|
18
|
-
result: list[Effect] = plugin["class"](Event(EventRequest(type=EventType.UNKNOWN))).compute()
|
|
19
|
-
assert "html" in result[0].payload
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@pytest.mark.parametrize("install_test_plugin", ["test_render_template"], indirect=True)
|
|
23
|
-
def test_render_to_string_invalid_template(
|
|
24
|
-
install_test_plugin: Path, load_test_plugins: None
|
|
25
|
-
) -> None:
|
|
26
|
-
"""Test that the render_to_string function raises an error for invalid templates."""
|
|
27
|
-
plugin = LOADED_PLUGINS[
|
|
28
|
-
"test_render_template:test_render_template.protocols.my_protocol:InvalidTemplate"
|
|
29
|
-
]
|
|
30
|
-
with pytest.raises(FileNotFoundError):
|
|
31
|
-
plugin["class"](Event(EventRequest(type=EventType.UNKNOWN))).compute()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@pytest.mark.parametrize("install_test_plugin", ["test_render_template"], indirect=True)
|
|
35
|
-
def test_render_to_string_forbidden_template(
|
|
36
|
-
install_test_plugin: Path, load_test_plugins: None
|
|
37
|
-
) -> None:
|
|
38
|
-
"""Test that the render_to_string function raises an error for a template outside plugin package."""
|
|
39
|
-
plugin = LOADED_PLUGINS[
|
|
40
|
-
"test_render_template:test_render_template.protocols.my_protocol:ForbiddenTemplate"
|
|
41
|
-
]
|
|
42
|
-
with pytest.raises(PermissionError):
|
|
43
|
-
plugin["class"](Event(EventRequest(type=EventType.UNKNOWN))).compute()
|
canvas_sdk/tests/__init__.py
DELETED
|
File without changes
|
|
File without changes
|