function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mohan s 37mohan s 37 

System.QueryException: line 6:730 no viable alternative at character 'a'

Hi Friends,
I am getting following bug while testing my controller "System.QueryException: line 6:730 no viable alternative at character 'a' ". Can any one help how to resolve it. Can any one tell me is the following query is correct or not if it is wrong modify the query and give me reply as correct query your help is really appreciable. I hope i receive reply.
In the following query i am passing SiteIds, procedures and patientage as a string of values dynamically but they are not passed to the query.
I ahve written the query like this
 conditionQuery =     ' AND Patient__r.IsActive__c = true ' +
                             ' AND Patient__r.Site_Id__c IN : siteIds ' +
                             ' AND Patient__c IN : patEnrollTeamIds' +
                             ' AND Patient__r.Patient__r.Gender__c IN : gender ' +
                             ' AND Patient__r.Patient__r.Age_Group__c IN : patientAge ' +
                             ' AND Patient__r.Surgery_Type__c IN : procedures ' +
                             ' AND Patient__r.ASA_Score__c IN : asascore ';

This is debug log:
Final Query :Select Text_Field__c, Patient_Survey__r.Patient__r.Id, Patient_Survey__r.Patient__r.Patient__r.First_Name__c, ER_DOS_Delta__c, Patient_Survey__r.Patient__r.Patient__r.Last_Name__c,LOS__c, Patient_Survey__r.Patient__r.Surgery_Date__c,Number__c, Patient_Survey__r.Patient__r.Surgery_Type__c,Patient_Survey__r.Patient__r.ASA_Score__c, Patient_Survey__r.Patient__r.Patient_Enrollment_Status__c, Patient_Survey__r.Patient__r.Percent_Survey_Completed__c,Patient_Survey__r.Patient__r.Missed_Surveys__c,Patient_Survey__r.Patient__r.Other_Pain_Management_used_if_any__c From Patient_Responses__c WHERE Number__c != null AND IsDemo__c =false AND Question_Pattern__c = 'Group' AND Group_Name__c = 'Pain' AND Patient_Survey__r.Survey_Status__c IN ('Completed', 'In-Progress' , 'Expired') AND Category__c LIKE '%Rest%' AND Patient_Survey__r.Name= 'Post Surgery, day 3' AND Patient_Survey__r.Patient__r.Patient__r.Account__c in :siteIds AND Patient_Survey__r.Patient__c IN : patEnrollTeamIds AND Patient_Survey__r.Patient__r.Surgery_Type__c in :procedures AND Patient_Survey__r.Patient__r.Patient__r.Age_Group__c in :patientAge AND Patient_Survey__r.Patient__r.Patient__r.Gender__c in :gender AND Patient_Survey__r.Patient__r.ASA_Score__c IN : asascore AND DAY_ONLY(Createddate) <=2017-08-10 00:00:00and DAY_ONLY(Createddate) >=2017-01-10 00:00:00 ORDER BY Patient_Survey__r.Name LIMIT 1000
 global class SelectedFilters{
        public Set<String> SiteIds{get;set;}
        public Set<String> surgeonIds{get;set;}
        public Set<string> anesthesiologistIds{get;set;}
        public List<String> procedures{get;set;}
        public List<string> ONQUsed{get;set;}
        public List<string> patientAge{get;set;}
        public List<string> gender{get;set;}
        public string onload {get;set;}
        public List<string> PainManagementUsed{get;set;}
        public List<String> HospitalName {get;set;}
        public List<String> ASAScore {get;set;}
        
        public SelectedFilters(Set<String> siteIds, /*Boolean is_ReadOnlySite,*/
                             Set<String> surgeonIds,Set<String> anesthesiologistIds,
                             List<String> procedures,List<string> ONQUsed,
                             List<string> patientAge,List<string> gender,
                             List<string> PainManagementUsed , List<String> HospitalName,List<String> ASAScore) {
            this.siteIds = siteIds;
            this.surgeonIds = surgeonIds;
            this.anesthesiologistIds = anesthesiologistIds;
            this.procedures = procedures;
            this.ONQUsed= ONQUsed;
            this.patientAge= patientAge;
            this.gender= gender;
            this.PainManagementUsed= PainManagementUsed;
            this.HospitalName = HospitalName;
            this.ASAScore = ASAScore;
        }
==
 JSONstring ='{"siteIds":["'+String.valueof(testAccount.id)+
            '"],"surgeonIds":["' +String.valueof(testContact.id)+
            '"],"anesthesiologistIds":["'+String.valueof(testContact.id) +
            '"],"procedures":["Lap BSO"],"ONQUsed":["Yes"],"patientAge":["0-18","18 – 29"],"gender":["Male","Female"],"PainManagementUsed":["ON-Q","Single Injection nerve block","Wound infusion","Local infiltration"],"HospitalName":["ABC","DEF"],"ASAScore":["I"]}';
      
 if(String.isNotBlank(jsonString))
        {
            EngagementGraphsController.SelectedFilters test  = (EngagementGraphsController.SelectedFilters)JSON.deserialize(jsonString,EngagementGraphsController.SelectedFilters.class);
            system.debug('-----------test :'+test);  
            
            EngagementGraphsController.SelectedFilters currentFilter = EngagementGraphsController.generateFilterWrapper(jsonString);
            Set<String> siteIds = currentFilter.SiteIds;
            Set<String> surgeonIds = currentFilter.surgeonIds;
            Set<String> anesthesiologistIds = currentFilter.anesthesiologistIds;
            List<String> procedures = currentFilter.procedures;
            List<string> painMgmntUsed = currentFilter.PainManagementUsed;
            List<string> patientAge = currentFilter.patientAge;
            List<string> gender = currentFilter.gender;
            List<string> hospital = currentFilter.HospitalName;
            List<string> asascore = currentFilter.ASAScore;
     
Abhishek_DEOAbhishek_DEO
not sure but your debug log shows below filters

AND DAY_ONLY(Createddate) <=2017-08-10 00:00:00and DAY_ONLY(Createddate) >=2017-01-10 00:00:00 ORDER BY Patient_Survey__r.Name LIMIT 1000 // see there is no space in datetime value and "AND"

you may give space and try again