diff --git a/cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/service/SictUser.java b/cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/service/SictUser.java index 5d0f01f028d9fc6055ea2391e87c8cc355ce136e..c32436f8089859e219fe8bd448c2400776260ab1 100644 --- a/cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/service/SictUser.java +++ b/cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/service/SictUser.java @@ -9,7 +9,7 @@ import org.springframework.security.core.userdetails.User; import java.util.Collection; /** - * @Description TODO 扩展用户信息 + * @Description 扩展用户信息 * @Author * @Date */ diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/constant/PatientConstant.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/constant/PatientConstant.java index 398c8f2901ac3225410efbe02f03eae60da5c1ae..d214b641a20ed54d241b26ce145e5e733d0fea8d 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/constant/PatientConstant.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/constant/PatientConstant.java @@ -82,6 +82,14 @@ public class PatientConstant { public static final String DIABETES = "diabetes"; public static final String OTHER = "other"; public static final String GENDER_1 = "男"; + /** + * 国标性别:男 + */ + public static final String NORMAL_GENDER_1 = "1"; + /** + * 国标性别:女 + */ + public static final String NORMAL_GENDER_2 = "2"; public static Byte getGender(String gender) { if (GENDER_1.equals(gender)) { @@ -89,4 +97,18 @@ public class PatientConstant { } return Constant.BYTE_NO; } + + + /** + * 获取国标性别 + * + * @param gender + * @return + */ + public static String getNomalGender(String gender) { + if (GENDER_1.equals(gender)) { + return NORMAL_GENDER_1; + } + return NORMAL_GENDER_2; + } } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/AppointmentController.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/AppointmentController.java index 4bdfa803203230d523301a4a30339a20abe1effd..f8fce834ac8a49c18dd52682dc4ff76eb14c443b 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/AppointmentController.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/AppointmentController.java @@ -1,11 +1,30 @@ package cn.sh.stc.sict.theme.hphy.controller.mp; +import cn.hutool.core.net.Ipv4Util; +import cn.hutool.core.util.StrUtil; +import cn.sh.stc.sict.cloud.common.core.constant.Constant; import cn.sh.stc.sict.cloud.common.core.util.R; +import cn.sh.stc.sict.cloud.common.core.util.WebUtils; +import cn.sh.stc.sict.cloud.common.security.util.SecurityUtils; +import cn.sh.stc.sict.cloud.upms.dto.CurrentUser; +import cn.sh.stc.sict.theme.hphy.constant.PatientConstant; +import cn.sh.stc.sict.theme.hphy.model.HpAppointment; +import cn.sh.stc.sict.theme.hphy.model.HpDocInfo; +import cn.sh.stc.sict.theme.hphy.model.HpHosInfo; +import cn.sh.stc.sict.theme.hphy.model.HphyPatientBase; +import cn.sh.stc.sict.theme.hphy.service.HpAppointmentService; +import cn.sh.stc.sict.theme.hphy.service.HpDocInfoService; +import cn.sh.stc.sict.theme.hphy.service.HphyPatientBaseService; import cn.sh.stc.sict.theme.hphy.wd.*; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.netty.util.internal.MacAddressUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import ma.glasnost.orika.MapperFactory; +import ma.glasnost.orika.impl.DefaultMapperFactory; import org.springframework.web.bind.annotation.*; /** @@ -18,48 +37,129 @@ import org.springframework.web.bind.annotation.*; @Api(tags = "[C]预约挂号管理") public class AppointmentController { + private HpAppointmentService hpAppointmentService; + private HpDocInfoService hpDocInfoService; + private HphyPatientBaseService hphyPatientBaseService; + @ApiOperation("预约须知") @GetMapping("/app/rule") - public R getAppRule(HosInfo hosInfo){ + public R getAppRule(HosInfo hosInfo) { HospitalCfg cfg = WanDaHttpUtil.getHospitalCfg(hosInfo); return new R(cfg); } @ApiOperation("预约") @PostMapping("/app") - public R appointment(@RequestBody OrderInfo orderInfo){ - - AppResult result = WanDaHttpUtil.submitOrderByUserInfo(orderInfo); - - // TODO 调用service存入mysql - - return new R(); + public R appointment(@RequestBody OrderInfo order) { + CurrentUser current = SecurityUtils.getCurrentUser(); + if (StrUtil.isBlank(current.getOpenId())) { + return new R().error("患者信息异常!"); + } + if (StrUtil.isBlank(order.getHosOrgCode())) { + return new R().error("预约医院信息不可为空!"); + } + if (StrUtil.isBlank(order.getDoctorId())) { + return new R().error("预约医生信息不可为空!"); + } + if (StrUtil.isBlank(order.getScheduleId()) || StrUtil.isBlank(order.getNumSourceId())) { + return new R().error("预约排班号源信息不可为空!"); + } + HphyPatientBase patient = hphyPatientBaseService.getByOpenId(current.getOpenId()); + if (null == patient) { + return new R().error("未找到患者信息!"); + } + HpDocInfo docInfo = hpDocInfoService.getById(order.getDoctorId()); + if (null == docInfo) { + return new R().error("未找到医生信息!"); + } + order.setOneDeptCode(docInfo.getOneDeptCode()); + order.setDeptCode(docInfo.getDeptCode()); + order.setOrderType(WanDaConstant.ORDER_TYPE_OUTP); + order.setResourceCode(docInfo.getResourceCode()); + order.setChannelCode(WanDaConstant.CHANNEL_CODE_OTHER); + order.setPayMode(WanDaConstant.PAY_MODE_HOSP); + order.setUserCardType(WanDaConstant.USER_CARD_TYPE_ID); + order.setUserCardId(patient.getCertId()); + order.setUserName(patient.getName()); + order.setUserPhone(patient.getPhone()); + order.setUserSex(PatientConstant.getNomalGender(patient.getGender())); + order.setReplaceUserCardType(WanDaConstant.USER_CARD_TYPE_ID); + order.setReplaceUserCardId(patient.getCertId()); + order.setReplaceUserName(patient.getName()); + order.setIpAddr(WebUtils.getIP()); + order.setMacAddr(WanDaConstant.DEFAULT_MAC_ADDR); + order.setPlatformCode(WanDaConstant.PLATFORM_CODE); + order.setPlatformType(WanDaConstant.PLATFORM_TYPE); + order.setChannelName(WanDaConstant.CHANNEL_NAME); + order.setNumSourceFrom(WanDaConstant.NUM_SOURCE_FROM); + AppResult result = WanDaHttpUtil.submitOrderByUserInfo(order); + if (null != result) { + MapperFactory factory = new DefaultMapperFactory.Builder().build(); + HpAppointment app = factory.getMapperFacade().map(order, HpAppointment.class); + app.setOrderId(result.getOrderId()); + app.setPatientId(patient.getId().toString()); + app.setDoctorId(docInfo.getId().toString()); + app.setResourceCertId(docInfo.getPersonId()); + app.setNumSourceDetailId(result.getNumSourceDetailId()); + app.setNumPassword(result.getNumPassword()); + app.setRoom(result.getRoom()); + app.setHosNumSourceId(result.getHosNumSourceId()); + app.setStatus(Constant.STRING_NO); + hpAppointmentService.save(app); + return new R().success(result); + } + return new R().error("预约失败!"); } - @ApiOperation("取消预约") @PostMapping("/cancel/app") - public R cancelAppointment(@RequestBody CancelOrderInfo orderInfo){ - - boolean flag = WanDaHttpUtil.orderCancelInfo(orderInfo); - - // TODO 调用service存入mysql - - return new R(); + public R cancelAppointment(@RequestBody CancelOrderInfo order) { + if (StrUtil.isBlank(order.getAppId())) { + return new R().error("预约信息不可为空!"); + } + HpAppointment app = hpAppointmentService.getById(order.getAppId()); + if (null == app) { + return new R().error("未找到预约信息!"); + } + boolean flag = WanDaHttpUtil.orderCancelInfo(order); + + if (flag) { + HpAppointment update = new HpAppointment(); + update.setId(app.getId()); + update.setStatus(Constant.STRING_YES); + hpAppointmentService.updateById(update); + return new R(); + } + return new R().error("取消预约失败!"); } @ApiOperation("预约列表") @GetMapping("/app/list") - public R appList(){ - - return new R(); + public R appList(Page page, + @RequestParam(value = "startDate", required = false) String startDate, + @RequestParam(value = "endDate", required = false) String endDate) { + CurrentUser current = SecurityUtils.getCurrentUser(); + if (StrUtil.isBlank(current.getOpenId())) { + return new R().error("患者信息异常!"); + } + HphyPatientBase patient = hphyPatientBaseService.getByOpenId(current.getOpenId()); + if (null == patient) { + return new R().error("未找到患者信息!"); + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.ge(StrUtil.isNotBlank(startDate), HpAppointment::getNumSourceDate, startDate) + .le(StrUtil.isNotBlank(endDate), HpAppointment::getNumSourceDate, endDate) + .orderByDesc(HpAppointment::getCreateTime); + page = hpAppointmentService.page(page, wrapper); + + return new R(page); } @ApiOperation("预约详情") @GetMapping("/app/info") - public R appInfo(){ - - return new R(); + public R appInfo(@RequestParam("appId")String appId) { + HpAppointment app = hpAppointmentService.getById(appId); + return new R(app); } } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HpAppointment.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HpAppointment.java index 331cd683dbd3c08e6d6206176bdc54601da00c83..ae69033b85ef6eb2c7f067d9c92fcb2d49fc2a45 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HpAppointment.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HpAppointment.java @@ -1,5 +1,7 @@ package cn.sh.stc.sict.theme.hphy.model; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.annotations.ApiModelProperty; @@ -7,6 +9,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; +import java.util.Date; /** * [黄浦]预约记录(HpAppointment)表实体类 @@ -19,111 +22,139 @@ import java.io.Serializable; public class HpAppointment extends Model { //id @TableId - @ApiModelProperty(hidden = false, value = "id") + @ApiModelProperty(value = "id") private Long id; //医院代码 - @ApiModelProperty(hidden = false, value = "医院代码") + @ApiModelProperty(value = "医院代码") private String hosOrgCode; //一级科室代码 - @ApiModelProperty(hidden = false, value = "一级科室代码") + @ApiModelProperty(value = "一级科室代码") private String oneDeptCode; //二级科室代码 - @ApiModelProperty(hidden = false, value = "二级科室代码") + @ApiModelProperty(value = "二级科室代码") private String deptCode; //预约类型:1-医生 2-门诊 - @ApiModelProperty(hidden = false, value = "预约类型:1-医生 2-门诊") + @ApiModelProperty(value = "预约类型:1-医生 2-门诊") private String orderType; //医生|门诊代码 - @ApiModelProperty(hidden = false, value = "医生|门诊代码") + @ApiModelProperty(value = "医生|门诊代码") private String resourceCode; + @ApiModelProperty(value = "医生|门诊代码 姓名") + private String resourceName; + @ApiModelProperty(value = "医生证件号") + private String resourceCertId; //预约渠道方式:1-官网 2-微信 3-app 4-支付宝 5-电话 6-转诊预约 7-(1+1+1)转诊预约 8-现场预约 0-其他 - @ApiModelProperty(hidden = false, value = "预约渠道方式:1-官网 2-微信 3-app 4-支付宝 5-电话 6-转诊预约 7-(1+1+1)转诊预约 8-现场预约 0-其他") + @ApiModelProperty(value = "预约渠道方式:1-官网 2-微信 3-app 4-支付宝 5-电话 6-转诊预约 7-(1+1+1)转诊预约 8-现场预约 0-其他") private String channelCode; //排班id - @ApiModelProperty(hidden = false, value = "排班id") + @ApiModelProperty(value = "排班id") private String scheduleId; //号源id - @ApiModelProperty(hidden = false, value = "号源id") + @ApiModelProperty(value = "号源id") private String numSourceId; //支付方式 - @ApiModelProperty(hidden = false, value = "支付方式") + @ApiModelProperty(value = "支付方式") private String payMode; //预约患者类型 - @ApiModelProperty(hidden = false, value = "预约患者类型") + @ApiModelProperty(value = "预约患者类型") private String patientType; //1+1+1 签约编号 - @ApiModelProperty(hidden = false, value = "1+1+1 签约编号") + @ApiModelProperty(value = "1+1+1 签约编号") private String patientId; //就诊人卡号 - @ApiModelProperty(hidden = false, value = "就诊人卡号") + @ApiModelProperty(value = "就诊人卡号") private String mediCardId; //就诊人卡类型 - @ApiModelProperty(hidden = false, value = "就诊人卡类型") + @ApiModelProperty(value = "就诊人卡类型") private String mediCardType; //就诊人证件类型 - @ApiModelProperty(hidden = false, value = "就诊人证件类型") + @ApiModelProperty(value = "就诊人证件类型") private String userCardType; //就诊人证件号码 - @ApiModelProperty(hidden = false, value = "就诊人证件号码") + @ApiModelProperty(value = "就诊人证件号码") private String userCardId; //就诊人姓名 - @ApiModelProperty(hidden = false, value = "就诊人姓名") + @ApiModelProperty(value = "就诊人姓名") private String userName; //手机号码 - @ApiModelProperty(hidden = false, value = "手机号码") + @ApiModelProperty(value = "手机号码") private String userPhone; //就诊人性别 - @ApiModelProperty(hidden = false, value = "就诊人性别") + @ApiModelProperty(value = "就诊人性别") private String userSex; //就诊人出生日期 - @ApiModelProperty(hidden = false, value = "就诊人出生日期") + @ApiModelProperty(value = "就诊人出生日期") private String userBd; //就诊人联系地址 - @ApiModelProperty(hidden = false, value = "就诊人联系地址") + @ApiModelProperty(value = "就诊人联系地址") private String userContAdd; //预约人证件类型 - @ApiModelProperty(hidden = false, value = "预约人证件类型") + @ApiModelProperty(value = "预约人证件类型") private String replaceUserCardType; //预约人证件号码 - @ApiModelProperty(hidden = false, value = "预约人证件号码") + @ApiModelProperty(value = "预约人证件号码") private String replaceUserCardId; //预约人姓名 - @ApiModelProperty(hidden = false, value = "预约人姓名") + @ApiModelProperty(value = "预约人姓名") private String replaceUserName; //ip地址 - @ApiModelProperty(hidden = false, value = "ip地址") + @ApiModelProperty(value = "ip地址") private String ipAddr; //mac地址 - @ApiModelProperty(hidden = false, value = "mac地址") + @ApiModelProperty(value = "mac地址") private String macAddr; //预约转诊转出机构代码(1+1+1预约转诊专用) - @ApiModelProperty(hidden = false, value = "预约转诊转出机构代码(1+1+1预约转诊专用)") + @ApiModelProperty(value = "预约转诊转出机构代码(1+1+1预约转诊专用)") private String outHospitalCode; //预约转诊转出机构本地转诊id - @ApiModelProperty(hidden = false, value = "预约转诊转出机构本地转诊id") + @ApiModelProperty(value = "预约转诊转出机构本地转诊id") private String outOrderId; //号源日期 - @ApiModelProperty(hidden = false, value = "号源日期") + @ApiModelProperty(value = "号源日期") private String numSourceDate; //就诊_开始时段 - @ApiModelProperty(hidden = false, value = "就诊_开始时段") + @ApiModelProperty(value = "就诊_开始时段") private String startTime; //就诊_结束时段 - @ApiModelProperty(hidden = false, value = "就诊_结束时段") + @ApiModelProperty(value = "就诊_结束时段") private String endTime; //预约平台类型 - @ApiModelProperty(hidden = false, value = "预约平台类型") + @ApiModelProperty(value = "预约平台类型") private String platformType; //预约平台菜吗 - @ApiModelProperty(hidden = false, value = "预约平台菜吗") + @ApiModelProperty(value = "预约平台菜吗") private String platformCode; //预约渠道描述 - @ApiModelProperty(hidden = false, value = "预约渠道描述") + @ApiModelProperty(value = "预约渠道描述") private String channelName; //号源来源 - @ApiModelProperty(hidden = false, value = "号源来源") + @ApiModelProperty(value = "号源来源") private String numSourceFrom; + @ApiModelProperty(value = "状态:0-默认 1-取消预约") + private String status; + + private String doctorId; + private String orderId; + private String visitNo; + private String numSourceDetailId; + private String numPassword; + private String room; + private String hosNumSourceId; + + /** + * + */ + @TableField(fill = FieldFill.INSERT) + @ApiModelProperty(hidden = true, value = "") + private Date createTime; + /** + * + */ + @TableField(fill = FieldFill.UPDATE) + @ApiModelProperty(hidden = true, value = "") + private Date updateTime; + /** * 获取主键值 diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HphyPatientBase.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HphyPatientBase.java index 6a61ca4a2ac86bf279aa70839485c70ee7e093ec..4882e20bf3b7de173977c43221057cdd4f449246 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HphyPatientBase.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HphyPatientBase.java @@ -125,7 +125,7 @@ public class HphyPatientBase extends Model { @ApiModelProperty(value = "卡类型") private String mediCardType; - @ApiModelProperty(value = "卡类型") + @ApiModelProperty(value = "企业名称") private String enterpriseName; @TableField(exist = false) diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/CancelOrderInfo.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/CancelOrderInfo.java index 38cea80e72bda19bec47b4637eebe25d4d556ea1..eae05a5c8b1ed9d131d794a47e8a491f0451427f 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/CancelOrderInfo.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/CancelOrderInfo.java @@ -1,11 +1,14 @@ package cn.sh.stc.sict.theme.hphy.wd; +import com.thoughtworks.xstream.annotations.XStreamAlias; import lombok.Data; @Data +@XStreamAlias("OrderInfo") public class CancelOrderInfo { - private String hosOrgCode ; - private String orderId ; + private String hosOrgCode; + private String orderId; private String cancelReason; - private String cancelObj ; + private String cancelObj; + private String appId; } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/OrderInfo.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/OrderInfo.java index 82ec8b0783638c3e52a20a23189d477d450486a3..d4e7255874d1e828417e0630fdb7a5f8d27e0ed5 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/OrderInfo.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/OrderInfo.java @@ -4,6 +4,7 @@ import lombok.Data; @Data public class OrderInfo { + private String doctorId; private String hosOrgCode; private String oneDeptCode; private String deptCode; diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaConstant.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..18c8661b49efab4d789fb4481c5dbc1461fdc047 --- /dev/null +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaConstant.java @@ -0,0 +1,38 @@ +package cn.sh.stc.sict.theme.hphy.wd; + +public class WanDaConstant { + + /** + * 预约类型:医生 + */ + public static final String ORDER_TYPE_OUTP = "1"; + + + /** + * 预约方式:其他 + */ + public static final String CHANNEL_CODE_OTHER = "9"; + + /** + * 支付方式:到院支付 + */ + public static final String PAY_MODE_HOSP = "3"; + + /** + * 就诊人卡类型:1-身份证 + */ + public static final String USER_CARD_TYPE_ID = "1"; + + /** + * 默认mac地址 + */ + public static final String DEFAULT_MAC_ADDR = "FF-FF-FF-FF-FF-FF"; + + public static final String PLATFORM_TYPE = "0"; + + public static final String PLATFORM_CODE = "高血压精准导医平台"; + + public static final String CHANNEL_NAME = "高血压精准导医平台"; + + public static final String NUM_SOURCE_FROM = "3"; +}