onaio / fhir-tooling

A command line utility to support FHIR Core content authoring
Other
2 stars 1 forks source link

[Impoter] Bug fix on importing inventory using the tooling #290

Open dubdabasoduba opened 4 weeks ago

dubdabasoduba commented 4 weeks ago

Context.

Acceptance Criteria

extract info


Traceback (most recent call last):
  File "/Users/dubdabasoduba/code/ona/server/fhir-tooling/importer/main.py", line 295, in <module>
    main()
  File "/Users/dubdabasoduba/code/ona/virtual-envs/lib/python3.12/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dubdabasoduba/code/ona/virtual-envs/lib/python3.12/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/dubdabasoduba/code/ona/virtual-envs/lib/python3.12/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dubdabasoduba/code/ona/virtual-envs/lib/python3.12/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dubdabasoduba/code/ona/server/fhir-tooling/importer/main.py", line 263, in main
    link_payload = link_to_location(resource_list)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dubdabasoduba/code/ona/server/fhir-tooling/importer/importer/builder.py", line 1065, in link_to_location
    return build_assign_payload(arr, "List", "subject=Location/")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dubdabasoduba/code/ona/server/fhir-tooling/importer/importer/builder.py", line 982, in build_assign_payload
    raise ValueError("The number of references should only be 0 or 1")
ValueError: The number of references should only be 0 or 1```
Wambere commented 4 weeks ago

@dubdabasoduba are you able to share the csv or the record or something that can help me recreate this?

Wambere commented 3 weeks ago

@dubdabasoduba the error above is brought by a check in the build_assign_payload function here

What it basically tries to do is figure out if we need to create a new List resource or update an existing one by checking how many List resources have the subject = the location resource. For this check we use the url https://some-project.smartregister.org/fhir/List/_search?_count=1&subject=Location/some-location-uuid

If the response has:

Should this be working differently?

dubdabasoduba commented 3 weeks ago

@Wambere I think it should work the same way but in this case it stopped the whole upload after throwing the error. Does option 3 anything else mean the server check failed?

Wambere commented 3 weeks ago

Yes, it means multiple List resources were found with the same subject Location I can update the script to simply log the error and continue. But that would just mean that none of these will be linked to the Location, that part of the process would be skipped

dubdabasoduba commented 3 weeks ago

Let me check the location and figure out why it has two lists. I think that's a bug either on the web or tooling.

pld commented 1 day ago

any update on this?