123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/service"
- "XT_New/utils"
- "time"
-
- "github.com/astaxie/beego"
- )
-
- type QcdApiController struct {
- BaseAuthAPIController
- }
-
- func QcdApiRegistRouters() {
- beego.Router("/api/qcd/dialysistotaldata", &QcdApiController{}, "get:GetDialysisTotalData")
- beego.Router("/api/qcd/processindicatorsdata", &QcdApiController{}, "get:GetProcessIndicatorsData")
- beego.Router("/api/qcd/oicdata", &QcdApiController{}, "get:GetOICData")
- beego.Router("/api/qcd/oiqdata", &QcdApiController{}, "get:GetOIQData")
- beego.Router("/api/qcd/patotaldata", &QcdApiController{}, "get:GetPATotalData")
- beego.Router("/api/qcd/padialysisagedata", &QcdApiController{}, "get:GetPADialysisAgeData")
- beego.Router("/api/qcd/paweightdata", &QcdApiController{}, "get:GetPAWeightData")
- beego.Router("/api/qcd/pabloodpressuredata", &QcdApiController{}, "get:GetPABloodPressureData")
- beego.Router("/api/qcd/pacomplicationdata", &QcdApiController{}, "get:GetPAComplicationData")
- beego.Router("/api/qcd/painfectiousdiseasesdata", &QcdApiController{}, "get:GetPAInfectiousDiseasesData")
- beego.Router("/api/qcd/papersonlapsetdata", &QcdApiController{}, "get:GetPersonLapsetoData")
- beego.Router("/api/qcd/papersonweightdata", &QcdApiController{}, "get:GetPersonWeightData")
- beego.Router("/api/qcd/papersonbloodpressuredata", &QcdApiController{}, "get:GetPersonBloodPressureData")
- beego.Router("/api/qcd/papersonicdata", &QcdApiController{}, "get:GetPersonICData")
- beego.Router("/api/qcd/papersonadvicedata", &QcdApiController{}, "get:GetPersonAdviceData")
- }
-
- func (c *QcdApiController) GetDialysisTotalData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- lapseto, _ := c.GetInt64("lapseto", 0)
- statisticalMethod, _ := c.GetInt64("statistical_method", 0)
- modeID, _ := c.GetInt64("mode_id", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- data, ttd, total, _ := service.GetDialysisTotalData(adminUserInfo.CurrentOrgId, page, limit, lapseto, statisticalMethod, modeID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dtd": data,
- "ttd": ttd,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetProcessIndicatorsData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- lapseto, _ := c.GetInt64("lapseto", 0)
- dialysisAge, _ := c.GetInt64("dialysis_age", 0)
- projectID, _ := c.GetInt64("project_id", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- inspections, references, patients, counts, total, err := service.GetProcessIndicatorsData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisAge, projectID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "inspections": inspections,
- "references": references,
- "patients": patients,
- "unfinishedcount": counts[0].Count,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetOICData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- lapseto, _ := c.GetInt64("lapseto", 0)
- dialysisAge, _ := c.GetInt64("dialysis_age", 0)
- projectID, _ := c.GetInt64("project_id", 0)
- itemID, _ := c.GetInt64("item_id", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- inspections, references, patients, counts, total, err := service.GetOICData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisAge, projectID, itemID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "inspections": inspections,
- "references": references,
- "patients": patients,
- "unfinishedcount": counts[0].Count,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetOIQData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- projectID, _ := c.GetInt64("project_id", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- searchKey := c.GetString("search", "")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- inspections, references, patients, total, err := service.GetOIQData(adminUserInfo.CurrentOrgId, page, limit, projectID, theStartTIme, theEndtTIme, isStartTime, isEndTime, searchKey)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "inspections": inspections,
- "references": references,
- "patients": patients,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPATotalData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- searchKey := c.GetString("search", "")
- age, _ := c.GetInt64("age", 0)
- lapseto, _ := c.GetInt64("lapseto", 0)
- source, _ := c.GetInt64("source", 0)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- patients, lapsetoOut, lapsetoIn, total, err := service.GetPATotalData(adminUserInfo.CurrentOrgId, page, limit, lapseto, source, age, theStartTIme, theEndtTIme, isStartTime, isEndTime, searchKey)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patients": patients,
- "total": total,
- "lapsetoOut": lapsetoOut,
- "lapsetoIn": lapsetoIn,
- })
- return
- }
-
- func (c *QcdApiController) GetPADialysisAgeData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- age, _ := c.GetInt64("age", 0)
- dialysisAge, _ := c.GetInt64("dialysis_age", 0)
- lapseto, _ := c.GetInt64("lapseto", 0)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- patients, counts, total, err := service.GetPADialysisAgeData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, dialysisAge, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patients": patients,
- "counts": counts,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPAWeightData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- age, _ := c.GetInt64("age", 0)
- lapseto, _ := c.GetInt64("lapseto", 0)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- weights, dryweight, weightincrease, afterweight, total, err := service.GetPAWeightData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "weights": weights,
- "dryweight": dryweight,
- "weightincrease": weightincrease,
- "afterweight": afterweight,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPABloodPressureData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- lapseto, _ := c.GetInt64("lapseto", 0)
- dialysisStage, _ := c.GetInt64("dialysis_stage", 0)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- bloodPressures, bps, total, err := service.GetPABloodPressureData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisStage, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "blood_pressures": bloodPressures,
- "bps": bps,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPAComplicationData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- age, _ := c.GetInt64("age", 0)
- statisticalState, _ := c.GetInt64("statistical_state", 0)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- complications, pcps, total, err := service.GetPAComplicationData(adminUserInfo.CurrentOrgId, page, limit, age, statisticalState, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "complications": complications,
- "pcps": pcps,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPAInfectiousDiseasesData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- age, _ := c.GetInt64("age", 0)
- contagionType, _ := c.GetInt64("contagion_type", 0)
- lapseto, _ := c.GetInt64("lapseto", 0)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- patients, dsp, total, err := service.GetPAInfectiousDiseasesData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, contagionType, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patients": patients,
- "dsp": dsp,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPersonLapsetoData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- patientId, _ := c.GetInt64("patient_id", 0)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- patient, lapsetos, total, err := service.GetPersonLapsetoData(adminUserInfo.CurrentOrgId, patientId, page, limit)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "lapsetos": lapsetos,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPersonWeightData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- patientId, _ := c.GetInt64("patient_id", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- var isStartTime bool
- var theStartTIme int64
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- patient, weight, pie, total, err := service.GetPersonWeightData(adminUserInfo.CurrentOrgId, patientId, page, limit, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "weight": weight,
- "pie": pie,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPersonBloodPressureData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- patientId, _ := c.GetInt64("patient_id", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- var isStartTime bool
- var theStartTIme int64
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- patient, bps, lines, total, err := service.GetPersonBloodPressureData(adminUserInfo.CurrentOrgId, patientId, page, limit, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "bps": bps,
- "lines": lines,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPersonICData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- patientId, _ := c.GetInt64("patient_id", 0)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- adminUserInfo := c.GetAdminUserInfo()
-
- patient, inspections, references, total, err := service.GetPersonICData(adminUserInfo.CurrentOrgId, patientId, page, limit)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "inspections": inspections,
- "references": references,
- "total": total,
- })
- return
- }
-
- func (c *QcdApiController) GetPersonAdviceData() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- patientId, _ := c.GetInt64("patient_id", 0)
- adviceType, _ := c.GetInt64("advice_type", 0)
- medicalType, _ := c.GetInt64("medical_type", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- var isStartTime bool
- var theStartTIme int64
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- patient, advices, total, err := service.GetPersonAdviceData(adminUserInfo.CurrentOrgId, patientId, page, limit, adviceType, medicalType, theStartTIme, theEndtTIme, isStartTime, isEndTime)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- users, err := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "advices": advices,
- "users": users,
- "total": total,
- })
- return
- }
|