123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570 |
- package manage
-
- import (
- "Kya_New/controllers"
- "Kya_New/enums"
- "Kya_New/models"
- "Kya_New/service/login_service"
- "Kya_New/service/manage_service"
- "Kya_New/service/patient_service"
- "Kya_New/utils"
- "encoding/json"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "strconv"
- "strings"
- "time"
- )
-
- func ManageRouter() {
-
- beego.Router("/api/patient/getcoursemanagement", &Manage{}, "Post:GetCourseManagement")
- beego.Router("/api/patient/savepatient", &Manage{}, "Post:SavePatient")
- beego.Router("/api/patient/todeletecousemanage", &Manage{}, "Get:DeleteCouseManage")
- beego.Router("/api/patient/getmissioninformation", &Manage{}, "Get:GetMissionInformation")
- beego.Router("/api/patient/getrecordsave", &Manage{}, "Get:GetRecordSave")
- beego.Router("/api/patient/getcheckpatientdata", &Manage{}, "Get:GetCheckPatientData")
- beego.Router("/api/patient/getlongdialysis", &Manage{}, "Get:GetLongDialysis")
- beego.Router("/api/patient/getdialysrecord", &Manage{}, "Get:GetDialysRecord")
- beego.Router("/api/site/toseacherCourseManagement", &Manage{}, "Get:ToSeacherCourseManagement")
- beego.Router("/api/site/todeletesaverecord", &Manage{}, "Get:ToDeleteSaveRecord")
- beego.Router("/api/site/toSeacherRecord", &Manage{}, "Get:ToSeacherRecord")
- beego.Router("/api/site/deletemissioninformation", &Manage{}, "Get:DeleteMissionInformation")
- beego.Router("/api/patient/toseachermissioninformation", &Manage{}, "Get:ToSeacherMissionInformation")
- beego.Router("/api/patient/getpatientschedules", &Manage{}, "Get:GetPatientSchedules")
- beego.Router("/api/patient/deletescheduleinformation", &Manage{}, "Get:DeleteScheduleinformation")
- beego.Router("/api/patient/toseacherscheduleinformation", &Manage{}, "Get:ToSeacherScheduleInformation")
- beego.Router("/api/patient/getpatienttype", &Manage{}, "Get:GetPatientType")
- beego.Router("/api/patient/checkall", &Manage{}, "Get:GetCheckall")
- }
-
- type Manage struct {
- controllers.BaseAPIController
- }
-
- func (this *Manage) ServeFailJsonSend(code int, msg string) {
- fmt.Println("code", code)
- this.Data["json"] = enums.MakeFailResponseJSON(msg, code)
- this.ServeJSON()
- }
-
- func (this *Manage) ServeSuccessJSON(data map[string]interface{}) {
- this.Data["json"] = enums.MakeSuccessResponseJSON(data)
- this.ServeJSON()
- }
-
- func (this *Manage) GetCourseManagement() {
-
- patienid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patienid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- startime := this.GetString("startime")
- fmt.Println("startime", startime)
- endtime := this.GetString("endtime")
- endTimeYMDHmsStr := endtime + " 23:59:59"
- endTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
- fmt.Println("endtime", endtime)
- timeLayout := "2006-01-02 15:04:05"
- theTime, _ := utils.ParseTimeStringToTime(timeLayout, startime+" 00:00:00")
- star := theTime.Unix()
- patients, _ := login_service.GetPatintsInfo(patienid, orgid)
-
- patientCourse, err := patient_service.GetCourseManagementData(patienid, orgid, star, endTime.Unix())
- fmt.Print("报错----------------------", err)
- infectious, err := patient_service.GetPatientInfectious(patienid)
- fmt.Println("错误是设么", err)
- fmt.Println("patietnCourse", patientCourse)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patientCourse": patientCourse,
- "patients": patients,
- "infectious": infectious,
- })
- }
-
- func (this *Manage) SavePatient() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- mobile := this.GetString("telephone")
- fmt.Println("phone", mobile)
- admin, _ := patient_service.GetCreatorId(mobile)
- org, _ := patient_service.GetOrgId(admin.ID)
- var orgID = org.ID
- fmt.Println("orgID是什么", orgID)
- //基本信息
- name := dataBody["name"].(string)
- fmt.Println("病人姓名", name)
- sex := int64(dataBody["sex"].(float64))
- fmt.Println("性别", sex)
- idcard := dataBody["idCard"].(string)
- fmt.Println("idcard", idcard)
-
- //manage_service.GetIdCardInfo(idcard)
- birthday := dataBody["birthday"].(string)
- births := strings.Split(birthday, "-")
- birYear, _ := strconv.Atoi(births[0])
- age := time.Now().Year() - birYear
- ages := int64(age)
- fmt.Println("age是多少", ages)
- fmt.Println("birthday", birthday)
- timeLayout := "2006-01-02 15:04:05"
- theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
- birth := theTime.Unix()
- fmt.Println("出生日期", birth)
- phone := dataBody["phone"].(string)
- fmt.Println("手机号", phone)
- patientType := dataBody["patient_type"].([]interface{})
- fmt.Println("病人类型", patientType)
-
- //血透信息
- dialysis := dataBody["dialysis"].(string)
- fmt.Println("透析号", dialysis)
- admissionNumber := dataBody["admissionNumber"].(string)
- fmt.Println("住院门诊号", admissionNumber)
- patientsoure := int64(dataBody["patientsoure"].(float64))
- fmt.Println("患者来源", patientsoure)
- lapseto := int64(dataBody["lapseto"].(float64))
- fmt.Println("留置状态", lapseto)
- contagions := dataBody["contagions"].([]interface{})
- ids := make([]int64, 0)
- for _, contagion := range contagions {
- id := int64(contagion.(float64))
- ids = append(ids, id)
- }
-
- fmt.Println("传染病", contagions)
- fistdata := dataBody["fistDate"].(string)
- fmt.Println("首次透析日期", fistdata)
- times, err := utils.ParseTimeStringToTime(timeLayout, fistdata+"00:00:00")
- fisttime := times.Unix()
- fmt.Println("第一透析日期", fisttime)
- diagnose := dataBody["diagnose"].(string)
- fmt.Println("诊断", diagnose)
- patientHead := dataBody["patientHead"].(string)
- fmt.Println("患者头像", patientHead)
-
- //慢病信息
- requipmentid := dataBody["requipmentId"].(string)
- fmt.Println("设备id", requipmentid)
- slowcontagions := dataBody["slowcontagions"].([]interface{})
- fmt.Println("传染病", slowcontagions)
- slowPatients := dataBody["slowPatients"].([]interface{})
- fmt.Println("slowPatients", slowPatients)
-
- //会员信息
- memberIllnessTime := dataBody["memberIllnessTime"].(string)
- fmt.Println("会员患病时间", memberIllnessTime)
-
- memberTime, err := utils.ParseTimeStringToTime(timeLayout, memberIllnessTime+" 00:00:00")
- memberdata := memberTime.Unix()
- fmt.Println("会员患病时间", memberdata)
- memberlapseto := int64(dataBody["memberlapseto"].(float64))
- fmt.Println("留治转台", memberlapseto)
- treatementmethod := int64(dataBody["TreatmentMethod"].(float64))
- fmt.Println("治疗方式", treatementmethod)
-
- patients, errcode := manage_service.GetPatientInfoByIdCard(idcard, orgID)
- fmt.Println("errcode", errcode)
- fmt.Println("patients", patients)
- if errcode == gorm.ErrRecordNotFound {
- byPhone, err := manage_service.GetPatientInfoByPhone(phone, orgID)
- fmt.Println("byphone", byPhone)
- if err == gorm.ErrRecordNotFound {
- bloodPatients := models.Patients{
- Name: name,
- Gender: sex,
- IdCardNo: idcard,
- Birthday: birth,
- Phone: phone,
- DialysisNo: dialysis,
- Source: patientsoure,
- PatientType: 1,
- Lapseto: lapseto,
- FirstDialysisDate: fisttime,
- Diagnose: diagnose,
- Avatar: patientHead,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UserOrgId: orgID,
- Age: ages,
- }
- idtrs := make([]int64, 0)
- for _, patienttype := range patientType {
- id := int64(patienttype.(float64))
- idtrs = append(idtrs, id)
- }
- err := manage_service.AddPatients(&bloodPatients)
- patientss, _ := manage_service.GetLastData(orgID)
- err = manage_service.AddPatientType(orgID, patientss.ID, idtrs)
- fmt.Println("添加患者类型")
- fmt.Println("错误是什么", err)
- patients, err := manage_service.GetPatientLastData(orgID)
- fmt.Println("错误", err)
- fmt.Println("获取新增病人信息", patients)
- err = manage_service.AddContagions(patients.ID, patients.CreatedTime, patients.UpdatedTime, ids)
- fmt.Println("添加传染病失败", err)
- this.ServeSuccessJSON(map[string]interface{}{
- "bloodPatients": bloodPatients,
- "patientss": patientss,
- })
- fmt.Println("bloodPatients", bloodPatients)
- fmt.Println("数据为空")
- } else if errcode == nil {
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
-
- return
- }
- } else if errcode == nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
-
- }
-
- }
-
- func (this *Manage) DeleteCouseManage() {
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- err := manage_service.DeleteCouseManage(id, orgid)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
-
- }
-
- func (this *Manage) GetMissionInformation() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid是什么", orgid)
- startime := this.GetString("startime")
- fmt.Println("startime", startime)
- endtime := this.GetString("endtime")
- fmt.Println("endtime", endtime)
- timeLayout := "2006-01-02 15:04:05"
- theTime, _ := utils.ParseTimeStringToTime(timeLayout, startime+" 00:00:00")
- star := theTime.Unix()
- fmt.Println("star", star)
- toTime, _ := utils.ParseTimeStringToTime(timeLayout, endtime+" 00:00:00")
- end := toTime.Unix()
- fmt.Println("end", end)
- treatment, err := manage_service.GetMissionInforMation(patientid, orgid, star, end)
- patients, _ := login_service.GetPatintsInfo(patientid, orgid)
- fmt.Println("patients", patients)
- infectious, err := patient_service.GetPatientInfectious(patientid)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "treatment": treatment,
- "patients": patients,
- "infectious": infectious,
- })
- }
-
- func (this *Manage) GetRecordSave() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- startime := this.GetString("startime")
- fmt.Println("startime", startime)
- timeLayout := "2006-01-02 15:04:05"
- theTime, _ := utils.ParseTimeStringToTime(timeLayout, startime+" 00:00:00")
- startimes := theTime.Unix()
- fmt.Println("startimes", startimes)
- endtime := this.GetString("endtime")
- endTimeYMDHmsStr := endtime + " 23:59:59"
- endTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
- patients, _ := login_service.GetPatintsInfo(patientid, orgid)
- fmt.Println("paptients", patients)
- infectious, err := patient_service.GetPatientInfectious(patientid)
- record, err := manage_service.GetRecordServe(patientid, orgid, startimes, endTime.Unix())
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- "patients": patients,
- "infectious": infectious,
- })
- }
-
- func (this *Manage) GetCheckPatientData() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- startime := this.GetString("startime")
- fmt.Println("startime", startime)
- timeLayout := "2006-01-02 15:04:05"
- theTime, _ := utils.ParseTimeStringToTime(timeLayout, startime+" 00:00:00")
- startimes := theTime.Unix()
- fmt.Println("startimes", startimes)
- endtime := this.GetString("endtime")
- fmt.Println("endtime是什么", endtime)
- theTimes, _ := utils.ParseTimeStringToTime(timeLayout, endtime+" 00:00:00")
- endtimes := theTimes.Unix()
- fmt.Println("endtime", endtimes)
- checkpatientdata, err := patient_service.GetCheckPatientData(patientid, orgid, startimes, endtimes)
- //for _, check := range checkpatientdata {
- // Checkdata, _ := patient_service.GetCheckData(check.InspectDate, patientid, orgid)
- // this.ServeSuccessJSON(map[string]interface{}{
- // "checkdata":Checkdata,
- // })
- //}
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "checkpatientdata": checkpatientdata,
- })
- }
-
- func (this *Manage) GetLongDialysis() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- startime := this.GetString("startime")
- fmt.Println("startime", startime)
- timeLayout := "2006-01-02 15:04:05"
- theTime, _ := utils.ParseTimeStringToTime(timeLayout, startime+" 00:00:00")
- startimes := theTime.Unix()
- fmt.Println("startimes", startimes)
- endtime := this.GetString("endtime")
- fmt.Println("endtime是什么", endtime)
- theTimes, _ := utils.ParseTimeStringToTime(timeLayout, endtime+" 00:00:00")
- endtimes := theTimes.Unix()
- fmt.Println("endtime", endtimes)
- patients, err := login_service.GetPatintsInfo(patientid, orgid)
- dialysis, err := manage_service.GetLongDialysisData(patientid, orgid, startimes, endtimes)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patients": patients,
- "dialysis": dialysis,
- })
- }
-
- func (this *Manage) GetDialysRecord() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- startime := this.GetString("startime")
- fmt.Println("startime", startime)
- timeLayout := "2006-01-02 15:04:05"
- theTime, _ := utils.ParseTimeStringToTime(timeLayout, startime+" 00:00:00")
- startimes := theTime.Unix()
- fmt.Println("startimes", startimes)
- endtime := this.GetString("endtime")
- fmt.Println("endtime是什么", endtime)
- theTimes, _ := utils.ParseTimeStringToTime(timeLayout, endtime+" 00:00:00")
- endtimes := theTimes.Unix()
- fmt.Println("endtime", endtimes)
- patients, err := login_service.GetPatintsInfo(patientid, orgid)
- dialysisOrder, err := manage_service.GetDialysReCord(patientid, orgid, startimes, endtimes)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "dialysisOrder": dialysisOrder,
- "patients": patients,
- })
- }
-
- func (this *Manage) ToSeacherCourseManagement() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid是什么", orgid)
- seacherval := this.GetString("seacherVal")
- fmt.Println("seacherval", seacherval)
- patientCourse, err := manage_service.ToSeacherCourseManagement(patientid, orgid, seacherval)
- fmt.Println("patientCousrse是什么", patientCourse)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patientCourse": patientCourse,
- })
- }
-
- func (this *Manage) ToDeleteSaveRecord() {
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- err := manage_service.ToDeleteSaveRecord(id)
- fmt.Println("错误", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *Manage) ToSeacherRecord() {
- patientid, _ := this.GetInt64("patientid")
- orgid, _ := this.GetInt64("orgid")
- seacherVal := this.GetString("seacherVal")
- record, err := manage_service.ToSeacherRecord(patientid, orgid, seacherVal)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- func (this *Manage) DeleteMissionInformation() {
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- err := manage_service.DeletMissionInformation(id)
- fmt.Println("err", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
-
- }
-
- func (this *Manage) ToSeacherMissionInformation() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- seacherval := this.GetString("seacherVal")
- fmt.Println("seacherval", seacherval)
- treat, err := manage_service.ToSeacherMissionInformation(patientid, orgid, seacherval)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "treat": treat,
- })
- }
-
- func (this *Manage) GetPatientSchedules() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- startime := this.GetString("startime")
- fmt.Println("startime", startime)
- timeLayout := "2006-01-02 15:04:05"
- theTime, _ := utils.ParseTimeStringToTime(timeLayout, startime+" 00:00:00")
- startimes := theTime.Unix()
- fmt.Println("startimes", startimes)
- endtime := this.GetString("endtime")
- toTime, _ := utils.ParseTimeStringToTime(timeLayout, endtime+" 00:00:00")
- endtimes := toTime.Unix()
- fmt.Println("endtimes", endtimes)
- schedules, err := manage_service.GetPatientSchedules(patientid, orgid, startimes, endtimes)
- patients, _ := login_service.GetPatintsInfo(patientid, orgid)
- infectious, err := patient_service.GetPatientInfectious(patientid)
- fmt.Println("err", err)
- fmt.Println("schedules", schedules)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedules": schedules,
- "patients": patients,
- "infectious": infectious,
- })
- }
-
- func (this *Manage) DeleteScheduleinformation() {
- id, _ := this.GetInt64("id")
- err := manage_service.DeleteScheduleinformationById(id)
- fmt.Println("错误是什么", err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除排班失败")
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *Manage) ToSeacherScheduleInformation() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- seacherval := this.GetString("seacherVal")
- fmt.Println("seacherval", seacherval)
- schedules, err := manage_service.ToSeacherSheduleinformation(patientid, orgid, seacherval)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedules": schedules,
- })
- }
-
- func (this *Manage) GetPatientType() {
- patientid, _ := this.GetInt64("patientid")
- fmt.Println("paitentid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- patientType, err := manage_service.GetPaitentType(patientid, orgid)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patientType": patientType,
- })
- }
-
- func (this *Manage) GetCheckall() {
- checkdate, _ := this.GetInt64("checkdate")
- fmt.Print("checkdate", checkdate)
- patientid, _ := this.GetInt64("patientid")
- fmt.Print("patientid", patientid)
- orgid, _ := this.GetInt64("orgid")
- fmt.Print("org", orgid)
- checkdata, err := patient_service.GetCheckData(checkdate, patientid, orgid)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "checkdata": checkdata,
- })
-
- }
|