|
@ -144,121 +144,153 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
* @param patient
|
|
* @param patient
|
|
* @param item 1基本信息 2日常生活能力 3认知能力 4精神状态与社会交流能力
|
|
|
|
|
|
* @param item 0全部 1基本信息 2日常生活能力 3认知能力 4精神状态与社会交流能力
|
|
* @param year
|
|
* @param year
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONObject getAssessmentItemDetail(String patient,Integer item,String year) throws Exception {
|
|
public JSONObject getAssessmentItemDetail(String patient,Integer item,String year) throws Exception {
|
|
|
|
JSONObject result = new JSONObject();
|
|
String tableName = "";
|
|
String tableName = "";
|
|
String objName="";
|
|
String objName="";
|
|
|
|
String keyName="";
|
|
|
|
Integer tmpItem=item;
|
|
|
|
boolean allSearch=false;
|
|
if(StringUtils.isBlank(year)){
|
|
if(StringUtils.isBlank(year)){
|
|
year = DateUtil.getNowYear()+"";
|
|
year = DateUtil.getNowYear()+"";
|
|
}
|
|
}
|
|
if (item==1){
|
|
|
|
tableName="base_capacity_assessment_baseinfo";
|
|
|
|
objName="com.yihu.jw.entity.care.sign.CapacityAssessmentBaseInfoDo";
|
|
|
|
}else if (item==2){
|
|
|
|
tableName="base_capacity_assessment_living_ability";
|
|
|
|
objName="com.yihu.jw.entity.care.sign.CapacityAssessmentLivingAbilityDo";
|
|
|
|
}else if (item==3){
|
|
|
|
tableName="base_capacity_assessment_cognitive_ability";
|
|
|
|
objName="com.yihu.jw.entity.care.sign.CapacityAssessmentCognitiveAbilityDo";
|
|
|
|
|
|
if (item==0){
|
|
|
|
tmpItem++;
|
|
|
|
allSearch=true;
|
|
}
|
|
}
|
|
else if (item==4){
|
|
|
|
tableName="base_capacity_assessment_social_ability";
|
|
|
|
objName="com.yihu.jw.entity.care.sign.CapacityAssessmentSocialAbilityDo";
|
|
|
|
}
|
|
|
|
else return new JSONObject();
|
|
|
|
|
|
|
|
Class c1 = Class.forName(objName);
|
|
|
|
String sql = "select * from "+tableName+" where patient='"+patient+"' and assessment_year='"+year+"' and status=1";
|
|
|
|
Object O1 =null;
|
|
|
|
Boolean searchFlag=true;
|
|
|
|
try {
|
|
|
|
O1 = jdbcTemplate.queryForObject(sql.toString(),new BeanPropertyRowMapper(c1));
|
|
|
|
}catch (Exception e){
|
|
|
|
searchFlag=false;
|
|
|
|
O1 = c1.newInstance();
|
|
|
|
}
|
|
|
|
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(O1, SerializerFeature.WriteMapNullValue));
|
|
|
|
if (!searchFlag&&item==1){//基本信息带入
|
|
|
|
CapacityAssessmentBaseInfoDo obj = new CapacityAssessmentBaseInfoDo();
|
|
|
|
BasePatientDO patientDo = patientDao.findById(patient);
|
|
|
|
if (patientDo!=null){
|
|
|
|
obj.setPatient(patientDo.getId());
|
|
|
|
obj.setName(patientDo.getName());
|
|
|
|
obj.setSex(patientDo.getSex());
|
|
|
|
obj.setIdcard(patientDo.getIdcard());
|
|
|
|
obj.setAge(IdCardUtil.getAgeForIdcard(patientDo.getIdcard())+"");
|
|
|
|
obj.setNation(patientDo.getNational()==null?null:patientDo.getNational()+"");//名族
|
|
|
|
obj.setNationName(patientDo.getNationalName());
|
|
|
|
obj.setPatientPhone(patientDo.getMobile());//手机
|
|
|
|
obj.setResidencePhone(patientDo.getPhone());//住宅电话
|
|
|
|
obj.setDomicileCounty(patientDo.getTownCode());//户籍 区
|
|
|
|
obj.setDomicileCountyName(patientDo.getTownName());
|
|
|
|
obj.setDomicileStreet(patientDo.getStreetCode());//户籍 街道
|
|
|
|
obj.setDomicileStreetName(patientDo.getStreetName());
|
|
|
|
obj.setLiveCounty(patientDo.getLiveTownCode());
|
|
|
|
obj.setLiveCountyName(patientDo.getLiveTownName());
|
|
|
|
obj.setLiveStreet(patientDo.getLiveStreetCode());
|
|
|
|
obj.setLiveStreetName(patientDo.getLiveStreetName());
|
|
|
|
jsonObject = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
|
|
for(;tmpItem<=4;) {
|
|
|
|
if (tmpItem == 1) {
|
|
|
|
tableName = "base_capacity_assessment_baseinfo";
|
|
|
|
objName = "com.yihu.jw.entity.care.sign.CapacityAssessmentBaseInfoDo";
|
|
|
|
keyName = "baseinfo";
|
|
|
|
} else if (tmpItem == 2) {
|
|
|
|
tableName = "base_capacity_assessment_living_ability";
|
|
|
|
objName = "com.yihu.jw.entity.care.sign.CapacityAssessmentLivingAbilityDo";
|
|
|
|
keyName = "living_ability";
|
|
|
|
} else if (tmpItem == 3) {
|
|
|
|
tableName = "base_capacity_assessment_cognitive_ability";
|
|
|
|
objName = "com.yihu.jw.entity.care.sign.CapacityAssessmentCognitiveAbilityDo";
|
|
|
|
keyName = "cognitive_ability";
|
|
|
|
} else if (tmpItem == 4) {
|
|
|
|
tableName = "base_capacity_assessment_social_ability";
|
|
|
|
objName = "com.yihu.jw.entity.care.sign.CapacityAssessmentSocialAbilityDo";
|
|
|
|
keyName = "social_ability";
|
|
|
|
}
|
|
|
|
Class c1 = Class.forName(objName);
|
|
|
|
String sql = "select * from " + tableName + " where patient='" + patient + "' and assessment_year='" + year + "' and status=1";
|
|
|
|
Object O1 = null;
|
|
|
|
Boolean searchFlag = true;
|
|
|
|
try {
|
|
|
|
O1 = jdbcTemplate.queryForObject(sql.toString(), new BeanPropertyRowMapper(c1));
|
|
|
|
} catch (Exception e) {
|
|
|
|
searchFlag = false;
|
|
|
|
O1 = c1.newInstance();
|
|
}
|
|
}
|
|
|
|
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(O1, SerializerFeature.WriteMapNullValue));
|
|
|
|
if (!searchFlag && item == 1) {//基本信息带入
|
|
|
|
CapacityAssessmentBaseInfoDo obj = new CapacityAssessmentBaseInfoDo();
|
|
|
|
BasePatientDO patientDo = patientDao.findById(patient);
|
|
|
|
if (patientDo != null) {
|
|
|
|
obj.setPatient(patientDo.getId());
|
|
|
|
obj.setName(patientDo.getName());
|
|
|
|
obj.setSex(patientDo.getSex());
|
|
|
|
obj.setIdcard(patientDo.getIdcard());
|
|
|
|
obj.setAge(IdCardUtil.getAgeForIdcard(patientDo.getIdcard()) + "");
|
|
|
|
obj.setNation(patientDo.getNational() == null ? null : patientDo.getNational() + "");//名族
|
|
|
|
obj.setNationName(patientDo.getNationalName());
|
|
|
|
obj.setPatientPhone(patientDo.getMobile());//手机
|
|
|
|
obj.setResidencePhone(patientDo.getPhone());//住宅电话
|
|
|
|
obj.setDomicileCounty(patientDo.getTownCode());//户籍 区
|
|
|
|
obj.setDomicileCountyName(patientDo.getTownName());
|
|
|
|
obj.setDomicileStreet(patientDo.getStreetCode());//户籍 街道
|
|
|
|
obj.setDomicileStreetName(patientDo.getStreetName());
|
|
|
|
obj.setLiveCounty(patientDo.getLiveTownCode());
|
|
|
|
obj.setLiveCountyName(patientDo.getLiveTownName());
|
|
|
|
obj.setLiveStreet(patientDo.getLiveStreetCode());
|
|
|
|
obj.setLiveStreetName(patientDo.getLiveStreetName());
|
|
|
|
jsonObject = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
result.put(keyName, jsonObject);
|
|
|
|
if (allSearch){
|
|
|
|
tmpItem++;
|
|
|
|
}
|
|
|
|
else break;
|
|
}
|
|
}
|
|
return jsonObject;
|
|
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
* @param json
|
|
* @param json
|
|
* @param item 1基本信息 2日常生活能力 3认知能力 4精神状态与社会交流能力
|
|
|
|
|
|
* @param item 0全部 1基本信息 2日常生活能力 3认知能力 4精神状态与社会交流能力
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONObject saveAssessmentItemDetail(String json,Integer item){
|
|
public JSONObject saveAssessmentItemDetail(String json,Integer item){
|
|
String year = DateUtil.getNowYear()+"";
|
|
String year = DateUtil.getNowYear()+"";
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if (item==1){
|
|
|
|
CapacityAssessmentBaseInfoDo obj = JSON.parseObject(json,CapacityAssessmentBaseInfoDo.class);
|
|
|
|
List<CapacityAssessmentBaseInfoDo> tmp = CAbaseInfoDao.findByPatientAndYear(obj.getPatient(),year);
|
|
|
|
if (tmp.size()>0){
|
|
|
|
obj.setId(tmp.get(0).getId());
|
|
|
|
}
|
|
|
|
obj.setStatus(1);
|
|
|
|
obj.setAssessmentYear(year);
|
|
|
|
CAbaseInfoDao.save(obj);
|
|
|
|
result = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
}else if (item==2){
|
|
|
|
CapacityAssessmentLivingAbilityDo obj = JSON.parseObject(json,CapacityAssessmentLivingAbilityDo.class);
|
|
|
|
List<CapacityAssessmentLivingAbilityDo> tmp = CALivingAbilityDao.findByPatientAndYear(obj.getPatient(),year);
|
|
|
|
if (tmp.size()>0){
|
|
|
|
obj.setId(tmp.get(0).getId());
|
|
|
|
}
|
|
|
|
obj.setStatus(1);
|
|
|
|
obj.setAssessmentYear(year);
|
|
|
|
CALivingAbilityDao.save(obj);
|
|
|
|
result = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
}else if (item==3){
|
|
|
|
CapacityAssessmentCognitiveAbilityDo obj = JSON.parseObject(json,CapacityAssessmentCognitiveAbilityDo.class);
|
|
|
|
List<CapacityAssessmentCognitiveAbilityDo> tmp = CACognitiveAbilityDao.findByPatientAndYear(obj.getPatient(),year);
|
|
|
|
if (tmp.size()>0){
|
|
|
|
obj.setId(tmp.get(0).getId());
|
|
|
|
}
|
|
|
|
obj.setStatus(1);
|
|
|
|
obj.setAssessmentYear(year);
|
|
|
|
CACognitiveAbilityDao.save(obj);
|
|
|
|
result = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
}else if (item==4){
|
|
|
|
CapacityAssessmentSocialAbilityDo obj = JSON.parseObject(json,CapacityAssessmentSocialAbilityDo.class);
|
|
|
|
List<CapacityAssessmentSocialAbilityDo> tmp = CASocialAbilityDao.findByPatientAndYear(obj.getPatient(),year);
|
|
|
|
if (tmp.size()>0){
|
|
|
|
obj.setId(tmp.get(0).getId());
|
|
|
|
}
|
|
|
|
obj.setStatus(1);
|
|
|
|
obj.setAssessmentYear(year);
|
|
|
|
CASocialAbilityDao.save(obj);
|
|
|
|
result = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
|
|
JSONObject jsonObj = JSONObject.parseObject(json);
|
|
|
|
boolean saveAll = false;
|
|
|
|
if (item==0){
|
|
|
|
saveAll=true;
|
|
|
|
}
|
|
|
|
if (item==1||saveAll){
|
|
|
|
String tmpStr = jsonObj.getString("baseinfo");
|
|
|
|
CapacityAssessmentBaseInfoDo obj = JSON.parseObject(tmpStr,CapacityAssessmentBaseInfoDo.class);
|
|
|
|
List<CapacityAssessmentBaseInfoDo> tmp = CAbaseInfoDao.findByPatientAndYear(obj.getPatient(),year);
|
|
|
|
if (tmp.size()>0){
|
|
|
|
obj.setId(tmp.get(0).getId());
|
|
|
|
}
|
|
|
|
obj.setStatus(1);
|
|
|
|
obj.setAssessmentYear(year);
|
|
|
|
CAbaseInfoDao.save(obj);
|
|
|
|
JSONObject resultTmp = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
result.put("baseinfo",resultTmp);
|
|
|
|
}
|
|
|
|
if (item==2||saveAll){
|
|
|
|
String tmpStr = jsonObj.getString("living_ability");
|
|
|
|
CapacityAssessmentLivingAbilityDo obj = JSON.parseObject(tmpStr,CapacityAssessmentLivingAbilityDo.class);
|
|
|
|
List<CapacityAssessmentLivingAbilityDo> tmp = CALivingAbilityDao.findByPatientAndYear(obj.getPatient(),year);
|
|
|
|
if (tmp.size()>0){
|
|
|
|
obj.setId(tmp.get(0).getId());
|
|
|
|
}
|
|
|
|
obj.setStatus(1);
|
|
|
|
obj.setAssessmentYear(year);
|
|
|
|
CALivingAbilityDao.save(obj);
|
|
|
|
JSONObject resultTmp = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
result.put("living_ability",resultTmp);
|
|
|
|
}
|
|
|
|
if (item==3||saveAll){
|
|
|
|
String tmpStr = jsonObj.getString("cognitive_ability");
|
|
|
|
CapacityAssessmentCognitiveAbilityDo obj = JSON.parseObject(tmpStr,CapacityAssessmentCognitiveAbilityDo.class);
|
|
|
|
List<CapacityAssessmentCognitiveAbilityDo> tmp = CACognitiveAbilityDao.findByPatientAndYear(obj.getPatient(),year);
|
|
|
|
if (tmp.size()>0){
|
|
|
|
obj.setId(tmp.get(0).getId());
|
|
|
|
}
|
|
|
|
obj.setStatus(1);
|
|
|
|
obj.setAssessmentYear(year);
|
|
|
|
CACognitiveAbilityDao.save(obj);
|
|
|
|
JSONObject resultTmp = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
result.put("cognitive_ability",resultTmp);
|
|
|
|
}
|
|
|
|
if (item==4||saveAll){
|
|
|
|
String tmpStr = jsonObj.getString("social_ability");
|
|
|
|
CapacityAssessmentSocialAbilityDo obj = JSON.parseObject(tmpStr,CapacityAssessmentSocialAbilityDo.class);
|
|
|
|
List<CapacityAssessmentSocialAbilityDo> tmp = CASocialAbilityDao.findByPatientAndYear(obj.getPatient(),year);
|
|
|
|
if (tmp.size()>0){
|
|
|
|
obj.setId(tmp.get(0).getId());
|
|
|
|
}
|
|
|
|
obj.setStatus(1);
|
|
|
|
obj.setAssessmentYear(year);
|
|
|
|
CASocialAbilityDao.save(obj);
|
|
|
|
JSONObject resultTmp = JSON.parseObject(JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue));
|
|
|
|
result.put("social_ability",resultTmp);
|
|
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
}
|