Преглед изворни кода

Merge branch 'dev' of lyr/patient-co-management into dev

lyr пре 8 година
родитељ
комит
e20450cc17

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -303,6 +303,6 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	@Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 and a.id >= ?3 and a.id <= ?4 order by a.id")
	Page<SignFamily> findByTypeAndSignSourceAndId(Integer type,String signSource,Long start,Long end,Pageable pageable);
	@Query("select a from SignFamily a where a.patient = ?1 and a.status > 0")
	@Query("select a from SignFamily a where a.patient = ?1 and a.status >= 0")
	List<SignFamily> findAllSignByPatient(String patient);
}

+ 57 - 12
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

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

+ 32 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/family/DoctorFamilyController.java

@ -1,9 +1,11 @@
package com.yihu.wlyy.web.doctor.family;
import com.yihu.wlyy.service.app.family.FamilyMemberService;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -11,15 +13,20 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by Administrator on 2016.08.20.
 */
@Controller
@RequestMapping(value = "/doctor/family", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-家庭查询")
public class DoctorFamilyController extends WeixinBaseController{
public class DoctorFamilyController extends WeixinBaseController {
    @Autowired
    private FamilyService familyService;
    @Autowired
    FamilyMemberService familyMemberService;
    //通過患者身份證查找患者家庭成员
    @RequestMapping(value = "/getfamilyMember")
@ -30,8 +37,26 @@ public class DoctorFamilyController extends WeixinBaseController{
            String idcard//患者身份证号
    ) {
        try {
            JSONArray patients = familyService.getfamilyMember(patientCode,idcard,doctorCode);
            return write(200, "查询成功", "list", patients);
            Map<String, JSONObject> result = new HashMap<>();
            JSONArray patients = familyService.getfamilyMember(patientCode, idcard, doctorCode);
            JSONArray patientsCustom = familyMemberService.getPatientFamilyMembers(patientCode, doctorCode);
            if (patients != null) {
                for(int i = 0;i < patients.length(); i++){
                    if(patients.getJSONObject(i).get("idcard") != null) {
                        result.put(patients.getJSONObject(i).getString("idcard"), patients.getJSONObject(i));
                    }
                }
            }
            if (patientsCustom != null) {
                for(int i = 0;i < patientsCustom.length(); i++){
                    if(patientsCustom.getJSONObject(i).get("idcard") != null) {
                        result.put(patientsCustom.getJSONObject(i).getString("idcard"), patientsCustom.getJSONObject(i));
                    }
                }
            }
            return write(200, "查询成功", "list", result.size() > 0 ? result.values() : new JSONArray());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
@ -48,12 +73,12 @@ public class DoctorFamilyController extends WeixinBaseController{
            String relation//关系
    ) {
        try {
            String returnCode=  familyService.inviteFamilyMember(patient,currentPatient,doctor,relation);
            if("-1".equals(returnCode)){
            String returnCode = familyService.inviteFamilyMember(patient, currentPatient, doctor, relation);
            if ("-1".equals(returnCode)) {
                return write(-1, "邀请失败,患者已经签约");
            }else if("-2".equals(returnCode)){
            } else if ("-2".equals(returnCode)) {
                return write(-2, "邀请失败,医生已经邀请过该患者");
            }else if("-3".equals(returnCode)){
            } else if ("-3".equals(returnCode)) {
                return write(-3, "邀请失败,与患者签约的三师医生不一致");
            }
            return write(200, "查询成功");

+ 3 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java

@ -62,6 +62,8 @@ public class FamilyMemberController extends BaseController {
                return error(-1, StringUtils.isNotEmpty(captcha) ? "验证码错误" : "密码错误");
            } else if (result == -4) {
                return error(-1, "该家庭成员已存在");
            } else if (result == 0) {
                return error(-1, "不能添加自己");
            } else {
                return write(200, "添加成功");
            }
@ -142,7 +144,7 @@ public class FamilyMemberController extends BaseController {
    @ApiOperation(value = "家庭成员查询")
    public String getPatientFamilyMembers() {
        try {
            JSONArray result = familyMemberService.getPatientFamilyMembers(getUID());
            JSONArray result = familyMemberService.getPatientFamilyMembers(getUID(),"");
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {