Skip to content

Commit

Permalink
create medication statement command
Browse files Browse the repository at this point in the history
  • Loading branch information
mbiannaccone committed Feb 21, 2024
1 parent da6b98c commit d580ba3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
2 changes: 2 additions & 0 deletions canvas_sdk/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = (
Expand All @@ -10,4 +11,5 @@
"DiagnoseCommand",
"GoalCommand",
"HistoryOfPresentIllnessCommand",
"MedicationStatementCommand",
)
13 changes: 13 additions & 0 deletions canvas_sdk/commands/medication_statement.py
Original file line number Diff line number Diff line change
@@ -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}
43 changes: 41 additions & 2 deletions canvas_sdk/commands/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
DiagnoseCommand,
GoalCommand,
HistoryOfPresentIllnessCommand,
MedicationStatementCommand,
PlanCommand,
)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d580ba3

Please sign in to comment.