|
|
@@ -7,7 +7,7 @@ import com.fs.app.annotation.Login;
|
|
|
import com.fs.app.param.FsPatientAddEditParam;
|
|
|
import com.fs.common.annotation.RepeatSubmit;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
-import com.fs.common.exception.CustomException;
|
|
|
+import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.his.config.StoreConfig;
|
|
|
import com.fs.his.domain.FsPatient;
|
|
|
@@ -19,6 +19,7 @@ import com.fs.his.utils.IdCardUtil;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -61,11 +62,62 @@ public class PatientController extends AppBaseController {
|
|
|
fsPatient.setMobile(decryptPhoneMk(fsPatient.getMobile()));
|
|
|
}
|
|
|
}
|
|
|
+ //如果用户关联就诊人为空,就添加默认就诊人返回
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
+ FsPatient fsPatient = addDefaultPatient(map.getUserId());
|
|
|
+ list.add(fsPatient);
|
|
|
+ }
|
|
|
return R.ok().put("data",list);
|
|
|
} catch (Exception e){
|
|
|
return R.error("操作异常");
|
|
|
}
|
|
|
}
|
|
|
+ //创建用户默认就诊人方法
|
|
|
+ private FsPatient addDefaultPatient(Long userId){
|
|
|
+ FsPatient addPatient = new FsPatient();
|
|
|
+ addPatient.setUserId(userId);
|
|
|
+ addPatient.setPatientName("默认就诊人");
|
|
|
+ String idCard = "210522194909263092";
|
|
|
+ addPatient.setIdCard(idCard);
|
|
|
+ // 从身份证号中提取出生日期
|
|
|
+ Date birthday = parseBirthdayFromIdCard(idCard);
|
|
|
+ addPatient.setBirthday(birthday);
|
|
|
+ addPatient.setSex(1);
|
|
|
+ addPatient.setMobile("15502411234");
|
|
|
+ addPatient.setIsDel(0);
|
|
|
+ addPatient.setStatus(1);
|
|
|
+ addPatient.setRelation("其他");
|
|
|
+ addPatient.setLiverUnusual("待填");
|
|
|
+ addPatient.setRenalUnusual("待填");
|
|
|
+ addPatient.setHistoryAllergic("待填");
|
|
|
+ addPatient.setFamilyMedHistory("待填");
|
|
|
+ addPatient.setSelfMedHistory("待填");
|
|
|
+ addPatient.setCreateTime(DateUtils.getNowDate());
|
|
|
+ addPatient.setIsDefault(1);
|
|
|
+ patientService.insertFsPatient(addPatient);
|
|
|
+ return addPatient;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从18位身份证号中解析出生日期
|
|
|
+ * @param idCard 身份证号
|
|
|
+ * @return Date 出生日期,解析失败返回 null
|
|
|
+ */
|
|
|
+ private Date parseBirthdayFromIdCard(String idCard) {
|
|
|
+ if (idCard == null || idCard.length() != 18) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String birthStr = idCard.substring(6, 14); // 格式:yyyyMMdd
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
+ sdf.setLenient(false); // 严格校验日期合法性
|
|
|
+ return sdf.parse(birthStr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 解析失败,记录日志或按业务处理
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Login
|
|
|
@ApiOperation("获取病人详情")
|
|
|
@GetMapping("/getPatientById")
|