package com.yihu.figure.service.data;

import com.yihu.figure.service.jw.JwArchivesService;
import com.yihu.figure.service.jw.JwSignService;
import com.yihu.figure.service.jw.JwSmjkService;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by chenweida on 2017/3/6.
 */
@Service
public class DataService {
    @Autowired
    private JwArchivesService jwArchivesService;
    @Autowired
    private JwSignService jwSignService;
    @Autowired
    private JwSmjkService jwSmjkService;

    public String getResidentEventListJson(String strSSID) {
        JSONObject jo = new JSONObject();
        try {
            Integer page = 1;
            Integer pageSize = 100;
            //门诊
            String ehrList1 = jwSmjkService.getResidentEventListJson(strSSID, "1", page + "", pageSize + "");
            //住院
            String ehrList2 = jwSmjkService.getResidentEventListJson(strSSID, "2", page + "", pageSize + "");
            jo.put("status", 10000);
            jo.put("门诊", new JSONArray(ehrList1));
            jo.put("住院", new JSONArray(ehrList2));
        }catch (Exception e){
            jo.put("status", 10001);
        }
        return jo.toString();
    }

    public String GetRecordListByCatalogcodesJson(String strSSID) {
        JSONObject jo = new JSONObject();
        try {
            Integer page = 1;
            Integer pageSize = 100;
            //检查
            String ehrList1 = jwSmjkService.getExamAndLabReport(strSSID, page + "", pageSize + "");
            jo.put("status", 10000);
            jo.put("检查", new JSONArray(ehrList1));
        }catch (Exception e){
            jo.put("status", 10001);
        }
        return jo.toString();
    }
}
