|  | @ -9,10 +9,14 @@ import com.yihu.figure.util.HttpClientUtil;
 | 
												
													
														
															|  | import org.json.JSONArray;
 |  | import org.json.JSONArray;
 | 
												
													
														
															|  | import org.json.JSONObject;
 |  | import org.json.JSONObject;
 | 
												
													
														
															|  | import org.springframework.beans.factory.annotation.Autowired;
 |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
												
													
														
															|  | 
 |  | import org.springframework.jdbc.core.BeanPropertyRowMapper;
 | 
												
													
														
															|  | 
 |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
												
													
														
															|  | import org.springframework.stereotype.Service;
 |  | import org.springframework.stereotype.Service;
 | 
												
													
														
															|  | import org.springframework.transaction.annotation.Transactional;
 |  | import org.springframework.transaction.annotation.Transactional;
 | 
												
													
														
															|  | 
 |  | import org.springframework.util.StringUtils;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | import java.net.URLEncoder;
 |  | import java.net.URLEncoder;
 | 
												
													
														
															|  | 
 |  | import java.time.LocalDate;
 | 
												
													
														
															|  | import java.util.ArrayList;
 |  | import java.util.ArrayList;
 | 
												
													
														
															|  | import java.util.List;
 |  | import java.util.List;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
											
												
													
														
															|  | @ -26,6 +30,8 @@ public class DiseaseService {
 | 
												
													
														
															|  |     private VisitDao visitDao;
 |  |     private VisitDao visitDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private InspectionDao inspectionDao;
 |  |     private InspectionDao inspectionDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private JdbcTemplate jdbcTemplate;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
													
														
															|  |      * 造就诊事件的数据
 |  |      * 造就诊事件的数据
 | 
												
											
												
													
														
															|  | @ -33,7 +39,7 @@ public class DiseaseService {
 | 
												
													
														
															|  |      * @param strSSID
 |  |      * @param strSSID
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     @Transactional
 |  |     @Transactional
 | 
												
													
														
															|  |     public void getResidentEventListJson(String strSSID) {
 |  | 
 | 
												
													
														
															|  | 
 |  |     public void getResidentEventListJson(String strSSID,String patientCode) {
 | 
												
													
														
															|  |         String url = baseurl + "data/getResidentEventListJson?strSSID=" + strSSID;
 |  |         String url = baseurl + "data/getResidentEventListJson?strSSID=" + strSSID;
 | 
												
													
														
															|  |         String response = HttpClientUtil.get(url, "UTF-8");
 |  |         String response = HttpClientUtil.get(url, "UTF-8");
 | 
												
													
														
															|  |         JSONObject obj = new JSONObject(response);
 |  |         JSONObject obj = new JSONObject(response);
 | 
												
											
												
													
														
															|  | @ -42,14 +48,14 @@ public class DiseaseService {
 | 
												
													
														
															|  |             JSONArray ja = obj.getJSONArray("门诊");
 |  |             JSONArray ja = obj.getJSONArray("门诊");
 | 
												
													
														
															|  |             for (int i = 0; i < ja.length(); i++) {
 |  |             for (int i = 0; i < ja.length(); i++) {
 | 
												
													
														
															|  |                 JSONObject jo = ja.getJSONObject(i);
 |  |                 JSONObject jo = ja.getJSONObject(i);
 | 
												
													
														
															|  |                 Visit visit = new Visit();
 |  | 
 | 
												
													
														
															|  | 
 |  |                 Visit visit = new Visit(patientCode);
 | 
												
													
														
															|  |                 visit.setDiagnosis(jo.getString("DIAGNOSIS"));
 |  |                 visit.setDiagnosis(jo.getString("DIAGNOSIS"));
 | 
												
													
														
															|  |                 visit.setEndTime(DateUtil.strToDate(jo.getString("END_TIME"),"yyyy-MM-dd HH:mm:ss"));
 |  | 
 | 
												
													
														
															|  | 
 |  |                 visit.setEndTime(DateUtil.strToDate(jo.getString("END_TIME"), "yyyy-MM-dd HH:mm:ss"));
 | 
												
													
														
															|  |                 visit.setEvent(jo.getString("EVENT"));
 |  |                 visit.setEvent(jo.getString("EVENT"));
 | 
												
													
														
															|  |                 visit.setOrgId(jo.getInt("ORG_ID"));
 |  |                 visit.setOrgId(jo.getInt("ORG_ID"));
 | 
												
													
														
															|  |                 visit.setOrgName(jo.getString("ORG_NAME"));
 |  |                 visit.setOrgName(jo.getString("ORG_NAME"));
 | 
												
													
														
															|  |                 visit.setR(jo.getInt("R")+"");
 |  | 
 | 
												
													
														
															|  |                 visit.setType(jo.getInt("TYPE")+"");
 |  | 
 | 
												
													
														
															|  | 
 |  |                 visit.setR(jo.getInt("R") + "");
 | 
												
													
														
															|  | 
 |  |                 visit.setType(jo.getInt("TYPE") + "");
 | 
												
													
														
															|  |                 visit.setIcdCode(jo.getString("ICD_CODE"));
 |  |                 visit.setIcdCode(jo.getString("ICD_CODE"));
 | 
												
													
														
															|  |                 visits.add(visit);
 |  |                 visits.add(visit);
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
											
												
													
														
															|  | @ -62,12 +68,12 @@ public class DiseaseService {
 | 
												
													
														
															|  |                 JSONObject jo = ja.getJSONObject(i);
 |  |                 JSONObject jo = ja.getJSONObject(i);
 | 
												
													
														
															|  |                 Visit visit = new Visit();
 |  |                 Visit visit = new Visit();
 | 
												
													
														
															|  |                 visit.setDiagnosis(jo.getString("DIAGNOSIS"));
 |  |                 visit.setDiagnosis(jo.getString("DIAGNOSIS"));
 | 
												
													
														
															|  |                 visit.setEndTime(DateUtil.strToDate(jo.getString("END_TIME"),"yyyy-MM-dd HH:mm:ss"));
 |  | 
 | 
												
													
														
															|  | 
 |  |                 visit.setEndTime(DateUtil.strToDate(jo.getString("END_TIME"), "yyyy-MM-dd HH:mm:ss"));
 | 
												
													
														
															|  |                 visit.setEvent(jo.getString("EVENT"));
 |  |                 visit.setEvent(jo.getString("EVENT"));
 | 
												
													
														
															|  |                 visit.setOrgId(jo.getInt("ORG_ID"));
 |  |                 visit.setOrgId(jo.getInt("ORG_ID"));
 | 
												
													
														
															|  |                 visit.setOrgName(jo.getString("ORG_NAME"));
 |  |                 visit.setOrgName(jo.getString("ORG_NAME"));
 | 
												
													
														
															|  |                 visit.setR(jo.getInt("R")+"");
 |  | 
 | 
												
													
														
															|  |                 visit.setType(jo.getInt("TYPE")+"");
 |  | 
 | 
												
													
														
															|  | 
 |  |                 visit.setR(jo.getInt("R") + "");
 | 
												
													
														
															|  | 
 |  |                 visit.setType(jo.getInt("TYPE") + "");
 | 
												
													
														
															|  |                 visit.setIcdCode(jo.getString("ICD_CODE"));
 |  |                 visit.setIcdCode(jo.getString("ICD_CODE"));
 | 
												
													
														
															|  |                 visits.add(visit);
 |  |                 visits.add(visit);
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
											
												
													
														
															|  | @ -81,7 +87,7 @@ public class DiseaseService {
 | 
												
													
														
															|  |      * @param strSSID
 |  |      * @param strSSID
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     @Transactional
 |  |     @Transactional
 | 
												
													
														
															|  |     public void GetRecordListByCatalogcodesJson(String strSSID) {
 |  | 
 | 
												
													
														
															|  | 
 |  |     public void GetRecordListByCatalogcodesJson(String strSSID,String patientCode) {
 | 
												
													
														
															|  |         String url = baseurl + "data/GetRecordListByCatalogcodesJson?strSSID=" + strSSID;
 |  |         String url = baseurl + "data/GetRecordListByCatalogcodesJson?strSSID=" + strSSID;
 | 
												
													
														
															|  |         String response = HttpClientUtil.get(url, "UTF-8");
 |  |         String response = HttpClientUtil.get(url, "UTF-8");
 | 
												
													
														
															|  |         JSONObject obj = new JSONObject(response);
 |  |         JSONObject obj = new JSONObject(response);
 | 
												
											
												
													
														
															|  | @ -90,17 +96,17 @@ public class DiseaseService {
 | 
												
													
														
															|  |             JSONArray ja = obj.getJSONArray("检查");
 |  |             JSONArray ja = obj.getJSONArray("检查");
 | 
												
													
														
															|  |             for (int i = 0; i < ja.length(); i++) {
 |  |             for (int i = 0; i < ja.length(); i++) {
 | 
												
													
														
															|  |                 JSONObject jo = ja.getJSONObject(i);
 |  |                 JSONObject jo = ja.getJSONObject(i);
 | 
												
													
														
															|  |                 Inspection inspection = new Inspection();
 |  | 
 | 
												
													
														
															|  | 
 |  |                 Inspection inspection = new Inspection(patientCode);
 | 
												
													
														
															|  |                 inspection.setCatalogCode(jo.getString("CATALOG_CODE"));
 |  |                 inspection.setCatalogCode(jo.getString("CATALOG_CODE"));
 | 
												
													
														
															|  |                 inspection.setEhrCommitTime(DateUtil.strToDate(jo.getString("EHR_COMMIT_TIME"),"yyyy-MM-dd HH:mm:ss"));
 |  | 
 | 
												
													
														
															|  |                 inspection.setEndTime(DateUtil.strToDate(jo.getString("END_TIME"),"yyyy-MM-dd HH:mm:ss"));
 |  | 
 | 
												
													
														
															|  | 
 |  |                 inspection.setEhrCommitTime(DateUtil.strToDate(jo.getString("EHR_COMMIT_TIME"), "yyyy-MM-dd HH:mm:ss"));
 | 
												
													
														
															|  | 
 |  |                 inspection.setEndTime(DateUtil.strToDate(jo.getString("END_TIME"), "yyyy-MM-dd HH:mm:ss"));
 | 
												
													
														
															|  |                 inspection.setEvent(jo.getString("EVENT"));
 |  |                 inspection.setEvent(jo.getString("EVENT"));
 | 
												
													
														
															|  |                 inspection.setItem(jo.getString("ITEM"));
 |  |                 inspection.setItem(jo.getString("ITEM"));
 | 
												
													
														
															|  |                 inspection.setOrgId(jo.getInt("ORG_ID"));
 |  |                 inspection.setOrgId(jo.getInt("ORG_ID"));
 | 
												
													
														
															|  |                 inspection.setOrgName(jo.getString("ORG_NAME"));
 |  |                 inspection.setOrgName(jo.getString("ORG_NAME"));
 | 
												
													
														
															|  |                 inspection.setR(jo.getInt("R"));
 |  |                 inspection.setR(jo.getInt("R"));
 | 
												
													
														
															|  |                 inspection.setSerial(jo.getString("SERIAL"));
 |  | 
 | 
												
													
														
															|  |                 inspection.setType(jo.getString("TYPE"));
 |  | 
 | 
												
													
														
															|  | 
 |  |                 inspection.setSerial(jo.getInt("SERIAL")+"");
 | 
												
													
														
															|  | 
 |  |                 inspection.setType(jo.getInt("TYPE")+"");
 | 
												
													
														
															|  |                 inspection.setUnionssid(jo.getString("UNIONSSID"));
 |  |                 inspection.setUnionssid(jo.getString("UNIONSSID"));
 | 
												
													
														
															|  |                 inspection.setXmanId(jo.getString("XMAN_ID"));
 |  |                 inspection.setXmanId(jo.getString("XMAN_ID"));
 | 
												
													
														
															|  |                 inspections.add(inspection);
 |  |                 inspections.add(inspection);
 | 
												
											
												
													
														
															|  | @ -108,4 +114,43 @@ public class DiseaseService {
 | 
												
													
														
															|  |             inspectionDao.save(inspections);
 |  |             inspectionDao.save(inspections);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      *
 | 
												
													
														
															|  | 
 |  |      * @param patientCode
 | 
												
													
														
															|  | 
 |  |      * @param time  2015
 | 
												
													
														
															|  | 
 |  |       * @return
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     public List<Visit> getVisits(String patientCode,String time) {
 | 
												
													
														
															|  | 
 |  |         StringBuffer sql=new StringBuffer("select * from figure_visit f where 1=1 and  f.patient_code =? ");
 | 
												
													
														
															|  | 
 |  |         List<Object> params=new ArrayList<>();
 | 
												
													
														
															|  | 
 |  |         params.add(patientCode);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         if(!StringUtils.isEmpty(time)){
 | 
												
													
														
															|  | 
 |  |             sql.append(" and f.end_time >= ? ");
 | 
												
													
														
															|  | 
 |  |             params.add( LocalDate.of(Integer.valueOf(time),1,1).toString());
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             sql.append(" and f.end_time < ? ");
 | 
												
													
														
															|  | 
 |  |             params.add( LocalDate.of(Integer.valueOf(time),1,1).plusYears(1).toString());
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         List<Visit> visisList= jdbcTemplate.query(sql.toString(),params.toArray(),new BeanPropertyRowMapper(Visit.class));
 | 
												
													
														
															|  | 
 |  |         return visisList;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public List<Inspection> getInspections(String patientCode,String time) {
 | 
												
													
														
															|  | 
 |  |         StringBuffer sql=new StringBuffer("select * from figure_inspection f where 1=1 and  f.patient_code =? ");
 | 
												
													
														
															|  | 
 |  |         List<Object> params=new ArrayList<>();
 | 
												
													
														
															|  | 
 |  |         params.add(patientCode);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         if(!StringUtils.isEmpty(time)){
 | 
												
													
														
															|  | 
 |  |             sql.append(" and f.end_time >= ? ");
 | 
												
													
														
															|  | 
 |  |             params.add( LocalDate.of(Integer.valueOf(time),1,1).toString());
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             sql.append(" and f.end_time < ? ");
 | 
												
													
														
															|  | 
 |  |             params.add( LocalDate.of(Integer.valueOf(time),1,1).plusYears(1).toString());
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         List<Inspection> inspectionList= jdbcTemplate.query(sql.toString(),params.toArray(),new BeanPropertyRowMapper(Inspection.class));
 | 
												
													
														
															|  | 
 |  |         return inspectionList;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | }
 |  | }
 |