-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
21Questions
-
17Replies
I don't know what is wrong in this can some help me on this I am getting this error 'INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY'
public static void careTeamInsertO(map<Id,CareTeam__c> newCareTeamList){
system.debug('********************careTeamInsert********************');
Map<Id, List<CareTeam__c>> mapMemberIdtoCareTeam =new Map<Id, List<CareTeam__c>>();
Map<Id,Id> mapTerritoryToUser = new Map<Id, Id>();
Set<Id> mapOfPatient = new Set<Id>();
Map<Id, Account> mapAccountOfPatient = new Map<Id, Account>();
List<AccountShare> aShareList = new list<AccountShare>();
for(CareTeam__c careRec :newCareTeamList.values()){
system.debug('mapMemberIdtoCareTeam==='+ mapMemberIdtoCareTeam.containskey(careRec.Member__c));
if(careRec.Member__c != null){
if(mapMemberIdtoCareTeam.containskey(careRec.Member__c))
{
mapMemberIdtoCareTeam.get(careRec.Member__c).add(careRec);
mapOfPatient.add(careRec.Patient__c);
}
else
{
mapMemberIdtoCareTeam.put(careRec.Member__c, new List<CareTeam__c>{careRec});
system.debug('mapMemberIdtoCareTeamputttttt==='+ mapMemberIdtoCareTeam.containskey(careRec.Member__c));
mapOfPatient.add(careRec.Patient__c);
}
}
}
system.debug(' mapMemberIdtoCareTeam.keyset()===' + mapMemberIdtoCareTeam.keyset());
for(UserTerritory2Association us:[SELECT Id, RoleInTerritory2, Territory2Id, User.name FROM UserTerritory2Association
WHERE UserId IN : mapMemberIdtoCareTeam.keyset() ]){
mapTerritoryToUser.put(us.Territory2Id, us.UserId);
}
System.debug('mapTerritoryToUser===='+ mapTerritoryToUser);
for(UserTerritory2Association us:[SELECT Id, RoleInTerritory2, UserId,
User.name, user.profile.name, Territory2Id
FROM UserTerritory2Association
WHERE Territory2Id IN : mapTerritoryToUser.keyset()
AND (user.profile.name = 'Sales Representative' OR user.profile.name = 'Remote Care Team')
]){
System.debug('mapMemberIdtoCareTeam.get(mapTerritoryToUser.get(us.Territory2Id))===='+ mapMemberIdtoCareTeam.get(mapTerritoryToUser.get(us.Territory2Id)));
for(CareTeam__c care : mapMemberIdtoCareTeam.get(mapTerritoryToUser.get(us.Territory2Id)))
{
system.debug('us.UserId '+ us.UserId);
system.debug('care.Patient__c. '+ care.Patient__c);
AccountShare aShare = New AccountShare();
aShare.UserOrGroupID = us.UserId;
aShare.AccountID = care.Patient__c;
aShare.AccountaccessLevel = 'Read';
aShare.OpportunityAccessLevel = 'Read';
aShare.RowCause = MANUAL;
aShareList.add(aShare);
}
}
system.debug('aShareList=='+ aShareList.size());
insert aShareList;
}
system.debug('********************careTeamInsert********************');
Map<Id, List<CareTeam__c>> mapMemberIdtoCareTeam =new Map<Id, List<CareTeam__c>>();
Map<Id,Id> mapTerritoryToUser = new Map<Id, Id>();
Set<Id> mapOfPatient = new Set<Id>();
Map<Id, Account> mapAccountOfPatient = new Map<Id, Account>();
List<AccountShare> aShareList = new list<AccountShare>();
for(CareTeam__c careRec :newCareTeamList.values()){
system.debug('mapMemberIdtoCareTeam==='+ mapMemberIdtoCareTeam.containskey(careRec.Member__c));
if(careRec.Member__c != null){
if(mapMemberIdtoCareTeam.containskey(careRec.Member__c))
{
mapMemberIdtoCareTeam.get(careRec.Member__c).add(careRec);
mapOfPatient.add(careRec.Patient__c);
}
else
{
mapMemberIdtoCareTeam.put(careRec.Member__c, new List<CareTeam__c>{careRec});
system.debug('mapMemberIdtoCareTeamputttttt==='+ mapMemberIdtoCareTeam.containskey(careRec.Member__c));
mapOfPatient.add(careRec.Patient__c);
}
}
}
system.debug(' mapMemberIdtoCareTeam.keyset()===' + mapMemberIdtoCareTeam.keyset());
for(UserTerritory2Association us:[SELECT Id, RoleInTerritory2, Territory2Id, User.name FROM UserTerritory2Association
WHERE UserId IN : mapMemberIdtoCareTeam.keyset() ]){
mapTerritoryToUser.put(us.Territory2Id, us.UserId);
}
System.debug('mapTerritoryToUser===='+ mapTerritoryToUser);
for(UserTerritory2Association us:[SELECT Id, RoleInTerritory2, UserId,
User.name, user.profile.name, Territory2Id
FROM UserTerritory2Association
WHERE Territory2Id IN : mapTerritoryToUser.keyset()
AND (user.profile.name = 'Sales Representative' OR user.profile.name = 'Remote Care Team')
]){
System.debug('mapMemberIdtoCareTeam.get(mapTerritoryToUser.get(us.Territory2Id))===='+ mapMemberIdtoCareTeam.get(mapTerritoryToUser.get(us.Territory2Id)));
for(CareTeam__c care : mapMemberIdtoCareTeam.get(mapTerritoryToUser.get(us.Territory2Id)))
{
system.debug('us.UserId '+ us.UserId);
system.debug('care.Patient__c. '+ care.Patient__c);
AccountShare aShare = New AccountShare();
aShare.UserOrGroupID = us.UserId;
aShare.AccountID = care.Patient__c;
aShare.AccountaccessLevel = 'Read';
aShare.OpportunityAccessLevel = 'Read';
aShare.RowCause = MANUAL;
aShareList.add(aShare);
}
}
system.debug('aShareList=='+ aShareList.size());
insert aShareList;
}
-
- Krishna Sahu 1
- August 05, 2022
- Like
- 0
Portal user must have an role i am getting this error while exceuting mt test class please help me on this
@isTest
private static void VerifyPopulatePhysicianOnCareTeam(){
User adminUser = [Select Id, UserRoleId From User Where Profile.Name='System Administrator' AND isActive = true Limit 1];
System.runAs(adminUser){
Test.startTest();
Account businessAccount = TestUtility.createAccounts(1, 'Test', false)[0];
businessAccount.Type = 'Customer';
insert businessAccount;
List<Account> listPersonAccount = TestUtility.createPatientAccounts(1, 'Patient Account', true);
Id RecordTypeIdValue =SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Provider').getRecordTypeId();
Contact physicianContact = new Contact(LastName = 'physician Contact', AccountId = businessAccount.Id , RecordTypeId = RecordTypeIdValue);
insert physicianContact;
User user = new User();
user.ProfileID = [Select Id From Profile Where Profile.Name='Ext. Physician'].Id;
user.EmailEncodingKey = 'ISO-8859-1';
user.LanguageLocaleKey = 'en_US';
user.TimeZoneSidKey = 'America/New_York';
user.LocaleSidKey = 'en_US';
user.FirstName = 'first';
user.LastName = 'last';
user.Username = 'test@edomain.com';
user.CommunityNickname = 'testUser123';
user.Alias = 't1';
user.Email = 'no@email.com';
user.UserRoleId = 'US - Finance';
user.IsActive = true;
user.ContactId = physicianContact.Id;
insert user;
Order orderObj = new Order();
orderObj.EffectiveDate = system.today();
orderObj.EndDate = system.today() + 4;
orderObj.AccountId = businessAccount.Id;
orderObj.patient_account__c=listPersonAccount[0].Id;
orderObj.Implanting_physician__c=user.ContactId;
orderObj.Type='NROT';
insert orderObj;
Test.stopTest();
List<CareTeam__c> objCareTeam = [SELECT Id, Name, Member__r.ContactId, Patient__c
FROM CareTeam__c
WHERE Patient__c =: orderObj.patient_account__c LIMIT 1];
System.assertEquals(objCareTeam[0].Member__r.ContactId, orderObj.implanting_physician__c);
}
}
private static void VerifyPopulatePhysicianOnCareTeam(){
User adminUser = [Select Id, UserRoleId From User Where Profile.Name='System Administrator' AND isActive = true Limit 1];
System.runAs(adminUser){
Test.startTest();
Account businessAccount = TestUtility.createAccounts(1, 'Test', false)[0];
businessAccount.Type = 'Customer';
insert businessAccount;
List<Account> listPersonAccount = TestUtility.createPatientAccounts(1, 'Patient Account', true);
Id RecordTypeIdValue =SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Provider').getRecordTypeId();
Contact physicianContact = new Contact(LastName = 'physician Contact', AccountId = businessAccount.Id , RecordTypeId = RecordTypeIdValue);
insert physicianContact;
User user = new User();
user.ProfileID = [Select Id From Profile Where Profile.Name='Ext. Physician'].Id;
user.EmailEncodingKey = 'ISO-8859-1';
user.LanguageLocaleKey = 'en_US';
user.TimeZoneSidKey = 'America/New_York';
user.LocaleSidKey = 'en_US';
user.FirstName = 'first';
user.LastName = 'last';
user.Username = 'test@edomain.com';
user.CommunityNickname = 'testUser123';
user.Alias = 't1';
user.Email = 'no@email.com';
user.UserRoleId = 'US - Finance';
user.IsActive = true;
user.ContactId = physicianContact.Id;
insert user;
Order orderObj = new Order();
orderObj.EffectiveDate = system.today();
orderObj.EndDate = system.today() + 4;
orderObj.AccountId = businessAccount.Id;
orderObj.patient_account__c=listPersonAccount[0].Id;
orderObj.Implanting_physician__c=user.ContactId;
orderObj.Type='NROT';
insert orderObj;
Test.stopTest();
List<CareTeam__c> objCareTeam = [SELECT Id, Name, Member__r.ContactId, Patient__c
FROM CareTeam__c
WHERE Patient__c =: orderObj.patient_account__c LIMIT 1];
System.assertEquals(objCareTeam[0].Member__r.ContactId, orderObj.implanting_physician__c);
}
}
-
- Krishna Sahu 1
- August 04, 2022
- Like
- 0
Please Help to write the test class on Before Insert
public static void addRepForCredit(List<order> newOrderList){
Set<Id> patientIdSet = new Set<Id>();
for(order orderRec: newOrderList){
if(orderRec.Type == Constants.PERMANENT_IMPLANT )
patientIdSet.add(orderRec.patient_account__c);
}
List<order> trialOrderList = new List<order>();
Map<Id, order> trialOrderMap = new Map<Id, order>();
if(!patientIdSet.isEmpty()){
trialOrderList = [
SELECT Id, patient_account__c, Type, rep_for_credit__c, Status, EffectiveDate
FROM order
WHERE patient_account__c IN :patientIdSet
AND Type =:Constants.TRIAL_IMPLANT
AND Status !=:Constants.PICKLIST_VALUE_STATUS_CANCELLED
];
if(!trialOrderList.isEmpty()){
for(order orderRec: trialOrderList){
if(!trialOrderMap.containsKey(orderRec.patient_account__c)){
trialOrderMap.put(orderRec.patient_account__c, orderRec);
}
else if(
orderRec.EffectiveDate
>
trialOrderMap.get(orderRec.patient_account__c).EffectiveDate
){
trialOrderMap.put(orderRec.patient_account__c, orderRec);
}
}
for(order orderRec: newOrderList){
if(trialOrderMap.containsKey(orderRec.patient_account__c) && orderRec.rep_for_credit__c==null){
orderRec.rep_for_credit__c =
trialOrderMap.get(orderRec.patient_account__c).rep_for_credit__c;
}
else if(
trialOrderMap.containsKey(orderRec.patient_account__c)
&&
orderRec.rep_for_credit__c != trialOrderMap.get(orderRec.patient_account__c).rep_for_credit__c
){
orderRec.addError(Constants.ORDER_RFC_TRIAL_PERMANENT_ERROR_MESSAGE);
}
}
}
}
}
Set<Id> patientIdSet = new Set<Id>();
for(order orderRec: newOrderList){
if(orderRec.Type == Constants.PERMANENT_IMPLANT )
patientIdSet.add(orderRec.patient_account__c);
}
List<order> trialOrderList = new List<order>();
Map<Id, order> trialOrderMap = new Map<Id, order>();
if(!patientIdSet.isEmpty()){
trialOrderList = [
SELECT Id, patient_account__c, Type, rep_for_credit__c, Status, EffectiveDate
FROM order
WHERE patient_account__c IN :patientIdSet
AND Type =:Constants.TRIAL_IMPLANT
AND Status !=:Constants.PICKLIST_VALUE_STATUS_CANCELLED
];
if(!trialOrderList.isEmpty()){
for(order orderRec: trialOrderList){
if(!trialOrderMap.containsKey(orderRec.patient_account__c)){
trialOrderMap.put(orderRec.patient_account__c, orderRec);
}
else if(
orderRec.EffectiveDate
>
trialOrderMap.get(orderRec.patient_account__c).EffectiveDate
){
trialOrderMap.put(orderRec.patient_account__c, orderRec);
}
}
for(order orderRec: newOrderList){
if(trialOrderMap.containsKey(orderRec.patient_account__c) && orderRec.rep_for_credit__c==null){
orderRec.rep_for_credit__c =
trialOrderMap.get(orderRec.patient_account__c).rep_for_credit__c;
}
else if(
trialOrderMap.containsKey(orderRec.patient_account__c)
&&
orderRec.rep_for_credit__c != trialOrderMap.get(orderRec.patient_account__c).rep_for_credit__c
){
orderRec.addError(Constants.ORDER_RFC_TRIAL_PERMANENT_ERROR_MESSAGE);
}
}
}
}
}
-
- Krishna Sahu 1
- August 01, 2022
- Like
- 0
Is it somting wron this
<template if:true = {trialFollowUpCareCoordinator}>
<c-lwc-lookup-component
object-api-name="User"
icon-name="standard:user"
lookup-label = "User"
onerror={showError}
filter="Profile.Name= 'Sales Representative' OR Profile.Name= 'Remote Care Team'"
onrecordselection = {updateSelectedUser}
>
</c-lwc-lookup-component>
</template>
<c-lwc-lookup-component
object-api-name="User"
icon-name="standard:user"
lookup-label = "User"
onerror={showError}
filter="Profile.Name= 'Sales Representative' OR Profile.Name= 'Remote Care Team'"
onrecordselection = {updateSelectedUser}
>
</c-lwc-lookup-component>
</template>
-
- Krishna Sahu 1
- July 26, 2022
- Like
- 0
Would it we possible that someone can help me to write test class on that
public class BodyMapController {
private static Map<String, String> getBodyParts()
{
Map<String, String> mapPicklistKeyToValue = new Map<String, String>();
for(EventWrapper.PicklistWrapper objPicklist : PatientJourneyUtil.pickListValueDynamically(new Patient_Log__c(), 'primary_area_front__c'))
{
mapPicklistKeyToValue.put(objPicklist.value.replaceAll(' ', ''), objPicklist.value);
}
for(EventWrapper.PicklistWrapper objPicklist : PatientJourneyUtil.pickListValueDynamically(new Patient_Log__c(), 'primary_area_back__c'))
{
mapPicklistKeyToValue.put(objPicklist.value.replaceAll(' ', ''), objPicklist.value);
}
return mapPicklistKeyToValue;
}
@AuraEnabled
public static String savePatientLogs( String patientId,
String listPrimaryFrontBodyParts,
String listPrimaryBackBodyParts,
String listSecondaryFrontBodyParts,
String listSecondaryBackBodyParts,
String listTertiaryFrontBodyParts,
String listTertiaryBackBodyParts,
String intensity,
String frequency,
String sensation)
{
Map<String, String> mapPicklistKeyToValue = BodyMapController.getBodyParts();
List<String> lstPrimaryFrontBodyParts = new List<String>();
System.debug('listPrimaryFrontBodyParts'+listPrimaryFrontBodyParts);
for(String bodyPart : (List<String>)JSON.deserialize(listPrimaryFrontBodyParts, List<String>.class))
{
lstPrimaryFrontBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstPrimaryBackBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listPrimaryBackBodyParts, List<String>.class))
{
lstPrimaryBackBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstSecondaryFrontBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listSecondaryFrontBodyParts, List<String>.class))
{
lstSecondaryFrontBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstSecondaryBackBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listSecondaryBackBodyParts, List<String>.class))
{
lstSecondaryBackBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstTertiaryFrontBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listTertiaryFrontBodyParts, List<String>.class))
{
lstTertiaryFrontBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstTertiaryBackBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listTertiaryBackBodyParts, List<String>.class))
{
lstTertiaryBackBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
//Name, sensation__c,frequency__c, pain_Intensity__c,
Patient_Log__c objPatientLog = new Patient_Log__c(patient__c = patientId,
Log_Type__c = 'Healthcloud',
primary_area_front__c = String.join(lstPrimaryFrontBodyParts, ';'),
secondary_area_front__c = String.join(lstSecondaryFrontBodyParts, ';'),
tertiary_area_front__c = String.join(lstTertiaryFrontBodyParts, ';'),
primary_area_back__c = String.join(lstPrimaryBackBodyParts, ';'),
secondary_area_back__c = String.join(lstSecondaryBackBodyParts, ';'),
tertiary_area_back__c = String.join(lstTertiaryBackBodyParts, ';'));
insert objPatientLog;
return objPatientLog.Id;
}
@AuraEnabled (cacheable=true)
public static List<PatientLogSelectionWrapper> getPatientLog(String patientId) {
system.debug('patientId=>'+patientId);
List<PatientLogSelectionWrapper> lstPatientLogSelectionWrappers = new List<PatientLogSelectionWrapper>();
Integer counter = 0;
for(Patient_Log__c objPatientLog : [SELECT Name, pain_details__c, Id,
pain_Intensity__c,source__c,Log_Type__c,
CreatedBy.Name,CreatedDate
FROM Patient_Log__c
WHERE patient__c =: Id.valueOf(patientId)
ORDER BY CreatedDate asc])
{
PatientLogSelectionWrapper objPatientLogSelectionWrapper = new PatientLogSelectionWrapper(objPatientLog.Id,
objPatientLog.Name,
objPatientLog.pain_details__c,
objPatientLog.pain_Intensity__c,
objPatientLog.Log_Type__c,
objPatientLog.createdBy.Name,
objPatientLog.createdDate.date(),
objPatientLog.createdDate.time(),
objPatientLog.createdDate,
counter == 0);
lstPatientLogSelectionWrappers.add(objPatientLogSelectionWrapper);
counter++;
}
system.debug('patientLogList=>'+lstPatientLogSelectionWrappers);
return lstPatientLogSelectionWrappers;
}
@AuraEnabled (cacheable=true)
public static PatientLogWrapper getPatientLogDetails(String logId) {
system.debug('logId==>'+logId);
List<String> listFrontBodyPart = new List<String>();
List<String> listBackBodyPart = new List<String>();
List<Patient_Log__c> patientLogList = new List<Patient_Log__c>();
{
patientLogList= [SELECT Name, sensation__c,frequency__c, sleep__c, pain_details__c, pain_Intensity__c,source__c , Log_Type__c, mood__c, primary_area_front__c,
secondary_area_front__c,tertiary_area_front__c, primary_area_back__c, secondary_area_back__c, tertiary_area_back__c, CreatedDate
FROM Patient_Log__c
WHERE Id =: Id.valueOf(logId)
];
}
if(patientLogList[0].primary_area_front__c != null ){
listFrontBodyPart.addAll(patientLogList[0].primary_area_front__c.split(';'));
}
if(patientLogList[0].secondary_area_front__c != null ){
listFrontBodyPart.addAll(patientLogList[0].secondary_area_front__c.split(';'));
}
if(patientLogList[0].tertiary_area_front__c != null ){
listFrontBodyPart.addAll(patientLogList[0].tertiary_area_front__c.split(';'));
}
if(patientLogList[0].primary_area_back__c != null ){
listBackBodyPart.addAll(patientLogList[0].primary_area_back__c.split(';'));
}
if(patientLogList[0].secondary_area_back__c != null ){
listBackBodyPart.addAll(patientLogList[0].secondary_area_back__c.split(';'));
}
if(patientLogList[0].tertiary_area_back__c != null ){
listBackBodyPart.addAll(patientLogList[0].tertiary_area_back__c.split(';'));
}
PatientLogWrapper pw = new PatientLogWrapper(listFrontBodyPart, listBackBodyPart, patientLogList[0].pain_Intensity__c, patientLogList[0].frequency__c, patientLogList[0].sensation__c, patientLogList[0].CreatedDate);
system.debug('pwpwpw==>'+pw);
return pw;
}
@AuraEnabled (cacheable=true)
public static comparisonWrapper getComparisonLogDetails(String logId1, String logId2, Boolean isFrontSide){
system.debug('in getComparisonLogDetails logId1'+ logId1);
system.debug('in getComparisonLogDetails logId2'+ logId2);
List<PatientLogWrapper> listWrapper = new List<PatientLogWrapper>();
List<String> commonBodyPart = new List<String>();
List<String> listFrontBodyPart = new List<String>();
List<String> listBackBodyPart = new List<String>();
set<Id> setLogIds = new set<Id>();
setLogIds.add(Id.valueof(logId1));
setLogIds.add(Id.valueof(logId2));
//List<String> listFields = new List<String>{'primary_area_front__c','secondary_area_front__c','tertiary_area_front__c','primary_area_back__c', 'secondary_area_back__c', 'tertiary_area_back__c'};
List<String> listFields = new List<String>();
if(isFrontSide){
listFields.add('primary_area_front__c');
listFields.add('secondary_area_front__c');
listFields.add('tertiary_area_front__c');
}else{
listFields.add('primary_area_back__c');
listFields.add('secondary_area_back__c');
listFields.add('tertiary_area_back__c');
}
List<Patient_Log__c> listPatientLogs = [SELECT Name, sensation__c,frequency__c, sleep__c, pain_details__c, pain_Intensity__c,source__c , Log_Type__c, mood__c,
primary_area_front__c, secondary_area_front__c,tertiary_area_front__c, primary_area_back__c, secondary_area_back__c,
tertiary_area_back__c FROM Patient_Log__c WHERE Id IN : setLogIds order by createdDate ASC];
Patient_Log__c patientLog1 = listPatientLogs[0];
Patient_Log__c patientLog2 = listPatientLogs[1];
for(String field : listFields){
set<String> setBodyParts1 = new set<String>();
String bodyParts = String.valueof(patientLog1.get(field));
if(!string.isEmpty(bodyParts)){
setBodyParts1.addAll(bodyParts.split(';'));
}
set<String> setbodyParts2 = new set<String>();
String bodyParts2 = String.valueof(patientLog2.get(field));
if(!string.isEmpty(bodyParts2)){
setbodyParts2.addAll(bodyParts2.split(';'));
}
if(setBodyParts1.size() > setbodyParts2.size()){
for(String bpart : setBodyParts1){
if(setbodyParts2.contains(bpart)){
commonBodyPart.add(bpart);
}/*else if(bpart.startsWith('FRONT')){
listFrontBodyPart.add(bpart);
} else if(bpart.startsWith('BACK')){
listBackBodyPart.add(bpart);
}*/
}
}else{
for(String bpart : setbodyParts2){
if(setBodyParts1.contains(bpart)){
commonBodyPart.add(bpart);
}/*else if(bpart.startsWith('FRONT')){
listFrontBodyPart.add(bpart);
} else if(bpart.startsWith('BACK')){
listBackBodyPart.add(bpart);
}*/
}
}
}
listWrapper.add(getPatientLogDetails(logId1));
listWrapper.add(getPatientLogDetails(logId2));
system.debug('commonBodyPart'+commonBodyPart);
system.debug('listWrapper'+listWrapper);
ComparisonWrapper cw = new ComparisonWrapper(listWrapper, commonBodyPart);
system.debug('ComparisonWrapper'+cw);
return cw;
}
@AuraEnabled (cacheable=true)
public static Account getPatientDetails(String patientId){
List<Account> listPatients = new List<Account>();
listPatients = [SELECT id, Name, journey_stage__c FROM Account WHERE ID =: Id.valueof(patientId)];
return listPatients[0];
}
public class PatientLogSelectionWrapper
{
@AuraEnabled public String patientLogId {get;set;}
@AuraEnabled public String patientLogName {get;set;}
@AuraEnabled public String patientDetail {get;set;}
@AuraEnabled public String painIntensity {get;set;}
@AuraEnabled public String source {get;set;}
@AuraEnabled public String createdBy {get;set;}
@AuraEnabled public Date createdDate {get;set;}
@AuraEnabled public Time createdTime {get;set;}
@AuraEnabled public DateTime createdDatetime {get;set;}
@AuraEnabled public Boolean isBaseline {get;set;}
public PatientLogSelectionWrapper(String patientLogId,
String patientLogName,
String patientDetail,
String painIntensity,
String source,
String createdBy,
Date createdDate,
Time createdTime,
DateTime createdDatetime,
Boolean isBaseline)
{
this.patientLogId = patientLogId;
this.patientLogName = patientLogName;
this.patientDetail = patientDetail;
this.painIntensity = painIntensity;
this.source = source;
this.createdBy = createdBy;
this.createdDate = createdDate;
this.createdTime = createdTime;
this.createdDatetime = createdDatetime;
this.isBaseline = isBaseline;
}
}
public class PatientLogWrapper{
@AuraEnabled public List<String> listFrontBodyPart {get;set;}
@AuraEnabled public List<String> listBackBodyPart {get;set;}
@AuraEnabled public String painIntensity {get;set;}
@AuraEnabled public Decimal frequency {get;set;}
@AuraEnabled public String sensation {get;set;}
@AuraEnabled public Datetime createdDate {get;set;}
PatientLogWrapper(List<String> listFrontBodyPart,List<String> listBackBodyPart, string painIntensity, Decimal frequency, String sensation, Datetime createdDate){
//this.listBodyPart = new List<String>();
this.listFrontBodyPart = listFrontBodyPart;
this.listBackBodyPart = listBackBodyPart;
this.painIntensity =painIntensity;
this.frequency = frequency;
this.sensation = sensation;
this.createdDate = createdDate;
}
}
public class ComparisonWrapper{
@AuraEnabled public List<PatientLogWrapper> listWrappers {get;set;}
@AuraEnabled public List<String> commonBodyPart {get;set;}
ComparisonWrapper(List<PatientLogWrapper> listWrappers, List<String> commonBodyPart){
this.listWrappers = listWrappers;
this.commonBodyPart = commonBodyPart;
}
}
}
private static Map<String, String> getBodyParts()
{
Map<String, String> mapPicklistKeyToValue = new Map<String, String>();
for(EventWrapper.PicklistWrapper objPicklist : PatientJourneyUtil.pickListValueDynamically(new Patient_Log__c(), 'primary_area_front__c'))
{
mapPicklistKeyToValue.put(objPicklist.value.replaceAll(' ', ''), objPicklist.value);
}
for(EventWrapper.PicklistWrapper objPicklist : PatientJourneyUtil.pickListValueDynamically(new Patient_Log__c(), 'primary_area_back__c'))
{
mapPicklistKeyToValue.put(objPicklist.value.replaceAll(' ', ''), objPicklist.value);
}
return mapPicklistKeyToValue;
}
@AuraEnabled
public static String savePatientLogs( String patientId,
String listPrimaryFrontBodyParts,
String listPrimaryBackBodyParts,
String listSecondaryFrontBodyParts,
String listSecondaryBackBodyParts,
String listTertiaryFrontBodyParts,
String listTertiaryBackBodyParts,
String intensity,
String frequency,
String sensation)
{
Map<String, String> mapPicklistKeyToValue = BodyMapController.getBodyParts();
List<String> lstPrimaryFrontBodyParts = new List<String>();
System.debug('listPrimaryFrontBodyParts'+listPrimaryFrontBodyParts);
for(String bodyPart : (List<String>)JSON.deserialize(listPrimaryFrontBodyParts, List<String>.class))
{
lstPrimaryFrontBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstPrimaryBackBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listPrimaryBackBodyParts, List<String>.class))
{
lstPrimaryBackBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstSecondaryFrontBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listSecondaryFrontBodyParts, List<String>.class))
{
lstSecondaryFrontBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstSecondaryBackBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listSecondaryBackBodyParts, List<String>.class))
{
lstSecondaryBackBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstTertiaryFrontBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listTertiaryFrontBodyParts, List<String>.class))
{
lstTertiaryFrontBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
List<String> lstTertiaryBackBodyParts = new List<String>();
for(String bodyPart : (List<String>)JSON.deserialize(listTertiaryBackBodyParts, List<String>.class))
{
lstTertiaryBackBodyParts.add(mapPicklistKeyToValue.get(bodyPart));
}
//Name, sensation__c,frequency__c, pain_Intensity__c,
Patient_Log__c objPatientLog = new Patient_Log__c(patient__c = patientId,
Log_Type__c = 'Healthcloud',
primary_area_front__c = String.join(lstPrimaryFrontBodyParts, ';'),
secondary_area_front__c = String.join(lstSecondaryFrontBodyParts, ';'),
tertiary_area_front__c = String.join(lstTertiaryFrontBodyParts, ';'),
primary_area_back__c = String.join(lstPrimaryBackBodyParts, ';'),
secondary_area_back__c = String.join(lstSecondaryBackBodyParts, ';'),
tertiary_area_back__c = String.join(lstTertiaryBackBodyParts, ';'));
insert objPatientLog;
return objPatientLog.Id;
}
@AuraEnabled (cacheable=true)
public static List<PatientLogSelectionWrapper> getPatientLog(String patientId) {
system.debug('patientId=>'+patientId);
List<PatientLogSelectionWrapper> lstPatientLogSelectionWrappers = new List<PatientLogSelectionWrapper>();
Integer counter = 0;
for(Patient_Log__c objPatientLog : [SELECT Name, pain_details__c, Id,
pain_Intensity__c,source__c,Log_Type__c,
CreatedBy.Name,CreatedDate
FROM Patient_Log__c
WHERE patient__c =: Id.valueOf(patientId)
ORDER BY CreatedDate asc])
{
PatientLogSelectionWrapper objPatientLogSelectionWrapper = new PatientLogSelectionWrapper(objPatientLog.Id,
objPatientLog.Name,
objPatientLog.pain_details__c,
objPatientLog.pain_Intensity__c,
objPatientLog.Log_Type__c,
objPatientLog.createdBy.Name,
objPatientLog.createdDate.date(),
objPatientLog.createdDate.time(),
objPatientLog.createdDate,
counter == 0);
lstPatientLogSelectionWrappers.add(objPatientLogSelectionWrapper);
counter++;
}
system.debug('patientLogList=>'+lstPatientLogSelectionWrappers);
return lstPatientLogSelectionWrappers;
}
@AuraEnabled (cacheable=true)
public static PatientLogWrapper getPatientLogDetails(String logId) {
system.debug('logId==>'+logId);
List<String> listFrontBodyPart = new List<String>();
List<String> listBackBodyPart = new List<String>();
List<Patient_Log__c> patientLogList = new List<Patient_Log__c>();
{
patientLogList= [SELECT Name, sensation__c,frequency__c, sleep__c, pain_details__c, pain_Intensity__c,source__c , Log_Type__c, mood__c, primary_area_front__c,
secondary_area_front__c,tertiary_area_front__c, primary_area_back__c, secondary_area_back__c, tertiary_area_back__c, CreatedDate
FROM Patient_Log__c
WHERE Id =: Id.valueOf(logId)
];
}
if(patientLogList[0].primary_area_front__c != null ){
listFrontBodyPart.addAll(patientLogList[0].primary_area_front__c.split(';'));
}
if(patientLogList[0].secondary_area_front__c != null ){
listFrontBodyPart.addAll(patientLogList[0].secondary_area_front__c.split(';'));
}
if(patientLogList[0].tertiary_area_front__c != null ){
listFrontBodyPart.addAll(patientLogList[0].tertiary_area_front__c.split(';'));
}
if(patientLogList[0].primary_area_back__c != null ){
listBackBodyPart.addAll(patientLogList[0].primary_area_back__c.split(';'));
}
if(patientLogList[0].secondary_area_back__c != null ){
listBackBodyPart.addAll(patientLogList[0].secondary_area_back__c.split(';'));
}
if(patientLogList[0].tertiary_area_back__c != null ){
listBackBodyPart.addAll(patientLogList[0].tertiary_area_back__c.split(';'));
}
PatientLogWrapper pw = new PatientLogWrapper(listFrontBodyPart, listBackBodyPart, patientLogList[0].pain_Intensity__c, patientLogList[0].frequency__c, patientLogList[0].sensation__c, patientLogList[0].CreatedDate);
system.debug('pwpwpw==>'+pw);
return pw;
}
@AuraEnabled (cacheable=true)
public static comparisonWrapper getComparisonLogDetails(String logId1, String logId2, Boolean isFrontSide){
system.debug('in getComparisonLogDetails logId1'+ logId1);
system.debug('in getComparisonLogDetails logId2'+ logId2);
List<PatientLogWrapper> listWrapper = new List<PatientLogWrapper>();
List<String> commonBodyPart = new List<String>();
List<String> listFrontBodyPart = new List<String>();
List<String> listBackBodyPart = new List<String>();
set<Id> setLogIds = new set<Id>();
setLogIds.add(Id.valueof(logId1));
setLogIds.add(Id.valueof(logId2));
//List<String> listFields = new List<String>{'primary_area_front__c','secondary_area_front__c','tertiary_area_front__c','primary_area_back__c', 'secondary_area_back__c', 'tertiary_area_back__c'};
List<String> listFields = new List<String>();
if(isFrontSide){
listFields.add('primary_area_front__c');
listFields.add('secondary_area_front__c');
listFields.add('tertiary_area_front__c');
}else{
listFields.add('primary_area_back__c');
listFields.add('secondary_area_back__c');
listFields.add('tertiary_area_back__c');
}
List<Patient_Log__c> listPatientLogs = [SELECT Name, sensation__c,frequency__c, sleep__c, pain_details__c, pain_Intensity__c,source__c , Log_Type__c, mood__c,
primary_area_front__c, secondary_area_front__c,tertiary_area_front__c, primary_area_back__c, secondary_area_back__c,
tertiary_area_back__c FROM Patient_Log__c WHERE Id IN : setLogIds order by createdDate ASC];
Patient_Log__c patientLog1 = listPatientLogs[0];
Patient_Log__c patientLog2 = listPatientLogs[1];
for(String field : listFields){
set<String> setBodyParts1 = new set<String>();
String bodyParts = String.valueof(patientLog1.get(field));
if(!string.isEmpty(bodyParts)){
setBodyParts1.addAll(bodyParts.split(';'));
}
set<String> setbodyParts2 = new set<String>();
String bodyParts2 = String.valueof(patientLog2.get(field));
if(!string.isEmpty(bodyParts2)){
setbodyParts2.addAll(bodyParts2.split(';'));
}
if(setBodyParts1.size() > setbodyParts2.size()){
for(String bpart : setBodyParts1){
if(setbodyParts2.contains(bpart)){
commonBodyPart.add(bpart);
}/*else if(bpart.startsWith('FRONT')){
listFrontBodyPart.add(bpart);
} else if(bpart.startsWith('BACK')){
listBackBodyPart.add(bpart);
}*/
}
}else{
for(String bpart : setbodyParts2){
if(setBodyParts1.contains(bpart)){
commonBodyPart.add(bpart);
}/*else if(bpart.startsWith('FRONT')){
listFrontBodyPart.add(bpart);
} else if(bpart.startsWith('BACK')){
listBackBodyPart.add(bpart);
}*/
}
}
}
listWrapper.add(getPatientLogDetails(logId1));
listWrapper.add(getPatientLogDetails(logId2));
system.debug('commonBodyPart'+commonBodyPart);
system.debug('listWrapper'+listWrapper);
ComparisonWrapper cw = new ComparisonWrapper(listWrapper, commonBodyPart);
system.debug('ComparisonWrapper'+cw);
return cw;
}
@AuraEnabled (cacheable=true)
public static Account getPatientDetails(String patientId){
List<Account> listPatients = new List<Account>();
listPatients = [SELECT id, Name, journey_stage__c FROM Account WHERE ID =: Id.valueof(patientId)];
return listPatients[0];
}
public class PatientLogSelectionWrapper
{
@AuraEnabled public String patientLogId {get;set;}
@AuraEnabled public String patientLogName {get;set;}
@AuraEnabled public String patientDetail {get;set;}
@AuraEnabled public String painIntensity {get;set;}
@AuraEnabled public String source {get;set;}
@AuraEnabled public String createdBy {get;set;}
@AuraEnabled public Date createdDate {get;set;}
@AuraEnabled public Time createdTime {get;set;}
@AuraEnabled public DateTime createdDatetime {get;set;}
@AuraEnabled public Boolean isBaseline {get;set;}
public PatientLogSelectionWrapper(String patientLogId,
String patientLogName,
String patientDetail,
String painIntensity,
String source,
String createdBy,
Date createdDate,
Time createdTime,
DateTime createdDatetime,
Boolean isBaseline)
{
this.patientLogId = patientLogId;
this.patientLogName = patientLogName;
this.patientDetail = patientDetail;
this.painIntensity = painIntensity;
this.source = source;
this.createdBy = createdBy;
this.createdDate = createdDate;
this.createdTime = createdTime;
this.createdDatetime = createdDatetime;
this.isBaseline = isBaseline;
}
}
public class PatientLogWrapper{
@AuraEnabled public List<String> listFrontBodyPart {get;set;}
@AuraEnabled public List<String> listBackBodyPart {get;set;}
@AuraEnabled public String painIntensity {get;set;}
@AuraEnabled public Decimal frequency {get;set;}
@AuraEnabled public String sensation {get;set;}
@AuraEnabled public Datetime createdDate {get;set;}
PatientLogWrapper(List<String> listFrontBodyPart,List<String> listBackBodyPart, string painIntensity, Decimal frequency, String sensation, Datetime createdDate){
//this.listBodyPart = new List<String>();
this.listFrontBodyPart = listFrontBodyPart;
this.listBackBodyPart = listBackBodyPart;
this.painIntensity =painIntensity;
this.frequency = frequency;
this.sensation = sensation;
this.createdDate = createdDate;
}
}
public class ComparisonWrapper{
@AuraEnabled public List<PatientLogWrapper> listWrappers {get;set;}
@AuraEnabled public List<String> commonBodyPart {get;set;}
ComparisonWrapper(List<PatientLogWrapper> listWrappers, List<String> commonBodyPart){
this.listWrappers = listWrappers;
this.commonBodyPart = commonBodyPart;
}
}
}
-
- Krishna Sahu 1
- July 20, 2022
- Like
- 0
I am facing problem on checkbox field it is not moving in unchecked states when i am click on Inactive or Active button
<template>
<div class="slds-m-top_small slds-m-bottom_medium">
<p align="right">
<lightning-button variant="brand" label="Add Team Member" title="addteammember" onclick={showModalBox} class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="brand" label="Active" title="active" data-status="Active" onclick={handleActiveAndInActive} class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="brand" label="InActive" title="inactive" data-status="InActive" onclick={handleActiveAndInActive} class="slds-m-left_x-small"></lightning-button>
</p>
</div>
<template if:true={isShowModal}>
<lightning-card>
<lightning-layout>
<lightning-layout-item size="12">
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<!-- modal header start -->
<header class="slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
<lightning-icon icon-name="utility:close"
alternative-text="close"
variant="inverse"
size="small" ></lightning-icon>
<span class="slds-assistive-text">Close</span>
</button>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Active Physician</h2>
</header>
<!-- modal body start -->
<div class="slds-modal__content slds-p-around_medium" style="overflow:initial;" id="modal-content-id-1">
<div class="slds-m-around_medium">
<template if:true={rolePicklist}>
<lightning-combobox name="Role"
label="Role"
value={caseTeamRole}
options={rolePicklist}
style="overflow-y: visible;"
onchange={handleCaseTeamRole}>
</lightning-combobox>
</template>
<template if:false={internalUserFilter}>
<c-lwc-lookup-component
object-api-name="User"
icon-name="standard:user"
lookup-label = "User"
onerror={showError}
filter="Profile.Name= 'Ext. Physician'"
onrecordselection = {updateSelectedUser}
>
</c-lwc-lookup-component>
</template>
<template if:true={internalUserFilter}>
<c-lwc-lookup-component
object-api-name="User"
icon-name="standard:user"
lookup-label = "User"
onerror={showError}
onrecordselection = {updateSelectedUser}
>
</c-lwc-lookup-component>
</template>
</div>
</div>
<!-- modal footer start-->
<footer class="slds-modal__footer">
<lightning-button variant="neutral" label="Cancel" title="Cancel" onclick={hideModalBox} class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="brand" label="Save" title="Save" onclick={saveCareTeams} class="slds-m-left_x-small"></lightning-button>
</footer>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</lightning-layout-item>
</lightning-layout>
</lightning-card>
</template>
<!-- modal end -->
<template if:true={recordId}>
<lightning-layout>
<lightning-layout-item size="1" class="slds-border_top slds-border_left slds-border_bottom slds_th">
Check
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_top slds-border_left slds-border_bottom slds_th">
Member Name
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_top slds-border_left slds-border_bottom slds_th">
Role
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_top slds-border_left slds-border_bottom slds_th">
Date Time
</lightning-layout-item>
<lightning-layout-item size="2" class="slds-border_top slds-border_left slds-border_bottom slds-border_right slds_th">
Status
</lightning-layout-item>
</lightning-layout>
<template for:each={lstWrappers} for:item="caseteam">
<lightning-layout key={caseteam.ids}>
<lightning-layout-item size="1" class="slds-border_bottom slds-border_left slds_td">
<lightning-input type="checkbox" data-id={caseteam.ids} onchange={updateCaseTeamIds} checked={checkboxVal}></lightning-input>
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_bottom slds-border_left slds_td">
{caseteam.memberName}
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_bottom slds-border_left slds_td">
{caseteam.teamRoleName}
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_bottom slds-border_left slds_td">
<lightning-formatted-date-time value={caseteam.createdDate}></lightning-formatted-date-time>
</lightning-layout-item>
<lightning-layout-item size="2" class="slds-border_top slds-border_left slds-border_bottom slds-border_right slds_td">
<lightning-formatted-text value={caseteam.status}></lightning-formatted-text>
</lightning-layout-item>
</lightning-layout>
</template>
</template>
</template>
=====================================================
import { LightningElement,api,track,wire } from 'lwc';
import { Toaster, Utils, reduceErrors } from 'c/utilityServices';
import getCaseTeamMembers from '@salesforce/apex/CareTeamController.getCaseTeamMembers';
import saveCareTeam from '@salesforce/apex/CareTeamController.saveCareTeam';
import updateStatus from '@salesforce/apex/CareTeamController.updateStatus';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import CARETEAM_OBJECT from '@salesforce/schema/CareTeam__c';
import ROLE_FIELD from '@salesforce/schema/CareTeam__c.Roles__c';
import care_coordinator from '@salesforce/label/c.care_coordinator';
export default class CareTeamList extends LightningElement
{
@api recordId;
@track lstWrappers;
@track isProcessing = false;
@track error;
@track selectUserId;
@track isShowModal = false;
@track checkedCaseIds = [];
@track rolePicklist=[];
@track caseTeamRole;
checkboxVal;
showModalBox() {
this.isShowModal = true;
console.log(this.isShowModal);
}
hideModalBox() {
this.isShowModal = false;
}
// to get the default record type id, if you dont' have any recordtypes then it will get master
@wire(getObjectInfo, { objectApiName: CARETEAM_OBJECT })
careTeamMetadata;
// now get the industry picklist values
@wire(getPicklistValues,{
recordTypeId: '$careTeamMetadata.data.defaultRecordTypeId',
fieldApiName: ROLE_FIELD
}
)
getRolePicklist(data, error){
if(data && data.data && data.data.values){
data.data.values.forEach( objPicklist => {
this.rolePicklist.push({
label: objPicklist.label,
value: objPicklist.value
});
});
} else if(error){
console.log(error);
}
console.log('rolePicklist'+this.rolePicklist)
};
// on select picklist value to show the selected value
handleCaseTeamRole(event) {
this.caseTeamRole = event.detail.value;
if(this.caseTeamRole == care_coordinator){
this.internalUserFilter = true;
}else{
this.internalUserFilter = false;
}
}
saveCareTeams(event)
{
saveCareTeam({role : this.caseTeamRole,
userId : this.selectUserId,
patientId : this.recordId})
.then((result) => {
console.log('========'+JSON.stringify(result));
this.lstWrappers = JSON.parse(JSON.stringify(result));
this.hideModalBox();
this.isProcessing = false;
this.error = undefined;
})
.catch((error) => {
this.error = error;
this.isProcessing = false;
this.lstWrappers = undefined;
Toaster.error('Error', reduceErrors(this.error));
});
}
connectedCallback()
{
this.getWrapper();
}
updateSelectedUser(event){
this.selectUserId = event.detail.selectedRecordId;
}
getWrapper()
{
this.isProcessing = true;
console.log('========'+this.recordId);
if(this.recordId){
getCaseTeamMembers({patientId : this.recordId})
.then((result) => {
console.log('========'+JSON.stringify(result));
this.lstWrappers = result;
this.isProcessing = false;
this.error = undefined;
})
.catch((error) => {
this.error = error;
this.isProcessing = false;
this.lstWrappers = undefined;
Toaster.error('Error', reduceErrors(this.error));
});
}
}
updateCaseTeamIds(event)
{
console.log('==='+event.detail.checked);
console.log('==='+event.currentTarget.dataset.id);
console.log('==='+this.checkedCaseIds);
if(event.detail.checked)
{
this.checkedCaseIds.push(event.currentTarget.dataset.id);
}
else
{
if(this.checkedCaseIds.length > 0)
{
var index = this.checkedCaseIds.indexOf(event.currentTarget.dataset.id);
if (index > -1) {
this.checkedCaseIds.splice(index, 1);
}
}
}
}
handleActiveAndInActive(event)
{
console.log('========'+JSON.stringify(this.checkedCaseIds));
console.log('========'+event.currentTarget.dataset.status);
if(this.checkedCaseIds && this.checkedCaseIds.length > 0)
{
updateStatus({patientId : this.recordId,
lstCaseTeamIdsStr : JSON.stringify(this.checkedCaseIds),
status : event.currentTarget.dataset.status,
})
.then((result) => {
console.log('========'+JSON.stringify(result));
this.lstWrappers = JSON.parse(JSON.stringify(result));
this.hideModalBox();
this.isProcessing = false;
this.error = undefined;
})
.catch((error) => {
this.error = error;
this.isProcessing = false;
this.lstWrappers = undefined;
Toaster.error('Error', reduceErrors(this.error));
});
}
}
}
<div class="slds-m-top_small slds-m-bottom_medium">
<p align="right">
<lightning-button variant="brand" label="Add Team Member" title="addteammember" onclick={showModalBox} class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="brand" label="Active" title="active" data-status="Active" onclick={handleActiveAndInActive} class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="brand" label="InActive" title="inactive" data-status="InActive" onclick={handleActiveAndInActive} class="slds-m-left_x-small"></lightning-button>
</p>
</div>
<template if:true={isShowModal}>
<lightning-card>
<lightning-layout>
<lightning-layout-item size="12">
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<!-- modal header start -->
<header class="slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
<lightning-icon icon-name="utility:close"
alternative-text="close"
variant="inverse"
size="small" ></lightning-icon>
<span class="slds-assistive-text">Close</span>
</button>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Active Physician</h2>
</header>
<!-- modal body start -->
<div class="slds-modal__content slds-p-around_medium" style="overflow:initial;" id="modal-content-id-1">
<div class="slds-m-around_medium">
<template if:true={rolePicklist}>
<lightning-combobox name="Role"
label="Role"
value={caseTeamRole}
options={rolePicklist}
style="overflow-y: visible;"
onchange={handleCaseTeamRole}>
</lightning-combobox>
</template>
<template if:false={internalUserFilter}>
<c-lwc-lookup-component
object-api-name="User"
icon-name="standard:user"
lookup-label = "User"
onerror={showError}
filter="Profile.Name= 'Ext. Physician'"
onrecordselection = {updateSelectedUser}
>
</c-lwc-lookup-component>
</template>
<template if:true={internalUserFilter}>
<c-lwc-lookup-component
object-api-name="User"
icon-name="standard:user"
lookup-label = "User"
onerror={showError}
onrecordselection = {updateSelectedUser}
>
</c-lwc-lookup-component>
</template>
</div>
</div>
<!-- modal footer start-->
<footer class="slds-modal__footer">
<lightning-button variant="neutral" label="Cancel" title="Cancel" onclick={hideModalBox} class="slds-m-left_x-small"></lightning-button>
<lightning-button variant="brand" label="Save" title="Save" onclick={saveCareTeams} class="slds-m-left_x-small"></lightning-button>
</footer>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</lightning-layout-item>
</lightning-layout>
</lightning-card>
</template>
<!-- modal end -->
<template if:true={recordId}>
<lightning-layout>
<lightning-layout-item size="1" class="slds-border_top slds-border_left slds-border_bottom slds_th">
Check
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_top slds-border_left slds-border_bottom slds_th">
Member Name
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_top slds-border_left slds-border_bottom slds_th">
Role
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_top slds-border_left slds-border_bottom slds_th">
Date Time
</lightning-layout-item>
<lightning-layout-item size="2" class="slds-border_top slds-border_left slds-border_bottom slds-border_right slds_th">
Status
</lightning-layout-item>
</lightning-layout>
<template for:each={lstWrappers} for:item="caseteam">
<lightning-layout key={caseteam.ids}>
<lightning-layout-item size="1" class="slds-border_bottom slds-border_left slds_td">
<lightning-input type="checkbox" data-id={caseteam.ids} onchange={updateCaseTeamIds} checked={checkboxVal}></lightning-input>
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_bottom slds-border_left slds_td">
{caseteam.memberName}
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_bottom slds-border_left slds_td">
{caseteam.teamRoleName}
</lightning-layout-item>
<lightning-layout-item size="3" class="slds-border_bottom slds-border_left slds_td">
<lightning-formatted-date-time value={caseteam.createdDate}></lightning-formatted-date-time>
</lightning-layout-item>
<lightning-layout-item size="2" class="slds-border_top slds-border_left slds-border_bottom slds-border_right slds_td">
<lightning-formatted-text value={caseteam.status}></lightning-formatted-text>
</lightning-layout-item>
</lightning-layout>
</template>
</template>
</template>
=====================================================
import { LightningElement,api,track,wire } from 'lwc';
import { Toaster, Utils, reduceErrors } from 'c/utilityServices';
import getCaseTeamMembers from '@salesforce/apex/CareTeamController.getCaseTeamMembers';
import saveCareTeam from '@salesforce/apex/CareTeamController.saveCareTeam';
import updateStatus from '@salesforce/apex/CareTeamController.updateStatus';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import CARETEAM_OBJECT from '@salesforce/schema/CareTeam__c';
import ROLE_FIELD from '@salesforce/schema/CareTeam__c.Roles__c';
import care_coordinator from '@salesforce/label/c.care_coordinator';
export default class CareTeamList extends LightningElement
{
@api recordId;
@track lstWrappers;
@track isProcessing = false;
@track error;
@track selectUserId;
@track isShowModal = false;
@track checkedCaseIds = [];
@track rolePicklist=[];
@track caseTeamRole;
checkboxVal;
showModalBox() {
this.isShowModal = true;
console.log(this.isShowModal);
}
hideModalBox() {
this.isShowModal = false;
}
// to get the default record type id, if you dont' have any recordtypes then it will get master
@wire(getObjectInfo, { objectApiName: CARETEAM_OBJECT })
careTeamMetadata;
// now get the industry picklist values
@wire(getPicklistValues,{
recordTypeId: '$careTeamMetadata.data.defaultRecordTypeId',
fieldApiName: ROLE_FIELD
}
)
getRolePicklist(data, error){
if(data && data.data && data.data.values){
data.data.values.forEach( objPicklist => {
this.rolePicklist.push({
label: objPicklist.label,
value: objPicklist.value
});
});
} else if(error){
console.log(error);
}
console.log('rolePicklist'+this.rolePicklist)
};
// on select picklist value to show the selected value
handleCaseTeamRole(event) {
this.caseTeamRole = event.detail.value;
if(this.caseTeamRole == care_coordinator){
this.internalUserFilter = true;
}else{
this.internalUserFilter = false;
}
}
saveCareTeams(event)
{
saveCareTeam({role : this.caseTeamRole,
userId : this.selectUserId,
patientId : this.recordId})
.then((result) => {
console.log('========'+JSON.stringify(result));
this.lstWrappers = JSON.parse(JSON.stringify(result));
this.hideModalBox();
this.isProcessing = false;
this.error = undefined;
})
.catch((error) => {
this.error = error;
this.isProcessing = false;
this.lstWrappers = undefined;
Toaster.error('Error', reduceErrors(this.error));
});
}
connectedCallback()
{
this.getWrapper();
}
updateSelectedUser(event){
this.selectUserId = event.detail.selectedRecordId;
}
getWrapper()
{
this.isProcessing = true;
console.log('========'+this.recordId);
if(this.recordId){
getCaseTeamMembers({patientId : this.recordId})
.then((result) => {
console.log('========'+JSON.stringify(result));
this.lstWrappers = result;
this.isProcessing = false;
this.error = undefined;
})
.catch((error) => {
this.error = error;
this.isProcessing = false;
this.lstWrappers = undefined;
Toaster.error('Error', reduceErrors(this.error));
});
}
}
updateCaseTeamIds(event)
{
console.log('==='+event.detail.checked);
console.log('==='+event.currentTarget.dataset.id);
console.log('==='+this.checkedCaseIds);
if(event.detail.checked)
{
this.checkedCaseIds.push(event.currentTarget.dataset.id);
}
else
{
if(this.checkedCaseIds.length > 0)
{
var index = this.checkedCaseIds.indexOf(event.currentTarget.dataset.id);
if (index > -1) {
this.checkedCaseIds.splice(index, 1);
}
}
}
}
handleActiveAndInActive(event)
{
console.log('========'+JSON.stringify(this.checkedCaseIds));
console.log('========'+event.currentTarget.dataset.status);
if(this.checkedCaseIds && this.checkedCaseIds.length > 0)
{
updateStatus({patientId : this.recordId,
lstCaseTeamIdsStr : JSON.stringify(this.checkedCaseIds),
status : event.currentTarget.dataset.status,
})
.then((result) => {
console.log('========'+JSON.stringify(result));
this.lstWrappers = JSON.parse(JSON.stringify(result));
this.hideModalBox();
this.isProcessing = false;
this.error = undefined;
})
.catch((error) => {
this.error = error;
this.isProcessing = false;
this.lstWrappers = undefined;
Toaster.error('Error', reduceErrors(this.error));
});
}
}
}
-
- Krishna Sahu 1
- July 18, 2022
- Like
- 0
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;
}
}
-
- Krishna Sahu 1
- July 18, 2022
- Like
- 0
Is it somting wrong in this Map Variable i trying to fix but not resolving.
Map<String, String> mapOrderType_Role= new Map<>(){'NROP'=>'Trialing Physician', 'NROP'=>'Implanting Physician',
'NREP'=>'Replacement Physician', 'NREV'=>'Revision Physician'};
'NREP'=>'Replacement Physician', 'NREV'=>'Revision Physician'};
-
- Krishna Sahu 1
- July 18, 2022
- Like
- 0
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;
}
}
-
- Krishna Sahu 1
- July 14, 2022
- Like
- 0
Hi friends i want writa a trigger to create a new team member but i getting a issue while i am changing the implating physician field value it not going right please help me on this
public static void PhysicianOnCareTeamAfterOrderStatusUpdate(map<Id, Order> newMap, map<Id, Order> oldMap){
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 : newMap.values())
{
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 : newMap.values())
{
// for permanent type
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'));
}
}
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 : newMap.values())
{
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 : newMap.values())
{
// for permanent type
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'));
}
}
if(!mapCaseTeam.isEmpty()){
insert mapCaseTeam;
}
}
-
- Krishna Sahu 1
- July 13, 2022
- Like
- 0
Please help me to write test class on before insert
public static void resistDuplicateRecordName(List<Lead> listLeads){
map<String, Lead> mapExistingRecordLead = new map<String, Lead>();
Set<String> setOfFirstName = new Set<String>();
Set<String> setOfMiddleName = new Set<String>();
Set<String> setOfLastName = new Set<String>();
Set<Date> setOfDob = new Set<Date>();
Set<String> setOfMobileNumber = new Set<String>();
for(Lead objeLead : listLeads){
if(objeLead.HealthCloudGA__BirthDate__c != null && objeLead.MobilePhone != null){
setOfFirstName.add(objeLead.FirstName);
setOfMiddleName.add(objeLead.MiddleName);
setOfLastName.add(objeLead.LastName);
setOfDob.add(objeLead.HealthCloudGA__BirthDate__c);
setOfMobileNumber.add(objeLead.MobilePhone);
}
}
for(Lead objeLead : [SELECT Id , Name , FirstName, MiddleName, MobilePhone, LastName , HealthCloudGA__BirthDate__c
FROM Lead
WHERE FirstName =:setOfFirstName AND MiddleName =:setOfMiddleName AND LastName=:setOfLastName
AND HealthCloudGA__BirthDate__c =:setOfDob AND MobilePhone =:setOfMobileNumber]){
System.debug('HealthCloudGA__BirthDate__c '+objeLead.HealthCloudGA__BirthDate__c);
System.debug('MobilePhone '+objeLead.MobilePhone);
System.debug('MobilePhone '+objeLead.Name);
String leadkey = String.valueOf(objeLead.HealthCloudGA__BirthDate__c)+'-'+ String.valueOf(objeLead.MobilePhone) + '-'
+ objeLead.FirstName + objeLead.MiddleName + objeLead.LastName;
mapExistingRecordLead.put(leadkey, objeLead);
}
for(Lead newLeadRecord : listLeads){
String leadkey = String.valueOf(newLeadRecord.HealthCloudGA__BirthDate__c) + '-' + String.valueOf(newLeadRecord.MobilePhone) + '-'
+ newLeadRecord.FirstName + newLeadRecord.MiddleName + newLeadRecord.LastName;
if(mapExistingRecordLead.containsKey(leadKey)){
newLeadRecord.FirstName.addError(Label.duplicate_record_candidate);
}
}
}
map<String, Lead> mapExistingRecordLead = new map<String, Lead>();
Set<String> setOfFirstName = new Set<String>();
Set<String> setOfMiddleName = new Set<String>();
Set<String> setOfLastName = new Set<String>();
Set<Date> setOfDob = new Set<Date>();
Set<String> setOfMobileNumber = new Set<String>();
for(Lead objeLead : listLeads){
if(objeLead.HealthCloudGA__BirthDate__c != null && objeLead.MobilePhone != null){
setOfFirstName.add(objeLead.FirstName);
setOfMiddleName.add(objeLead.MiddleName);
setOfLastName.add(objeLead.LastName);
setOfDob.add(objeLead.HealthCloudGA__BirthDate__c);
setOfMobileNumber.add(objeLead.MobilePhone);
}
}
for(Lead objeLead : [SELECT Id , Name , FirstName, MiddleName, MobilePhone, LastName , HealthCloudGA__BirthDate__c
FROM Lead
WHERE FirstName =:setOfFirstName AND MiddleName =:setOfMiddleName AND LastName=:setOfLastName
AND HealthCloudGA__BirthDate__c =:setOfDob AND MobilePhone =:setOfMobileNumber]){
System.debug('HealthCloudGA__BirthDate__c '+objeLead.HealthCloudGA__BirthDate__c);
System.debug('MobilePhone '+objeLead.MobilePhone);
System.debug('MobilePhone '+objeLead.Name);
String leadkey = String.valueOf(objeLead.HealthCloudGA__BirthDate__c)+'-'+ String.valueOf(objeLead.MobilePhone) + '-'
+ objeLead.FirstName + objeLead.MiddleName + objeLead.LastName;
mapExistingRecordLead.put(leadkey, objeLead);
}
for(Lead newLeadRecord : listLeads){
String leadkey = String.valueOf(newLeadRecord.HealthCloudGA__BirthDate__c) + '-' + String.valueOf(newLeadRecord.MobilePhone) + '-'
+ newLeadRecord.FirstName + newLeadRecord.MiddleName + newLeadRecord.LastName;
if(mapExistingRecordLead.containsKey(leadKey)){
newLeadRecord.FirstName.addError(Label.duplicate_record_candidate);
}
}
}
-
- Krishna Sahu 1
- July 12, 2022
- Like
- 0
Need help to write test class on the classs
public static void leadConversion(List<flowInputs> leadIdSet){
System.debug('This is the lead Id from Convert Lead Flow===>'+leadIdSet[0]);
Map<Id, Case> mapCases = new Map<Id, Case>();
List<CaseTeamMember> listCaseTeamMember = new List<CaseTeamMember>();
List<Database.LeadConvert> leadsToConvert = new List<Database.LeadConvert>();
for(Id leadId: leadIdSet[0].ids){
Database.LeadConvert newConvertLead = new Database.LeadConvert();
newConvertLead.setLeadId(leadId);
newConvertLead.setDoNotCreateOpportunity(true);
newConvertLead.setConvertedStatus(leadConvertedStatus);
leadsToConvert.add(newConvertLead);
}
if(!leadsToConvert.isEmpty())
{
List<Database.LeadConvertResult> convertResult = Database.convertLead(leadsToConvert);
CaseTeamRole caseTeamRole = [SELECT Id,Name FROM CaseTeamRole WHERE Name ='Care Coordinator' LIMIT 1];
Set<Id> setAccountIds = new Set<Id>();
Map<Id, Id> mapAccountIdToContactId = new Map<Id, Id>();
for(Database.LeadConvertResult convertedLead : convertResult)
{
mapAccountIdToContactId.put(convertedLead.getAccountId(), convertedLead.getContactId());
}
Map<Id, Account> mapAccounts = new Map<Id, Account>([SELECT Id, OwnerId,
sales_representative__c, Name
FROM Account
WHERE Id IN :mapAccountIdToContactId.keyset() AND sales_representative__c !=null]);
if(!mapAccounts.isEmpty())
{
for(Account accountRecord : mapAccounts.values())
{
if(accountRecord.OwnerId != null && accountRecord.Name !=null)
{
mapCases.put(accountRecord.Id, new Case(OwnerId = accountRecord.OwnerId,
ContactId = mapAccountIdToContactId.get(accountRecord.Id),
AccountId = accountRecord.Id,
Status = 'New',
Subject = accountRecord.Name+' Care Plan'));
}
}
insert mapCases.values();
List<CaseTeamMember> lstCareTeamMembers = new List<CaseTeamMember>();
for(Case objCase : mapCases.values())
{
lstCareTeamMembers.add(new CaseTeamMember(ParentId = objCase.Id,
MemberId = mapAccounts.get(objCase.AccountId).sales_representative__c,
TeamRoleId = caseTeamRole.Id));
}
insert lstCareTeamMembers;
}
}
System.debug('This is the lead Id from Convert Lead Flow===>'+leadIdSet[0]);
Map<Id, Case> mapCases = new Map<Id, Case>();
List<CaseTeamMember> listCaseTeamMember = new List<CaseTeamMember>();
List<Database.LeadConvert> leadsToConvert = new List<Database.LeadConvert>();
for(Id leadId: leadIdSet[0].ids){
Database.LeadConvert newConvertLead = new Database.LeadConvert();
newConvertLead.setLeadId(leadId);
newConvertLead.setDoNotCreateOpportunity(true);
newConvertLead.setConvertedStatus(leadConvertedStatus);
leadsToConvert.add(newConvertLead);
}
if(!leadsToConvert.isEmpty())
{
List<Database.LeadConvertResult> convertResult = Database.convertLead(leadsToConvert);
CaseTeamRole caseTeamRole = [SELECT Id,Name FROM CaseTeamRole WHERE Name ='Care Coordinator' LIMIT 1];
Set<Id> setAccountIds = new Set<Id>();
Map<Id, Id> mapAccountIdToContactId = new Map<Id, Id>();
for(Database.LeadConvertResult convertedLead : convertResult)
{
mapAccountIdToContactId.put(convertedLead.getAccountId(), convertedLead.getContactId());
}
Map<Id, Account> mapAccounts = new Map<Id, Account>([SELECT Id, OwnerId,
sales_representative__c, Name
FROM Account
WHERE Id IN :mapAccountIdToContactId.keyset() AND sales_representative__c !=null]);
if(!mapAccounts.isEmpty())
{
for(Account accountRecord : mapAccounts.values())
{
if(accountRecord.OwnerId != null && accountRecord.Name !=null)
{
mapCases.put(accountRecord.Id, new Case(OwnerId = accountRecord.OwnerId,
ContactId = mapAccountIdToContactId.get(accountRecord.Id),
AccountId = accountRecord.Id,
Status = 'New',
Subject = accountRecord.Name+' Care Plan'));
}
}
insert mapCases.values();
List<CaseTeamMember> lstCareTeamMembers = new List<CaseTeamMember>();
for(Case objCase : mapCases.values())
{
lstCareTeamMembers.add(new CaseTeamMember(ParentId = objCase.Id,
MemberId = mapAccounts.get(objCase.AccountId).sales_representative__c,
TeamRoleId = caseTeamRole.Id));
}
insert lstCareTeamMembers;
}
}
-
- Krishna Sahu 1
- June 24, 2022
- Like
- 0
I need to write test class with assertion please help me on this
@HttpGet
global static List<Patient_Goal__c> getRecords() {
RestRequest request = RestContext.request;
System.debug('request.requestURI: '+request.requestURI);
System.debug('request.params.get(\'patientId\'): '+request.params.get('patientId'));
String ids = request.params.get('patientId');
System.debug(ids);
List<String> listInvIds = ids.split(',');
List<Patient_Goal__c> result =[SELECT Id , Name,goal__c,CurrencyIsoCode,patient__c
FROM Patient_Goal__c
WHERE patient__c = :listInvIds];
return result;
}
global static List<Patient_Goal__c> getRecords() {
RestRequest request = RestContext.request;
System.debug('request.requestURI: '+request.requestURI);
System.debug('request.params.get(\'patientId\'): '+request.params.get('patientId'));
String ids = request.params.get('patientId');
System.debug(ids);
List<String> listInvIds = ids.split(',');
List<Patient_Goal__c> result =[SELECT Id , Name,goal__c,CurrencyIsoCode,patient__c
FROM Patient_Goal__c
WHERE patient__c = :listInvIds];
return result;
}
-
- Krishna Sahu 1
- June 03, 2022
- Like
- 0
Taslk is not creating
/**
* @description : Prior auth procedure service class
* @author : Rialtes Dev Team
* @last modified on : 06-01-2022
* @last modified by : Rialtes Dev Team
**/
public inherited sharing class PriorAuthProcedureCodeService
{
/**
* @description : These method fetch all the details of the procedure codes
* @author Rialtes Dev Team
* @param PriorAuthWrapper objPriorAuthWrapper
**/
public static Map<String, List<ProcedureCode>> getProcedureCodes(PriorAuthWrapper objPriorAuthWrapper)
{
Map<String, List<ProcedureCode>> mapKeyToProcedureCodes = new Map<String, List<ProcedureCode>>();
Map<Id, Procedure_Code__c> mapMasterToProcedureCode = new Map<Id, Procedure_Code__c>();
String type = (objPriorAuthWrapper.serviceRequestType == Label.JOURNEY_STAGE_TRIAL_PRIOR_AUTH ? Label.JOURNEY_STAGE_PERMANENT_PRIOR_AUTH : Label.JOURNEY_STAGE_TRIAL_PRIOR_AUTH) + ' Procedure';
if(objPriorAuthWrapper.recordId != null)
{
for(Procedure_Code__c objProcedureCode : [SELECT Id, units__c,
procedure_code_master_data__c,
procedure_code_master_data__r.description__c,
procedure_code_master_data__r.Name,
procedure_code_master_data__r.type__c
FROM Procedure_Code__c
WHERE procedure_code_master_data__r.type__c != :type
AND prior_authorization__c =: objPriorAuthWrapper.recordId])
{
mapMasterToProcedureCode.put(objProcedureCode.procedure_code_master_data__c, objProcedureCode);
}
}
for(Procedure_Code_Master_Data__c objProcedureCodeMaster : [SELECT Id, description__c,
type__c, Name
FROM Procedure_Code_Master_Data__c
WHERE type__c != :type
AND Enabled__c = true])
{
ProcedureCode objProcedure = new ProcedureCode(null, objProcedureCodeMaster.Id, objProcedureCodeMaster.Name, objProcedureCodeMaster.description__c, null);
if(!mapKeyToProcedureCodes.containsKey(objProcedureCodeMaster.type__c))
{
mapKeyToProcedureCodes.put(objProcedureCodeMaster.type__c, new List<ProcedureCode>{objProcedure});
}
else
{
mapKeyToProcedureCodes.get(objProcedureCodeMaster.type__c).add(objProcedure);
}
}
for(String key : mapKeyToProcedureCodes.keyset())
{
List<ProcedureCode> lstProcedures = new List<ProcedureCode>();
for(ProcedureCode objProcedure : mapKeyToProcedureCodes.get(key))
{
if(mapMasterToProcedureCode.containsKey(objProcedure.procedureMasterCode))
{
objProcedure.procedureCodeId = mapMasterToProcedureCode.get(objProcedure.procedureMasterCode).Id;
objProcedure.units = mapMasterToProcedureCode.get(objProcedure.procedureMasterCode).units__c;
}
lstProcedures.add(objProcedure);
}
mapKeyToProcedureCodes.put(key, lstProcedures);
}
return mapKeyToProcedureCodes;
}
/**
* @description : These method upsert all the details of the procedure codes
* @author Rialtes Dev Team
* @param PriorAuthWrapper objPriorAuthWrapper
* @param CareRequest objCareRequest
**/
public static void saveProcedureCodes(PriorAuthWrapper objPriorAuthWrapper, CareRequest objCareRequest)
{
List<Procedure_Code__c> lstProcedureCodes = new List<Procedure_Code__c>();
if(objPriorAuthWrapper.lstTrialProcedureCodes != null && objPriorAuthWrapper.serviceRequestType == 'Trial')
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstTrialProcedureCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstPermanentProcedureCodes != null && objPriorAuthWrapper.serviceRequestType == 'Permanent')
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstPermanentProcedureCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstRevisionOrRemovalCodes != null)
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstRevisionOrRemovalCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstSCSAnalysisProgramming != null)
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstSCSAnalysisProgramming)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
upsert lstProcedureCodes;
}
}
* @description : Prior auth procedure service class
* @author : Rialtes Dev Team
* @last modified on : 06-01-2022
* @last modified by : Rialtes Dev Team
**/
public inherited sharing class PriorAuthProcedureCodeService
{
/**
* @description : These method fetch all the details of the procedure codes
* @author Rialtes Dev Team
* @param PriorAuthWrapper objPriorAuthWrapper
**/
public static Map<String, List<ProcedureCode>> getProcedureCodes(PriorAuthWrapper objPriorAuthWrapper)
{
Map<String, List<ProcedureCode>> mapKeyToProcedureCodes = new Map<String, List<ProcedureCode>>();
Map<Id, Procedure_Code__c> mapMasterToProcedureCode = new Map<Id, Procedure_Code__c>();
String type = (objPriorAuthWrapper.serviceRequestType == Label.JOURNEY_STAGE_TRIAL_PRIOR_AUTH ? Label.JOURNEY_STAGE_PERMANENT_PRIOR_AUTH : Label.JOURNEY_STAGE_TRIAL_PRIOR_AUTH) + ' Procedure';
if(objPriorAuthWrapper.recordId != null)
{
for(Procedure_Code__c objProcedureCode : [SELECT Id, units__c,
procedure_code_master_data__c,
procedure_code_master_data__r.description__c,
procedure_code_master_data__r.Name,
procedure_code_master_data__r.type__c
FROM Procedure_Code__c
WHERE procedure_code_master_data__r.type__c != :type
AND prior_authorization__c =: objPriorAuthWrapper.recordId])
{
mapMasterToProcedureCode.put(objProcedureCode.procedure_code_master_data__c, objProcedureCode);
}
}
for(Procedure_Code_Master_Data__c objProcedureCodeMaster : [SELECT Id, description__c,
type__c, Name
FROM Procedure_Code_Master_Data__c
WHERE type__c != :type
AND Enabled__c = true])
{
ProcedureCode objProcedure = new ProcedureCode(null, objProcedureCodeMaster.Id, objProcedureCodeMaster.Name, objProcedureCodeMaster.description__c, null);
if(!mapKeyToProcedureCodes.containsKey(objProcedureCodeMaster.type__c))
{
mapKeyToProcedureCodes.put(objProcedureCodeMaster.type__c, new List<ProcedureCode>{objProcedure});
}
else
{
mapKeyToProcedureCodes.get(objProcedureCodeMaster.type__c).add(objProcedure);
}
}
for(String key : mapKeyToProcedureCodes.keyset())
{
List<ProcedureCode> lstProcedures = new List<ProcedureCode>();
for(ProcedureCode objProcedure : mapKeyToProcedureCodes.get(key))
{
if(mapMasterToProcedureCode.containsKey(objProcedure.procedureMasterCode))
{
objProcedure.procedureCodeId = mapMasterToProcedureCode.get(objProcedure.procedureMasterCode).Id;
objProcedure.units = mapMasterToProcedureCode.get(objProcedure.procedureMasterCode).units__c;
}
lstProcedures.add(objProcedure);
}
mapKeyToProcedureCodes.put(key, lstProcedures);
}
return mapKeyToProcedureCodes;
}
/**
* @description : These method upsert all the details of the procedure codes
* @author Rialtes Dev Team
* @param PriorAuthWrapper objPriorAuthWrapper
* @param CareRequest objCareRequest
**/
public static void saveProcedureCodes(PriorAuthWrapper objPriorAuthWrapper, CareRequest objCareRequest)
{
List<Procedure_Code__c> lstProcedureCodes = new List<Procedure_Code__c>();
if(objPriorAuthWrapper.lstTrialProcedureCodes != null && objPriorAuthWrapper.serviceRequestType == 'Trial')
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstTrialProcedureCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstPermanentProcedureCodes != null && objPriorAuthWrapper.serviceRequestType == 'Permanent')
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstPermanentProcedureCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstRevisionOrRemovalCodes != null)
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstRevisionOrRemovalCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstSCSAnalysisProgramming != null)
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstSCSAnalysisProgramming)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
upsert lstProcedureCodes;
}
}
-
- Krishna Sahu 1
- June 01, 2022
- Like
- 0
Need help to write test class on that
public inherited sharing class ProcedureCode
{
@AuraEnabled
public String procedureCodeId;
@AuraEnabled
public String procedureMasterCode;
@AuraEnabled
public String cptCode;
@AuraEnabled
public String description;
@AuraEnabled
public Decimal units;
public ProcedureCode(String procedureCodeId, String procedureMasterCode, String cptCode, String description, Decimal units)
{
this.procedureCodeId = this.procedureCodeId;
this.procedureMasterCode = procedureMasterCode;
this.cptCode = cptCode;
this.description = description;
this.units = units;
}
}
{
@AuraEnabled
public String procedureCodeId;
@AuraEnabled
public String procedureMasterCode;
@AuraEnabled
public String cptCode;
@AuraEnabled
public String description;
@AuraEnabled
public Decimal units;
public ProcedureCode(String procedureCodeId, String procedureMasterCode, String cptCode, String description, Decimal units)
{
this.procedureCodeId = this.procedureCodeId;
this.procedureMasterCode = procedureMasterCode;
this.cptCode = cptCode;
this.description = description;
this.units = units;
}
}
-
- Krishna Sahu 1
- June 01, 2022
- Like
- 0
Please help to write test class on after update trigger
public static void mapBirthdayFieldsOnEducationSession(map<Id,Lead> newLeadMap, map<Id,Lead> oldLeadMap){
map<Id,Lead> newConvertedIdMap = new map<Id,Lead>();
for(Lead listLead : newLeadMap.values()){
if(listLead.isConverted && listLead.ConvertedAccountId !=null && listLead.HealthCloudGA__BirthDate__c !=null){
newConvertedIdMap.put(listLead.ConvertedAccountId,listLead );
}
}
if(!newConvertedIdMap.isEmpty()){
List<Account> listAccount = [SELECT Id , PersonBirthdate FROM Account WHERE Id IN : newConvertedIdMap.keySet()];
for(Account account : listAccount){
Account.PersonBirthdate = newConvertedIdMap.get(account.Id).HealthCloudGA__BirthDate__c;
}
update listAccount ;
}
}
map<Id,Lead> newConvertedIdMap = new map<Id,Lead>();
for(Lead listLead : newLeadMap.values()){
if(listLead.isConverted && listLead.ConvertedAccountId !=null && listLead.HealthCloudGA__BirthDate__c !=null){
newConvertedIdMap.put(listLead.ConvertedAccountId,listLead );
}
}
if(!newConvertedIdMap.isEmpty()){
List<Account> listAccount = [SELECT Id , PersonBirthdate FROM Account WHERE Id IN : newConvertedIdMap.keySet()];
for(Account account : listAccount){
Account.PersonBirthdate = newConvertedIdMap.get(account.Id).HealthCloudGA__BirthDate__c;
}
update listAccount ;
}
}
-
- Krishna Sahu 1
- April 28, 2022
- Like
- 0
Write a trigger to map filed.
I need your help in one scenerio like i have two object Lead and Account.
i create a lead and add values on fields and after that i convert that lead into account.But when i open account record so one field Email value is empty on account object so i need to write trigger ot that field please help me on this.
i create a lead and add values on fields and after that i convert that lead into account.But when i open account record so one field Email value is empty on account object so i need to write trigger ot that field please help me on this.
-
- Krishna Sahu 1
- April 28, 2022
- Like
- 0
Please help me to solve the code to cover all the code
Set<Id> setInvalidWhatIdRecordTypes = new Set<Id>();
Set<Id> setWhatIds = new Set<Id>();
for(Event objEvent : listEvents)
{
if(objEvent.WhatId != null){
setWhatIds.add(objEvent.WhatId);
}
}
for(Account acc : [SELECT Id
FROM Account
WHERE Id IN : setWhatIds
AND RecordType.DeveloperName != 'IndustriesBusiness']){
setInvalidWhatIdRecordTypes.add(acc.Id);
}
if(!setInvalidWhatIdRecordTypes.isEmpty())
{
for(Event objEvent : listEvents)
{
if(objEvent.whatId != null && setInvalidWhatIdRecordTypes.contains(objEvent.whatId))
{
objEvent.WhatId.addError('Account record type can only be business.');
}
}
}
}
Set<Id> setWhatIds = new Set<Id>();
for(Event objEvent : listEvents)
{
if(objEvent.WhatId != null){
setWhatIds.add(objEvent.WhatId);
}
}
for(Account acc : [SELECT Id
FROM Account
WHERE Id IN : setWhatIds
AND RecordType.DeveloperName != 'IndustriesBusiness']){
setInvalidWhatIdRecordTypes.add(acc.Id);
}
if(!setInvalidWhatIdRecordTypes.isEmpty())
{
for(Event objEvent : listEvents)
{
if(objEvent.whatId != null && setInvalidWhatIdRecordTypes.contains(objEvent.whatId))
{
objEvent.WhatId.addError('Account record type can only be business.');
}
}
}
}
-
- Krishna Sahu 1
- April 21, 2022
- Like
- 0
How to restrict field to show other recordtypes record
I want to restrict a field to show only one recordtype record by trigger.
-
- Krishna Sahu 1
- April 20, 2022
- Like
- 0
Look up filter criteria by lwc component
Hello Guys,
I have a standard field which is look up to contact object and i want to show only contact record but it is showing also account record.So how can i achieve the criteria by the lwc component.Please help me on this.
I have a standard field which is look up to contact object and i want to show only contact record but it is showing also account record.So how can i achieve the criteria by the lwc component.Please help me on this.
-
- Krishna Sahu 1
- April 20, 2022
- Like
- 0
Portal user must have an role i am getting this error while exceuting mt test class please help me on this
@isTest
private static void VerifyPopulatePhysicianOnCareTeam(){
User adminUser = [Select Id, UserRoleId From User Where Profile.Name='System Administrator' AND isActive = true Limit 1];
System.runAs(adminUser){
Test.startTest();
Account businessAccount = TestUtility.createAccounts(1, 'Test', false)[0];
businessAccount.Type = 'Customer';
insert businessAccount;
List<Account> listPersonAccount = TestUtility.createPatientAccounts(1, 'Patient Account', true);
Id RecordTypeIdValue =SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Provider').getRecordTypeId();
Contact physicianContact = new Contact(LastName = 'physician Contact', AccountId = businessAccount.Id , RecordTypeId = RecordTypeIdValue);
insert physicianContact;
User user = new User();
user.ProfileID = [Select Id From Profile Where Profile.Name='Ext. Physician'].Id;
user.EmailEncodingKey = 'ISO-8859-1';
user.LanguageLocaleKey = 'en_US';
user.TimeZoneSidKey = 'America/New_York';
user.LocaleSidKey = 'en_US';
user.FirstName = 'first';
user.LastName = 'last';
user.Username = 'test@edomain.com';
user.CommunityNickname = 'testUser123';
user.Alias = 't1';
user.Email = 'no@email.com';
user.UserRoleId = 'US - Finance';
user.IsActive = true;
user.ContactId = physicianContact.Id;
insert user;
Order orderObj = new Order();
orderObj.EffectiveDate = system.today();
orderObj.EndDate = system.today() + 4;
orderObj.AccountId = businessAccount.Id;
orderObj.patient_account__c=listPersonAccount[0].Id;
orderObj.Implanting_physician__c=user.ContactId;
orderObj.Type='NROT';
insert orderObj;
Test.stopTest();
List<CareTeam__c> objCareTeam = [SELECT Id, Name, Member__r.ContactId, Patient__c
FROM CareTeam__c
WHERE Patient__c =: orderObj.patient_account__c LIMIT 1];
System.assertEquals(objCareTeam[0].Member__r.ContactId, orderObj.implanting_physician__c);
}
}
private static void VerifyPopulatePhysicianOnCareTeam(){
User adminUser = [Select Id, UserRoleId From User Where Profile.Name='System Administrator' AND isActive = true Limit 1];
System.runAs(adminUser){
Test.startTest();
Account businessAccount = TestUtility.createAccounts(1, 'Test', false)[0];
businessAccount.Type = 'Customer';
insert businessAccount;
List<Account> listPersonAccount = TestUtility.createPatientAccounts(1, 'Patient Account', true);
Id RecordTypeIdValue =SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Provider').getRecordTypeId();
Contact physicianContact = new Contact(LastName = 'physician Contact', AccountId = businessAccount.Id , RecordTypeId = RecordTypeIdValue);
insert physicianContact;
User user = new User();
user.ProfileID = [Select Id From Profile Where Profile.Name='Ext. Physician'].Id;
user.EmailEncodingKey = 'ISO-8859-1';
user.LanguageLocaleKey = 'en_US';
user.TimeZoneSidKey = 'America/New_York';
user.LocaleSidKey = 'en_US';
user.FirstName = 'first';
user.LastName = 'last';
user.Username = 'test@edomain.com';
user.CommunityNickname = 'testUser123';
user.Alias = 't1';
user.Email = 'no@email.com';
user.UserRoleId = 'US - Finance';
user.IsActive = true;
user.ContactId = physicianContact.Id;
insert user;
Order orderObj = new Order();
orderObj.EffectiveDate = system.today();
orderObj.EndDate = system.today() + 4;
orderObj.AccountId = businessAccount.Id;
orderObj.patient_account__c=listPersonAccount[0].Id;
orderObj.Implanting_physician__c=user.ContactId;
orderObj.Type='NROT';
insert orderObj;
Test.stopTest();
List<CareTeam__c> objCareTeam = [SELECT Id, Name, Member__r.ContactId, Patient__c
FROM CareTeam__c
WHERE Patient__c =: orderObj.patient_account__c LIMIT 1];
System.assertEquals(objCareTeam[0].Member__r.ContactId, orderObj.implanting_physician__c);
}
}
- Krishna Sahu 1
- August 04, 2022
- Like
- 0
Is it somting wron this
<template if:true = {trialFollowUpCareCoordinator}>
<c-lwc-lookup-component
object-api-name="User"
icon-name="standard:user"
lookup-label = "User"
onerror={showError}
filter="Profile.Name= 'Sales Representative' OR Profile.Name= 'Remote Care Team'"
onrecordselection = {updateSelectedUser}
>
</c-lwc-lookup-component>
</template>
<c-lwc-lookup-component
object-api-name="User"
icon-name="standard:user"
lookup-label = "User"
onerror={showError}
filter="Profile.Name= 'Sales Representative' OR Profile.Name= 'Remote Care Team'"
onrecordselection = {updateSelectedUser}
>
</c-lwc-lookup-component>
</template>
- Krishna Sahu 1
- July 26, 2022
- Like
- 0
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;
}
}
- Krishna Sahu 1
- July 14, 2022
- Like
- 0
Need help to write test class on the classs
public static void leadConversion(List<flowInputs> leadIdSet){
System.debug('This is the lead Id from Convert Lead Flow===>'+leadIdSet[0]);
Map<Id, Case> mapCases = new Map<Id, Case>();
List<CaseTeamMember> listCaseTeamMember = new List<CaseTeamMember>();
List<Database.LeadConvert> leadsToConvert = new List<Database.LeadConvert>();
for(Id leadId: leadIdSet[0].ids){
Database.LeadConvert newConvertLead = new Database.LeadConvert();
newConvertLead.setLeadId(leadId);
newConvertLead.setDoNotCreateOpportunity(true);
newConvertLead.setConvertedStatus(leadConvertedStatus);
leadsToConvert.add(newConvertLead);
}
if(!leadsToConvert.isEmpty())
{
List<Database.LeadConvertResult> convertResult = Database.convertLead(leadsToConvert);
CaseTeamRole caseTeamRole = [SELECT Id,Name FROM CaseTeamRole WHERE Name ='Care Coordinator' LIMIT 1];
Set<Id> setAccountIds = new Set<Id>();
Map<Id, Id> mapAccountIdToContactId = new Map<Id, Id>();
for(Database.LeadConvertResult convertedLead : convertResult)
{
mapAccountIdToContactId.put(convertedLead.getAccountId(), convertedLead.getContactId());
}
Map<Id, Account> mapAccounts = new Map<Id, Account>([SELECT Id, OwnerId,
sales_representative__c, Name
FROM Account
WHERE Id IN :mapAccountIdToContactId.keyset() AND sales_representative__c !=null]);
if(!mapAccounts.isEmpty())
{
for(Account accountRecord : mapAccounts.values())
{
if(accountRecord.OwnerId != null && accountRecord.Name !=null)
{
mapCases.put(accountRecord.Id, new Case(OwnerId = accountRecord.OwnerId,
ContactId = mapAccountIdToContactId.get(accountRecord.Id),
AccountId = accountRecord.Id,
Status = 'New',
Subject = accountRecord.Name+' Care Plan'));
}
}
insert mapCases.values();
List<CaseTeamMember> lstCareTeamMembers = new List<CaseTeamMember>();
for(Case objCase : mapCases.values())
{
lstCareTeamMembers.add(new CaseTeamMember(ParentId = objCase.Id,
MemberId = mapAccounts.get(objCase.AccountId).sales_representative__c,
TeamRoleId = caseTeamRole.Id));
}
insert lstCareTeamMembers;
}
}
System.debug('This is the lead Id from Convert Lead Flow===>'+leadIdSet[0]);
Map<Id, Case> mapCases = new Map<Id, Case>();
List<CaseTeamMember> listCaseTeamMember = new List<CaseTeamMember>();
List<Database.LeadConvert> leadsToConvert = new List<Database.LeadConvert>();
for(Id leadId: leadIdSet[0].ids){
Database.LeadConvert newConvertLead = new Database.LeadConvert();
newConvertLead.setLeadId(leadId);
newConvertLead.setDoNotCreateOpportunity(true);
newConvertLead.setConvertedStatus(leadConvertedStatus);
leadsToConvert.add(newConvertLead);
}
if(!leadsToConvert.isEmpty())
{
List<Database.LeadConvertResult> convertResult = Database.convertLead(leadsToConvert);
CaseTeamRole caseTeamRole = [SELECT Id,Name FROM CaseTeamRole WHERE Name ='Care Coordinator' LIMIT 1];
Set<Id> setAccountIds = new Set<Id>();
Map<Id, Id> mapAccountIdToContactId = new Map<Id, Id>();
for(Database.LeadConvertResult convertedLead : convertResult)
{
mapAccountIdToContactId.put(convertedLead.getAccountId(), convertedLead.getContactId());
}
Map<Id, Account> mapAccounts = new Map<Id, Account>([SELECT Id, OwnerId,
sales_representative__c, Name
FROM Account
WHERE Id IN :mapAccountIdToContactId.keyset() AND sales_representative__c !=null]);
if(!mapAccounts.isEmpty())
{
for(Account accountRecord : mapAccounts.values())
{
if(accountRecord.OwnerId != null && accountRecord.Name !=null)
{
mapCases.put(accountRecord.Id, new Case(OwnerId = accountRecord.OwnerId,
ContactId = mapAccountIdToContactId.get(accountRecord.Id),
AccountId = accountRecord.Id,
Status = 'New',
Subject = accountRecord.Name+' Care Plan'));
}
}
insert mapCases.values();
List<CaseTeamMember> lstCareTeamMembers = new List<CaseTeamMember>();
for(Case objCase : mapCases.values())
{
lstCareTeamMembers.add(new CaseTeamMember(ParentId = objCase.Id,
MemberId = mapAccounts.get(objCase.AccountId).sales_representative__c,
TeamRoleId = caseTeamRole.Id));
}
insert lstCareTeamMembers;
}
}
- Krishna Sahu 1
- June 24, 2022
- Like
- 0
Taslk is not creating
/**
* @description : Prior auth procedure service class
* @author : Rialtes Dev Team
* @last modified on : 06-01-2022
* @last modified by : Rialtes Dev Team
**/
public inherited sharing class PriorAuthProcedureCodeService
{
/**
* @description : These method fetch all the details of the procedure codes
* @author Rialtes Dev Team
* @param PriorAuthWrapper objPriorAuthWrapper
**/
public static Map<String, List<ProcedureCode>> getProcedureCodes(PriorAuthWrapper objPriorAuthWrapper)
{
Map<String, List<ProcedureCode>> mapKeyToProcedureCodes = new Map<String, List<ProcedureCode>>();
Map<Id, Procedure_Code__c> mapMasterToProcedureCode = new Map<Id, Procedure_Code__c>();
String type = (objPriorAuthWrapper.serviceRequestType == Label.JOURNEY_STAGE_TRIAL_PRIOR_AUTH ? Label.JOURNEY_STAGE_PERMANENT_PRIOR_AUTH : Label.JOURNEY_STAGE_TRIAL_PRIOR_AUTH) + ' Procedure';
if(objPriorAuthWrapper.recordId != null)
{
for(Procedure_Code__c objProcedureCode : [SELECT Id, units__c,
procedure_code_master_data__c,
procedure_code_master_data__r.description__c,
procedure_code_master_data__r.Name,
procedure_code_master_data__r.type__c
FROM Procedure_Code__c
WHERE procedure_code_master_data__r.type__c != :type
AND prior_authorization__c =: objPriorAuthWrapper.recordId])
{
mapMasterToProcedureCode.put(objProcedureCode.procedure_code_master_data__c, objProcedureCode);
}
}
for(Procedure_Code_Master_Data__c objProcedureCodeMaster : [SELECT Id, description__c,
type__c, Name
FROM Procedure_Code_Master_Data__c
WHERE type__c != :type
AND Enabled__c = true])
{
ProcedureCode objProcedure = new ProcedureCode(null, objProcedureCodeMaster.Id, objProcedureCodeMaster.Name, objProcedureCodeMaster.description__c, null);
if(!mapKeyToProcedureCodes.containsKey(objProcedureCodeMaster.type__c))
{
mapKeyToProcedureCodes.put(objProcedureCodeMaster.type__c, new List<ProcedureCode>{objProcedure});
}
else
{
mapKeyToProcedureCodes.get(objProcedureCodeMaster.type__c).add(objProcedure);
}
}
for(String key : mapKeyToProcedureCodes.keyset())
{
List<ProcedureCode> lstProcedures = new List<ProcedureCode>();
for(ProcedureCode objProcedure : mapKeyToProcedureCodes.get(key))
{
if(mapMasterToProcedureCode.containsKey(objProcedure.procedureMasterCode))
{
objProcedure.procedureCodeId = mapMasterToProcedureCode.get(objProcedure.procedureMasterCode).Id;
objProcedure.units = mapMasterToProcedureCode.get(objProcedure.procedureMasterCode).units__c;
}
lstProcedures.add(objProcedure);
}
mapKeyToProcedureCodes.put(key, lstProcedures);
}
return mapKeyToProcedureCodes;
}
/**
* @description : These method upsert all the details of the procedure codes
* @author Rialtes Dev Team
* @param PriorAuthWrapper objPriorAuthWrapper
* @param CareRequest objCareRequest
**/
public static void saveProcedureCodes(PriorAuthWrapper objPriorAuthWrapper, CareRequest objCareRequest)
{
List<Procedure_Code__c> lstProcedureCodes = new List<Procedure_Code__c>();
if(objPriorAuthWrapper.lstTrialProcedureCodes != null && objPriorAuthWrapper.serviceRequestType == 'Trial')
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstTrialProcedureCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstPermanentProcedureCodes != null && objPriorAuthWrapper.serviceRequestType == 'Permanent')
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstPermanentProcedureCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstRevisionOrRemovalCodes != null)
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstRevisionOrRemovalCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstSCSAnalysisProgramming != null)
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstSCSAnalysisProgramming)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
upsert lstProcedureCodes;
}
}
* @description : Prior auth procedure service class
* @author : Rialtes Dev Team
* @last modified on : 06-01-2022
* @last modified by : Rialtes Dev Team
**/
public inherited sharing class PriorAuthProcedureCodeService
{
/**
* @description : These method fetch all the details of the procedure codes
* @author Rialtes Dev Team
* @param PriorAuthWrapper objPriorAuthWrapper
**/
public static Map<String, List<ProcedureCode>> getProcedureCodes(PriorAuthWrapper objPriorAuthWrapper)
{
Map<String, List<ProcedureCode>> mapKeyToProcedureCodes = new Map<String, List<ProcedureCode>>();
Map<Id, Procedure_Code__c> mapMasterToProcedureCode = new Map<Id, Procedure_Code__c>();
String type = (objPriorAuthWrapper.serviceRequestType == Label.JOURNEY_STAGE_TRIAL_PRIOR_AUTH ? Label.JOURNEY_STAGE_PERMANENT_PRIOR_AUTH : Label.JOURNEY_STAGE_TRIAL_PRIOR_AUTH) + ' Procedure';
if(objPriorAuthWrapper.recordId != null)
{
for(Procedure_Code__c objProcedureCode : [SELECT Id, units__c,
procedure_code_master_data__c,
procedure_code_master_data__r.description__c,
procedure_code_master_data__r.Name,
procedure_code_master_data__r.type__c
FROM Procedure_Code__c
WHERE procedure_code_master_data__r.type__c != :type
AND prior_authorization__c =: objPriorAuthWrapper.recordId])
{
mapMasterToProcedureCode.put(objProcedureCode.procedure_code_master_data__c, objProcedureCode);
}
}
for(Procedure_Code_Master_Data__c objProcedureCodeMaster : [SELECT Id, description__c,
type__c, Name
FROM Procedure_Code_Master_Data__c
WHERE type__c != :type
AND Enabled__c = true])
{
ProcedureCode objProcedure = new ProcedureCode(null, objProcedureCodeMaster.Id, objProcedureCodeMaster.Name, objProcedureCodeMaster.description__c, null);
if(!mapKeyToProcedureCodes.containsKey(objProcedureCodeMaster.type__c))
{
mapKeyToProcedureCodes.put(objProcedureCodeMaster.type__c, new List<ProcedureCode>{objProcedure});
}
else
{
mapKeyToProcedureCodes.get(objProcedureCodeMaster.type__c).add(objProcedure);
}
}
for(String key : mapKeyToProcedureCodes.keyset())
{
List<ProcedureCode> lstProcedures = new List<ProcedureCode>();
for(ProcedureCode objProcedure : mapKeyToProcedureCodes.get(key))
{
if(mapMasterToProcedureCode.containsKey(objProcedure.procedureMasterCode))
{
objProcedure.procedureCodeId = mapMasterToProcedureCode.get(objProcedure.procedureMasterCode).Id;
objProcedure.units = mapMasterToProcedureCode.get(objProcedure.procedureMasterCode).units__c;
}
lstProcedures.add(objProcedure);
}
mapKeyToProcedureCodes.put(key, lstProcedures);
}
return mapKeyToProcedureCodes;
}
/**
* @description : These method upsert all the details of the procedure codes
* @author Rialtes Dev Team
* @param PriorAuthWrapper objPriorAuthWrapper
* @param CareRequest objCareRequest
**/
public static void saveProcedureCodes(PriorAuthWrapper objPriorAuthWrapper, CareRequest objCareRequest)
{
List<Procedure_Code__c> lstProcedureCodes = new List<Procedure_Code__c>();
if(objPriorAuthWrapper.lstTrialProcedureCodes != null && objPriorAuthWrapper.serviceRequestType == 'Trial')
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstTrialProcedureCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstPermanentProcedureCodes != null && objPriorAuthWrapper.serviceRequestType == 'Permanent')
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstPermanentProcedureCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstRevisionOrRemovalCodes != null)
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstRevisionOrRemovalCodes)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
if(objPriorAuthWrapper.lstSCSAnalysisProgramming != null)
{
for(ProcedureCode objProcedureCode : objPriorAuthWrapper.lstSCSAnalysisProgramming)
{
lstProcedureCodes.add(new Procedure_Code__c(Id = objProcedureCode.procedureCodeId,
prior_authorization__c = objCareRequest.Id,
procedure_code_master_data__c = objProcedureCode.procedureMasterCode,
units__c = objProcedureCode.units));
}
}
upsert lstProcedureCodes;
}
}
- Krishna Sahu 1
- June 01, 2022
- Like
- 0
Need help to write test class on that
public inherited sharing class ProcedureCode
{
@AuraEnabled
public String procedureCodeId;
@AuraEnabled
public String procedureMasterCode;
@AuraEnabled
public String cptCode;
@AuraEnabled
public String description;
@AuraEnabled
public Decimal units;
public ProcedureCode(String procedureCodeId, String procedureMasterCode, String cptCode, String description, Decimal units)
{
this.procedureCodeId = this.procedureCodeId;
this.procedureMasterCode = procedureMasterCode;
this.cptCode = cptCode;
this.description = description;
this.units = units;
}
}
{
@AuraEnabled
public String procedureCodeId;
@AuraEnabled
public String procedureMasterCode;
@AuraEnabled
public String cptCode;
@AuraEnabled
public String description;
@AuraEnabled
public Decimal units;
public ProcedureCode(String procedureCodeId, String procedureMasterCode, String cptCode, String description, Decimal units)
{
this.procedureCodeId = this.procedureCodeId;
this.procedureMasterCode = procedureMasterCode;
this.cptCode = cptCode;
this.description = description;
this.units = units;
}
}
- Krishna Sahu 1
- June 01, 2022
- Like
- 0
Please help to write test class on after update trigger
public static void mapBirthdayFieldsOnEducationSession(map<Id,Lead> newLeadMap, map<Id,Lead> oldLeadMap){
map<Id,Lead> newConvertedIdMap = new map<Id,Lead>();
for(Lead listLead : newLeadMap.values()){
if(listLead.isConverted && listLead.ConvertedAccountId !=null && listLead.HealthCloudGA__BirthDate__c !=null){
newConvertedIdMap.put(listLead.ConvertedAccountId,listLead );
}
}
if(!newConvertedIdMap.isEmpty()){
List<Account> listAccount = [SELECT Id , PersonBirthdate FROM Account WHERE Id IN : newConvertedIdMap.keySet()];
for(Account account : listAccount){
Account.PersonBirthdate = newConvertedIdMap.get(account.Id).HealthCloudGA__BirthDate__c;
}
update listAccount ;
}
}
map<Id,Lead> newConvertedIdMap = new map<Id,Lead>();
for(Lead listLead : newLeadMap.values()){
if(listLead.isConverted && listLead.ConvertedAccountId !=null && listLead.HealthCloudGA__BirthDate__c !=null){
newConvertedIdMap.put(listLead.ConvertedAccountId,listLead );
}
}
if(!newConvertedIdMap.isEmpty()){
List<Account> listAccount = [SELECT Id , PersonBirthdate FROM Account WHERE Id IN : newConvertedIdMap.keySet()];
for(Account account : listAccount){
Account.PersonBirthdate = newConvertedIdMap.get(account.Id).HealthCloudGA__BirthDate__c;
}
update listAccount ;
}
}
- Krishna Sahu 1
- April 28, 2022
- Like
- 0
Write a trigger to map filed.
I need your help in one scenerio like i have two object Lead and Account.
i create a lead and add values on fields and after that i convert that lead into account.But when i open account record so one field Email value is empty on account object so i need to write trigger ot that field please help me on this.
i create a lead and add values on fields and after that i convert that lead into account.But when i open account record so one field Email value is empty on account object so i need to write trigger ot that field please help me on this.
- Krishna Sahu 1
- April 28, 2022
- Like
- 0
Please help me to solve the code to cover all the code
Set<Id> setInvalidWhatIdRecordTypes = new Set<Id>();
Set<Id> setWhatIds = new Set<Id>();
for(Event objEvent : listEvents)
{
if(objEvent.WhatId != null){
setWhatIds.add(objEvent.WhatId);
}
}
for(Account acc : [SELECT Id
FROM Account
WHERE Id IN : setWhatIds
AND RecordType.DeveloperName != 'IndustriesBusiness']){
setInvalidWhatIdRecordTypes.add(acc.Id);
}
if(!setInvalidWhatIdRecordTypes.isEmpty())
{
for(Event objEvent : listEvents)
{
if(objEvent.whatId != null && setInvalidWhatIdRecordTypes.contains(objEvent.whatId))
{
objEvent.WhatId.addError('Account record type can only be business.');
}
}
}
}
Set<Id> setWhatIds = new Set<Id>();
for(Event objEvent : listEvents)
{
if(objEvent.WhatId != null){
setWhatIds.add(objEvent.WhatId);
}
}
for(Account acc : [SELECT Id
FROM Account
WHERE Id IN : setWhatIds
AND RecordType.DeveloperName != 'IndustriesBusiness']){
setInvalidWhatIdRecordTypes.add(acc.Id);
}
if(!setInvalidWhatIdRecordTypes.isEmpty())
{
for(Event objEvent : listEvents)
{
if(objEvent.whatId != null && setInvalidWhatIdRecordTypes.contains(objEvent.whatId))
{
objEvent.WhatId.addError('Account record type can only be business.');
}
}
}
}
- Krishna Sahu 1
- April 21, 2022
- Like
- 0
How to restrict field to show other recordtypes record
I want to restrict a field to show only one recordtype record by trigger.
- Krishna Sahu 1
- April 20, 2022
- Like
- 0
I want to update parent account object picklist field when child education field is update as completed
public static void updateJourneyStatus(Map<Id,Education_Request__c> newMap, Map<Id,Education_Request__c> oldMap){
Map < Id, Education_Request__c > mapAccount = new Map < Id, Education_Request__c >();
List < Account > listAccount = new List< Account >();
for ( Education_Request__c acct : newMap.values() ) {
if (acct.education_status__c != oldMap.get( acct.Id ).education_status__c && acct.education_status__c=='Completed'){
mapAccount.put( acct.Id, acct );
}
if ( !mapAccount.isEmpty() ) {
for ( Education_Request__c edRequest : mapAccount.values() ) {
if(edRequest.education_status__c=='Completed'){
Account acc=new Account();
acc.Name=edRequest.Id;
acc.journey_stage__c='Psych Evaluation';
listAccount.add(acc);
}
}
update listAccount;
}
}
}
Map < Id, Education_Request__c > mapAccount = new Map < Id, Education_Request__c >();
List < Account > listAccount = new List< Account >();
for ( Education_Request__c acct : newMap.values() ) {
if (acct.education_status__c != oldMap.get( acct.Id ).education_status__c && acct.education_status__c=='Completed'){
mapAccount.put( acct.Id, acct );
}
if ( !mapAccount.isEmpty() ) {
for ( Education_Request__c edRequest : mapAccount.values() ) {
if(edRequest.education_status__c=='Completed'){
Account acc=new Account();
acc.Name=edRequest.Id;
acc.journey_stage__c='Psych Evaluation';
listAccount.add(acc);
}
}
update listAccount;
}
}
}
- Krishna Sahu 1
- April 11, 2022
- Like
- 0