Skip to content

Commit

Permalink
fix: create_patient_medical_records_for_observations patch failing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajinsr committed Dec 25, 2024
1 parent bd7ba82 commit e93df1c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion healthcare/healthcare/doctype/observation/observation.html
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

0 comments on commit e93df1c

Please sign in to comment.