123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "encoding/json"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "reflect"
- "strconv"
- "time"
- )
-
- func SignWeighAPIControllerRegistRouters() {
- beego.Router("/api/sign/patients", &SignWeighAPIController{}, "Get:GetPatients")
- beego.Router("/api/sign/patientsign", &SignWeighAPIController{}, "Get:GetPatientSign")
-
- beego.Router("/api/signweign", &SignWeighAPIController{}, "Post:EditPatientSign")
-
- beego.Router("/api/sign/getDialysisInforInfomation", &SignWeighAPIController{}, "Get:GetPatientList")
-
- beego.Router("/api/sign/getDialysisAfterInfomation", &SignWeighAPIController{}, "Get:GetInforByPatientId")
-
- beego.Router("/api/sign/savaData", &SignWeighAPIController{}, "Post:SaveData")
-
- beego.Router("/api/sign/editdata", &SignWeighAPIController{}, "Post:EditData")
-
- beego.Router("/api/sigh/sighdata", &SignWeighAPIController{}, "Post:Sighdata")
-
- beego.Router("/api/sign/updateSignweight", &SignWeighAPIController{}, "Post:UpdateSignweight")
-
- }
-
- type SignWeighAPIController struct {
- BaseAuthAPIController
- }
-
- // /api/sign/patients [get]
- func (c *SignWeighAPIController) GetPatients() {
- keywrods := c.GetString("keywords")
- scheduleType, _ := c.GetInt64("schedule_type", 0)
- needScheduleType, _ := c.GetInt64("need_schedule_type", 0)
- nowDateTime := time.Now()
- nowDate := nowDateTime.Format("2006-01-02")
- today := nowDate
- nowDate += " 00:00:00"
-
- //认为没有选择{0:'全部',1:'上午',2:'下午'3:'晚上' }中的一个
- if scheduleType < 0 || scheduleType > 3 {
- nowH := nowDateTime.Hour()
-
- if nowH < 12 {
- scheduleType = 1
- } else if nowH < 18 {
- scheduleType = 2
- } else {
- scheduleType = 3
- }
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- dateTime := theTime.Unix()
- fmt.Println("dataTime是多少", dateTime)
- adminUserInfo := c.GetAdminUserInfo()
-
- patients, err := service.GetSignPatients(adminUserInfo.CurrentOrgId, keywrods, dateTime, scheduleType)
-
- fmt.Println("病人信息", patients)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- panel := make(map[int64]map[string]int64, 0)
- if needScheduleType == 1 {
- panel, _ = service.GetSignPanels(adminUserInfo.CurrentOrgId, dateTime)
- fmt.Println("panel是什么", panel)
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patients": patients,
- "today": today,
- "schedule_type": scheduleType,
- "panel": panel,
- })
- return
- }
-
- func (c *SignWeighAPIController) GetPatientSign() {
- patientID, _ := c.GetInt64("patient_id", 0)
- dateTime := c.GetString("date_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dateTimeStam := theTime.Unix()
-
- adminUserInfo := c.GetAdminUserInfo()
-
- sign, err := service.GetPatientDateSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "sign": sign,
- })
- return
- }
-
- func (c *SignWeighAPIController) EditPatientSign() {
- patientID, _ := c.GetInt64("patient_id", 0)
- dateTime := c.GetString("date_time")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dateTimeStam := theTime.Unix()
-
- adminUserInfo := c.GetAdminUserInfo()
-
- sign, err := service.GetPatientDateSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- var signForm models.SigninAndWeigh
- if sign != nil {
- signForm = *sign
- signForm.UpdatedTime = time.Now().Unix()
-
- } else {
- signForm.PatientId = patientID
- signForm.RecordDate = dateTimeStam
- signForm.UserOrgId = adminUserInfo.CurrentOrgId
- signForm.SignTime = time.Now().Unix()
- signForm.Status = 1
- signForm.CreatedTime = time.Now().Unix()
- signForm.UpdatedTime = time.Now().Unix()
- }
-
- signData := make(map[string]interface{}, 0)
- err = json.Unmarshal(c.Ctx.Input.RequestBody, &signData)
- if err != nil {
- //utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
- }
-
- if signData["dry_weight"] == nil || reflect.TypeOf(signData["dry_weight"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dryWeight, _ := strconv.ParseFloat(signData["dry_weight"].(string), 64)
- signForm.DryWeight = dryWeight
-
- if signData["clothes_weight"] == nil || reflect.TypeOf(signData["clothes_weight"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- clothesWeight, _ := strconv.ParseFloat(signData["clothes_weight"].(string), 64)
- signForm.ClothingWeight = clothesWeight
-
- if signData["weigh_before"] == nil || reflect.TypeOf(signData["weigh_before"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- weighBefore, _ := strconv.ParseFloat(signData["weigh_before"].(string), 64)
- signForm.WeighingBefore = weighBefore
-
- if signData["dehydrated_weight"] == nil || reflect.TypeOf(signData["dehydrated_weight"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dehydratedWeight, _ := strconv.ParseFloat(signData["dehydrated_weight"].(string), 64)
- signForm.TargetDewatering = dehydratedWeight
-
- if signData["weight_before"] == nil || reflect.TypeOf(signData["weight_before"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- weightBefore, _ := strconv.ParseFloat(signData["weight_before"].(string), 64)
- signForm.WeightBefore = weightBefore
-
- if signData["temperature_before"] == nil || reflect.TypeOf(signData["temperature_before"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- temperatureBefore, _ := strconv.ParseFloat(signData["temperature_before"].(string), 64)
- signForm.TemperatureBefore = temperatureBefore
-
- if signData["pulse_rate_before"] == nil || reflect.TypeOf(signData["pulse_rate_before"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- pulseRateBefore, _ := strconv.ParseFloat(signData["pulse_rate_before"].(string), 64)
- signForm.PulseFrequencyBefore = pulseRateBefore
-
- if signData["respiratory_rate_before"] == nil || reflect.TypeOf(signData["respiratory_rate_before"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- respiratoryRateBefore, _ := strconv.ParseFloat(signData["respiratory_rate_before"].(string), 64)
- signForm.BreathingRateBefore = respiratoryRateBefore
-
- if signData["DBP_before"] == nil || reflect.TypeOf(signData["DBP_before"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- DBPBefore, _ := strconv.ParseFloat(signData["DBP_before"].(string), 64)
- signForm.DiastolicBloodPressureBefore = DBPBefore
-
- if signData["SBP_before"] == nil || reflect.TypeOf(signData["SBP_before"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- SBPBefore, _ := strconv.ParseFloat(signData["SBP_before"].(string), 64)
- signForm.SystolicBloodPressureBefore = SBPBefore
-
- if signData["weigh_after"] == nil || reflect.TypeOf(signData["weigh_after"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- weighAfter, _ := strconv.ParseFloat(signData["weigh_after"].(string), 64)
- signForm.WeighingAfter = weighAfter
-
- if signData["weight_reduce_after"] == nil || reflect.TypeOf(signData["weight_reduce_after"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- weightReduceAfter, _ := strconv.ParseFloat(signData["weight_reduce_after"].(string), 64)
- signForm.WeightLoss = weightReduceAfter
-
- if signData["weight_after"] == nil || reflect.TypeOf(signData["weight_after"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- weightAfter, _ := strconv.ParseFloat(signData["weight_after"].(string), 64)
- signForm.WeightAfter = weightAfter
-
- if signData["temperature_after"] == nil || reflect.TypeOf(signData["temperature_after"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- temperatureAfter, _ := strconv.ParseFloat(signData["temperature_after"].(string), 64)
- signForm.TemperatureAfter = temperatureAfter
-
- if signData["pulse_rate_after"] == nil || reflect.TypeOf(signData["pulse_rate_after"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- pulseRateAfter, _ := strconv.ParseFloat(signData["pulse_rate_after"].(string), 64)
- signForm.PulseFrequencyAfter = pulseRateAfter
-
- if signData["respiratory_rate_after"] == nil || reflect.TypeOf(signData["respiratory_rate_after"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- respiratoryRateAfter, _ := strconv.ParseFloat(signData["respiratory_rate_after"].(string), 64)
- signForm.BreathingRateAfter = respiratoryRateAfter
-
- if signData["DBP_after"] == nil || reflect.TypeOf(signData["DBP_after"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- DBPAfter, _ := strconv.ParseFloat(signData["DBP_after"].(string), 64)
- signForm.DiastolicBloodPressureAfter = DBPAfter
-
- if signData["SBP_after"] == nil || reflect.TypeOf(signData["SBP_after"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- SBPAfter, _ := strconv.ParseFloat(signData["SBP_after"].(string), 64)
- signForm.SystolicBloodPressureAfter = SBPAfter
-
- if signForm.WeighingAfter > 0 {
- signForm.WeighTime = time.Now().Unix()
- }
- if signForm.WeighingBefore > 0 {
- signForm.WeighBeforeTime = time.Now().Unix()
- }
-
- err = service.EditPatientSign(&signForm)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "sign": signForm,
- })
- return
- }
-
- func (c *SignWeighAPIController) GetPatientList() {
- patientID, _ := c.GetInt64("patient_id", 0)
- adminUserInfo := c.GetAdminUserInfo()
- nowDateTime := time.Now()
- nowDate := nowDateTime.Format("2006-01-02")
- nowDate += " 00:00:00"
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
- datetime := theTime.Unix()
-
- list := service.GetPatientInformationList(adminUserInfo.CurrentOrgId, patientID, datetime)
- dryWeight, _ := service.GetPatientLastDryWeight(patientID, adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "patientlist": list,
- "dryWeight": dryWeight,
- })
- return
- }
-
- func (c *SignWeighAPIController) GetInforByPatientId() {
- patientID, _ := c.GetInt64("patient_id", 0)
- adminUserInfo := c.GetAdminUserInfo()
- nowDateTime := time.Now()
- nowDate := nowDateTime.Format("2006-01-02")
- nowDate += " 00:00:00"
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
- datetime := theTime.Unix()
- patient := service.GetInforByPatient(adminUserInfo.CurrentOrgId, patientID, datetime)
- fmt.Println("patient是什么", patient)
- c.ServeSuccessJSON(map[string]interface{}{
- "patientinfor": patient,
- })
- }
-
- func (c *SignWeighAPIController) SaveData() {
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- patient_id, _ := c.GetInt64("patient_id", 0)
- weight_before, _ := c.GetFloat("weight_before", 0)
- dry_weight, _ := c.GetFloat("dry_weight", 0)
- temperature, _ := c.GetFloat("temperature", 0)
- pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
- breathing_rate := c.GetString("breathing_rate")
- systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
- diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
- predialysisevaluation := &models.PredialysisEvaluation{
- WeightBefore: weight_before,
- DryWeight: dry_weight,
- Temperature: temperature,
- PulseFrequency: pulse_frequency,
- BreathingRate: breathing_rate,
- SystolicBloodPressure: systolic_blood_pressure,
- DiastolicBloodPressure: diastolic_blood_pressure,
- }
- data := service.SaveData(predialysisevaluation, patient_id, orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "params": data,
- })
- }
-
- func (c *SignWeighAPIController) EditData() {
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- patient_id, _ := c.GetInt64("patient_id", 0)
- weight_after, _ := c.GetFloat("weight_after", 0)
- dry_weight, _ := c.GetFloat("dry_weight", 0)
- temperature, _ := c.GetFloat("temperature", 0)
- pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
- breathing_rate := c.GetString("breathing_rate")
- systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
- diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
- assessmentafterdislysis := &models.AssessmentAfterDislysis{
- WeightAfter: weight_after,
- DryWeight: dry_weight,
- Temperature: temperature,
- PulseFrequency: pulse_frequency,
- BreathingRate: breathing_rate,
- SystolicBloodPressure: systolic_blood_pressure,
- DiastolicBloodPressure: diastolic_blood_pressure,
- }
- editdata := service.Editdata(assessmentafterdislysis, patient_id, orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "params": editdata,
- })
- }
-
- func (c *SignWeighAPIController) Sighdata() {
-
- patientID, _ := c.GetInt64("patient_id", 0)
- fmt.Println("patientID", patientID)
- dateTime := c.GetString("date_time")
- fmt.Println(patientID, dateTime)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dateTimeStam := theTime.Unix()
- adminUserInfo := c.GetAdminUserInfo()
- sign, errord := service.GetSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
- fmt.Println("sign", sign)
- fmt.Println(err)
- weighbefore, _ := c.GetFloat("weight_before", 0)
- dryweightbefore, _ := c.GetFloat("dry_weight", 0)
- temperaturebefore, _ := c.GetFloat("temperature", 0)
- pulsefrequencybefore, _ := c.GetFloat("pulse_frequency", 0)
- breathinratebefore, _ := c.GetFloat("breathing_rate", 0)
- systolicbloodpressurebefore, _ := c.GetFloat("systolic_blood_pressure", 0)
- diastorlicbloodpressurebefore, _ := c.GetFloat("diastolic_blood_pressure", 0)
- weightafter, _ := c.GetFloat("weight_after", 0)
- temperatureafter, _ := c.GetFloat("temperatureafter", 0)
- pulsefrequencyafter, _ := c.GetFloat("pulse_frequencyafter", 0)
- breathingrateafter, _ := c.GetFloat("breathing_rateafter", 0)
- systolicbloodpressureafter, _ := c.GetFloat("systolic_blood_pressureafter", 0)
- diastolicbloodpressureafter, _ := c.GetFloat("diastolic_blood_pressureafter", 0)
-
- var sighForm models.SignWeight
-
- sighForm.WeightBefore = weighbefore
- sighForm.DryWeightBefore = dryweightbefore
- sighForm.TemperatureBefore = temperaturebefore
- sighForm.PulseFrequencyBefore = pulsefrequencybefore
- sighForm.BreathingRateBefore = breathinratebefore
- sighForm.SystolicBloodPressureBefore = systolicbloodpressurebefore
- sighForm.DiastolicBloodPressureBefore = diastorlicbloodpressurebefore
- sighForm.WeightAfter = weightafter
- sighForm.TemperatureAfter = temperatureafter
- sighForm.PulseFrequencyAfter = pulsefrequencyafter
- sighForm.BreathingRateAfter = breathingrateafter
- sighForm.SystolicBloodPressureAfter = systolicbloodpressureafter
- sighForm.DiastolicBloodPressureAfter = diastolicbloodpressureafter
- sighForm.PatientId = patientID
- sighForm.RecordDate = dateTimeStam
- sighForm.UserOrgId = adminUserInfo.CurrentOrgId
- sighForm.SignTime = time.Now().Unix()
- sighForm.Status = 1
- sighForm.CreatedTime = time.Now().Unix()
-
- if sighForm.WeightBefore > 0 {
- sighForm.WeighBeforeTime = time.Now().Unix()
- }
-
- if sighForm.WeightAfter > 0 {
- sighForm.WeighTime = time.Now().Unix()
- }
-
- if errord == gorm.ErrRecordNotFound {
-
- savesignweigh := service.Savesignweigh(&sighForm)
- fmt.Println("savesignweight", savesignweigh)
- c.ServeSuccessJSON(map[string]interface{}{
- "signs": sighForm,
- })
-
- } else if errord == nil {
- service.Updatesignweigh(&sighForm, patientID, adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "signs": sighForm,
- })
- } else {
-
- service.Updatesignweigh(&sighForm, patientID, adminUserInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "signs": sighForm,
- })
- }
- return
- }
-
- func (c *SignWeighAPIController) UpdateSignweight() {
- patientID, _ := c.GetInt64("patient_id", 0)
- dateTime := c.GetString("date_time")
- fmt.Println("病人ID", patientID, dateTime)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dateTimeStam := theTime.Unix()
- fmt.Println("datatimestam是什么", dateTimeStam)
- adminUserInfo := c.GetAdminUserInfo()
- fmt.Println(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
- //透前
- weight_before, _ := c.GetFloat("weight_before", 0)
- dry_weight, _ := c.GetFloat("dry_weight", 0)
- temperature, _ := c.GetFloat("temperature", 0)
- fmt.Println("温度", temperature)
- pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
- systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
- diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
- fmt.Println("dry_weight", dry_weight)
- var predialysisevaluation models.PredialysisEvaluation
- predialysisevaluation.PatientId = patientID
- predialysisevaluation.UserOrgId = adminUserInfo.CurrentOrgId
- predialysisevaluation.AssessmentDate = dateTimeStam
- predialysisevaluation.WeightBefore = weight_before
- predialysisevaluation.DryWeight = dry_weight
- predialysisevaluation.Temperature = temperature
- predialysisevaluation.PulseFrequency = pulse_frequency
- predialysisevaluation.SystolicBloodPressure = systolic_blood_pressure
- predialysisevaluation.DiastolicBloodPressure = diastolic_blood_pressure
- predialysisevaluation.CreatedTime = time.Now().Unix()
- predialysisevaluation.Status = 1
-
- predialysis, errcode := service.GetDislysisBerfore(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
- fmt.Println("sigh", predialysis)
- fmt.Println("错误:", errcode)
- if errcode == gorm.ErrRecordNotFound {
- service.SaveDislysisiBefore(&predialysisevaluation)
- } else if errcode == nil {
-
- service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
- } else {
- service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- }
-
- //透后
- weight_after, _ := c.GetFloat("weight_after", 0)
- temperatureafter, _ := c.GetFloat("temperatureafter", 0)
- pulsefrequencyafter, _ := c.GetFloat("pulse_frequencyafter", 0)
- systolicbloodpressureafter, _ := c.GetFloat("systolic_blood_pressureafter", 0)
- diastolicbloodpressureafter, _ := c.GetFloat("diastolic_blood_pressureafter", 0)
-
- var assessmentafterdislysis models.AssessmentAfterDislysis
- assessmentafterdislysis.PatientId = patientID
- assessmentafterdislysis.UserOrgId = adminUserInfo.CurrentOrgId
- assessmentafterdislysis.AssessmentDate = dateTimeStam
- assessmentafterdislysis.WeightAfter = weight_after
- assessmentafterdislysis.Temperature = temperatureafter
- assessmentafterdislysis.PulseFrequency = pulsefrequencyafter
- assessmentafterdislysis.SystolicBloodPressure = systolicbloodpressureafter
- assessmentafterdislysis.DiastolicBloodPressure = diastolicbloodpressureafter
- assessmentafterdislysis.CreatedTime = time.Now().Unix()
- assessmentafterdislysis.Status = 1
- dislysis, errcoder := service.GetAssessmentaafterdislysis(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
- fmt.Println("sigh", dislysis)
- fmt.Println("错误装太:", errcoder)
-
- if errcoder == gorm.ErrRecordNotFound {
- service.SaveAssessmentafter(&assessmentafterdislysis)
- c.ServeSuccessJSON(map[string]interface{}{
- "signs": predialysisevaluation,
- })
- } else if errcoder == nil {
- service.UpdataAssessment(&assessmentafterdislysis, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
- c.ServeSuccessJSON(map[string]interface{}{
- "signs": predialysisevaluation,
- })
- } else {
- service.UpdataAssessment(&assessmentafterdislysis, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- }
- }
-
- //func (c *SignWeighAPIController) GetForenoonData() {
- // nowDateTime := time.Now()
- // nowDate := nowDateTime.Format("2006-01-02")
- // nowDate += " 00:00:00"
- // timeLayout := "2006-01-02"
- // loc, _ := time.LoadLocation("Local")
- // theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
- // datetime := theTime.Unix()
- // fmt.Println("hhhhhhhhhhhhhhhhhhh")
- // fmt.Println("datetime",datetime)
- // adminUserInfo := c.GetAdminUserInfo()
- // orgId := adminUserInfo.CurrentOrgId
- // fmt.Println("orgid是什么",orgId)
- // total, schedule, err := service.GetForenoonData(datetime, orgId, 1)
- // fmt.Println("total",total)
- // fmt.Println("schedule",schedule)
- // if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- //
- // c.ServeSuccessJSON(map[string]interface{}{
- // "total": total,
- // })
- //
- //}
|