hamyar_paygah.services.mission_details_service ============================================== .. py:module:: hamyar_paygah.services.mission_details_service .. autoapi-nested-parse:: Services to get mission details from server. Attributes ---------- .. autoapisummary:: hamyar_paygah.services.mission_details_service.CACHE_DIR Functions --------- .. autoapisummary:: hamyar_paygah.services.mission_details_service._fetch_mission_details hamyar_paygah.services.mission_details_service._get_cache_file_path hamyar_paygah.services.mission_details_service._save_xml_cache hamyar_paygah.services.mission_details_service._load_xml_cache hamyar_paygah.services.mission_details_service.get_mission_details Module Contents --------------- .. py:data:: CACHE_DIR .. py:function:: _fetch_mission_details(server_address, mission_id, patient_id) :async: Fetch details of a mission from the EMS SOAP service. This function send an asynchronous SOAP request to the EMS reporting service and retrieves the raw XML response containing mission details for the given mission ID and patient ID. The request uses a legacy SOAP endpoint with strict field names. :param server_address: Base address of the EMS server (without trailing slash). :type server_address: str :param mission_id: ID of the mission. :type mission_id: int :param patient_id: ID of the patient. :type patient_id: int :returns: The raw SOAP response body as a string. The returned value is unparsed XML and must be processed by the caller if structured data is required. .. py:function:: _get_cache_file_path(mission_id, patient_id) Generate a cache file path for a given mission and patient ID. This function constructs a unique file path within the `CACHE_DIR` directory based on the provided mission ID and patient ID. The resulting file name follows the format `mission_{mission_id}_patient_{patient_id}.xml.xz`, ensuring that cached data for different missions and patients are stored separately. :param mission_id: The ID of the mission. :type mission_id: int :param patient_id: The ID of the patient. :type patient_id: int :returns: The path to the cache file. :rtype: anyio.Path .. py:function:: _save_xml_cache(mission_id, patient_id, xml_text) Save XML response as compressed LZMA file. .. py:function:: _load_xml_cache(mission_id, patient_id) Load compressed XML response from cache. .. py:function:: get_mission_details(server_address, mission_id, patient_id) :async: Get mission details with caching mechanism. This function first checks if the mission details for the given mission ID and patient ID are available in the cache. If a cached file exists, it reads the data from the cache and parses it into a `MissionDetails` object. If no cache is found, it fetches the details from the server, parses it, and saves the raw response to the cache for future use if mission is older than 2 days. :param server_address: The base address of the EMS server. :type server_address: str :param mission_id: The ID of the mission. :type mission_id: int :param patient_id: The ID of the patient. :type patient_id: int :returns: An object containing the details of the mission. :rtype: MissionDetails