hamyar_paygah.services.parsers

XML parsers module.

This module provides functions to parse SOAP XML responses from the EMS server and convert them into Python data models.

Functions

parse_to_missions_list(xml_text)

Parse EMS mission data from a SOAP XML response.

parse_to_mission_details(xml_text)

Parse EMS mission details from a SOAP XML response.

_parse_information(document, namespaces)

Parses the information sub model and returns it.

_parse_times_and_distances(document, namespaces)

_parse_location_and_emergency(document, namespaces)

Parses the location and emergency sub model and returns it.

_parse_symptoms(document, namespaces)

Parses the symptoms sub model and returns it.

_parse_vital_signs(document, namespaces)

Extracts patient vital sign records from SOAP XML response.

_parse_medical_history(document, namespaces)

Extracts patient medical history from SOAP XML response.

_parse_pupils_lungs_heart(document, namespaces)

Parses the pupils, lungs and heart sub model and returns it.

_parse_pupil_status(document, namespaces, pupil_side)

Parses the status of pupil from server into Pupil status object.

_parse_lung_status(document, namespaces, lung_side)

Parses the status of lung from server into Lung side object.

_parse_heart_status(document, namespaces)

Parses the status of heart from server into heart object.

_parse_trauma_types(document, namespaces)

Parses the trauma types sub model and returns it.

_parse_medical_actions(document, namespaces)

Parses the medical actions sub model and returns it.

_parse_drugs_list(document, namespaces)

Parses the list of drugs sub model and returns it.

_parse_mission_result(document, namespaces)

Parses the mission result sub model and returns it.

_parse_medical_center(document, namespaces)

Parses the medical center sub model and returns it.

_parse_consumables_used(document, namespaces)

Parses the consumables used sub model and returns it.

Module Contents

hamyar_paygah.services.parsers.parse_to_missions_list(xml_text)

Parse EMS mission data from a SOAP XML response.

This function reads a raw SOAP XML string returned from the EMS server, extracts each <DocumentReport> element, and converts it into a Mission dataclass instance. Fields that may be missing or nil are safely handled. Numeric fields are converted using convert_to_integer, and missing string fields are defaulted to an empty string.

Parameters:

xml_text (str) – Raw XML string returned from the EMS SOAP server.

Returns:

A list of Mission dataclass instances representing each mission in the XML response.

Return type:

list[Mission]

hamyar_paygah.services.parsers.parse_to_mission_details(xml_text)

Parse EMS mission details from a SOAP XML response.

Parameters:

xml_text (str) – Raw XML string returned from the EMS SOAP server.

Returns:

Details of a mission in an object.

Return type:

MissionDetails

hamyar_paygah.services.parsers._parse_information(document, namespaces)

Parses the information sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

Information sub model

Return type:

Information

hamyar_paygah.services.parsers._parse_times_and_distances(document, namespaces)
Parameters:
  • document (lxml.etree._Element)

  • namespaces (dict[str, str])

Return type:

hamyar_paygah.models.mission_details_submodels.times_and_distances_model.TimesAndDistances

hamyar_paygah.services.parsers._parse_location_and_emergency(document, namespaces)

Parses the location and emergency sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

Location and emergency sub model

Return type:

LocationAndEmergency

hamyar_paygah.services.parsers._parse_symptoms(document, namespaces)

Parses the symptoms sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

Symptoms sub model

Return type:

Symptoms

hamyar_paygah.services.parsers._parse_vital_signs(document, namespaces)

Extracts patient vital sign records from SOAP XML response.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

List of vita signs

Return type:

list[VitalSigns]

hamyar_paygah.services.parsers._parse_medical_history(document, namespaces)

Extracts patient medical history from SOAP XML response.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

Medical history of patient

Return type:

MedicalHistory

hamyar_paygah.services.parsers._parse_pupils_lungs_heart(document, namespaces)

Parses the pupils, lungs and heart sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

Pupils, lungs and heart model

Return type:

PupilsLungsHeart

hamyar_paygah.services.parsers._parse_pupil_status(document, namespaces, pupil_side)

Parses the status of pupil from server into Pupil status object.

Parameters:
  • document (etree._Element) – XML SOAP response

  • namespaces (dict[str, str]) – SOAP namespaces

  • pupil_side (str) – “R” for right side and “L” for left side

Returns:

PupilStatus object or none.

Return type:

PupilStatus | None

hamyar_paygah.services.parsers._parse_lung_status(document, namespaces, lung_side)

Parses the status of lung from server into Lung side object.

Parameters:
  • document (etree._Element) – XML SOAP response

  • namespaces (dict[str, str]) – SOAP namespaces

  • lung_side (str) – “R” for right side and “L” for left side.

Returns:

LungSide object.

Return type:

LungSide

hamyar_paygah.services.parsers._parse_heart_status(document, namespaces)

Parses the status of heart from server into heart object.

Parameters:
  • document (etree._Element) – XML SOAP response

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

Heart object.

Return type:

Heart

hamyar_paygah.services.parsers._parse_trauma_types(document, namespaces)

Parses the trauma types sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

trauma types sub model

Return type:

TraumaTypes

hamyar_paygah.services.parsers._parse_medical_actions(document, namespaces)

Parses the medical actions sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

Medical actions sub model

Return type:

MedicalActions

hamyar_paygah.services.parsers._parse_drugs_list(document, namespaces)

Parses the list of drugs sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

list of drugs sub model

Return type:

list[Drug]

hamyar_paygah.services.parsers._parse_mission_result(document, namespaces)

Parses the mission result sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

mission result sub model

Return type:

MissionResult

hamyar_paygah.services.parsers._parse_medical_center(document, namespaces)

Parses the medical center sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

medical center sub model

Return type:

MedicalCenter

hamyar_paygah.services.parsers._parse_consumables_used(document, namespaces)

Parses the consumables used sub model and returns it.

Parameters:
  • document (etree._Element) – XML SOAP document

  • namespaces (dict[str, str]) – SOAP namespaces

Returns:

consumables used sub model

Return type:

ConsumablesUsed