Skip to content
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

Serialize ServiceRequest properly to get requester fields #2681

Open
wants to merge 1 commit into
base: khavinshankar/labs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions care/emr/resources/diagnostic_report/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ class DiagnosticReportReadSpec(BaseDiagnosticReportSpec):

@classmethod
def perform_extra_serialization(cls, mapping, obj):
mapping["based_on"] = ServiceRequestReadSpec.serialize(obj.based_on).model_dump(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use .to_json() instead.

exclude=["meta"]
)
mapping["id"] = obj.external_id

mapping["subject"] = PatientDetailSerializer(obj.subject).data
Expand Down
2 changes: 1 addition & 1 deletion care/emr/resources/service_request/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class ServiceRequestReadSpec(BaseServiceRequestSpec):

@classmethod
def perform_extra_serialization(cls, mapping, obj):
mapping["id"] = obj.external_id
mapping["id"] = obj.id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

It is a mistake in interpretation. Before mapping mapping["based_on"] = ServiceRequestReadSpec.serialize(obj.based_on).model_dump( it was returning id so after adding manual mapping it is returning exterbal_id I thought we needed to show id instead of the external_id. Now I think I realised we are supposed to external_id 🙂


mapping["subject"] = PatientDetailSerializer(obj.subject).data
mapping["encounter"] = PatientConsultationSerializer(obj.encounter).data
Expand Down
4 changes: 4 additions & 0 deletions care/emr/resources/specimen/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ def perform_extra_serialization(cls, mapping, obj):
else None
)

mapping["request"] = ServiceRequestReadSpec.serialize(obj.request).model_dump(
exclude=["meta"]
)


class SpecimenCollectRequest(BaseModel):
identifier: str | None = Field(
Expand Down
Loading