fhirbase / fhirbase-plv8

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

Creating indexes for params that have 2 dashes does not work #115

Open Andrzej-Pietrzak opened 8 years ago

Andrzej-Pietrzak commented 8 years ago

SELECT fhir_index_parameter('{"resourceType": "Observation", "name": "component-value-quantity"}');

ERROR: Error: syntax error at or near "-"

DETAIL: plv8_init() LINE 195: return plv8.execute.call(plv8, q[0], q.slice(1));

szymonp-kainos commented 8 years ago

What's the status on this issue ?

uuppala commented 7 years ago

The reason is when constructing the index name javascript "replace" function is used which will only replace the first occurrence e.g. select fhir_index_parameter('{"resourceType":"Observation","name":"data-absent-reason"}') idx_name = "#{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"