12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787 |
- package controllers
-
- import (
- "Xcx_New/enums"
- "Xcx_New/models"
- "Xcx_New/service"
- "Xcx_New/utils"
- "encoding/json"
- "fmt"
- "reflect"
- "strconv"
- "time"
-
- "github.com/astaxie/beego"
- )
-
- type DataApiController struct {
- BaseAuthAPIController
- }
-
- func DataApiRegistRouters() {
- beego.Router("/api/getconfiglist", &DataApiController{}, "get,post:GetConfigList")
- beego.Router("/api/createconfig", &DataApiController{}, "Post:CreateConfig")
- beego.Router("/api/createchildconfig", &DataApiController{}, "Post:CreateChildConfig")
- beego.Router("/api/updatechildconfig", &DataApiController{}, "Post:UpdateChildConfig")
- beego.Router("/api/deletechildconfig", &DataApiController{}, "Post:DeleteChildConfig")
- beego.Router("/api/updatetemplate", &DataApiController{}, "Post:UpdateTemplate")
-
- beego.Router("/api/getadviceconfigs", &DataApiController{}, "Get:GetAdviceConfigs")
- beego.Router("/api/getalladviceconfig", &DataApiController{}, "Get:GetAllAdviceConfigs")
-
- beego.Router("/api/drugdic/create", &DataApiController{}, "Post:CreateDrugDic")
- beego.Router("/api/drugdic/update", &DataApiController{}, "Put:UpdateDrugDic")
- beego.Router("/api/drugdic/delete", &DataApiController{}, "Delete:DeleteDrugDic")
- beego.Router("/api/drugway/create", &DataApiController{}, "Post:CreateDrugWay")
- beego.Router("/api/drugway/update", &DataApiController{}, "Put:UpdateDrugWay")
- beego.Router("/api/drugway/delete", &DataApiController{}, "Delete:DeleteDrugWay")
- beego.Router("/api/executionfrequency/create", &DataApiController{}, "Post:CreateExecutionFrequency")
- beego.Router("/api/executionfrequency/update", &DataApiController{}, "Put:UpdateExecutionFrequency")
- beego.Router("/api/executionfrequency/delete", &DataApiController{}, "Delete:DeleteExecutionFrequency")
-
- beego.Router("/api/advicetemplate/create", &DataApiController{}, "Post:CreateAdviceTemplate")
- beego.Router("/api/subadvice/create", &DataApiController{}, "Post:CreateSubAdviceTemplate")
- beego.Router("/api/advicetemplate/update", &DataApiController{}, "Put:UpdateAdviceTemplate")
- beego.Router("/api/advicetemplate/delete", &DataApiController{}, "Delete:DeleteAdviceTemplate")
- beego.Router("/api/advicetemplate/add", &DataApiController{}, "Post:CreateSingleAdviceTemplate")
- beego.Router("/api/adviceparenttemplate/delete", &DataApiController{}, "Delete:DeleteParentAdviceTemplate")
- beego.Router("/api/template/modify", &DataApiController{}, "Post:ModifyTemplateName")
-
- beego.Router("/api/filed/show", &DataApiController{}, "Post:ModifyFiledIsShow")
- beego.Router("/article/hanleupdatetwo", &DataApiController{}, "Get:GetHandleData")
- beego.Router("/article/updatedatatwo", &DataApiController{}, "Post:UpdateDataTwo")
-
- beego.Router("/api/hisadvicetemplate/create", &DataApiController{}, "Post:CreateHisAdviceTemplate")
- beego.Router("/api/hisadvicetemplate/update", &DataApiController{}, "Put:UpdateHisAdviceTemplate")
- beego.Router("/api/hisadvicetemplate/delete", &DataApiController{}, "Delete:DeleteHisAdviceTemplate")
- beego.Router("/api/hisadvicetemplate/add", &DataApiController{}, "Post:CreateSingleHisAdviceTemplate")
- beego.Router("/api/hisadviceparenttemplate/delete", &DataApiController{}, "Delete:DeleteHisParentAdviceTemplate")
- beego.Router("/api/histemplate/modify", &DataApiController{}, "Post:ModifyHisTemplateName")
- beego.Router("/api/getallhisadvicetemplate", &DataApiController{}, "Get:GetAllHisAdviceTemplate")
-
- }
-
- //GetPatientsList 取配置信息列表
- func (c *DataApiController) GetConfigList() {
- adminUserInfo := c.GetAdminUserInfo()
- configList, _ := service.GetConfigList(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "configlist": configList,
- })
- return
-
- }
-
- //CreateConfig 创建配置信息
- func (c *DataApiController) CreateConfig() {
- adminUserInfo := c.GetAdminUserInfo()
-
- var dataconfig models.Dataconfig
- var resultConfig models.ConfigViewModel
- code := configFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
- // 验证关键字段的值是否重复
-
- thisConfig, _ := service.FindConfigByTitle(dataconfig.Module, dataconfig.FieldName, adminUserInfo.CurrentOrgId)
- fmt.Println("99999", thisConfig)
- if thisConfig.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
- return
- }
-
- fieldValue := service.GetChildValue(dataconfig.Module, dataconfig.ParentId, adminUserInfo.CurrentOrgId)
- dataconfig.Value = fieldValue + 1
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 1
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- if dataBody["order"] != nil {
- dataconfig.Order = int64(dataBody["order"].(float64))
- } else {
- dataconfig.Order = 0
- }
- fmt.Println("dataconfig-------------", dataconfig)
- err = service.CreateConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- } else {
- resultConfig.ID = dataconfig.ID
- resultConfig.Module = dataconfig.Module
- resultConfig.Name = dataconfig.Name
- resultConfig.OrgId = dataconfig.OrgId
- resultConfig.ParentId = dataconfig.ParentId
- resultConfig.FieldName = dataconfig.FieldName
- resultConfig.CreateUserId = dataconfig.CreateUserId
- resultConfig.Title = dataconfig.Title
- resultConfig.Content = dataconfig.Content
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": resultConfig,
- "msg": "ok",
- })
- return
- }
-
- func (c *DataApiController) UpdateTemplate() {
- adminUserInfo := c.GetAdminUserInfo()
- var dataconfig models.Dataconfig
- code := configFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 1
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- if dataBody["order"] != nil {
- dataconfig.Order = int64(dataBody["order"].(float64))
- } else {
- dataconfig.Order = 0
- }
-
- // 验证关键字段的值是否重复
- // cur_id := int64(dataBody["id"].(float64))
- // thisConfig,_:=service.FindConfigByTitleForUpdate(dataconfig.Module, dataconfig.Title,dataconfig.OrgId,cur_id)
- // if thisConfig.ID >0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
- // return
- // }
-
- configOrgId := int64(dataBody["org_id"].(float64))
- if configOrgId == 0 {
- dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
- err := service.CreateConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- } else {
- dataconfig.ID = int64(dataBody["id"].(float64))
- err = service.UpdateTemplate(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": dataconfig,
- "msg": "ok",
- })
- return
- }
-
- func (c *DataApiController) UpdateChildConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- var dataconfig models.Dataconfig
- code := configChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 1
- dataconfig.Value = int(int64(dataBody["value"].(float64)))
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- dataconfig.Order = int64(dataBody["orders"].(float64))
- dataconfig.FieldType = int64(dataBody["field_type"].(float64))
- fmt.Println("dataconfitg------", dataconfig.Order)
- //if dataBody["orders"] != nil {
- // dataconfig.Order = int64(dataBody["orders"].(float64))
- // fmt.Println("dataconfig",dataconfig.Order)
- //} else {
- // dataconfig.Order = 0
- //}
- configOrgId := int64(dataBody["org_id"].(float64))
- // 验证关键字段的值是否重复
- // configId := int64(dataBody["id"].(float64))
- // thisConfig,_:=service.FindConfigByNameForUpdate(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId,configId)
- // if thisConfig.ID >0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
- // return
- // }
-
- if configOrgId == 0 {
- dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
- err := service.CreateConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- } else {
- dataconfig.ID = int64(dataBody["id"].(float64))
- err = service.UpdateChildConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": dataconfig,
- "msg": "ok",
- })
- return
- }
-
- func (c *DataApiController) DeleteChildConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- var dataconfig models.Dataconfig
- code := configChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 0
- dataconfig.Value = int(int64(dataBody["value"].(float64)))
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- if dataBody["order"] != nil {
- dataconfig.Order = int64(dataBody["order"].(float64))
- } else {
- dataconfig.Order = 0
- }
- configOrgId := int64(dataBody["org_id"].(float64))
-
- if configOrgId == 0 {
- dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
- err := service.CreateConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- } else {
- dataconfig.ID = int64(dataBody["id"].(float64))
- err := service.DeleteChildConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": dataconfig,
- "msg": "ok",
- })
- return
- }
-
- //CreateChildConfig 创建子配置信息
- func (c *DataApiController) CreateChildConfig() {
- adminUserInfo := c.GetAdminUserInfo()
-
- var dataconfig models.Dataconfig
- code := configChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 1
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- if dataBody["order"] != nil {
- dataconfig.Order = int64(dataBody["order"].(float64))
- } else {
- dataconfig.Order = 0
- }
-
- if dataBody["field_type"] != nil {
- dataconfig.FieldType = int64(dataBody["field_type"].(float64))
- } else {
- dataconfig.FieldType = 0
- }
-
- // 验证关键字段的值是否重复
- // thisConfig,_:=service.FindConfigByName(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId)
- // if thisConfig.ID >0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
- // return
- // }
-
- fieldValue := service.GetChildValue(dataconfig.Module, dataconfig.ParentId, dataconfig.OrgId)
- dataconfig.Value = fieldValue + 1
-
- err = service.CreateConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": dataconfig,
- "msg": "ok",
- })
- return
- }
-
- func configFormData(dataconfig *models.Dataconfig, data []byte) (code int) {
- configBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &configBody)
- utils.InfoLog(string(data))
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
- utils.ErrorLog("module")
- code = enums.ErrorCodeParamWrong
- return
- }
- module, _ := configBody["module"].(string)
- if len(module) == 0 {
- utils.ErrorLog("len(module) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Module = module
-
- if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" || module == "special_treatment" || module == "template_summary" || module == "template_plan" {
- if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
- utils.ErrorLog("title")
- code = enums.ErrorCodeParamWrong
- return
- }
- title, _ := configBody["title"].(string)
- if len(title) == 0 {
- utils.ErrorLog("len(title) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Title = title
-
- if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
- utils.ErrorLog("content")
- code = enums.ErrorCodeParamWrong
- return
- }
- content, _ := configBody["content"].(string)
- if len(content) == 0 {
- utils.ErrorLog("len(content) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Content = content
- } else {
- if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
- utils.ErrorLog("name")
- code = enums.ErrorCodeParamWrong
- return
- }
- name, _ := configBody["name"].(string)
- if len(name) == 0 {
- utils.ErrorLog("len(name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Name = name
-
- if configBody["field_name"] == nil || reflect.TypeOf(configBody["field_name"]).String() != "string" {
- utils.ErrorLog("field_name")
- code = enums.ErrorCodeParamWrong
- return
- }
- field_name, _ := configBody["field_name"].(string)
- if len(field_name) == 0 {
- utils.ErrorLog("len(field_name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.FieldName = field_name
- }
- return
- }
-
- func configChildFormData(dataconfig *models.Dataconfig, data []byte) (code int) {
- configBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &configBody)
- utils.InfoLog(string(data))
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
-
- if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
- utils.ErrorLog("module")
- code = enums.ErrorCodeParamWrong
- return
- }
- module, _ := configBody["module"].(string)
- if len(module) == 0 {
- utils.ErrorLog("len(module) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Module = module
-
- if module == "education" || module == "summary" {
- if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
- utils.ErrorLog("title")
- code = enums.ErrorCodeParamWrong
- return
- }
- title, _ := configBody["title"].(string)
- if len(title) == 0 {
- utils.ErrorLog("len(title) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Title = title
-
- if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
- utils.ErrorLog("content")
- code = enums.ErrorCodeParamWrong
- return
- }
- content, _ := configBody["content"].(string)
- if len(content) == 0 {
- utils.ErrorLog("len(content) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Content = content
- } else {
- if configBody["parent_id"] == nil || reflect.TypeOf(configBody["parent_id"]).String() != "float64" {
- utils.ErrorLog("module")
- code = enums.ErrorCodeParamWrong
- return
- }
- parent_id := int64(configBody["parent_id"].(float64))
- if parent_id <= 0 {
- utils.ErrorLog("parent_id <= 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.ParentId = parent_id
-
- if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
- utils.ErrorLog("name")
- code = enums.ErrorCodeParamWrong
- return
- }
- name, _ := configBody["name"].(string)
- if len(name) == 0 {
- utils.ErrorLog("len(name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Name = name
- }
- return
- }
-
- func (c *DataApiController) GetAdviceConfigs() {
- advice_type, _ := c.GetInt64("type", 0)
- adminUserInfo := c.GetAdminUserInfo()
- var drugs []models.DrugDic
- drugways, _, _ := service.GetDrugWayDics(adminUserInfo.CurrentOrgId)
- efs, _, _ := service.GetExecutionFrequencyDics(adminUserInfo.CurrentOrgId)
- adviceTemplates, _ := service.FindAllAdviceTemplate(adminUserInfo.CurrentOrgId, advice_type)
- c.ServeSuccessJSON(map[string]interface{}{
- "drugs": drugs,
- "drugways": drugways,
- "efs": efs,
- "advice_templates": adviceTemplates,
- })
- }
-
- func (c *DataApiController) CreateDrugDic() {
-
- adminUserInfo := c.GetAdminUserInfo()
-
- var drugdic models.DrugDic
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &drugdic)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if drugdic.Name == "" {
- utils.ErrorLog("医嘱名称不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeNow := time.Now().Unix()
- drugdic.Code = ""
- drugdic.Status = 1
- drugdic.CreatedTime = timeNow
- drugdic.UpdatedTime = timeNow
- drugdic.OrgId = adminUserInfo.CurrentOrgId
- drugdic.Creator = adminUserInfo.AdminUser.Id
-
- err = service.CreateDrugDic(&drugdic)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "drugdic": drugdic,
- })
- return
- }
-
- func (c *DataApiController) UpdateDrugDic() {
-
- adminUserInfo := c.GetAdminUserInfo()
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- drugdic, _ := service.FindDrugDic(adminUserInfo.CurrentOrgId, id)
- if drugdic == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- var drugdicdata models.DrugDic
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &drugdicdata)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if drugdicdata.Name == "" {
- utils.ErrorLog("医嘱名称不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeNow := time.Now().Unix()
- drugdic.UpdatedTime = timeNow
- drugdic.Name = drugdicdata.Name
- drugdic.Spec = drugdicdata.Spec
- drugdic.SpecUnit = drugdicdata.SpecUnit
- drugdic.Form = drugdicdata.Form
- drugdic.FormUnit = drugdicdata.FormUnit
-
- err = service.UpdateDrugDic(drugdic)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "drugdic": drugdic,
- })
- return
- }
-
- func (c *DataApiController) DeleteDrugDic() {
- adminUserInfo := c.GetAdminUserInfo()
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drugdic, _ := service.FindDrugDic(adminUserInfo.CurrentOrgId, id)
- if drugdic == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
- timeNow := time.Now().Unix()
- drugdic.UpdatedTime = timeNow
- drugdic.Status = 2
-
- err := service.UpdateDrugDic(drugdic)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
- }
-
- func (c *DataApiController) CreateDrugWay() {
-
- adminUserInfo := c.GetAdminUserInfo()
-
- var drugway models.DrugwayDic
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &drugway)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if drugway.Name == "" {
- utils.ErrorLog("给药途径不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeNow := time.Now().Unix()
- drugway.Code = ""
- drugway.Status = 1
- drugway.CreatedTime = timeNow
- drugway.UpdatedTime = timeNow
- drugway.OrgId = adminUserInfo.CurrentOrgId
- drugway.Creator = adminUserInfo.AdminUser.Id
-
- err = service.CreateDrugWay(&drugway)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "drugway": drugway,
- })
- return
- }
-
- func (c *DataApiController) UpdateDrugWay() {
-
- adminUserInfo := c.GetAdminUserInfo()
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- drugway, _ := service.FindDrugWay(adminUserInfo.CurrentOrgId, id)
- if drugway == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- var drugwaydata models.DrugwayDic
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &drugwaydata)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if drugwaydata.Name == "" {
- utils.ErrorLog("给药途径不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeNow := time.Now().Unix()
- drugway.UpdatedTime = timeNow
- drugway.Name = drugwaydata.Name
-
- err = service.UpdateDrugWay(drugway)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "drugway": drugway,
- })
- return
- }
-
- func (c *DataApiController) DeleteDrugWay() {
- adminUserInfo := c.GetAdminUserInfo()
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- drugway, _ := service.FindDrugWay(adminUserInfo.CurrentOrgId, id)
- if drugway == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- timeNow := time.Now().Unix()
- drugway.UpdatedTime = timeNow
- drugway.Status = 2
-
- err := service.UpdateDrugWay(drugway)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
- }
-
- func (c *DataApiController) CreateExecutionFrequency() {
-
- adminUserInfo := c.GetAdminUserInfo()
-
- var ef models.ExecutionFrequencyDic
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &ef)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if ef.Name == "" {
- utils.ErrorLog("执行频率不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeNow := time.Now().Unix()
- ef.Code = ""
- ef.Status = 1
- ef.CreatedTime = timeNow
- ef.UpdatedTime = timeNow
- ef.OrgId = adminUserInfo.CurrentOrgId
- ef.Creator = adminUserInfo.AdminUser.Id
-
- err = service.CreateExecutionFrequency(&ef)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "ef": ef,
- })
- return
- }
-
- func (c *DataApiController) UpdateExecutionFrequency() {
-
- adminUserInfo := c.GetAdminUserInfo()
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- ef, _ := service.FindExecutionFrequency(adminUserInfo.CurrentOrgId, id)
- if ef == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- var efdata models.ExecutionFrequencyDic
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &efdata)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if efdata.Name == "" {
- utils.ErrorLog("执行频率不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeNow := time.Now().Unix()
- ef.UpdatedTime = timeNow
- ef.Name = efdata.Name
-
- err = service.UpdateExecutionFrequency(ef)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "ef": ef,
- })
- return
- }
-
- func (c *DataApiController) DeleteExecutionFrequency() {
- adminUserInfo := c.GetAdminUserInfo()
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- ef, _ := service.FindExecutionFrequency(adminUserInfo.CurrentOrgId, id)
- if ef == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- timeNow := time.Now().Unix()
- ef.UpdatedTime = timeNow
- ef.Status = 2
-
- err := service.UpdateExecutionFrequency(ef)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
- }
-
- func (c *DataApiController) CreateAdviceTemplate() {
- templateName := c.GetString("template_name")
- advice_type, _ := c.GetInt64("advice_type")
- sort, _ := c.GetInt64("sort")
-
- if templateName == "" {
- utils.ErrorLog("模版名称不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamEmptyWrong)
- return
- }
-
- if advice_type < 0 {
- utils.ErrorLog("医嘱模版类型不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceTypeWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- if appRole.UserType == 3 {
- headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- if getPermissionErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if headNursePermission == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateAdvice)
- return
- }
- }
-
- template := &models.DoctorAdviceParentTemplate{
- Name: templateName,
- OrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- AdviceType: advice_type,
- Sort: sort,
- }
-
- createErr := service.CreateTemplate(template)
- if createErr != nil {
- utils.ErrorLog("%v", createErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- var subTemplate []*models.DoctorAdviceTemplate
- if dataBody["data"] != nil && reflect.TypeOf(dataBody["data"]).String() == "[]interface {}" {
- subTemp, _ := dataBody["data"].([]interface{})
- if len(subTemp) > 0 {
- for _, item := range subTemp {
- items := item.(map[string]interface{})
- if items["advice_name"] == nil || reflect.TypeOf(items["advice_name"]).String() != "string" {
- utils.ErrorLog("advice_name")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- advice_name, _ := items["advice_name"].(string)
- advice_desc, _ := items["advice_desc"].(string)
- single_dose_unit, _ := items["single_dose_unit"].(string)
- prescribing_number_unit, _ := items["prescribing_number_unit"].(string)
- delivery_way, _ := items["delivery_way"].(string)
- execution_frequency, _ := items["execution_frequency"].(string)
- drug_spec, _ := items["drug_spec"].(string)
- drug_spec_unit, _ := items["drug_spec_unit"].(string)
- single_dose := items["single_dose"].(float64)
- prescribing_number := items["prescribing_number"].(float64)
-
- day_count, _ := strconv.ParseInt(items["day_count"].(string), 10, 64)
- weekdays := items["weekdays"].(string)
- frequency_type := int64(items["frequency_type"].(float64))
-
- drug_id := int64(items["drug_id"].(float64))
-
- way := int64(items["way"].(float64))
-
- subTemps := &models.DoctorAdviceTemplate{
- AdviceName: advice_name,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- OrgId: adminUserInfo.CurrentOrgId,
- AdviceDesc: advice_desc,
- AdviceType: advice_type,
- SingleDoseUnit: single_dose_unit,
- PrescribingNumber: prescribing_number,
- PrescribingNumberUnit: prescribing_number_unit,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- TemplateId: template.ID,
- DrugSpec: drug_spec,
- DrugSpecUnit: drug_spec_unit,
- SingleDose: single_dose,
- AdviceDoctor: adminUserInfo.AdminUser.Id,
- DayCount: day_count,
- WeekDays: weekdays,
- FrequencyType: frequency_type,
- Way: way,
- DrugId: drug_id,
- DrugNameId: 0,
- }
- subTemplate = append(subTemplate, subTemps)
-
- }
- }
- }
- //errs := service.CreateBatchRecord(subTemplate)
- errs := service.CreateSubTemplate(subTemplate)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
- return
- }
- templates, _ := service.FindDoctorAdviceTemplateById(template.ID, adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "template": templates,
- })
- return
- }
-
- func (c *DataApiController) UpdateAdviceTemplate() {
-
- adminUserInfo := c.GetAdminUserInfo()
- id, _ := c.GetInt64("id", 0)
-
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- template, _ := service.FindAdviceTemplate(adminUserInfo.CurrentOrgId, id)
- if template == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- //TODO 根据路由来做权限
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- //if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- var templatedata models.DoctorAdviceTemplate
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &templatedata)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if templatedata.AdviceName == "" {
- utils.ErrorLog("不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeNow := time.Now().Unix()
- template.UpdatedTime = timeNow
- template.AdviceName = templatedata.AdviceName
- template.AdviceDesc = templatedata.AdviceDesc
- template.SingleDose = templatedata.SingleDose
- template.SingleDoseUnit = templatedata.SingleDoseUnit
- template.PrescribingNumber = templatedata.PrescribingNumber
- template.PrescribingNumberUnit = templatedata.PrescribingNumberUnit
- template.DrugSpec = templatedata.DrugSpec
- template.DrugSpecUnit = templatedata.DrugSpecUnit
- template.DeliveryWay = templatedata.DeliveryWay
- template.ExecutionFrequency = templatedata.ExecutionFrequency
-
- template.FrequencyType = templatedata.FrequencyType
- template.DayCount = templatedata.DayCount
- template.WeekDays = templatedata.WeekDays
- template.DrugId = template.DrugId
- template.Way = template.Way
-
- err = service.UpdateAdviceTemplate(template)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- return
- }
-
- func (c *DataApiController) DeleteAdviceTemplate() {
- adminUserInfo := c.GetAdminUserInfo()
- parent_id, _ := c.GetInt64("parent_id", 0)
- id, _ := c.GetInt64("id", 0)
-
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- template, _ := service.FindAdviceTemplate(adminUserInfo.CurrentOrgId, id)
- if template == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- //if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- timeNow := time.Now().Unix()
- template.ID = id
- template.UpdatedTime = timeNow
- template.ParentId = parent_id
- template.Status = 2
-
- if parent_id > 0 { //删除子医嘱
- err := service.UpdateAdviceTemplate(template)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- } else { //删除该医嘱下的所有子医嘱
- err := service.UpdateAdviceAndSubAdviceTemplate(template)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
- }
-
- func (c *DataApiController) CreateSingleAdviceTemplate() {
- drug_spec := c.GetString("drug_spec")
- drug_spec_unit := c.GetString("drug_spec_unit")
- advice_name := c.GetString("advice_name")
- advice_desc := c.GetString("advice_desc")
- single_dose, _ := c.GetFloat("single_dose", 0)
- single_dose_unit := c.GetString("single_dose_unit")
- prescribing_number, _ := c.GetFloat("prescribing_number", 0)
- prescribing_number_unit := c.GetString("prescribing_number_unit")
- delivery_way := c.GetString("delivery_way")
- execution_frequency := c.GetString("execution_frequency")
- template_id, _ := c.GetInt64("template_id", -1)
-
- advice_type, _ := c.GetInt64("advice_type", -1)
- frequency_type, _ := c.GetInt64("frequency_type", -1)
- week_days := c.GetString("week_days")
- day_count, _ := c.GetInt64("day_count", -1)
- drug_id, _ := c.GetInt64("drug_id")
- way, _ := c.GetInt64("way")
- adminUserInfo := c.GetAdminUserInfo()
-
- template := models.DoctorAdviceTemplate{
- OrgId: adminUserInfo.CurrentOrgId,
- AdviceDoctor: adminUserInfo.AdminUser.Id,
- AdviceType: advice_type,
- FrequencyType: frequency_type,
- WeekDays: week_days,
- DayCount: day_count,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- DrugSpec: drug_spec,
- DrugSpecUnit: drug_spec_unit,
- AdviceName: advice_name,
- AdviceDesc: advice_desc,
- SingleDose: single_dose,
- SingleDoseUnit: single_dose_unit,
- PrescribingNumber: prescribing_number,
- PrescribingNumberUnit: prescribing_number_unit,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- TemplateId: template_id,
- Way: way,
- DrugId: drug_id,
- }
-
- if template.AdviceName == "" {
- utils.ErrorLog("医嘱名字不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamAdviceEmptyWrong)
- return
- }
-
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- if appRole.UserType == 3 {
- headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- if getPermissionErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if headNursePermission == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateAdvice)
- return
- }
- }
-
- err := service.CreateAdviceTemplate(&template)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- return
-
- }
-
- func (c *DataApiController) DeleteParentAdviceTemplate() {
- template_id, _ := c.GetInt64("template_id", 0)
- adminUserInfo := c.GetAdminUserInfo()
-
- _, err := service.FindParentTemplateRecordById(adminUserInfo.CurrentOrgId, template_id)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- err1 := service.DeleteParentDoctorAdviceByTemplateId(template_id, adminUserInfo.CurrentOrgId)
- if err1 != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
-
- }
-
- func (c *DataApiController) CreateSubAdviceTemplate() {
- drug_spec := c.GetString("drug_spec")
- drug_spec_unit := c.GetString("drug_spec_unit")
- advice_name := c.GetString("advice_name")
- advice_desc := c.GetString("advice_desc")
- single_dose, _ := c.GetFloat("single_dose", 0)
- single_dose_unit := c.GetString("single_dose_unit")
- prescribing_number, _ := c.GetFloat("prescribing_number", 0)
- prescribing_number_unit := c.GetString("prescribing_number_unit")
- delivery_way := c.GetString("delivery_way")
- execution_frequency := c.GetString("execution_frequency")
- template_id, _ := c.GetInt64("template_id", 0)
- parent_id, _ := c.GetInt64("parent_id", 0)
- drug_id, _ := c.GetInt64("drug_id")
- way, _ := c.GetInt64("way")
- adminUserInfo := c.GetAdminUserInfo()
-
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- if appRole.UserType == 3 {
- headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- if getPermissionErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if headNursePermission == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateAdvice)
- return
- }
- }
-
- template := models.DoctorAdviceTemplate{
- OrgId: adminUserInfo.CurrentOrgId,
- AdviceDoctor: adminUserInfo.AdminUser.Id,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- DrugSpec: drug_spec,
- DrugSpecUnit: drug_spec_unit,
- AdviceName: advice_name,
- AdviceDesc: advice_desc,
- SingleDose: single_dose,
- SingleDoseUnit: single_dose_unit,
- PrescribingNumber: prescribing_number,
- PrescribingNumberUnit: prescribing_number_unit,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- TemplateId: template_id,
- ParentId: parent_id,
- DrugId: drug_id,
- Way: way,
- }
-
- if template.AdviceName == "" {
- utils.ErrorLog("医嘱名字不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamAdviceEmptyWrong)
- return
- }
- err := service.CreateAdviceTemplate(&template)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- return
-
- }
-
- func (this *DataApiController) ModifyTemplateName() {
- template_name := this.GetString("template_name")
- template_id, _ := this.GetInt64("template_id", 0)
- sort, _ := this.GetInt64("sort")
- if len(template_name) <= 0 {
- utils.ErrorLog("模版名字不能为空")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamEmptyWrong)
- return
- }
-
- if template_id == 0 {
- utils.ErrorLog("模版不存在")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamTemplateNOEXISTWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
-
- template, _ := service.FindParentTemplateRecordById(adminUserInfo.CurrentOrgId, template_id)
- var err error
- if template.Name == template_name {
- err = service.ModifyTemplateNameOne(template_id, template_name, sort)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
- } else {
- //total := service.FindTemplateRecordByName(adminUserInfo.CurrentOrgId, template_name);
- //if total > 0 {
- // utils.ErrorLog("模版名称已经存在")
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNameWrong)
- // return
- //}
- err = service.ModifyTemplateNameOne(template_id, template_name, sort)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "template_name": template_name,
- "template_id": template_id,
- })
-
- }
-
- func (this *DataApiController) ModifyFiledIsShow() {
- id, _ := this.GetInt64("id", 0)
- is_show, _ := this.GetInt("is_show", 0)
- adminUserInfo := this.GetAdminUserInfo()
- err := service.ShowFiledConfig(adminUserInfo.CurrentOrgId, is_show, id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- } else {
-
- this.ServeSuccessJSON(map[string]interface{}{
- "id": id,
- "is_show": is_show,
- })
- }
- }
-
- func (c *DataApiController) GetAllAdviceConfigs() {
-
- adminUserInfo := c.GetAdminUserInfo()
- var drugs []models.DrugDic
- drugways, _, _ := service.GetDrugWayDics(adminUserInfo.CurrentOrgId)
- efs, _, _ := service.GetExecutionFrequencyDics(adminUserInfo.CurrentOrgId)
- adviceTemplates, _ := service.FindOtherAllAdviceTemplate(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "drugs": drugs,
- "drugways": drugways,
- "efs": efs,
- "advice_templates": adviceTemplates,
- })
- }
-
- func (c *DataApiController) GetHandleData() {
- id, _ := c.GetInt64("id")
- config, err := service.GetHandleData(id)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
-
- func (c *DataApiController) UpdateDataTwo() {
- id, _ := c.GetInt64("id")
- //fmt.Print("id",id)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- //fmt.Print("err",err)
- //fmt.Print("id",id)
- name := dataBody["name"].(string)
- // fmt.Print("name",name)
- order := int64(dataBody["order"].(float64))
- // fmt.Print("order",order)
- remake := dataBody["remark"].(string)
- // fmt.Print("remake",remake)
- configModel := models.ConfigViewModel{
- Name: name,
- Order: order,
- Remark: remake,
- }
- err = service.UpdateDataTwo(id, configModel)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "configModel": configModel,
- })
- }
-
- func (c *DataApiController) CreateHisAdviceTemplate() {
- templateName := c.GetString("template_name")
- advice_type, _ := c.GetInt64("advice_type")
-
- if templateName == "" {
- utils.ErrorLog("模版名称不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamEmptyWrong)
- return
- }
- if advice_type < 0 {
- utils.ErrorLog("医嘱模版类型不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceTypeWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- if appRole.UserType == 3 {
- headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- if getPermissionErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if headNursePermission == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateAdvice)
- return
- }
- }
- template := &models.HisDoctorAdviceParentTemplate{
- Name: templateName,
- OrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- AdviceType: advice_type,
- }
- createErr := service.CreateHisDoctorAdviceTemplate(template)
- if createErr != nil {
- utils.ErrorLog("%v", createErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var subTemplate []*models.HisDoctorAdviceTemplate
- if dataBody["data"] != nil && reflect.TypeOf(dataBody["data"]).String() == "[]interface {}" {
- subTemp, _ := dataBody["data"].([]interface{})
- if len(subTemp) > 0 {
- for _, item := range subTemp {
- items := item.(map[string]interface{})
- if items["advice_name"] == nil || reflect.TypeOf(items["advice_name"]).String() != "string" {
- utils.ErrorLog("advice_name")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- advice_name, _ := items["advice_name"].(string)
- advice_desc, _ := items["advice_desc"].(string)
- single_dose_unit, _ := items["single_dose_unit"].(string)
- prescribing_number_unit, _ := items["prescribing_number_unit"].(string)
- delivery_way, _ := items["delivery_way"].(string)
- execution_frequency, _ := items["execution_frequency"].(string)
- drug_spec, _ := items["drug_spec"].(string)
- drug_spec_unit, _ := items["drug_spec_unit"].(string)
- single_dose := items["single_dose"].(float64)
- prescribing_number := items["prescribing_number"].(float64)
- drug_id := int64(items["drug_id"].(float64))
-
- subTemps := &models.HisDoctorAdviceTemplate{
- AdviceName: advice_name,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- OrgId: adminUserInfo.CurrentOrgId,
- AdviceDesc: advice_desc,
- AdviceType: advice_type,
- SingleDoseUnit: single_dose_unit,
- PrescribingNumber: prescribing_number,
- PrescribingNumberUnit: prescribing_number_unit,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- TemplateId: template.ID,
- DrugSpec: drug_spec,
- DrugSpecUnit: drug_spec_unit,
- SingleDose: single_dose,
- AdviceDoctor: adminUserInfo.AdminUser.Id,
- DrugId: drug_id,
- }
- subTemplate = append(subTemplate, subTemps)
-
- }
- }
- }
- //errs := service.CreateBatchRecord(subTemplate)
- errs := service.CreateHisSubDoctorAdviceTemplate(subTemplate)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
- return
- }
- templates, _ := service.FindHisDoctorAdviceTemplateById(template.ID, adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "template": templates,
- })
- return
- }
- func (c *DataApiController) UpdateHisAdviceTemplate() {
-
- adminUserInfo := c.GetAdminUserInfo()
- id, _ := c.GetInt64("id", 0)
-
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- template, _ := service.FindHisAdviceTemplate(adminUserInfo.CurrentOrgId, id)
- if template == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- var templatedata models.HisDoctorAdviceTemplate
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &templatedata)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if templatedata.AdviceName == "" {
- utils.ErrorLog("不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeNow := time.Now().Unix()
- template.UpdatedTime = timeNow
- template.AdviceName = templatedata.AdviceName
- template.AdviceDesc = templatedata.AdviceDesc
- template.SingleDose = templatedata.SingleDose
- template.SingleDoseUnit = templatedata.SingleDoseUnit
- template.PrescribingNumber = templatedata.PrescribingNumber
- template.PrescribingNumberUnit = templatedata.PrescribingNumberUnit
- template.DrugSpec = templatedata.DrugSpec
- template.DrugSpecUnit = templatedata.DrugSpecUnit
- template.DeliveryWay = templatedata.DeliveryWay
- template.ExecutionFrequency = templatedata.ExecutionFrequency
- template.DrugId = template.DrugId
-
- err = service.UpdateHisAdviceTemplate(template)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- return
-
- }
- func (c *DataApiController) DeleteHisAdviceTemplate() {
- adminUserInfo := c.GetAdminUserInfo()
- parent_id, _ := c.GetInt64("parent_id", 0)
- id, _ := c.GetInt64("id", 0)
-
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- template, _ := service.FindHisAdviceTemplate(adminUserInfo.CurrentOrgId, id)
- if template == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
- return
- }
-
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- //if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- timeNow := time.Now().Unix()
- template.ID = id
- template.UpdatedTime = timeNow
- template.ParentId = parent_id
- template.Status = 2
-
- if parent_id > 0 { //删除子医嘱
- err := service.UpdateHisAdviceTemplate(template)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- } else { //删除该医嘱下的所有子医嘱
- err := service.UpdateHisAdviceAndSubAdviceTemplate(template)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
- }
- func (c *DataApiController) CreateSingleHisAdviceTemplate() {
- drug_spec := c.GetString("drug_spec")
- drug_spec_unit := c.GetString("drug_spec_unit")
- advice_name := c.GetString("advice_name")
- advice_desc := c.GetString("advice_desc")
- single_dose, _ := c.GetFloat("single_dose", 0)
- single_dose_unit := c.GetString("single_dose_unit")
- prescribing_number, _ := c.GetFloat("prescribing_number", 0)
- prescribing_number_unit := c.GetString("prescribing_number_unit")
- delivery_way := c.GetString("delivery_way")
- execution_frequency := c.GetString("execution_frequency")
- template_id, _ := c.GetInt64("template_id", -1)
- drug_id, _ := c.GetInt64("drug_id")
- adminUserInfo := c.GetAdminUserInfo()
-
- template := models.HisDoctorAdviceTemplate{
- OrgId: adminUserInfo.CurrentOrgId,
- AdviceDoctor: adminUserInfo.AdminUser.Id,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- DrugSpec: drug_spec,
- DrugSpecUnit: drug_spec_unit,
- AdviceName: advice_name,
- AdviceDesc: advice_desc,
- SingleDose: single_dose,
- SingleDoseUnit: single_dose_unit,
- PrescribingNumber: prescribing_number,
- PrescribingNumberUnit: prescribing_number_unit,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- TemplateId: template_id,
- DrugId: drug_id,
- }
-
- if template.AdviceName == "" {
- utils.ErrorLog("医嘱名字不能为空")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamAdviceEmptyWrong)
- return
- }
-
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- if appRole.UserType == 3 {
- headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- if getPermissionErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if headNursePermission == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateAdvice)
- return
- }
- }
- err := service.CreateHisAdviceTemplate(&template)
- if err != nil {
- utils.ErrorLog("%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- return
- }
- func (c *DataApiController) DeleteHisParentAdviceTemplate() {
- template_id, _ := c.GetInt64("template_id", 0)
- adminUserInfo := c.GetAdminUserInfo()
- _, err := service.FindParentHisTemplateRecordById(adminUserInfo.CurrentOrgId, template_id)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- err1 := service.DeleteHisParentDoctorAdviceByTemplateId(template_id, adminUserInfo.CurrentOrgId)
- if err1 != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- }
- func (this *DataApiController) ModifyHisTemplateName() {
- template_name := this.GetString("template_name")
- template_id, _ := this.GetInt64("template_id", 0)
-
- if len(template_name) <= 0 {
- utils.ErrorLog("模版名字不能为空")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamEmptyWrong)
- return
- }
-
- if template_id == 0 {
- utils.ErrorLog("模版不存在")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamTemplateNOEXISTWrong)
- return
- }
- adminUserInfo := this.GetAdminUserInfo()
- template, _ := service.FindParentHisTemplateRecordById(adminUserInfo.CurrentOrgId, template_id)
- var err error
- if template.Name == template_name {
- err = service.ModifyTemplateName(template_id, template_name)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
- } else {
- err = service.ModifyHisTemplateName(template_id, template_name)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template_name": template_name,
- "template_id": template_id,
- })
-
- }
- func (this *DataApiController) GetAllHisAdviceTemplate() {
- adminUserInfo := this.GetAdminUserInfo()
- drugs, _ := service.GetAllDrugLibs(adminUserInfo.CurrentOrgId)
- drugways, _, _ := service.GetDrugWayDics(adminUserInfo.CurrentOrgId)
- efs, _, _ := service.GetExecutionFrequencyDics(adminUserInfo.CurrentOrgId)
- adviceTemplates, _ := service.FindHisAllAdviceTemplate(adminUserInfo.CurrentOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "drugways": drugways,
- "efs": efs,
- "advice_templates": adviceTemplates,
- "drugs": drugs,
- })
-
- }
|