When sending FHIR messages to the test harness, the FHIR release required is STU3. I have tried to parse the ACK using the following :
from fhir.resources.STU3.bundle import Bundle as STU3Bundle
message_content_xml_bytes = client.retrieve_message(message_id).read()
message_content_fhir = STU3Bundle.parse_raw(message_content_xml_bytes, content_type='text/xml')
Traceback:
message_content_fhir = STU3Bundle.parse_raw(message_content_xml_bytes, content_type='text/xml')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\site-packages\fhir\resources\core\fhirabstractmodel.py", line 258, in parse_raw
obj = load_str_bytes(
^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\site-packages\fhir\resources\core\utils\__init__.py", line 96, in load_str_bytes
obj = xml_loads(extra["cls"], b, **params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\site-packages\fhir\resources\core\utils\xml.py", line 1038, in xml_loads
return node.to_fhir(cls)
^^^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\site-packages\fhir\resources\core\utils\xml.py", line 942, in to_fhir
value = Node.get_fhir_value(child, field)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\site-packages\fhir\resources\core\utils\xml.py", line 895, in get_fhir_value
value = obj.to_fhir(klass_)
^^^^^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\site-packages\fhir\resources\core\utils\xml.py", line 942, in to_fhir
value = Node.get_fhir_value(child, field)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\site-packages\fhir\resources\core\utils\xml.py", line 895, in get_fhir_value
value = obj.to_fhir(klass_)
^^^^^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\site-packages\fhir\resources\core\utils\xml.py", line 905, in to_fhir
klass_ = get_fhir_root_module(f_release).get_fhir_model_class(child.name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\site-packages\fhir\resources\core\utils\xml.py", line 77, in get_fhir_root_module
FHIR_ROOT_MODULES[fhir_release] = importlib.import_module(mod_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python 3.11.0\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'fhir.resources.R4'
I have also tried the same using other FHIR release types (default / R4B) but then get validation errors regarding the "event" property of the message.
Please let me know if you require any further information.
@lshironschec thanks for your error report. I will look on it as soon as possible. Though it could take a bit time, as I am so busy now with my professional works.
fhir.resources==7.0.2 Python 3.11.0 Windows 10
Description
Attempting to use
Bundle.parse_raw
to convert XML byte string into aBundle
object.XML byte string content is an acknowledgment response from NHS MESH ITK Test Harness, which includes
OperationOutcome
resource. XML Content :What I Did
When sending FHIR messages to the test harness, the FHIR release required is STU3. I have tried to parse the ACK using the following :
Traceback:
I have also tried the same using other FHIR release types (default / R4B) but then get validation errors regarding the "event" property of the message.
Please let me know if you require any further information.