liuyan
2022-11-24 8badb57ea2c82557850ad5b39281c3e8714eb119
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
@isTest
public with sharing class NFM624RestAboutTest {
        static testMethod void testMethod4(){
        oly_TriggerHandler.bypass('ContactTriggerHandler');
        //用户
        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 = '00e10000000xnp2');
        insert hpowner;
 
        User hpowner2 = new User(Test_staff__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp1', Work_Location__c = '北京', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner1@sunbridge.com', Username = 'olympus_hpowner1@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = '00e10000000xnp2');
        insert hpowner2;
        
        //医院
        Account hp = new Account(RecordTypeId = '01210000000QemG', Name = '北京德胜门中医院', OwnerId = hpOwner.Id);
        hp.FSE_GI_Main_Leader__c = hpOwner.Id;
        hp.Advance_Payment_Identification_Approval__c = Date.today().addyears(-1);
        hp.AgentCode_Ext__c = '112358';
        hp.PlatformCode__c = '1375';
        hp.Is_Active__c = '有効';
        insert hp;
        
 
        Account hptemp = [select Id,PlatformCode__c,AgentCode_Ext__c,Is_Active_Formula__c from Account where Id = :hp.Id];
        
        // 戦略科室を得る
        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hp.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
        // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
        dep.Name = 'test dep';
        dep.AgentCode_Ext__c = '9999998';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hp.Id;
        insert dep;
 
        //联系人
        Contact contact2 = new Contact();
        contact2.AccountId = dep.Id;
        contact2.FirstName = '責任者';
        contact2.LastName = 'test1经销商';
        contact2.LastName_Encrypted__c ='24616254c7c7b65d985567f475b667d7';
        insert contact2;
 
        NFM624Rest.GeData GeData1 = new NFM624Rest.GeData();
        NFM624Rest.GeDatas GaDatas = new  NFM624Rest.GeDatas();
 
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        GaDatas.Monitoring = new NFMUtil.Monitoring();
        GaDatas.Monitoring.MessageGroupNumber = nowStr + '01';
        //有医院没有科室没有人员管理编码——>新建科室+新建联系人
        // GaDatas.GeData = new NFM624Rest.Gedata[] { GeData1 };
        // GeData1.ContactId = '958432058911227904';
        // GeData1.ServiceUserId = '958432058911227904';
        // GeData1.PersonManagementCode = '';
        // GeData1.HospitalManagementCode2 = '1375';
        // GeData1.DepartmentManagementCode2 = '1376';
        // GeData1.Name = '***';
        // GeData1.NameEncrypted = '24616254c7c7b65d985567f475b667d7';
        // GeData1.Mobile = '***********';
        // GeData1.MobileEncrypted = 'c34725fe79b3965ea9abfd7c1435cf9a';
        // GeData1.State = '北京市';
        // GeData1.City = '西城区';
        // GeData1.AccountName = '北京德胜门中医院';
        // GeData1.RelatedHospital = '112358';
        // GeData1.DepartmentClass = '消化科';
        // GeData1.DepartmentName = '北京德胜门中医院 消化科 胃镜室';
        // GeData1.RelatedDepartment = '5311053';
        // GeData1.Type = '*****';
        // GeData1.TypeEncrypted = '53173e61ac22874aab5b8d1f802515db';
        // GeData1.ContactAddress = '**********';
        // GeData1.ContactAddressEncrypted = '121a09fd9e0e9b090c4aa9c95da52810';
        // GeData1.ForbiddenStatus = false;
        // GeData1.RegSource = '1';
        // GeData1.AgentFlag = false;
        // GeData1.ApproverID = hpowner.Id;
        // GeData1.DataId = '958432058273693696';
       
        // BatchIF_Log__c rowData = NFMUtil.saveRowData(GaDatas.Monitoring, 'NFM624About', GaDatas.GeData);
        // if (String.isBlank(rowData.Log__c) == false)
        //     NFM624RestAbout.execute(rowData.Id);
        
 
 
        //有医院有有科室没有人员管理编码——>更新联系人
        NFM624Rest.GeData GeData3 = new NFM624Rest.GeData();
        GaDatas.GeData = new NFM624Rest.Gedata[] { GeData3 };
       // GeData3.ContactId = '958432058911227904';
        //GeData3.ServiceUserId = '958432058911227904';
        GeData3.PersonManagementCode = '';
        GeData3.HospitalManagementCode2 = '1375';
        GeData3.DepartmentManagementCode2 = '1376';
        //GeData3.Name = '***';
        GeData3.NameEncrypted = '24616254c7c7b65d985567f475b667d7';
        //GeData3.Mobile = '***********';
        //GeData3.MobileEncrypted = 'c34725fe79b3965ea9abfd7c1435cf9a';
        //GeData3.State = '北京市';
        //GeData3.City = '西城区';
        GeData3.AccountName = '北京德胜门中医院';
        GeData3.RelatedHospital = '112358';
        GeData3.DepartmentClass = '消化科';
        GeData3.DepartmentName = '北京德胜门中医院 消化科 胃镜室';
        GeData3.RelatedDepartment = '5311053';
        //GeData3.Type = '*****';
        //GeData3.TypeEncrypted = '53173e61ac22874aab5b8d1f802515db';
        //GeData3.ContactAddress = '**********';
        //GeData3.ContactAddressEncrypted = '121a09fd9e0e9b090c4aa9c95da52810';
        //GeData3.ForbiddenStatus = false;
        //GeData3.RegSource = '1';
        //GeData3.AgentFlag = false;
        //GeData3.ApproverID = hpowner.Id;
        GeData3.DataId = '958432058273693696';
        
        BatchIF_Log__c rowData3 = NFMUtil.saveRowData(GaDatas.Monitoring, 'NFM624About', GaDatas.GeData);
        if (String.isBlank(rowData3.Log__c) == false){
            NFM624RestAbout.executefuture(rowData3.Id);
        }
    }
 
    static testMethod void test_method_execute(){
        Test.startTest();
        
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
 
        String JsonMsg = '{"Monitoring":{"Tag":"MSGH","Sender":"SPO","Receiver":"SFDC","MessageType":"NFM624About","MessageGroupNumber":"20210000004695","NumberOfRecord":"4","TransmissionDateTime":"2022-05-19","Text":""},"GeData":[{"PersonManagementCode":"thhTest","HospitalManagementCode2":"thhTest","DepartmentManagementCode2":"thhTest","NameEncrypted":"thhTest","RelatedHospital":"thhTest","DepartmentClass":"thhTest","DepartmentName":"thhTest","RelatedDepartment":"thhTest","dataId":"thh121231345","AccountName":"thhTest","MobileEncrypted":"11223344"}]}';
        req.requestURI = 'services/apexrest/NFM624RestAbout/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;
 
        NFM624RestAbout.execute();
 
        Test.stopTest();
    }
}