zjh
2024-05-31 a3f44ad3f0b9728a6f9ff4b515a187502bbb39b3
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
package com.ltkj.web.controller.his;
 
 
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.service.ITjCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/* @Authot:zjh
 * @Date:  2024-05-30
 * */
 
@Component
public class HisApiMethod {
    @Autowired
    private HisApiMethodService controller;
 
    @Autowired
    private ITjCustomerService customerService;
 
 
    //将方法返回值解析成json格式
    public JSONObject getJSONObject (String builder) {
        return JSONUtil.parseObj (builder);
    }
 
    //获取方法返回值信息
    public String getAjaxResult (AjaxResult result) {
        return result.get ("data").toString ();
    }
 
    //对接his总接口
    public AjaxResult HisApiMethods (TjCustomer customer) {
 
//        Date date = new Date ();
        AjaxResult result = controller.Outpincreateapply (customer);
        String result1 = getAjaxResult (result);
        JSONObject object = getJSONObject (result1);
        String code = object.getStr ("ResultCode");
        if (code.equals ("0")) {
            Map<String, Object> resultData = (Map<String, Object>) object.get ("ResultData");
            if (null != resultData && resultData.size () > 0) {
                String cardId = resultData.get ("pationid").toString ();
                if(null !=cardId){
                    customer.setCardId (cardId);
                    customerService.updateById (customer);
                }
            }
 
        }
        return AjaxResult.success ();
    }
 
}