LymsPatientServiceImpl.java 2.85 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
package com.lyms.talkonlineweb.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lyms.talkonlineweb.domain.LymsPatient;
import com.lyms.talkonlineweb.service.LymsPatientService;
import com.lyms.talkonlineweb.mapper.LymsPatientMapper;
import com.lyms.talkonlineweb.util.Constant;
import com.lyms.talkonlineweb.util.HXService;
import com.lyms.talkonlineweb.util.JwtUtils;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
*
*/
@Service
public class LymsPatientServiceImpl extends ServiceImpl<LymsPatientMapper, LymsPatient>
implements LymsPatientService{

@Autowired
private LymsPatientMapper lymsPatientMapper;

@Autowired
private HXService hxService;

@Override
public List<Map<String,String>> getAppPatientHospital(Integer patientId) {
return lymsPatientMapper.getAppPatientHospital(patientId);
}

@Override
public List<Map> getPatient(QueryWrapper queryWrapper) {
return lymsPatientMapper.getPatient(queryWrapper);
}

@Override
public List<Map<String,Object>> getPcInfoList() {
return lymsPatientMapper.getPcInfoList();
}

@Override
public LymsPatient addPatientHxId(LymsPatient patient) {

JSONObject hxUserJSON = hxService.getUser(patient.getIdno());
if(hxUserJSON != null && hxUserJSON.getJSONArray("entities") != null && hxUserJSON.getJSONArray("entities").size() > 0){
patient.setHxid(hxUserJSON.getJSONArray("entities").getJSONObject(0).getString("uuid"));
updateById(patient);
}else{
JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname());
JSONArray rArr = json.getJSONArray("entities");
if (rArr.size() > 0) {
patient.setHxid(rArr.getJSONObject(0).getString("uuid"));
updateById(patient);
}
}

return patient;
}

@Override
public LymsPatient getPatientByToken(String token) {
Claims claims = null;
try {
claims = JwtUtils.parseJWT(token);
} catch (Exception e) {
log.error("根据token获取信息异常",e);
}
String idno = claims.getSubject();

QueryWrapper<LymsPatient> query = new QueryWrapper<>();
query.eq("idno",idno);
List<LymsPatient> list = this.list(query);
if(CollectionUtils.isNotEmpty(list)){
return list.get(0);
}
throw new RuntimeException("查询患者信息异常");
}
}