123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- package controllers
-
- import (
- "XT_New/enums"
- service "XT_New/service/print_data_service/schedule_dialysis"
- "XT_New/utils"
- "fmt"
- "strings"
- "time"
-
- "github.com/astaxie/beego"
- )
-
- func PrintDataAPIControllerRegistRouters() {
- beego.Router("/api/print/schedule/dialysis", &PrintDataAPIController{}, "get:ScheduleDialysisRecordPrintData")
- beego.Router("/api/print/stock", &PrintDataAPIController{}, "get:StockRecordPrintData")
- beego.Router("/api/print/course", &PrintDataAPIController{}, "get:CourseRecordPrintData")
- beego.Router("/api/print/getlastafterweight", &PrintDataAPIController{}, "get:GetLastAfterWeight")
- beego.Router("/api/stock/getgooddetailprintlist", &PrintDataAPIController{}, "get:GetGoodDetailPrintList")
-
- }
-
- type PrintDataAPIController struct {
- BaseAuthAPIController
- }
-
- // /api/print/schedule/dialysis [get]
- // @param ids:string 排班 id,以逗号隔开 ("1,2,3")
- func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
- schIDStr := this.GetString("ids")
-
- if len(schIDStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- idStrs := strings.Split(schIDStr, ",")
- adminUserInfo := this.GetAdminUserInfo()
-
- if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 || this.GetAdminUserInfo().CurrentOrgId == 10188 || this.GetAdminUserInfo().CurrentOrgId == 10217 || this.GetAdminUserInfo().CurrentOrgId == 10340 || this.GetAdminUserInfo().CurrentOrgId == 9905 || this.GetAdminUserInfo().CurrentOrgId == 10346 || this.GetAdminUserInfo().CurrentOrgId == 10441 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 {
- fmt.Println("JINALADOOWOWOWOWOWOO")
- schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
- for _, item := range schedules {
-
- //获取透析上机
- order, _ := service.GetBatchDialysisOrder(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.DialysisOrder = order
-
- //获取透析处方
- prescription, _ := service.GetBatchPrescription(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.Prescription = prescription
- //接诊评估
- receiveTreatmentAsses, _ := service.GetBatchReceiveTreatmentAsses(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.ReceiveAssessment = receiveTreatmentAsses
-
- //透前评估
- assessmentBeforeDislysisVM, _ := service.GetBatchAssessmentBeforeDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
-
- //透后评估
- assessmentAfterDislysisVM, _ := service.GetBatchAssessmentAfterDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.AssessmentAfterDislysis = assessmentAfterDislysisVM
-
- //上次透后体重
- lastAfterWeight, _ := service.GetBatchLastAfterWeight(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.LastAfterWeight = lastAfterWeight
-
- //透析监测
- monitor, _ := service.GetBatchMonitor(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.MonitoringRecords = monitor
-
- //透析医嘱
- advice, _ := service.GetBatchDoctorAdvice(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.Advices = advice
-
- //获取His医嘱
- doctorAdvice, _ := service.GetHisBatchDoctorAdvice(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.HisAdvices = doctorAdvice
-
- //获取项目
- project, _ := service.GetHisBatchProject(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.HisPrescriptionProject = project
- //双人核对
- dobuleCheck, _ := service.GetBatchDobuleCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.DoubleCheck = dobuleCheck
-
- //透析小结
- summerVM, _ := service.GetBatchSummerVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
- item.Summer = summerVM
-
- list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
- if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 && this.GetAdminUserInfo().CurrentOrgId != 9970 && this.GetAdminUserInfo().CurrentOrgId != 10495 {
- item.Count = list.Count
- }
-
- lastSchedule, _ := service.FindLastSchedule(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
-
- item.Schedule = &lastSchedule
-
- if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 {
-
- if item.ScheduleDate <= 1703952000 {
- listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
-
- item.Patient.TotalDialysis = listOne.Count
- item.Count = listOne.Count
- }
-
- if item.ScheduleDate >= 1704038400 {
-
- listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
-
- item.Patient.TotalDialysis = listOne.Count
- item.Count = listOne.Count
- }
-
- }
- }
-
- if getScheduleErr != nil {
- this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
-
- if getMedicalStaffErr != nil {
- this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "schedules": schedules,
- "medical_staffs": medicalStaffs,
- "users": adminUser,
- "templateInfo": templateInfo,
- "name": name,
- })
- }
-
- if this.GetAdminUserInfo().CurrentOrgId != 10016 && this.GetAdminUserInfo().CurrentOrgId != 9882 && this.GetAdminUserInfo().CurrentOrgId != 10138 && this.GetAdminUserInfo().CurrentOrgId != 10278 && this.GetAdminUserInfo().CurrentOrgId != 9841 && this.GetAdminUserInfo().CurrentOrgId != 9845 && this.GetAdminUserInfo().CurrentOrgId != 10081 && this.GetAdminUserInfo().CurrentOrgId != 10215 && this.GetAdminUserInfo().CurrentOrgId != 10121 && this.GetAdminUserInfo().CurrentOrgId != 10234 && this.GetAdminUserInfo().CurrentOrgId != 10188 && this.GetAdminUserInfo().CurrentOrgId != 10217 && this.GetAdminUserInfo().CurrentOrgId != 10340 && this.GetAdminUserInfo().CurrentOrgId != 9905 && this.GetAdminUserInfo().CurrentOrgId != 10346 && this.GetAdminUserInfo().CurrentOrgId != 10441 && this.GetAdminUserInfo().CurrentOrgId != 9970 && this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 10495 && this.GetAdminUserInfo().CurrentOrgId != 10013 && this.GetAdminUserInfo().CurrentOrgId != 10014 {
-
- schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
- for _, item := range schedules {
-
- list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
- if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 {
- if this.GetAdminUserInfo().CurrentOrgId == 10445 {
- if item.ScheduleDate <= 1703952000 {
- listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
-
- item.Patient.TotalDialysis = listOne.Count
- item.Count = listOne.Count
- }
-
- if item.ScheduleDate >= 1704038400 {
-
- listOrder, _ := service.GetDialysisOrderCountTen(item.PatientID, item.ScheduleDate)
- item.Count = listOrder.DialysisTotal
- }
-
- }
- if this.GetAdminUserInfo().CurrentOrgId != 10445 {
- item.Count = list.Count
- }
-
- }
- lastSchedule, _ := service.FindLastSchedule(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
-
- item.Schedule = &lastSchedule
- if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 {
-
- if item.ScheduleDate <= 1640966400 {
- listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
-
- item.Patient.TotalDialysis = listOne.Count
- item.Count = listOne.Count
- }
-
- if item.ScheduleDate >= 1672502400 {
- listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
-
- item.Patient.TotalDialysis = listOne.Count
- item.Count = listOne.Count
- }
- }
-
- }
- if getScheduleErr != nil {
- this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getMedicalStaffErr != nil {
- this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "schedules": schedules,
- "medical_staffs": medicalStaffs,
- "users": adminUser,
- "templateInfo": templateInfo,
- "name": name,
- })
- }
-
- }
-
- func (this *PrintDataAPIController) StockRecordPrintData() {
- types, _ := this.GetInt("type", 0)
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- adminUserInfo := this.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
- stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
-
- info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
-
- infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "type": types,
- "stockTotal": stockTotal,
- "info": info,
- "orgid": adminUserInfo.CurrentOrgId,
- "infomationList": infomationList,
- })
- }
- }
-
- func (this *PrintDataAPIController) CourseRecordPrintData() {
- ids_str := this.GetString("ids")
- ids_arr := strings.Split(ids_str, ",")
- adminUserInfo := this.GetAdminUserInfo()
- patient_id, _ := this.GetInt64("patient_id")
-
- record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, ids_arr)
-
- //patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, patient_id)
- patient, _ := service.GetPatientDetail(adminUserInfo.CurrentOrgId, patient_id)
-
- adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
-
- operators, err := service.GetAdminUserEsTwo(adminUserInfo.CurrentOrgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- "patient": patient,
- "adminUser": adminUser,
- "operators": operators,
- })
- }
- }
-
- func (this *PrintDataAPIController) GetLastAfterWeight() {
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- assmentdate, _ := this.GetInt64("assmentdate")
-
- adminUserInfo := this.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- weight, err := service.GetLastAfterWeight(org_id, id, assmentdate)
- //fmt.Print("errr-------------",err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "weight": weight,
- })
- }
-
- func (this *PrintDataAPIController) GetGoodDetailPrintList() {
-
- types, _ := this.GetInt("type", 0)
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- adminUserInfo := this.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
-
- //入库详情
- if types == 1 {
- list, err := service.GetWarehouseInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- //出库详情
- if types == 2 {
- //list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
- list, _ := service.GetWarehouseOutInfoPrintList(adminUserInfo.CurrentOrgId, startTime, endTime)
-
- stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "stockTotal": stockTotal,
- })
- }
-
- //退库详情
- if types == 4 {
-
- list, _ := service.GetWarehouseCancelPrintList(adminUserInfo.CurrentOrgId, startTime, endTime)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- }
|