hamyar_paygah.services.mission_details_service¶
Services to get mission details from server.
Attributes¶
Functions¶
|
Fetch details of a mission from the EMS SOAP service. |
|
Generate a cache file path for a given mission and patient ID. |
|
Save XML response as compressed LZMA file. |
|
Load compressed XML response from cache. |
|
Get mission details with caching mechanism. |
Module Contents¶
- hamyar_paygah.services.mission_details_service.CACHE_DIR¶
- async hamyar_paygah.services.mission_details_service._fetch_mission_details(server_address, mission_id, patient_id)¶
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.
- Parameters:
- 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.
- Return type:
- hamyar_paygah.services.mission_details_service._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.
- Parameters:
- Returns:
The path to the cache file.
- Return type:
- hamyar_paygah.services.mission_details_service._save_xml_cache(mission_id, patient_id, xml_text)¶
Save XML response as compressed LZMA file.
- hamyar_paygah.services.mission_details_service._load_xml_cache(mission_id, patient_id)¶
Load compressed XML response from cache.
- async hamyar_paygah.services.mission_details_service.get_mission_details(server_address, mission_id, patient_id)¶
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.
- Parameters:
- Returns:
An object containing the details of the mission.
- Return type: