5686 |
25 Oct 19 |
olle |
var Istat = function() |
5686 |
25 Oct 19 |
olle |
2 |
{ |
5686 |
25 Oct 19 |
olle |
var istat = {}; |
5686 |
25 Oct 19 |
olle |
var debug = 0; |
5686 |
25 Oct 19 |
olle |
5 |
|
5686 |
25 Oct 19 |
olle |
var caseInfo; |
5686 |
25 Oct 19 |
olle |
7 |
|
5686 |
25 Oct 19 |
olle |
var usesSitePrefix = false; |
5686 |
25 Oct 19 |
olle |
var referralPrefix = ''; |
5686 |
25 Oct 19 |
olle |
var referralNumDigits = 5; |
5686 |
25 Oct 19 |
olle |
var refVariantDefault = 'kit1_standard'; |
5686 |
25 Oct 19 |
olle |
12 |
|
5686 |
25 Oct 19 |
olle |
var refStartItemIdPure; |
5686 |
25 Oct 19 |
olle |
var itemIsValid = false; |
5686 |
25 Oct 19 |
olle |
15 |
|
5686 |
25 Oct 19 |
olle |
istat.initPage = function() |
5686 |
25 Oct 19 |
olle |
17 |
{ |
5695 |
04 Nov 19 |
olle |
//alert("generate-referral-forms_alt_ntr.js::initPage(): Start"); |
5686 |
25 Oct 19 |
olle |
// Step 1 |
5695 |
04 Nov 19 |
olle |
20 |
/* |
5686 |
25 Oct 19 |
olle |
Events.addEventHandler('step-1', 'wizard-validate', istat.validateStep1); |
5686 |
25 Oct 19 |
olle |
Events.addEventHandler('sites', 'change', istat.siteAndVariantOnChange); |
5686 |
25 Oct 19 |
olle |
//Events.addEventHandler('referralvariant', 'change', istat.siteAndVariantOnChange); |
5686 |
25 Oct 19 |
olle |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5686 |
25 Oct 19 |
olle |
25 |
|
5686 |
25 Oct 19 |
olle |
// Step 2 |
5686 |
25 Oct 19 |
olle |
Events.addEventHandler('step-2', 'wizard-validate', istat.validateStep2); |
5695 |
04 Nov 19 |
olle |
28 |
*/ |
5695 |
04 Nov 19 |
olle |
Events.addEventHandler('step-1', 'wizard-validate', istat.validateStep2); |
5686 |
25 Oct 19 |
olle |
Events.addEventHandler('itemName', 'keypress', Wizard.focusOnEnter); |
5686 |
25 Oct 19 |
olle |
Events.addEventHandler('itemName', 'blur', istat.itemNameOnChange); |
5695 |
04 Nov 19 |
olle |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5686 |
25 Oct 19 |
olle |
33 |
|
5695 |
04 Nov 19 |
olle |
// Step 2 |
5686 |
25 Oct 19 |
olle |
Buttons.addClickHandler('downloadformbatch1', istat.downloadFormBatch1); |
5686 |
25 Oct 19 |
olle |
Buttons.addClickHandler('downloadformbatch2', istat.downloadFormBatch2); |
5686 |
25 Oct 19 |
olle |
Buttons.addClickHandler('downloadlabelfile', istat.downloadLabelFile); |
5686 |
25 Oct 19 |
olle |
Buttons.addClickHandler('updateuseditemidlist', istat.updateUsedItemIdDigitsList); |
5686 |
25 Oct 19 |
olle |
39 |
|
5686 |
25 Oct 19 |
olle |
// Navigation |
5686 |
25 Oct 19 |
olle |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5686 |
25 Oct 19 |
olle |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5686 |
25 Oct 19 |
olle |
43 |
|
5686 |
25 Oct 19 |
olle |
Doc.show('step-1'); |
5686 |
25 Oct 19 |
olle |
Doc.show('gonext'); |
5686 |
25 Oct 19 |
olle |
Doc.addClass('gonext', 'disabled'); |
5686 |
25 Oct 19 |
olle |
47 |
|
5686 |
25 Oct 19 |
olle |
refStartItemIdPure = ''; |
5686 |
25 Oct 19 |
olle |
49 |
|
5695 |
04 Nov 19 |
olle |
50 |
/* |
5686 |
25 Oct 19 |
olle |
// Load sites |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
var url = '../ReferralGenerator.servlet?ID='+App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=GetSites'; |
5686 |
25 Oct 19 |
olle |
Doc.addClass('sites', 'list-loading'); |
5686 |
25 Oct 19 |
olle |
frm.sites[0] = new Option('loading...'); |
5686 |
25 Oct 19 |
olle |
Wizard.asyncJsonRequest(url, istat.sitesLoaded); |
5695 |
04 Nov 19 |
olle |
58 |
*/ |
5686 |
25 Oct 19 |
olle |
59 |
|
5686 |
25 Oct 19 |
olle |
// Load permissions |
5686 |
25 Oct 19 |
olle |
istat.initPermissions(); |
5686 |
25 Oct 19 |
olle |
// Load configuration |
5686 |
25 Oct 19 |
olle |
istat.loadConfiguration(); |
5695 |
04 Nov 19 |
olle |
64 |
// |
5695 |
04 Nov 19 |
olle |
istat.initializeStep2(); |
5686 |
25 Oct 19 |
olle |
66 |
} |
5686 |
25 Oct 19 |
olle |
67 |
|
5686 |
25 Oct 19 |
olle |
istat.initPermissions = function() |
5686 |
25 Oct 19 |
olle |
69 |
{ |
5686 |
25 Oct 19 |
olle |
// Get permission information |
5686 |
25 Oct 19 |
olle |
var url = '../Install.servlet?ID='+App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=GetPermissions'; |
5686 |
25 Oct 19 |
olle |
var request = Ajax.getXmlHttpRequest(); |
5686 |
25 Oct 19 |
olle |
request.open("GET", url, true); |
5686 |
25 Oct 19 |
olle |
Ajax.setReadyStateHandler(request, istat.onPermissionsLoaded, istat.onPermissionsLoaded); |
5686 |
25 Oct 19 |
olle |
request.send(null); |
5686 |
25 Oct 19 |
olle |
77 |
} |
5686 |
25 Oct 19 |
olle |
78 |
|
5686 |
25 Oct 19 |
olle |
// Callback when permission information is ready |
5686 |
25 Oct 19 |
olle |
istat.onPermissionsLoaded = function(request) |
5686 |
25 Oct 19 |
olle |
81 |
{ |
5686 |
25 Oct 19 |
olle |
if (debug) App.debug(Strings.encodeTags(request.responseText)); |
5686 |
25 Oct 19 |
olle |
var response; |
5686 |
25 Oct 19 |
olle |
var error = false; |
5686 |
25 Oct 19 |
olle |
try |
5686 |
25 Oct 19 |
olle |
86 |
{ |
5686 |
25 Oct 19 |
olle |
response = JSON.parse(request.responseText); |
5686 |
25 Oct 19 |
olle |
if (response.status != 'ok') |
5686 |
25 Oct 19 |
olle |
89 |
{ |
5686 |
25 Oct 19 |
olle |
error = response.message || response.stacktrace || 'Unexpected error'; |
5686 |
25 Oct 19 |
olle |
91 |
} |
5686 |
25 Oct 19 |
olle |
92 |
} |
5686 |
25 Oct 19 |
olle |
catch (ex) |
5686 |
25 Oct 19 |
olle |
94 |
{ |
5686 |
25 Oct 19 |
olle |
error = ex; |
5686 |
25 Oct 19 |
olle |
96 |
} |
5686 |
25 Oct 19 |
olle |
97 |
|
5686 |
25 Oct 19 |
olle |
if (error) |
5686 |
25 Oct 19 |
olle |
99 |
{ |
5686 |
25 Oct 19 |
olle |
alert(error); |
5686 |
25 Oct 19 |
olle |
return; |
5686 |
25 Oct 19 |
olle |
102 |
} |
5686 |
25 Oct 19 |
olle |
103 |
|
5686 |
25 Oct 19 |
olle |
myPermissions = response.permissions; |
5686 |
25 Oct 19 |
olle |
//var isAdmin = myPermissions['Administrator'] == 1; |
5686 |
25 Oct 19 |
olle |
//var noProjectIsActive = !App.getActiveProjectId(); |
5686 |
25 Oct 19 |
olle |
107 |
} |
5686 |
25 Oct 19 |
olle |
108 |
|
5686 |
25 Oct 19 |
olle |
istat.loadConfiguration = function() |
5686 |
25 Oct 19 |
olle |
110 |
{ |
5686 |
25 Oct 19 |
olle |
var url = '../Session.servlet?ID='+App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=GetConfiguration' |
5686 |
25 Oct 19 |
olle |
var request = Ajax.getXmlHttpRequest(); |
5686 |
25 Oct 19 |
olle |
request.open("GET", url, true); |
5686 |
25 Oct 19 |
olle |
Ajax.setReadyStateHandler(request, istat.onConfiguration, istat.onConfiguration); |
5686 |
25 Oct 19 |
olle |
request.send(null); |
5686 |
25 Oct 19 |
olle |
117 |
} |
5686 |
25 Oct 19 |
olle |
118 |
|
5686 |
25 Oct 19 |
olle |
istat.onConfiguration = function(request) |
5686 |
25 Oct 19 |
olle |
120 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
122 |
|
5686 |
25 Oct 19 |
olle |
if (debug) |
5686 |
25 Oct 19 |
olle |
124 |
{ |
5686 |
25 Oct 19 |
olle |
App.debug(Strings.encodeTags(request.responseText)); |
5686 |
25 Oct 19 |
olle |
126 |
} |
5686 |
25 Oct 19 |
olle |
127 |
|
5686 |
25 Oct 19 |
olle |
var response; |
5686 |
25 Oct 19 |
olle |
var error = false; |
5686 |
25 Oct 19 |
olle |
try |
5686 |
25 Oct 19 |
olle |
131 |
{ |
5686 |
25 Oct 19 |
olle |
response = JSON.parse(request.responseText); |
5686 |
25 Oct 19 |
olle |
if (response.status != 'ok') |
5686 |
25 Oct 19 |
olle |
134 |
{ |
5686 |
25 Oct 19 |
olle |
error = response.message || response.stacktrace || 'Unexpected error'; |
5686 |
25 Oct 19 |
olle |
136 |
} |
5686 |
25 Oct 19 |
olle |
137 |
} |
5686 |
25 Oct 19 |
olle |
catch (ex) |
5686 |
25 Oct 19 |
olle |
139 |
{ |
5686 |
25 Oct 19 |
olle |
error = ex; |
5686 |
25 Oct 19 |
olle |
141 |
} |
5686 |
25 Oct 19 |
olle |
if (error) App.debug(error); |
5686 |
25 Oct 19 |
olle |
143 |
|
5686 |
25 Oct 19 |
olle |
// Get configuration result |
5686 |
25 Oct 19 |
olle |
var conf = response.configuration; |
5686 |
25 Oct 19 |
olle |
// Check for uses site prefix flag |
5686 |
25 Oct 19 |
olle |
usesSitePrefix = conf.usesSitePrefix; |
5686 |
25 Oct 19 |
olle |
referralPrefix = conf.referralPrefix; |
5686 |
25 Oct 19 |
olle |
referralNumDigits = conf.referralNumDigits; |
5686 |
25 Oct 19 |
olle |
//alert("generate-referral-forms.js::onConfiguration(): usesSitePrefix = " + usesSitePrefix + " referralPrefix = " + referralPrefix + " referralNumDigits = " + referralNumDigits); |
5686 |
25 Oct 19 |
olle |
151 |
/* |
5686 |
25 Oct 19 |
olle |
// Check for project focus default |
5686 |
25 Oct 19 |
olle |
var projectFocusDefault = conf.projectFocusDefault; |
5686 |
25 Oct 19 |
olle |
if (projectFocusDefault != null) |
5686 |
25 Oct 19 |
olle |
155 |
{ |
5686 |
25 Oct 19 |
olle |
frm.projectFocus.value = projectFocusDefault; |
5686 |
25 Oct 19 |
olle |
streg.projectFocusOnChange(); |
5686 |
25 Oct 19 |
olle |
158 |
} |
5686 |
25 Oct 19 |
olle |
// Check for specimen type default |
5686 |
25 Oct 19 |
olle |
var specimenTypeDefault = conf.specimenTypeDefault; |
5686 |
25 Oct 19 |
olle |
if (specimenTypeDefault != null) |
5686 |
25 Oct 19 |
olle |
162 |
{ |
5686 |
25 Oct 19 |
olle |
frm.specimenType.value = specimenTypeDefault; |
5686 |
25 Oct 19 |
olle |
164 |
} |
5686 |
25 Oct 19 |
olle |
// Check for specimen input type default |
5686 |
25 Oct 19 |
olle |
var specimenInputTypeDefault = conf.specimenInputTypeDefault; |
5686 |
25 Oct 19 |
olle |
if (specimenInputTypeDefault != null) |
5686 |
25 Oct 19 |
olle |
168 |
{ |
5686 |
25 Oct 19 |
olle |
frm.specimenInputType.value = specimenInputTypeDefault; |
5686 |
25 Oct 19 |
olle |
170 |
} |
5686 |
25 Oct 19 |
olle |
// Check for extracts from first specimen only default |
5686 |
25 Oct 19 |
olle |
var extractsFromFirstSpecimenOnlyDefault = conf.extractsFromFirstSpecimenOnlyDefault; |
5686 |
25 Oct 19 |
olle |
if (extractsFromFirstSpecimenOnlyDefault != null) |
5686 |
25 Oct 19 |
olle |
174 |
{ |
5686 |
25 Oct 19 |
olle |
frm.extractsFromFirstSpecimenOnlyCB.checked = extractsFromFirstSpecimenOnlyDefault; |
5686 |
25 Oct 19 |
olle |
176 |
} |
5686 |
25 Oct 19 |
olle |
177 |
*/ |
5686 |
25 Oct 19 |
olle |
178 |
|
5686 |
25 Oct 19 |
olle |
179 |
/* |
5686 |
25 Oct 19 |
olle |
// Continue with initializing info for case |
5686 |
25 Oct 19 |
olle |
var url = '../LabelGeneration.servlet?ID='+App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=CountCases'; |
5686 |
25 Oct 19 |
olle |
Wizard.showLoadingAnimation('Loading cases...'); |
5686 |
25 Oct 19 |
olle |
Wizard.asyncJsonRequest(url, streg.caseInfoLoadedStep1); |
5686 |
25 Oct 19 |
olle |
185 |
*/ |
5695 |
04 Nov 19 |
olle |
if (usesSitePrefix) |
5695 |
04 Nov 19 |
olle |
187 |
{ |
5695 |
04 Nov 19 |
olle |
// Load sites |
5695 |
04 Nov 19 |
olle |
var frm = document.forms['meludi']; |
5695 |
04 Nov 19 |
olle |
var url = '../ReferralGenerator.servlet?ID='+App.getSessionId(); |
5695 |
04 Nov 19 |
olle |
url += '&cmd=GetSites'; |
5695 |
04 Nov 19 |
olle |
Doc.addClass('sites', 'list-loading'); |
5695 |
04 Nov 19 |
olle |
frm.sites[0] = new Option('loading...'); |
5695 |
04 Nov 19 |
olle |
Wizard.asyncJsonRequest(url, istat.sitesLoaded); |
5695 |
04 Nov 19 |
olle |
195 |
} |
5686 |
25 Oct 19 |
olle |
196 |
} |
5686 |
25 Oct 19 |
olle |
197 |
|
5686 |
25 Oct 19 |
olle |
istat.sitesLoaded = function(response) |
5686 |
25 Oct 19 |
olle |
199 |
{ |
5686 |
25 Oct 19 |
olle |
Doc.removeClass('sites', 'list-loading'); |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
var sites = response.sites; |
5686 |
25 Oct 19 |
olle |
frm.sites.length = 0; |
5686 |
25 Oct 19 |
olle |
//frm.sites[0] = new Option('All sites together', ''); |
5686 |
25 Oct 19 |
olle |
frm.sites[0] = new Option('- Select site -', ''); |
5686 |
25 Oct 19 |
olle |
for (var i = 0; i < sites.length; i++) |
5686 |
25 Oct 19 |
olle |
207 |
{ |
5686 |
25 Oct 19 |
olle |
var s = sites[i]; |
5686 |
25 Oct 19 |
olle |
//var option = new Option(s.name, s.prefix); |
5686 |
25 Oct 19 |
olle |
var option = new Option(s.name + ' [' + s.prefix + ']', s.prefix); |
5686 |
25 Oct 19 |
olle |
frm.sites[frm.sites.length] = option; |
5686 |
25 Oct 19 |
olle |
212 |
} |
5686 |
25 Oct 19 |
olle |
213 |
} |
5686 |
25 Oct 19 |
olle |
214 |
|
5686 |
25 Oct 19 |
olle |
istat.siteAndVariantOnChange = function() |
5686 |
25 Oct 19 |
olle |
216 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
var site = frm.sites.value; |
5686 |
25 Oct 19 |
olle |
//var refVariant = frm.referralvariant.value; |
5686 |
25 Oct 19 |
olle |
var refVariant = refVariantDefault; |
5686 |
25 Oct 19 |
olle |
var siteAndVariantAreValid = false; |
5686 |
25 Oct 19 |
olle |
if (site != '' && refVariant != '') |
5686 |
25 Oct 19 |
olle |
223 |
{ |
5686 |
25 Oct 19 |
olle |
siteAndVariantAreValid = true; |
5686 |
25 Oct 19 |
olle |
225 |
} |
5686 |
25 Oct 19 |
olle |
if (siteAndVariantAreValid) |
5686 |
25 Oct 19 |
olle |
227 |
{ |
5686 |
25 Oct 19 |
olle |
// Check if multiple template files for same referral from type |
5686 |
25 Oct 19 |
olle |
var url = '../ReferralGenerator.servlet?ID='+App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=GetReferralTemplateInfo'; |
5686 |
25 Oct 19 |
olle |
url += '&site='+encodeURIComponent(site); |
5686 |
25 Oct 19 |
olle |
url += '&referralvariant='+encodeURIComponent(refVariant); |
5686 |
25 Oct 19 |
olle |
Wizard.showLoadingAnimation('Getting referral template info...', 'ref-gen-progress'); |
5686 |
25 Oct 19 |
olle |
Wizard.asyncJsonRequest(url, istat.preValidateStep1); |
5686 |
25 Oct 19 |
olle |
235 |
} |
5686 |
25 Oct 19 |
olle |
else |
5686 |
25 Oct 19 |
olle |
237 |
{ |
5686 |
25 Oct 19 |
olle |
Doc.addClass('gonext', 'disabled'); |
5686 |
25 Oct 19 |
olle |
239 |
} |
5686 |
25 Oct 19 |
olle |
240 |
} |
5686 |
25 Oct 19 |
olle |
241 |
|
5686 |
25 Oct 19 |
olle |
istat.preValidateStep1 = function(response) |
5686 |
25 Oct 19 |
olle |
243 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
245 |
|
5686 |
25 Oct 19 |
olle |
var jsonMultTemplates = response.multTemplates; |
5686 |
25 Oct 19 |
olle |
if (jsonMultTemplates.length > 0) |
5686 |
25 Oct 19 |
olle |
248 |
{ |
5686 |
25 Oct 19 |
olle |
// List multiple templates/type |
5686 |
25 Oct 19 |
olle |
//var html = '<table id="templateFilesTable" class="step-form">'; |
5686 |
25 Oct 19 |
olle |
var html = '<br>'; |
5686 |
25 Oct 19 |
olle |
html += '<table id="templateFilesTable">'; |
5686 |
25 Oct 19 |
olle |
// Header row |
5686 |
25 Oct 19 |
olle |
html += '<tr>'; |
5686 |
25 Oct 19 |
olle |
html += '<th>Multiple template files for same type</th>'; |
5686 |
25 Oct 19 |
olle |
html += '<th>Template type</th>'; |
5686 |
25 Oct 19 |
olle |
html += '</tr>'; |
5686 |
25 Oct 19 |
olle |
// File list |
5686 |
25 Oct 19 |
olle |
for (var i = 0; i < jsonMultTemplates.length; i++) |
5686 |
25 Oct 19 |
olle |
260 |
{ |
5686 |
25 Oct 19 |
olle |
//var filename = jsonMultTemplates[i]; |
5686 |
25 Oct 19 |
olle |
var jsonMultTempl = jsonMultTemplates[i]; |
5686 |
25 Oct 19 |
olle |
var filename = jsonMultTempl['file']; |
5686 |
25 Oct 19 |
olle |
var type = jsonMultTempl['type']; |
5686 |
25 Oct 19 |
olle |
html += '<tr>'; |
5686 |
25 Oct 19 |
olle |
html += '<td> ' + filename + '</td>'; |
5686 |
25 Oct 19 |
olle |
html += '<td> ' + type + '</td>'; |
5686 |
25 Oct 19 |
olle |
html += '</tr>'; |
5686 |
25 Oct 19 |
olle |
269 |
} |
5686 |
25 Oct 19 |
olle |
html += '</table>'; |
5686 |
25 Oct 19 |
olle |
Doc.element('step1message').innerHTML = html; |
5686 |
25 Oct 19 |
olle |
272 |
|
5686 |
25 Oct 19 |
olle |
// Display extra checkbox to confirm use of multiple templates/type |
5686 |
25 Oct 19 |
olle |
var confirmMsg = 'Check to verify use of multiple template files for same type.'; |
5686 |
25 Oct 19 |
olle |
Wizard.showGoNextConfirmation(true, confirmMsg); |
5686 |
25 Oct 19 |
olle |
return; |
5686 |
25 Oct 19 |
olle |
277 |
} |
5686 |
25 Oct 19 |
olle |
else |
5686 |
25 Oct 19 |
olle |
279 |
{ |
5686 |
25 Oct 19 |
olle |
Doc.removeClass('gonext', 'disabled'); |
5686 |
25 Oct 19 |
olle |
281 |
} |
5686 |
25 Oct 19 |
olle |
282 |
} |
5686 |
25 Oct 19 |
olle |
283 |
|
5686 |
25 Oct 19 |
olle |
istat.validateStep1 = function(event) |
5686 |
25 Oct 19 |
olle |
285 |
{ |
5686 |
25 Oct 19 |
olle |
istat.initializeStep2(); |
5686 |
25 Oct 19 |
olle |
287 |
} |
5686 |
25 Oct 19 |
olle |
288 |
|
5686 |
25 Oct 19 |
olle |
istat.initializeStep2 = function(response) |
5686 |
25 Oct 19 |
olle |
290 |
{ |
5695 |
04 Nov 19 |
olle |
//alert("generate-referral-forms_alt_ntr.js::initializeStep2(): Start"); |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5695 |
04 Nov 19 |
olle |
//Wizard.setCurrentStep(2); |
5695 |
04 Nov 19 |
olle |
Wizard.setCurrentStep(1); |
5686 |
25 Oct 19 |
olle |
295 |
|
5695 |
04 Nov 19 |
olle |
//istat.selectOptionsDisabled('sites', true); |
5686 |
25 Oct 19 |
olle |
//istat.selectOptionsDisabled('referralvariant', true); |
5686 |
25 Oct 19 |
olle |
298 |
|
5686 |
25 Oct 19 |
olle |
// Get referral start info |
5686 |
25 Oct 19 |
olle |
var url = '../ReferralGenerator.servlet?ID='+App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=GetReferralStartInfo'; |
5686 |
25 Oct 19 |
olle |
Wizard.showLoadingAnimation('Getting referral start info...', 'ref-gen-progress'); |
5686 |
25 Oct 19 |
olle |
Wizard.asyncJsonRequest(url, istat.initializeStep2a); |
5686 |
25 Oct 19 |
olle |
304 |
} |
5686 |
25 Oct 19 |
olle |
305 |
|
5686 |
25 Oct 19 |
olle |
istat.initializeStep2a = function(response) |
5686 |
25 Oct 19 |
olle |
307 |
{ |
5695 |
04 Nov 19 |
olle |
//alert("generate-referral-forms_alt_ntr.js::initializeStep2a(): Start"); |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
310 |
|
5686 |
25 Oct 19 |
olle |
var jsonRefStartInfo = response.refStartInfo; |
5686 |
25 Oct 19 |
olle |
312 |
|
5695 |
04 Nov 19 |
olle |
//var site = frm.sites.value; |
5686 |
25 Oct 19 |
olle |
//var refVariant = frm.referralvariant.value; |
5686 |
25 Oct 19 |
olle |
var refVariant = refVariantDefault; |
5686 |
25 Oct 19 |
olle |
316 |
|
5686 |
25 Oct 19 |
olle |
// Initialize number of referral forms to generate |
5686 |
25 Oct 19 |
olle |
var nofFormSetsDefault = 50; |
5686 |
25 Oct 19 |
olle |
if (refVariant == 'kit2_neoadjuvant') |
5686 |
25 Oct 19 |
olle |
320 |
{ |
5686 |
25 Oct 19 |
olle |
nofFormSetsDefault = 25; |
5686 |
25 Oct 19 |
olle |
322 |
} |
5686 |
25 Oct 19 |
olle |
frm.nofFormSets.value = nofFormSetsDefault; |
5686 |
25 Oct 19 |
olle |
324 |
|
5726 |
14 Nov 19 |
olle |
if (referralPrefix == null || referralPrefix == '') |
5726 |
14 Nov 19 |
olle |
326 |
{ |
5726 |
14 Nov 19 |
olle |
referralPrefix = 'NT'; |
5726 |
14 Nov 19 |
olle |
328 |
} |
5686 |
25 Oct 19 |
olle |
refStartItemIdPure = jsonRefStartInfo['startItemIdDigitsPure']; |
5686 |
25 Oct 19 |
olle |
//alert("generate-referral-forms.js::initializeStep2a(): refStartItemIdPure = " + refStartItemIdPure); |
5686 |
25 Oct 19 |
olle |
var lastUpdated = jsonRefStartInfo['lastUpdated']; |
5686 |
25 Oct 19 |
olle |
// Add site prefix to referral pure start item id |
5695 |
04 Nov 19 |
olle |
//var refStartItemId = referralPrefix + site + refStartItemIdPure; |
5695 |
04 Nov 19 |
olle |
var refStartItemId = referralPrefix + refStartItemIdPure; |
5686 |
25 Oct 19 |
olle |
if (lastUpdated != null && lastUpdated != '') |
5686 |
25 Oct 19 |
olle |
336 |
{ |
5686 |
25 Oct 19 |
olle |
Doc.element('referralIdLastUpdated').innerHTML = lastUpdated; |
5686 |
25 Oct 19 |
olle |
338 |
} |
5686 |
25 Oct 19 |
olle |
frm.itemName.value = refStartItemId; |
5686 |
25 Oct 19 |
olle |
340 |
|
5686 |
25 Oct 19 |
olle |
Doc.show('gonext'); |
5686 |
25 Oct 19 |
olle |
342 |
|
5695 |
04 Nov 19 |
olle |
//Doc.show('step-2'); |
5695 |
04 Nov 19 |
olle |
Doc.show('step-1'); |
5686 |
25 Oct 19 |
olle |
345 |
} |
5686 |
25 Oct 19 |
olle |
346 |
|
5686 |
25 Oct 19 |
olle |
istat.itemNameOnChange = function() |
5686 |
25 Oct 19 |
olle |
348 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
var itemName = frm.itemName.value.toUpperCase(); |
5686 |
25 Oct 19 |
olle |
itemIsValid = false; |
5686 |
25 Oct 19 |
olle |
Doc.addClass('gonext', 'disabled'); |
5686 |
25 Oct 19 |
olle |
if (itemName == '') |
5686 |
25 Oct 19 |
olle |
354 |
{ |
5686 |
25 Oct 19 |
olle |
Wizard.setInputStatus('itemName', 'invalid', 'Missing'); |
5686 |
25 Oct 19 |
olle |
frm.itemName.focus(); |
5686 |
25 Oct 19 |
olle |
return; |
5686 |
25 Oct 19 |
olle |
358 |
} |
5686 |
25 Oct 19 |
olle |
//alert("generate-referral-forms.js::itemNameOnChange(): itemName = " + itemName) |
5686 |
25 Oct 19 |
olle |
360 |
/* |
5686 |
25 Oct 19 |
olle |
if (!Meludi.isValidCaseName(caseName, true)) // Allow C/D suffix to be used |
5686 |
25 Oct 19 |
olle |
362 |
{ |
5686 |
25 Oct 19 |
olle |
Wizard.setInputStatus('caseName', 'invalid', 'Only 7-digits name + optional \'C\' or \'D\' is allowed.'); |
5686 |
25 Oct 19 |
olle |
frm.caseName.focus(); |
5686 |
25 Oct 19 |
olle |
return; |
5686 |
25 Oct 19 |
olle |
366 |
} |
5686 |
25 Oct 19 |
olle |
// Check if pure case name < stored next pure case name |
5686 |
25 Oct 19 |
olle |
var currefStartCaseIdPure = caseName.substring(2); |
5686 |
25 Oct 19 |
olle |
if (currefStartCaseIdPure < refStartCaseIdPure) |
5686 |
25 Oct 19 |
olle |
370 |
{ |
5686 |
25 Oct 19 |
olle |
var confirmMsg = 'Check to verify use of pure SCAN-B ID < ' + refStartCaseIdPure + ' (stored value).'; |
5686 |
25 Oct 19 |
olle |
Wizard.showGoNextConfirmation(true, confirmMsg); |
5686 |
25 Oct 19 |
olle |
return; |
5686 |
25 Oct 19 |
olle |
374 |
} |
5686 |
25 Oct 19 |
olle |
375 |
*/ |
5686 |
25 Oct 19 |
olle |
Wizard.setInputStatus('itemName'); |
5686 |
25 Oct 19 |
olle |
if (itemName == '') |
5686 |
25 Oct 19 |
olle |
378 |
{ |
5686 |
25 Oct 19 |
olle |
Wizard.setInputStatus('itemName', 'invalid', 'Missing'); |
5686 |
25 Oct 19 |
olle |
frm.itemName.focus(); |
5686 |
25 Oct 19 |
olle |
381 |
} |
5686 |
25 Oct 19 |
olle |
else if (!Meludi.isValidCaseName2(itemName, referralPrefix, referralNumDigits)) |
5686 |
25 Oct 19 |
olle |
383 |
{ |
5686 |
25 Oct 19 |
olle |
Wizard.setInputStatus('itemName', 'invalid', 'Only name = "' + referralPrefix + '" + ' + referralNumDigits + ' digits is allowed.'); |
5686 |
25 Oct 19 |
olle |
frm.itemName.focus(); |
5686 |
25 Oct 19 |
olle |
386 |
} |
5686 |
25 Oct 19 |
olle |
else |
5686 |
25 Oct 19 |
olle |
388 |
{ |
5686 |
25 Oct 19 |
olle |
Wizard.setInputStatus('itemName', 'valid'); |
5686 |
25 Oct 19 |
olle |
itemIsValid = true; |
5686 |
25 Oct 19 |
olle |
391 |
} |
5686 |
25 Oct 19 |
olle |
392 |
/* |
5686 |
25 Oct 19 |
olle |
// Check if pure case name < stored next pure case name |
5686 |
25 Oct 19 |
olle |
var currefStartCaseIdPure = caseName.substring(2); |
5686 |
25 Oct 19 |
olle |
if (currefStartCaseIdPure < refStartCaseIdPure) |
5686 |
25 Oct 19 |
olle |
396 |
{ |
5686 |
25 Oct 19 |
olle |
var confirmMsg = 'Check to verify use of pure SCAN-B ID < ' + refStartCaseIdPure + ' (stored value).'; |
5686 |
25 Oct 19 |
olle |
Wizard.showGoNextConfirmation(true, confirmMsg); |
5686 |
25 Oct 19 |
olle |
return; |
5686 |
25 Oct 19 |
olle |
400 |
} |
5686 |
25 Oct 19 |
olle |
401 |
*/ |
5686 |
25 Oct 19 |
olle |
402 |
|
5686 |
25 Oct 19 |
olle |
frm.itemName.value = itemName; |
5686 |
25 Oct 19 |
olle |
Wizard.setInputStatus('itemName', 'valid'); |
5686 |
25 Oct 19 |
olle |
itemIsValid = true; |
5686 |
25 Oct 19 |
olle |
Doc.removeClass('gonext', 'disabled'); |
5686 |
25 Oct 19 |
olle |
407 |
} |
5686 |
25 Oct 19 |
olle |
408 |
|
5686 |
25 Oct 19 |
olle |
istat.validateStep2 = function(event) |
5686 |
25 Oct 19 |
olle |
410 |
{ |
5686 |
25 Oct 19 |
olle |
var valid = true; |
5686 |
25 Oct 19 |
olle |
valid &= Wizard.isValid('itemName'); |
5686 |
25 Oct 19 |
olle |
if (!valid) event.preventDefault(); |
5686 |
25 Oct 19 |
olle |
414 |
|
5686 |
25 Oct 19 |
olle |
istat.generateReferralForms(); |
5686 |
25 Oct 19 |
olle |
416 |
} |
5686 |
25 Oct 19 |
olle |
417 |
|
5686 |
25 Oct 19 |
olle |
istat.generateReferralForms = function() |
5686 |
25 Oct 19 |
olle |
419 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
//var refVariant = frm.referralvariant.value; |
5686 |
25 Oct 19 |
olle |
var refVariant = refVariantDefault; |
5686 |
25 Oct 19 |
olle |
var startItemName = frm.itemName.value; |
5686 |
25 Oct 19 |
olle |
var nofFormSets = frm.nofFormSets.value; |
5686 |
25 Oct 19 |
olle |
425 |
|
5686 |
25 Oct 19 |
olle |
Doc.addClass('itemName', 'disabled'); |
5686 |
25 Oct 19 |
olle |
Doc.addClass('nofFormSets', 'disabled'); |
5686 |
25 Oct 19 |
olle |
428 |
|
5686 |
25 Oct 19 |
olle |
Doc.hide('gonext'); |
5686 |
25 Oct 19 |
olle |
430 |
|
5686 |
25 Oct 19 |
olle |
var url = '../ReferralGenerator.servlet?ID='+App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=GenerateReferralForms'; |
5686 |
25 Oct 19 |
olle |
url += '&referralvariant='+encodeURIComponent(refVariant); |
5686 |
25 Oct 19 |
olle |
url += '&startitemname='+encodeURIComponent(startItemName); |
5686 |
25 Oct 19 |
olle |
url += '&nofformsets='+encodeURIComponent(nofFormSets); |
5686 |
25 Oct 19 |
olle |
436 |
|
5686 |
25 Oct 19 |
olle |
Wizard.showLoadingAnimation('Generating referral forms...', 'ref-gen-progress'); |
5686 |
25 Oct 19 |
olle |
Wizard.asyncJsonRequest(url, istat.initializeStep3); |
5686 |
25 Oct 19 |
olle |
439 |
/* |
5686 |
25 Oct 19 |
olle |
// POST |
5686 |
25 Oct 19 |
olle |
Wizard.showLoadingAnimation('Generating referral forms...', 'ref-gen-progress'); |
5686 |
25 Oct 19 |
olle |
Wizard.asyncJsonRequest(url, istat.initializeStep2, 'POST', formData); |
5686 |
25 Oct 19 |
olle |
443 |
*/ |
5686 |
25 Oct 19 |
olle |
444 |
} |
5686 |
25 Oct 19 |
olle |
445 |
|
5686 |
25 Oct 19 |
olle |
istat.initializeStep3 = function(response) |
5686 |
25 Oct 19 |
olle |
447 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
Wizard.setCurrentStep(3); |
5686 |
25 Oct 19 |
olle |
Wizard.showFinalMessage(response.messages); |
5686 |
25 Oct 19 |
olle |
451 |
|
5686 |
25 Oct 19 |
olle |
Doc.hide('gonext'); |
5686 |
25 Oct 19 |
olle |
Doc.show('downloadformbatch1'); |
5686 |
25 Oct 19 |
olle |
Doc.show('downloadformbatch2'); |
5686 |
25 Oct 19 |
olle |
Doc.show('downloadlabelfile'); |
5686 |
25 Oct 19 |
olle |
Doc.show('updateuseditemidlist'); |
5686 |
25 Oct 19 |
olle |
457 |
|
5686 |
25 Oct 19 |
olle |
Doc.show('step-3'); |
5686 |
25 Oct 19 |
olle |
459 |
} |
5686 |
25 Oct 19 |
olle |
460 |
|
5686 |
25 Oct 19 |
olle |
istat.initializeStep3a = function(response) |
5686 |
25 Oct 19 |
olle |
462 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
Wizard.setCurrentStep(3); |
5686 |
25 Oct 19 |
olle |
Wizard.showFinalMessage(response.messages); |
5686 |
25 Oct 19 |
olle |
466 |
|
5686 |
25 Oct 19 |
olle |
Doc.show('gorestart'); |
5686 |
25 Oct 19 |
olle |
Doc.hide('gonext'); |
5686 |
25 Oct 19 |
olle |
Doc.show('downloadformbatch1'); |
5686 |
25 Oct 19 |
olle |
Doc.show('downloadformbatch2'); |
5686 |
25 Oct 19 |
olle |
Doc.show('downloadlabelfile'); |
5686 |
25 Oct 19 |
olle |
Doc.show('updateuseditemidlist'); |
5686 |
25 Oct 19 |
olle |
Doc.addClass('updateuseditemidlist', 'disabled'); |
5686 |
25 Oct 19 |
olle |
474 |
|
5686 |
25 Oct 19 |
olle |
Doc.show('step-3'); |
5686 |
25 Oct 19 |
olle |
476 |
} |
5686 |
25 Oct 19 |
olle |
477 |
|
5686 |
25 Oct 19 |
olle |
istat.downloadFormBatch1 = function() |
5686 |
25 Oct 19 |
olle |
479 |
{ |
5686 |
25 Oct 19 |
olle |
istat.downloadFormBatch(1); |
5686 |
25 Oct 19 |
olle |
481 |
} |
5686 |
25 Oct 19 |
olle |
482 |
|
5686 |
25 Oct 19 |
olle |
istat.downloadFormBatch2 = function() |
5686 |
25 Oct 19 |
olle |
484 |
{ |
5686 |
25 Oct 19 |
olle |
istat.downloadFormBatch(2); |
5686 |
25 Oct 19 |
olle |
486 |
} |
5686 |
25 Oct 19 |
olle |
487 |
|
5686 |
25 Oct 19 |
olle |
istat.downloadFormBatch = function(batchType) |
5686 |
25 Oct 19 |
olle |
489 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
var startItemName = frm.itemName.value; |
5686 |
25 Oct 19 |
olle |
var nofFormSets = frm.nofFormSets.value; |
5686 |
25 Oct 19 |
olle |
493 |
|
5686 |
25 Oct 19 |
olle |
var url = '../ReferralGenerator.servlet?ID='+App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=DownloadFormBatchFile'; |
5686 |
25 Oct 19 |
olle |
url += '&batchType='+batchType; |
5686 |
25 Oct 19 |
olle |
url += '&startitemname='+encodeURIComponent(startItemName); |
5686 |
25 Oct 19 |
olle |
url += '&nofformsets='+encodeURIComponent(nofFormSets); |
5686 |
25 Oct 19 |
olle |
window.open(url); |
5686 |
25 Oct 19 |
olle |
500 |
} |
5686 |
25 Oct 19 |
olle |
501 |
|
5686 |
25 Oct 19 |
olle |
istat.downloadLabelFile = function() |
5686 |
25 Oct 19 |
olle |
503 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
var startItemName = frm.itemName.value; |
5686 |
25 Oct 19 |
olle |
var nofFormSets = frm.nofFormSets.value; |
5686 |
25 Oct 19 |
olle |
var preview = false; |
5686 |
25 Oct 19 |
olle |
508 |
|
5686 |
25 Oct 19 |
olle |
var url = '../LabelGeneration.servlet?ID=' + App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=GetSerumLabelFile'; |
5686 |
25 Oct 19 |
olle |
url += '&startitemname='+encodeURIComponent(startItemName); |
5686 |
25 Oct 19 |
olle |
url += '&nofformsets='+encodeURIComponent(nofFormSets); |
5686 |
25 Oct 19 |
olle |
url += '&preview=' + preview; |
5686 |
25 Oct 19 |
olle |
514 |
|
5686 |
25 Oct 19 |
olle |
if (preview) |
5686 |
25 Oct 19 |
olle |
516 |
{ |
5686 |
25 Oct 19 |
olle |
Doc.hide('previewWrapper'); |
5686 |
25 Oct 19 |
olle |
url += '&preview=1'; |
5686 |
25 Oct 19 |
olle |
519 |
|
5686 |
25 Oct 19 |
olle |
Wizard.showLoadingAnimation('Working...'); |
5686 |
25 Oct 19 |
olle |
Doc.hide('navigation'); |
5686 |
25 Oct 19 |
olle |
Wizard.asyncJsonRequest(url, istat.onPreviewLoaded); |
5686 |
25 Oct 19 |
olle |
523 |
} |
5686 |
25 Oct 19 |
olle |
else |
5686 |
25 Oct 19 |
olle |
525 |
{ |
5686 |
25 Oct 19 |
olle |
//window.location = url; |
5686 |
25 Oct 19 |
olle |
window.open(url); |
5686 |
25 Oct 19 |
olle |
528 |
} |
5686 |
25 Oct 19 |
olle |
529 |
} |
5686 |
25 Oct 19 |
olle |
530 |
|
5686 |
25 Oct 19 |
olle |
istat.updateUsedItemIdDigitsList = function() |
5686 |
25 Oct 19 |
olle |
532 |
{ |
5686 |
25 Oct 19 |
olle |
var frm = document.forms['meludi']; |
5686 |
25 Oct 19 |
olle |
var startItemName = frm.itemName.value; |
5686 |
25 Oct 19 |
olle |
var nofFormSets = frm.nofFormSets.value; |
5686 |
25 Oct 19 |
olle |
536 |
|
5686 |
25 Oct 19 |
olle |
var url = '../ReferralGenerator.servlet?ID='+App.getSessionId(); |
5686 |
25 Oct 19 |
olle |
url += '&cmd=UpdateUsedItemIdDigitsList'; |
5686 |
25 Oct 19 |
olle |
url += '&startitemname='+encodeURIComponent(startItemName); |
5686 |
25 Oct 19 |
olle |
url += '&nofformsets='+encodeURIComponent(nofFormSets); |
5686 |
25 Oct 19 |
olle |
541 |
|
5686 |
25 Oct 19 |
olle |
Wizard.asyncJsonRequest(url, istat.initializeStep3a); |
5686 |
25 Oct 19 |
olle |
543 |
} |
5686 |
25 Oct 19 |
olle |
544 |
|
5686 |
25 Oct 19 |
olle |
istat.selectOptionsDisabled = function(id, value) |
5686 |
25 Oct 19 |
olle |
546 |
{ |
5686 |
25 Oct 19 |
olle |
var op = document.getElementById(id).getElementsByTagName('option'); |
5686 |
25 Oct 19 |
olle |
for (var i = 0; i < op.length; i++) |
5686 |
25 Oct 19 |
olle |
549 |
{ |
5686 |
25 Oct 19 |
olle |
op[i].disabled = value; |
5686 |
25 Oct 19 |
olle |
551 |
} |
5686 |
25 Oct 19 |
olle |
552 |
} |
5686 |
25 Oct 19 |
olle |
553 |
|
5686 |
25 Oct 19 |
olle |
return istat; |
5686 |
25 Oct 19 |
olle |
555 |
}(); |
5686 |
25 Oct 19 |
olle |
556 |
|
5686 |
25 Oct 19 |
olle |
Doc.onLoad(Istat.initPage); |
5686 |
25 Oct 19 |
olle |
558 |
|