in clns-eTarget/src/main/webapp/js/app.js [1159:1339]
$scope.saveMeetingOutcome = function() {
////console.log($scope.meeting.add);
if($scope.meeting.flag) {
return false;
}
// Validate input
if($scope.meeting.add.outcome == '') {
alert('You must complete the meeting outcome dropdown.');
return false;
}
if($scope.meeting.add.date == '') {
alert('You must select a date.');
return false;
}
$scope.meeting.flag=true;
/*
if(!confirm("If you have selected any significant mutations please ensure that they are correct as they cannot be edited in the meeting outcome once it has been saved. Do you want to continue?")) {
event.preventDefault();
return false;
}
*/
// If multiple meeting outcomes selected, convert to a string (with newlines)
if(Array.isArray($scope.meeting.add.outcome)) {
var meetingOutcomeArray = $scope.meeting.add.outcome;
$scope.meeting.add.outcome = meetingOutcomeArray.join("\n");
}
var genericGenomic={};
Object.keys($scope.currentPatient.significantMutations.latestGenericGenomic).map(function(key, index) {
genericGenomic[key] = {copyNumberAlteration:[], shortVariant:[], rearrangement:[]}
genericGenomic[key].copyNumberAlteration= $scope.currentPatient.significantMutations.latestGenericGenomic[key].copyNumberAlteration.map(function(a) {
return a.gene_variant_id;
});
genericGenomic[key].shortVariant= $scope.currentPatient.significantMutations.latestGenericGenomic[key].shortVariant.map(function(a) {
return a.gene_variant_id;
});
genericGenomic[key].rearrangement= $scope.currentPatient.significantMutations.latestGenericGenomic[key].rearrangement.map(function(a) {
return a.gene_variant_id;
});
});
// Send to API
$http({
method: 'POST',
url: 'api/data.jsp?endpoint=postmeetingoutcome',
data: $.param({
personID: $scope.currentPatient.person_id,
meetingDate: $scope.meeting.add.date,
outcome: $scope.meeting.add.outcome,
notes: $scope.meeting.add.notes,
ctDNA: angular.toJson($scope.currentPatient.significantMutations.latestCtDNA.map(function(a) {
return a.geneVarientID;
})),
tumourNGS: angular.toJson($scope.currentPatient.significantMutations.latestTumourNGS.map(function(a) {
return a.geneVarientID;
})),
fmTumour: angular.toJson({
copyNumberAlteration: $scope.currentPatient.significantMutations.latestFmTumour.copyNumberAlteration.map(function(a) {
return a.gene_variant_id;
}),
shortVariant: $scope.currentPatient.significantMutations.latestFmTumour.shortVariant.map(function(a) {
return a.gene_variant_id;
}),
rearrangement: $scope.currentPatient.significantMutations.latestFmTumour.rearrangement.map(function(a) {
return a.gene_variant_id;
})
}),
fmBlood: angular.toJson({
copyNumberAlteration: $scope.currentPatient.significantMutations.latestFmBlood.copyNumberAlteration.map(function(a) {
return a.gene_variant_id;
}),
shortVariant: $scope.currentPatient.significantMutations.latestFmBlood.shortVariant.map(function(a) {
return a.gene_variant_id;
}),
rearrangement: $scope.currentPatient.significantMutations.latestFmBlood.rearrangement.map(function(a) {
return a.gene_variant_id;
})
}),
genericGenomic: angular.toJson(genericGenomic)
}),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function successCallback(response) {
//console.log('Meeting outcome updated.');
// Show success message
$scope.meeting.message = 'Meeting outcome updated.';
$timeout( function() {
$scope.meeting.message = '';
}, 10000);
// Add new row data
var bloodSpecimenDate;
var tumourSpecimenDate;
if(typeof $scope.currentPatient.significantMutations.latestCtDNA[0] != 'undefined'){
bloodSpecimenDate=$scope.currentPatient.significantMutations.latestCtDNA[0].specimenDate;
} else if(typeof $scope.currentPatient.treatments.bloodSamples[0] != 'undefined'){
bloodSpecimenDate=$scope.currentPatient.treatments.bloodSamples[$scope.currentPatient.treatments.bloodSamples.length-1].dateBlood;
} else {
bloodSpecimenDate='no blood sample';
}
if(typeof $scope.currentPatient.significantMutations.latestTumourNGS[0] != 'undefined'){
tumourSpecimenDate=$scope.currentPatient.significantMutations.latestTumourNGS[0].specimenDate;
} else if(typeof $scope.currentPatient.treatments.tumourSamples[0] != 'undefined'){
tumourSpecimenDate=$scope.currentPatient.treatments.tumourSamples[$scope.currentPatient.treatments.tumourSamples.length-1].dateTumour;
} else {
tumourSpecimenDate='no tumour sample';
}
var copy = angular.copy($scope.currentPatient.significantMutations.latestGenericGenomic);
angular.forEach(copy, function(v, k) {
if (v.hasOwnProperty('shortVariant')) {
v[k+"SV"] = v['shortVariant'];
delete v['shortVariant'];
}
if (v.hasOwnProperty('rearrangement')) {
v[k+'R'] = v['rearrangement'];
delete v['rearrangement'];
}
if (v.hasOwnProperty('copyNumberAlteration')) {
v[k+'CNA'] = v['copyNumberAlteration'];
delete v['copyNumberAlteration'];
}
console.log(v)
});
$scope.meeting.outcome.unshift({
meeting_id: response.data.mo_id,
meetingDate: $scope.meeting.add.date,
outcome: $scope.meeting.add.outcome,
notes: $scope.meeting.add.notes,
//geneTables: $scope.currentPatient.significantMutations,
summary: $scope.currentPatient.significantMutations.summery.slice(0),
ctDNA: $scope.currentPatient.significantMutations.latestCtDNA.slice(0),
tumourNGS: $scope.currentPatient.significantMutations.latestTumourNGS.slice(0),
fmBlood: {
FMBloodSV: $scope.currentPatient.significantMutations.latestFmBlood.shortVariant.slice(0),
FMBloodR: $scope.currentPatient.significantMutations.latestFmBlood.rearrangement.slice(0),
FMBloodCNA: $scope.currentPatient.significantMutations.latestFmBlood.copyNumberAlteration.slice(0)
},
fmTumour: {
FMTumourSV: $scope.currentPatient.significantMutations.latestFmTumour.shortVariant.slice(0),
FMTumourR: $scope.currentPatient.significantMutations.latestFmTumour.rearrangement.slice(0),
FMTumourCNA: $scope.currentPatient.significantMutations.latestFmTumour.copyNumberAlteration.slice(0)
},
genericGenomic: Object.assign({}, copy),
lastUpdated: '',
lastPrinted: '',
ctDNASampleDate: bloodSpecimenDate,
tumourSampleDate: tumourSpecimenDate,
updatedBy: $scope.currentUser.userID
});
$scope.meeting.add.outcome = '';
$scope.meeting.add.notes = '';
picker.setDate(moment().toDate());
$scope.meeting.new = false;
// Clear the significantMutations
//$scope.currentPatient.significantMutations.meetingOutcomeSummary = {};
}, function errorCallback(response) {
//console.log('Error fetching meeting outcome: '+response.status);
$scope.meeting.message = '';
$scope.showPage('detail', $scope.currentPatient.person_id);
if(typeof response.data.error!= "undefined"){
$scope.currentPatient.editLockMessage = response.data.error;
} else {
// Show error message
alert('Error: Unable to update the meeting outcome.');
}
}).finally(function (){
$scope.meeting.flag=false;
});
};