Skip to content

Commit

Permalink
closes #962
Browse files Browse the repository at this point in the history
  • Loading branch information
ppazos committed Jul 31, 2018
1 parent 2a30af6 commit 3bbbc89
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class DataCriteriaDV_CODED_TEXT extends DataCriteria {
]
],
[
value: [contains: 'value']
value: [contains: 'value', eq: 'value']
]
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
package com.cabolabs.ehrserver.query.datatypes

import com.cabolabs.ehrserver.query.DataCriteria
import com.cabolabs.openehr.opt.manager.OptManager
import com.cabolabs.ehrserver.ehr.clinical_documents.ArchetypeIndexItem
import org.springframework.web.context.request.RequestContextHolder

class DataCriteriaDV_ORDINAL extends DataCriteria {

Expand Down Expand Up @@ -66,48 +69,80 @@ class DataCriteriaDV_ORDINAL extends DataCriteria {
symbol_valueValue column: "dv_ordinal_value"
}

/**
* Metadata that defines the types of criteria supported to search
* by conditions over DV_CODED_TEXT.
* @return
*/
static List criteriaSpec(String archetypeId, String path, boolean returnCodes = true)
{
return [
[ // for the ordinal number
value: [
eq: 'value', // operands eq,lt,gt,... can be applied to attribute magnitude and the reference value is a single value
lt: 'value',
gt: 'value',
neq: 'value',
le: 'value',
ge: 'value',
between: 'range'
]
],
[ // like dv text
symbol_value: [
contains: 'value', // ilike %value%
eq: 'value'
]
],
[ // like coded text
symbol_code: [
eq: 'value', // operand eq can be applied to attribute code and the reference value is a single value
in_list: 'list' // operand in_list can be applied to attribute code and the reference value is a list of values
],
symbol_terminology_id: [
eq: 'value',
contains: 'value'
]
]
]
}
/**
* Metadata that defines the types of criteria supported to search
* by conditions over DV_CODED_TEXT.
* @return
*/
static List criteriaSpec(String archetypeId, String path, boolean returnCodes = true)
{
def spec = [
[ // for the ordinal number
value: [
eq: 'value', // operands eq,lt,gt,... can be applied to attribute magnitude and the reference value is a single value
lt: 'value',
gt: 'value',
neq: 'value',
le: 'value',
ge: 'value',
between: 'range'
]
]
/*, // REMOVED the other criteria because it only make sense to query by the ordinal value and get the code, not query by the code.
[ // like dv text
symbol_value: [
contains: 'value', // ilike %value%
eq: 'value'
]
],
[ // like coded text
symbol_code: [
eq: 'value', // operand eq can be applied to attribute code and the reference value is a single value
in_list: 'list', // operand in_list can be applied to attribute code and the reference value is a list of values
in_snomed_exp: 'snomed_exp'
],
symbol_terminology_id: [
eq: 'value',
contains: 'value'
]
]
*/
]

static List attributes()
{
return ['value', 'symbol_value', 'symbol_code', 'symbol_terminology_id']
}
if (returnCodes)
{
def optMan = OptManager.getInstance()
def codes = [:]
def lang = RequestContextHolder.currentRequestAttributes().session.lang
def namespace = RequestContextHolder.currentRequestAttributes().session.organization.uid
def constraint = optMan.getNode(archetypeId, path, namespace)

if (constraint.type == 'C_DV_ORDINAL')
{
constraint.list.each { cdvord_item ->

//println cdvord_item.value +" "+ cdvord_item.symbol.codeString +" "+ cdvord_item.symbol.terminologyId // int, CodePhrase
/*
codes[cdvord_item.value] = [
code: cdvord_item.symbol.codeString,
name: optMan.getText(archetypeId, cdvord_item.symbol.codeString, lang, namespace),
terminologyId: cdvord_item.symbol.terminologyId // instead of putting the terminology appart from the code, this needs both and value to be on the same structure, the GUI should handle this case for displaying
]
*/
codes[cdvord_item.value] = optMan.getText(archetypeId, cdvord_item.symbol.codeString, lang, namespace)
}

spec[0].value.codes = codes
}
}

return spec
}

static List attributes()
{
return ['value', 'symbol_value', 'symbol_code', 'symbol_terminology_id']
}

static List functions()
{
Expand Down
29 changes: 22 additions & 7 deletions grails-app/views/query/create.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,10 @@ resp.responseJSON.result.message +'</div>'
possible_values = conditions['codes'];
delete conditions['codes'];
break;
case 'DV_ORDINAL':
possible_values = conditions['codes'];
delete conditions['codes'];
break;
case 'DV_QUANTITY':
possible_values = conditions['units'];
delete conditions['units'];
Expand All @@ -1290,7 +1294,6 @@ resp.responseJSON.result.message +'</div>'
}
//console.log(datatype, possible_values, conditions);
//console.log('possible values', datatype, attr, possible_values);
//console.log('conditions', conditions);
// =======================================================================================================
Expand All @@ -1309,7 +1312,6 @@ resp.responseJSON.result.message +'</div>'
criteria += '</select></div>';
// *******************************************************************************
// FIXME: date* is not supported bu FF, we might need to use a JS lib / polyfill
// *******************************************************************************
Expand Down Expand Up @@ -1353,16 +1355,13 @@ resp.responseJSON.result.message +'</div>'
for (cond in conditions)
{
//console.log('cond', cond, 'conditions[cond]', conditions[cond]);
// starts with underscore is for internal use, avoid processing,
// used to pass list of codes to fill the condition value criteria
if (cond.startsWith('_'))
{
continue;
}
criteria += '<span class="criteria_value '+ attr +'" data-criteria="'+ global_criteria_id +'">';
if (cond == 'eq_one')
Expand Down Expand Up @@ -1403,6 +1402,7 @@ resp.responseJSON.result.message +'</div>'
}
else // we have possible_values for this criteria
{
console.log(datatype, conditions[cond]);
switch ( conditions[cond] )
{
case 'value':
Expand All @@ -1426,8 +1426,23 @@ resp.responseJSON.result.message +'</div>'
criteria += '</div>';
break
case 'range':
// this case deosnt happen for now...
//criteria += '<input type="'+ input_type +'" name="range" class="value min'+ ((i==0)?' selected':'') +' '+ attr +' form-control input-sm '+ class_type +'" />..<input type="'+ input_type +'" name="range" class="value max'+ ((i==0)?' selected':'') +' '+ attr +' form-control input-sm '+ class_type +'" />';
// this case happens only for DV_ORDINAL, where the value is a number, and we show a list
// of possible values then between min and max should be the list of values.
criteria += '<select name="value" class="value min '+ ((i==0)?' selected':'') +' '+ attr +' form-control input-sm '+ class_type +'">';
for (k in possible_values)
{
criteria += '<option value="'+ k +'">'+ possible_values[k] +'</option>';
}
criteria += '</select>';
criteria += '..';
criteria += '<select name="value" class="value max '+ ((i==0)?' selected':'') +' '+ attr +' form-control input-sm '+ class_type +'">';
for (k in possible_values)
{
criteria += '<option value="'+ k +'">'+ possible_values[k] +'</option>';
}
criteria += '</select>';
break
}
}
Expand Down

0 comments on commit 3bbbc89

Please sign in to comment.