Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves __init__ to BaseProtocol class #33

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions canvas_sdk/protocols/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json


class BaseProtocol:
def __init__(self) -> None:
pass
def __init__(self, event) -> None:
self.event = event
self.context = json.loads(event.context)
7 changes: 1 addition & 6 deletions custom-plugins/my_first_plugin/protocols/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ class Protocol(BaseProtocol):

NARRATIVE_STRING = "monkey"

# TODO - move __init__ to BaseProtocol class;
def __init__(self, event) -> None:
self.event = event
self.payload = json.loads(event.target)

def compute(self):
payload = {
"note": {"uuid": self.payload["note"]["uuid"]},
"note": {"uuid": self.context["note"]["uuid"]},
"data": {"narrative": self.NARRATIVE_STRING},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
class Protocol(BaseProtocol):
RESPONDS_TO = EventType.Name(EventType.MEDICATION_STATEMENT__MEDICATION__POST_SEARCH)

def __init__(self, event) -> None:
self.event = event
self.context = json.loads(event.context)

def compute(self):
results = self.context.get("results")

Expand Down
Loading