123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932 |
- package mobile_api_controllers
-
- import (
- "encoding/json"
- _ "encoding/json"
- "fmt"
- "net/http"
- "net/url"
- "strconv"
- _ "strings"
-
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- _ "XT_New/utils"
- "github.com/astaxie/beego"
- _ "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
-
- // "fmt"
- _ "reflect"
- "time"
- )
-
- type CheckWeightApiController struct {
- MobileBaseAPIAuthController
- }
-
- func (c *CheckWeightApiController) SaveBloodPressure() {
- id, _ := c.GetInt64("patient", 0)
- dialysistype, _ := c.GetInt64("dialysistype", 0)
- systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0) //收缩压
- diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0) //舒张压
- pulse_frequency, _ := c.GetFloat("pulse_frequency", 0) //脉率
-
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- if dialysistype <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- if systolic_blood_pressure <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- if diastolic_blood_pressure <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- thisTime := time.Now()
-
- scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- theAssessmentDateTime := theStartTime.Unix()
-
- if dialysistype == 1 {
-
- theEvaluation, getPEErr := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- if getPEErr != nil {
- c.ErrorLog("获取透前评估失败:%v", getPEErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var evaluation models.PredialysisEvaluation
- if theEvaluation != nil {
- evaluation = *theEvaluation
- }
-
- // 如果今天没有透前评估,则插入新的数据
- if theEvaluation == nil {
- evaluation.CreatedTime = time.Now().Unix()
- evaluation.Status = 1
- evaluation.AssessmentDate = theAssessmentDateTime
- evaluation.PatientId = id
- evaluation.UserOrgId = adminUserInfo.Org.Id
- // 获取上一次透前评估信息,部分数据是需要从上一次透前评估继承
- lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- // 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
- assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
-
- if getAADErr != nil {
- c.ErrorLog("获取透后评估失败:%v", getAADErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- // 获取干体重,先从干体重配置里去读,如果没有,则读取上一次透前评估的干体重
- weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
- if err == gorm.ErrRecordNotFound {
- if lastPredialysisEvaluation != nil {
- evaluation.DryWeight = lastPredialysisEvaluation.DryWeight
- evaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
- evaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin
- evaluation.VenousCatheterization = lastPredialysisEvaluation.VenousCatheterization
- evaluation.Catheter = lastPredialysisEvaluation.Catheter
- evaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend
- evaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
- evaluation.PunctureNeedleDirection = lastPredialysisEvaluation.PunctureNeedleDirection
- evaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
- evaluation.PointPuncture = lastPredialysisEvaluation.PointPuncture
- evaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage
- evaluation.ThromubusType = lastPredialysisEvaluation.ThromubusType
- evaluation.Skin = lastPredialysisEvaluation.Skin
- evaluation.Complication = lastPredialysisEvaluation.Complication
- evaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
- evaluation.LastPostDialysisOther = lastPredialysisEvaluation.LastPostDialysisOther
- } else {
- evaluation.DryWeight = 0
- }
- } else {
- evaluation.DryWeight = weight.DryWeight
- }
-
- if assessmentAfterDislysis != nil {
- evaluation.WeightAfterLastTransparency = assessmentAfterDislysis.WeightAfter
- }
-
- if lastPredialysisEvaluation != nil {
- evaluation.BloodAccessPartId = lastPredialysisEvaluation.BloodAccessPartId
- evaluation.BloodAccessPartOperaId = lastPredialysisEvaluation.BloodAccessPartOperaId
- evaluation.AdditionalWeight = lastPredialysisEvaluation.AdditionalWeight // 衣物重
-
- evaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
- evaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin
- evaluation.VenousCatheterization = lastPredialysisEvaluation.VenousCatheterization
- evaluation.Catheter = lastPredialysisEvaluation.Catheter
- evaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend
- evaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
- evaluation.PunctureNeedleDirection = lastPredialysisEvaluation.PunctureNeedleDirection
- evaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
- evaluation.PointPuncture = lastPredialysisEvaluation.PointPuncture
- evaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage
- evaluation.ThromubusType = lastPredialysisEvaluation.ThromubusType
- evaluation.Skin = lastPredialysisEvaluation.Skin
- evaluation.Complication = lastPredialysisEvaluation.Complication
- evaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
- evaluation.LastPostDialysisOther = lastPredialysisEvaluation.LastPostDialysisOther
-
- //从化益达 备注默认上一次数据
- if adminUserInfo.Org.Id == 10318 {
- evaluation.Remark = lastPredialysisEvaluation.Remark
- }
-
- }
- } else {
- evaluation.UpdatedTime = time.Now().Unix()
- }
-
- evaluation.SystolicBloodPressure = systolic_blood_pressure // 收缩压
- evaluation.DiastolicBloodPressure = diastolic_blood_pressure // 舒张压
- evaluation.PulseFrequency = pulse_frequency
- // 脉率
-
- evaluation.AssessmentTime = time.Now().Unix()
-
- err := service.UpadatePredialysisEvaluation(&evaluation)
- //记录日志
- byterequest, _ := json.Marshal(evaluation)
- assessmentBeforeDislysisLog := models.XtAssessmentBeforeDislysisLog{
- UserOrgId: adminUserInfo.Org.Id,
- AdminUserId: adminUserInfo.AdminUser.Id,
- ErrLog: string(byterequest),
- PatientId: evaluation.PatientId,
- RecordDate: evaluation.AssessmentDate,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- Source: "物联网上传透前血压",
- }
-
- service.CreateBeforLog(assessmentBeforeDislysisLog)
-
- assessdateDateStart := thisTime.Format("2006-01-02")
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
- redis := service.RedisClient()
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_befores_list_all"
- redis.Set(keyOne, "", time.Second)
- keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyTwo, "", time.Second)
- redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "evaluation": evaluation,
- })
- return
-
- } else {
-
- // 保存透后相关数据
- assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
-
- if getAADErr != nil {
- c.ErrorLog("获取透后评估失败:%v", getAADErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var afterevaluation models.AssessmentAfterDislysis
- if assessmentAfterDislysis != nil {
- afterevaluation = *assessmentAfterDislysis
- }
- if assessmentAfterDislysis == nil {
- afterevaluation.CreatedTime = time.Now().Unix()
- afterevaluation.Status = 1
- afterevaluation.AssessmentDate = theAssessmentDateTime
- afterevaluation.PatientId = id
- afterevaluation.UserOrgId = adminUserInfo.Org.Id
- } else {
-
- afterevaluation.UpdatedTime = time.Now().Unix()
- }
-
- afterevaluation.SystolicBloodPressure = systolic_blood_pressure // 收缩压
- afterevaluation.DiastolicBloodPressure = diastolic_blood_pressure // 舒张压
- afterevaluation.PulseFrequency = pulse_frequency // 脉率
-
- if adminUserInfo.Org.Id == 10138 {
- afterevaluation.LeaveOfficeMethod = assessmentAfterDislysis.LeaveOfficeMethod //离科方式
- afterevaluation.Lapse = assessmentAfterDislysis.Lapse //转归
- afterevaluation.Consciousness = assessmentAfterDislysis.Consciousness //意识
- afterevaluation.Fallrisk = assessmentAfterDislysis.Fallrisk //跌倒风险
- }
-
- err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
-
- //记录日志
- byterequest, _ := json.Marshal(afterevaluation)
- afterLog := models.XtAssessmentAfterDialysisLog{
- UserOrgId: adminUserInfo.Org.Id,
- AdminUserId: adminUserInfo.AdminUser.Id,
- ErrLog: string(byterequest),
- PatientId: afterevaluation.PatientId,
- RecordDate: afterevaluation.AssessmentDate,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- Source: "物联网上传透后血压",
- }
-
- service.CreateAfterDialysisLog(afterLog)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
- assessdateDateStart := thisTime.Format("2006-01-02")
- keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyTwo, "", time.Second)
- defer redis.Close()
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "assessmentAfterDislysis": afterevaluation,
- })
- }
- }
-
- }
-
- func (c *CheckWeightApiController) SavePatientInfoDialysis() {
- id, _ := c.GetInt64("patient", 0)
- dialysistype, _ := c.GetInt64("dialysistype", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- if dialysistype <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- thisTime := time.Now()
-
- scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
- // scheduleDateEnd := thisTime.Format("2006-01-02") + " 23:59:59"
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- // theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
- theAssessmentDateTime := theStartTime.Unix()
- // endTime := theEndTime.Unix()
- // dry_weight,_ := c.GetFloat("dry_weight",0) // 干体重
- weighing_before, _ := c.GetFloat("weighing_before", 0) // 透前体重
- dewater_amount, _ := c.GetFloat("dewater_amount", 0) // 目标脱水量(L)
-
- weight_after, _ := c.GetFloat("weight_after", 0) // 透后体重
- weight_loss, _ := c.GetFloat("weight_loss", 0) // 体重减少
-
- schedual, _ := service.MobileGetSchedualDetail(adminUserInfo.Org.Id, patient.ID, theStartTime.Unix())
-
- template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
-
- if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 || template.TemplateId == 53 || template.TemplateId == 48 || adminUserInfo.Org.Id == 10345 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10138 || adminUserInfo.Org.Id == 10278 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10471 || adminUserInfo.Org.Id == 10537 || adminUserInfo.Org.Id == 10667 || adminUserInfo.Org.Id == 10723 {
- if adminUserInfo.Org.Id != 10447 {
- dewater_amount = dewater_amount * 1000
- }
-
- }
-
- if adminUserInfo.Org.Id == 10727 {
- dewater_amount = dewater_amount * 1000
- }
-
- if dewater_amount < 0 {
- dewater_amount = 0
- }
-
- if dialysistype == 1 {
- // 保存透前相关数据
- // 获取透析处方
-
- var lastDialysisPrescribe *models.DialysisPrescription
- var dialysisSolution *models.DialysisSolution
- var dialysisPrescribe *models.DialysisPrescription
- var system_dialysisPrescribe *models.SystemPrescription
-
- var mode_id int64
- //weightfirst, _ := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
- //if weightfirst.DryWeight > weighing_before {
- // return
- //}
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- if schedual != nil {
- // 获取透析模版
- dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
- system_dialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, schedual.ModeId)
- lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
-
- //判断透析模式,针对河间咸的
- if adminUserInfo.Org.Id == 10090 {
- if dialysisSolution.ModeId != 2 && dialysisSolution.ModeId != 5 && dialysisSolution.ModeId != 12 {
- dialysisSolution.DisplaceLiquiPart = 0
- dialysisSolution.DisplaceLiquiValue = 0
- }
- if lastDialysisPrescribe.ModeId != 2 && lastDialysisPrescribe.ModeId != 5 && lastDialysisPrescribe.ModeId != 12 {
- dialysisSolution.DisplaceLiquiPart = 0
- dialysisSolution.DisplaceLiquiValue = 0
- }
- }
-
- mode_id = schedual.ModeId
- } else {
- // 获取透析模版
- dialysisSolution, _ = service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
-
- if dialysisPrescribe == nil && dialysisSolution != nil {
- mode_id = dialysisSolution.ModeId
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- mode_id = 0
- }
- }
-
- // 插入透析处方
- if dialysisPrescribe == nil && dialysisSolution != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = dialysisSolution.UserOrgId
- newprescribe.PatientId = dialysisSolution.PatientId
- newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
- newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
- newprescribe.ModeId = dialysisSolution.ModeId
- newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
- newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
- newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
- newprescribe.BloodFilter = dialysisSolution.BloodFilter
- newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
- newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
- newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
- newprescribe.Glucose = dialysisSolution.Glucose
- newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
- newprescribe.Kalium = dialysisSolution.Kalium
- newprescribe.Sodium = dialysisSolution.Sodium
- newprescribe.Calcium = dialysisSolution.Calcium
- newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
- newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
- newprescribe.Conductivity = dialysisSolution.Conductivity
- newprescribe.BodyFluid = dialysisSolution.BodyFluid
- newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
- newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
- newprescribe.BloodAccess = dialysisSolution.BloodAccess
- newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
- newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
- newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
- newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
- newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
- newprescribe.Dialyzer = dialysisSolution.Dialyzer
- newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
- newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
- newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
- newprescribe.DialysisStrainer = dialysisSolution.DialysisStrainer
- newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
- newprescribe.TargetKtv = dialysisSolution.TargetKtv
-
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = theAssessmentDateTime
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.PrescriptionWater = dewater_amount
- newprescribe.Chaptalization = dialysisSolution.Chaptalization
- newprescribe.PrescribingNumber = 1
- newprescribe.BloodAccessPartId = dialysisSolution.BloodAccessPartId
- newprescribe.Status = 1
- if adminUserInfo.Org.Id != 10013 && adminUserInfo.Org.Id != 10014 && adminUserInfo.Org.Id != 10016 {
- newprescribe.Remark = dialysisSolution.Remark
- }
-
- if adminUserInfo.Org.Id == 10340 {
- newprescribe.TargetUltrafiltration = 0
- newprescribe.Sodium = 138
- newprescribe.Bicarbonate = 31.1
- newprescribe.DialysateFlow = 500
- newprescribe.TargetUltrafiltration = 0
- }
- // 针对新化博翔
- if adminUserInfo.Org.Id == 10447 {
- newprescribe.DisplaceLiquiPart = 1
- newprescribe.DisplaceLiquiValue = 32
- newprescribe.DialysateFlow = 500
- }
-
- if adminUserInfo.Org.Id == 10121 {
- newprescribe.DialysisDurationHour = 4
- newprescribe.DialysisDurationMinute = 0
- newprescribe.BloodAccess = dialysisSolution.BloodAccess
- }
-
- if adminUserInfo.Org.Id == 10445 {
- lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
- newprescribe.Remark = lastDialysisPrescription.Remark
- }
-
- //恒泰
- if adminUserInfo.Org.Id == 10490 || adminUserInfo.Org.Id == 10016 {
- newprescribe.Remark = ""
- }
-
- if adminUserInfo.Org.Id == 10599 {
- // 获取透析模版
- solutionone, _ := service.MobileGetDialysisSolutionByModeIdSevenTwety(adminUserInfo.Org.Id, id, schedual.ModeId)
- if solutionone.Anticoagulant > 0 {
- newprescribe.Anticoagulant = solutionone.Anticoagulant
- newprescribe.AnticoagulantShouji = solutionone.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = solutionone.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = solutionone.AnticoagulantZongliang
- newprescribe.BloodAccess = solutionone.BloodAccess
- newprescribe.DialysisDurationHour = solutionone.DialysisDurationHour
- newprescribe.DialysisDurationMinute = solutionone.DialysisDurationMinute
- newprescribe.DialysisIrrigation = solutionone.DialysisIrrigation
- newprescribe.DialysisDialyszers = solutionone.DialysisDialyszers
- newprescribe.DialysisStrainer = solutionone.DialysisStrainer
-
- }
-
- }
-
- //针对普宁和揭阳
- if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10599 {
- prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
- if prescriptionTwenty.ID == 0 {
- //插入透析处方
- service.AddSigleRecord(&newprescribe)
- } else {
- //插入透析处方
- service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
- }
- } else {
- //避免插入失败问题
- if adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10121 {
- //插入透析处方
- service.AddSigleRecordOne(&newprescribe)
- } else {
- //插入透析处方
- service.AddSigleRecord(&newprescribe)
- }
-
- }
-
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: newprescribe.UserOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: newprescribe.PatientId,
- Source: "物联网上传",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keyTwo, "", time.Second)
- scheduleDateStartOne := thisTime.Format("2006-01-02")
- keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- if lastDialysisPrescribe != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
- newprescribe.PatientId = lastDialysisPrescribe.PatientId
- newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
- newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
- newprescribe.ModeId = lastDialysisPrescribe.ModeId
- newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
- newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
- newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
- newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
- newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
- newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
- newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
- newprescribe.Glucose = lastDialysisPrescribe.Glucose
- newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
- newprescribe.Kalium = lastDialysisPrescribe.Kalium
- newprescribe.Sodium = lastDialysisPrescribe.Sodium
- newprescribe.Calcium = lastDialysisPrescribe.Calcium
- newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
- newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
- newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
- newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
- newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
- newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
- newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
- newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
- newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
- newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
- newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
- newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
- newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
- newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
- newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
- newprescribe.DialysisStrainer = lastDialysisPrescribe.DialysisStrainer
- newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
- newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
- newprescribe.BloodAccessPartId = lastDialysisPrescribe.BloodAccessPartId
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = theAssessmentDateTime
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.PrescriptionWater = dewater_amount
- newprescribe.Status = 1
- //if adminUserInfo.Org.Id != 10490 {
- // newprescribe.Remark = lastDialysisPrescribe.Remark
- //} else {
- // newprescribe.Remark = ""
- //}
- if adminUserInfo.Org.Id == 10490 || adminUserInfo.Org.Id == 10016 {
- newprescribe.Remark = ""
- }
-
- newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
- newprescribe.PrescribingNumber = 1
- if adminUserInfo.Org.Id == 10340 {
- newprescribe.TargetUltrafiltration = 0
- }
- if adminUserInfo.Org.Id == 10121 {
- newprescribe.DialysisDurationHour = 4
- newprescribe.DialysisDurationMinute = 0
- newprescribe.BloodAccess = dialysisSolution.BloodAccess
- }
-
- if adminUserInfo.Org.Id == 10445 {
- lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
- newprescribe.Remark = lastDialysisPrescription.Remark
- }
- //err := service.AddSigleRecord(&newprescribe)
- var err error
- if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10599 || adminUserInfo.Org.Id == 3877 {
- prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
- if prescriptionTwenty.ID == 0 {
- //插入透析处方
- service.AddSigleRecord(&newprescribe)
- } else {
- //插入透析处方
- service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
- }
- } else {
- //插入透析处方
- err = service.AddSigleRecord(&newprescribe)
- }
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "物联网上传",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keyTwo, "", time.Second)
- scheduleDateStartOne := thisTime.Format("2006-01-02")
- keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- } else if system_dialysisPrescribe != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = system_dialysisPrescribe.UserOrgId
- newprescribe.PatientId = id
- newprescribe.Anticoagulant = system_dialysisPrescribe.Anticoagulant
- newprescribe.AnticoagulantShouji = system_dialysisPrescribe.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = system_dialysisPrescribe.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = system_dialysisPrescribe.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = system_dialysisPrescribe.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = system_dialysisPrescribe.AnticoagulantGaijiliang
- newprescribe.ModeId = system_dialysisPrescribe.ModeId
- newprescribe.DialysisDuration = system_dialysisPrescribe.DialysisDuration
- newprescribe.ReplacementWay = system_dialysisPrescribe.ReplacementWay
- newprescribe.HemodialysisMachine = system_dialysisPrescribe.HemodialysisMachine
- newprescribe.BloodFilter = system_dialysisPrescribe.BloodFilter
- newprescribe.PerfusionApparatus = system_dialysisPrescribe.PerfusionApparatus
- newprescribe.BloodFlowVolume = system_dialysisPrescribe.BloodFlowVolume
- newprescribe.DisplaceLiqui = system_dialysisPrescribe.DisplaceLiqui
- newprescribe.Glucose = system_dialysisPrescribe.Glucose
- newprescribe.DialysateFlow = system_dialysisPrescribe.DialysateFlow
- newprescribe.Kalium = system_dialysisPrescribe.Kalium
- newprescribe.Sodium = system_dialysisPrescribe.Sodium
- newprescribe.Calcium = system_dialysisPrescribe.Calcium
- newprescribe.Bicarbonate = system_dialysisPrescribe.Bicarbonate
- newprescribe.DialysateTemperature = system_dialysisPrescribe.DialysateTemperature
- newprescribe.Conductivity = system_dialysisPrescribe.Conductivity
- newprescribe.BodyFluid = system_dialysisPrescribe.BodyFluid
- newprescribe.SpecialMedicine = system_dialysisPrescribe.SpecialMedicine
- newprescribe.SpecialMedicineOther = system_dialysisPrescribe.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = system_dialysisPrescribe.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = system_dialysisPrescribe.DisplaceLiquiValue
- newprescribe.BloodAccess = system_dialysisPrescribe.BloodAccess
- newprescribe.Ultrafiltration = system_dialysisPrescribe.Ultrafiltration
- newprescribe.DialysisDurationHour = system_dialysisPrescribe.DialysisDurationHour
- newprescribe.DialysisDurationMinute = system_dialysisPrescribe.DialysisDurationMinute
- newprescribe.DialysateFormulation = system_dialysisPrescribe.DialysateFormulation
- newprescribe.Dialyzer = system_dialysisPrescribe.Dialyzer
- newprescribe.ReplacementTotal = system_dialysisPrescribe.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = system_dialysisPrescribe.DialyzerPerfusionApparatus
- newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
- newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
- newprescribe.BodyFluidOther = system_dialysisPrescribe.BodyFluidOther
- newprescribe.TargetKtv = system_dialysisPrescribe.TargetKtv
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = theAssessmentDateTime
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
- newprescribe.BloodAccessPartId = lastDialysisPrescribe.BloodAccessPartId
- newprescribe.Status = 1
- newprescribe.PrescribingNumber = 1
-
- if adminUserInfo.Org.Id == 10340 {
- newprescribe.TargetUltrafiltration = 0
- }
- if adminUserInfo.Org.Id == 10121 {
- newprescribe.DialysisDurationHour = 4
- newprescribe.DialysisDurationMinute = 0
- newprescribe.BloodAccess = dialysisSolution.BloodAccess
- }
- if adminUserInfo.Org.Id == 10445 {
- lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
- newprescribe.Remark = lastDialysisPrescription.Remark
- }
-
- if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10599 || adminUserInfo.Org.Id == 3877 {
- prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
- if prescriptionTwenty.ID == 0 {
- //插入透析处方
- service.AddSigleRecord(&newprescribe)
- } else {
- //插入透析处方
- service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
- }
- } else {
- service.AddSigleRecord(&newprescribe)
- }
-
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "物联网上传",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keyTwo, "", time.Second)
- scheduleDateStartOne := thisTime.Format("2006-01-02")
- keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
-
- } else {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.Org.Id
- newprescribe.PatientId = id
- newprescribe.ModeId = mode_id
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = theAssessmentDateTime
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.Status = 1
- if adminUserInfo.Org.Id == 10445 {
- lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
- newprescribe.Remark = lastDialysisPrescription.Remark
- }
- err := service.AddSigleRecord(&newprescribe)
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "物联网上传",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keyTwo, "", time.Second)
- scheduleDateStartOne := thisTime.Format("2006-01-02")
- keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
- }
-
- if dialysisPrescribe != nil && dialysisPrescribe.TargetUltrafiltration == 0 {
- dialysisPrescribe.UpdatedTime = time.Now().Unix()
- dialysisPrescribe.RecordDate = theAssessmentDateTime
- dialysisPrescribe.DewaterAmount = dewater_amount
- dialysisPrescribe.TargetUltrafiltration = dewater_amount
- dialysisPrescribe.Status = 1
- if adminUserInfo.Org.Id == 10340 {
- dialysisPrescribe.TargetUltrafiltration = 0
- }
- if adminUserInfo.Org.Id == 10445 {
- lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
- dialysisPrescribe.Remark = lastDialysisPrescription.Remark
- }
- updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
- //记录日志
- byterequest, _ := json.Marshal(dialysisPrescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: dialysisPrescribe.RecordDate,
- PatientId: id,
- Source: "物联网上传",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keyTwo, "", time.Second)
- scheduleDateStartOne := thisTime.Format("2006-01-02")
- keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- if updateErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
-
- theEvaluation, getPEErr := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- if getPEErr != nil {
- c.ErrorLog("获取透前评估失败:%v", getPEErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var evaluation models.PredialysisEvaluation
- if theEvaluation != nil {
- evaluation = *theEvaluation
- }
-
- // 如果今天没有透前评估,则插入新的数据
- if theEvaluation == nil {
- evaluation.CreatedTime = time.Now().Unix()
- evaluation.Status = 1
- evaluation.AssessmentDate = theAssessmentDateTime
- evaluation.PatientId = id
- evaluation.UserOrgId = adminUserInfo.Org.Id
- // 获取上一次透前评估信息,部分数据是需要从上一次透前评估继承
- lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- // 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
- assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- if getAADErr != nil {
- c.ErrorLog("获取透后评估失败:%v", getAADErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- // 获取干体重,先从干体重配置里去读,如果没有,则读取上一次透前评估的干体重
- weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
- if err == gorm.ErrRecordNotFound {
- if lastPredialysisEvaluation != nil {
- evaluation.DryWeight = lastPredialysisEvaluation.DryWeight
- } else {
- evaluation.DryWeight = 0
- }
- } else {
- evaluation.DryWeight = weight.DryWeight
- }
-
- if assessmentAfterDislysis != nil {
- evaluation.WeightAfterLastTransparency = assessmentAfterDislysis.WeightAfter
- }
-
- if lastPredialysisEvaluation != nil {
- evaluation.BloodAccessPartId = lastPredialysisEvaluation.BloodAccessPartId
- evaluation.BloodAccessPartOperaId = lastPredialysisEvaluation.BloodAccessPartOperaId
- evaluation.AdditionalWeight = lastPredialysisEvaluation.AdditionalWeight
- evaluation.Temperature = lastPredialysisEvaluation.Temperature
- evaluation.BreathingRate = lastPredialysisEvaluation.BreathingRate
- evaluation.Catheter = lastPredialysisEvaluation.Catheter
- evaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
- evaluation.PulseFrequency = lastPredialysisEvaluation.PulseFrequency
- evaluation.Complication = lastPredialysisEvaluation.Complication
- evaluation.LastPostDialysis = lastPredialysisEvaluation.LastPostDialysis
- evaluation.DialysisInterphase = lastPredialysisEvaluation.DialysisInterphase
- evaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
- evaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
- evaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
-
- evaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin //血透通路皮肤情况
- evaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend //导管打折
- evaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage //出血
- evaluation.IsInfect = lastPredialysisEvaluation.IsInfect //感染
- evaluation.Exposed = lastPredialysisEvaluation.Exposed // 外漏
- evaluation.DialysisCount = lastPredialysisEvaluation.DialysisCount //呼吸频次
- evaluation.Phinholing = lastPredialysisEvaluation.Phinholing //针眼
-
- evaluation.Remark = lastPredialysisEvaluation.Remark
- if adminUserInfo.Org.Id == 10318 || adminUserInfo.Org.Id == 10490 || adminUserInfo.Org.Id == 10016 {
- evaluation.Remark = ""
- }
- if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10447 {
- evaluation.BreathingRate = "20"
- }
- if adminUserInfo.Org.Id == 10445 {
- evaluation.VenousCatheterization = lastPredialysisEvaluation.VenousCatheterization
- }
-
- if adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10471 {
- evaluation.PulseFrequency = 80
- }
- if adminUserInfo.Org.Id == 10440 {
- evaluation.Temperature = 36.5
- }
- if adminUserInfo.Org.Id == 10469 {
- evaluation.Temperature = 36.5
- }
- if adminUserInfo.Org.Id == 10471 {
- evaluation.Temperature = 36.5
- }
-
- if adminUserInfo.Org.Id == 10721 {
- evaluation.Temperature = 36.5
- }
- }
- } else {
- evaluation.UpdatedTime = time.Now().Unix()
- }
-
- evaluation.WeightBefore = weighing_before
- evaluation.AssessmentTime = time.Now().Unix()
-
- if adminUserInfo.Org.Id == 10644 {
- evaluation.PunctureNeedle = ""
- }
-
- //针对患者称重两次没有数据的问题
- if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 || adminUserInfo.Org.Id == 10721 {
-
- dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
- lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
- service.UpdateMobileGetDialysisPrescribeOne(lastDialysisPrescription.ID, dewater_amount)
- }
-
- err := service.UpadatePredialysisEvaluation(&evaluation)
-
- //记录日志
- byterequest, _ := json.Marshal(evaluation)
- beforLog := models.XtAssessmentBeforeDislysisLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: evaluation.AssessmentDate,
- PatientId: id,
- Source: "物联网上传",
- Status: 1,
- }
-
- service.CreateBeforLog(beforLog)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_befores_list_all"
- redis.Set(keyOne, "", time.Second)
- assessdateDateStart := thisTime.Format("2006-01-02")
- keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyTwo, "", time.Second)
- redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "evaluation": evaluation,
- })
- return
-
- } else {
-
- // 保存透后相关数据
- assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- if getAADErr != nil {
- c.ErrorLog("获取透后评估失败:%v", getAADErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var afterevaluation models.AssessmentAfterDislysis
- if assessmentAfterDislysis != nil {
- afterevaluation = *assessmentAfterDislysis
- }
- if assessmentAfterDislysis == nil {
- afterevaluation.CreatedTime = time.Now().Unix()
- afterevaluation.Status = 1
- afterevaluation.AssessmentDate = theAssessmentDateTime
- afterevaluation.PatientId = id
- afterevaluation.UserOrgId = adminUserInfo.Org.Id
- } else {
-
- afterevaluation.UpdatedTime = time.Now().Unix()
- }
-
- afterevaluation.WeightAfter = weight_after
- afterevaluation.WeightLoss = weight_loss
-
- if adminUserInfo.Org.Id == 10138 {
- afterevaluation.LeaveOfficeMethod = assessmentAfterDislysis.LeaveOfficeMethod //离科方式
- afterevaluation.Lapse = assessmentAfterDislysis.Lapse //转归
- afterevaluation.Consciousness = assessmentAfterDislysis.Consciousness //意识
- afterevaluation.Fallrisk = assessmentAfterDislysis.Fallrisk
- }
-
- if adminUserInfo.Org.Id == 10307 || adminUserInfo.Org.Id == 10445 {
- afterevaluation.ActualUltrafiltration = weight_loss * 1000 //中能建的计量单位是毫升(ml)
- }
- //北方营口
- if adminUserInfo.Org.Id == 10445 {
- prescribe, _ := service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- afterevaluation.ActualDisplacement = prescribe.DisplaceLiquiValue
- }
-
- //蓬安济民
-
- if adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10469 {
- afterevaluation.PulseFrequency = 80
- }
-
- if adminUserInfo.Org.Id == 10693 {
-
- afterevaluation.ActualUltrafiltration = assessmentAfterDislysis.ActualUltrafiltration
-
- afterevaluation.SystolicBloodPressure = assessmentAfterDislysis.SystolicBloodPressure
-
- afterevaluation.DiastolicBloodPressure = assessmentAfterDislysis.DiastolicBloodPressure
-
- afterevaluation.PulseFrequency = assessmentAfterDislysis.PulseFrequency
-
- if afterevaluation.ActualUltrafiltration == 0 {
-
- lastRecord, _ := service.GetLastMonitorRecordTwenty(adminUserInfo.Org.Id, id, theAssessmentDateTime)
-
- UltrafiltrationVolumeOne, _ := strconv.ParseFloat(lastRecord.UltrafiltrationVolumeOne, 64)
- afterevaluation.ActualUltrafiltration = UltrafiltrationVolumeOne
-
- }
-
- if afterevaluation.SystolicBloodPressure == 0 {
- lastRecord, _ := service.GetLastMonitorRecordTwentyOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
-
- systolicBloodPressureOne, _ := strconv.ParseFloat(lastRecord.MonitorSystolicBloodPressureOne, 64)
-
- afterevaluation.SystolicBloodPressure = systolicBloodPressureOne
- }
-
- if afterevaluation.DiastolicBloodPressure == 0 {
-
- lastRecord, _ := service.GetLastMonitorRecordTwentyTwo(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- MonitorDiastolicBloodPressureOne, _ := strconv.ParseFloat(lastRecord.MonitorDiastolicBloodPressureOne, 64)
- afterevaluation.DiastolicBloodPressure = MonitorDiastolicBloodPressureOne
- }
-
- if afterevaluation.PulseFrequency == 0 {
- lastRecord, _ := service.GetLastMonitorRecordTwentyThree(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- PulseFrequencyOne, _ := strconv.ParseFloat(lastRecord.PulseFrequencyOne, 64)
- afterevaluation.PulseFrequency = PulseFrequencyOne
- }
-
- if afterevaluation.ActualDisplacement == 0 {
-
- lastRecord, _ := service.GetLastMonitorRecordTwentyFour(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- DisplacementQuantityOne, _ := strconv.ParseFloat(lastRecord.DisplacementQuantityOne, 64)
- afterevaluation.ActualDisplacement = DisplacementQuantityOne
- }
- }
- if adminUserInfo.Org.Id == 10721 {
- afterevaluation.Temperature = 36.5
- }
-
- err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
-
- //记录日志
- byterequest, _ := json.Marshal(afterevaluation)
- afterDialysisLog := models.XtAssessmentAfterDialysisLog{
- UserOrgId: afterevaluation.UserOrgId,
- PatientId: afterevaluation.PatientId,
- RecordDate: afterevaluation.AssessmentDate,
- Status: 1,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "物联网称重",
- }
-
- service.CreateAfterDialysisLog(afterDialysisLog)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
- assessdateDateStart := thisTime.Format("2006-01-02")
- keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyTwo, "", time.Second)
- redis.Close()
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "assessmentAfterDislysis": afterevaluation,
- })
- }
- }
- }
-
- func (c *CheckWeightApiController) SetSyncTime() {
- sn := c.GetString("sn")
- if len(sn) > 0 {
- redis := service.RedisClient()
- defer redis.Close()
- redis.Set(sn, 0, 0)
- }
- serviceTime := time.Now().Unix()
- c.ServeSuccessJSON(map[string]interface{}{
- "status": 1,
- "servicetime": serviceTime,
- })
- }
-
- func (c *CheckWeightApiController) GetPatientList() {
- ftype, _ := c.GetInt64("type", 0)
- sn := c.GetString("sn")
- syncTime := int64(0)
-
- redis := service.RedisClient()
- defer redis.Close()
- if len(sn) > 0 {
- syncTimeStr, _ := redis.Get(sn).Result()
- syncTime, _ = strconv.ParseInt(syncTimeStr, 10, 64)
- }
-
- if ftype == 1 {
- timeNow := time.Now().Unix()
- redis.Set(sn, timeNow, 0)
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- patientList, total, error := service.GetPatientListByUpdateTime(adminUserInfo.Org.Id, int64(syncTime))
- need_update := 0
- if syncTime == 0 {
- need_update = 1
- }
- if error != nil {
- c.ErrorLog("获取病人列表失败:%v", error)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- serviceTime := time.Now().Unix()
- c.ServeSuccessJSON(map[string]interface{}{
- "need_update": need_update,
- "patientlist": patientList,
- "total": total,
- "servicetime": serviceTime,
- })
- }
-
- func (c *CheckWeightApiController) GetPatientListForSchedules() {
- thisTime := time.Now()
- scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- syncTime := theStartTime.Unix()
- adminUserInfo := c.GetMobileAdminUserInfo()
- patientList, total, error := service.GetPatientListBySchedules(adminUserInfo.Org.Id, syncTime)
- patientSchedule := make([]map[string]interface{}, 0)
- for _, item := range patientList {
- patientTemp := make(map[string]interface{})
- patientTemp["patient_id"] = item.PatientId
- patientTemp["patient_name"] = item.Patient.Name
- patientTemp["schedule_type"] = item.ScheduleType
- patientSchedule = append(patientSchedule, patientTemp)
- }
-
- if error != nil {
- c.ErrorLog("获取病人列表失败:%v", error)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- serviceTime := time.Now().Unix()
- c.ServeSuccessJSON(map[string]interface{}{
- "patientlist": patientSchedule,
- "total": total,
- "servicetime": serviceTime,
- })
- }
-
- func (c *CheckWeightApiController) GetPatientListForSchedulesFind() {
- patient_name := c.GetString("patient_name") //脉率
- thisTime := time.Now()
- scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- syncTime := theStartTime.Unix()
- adminUserInfo := c.GetMobileAdminUserInfo()
- if len(patient_name) == 0 {
- patientList, total, error := service.GetPatientListBySchedules(adminUserInfo.Org.Id, syncTime)
- patientSchedule := make([]map[string]interface{}, 0)
- for _, item := range patientList {
- patientTemp := make(map[string]interface{})
- patientTemp["patient_id"] = item.PatientId
- patientTemp["patient_name"] = item.Patient.Name
- patientTemp["schedule_type"] = item.ScheduleType
- patientSchedule = append(patientSchedule, patientTemp)
- }
-
- if error != nil {
- c.ErrorLog("获取病人列表失败:%v", error)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- serviceTime := time.Now().Unix()
- c.ServeSuccessJSON(map[string]interface{}{
- "patientlist": patientSchedule,
- "total": total,
- "servicetime": serviceTime,
- })
- } else {
- patientList, total, error := service.GetPatientListBySchedulesFind(adminUserInfo.Org.Id, syncTime, patient_name)
- patientSchedule := make([]map[string]interface{}, 0)
- for _, item := range patientList {
- if item.Patient.ID > 0 {
- patientTemp := make(map[string]interface{})
- patientTemp["patient_id"] = item.PatientId
- patientTemp["patient_name"] = item.Patient.Name
- patientTemp["schedule_type"] = item.ScheduleType
- patientSchedule = append(patientSchedule, patientTemp)
- }
- }
-
- if error != nil {
- c.ErrorLog("获取病人列表失败:%v", error)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- serviceTime := time.Now().Unix()
- c.ServeSuccessJSON(map[string]interface{}{
- "patientlist": patientSchedule,
- "total": total,
- "servicetime": serviceTime,
- })
- }
- }
-
- func (c *CheckWeightApiController) GetPatientListById() {
- patientId, _ := c.GetInt64("patient_id", 0)
- if patientId <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- patient, error := service.GetPatientListById(adminUserInfo.Org.Id, patientId)
- if error != nil {
- c.ErrorLog("获取病人详情失败:%v", error)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patientinfo": patient,
- })
- }
-
- func (c *CheckWeightApiController) GetPatientInfoDialysis() {
- id, _ := c.GetInt64("patient", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetMobileAdminUserInfo()
- patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
- if patient.ID <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- var dialysisinfo map[string]interface{}
- dialysisinfo = make(map[string]interface{})
-
- dialysisinfo["id"] = patient.ID
- dialysisinfo["name"] = patient.Name
- dialysisinfo["dialysis_no"] = patient.DialysisNo
-
- thisTime := time.Now()
-
- scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
- scheduleDateEnd := thisTime.Format("2006-01-02") + " 23:59:59"
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
- startTime := theStartTime.Unix()
- endTime := theEndTime.Unix()
-
- // 判断当前用户是透析前还是透析后
- var dialysistype int
-
- _, dialysisOrder := service.FindDialysisRecordById(adminUserInfo.Org.Id, id, startTime)
- if dialysisOrder == nil {
- dialysistype = 1
- } else {
- dialysistype = 2
- }
-
- // 获取当前或者下次排班信息
- var sc map[string]interface{}
- sc = make(map[string]interface{})
- if dialysistype == 1 {
- daySchedule, _ := service.GetPatientScheduleFormDay(adminUserInfo.Org.Id, startTime, endTime, id)
- if len(daySchedule) <= 0 {
- sc["code"] = 1
- sc["msg"] = "抱歉,您今天没有排版!"
- sc["mode"] = 0
- sc["data"] = daySchedule
- } else {
- if daySchedule[0].Schedule.ID > 0 {
- sc["code"] = 0
- sc["msg"] = ""
- var mode = "HD"
- if daySchedule[0].Schedule.ModeId == 1 {
- mode = "HD"
- }
-
- if daySchedule[0].Schedule.ModeId == 2 {
- mode = "HDF"
- }
-
- if daySchedule[0].Schedule.ModeId == 3 {
- mode = "HD+HP"
- }
-
- if daySchedule[0].Schedule.ModeId == 4 {
- mode = "HP"
- }
-
- if daySchedule[0].Schedule.ModeId == 5 {
- mode = "HF"
- }
-
- if daySchedule[0].Schedule.ModeId == 6 {
- mode = "SCUF"
- }
-
- if daySchedule[0].Schedule.ModeId == 7 {
- mode = "IUF"
- }
-
- if daySchedule[0].Schedule.ModeId == 8 {
- mode = "HFHD"
- }
-
- if daySchedule[0].Schedule.ModeId == 9 {
- mode = "HFHD+HP"
- }
- if daySchedule[0].Schedule.ModeId == 10 {
- mode = "PHF"
- }
-
- if daySchedule[0].Schedule.ModeId == 11 {
- mode = "HFR"
- }
-
- if daySchedule[0].Schedule.ModeId == 12 {
- mode = "HDF+HP"
- }
-
- if daySchedule[0].Schedule.ModeId == 13 {
- mode = "CRRT"
- }
-
- if daySchedule[0].Schedule.ModeId == 14 {
- mode = "腹水回输"
- }
- if daySchedule[0].Schedule.ModeId == 19 {
- mode = "IUF+HD"
- }
- if daySchedule[0].Schedule.ModeId == 20 {
- mode = "UF"
- }
- if daySchedule[0].Schedule.ModeId == 21 {
- mode = "HD+"
- }
- if daySchedule[0].Schedule.ModeId == 22 {
- mode = "血浆胆红素吸附+HDF"
- }
- if daySchedule[0].Schedule.ModeId == 23 {
- mode = "血浆胆红素吸附"
- }
- if daySchedule[0].Schedule.ModeId == 24 {
- mode = "I-HDF"
- }
-
- if daySchedule[0].Schedule.ModeId == 25 {
- mode = "HD高通"
- }
-
- if daySchedule[0].Schedule.ModeId == 26 {
- mode = "CVVH"
- }
-
- if daySchedule[0].Schedule.ModeId == 27 {
- mode = "CVVHD"
- }
-
- if daySchedule[0].Schedule.ModeId == 28 {
- mode = "CVVHDF"
- }
-
- if daySchedule[0].Schedule.ModeId == 29 {
- mode = "PE"
- }
-
- if daySchedule[0].Schedule.ModeId == 30 {
- mode = "血浆胆红素吸附+HP"
- }
- if daySchedule[0].Schedule.ModeId == 31 {
- mode = "HPD"
- }
- if daySchedule[0].Schedule.ModeId == 32 {
- mode = "HDP"
- }
- if daySchedule[0].Schedule.ModeId == 33 {
- mode = "HFD"
- }
- if daySchedule[0].Schedule.ModeId == 34 {
- mode = "HDF100"
- }
- if daySchedule[0].Schedule.ModeId == 35 {
- mode = "HDF600"
- }
- if daySchedule[0].Schedule.ModeId == 36 {
- mode = "HDF800"
- }
- if daySchedule[0].Schedule.ModeId == 37 {
- mode = "HDF1000"
- }
-
- sc["mode"] = mode
- sc["data"] = daySchedule
- } else {
- sc["code"] = 1
- sc["msg"] = "抱歉,您今天没有排版!"
- sc["mode"] = "HD"
- sc["data"] = daySchedule
- }
- }
-
- // 排队叫号的签到
- go func() {
- ssoDomain := beego.AppConfig.String("call_domain")
- api := ssoDomain + "/index/patientsign/" + strconv.FormatInt(adminUserInfo.Org.Id, 10) + "/" + strconv.FormatInt(id, 10)
- values := make(url.Values)
- http.PostForm(api, values)
- }()
- } else {
- nextSchedule, _ := service.GetNextSchedule(adminUserInfo.Org.Id, endTime, id)
- if len(nextSchedule) <= 0 {
- sc["code"] = 1
- sc["msg"] = "抱歉,您后续没有排版!"
- sc["mode"] = "HD"
- sc["data"] = nextSchedule
- } else {
- if nextSchedule[0].Schedule.ID > 0 {
- sc["code"] = 0
- sc["msg"] = ""
- var mode = "HD"
- if nextSchedule[0].Schedule.ModeId == 1 {
- mode = "HD"
- }
-
- if nextSchedule[0].Schedule.ModeId == 2 {
- mode = "HDF"
- }
-
- if nextSchedule[0].Schedule.ModeId == 3 {
- mode = "HD+HP"
- }
-
- if nextSchedule[0].Schedule.ModeId == 4 {
- mode = "HP"
- }
-
- if nextSchedule[0].Schedule.ModeId == 5 {
- mode = "HF"
- }
-
- if nextSchedule[0].Schedule.ModeId == 6 {
- mode = "SCUF"
- }
-
- if nextSchedule[0].Schedule.ModeId == 7 {
- mode = "IUF"
- }
-
- if nextSchedule[0].Schedule.ModeId == 8 {
- mode = "HFHD"
- }
-
- if nextSchedule[0].Schedule.ModeId == 9 {
- mode = "HFHD+HP"
- }
- if nextSchedule[0].Schedule.ModeId == 10 {
- mode = "PHF"
- }
-
- if nextSchedule[0].Schedule.ModeId == 11 {
- mode = "HFR"
- }
-
- if nextSchedule[0].Schedule.ModeId == 12 {
- mode = "HDF+HP"
- }
-
- if nextSchedule[0].Schedule.ModeId == 13 {
- mode = "CRRT"
- }
-
- if nextSchedule[0].Schedule.ModeId == 14 {
- mode = "腹水回输"
- }
- if nextSchedule[0].Schedule.ModeId == 19 {
- mode = "IUF+HD"
- }
- if nextSchedule[0].Schedule.ModeId == 20 {
- mode = "UF"
- }
- if nextSchedule[0].Schedule.ModeId == 21 {
- mode = "HD+"
- }
- if nextSchedule[0].Schedule.ModeId == 22 {
- mode = "血浆胆红素吸附+HDF"
- }
- if nextSchedule[0].Schedule.ModeId == 23 {
- mode = "血浆胆红素吸附"
- }
- if nextSchedule[0].Schedule.ModeId == 24 {
- mode = "I-HDF"
- }
-
- if nextSchedule[0].Schedule.ModeId == 25 {
- mode = "HD高通"
- }
-
- if nextSchedule[0].Schedule.ModeId == 26 {
- mode = "CVVH"
- }
-
- if nextSchedule[0].Schedule.ModeId == 27 {
- mode = "CVVHD"
- }
-
- if nextSchedule[0].Schedule.ModeId == 28 {
- mode = "CVVHDF"
- }
-
- if nextSchedule[0].Schedule.ModeId == 29 {
- mode = "PE"
- }
-
- if nextSchedule[0].Schedule.ModeId == 30 {
- mode = "血浆胆红素吸附+HP"
- }
- if nextSchedule[0].Schedule.ModeId == 31 {
- mode = "HPD"
- }
- if nextSchedule[0].Schedule.ModeId == 32 {
- mode = "HDP"
- }
- if nextSchedule[0].Schedule.ModeId == 33 {
- mode = "HFD"
- }
- if nextSchedule[0].Schedule.ModeId == 34 {
- mode = "HDF100"
- }
- if nextSchedule[0].Schedule.ModeId == 35 {
- mode = "HDF600"
- }
- if nextSchedule[0].Schedule.ModeId == 36 {
- mode = "HDF800"
- }
- if nextSchedule[0].Schedule.ModeId == 37 {
- mode = "HDF1000"
- }
- sc["mode"] = mode
- sc["data"] = nextSchedule
- } else {
- sc["code"] = 1
- sc["msg"] = "抱歉,您后续没有排版!"
- sc["mode"] = "HD"
- sc["data"] = nextSchedule
- }
- }
- }
-
- //switch sc["mode"] {
- //case 1:
- // sc["mode"] = "HD"
- // break
- //case 2:
- // sc["mode"] = "HDF"
- // break
- //case 3:
- // sc["mode"] = "HD+HP"
- // break
- //case 4:
- // sc["mode"] = "HP"
- // break
- //case 5:
- // sc["mode"] = "HF"
- // break
- //case 6:
- // sc["mode"] = "SCUF"
- // break
- //case 7:
- // sc["mode"] = "IUF"
- // break
- //case 8:
- // sc["mode"] = "HFHD"
- // break
- //case 9:
- // sc["mode"] = "HFHD+HP"
- // break
- //case 10:
- // sc["mode"] = "PHF"
- // break
- //case 11:
- // sc["mode"] = "HFR"
- // break
- //case 12:
- // sc["mode"] = "HDF+HP"
- // break
- //case 13:
- // sc["mode"] = "CRRT"
- // break
- //case 14:
- // sc["mode"] = "腹水回输"
- // break
- //case 15:
- // sc["mode"] = "HD前置换"
- // break
- //case 16:
- // sc["mode"] = "HD后置换"
- // break
- //case 17:
- // sc["mode"] = "HDF前置换"
- // break
- //case 18:
- // sc["mode"] = "HDF后置换"
- // break
- //default:
- // sc["mode"] = "HD"
- // break
- //}
-
- // 获取患者透前干体重或者获取患者透前体重
- var dry_weight map[string]interface{}
- dry_weight = make(map[string]interface{})
- var after_dry_weight map[string]interface{}
- after_dry_weight = make(map[string]interface{})
- if dialysistype == 1 {
-
- lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, endTime)
- weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
- if err == gorm.ErrRecordNotFound {
- if getLPEErr != nil {
- dry_weight["code"] = 1
- dry_weight["dry_weight"] = nil
- } else {
- if lastPredialysisEvaluation == nil {
- dry_weight["code"] = 1
- dry_weight["dry_weight"] = nil
- } else {
- // 传输的干体重实际为干体重加上衣服重
- dry_weight["code"] = 0
- dry_weight["dry_weight"] = lastPredialysisEvaluation.DryWeight + lastPredialysisEvaluation.AdditionalWeight
- }
- }
- } else {
- if err != nil {
- dry_weight["code"] = 1
- dry_weight["dry_weight"] = nil
- } else {
- dry_weight["code"] = 0
- if getLPEErr != nil {
- dry_weight["code"] = 0
- dry_weight["dry_weight"] = weight.DryWeight
- } else {
- if lastPredialysisEvaluation == nil {
- dry_weight["code"] = 1
- dry_weight["dry_weight"] = weight.DryWeight
- } else {
- // 传输的干体重实际为干体重加上衣服重
- dry_weight["code"] = 0
- dry_weight["dry_weight"] = weight.DryWeight + lastPredialysisEvaluation.AdditionalWeight
- }
- }
- }
- }
-
- } else {
- predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, startTime)
- if getPEErr != nil {
- dry_weight["code"] = 1
- dry_weight["dry_weight"] = nil
- } else {
- if predialysisEvaluation == nil {
- dry_weight["code"] = 1
- dry_weight["dry_weight"] = nil
- } else {
- dry_weight["code"] = 0
- dry_weight["dry_weight"] = predialysisEvaluation.WeightBefore
- }
- }
-
- lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, endTime)
- weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
- if err == gorm.ErrRecordNotFound {
- if getLPEErr != nil {
- after_dry_weight["code"] = 1
- after_dry_weight["dry_weight"] = nil
- } else {
- if lastPredialysisEvaluation == nil {
- after_dry_weight["code"] = 1
- after_dry_weight["dry_weight"] = nil
- } else {
- // 传输的干体重实际为干体重加上衣服重
- after_dry_weight["code"] = 0
- after_dry_weight["dry_weight"] = lastPredialysisEvaluation.DryWeight + lastPredialysisEvaluation.AdditionalWeight
- }
- }
- } else {
- if err != nil {
- after_dry_weight["code"] = 1
- after_dry_weight["dry_weight"] = nil
- } else {
- after_dry_weight["code"] = 0
- if getLPEErr != nil {
- after_dry_weight["code"] = 0
- after_dry_weight["dry_weight"] = weight.DryWeight
- } else {
- if lastPredialysisEvaluation == nil {
- after_dry_weight["code"] = 1
- after_dry_weight["dry_weight"] = weight.DryWeight
- } else {
- // 传输的干体重实际为干体重加上衣服重
- after_dry_weight["code"] = 0
- after_dry_weight["dry_weight"] = weight.DryWeight + lastPredialysisEvaluation.AdditionalWeight
- }
- }
- }
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dialysistype": dialysistype,
- "patient": dialysisinfo,
- "schedule": sc,
- "dryweight": dry_weight,
- "after_dry_weight": after_dry_weight,
- })
- return
- }
- func (c *CheckWeightApiController) GetPatientInfoBeforeDialysis() {
- id, _ := c.GetInt64("patient", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetMobileAdminUserInfo()
- patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- var dialysisinfo map[string]interface{}
- dialysisinfo = make(map[string]interface{})
-
- dialysisinfo["id"] = patient.ID
- dialysisinfo["name"] = patient.Name
- dialysisinfo["dialysis_no"] = patient.DialysisNo
-
- thisTime := time.Now()
-
- scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
- scheduleDateEnd := thisTime.Format("2006-01-02") + " 23:59:59"
- fmt.Println(scheduleDateStart, scheduleDateEnd)
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
- fmt.Println(theStartTime, theEndTime)
- startTime := theStartTime.Unix()
- endTime := theEndTime.Unix()
-
- var sc map[string]interface{}
- sc = make(map[string]interface{})
- //一天只有排班一次
- daySchedule, _ := service.GetDaySchedule(adminUserInfo.Org.Id, startTime, endTime, id)
- if daySchedule.ID > 0 {
- switch daySchedule.ModeId {
- case 1:
- sc["mode"] = "HD"
- case 2:
- sc["mode"] = "HDF"
- case 3:
- sc["mode"] = "HD+HP"
- case 4:
- sc["mode"] = "HP"
- case 5:
- sc["mode"] = "HF"
- case 6:
- sc["mode"] = "SCUF"
- case 7:
- sc["mode"] = "IUF"
- case 8:
- sc["mode"] = "HFHD"
- case 9:
- sc["mode"] = "HFHD+HP"
- case 10:
- sc["mode"] = "PHF"
- case 11:
- sc["mode"] = "HFR"
- case 12:
- sc["mode"] = "HDF+HP"
- case 13:
- sc["mode"] = "CRRT"
- case 14:
- sc["mode"] = "腹水回输"
- case 15:
- sc["mode"] = "HD前置换"
- case 16:
- sc["mode"] = "HD后置换"
- case 17:
- sc["mode"] = "HDF前置换"
- case 18:
- sc["mode"] = "HDF后置换"
- default:
- sc["mode"] = "HD"
- }
- sc["code"] = 0
- sc["msg"] = ""
- sc["data"] = daySchedule
- } else {
- sc["code"] = 1
- sc["msg"] = "抱歉,您今天没有排版!"
- sc["mode"] = ""
- sc["data"] = daySchedule
- }
-
- fmt.Println(sc)
-
- type dryWeight struct {
- code int
- dry_weight float64
- }
-
- var dry_weight map[string]interface{}
- dry_weight = make(map[string]interface{})
-
- lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, startTime)
- if getLPEErr != nil {
- dry_weight["code"] = 1
- dry_weight["dry_weight"] = nil
- } else {
- if lastPredialysisEvaluation == nil {
- dry_weight["code"] = 1
- dry_weight["dry_weight"] = nil
- } else {
- dry_weight["code"] = 0
- dry_weight["dry_weight"] = lastPredialysisEvaluation.DryWeight
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": dialysisinfo,
- "schedule": sc,
- "dryweight": dry_weight,
- })
- return
- }
|