Skip to content

Commit

Permalink
Added Medication Update spec
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari committed Jan 15, 2025
1 parent fab832b commit 109e855
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions care/emr/api/viewsets/medication_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
MedicationRequestReadSpec,
MedicationRequestSpec,
MedicationRequestStatus,
MedicationRequestUpdateSpec,
)
from care.emr.resources.questionnaire.spec import SubjectType

Expand Down Expand Up @@ -49,6 +50,7 @@ class MedicationRequestViewSet(
database_model = MedicationRequest
pydantic_model = MedicationRequestSpec
pydantic_read_model = MedicationRequestReadSpec
pydantic_update_model = MedicationRequestUpdateSpec
questionnaire_type = "medication_request"
questionnaire_title = "Medication Request"
questionnaire_description = "Medication Request"
Expand Down
1 change: 1 addition & 0 deletions care/emr/api/viewsets/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def mine(self, request, *args, **kwargs):
class OrganizationUserFilter(filters.FilterSet):
username = filters.CharFilter(field_name="user__username", lookup_expr="icontains")


class OrganizationUsersViewSet(EMRModelViewSet):
database_model = OrganizationUser
pydantic_model = OrganizationUserWriteSpec
Expand Down
9 changes: 8 additions & 1 deletion care/emr/resources/medication/request/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,12 @@ def validate_method(cls, code):
)


class BaseMedicationRequestSpec(EMRResource):
class MedicationRequestResource(EMRResource):
__model__ = MedicationRequest
__exclude__ = ["patient", "encounter"]


class BaseMedicationRequestSpec(MedicationRequestResource):
id: UUID4 = None

status: MedicationRequestStatus
Expand Down Expand Up @@ -248,6 +251,10 @@ def perform_extra_deserialization(self, is_update, obj):
obj.patient = obj.encounter.patient


class MedicationRequestUpdateSpec(MedicationRequestResource):
status: MedicationRequestStatus


class MedicationRequestReadSpec(BaseMedicationRequestSpec):
created_by: UserSpec = dict
updated_by: UserSpec = dict
Expand Down

0 comments on commit 109e855

Please sign in to comment.