• Team Cirrus
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am a newbie to salesforce and I am doing a project on hospital management system in it. I have Objects for Hospitals, Wards & Patients. Patient is in a lookup relationship with Ward and Hospital. In Ward I have a picklist called ward type(values: General, ICU, HCU, ICCU, Cabin). In Patient Object I also have a similar picklist called ward type but here I want to display only those wards which are available in the hospital where the patient is getting admitted(for e.g, ICCU and HCU are not present in every hospital so it is meaningless to show those options in ward type of such hospitals while filling a new patient detail).

Other than salesforce I could query the database of Ward object filtered by hospital name entered and put the options in the drop-down list but I do not know how to put options in picklist in real-time fetching the records of wards, filtered by hospital name entered by the user in salesforce.

Plz help if you know anything in this regard :)
public class chkDoctorRegn {
    public static void chkRegn(Map<Id, Doctor__c> oldV, List <Doctor__c> newV){
        Map<String, Id> docMap=new Map<String, Id>();
        List<Doctor__c> docList=[select Registration_no__c, Registration_State__c from Doctor__c];
        for(Doctor__c d : docList){
            docMap.put(d.Registration_no__c, d.Registration_State__c);
        }
        for(Doctor__c d1 : newV){
                if(d1.Registration_State__c!=oldV.get(d1.Id).Registration_State__c){
                    List<String> l=new List<String>();
                    l=[Select Registration_no__c from Doctor__c Where Registration_State__c=:d1.Registration_State__c];
                    if(l.contains(String.valueOf(d1.Registration_no__c))==true){
                        d1.addError('Incorrect Value: Updated State already has doctor with same registration no.');
                    }
                }
            }
        }
    }
    
    public static void chkInsRegn(List <Doctor__c> newV){
        Map<String, Id> docMap=new Map<String, Id>();
        List<Doctor__c> docList=[select Registration_no__c, Registration_State__c from Doctor__c];
        for(Doctor__c d : docList){
            docMap.put(d.Registration_no__c, d.Registration_State__c);
        }
        for(Doctor__c d1 : newV){
            if((docMap.get(d1.Registration_no__c)!=null) && (docMap.get(d1.Registration_no__c).equals(d1.Registration_State__c))){
                d1.addError('Incorrect Value: State already has doctor with same registration no.');
            }
        }
    }
}

The code gives error:
illegal assignment from list to list   -> line 11
missing '' at 'public'  -> line 20
Plz Help me out:)
public class chkDoctorRegn {
    public static void chkRegn(Map<Id, Doctor__c> oldV, List <Doctor__c> newV){
        Map<String, Id> docMap=new Map<String, Id>();
        List<Doctor__c> docList=[select Registration_no__c, Registration_State__c from Doctor__c];
        for(Doctor__c d : docList){
            docMap.put(d.Registration_no__c, d.Registration_State__c);
        }
        for(Doctor__c d1 : newV){
                if(d1.Registration_State__c!=oldV.get(d1.Id).Registration_State__c){
                    List<String> l=new List<String>();
                    l=[Select Registration_no__c from Doctor__c Where Registration_State__c=:d1.Registration_State__c];
                    if(l.contains(String.valueOf(d1.Registration_no__c))==true){
                        d1.addError('Incorrect Value: Updated State already has doctor with same registration no.');
                    }
                }
            }
        }
    }
    
    public static void chkInsRegn(List <Doctor__c> newV){
        Map<String, Id> docMap=new Map<String, Id>();
        List<Doctor__c> docList=[select Registration_no__c, Registration_State__c from Doctor__c];
        for(Doctor__c d : docList){
            docMap.put(d.Registration_no__c, d.Registration_State__c);
        }
        for(Doctor__c d1 : newV){
            if((docMap.get(d1.Registration_no__c)!=null) && (docMap.get(d1.Registration_no__c).equals(d1.Registration_State__c))){
                d1.addError('Incorrect Value: State already has doctor with same registration no.');
            }
        }
    }
}

The code gives error:
illegal assignment from list to list   -> line 11
missing '' at 'public'  -> line 20
Plz Help me out:)