diff --git a/healthcare/healthcare/doctype/observation/observation.html b/healthcare/healthcare/doctype/observation/observation.html
index 178a767a94..f3d85b307c 100644
--- a/healthcare/healthcare/doctype/observation/observation.html
+++ b/healthcare/healthcare/doctype/observation/observation.html
@@ -125,7 +125,7 @@
{% if doc.get("name") %}
{% set full_data = get_observations_for_medical_record(doc.name, doc.parent_observation) %}
- {% 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") %}
diff --git a/healthcare/healthcare/doctype/observation/observation.py b/healthcare/healthcare/doctype/observation/observation.py
index ed5611a538..8002f331fd 100644
--- a/healthcare/healthcare/doctype/observation/observation.py
+++ b/healthcare/healthcare/doctype/observation/observation.py
@@ -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
@@ -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
diff --git a/healthcare/patches.txt b/healthcare/patches.txt
index a90e136498..4b4ce0ec54 100644
--- a/healthcare/patches.txt
+++ b/healthcare/patches.txt
@@ -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