updates to enable additional umls search results to be displayed (along with whether or not they are best match or not)
This commit is contained in:
parent
08f6f4e6af
commit
f723e62c90
1 changed files with 42 additions and 14 deletions
|
@ -152,22 +152,27 @@ var addConceptForm = {
|
||||||
else {
|
else {
|
||||||
//array is an array of objects representing concept information
|
//array is an array of objects representing concept information
|
||||||
//loop through and find all the best matches
|
//loop through and find all the best matches
|
||||||
var bestMatchResults = addConceptForm.parseResults(results.conceptList);
|
var allResults = addConceptForm.parseResults(results.conceptList);
|
||||||
var numberMatches = bestMatchResults.length;
|
var bestMatchResults = allResults["bestMatch"];
|
||||||
|
var alternateResults = allResults["alternate"];
|
||||||
|
var numberBestMatches = bestMatchResults.length;
|
||||||
|
var numberAlternateMatches = alternateResults.length;
|
||||||
|
var numberTotalMatches = numberBestMatches + numberAlternateMatches;
|
||||||
|
|
||||||
var i;
|
var i;
|
||||||
//For each result, display
|
//For each result, display
|
||||||
if(numberMatches > 0) {
|
if(numberTotalMatches > 0) {
|
||||||
htmlAdd = "<ul class='dd' id='concepts' name='concepts'>";
|
htmlAdd = "<ul class='dd' id='concepts' name='concepts'>";
|
||||||
htmlAdd+= addConceptForm.addResultsHeader();
|
htmlAdd+= addConceptForm.addResultsHeader();
|
||||||
for(i = 0; i < numberMatches; i++) {
|
//Show best matches first
|
||||||
|
for(i = 0; i < numberBestMatches; i++) {
|
||||||
var conceptResult = bestMatchResults[i];
|
var conceptResult = bestMatchResults[i];
|
||||||
var conceptId = conceptResult.conceptId;
|
htmlAdd+= addConceptForm.displayConceptSearchResult(conceptResult, true);
|
||||||
var label = conceptResult.label;
|
}
|
||||||
var definition = conceptResult.definition;
|
//If any alternate matches, show that next
|
||||||
var definedBy = conceptResult.definedBy;
|
for(i = 0; i < numberAlternateMatches; i++) {
|
||||||
var type = conceptResult.type;
|
var conceptResult = alternateResults[i];
|
||||||
var uri = conceptResult.uri;
|
htmlAdd+= addConceptForm.displayConceptSearchResult(conceptResult, false);
|
||||||
htmlAdd+= addConceptForm.generateIndividualConceptDisplay(uri, label, definition, type, definedBy);
|
|
||||||
}
|
}
|
||||||
htmlAdd+= "</ul>";
|
htmlAdd+= "</ul>";
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,21 +193,35 @@ var addConceptForm = {
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
displayConceptSearchResult:function(conceptResult, isBestMatch) {
|
||||||
|
var conceptId = conceptResult.conceptId;
|
||||||
|
var label = conceptResult.label;
|
||||||
|
var definition = conceptResult.definition;
|
||||||
|
var definedBy = conceptResult.definedBy;
|
||||||
|
var type = conceptResult.type;
|
||||||
|
var uri = conceptResult.uri;
|
||||||
|
return addConceptForm.generateIndividualConceptDisplay(uri, label, definition, type, definedBy, isBestMatch);
|
||||||
|
},
|
||||||
|
//This should now return all best matches in one array and other results in another
|
||||||
parseResults:function(resultsArray) {
|
parseResults:function(resultsArray) {
|
||||||
//Loop through array and check if this is the best match
|
//Loop through array and check if this is the best match
|
||||||
var arrayLen = resultsArray.length;
|
var arrayLen = resultsArray.length;
|
||||||
var bestMatchResults = new Array();
|
var bestMatchResults = new Array();
|
||||||
|
//this is for results that are not best match results
|
||||||
|
var alternateResults = new Array();
|
||||||
var i;
|
var i;
|
||||||
for(i = 0; i < arrayLen; i++) {
|
for(i = 0; i < arrayLen; i++) {
|
||||||
var concept = resultsArray[i];
|
var concept = resultsArray[i];
|
||||||
if(concept.bestMatch != "false") {
|
if(concept.bestMatch != "false") {
|
||||||
bestMatchResults.push(concept);
|
bestMatchResults.push(concept);
|
||||||
|
} else {
|
||||||
|
alternateResults.push(concept);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bestMatchResults;
|
return {"bestMatch":bestMatchResults, "alternate":alternateResults};
|
||||||
},
|
},
|
||||||
addResultsHeader:function() {
|
addResultsHeader:function() {
|
||||||
var htmlAdd = "<li class='concepts'><div class='row'><span class='column conceptLabel'>Label (Type) </span><span class='column conceptDefinition'>Definition</span></div></li>";
|
var htmlAdd = "<li class='concepts'><div class='row'><span class='column conceptLabel'>Label (Type) </span><span class='column conceptDefinition'>Definition</span><span class='column'>Best Match</span></div></li>";
|
||||||
return htmlAdd;
|
return htmlAdd;
|
||||||
},
|
},
|
||||||
hideSearchResults:function() {
|
hideSearchResults:function() {
|
||||||
|
@ -234,13 +253,14 @@ var addConceptForm = {
|
||||||
this.externalConceptSource.val(conceptSources);
|
this.externalConceptSource.val(conceptSources);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
generateIndividualConceptDisplay: function(cuiURI, label, definition, type, definedBy) {
|
generateIndividualConceptDisplay: function(cuiURI, label, definition, type, definedBy, isBestMatch) {
|
||||||
var htmlAdd = "<li class='concepts'>" +
|
var htmlAdd = "<li class='concepts'>" +
|
||||||
"<div class='row'>" +
|
"<div class='row'>" +
|
||||||
"<span class='column conceptLabel'>" +
|
"<span class='column conceptLabel'>" +
|
||||||
addConceptForm.generateIndividualCUIInput(cuiURI, label, type, definedBy) +
|
addConceptForm.generateIndividualCUIInput(cuiURI, label, type, definedBy) +
|
||||||
label + addConceptForm.generateIndividualTypeDisplay(type) + "</span>" +
|
label + addConceptForm.generateIndividualTypeDisplay(type) + "</span>" +
|
||||||
addConceptForm.generateIndividualDefinitionDisplay(definition) +
|
addConceptForm.generateIndividualDefinitionDisplay(definition) +
|
||||||
|
addConceptForm.generateBestOrAlternate(isBestMatch) +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
"</li>";
|
"</li>";
|
||||||
return htmlAdd;
|
return htmlAdd;
|
||||||
|
@ -257,6 +277,14 @@ var addConceptForm = {
|
||||||
generateIndividualDefinitionDisplay:function(definition) {
|
generateIndividualDefinitionDisplay:function(definition) {
|
||||||
return "<span class='column conceptDefinition'>" + definition + "</span>";
|
return "<span class='column conceptDefinition'>" + definition + "</span>";
|
||||||
},
|
},
|
||||||
|
//adds another div with "best match" next to it if best match
|
||||||
|
generateBestOrAlternate:function(isBestMatch) {
|
||||||
|
var content = " ";
|
||||||
|
if(isBestMatch) {
|
||||||
|
content = "(Best Match)"
|
||||||
|
}
|
||||||
|
return "<span class='column'>" + content + "</span>";
|
||||||
|
},
|
||||||
validateConceptSelection:function(checkedElements) {
|
validateConceptSelection:function(checkedElements) {
|
||||||
var numberElements = checkedElements.length;
|
var numberElements = checkedElements.length;
|
||||||
if(numberElements < 1) {
|
if(numberElements < 1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue