1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
@isTest
public with sharing class buttonOnCallCtlTest {
    public buttonOnCallCtlTest() {
 
    }
    @IsTest 
    static void testAccountDelayApply(){
        
        // List<Account> HP = [select Id from Account where RecordTypeId = '01210000000QemGAAS' and Is_Active__c = '有効' limit 1];//    病院
        String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        String rectDpt = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId();
        Address_Level__c al = new Address_Level__c();
        al.Name = '東京';
        al.Level1_Code__c = 'CN-99';
        al.Level1_Sys_No__c = '999999';
        insert al;
        // 市
        Address_Level2__c al2 = new Address_Level2__c();
        al2.Level1_Code__c = 'CN-99';
        al2.Level1_Sys_No__c = '999999';
        al2.Level1_Name__c = '東京';
        al2.Name = '渋谷区';
        al2.Level2_Code__c = 'CN-9999';
        al2.Level2_Sys_No__c = '9999999';
        al2.Address_Level__c = al.id;
        insert al2;
 
        // 病院を作る
        Account HP = new Account();
        HP.recordtypeId = rectHp;
        HP.Name = 'test hospital';
        HP.Is_Active__c = '有効';
        HP.Attribute_Type__c = '卫生部';
        HP.Speciality_Type__c = '综合医院';
        HP.Grade__c = '一级';
        HP.OCM_Category__c = 'SLTV';
        HP.Is_Medical__c = '医疗机构';
        HP.State_Master__c = al.id;
        HP.City_Master__c = al2.id;
        HP.Town__c = '东京';
        insert HP;
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
 
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        // List<On_Call__c> oncall = [select Id from On_Call__c limit 1];//    oncall
        Account hospital = new Account(RecordTypeId = rectHp, Name = 'hp', OwnerId = hpOwner.Id);
        hospital.FSE_GI_Main_Leader__c = hpOwner.Id;
        hospital.FSE_SP_Main_Leader__c = hpOwner2.Id;
        insert hospital;
 
        Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hospital.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
        
        // 診療科を作る
        Account dpt = new Account(RecordTypeId = rectDpt);
        dpt.Name         = '*';
        dpt.Department_Name__c  = 'TestDepart';
        dpt.ParentId            = dc.Id;
        dpt.Department_Class__c = dc.Id;
        dpt.Hospital__c         = hospital.Id;
        insert dpt;
        On_Call__c onCall = new On_Call__c();
        onCall.segment__c = dpt.Id;
        onCall.Hospital__c = hospital.Id;
        insert onCall;
        String timenow = Datetime.now().format('yyyyMMddHHmmss');
        List<User> user = [SELECT Id FROM User limit 1];
        buttonOnCallCtl.init(oncall.Id);
        buttonOnCallCtl.selecctAccountBySegmentId(HP.Id);
        buttonOnCallCtl.selecctAccountBySegmentId02(HP.Id);
        buttonOnCallCtl.initUserName(user[0].Id);
 
        buttonOnCallCtl.init('');
        buttonOnCallCtl.selecctAccountBySegmentId('');
        buttonOnCallCtl.selecctAccountBySegmentId02('');
        buttonOnCallCtl.initUserName('');
    }
}