canvas 0.42.0__py3-none-any.whl → 0.44.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of canvas might be problematic. Click here for more details.

Files changed (47) hide show
  1. {canvas-0.42.0.dist-info → canvas-0.44.0.dist-info}/METADATA +1 -2
  2. {canvas-0.42.0.dist-info → canvas-0.44.0.dist-info}/RECORD +47 -33
  3. canvas_cli/apps/auth/storage.py +65 -0
  4. canvas_cli/apps/auth/utils.py +6 -42
  5. canvas_generated/messages/effects_pb2.py +2 -2
  6. canvas_generated/messages/effects_pb2.pyi +12 -0
  7. canvas_sdk/effects/note/appointment.py +135 -50
  8. canvas_sdk/effects/note/base.py +108 -10
  9. canvas_sdk/effects/note/note.py +81 -22
  10. canvas_sdk/effects/patient/__init__.py +10 -2
  11. canvas_sdk/effects/patient/base.py +20 -1
  12. canvas_sdk/effects/patient/create_patient_external_identifier.py +40 -0
  13. canvas_sdk/effects/protocol_card/__init__.py +4 -1
  14. canvas_sdk/effects/protocol_card/protocol_card.py +2 -0
  15. canvas_sdk/utils/http.py +46 -2
  16. canvas_sdk/v1/data/__init__.py +45 -0
  17. canvas_sdk/v1/data/allergy_intolerance.py +6 -2
  18. canvas_sdk/v1/data/assessment.py +7 -3
  19. canvas_sdk/v1/data/billing.py +1 -1
  20. canvas_sdk/v1/data/business_line.py +35 -0
  21. canvas_sdk/v1/data/claim.py +321 -0
  22. canvas_sdk/v1/data/claim_line_item.py +140 -0
  23. canvas_sdk/v1/data/command.py +12 -3
  24. canvas_sdk/v1/data/condition.py +7 -2
  25. canvas_sdk/v1/data/detected_issue.py +9 -3
  26. canvas_sdk/v1/data/device.py +9 -3
  27. canvas_sdk/v1/data/discount.py +21 -0
  28. canvas_sdk/v1/data/fields.py +37 -0
  29. canvas_sdk/v1/data/imaging.py +18 -6
  30. canvas_sdk/v1/data/invoice.py +62 -0
  31. canvas_sdk/v1/data/lab.py +36 -12
  32. canvas_sdk/v1/data/line_item_transaction.py +83 -0
  33. canvas_sdk/v1/data/medication.py +6 -2
  34. canvas_sdk/v1/data/observation.py +9 -3
  35. canvas_sdk/v1/data/organization.py +3 -1
  36. canvas_sdk/v1/data/patient.py +17 -1
  37. canvas_sdk/v1/data/patient_consent.py +92 -0
  38. canvas_sdk/v1/data/payment_collection.py +35 -0
  39. canvas_sdk/v1/data/payor_specific_charge.py +28 -0
  40. canvas_sdk/v1/data/posting.py +225 -0
  41. canvas_sdk/v1/data/protocol_override.py +6 -2
  42. canvas_sdk/v1/data/questionnaire.py +6 -2
  43. canvas_sdk/v1/data/user.py +2 -0
  44. canvas_sdk/v1/data/utils.py +10 -0
  45. protobufs/canvas_generated/messages/effects.proto +7 -0
  46. {canvas-0.42.0.dist-info → canvas-0.44.0.dist-info}/WHEEL +0 -0
  47. {canvas-0.42.0.dist-info → canvas-0.44.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,92 @@
1
+ from django.db import models
2
+
3
+
4
+ class PatientConsentRejectionCoding(models.Model):
5
+ """Patient Consent Rejection Coding."""
6
+
7
+ class Meta:
8
+ managed = False
9
+ db_table = "canvas_sdk_data_api_patientconsentrejectioncoding_001"
10
+
11
+ dbid = models.BigIntegerField(primary_key=True)
12
+ system = models.CharField()
13
+ version = models.CharField()
14
+ code = models.CharField()
15
+ display = models.CharField()
16
+ user_selected = models.BooleanField()
17
+
18
+
19
+ class PatientConsentExpirationRule(models.TextChoices):
20
+ """PatientConsentExpirationRule."""
21
+
22
+ NEVER = "never", "Never"
23
+ IN_ONE_YEAR = "in_one_year", "In one year"
24
+ END_OF_YEAR = "end_of_year", "End of year"
25
+
26
+
27
+ class PatientConsentCoding(models.Model):
28
+ """Patient Consent Coding."""
29
+
30
+ class Meta:
31
+ managed = False
32
+ db_table = "canvas_sdk_data_api_patientconsentcoding_001"
33
+
34
+ dbid = models.BigIntegerField(primary_key=True)
35
+ system = models.CharField()
36
+ version = models.CharField()
37
+ code = models.CharField()
38
+ display = models.CharField()
39
+ user_selected = models.BooleanField()
40
+ expiration_rule = models.CharField(choices=PatientConsentExpirationRule, max_length=255)
41
+ is_mandatory = models.BooleanField()
42
+ is_proof_required = models.BooleanField()
43
+ show_in_patient_portal = models.BooleanField()
44
+ summary = models.TextField()
45
+
46
+
47
+ class PatientConsentStatus(models.TextChoices):
48
+ """PatientConsentStatus."""
49
+
50
+ ACCEPTED = "accepted", "Accepted"
51
+ ACCEPTED_VIA_PORTAL = (
52
+ "accepted_via_patient_portal",
53
+ "Accepted Via Patient Portal",
54
+ )
55
+ REJECTED = "rejected", "Rejected"
56
+ REJECTED_VIA_PORTAL = "rejected_via_patient_portal", "Rejected Via Patient Portal"
57
+
58
+
59
+ class PatientConsent(models.Model):
60
+ """Patient Consent."""
61
+
62
+ class Meta:
63
+ managed = False
64
+ db_table = "canvas_sdk_data_api_patientconsent_001"
65
+
66
+ id = models.UUIDField()
67
+ dbid = models.BigIntegerField(primary_key=True)
68
+ patient = models.ForeignKey(
69
+ "v1.Patient", on_delete=models.DO_NOTHING, related_name="patient_consent"
70
+ )
71
+ category = models.ForeignKey(
72
+ "v1.PatientConsentCoding",
73
+ on_delete=models.DO_NOTHING,
74
+ related_name="patient_consent",
75
+ )
76
+ state = models.CharField(choices=PatientConsentStatus, max_length=255)
77
+ effective_date = models.DateField()
78
+ expired_date = models.DateField()
79
+ rejection_reason = models.ForeignKey(
80
+ "v1.PatientConsentRejectionCoding",
81
+ on_delete=models.DO_NOTHING,
82
+ null=True,
83
+ related_name="patient_consents",
84
+ )
85
+ originator = models.ForeignKey("v1.CanvasUser", on_delete=models.DO_NOTHING, related_name="+")
86
+
87
+
88
+ __exports__ = (
89
+ "PatientConsent",
90
+ "PatientConsentCoding",
91
+ "PatientConsentRejectionCoding",
92
+ )
@@ -0,0 +1,35 @@
1
+ from django.db import models
2
+
3
+
4
+ class PostingMethods(models.TextChoices):
5
+ """PostingMethods."""
6
+
7
+ CASH = "cash", "Cash"
8
+ CHECK = "check", "Check"
9
+ CARD = "card", "Card"
10
+ OTHER = "other", "Other"
11
+
12
+
13
+ class PaymentCollection(models.Model):
14
+ """Stores the total collected amount and the payment method."""
15
+
16
+ class Meta:
17
+ managed = False
18
+ db_table = "canvas_sdk_data_quality_and_revenue_paymentcollection_001"
19
+
20
+ id = models.UUIDField()
21
+ dbid = models.BigIntegerField(primary_key=True)
22
+ total_collected = models.DecimalField(max_digits=8, decimal_places=2)
23
+ method = models.CharField(choices=PostingMethods.choices)
24
+
25
+ check_number = models.CharField()
26
+ check_date = models.DateField()
27
+ deposit_date = models.DateField()
28
+
29
+ description = models.TextField()
30
+
31
+ created = models.DateTimeField()
32
+ modified = models.DateTimeField()
33
+
34
+
35
+ __exports__ = ("PaymentCollection", "PostingMethods")
@@ -0,0 +1,28 @@
1
+ from django.db import models
2
+
3
+
4
+ class PayorSpecificCharge(models.Model):
5
+ """Payor Specific Charge."""
6
+
7
+ class Meta:
8
+ managed = False
9
+ db_table = "canvas_sdk_data_quality_and_revenue_payorspecificcharge_001"
10
+
11
+ dbid = models.BigIntegerField(primary_key=True)
12
+ transactor = models.ForeignKey(
13
+ "v1.Transactor", related_name="specific_charges", on_delete=models.DO_NOTHING
14
+ )
15
+ # uncomment this when ChargeDescriptionMaster is added to data module
16
+ # charge = models.ForeignKey(
17
+ # "v1.ChargeDescriptionMaster",
18
+ # related_name="transactor_charges",
19
+ # on_delete=models.DO_NOTHING,
20
+ # )
21
+
22
+ charge_amount = models.DecimalField()
23
+ effective_date = models.DateField()
24
+ end_date = models.DateField()
25
+ part_of_capitated_set = models.BooleanField()
26
+
27
+
28
+ __exports__ = ("PayorSpecificCharge",)
@@ -0,0 +1,225 @@
1
+ from decimal import Decimal
2
+ from typing import Self
3
+
4
+ from django.db import models
5
+
6
+ from canvas_sdk.v1.data.utils import quantize
7
+
8
+
9
+ class PostingQuerySet(models.QuerySet):
10
+ """A queryset for CoveragePosting objects."""
11
+
12
+ def active(self) -> Self:
13
+ """Return a queryset that filters for active postings."""
14
+ return self.filter(entered_in_error__isnull=True)
15
+
16
+
17
+ class BasePosting(models.Model):
18
+ """
19
+ Base model to aggregate multiple line item transactions on a claim.
20
+ """
21
+
22
+ class Meta:
23
+ managed = False
24
+ db_table = "canvas_sdk_data_quality_and_revenue_baseposting_001"
25
+
26
+ objects = PostingQuerySet.as_manager()
27
+
28
+ dbid = models.BigIntegerField(primary_key=True)
29
+ corrected_posting = models.ForeignKey(
30
+ "v1.BasePosting", related_name="correction_postings", on_delete=models.PROTECT, null=True
31
+ )
32
+
33
+ claim = models.ForeignKey("v1.Claim", related_name="postings", on_delete=models.PROTECT)
34
+ payment_collection = models.ForeignKey(
35
+ "v1.PaymentCollection", related_name="postings", null=True, on_delete=models.PROTECT
36
+ )
37
+
38
+ description = models.TextField(default="")
39
+
40
+ entered_in_error = models.ForeignKey(
41
+ "v1.CanvasUser", on_delete=models.PROTECT, null=True, blank=True
42
+ )
43
+
44
+ created = models.DateTimeField()
45
+ modified = models.DateTimeField()
46
+
47
+ @property
48
+ def paid_amount(self) -> Decimal:
49
+ """Returns the total amount paid for this posting."""
50
+ return quantize(sum(lip.amount for lip in self.newlineitempayments.all()))
51
+
52
+ @property
53
+ def contractual_adjusted_amount(self) -> Decimal:
54
+ """Returns the total amount of contractual adjustments for this posting."""
55
+ return quantize(
56
+ sum(lia.amount for lia in self.newlineitemadjustments.all() if lia.write_off)
57
+ )
58
+
59
+ @property
60
+ def non_write_off_adjusted_amount(self) -> Decimal | int:
61
+ """Returns the total amount of non-write-off adjustments for this posting."""
62
+ return sum(lia.amount for lia in self.newlineitemadjustments.all() if not lia.write_off)
63
+
64
+ @property
65
+ def transferred_amount(self) -> Decimal:
66
+ """Returns the total amount transferred for this posting."""
67
+ return quantize(sum(lit.amount for lit in self.lineitemtransfers.all()))
68
+
69
+ @property
70
+ def transferred_to_patient_amount(self) -> Decimal | int:
71
+ """Returns the total amount transferred to the patient."""
72
+ transfers = [trans for trans in self.lineitemtransfers.all() if trans.transfer_to_patient]
73
+ return sum(lit.amount for lit in transfers)
74
+
75
+ @property
76
+ def transferred_to_coverage_amount(self) -> Decimal | int:
77
+ """Returns the total amount transferred to another coverage."""
78
+ transfers = [trans for trans in self.lineitemtransfers.all() if trans.transfer_to]
79
+ return sum(lit.amount for lit in transfers)
80
+
81
+ @property
82
+ def adjusted_and_transferred_amount(self) -> Decimal:
83
+ """Returns the charges amount per claim for a patient posting."""
84
+ return self.contractual_adjusted_amount + self.transferred_amount
85
+
86
+ @property
87
+ def posted_amount(self) -> Decimal:
88
+ """Property to compute how much was posted with this posting: sums all payments and write-off adjustments."""
89
+ return self.paid_amount + self.contractual_adjusted_amount + self.transferred_amount
90
+
91
+
92
+ class CoveragePosting(BasePosting):
93
+ """Represents an insurance payment/adjustment on a claim level."""
94
+
95
+ class Meta:
96
+ managed = False
97
+ db_table = "canvas_sdk_data_quality_and_revenue_coverageposting_001"
98
+
99
+ remittance = models.ForeignKey(
100
+ "v1.BaseRemittanceAdvice", related_name="postings", on_delete=models.PROTECT, null=True
101
+ )
102
+ claim_coverage = models.ForeignKey(
103
+ "v1.ClaimCoverage", related_name="postings", on_delete=models.PROTECT
104
+ )
105
+
106
+ crossover_carrier = models.CharField()
107
+ crossover_id = models.CharField()
108
+ payer_icn = models.CharField()
109
+ position_in_era = models.PositiveIntegerField()
110
+
111
+
112
+ class PatientPosting(BasePosting):
113
+ """A model that represents a patient payment/adjustment on a claim level."""
114
+
115
+ class Meta:
116
+ managed = False
117
+ db_table = "canvas_sdk_data_quality_and_revenue_patientposting_001"
118
+
119
+ claim_patient = models.ForeignKey(
120
+ "v1.ClaimPatient", related_name="postings", on_delete=models.PROTECT
121
+ )
122
+ patient_payment = models.ForeignKey(
123
+ "v1.BulkPatientPosting", related_name="postings", on_delete=models.PROTECT, null=True
124
+ )
125
+
126
+ copay = models.ForeignKey(
127
+ "v1.BulkPatientPosting", related_name="copays", on_delete=models.PROTECT, null=True
128
+ )
129
+
130
+ @property
131
+ def discounted_amount(self) -> Decimal:
132
+ """Returns the discounted amount per claim for a patient bulk posting."""
133
+ if not self.patient_payment or not self.patient_payment.discount:
134
+ return Decimal("0")
135
+
136
+ discount = self.patient_payment.discount
137
+ return quantize(
138
+ sum(
139
+ lia.amount
140
+ for lia in self.newlineitemadjustments.all()
141
+ if (
142
+ lia.write_off
143
+ and (lia.group, lia.code)
144
+ == (discount.adjustment_group, discount.adjustment_code)
145
+ )
146
+ )
147
+ )
148
+
149
+ @property
150
+ def charges_amount(self) -> Decimal:
151
+ """Returns the charges amount per claim for a patient posting."""
152
+ return self.discounted_amount + self.paid_amount
153
+
154
+
155
+ class AbstractBulkPosting(models.Model):
156
+ """Patient and Insurance bulk posting shared columns."""
157
+
158
+ class Meta:
159
+ abstract = True
160
+
161
+ id = models.UUIDField()
162
+ dbid = models.BigIntegerField(primary_key=True)
163
+
164
+ payment_collection = models.OneToOneField(
165
+ "v1.PaymentCollection", related_name="%(class)s", on_delete=models.PROTECT
166
+ )
167
+
168
+ total_paid = models.DecimalField(max_digits=8, decimal_places=2)
169
+
170
+ created = models.DateTimeField()
171
+ modified = models.DateTimeField()
172
+
173
+
174
+ class BulkPatientPosting(AbstractBulkPosting):
175
+ """Model to aggregate bulk patient payments on multiple claims."""
176
+
177
+ class Meta:
178
+ managed = False
179
+ db_table = "canvas_sdk_data_quality_and_revenue_bulkpatientposting_001"
180
+
181
+ discount = models.ForeignKey(
182
+ "v1.Discount", related_name="patient_postings", null=True, on_delete=models.SET_NULL
183
+ )
184
+ payer = models.ForeignKey("v1.Patient", related_name="payments", on_delete=models.PROTECT)
185
+
186
+ @property
187
+ def total_posted_amount(self) -> Decimal:
188
+ """Property to compute how much was posted with all associated postings."""
189
+ postings = self.postings.active()
190
+ return quantize(sum(posting.posted_amount for posting in postings))
191
+
192
+ @property
193
+ def discounted_amount(self) -> Decimal:
194
+ """Returns the sum of discounted amounts for every posting created with this collection."""
195
+ postings = self.postings.active()
196
+ return quantize(sum(posting.discounted_amount for posting in postings))
197
+
198
+
199
+ class BaseRemittanceAdvice(AbstractBulkPosting):
200
+ """Manual and Electronic Shared columns."""
201
+
202
+ class Meta:
203
+ managed = False
204
+ db_table = "canvas_sdk_data_quality_and_revenue_baseremittanceadvice_001"
205
+
206
+ transactor = models.ForeignKey(
207
+ "v1.Transactor", related_name="remits", null=True, on_delete=models.PROTECT
208
+ )
209
+
210
+ era_id = models.CharField(max_length=255, null=True, blank=True, db_index=True)
211
+
212
+ @property
213
+ def total_posted_amount(self) -> Decimal:
214
+ """Property to compute how much was posted with all associated postings."""
215
+ postings = self.postings.active()
216
+ return quantize(sum(posting.posted_amount for posting in postings))
217
+
218
+
219
+ __exports__ = (
220
+ "BasePosting",
221
+ "CoveragePosting",
222
+ "PatientPosting",
223
+ "BulkPatientPosting",
224
+ "BaseRemittanceAdvice",
225
+ )
@@ -48,8 +48,12 @@ class ProtocolOverride(models.Model):
48
48
  created = models.DateTimeField()
49
49
  modified = models.DateTimeField()
50
50
  deleted = models.BooleanField()
51
- committer = models.ForeignKey("v1.CanvasUser", on_delete=models.DO_NOTHING, null=True)
52
- entered_in_error = models.ForeignKey("v1.CanvasUser", on_delete=models.DO_NOTHING, null=True)
51
+ committer = models.ForeignKey(
52
+ "v1.CanvasUser", on_delete=models.DO_NOTHING, null=True, related_name="+"
53
+ )
54
+ entered_in_error = models.ForeignKey(
55
+ "v1.CanvasUser", on_delete=models.DO_NOTHING, null=True, related_name="+"
56
+ )
53
57
  patient = models.ForeignKey(
54
58
  "v1.Patient", on_delete=models.DO_NOTHING, related_name="protocol_overrides", null=True
55
59
  )
@@ -148,8 +148,12 @@ class Interview(models.Model):
148
148
  id = models.UUIDField()
149
149
  dbid = models.BigIntegerField(primary_key=True)
150
150
  deleted = models.BooleanField()
151
- committer = models.ForeignKey("v1.CanvasUser", on_delete=models.DO_NOTHING, null=True)
152
- entered_in_error = models.ForeignKey("v1.CanvasUser", on_delete=models.DO_NOTHING, null=True)
151
+ committer = models.ForeignKey(
152
+ "v1.CanvasUser", on_delete=models.DO_NOTHING, null=True, related_name="+"
153
+ )
154
+ entered_in_error = models.ForeignKey(
155
+ "v1.CanvasUser", on_delete=models.DO_NOTHING, null=True, related_name="+"
156
+ )
153
157
  status = models.CharField()
154
158
  name = models.CharField()
155
159
  language_id = models.BigIntegerField()
@@ -11,6 +11,8 @@ class CanvasUser(models.Model):
11
11
  dbid = models.BigIntegerField(db_column="dbid", primary_key=True)
12
12
  email = models.EmailField(db_column="email")
13
13
  phone_number = models.CharField(db_column="phone_number", max_length=255)
14
+ last_invite_date_time = models.DateTimeField()
15
+ is_portal_registered = models.BooleanField()
14
16
 
15
17
 
16
18
  __exports__ = ("CanvasUser",)
@@ -0,0 +1,10 @@
1
+ from collections.abc import Sequence
2
+ from decimal import Decimal
3
+
4
+
5
+ def quantize(deci: Decimal | float | str | tuple[int, Sequence[int], int]) -> Decimal:
6
+ """Rounds a Decimal value to two decimal places."""
7
+ return Decimal(deci).quantize(Decimal(".01"))
8
+
9
+
10
+ __exports__ = ()
@@ -269,8 +269,14 @@ enum EffectType {
269
269
  UPDATE_USER = 5000;
270
270
 
271
271
  CREATE_NOTE = 6000;
272
+ UPDATE_NOTE = 6013;
273
+
272
274
  CREATE_APPOINTMENT = 6001;
275
+ UPDATE_APPOINTMENT = 6014;
276
+ CANCEL_APPOINTMENT = 6015;
273
277
  CREATE_SCHEDULE_EVENT = 6002;
278
+ UPDATE_SCHEDULE_EVENT = 6016;
279
+ DELETE_SCHEDULE_EVENT = 6017;
274
280
 
275
281
  CREATE_PATIENT = 6003;
276
282
 
@@ -281,6 +287,7 @@ enum EffectType {
281
287
 
282
288
  PATIENT_METADATA__CREATE_ADDITIONAL_FIELDS = 6010;
283
289
  UPSERT_PATIENT_METADATA = 6011;
290
+ CREATE_PATIENT_EXTERNAL_IDENTIFIER = 6012;
284
291
  }
285
292
 
286
293
  message Effect {