-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to show redcap error messages (#39)
* added error message to the recordcreationerror exception * raise exception to read error message * processResponse method changed to process RedCap's error message * checking to see if prior redcap error messages exist so they don't get printed again * create the error message to be displayed * changed unit test * created method fieldValidation and added redcap validation map * showing the validation notes on the table * changing Y->y to show isRequired note on table * is required y OR Y * created separate process response that is redcap specific * processresponse moved to driver.py in redcap * added class to header * getting rid of stub * spacing * ehb_datasources/drivers/Base.py * spacing * changed description for time mm:ss and zipcode
- Loading branch information
1 parent
fb176e5
commit ce6bffc
Showing
4 changed files
with
129 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,7 +224,22 @@ def construct_form(self, meta, record_set, form_name, record_id, | |
success: function(data){ | ||
if(data.status == 'error'){ | ||
$("#pleaseWaitModal").modal('hide'); | ||
// Check to see if error messages exist prior | ||
// to remove them | ||
var elementExists = document.getElementById("errorMsg"); | ||
if (elementExists) { | ||
var element = document.getElementById("errorMsg"); | ||
element.parentNode.removeChild(element); | ||
} | ||
else { | ||
} | ||
$("#errorModal").modal('show'); | ||
$("#errorClass").append("<div id='errorMsg'>" + "<p style='color:#F08080'> <br>[ REDCAP ERROR MESSAGE ] <br>" + data.errors + "</p>" + "</div>"); | ||
} | ||
else{ | ||
if(next_form_url != ""){ | ||
|
@@ -359,13 +374,55 @@ def table_rows(self, meta, record, form_name, master_dep_map, apriori_branch_eva | |
|
||
def make_tr_for(self, field, record, master_dep_map, apriori_branch_evals): | ||
def isRequired(): | ||
if field.get('required_field') and field.get('required_field')=='Y': return '* must provide value' | ||
if field.get('required_field') and field.get('required_field')=='y': return '* must provide value' | ||
elif field.get('required_field') and field.get('required_field')=='Y': return '* must provide value' | ||
else: return '' | ||
|
||
def fieldNote(): | ||
if field.get('field_note'): return field.get('field_note') | ||
else: return '' | ||
|
||
def fieldValidation(): | ||
redcap_field_validation_map = { | ||
'date_dmy': 'YYYY-MM-DD.', | ||
'date_mdy': 'YYYY-MM-DD. ', | ||
'date_ymd': 'YYYY-MM-DD.', | ||
'datetime_dmy': 'YYYY-MM-DD HH:MM (time is in military format)', | ||
'datetime_ymd': 'YYYY-MM-DD HH:MM (time is in military format)', | ||
'datetime_mdy': 'YYYY-MM-DD HH:MM (time is in military format)', | ||
'datetime_seconds_mdy': 'YYYY-MM-DD HH:MM:SS (time is in military format)', | ||
'datetime_seconds_ymd': 'YYYY-MM-DD HH:MM:SS (time is in military format) ', | ||
'datetime_seconds_dmy': 'YYYY-MM-DD HH:MM:SS (time is in military format) ', | ||
'email': '[email protected]', | ||
'integer': 'whole number (no letters or decimal)', | ||
'alpha_only': 'letters (no numbers)', | ||
'mrn_8d': 'medical record number (8 digits)', | ||
'number': 'number (no letters)', | ||
'number_1dp': 'number with 1 decimal place #.#', | ||
'number_2dp': 'number with 2 decimal place #.##', | ||
'number_3dp': 'number with 3 decimal place #.###', | ||
'number_4dp': 'number with 4 decimal place #.####', | ||
'phone': '10 digit phone number (###)###-####', | ||
'ssn': '9 digit social security number ###-##-####', | ||
'text_0_150': 'characters (max. 150)', | ||
'text_0_200': 'characters (max. 200)', | ||
'time': 'time HH:MM (military format)', | ||
'time_mm_ss': 'time MM:SS', | ||
'zipcode': '5 or 9 digit zipcode (#####-####)' | ||
} | ||
|
||
#if validation note exists for the field | ||
if field.get('text_validation_type_or_show_slider_number'): | ||
#loop through the validation map to find the correct validation msg to show | ||
for validation_key, validation_message in redcap_field_validation_map.items(): | ||
if field.get('text_validation_type_or_show_slider_number') == str(validation_key): | ||
return "field value expected is " + str(validation_message) | ||
#validation doesn't match with any of the keys above. | ||
#print the validation note anyways | ||
return "field value expected is: " + field.get('text_validation_type_or_show_slider_number') | ||
#no validation note exists | ||
else: return '' | ||
|
||
section_header = field.get('section_header') | ||
header = '' | ||
radio_reset = '' | ||
|
@@ -379,16 +436,17 @@ def fieldNote(): | |
return """{0} | ||
<tr id="{5}" {6}> | ||
<td><div>{1}</div><div style="color:red; font-size:12px;">{2}</div></td> | ||
<td><div>{3}</div><div style="color:blue; font-size:12px;">{4}</div>{7}</td> | ||
<td><div>{3}</div><div style="color:blue; font-size:12px;">{4}</div><div style="color:grey; font-size:10px;">{8}</div>{7}</td> | ||
</tr> | ||
""".format(header, | ||
field.get('field_label'), | ||
isRequired(), | ||
self.build_field(field, record, master_dep_map), | ||
fieldNote(), | ||
field.get('field_name'), | ||
dis, | ||
radio_reset | ||
""".format(header, #{0} | ||
field.get('field_label'), #{1} | ||
isRequired(), #{2} | ||
self.build_field(field, record, master_dep_map), #{3} | ||
fieldNote(), #{4} | ||
field.get('field_name'), #{5} | ||
dis,#{6} | ||
radio_reset,#{7} | ||
fieldValidation() #{8} | ||
) | ||
|
||
def build_fld_on_change_function(self, fld_name, master_dep_map): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters