1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453 |
- package xcx_mobile_api_controller_go
-
- import (
- "Xcx_New/controllers/mobile_api_controllers"
- "Xcx_New/enums"
- "Xcx_New/models"
- "Xcx_New/service"
- "Xcx_New/utils"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "github.com/shopspring/decimal"
- "strconv"
- "time"
- )
-
- func XcxApiControllersRegisterRouters() {
- ////传送codeinit
- beego.Router("/xcx/m/api/code", &XcxApiController{}, "Get:GetCodeInit")
- //获取验证码
- beego.Router("/xcx/api/mobile/code", &XcxApiController{}, "Post:GetCodeInfo")
- //用户绑定
- beego.Router("/xcx/api/mobile/register", &XcxApiController{}, "Get:GetUserNameRegister")
- //手机号登录
- beego.Router("/xcx/api/mobile/login", &XcxApiController{}, "Get:GetLoginInfor")
-
- //openid登录
- beego.Router("/xcx/api/openid/login", &XcxApiController{}, "Get:GetLoginInfoByOpenid")
-
- //获取二维码信息
- beego.Router("/xcx/api/mobile/patient", &XcxApiController{}, "Get:GetPatientList")
-
- //获取登录后的信息
- beego.Router("/xcx/api/mobile/getdatainfo", &XcxApiController{}, "Get:GetDataInfo")
-
- //获取排班数据
- beego.Router("/xcx/api/mobile/schedulebyweek", &XcxApiController{}, "Post:GetSchedulesByWeek")
-
- //获取排班数据
- beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
-
- //获取透析记录
- beego.Router("/xcx/api/mobile/dialysis", &XcxApiController{}, "Get:GetMobileSchedule")
-
- //获取体重纪录
- beego.Router("/xcx/api/mobile/signweight", &XcxApiController{}, "Get:GetSignsByWeight")
-
- //获取血压纪录
- beego.Router("/xcx/api/mobile/signblood", &XcxApiController{}, "Get:GetSignsByBlood")
-
- //获取患者的电子病历
- beego.Router("/xcx/api/mobile/getpatientinfo", &XcxApiController{}, "Get:GetPatientInfo")
-
- //获取机构名称
- beego.Router("/xcx/api/mobile/getorginfo", &XcxApiController{}, "Get:GetOrgInfo")
-
- //获取宣教信息
- beego.Router("/xcx/api/mobile/geteducation", &XcxApiController{}, "Get:GetEducationList")
-
- //获取医嘱信息
- beego.Router("/xcx/api/mobile/getdoctoradvice", &XcxApiController{}, "Get:GetDoctorAdvice")
-
- //获取机构医生护士的姓名
- beego.Router("/xcx/api/mobile/getdoctorname", &XcxApiController{}, "Get:GetDoctorName")
-
- //获取显示配置
- beego.Router("/xcx/api/moible/getfieldconfig", &XcxApiController{}, "Get:GetFieldConfig")
-
- //获取数据字典数据
- beego.Router("/xcx/api/mobile/getdataconfig", &XcxApiController{}, "Get:GetDataConfig")
-
- //检验检查列表
- beego.Router("/xcx/api/mobile/getinspectionlist", &XcxApiController{}, "Get:GetInspectionList")
-
- //检验检查详情
- beego.Router("/xcx/api/mobile/getinspectioninfo", &XcxApiController{}, "Get:GetInspectionInfo")
-
- //肾有杯
- beego.Router("/xcx/api/mobile/getarticlist", &XcxApiController{}, "Get:GetArticList")
-
- beego.Router("/xcx/api/mobile/getarticlistdetail", &XcxApiController{}, "Get:GetArticListDetail")
-
- beego.Router("/xcx/api/mobile/getstoryscore", &XcxApiController{}, "Get:GetStoryScoreList")
-
- //获取appid
- beego.Router("/xcx/api/mobile/getappid", &XcxApiController{}, "Get:GetAppId")
-
- // 获取充值当前余额信息
- beego.Router("/xcx/api/mobile/getbalance", &XcxApiController{}, "Get:IdToBalance")
-
- // 获取一段时间内
- beego.Router("/xcx/api/mobile/getbalanceinfo", &XcxApiController{}, "Get:DepositFlow")
- }
-
- type XcxApiController struct {
- mobile_api_controllers.MobileBaseAPIController
- }
-
- // 根据id获取押金流水
- func (this *XcxApiController) DepositFlow() {
- orgid, _ := this.GetInt64("org_id", 0)
- patient_id, _ := this.GetInt64("patient_id", 0) //患者id
- //获取当前患者的姓名
- tmp, _ := service.GetHisUserName(orgid, patient_id)
- name := tmp.Name
-
- start_time := this.GetString("start_time", "") //开始时间
- end_time := this.GetString("end_time", "") //结束时间
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var stime int64 //开始时间
- var etime int64 //结束时间
- if start_time == "" || end_time == "" {
- //如果为空则查全部的
- stime, etime = service.GetMonth()
- } else {
- stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- stime = stmp.Unix()
- etime = etmp.Unix()
- }
- ////获取该角色当前时间段的余额
- //decimal := service.GetMoneyforTime(id, orgid, etime)
- //获取列表
- deposirhistory, errs := service.GetFlowList(patient_id, orgid, stime, etime)
- if errs != nil {
- utils.ErrorLog("获取列表失败,原因为:", errs.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
- return
- }
- var expenditure, recharge decimal.Decimal
-
- for i := 0; i < len(deposirhistory); i++ {
- //如果为扣费,或退费 则把订单id变为就诊号
- if deposirhistory[i].DepositStatus == 1 || deposirhistory[i].DepositStatus == 3 || deposirhistory[i].DepositStatus == 4 {
- recharge = recharge.Add(deposirhistory[i].Deposit)
- }
-
- if deposirhistory[i].DepositStatus == 2 {
- expenditure = expenditure.Add(deposirhistory[i].Deposit)
- }
-
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": deposirhistory,
- "name": name,
- "start_time": time.Unix(stime, 0).Format("2006-01-02"),
- "end_time": time.Unix(etime, 0).Format("2006-01-02"),
- "expenditure": expenditure,
- "recharge": recharge,
- })
- return
- }
-
- // 根据患者id查询患者的余额
- func (this *XcxApiController) IdToBalance() {
-
- orgid, _ := this.GetInt64("org_id", 0)
- his_patient_id, _ := this.GetInt64("patient_id", 0)
- if orgid <= 0 || his_patient_id <= 0 {
- this.ServeSuccessJSON(map[string]interface{}{
- "error_code": 1001,
- "error_msg": "参数错误",
- })
- }
- balance := service.GetUserMoney(his_patient_id, orgid)
- patient, _ := service.GetPatientByIdXcx(his_patient_id)
- this.ServeSuccessJSON(map[string]interface{}{
- "balance": balance,
- "patient": patient,
- })
- return
- }
-
- func (this *XcxApiController) GetCodeInit() {
- redisClient := service.RedisClient()
- defer redisClient.Close()
- req := this.Ctx.Request
- addr := utils.GetIP(req)
- cur_time := time.Now().Format("2006-01-02")
- _, err := redisClient.Get("ip:host_" + cur_time + "_" + addr).Result()
- if err != nil {
- redisClient.Set("ip:host_"+cur_time+"_"+addr, 0, time.Second*24*60*60)
- }
- //将客户端的ip加密传给前端,作为短信验证的密钥,来验证短信发送的IP地址
- aespass := utils.AESEncrypt(addr)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "aespass": aespass,
- })
-
- }
-
- func (this *XcxApiController) GetUserNameRegister() {
- // name := this.GetString("name")
- // relationship := this.GetString("relationship")
- id_card_no := this.GetString("id_card_no")
- mobile := this.GetString("mobile")
- // code := this.GetString("code")
- openid := this.GetString("openid")
-
- if len(mobile) == 0 || len(openid) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- // redisClient := service.RedisClient()
- // defer redisClient.Close()
- // cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
- // utils.TraceLog("cache_code:%v code:%v", cache_code, code)
- // if cache_code != code {
- // this.ServeSuccessJSON(map[string]interface{}{
- // "err_code": "1001",
- // "err_msg": "验证码错误",
- // })
- // return
- // }
-
- // this.Ctx.SetCookie("mobile", mobile)
- // // 注册成功后验证码就要使其失效
- // redisClient.Del("code_msg_" + mobile)
-
- patient, errcodes := service.GetPatientByIdcardno(id_card_no)
- if errcodes == nil {
- role := models.XcxAdminUserRole{
- PatientName: patient.Name,
- // Relationship: relationship,
- IdCardNo: id_card_no,
- Mobile: mobile,
- // Code: code,
- PatientId: patient.ID,
- UserOrgId: patient.UserOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Appid: "",
- Appsecret: "",
- SessionKey: "",
- Openid: openid,
- }
- err := service.CreateXcxAdminUser(role)
- if err == nil {
- //mobilePatient, _ := service.GetNamePatient(name, id_card_no)
- //template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
- ////处方
- //prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
- //
- ////接诊评估
- //receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
- //
- ////透前评估
- //dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
- //
- ////透析上机
- //dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
- //
- ////透析监测
- //monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
- //
- ////透后评估
- //dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
- //
- //treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
- //var configList interface{}
- //configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "role": role,
- "is_bind": true,
- "err_code": "0",
- "err_msg": "",
- //"patient": mobilePatient,
- //"template_id": template_id,
- "user_org_id": patient.UserOrgId,
- //"prescripition_config": prescripition_config,
- //"receive_treatement_config": receive_treatement_config,
- //"dialysis_befor": dialysis_befor,
- //"dialysis_order": dialysis_order,
- //"monitor_record": monitor_record,
- //"dialysis_after": dialysis_after,
- //"treate_ment": treate_ment,
- //"configList": configList,
- //"result": false,
- })
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": false,
- "msg": "绑定失败",
- "result": false,
- })
- }
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": false,
- "msg": "绑定失败,没有对应的患者信息",
- "result": false,
- })
- }
- }
-
- func (this *XcxApiController) GetUserRegister() {
-
- //用户绑定
- name := this.GetString("name")
- id_card_no := this.GetString("id_card_no")
- fmt.Println("id_card_no", id_card_no)
- mobile := this.GetString("mobile")
- code := this.GetString("code")
-
- if len(code) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeVerificationCodeWrong)
- return
- }
-
- if code == "000000" {
- patient, errcodes := service.GetMobilePatient(mobile, id_card_no)
- fmt.Println("errcodes2323232232", errcodes)
- if errcodes == nil {
- role := models.XcxAdminUserRole{
- PatientName: name,
- IdCardNo: id_card_no,
- Mobile: mobile,
- Code: code,
- PatientId: patient.ID,
- UserOrgId: patient.UserOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Appid: "",
- Appsecret: "",
- SessionKey: "",
- }
-
- //查找该电话号码是否存在
- _, errcode := service.GetMobilePatientOne(mobile)
- if errcode == gorm.ErrRecordNotFound {
- err := service.CreateXcxAdminUser(role)
- if err == nil {
- mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
- template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
- //处方
- prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
-
- //接诊评估
- receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
-
- //透前评估
- dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
-
- //透析上机
- dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
-
- //透析监测
- monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
-
- //透后评估
- dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
-
- treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
- var configList interface{}
- configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "role": role,
- "is_bind": true,
- "patient": mobilePatient,
- "template_id": template_id,
- "user_org_id": mobilePatient.UserOrgId,
- "prescripition_config": prescripition_config,
- "receive_treatement_config": receive_treatement_config,
- "dialysis_befor": dialysis_befor,
- "dialysis_order": dialysis_order,
- "monitor_record": monitor_record,
- "dialysis_after": dialysis_after,
- "treate_ment": treate_ment,
- "configList": configList,
- "result": false,
- })
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": false,
- "msg": "绑定失败",
- "result": false,
- })
- }
- } else if errcode == nil {
- mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
- template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
- //处方
- prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
-
- //接诊评估
- receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
-
- //透前评估
- dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
-
- //透析上机
- dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
-
- //透析监测
- monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
-
- //透后评估
- dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
-
- treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
- var configList interface{}
- configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": true,
- "patient": mobilePatient,
- "template_id": template_id,
- "user_org_id": mobilePatient.UserOrgId,
- "prescripition_config": prescripition_config,
- "receive_treatement_config": receive_treatement_config,
- "dialysis_befor": dialysis_befor,
- "dialysis_order": dialysis_order,
- "monitor_record": monitor_record,
- "dialysis_after": dialysis_after,
- "treate_ment": treate_ment,
- "list": configList,
- "result": false,
- })
- }
-
- fmt.Println("roler", role)
- } else if errcodes == gorm.ErrRecordNotFound {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": false,
- "result": false,
- })
- }
- this.ServeJSON()
- } else {
- redisClient := service.RedisClient()
- defer redisClient.Close()
- cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
- fmt.Println("cache_code9999999293323232322323", cache_code)
- if cache_code != code {
- this.ServeSuccessJSON(map[string]interface{}{
- "result": false,
- })
- return
- } else {
- this.Ctx.SetCookie("mobile", mobile)
- // 注册成功后验证码就要使其失效
- redisClient.Del("code_msg_" + mobile)
- patient, errcodes := service.GetMobilePatient(mobile, id_card_no)
- fmt.Println("errcodes2323232232", errcodes)
- if errcodes == nil {
- role := models.XcxAdminUserRole{
- PatientName: name,
- IdCardNo: id_card_no,
- Mobile: mobile,
- Code: code,
- PatientId: patient.ID,
- UserOrgId: patient.UserOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Appid: "",
- Appsecret: "",
- SessionKey: "",
- }
-
- //查找该电话号码是否存在
- _, errcode := service.GetMobilePatientOne(mobile)
- if errcode == gorm.ErrRecordNotFound {
- err := service.CreateXcxAdminUser(role)
- if err == nil {
- mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
- template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
- //处方
- prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
-
- //接诊评估
- receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
-
- //透前评估
- dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
-
- //透析上机
- dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
-
- //透析监测
- monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
-
- //透后评估
- dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
-
- treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
- var configList interface{}
- configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "role": role,
- "is_bind": true,
- "patient": mobilePatient,
- "template_id": template_id,
- "user_org_id": mobilePatient.UserOrgId,
- "prescripition_config": prescripition_config,
- "receive_treatement_config": receive_treatement_config,
- "dialysis_befor": dialysis_befor,
- "dialysis_order": dialysis_order,
- "monitor_record": monitor_record,
- "dialysis_after": dialysis_after,
- "treate_ment": treate_ment,
- "configList": configList,
- "result": false,
- })
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": false,
- "msg": "绑定失败",
- "result": false,
- })
- }
- } else if errcode == nil {
- mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
- template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
- //处方
- prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
-
- //接诊评估
- receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
-
- //透前评估
- dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
-
- //透析上机
- dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
-
- //透析监测
- monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
-
- //透后评估
- dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
-
- treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
- var configList interface{}
- configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": true,
- "patient": mobilePatient,
- "template_id": template_id,
- "user_org_id": mobilePatient.UserOrgId,
- "prescripition_config": prescripition_config,
- "receive_treatement_config": receive_treatement_config,
- "dialysis_befor": dialysis_befor,
- "dialysis_order": dialysis_order,
- "monitor_record": monitor_record,
- "dialysis_after": dialysis_after,
- "treate_ment": treate_ment,
- "list": configList,
- "result": false,
- })
- }
-
- fmt.Println("roler", role)
- } else if errcodes == gorm.ErrRecordNotFound {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": false,
- "result": false,
- })
- }
- this.ServeJSON()
- }
-
- }
- }
-
- func (this *XcxApiController) GetCodeInfo() {
-
- mobile := this.GetString("phone")
- aespass := this.GetString("aespass")
-
- utils.TraceLog("mobile:%v aespass:%v", mobile, aespass)
-
- if utils.CellPhoneRegexp().MatchString(mobile) == false {
- this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMobileFormat)
- this.ServeJSON()
- return
- }
-
- if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
- this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)
- this.ServeJSON()
- } else {
- this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
- "msg": "短信发送成功,有效期为10分钟",
- })
- this.ServeJSON()
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "code": "100100",
- })
- }
-
- func (this *XcxApiController) GetLoginInfoByOpenid() {
- openid := this.GetString("openid")
- user_admin, errcodes := service.GetXcxOpneidInformation(openid)
- if errcodes == gorm.ErrRecordNotFound {
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": "",
- "patient_id": 0,
- "user_org_id": 0,
- "role": user_admin,
- "is_bind": false,
- })
- } else if errcodes == nil {
- info, _ := service.GetPatientListByPatientId(user_admin.PatientId)
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": info,
- "role": user_admin,
- "is_bind": true,
- "user_org_id": info.UserOrgId,
- "patient_id": user_admin.PatientId,
- })
- }
- }
-
- func (this *XcxApiController) GetLoginInfor() {
- mobile := this.GetString("mobile")
- user_admin, errcodes := service.GetXcxMobileInformation(mobile)
- if errcodes == gorm.ErrRecordNotFound {
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": "",
- "patient_id": 0,
- "user_org_id": 0,
- "role": user_admin,
- "is_bind": false,
- })
- } else if errcodes == nil {
- info, _ := service.GetPatientListByPatientId(user_admin.PatientId)
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": info,
- "role": user_admin,
- "is_bind": true,
- "user_org_id": info.UserOrgId,
- "patient_id": user_admin.PatientId,
- })
- }
- }
-
- func (this *XcxApiController) GetPatientList() {
- //appid := "wx20b60369111b063a"
- appid := "wxcdf53b48b7df107e"
- key := "Yz1HgsFX3yJvWPJSEdwJDA=="
- strs := "uSevGQ5ShkiHjQuqz7s36SKZisVGA4fHH/dy+etg0W7ibVeidl6TyFS+kQZ6B9AI2T+1kOtKXeyveQR7q2TXJdu3fhKCFoLKVFzICNEvkiHMnchJ0T0OpRO3oT+icYq80+egvT+jMSgP7yi0cAgmiKaK/4QURD7+nvxRAj9drzz77sbeFt8KElb1LN/+Wn8dIoQzisxbON9G1VJYYtyBkQ=="
- iv := "JgsbDhJ613uaAgAoBVh0Zw=="
- //data, err := service.Dncrypt(strs, key, iv)
- //fmt.Println(err)
-
- data, err := service.DecryptData(appid, key, iv, strs)
- patient_id, _ := this.GetInt64("patient_id")
- patient, err := service.GetPatientListByPatientId(patient_id)
-
- if err == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "data": data,
- })
- }
-
- func (this *XcxApiController) GetDataInfo() {
-
- appid := this.GetString("appid")
- fmt.Println(appid)
- key := this.GetString("key")
- iv := this.GetString("iv")
- encryptedData := this.GetString("encryptedData")
- list, _ := service.DecryptData(appid, key, iv, encryptedData)
- //list, _ := service.Dncrypt(encryptedData, key, iv)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *XcxApiController) GetSignsByBlood() {
- start := this.GetString("start", "")
- end := this.GetString("end", "")
- patient_id, _ := this.GetInt64("patient_id", 0)
- org_id, _ := this.GetInt64("org_id", 0)
-
- if len(start) <= 0 || len(end) <= 0 || patient_id <= 0 || org_id <= 0 {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "缺少参数",
- "data": "",
- })
- }
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation("2006-01-02", start, loc)
- startTimeUnix := startTime.Unix()
- endTime, _ := time.ParseInLocation("2006-01-02", end, loc)
- endTimeUinx := endTime.Unix()
-
- utils.TraceLog("startTime:%v endTime:%v", startTime, endTime)
- utils.TraceLog("startTimeUnix:%v endTimeUinx:%v", startTimeUnix, endTimeUinx)
- if startTimeUnix < 0 || endTimeUinx < 0 {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "时间超出范围",
- "data": "",
- })
- }
- if startTimeUnix > endTimeUinx {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "开始时间大于结束时间",
- "data": "",
- })
- }
-
- if endTimeUinx-startTimeUnix > 60*60*24*60 {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "时间范围超过60天",
- "data": "",
- })
- }
-
- beforeblood, _ := service.GetSignsByBlood(org_id, startTimeUnix, endTimeUinx, patient_id)
- afterblood, _ := service.GetSignsByAfterBlood(org_id, startTimeUnix, endTimeUinx, patient_id)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 0,
- "err_msg": "",
- "before_blood": beforeblood,
- "after_blood": afterblood,
- })
-
- //now := time.Now()
- //offset := int(time.Monday - now.Weekday())
- //if offset > 0 {
- // offset = -6
- //}
- //monday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
- //endday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset+6)
- //startTime := monday.Unix()
- //endTime := endday.Unix()
- //
- //this.ServeSuccessJSON(map[string]interface{}{
- // "monday": startTime,
- // "endday": endTime,
- //})
- }
-
- func (this *XcxApiController) GetSignsByWeight() {
- start := this.GetString("start", "")
- end := this.GetString("end", "")
- patient_id, _ := this.GetInt64("patient_id", 0)
- org_id, _ := this.GetInt64("org_id", 0)
-
- if len(start) <= 0 || len(end) <= 0 || patient_id <= 0 || org_id <= 0 {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "缺少参数",
- "data": "",
- })
- }
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation("2006-01-02", start, loc)
- startTimeUnix := startTime.Unix()
- endTime, _ := time.ParseInLocation("2006-01-02", end, loc)
- endTimeUinx := endTime.Unix()
-
- utils.TraceLog("startTime:%v endTime:%v", startTime, endTime)
- utils.TraceLog("startTimeUnix:%v endTimeUinx:%v", startTimeUnix, endTimeUinx)
- if startTimeUnix < 0 || endTimeUinx < 0 {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "时间超出范围",
- "data": "",
- })
- }
- if startTimeUnix > endTimeUinx {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "开始时间大于结束时间",
- "data": "",
- })
- }
-
- if endTimeUinx-startTimeUnix > 60*60*24*60 {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "时间范围超过60天",
- "data": "",
- })
- }
-
- beforeweight, _ := service.GetSignsByWeight(org_id, startTimeUnix, endTimeUinx, patient_id)
- dryweight, _ := service.GetSignsByDryWeight(org_id, startTimeUnix, endTimeUinx, patient_id)
- afterweight, _ := service.GetSignsByAfterWeight(org_id, startTimeUnix, endTimeUinx, patient_id)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 0,
- "err_msg": "",
- "before_eweight": beforeweight,
- "dry_eweight": dryweight,
- "after_eweight": afterweight,
- })
-
- //now := time.Now()
- //offset := int(time.Monday - now.Weekday())
- //if offset > 0 {
- // offset = -6
- //}
- //monday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
- //endday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset+6)
- //startTime := monday.Unix()
- //endTime := endday.Unix()
- //
- //this.ServeSuccessJSON(map[string]interface{}{
- // "monday": startTime,
- // "endday": endTime,
- //})
- }
-
- func (this *XcxApiController) GetSchedulesByWeek() {
- start := this.GetString("start", "")
- end := this.GetString("end", "")
- patient_id, _ := this.GetInt64("patient_id", 0)
- org_id, _ := this.GetInt64("org_id", 0)
-
- if len(start) <= 0 || len(end) <= 0 || patient_id <= 0 || org_id <= 0 {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "缺少参数",
- "data": "",
- })
- }
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation("2006-01-02", start, loc)
- startTimeUnix := startTime.Unix()
- endTime, _ := time.ParseInLocation("2006-01-02", end, loc)
- endTimeUinx := endTime.Unix()
-
- utils.TraceLog("startTime:%v endTime:%v", startTime, endTime)
- utils.TraceLog("startTimeUnix:%v endTimeUinx:%v", startTimeUnix, endTimeUinx)
- if startTimeUnix < 0 || endTimeUinx < 0 {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "时间超出范围",
- "data": "",
- })
- }
- if startTimeUnix > endTimeUinx {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "开始时间大于结束时间",
- "data": "",
- })
- }
-
- if endTimeUinx-startTimeUnix > 60*60*24*60 {
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 1001,
- "err_msg": "时间范围超过60天",
- "data": "",
- })
- }
-
- schedule, _ := service.GetScheduleByXcx(org_id, startTimeUnix, endTimeUinx, patient_id)
- this.ServeSuccessJSON(map[string]interface{}{
- "err_code": 0,
- "err_msg": "",
- "data": schedule,
- })
-
- //now := time.Now()
- //offset := int(time.Monday - now.Weekday())
- //if offset > 0 {
- // offset = -6
- //}
- //monday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
- //endday := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset+6)
- //startTime := monday.Unix()
- //endTime := endday.Unix()
- //
- //this.ServeSuccessJSON(map[string]interface{}{
- // "monday": startTime,
- // "endday": endTime,
- //})
- }
-
- func (this *XcxApiController) GetScheduleInfo() {
-
- patient_id, _ := this.GetInt64("patient_id")
- fmt.Println(patient_id)
- thisWeekMonday := service.GetFirstDateOfWeek()
- weekDayWeek := service.GetWeekDayOfWeek()
- TimeMonday, _ := time.Parse("2006-01-02", thisWeekMonday)
- weekDays, _ := time.Parse("2006-01-02", weekDayWeek)
- lastWeekMonday := TimeMonday.AddDate(0, 0, -7)
- nextWeekMonday := weekDays.AddDate(0, 0, +13)
- var weekMonday = lastWeekMonday.Format("2006-01-02")
- var weekDay = nextWeekMonday.Format("2006-01-02")
- fmt.Println("weekmodonday", weekMonday)
- fmt.Println("nextweeekday", weekDay)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", weekMonday+" 00:00:00", loc)
- fmt.Println("startiem", startTime)
- endTime, _ := time.ParseInLocation(timeLayout+"15:04:05", weekDay+"00:00:00", loc)
- fmt.Println(startTime.Unix(), endTime.Unix())
- schedule, err := service.GetScheduleInfo(startTime.Unix(), endTime.Unix(), patient_id)
-
- //获取当前今日的排班日期
- time_now := time.Now().Format("2006-01-02")
- fmt.Println("time_now", time_now)
- timeNowUnix, _ := time.ParseInLocation(timeLayout+"15:04:05", time_now+"00:00:00", loc)
- fmt.Println("timeNowUnix", timeNowUnix.Unix())
-
- //获取今日下机日期
- order, _ := service.GetTodayDialysis(timeNowUnix.Unix(), patient_id)
-
- //获取今日的处方
- prescription, _ := service.GetTodayPrescription(timeNowUnix.Unix(), patient_id)
-
- //获取下一次排班信息
- patientSchedule, _ := service.GetNextPatientSchedule(patient_id, timeNowUnix.Unix())
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- var one = startTime.Unix()
- fmt.Println("one2322332", one)
- var two = one + 86400
- var three = two + 86400
- var four = three + 86400
- var five = four + 86400
- var six = five + 86400
- var seven = six + 86400
-
- var nextOne = seven + 86400
- var nexttwo = nextOne + 86400
- var nextthree = nexttwo + 86400
- var nextfour = nextthree + 86400
- var nextfive = nextfour + 86400
- var nextsix = nextfive + 86400
- var nextseven = nextsix + 86400
-
- var lastOne = nextseven + 86400
- var lastwo = lastOne + 86400
- var lasthree = lastwo + 86400
- var lastfour = lasthree + 86400
- var lastfive = lastfour + 86400
- var lastsix = lastfive + 86400
- var lastseven = lastsix + 86400
-
- array := []interface{}{
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
-
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
-
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": schedule,
- "array": array,
- "order": order,
- "patientSchedule": patientSchedule,
- "prescription": prescription,
- })
- }
-
- func (this *XcxApiController) GetMobileSchedule() {
-
- patientID, _ := this.GetInt64("patient_id")
- info, _ := service.GetXcxPatientInfo(patientID)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- time_now := time.Now().Format("2006-01-02")
- timeNowUnix, _ := time.ParseInLocation(timeLayout+"15:04:05", time_now+"00:00:00", loc)
- //获取该患者最后一次排班
- list, _ := service.GetLastScheduleListOne(patientID, timeNowUnix.Unix())
-
- patient, getPatientErr := service.MobileGetPatientDetail(info.UserOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- schedual, getSchedualErr := service.MobileGetSchedualDetailOne(info.UserOrgId, patientID)
-
- if getSchedualErr != nil {
- this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- receiverTreatmentAccess, getRTARErr := service.MobileGetReceiverTreatmentAccessRecordOne(info.UserOrgId, patientID, list.ScheduleDate)
- if getRTARErr != nil {
- this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluationOne(info.UserOrgId, patientID, list.ScheduleDate)
- if getPEErr != nil {
- this.ErrorLog("获取透前评估失败:%v", getPEErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluationOne(info.UserOrgId, patientID)
- if getLPEErr != nil {
- this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- doctorAdvices, getDoctorAdvicesErr := service.MobileGetDoctorAdvicesByGroupsOne(info.UserOrgId, patientID, list.ScheduleDate)
- if getDoctorAdvicesErr != nil {
- this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- dialysisOrder, getDialysisOrderErr := service.MobileGetSchedualDialysisRecordOne(info.UserOrgId, patientID, list.ScheduleDate)
- if getDialysisOrderErr != nil {
- this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- doubleCheck, getDoubleCheckErr := service.MobileGetDoubleCheckOne(info.UserOrgId, patientID, list.ScheduleDate)
- if getDoubleCheckErr != nil {
- this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- monitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecordsOne(info.UserOrgId, patientID, list.ScheduleDate)
- if getMonitorRecordsErr != nil {
- this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var lastMonitorRecord *models.MonitoringRecord
-
- lastMonitorRecord, getLastErr := service.MobileGetLastMonitorRecordOne(info.UserOrgId, patientID)
- if getLastErr != nil {
- this.ErrorLog("获取上一次透析的监测记录失败:%v", getLastErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(info.UserOrgId, patientID, list.ScheduleDate)
- if getAADErr != nil {
- this.ErrorLog("获取透后评估失败:%v", getAADErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- lastAssessmentAfterDislysis, getLAADErr := service.MobileGetAssessmentAfterDislysisOne(info.UserOrgId, patientID, list.ScheduleDate)
- if getLAADErr != nil {
- this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- treatmentSummary, getTreatmentSummaryErr := service.MobileGetTreatmentSummaryOne(info.UserOrgId, patientID, list.ScheduleDate)
- if getTreatmentSummaryErr != nil {
- this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- dialysisSolution, _ := service.MobileGetDialysisSolutionByModeId(info.UserOrgId, patientID, schedual.ModeId)
-
- lastDialysisPrescribe, _ := service.MobileGetLastDialysisPrescribeByModeId(info.UserOrgId, patientID, schedual.ModeId)
-
- //获取系统透析处方模版
- systemDialysisPrescribe, _ := service.MobileGetSystemDialysisPrescribeByModeId(info.UserOrgId, schedual.ModeId)
-
- _, is_open_config := service.FindXTHisRecordByOrgId(info.UserOrgId)
-
- _, is_project_open_config := service.FindXTHisProjectByOrgId(info.UserOrgId)
-
- projects, _ := service.GetHisPrescriptionProjectsOne(info.UserOrgId, patientID)
-
- stockType, _ := service.GetStockType(info.UserOrgId)
-
- prepare, _ := service.GetDialyStockOutOne(info.UserOrgId, patientID)
-
- //获取最后一次血管通路
- lastAssessment, _ := service.GetLastPassWayAssessment(info.UserOrgId, patientID)
-
- prescribeOne, _ := service.MobileGetDialysisPrescribeByModeIdFive(info.UserOrgId, patientID, list.ScheduleDate)
- var his_advices []*models.HisDoctorAdviceInfo
- if is_open_config.IsOpen == 1 {
- his_advices, _ = service.GetAllHisDoctorAdviceOne(info.UserOrgId, patientID, list.ScheduleDate)
- }
-
- if getLPEErr != nil {
- this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- lastDryWeightDislysis, getDryErr := service.MobileGetLastDryWeight(info.UserOrgId, patientID)
- if getDryErr != nil {
- this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- _, gobalConfig := service.FindAutomaticReduceRecordByOrgId(info.UserOrgId)
-
- operators, _ := service.GetAllStarfEs(info.UserOrgId)
-
- returnData := map[string]interface{}{
- "patient": patient,
- "schedual": schedual,
- "prescription": prescribeOne,
- "solution": dialysisSolution,
- "last_prescription": lastDialysisPrescribe,
- "receiver_treatment_access": receiverTreatmentAccess,
- "predialysis_evaluation": predialysisEvaluation,
- "doctor_advices": doctorAdvices,
- "double_check": doubleCheck,
- "assessment_after_dislysis": assessmentAfterDislysis,
- "treatment_summary": treatmentSummary,
- "monitor_records": monitorRecords,
- "dialysis_order": dialysisOrder,
- "operators": operators,
- "last_predialysis_evaluation": lastPredialysisEvaluation,
- "last_assessment_after_dislysis": lastAssessmentAfterDislysis,
- "last_monitor_record": lastMonitorRecord,
- "config": gobalConfig,
- "dry_weight": lastDryWeightDislysis,
- "system_prescription": systemDialysisPrescribe,
- "his_advices": his_advices,
- "is_open_config": is_open_config,
- "stockType": stockType,
- "prepare": prepare,
- "lastAssessment": lastAssessment,
- "is_project_open_config": is_project_open_config,
- "project": projects,
- "scheduleDate": list.ScheduleDate,
- }
- this.ServeSuccessJSON(returnData)
-
- }
-
- func (this *XcxApiController) GetPatientInfo() {
-
- patient_id, _ := this.GetInt64("patient_id")
- patient, _ := service.GetXcxPatientInfo(patient_id)
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *XcxApiController) GetOrgInfo() {
- patient_id, _ := this.GetInt64("patient_id")
- info, _ := service.GetXcxPatientInfo(patient_id)
- orgInfo, _ := service.GetOrgInfo(info.UserOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "orgInfo": orgInfo,
- })
- }
-
- func (this *XcxApiController) GetEducationList() {
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- patient_id, _ := this.GetInt64("patient_id")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
- list, _ := service.GetEducationList(startTime.Unix(), endTime.Unix(), patient_id)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *XcxApiController) GetDoctorAdvice() {
-
- //判断是否开启医嘱同步功能
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- patient_id, _ := this.GetInt64("patient_id")
- fmt.Println("patient_id", patient_id)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
- info, _ := service.GetXcxPatientInfo(patient_id)
- _, config := service.FindXTHisRecordByOrgId(info.UserOrgId)
- fmt.Println(startTime, endTime, config.IsOpen)
- if config.IsOpen == 0 {
- list, _ := service.GetDoctorAdviceGroup(patient_id, startTime.Unix(), endTime.Unix())
- advice, _ := service.GetDoctorAdvice(patient_id, startTime.Unix(), endTime.Unix())
- for _, item := range list {
- for _, it := range advice {
- if item.AdviceDate == it.AdviceDate {
- item.Childs = append(item.Childs, it)
- }
- }
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- if config.IsOpen == 1 {
- list, _ := service.GetHisDoctorAdviceGroup(patient_id, startTime.Unix(), endTime.Unix())
- advice, _ := service.GetHisDoctorAdvice(patient_id, startTime.Unix(), endTime.Unix())
- for _, item := range list {
- for _, it := range advice {
- if item.AdviceDate == it.AdviceDate {
- item.Childs = append(item.Childs, it)
- }
- }
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- }
-
- func (this *XcxApiController) GetDoctorName() {
- patient_id, _ := this.GetInt64("patient_id")
- fmt.Println("patient_id", patient_id)
- info, _ := service.GetXcxPatientInfo(patient_id)
- user_name, _ := service.GetDoctorName(info.UserOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "user_name": user_name,
- })
- }
-
- func (this *XcxApiController) GetFieldConfig() {
-
- patient_id, _ := this.GetInt64("patient_id")
- fmt.Println("patient_id", patient_id)
- info, _ := service.GetXcxPatientInfo(patient_id)
-
- //处方
- prescripition_config, _ := service.GetPrescripionFieldConfig(info.UserOrgId)
-
- //接诊评估
- receive_treatement_config, _ := service.GetReceiveTreatmentAssess(info.UserOrgId)
-
- //透前评估
- dialysis_befor, _ := service.GetDialysisBefor(info.UserOrgId)
-
- //透析上机
- dialysis_order, _ := service.GetDialysisOrderConfig(info.UserOrgId)
-
- //透析监测
- monitor_record, _ := service.GetMonitorRecordConfig(info.UserOrgId)
-
- //透后评估
- dialysis_after, _ := service.GetDialysisAfeterConfig(info.UserOrgId)
-
- treate_ment, _ := service.GetTreatMentConfig(info.UserOrgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "prescripition_config": prescripition_config,
- "receive_treatement_config": receive_treatement_config,
- "dialysis_befor": dialysis_befor,
- "dialysis_order": dialysis_order,
- "monitor_record": monitor_record,
- "dialysis_after": dialysis_after,
- "treate_ment": treate_ment,
- })
- }
-
- func (this *XcxApiController) GetDataConfig() {
- var configList interface{}
- patient_id, _ := this.GetInt64("patient_id")
- fmt.Println("patient_id", patient_id)
- info, _ := service.GetXcxPatientInfo(patient_id)
- //list, _ := service.GetDataConfig(info.UserOrgId)
- configList, _ = service.GetConfigList(info.UserOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": configList,
- })
- }
-
- func (this *XcxApiController) GetInspectionList() {
-
- page, _ := this.GetInt64("page", 0)
- number, _ := this.GetInt64("number", 10)
- patient_id, _ := this.GetInt64("patient_id", 0)
- //fmt.Println("patient_id", patient_id)
- //timeLayout := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- //startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- //endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
-
- list, err := service.GetInspectionGroupListByXcx(patient_id, page, number)
-
- if err == gorm.ErrRecordNotFound {
- this.ServeSuccessJSON(map[string]interface{}{
- "error_code": "1001",
- "error_msg": "没有更多数据",
- })
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "error_code": "0",
- "error_msg": "",
- "list": list,
- })
- }
-
- func (this *XcxApiController) GetInspectionInfo() {
-
- project_id, _ := this.GetInt64("project_id", 0)
- inspect_date, _ := this.GetInt64("inspect_date", 0)
- patient_id, _ := this.GetInt64("patient_id", 0)
-
- if project_id <= 0 || inspect_date <= 0 || patient_id <= 0 {
- this.ServeSuccessJSON(map[string]interface{}{
- "error_code": 1001,
- "error_msg": "缺少参数",
- })
- }
-
- list, _ := service.GetInspectionInfoByXcx(patient_id, project_id, inspect_date)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *XcxApiController) GetArticList() {
-
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- activity_id, _ := this.GetInt64("activity_id")
- list, total, _ := service.GetArticList(activity_id, page, limit)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- })
- }
-
- func (this *XcxApiController) GetArticListDetail() {
-
- id, _ := this.GetInt64("id")
- detail, _ := service.GetArticListDetail(id)
- this.ServeSuccessJSON(map[string]interface{}{
- "story": detail,
- })
- }
-
- func (this *XcxApiController) GetStoryScoreList() {
-
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- activity_id, _ := this.GetInt64("activity_id")
- list, total, _ := service.GetStoryScoreList(activity_id, page, limit)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- })
- }
-
- func (this *XcxApiController) GetAppId() {
-
- var appid = "wxcdf53b48b7df107e"
- var secret = "94e944a69ad1d43ac447f5a8769ab801"
- var grant_type = "authorization_code"
- code := this.GetString("js_code")
- //var code = "041pXnGa1eLxTB0iypFa1W6USs1pXnGK"
-
- openId, _ := service.SendWxAuthAPI(appid, secret, grant_type, code)
- //session_key, _ := service.SendWxAuthAPIOne(appid, secret, grant_type, code)
- this.ServeSuccessJSON(map[string]interface{}{
- "data": openId,
- //"session_key": session_key,
- })
- }
|