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

fix: create_patient_medical_records_for_observations patch failing #560

Merged
merged 1 commit into from
Dec 25, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
{% if doc.get("name") %}
{% set full_data = get_observations_for_medical_record(doc.name, doc.parent_observation) %}
<div class="observation-report">
{% for data in full_data[0] %}
{% for data in full_data %}
{% if not data.get("has_component") %}
{% if data.get("observation").get("preferred_display_name") %}
{% set observation_name = data.get("observation").get("preferred_display_name") %}
Expand Down
25 changes: 22 additions & 3 deletions healthcare/healthcare/doctype/observation/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def get_child_observations(obs):
)


def return_child_observation_data_as_dict(child_observations, obs, obs_length):
def return_child_observation_data_as_dict(child_observations, obs, obs_length=0):
obs_list = []
has_result = False
obs_approved = False
Expand Down Expand Up @@ -613,6 +613,25 @@ def get_observations_for_medical_record(observation, parent_observation=None):
else:
obs_doc = frappe.get_doc("Observation", observation)

out_data, obs_length = aggregate_and_return_observation_data([obs_doc])
obs_doc = obs_doc.as_dict()
out_data = []

return out_data, obs_length
if not obs_doc.get("has_component"):
if obs_doc.get("permitted_data_type") == "Select" and obs_doc.get("options"):
obs_doc["options_list"] = obs_doc.get("options").split("\n")

if obs_doc.get("observation_template") and obs_doc.get("specimen"):
obs_doc["received_time"] = frappe.get_value(
"Specimen", obs_doc.get("specimen"), "received_time"
)

out_data.append({"observation": obs_doc})

else:
child_observations = get_child_observations(obs_doc)
obs_dict = return_child_observation_data_as_dict(child_observations, obs_doc)

if len(obs_dict) > 0:
out_data.append(obs_dict)

return out_data
2 changes: 1 addition & 1 deletion healthcare/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ healthcare.patches.v15_0.rename_medical_code_standard_and_medical_code
healthcare.patches.v15_0.setup_service_request
healthcare.patches.v15_0.create_custom_field_in_payment_entry
healthcare.patches.v15_0.add_observation_to_patient_history
healthcare.patches.v15_0.create_patient_medical_records_for_observations
healthcare.patches.v15_0.create_patient_medical_records_for_observations #25-12-2024

[post_model_sync]
healthcare.patches.v15_0.rename_field_medical_department_in_appoitment_type_service_item
Expand Down
Loading