|
@ -1,11 +1,14 @@
|
|
|
package com.yihu.jw.care.service.patient;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.care.dao.label.PatientLabelDao;
|
|
|
import com.yihu.jw.care.service.common.DictService;
|
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
|
|
|
import com.yihu.jw.entity.care.label.PatientLabelDO;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
@ -13,10 +16,12 @@ import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.repository.CrudRepository;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@ -33,17 +38,17 @@ import java.util.Map;
|
|
|
* @since 1.
|
|
|
*/
|
|
|
@Service
|
|
|
public class CarePatientService<T, R extends CrudRepository> extends BaseJpaService<BasePatientDO, BasePatientDao> {
|
|
|
public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatientDao> {
|
|
|
|
|
|
@Autowired
|
|
|
private BasePatientDao basePatientDao;
|
|
|
private BasePatientDao patientDao;
|
|
|
|
|
|
@Autowired
|
|
|
private BasePatientMedicardCardService basePatientMedicardCardService;
|
|
|
@Autowired
|
|
|
private ServicePackageService servicePackageService;
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
private PatientLabelDao patientLabelDao;
|
|
|
@Autowired
|
|
|
private DictService dictService;
|
|
|
|
|
@ -91,7 +96,7 @@ public class CarePatientService<T, R extends CrudRepository> extends BaseJpaServ
|
|
|
*/
|
|
|
public JSONObject findPatientById(String patientId) throws Exception{
|
|
|
JSONObject res = new JSONObject();
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patientId);
|
|
|
BasePatientDO patientDO = patientDao.findById(patientId);
|
|
|
patientDO.setArchiveStatusName(dictService.fingByNameAndCode("archiveStatus",String.valueOf(patientDO.getArchiveStatus())));
|
|
|
patientDO.setNationalName(dictService.fingByNameAndCode("national",String.valueOf(patientDO.getNational())));
|
|
|
patientDO.setArchiveTypeName(dictService.fingByNameAndCode("archiveType",String.valueOf(patientDO.getArchiveType())));
|
|
@ -106,26 +111,76 @@ public class CarePatientService<T, R extends CrudRepository> extends BaseJpaServ
|
|
|
ServicePackageSignRecordDO signRecordDO = signRecordDOs.get(0);
|
|
|
String signId = signRecordDO.getId();
|
|
|
List<Map<String,Object>> packageList = servicePackageService.fingdBySignId(signId);
|
|
|
List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorBySignId(signId,"generalDoctor");
|
|
|
List<Map<String,Object>> helperList = servicePackageService.fingdDoctorBySignId(signId,"helper");
|
|
|
String doctorInfo = "";
|
|
|
String helperInfo = "";
|
|
|
String packageInfo = "";
|
|
|
if(doctorList.size()>0){
|
|
|
doctorInfo = doctorList.get(0).get("name").toString()+"等"+doctorList.size()+"名";
|
|
|
}
|
|
|
if(helperList.size()>0){
|
|
|
helperInfo = doctorList.get(0).get("name").toString()+"等"+helperList.size()+"名";
|
|
|
}
|
|
|
if(packageList.size()>0){
|
|
|
packageInfo = packageList.get(0).get("name").toString()+"等"+packageList.size()+"个";
|
|
|
}
|
|
|
signRecordDO.setDoctorInfo(doctorInfo);
|
|
|
signRecordDO.setHelperInfo(helperInfo);
|
|
|
signRecordDO.setPackageInfo(packageInfo);
|
|
|
List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorBySignId(signId,1);
|
|
|
List<Map<String,Object>> helperList = servicePackageService.fingdDoctorBySignId(signId,2);
|
|
|
signRecordDO.setDoctorList(doctorList);
|
|
|
signRecordDO.setHelperList(helperList);
|
|
|
signRecordDO.setPackageList(packageList);
|
|
|
res.put("signRecordDO",signRecordDO);
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改居民信息
|
|
|
* @param jsonData
|
|
|
* @param doctorId
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updPatient(String jsonData,String doctorId) throws Exception{
|
|
|
JSONObject jsonObject = JSON.parseObject(jsonData);
|
|
|
BasePatientDO patientDetail = JSONObject.parseObject(jsonObject.getJSONObject("patient").toJSONString(), BasePatientDO.class);
|
|
|
BasePatientDO patientBrief = patientDao.findById(patientDetail.getId());
|
|
|
patientBrief.setName(patientDetail.getName());
|
|
|
patientBrief.setSex(patientDetail.getSex());
|
|
|
patientBrief.setIdcard(patientDetail.getIdcard());
|
|
|
patientBrief.setProvinceCode(patientDetail.getProvinceCode());
|
|
|
patientBrief.setProvinceName(patientDetail.getProvinceName());
|
|
|
patientBrief.setCityCode(patientDetail.getCityCode());
|
|
|
patientBrief.setCityName(patientDetail.getCityName());
|
|
|
patientBrief.setTownCode(patientDetail.getTownCode());
|
|
|
patientBrief.setTownName(patientDetail.getTownName());
|
|
|
patientBrief.setLiveProvinceCode(patientDetail.getLiveProvinceCode());
|
|
|
patientBrief.setLiveProvinceName(patientDetail.getLiveProvinceName());
|
|
|
patientBrief.setLiveCityCode(patientDetail.getLiveCityCode());
|
|
|
patientBrief.setLiveCityName(patientDetail.getLiveCityName());
|
|
|
patientBrief.setLiveTownCode(patientDetail.getLiveTownCode());
|
|
|
patientBrief.setLiveTownName(patientDetail.getLiveTownName());
|
|
|
patientBrief.setLiveStreetCode(patientDetail.getLiveStreetCode());
|
|
|
patientBrief.setLiveStreetName(patientDetail.getLiveStreetName());
|
|
|
patientBrief.setAddress(patientDetail.getAddress());
|
|
|
patientBrief.setCommitteeCode(patientDetail.getCommitteeCode());
|
|
|
patientBrief.setCommitteeName(patientDetail.getCommitteeName());
|
|
|
patientBrief.setArchiveStatus(patientDetail.getArchiveStatus());
|
|
|
patientBrief.setSsc(patientDetail.getSsc());
|
|
|
patientBrief.setMedicareNumber(patientDetail.getMedicareNumber());
|
|
|
patientBrief.setMobile(patientDetail.getMobile());
|
|
|
patientBrief.setMobileRemarks(patientDetail.getMobileRemarks());
|
|
|
patientDao.save(patientBrief);
|
|
|
|
|
|
JSONObject jsonObject1 = jsonObject.getJSONObject("signRecordDO");
|
|
|
if(jsonObject1!=null){
|
|
|
servicePackageService.servicePackageSign(jsonObject1.toJSONString(),doctorId,patientBrief.getId());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改居民标签信息
|
|
|
* @param jsonData
|
|
|
* @param patientId
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updPatientLabel(String jsonData,String patientId) throws Exception{
|
|
|
patientLabelDao.deleteByPatient(patientId);
|
|
|
JSONArray jsonArray = JSON.parseArray(jsonData);
|
|
|
List<PatientLabelDO> labelDOList = new ArrayList<>();
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
PatientLabelDO labelDO = JSONObject.parseObject(jsonArray.getJSONObject(i).toJSONString(), PatientLabelDO.class);
|
|
|
labelDO.setPatient(patientId);
|
|
|
labelDO.setCzrq(new Date());
|
|
|
labelDOList.add(labelDO);
|
|
|
}
|
|
|
patientLabelDao.save(labelDOList);
|
|
|
}
|
|
|
}
|