-
Notifications
You must be signed in to change notification settings - Fork 348
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
Adding consent Viewset #2856
base: vigneshhari/devices
Are you sure you want to change the base?
Adding consent Viewset #2856
Conversation
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@@ -49,6 +50,18 @@ def file_authorizer(user, file_type, associating_id, permission): | |||
allowed = AuthorizationController.call( | |||
"can_update_encounter_obj", user, encounter_obj | |||
) | |||
elif file_type == FileTypeChoices.consent.value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its repeating the same thing as above, can we reuse the logic ?
|
||
class Consent(EMRBaseModel): | ||
status = models.CharField(max_length=50) | ||
category = models.JSONField(default=list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Category is a code right? can we make it as a single string?
) | ||
decision = models.CharField(max_length=10) | ||
verification_details = models.JSONField(null=True, blank=True) | ||
source_attachment = ArrayField(models.UUIDField(), default=[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this here? or can we fetch from the other table?
for attachment in obj.source_attachment or [] | ||
] | ||
mapping["encounter"] = obj.encounter.external_id | ||
mapping["source_attachment"] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it done twice?
] | ||
|
||
|
||
class ConsentRetrieveSpec(ConsentBaseSpec): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If retrieve is same as list, inherit instead of re-writing it.
|
||
@extend_schema(request=ConsentFileUploadCreateSpec) | ||
@action(detail=True, methods=["POST"]) | ||
def add_attachment(self, request, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this different from just using the API for file uploads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance.source_attachment.append(file_obj.external_id)
here we are creating the file and also adding it to the source_attachment field of consent object
return super().get_queryset() | ||
|
||
@action(detail=True, methods=["GET"]) | ||
def get_attachments(self, request, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the retrieve API already gives all the attachments why the separate API ?
def get_patient_obj(self): | ||
return self.get_object().encounter.patient | ||
|
||
def authorize_read_encounter(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isnt this defined in the base?
# Todo: Implement File authorization so that only attachments that the user has access to are returned | ||
if self.action == "list": | ||
# Todo: Implement permission checks for encounters to return only consent's whose encounters the user has access to | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement this. Look at any of the encounter related viewsets
Proposed Changes
Associated Issue
Architecture changes
Merge Checklist
/docs
Only PR's with test cases included and passing lint and test pipelines will be reviewed
@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins