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.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 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;
}
}