Skip to content

Commit

Permalink
[misc] Don't throw an error if certain panels are missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose committed Jun 22, 2016
1 parent 0e1f342 commit a73384a
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions ui/src/main/resources/PhenoTips/Clinical Notes Annotation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ refreshButton.observe('click', function() {

//generate initial UI elements
var panel = $$(".current-phenotype-selection")[0];
if(panel) {
var suggestionSourcesIds = ['indication_for_referral', 'medical_history'];
var suggestionSources = $$('textarea[name$="' + suggestionSourcesIds.join('"], textarea[name$="') + '"]');
var _getSourceTexts = function() {
return suggestionSources.pluck('value').join('.\n');
}
if (panel && suggestionSources.size() > 0) {
var clinicalNotesSubPanel =
new Element('div', {"class" : "sub-panel"}).insert(
new Element('h3', {"class" : "wikigeneratedheader"}).update(
Expand All @@ -196,20 +201,14 @@ if(panel) {
).insert(widgetContainer);
panel.insert({top : clinicalNotesSubPanel});

//listen for changes in indication for referral text box
var referalIndication = $("PhenoTips.PatientClass_0_indication_for_referral");
var medicalHistory = $("PhenoTips.PatientClass_0_medical_history");
text = referalIndication.value + "\n" + medicalHistory.value;
// Init
text = _getSourceTexts();
fetchDismissedSuggestions(updateAnnotations);
referalIndication.observe('blur', function() {
if(!text.startsWith(referalIndication.value)) {
text = referalIndication.value + "\n" + medicalHistory.value;
updateAnnotations();
}
});
medicalHistory.observe('blur', function() {
if(!text.endsWith(medicalHistory.value)) {
text = referalIndication.value + "\n" + medicalHistory.value;
//listen for changes in indication for referral text box
suggestionSources.invoke('observe', 'blur', function() {
var newText = _getSourceTexts();
if (newText != text) {
text = newText;
updateAnnotations();
}
});
Expand Down

0 comments on commit a73384a

Please sign in to comment.