Skip to content

Commit

Permalink
Changes related to Test class
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakmulamalla committed Nov 24, 2024
1 parent 348b25b commit e29046f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LightningElement } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import EDRD_label_SaveForLaterAcknowledge from '@salesforce/label/c.EDRD_label_SaveForLaterAcknowledge';
import EDRD_label_SaveForLaterAcknowledge_HelpText from '@salesforce/label/c.EDRD_label_SaveForLaterAcknowledge_HelpText';
import omniscriptSaveForLaterAcknowledge from 'omnistudio/omniscriptSaveForLaterAcknowledge';
Expand All @@ -11,16 +10,9 @@ export default class eDRD_lwc_customSaveforlater extends OmniscriptBaseMixin(omn
render() {
return tmpl;
}

handleRefresh(event) {
this[NavigationMixin.Navigate]({
type: 'comm__namedPage',
attributes: {
name: 'Home'
}
});
window.location.reload()
}

label = {
EDRD_label_SaveForLaterAcknowledge,
EDRD_label_SaveForLaterAcknowledge_HelpText
Expand Down
30 changes: 12 additions & 18 deletions force-app/main/default/classes/EDRDAccountLookupController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,19 @@ public with sharing class EDRDAccountLookupController{
@AuraEnabled(cacheable=false)
public static String getAccount(string actPHN){
Map<String, String> keyVsValueMap = new Map<String, string>{'ISPHNFOUND' => '', 'PHNDETAILS' => '', 'SFPHNDETAILS' => ''};
List<Account> accList = new List<Account>();
try{
Patient patientObj = Test.isRunningTest() ? mockPatient : EmpiIntegration.getPatient(actPHN);
If(patientObj.names != NULL){
keyVsValueMap.put('ISPHNFOUND', 'YES');
keyVsValueMap.put('PHNDETAILS', JSON.Serialize(patientObj));
}else If (!String.isBlank(actPHN) && patientObj.names == NULL){
string accountIdentificationNumber = actPHN ;
accList = [SELECT Id, Name,LastName,PersonContact.Birthdate,PersonBirthdate, PersonContact.Patient_Identifier__c, Patient_Identifier__pc
FROM Account WHERE PersonContact.Patient_Identifier__c LIKE :accountIdentificationNumber ORDER BY createdDate DESC LIMIT 5];
keyVsValueMap.put('ISPHNFOUND', 'NO');
if(!accList.IsEmpty()){
keyVsValueMap.put('SFPHNDETAILS', JSON.Serialize(accList.get(0)));

try{
Patient patientObj = Test.isRunningTest() ? mockPatient : EmpiIntegration.getPatient(actPHN);
If(patientObj.names != NULL){
keyVsValueMap.put('ISPHNFOUND', 'YES');
keyVsValueMap.put('PHNDETAILS', JSON.Serialize(patientObj));
}else If (!String.isBlank(actPHN) && patientObj.names == NULL){
string accountIdentificationNumber = actPHN ;
keyVsValueMap.put('ISPHNFOUND', 'NO');
}
}
} catch(exception ex){
system.debug('An error occurred: ' + ex.getMessage());
}
} catch(exception ex){
system.debug('An error occurred: ' + ex.getMessage());
}
return JSON.Serialize(keyVsValueMap);
}
/**
Expand Down Expand Up @@ -90,7 +85,6 @@ public with sharing class EDRDAccountLookupController{
}

soql += ' ORDER BY CreatedDate Desc LIMIT 10';
System.debug('soql'+ soql);

patients = Database.query(soql);
return patients;
Expand Down
43 changes: 21 additions & 22 deletions force-app/main/default/classes/EDRDAccountLookupController_Test.cls
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,21 @@ public class EDRDAccountLookupController_Test {
* @Modification Log: [Date] - [Change Reference] - [Changed By] - [Description]
16-Nov - EDRD-104 - Deepak - Changes related to EDRD EMPI Integration
*/
/*@isTest
@isTest
public static void testGetAccount() {
Id accountRecType = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Patient').getRecordTypeId();
Account testPatientAccount = new Account(
LastName = 'Test Patient Account',
Patient_Identifier__pc = '8910947511',
PersonBirthdate = Date.newInstance(2000, 1, 1),
RecordTypeId = accountRecType
);
insert testPatientAccount;
Patient mockPatient = new Patient();
mockPatient.phn = '1234567890';
EDRDAccountLookupController.mockPatient = mockPatient;

Test.startTest();
List<Account> result = EDRDAccountLookupController.getAccount('8910947511');
String sTR = EDRDAccountLookupController.getAccount('1234567890');
Map<String, Object> jsonMap = (Map<String, Object>) JSON.deserializeUntyped(sTR);
Test.stopTest();
Assert.areEqual(1, result.size(), 'Expected one account in the result list');
Account retrievedAccount = result[0];
Assert.areEqual('Test Patient Account', retrievedAccount.LastName, 'Unexpected Account Name');
Assert.areEqual('8910947511', retrievedAccount.Patient_Identifier__pc, 'Unexpected Contact Patient Identifier');
Assert.areEqual(Date.newInstance(2000, 1, 1), retrievedAccount.PersonBirthdate, 'Unexpected Contact Birthdate');
Assert.areNotEqual(testPatientAccount.Patient_Identifier__pc, 'DifferentValue', 'Expected different Contact Patient Identifier');
} */

Assert.areEqual(jsonMap.isEmpty(), false, 'Method has been failed');
Assert.areEqual(jsonMap.get('ISPHNFOUND'), 'NO', 'PHN is not match');
Assert.areNotEqual(jsonMap.isEmpty(), true, 'Method has null response');
}

/**
* @author: Suman
Expand Down Expand Up @@ -71,17 +66,20 @@ public class EDRDAccountLookupController_Test {
*/
@isTest
public static void searchPatientsTest(){
Account pntAccount = TestFactory.newPatient('Patient Test');
Account pntAccount = TestFactory.newPatient('Patient');
insert pntAccount;
Map<String, String> searchCriteria = new Map<String, String>{'patientIdentifier' => '222333444'};
Map<String, String> detailSearchCriteria = new Map<String, String>{'firstName' => 'Patient', 'lastName' => 'TestPatient', 'dOB' => '1990-01-01'};

Test.startTest();
List<Account> result = EDRDAccountLookupController.searchPatients(searchCriteria);
List<Account> pHNResult = EDRDAccountLookupController.searchPatients(searchCriteria);
List<Account> detailResult = EDRDAccountLookupController.searchPatients(detailSearchCriteria);
Test.stopTest();

Assert.areEqual(1, result.size(), 'Expected one patient record');
Account retrievedPatient = result[0];
Assert.areEqual('Patient Test', retrievedPatient.FirstName, 'Unexpected First Name');
Assert.areEqual(1, pHNResult.size(), 'Expected one patient record');
Assert.areEqual(1, detailResult.size(), 'Expected one patient record');
Account retrievedPatient = pHNResult[0];
Assert.areEqual('Patient', retrievedPatient.FirstName, 'Unexpected First Name');
Assert.areEqual('TestPatient', retrievedPatient.LastName, 'Unexpected Last Name');
Assert.areEqual('222333444', retrievedPatient.Patient_Identifier__pc, 'Unexpected Patient Identifier');
Assert.areNotEqual('WrongFirstName', retrievedPatient.FirstName, 'First Name should not match an incorrect value');
Expand All @@ -103,6 +101,7 @@ public class EDRDAccountLookupController_Test {
Test.startTest();
Boolean isValid = EDRDAccountLookupController.validatePatientIdentifier('222333444');
Boolean isInvalid = EDRDAccountLookupController.validatePatientIdentifier('INVALID_PID');
Boolean isBlank = EDRDAccountLookupController.validatePatientIdentifier('');
Test.stopTest();

Assert.areEqual(isValid, true, 'Expected the patient identifier to be valid');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<picklistValues>
<picklist>Committee_Name__pc</picklist>
<values>
<fullName>Cardiac Clinical Subcommittee</fullName>
<fullName>Cardiac Subcommittee</fullName>
<default>false</default>
</values>
<values>
<fullName>Cystic Fibrosis Mutation Subcommittee</fullName>
<fullName>Cystic Fibrosis Subcommittee</fullName>
<default>false</default>
</values>
<values>
Expand All @@ -31,7 +31,7 @@
<default>false</default>
</values>
<values>
<fullName>Neurological Disorders Subcommittee</fullName>
<fullName>Neurology Subcommittee</fullName>
<default>false</default>
</values>
<values>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@
<field>Case.EDRD_Patient_Meets_Criteria_for_SC__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Case.EDRD_Patient_Override_Reason__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Case.EDRD_Please_specify_other__c</field>
Expand Down

0 comments on commit e29046f

Please sign in to comment.