Skip to content

Commit

Permalink
Adds imaging models and common choice classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwils authored and jamagalhaes committed Oct 22, 2024
1 parent d4aff18 commit 2e33410
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 0 deletions.
72 changes: 72 additions & 0 deletions canvas_sdk/v1/data/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
class DocumentReviewMode:
REVIEW_REQUIRED = "RR"
ALREADY_REVIEWED_OFFLINE = "AR"
REVIEW_NOT_REQUIRED = "RN"

CHOICES = {
REVIEW_REQUIRED: "Review required",
ALREADY_REVIEWED_OFFLINE: "Already reviewed offline",
REVIEW_NOT_REQUIRED: "Review not required",
}


class OrderStatus:
PROPOSED = "proposed"
DRAFT = "draft"
PLANNED = "planned"
REQUESTED = "requested"
RECEIVED = "received"
ACCEPTED = "accepted"
IN_PROGRESS = "in-progress"
REVIEW = "review"
COMPLETED = "completed"
CANCELLED = "cancelled"
SUSPENDED = "suspended"
REJECTED = "rejected"
FAILED = "failed"
ENTERED_IN_ERROR = "EIE"

CHOICES = {
PROPOSED: "Proposed",
DRAFT: "Draft",
PLANNED: "Planned",
REQUESTED: "Requested",
RECEIVED: "Received",
ACCEPTED: "Accepted",
IN_PROGRESS: "In-progress",
REVIEW: "Review",
COMPLETED: "Completed",
CANCELLED: "Cancelled",
SUSPENDED: "Suspended",
REJECTED: "Rejected",
FAILED: "Failed",
ENTERED_IN_ERROR: "Entered in Error",
}


class ReviewPatientCommunicationMethod:
DELEGATED_CALL_CAN_LEAVE_MESSAGE = "DM"
DELEGATED_CALL_NEED_ANSWER = "DA"
DELEGATED_LETTER = "DL"
DO_NOT_COMMUNICATE = "DC"
ALREADY_LEFT_MESSAGE = "AM"
ALREADY_REVIEWED_WITH_PATIENT = "AR"

CHOICES = {
DELEGATED_CALL_CAN_LEAVE_MESSAGE: "delegate call, can leave message",
DELEGATED_CALL_NEED_ANSWER: "delegate call, need patient to answer",
DELEGATED_LETTER: "delegate letter",
DO_NOT_COMMUNICATE: "do not communicate",
ALREADY_LEFT_MESSAGE: "already left message",
ALREADY_REVIEWED_WITH_PATIENT: "already reviewed with patient",
}


class ReviewStatus:
STATUS_REVIEWING = "reviewing"
STATUS_REVIEWED = "reviewed"

CHOICES = {
STATUS_REVIEWING: "reviewing",
STATUS_REVIEWING: "reviewed",
}
102 changes: 102 additions & 0 deletions canvas_sdk/v1/data/imaging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from django.db import models

from canvas_sdk.v1.data.common import (
DocumentReviewMode,
OrderStatus,
ReviewPatientCommunicationMethod,
ReviewStatus,
)
from canvas_sdk.v1.data.patient import Patient
from canvas_sdk.v1.data.user import CanvasUser


class ImagingOrder(models.Model):
class Meta:
managed = False
app_label = "canvas_sdk"
db_table = "canvas_sdk_data_api_imagingorder_001"

id = models.UUIDField()
dbid = models.BigIntegerField(primary_key=True)
created = models.DateTimeField()
modified = models.DateTimeField()
originator = models.ForeignKey(CanvasUser, on_delete=models.DO_NOTHING)
deleted = models.BooleanField()
committer = models.ForeignKey(CanvasUser, on_delete=models.DO_NOTHING)
entered_in_error = models.ForeignKey(CanvasUser, on_delete=models.DO_NOTHING)
patient = models.ForeignKey(Patient, on_delete=models.DO_NOTHING, related_name="imaging_orders")
# TODO - uncomment when Note model is complete
# note = models.ForeigneKey(Note, on_delete=models.DO_NOTHING, related_name="imaging_orders")
imaging = models.CharField()
# TODO - uncomment when ServiceProvider model is complete
# imaging_center = models.ForeignKey(ServiceProvider, related_name="imaging_orders", null=True, on_delete=models.DO_NOTHING)
note_to_radiologist = models.CharField()
internal_comment = models.CharField()
status = models.CharField(choices=OrderStatus.CHOICES)
date_time_ordered = models.DateTimeField()
priority = models.CharField()
# TODO - uncomment when Staff model is complete
# ordering_provider = models.ForeignKey(Staff, on_delete=models.CASCADE, related_name="imaging_orders", null=True)
delegated = models.BooleanField(default=False)


class ImagingReview(models.Model):
class Meta:
managed = False
app_label = "canvas_sdk"
db_table = "canvas_sdk_data_api_imagingreview_001"

id = models.UUIDField()
dbid = models.BigIntegerField(primary_key=True)
created = models.DateTimeField()
modified = models.DateTimeField()
originator = models.ForeignKey(CanvasUser, on_delete=models.DO_NOTHING)
deleted = models.BooleanField()
committer = models.ForeignKey(CanvasUser, on_delete=models.DO_NOTHING)
entered_in_error = models.ForeignKey(CanvasUser, on_delete=models.DO_NOTHING)
patient_communication_method = models.CharField(choices=ReviewPatientCommunicationMethod)
# TODO - uncomment when Note model is complete
# note = models.ForeignKey(Note, on_delete=models.DO_NOTHING, related_name="imaging_reviews")
internal_comment = models.CharField()
message_to_patient = models.CharField()
is_released_to_patient = models.BooleanField()
status = models.CharField(choices=ReviewStatus.CHOICES)
patient = models.ForeignKey(
Patient, on_delete=models.DO_NOTHING, related_name="imaging_reviews"
)


class ImagingReport(models.Model):
class ImagingReportSource:
RADIOLOGY_FROM_PATIENT = "RADIOLOGY_PATIENT"
VERBAL_FROM_PATIENT = "VERBAL_PATIENT"
DIRECTLY_REPORT = "DIRECTLY_RADIOLOGY"

CHOICES = {
RADIOLOGY_FROM_PATIENT: "Radiology Report From Patient",
VERBAL_FROM_PATIENT: "Verbal Report From Patient",
DIRECTLY_REPORT: "Directly Radiology Report",
}

class Meta:
managed = False
app_label = "canvas_sdk"
db_table = "canvas_sdk_data_api_imagingreport_001"

id = models.UUIDField()
dbid = models.BigIntegerField(primary_key=True)
created = models.DateTimeField()
modified = models.DateTimeField()
review_mode = models.CharField(choices=DocumentReviewMode.CHOICES)
junked = models.BooleanField()
requires_signature = models.BooleanField()
assigned_date = models.DateTimeField()
patient = models.ForeignKey(
Patient, on_delete=models.DO_NOTHING, related_name="imaging_results"
)
order = models.ForeignKey(ImagingOrder, on_delete=models.DO_NOTHING, null=True)
source = models.CharField(choices=ImagingReportSource.CHOICES)
name = models.CharField()
result_date = models.DateField()
original_date = models.DateField()
review = models.ForeignKey(ImagingReview, null=True, on_delete=models.DO_NOTHING)

0 comments on commit 2e33410

Please sign in to comment.