Module: Lab::Lims::OrderSerializer

Extended by:
Utils
Defined in:
app/services/lab/lims/order_serializer.rb

Overview

Serializes a LabOrder into a LIMS OrderDTO.

Constant Summary

Constants included from Utils

Utils::LIMS_LOG_PATH, Utils::TEST_NAME_MAPPINGS

Class Method Summary collapse

Methods included from Utils

find_concept_by_name, lab_user, logger, parse_date, structify, translate_test_name

Class Method Details

.serialize_order(order) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/services/lab/lims/order_serializer.rb', line 15

def serialize_order(order)
  serialized_order = Lims::Utils.structify(Lab::LabOrderSerializer.serialize_order(order))
  Lims::OrderDTO.new(
    _id: Lab::LimsOrderMapping.find_by(order: order)&.lims_id || serialized_order.accession_number,
    tracking_number: serialized_order.accession_number,
    sending_facility: current_facility_name,
    receiving_facility: serialized_order.target_lab,
    tests: serialized_order.tests.map { |test| format_test_name(test.name) },
    patient: format_patient(serialized_order.patient_id),
    order_location: format_order_location(serialized_order.encounter_id),
    sample_type: format_sample_type(serialized_order.specimen.name),
    sample_status: format_sample_status(serialized_order.specimen.name),
    sample_statuses: format_sample_status_trail(order),
    test_statuses: format_test_status_trail(order),
    who_order_test: format_orderer(order),
    districy: current_district, # yes districy [sic]...
    priority: format_sample_priority(serialized_order.reason_for_test.name),
    date_created: serialized_order.order_date,
    test_results: format_test_results(serialized_order),
    type: 'Order'
  )
end