-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: plugins functionality for protocol conversions (#183)
Signed-off-by: Kristen ONeill <91080969+kristenoneill@users.noreply.github.com> Co-authored-by: Christopher Sande <christopher.sande@canvasmedical.com> Co-authored-by: José Magalhães <jose.magalhaes@canvasmedical.com> Co-authored-by: Michela Iannaccone <mbiannaccone@gmail.com> Co-authored-by: Kristen ONeill <91080969+kristenoneill@users.noreply.github.com>
- Loading branch information
1 parent
0fc5590
commit 69e95c8
Showing
15 changed files
with
1,441 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import arrow | ||
|
||
|
||
class Timeframe: | ||
"""A class representing a timeframe with a start and and end.""" | ||
|
||
def __init__(self, start: arrow.Arrow, end: arrow.Arrow): | ||
self.start = start | ||
self.end = end | ||
|
||
def __str__(self) -> str: | ||
return f"<Timeframe start={self.start}, end={self.end}>" | ||
|
||
@property | ||
def duration(self) -> int: | ||
"""Returns the number of days in the timeframe.""" | ||
return (self.end - self.start).days | ||
|
||
def increased_by(self, years: int = 0, months: int = 0, days: int = 0) -> "Timeframe": | ||
"""Returns a new Timeframe object increased by the years, months, days in the arguments.""" | ||
start = self.start | ||
end = self.end | ||
|
||
if years > 0: | ||
end = end.shift(years=years) | ||
elif years < 0: | ||
start = start.shift(years=years) | ||
|
||
if months > 0: | ||
end = end.shift(months=months) | ||
elif months < 0: | ||
start = start.shift(months=months) | ||
|
||
if days > 0: | ||
end = end.shift(days=days) | ||
elif days < 0: | ||
start = start.shift(days=days) | ||
|
||
return Timeframe(start=start, end=end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from typing import TYPE_CHECKING, Type | ||
|
||
from django.db import models | ||
|
||
from canvas_sdk.v1.data.base import ValueSetTimeframeLookupQuerySet | ||
from canvas_sdk.v1.data.note import Note | ||
from canvas_sdk.v1.data.patient import Patient | ||
from canvas_sdk.value_set.value_set import CodeConstants | ||
|
||
if TYPE_CHECKING: | ||
from canvas_sdk.value_set.value_set import ValueSet | ||
|
||
|
||
class BillingLineItemQuerySet(ValueSetTimeframeLookupQuerySet): | ||
"""A class that adds functionality to filter BillingLineItem objects.""" | ||
|
||
def find(self, value_set: Type["ValueSet"]) -> models.QuerySet: | ||
""" | ||
This method is overridden to use for BillingLineItem CPT codes. | ||
The codes are saved as string values in the BillingLineItem.cpt field, | ||
which differs from other coding models. | ||
""" | ||
values_dict = value_set.values | ||
return self.filter(cpt__in=values_dict.get(CodeConstants.HCPCS, [])) | ||
|
||
|
||
class BillingLineItemStatus(models.TextChoices): | ||
"""Billing line item status.""" | ||
|
||
ACTIVE = "active", "Active" | ||
REMOVED = "removed", "Removed" | ||
|
||
|
||
class BillingLineItem(models.Model): | ||
"""BillingLineItem.""" | ||
|
||
class Meta: | ||
managed = False | ||
app_label = "canvas_sdk" | ||
db_table = "canvas_sdk_data_api_billinglineitem_001" | ||
|
||
# objects = BillingLineItemQuerySet.as_manager() | ||
objects = models.Manager().from_queryset(BillingLineItemQuerySet)() | ||
|
||
id = models.UUIDField() | ||
dbid = models.BigIntegerField(primary_key=True) | ||
created = models.DateTimeField() | ||
modified = models.DateTimeField() | ||
note = models.ForeignKey(Note, on_delete=models.DO_NOTHING, related_name="billing_line_items") | ||
patient = models.ForeignKey( | ||
Patient, on_delete=models.DO_NOTHING, related_name="billing_line_items" | ||
) | ||
cpt = models.CharField() | ||
charge = models.DecimalField() | ||
description = models.CharField() | ||
units = models.IntegerField() | ||
command_type = models.CharField() | ||
command_id = models.IntegerField() | ||
status = models.CharField(choices=BillingLineItemStatus.choices) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.