|
@@ -116,7 +116,41 @@
|
|
handleSubmitResponse(resp,_section, summaryContainer);
|
|
handleSubmitResponse(resp,_section, summaryContainer);
|
|
|
|
|
|
// if "dx", refresh "cc" if it exists in the note
|
|
// if "dx", refresh "cc" if it exists in the note
|
|
-
|
|
|
|
|
|
+ if(_section.attr('data-section-template-name') === 'dx') {
|
|
|
|
+ let ccSection = $('[data-section-template-name="cc"]').first();
|
|
|
|
+ if(ccSection.length) {
|
|
|
|
+ let ccSectionUid = ccSection.attr('data-section-uid');
|
|
|
|
+ let items = JSON.parse(value);
|
|
|
|
+ if(items && items.items) {
|
|
|
|
+ items = items.items
|
|
|
|
+ .filter((_x) => {
|
|
|
|
+ return !!_x.included;
|
|
|
|
+ })
|
|
|
|
+ .map((_x) => {
|
|
|
|
+ return _x.title;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ let itemsText = '';
|
|
|
|
+ if(items.length > 1) {
|
|
|
|
+ let lastItem = items[items.length - 1];
|
|
|
|
+ items.splice(items.length - 1, 1);
|
|
|
|
+ itemsText = items.join(', ') + ' and ' + lastItem;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ itemsText = items[0];
|
|
|
|
+ }
|
|
|
|
+ if(!!itemsText && !!ccSectionUid) {
|
|
|
|
+ let ccValue = 'Patient {{$patient->name_first . ' ' . $patient->name_last}} ' +
|
|
|
|
+ 'is a {{$patient->age_in_years}} year old {{$patient->sex}} with a history of ' +
|
|
|
|
+ itemsText + ' ' +
|
|
|
|
+ '{{ @$note ? (@$note->new_or_fu_or_na === 'NEW' ? 'presenting for establishing care' : 'presenting for follow-up') : '' }}';
|
|
|
|
+ let para = $('<p/>').text(ccValue)[0].outerHTML;
|
|
|
|
+ ccSection.find('[name="data"]').first().val(JSON.stringify({value: para}));
|
|
|
|
+ ccSection.find('.ql-editor').html(para);
|
|
|
|
+ ccSection.find('[btn-save-form]').click();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
}, 'json');
|
|
}, 'json');
|
|
}
|
|
}
|