/*
 * Author: 	Zhang,Heyang
 * Created Date: 06/01/2023
 * Purpose: get page layout and record data
 * Test Class: LexNewAndEditReportPIPLControllerTest
 *
 * */
public with sharing class LexNewAndEditReportPIPLController {
    @AuraEnabled
    public static ResponseBodyLWC initData(Id rid, String recordTypeId, String sobjectType) {
        Map<String, object> data = new Map<String, object>();
        ResponseBodyLWC rbl = LexNewAndEditBasePIPLController.initData(rid, recordTypeId, sobjectType);
        if(rbl.status == 'Success'){
            data = (Map<String,Object>)rbl.entity;
            data.put('staticResourceContact', Json.serialize(PIHelper.getPIIntegrationInfo('Contact')));
            if(String.isNotBlank(rid)){
                String sql = 'SELECT Practitioner1__r.LastName,Practitioner2__r.LastName,Practitioner3__r.LastName,Practitioner4__r.LastName,Person_In_Charge__r.LastName,HospitalAcceptancePerson__r.LastName,Practitioner1__r.AWS_Data_Id__c,Practitioner2__r.AWS_Data_Id__c,Practitioner3__r.AWS_Data_Id__c,Practitioner4__r.AWS_Data_Id__c,Person_In_Charge__r.AWS_Data_Id__c,HospitalAcceptancePerson__r.AWS_Data_Id__c,Daily_Report__r.Name, ';
                DescribeSObjectResult objectType = rid.getSobjectType().getDescribe();
                List<String> objectFields = new List<String>(objectType.fields.getMap().keySet());
                sql += String.join(objectFields, ',') +' from '+sobjectType+' where id =\''+rid+'\' limit 1';
                System.debug('sql: ' + sql);
                Sobject leadData = Database.query(sql);
                data.put('data',leadData);
            }

            rbl.entity = data;
        }
        return rbl;
    }

    @AuraEnabled
    public static ResponseBodyLWC queryAccount(String accountTypes, String accountId) {
        ResponseBodyLWC rbl = LexNewAndEditBasePIPLController.queryAccount(accountTypes, accountId);
        return rbl;
    }

    @AuraEnabled
    public static ResponseBodyLWC searchContactInit(String accountId, String searchKeyWord) {
        ResponseBodyLWC rbl = LexNewAndEditBasePIPLController.searchContactInit(accountId, searchKeyWord);
        return rbl;
    }

    public void testMock(){ 
        Integer i = 0;
		i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
     
    }

}