|
@ -903,77 +903,88 @@ public class FollowUpService extends BaseService {
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void esSaveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
|
|
|
JestClient jestClient = null;
|
|
|
try {
|
|
|
|
|
|
JestClient jestClient = elasticFactory.getJestClient();
|
|
|
//先根据条件查找出来
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
new BoolQueryBuilder()
|
|
|
.must(QueryBuilders.matchQuery("followup_id", id))
|
|
|
.must(QueryBuilders.matchQuery("followup_project", followupProject))
|
|
|
);
|
|
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
.build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
|
|
|
|
|
|
//删除原有记录
|
|
|
this.esDeleteFollowUpContent(dataList);
|
|
|
|
|
|
//保存新的随访详情信息
|
|
|
List<FollowupContentESDO> newdatalist = new ArrayList<>();
|
|
|
FollowupContentESDO followupContentESDO = new FollowupContentESDO();
|
|
|
|
|
|
followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
|
|
|
|
|
|
followupContentESDO.setFollowup_id(id);
|
|
|
followupContentESDO.setFollowup_project(followupProject);
|
|
|
followupContentESDO.setCreate_time(new Date());
|
|
|
newdatalist.add(followupContentESDO);
|
|
|
elastricSearchSave.save(newdatalist, esIndex, esType);
|
|
|
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
|
//先根据条件查找出来
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
new BoolQueryBuilder()
|
|
|
.must(QueryBuilders.matchQuery("followup_id", id))
|
|
|
.must(QueryBuilders.matchQuery("followup_project", followupProject))
|
|
|
);
|
|
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
.build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
|
|
|
|
|
|
//删除原有记录
|
|
|
this.esDeleteFollowUpContent(dataList);
|
|
|
|
|
|
//保存新的随访详情信息
|
|
|
List<FollowupContentESDO> newdatalist = new ArrayList<>();
|
|
|
FollowupContentESDO followupContentESDO = new FollowupContentESDO();
|
|
|
|
|
|
followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
|
|
|
|
|
|
followupContentESDO.setFollowup_id(id);
|
|
|
followupContentESDO.setFollowup_project(followupProject);
|
|
|
followupContentESDO.setCreate_time(new Date());
|
|
|
newdatalist.add(followupContentESDO);
|
|
|
elastricSearchSave.save(newdatalist, esIndex, esType);
|
|
|
|
|
|
|
|
|
//如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
|
|
|
Followup followup = followupDao.findOne(Long.valueOf(id));
|
|
|
if ("1".equals(followup.getStatus())) {
|
|
|
FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
|
|
|
if (followupMapping == null) {
|
|
|
followupMapping = new FollowupMapping();
|
|
|
followupMapping.setCode(UUID.randomUUID().toString());
|
|
|
followupMapping.setFollowupId(Integer.parseInt(id));
|
|
|
followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
|
|
|
followupMapping.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
}
|
|
|
followupMapping.setNeedUpload(1);
|
|
|
followUpMappingDao.save(followupMapping);
|
|
|
}
|
|
|
|
|
|
//如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
|
|
|
Followup followup = followupDao.findOne(Long.valueOf(id));
|
|
|
if ("1".equals(followup.getStatus())) {
|
|
|
FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
|
|
|
if (followupMapping == null) {
|
|
|
followupMapping = new FollowupMapping();
|
|
|
followupMapping.setCode(UUID.randomUUID().toString());
|
|
|
followupMapping.setFollowupId(Integer.parseInt(id));
|
|
|
followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
|
|
|
followupMapping.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
} finally {
|
|
|
if (jestClient != null) {
|
|
|
jestClient.shutdownClient();
|
|
|
}
|
|
|
followupMapping.setNeedUpload(1);
|
|
|
followUpMappingDao.save(followupMapping);
|
|
|
}
|
|
|
|
|
|
|
|
|
jestClient.shutdownClient();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* ES获取面访项目数据
|
|
|
*/
|
|
|
public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
|
|
|
//根据随访ID、分类ID获取随访记录详情
|
|
|
|
|
|
JestClient jestClient = elasticFactory.getJestClient();
|
|
|
//先根据条件查找出来
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
new BoolQueryBuilder()
|
|
|
.must(QueryBuilders.matchQuery("followup_id", id))
|
|
|
.must(QueryBuilders.matchQuery("followup_project", followupProject))
|
|
|
);
|
|
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
.build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
|
|
|
|
|
|
jestClient.shutdownClient();
|
|
|
JestClient jestClient = null;
|
|
|
FollowupContentESDO followupContentESDO = null;
|
|
|
try {
|
|
|
//根据随访ID、分类ID获取随访记录详情
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
|
//先根据条件查找出来
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
new BoolQueryBuilder()
|
|
|
.must(QueryBuilders.matchQuery("followup_id", id))
|
|
|
.must(QueryBuilders.matchQuery("followup_project", followupProject))
|
|
|
);
|
|
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
.build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
|
|
|
} finally {
|
|
|
if (jestClient != null) {
|
|
|
jestClient.shutdownClient();
|
|
|
}
|
|
|
}
|
|
|
return followupContentESDO;
|
|
|
}
|
|
|
|
|
@ -984,8 +995,9 @@ public class FollowUpService extends BaseService {
|
|
|
* @date 2017/11/1 15:17
|
|
|
*/
|
|
|
public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception {
|
|
|
JestClient jestClient = null;
|
|
|
try {
|
|
|
JestClient jestClient = elasticFactory.getJestClient();
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
|
//根据id批量删除
|
|
|
Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
|
for (FollowupContentESDO obj : datalist) {
|
|
@ -997,8 +1009,10 @@ public class FollowUpService extends BaseService {
|
|
|
logger.info("delete data count:" + datalist.size());
|
|
|
logger.info("delete flag:" + br.isSucceeded());
|
|
|
jestClient.shutdownClient();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
if (jestClient != null) {
|
|
|
jestClient.shutdownClient();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
@ -1010,32 +1024,37 @@ public class FollowUpService extends BaseService {
|
|
|
* @date 2017/11/1 19:41
|
|
|
*/
|
|
|
public List<String> esfindProjectByFollowupId(String id) throws Exception {
|
|
|
//根据随访ID、分类ID获取随访记录详情
|
|
|
|
|
|
JestClient jestClient = null;
|
|
|
List<String> resultList = new ArrayList<>();
|
|
|
try {
|
|
|
//根据随访ID、分类ID获取随访记录详情
|
|
|
elasticFactory.getJestClient();
|
|
|
//先根据条件查找出来
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
new BoolQueryBuilder()
|
|
|
.must(QueryBuilders.matchQuery("followup_id", id))
|
|
|
);
|
|
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
.build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
|
|
|
List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
|
|
|
|
|
|
followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
|
|
|
if (!followupContentESDOList.isEmpty()) {
|
|
|
for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
|
|
|
resultList.add(followupContentESDO.getFollowup_project());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
JestClient jestClient = elasticFactory.getJestClient();
|
|
|
//先根据条件查找出来
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
new BoolQueryBuilder()
|
|
|
.must(QueryBuilders.matchQuery("followup_id", id))
|
|
|
);
|
|
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
.build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
|
|
|
List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
|
|
|
|
|
|
followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
|
|
|
if (!followupContentESDOList.isEmpty()) {
|
|
|
for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
|
|
|
resultList.add(followupContentESDO.getFollowup_project());
|
|
|
jestClient.shutdownClient();
|
|
|
} finally {
|
|
|
if (jestClient != null) {
|
|
|
jestClient.shutdownClient();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
jestClient.shutdownClient();
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
@ -1046,30 +1065,36 @@ public class FollowUpService extends BaseService {
|
|
|
* @date 2017/11/1 19:41
|
|
|
*/
|
|
|
public List<FollowupContentESDO> esfindFollowUpContestsByFollowupId(String id) throws Exception {
|
|
|
//根据随访ID、分类ID获取随访记录详情
|
|
|
|
|
|
List<String> resultList = new ArrayList<>();
|
|
|
JestClient jestClient = null;
|
|
|
List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
|
|
|
try {
|
|
|
//根据随访ID、分类ID获取随访记录详情
|
|
|
|
|
|
JestClient jestClient = elasticFactory.getJestClient();
|
|
|
//先根据条件查找出来
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
new BoolQueryBuilder()
|
|
|
.must(QueryBuilders.matchQuery("followup_id", id))
|
|
|
);
|
|
|
List<String> resultList = new ArrayList<>();
|
|
|
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
.build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
jestClient = elasticFactory.getJestClient();
|
|
|
//先根据条件查找出来
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
searchSourceBuilder.query(
|
|
|
new BoolQueryBuilder()
|
|
|
.must(QueryBuilders.matchQuery("followup_id", id))
|
|
|
);
|
|
|
|
|
|
List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
|
|
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
|
|
|
.build();
|
|
|
SearchResult result = jestClient.execute(search);
|
|
|
|
|
|
jestClient.shutdownClient();
|
|
|
} finally {
|
|
|
if (jestClient != null) {
|
|
|
jestClient.shutdownClient();
|
|
|
}
|
|
|
}
|
|
|
return followupContentESDOList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据续方CODE获取随访记录信息
|
|
|
*
|
|
|
* @param prescriptionCode
|
|
|
* @return
|
|
|
*/
|
|
@ -1084,6 +1109,7 @@ public class FollowUpService extends BaseService {
|
|
|
|
|
|
/**
|
|
|
* 获取随访详情记录分类记录数
|
|
|
*
|
|
|
* @param followupid
|
|
|
* @param type
|
|
|
* @return
|
|
@ -1092,25 +1118,25 @@ public class FollowUpService extends BaseService {
|
|
|
|
|
|
int count = 0;
|
|
|
String[] typelist = null;
|
|
|
if(type.contains(",")){
|
|
|
if (type.contains(",")) {
|
|
|
typelist = type.split(",");
|
|
|
}else{
|
|
|
} else {
|
|
|
typelist = new String[]{type};
|
|
|
}
|
|
|
|
|
|
for (String typekey: typelist) {
|
|
|
if(!"drug".equals(type)){
|
|
|
for (String typekey : typelist) {
|
|
|
if (!"drug".equals(type)) {
|
|
|
|
|
|
FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid,typekey);
|
|
|
if(followupContentESDO != null){
|
|
|
count ++;
|
|
|
FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid, typekey);
|
|
|
if (followupContentESDO != null) {
|
|
|
count++;
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
} else {
|
|
|
//获取用药记录
|
|
|
List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(followupid));
|
|
|
if(!drugsList.isEmpty()){
|
|
|
count = count +drugsList.size();
|
|
|
if (!drugsList.isEmpty()) {
|
|
|
count = count + drugsList.size();
|
|
|
}
|
|
|
}
|
|
|
}
|