OHDSI / ROhdsiWebApi

An R package for interfacing with a WebAPI instance
https://ohdsi.github.io/ROhdsiWebApi
10 stars 17 forks source link

Problem with postConceptSetDefinition #189

Closed siirtola closed 3 years ago

siirtola commented 3 years ago

I might have misunderstood something, but shouldn't the getConceptSetDefinition and postConceptSetDefinition be symmetric? Below, I get a concept set from Atlas ("asthma", just the standard asthma definition) and try to post it under a new name. Atlas responds "Bad Request (HTTP 400)".

# ATLAS Version 2.7.8 Release 
# WebAPI Version 2.7.8 Release 
# 
# Both client and server have the same java version:
# openjdk version "1.8.0_292"
# OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
# OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)

asthma_id <- 30 # standard "asthma" concept
conceptSetDefinition <- ROhdsiWebApi::getConceptSetDefinition(conceptSetId = asthma_id, baseUrl = "http://localhost/WebAPI")

conceptSetDefinition

postDefinition <- ROhdsiWebApi::postConceptSetDefinition(name = "asthma_test", 
                                                         baseUrl = "http://localhost/WebAPI", 
                                                         conceptSetDefinition = conceptSetDefinition)

# Error in .request(url, method = "PUT", config = config, handle = handle,  : 
#                     Bad Request (HTTP 400).
azimov commented 3 years ago

@siirtola so the request to post a concept set defintion and get are different. This is because the id and name aren't set as part of the expression (the id will be different because

If you, instead, posted the expression it should work, e.g:

ROhdsiWebApi::postConceptSetDefinition(name = "asthma_test", 
                                                         baseUrl = "http://localhost/WebAPI", 
                                                         conceptSetDefinition = conceptSetDefinition$expression)

You would post a new definition and get a new id.

siirtola commented 3 years ago

Hi @azimov, thank you for looking into this! I tried posting just the expression, but the outcome was the same, "HTTP 400".

Do you have any suggestions how to debug this?

siirtola commented 3 years ago

Looking from the Atlas end, the new concept set is created, but the adding of concepts to it fails.

siirtola commented 3 years ago

Hi @azimov, I am still puzzled with this. Would it possible to test this on atlas-demo.ohdsi.org? Are the credentials available somewhere?

azimov commented 3 years ago

@siirtola I'm sorry I didn't get back to you, I can confirm the issue but I'm trying to determine the circumstances and what else it might be impacting.

siirtola commented 3 years ago

@azimov thanks for the confirmation! This was driving me crazy.

alondhe commented 3 years ago

Facing the same issue in Atlas/WebAPI 2.8.1.

alondhe commented 3 years ago

Looks like the issue is here: https://github.com/OHDSI/ROhdsiWebApi/blob/master/R/PostDefinition.R#L109

This payload is nested one level too deep for the PUT endpoint of "{id}/items" (handled by function saveConceptSetItems). I tried changing the call to use itemsTranspose[[1]] instead, and it worked. Making a PR.

azimov commented 3 years ago

@alondhe thanks for the fix! Looks like it works following the more recent patch. We should try and make a PR next time, even its small its good to have extra eyes review the changes.