3779 |
10 Mar 16 |
nicklas |
var YellowLabel = function() |
3779 |
10 Mar 16 |
nicklas |
2 |
{ |
3779 |
10 Mar 16 |
nicklas |
var yellow = {}; |
3779 |
10 Mar 16 |
nicklas |
var debug = 0; |
3782 |
11 Mar 16 |
nicklas |
var home; |
3787 |
17 Mar 16 |
nicklas |
6 |
|
3779 |
10 Mar 16 |
nicklas |
var specimen; |
3787 |
17 Mar 16 |
nicklas |
var sites; |
3787 |
17 Mar 16 |
nicklas |
var permissions; |
3779 |
10 Mar 16 |
nicklas |
10 |
|
3779 |
10 Mar 16 |
nicklas |
// Page initialization |
3779 |
10 Mar 16 |
nicklas |
yellow.initPage = function() |
3779 |
10 Mar 16 |
nicklas |
13 |
{ |
3782 |
11 Mar 16 |
nicklas |
home = Data.get('page-data', 'home-reggie'); |
3782 |
11 Mar 16 |
nicklas |
15 |
|
3779 |
10 Mar 16 |
nicklas |
// Step 1 |
4183 |
27 Oct 16 |
nicklas |
Events.addEventHandler('nameFilter', 'change', yellow.filterOnChange); |
3779 |
10 Mar 16 |
nicklas |
Events.addEventHandler('siteFilter', 'change', yellow.filterOnChange); |
3779 |
10 Mar 16 |
nicklas |
Events.addEventHandler('samplingDateFilter', 'change', yellow.filterOnChange); |
3779 |
10 Mar 16 |
nicklas |
Events.addEventHandler('arrivalDateFilter', 'change', yellow.filterOnChange); |
3826 |
05 Apr 16 |
nicklas |
Events.addEventHandler('consentDateFilter', 'change', yellow.filterOnChange); |
3780 |
10 Mar 16 |
nicklas |
Events.addEventHandler('extractionDateFilter', 'change', yellow.filterOnChange); |
3827 |
05 Apr 16 |
nicklas |
Events.addEventHandler('rnaqcFilter', 'change', yellow.filterOnChange); |
3780 |
10 Mar 16 |
nicklas |
Events.addEventHandler('libraryDateFilter', 'change', yellow.filterOnChange); |
3782 |
11 Mar 16 |
nicklas |
Events.addEventHandler('rawBioAssayDateFilter', 'change', yellow.filterOnChange); |
3810 |
23 Mar 16 |
nicklas |
Events.addEventHandler('pilotReportDateFilter', 'change', yellow.filterOnChange); |
3814 |
23 Mar 16 |
nicklas |
Events.addEventHandler('completedDateFilter', 'change', yellow.completedDateFilterOnChange); |
4188 |
28 Oct 16 |
nicklas |
Events.addEventHandler('downloadedDateFilter', 'change', yellow.filterOnChange); |
3779 |
10 Mar 16 |
nicklas |
29 |
|
3779 |
10 Mar 16 |
nicklas |
Buttons.addClickHandler('check_uncheck', yellow.selectAll); |
3787 |
17 Mar 16 |
nicklas |
Buttons.addClickHandler('btnMarkAsCompleted', yellow.markAsCompleted); |
3789 |
17 Mar 16 |
nicklas |
Buttons.addClickHandler('btnCreatePilotReportZip', yellow.createPilotReportZip); |
3825 |
05 Apr 16 |
nicklas |
Buttons.addClickHandler('btnCreatePilotReportPdf', yellow.createPilotReportPdf); |
4028 |
26 Jul 16 |
nicklas |
Buttons.addClickHandler('btnPublishForDelivery', yellow.publishForDelivery); |
3779 |
10 Mar 16 |
nicklas |
35 |
|
3779 |
10 Mar 16 |
nicklas |
// Navigation |
3779 |
10 Mar 16 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
3779 |
10 Mar 16 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
3779 |
10 Mar 16 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
3779 |
10 Mar 16 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
3779 |
10 Mar 16 |
nicklas |
41 |
|
3779 |
10 Mar 16 |
nicklas |
// Final registration |
3787 |
17 Mar 16 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', yellow.submit); |
3779 |
10 Mar 16 |
nicklas |
44 |
|
3779 |
10 Mar 16 |
nicklas |
var url = '../YellowLabel.servlet?ID='+App.getSessionId(); |
3815 |
23 Mar 16 |
nicklas |
url += '&cmd=LoadSitesAndPermissions'; |
3815 |
23 Mar 16 |
nicklas |
Wizard.asyncJsonRequest(url, yellow.onSitesLoaded); |
3815 |
23 Mar 16 |
nicklas |
Wizard.showLoadingAnimation('Loading sites...'); |
3815 |
23 Mar 16 |
nicklas |
49 |
} |
3815 |
23 Mar 16 |
nicklas |
50 |
|
3815 |
23 Mar 16 |
nicklas |
yellow.onSitesLoaded = function(response) |
3815 |
23 Mar 16 |
nicklas |
52 |
{ |
3815 |
23 Mar 16 |
nicklas |
var frm = document.forms['reggie']; |
3815 |
23 Mar 16 |
nicklas |
54 |
|
3815 |
23 Mar 16 |
nicklas |
sites = response.sites; |
3815 |
23 Mar 16 |
nicklas |
permissions = response.permissions; |
3815 |
23 Mar 16 |
nicklas |
if (permissions.PatientCurator || permissions.Administrator) |
3815 |
23 Mar 16 |
nicklas |
58 |
{ |
3815 |
23 Mar 16 |
nicklas |
Doc.show('yellow-toolbar'); |
3815 |
23 Mar 16 |
nicklas |
60 |
} |
3815 |
23 Mar 16 |
nicklas |
61 |
|
3815 |
23 Mar 16 |
nicklas |
for (var siteNo = 0; siteNo < sites.length; siteNo++) |
3815 |
23 Mar 16 |
nicklas |
63 |
{ |
3815 |
23 Mar 16 |
nicklas |
var site = sites[siteNo]; |
3815 |
23 Mar 16 |
nicklas |
frm.siteFilter[frm.siteFilter.length] = new Option(site.name, site.prefix); |
3815 |
23 Mar 16 |
nicklas |
66 |
} |
3815 |
23 Mar 16 |
nicklas |
67 |
|
3815 |
23 Mar 16 |
nicklas |
var url = '../YellowLabel.servlet?ID='+App.getSessionId(); |
3779 |
10 Mar 16 |
nicklas |
url += '&cmd=LoadActiveYellowSpecimen'; |
3779 |
10 Mar 16 |
nicklas |
Wizard.showLoadingAnimation('Loading YellowLabel specimen...'); |
3779 |
10 Mar 16 |
nicklas |
Wizard.asyncJsonRequest(url, yellow.onSpecimenLoaded); |
3779 |
10 Mar 16 |
nicklas |
72 |
} |
3779 |
10 Mar 16 |
nicklas |
73 |
|
3779 |
10 Mar 16 |
nicklas |
yellow.onSpecimenLoaded = function(response) |
3779 |
10 Mar 16 |
nicklas |
75 |
{ |
3779 |
10 Mar 16 |
nicklas |
specimen = response.specimen; |
3779 |
10 Mar 16 |
nicklas |
var frm = document.forms['reggie']; |
3779 |
10 Mar 16 |
nicklas |
78 |
|
3787 |
17 Mar 16 |
nicklas |
var siteCount = []; |
3787 |
17 Mar 16 |
nicklas |
for (var siteNo = 0; siteNo < sites.length; siteNo++) |
3787 |
17 Mar 16 |
nicklas |
81 |
{ |
3787 |
17 Mar 16 |
nicklas |
siteCount[sites[siteNo].prefix] = 0; |
3787 |
17 Mar 16 |
nicklas |
83 |
} |
3787 |
17 Mar 16 |
nicklas |
84 |
|
3779 |
10 Mar 16 |
nicklas |
var html = ''; |
3785 |
16 Mar 16 |
nicklas |
var numActive = 0; |
3785 |
16 Mar 16 |
nicklas |
var numCompleted = 0; |
3779 |
10 Mar 16 |
nicklas |
for (var spNo = 0; spNo < specimen.length; spNo++) |
3779 |
10 Mar 16 |
nicklas |
89 |
{ |
3779 |
10 Mar 16 |
nicklas |
var sp = specimen[spNo]; |
3780 |
10 Mar 16 |
nicklas |
var rna = sp.rna; |
3827 |
05 Apr 16 |
nicklas |
var rnaqc = sp.rnaqc; |
3780 |
10 Mar 16 |
nicklas |
var lib = sp.library; |
3782 |
11 Mar 16 |
nicklas |
var raw = sp.raw; |
3782 |
11 Mar 16 |
nicklas |
var pilotReport = sp.pilotReport; |
3782 |
11 Mar 16 |
nicklas |
96 |
|
3779 |
10 Mar 16 |
nicklas |
sp.include = true; |
3784 |
16 Mar 16 |
nicklas |
var rowClass = 'highlight'; |
3784 |
16 Mar 16 |
nicklas |
rowClass += spNo % 2 == 0 ? ' oddrow' : ' evenrow'; |
3800 |
18 Mar 16 |
nicklas |
if (sp.CompletedDate) |
3800 |
18 Mar 16 |
nicklas |
101 |
{ |
3800 |
18 Mar 16 |
nicklas |
rowClass += ' completed'; |
3800 |
18 Mar 16 |
nicklas |
103 |
} |
3800 |
18 Mar 16 |
nicklas |
else if (sp.pilotReport) |
3800 |
18 Mar 16 |
nicklas |
105 |
{ |
3800 |
18 Mar 16 |
nicklas |
rowClass += ' pilotreport'; |
3800 |
18 Mar 16 |
nicklas |
107 |
} |
4993 |
02 Oct 18 |
nicklas |
if (raw && raw.DO_NOT_USE || rna && rna.DO_NOT_USE) |
4993 |
02 Oct 18 |
nicklas |
109 |
{ |
4993 |
02 Oct 18 |
nicklas |
rowClass += ' donotuse'; |
4993 |
02 Oct 18 |
nicklas |
111 |
} |
3779 |
10 Mar 16 |
nicklas |
112 |
|
3784 |
16 Mar 16 |
nicklas |
html += '<tr class="' + rowClass + '" id="sp.'+sp.id + '">'; |
3784 |
16 Mar 16 |
nicklas |
html += '<td>'; |
3787 |
17 Mar 16 |
nicklas |
siteCount[sp.site.prefix]++; |
3784 |
16 Mar 16 |
nicklas |
if (!sp.CompletedDate) |
3784 |
16 Mar 16 |
nicklas |
117 |
{ |
3785 |
16 Mar 16 |
nicklas |
numActive++; |
3785 |
16 Mar 16 |
nicklas |
html += '<span id="index.'+sp.id+'">'+numActive+'</span> <input type="checkbox" name="sp.'+sp.id+'">'; |
3784 |
16 Mar 16 |
nicklas |
120 |
} |
3784 |
16 Mar 16 |
nicklas |
else |
3784 |
16 Mar 16 |
nicklas |
122 |
{ |
3785 |
16 Mar 16 |
nicklas |
numCompleted++; |
3784 |
16 Mar 16 |
nicklas |
124 |
} |
3784 |
16 Mar 16 |
nicklas |
html += '</td>'; |
3822 |
04 Apr 16 |
nicklas |
html += '<td class="dottedleft"><span class="link linked-item" data-item-type="SAMPLE" data-item-id="'+sp.id+'">'+Strings.encodeTags(sp.name)+'</span></td>'; |
4993 |
02 Oct 18 |
nicklas |
html += '<td class="iconcol-2"><img class="link case-summary" data-name="'+Strings.encodeTags(sp.name)+'" src="../images/case_summary.png">'+yellow.doNotUseWarning(raw, rna)+'</td>'; |
3779 |
10 Mar 16 |
nicklas |
html += '<td>'+Strings.encodeTags(sp.site.name) + '</td>'; |
3779 |
10 Mar 16 |
nicklas |
html += '<td>'+Reggie.reformatDate(sp.SamplingDate)+'</td>'; |
3779 |
10 Mar 16 |
nicklas |
html += '<td>'+Reggie.reformatDate(sp.ArrivalDate)+'</td>'; |
3828 |
05 Apr 16 |
nicklas |
html += '<td>'+Reggie.reformatDate(sp.ConsentDate, '<span class="missing">Missing</span>')+'</td>'; |
3828 |
05 Apr 16 |
nicklas |
html += '<td class="dottedleft">'+(rna ? Reggie.reformatDate(rna.QiacubeDate, '<span class="in-progress">In progress</span>'):'')+'</td>'; |
3822 |
04 Apr 16 |
nicklas |
html += '<td class="iconcol-2">'+yellow.asItemLink(rna, 'EXTRACT')+yellow.asFlag(rna)+'</td>'; |
3828 |
05 Apr 16 |
nicklas |
html += '<td>'+(rnaqc ? Reggie.formatNumber(rnaqc.RQS || rnaqc.RIN, '', 1) : (rna && rna.QiacubeDate ? '<span class="in-progress">In progress</span>' : ''))+'</td>'; |
3828 |
05 Apr 16 |
nicklas |
html += '<td class="dottedleft">'+(lib ? Reggie.reformatDate(lib.creationDate, '<span class="in-progress">In progress</span>'):'')+'</td>'; |
3822 |
04 Apr 16 |
nicklas |
html += '<td class="iconcol-1">'+yellow.asItemLink(lib, 'EXTRACT')+'</td>'; |
3828 |
05 Apr 16 |
nicklas |
html += '<td class="dottedleft">'+(raw ? Reggie.reformatDate(raw.creationDate, '<span class="in-progress">In progress</span>'):'')+'</td>'; |
3822 |
04 Apr 16 |
nicklas |
html += '<td class="iconcol-1">'+yellow.asItemLink(raw, 'RAWBIOASSAY')+'</td>'; |
3822 |
04 Apr 16 |
nicklas |
html += '<td class="dottedleft">'+(pilotReport ? Reggie.reformatDate(pilotReport.lastUpdatedDate):'')+'</td>'; |
3822 |
04 Apr 16 |
nicklas |
html += '<td class="iconcol-1">'+yellow.asFileLink(pilotReport, 'pdffile.png')+'</td>'; |
3812 |
23 Mar 16 |
nicklas |
html += '<td class="dottedleft">'+Reggie.reformatDate(sp.CompletedDate)+'</td>'; |
4188 |
28 Oct 16 |
nicklas |
html += '<td class="dottedleft">'; |
4188 |
28 Oct 16 |
nicklas |
if (pilotReport) |
4188 |
28 Oct 16 |
nicklas |
144 |
{ |
4188 |
28 Oct 16 |
nicklas |
if (pilotReport.isPublished) |
4188 |
28 Oct 16 |
nicklas |
146 |
{ |
4188 |
28 Oct 16 |
nicklas |
if (pilotReport.downloadCount > 0) |
4188 |
28 Oct 16 |
nicklas |
148 |
{ |
4188 |
28 Oct 16 |
nicklas |
html += Reggie.reformatDate(pilotReport.downloadedDate)+' ('+pilotReport.downloadCount+')'; |
4188 |
28 Oct 16 |
nicklas |
150 |
} |
4188 |
28 Oct 16 |
nicklas |
else |
4188 |
28 Oct 16 |
nicklas |
152 |
{ |
4188 |
28 Oct 16 |
nicklas |
html += 'Not downloaded'; |
4188 |
28 Oct 16 |
nicklas |
154 |
} |
4188 |
28 Oct 16 |
nicklas |
155 |
} |
4188 |
28 Oct 16 |
nicklas |
else if (sp.CompletedDate) |
4188 |
28 Oct 16 |
nicklas |
157 |
{ |
4188 |
28 Oct 16 |
nicklas |
html += 'Not published'; |
4188 |
28 Oct 16 |
nicklas |
159 |
} |
4188 |
28 Oct 16 |
nicklas |
160 |
} |
4188 |
28 Oct 16 |
nicklas |
html += '</td>'; |
3779 |
10 Mar 16 |
nicklas |
html += '</tr>'; |
3779 |
10 Mar 16 |
nicklas |
163 |
} |
3779 |
10 Mar 16 |
nicklas |
164 |
|
3815 |
23 Mar 16 |
nicklas |
// Update the site filter list with current counts |
3815 |
23 Mar 16 |
nicklas |
for (var siteNo = 0; siteNo < sites.length; siteNo++) |
3779 |
10 Mar 16 |
nicklas |
167 |
{ |
3815 |
23 Mar 16 |
nicklas |
var site = sites[siteNo]; |
3815 |
23 Mar 16 |
nicklas |
frm.siteFilter[siteNo+1].text = site.name + ' ('+siteCount[site.prefix]+')'; |
3779 |
10 Mar 16 |
nicklas |
170 |
} |
3779 |
10 Mar 16 |
nicklas |
171 |
|
3779 |
10 Mar 16 |
nicklas |
Doc.element('specimen-list').innerHTML = html; |
3785 |
16 Mar 16 |
nicklas |
Doc.element('num-active').innerHTML = numActive; |
3785 |
16 Mar 16 |
nicklas |
Doc.element('num-completed').innerHTML = numCompleted; |
3779 |
10 Mar 16 |
nicklas |
175 |
|
3779 |
10 Mar 16 |
nicklas |
var cs = document.getElementsByClassName('case-summary'); |
3779 |
10 Mar 16 |
nicklas |
for (var i = 0; i < cs.length; i++) |
3779 |
10 Mar 16 |
nicklas |
178 |
{ |
5019 |
10 Oct 18 |
nicklas |
Events.addEventHandler(cs[i], 'click', Reggie.openCaseSummaryPopupOnEvent); |
3779 |
10 Mar 16 |
nicklas |
180 |
} |
3782 |
11 Mar 16 |
nicklas |
181 |
|
3787 |
17 Mar 16 |
nicklas |
var linkedItems = document.getElementsByClassName('linked-item'); |
3787 |
17 Mar 16 |
nicklas |
for (var itemNo = 0; itemNo < linkedItems.length; itemNo++) |
3787 |
17 Mar 16 |
nicklas |
184 |
{ |
3787 |
17 Mar 16 |
nicklas |
Events.addEventHandler(linkedItems[itemNo], 'click', Items.itemOnClick); |
3787 |
17 Mar 16 |
nicklas |
186 |
} |
3787 |
17 Mar 16 |
nicklas |
187 |
|
3782 |
11 Mar 16 |
nicklas |
var linkedFiles = document.getElementsByClassName('linked-file'); |
3782 |
11 Mar 16 |
nicklas |
for (var fileNo = 0; fileNo < linkedFiles.length; fileNo++) |
3782 |
11 Mar 16 |
nicklas |
190 |
{ |
3782 |
11 Mar 16 |
nicklas |
Events.addEventHandler(linkedFiles[fileNo], 'click', Files.viewFileOnClick); |
3782 |
11 Mar 16 |
nicklas |
192 |
} |
3814 |
23 Mar 16 |
nicklas |
193 |
|
3815 |
23 Mar 16 |
nicklas |
Doc.show('step-1'); |
3815 |
23 Mar 16 |
nicklas |
195 |
|
3814 |
23 Mar 16 |
nicklas |
yellow.filterOnChange(); |
3782 |
11 Mar 16 |
nicklas |
197 |
|
3779 |
10 Mar 16 |
nicklas |
198 |
} |
3779 |
10 Mar 16 |
nicklas |
199 |
|
3779 |
10 Mar 16 |
nicklas |
yellow.selectAll = function() |
3779 |
10 Mar 16 |
nicklas |
201 |
{ |
3779 |
10 Mar 16 |
nicklas |
var frm = document.forms['reggie']; |
3779 |
10 Mar 16 |
nicklas |
var firstChecked = null; |
3779 |
10 Mar 16 |
nicklas |
for (var spNo = 0; spNo < specimen.length; spNo++) |
3779 |
10 Mar 16 |
nicklas |
205 |
{ |
3779 |
10 Mar 16 |
nicklas |
var sp = specimen[spNo]; |
3784 |
16 Mar 16 |
nicklas |
var checkbox = frm['sp.'+sp.id]; |
3784 |
16 Mar 16 |
nicklas |
if (sp.include && checkbox) |
3779 |
10 Mar 16 |
nicklas |
209 |
{ |
3779 |
10 Mar 16 |
nicklas |
if (firstChecked == null) |
3779 |
10 Mar 16 |
nicklas |
211 |
{ |
3784 |
16 Mar 16 |
nicklas |
firstChecked = checkbox.checked; |
3779 |
10 Mar 16 |
nicklas |
213 |
} |
3784 |
16 Mar 16 |
nicklas |
checkbox.checked = !firstChecked; |
3779 |
10 Mar 16 |
nicklas |
215 |
} |
3779 |
10 Mar 16 |
nicklas |
216 |
} |
3779 |
10 Mar 16 |
nicklas |
217 |
} |
3779 |
10 Mar 16 |
nicklas |
218 |
|
3814 |
23 Mar 16 |
nicklas |
yellow.completedDateFilterOnChange = function() |
3814 |
23 Mar 16 |
nicklas |
220 |
{ |
3814 |
23 Mar 16 |
nicklas |
var frm = document.forms['reggie']; |
3814 |
23 Mar 16 |
nicklas |
var url = '../YellowLabel.servlet?ID='+App.getSessionId(); |
3814 |
23 Mar 16 |
nicklas |
var completedDate = frm.completedDateFilter.value.replace(/\-/g, ''); |
4993 |
02 Oct 18 |
nicklas |
Doc.element('specimen-list').innerHTML = ''; |
3814 |
23 Mar 16 |
nicklas |
url += '&cmd=LoadActiveYellowSpecimen&completedDateFilter='+encodeURIComponent(completedDate); |
3814 |
23 Mar 16 |
nicklas |
Wizard.showLoadingAnimation('Loading YellowLabel specimen...'); |
3814 |
23 Mar 16 |
nicklas |
Wizard.asyncJsonRequest(url, yellow.onSpecimenLoaded); |
3814 |
23 Mar 16 |
nicklas |
228 |
} |
3814 |
23 Mar 16 |
nicklas |
229 |
|
3779 |
10 Mar 16 |
nicklas |
yellow.filterOnChange = function() |
3779 |
10 Mar 16 |
nicklas |
231 |
{ |
3779 |
10 Mar 16 |
nicklas |
var frm = document.forms['reggie']; |
3779 |
10 Mar 16 |
nicklas |
233 |
|
3779 |
10 Mar 16 |
nicklas |
var filter = new Filter(); |
3779 |
10 Mar 16 |
nicklas |
// Specimen filters |
4183 |
27 Oct 16 |
nicklas |
filter.addContainsCriteria(ItemProperty.Name, frm.nameFilter.value); |
3779 |
10 Mar 16 |
nicklas |
filter.addTextCriteria(ItemProperty.Site, frm.siteFilter.value); |
3779 |
10 Mar 16 |
nicklas |
filter.addDateCriteria(ItemProperty.SamplingDate, frm.samplingDateFilter.value); |
3779 |
10 Mar 16 |
nicklas |
filter.addDateCriteria(ItemProperty.ArrivalDate, frm.arrivalDateFilter.value); |
3826 |
05 Apr 16 |
nicklas |
filter.addDateCriteria(ItemProperty.ConsentDate, frm.consentDateFilter.value); |
3780 |
10 Mar 16 |
nicklas |
filter.addDateCriteria(ItemProperty.ExtractionDate, frm.extractionDateFilter.value); |
3827 |
05 Apr 16 |
nicklas |
filter.addNumericCriteria(ItemProperty.RqsOrRin, frm.rnaqcFilter.value); |
3780 |
10 Mar 16 |
nicklas |
filter.addDateCriteria(ItemProperty.LibraryDate, frm.libraryDateFilter.value); |
3782 |
11 Mar 16 |
nicklas |
filter.addDateCriteria(ItemProperty.RawDate, frm.rawBioAssayDateFilter.value); |
3810 |
23 Mar 16 |
nicklas |
filter.addDateCriteria(ItemProperty.PilotReportDate, frm.pilotReportDateFilter.value); |
3812 |
23 Mar 16 |
nicklas |
filter.addDateCriteria(ItemProperty.CompletedDate, frm.completedDateFilter.value); |
4188 |
28 Oct 16 |
nicklas |
filter.addDateCriteria(ItemProperty.DownloadedDate, frm.downloadedDateFilter.value); |
3779 |
10 Mar 16 |
nicklas |
248 |
|
3785 |
16 Mar 16 |
nicklas |
var numActive = 0; |
3785 |
16 Mar 16 |
nicklas |
var numCompleted = 0; |
3779 |
10 Mar 16 |
nicklas |
for (var spNo = 0; spNo < specimen.length; spNo++) |
3779 |
10 Mar 16 |
nicklas |
252 |
{ |
3779 |
10 Mar 16 |
nicklas |
var sp = specimen[spNo]; |
3779 |
10 Mar 16 |
nicklas |
254 |
|
3779 |
10 Mar 16 |
nicklas |
sp.include = filter.check(sp); |
3779 |
10 Mar 16 |
nicklas |
if (sp.include) |
3779 |
10 Mar 16 |
nicklas |
257 |
{ |
3785 |
16 Mar 16 |
nicklas |
if (sp.CompletedDate) |
3785 |
16 Mar 16 |
nicklas |
259 |
{ |
3785 |
16 Mar 16 |
nicklas |
numCompleted++; |
3785 |
16 Mar 16 |
nicklas |
261 |
} |
3785 |
16 Mar 16 |
nicklas |
else |
3785 |
16 Mar 16 |
nicklas |
263 |
{ |
3785 |
16 Mar 16 |
nicklas |
numActive++; |
3785 |
16 Mar 16 |
nicklas |
Doc.element('index.'+sp.id).innerHTML = numActive; |
3785 |
16 Mar 16 |
nicklas |
266 |
} |
3787 |
17 Mar 16 |
nicklas |
var evenRow = (numActive + numCompleted) % 2 == 0; |
3787 |
17 Mar 16 |
nicklas |
var tr = Doc.element('sp.'+sp.id); |
3787 |
17 Mar 16 |
nicklas |
Doc.addOrRemoveClass(tr, 'oddrow', !evenRow); |
3787 |
17 Mar 16 |
nicklas |
Doc.addOrRemoveClass(tr, 'evenrow', evenRow); |
3779 |
10 Mar 16 |
nicklas |
Doc.show(tr); |
3779 |
10 Mar 16 |
nicklas |
272 |
} |
3779 |
10 Mar 16 |
nicklas |
else |
3779 |
10 Mar 16 |
nicklas |
274 |
{ |
3779 |
10 Mar 16 |
nicklas |
Doc.hide('sp.'+sp.id); |
3779 |
10 Mar 16 |
nicklas |
276 |
} |
3779 |
10 Mar 16 |
nicklas |
277 |
} |
3779 |
10 Mar 16 |
nicklas |
278 |
|
3787 |
17 Mar 16 |
nicklas |
Doc.showHide('specimen-list', numActive+numCompleted > 0); |
3787 |
17 Mar 16 |
nicklas |
Doc.showHide('no-matching-specimen', numActive+numCompleted==0); |
3785 |
16 Mar 16 |
nicklas |
Doc.element('num-active').innerHTML = numActive; |
3785 |
16 Mar 16 |
nicklas |
Doc.element('num-completed').innerHTML = numCompleted; |
3779 |
10 Mar 16 |
nicklas |
283 |
} |
3779 |
10 Mar 16 |
nicklas |
284 |
|
3822 |
04 Apr 16 |
nicklas |
yellow.asFlag = function(item) |
3822 |
04 Apr 16 |
nicklas |
286 |
{ |
3822 |
04 Apr 16 |
nicklas |
var html = ''; |
3822 |
04 Apr 16 |
nicklas |
if (item && item.Flag) |
3822 |
04 Apr 16 |
nicklas |
289 |
{ |
3822 |
04 Apr 16 |
nicklas |
html += '<img class="flagged" src="'+home+'/images/flag.png" title="'+Strings.encodeTags(item.Flag)+'">'; |
3822 |
04 Apr 16 |
nicklas |
291 |
} |
3822 |
04 Apr 16 |
nicklas |
return html; |
3822 |
04 Apr 16 |
nicklas |
293 |
} |
3822 |
04 Apr 16 |
nicklas |
294 |
|
3811 |
23 Mar 16 |
nicklas |
yellow.asItemLink = function(item, itemType) |
3811 |
23 Mar 16 |
nicklas |
296 |
{ |
3811 |
23 Mar 16 |
nicklas |
var link = ''; |
3811 |
23 Mar 16 |
nicklas |
if (item) |
3811 |
23 Mar 16 |
nicklas |
299 |
{ |
3811 |
23 Mar 16 |
nicklas |
link = '<span class="link linked-item" data-item-type="'+itemType+'" data-item-id="'+item.id+'"><img src="../../../images/edit.png"></span>'; |
3811 |
23 Mar 16 |
nicklas |
301 |
} |
3811 |
23 Mar 16 |
nicklas |
return link; |
3811 |
23 Mar 16 |
nicklas |
303 |
} |
3811 |
23 Mar 16 |
nicklas |
304 |
|
3782 |
11 Mar 16 |
nicklas |
yellow.asFileLink = function(file, icon) |
3782 |
11 Mar 16 |
nicklas |
306 |
{ |
3782 |
11 Mar 16 |
nicklas |
var link = ''; |
3782 |
11 Mar 16 |
nicklas |
if (file) |
3782 |
11 Mar 16 |
nicklas |
309 |
{ |
3811 |
23 Mar 16 |
nicklas |
link = '<span class="link linked-file" data-file-id="'+file.id+'"><img src="'+home+'/images/'+icon+'"></span>'; |
3782 |
11 Mar 16 |
nicklas |
311 |
} |
3782 |
11 Mar 16 |
nicklas |
return link; |
3782 |
11 Mar 16 |
nicklas |
313 |
} |
4993 |
02 Oct 18 |
nicklas |
314 |
|
4993 |
02 Oct 18 |
nicklas |
yellow.doNotUseWarning = function(raw, rna) |
4993 |
02 Oct 18 |
nicklas |
316 |
{ |
4993 |
02 Oct 18 |
nicklas |
var warning = ''; |
4993 |
02 Oct 18 |
nicklas |
if (raw && raw.DO_NOT_USE) |
4993 |
02 Oct 18 |
nicklas |
319 |
{ |
4993 |
02 Oct 18 |
nicklas |
warning += '<img src="'+home+'/images/warning.png" title="DoNotUse-'+Strings.encodeTags(raw.DO_NOT_USE + ': ' + raw.DO_NOT_USE_COMMENT)+'">'; |
4993 |
02 Oct 18 |
nicklas |
321 |
} |
4993 |
02 Oct 18 |
nicklas |
else if (rna && rna.DO_NOT_USE) |
4993 |
02 Oct 18 |
nicklas |
323 |
{ |
4993 |
02 Oct 18 |
nicklas |
warning += '<img src="'+home+'/images/warning.png" title="DoNotUse-'+Strings.encodeTags(rna.DO_NOT_USE + ': ' + rna.DO_NOT_USE_COMMENT)+'">'; |
4993 |
02 Oct 18 |
nicklas |
325 |
} |
4993 |
02 Oct 18 |
nicklas |
return warning; |
4993 |
02 Oct 18 |
nicklas |
327 |
} |
3779 |
10 Mar 16 |
nicklas |
328 |
|
3787 |
17 Mar 16 |
nicklas |
yellow.checkSelected = function(filter, noneSelectedMsg) |
3787 |
17 Mar 16 |
nicklas |
330 |
{ |
3787 |
17 Mar 16 |
nicklas |
var frm = document.forms['reggie']; |
3787 |
17 Mar 16 |
nicklas |
var selected = []; |
3787 |
17 Mar 16 |
nicklas |
333 |
|
3787 |
17 Mar 16 |
nicklas |
for (var spNo = 0; spNo < specimen.length; spNo++) |
3787 |
17 Mar 16 |
nicklas |
335 |
{ |
3787 |
17 Mar 16 |
nicklas |
var sp = specimen[spNo]; |
3787 |
17 Mar 16 |
nicklas |
if (sp.include && frm['sp.'+sp.id] && frm['sp.'+sp.id].checked) |
3787 |
17 Mar 16 |
nicklas |
338 |
{ |
3787 |
17 Mar 16 |
nicklas |
if (!filter || filter.check(sp)) |
3787 |
17 Mar 16 |
nicklas |
selected[selected.length] = sp; |
3787 |
17 Mar 16 |
nicklas |
341 |
} |
3787 |
17 Mar 16 |
nicklas |
342 |
} |
3787 |
17 Mar 16 |
nicklas |
343 |
|
3787 |
17 Mar 16 |
nicklas |
if (selected.length == 0 && noneSelectedMsg) |
3787 |
17 Mar 16 |
nicklas |
345 |
{ |
3787 |
17 Mar 16 |
nicklas |
Forms.showNotification('check_uncheck', noneSelectedMsg, null, 'pointer-below'); |
3787 |
17 Mar 16 |
nicklas |
347 |
} |
3787 |
17 Mar 16 |
nicklas |
348 |
|
3787 |
17 Mar 16 |
nicklas |
return selected; |
3787 |
17 Mar 16 |
nicklas |
350 |
} |
4993 |
02 Oct 18 |
nicklas |
351 |
|
4993 |
02 Oct 18 |
nicklas |
352 |
/** |
4993 |
02 Oct 18 |
nicklas |
Count the number of items in the list that has a raw bioassay |
4993 |
02 Oct 18 |
nicklas |
or RNA marked as DoNotUse. |
4993 |
02 Oct 18 |
nicklas |
355 |
*/ |
4993 |
02 Oct 18 |
nicklas |
yellow.countDoNotUse = function(items) |
4993 |
02 Oct 18 |
nicklas |
357 |
{ |
4993 |
02 Oct 18 |
nicklas |
var numDoNotUse = 0; |
4993 |
02 Oct 18 |
nicklas |
for (var i = 0; i < items.length; i++) |
4993 |
02 Oct 18 |
nicklas |
360 |
{ |
4993 |
02 Oct 18 |
nicklas |
var item = items[i]; |
4993 |
02 Oct 18 |
nicklas |
if (item.raw && item.raw.DO_NOT_USE || item.rna && item.rna.DO_NOT_USE) numDoNotUse++; |
4993 |
02 Oct 18 |
nicklas |
363 |
} |
4993 |
02 Oct 18 |
nicklas |
return numDoNotUse; |
4993 |
02 Oct 18 |
nicklas |
365 |
} |
3782 |
11 Mar 16 |
nicklas |
366 |
|
3824 |
04 Apr 16 |
nicklas |
367 |
/** |
3824 |
04 Apr 16 |
nicklas |
Called when clicking the button and also a callback |
3824 |
04 Apr 16 |
nicklas |
for for the dialog. In the second case, options |
3824 |
04 Apr 16 |
nicklas |
must be specifed. |
3824 |
04 Apr 16 |
nicklas |
371 |
*/ |
3824 |
04 Apr 16 |
nicklas |
yellow.markAsCompleted = function(event, options) |
3779 |
10 Mar 16 |
nicklas |
373 |
{ |
3787 |
17 Mar 16 |
nicklas |
var selected = yellow.checkSelected(null, 'Select at least one specimen'); |
3787 |
17 Mar 16 |
nicklas |
if (selected.length == 0) return; |
3787 |
17 Mar 16 |
nicklas |
376 |
|
3824 |
04 Apr 16 |
nicklas |
if (!options) |
3787 |
17 Mar 16 |
nicklas |
378 |
{ |
3824 |
04 Apr 16 |
nicklas |
var url = 'mark-completed.jsp?ID='+App.getSessionId(); |
3824 |
04 Apr 16 |
nicklas |
url += '&numSelected='+selected.length; |
4993 |
02 Oct 18 |
nicklas |
url += '&numDoNotUse='+yellow.countDoNotUse(selected); |
3824 |
04 Apr 16 |
nicklas |
Dialogs.openPopup(url, 'MarkCompleted', 450, 300); |
3787 |
17 Mar 16 |
nicklas |
383 |
} |
3824 |
04 Apr 16 |
nicklas |
else |
3824 |
04 Apr 16 |
nicklas |
385 |
{ |
3824 |
04 Apr 16 |
nicklas |
var sp = []; |
3824 |
04 Apr 16 |
nicklas |
for (var i = 0; i < selected.length; i++) |
3824 |
04 Apr 16 |
nicklas |
388 |
{ |
3824 |
04 Apr 16 |
nicklas |
var tmp = {}; |
3824 |
04 Apr 16 |
nicklas |
tmp.id = selected[i].id; |
3824 |
04 Apr 16 |
nicklas |
sp[i] = tmp; |
3824 |
04 Apr 16 |
nicklas |
392 |
} |
3824 |
04 Apr 16 |
nicklas |
393 |
|
3824 |
04 Apr 16 |
nicklas |
var submitInfo = {}; |
3824 |
04 Apr 16 |
nicklas |
submitInfo.cmd = 'MarkAsCompleted'; |
3824 |
04 Apr 16 |
nicklas |
submitInfo.message = 'Marking ' + selected.length + ' specimen as completed'; |
3824 |
04 Apr 16 |
nicklas |
submitInfo.specimen = sp; |
3824 |
04 Apr 16 |
nicklas |
submitInfo.options = options; |
3824 |
04 Apr 16 |
nicklas |
Wizard.goRegister(submitInfo); |
3824 |
04 Apr 16 |
nicklas |
400 |
} |
3787 |
17 Mar 16 |
nicklas |
401 |
} |
3787 |
17 Mar 16 |
nicklas |
402 |
|
3791 |
17 Mar 16 |
nicklas |
403 |
/** |
3791 |
17 Mar 16 |
nicklas |
Called when clicking the button and also a callback |
3791 |
17 Mar 16 |
nicklas |
for downloading the ZIP file. In the second case, options |
3791 |
17 Mar 16 |
nicklas |
must be specifed. |
3791 |
17 Mar 16 |
nicklas |
407 |
*/ |
3791 |
17 Mar 16 |
nicklas |
yellow.createPilotReportZip = function(event, options) |
3789 |
17 Mar 16 |
nicklas |
409 |
{ |
3789 |
17 Mar 16 |
nicklas |
var frm = document.forms['reggie']; |
3789 |
17 Mar 16 |
nicklas |
411 |
|
3791 |
17 Mar 16 |
nicklas |
// Filter out items that have a pilot report |
3789 |
17 Mar 16 |
nicklas |
var filter = new Filter(); |
3789 |
17 Mar 16 |
nicklas |
filter.addNumericCriteria(ItemProperty.PilotReportExists, '1'); |
3789 |
17 Mar 16 |
nicklas |
415 |
|
3826 |
05 Apr 16 |
nicklas |
var selected = yellow.checkSelected(filter, 'Select at least one specimen that has a pilot report'); |
3789 |
17 Mar 16 |
nicklas |
if (selected.length == 0) return; |
3823 |
04 Apr 16 |
nicklas |
418 |
|
3791 |
17 Mar 16 |
nicklas |
if (!options) |
3789 |
17 Mar 16 |
nicklas |
420 |
{ |
3791 |
17 Mar 16 |
nicklas |
var url = 'make-zip.jsp?ID='+App.getSessionId(); |
3791 |
17 Mar 16 |
nicklas |
url += '&numSelected='+selected.length; |
4993 |
02 Oct 18 |
nicklas |
url += '&numDoNotUse='+yellow.countDoNotUse(selected); |
3791 |
17 Mar 16 |
nicklas |
Dialogs.openPopup(url, 'MakeZip', 450, 300); |
3789 |
17 Mar 16 |
nicklas |
425 |
} |
3791 |
17 Mar 16 |
nicklas |
else |
3791 |
17 Mar 16 |
nicklas |
427 |
{ |
3791 |
17 Mar 16 |
nicklas |
var raw = []; |
3821 |
04 Apr 16 |
nicklas |
var specimen = []; |
3791 |
17 Mar 16 |
nicklas |
for (var i = 0; i < selected.length; i++) |
3791 |
17 Mar 16 |
nicklas |
431 |
{ |
3791 |
17 Mar 16 |
nicklas |
raw[i] = selected[i].raw.id; |
3821 |
04 Apr 16 |
nicklas |
specimen[i] = selected[i].id; |
3791 |
17 Mar 16 |
nicklas |
434 |
} |
3791 |
17 Mar 16 |
nicklas |
435 |
|
3791 |
17 Mar 16 |
nicklas |
var url = '../YellowLabel.servlet?ID='+App.getSessionId(); |
3791 |
17 Mar 16 |
nicklas |
url += '&cmd=CreatePilotReportZip'; |
3791 |
17 Mar 16 |
nicklas |
url += '&rawBioAssays='+raw.join(','); |
3821 |
04 Apr 16 |
nicklas |
url += '&specimen='+specimen.join(','); |
3791 |
17 Mar 16 |
nicklas |
url += '&password='+encodeURIComponent(options.password); |
3821 |
04 Apr 16 |
nicklas |
url += '&completedDate='+encodeURIComponent(options.completedDate); |
3823 |
04 Apr 16 |
nicklas |
url += '&site='+encodeURIComponent(frm.siteFilter.value); |
3826 |
05 Apr 16 |
nicklas |
location.href = url; |
3791 |
17 Mar 16 |
nicklas |
444 |
} |
3789 |
17 Mar 16 |
nicklas |
445 |
} |
3789 |
17 Mar 16 |
nicklas |
446 |
|
3825 |
05 Apr 16 |
nicklas |
yellow.createPilotReportPdf = function() |
3825 |
05 Apr 16 |
nicklas |
448 |
{ |
4359 |
15 Feb 17 |
nicklas |
// Filter out items that have raw data |
3825 |
05 Apr 16 |
nicklas |
var filter = new Filter(); |
4359 |
15 Feb 17 |
nicklas |
filter.addNumericCriteria(ItemProperty.RawDataExists, '1'); |
3825 |
05 Apr 16 |
nicklas |
452 |
|
3825 |
05 Apr 16 |
nicklas |
var selected = yellow.checkSelected(filter, 'Select at least one specimen that has raw data'); |
3825 |
05 Apr 16 |
nicklas |
if (selected.length == 0) return; |
3791 |
17 Mar 16 |
nicklas |
455 |
|
3825 |
05 Apr 16 |
nicklas |
var raw = []; |
3825 |
05 Apr 16 |
nicklas |
for (var i = 0; i < selected.length; i++) |
3825 |
05 Apr 16 |
nicklas |
458 |
{ |
3825 |
05 Apr 16 |
nicklas |
raw[i] = { 'id': selected[i].raw.id }; |
3825 |
05 Apr 16 |
nicklas |
460 |
} |
3825 |
05 Apr 16 |
nicklas |
461 |
|
3825 |
05 Apr 16 |
nicklas |
var submitInfo = {}; |
3825 |
05 Apr 16 |
nicklas |
submitInfo.rawBioAssays = raw; |
3825 |
05 Apr 16 |
nicklas |
submitInfo.useDefaultSoftware = 1; |
3825 |
05 Apr 16 |
nicklas |
submitInfo.report = 'PILOT_REPORT'; |
3825 |
05 Apr 16 |
nicklas |
466 |
|
3825 |
05 Apr 16 |
nicklas |
var url = '../Report.servlet?ID='+App.getSessionId(); |
3825 |
05 Apr 16 |
nicklas |
url += '&cmd=CreateReport'; |
3825 |
05 Apr 16 |
nicklas |
Wizard.asyncJsonRequest(url, yellow.reportJobSubmitted, 'POST', JSON.stringify(submitInfo)); |
3825 |
05 Apr 16 |
nicklas |
470 |
} |
3825 |
05 Apr 16 |
nicklas |
471 |
|
4028 |
26 Jul 16 |
nicklas |
472 |
/** |
4028 |
26 Jul 16 |
nicklas |
Called when clicking the button and also a callback |
4028 |
26 Jul 16 |
nicklas |
for starting the publish job. In the second case, options |
4028 |
26 Jul 16 |
nicklas |
must be specifed. |
4028 |
26 Jul 16 |
nicklas |
476 |
*/ |
4028 |
26 Jul 16 |
nicklas |
yellow.publishForDelivery = function(event, options) |
4028 |
26 Jul 16 |
nicklas |
478 |
{ |
4028 |
26 Jul 16 |
nicklas |
// Filter out items that have a pilot report |
4028 |
26 Jul 16 |
nicklas |
var filter = new Filter(); |
4028 |
26 Jul 16 |
nicklas |
filter.addNumericCriteria(ItemProperty.PilotReportExists, '1'); |
4028 |
26 Jul 16 |
nicklas |
482 |
|
4028 |
26 Jul 16 |
nicklas |
var selected = yellow.checkSelected(filter, 'Select at least one specimen that has a pilot report'); |
4028 |
26 Jul 16 |
nicklas |
if (selected.length == 0) return; |
4028 |
26 Jul 16 |
nicklas |
485 |
|
4028 |
26 Jul 16 |
nicklas |
if (!options) |
4028 |
26 Jul 16 |
nicklas |
487 |
{ |
4028 |
26 Jul 16 |
nicklas |
var url = 'publish-for-delivery.jsp?ID='+App.getSessionId(); |
4028 |
26 Jul 16 |
nicklas |
url += '&numSelected='+selected.length; |
4993 |
02 Oct 18 |
nicklas |
url += '&numDoNotUse='+yellow.countDoNotUse(selected); |
4028 |
26 Jul 16 |
nicklas |
Dialogs.openPopup(url, 'PublishForDelivery', 450, 300); |
4028 |
26 Jul 16 |
nicklas |
492 |
} |
4028 |
26 Jul 16 |
nicklas |
else |
4028 |
26 Jul 16 |
nicklas |
494 |
{ |
4028 |
26 Jul 16 |
nicklas |
var raw = []; |
4028 |
26 Jul 16 |
nicklas |
var specimen = []; |
4028 |
26 Jul 16 |
nicklas |
for (var i = 0; i < selected.length; i++) |
4028 |
26 Jul 16 |
nicklas |
498 |
{ |
4028 |
26 Jul 16 |
nicklas |
raw[i] = {'id': selected[i].raw.id }; |
4028 |
26 Jul 16 |
nicklas |
specimen[i] = {'id': selected[i].id }; |
4028 |
26 Jul 16 |
nicklas |
501 |
} |
4028 |
26 Jul 16 |
nicklas |
502 |
|
4028 |
26 Jul 16 |
nicklas |
var submitInfo = {}; |
4028 |
26 Jul 16 |
nicklas |
submitInfo.cmd = 'PublishForDelivery'; |
4028 |
26 Jul 16 |
nicklas |
submitInfo.rawBioAssays = raw; |
4028 |
26 Jul 16 |
nicklas |
submitInfo.specimen = specimen; |
4028 |
26 Jul 16 |
nicklas |
submitInfo.options = options; |
4028 |
26 Jul 16 |
nicklas |
508 |
|
4028 |
26 Jul 16 |
nicklas |
Wizard.goRegister(submitInfo); |
4028 |
26 Jul 16 |
nicklas |
510 |
} |
4028 |
26 Jul 16 |
nicklas |
511 |
} |
4028 |
26 Jul 16 |
nicklas |
512 |
|
3825 |
05 Apr 16 |
nicklas |
yellow.reportJobSubmitted = function(response) |
3825 |
05 Apr 16 |
nicklas |
514 |
{ |
3825 |
05 Apr 16 |
nicklas |
if (response.job) |
3825 |
05 Apr 16 |
nicklas |
516 |
{ |
3825 |
05 Apr 16 |
nicklas |
Items.viewItem('JOB', response.job.id); |
3825 |
05 Apr 16 |
nicklas |
location.reload(true); |
3825 |
05 Apr 16 |
nicklas |
519 |
} |
3825 |
05 Apr 16 |
nicklas |
520 |
} |
3825 |
05 Apr 16 |
nicklas |
521 |
|
3787 |
17 Mar 16 |
nicklas |
yellow.submit = function(event) |
3787 |
17 Mar 16 |
nicklas |
523 |
{ |
3787 |
17 Mar 16 |
nicklas |
var submitInfo = event.detail; |
3787 |
17 Mar 16 |
nicklas |
var url = '../YellowLabel.servlet?ID='+App.getSessionId(); |
3787 |
17 Mar 16 |
nicklas |
url += '&cmd='+submitInfo.cmd; |
3787 |
17 Mar 16 |
nicklas |
Wizard.showLoadingAnimation(submitInfo.message || 'Registering YellowLabel specimen...'); |
3787 |
17 Mar 16 |
nicklas |
Wizard.asyncJsonRequest(url, yellow.submissionResults, 'POST', JSON.stringify(submitInfo)); |
3779 |
10 Mar 16 |
nicklas |
529 |
} |
3779 |
10 Mar 16 |
nicklas |
530 |
|
3779 |
10 Mar 16 |
nicklas |
yellow.submissionResults = function(response) |
3779 |
10 Mar 16 |
nicklas |
532 |
{ |
3779 |
10 Mar 16 |
nicklas |
Wizard.showFinalMessage(response.messages); |
3779 |
10 Mar 16 |
nicklas |
Doc.show('gorestart'); |
3779 |
10 Mar 16 |
nicklas |
535 |
} |
3779 |
10 Mar 16 |
nicklas |
536 |
|
3779 |
10 Mar 16 |
nicklas |
return yellow; |
3779 |
10 Mar 16 |
nicklas |
538 |
}(); |
3779 |
10 Mar 16 |
nicklas |
539 |
|
3779 |
10 Mar 16 |
nicklas |
Doc.onLoad(YellowLabel.initPage); |
3779 |
10 Mar 16 |
nicklas |
541 |
|
3779 |
10 Mar 16 |
nicklas |
542 |
|
3779 |
10 Mar 16 |
nicklas |
543 |
/** |
3779 |
10 Mar 16 |
nicklas |
Holds one or more filter criterias. Use the 'add*' methods |
3779 |
10 Mar 16 |
nicklas |
to add criterias to the filter, and the 'check(item)' method |
3779 |
10 Mar 16 |
nicklas |
to evaluate all criterias against a single item. |
3779 |
10 Mar 16 |
nicklas |
547 |
*/ |
3779 |
10 Mar 16 |
nicklas |
var Filter = function() |
3779 |
10 Mar 16 |
nicklas |
549 |
{ |
3779 |
10 Mar 16 |
nicklas |
this.criterias = []; |
3779 |
10 Mar 16 |
nicklas |
551 |
} |
3779 |
10 Mar 16 |
nicklas |
552 |
|
3779 |
10 Mar 16 |
nicklas |
553 |
/** |
3779 |
10 Mar 16 |
nicklas |
Adds a text criteria comparing the given item property to |
3779 |
10 Mar 16 |
nicklas |
a static value (f2). |
3779 |
10 Mar 16 |
nicklas |
556 |
*/ |
3779 |
10 Mar 16 |
nicklas |
Filter.prototype.addTextCriteria = function(itemProp, f2) |
3779 |
10 Mar 16 |
nicklas |
558 |
{ |
3779 |
10 Mar 16 |
nicklas |
if (f2 != '') |
3779 |
10 Mar 16 |
nicklas |
560 |
{ |
4359 |
15 Feb 17 |
nicklas |
var cmp; |
4359 |
15 Feb 17 |
nicklas |
if (f2 == '=') |
4359 |
15 Feb 17 |
nicklas |
563 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.eq; |
4359 |
15 Feb 17 |
nicklas |
f2 = null; |
4359 |
15 Feb 17 |
nicklas |
566 |
} |
4359 |
15 Feb 17 |
nicklas |
else if (f2 == '<>') |
4359 |
15 Feb 17 |
nicklas |
568 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.neq; |
4359 |
15 Feb 17 |
nicklas |
f2 = null; |
4359 |
15 Feb 17 |
nicklas |
571 |
} |
4359 |
15 Feb 17 |
nicklas |
else |
4359 |
15 Feb 17 |
nicklas |
573 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.eq; |
4359 |
15 Feb 17 |
nicklas |
575 |
} |
4359 |
15 Feb 17 |
nicklas |
this.criterias[this.criterias.length] = function(item) { return cmp(itemProp(item), f2) }; |
3779 |
10 Mar 16 |
nicklas |
577 |
} |
3779 |
10 Mar 16 |
nicklas |
578 |
} |
3779 |
10 Mar 16 |
nicklas |
579 |
|
3779 |
10 Mar 16 |
nicklas |
580 |
/** |
4183 |
27 Oct 16 |
nicklas |
Adds a text criteria checking if the given item property to |
4183 |
27 Oct 16 |
nicklas |
contains a static value (f2). |
4183 |
27 Oct 16 |
nicklas |
583 |
*/ |
4183 |
27 Oct 16 |
nicklas |
Filter.prototype.addContainsCriteria = function(itemProp, f2) |
4183 |
27 Oct 16 |
nicklas |
585 |
{ |
4183 |
27 Oct 16 |
nicklas |
if (f2 != '') |
4183 |
27 Oct 16 |
nicklas |
587 |
{ |
4359 |
15 Feb 17 |
nicklas |
var cmp; |
4359 |
15 Feb 17 |
nicklas |
if (f2 == '=') |
4359 |
15 Feb 17 |
nicklas |
590 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.eq; |
4359 |
15 Feb 17 |
nicklas |
f2 = null; |
4359 |
15 Feb 17 |
nicklas |
593 |
} |
4359 |
15 Feb 17 |
nicklas |
else if (f2 == '<>') |
4359 |
15 Feb 17 |
nicklas |
595 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.neq; |
4359 |
15 Feb 17 |
nicklas |
f2 = null; |
4359 |
15 Feb 17 |
nicklas |
598 |
} |
4359 |
15 Feb 17 |
nicklas |
else |
4359 |
15 Feb 17 |
nicklas |
600 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.contains; |
4359 |
15 Feb 17 |
nicklas |
602 |
} |
4359 |
15 Feb 17 |
nicklas |
this.criterias[this.criterias.length] = function(item) { return cmp(itemProp(item), f2) }; |
4183 |
27 Oct 16 |
nicklas |
604 |
} |
4183 |
27 Oct 16 |
nicklas |
605 |
} |
4183 |
27 Oct 16 |
nicklas |
606 |
|
4183 |
27 Oct 16 |
nicklas |
607 |
/** |
3779 |
10 Mar 16 |
nicklas |
Adds a numeric criteria comparing the given item property to |
3779 |
10 Mar 16 |
nicklas |
a static value (f2). The 'f2' value may start with either '<' or '>' |
3779 |
10 Mar 16 |
nicklas |
to compare with less than/greater than operators, otherwise |
3779 |
10 Mar 16 |
nicklas |
it will use the 'approximately equals' operator. |
3779 |
10 Mar 16 |
nicklas |
612 |
*/ |
3779 |
10 Mar 16 |
nicklas |
Filter.prototype.addNumericCriteria = function(itemProp, f2, factor) |
3779 |
10 Mar 16 |
nicklas |
614 |
{ |
3779 |
10 Mar 16 |
nicklas |
if (f2 != '') |
3779 |
10 Mar 16 |
nicklas |
616 |
{ |
4359 |
15 Feb 17 |
nicklas |
var cmp; |
4359 |
15 Feb 17 |
nicklas |
var limit; |
4359 |
15 Feb 17 |
nicklas |
if (f2 == '=') |
4359 |
15 Feb 17 |
nicklas |
620 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.eq; |
4359 |
15 Feb 17 |
nicklas |
limit = null; |
4359 |
15 Feb 17 |
nicklas |
623 |
} |
4359 |
15 Feb 17 |
nicklas |
else if (f2 == '<>') |
4359 |
15 Feb 17 |
nicklas |
625 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.neq; |
4359 |
15 Feb 17 |
nicklas |
limit = null; |
4359 |
15 Feb 17 |
nicklas |
628 |
} |
4359 |
15 Feb 17 |
nicklas |
else |
4359 |
15 Feb 17 |
nicklas |
630 |
{ |
4359 |
15 Feb 17 |
nicklas |
var firstChar = f2.charAt(0); |
4359 |
15 Feb 17 |
nicklas |
if (!firstChar.match(/[\d\-]/)) f2 = f2.substring(1); |
3779 |
10 Mar 16 |
nicklas |
633 |
|
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.get(firstChar, Comparator.approx); |
4359 |
15 Feb 17 |
nicklas |
limit = parseFloat(f2); |
4359 |
15 Feb 17 |
nicklas |
if (factor) limit *= factor; |
4359 |
15 Feb 17 |
nicklas |
637 |
} |
4359 |
15 Feb 17 |
nicklas |
638 |
|
3779 |
10 Mar 16 |
nicklas |
639 |
|
3779 |
10 Mar 16 |
nicklas |
this.criterias[this.criterias.length] = function(item) { return cmp(itemProp(item), limit) }; |
3779 |
10 Mar 16 |
nicklas |
641 |
} |
3779 |
10 Mar 16 |
nicklas |
642 |
} |
3779 |
10 Mar 16 |
nicklas |
643 |
|
3779 |
10 Mar 16 |
nicklas |
644 |
/** |
3779 |
10 Mar 16 |
nicklas |
Adds a temporal criteria for comparing dates. The 'f2' value |
3779 |
10 Mar 16 |
nicklas |
may start with either '<' or '>' to compare with earlier/later |
3779 |
10 Mar 16 |
nicklas |
than operators. In all cases, the 'f2' value is stripped from '-' |
3779 |
10 Mar 16 |
nicklas |
characters. |
3779 |
10 Mar 16 |
nicklas |
649 |
*/ |
3779 |
10 Mar 16 |
nicklas |
Filter.prototype.addDateCriteria = function(itemProp, f2) |
3779 |
10 Mar 16 |
nicklas |
651 |
{ |
3779 |
10 Mar 16 |
nicklas |
if (f2 != '') |
3779 |
10 Mar 16 |
nicklas |
653 |
{ |
4359 |
15 Feb 17 |
nicklas |
var cmp; |
4359 |
15 Feb 17 |
nicklas |
if (f2 == '=') |
4359 |
15 Feb 17 |
nicklas |
656 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.eq; |
4359 |
15 Feb 17 |
nicklas |
f2 = null; |
4359 |
15 Feb 17 |
nicklas |
659 |
} |
4359 |
15 Feb 17 |
nicklas |
else if (f2 == '<>') |
4359 |
15 Feb 17 |
nicklas |
661 |
{ |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.neq; |
4359 |
15 Feb 17 |
nicklas |
f2 = null; |
4359 |
15 Feb 17 |
nicklas |
664 |
} |
4359 |
15 Feb 17 |
nicklas |
else |
4359 |
15 Feb 17 |
nicklas |
666 |
{ |
4359 |
15 Feb 17 |
nicklas |
var firstChar = f2.charAt(0); |
4359 |
15 Feb 17 |
nicklas |
if (firstChar == '<' || firstChar == '>') f2 = f2.substring(1); |
4359 |
15 Feb 17 |
nicklas |
f2 = f2.replace(/\-/g, ''); |
4359 |
15 Feb 17 |
nicklas |
cmp = Comparator.get(firstChar, Comparator.startsWith); |
4359 |
15 Feb 17 |
nicklas |
671 |
} |
3779 |
10 Mar 16 |
nicklas |
this.criterias[this.criterias.length] = function(item) { return cmp(itemProp(item), f2) }; |
3779 |
10 Mar 16 |
nicklas |
673 |
} |
3779 |
10 Mar 16 |
nicklas |
674 |
|
3779 |
10 Mar 16 |
nicklas |
675 |
} |
3779 |
10 Mar 16 |
nicklas |
676 |
|
3779 |
10 Mar 16 |
nicklas |
677 |
/** |
3779 |
10 Mar 16 |
nicklas |
Evaluate all criterias. Return true if all pass, false otherwise. |
3779 |
10 Mar 16 |
nicklas |
679 |
*/ |
3779 |
10 Mar 16 |
nicklas |
Filter.prototype.check = function(item) |
3779 |
10 Mar 16 |
nicklas |
681 |
{ |
3779 |
10 Mar 16 |
nicklas |
for (var i = 0; i < this.criterias.length; i++) |
3779 |
10 Mar 16 |
nicklas |
683 |
{ |
3779 |
10 Mar 16 |
nicklas |
if (!this.criterias[i](item)) return false; |
3779 |
10 Mar 16 |
nicklas |
685 |
} |
3779 |
10 Mar 16 |
nicklas |
return true; |
3779 |
10 Mar 16 |
nicklas |
687 |
} |
3779 |
10 Mar 16 |
nicklas |
688 |
|
3779 |
10 Mar 16 |
nicklas |
689 |
/** |
3779 |
10 Mar 16 |
nicklas |
Functions for extracting various properties from |
3814 |
23 Mar 16 |
nicklas |
specimen items. Each method accepts a single specimen as a parameter |
3814 |
23 Mar 16 |
nicklas |
and return a value from the specimen item. The methods |
3779 |
10 Mar 16 |
nicklas |
are used as parameters to Filter.add*Criteria() methods. |
3779 |
10 Mar 16 |
nicklas |
694 |
*/ |
3779 |
10 Mar 16 |
nicklas |
var ItemProperty = function() |
3779 |
10 Mar 16 |
nicklas |
696 |
{ |
3779 |
10 Mar 16 |
nicklas |
var p = {}; |
3779 |
10 Mar 16 |
nicklas |
698 |
|
4183 |
27 Oct 16 |
nicklas |
p.Name = function(item) |
4183 |
27 Oct 16 |
nicklas |
700 |
{ |
4183 |
27 Oct 16 |
nicklas |
return item.name; |
4183 |
27 Oct 16 |
nicklas |
702 |
} |
4183 |
27 Oct 16 |
nicklas |
703 |
|
3779 |
10 Mar 16 |
nicklas |
// Get the item.site.prefix value |
3779 |
10 Mar 16 |
nicklas |
p.Site = function(item) |
3779 |
10 Mar 16 |
nicklas |
706 |
{ |
3779 |
10 Mar 16 |
nicklas |
return item.site.prefix; |
3779 |
10 Mar 16 |
nicklas |
708 |
} |
3779 |
10 Mar 16 |
nicklas |
709 |
|
3779 |
10 Mar 16 |
nicklas |
p.ArrivalDate = function(item) |
3779 |
10 Mar 16 |
nicklas |
711 |
{ |
3779 |
10 Mar 16 |
nicklas |
return item.ArrivalDate; |
3779 |
10 Mar 16 |
nicklas |
713 |
} |
3779 |
10 Mar 16 |
nicklas |
714 |
|
3779 |
10 Mar 16 |
nicklas |
p.SamplingDate = function(item) |
3779 |
10 Mar 16 |
nicklas |
716 |
{ |
3779 |
10 Mar 16 |
nicklas |
return item.SamplingDate; |
3779 |
10 Mar 16 |
nicklas |
718 |
} |
3780 |
10 Mar 16 |
nicklas |
719 |
|
3826 |
05 Apr 16 |
nicklas |
p.ConsentDate = function(item) |
3826 |
05 Apr 16 |
nicklas |
721 |
{ |
3826 |
05 Apr 16 |
nicklas |
return item.ConsentDate; |
3826 |
05 Apr 16 |
nicklas |
723 |
} |
3826 |
05 Apr 16 |
nicklas |
724 |
|
3780 |
10 Mar 16 |
nicklas |
p.ExtractionDate = function(item) |
3780 |
10 Mar 16 |
nicklas |
726 |
{ |
3780 |
10 Mar 16 |
nicklas |
return item.rna ? item.rna.QiacubeDate : null; |
3780 |
10 Mar 16 |
nicklas |
728 |
} |
3780 |
10 Mar 16 |
nicklas |
729 |
|
3827 |
05 Apr 16 |
nicklas |
p.RqsOrRin = function(item) |
3827 |
05 Apr 16 |
nicklas |
731 |
{ |
3827 |
05 Apr 16 |
nicklas |
return item.rnaqc ? (item.rnaqc.RQS || item.rnaqc.RIN) : null; |
3827 |
05 Apr 16 |
nicklas |
733 |
} |
3827 |
05 Apr 16 |
nicklas |
734 |
|
3780 |
10 Mar 16 |
nicklas |
p.LibraryDate = function(item) |
3780 |
10 Mar 16 |
nicklas |
736 |
{ |
3780 |
10 Mar 16 |
nicklas |
return item.library ? item.library.creationDate : null; |
3780 |
10 Mar 16 |
nicklas |
738 |
} |
3782 |
11 Mar 16 |
nicklas |
739 |
|
3782 |
11 Mar 16 |
nicklas |
p.RawDate = function(item) |
3782 |
11 Mar 16 |
nicklas |
741 |
{ |
3782 |
11 Mar 16 |
nicklas |
return item.raw ? item.raw.creationDate : null; |
3782 |
11 Mar 16 |
nicklas |
743 |
} |
3782 |
11 Mar 16 |
nicklas |
744 |
|
4359 |
15 Feb 17 |
nicklas |
p.RawDataExists = function(item) |
4359 |
15 Feb 17 |
nicklas |
746 |
{ |
4359 |
15 Feb 17 |
nicklas |
return item.raw ? 1 : 0; |
4359 |
15 Feb 17 |
nicklas |
748 |
} |
4359 |
15 Feb 17 |
nicklas |
749 |
|
3813 |
23 Mar 16 |
nicklas |
p.PilotReportExists = function(item) |
3813 |
23 Mar 16 |
nicklas |
751 |
{ |
3813 |
23 Mar 16 |
nicklas |
return item.pilotReport ? 1 : 0; |
3813 |
23 Mar 16 |
nicklas |
753 |
} |
3813 |
23 Mar 16 |
nicklas |
754 |
|
3810 |
23 Mar 16 |
nicklas |
p.PilotReportDate = function(item) |
3782 |
11 Mar 16 |
nicklas |
756 |
{ |
3810 |
23 Mar 16 |
nicklas |
return item.pilotReport ? item.pilotReport.lastUpdatedDate : null; |
3782 |
11 Mar 16 |
nicklas |
758 |
} |
3812 |
23 Mar 16 |
nicklas |
759 |
|
3812 |
23 Mar 16 |
nicklas |
p.CompletedDate = function(item) |
3812 |
23 Mar 16 |
nicklas |
761 |
{ |
3812 |
23 Mar 16 |
nicklas |
return item.CompletedDate; |
3812 |
23 Mar 16 |
nicklas |
763 |
} |
4188 |
28 Oct 16 |
nicklas |
764 |
|
4188 |
28 Oct 16 |
nicklas |
p.DownloadedDate = function(item) |
4188 |
28 Oct 16 |
nicklas |
766 |
{ |
4188 |
28 Oct 16 |
nicklas |
return item.pilotReport ? item.pilotReport.downloadedDate : null; |
4188 |
28 Oct 16 |
nicklas |
768 |
} |
3779 |
10 Mar 16 |
nicklas |
769 |
|
3779 |
10 Mar 16 |
nicklas |
return p; |
3779 |
10 Mar 16 |
nicklas |
771 |
}(); |
3779 |
10 Mar 16 |
nicklas |
772 |
|
3779 |
10 Mar 16 |
nicklas |
773 |
/** |
3779 |
10 Mar 16 |
nicklas |
Comparator functions for comparing two values. |
3779 |
10 Mar 16 |
nicklas |
775 |
*/ |
3779 |
10 Mar 16 |
nicklas |
var Comparator = function() |
3779 |
10 Mar 16 |
nicklas |
777 |
{ |
3779 |
10 Mar 16 |
nicklas |
var cmp = {}; |
3779 |
10 Mar 16 |
nicklas |
779 |
|
3779 |
10 Mar 16 |
nicklas |
780 |
/** |
3779 |
10 Mar 16 |
nicklas |
Return a comparator based on the symbol |
3779 |
10 Mar 16 |
nicklas |
which can be either '>' or '<' to return |
3779 |
10 Mar 16 |
nicklas |
Comparator.gt or Comparator.lt. Otherwise |
3779 |
10 Mar 16 |
nicklas |
the given default or Comparator.eq is returned. |
3779 |
10 Mar 16 |
nicklas |
785 |
*/ |
3779 |
10 Mar 16 |
nicklas |
cmp.get = function(symbol, defaultCmp) |
3779 |
10 Mar 16 |
nicklas |
787 |
{ |
3779 |
10 Mar 16 |
nicklas |
var c; |
3779 |
10 Mar 16 |
nicklas |
if (symbol == '<') |
3779 |
10 Mar 16 |
nicklas |
790 |
{ |
3779 |
10 Mar 16 |
nicklas |
c = cmp.lt; |
3779 |
10 Mar 16 |
nicklas |
792 |
} |
3779 |
10 Mar 16 |
nicklas |
else if (symbol == '>') |
3779 |
10 Mar 16 |
nicklas |
794 |
{ |
3779 |
10 Mar 16 |
nicklas |
c = cmp.gt; |
3779 |
10 Mar 16 |
nicklas |
796 |
} |
3779 |
10 Mar 16 |
nicklas |
else |
3779 |
10 Mar 16 |
nicklas |
798 |
{ |
3779 |
10 Mar 16 |
nicklas |
c = defaultCmp || cmp.eq; |
3779 |
10 Mar 16 |
nicklas |
800 |
} |
3779 |
10 Mar 16 |
nicklas |
return c; |
3779 |
10 Mar 16 |
nicklas |
802 |
} |
3779 |
10 Mar 16 |
nicklas |
803 |
|
3779 |
10 Mar 16 |
nicklas |
// Compare if two values are equal |
3779 |
10 Mar 16 |
nicklas |
cmp.eq = function(v1, v2) |
3779 |
10 Mar 16 |
nicklas |
806 |
{ |
3779 |
10 Mar 16 |
nicklas |
return v1 == v2; |
3779 |
10 Mar 16 |
nicklas |
808 |
} |
3779 |
10 Mar 16 |
nicklas |
809 |
|
4359 |
15 Feb 17 |
nicklas |
// Compare if two values are different |
4359 |
15 Feb 17 |
nicklas |
cmp.neq = function(v1, v2) |
4359 |
15 Feb 17 |
nicklas |
812 |
{ |
4359 |
15 Feb 17 |
nicklas |
return v1 != v2; |
4359 |
15 Feb 17 |
nicklas |
814 |
} |
4359 |
15 Feb 17 |
nicklas |
815 |
|
4183 |
27 Oct 16 |
nicklas |
// Check if v2 is contained in v1 |
4183 |
27 Oct 16 |
nicklas |
cmp.contains = function(v1, v2) |
4183 |
27 Oct 16 |
nicklas |
818 |
{ |
4183 |
27 Oct 16 |
nicklas |
return v1 != null && v2 != null && v1.indexOf(v2) >= 0; |
4183 |
27 Oct 16 |
nicklas |
820 |
} |
4183 |
27 Oct 16 |
nicklas |
821 |
|
3779 |
10 Mar 16 |
nicklas |
// Compare if two values are appoximately equals (difference is not more than 0.05) |
3779 |
10 Mar 16 |
nicklas |
cmp.approx = function(v1, v2) |
3779 |
10 Mar 16 |
nicklas |
824 |
{ |
3779 |
10 Mar 16 |
nicklas |
return Math.abs(v2 - v1) < 0.05; |
3779 |
10 Mar 16 |
nicklas |
826 |
} |
3779 |
10 Mar 16 |
nicklas |
827 |
|
3779 |
10 Mar 16 |
nicklas |
// Compare if v1 starts with the same string as v2 |
3779 |
10 Mar 16 |
nicklas |
cmp.startsWith = function(v1, v2) |
3779 |
10 Mar 16 |
nicklas |
830 |
{ |
3779 |
10 Mar 16 |
nicklas |
return v1 != null && v1.indexOf(v2) == 0; |
3779 |
10 Mar 16 |
nicklas |
832 |
} |
3779 |
10 Mar 16 |
nicklas |
833 |
|
3779 |
10 Mar 16 |
nicklas |
// Compare if v1 is greater than or equal to v2 |
3779 |
10 Mar 16 |
nicklas |
cmp.gt = function(v1, v2) |
3779 |
10 Mar 16 |
nicklas |
836 |
{ |
3814 |
23 Mar 16 |
nicklas |
return v1 != null && v2 != null && v1 >= v2; |
3779 |
10 Mar 16 |
nicklas |
838 |
} |
3779 |
10 Mar 16 |
nicklas |
839 |
|
3779 |
10 Mar 16 |
nicklas |
// Compare if v1 is less than or equal to v2 |
3779 |
10 Mar 16 |
nicklas |
cmp.lt = function(v1, v2) |
3779 |
10 Mar 16 |
nicklas |
842 |
{ |
3814 |
23 Mar 16 |
nicklas |
return v1 != null && v2 != null && v1 <= v2; |
3779 |
10 Mar 16 |
nicklas |
844 |
} |
3779 |
10 Mar 16 |
nicklas |
845 |
|
3779 |
10 Mar 16 |
nicklas |
return cmp; |
3779 |
10 Mar 16 |
nicklas |
847 |
}(); |
3779 |
10 Mar 16 |
nicklas |
848 |
|