You need to sign in to do that
Don't have an account?
Krishna Sahu 1
Please help me to write test class on that
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>();
System.debug('Outside the Loop');
for(Order objOrder : newList){
setOfPhysicianId.add(objOrder.implanting_physician__c );
}
for(User user : [SELECT Id, Name, ContactId FROM User WHERE ContactId =: setOfPhysicianId]){
mapOfUserId.put(user.ContactId, user);
}
for(Order objOrder : newList){
// for trail
if(objOrder.implanting_physician__c != null && objOrder.Type == 'NROT'){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = 'Trialing Physician',
Status__c = 'Active'));
}
// for permanent
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'));
}
// for replacement physician
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>();
System.debug('Outside the Loop');
for(Order objOrder : newList){
setOfPhysicianId.add(objOrder.implanting_physician__c );
}
for(User user : [SELECT Id, Name, ContactId FROM User WHERE ContactId =: setOfPhysicianId]){
mapOfUserId.put(user.ContactId, user);
}
for(Order objOrder : newList){
// for trail
if(objOrder.implanting_physician__c != null && objOrder.Type == 'NROT'){
mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c,
Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
Roles__c = 'Trialing Physician',
Status__c = 'Active'));
}
// for permanent
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'));
}
// for replacement physician
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;
}
}
Can you try the below test class which gives you 100% coverage.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
Can you try the below test class which gives you 100% coverage.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
It is working
Thank you