123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "fmt"
- "strconv"
- "strings"
- "time"
-
- "github.com/astaxie/beego"
- )
-
- func PatientDataConfigAPIControllerRegistRouters() {
- beego.Router("/api/patient/courses", &PatientDataConfigAPIController{}, "get:Courses")
- beego.Router("/api/patient/course/create", &PatientDataConfigAPIController{}, "get:CreateCourse")
- beego.Router("/api/patient/course/delete", &PatientDataConfigAPIController{}, "post:DeleteCourse")
- beego.Router("/api/patient/course/modify", &PatientDataConfigAPIController{}, "get:ModifyCourse")
-
- beego.Router("/api/patient/rescues", &PatientDataConfigAPIController{}, "get:Rescues")
- beego.Router("/api/patient/rescue/create", &PatientDataConfigAPIController{}, "post:CreateRescue")
- beego.Router("/api/patient/rescue/delete", &PatientDataConfigAPIController{}, "post:DeleteRescue")
-
- beego.Router("/api/patient/sickhistory", &PatientDataConfigAPIController{}, "get:GetSickHistorys")
- beego.Router("/api/patient/sickhistory/create", &PatientDataConfigAPIController{}, "get:CreateSickHistory")
- beego.Router("/api/patient/sickhistory/delete", &PatientDataConfigAPIController{}, "post:DeleteSickHistory")
- beego.Router("/api/patient/sickhistory/modify", &PatientDataConfigAPIController{}, "get:ModifySickHistory")
-
- beego.Router("/api/patient/physiquecheck", &PatientDataConfigAPIController{}, "get:GetPhysiqueChecks")
- beego.Router("/api/patient/physiquecheck/create", &PatientDataConfigAPIController{}, "get:CreatePhysiqueCheck")
- beego.Router("/api/patient/physiquecheck/delete", &PatientDataConfigAPIController{}, "post:DeletePhysiqueCheck")
- beego.Router("/api/patient/physiquecheck/modify", &PatientDataConfigAPIController{}, "get:ModifyPhysiqueCheck")
-
- beego.Router("/api/patient/sickhistory/print", &PatientDataConfigAPIController{}, "get:GetSickhistoryPrints")
- beego.Router("/api/patient/physiquecheck/print", &PatientDataConfigAPIController{}, "get:GetPhysiquecheckPrints")
-
- }
-
- type PatientDataConfigAPIController struct {
- BaseAuthAPIController
- }
-
- func (this *PatientDataConfigAPIController) GetPhysiquecheckPrints() {
-
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDStrs := strings.Split(idsStr, ",")
- patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
- sickHostory, _ := service.GetPatienttPhysiqueByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "sickhistorys": sickHostory,
- })
-
- }
- func (this *PatientDataConfigAPIController) GetSickhistoryPrints() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDStrs := strings.Split(idsStr, ",")
- patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
- sickHostory, _ := service.GetPatientSickHistoryByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
- for _, item := range sickHostory {
- pc, _ := service.GetLastPatientPhysiqueCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientId, item.RecordDate)
- item.XtPatientPhysiqueCheck = pc
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "sickhistorys": sickHostory,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetSickHistorys() {
- patientID, _ := this.GetInt64("patient_id")
- startTimeYMDStr := this.GetString("start_time")
- endTimeYMDStr := this.GetString("end_time")
- if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
- startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
- endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
- if parseStartTimeErr != nil || parseEndTimeErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- records, getRecordsErr := service.GetPatientSickHistory(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
- if getRecordsErr != nil {
- this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getAllAdminsErr != nil {
- this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "records": records,
- "doctors": admins,
- })
- }
- func (this *PatientDataConfigAPIController) CreateSickHistory() {
- patientID, _ := this.GetInt64("patient_id")
- content := this.GetString("content")
- record_time_str := this.GetString("record_time")
- title := this.GetString("title")
- is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
- is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
- is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
- guominyaowu_desc := this.GetString("guominyaowu_desc")
- doctor_id, _ := this.GetInt64("doctor_id")
-
- if patientID <= 0 || len(content) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- record_date := strings.Split(record_time_str, " ")
-
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
- checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
- record := models.XtPatientSickHistory{
- OrgId: adminUserInfo.CurrentOrgId,
- PatientId: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: checkDate.Unix(),
- Content: content,
- Status: 1,
- Title: title,
- IsShenyizhiHistory: is_shenyizhishi,
- IsFumoDialysisHistory: is_fumotouxishi,
- HypersusceptibilityDesc: guominyaowu_desc,
- IsHypersusceptibility: is_guominyaowu,
- Ctime: now,
- Mtime: now,
- DoctorId: doctor_id,
- RecordDate: checkDate_two.Unix(),
- }
-
- createErr := service.CreatePatientSickHistory(&record)
- if createErr != nil {
- this.ErrorLog("创建患者病史记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
- func (this *PatientDataConfigAPIController) DeleteSickHistory() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- recordIDStrs := strings.Split(idsStr, ",")
- recordIDs := make([]int64, 0, len(recordIDStrs))
- for _, idStr := range recordIDStrs {
- id, parseErr := strconv.Atoi(idStr)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDs = append(recordIDs, int64(id))
- }
-
- deleteErr := service.DeletePatientSickHistoryInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
- if deleteErr != nil {
- this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(nil)
- }
- func (this *PatientDataConfigAPIController) ModifySickHistory() {
- patientID, _ := this.GetInt64("patient_id")
- content := this.GetString("content")
- id, _ := this.GetInt64("id", 0)
- record_time_str := this.GetString("record_time")
- title := this.GetString("title")
-
- is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
- is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
- is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
- guominyaowu_desc := this.GetString("guominyaowu_desc")
- doctor_id, _ := this.GetInt64("doctor_id")
-
- if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- //timeLayout := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
-
- fmt.Println("checkDate--------------", checkDate)
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
-
- record := models.XtPatientSickHistory{
- ID: id,
- OrgId: adminUserInfo.CurrentOrgId,
- PatientId: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- Content: content,
- Status: 1,
- Ctime: now,
- Mtime: now,
- Title: title,
- RecordTime: checkDate.Unix(),
- IsShenyizhiHistory: is_shenyizhishi,
- IsFumoDialysisHistory: is_fumotouxishi,
- HypersusceptibilityDesc: guominyaowu_desc,
- IsHypersusceptibility: is_guominyaowu,
- DoctorId: doctor_id,
- }
- createErr := service.ModifyPatientSickHistory(&record)
- if createErr != nil {
- this.ErrorLog("创建患者抢救记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetPhysiqueChecks() {
- patientID, _ := this.GetInt64("patient_id")
- startTimeYMDStr := this.GetString("start_time")
- endTimeYMDStr := this.GetString("end_time")
- if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
- startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
- endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
- if parseStartTimeErr != nil || parseEndTimeErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- records, getRecordsErr := service.GetPatientPhysiqueCheck(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
- if getRecordsErr != nil {
- this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getAllAdminsErr != nil {
- this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "records": records,
- "doctors": admins,
- })
- }
- func (this *PatientDataConfigAPIController) CreatePhysiqueCheck() {
- patientID, _ := this.GetInt64("patient_id")
- doctor_id, _ := this.GetInt64("doctor_id")
- record_time_str := this.GetString("record_time")
- t := this.GetString("t")
- p := this.GetString("p")
- r := this.GetString("r")
- bp_left := this.GetString("bp_left")
- bp_right := this.GetString("bp_right")
- pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
- tiwei, _ := this.GetInt64("tiwei")
- fuzhong, _ := this.GetInt64("fuzhong")
- chuxuedian, _ := this.GetInt64("chuxuedian")
-
- fayu, _ := this.GetInt64("fayu")
- yinyang, _ := this.GetInt64("yinyang")
- shenzhi, _ := this.GetInt64("shenzhi")
- pifunianmo, _ := this.GetInt64("pifunianmo")
- buwei := this.GetString("buwei")
- chengdu := this.GetString("chengdu")
- pixiachuxue, _ := this.GetInt64("pixiachuxue")
- zidian, _ := this.GetInt64("zidian")
- pifuwendu, _ := this.GetInt64("pifuwendu")
- qita := this.GetString("qita")
-
- linbazhongda, _ := this.GetInt64("linbazhongda")
- linbabuwei := this.GetString("linbabuwei")
-
- yanlian, _ := this.GetInt64("yanlian")
- tongkong, _ := this.GetInt64("tongkong")
- zuo := this.GetString("zuo")
- you := this.GetString("you")
-
- duiguangfanshe := this.GetString("duiguangfanshe")
- biantaoti := this.GetString("biantaoti")
- yanbu := this.GetString("yanbu")
- toubuqita := this.GetString("toubuqita")
- huxiyin := this.GetString("huxiyin")
-
- xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
- feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
- luoyin, _ := this.GetInt64("luoyin")
- desc := this.GetString("desc")
-
- xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
- xinlv, _ := this.GetInt64("xinlv")
- xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
- zayin, _ := this.GetInt64("zayin")
- fujiayin, _ := this.GetInt64("fujiayin")
- xinzangdesc := this.GetString("xinzangdesc")
-
- fushuizheng, _ := this.GetInt64("fushuizheng")
- ganjingjingmai := this.GetString("ganjingjingmai")
-
- gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
- gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
- pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
- pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
-
- shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
- shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
- fubu_desc := this.GetString("fubu_desc")
- oth_desc := this.GetString("oth_desc")
-
- if patientID <= 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- record_date := strings.Split(record_time_str, " ")
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
- checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
- record := models.XtPatientPhysiqueCheck{
- DoctorId: doctor_id,
- OrgId: adminUserInfo.CurrentOrgId,
- PatientId: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: checkDate.Unix(),
- Status: 1,
- Ctime: now,
- Mtime: now,
- T: t,
- P: p,
- R: r,
- BpRight: bp_right,
- BpLeft: bp_left,
- Pinxuerongmao: pinxuerongmao,
- Tiwei: tiwei,
- Fuzhong: fuzhong,
- Chuxuedian: chuxuedian,
- Fayu: fayu,
- Yinyang: yinyang,
- Shenzhi: shenzhi,
- Pifunianmo: pifunianmo,
- Buwei: buwei,
- Chengdu: chengdu,
- Pixiachuxue: pixiachuxue,
- Zidian: zidian,
- Pifuwendu: pifuwendu,
- Qita: qita,
- Linbazhongda: linbazhongda,
- Linbabuwei: linbabuwei,
- Yanlian: yanlian,
- Tongkong: tongkong,
- Zuo: zuo,
- You: you,
- Duiguangfanshe: duiguangfanshe,
- Biantaoti: biantaoti,
- Yanbu: yanbu,
- Toubuqita: toubuqita,
- Huxiyin: huxiyin,
- Xiongmomocayin: xiongmomocayin,
- Feizhangbuwei: feizhangbuwei,
- Luoyin: luoyin,
- Desc: desc,
- Xinzangdaxiao: xinzangdaxiao,
- Xinlv: xinlv,
- Xinbaomocasheng: xinbaomocasheng,
- Zayin: zayin,
- Fujiayin: fujiayin,
- Xinzangdesc: xinzangdesc,
- Fushuizheng: fushuizheng,
- Ganjingjingmai: ganjingjingmai,
- GangzhangYatong: gangzhang_yatong,
- GangzhangKoutong: gangzhang_koutong,
- PizhangKoutong: pizhang_koutong,
- PizhangYatong: pizhang_yatong,
- ShenzhangKoutong: shenzhang_koutong,
- ShenzhangYatong: shenzhang_yatong,
- FubuDesc: fubu_desc,
- OthDesc: oth_desc,
- RecordDate: checkDate_two.Unix(),
- }
- createErr := service.CreatePatientPhysiqueCheck(&record)
- if createErr != nil {
- this.ErrorLog("创建患者病史记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
- func (this *PatientDataConfigAPIController) DeletePhysiqueCheck() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- recordIDStrs := strings.Split(idsStr, ",")
- recordIDs := make([]int64, 0, len(recordIDStrs))
- for _, idStr := range recordIDStrs {
- id, parseErr := strconv.Atoi(idStr)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDs = append(recordIDs, int64(id))
- }
-
- deleteErr := service.DeletePatientPhysiqueCheckInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
- if deleteErr != nil {
- this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(nil)
- }
- func (this *PatientDataConfigAPIController) ModifyPhysiqueCheck() {
- patientID, _ := this.GetInt64("patient_id")
- id, _ := this.GetInt64("id", 0)
- doctor_id, _ := this.GetInt64("doctor_id", 0)
-
- record_time_str := this.GetString("record_time")
-
- if patientID <= 0 || id == 0 || len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- t := this.GetString("t")
- p := this.GetString("p")
- r := this.GetString("r")
- bp_left := this.GetString("bp_left")
- bp_right := this.GetString("bp_right")
- pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
- tiwei, _ := this.GetInt64("tiwei")
- fuzhong, _ := this.GetInt64("fuzhong")
- chuxuedian, _ := this.GetInt64("chuxuedian")
-
- fayu, _ := this.GetInt64("fayu")
- yinyang, _ := this.GetInt64("yinyang")
- shenzhi, _ := this.GetInt64("shenzhi")
- pifunianmo, _ := this.GetInt64("pifunianmo")
- buwei := this.GetString("buwei")
- chengdu := this.GetString("chengdu")
- pixiachuxue, _ := this.GetInt64("pixiachuxue")
- zidian, _ := this.GetInt64("zidian")
- pifuwendu, _ := this.GetInt64("pifuwendu")
- qita := this.GetString("qita")
-
- linbazhongda, _ := this.GetInt64("linbazhongda")
- linbabuwei := this.GetString("linbabuwei")
-
- yanlian, _ := this.GetInt64("yanlian")
- tongkong, _ := this.GetInt64("tongkong")
- zuo := this.GetString("zuo")
- you := this.GetString("you")
-
- duiguangfanshe := this.GetString("duiguangfanshe")
- biantaoti := this.GetString("biantaoti")
- yanbu := this.GetString("yanbu")
- toubuqita := this.GetString("toubuqita")
- huxiyin := this.GetString("huxiyin")
-
- xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
- feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
- luoyin, _ := this.GetInt64("luoyin")
- desc := this.GetString("desc")
-
- xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
- xinlv, _ := this.GetInt64("xinlv")
- xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
- zayin, _ := this.GetInt64("zayin")
- fujiayin, _ := this.GetInt64("fujiayin")
- xinzangdesc := this.GetString("xinzangdesc")
-
- fushuizheng, _ := this.GetInt64("fushuizheng")
- ganjingjingmai := this.GetString("ganjingjingmai")
-
- gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
- gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
- pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
- pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
-
- shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
- shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
- fubu_desc := this.GetString("fubu_desc")
- oth_desc := this.GetString("oth_desc")
-
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- now := time.Now().Unix()
-
- record := models.XtPatientPhysiqueCheck{
- ID: id,
- OrgId: adminUserInfo.CurrentOrgId,
- PatientId: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: checkDate.Unix(),
- DoctorId: doctor_id,
- Status: 1,
- Ctime: now,
- Mtime: now,
- T: t,
- P: p,
- R: r,
- BpRight: bp_right,
- BpLeft: bp_left,
- Pinxuerongmao: pinxuerongmao,
- Tiwei: tiwei,
- Fuzhong: fuzhong,
- Chuxuedian: chuxuedian,
- Fayu: fayu,
- Yinyang: yinyang,
- Shenzhi: shenzhi,
- Pifunianmo: pifunianmo,
- Buwei: buwei,
- Chengdu: chengdu,
- Pixiachuxue: pixiachuxue,
- Zidian: zidian,
- Pifuwendu: pifuwendu,
- Qita: qita,
- Linbazhongda: linbazhongda,
- Linbabuwei: linbabuwei,
- Yanlian: yanlian,
- Tongkong: tongkong,
- Zuo: zuo,
- You: you,
- Duiguangfanshe: duiguangfanshe,
- Biantaoti: biantaoti,
- Yanbu: yanbu,
- Toubuqita: toubuqita,
- Huxiyin: huxiyin,
- Xiongmomocayin: xiongmomocayin,
- Feizhangbuwei: feizhangbuwei,
- Luoyin: luoyin,
- Desc: desc,
- Xinzangdaxiao: xinzangdaxiao,
- Xinlv: xinlv,
- Xinbaomocasheng: xinbaomocasheng,
- Zayin: zayin,
- Fujiayin: fujiayin,
- Xinzangdesc: xinzangdesc,
- Fushuizheng: fushuizheng,
- Ganjingjingmai: ganjingjingmai,
- GangzhangYatong: gangzhang_yatong,
- GangzhangKoutong: gangzhang_koutong,
- PizhangKoutong: pizhang_koutong,
- PizhangYatong: pizhang_yatong,
- ShenzhangKoutong: shenzhang_koutong,
- ShenzhangYatong: shenzhang_yatong,
- FubuDesc: fubu_desc,
- OthDesc: oth_desc,
- }
- createErr := service.ModifyPatientPhysiqueCheck(&record)
- if createErr != nil {
- this.ErrorLog("修改患者体格检查失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- // /api/patient/courses [get]
- // @param patient_id:int
- // @param start_time:string (yyyy-MM-dd)
- // @param end_time:string (yyyy-MM-dd)
- func (this *PatientDataConfigAPIController) Courses() {
- patientID, _ := this.GetInt64("patient_id")
- startTimeYMDStr := this.GetString("start_time")
- endTimeYMDStr := this.GetString("end_time")
- if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
- startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
- endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
- if parseStartTimeErr != nil || parseEndTimeErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- records, getRecordsErr := service.GetPatientCourseOfDisease(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
- if getRecordsErr != nil {
- this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getAllAdminsErr != nil {
- this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "records": records,
- "doctors": admins,
- })
- }
-
- // /api/patient/course/create [post]
- // @param patient_id:int
- // @param content:string
- func (this *PatientDataConfigAPIController) CreateCourse() {
- patientID, _ := this.GetInt64("patient_id")
- fmt.Println(patientID)
- content := this.GetString("content")
-
- record_time_str := this.GetString("record_time")
- title := this.GetString("title")
-
- if patientID <= 0 || len(content) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
- record := models.PatientDiseaseCourse{
- OrgID: adminUserInfo.CurrentOrgId,
- PatientID: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: checkDate.Unix(),
- Content: content,
- Status: 1,
- CreateTime: now,
- ModifyTime: now,
- Title: title,
- }
-
- createErr := service.CreatePatientCourseOfDisease(&record)
- if createErr != nil {
- this.ErrorLog("创建患者病程记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- // /api/patient/course/delete
- // @param patient_id:int
- // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
- func (this *PatientDataConfigAPIController) DeleteCourse() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- recordIDStrs := strings.Split(idsStr, ",")
- recordIDs := make([]int64, 0, len(recordIDStrs))
- for _, idStr := range recordIDStrs {
- id, parseErr := strconv.Atoi(idStr)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDs = append(recordIDs, int64(id))
- }
-
- deleteErr := service.DeletePatientCoursesInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
- if deleteErr != nil {
- this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(nil)
- }
-
- // /api/patient/rescues [get]
- // @param patient_id:int
- // @param start_time:string (yyyy-MM-dd)
- // @param end_time:string (yyyy-MM-dd)
- func (this *PatientDataConfigAPIController) Rescues() {
- patientID, _ := this.GetInt64("patient_id")
- startTimeYMDStr := this.GetString("start_time")
- endTimeYMDStr := this.GetString("end_time")
- if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
- startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
- endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
- if parseStartTimeErr != nil || parseEndTimeErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- records, getRecordsErr := service.GetPatientRescueRecords(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
- if getRecordsErr != nil {
- this.ErrorLog("获取患者抢救记录失败:%v", getRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getAllAdminsErr != nil {
- this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "records": records,
- "doctors": admins,
- })
- }
-
- // /api/patient/rescue/create [post]
- // @param patient_id:int
- // @param content:string
- func (this *PatientDataConfigAPIController) CreateRescue() {
- patientID, _ := this.GetInt64("patient_id")
- content := this.GetString("content")
- if patientID <= 0 || len(content) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
- record := models.PatientRescueRecord{
- OrgID: adminUserInfo.CurrentOrgId,
- PatientID: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: now,
- Content: content,
- Status: 1,
- CreateTime: now,
- ModifyTime: now,
- }
-
- createErr := service.CreatePatientRescueRecord(&record)
- if createErr != nil {
- this.ErrorLog("创建患者抢救记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- // /api/patient/rescue/delete
- // @param patient_id:int
- // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
- func (this *PatientDataConfigAPIController) DeleteRescue() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- recordIDStrs := strings.Split(idsStr, ",")
- recordIDs := make([]int64, 0, len(recordIDStrs))
- for _, idStr := range recordIDStrs {
- id, parseErr := strconv.Atoi(idStr)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDs = append(recordIDs, int64(id))
- }
-
- deleteErr := service.DeletePatientResuceRecordsInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
- if deleteErr != nil {
- this.ErrorLog("删除患者抢救记录失败:%v", deleteErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(nil)
- }
-
- func (this *PatientDataConfigAPIController) ModifyCourse() {
- patientID, _ := this.GetInt64("patient_id")
- content := this.GetString("content")
- id, _ := this.GetInt64("id", 0)
- record_time_str := this.GetString("record_time")
- title := this.GetString("title")
-
- if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- //timeLayout := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
-
- fmt.Println("checkDate--------------", checkDate)
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
-
- record := models.PatientDiseaseCourse{
- ID: id,
- OrgID: adminUserInfo.CurrentOrgId,
- PatientID: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- Content: content,
- Status: 1,
- CreateTime: now,
- ModifyTime: now,
- Title: title,
- RecordTime: checkDate.Unix(),
- }
-
- createErr := service.ModifyPatientCourses(&record)
- if createErr != nil {
- this.ErrorLog("创建患者抢救记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
|