|
@ -3,11 +3,14 @@ package com.yihu.wlyy.service.app.family;
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
|
|
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
|
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
|
|
import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
|
|
|
|
import com.yihu.wlyy.repository.patient.PatientInvitationLogDao;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.service.app.sign.FamilyContractService;
|
|
import com.yihu.wlyy.service.app.sign.FamilyContractService;
|
|
import com.yihu.wlyy.service.common.SMSService;
|
|
import com.yihu.wlyy.service.common.SMSService;
|
|
|
|
import com.yihu.wlyy.util.IdCardUtil;
|
|
import com.yihu.wlyy.util.MD5;
|
|
import com.yihu.wlyy.util.MD5;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONArray;
|
|
@ -35,6 +38,8 @@ public class FamilyMemberService extends BaseService {
|
|
@Autowired
|
|
@Autowired
|
|
SMSService smsService;
|
|
SMSService smsService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
private PatientInvitationLogDao patientInviteLogDao;
|
|
|
|
@Autowired
|
|
FamilyContractService contractService;
|
|
FamilyContractService contractService;
|
|
@Autowired
|
|
@Autowired
|
|
JdbcTemplate jdbcTemplate;
|
|
JdbcTemplate jdbcTemplate;
|
|
@ -48,7 +53,11 @@ public class FamilyMemberService extends BaseService {
|
|
* @param member 成员
|
|
* @param member 成员
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public int addMember(String patient, String member, String captcha, String password, int relation) {
|
|
|
|
|
|
public int addMember(String patient, String member, String captcha, String password, int relation) throws Exception {
|
|
|
|
if (patient.equals(member)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
Patient p = patientDao.findByCode(patient);
|
|
Patient p = patientDao.findByCode(patient);
|
|
Patient m = patientDao.findByCode(member);
|
|
Patient m = patientDao.findByCode(member);
|
|
|
|
|
|
@ -111,7 +120,7 @@ public class FamilyMemberService extends BaseService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
|
|
|
|
public int modifyFamilyRelation(String patient, String member, int relation) {
|
|
|
|
|
|
public int modifyFamilyRelation(String patient, String member, int relation) throws Exception {
|
|
Patient p = patientDao.findByCode(patient);
|
|
Patient p = patientDao.findByCode(patient);
|
|
Patient m = patientDao.findByCode(member);
|
|
Patient m = patientDao.findByCode(member);
|
|
|
|
|
|
@ -190,9 +199,9 @@ public class FamilyMemberService extends BaseService {
|
|
result.put("isRegister", 0);
|
|
result.put("isRegister", 0);
|
|
} else {
|
|
} else {
|
|
result.put("isRegister", 1);
|
|
result.put("isRegister", 1);
|
|
result.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" :p.getMobile());
|
|
|
|
result.put("name", StringUtils.isEmpty(p.getName()) ? "" :p.getName());
|
|
|
|
result.put("code", StringUtils.isEmpty(p.getCode()) ? "" :p.getCode());
|
|
|
|
|
|
result.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" : p.getMobile());
|
|
|
|
result.put("name", StringUtils.isEmpty(p.getName()) ? "" : p.getName());
|
|
|
|
result.put("code", StringUtils.isEmpty(p.getCode()) ? "" : p.getCode());
|
|
result.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
|
|
result.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
|
|
}
|
|
}
|
|
|
|
|
|
@ -205,7 +214,7 @@ public class FamilyMemberService extends BaseService {
|
|
* @param patient 居民
|
|
* @param patient 居民
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONArray getPatientFamilyMembers(String patient) {
|
|
|
|
|
|
public JSONArray getPatientFamilyMembers(String patient, String doctorCode) {
|
|
JSONArray resultArray = new JSONArray();
|
|
JSONArray resultArray = new JSONArray();
|
|
String sql = "select * " +
|
|
String sql = "select * " +
|
|
" from " +
|
|
" from " +
|
|
@ -224,12 +233,25 @@ public class FamilyMemberService extends BaseService {
|
|
List<SignFamily> signs = contractService.findAllSignByPatient(map.get("code").toString());
|
|
List<SignFamily> signs = contractService.findAllSignByPatient(map.get("code").toString());
|
|
boolean ssSign = false;
|
|
boolean ssSign = false;
|
|
boolean jtSign = false;
|
|
boolean jtSign = false;
|
|
|
|
int status = 0;
|
|
|
|
|
|
for (SignFamily sign : signs) {
|
|
for (SignFamily sign : signs) {
|
|
if (sign.getType() == 1) {
|
|
|
|
|
|
if (sign.getType() == 1 && sign.getStatus() > 0) {
|
|
ssSign = true;
|
|
ssSign = true;
|
|
} else {
|
|
|
|
jtSign = false;
|
|
|
|
|
|
status = 3;
|
|
|
|
} else if (sign.getType() == 2 && sign.getStatus() > 0) {
|
|
|
|
jtSign = true;
|
|
|
|
status = 3;
|
|
|
|
} else if (sign.getStatus() == 0) {
|
|
|
|
status = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(doctorCode)) {
|
|
|
|
List<PatientInvitationLog> patientInviteLog = patientInviteLogDao.getPatientInviteLog(doctorCode,
|
|
|
|
patient, map.get("code").toString());
|
|
|
|
if (patientInviteLog != null && patientInviteLog.size() > 0 && status != 0) {
|
|
|
|
status = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@ -237,11 +259,20 @@ public class FamilyMemberService extends BaseService {
|
|
obj.put("name", map.get("name"));
|
|
obj.put("name", map.get("name"));
|
|
obj.put("sex", map.get("sex"));
|
|
obj.put("sex", map.get("sex"));
|
|
obj.put("birthday", map.get("birthday"));
|
|
obj.put("birthday", map.get("birthday"));
|
|
obj.put("idcard", map.get("idcard"));
|
|
|
|
|
|
obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
|
|
obj.put("photo", map.get("photo"));
|
|
obj.put("photo", map.get("photo"));
|
|
obj.put("mobile", map.get("mobile"));
|
|
obj.put("mobile", map.get("mobile"));
|
|
obj.put("address", map.get("address"));
|
|
obj.put("address", map.get("address"));
|
|
obj.put("familyRelation", map.get("family_relation"));
|
|
obj.put("familyRelation", map.get("family_relation"));
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(doctorCode)) {
|
|
|
|
obj.put("relaholder", map.get("family_relation"));
|
|
|
|
obj.put("addressCode", "");
|
|
|
|
obj.put("addressName", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
|
|
|
|
obj.put("status", status);
|
|
|
|
obj.put("source", 1);
|
|
|
|
}
|
|
|
|
|
|
if (ssSign && jtSign) {
|
|
if (ssSign && jtSign) {
|
|
obj.put("signType", 3);
|
|
obj.put("signType", 3);
|
|
} else if (!ssSign && jtSign) {
|
|
} else if (!ssSign && jtSign) {
|
|
@ -266,7 +297,7 @@ public class FamilyMemberService extends BaseService {
|
|
* @param relation 关系 1父亲 2母亲 3老公 4老婆 5儿子 6女儿 7其他
|
|
* @param relation 关系 1父亲 2母亲 3老公 4老婆 5儿子 6女儿 7其他
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public int familyRelationTrans(Patient patient, int relation) {
|
|
|
|
|
|
public int familyRelationTrans(Patient patient, int relation) throws Exception {
|
|
int relationTrans = 0;
|
|
int relationTrans = 0;
|
|
|
|
|
|
switch (relation) {
|
|
switch (relation) {
|
|
@ -279,6 +310,13 @@ public class FamilyMemberService extends BaseService {
|
|
} else {
|
|
} else {
|
|
relationTrans = 0;
|
|
relationTrans = 0;
|
|
}
|
|
}
|
|
|
|
if(relationTrans == 0) {
|
|
|
|
if (IdCardUtil.getSexForIdcard(StringUtils.isEmpty(patient.getIdcard()) ? "" : patient.getIdcard()).equals("1")) {
|
|
|
|
relationTrans = 6;
|
|
|
|
} else if (IdCardUtil.getSexForIdcard(StringUtils.isEmpty(patient.getIdcard()) ? "" : patient.getIdcard()).equals("2")) {
|
|
|
|
relationTrans = 5;
|
|
|
|
}
|
|
|
|
}
|
|
break;
|
|
break;
|
|
case 3:
|
|
case 3:
|
|
relationTrans = 4;
|
|
relationTrans = 4;
|
|
@ -290,11 +328,18 @@ public class FamilyMemberService extends BaseService {
|
|
case 6:
|
|
case 6:
|
|
if (patient.getSex() == 1) {
|
|
if (patient.getSex() == 1) {
|
|
relationTrans = 1;
|
|
relationTrans = 1;
|
|
} else if (patient.getSex() == 1) {
|
|
|
|
|
|
} else if (patient.getSex() == 2) {
|
|
relationTrans = 2;
|
|
relationTrans = 2;
|
|
} else {
|
|
} else {
|
|
relationTrans = 0;
|
|
relationTrans = 0;
|
|
}
|
|
}
|
|
|
|
if(relationTrans == 0) {
|
|
|
|
if (IdCardUtil.getSexForIdcard(StringUtils.isEmpty(patient.getIdcard()) ? "" : patient.getIdcard()).equals("1")) {
|
|
|
|
relationTrans = 2;
|
|
|
|
} else if (IdCardUtil.getSexForIdcard(StringUtils.isEmpty(patient.getIdcard()) ? "" : patient.getIdcard()).equals("2")) {
|
|
|
|
relationTrans = 1;
|
|
|
|
}
|
|
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|