|
@ -155,46 +155,59 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
|
|
|
if (families.size()>0){
|
|
|
List<String> familyIds = families.stream().map(item->((JSONObject)item).getString("id")).collect(Collectors.toList());
|
|
|
if(patientArr.size()>0){
|
|
|
JSONObject tmp = patientArr.getJSONObject(0);
|
|
|
JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray");
|
|
|
for (int i=0;i<participantsTimeArray.size();i++){
|
|
|
JSONObject tmpObj = participantsTimeArray.getJSONObject(i);
|
|
|
String id = tmpObj.getString("id");
|
|
|
BasePatientDO patientDO = patientDao.findById(id);
|
|
|
if (patientDO.getArchiveType()==3){
|
|
|
continue;
|
|
|
}
|
|
|
if (!id.equals(patient)&&familyIds.contains(id)){
|
|
|
tmp.put("avatar",tmp.getString("photo"));
|
|
|
tmp.put("patientId",id);
|
|
|
String sql = " select family_relation from base_patient_family_member where " +
|
|
|
" patient = '"+patient+"' and family_member='"+id+"' " +
|
|
|
" and (del=1 or del is null) ";
|
|
|
List<Integer> relations = jdbcTemplate.queryForList(sql,Integer.class);
|
|
|
if(relations.size()>0){
|
|
|
tmp.put("relationName",familyMemberService.relations.get(relations.get(0)));
|
|
|
}else {
|
|
|
tmp.put("relationName","其他");
|
|
|
boolean findFlag = false;//有会话的展示会话中的一条 且不为家属
|
|
|
for (int i=0;i<patientArr.size();i++){
|
|
|
JSONObject tmp = patientArr.getJSONObject(i);
|
|
|
JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray");
|
|
|
for (int j=0;j<participantsTimeArray.size();j++){
|
|
|
JSONObject tmpObj = participantsTimeArray.getJSONObject(j);
|
|
|
String id = tmpObj.getString("id");
|
|
|
BasePatientDO patientDO = patientDao.findById(id);
|
|
|
if (patientDO.getArchiveType()==3){
|
|
|
continue;
|
|
|
}
|
|
|
if (!id.equals(patient)&&familyIds.contains(id)){
|
|
|
tmp.put("avatar",tmp.getString("photo"));
|
|
|
tmp.put("patientId",id);
|
|
|
String sql = " select family_relation from base_patient_family_member where " +
|
|
|
" patient = '"+patient+"' and family_member='"+id+"' " +
|
|
|
" and (del=1 or del is null) ";
|
|
|
List<Integer> relations = jdbcTemplate.queryForList(sql,Integer.class);
|
|
|
if(relations.size()>0){
|
|
|
tmp.put("relationName",familyMemberService.relations.get(relations.get(0)));
|
|
|
}else {
|
|
|
tmp.put("relationName","其他");
|
|
|
}
|
|
|
patientResult.add(tmp);
|
|
|
findFlag=true;
|
|
|
break;
|
|
|
}
|
|
|
patientResult.add(tmp);
|
|
|
}
|
|
|
if (findFlag){
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (patientResult.size()==0){
|
|
|
if (families.size()>0){
|
|
|
JSONObject tmp = families.getJSONObject(0);
|
|
|
JSONObject tmpObj = new JSONObject();
|
|
|
tmpObj.put("name",tmp.getString("name"));
|
|
|
tmpObj.put("unread_count","0");
|
|
|
tmpObj.put("avatar",tmp.getString("photo"));
|
|
|
tmpObj.put("userType","2");
|
|
|
tmpObj.put("patientId",tmp.get("id"));
|
|
|
tmpObj.put("relationName",tmp.get("familyRelationName"));
|
|
|
patientResult.add(tmpObj);
|
|
|
for (int i=0;i<families.size();i++){
|
|
|
JSONObject tmp = families.getJSONObject(i);
|
|
|
JSONObject tmpObj = new JSONObject();
|
|
|
tmpObj.put("name",tmp.getString("name"));
|
|
|
tmpObj.put("unread_count","0");
|
|
|
tmpObj.put("avatar",tmp.getString("photo"));
|
|
|
tmpObj.put("userType","2");
|
|
|
BasePatientDO patientDO = patientDao.findById(tmp.get("id").toString());
|
|
|
if (patientDO.getArchiveType()==3){
|
|
|
continue;
|
|
|
}
|
|
|
tmpObj.put("patientId",tmp.get("id"));
|
|
|
tmpObj.put("relationName",tmp.get("familyRelationName"));
|
|
|
patientResult.add(tmpObj);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
result.put("doctors",doctorResult);
|