From d580ba3bb6626f0d4c6bc2e4a6d3fdc721aba0a9 Mon Sep 17 00:00:00 2001 From: Michela Iannaccone Date: Wed, 21 Feb 2024 15:22:44 -0500 Subject: [PATCH] create medication statement command --- canvas_sdk/commands/__init__.py | 2 + canvas_sdk/commands/medication_statement.py | 13 +++++++ canvas_sdk/commands/tests.py | 43 ++++++++++++++++++++- 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 canvas_sdk/commands/medication_statement.py diff --git a/canvas_sdk/commands/__init__.py b/canvas_sdk/commands/__init__.py index 76aa21bf..34f4681a 100644 --- a/canvas_sdk/commands/__init__.py +++ b/canvas_sdk/commands/__init__.py @@ -2,6 +2,7 @@ from canvas_sdk.commands.diagnose import DiagnoseCommand from canvas_sdk.commands.goal import GoalCommand from canvas_sdk.commands.history_present_illness import HistoryOfPresentIllnessCommand +from canvas_sdk.commands.medication_statement import MedicationStatementCommand from canvas_sdk.commands.plan import PlanCommand __all__ = ( @@ -10,4 +11,5 @@ "DiagnoseCommand", "GoalCommand", "HistoryOfPresentIllnessCommand", + "MedicationStatementCommand", ) diff --git a/canvas_sdk/commands/medication_statement.py b/canvas_sdk/commands/medication_statement.py new file mode 100644 index 00000000..9ed34caa --- /dev/null +++ b/canvas_sdk/commands/medication_statement.py @@ -0,0 +1,13 @@ +from canvas_sdk.commands.base import _BaseCommand + + +class MedicationStatementCommand(_BaseCommand): + """A class for managing a MedicationStatement command within a specific note.""" + + fdb_code: str + sig: str | None = None + + @property + def values(self) -> dict: + """The MedicationStatement command's field values.""" + return {"fdb_code": self.fdb_code, "sig": self.sig} diff --git a/canvas_sdk/commands/tests.py b/canvas_sdk/commands/tests.py index 0ab6a7e8..f24a60bd 100644 --- a/canvas_sdk/commands/tests.py +++ b/canvas_sdk/commands/tests.py @@ -8,6 +8,7 @@ DiagnoseCommand, GoalCommand, HistoryOfPresentIllnessCommand, + MedicationStatementCommand, PlanCommand, ) @@ -207,11 +208,34 @@ "1 validation error for HistoryOfPresentIllnessCommand\nnarrative\n Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]", {"user_id": 1, "narrative": "hiya"}, ), + ( + MedicationStatementCommand, + {"user_id": 1}, + "1 validation error for MedicationStatementCommand\nfdb_code\n Field required [type=missing, input_value={'user_id': 1}, input_type=dict]", + {"user_id": 1, "fdb_code": "44"}, + ), + ( + MedicationStatementCommand, + {"user_id": 1, "fdb_code": None}, + "1 validation error for MedicationStatementCommand\nfdb_code\n Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]", + {"user_id": 1, "fdb_code": "44"}, + ), + ( + MedicationStatementCommand, + {"user_id": 1, "fdb_code": "44", "sig": 1}, + "1 validation error for MedicationStatementCommand\nsig\n Input should be a valid string [type=string_type, input_value=1, input_type=int]", + {"user_id": 1, "fdb_code": "44"}, + ), ], ) def test_command_raises_error_when_kwarg_given_incorrect_type( Command: ( - PlanCommand | AssessCommand | DiagnoseCommand | GoalCommand | HistoryOfPresentIllnessCommand + PlanCommand + | AssessCommand + | DiagnoseCommand + | GoalCommand + | HistoryOfPresentIllnessCommand + | MedicationStatementCommand ), err_kwargs: dict, err_msg: str, @@ -333,11 +357,26 @@ def test_command_raises_error_when_kwarg_given_incorrect_type( {"user_id": 1, "narrative": "hi!"}, {"user_id": 1, "narrative": "hows your day!"}, ), + ( + MedicationStatementCommand, + {"user_id": 1, "fdb_code": "9888"}, + {"user_id": 1, "fdb_code": "12333"}, + ), + ( + MedicationStatementCommand, + {"user_id": 1, "fdb_code": "9888", "sig": "1pobd"}, + {"user_id": 1, "fdb_code": "9888", "sig": None}, + ), ], ) def test_command_allows_kwarg_with_correct_type( Command: ( - PlanCommand | AssessCommand | DiagnoseCommand | GoalCommand | HistoryOfPresentIllnessCommand + PlanCommand + | AssessCommand + | DiagnoseCommand + | GoalCommand + | HistoryOfPresentIllnessCommand + | MedicationStatementCommand ), test_init_kwarg: dict, test_updated_value: dict,