Health-Informatics-UoN / Carrot-Mapper

Carrot: Convenient And Reusable Rapid Omop Transformer.
https://carrot4omop.ac.uk
MIT License
12 stars 3 forks source link

Mapping rules Term Map column returning null #637

Closed AndyRae closed 3 months ago

AndyRae commented 4 months ago

Is there an existing issue for this?

Current Behavior

On a fresh install of Carrot, the /mapping_rules/ page on a Scan Report may not show the entire mapping in the Term Map column.

Screenshot 2024-02-12 at 17 30 12

Expected Behavior

I would expect the sample data set to return something like this:

Screenshot 2024-02-12 at 17 17 51

Steps To Reproduce

  1. Create a new instance of the product in a clean database.
  2. Upload a scan report and add rules as in the quickstart.
  3. View the rules table.

Environment

- OS: MacOS 14.3.1
- Other environment details: Using the repository developer environment.

I'm part of a Project Team

DRS

Anything else?

The issue is that the content_type is hardcoded throughout the application, and relies on the django_content_type ID being 15 (ScanReportField) or 17 (ScanReportValue), this is reflected in the docs.

But there is no reason to expect those IDs to be attached to those types, and the current code does not create a table that does (they use ID 13 and 14). As it is the order of models.py and migrations that will probably influence what the IDs are, which have presumably changed.

Ironically most of the code works fine with these hardcoded values. For example concepts are created with a content_type of 15, and then have conditions on being 15 in both the backend and frontend, which is assumed to be ScanReportField, even if it actually isn't. The exception is the /mapping_rules table, which correctly uses get_for_model here. The code is complex to follow, but is used to create the term mapping, and the API endpoint will just return term_mapping: null.

Fix is one of these possibilities I think:

Are you willing to contribute to resolve this issue?

Yes