yeshijie před 8 roky
rodič
revize
bb17906008

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

@ -91,7 +91,7 @@ public class FamilyMemberService extends BaseService {
            return -2;
        }
        if (relation < 5) {
        if (relation>0&&relation < 5) {//家庭关系为父亲、母亲、老公、老婆时只能有一个
            List<PatientFamilyMember> familyMembers = memberDao.findByPatientAndFamilyRelation(patient, relation);
            if (familyMembers != null && familyMembers.size() > 0) {
@ -355,6 +355,25 @@ public class FamilyMemberService extends BaseService {
        return obj;
    }
    /**
     * 撤销添加家人
     * @param id
     * @return
     */
    public int revokeAddMember(Long id){
        PatientFamilyTemp temp = patientFamilyTempDao.findOne(id);
        if("1".equals(temp.getState())){
            return 1;
        }else if("2".equals(temp.getState())){
            return 2;
        }else if("3".equals(temp.getState())){
            return 3;
        }else if("0".equals(temp.getState())){
            temp.setState("3");
            patientFamilyTempDao.save(temp);
        }
        return 200;
    }
    /**
     * 获取所有家庭成员,包括自己
@ -479,10 +498,12 @@ public class FamilyMemberService extends BaseService {
                    }
                }
                Integer isAuthorize = (Integer)map.get("is_authorize");
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                obj.put("isAuthorize", isAuthorize);//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
@ -497,6 +518,19 @@ public class FamilyMemberService extends BaseService {
                    obj.put("addressName", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                    obj.put("status", status);
                    obj.put("source", 1);
                    if (isAuthorize==1){
                        PatientFamilyMember familyMember = memberDao.findByPatientAndFamilyMember(String.valueOf(map.get("family_member")),patient);
                        if(familyMember.getIsAuthorize()==1){
                            obj.put("authorizeStatus", 1);//相互授权
                        }else {
                            obj.put("authorizeStatus", 2);//居民单方向向家人授权
                        }
                    }else {
                        obj.put("authorizeStatus", 3);//居民被家人授权
                    }
                }
                if (ssSign && jtSign) {
@ -508,11 +542,38 @@ public class FamilyMemberService extends BaseService {
                } else {
                    obj.put("signType", 0);
                }
                obj.put("state","1");//0 :未处理;1:已同意;2:已拒绝
                obj.put("id",map.get("id"));
                resultArray.put(obj);
            }
        }
        //待审核记录
        if(StringUtils.isBlank(doctorCode)){
            List<PatientFamilyTemp> tempList = patientFamilyTempDao.findByPatientAndState(patient,"0");
            if(tempList!=null&&tempList.size()>0){
                for (PatientFamilyTemp temp:tempList){
                    JSONObject obj = new JSONObject();
                    Patient p = patientDao.findByCode(temp.getFamilyMember());
                    obj.put("code", p.getCode());
                    obj.put("name", p.getName());
                    obj.put("sex", p.getSex());
                    obj.put("isAuthorize", 0);//0:未授权,1:已授权
                    obj.put("birthday", p.getBirthday());
                    obj.put("idcard", StringUtils.isEmpty(p.getIdcard()) ? "" : p.getIdcard());
                    obj.put("photo", p.getPhoto());
                    obj.put("mobile", p.getMobile());
                    obj.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
                    obj.put("familyRelation", temp.getFamilyRelation());
                    obj.put("familyRelationName", relations.get(temp.getFamilyRelation()));
                    obj.put("signType", 0);
                    obj.put("state","0");//0 :未处理;1:已同意;2:已拒绝
                    obj.put("id",temp.getId());
                    resultArray.put(obj);
                }
            }
        }
        return resultArray;
    }
@ -541,26 +602,30 @@ public class FamilyMemberService extends BaseService {
     * @param patient
     * @return
     */
    public JSONArray getAuthorizeMembers(String patient){
    public JSONArray getAuthorizeMembers(String patient) throws Exception{
        JSONArray resultArray = new JSONArray();
        resultArray.put(getPatient(patient));
        String sql = "select * " +
                " from " +
                "    wlyy_patient_family_member t1, " +
                "    wlyy_patient t2 " +
                " where " +
                "        t1.patient = ? " +
                "    and t1.is_authorize = 1 " +
                "    and t1.family_member = t2.code order by t1.family_relation ";
//        String sql = "select * " +
//                " from " +
//                "    wlyy_patient_family_member t1, " +
//                "    wlyy_patient t2 " +
//                " where " +
//                "        t1.patient = ? " +
//                "    and t1.is_authorize = 1 " +
//                "    and t1.family_member = t2.code order by t1.family_relation ";
//
//        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient});
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient});
        if (result != null && result.size() > 0) {
        List<PatientFamilyMember> list = memberDao.findByFamilyMemberAndIsAuthorize(patient,1);
        if (list != null && list.size() > 0) {
            JSONArray tem = new JSONArray();
            for (Map<String, Object> map : result) {
            for (PatientFamilyMember member : list) {
                JSONObject obj = new JSONObject();
                List<SignFamily> signs = contractService.findAllSignByPatient(map.get("code").toString());
                Patient p = patientDao.findByCode(member.getPatient());
                List<SignFamily> signs = contractService.findAllSignByPatient(p.getCode());
                boolean ssSign = false;
                boolean jtSign = false;
@ -573,20 +638,20 @@ public class FamilyMemberService extends BaseService {
                    }
                }
                Integer family_relation = Integer.valueOf(map.get("family_relation").toString());
                Integer relation = familyRelationTrans(p,member.getFamilyRelation());
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                String idCard = StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString();
                obj.put("code", p.getCode());
                obj.put("name", p.getName());
                obj.put("sex", p.getSex());
                obj.put("isAuthorize", member.getIsAuthorize());//0:未授权,1:已授权
                obj.put("birthday", p.getBirthday());
                String idCard = StringUtils.isEmpty(p.getIdcard()) ? "" : p.getIdcard();
                obj.put("idcard", CommonUtil.getIdcardEncode(idCard));
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("ssc", map.get("ssc"));
                obj.put("familyRelation", family_relation);
                obj.put("familyRelationName", relations.get(map.get("family_relation")));
                obj.put("photo", p.getPhoto());
                obj.put("mobile", p.getMobile());
                obj.put("ssc", p.getSex());
                obj.put("familyRelation", relation);
                obj.put("familyRelationName", relations.get(relation));
                if (ssSign && jtSign) {
                    obj.put("signType", 3);
@ -598,7 +663,7 @@ public class FamilyMemberService extends BaseService {
                    obj.put("signType", 0);
                }
                if(family_relation==0){
                if(member.getIsAuthorize()==0){
                    tem.put(obj);
                }else {
                    resultArray.put(obj);
@ -657,6 +722,7 @@ public class FamilyMemberService extends BaseService {
            obj.put("familyRelation", "-1");
            obj.put("familyRelationName", "自己");
            obj.put("isAuthorize", 1);//0:未授权,1:已授权
            obj.put("authorizeStatus", 3);//
            if (ssSign && jtSign) {
                obj.put("signType", 3);
@ -1002,7 +1068,7 @@ public class FamilyMemberService extends BaseService {
    @Transactional
    public int addMemberFamily(Patient p, Patient m, String patient, String member, int relation) throws Exception {
        if (relation < 5) {
        if (relation>0&&relation < 5) {
            List<PatientFamilyMember> familyMembers = memberDao.findByPatientAndFamilyRelation(patient, relation);
            if (familyMembers != null && familyMembers.size() > 0) {