5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/serializers/lab/lab_order_serializer.rb', line 5
def self.serialize_order(order, tests: nil, requesting_clinician: nil, reason_for_test: nil, target_lab: nil)
tests ||= order.voided == 1 ? voided_tests(order) : order.tests
requesting_clinician ||= order.requesting_clinician
reason_for_test ||= order.reason_for_test
target_lab = target_lab&.value_text || order.target_lab&.value_text || Location.current_health_center&.name
ActiveSupport::HashWithIndifferentAccess.new(
{
id: order.order_id,
order_id: order.order_id, encounter_id: order.encounter_id,
order_date: order.date_created,
patient_id: order.patient_id,
accession_number: order.accession_number,
specimen: {
concept_id: order.concept_id,
name: concept_name(order.concept_id)
},
requesting_clinician: requesting_clinician&.value_text,
target_lab: target_lab,
reason_for_test: {
concept_id: reason_for_test&.value_coded,
name: concept_name(reason_for_test&.value_coded)
},
delivery_mode: order&.lims_acknowledgement_status&.acknowledgement_type,
tests: tests.map do |test|
result_obs = test.children.first
{
id: test.obs_id,
concept_id: test.value_coded,
uuid: test.uuid,
name: concept_name(test.value_coded),
result: result_obs && ResultSerializer.serialize(result_obs)
}
end
}
)
end
|