Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[imaging_uploader] Fix auto-populating VisitLabel #8881

Merged
Merged
Changes from all 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
36 changes: 30 additions & 6 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 PSCID_CandID_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;
Comment on lines +69 to +84
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I heard somewhere that phantom scans names don't get validated? but im not sure and this doesnt hurt it only helps

Copy link
Contributor Author

@zaliqarosli zaliqarosli Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this case isn't for phantom scans, its in the else if statement. the difference between this block of code and the block below is the auto-populating happening if you're filling out the IsPhantom first or the mriFile first, i think

}
}

Expand All @@ -81,10 +93,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 PSCID_CandID_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