Przeglądaj źródła

慢病管理:修改监测方案的相关方法

huangwenjie 7 lat temu
rodzic
commit
606485eaa9

+ 34 - 51
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -184,7 +184,7 @@ public class DoctorSchemeService {
    /**
     * 医生保存居民的血糖监测方案
     * 医生保存血糖监测方案
     * @param data
     * @throws Exception
     */
@ -193,7 +193,6 @@ public class DoctorSchemeService {
        JSONObject dataObj =  JSON.parseObject(data);
        List<DoctorSchemeBloodSugger> results = new ArrayList<>();
        List<String> patientcodeList = new ArrayList<>();
        String code = dataObj.getString("code");
@ -205,11 +204,6 @@ public class DoctorSchemeService {
        String content = dataObj.getString("content");
        String doctorcode = dataObj.getString("doctorcode");
        JSONArray datalist = dataObj.getJSONArray("list");
        JSONArray patientcodes = dataObj.getJSONArray("patientcodes");
        for (int i = 0; i < patientcodes.size(); i++) {
            patientcodeList.add(datalist.getJSONObject(i).toString());
        }
        for (int i = 0; i < datalist.size(); i++) {
@ -247,40 +241,11 @@ public class DoctorSchemeService {
        }
        if(!results.isEmpty()) {
            //使用事务控制批量更新
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                for (DoctorSchemeBloodSugger doctorSchemeBloodSugger  : results) {
                    doctoreSchemeBloodSuggerDao.save(doctorSchemeBloodSugger);
                }
                PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                for (String patientcode : patientcodeList) {
                    patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode,1,code);
                    patientSchemeListObj.setCode(UUID.randomUUID().toString());
                    patientSchemeListObj.setPatientcode(patientcode);
                    patientSchemeListObj.setSchemecode(code);
                    patientSchemeListObj.setDoctorcode(doctorcode);
                    Short _type = new Short("1");
                    patientSchemeListObj.setType(_type);
                    patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
                    patientSchemeListDao.save(patientSchemeListObj);
                }
                //事务提交
                transactionManager.commit(status);
            } catch (Exception ex) {
                //报错事务回滚
                transactionManager.rollback(status);
            }
            doctoreSchemeBloodSuggerDao.save(results);
        }
    }
    /**
     * 医生保存居民的血压监测方案
     * 医生保存血压监测方案
     * @param data
     * @throws Exception
     */
@ -289,7 +254,6 @@ public class DoctorSchemeService {
        JSONObject dataObj =  JSON.parseObject(data);
        List<DoctorSchemeBloodPressure> results = new ArrayList<>();
        List<String> patientcodeList = new ArrayList<>();
        String code = dataObj.getString("code");
@ -303,10 +267,6 @@ public class DoctorSchemeService {
        JSONArray datalist = dataObj.getJSONArray("list");
        JSONArray patientcodes = dataObj.getJSONArray("patientcodes");
        for (int i = 0; i < patientcodes.size(); i++) {
            patientcodeList.add(datalist.getJSONObject(i).toString());
        }
        for (int i = 0; i < datalist.size(); i++) {
            DoctorSchemeBloodPressure doctorSchemeBloodPressure = new DoctorSchemeBloodPressure();
@ -337,6 +297,34 @@ public class DoctorSchemeService {
        }
        if(!results.isEmpty()) {
            doctoreSchemeBloodPressureDao.save(results);
        }
    }
    /**
     * 医生保存居民监测方案
     *
     * @param doctorcode
     * @param schemecode
     * @param patientcodes
     * @param type
     * @throws Exception
     */
    public void savePatientScheme(String doctorcode, String schemecode, String type,String patientcodes) throws Exception {
        List<String> patientcodeList = new ArrayList<>();
        JSONObject dataObj = JSON.parseObject(patientcodes);
        JSONArray codes = dataObj.getJSONArray("patientcodes");
        if (codes == null || codes.size() == 0) {
            throw new Exception("居民列表不能为空");
        }
        for (int i = 0; i < codes.size(); i++) {
            patientcodeList.add(codes.getJSONObject(i).toString());
        }
        if (!patientcodeList.isEmpty()) {
            //使用事务控制批量更新
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
@ -344,23 +332,18 @@ public class DoctorSchemeService {
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : results) {
                    doctoreSchemeBloodPressureDao.save(doctorSchemeBloodPressure);
                }
                PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                for (String patientcode : patientcodeList) {
                    patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode,0,code);
                    patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode, Integer.parseInt(type), schemecode);
                    patientSchemeListObj.setCode(UUID.randomUUID().toString());
                    patientSchemeListObj.setPatientcode(patientcode);
                    patientSchemeListObj.setSchemecode(code);
                    patientSchemeListObj.setSchemecode(schemecode);
                    patientSchemeListObj.setDoctorcode(doctorcode);
                    Short _type = new Short("2");
                    Short _type = new Short(type);
                    patientSchemeListObj.setType(_type);
                    patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
                    patientSchemeListDao.save(patientSchemeListObj);
                }
                //事务提交
                transactionManager.commit(status);
            } catch (Exception ex) {

+ 22 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheme/DoctroSchemeController.java

@ -84,8 +84,8 @@ public class DoctroSchemeController extends BaseController {
        }
    }
    @RequestMapping(value="/post/save/patient/bloodpressure",method = RequestMethod.POST)
    @ApiOperation("医生保存居民的血压监测方案")
    @RequestMapping(value="/post/save/bloodpressure",method = RequestMethod.POST)
    @ApiOperation("医生保存血压监测方案")
    public String saveDoctorSchemeBloodPressure(
            @ApiParam(name="data", value="JSON数据") @RequestParam(value = "data",required = true) String data){
        try {
@ -99,8 +99,8 @@ public class DoctroSchemeController extends BaseController {
        }
    }
    @RequestMapping(value="/post/save/patient/bloodsugger",method = RequestMethod.POST)
    @ApiOperation("医生保存居民的血糖监测方案")
    @RequestMapping(value="/post/save/bloodsugger",method = RequestMethod.POST)
    @ApiOperation("医生保存血糖监测方案")
    public String saveDoctorSchemeBloodSugger(
            @ApiParam(name="data", value="JSON数据") @RequestParam(value = "data",required = true) String data){
        try {
@ -113,4 +113,22 @@ public class DoctroSchemeController extends BaseController {
            return error(-1, "操作失败,"+e.getMessage());
        }
    }
    @RequestMapping(value="/post/save/patient/scheme",method = RequestMethod.POST)
    @ApiOperation("医生保存居民的血糖监测方案")
    public String savePatientScheme(
            @ApiParam(name="doctorcode", value="医生CODE") @RequestParam(value = "doctorcode",required = true) String doctorcode,
            @ApiParam(name="schemecode", value="方案CODE") @RequestParam(value = "schemecode",required = true) String schemecode,
            @ApiParam(name="type", value="血糖1、血压2") @RequestParam(value = "type",required = true) String type,
            @ApiParam(name="patientcodes", value="JASON数据") @RequestParam(value = "patientcodes",required = true) String patientcodes){
        try {
            doctorSchemeService.savePatientScheme(doctorcode,schemecode,type,patientcodes);
            return write(200, "操作成功");
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败,"+e.getMessage());
        }
    }
}