Skip to content

Commit

Permalink
feat: added new CreateQuestionnaireResult effect type (#250)
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Sande <christopher.sande@canvasmedical.com>
Co-authored-by: Reba Magier <reba.magier@canvasmedical.com>
  • Loading branch information
csande and rmagier1 authored Jan 15, 2025
1 parent a0abdec commit 5a1b5bb
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions canvas_generated/messages/effects_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions canvas_generated/messages/effects_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class EffectType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
DELETE_CLOSE_GOAL_COMMAND: _ClassVar[EffectType]
COMMIT_CLOSE_GOAL_COMMAND: _ClassVar[EffectType]
ENTER_IN_ERROR_CLOSE_GOAL_COMMAND: _ClassVar[EffectType]
CREATE_QUESTIONNAIRE_RESULT: _ClassVar[EffectType]
ANNOTATE_PATIENT_CHART_CONDITION_RESULTS: _ClassVar[EffectType]
ANNOTATE_CLAIM_CONDITION_RESULTS: _ClassVar[EffectType]
SHOW_PATIENT_CHART_SUMMARY_SECTIONS: _ClassVar[EffectType]
Expand Down Expand Up @@ -293,6 +294,7 @@ EDIT_CLOSE_GOAL_COMMAND: EffectType
DELETE_CLOSE_GOAL_COMMAND: EffectType
COMMIT_CLOSE_GOAL_COMMAND: EffectType
ENTER_IN_ERROR_CLOSE_GOAL_COMMAND: EffectType
CREATE_QUESTIONNAIRE_RESULT: EffectType
ANNOTATE_PATIENT_CHART_CONDITION_RESULTS: EffectType
ANNOTATE_CLAIM_CONDITION_RESULTS: EffectType
SHOW_PATIENT_CHART_SUMMARY_SECTIONS: EffectType
Expand Down
29 changes: 29 additions & 0 deletions canvas_sdk/effects/questionnaire_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import Any

from canvas_sdk.effects.base import EffectType, _BaseEffect


class CreateQuestionnaireResult(_BaseEffect):
"""CreateQuestionnaireResult effect."""

class Meta:
effect_type = EffectType.CREATE_QUESTIONNAIRE_RESULT

interview_id: str | None = None
score: float | None = None
abnormal: bool | None = None
narrative: str | None = None
code_system: str | None = None
code: str | None = None

@property
def values(self) -> dict[str, Any]:
"""Make the payload."""
return {
"interview_id": self.interview_id,
"score": self.score,
"abnormal": self.abnormal or False,
"narrative": self.narrative or "",
"code_system": self.code_system,
"code": self.code,
}
1 change: 1 addition & 0 deletions canvas_sdk/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from canvas_sdk.v1.data.note import Note
from canvas_sdk.v1.data.patient import Patient
from canvas_sdk.v1.data.user import CanvasUser
from canvas_sdk.v1.data.questionnaire import Interview
13 changes: 13 additions & 0 deletions canvas_sdk/v1/data/command.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.apps import apps
from django.db import models

from canvas_sdk.v1.data.patient import Patient
Expand Down Expand Up @@ -25,3 +26,15 @@ class Meta:
schema_key = models.TextField()
data = models.JSONField()
origination_source = models.CharField()
anchor_object_type = models.CharField()
anchor_object_dbid = models.BigIntegerField()

@property
def anchor_object(self) -> models.Model | None:
"""
Use the anchor_object_type and anchor_object_dbid to get the anchor object for the command.
"""
# TODO: Is the anchor object type enough here, or do we need a mapping? The home-app model
# names might not exactly match the plugins model names.
anchor_model = apps.get_model(app_label="canvas_sdk", model_name=self.anchor_object_type)
return anchor_model.objects.get(dbid=self.anchor_object_dbid)
2 changes: 2 additions & 0 deletions protobufs/canvas_generated/messages/effects.proto
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ enum EffectType {
COMMIT_CLOSE_GOAL_COMMAND = 131;
ENTER_IN_ERROR_CLOSE_GOAL_COMMAND = 132;

CREATE_QUESTIONNAIRE_RESULT = 138;

ANNOTATE_PATIENT_CHART_CONDITION_RESULTS = 200;

ANNOTATE_CLAIM_CONDITION_RESULTS = 300;
Expand Down

0 comments on commit 5a1b5bb

Please sign in to comment.