Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task
dubdabasoduba opened this issue Sep 19, 2024 · 5 comments
Open
1 task

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

dubdabasoduba opened this issue Sep 19, 2024 · 5 comments
Assignees
Labels

Comments

@dubdabasoduba
Copy link
Member

Context.

  • The Inventory importer script seems to fail in some instances. This seems to be caused by an addition of multiple references to the List.subject
  • The subject property can only hold one reference.

Acceptance Criteria

  • Correctly map List subjects and entries to avoid such errors.

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
Copy link
Contributor

Wambere commented Sep 20, 2024

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

@Wambere
Copy link
Contributor

Wambere commented Sep 23, 2024

@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:

  • 0 resources: we create a new one
  • 1 resource: we update it (adding items to the entry)
  • anything else: we throw the error above

Should this be working differently?

@dubdabasoduba
Copy link
Member Author

@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
Copy link
Contributor

Wambere commented Sep 23, 2024

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
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants