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"
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"