123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- package new_mobile_api_controllers
-
- import (
- "Xcx_New/controllers/mobile_api_controllers"
- "Xcx_New/enums"
- "Xcx_New/service"
- "fmt"
- "github.com/jinzhu/gorm"
- "time"
- )
-
- type DialysisParamerterApiController struct {
- mobile_api_controllers.MobileBaseAPIAuthController
- }
-
- func (this *DialysisParamerterApiController) GetAllMobileZon() {
-
- adminUserInfo := this.GetMobileAdminUserInfo()
- orgid := adminUserInfo.Org.Id
- err, zone := service.GetAllDeviceZone(orgid)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "zone": zone,
- })
- }
- }
-
- func (this *DialysisParamerterApiController) GetMobileDialysisParameters() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- adminUserInfo := this.GetMobileAdminUserInfo()
- orgid := adminUserInfo.Org.Id
- fmt.Println(orgid)
- keywords := this.GetString("keyword")
- start_time := this.GetString("start_time")
- fmt.Println("start_time", start_time)
- limit, _ := this.GetInt64("limit")
- fmt.Println(limit)
- page, _ := this.GetInt64("page")
- fmt.Println(page)
- partitionType, _ := this.GetInt64("partitionType")
- fmt.Println("partiontype", partitionType)
- scheduleType, _ := this.GetInt64("scheduleType")
- fmt.Println(scheduleType)
-
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if len(keywords) > 0 {
-
- //dialysisSchedule, err, total := service.GetDialysisParametersByKeyword(orgid, keywords, scheduleType, partitionType, page, limit, theTime.Unix())
- //查询今日排班的病人
- patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords, scheduleType, partitionType)
- var vlist []interface{}
- var elist []interface{}
- for _, item := range patient {
- prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgid, theTime.Unix())
- vlist = append(vlist, prescription)
- dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, orgid, theTime.Unix())
- elist = append(elist, dialysis)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- //"schedule": dialysisSchedule,
- //"total": total,
- "prescription": vlist,
- "dialysbefor": elist,
- "patient": patient,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- }
- }
- } else {
- dialysisSchedule, err, total := service.GetDialysisParameter(orgid, theTime.Unix(), scheduleType, partitionType, page, limit)
- //查询今日排班的病人
- patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords, scheduleType, partitionType)
- var vlist []interface{}
- var elist []interface{}
- for _, item := range patient {
- prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgid, theTime.Unix())
- vlist = append(vlist, prescription)
- dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, orgid, theTime.Unix())
- elist = append(elist, dialysis)
- }
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": dialysisSchedule,
- "total": total,
- "prescription": vlist,
- "dialysbefor": elist,
- "patient": patient,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- }
- }
- }
-
- func (this *DialysisParamerterApiController) GetMobileWareHouseOutList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- end_time := this.GetString("end_time")
- endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- fmt.Println(start_time, end_time)
- orgId := this.GetMobileAdminUserInfo().Org.Id
- wareoutlist, err := service.GetWareHouseOutList(startime.Unix(), endtime.Unix(), orgId)
- count, err := service.GetAnticoagulantCount(startime.Unix(), endtime.Unix(), orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "wareoutlist": wareoutlist,
- "count": count,
- })
- }
-
- }
-
- func (this *DialysisParamerterApiController) GetAllMobileMaterial() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("startime")
- startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- fmt.Println("开始时间", startime)
- endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 23:59:59", loc)
- fmt.Println("结束时间", endtime)
- adminUserInfo := this.GetMobileAdminUserInfo()
- orgId := adminUserInfo.Org.Id
- material, err := service.GetAllMaterial(startime.Unix(), endtime.Unix(), orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "material": material,
- })
- }
- }
-
- func (this *DialysisParamerterApiController) GetMobileCollectList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- limit, _ := this.GetInt64("limit")
- fmt.Println(limit)
- page, _ := this.GetInt64("page")
- fmt.Println("page", page)
- partitiontype, _ := this.GetInt64("partitionType")
- fmt.Println(partitiontype)
- scheduletype, _ := this.GetInt64("scheduleType")
- fmt.Println(scheduletype)
- start_time := this.GetString("start_time")
- fmt.Println(start_time)
- startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- orgId := this.GetMobileAdminUserInfo().Org.Id
- keyword := this.GetString("keyword")
- //获取透析参数数据
- //schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
- //查询今日排班的病人
- patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword, scheduletype, partitiontype)
- var vlist []interface{}
- var clist []interface{}
- for _, item := range patient {
- prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgId, startime.Unix())
- vlist = append(vlist, prescription)
- }
- _, errors := service.FindStockOutByIsSys(orgId, 1, startime.Unix())
-
- goodTypes, _ := service.FindAllGoodType(orgId) //two, err, i := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
-
- if errors == gorm.ErrRecordNotFound {
- dialysisGoods, _, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
- for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
- goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
- lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
- item.LastAutomaticReduceDetail = goodUser
- item.LastDialysisBeforePrepare = lastGoodUserDetial
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "dialysis_goods": dialysisGoods,
- "good_type": goodTypes,
- "total": total,
- //"schedule": schedule,
- "prescription": vlist,
- "patient": patient,
- })
- return
-
- } else if err == nil {
- //获取当天排班的每个患者的库存使用情况
- dialysisGoods, err, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
- for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
- goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
- lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
-
- fmt.Println(goodUser)
- fmt.Println(lastGoodUserDetial)
-
- item.LastAutomaticReduceDetail = goodUser
- item.LastDialysisBeforePrepare = lastGoodUserDetial
- }
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "dialysis_goods": dialysisGoods,
- "good_type": goodTypes,
- "total": total,
- //"schedule": schedule,
- //"consumables": consumables,
- "prescription": vlist,
- "reducelist": clist,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- } else if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
- //if err == nil {
- // this.ServeSuccessJSON(map[string]interface{}{
- // "schedule": schedule,
- // "total": total,
- // "consumables": consumables,
- // "prescription": vlist,
- // "reducelist": clist,
- // })
- //}
- }
-
- func (this *DialysisParamerterApiController) GetMobileGatherList() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- startime, _ := 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)
- adminUserInfo := this.GetMobileAdminUserInfo()
- orgId := adminUserInfo.Org.Id
- fmt.Println("开始时间", startime)
- fmt.Println("结束时间", endtime)
- warehouselist, err := service.GetWareHouseOutList(startime.Unix(), endtime.Unix(), orgId)
-
- //获取透析耗材数据
- consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
-
- //统计抗凝剂数据
- count, err := service.GetAnticoagulantCount(startime.Unix(), endtime.Unix(), orgId)
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "warehouselist": warehouselist,
- "consumables": consumables,
- "count": count,
- })
- }
- }
|