You need to sign in to do that
Don't have an account?
Krishna Sahu 1
is somthing wrong in this code i getting null pointer exception while assigning member_c
public static void populatePhysicianOnCareTeam(List<Order> newList){
List<CareTeam__c> mapCaseTeam = new List<CareTeam__c>();
Set<Id> setOfPhysicianId = new Set<Id>();
Map<Id, User> mapOfUserId = new Map<Id, User>();
for(Order objOrder : newList){
setOfPhysicianId.add(objOrder.implanting_physician__c );
}
Map<String, String> mapOrderType_Role= new Map<String, String>{'NROP'=>'Trialing Physician', 'NROP'=>'Implanting Physician',
'NREP'=>'Replacement Physician', 'NREV'=>'Revision Physician'};
if(setOfPhysicianId.isEmpty()){
for(User user : [SELECT Id, Name, ContactId FROM User WHERE ContactId =: setOfPhysicianId]){
mapOfUserId.put(user.ContactId, user);
}
}
for(Order objOrder : newList){
if(objOrder.implanting_physician__c != null && mapOrderType_Role.containskey(objOrder.Type)){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = mapOrderType_Role.get(objOrder.Type),
Status__c = 'Active'));
}
/*else if(objOrder.implanting_physician__c != null && objOrder.Type == 'NROP'){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = 'Implanting Physician',
Status__c = 'Active'));
}
else if(objOrder.implanting_physician__c != null && objOrder.Type == 'NREP'){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = 'Replacement Physician',
Status__c = 'Active'));
}
else if(objOrder.implanting_physician__c != null && objOrder.Type == 'NREV'){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = 'Revision Physician',
Status__c = 'Active'));
}*/
}
if(!mapCaseTeam.isEmpty()){
insert mapCaseTeam;
}
}
List<CareTeam__c> mapCaseTeam = new List<CareTeam__c>();
Set<Id> setOfPhysicianId = new Set<Id>();
Map<Id, User> mapOfUserId = new Map<Id, User>();
for(Order objOrder : newList){
setOfPhysicianId.add(objOrder.implanting_physician__c );
}
Map<String, String> mapOrderType_Role= new Map<String, String>{'NROP'=>'Trialing Physician', 'NROP'=>'Implanting Physician',
'NREP'=>'Replacement Physician', 'NREV'=>'Revision Physician'};
if(setOfPhysicianId.isEmpty()){
for(User user : [SELECT Id, Name, ContactId FROM User WHERE ContactId =: setOfPhysicianId]){
mapOfUserId.put(user.ContactId, user);
}
}
for(Order objOrder : newList){
if(objOrder.implanting_physician__c != null && mapOrderType_Role.containskey(objOrder.Type)){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = mapOrderType_Role.get(objOrder.Type),
Status__c = 'Active'));
}
/*else if(objOrder.implanting_physician__c != null && objOrder.Type == 'NROP'){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = 'Implanting Physician',
Status__c = 'Active'));
}
else if(objOrder.implanting_physician__c != null && objOrder.Type == 'NREP'){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = 'Replacement Physician',
Status__c = 'Active'));
}
else if(objOrder.implanting_physician__c != null && objOrder.Type == 'NREV'){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = 'Revision Physician',
Status__c = 'Active'));
}*/
}
if(!mapCaseTeam.isEmpty()){
insert mapCaseTeam;
}
}
For the below If condition just add another condition as below.
Let me know if you still face the issue and also the line of error you are getting
If this solution helps, Please mark it as best answer.
Thanks,
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh