thrownewMeteor.Error(403,"patient can't be found.")unlesspatient?
thrownewMeteor.Error(433,"you are not allowed to upsert answers")unlessRoles.userIsInRole(@userId,['admin'])or(Roles.userIsInRole(@userId,'caseManager')and@userIdinpatient.caseManagerIds)
# use query from Patient
studyDesign = StudyDesigns.findOne
_id: $in: patient.studyDesignIds
'visits._id':designVisitId
thrownewMeteor.Error(403,"studyDesign can't be found.")unlessstudyDesign?
thrownewMeteor.Error(403,"visit can't be found.")unlessvisit?
patient = Patients.findOnevisit.patientId
thrownewMeteor.Error(403,"patient can't be found.")unlesspatient?
thrownewMeteor.Error(433,"you are not allowed change this visit")unlessRoles.userIsInRole(@userId,['admin'])or(Roles.userIsInRole(@userId,'caseManager')and@userIdinpatient.caseManagerIds)
Meteor.call"logActivity","remove all answers of questionnaire (#{questionnaire.id} - #{questionnaire.title}) from visit (#{visit.title} - #{visit._id}) from patient (#{patient.hrid} - #{patient.id})","critical",reason,answers