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

Default module id not working #588

Open
liquid36 opened this issue Apr 23, 2024 · 4 comments
Open

Default module id not working #588

liquid36 opened this issue Apr 23, 2024 · 4 comments
Assignees

Comments

@liquid36
Copy link
Contributor

Hi! I'm dealing with an issue trying yo create concepts. I created a new branch and set the default namespaces and module id. But if I create new concepts without moduleId, Snowstorm is still using de CORE_MODULE ID (900000000000207008).

Debugging the code i found out the problem (i think):

First, when concept is created, the CORE_MODULE is using as default:

https://github.com/IHTSDO/snowstorm/blob/master/src/main/java/org/snomed/snowstorm/core/data/domain/Concept.java#L97

So, the following conditions is always false:

https://github.com/IHTSDO/snowstorm/blob/master/src/main/java/org/snomed/snowstorm/core/data/services/ConceptUpdateHelper.java#L260

Descriptions and relationships is working fine.

@kaicode kaicode self-assigned this Apr 23, 2024
@kaicode
Copy link
Member

kaicode commented Apr 23, 2024

The core module should only be used when no default module is found in the branch metadata, including ancestor branches until the Codesystem branch.
The core module that you found in the java constructor should only be used by unit tests. It should get set to null when deserialising JSON.
Can you confirm that you are setting the module in the branch metadata using the key defaultModuleId. Can you also confirm that this module is being used for the new descriptions? Could you send an example request body too please? I can help debug this.

@liquid36
Copy link
Contributor Author

Yes, i'm using the key defaultModuleId. Look what I'm doing:

  1. Create codesystem
curl -X 'POST' \
  'http://localhost:8080/codesystems' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "TEST",
  "owner": "",
  "shortName": "TEST",
  "branchPath": "MAIN/SNOMEDCT-ES/SNOMEDCT-AR/TEST",
  "dependantVersionEffectiveTime": 20231130,
  "defaultLanguageCode": "es",
  "countryCode": "ar"
  
}'
  1. Update branch metadata:
curl -X 'PUT' \
  'http://localhost:8080/branches/MAIN%2FSNOMEDCT-ES%2FSNOMEDCT-AR%2FTEST/metadata-upsert' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "defaultNamespace": "1000309",
  "defaultModuleId" : "733690761000309105"

}'
  1. Create concept
curl -X 'POST' \
  'http://localhost:8080/browser/MAIN%2FSNOMEDCT-ES%2FSNOMEDCT-AR%2FTEST/concepts?validate=false' \
  -H 'accept: application/json' \
  -H 'Accept-Language: en-X-900000000000509007,en-X-900000000000508004,en' \
  -H 'Content-Type: application/json' \
  -d '{
            "descriptions": [
                {
                    "active": true,
                    "term": "test concept (finding)",
                    "acceptabilityMap": {
                        "450828004": "PREFERRED"
                    },
                    "typeId": "900000000000003001",
                    "type": "FSN",
                    "lang": "es",
                    "caseSignificance": "ENTIRE_TERM_CASE_SENSITIVE"
                },
                {
                    "active": true,
                    "term": "test concept",
                    "typeId": "900000000000013009",
                    "acceptabilityMap": {
                        "450828004": "PREFERRED"
                    },
                    "type": "SYNONYM",
                    "lang": "es",
                    "caseSignificance": "ENTIRE_TERM_CASE_SENSITIVE"
                }
            ],

            "classAxioms": [
               
            ]
        }'

The response:

{
  "conceptId": "706832731000309109",
  "fsn": {},
  "pt": {},
  "active": true,
  "released": false,
  "moduleId": "900000000000207008",
  "definitionStatus": "PRIMITIVE",
  "descriptions": [
    {
      "active": true,
      "moduleId": "733690761000309105",
      "released": false,
      "descriptionId": "104253741000309115",
      "term": "test concept",
      "conceptId": "706832731000309109",
      "typeId": "900000000000013009",
      "acceptabilityMap": {
        "450828004": "PREFERRED"
      },
      "type": "SYNONYM",
      "lang": "es",
      "caseSignificance": "ENTIRE_TERM_CASE_SENSITIVE"
    },
    {
      "active": true,
      "moduleId": "733690761000309105",
      "released": false,
      "descriptionId": "819473001000309118",
      "term": "test concept (finding)",
      "conceptId": "706832731000309109",
      "typeId": "900000000000003001",
      "acceptabilityMap": {
        "450828004": "PREFERRED"
      },
      "type": "FSN",
      "lang": "es",
      "caseSignificance": "ENTIRE_TERM_CASE_SENSITIVE"
    }
  ],
  "annotations": [],
  "classAxioms": [],
  "gciAxioms": [],
  "relationships": [],
  "alternateIdentifiers": [],
  "validationResults": []
}

As you can see, the descriptions has the proper module Id but the main concept not.

The question is: Do I set the module id manually or not? if so, what is the pourpuse of defaultModuleId?

@kaicode
Copy link
Member

kaicode commented Apr 23, 2024

It looks like you are right that the core module will be used in the JSON to Java object deserialisation.

@kaicode
Copy link
Member

kaicode commented Apr 23, 2024

This is a bug. Setting the proper moduleId in the request body would be a good workaround. This is how the SNOMED International authoring UI makes requests. That is why the bug was not discovered sooner.
The defaultModuleId is supposed to be used in this case.

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

No branches or pull requests

2 participants