高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
global class Add_Report {
    // TODO reportのidで検索じゃなく、event_id__cで検索
    WebService static String addReportPr(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4,String visitor5, String description, String reportDate){
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
 
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, Comment__c from Report__c where id =:reportId];
            if (rList.size() > 0) {
                return rList.get(0).id;
            }
        }
 
        Report__c r = new Report__c();
 
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class_Ref__c = a.Department_Class__r.Id;
            r.Hospital_Reference__c = a.Hospital__r.Id;
        } else {
            r.Manual_Name__c = aId;
        }
 
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        r.Event_Id__c = eventId;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        if(visitor1 != null && visitor1 != ''){
            r.Practitioner1__c = visitor1;
        }
        if(visitor2 != null && visitor2 != ''){
            r.Practitioner2__c = visitor2;
        }
        if(visitor3 != null && visitor3 != ''){
            r.Practitioner3__c = visitor3;
        }
        if(visitor4 != null && visitor4 != ''){
            r.Practitioner4__c = visitor4;
        }
        if(visitor5 != null && visitor5 != ''){
            r.Practitioner5__c = visitor5;
        }
        r.Comment__c = description;
        upsert r;
 
        updateEvent(r.id,eventId,recordType);
 
        return r.id;
    }
 
    WebService static String addReportOP(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4, String visitor5, String opp1, String opp2, String opp3, String opp4, String opp5, String reportDate){
        return addReportOPWithEvaluationPDF(repOwnerId, reportId, dailyReportId, eventId, recordType, aId, visitor1, visitor2, visitor3, visitor4, visitor5, opp1, opp2, opp3, opp4, opp5, reportDate, '', '', '', '');
    }
    WebService static String addReportOP2(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4, String visitor5, String opp1, String opp2, String opp3, String opp4, String opp5, String reportDate, String sTime, String eTime){
        return addReportOPWithEvaluationPDF(repOwnerId, reportId, dailyReportId, eventId, recordType, aId, visitor1, visitor2, visitor3, visitor4, visitor5, opp1, opp2, opp3, opp4, opp5, reportDate, '', '', sTime, eTime);
    }
    WebService static String addReportOPWithEvaluationPDF(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4, String visitor5, String opp1, String opp2, String opp3, String opp4, String opp5, String reportDate, String evaluationPDFNumber, String pro1, String sTime, String eTime) {
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
 
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, Opportunity1__c, Opportunity2__c, Opportunity3__c, Opportunity4__c, Opportunity5__c from Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
 
        Report__c r = new Report__c();
        
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class_Ref__c = a.Department_Class__r.Id;
            r.Hospital_Reference__c = a.Hospital__r.Id;
        } else {
            r.Manual_Name__c = aId;
        }
 
        if (String.isBlank(dailyReportId) == false) r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        if (String.isBlank(eventId) == false) r.Event_Id__c = eventId;
        r.Evaluation_PDF_number__c = evaluationPDFNumber;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        if(visitor1 != null && visitor1 != ''){
            r.Practitioner1__c = visitor1;
        }
        if(visitor2 != null && visitor2 != ''){
            r.Practitioner2__c = visitor2;
        }
        if(visitor3 != null && visitor3 != ''){
            r.Practitioner3__c = visitor3;
        }
        if(visitor4 != null && visitor4 != ''){
            r.Practitioner4__c = visitor4;
        }
        if(visitor5 != null && visitor5 != ''){
            r.Practitioner5__c = visitor5;
        }
 
        List<String> oppIdList = new List<String>();
        if(opp1 != null && opp1 != ''){
            oppIdList.add(opp1);
        }
        if(opp2 != null && opp2 != ''){
            oppIdList.add(opp2);
        }
        if(opp3 != null && opp3 != ''){
            oppIdList.add(opp3);
        }
        if(opp4 != null && opp4 != ''){
            oppIdList.add(opp4);
        }
        if(opp5 != null && opp5 != ''){
            oppIdList.add(opp5);
        }
 
        if(oppIdList.size() > 0){
            if(opp1 != null && opp1 != ''){
                r.Opportunity1__c = opp1;
            }
            if(opp2 != null && opp2 != ''){
                r.Opportunity2__c = opp2;
            }
            if(opp3 != null && opp3 != ''){
                r.Opportunity3__c = opp3;
            }
            if(opp4 != null && opp4 != ''){
                r.Opportunity4__c = opp4;
            }
            if(opp5 != null && opp5 != ''){
                r.Opportunity5__c = opp5;
            }
            r.Opportunity_Situation__c = '引合発生';
        }
        else{
            r.Opportunity_Situation__c = '引合無';
        }
        
        if (String.isBlank(pro1) == false) {
            r.Product1__c = pro1;
        }
 
        if (sTime != null && sTime != '') {
            r.Operation_From__c = datetime.parse(sTime);
        }
        if (eTime != null && eTime != '') {
            r.Operation_To__c = datetime.parse(eTime);
        }
        upsert r;
 
        if (String.isBlank(eventId) == false) updateEvent(r.id,eventId,recordType);
 
        return r.id;
    }
 
    WebService static String addReportNT(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String visitor2, String visitor3, String visitor4, String visitor5, String sTime, String eTime, String mainPlace){
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
 
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, From__c, To__c, Location__c from Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
 
        Report__c r = new Report__c();
 
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class_Ref__c = a.Department_Class__r.Id;
            r.Hospital_Reference__c = a.Hospital__r.Id;
        } else {
            r.Manual_Name__c = aId;
        }
 
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        r.Event_Id__c = eventId;
        if(visitor1 != null && visitor1 != ''){
            r.Practitioner1__c = visitor1;
        }
        if(visitor2 != null && visitor2 != ''){
            r.Practitioner2__c = visitor2;
        }
        if(visitor3 != null && visitor3 != ''){
            r.Practitioner3__c = visitor3;
        }
        if(visitor4 != null && visitor4 != ''){
            r.Practitioner4__c = visitor4;
        }
        if(visitor5 != null && visitor5 != ''){
            r.Practitioner5__c = visitor5;
        }
        if(sTime != null && sTime != ''){
            //sTime = sTime.substring(0,16);
            r.From__c = datetime.parse(sTime);
        }
        if(eTime != null && eTime != ''){
            //eTime = eTime.substring(0,16);
            r.To__c = datetime.parse(eTime);
        }
        r.Location__c = mainPlace;
        upsert r;
 
        updateEvent(r.id,eventId,recordType);
 
        return r.id;
    }
 
    WebService static String addReportOn(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String v1Str, String startHour, String startMin, String endHour, String endMin, String description){
        List<Account> aList = selectAccount(aId);
 
        if(reportId != null && reportId != ''){
            List<On_Call__c> oList = [select id, Daily_Report__c, Event_Id__c, segment__c from On_Call__c where id =:reportId];
            if(oList.size() > 0){
                return oList.get(0).id;
            }
        }
        
        On_Call__c o = new On_Call__c();
        
        if(aList.size() != 0){
            Account a = aList.get(0);
            o.segment__c = a.Id;
            // 病院ID(18桁)差込み
            o.Hospital__c = a.Hospital__r.Id;
        }
 
        o.Daily_Report__c = dailyReportId;
        o.OwnerId = repOwnerId;
        o.Event_Id__c = eventId;
        o.Responsible_Person_HP__c = v1Str;
        if(String.isBlank(description) == false){
            if(description.length() > 255){
                o.Customer_Problem_c__c = description.substring(0, 255);
            } else {
                o.Customer_Problem_c__c = description;
            }
 
        }
        Date rDate = date.parse(reportDate);
        o.From_c__c = Datetime.newInstance(rDate.year(), rDate.month(), rDate.day(), Integer.valueOf(startHour), Integer.valueOf(StartMin), 0);
        o.To_c__c = Datetime.newInstance(rDate.year(), rDate.month(), rDate.day(), Integer.valueOf(endHour), Integer.valueOf(endMin), 0);
 
        upsert o;
        
        updateEvent(o.id,eventId,recordType);
        
        return o.id;
    }
    
    WebService static String addReportAc(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description){
        List<Account> aList = selectAccount(aId);
 
        if(reportId != null && reportId != ''){
            List<Visit_Report__c> rList = [select id, Daily_Report__c, Event_Id__c, Hospital_Reference__c, Department_Class__c, Department__c, Date__c from Visit_Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
 
        Visit_Report__c r = new Visit_Report__c();
 
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Reference__c = a.Hospital__r.Id;
            r.Department_Class__c = a.Department_Class__r.Id;
            r.Department__c = a.Id;
//        } else {
//            r.Manual_Name__c = aId;
        }
        
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.Event_Id__c = eventId;
        r.Evaluate_And_Problem__c = description;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
 
        upsert r;
 
        updateEvent(r.id,eventId,recordType);
 
        return r.id;
    }
    
    WebService static String addClaim(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description){
        List<Account> aList = selectAccount(aId);
 
        if(reportId != null && reportId != ''){
            List<QIS_Report__c> rList = [select id, Daily_Report__c, Event_Id__c, Hospital_Department__c, Date__c from QIS_Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
 
        QIS_Report__c r = new QIS_Report__c();
 
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class__c = a.Department_Class__r.Id;
            r.Hospital__c = a.Hospital__r.Id;
        }
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.Event_Id__c = eventId;
        //r.Department_Class_Ref__c = a.Department_Class__r.Id;
        //r.Hospital_Reference__c = a.Hospital__r.Id;
        r.problem_detail__c = description;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        r.Generation_Source__c = '日报';
        r.Name = '*';
 
        upsert r;
 
        updateEvent(r.id,eventId,recordType);
 
        return r.id;
    }
 
    // MarketCondition or Competitor
    WebService static String addReportEx(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String visitor1, String reportDate, String description){
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
 
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, Comment__c from Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
        Report__c r = new Report__c();
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Department__c = a.Id;
            r.Department_Class_Ref__c = a.Department_Class__r.Id;
            r.Hospital_Reference__c = a.Hospital__r.Id;
        }
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        r.Event_Id__c = eventId;
        if (String.isBlank(visitor1) == false) {
            r.Person_In_Charge__c = visitor1;
        }
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        r.Comment__c = description;
 
        upsert r;
 
        updateEvent(r.id,eventId,recordType);
 
        return r.id;
    }
 
 
    WebService static String addReportIm(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description){
        String rt = selectRecordType(recordType);
        List<Account> aList = selectAccount(aId);
 
        if(reportId != null && reportId != ''){
            List<Report__c> rList = [select id, Daily_Report__c, RecordTypeId, Event_Id__c, Hospital_Department__c, Department_Class_Ref__c, Hospital_Reference__c, Date__c, Practitioner1__c, Practitioner2__c, Practitioner3__c, Practitioner4__c, Practitioner5__c, Comment__c from Report__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
 
        Report__c r = new Report__c();
 
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital_Reference__c = a.Hospital__r.Id;
        }
 
        r.Daily_Report__c = dailyReportId;
        r.OwnerId = repOwnerId;
        r.RecordTypeId = rt;
        r.Event_Id__c = eventId;
        if(reportDate != null && reportDate != ''){
            r.Date__c = date.parse(reportDate);
        }
        r.Comment__c = description;
 
        upsert r;
 
        updateEvent(r.id,eventId,recordType);
 
        return r.id;
    }
 
//    // Maintenance_Contract
//    WebService static String addMC(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description){
//        List<Account> aList = selectAccount(aId);
//
//        if(reportId != null && reportId != ''){
//            List<Maintenance_Contract__c> rList = [select id, Daily_Report__c, Event_Id__c from Maintenance_Contract__c where id =:reportId];
//            if(rList.size() > 0){
//                return rList.get(0).id;
//            }
//        }
//
//        Maintenance_Contract__c r = new Maintenance_Contract__c();
//
//        if(aList.size() != 0){
//            Account a = aList.get(0);
//            r.Hospital__c = a.Hospital__r.Id;
//            r.Department_Class__c = a.Department_Class__r.Id;
//            r.Department__c = a.Id;
//        }
//        
//        r.Daily_Report__c = dailyReportId;
//        r.Event_Id__c = eventId;
//        r.Description__c = description;
////        if(reportDate != null && reportDate != ''){
////            r.Estimation_Create_Date__c = date.parse(reportDate);
////        }
//
//        upsert r;
//
//        updateEvent(r.id,eventId,recordType);
//
//        return r.id;
//    }
 
    // Rental_Apply
    WebService static String addRA(String repOwnerId, String reportId, String dailyReportId, String eventId, String recordType, String aId, String reportDate, String description,String followOpps){
        List<Account> aList = selectAccount(aId);
 
        if(reportId != null && reportId != ''){
            List<Rental_Apply__c> rList = [select id, Daily_Report__c, Event_Id__c from Rental_Apply__c where id =:reportId];
            if(rList.size() > 0){
                return rList.get(0).id;
            }
        }
 
        Rental_Apply__c r = new Rental_Apply__c();
 
        if(aList.size() != 0){
            Account a = aList.get(0);
            r.Hospital__c = a.Hospital__r.Id;
            r.Strategic_dept__c = a.Department_Class__r.Id;
            r.Account__c = a.Id;
        }
        
        r.Daily_Report__c = dailyReportId;
        r.Event_Id__c = eventId;
        r.Demo_purpose_text__c = description;
        r.Request_return_day__c = Date.today();
        r.Person_In_Charge__c = repOwnerId;
        r.applyUser__c = repOwnerId;
        if(followOpps!=null&&followOpps!=''){
            r.Follow_UP_Opp__c = followOpps;
        }
        upsert r;
 
        updateEvent(r.id,eventId,recordType);
 
        return r.id;
    }
    
    WebService static String selectRecordType(String recordTypeName){
        List<RecordType> rtList = [select id from RecordType where IsActive = true and DeveloperName =:recordTypeName];
        return rtList.get(0).id;
    }
 
    WebService static List<Account> selectAccount(String aId){
        List<Account> aList = new List<Account>();
        if (aId != null && aId.startsWith('001')) {
            aList = [select Id, Department_Class__r.Id, Hospital__r.Id from Account where Id =:aId];
        }
        return aList;
    }
 
    WebService static void updateEvent(String rId, String eventId, String recordType){
        Event__c e = [
            select id,Maintenance_Contract_ID__c, Asset_Manual_ID__c, Rental_Apply_ID__c,
                   Product_Description_Id__c, OPD_ID__c, NTC_ID__c, ReportAccompanied_ID__c, CityStatus_ID__c, Improvement_ID__c, Conflict_ID__c, Claim_ID__c
              from Event__c where id =:eventId
        ];
//        if(recordType == 'Maintenance_Contract'){
//            e.Maintenance_Contract_ID__c = rId;
//        }
        if(recordType == 'Rental_Apply'){
            e.Rental_Apply_ID__c = rId;
        }
        if(recordType == 'Asset_Manual'){
            e.Asset_Manual_ID__c = rId;
        }
        if(recordType == 'Product_Explanation'){
            e.Product_Description_Id__c = rId;
        }
        else if(recordType == 'OPD' || recordType == 'SIS'){
            e.OPD_ID__c = rId;
        }
        else if(recordType == 'NTC'){
            e.NTC_ID__c = rId;
        }
        else if(recordType == 'On_Call'){
            e.OnCall_ID__c = rId;
        }
        else if(recordType == 'Visit_With'){
            e.ReportAccompanied_ID__c = rId;
        }
        else if(recordType == 'MarketCondition'){
            e.CityStatus_ID__c = rId;
        }
        else if(recordType == 'Improvement'){
            e.Improvement_ID__c = rId;
        }
        else if(recordType == 'Competitor'){
            e.Conflict_ID__c = rId;
        }
        else if(recordType == 'Complaint'){
            e.Claim_ID__c = rId;
        }
 
        update e;
    }
    
    WebService static Product2 getProduct2(String a){
        Product2 p2 = [select Id, Name, Intra_Trade_Cost_RMB__c, Intra_Trade_List_RMB__c FROM Product2 Where Id =:a];
        return p2;
    }
 
    WebService static Product2 getProduct2US(String a){
        Product2 p2 = [select Id, Name, Foreign_Trade_Cost_US__c, Foreign_Trade_List_US__c FROM Product2 Where Id =:a];
        return p2;
    }
    
    WebService static String getReportId(String oId, String rDate){
        List<Daily_Report__c> rtList = [select Id from Daily_Report__c where OwnerId =:oId and Reported_Date__c =:date.parse(rDate)];
        return rtList.get(0).id;
    }
    
    WebService static String checkAccountMatch(String name, String id){
        List<Account> accList = [select Id from Account where Name = :name and Id = :id];
        if (accList.size() > 0) {
            return 'OK';
        }
        return 'NG';
    }
    
    WebService static Account getAccountForJs(String id){
        return [select Id, Name, Department_Class__r.Name, Department_Class__r.Id,
                Hospital__r.Name, Hospital__r.Id, Hospital__r.OCM_Category__c
                from Account where Id = :id];
    }
}