|
@ -23,16 +23,13 @@ import org.springframework.transaction.TransactionStatus;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
/**
|
|
|
* Created by lyr-pc on 2016/10/11.
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class ManageUtilService extends BaseService {
|
|
|
|
|
|
@Autowired
|
|
@ -46,7 +43,9 @@ public class ManageUtilService extends BaseService {
|
|
|
@Autowired
|
|
|
JpaTransactionManager transactionManager;
|
|
|
|
|
|
static int page = 0;
|
|
|
public static int page = 0;
|
|
|
public static List<Integer> errorPages = new ArrayList<>();
|
|
|
public static List<Long> errorSigns = new ArrayList<>();
|
|
|
|
|
|
/**
|
|
|
* 清洗头同步签约数据分组
|
|
@ -58,7 +57,7 @@ public class ManageUtilService extends BaseService {
|
|
|
|
|
|
while (flag) {
|
|
|
PageRequest pageRequest = new PageRequest(page, 1000);
|
|
|
Page<SignFamily> signs = signFamilyDao.findByTypeAndSignSource(2, "1",pageRequest);
|
|
|
Page<SignFamily> signs = signFamilyDao.findByTypeAndSignSource(2, "1", pageRequest);
|
|
|
|
|
|
if (signs != null && signs.getContent().size() == 1000) {
|
|
|
page++;
|
|
@ -72,145 +71,448 @@ public class ManageUtilService extends BaseService {
|
|
|
|
|
|
try {
|
|
|
for (SignFamily sign : signs) {
|
|
|
if (StringUtils.isNotEmpty(sign.getTeamCode())) {
|
|
|
continue;
|
|
|
}
|
|
|
try {
|
|
|
if (StringUtils.isNotEmpty(sign.getTeamCode())) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
//建立团队
|
|
|
DoctorTeam doctorTeam = new DoctorTeam();
|
|
|
String doctorTeamCode = getCode();
|
|
|
|
|
|
doctorTeam.setCode(doctorTeamCode);
|
|
|
doctorTeam.setCzrq(new Date());
|
|
|
doctorTeam.setName("团队名称:" + sign.getName());
|
|
|
doctorTeam.setSignType("2");//家庭签约
|
|
|
doctorTeam.setDel("1");
|
|
|
|
|
|
teamDao.save(doctorTeam);
|
|
|
|
|
|
//添加团队成员
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctor())) {
|
|
|
//添加全科
|
|
|
DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctor());
|
|
|
wlyyDoctorTeamDoctor.setName(sign.getDoctorName());
|
|
|
wlyyDoctorTeamDoctor.setDel("1");
|
|
|
wlyyDoctorTeamDoctor.setType(2);
|
|
|
wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamDoctor.setCode(getCode());
|
|
|
wlyyDoctorTeamDoctor.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamDoctor);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
|
|
|
//添加健康管理师
|
|
|
DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctorHealth());
|
|
|
wlyyDoctorTeamDoctor.setName(sign.getDoctorHealthName());
|
|
|
wlyyDoctorTeamDoctor.setDel("1");
|
|
|
wlyyDoctorTeamDoctor.setType(3);
|
|
|
wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamDoctor.setCode(getCode());
|
|
|
wlyyDoctorTeamDoctor.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamDoctor);
|
|
|
}
|
|
|
//建立团队
|
|
|
DoctorTeam doctorTeam = new DoctorTeam();
|
|
|
String doctorTeamCode = getCode();
|
|
|
|
|
|
doctorTeam.setCode(doctorTeamCode);
|
|
|
doctorTeam.setCzrq(new Date());
|
|
|
doctorTeam.setName("团队名称:" + sign.getName());
|
|
|
doctorTeam.setSignType("2");//家庭签约
|
|
|
doctorTeam.setDel("1");
|
|
|
|
|
|
teamDao.save(doctorTeam);
|
|
|
|
|
|
//添加团队成员
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctor())) {
|
|
|
//添加全科
|
|
|
DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctor());
|
|
|
wlyyDoctorTeamDoctor.setName(sign.getDoctorName());
|
|
|
wlyyDoctorTeamDoctor.setDel("1");
|
|
|
wlyyDoctorTeamDoctor.setType(2);
|
|
|
wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamDoctor.setCode(getCode());
|
|
|
wlyyDoctorTeamDoctor.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamDoctor);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
|
|
|
//添加健康管理师
|
|
|
DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctorHealth());
|
|
|
wlyyDoctorTeamDoctor.setName(sign.getDoctorHealthName());
|
|
|
wlyyDoctorTeamDoctor.setDel("1");
|
|
|
wlyyDoctorTeamDoctor.setType(3);
|
|
|
wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamDoctor.setCode(getCode());
|
|
|
wlyyDoctorTeamDoctor.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamDoctor);
|
|
|
}
|
|
|
|
|
|
//添加患者和团队的关系
|
|
|
DoctorTeamMember wlyyDoctorTeamPatient = new DoctorTeamMember();
|
|
|
//添加患者和团队的关系
|
|
|
DoctorTeamMember wlyyDoctorTeamPatient = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamPatient.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamPatient.setMemberCode(sign.getPatient());
|
|
|
wlyyDoctorTeamPatient.setName(sign.getName());
|
|
|
wlyyDoctorTeamPatient.setDel("1");
|
|
|
wlyyDoctorTeamPatient.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamPatient.setType(5);
|
|
|
wlyyDoctorTeamPatient.setCode(getCode());
|
|
|
wlyyDoctorTeamPatient.setCzrq(new Date());
|
|
|
wlyyDoctorTeamPatient.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamPatient.setMemberCode(sign.getPatient());
|
|
|
wlyyDoctorTeamPatient.setName(sign.getName());
|
|
|
wlyyDoctorTeamPatient.setDel("1");
|
|
|
wlyyDoctorTeamPatient.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamPatient.setType(5);
|
|
|
wlyyDoctorTeamPatient.setCode(getCode());
|
|
|
wlyyDoctorTeamPatient.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamPatient);
|
|
|
teamMemberDao.save(wlyyDoctorTeamPatient);
|
|
|
|
|
|
if (StringUtils.isEmpty(sign.getIdcard())) {
|
|
|
System.out.println("error:sign-family-set-group:no-idcard:" + sign.getId());
|
|
|
continue;
|
|
|
}
|
|
|
if (StringUtils.isEmpty(sign.getIdcard())) {
|
|
|
System.out.println("error:sign-family-set-group:no-idcard:" + sign.getId());
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
int age = IdCardUtil.getAgeForIdcard(sign.getIdcard());
|
|
|
String groupCode = "1";
|
|
|
int age = IdCardUtil.getAgeForIdcard(sign.getIdcard());
|
|
|
String groupCode = "1";
|
|
|
|
|
|
if (age >= 65) {
|
|
|
groupCode = "3";
|
|
|
}
|
|
|
if (age >= 65) {
|
|
|
groupCode = "3";
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
|
|
|
//把病人添加到健康管理师的健康分组里
|
|
|
DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
|
|
|
|
|
|
doctorPatientGroupInfo.setCzrq(new Date());
|
|
|
doctorPatientGroupInfo.setDoctor(sign.getDoctorHealth());
|
|
|
doctorPatientGroupInfo.setStatus(1);
|
|
|
doctorPatientGroupInfo.setPatient(sign.getPatient());
|
|
|
doctorPatientGroupInfo.setPname(sign.getName());
|
|
|
doctorPatientGroupInfo.setPartAmount(0);
|
|
|
doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
|
|
|
doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
|
|
|
doctorPatientGroupInfo.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(doctorPatientGroupInfo);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
|
|
|
//把病人添加到健康管理师的健康分组里
|
|
|
DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
|
|
|
|
|
|
doctorPatientGroupInfo.setCzrq(new Date());
|
|
|
doctorPatientGroupInfo.setDoctor(sign.getDoctorHealth());
|
|
|
doctorPatientGroupInfo.setStatus(1);
|
|
|
doctorPatientGroupInfo.setPatient(sign.getPatient());
|
|
|
doctorPatientGroupInfo.setPname(sign.getName());
|
|
|
doctorPatientGroupInfo.setPartAmount(0);
|
|
|
doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
|
|
|
doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
|
|
|
doctorPatientGroupInfo.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(doctorPatientGroupInfo);
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctor())) {
|
|
|
//把病人添加到全科医生的健康分组里
|
|
|
DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
|
|
|
|
|
|
doctorPatientGroupInfo.setCzrq(new Date());
|
|
|
doctorPatientGroupInfo.setDoctor(sign.getDoctor());
|
|
|
doctorPatientGroupInfo.setStatus(1);
|
|
|
doctorPatientGroupInfo.setPatient(sign.getPatient());
|
|
|
doctorPatientGroupInfo.setPname(sign.getName());
|
|
|
doctorPatientGroupInfo.setPartAmount(0);
|
|
|
doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
|
|
|
doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
|
|
|
doctorPatientGroupInfo.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(doctorPatientGroupInfo);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctor())) {
|
|
|
//把病人添加到全科医生的健康分组里
|
|
|
DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
|
|
|
|
|
|
doctorPatientGroupInfo.setCzrq(new Date());
|
|
|
doctorPatientGroupInfo.setDoctor(sign.getDoctor());
|
|
|
doctorPatientGroupInfo.setStatus(1);
|
|
|
doctorPatientGroupInfo.setPatient(sign.getPatient());
|
|
|
doctorPatientGroupInfo.setPname(sign.getName());
|
|
|
doctorPatientGroupInfo.setPartAmount(0);
|
|
|
doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
|
|
|
doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
|
|
|
doctorPatientGroupInfo.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(doctorPatientGroupInfo);
|
|
|
}
|
|
|
|
|
|
List<DoctorPatientGroupInfo> groups = groupInfoDao.findPatientGroups(sign.getPatient());
|
|
|
List<DoctorPatientGroupInfo> groups = groupInfoDao.findPatientGroups(sign.getPatient());
|
|
|
|
|
|
if (groups != null && groups.size() > 0) {
|
|
|
for (DoctorPatientGroupInfo group : groups) {
|
|
|
if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
|
|
|
continue;
|
|
|
}
|
|
|
if (groups != null && groups.size() > 0) {
|
|
|
for (DoctorPatientGroupInfo group : groups) {
|
|
|
if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
DoctorPatientGroupInfo patientGroup = new DoctorPatientGroupInfo();
|
|
|
DoctorPatientGroupInfo patientGroup = new DoctorPatientGroupInfo();
|
|
|
|
|
|
patientGroup.setCzrq(new Date());
|
|
|
patientGroup.setDoctor(group.getDoctor());
|
|
|
patientGroup.setStatus(1);
|
|
|
patientGroup.setPatient(sign.getPatient());
|
|
|
patientGroup.setPname(sign.getName());
|
|
|
patientGroup.setPartAmount(0);
|
|
|
patientGroup.setGroup(group.getGroup());
|
|
|
patientGroup.setQyrq(sign.getApplyDate());
|
|
|
patientGroup.setSignType("2");//家庭签约
|
|
|
patientGroup.setCzrq(new Date());
|
|
|
patientGroup.setDoctor(group.getDoctor());
|
|
|
patientGroup.setStatus(1);
|
|
|
patientGroup.setPatient(sign.getPatient());
|
|
|
patientGroup.setPname(sign.getName());
|
|
|
patientGroup.setPartAmount(0);
|
|
|
patientGroup.setGroup(group.getGroup());
|
|
|
patientGroup.setQyrq(sign.getApplyDate());
|
|
|
patientGroup.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(patientGroup);
|
|
|
groupInfoDao.save(patientGroup);
|
|
|
}
|
|
|
}
|
|
|
sign.setTeamCode(doctorTeamCode);
|
|
|
signFamilyDao.save(sign);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
errorSigns.add(sign.getId());
|
|
|
}
|
|
|
sign.setTeamCode(doctorTeamCode);
|
|
|
signFamilyDao.save(sign);
|
|
|
}
|
|
|
//事物提交
|
|
|
transactionManager.commit(status);
|
|
|
} catch (Exception e) {
|
|
|
errorPages.add(page - 1);
|
|
|
transactionManager.rollback(status);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 执行某一页
|
|
|
*
|
|
|
* @param page
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void setSignTeamAndGroupByPage(int page) throws Exception {
|
|
|
PageRequest pageRequest = new PageRequest(page, 1000);
|
|
|
Page<SignFamily> signs = signFamilyDao.findByTypeAndSignSource(2, "1", pageRequest);
|
|
|
|
|
|
for (SignFamily sign : signs) {
|
|
|
if (StringUtils.isNotEmpty(sign.getTeamCode())) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
//建立团队
|
|
|
DoctorTeam doctorTeam = new DoctorTeam();
|
|
|
String doctorTeamCode = getCode();
|
|
|
|
|
|
doctorTeam.setCode(doctorTeamCode);
|
|
|
doctorTeam.setCzrq(new Date());
|
|
|
doctorTeam.setName("团队名称:" + sign.getName());
|
|
|
doctorTeam.setSignType("2");//家庭签约
|
|
|
doctorTeam.setDel("1");
|
|
|
|
|
|
teamDao.save(doctorTeam);
|
|
|
|
|
|
//添加团队成员
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctor())) {
|
|
|
//添加全科
|
|
|
DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctor());
|
|
|
wlyyDoctorTeamDoctor.setName(sign.getDoctorName());
|
|
|
wlyyDoctorTeamDoctor.setDel("1");
|
|
|
wlyyDoctorTeamDoctor.setType(2);
|
|
|
wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamDoctor.setCode(getCode());
|
|
|
wlyyDoctorTeamDoctor.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamDoctor);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
|
|
|
//添加健康管理师
|
|
|
DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctorHealth());
|
|
|
wlyyDoctorTeamDoctor.setName(sign.getDoctorHealthName());
|
|
|
wlyyDoctorTeamDoctor.setDel("1");
|
|
|
wlyyDoctorTeamDoctor.setType(3);
|
|
|
wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamDoctor.setCode(getCode());
|
|
|
wlyyDoctorTeamDoctor.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamDoctor);
|
|
|
}
|
|
|
|
|
|
//添加患者和团队的关系
|
|
|
DoctorTeamMember wlyyDoctorTeamPatient = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamPatient.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamPatient.setMemberCode(sign.getPatient());
|
|
|
wlyyDoctorTeamPatient.setName(sign.getName());
|
|
|
wlyyDoctorTeamPatient.setDel("1");
|
|
|
wlyyDoctorTeamPatient.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamPatient.setType(5);
|
|
|
wlyyDoctorTeamPatient.setCode(getCode());
|
|
|
wlyyDoctorTeamPatient.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamPatient);
|
|
|
|
|
|
if (StringUtils.isEmpty(sign.getIdcard())) {
|
|
|
System.out.println("error:sign-family-set-group:no-idcard:" + sign.getId());
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
int age = IdCardUtil.getAgeForIdcard(sign.getIdcard());
|
|
|
String groupCode = "1";
|
|
|
|
|
|
if (age >= 65) {
|
|
|
groupCode = "3";
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
|
|
|
//把病人添加到健康管理师的健康分组里
|
|
|
DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
|
|
|
|
|
|
doctorPatientGroupInfo.setCzrq(new Date());
|
|
|
doctorPatientGroupInfo.setDoctor(sign.getDoctorHealth());
|
|
|
doctorPatientGroupInfo.setStatus(1);
|
|
|
doctorPatientGroupInfo.setPatient(sign.getPatient());
|
|
|
doctorPatientGroupInfo.setPname(sign.getName());
|
|
|
doctorPatientGroupInfo.setPartAmount(0);
|
|
|
doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
|
|
|
doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
|
|
|
doctorPatientGroupInfo.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(doctorPatientGroupInfo);
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctor())) {
|
|
|
//把病人添加到全科医生的健康分组里
|
|
|
DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
|
|
|
|
|
|
doctorPatientGroupInfo.setCzrq(new Date());
|
|
|
doctorPatientGroupInfo.setDoctor(sign.getDoctor());
|
|
|
doctorPatientGroupInfo.setStatus(1);
|
|
|
doctorPatientGroupInfo.setPatient(sign.getPatient());
|
|
|
doctorPatientGroupInfo.setPname(sign.getName());
|
|
|
doctorPatientGroupInfo.setPartAmount(0);
|
|
|
doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
|
|
|
doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
|
|
|
doctorPatientGroupInfo.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(doctorPatientGroupInfo);
|
|
|
}
|
|
|
|
|
|
List<DoctorPatientGroupInfo> groups = groupInfoDao.findPatientGroups(sign.getPatient());
|
|
|
|
|
|
if (groups != null && groups.size() > 0) {
|
|
|
for (DoctorPatientGroupInfo group : groups) {
|
|
|
if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
DoctorPatientGroupInfo patientGroup = new DoctorPatientGroupInfo();
|
|
|
|
|
|
patientGroup.setCzrq(new Date());
|
|
|
patientGroup.setDoctor(group.getDoctor());
|
|
|
patientGroup.setStatus(1);
|
|
|
patientGroup.setPatient(sign.getPatient());
|
|
|
patientGroup.setPname(sign.getName());
|
|
|
patientGroup.setPartAmount(0);
|
|
|
patientGroup.setGroup(group.getGroup());
|
|
|
patientGroup.setQyrq(sign.getApplyDate());
|
|
|
patientGroup.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(patientGroup);
|
|
|
}
|
|
|
}
|
|
|
sign.setTeamCode(doctorTeamCode);
|
|
|
signFamilyDao.save(sign);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 执行某一条
|
|
|
*
|
|
|
* @param id
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void setSignTeamAndGroupById(Long id) throws Exception {
|
|
|
SignFamily sign = signFamilyDao.findOne(id);
|
|
|
|
|
|
try {
|
|
|
if (StringUtils.isNotEmpty(sign.getTeamCode())) {
|
|
|
throw new Exception("error:sign-family-set-group:team-exist:" + id);
|
|
|
}
|
|
|
|
|
|
//建立团队
|
|
|
DoctorTeam doctorTeam = new DoctorTeam();
|
|
|
String doctorTeamCode = getCode();
|
|
|
|
|
|
doctorTeam.setCode(doctorTeamCode);
|
|
|
doctorTeam.setCzrq(new Date());
|
|
|
doctorTeam.setName("团队名称:" + sign.getName());
|
|
|
doctorTeam.setSignType("2");//家庭签约
|
|
|
doctorTeam.setDel("1");
|
|
|
|
|
|
teamDao.save(doctorTeam);
|
|
|
|
|
|
//添加团队成员
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctor())) {
|
|
|
//添加全科
|
|
|
DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctor());
|
|
|
wlyyDoctorTeamDoctor.setName(sign.getDoctorName());
|
|
|
wlyyDoctorTeamDoctor.setDel("1");
|
|
|
wlyyDoctorTeamDoctor.setType(2);
|
|
|
wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamDoctor.setCode(getCode());
|
|
|
wlyyDoctorTeamDoctor.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamDoctor);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
|
|
|
//添加健康管理师
|
|
|
DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctorHealth());
|
|
|
wlyyDoctorTeamDoctor.setName(sign.getDoctorHealthName());
|
|
|
wlyyDoctorTeamDoctor.setDel("1");
|
|
|
wlyyDoctorTeamDoctor.setType(3);
|
|
|
wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamDoctor.setCode(getCode());
|
|
|
wlyyDoctorTeamDoctor.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamDoctor);
|
|
|
}
|
|
|
|
|
|
//添加患者和团队的关系
|
|
|
DoctorTeamMember wlyyDoctorTeamPatient = new DoctorTeamMember();
|
|
|
|
|
|
wlyyDoctorTeamPatient.setTeam(doctorTeamCode);
|
|
|
wlyyDoctorTeamPatient.setMemberCode(sign.getPatient());
|
|
|
wlyyDoctorTeamPatient.setName(sign.getName());
|
|
|
wlyyDoctorTeamPatient.setDel("1");
|
|
|
wlyyDoctorTeamPatient.setSignType("2");//家庭签约
|
|
|
wlyyDoctorTeamPatient.setType(5);
|
|
|
wlyyDoctorTeamPatient.setCode(getCode());
|
|
|
wlyyDoctorTeamPatient.setCzrq(new Date());
|
|
|
|
|
|
teamMemberDao.save(wlyyDoctorTeamPatient);
|
|
|
|
|
|
if (StringUtils.isEmpty(sign.getIdcard())) {
|
|
|
System.out.println("error:sign-family-set-group:no-idcard:" + sign.getId());
|
|
|
}
|
|
|
|
|
|
int age = IdCardUtil.getAgeForIdcard(sign.getIdcard());
|
|
|
String groupCode = "1";
|
|
|
|
|
|
if (age >= 65) {
|
|
|
groupCode = "3";
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
|
|
|
//把病人添加到健康管理师的健康分组里
|
|
|
DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
|
|
|
|
|
|
doctorPatientGroupInfo.setCzrq(new Date());
|
|
|
doctorPatientGroupInfo.setDoctor(sign.getDoctorHealth());
|
|
|
doctorPatientGroupInfo.setStatus(1);
|
|
|
doctorPatientGroupInfo.setPatient(sign.getPatient());
|
|
|
doctorPatientGroupInfo.setPname(sign.getName());
|
|
|
doctorPatientGroupInfo.setPartAmount(0);
|
|
|
doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
|
|
|
doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
|
|
|
doctorPatientGroupInfo.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(doctorPatientGroupInfo);
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(sign.getDoctor())) {
|
|
|
//把病人添加到全科医生的健康分组里
|
|
|
DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
|
|
|
|
|
|
doctorPatientGroupInfo.setCzrq(new Date());
|
|
|
doctorPatientGroupInfo.setDoctor(sign.getDoctor());
|
|
|
doctorPatientGroupInfo.setStatus(1);
|
|
|
doctorPatientGroupInfo.setPatient(sign.getPatient());
|
|
|
doctorPatientGroupInfo.setPname(sign.getName());
|
|
|
doctorPatientGroupInfo.setPartAmount(0);
|
|
|
doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
|
|
|
doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
|
|
|
doctorPatientGroupInfo.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(doctorPatientGroupInfo);
|
|
|
}
|
|
|
|
|
|
List<DoctorPatientGroupInfo> groups = groupInfoDao.findPatientGroups(sign.getPatient());
|
|
|
|
|
|
if (groups != null && groups.size() > 0) {
|
|
|
for (DoctorPatientGroupInfo group : groups) {
|
|
|
if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
DoctorPatientGroupInfo patientGroup = new DoctorPatientGroupInfo();
|
|
|
|
|
|
patientGroup.setCzrq(new Date());
|
|
|
patientGroup.setDoctor(group.getDoctor());
|
|
|
patientGroup.setStatus(1);
|
|
|
patientGroup.setPatient(sign.getPatient());
|
|
|
patientGroup.setPname(sign.getName());
|
|
|
patientGroup.setPartAmount(0);
|
|
|
patientGroup.setGroup(group.getGroup());
|
|
|
patientGroup.setQyrq(sign.getApplyDate());
|
|
|
patientGroup.setSignType("2");//家庭签约
|
|
|
|
|
|
groupInfoDao.save(patientGroup);
|
|
|
}
|
|
|
}
|
|
|
sign.setTeamCode(doctorTeamCode);
|
|
|
signFamilyDao.save(sign);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
errorSigns.add(sign.getId());
|
|
|
throw new Exception(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|