|
@ -3,9 +3,12 @@ package com.yihu.wlyy.service.third.jw;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.oldpeople.OldPeoplePhysicalExaminationEntity;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.Prescription;
|
|
|
import com.yihu.wlyy.repository.oldpeople.OldPeoplePhysicalExaminationDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
@ -17,10 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 基位长处方接口
|
|
@ -41,6 +41,8 @@ public class JwPrescriptionService {
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
@Autowired
|
|
|
private PatientService patientService;
|
|
|
@Autowired
|
|
|
private OldPeoplePhysicalExaminationDao oldPeoplePhysicalExaminationDao;
|
|
|
|
|
|
/**
|
|
|
* 获取字典列表
|
|
@ -286,4 +288,77 @@ public class JwPrescriptionService {
|
|
|
throw new Exception("获取慢病患者定标情况请求失败,无数据返回!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据起止时间查询老年人体检记录,并同步到本地数据库
|
|
|
* @param startdate
|
|
|
* @param enddate
|
|
|
* @return
|
|
|
*/
|
|
|
public void getOldPeoplePhysicalExaminationByTime(String startdate, String enddate)throws Exception {
|
|
|
|
|
|
logger.info("查询老年人体检记录,开始时间"+startdate+",结束时间:"+enddate);
|
|
|
|
|
|
|
|
|
String url = jwUrl + "/third/sign/getSickMedicalSimpleListInfo";
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("TIME_START", startdate));//开始时间
|
|
|
params.add(new BasicNameValuePair("TIME_END", enddate));//结束时间
|
|
|
String response = httpClientUtil.post(url, params, "UTF-8");
|
|
|
|
|
|
//老年人体检记录列表
|
|
|
List<OldPeoplePhysicalExaminationEntity> oldPeoplePhysicalExaminationEntities = new ArrayList<>();
|
|
|
|
|
|
if(StringUtils.isNotBlank(response)){
|
|
|
JSONObject reobj = JSON.parseObject(response);
|
|
|
Integer status = reobj.getInteger("status");
|
|
|
String errmsg = reobj.getString("msg");
|
|
|
if(200 == status){
|
|
|
JSONObject jwData = reobj.getJSONObject("data");
|
|
|
Integer jwCode = jwData.getInteger("CODE");
|
|
|
if(1 == jwCode){
|
|
|
JSONArray dataArray = jwData.getJSONArray("DATA");
|
|
|
for (int i = 0; i < dataArray.size(); i++) {
|
|
|
|
|
|
OldPeoplePhysicalExaminationEntity oldPeoplePhysicalExaminationEntity = new OldPeoplePhysicalExaminationEntity();
|
|
|
|
|
|
JSONObject json = dataArray.getJSONObject(i);
|
|
|
String idcard = json.getString("IDENTITY_CARD_NO");//身份证号码
|
|
|
String medicalNo = json.getString("MEDICAL_NO");//体检编码
|
|
|
String patientName = json.getString("SICK_NAME");//姓名
|
|
|
String orgName = json.getString("ORG_NAME");//医院名称
|
|
|
String orgCode = json.getString("ORG_CODE");//医院机构编码
|
|
|
String jwDoctorCode = json.getString("MEDICAL_OPERATOR");//体检医生
|
|
|
String medicalTime = json.getString("MEDICAL_TIME");//体检时间
|
|
|
|
|
|
oldPeoplePhysicalExaminationEntity.setCode(UUID.randomUUID().toString());
|
|
|
oldPeoplePhysicalExaminationEntity.setIdCard(idcard);
|
|
|
oldPeoplePhysicalExaminationEntity.setMedicalNo(medicalNo);
|
|
|
oldPeoplePhysicalExaminationEntity.setPatientName(patientName);
|
|
|
oldPeoplePhysicalExaminationEntity.setOrgName(orgName);
|
|
|
oldPeoplePhysicalExaminationEntity.setOrgCode(orgCode);
|
|
|
oldPeoplePhysicalExaminationEntity.setJwDoctorCode(jwDoctorCode);
|
|
|
oldPeoplePhysicalExaminationEntity.setMedicalTime(DateUtil.fomrmatStringToTimeStamp(medicalTime));
|
|
|
oldPeoplePhysicalExaminationEntity.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
oldPeoplePhysicalExaminationEntities.add(oldPeoplePhysicalExaminationEntity);
|
|
|
}
|
|
|
|
|
|
if(!oldPeoplePhysicalExaminationEntities.isEmpty()){
|
|
|
logger.info("从基卫接口获取老年人体检记录数为"+oldPeoplePhysicalExaminationEntities.size());
|
|
|
oldPeoplePhysicalExaminationDao.save(oldPeoplePhysicalExaminationEntities);
|
|
|
}else{
|
|
|
logger.info("从基卫接口获取老年人体检记录数个数为"+oldPeoplePhysicalExaminationEntities.size());
|
|
|
}
|
|
|
}else{
|
|
|
String jwMessage = jwData.getString("MESSAGE");
|
|
|
throw new Exception("从基卫接口获取老年人体检记,请求基卫接口失败:"+jwMessage);
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
throw new Exception("从基卫接口获取老年人体检记请求失败,"+errmsg);
|
|
|
}
|
|
|
}else{
|
|
|
throw new Exception("从基卫接口获取老年人体检记请求失败,无数据返回!");
|
|
|
}
|
|
|
}
|
|
|
}
|