fhirbase / fhirbase-plv8

[DEPRECATED] Fhirbase 2.0 is an FHIR relational storage
https://health-samurai.io/fhirbase
Other
105 stars 39 forks source link

fhir_index_parameter fails when there are multiple hyphens in the searchparameter name #168

Closed uuppala closed 7 years ago

uuppala commented 7 years ago

fhir_index_parameter fails when there are multiple hyphens in the parameter name.

e.g. select fhir_index_parameter('{"resourceType":"Observation","name":"data-absent-reason"}') fails with the error ERROR: Error: syntax error at or near "-" DETAIL: plv8_init() LINE 257: return plv8.execute.call(plv8, q[0], q.slice(1));

The reason is when constructing the index name javascript "replace" function is used which will only replace the first occurrence idxname = "#{meta.resourceType.toLowerCase()}#{meta.name.replace('-','_')}_token" So the index name for the above example is constructed as "name":"observation_data_absent-reason_token"

Suggestion: Solution could be to use split and join instead of replace idxname = "#{meta.resourceType.toLowerCase()}#{meta.name.split('-').join('_')}_token"

uuppala commented 7 years ago

115 Sorry did not see there is an issue already raised. Closing this issue and added comments in #115