Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[imaging_uploader] Fix auto-populating VisitLabel #8881

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions modules/imaging_uploader/jsx/UploadForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,22 @@ class UploadForm extends Component {
let ids = patientName.split('_');
formData.candID = ids[1];
formData.pSCID = ids[0];
// visitLabel can contain underscores
// join the remaining elements of patientName and use as visitLabel
// visitLabel can contain underscores, filename can have suffix appended to patientName
zaliqarosli marked this conversation as resolved.
Show resolved Hide resolved
// join the remaining elements of patientName and pattern match
// against each visit label. Use as visitLabel the best (longest) match
ids.splice(0, 2);
formData.visitLabel = ids.join('_');
const suffix = ids.join('_');
const visitLabels = Object.keys(form.visitLabel.options);
let bestMatch = '';
visitLabels.map((visitLabel) => {
if (suffix.match(visitLabel) !== null) {
// consider the first match only
if (suffix.match(visitLabel)[0].length > bestMatch.length) {
bestMatch = suffix.match(visitLabel)[0];
}
}
});
formData.visitLabel = bestMatch;
}
}

Expand All @@ -82,9 +94,21 @@ class UploadForm extends Component {
formData.candID = ids[1];
formData.pSCID = ids[0];
// visitLabel can contain underscores
zaliqarosli marked this conversation as resolved.
Show resolved Hide resolved
// join the remaining elements of patientName and use as visitLabel
// join the remaining elements of patientName and pattern match
// against each visit label. Use as visitLabel the best (longest) match
ids.splice(0, 2);
formData.visitLabel = ids.join('_');
const suffix = ids.join('_');
const visitLabels = Object.keys(form.visitLabel.options);
let bestMatch = '';
visitLabels.map((visitLabel) => {
if (suffix.match(visitLabel) !== null) {
// consider the first match only
if (suffix.match(visitLabel)[0].length > bestMatch.length) {
bestMatch = suffix.match(visitLabel)[0];
}
}
});
formData.visitLabel = bestMatch;
}
}

Expand Down
Loading