doctors_api_controller.go 53KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/astaxie/beego"
  10. "github.com/jinzhu/gorm"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. type DoctorsApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func DoctorApiRegistRouters() {
  19. beego.Router("/api/alldoctors", &DoctorsApiController{}, "get:GetAllDoctorAndNurse")
  20. beego.Router("/api/admin/users", &DoctorsApiController{}, "get:GetAllAdminUsers")
  21. beego.Router("/api/patient/getdryweightdata", &DoctorsApiController{}, "Get:GetDryWeightData")
  22. beego.Router("/api/patient/getAllDoctor", &DoctorsApiController{}, "Get:GetAllDoctor")
  23. beego.Router("/api/patient/updatedryweightdata", &DoctorsApiController{}, "Post:UpdatedDryWeightData")
  24. beego.Router("/api/patient/getalldata", &DoctorsApiController{}, "Get:GetAllData")
  25. beego.Router("/api/paients/getdryweightdetail", &DoctorsApiController{}, "Get:GetDryWeightDetail")
  26. beego.Router("/api/patients/modifydryweightdata", &DoctorsApiController{}, "Get:ModifydryWeightData")
  27. beego.Router("/api/patient/deletedryweight", &DoctorsApiController{}, "Delete:DeleteDryWeight")
  28. beego.Router("/api/schedule/advices", &DoctorsApiController{}, "Get:ScheduleAdvices")
  29. beego.Router("/api/schedule/new/advices", &DoctorsApiController{}, "Get:GetScheduleAdvicesList")
  30. beego.Router("/api/schedule/getdoctoradvicecount", &DoctorsApiController{}, "Get:GetDoctorAdviceCount")
  31. beego.Router("/api/patient/savevasularaccess", &DoctorsApiController{}, "Get:SaveVasularAccess")
  32. beego.Router("/api/patient/getallvascualraccesslist", &DoctorsApiController{}, "Get:GetAllVacualAccessList")
  33. beego.Router("/api/patient/getvascularaccessbydetial", &DoctorsApiController{}, "Get:GetVascularAccessByDetail")
  34. beego.Router("/api/patient/updatevasularaccess", &DoctorsApiController{}, "Get:UpdateVasularAccess")
  35. beego.Router("/api/patient/deletevascularaccess", &DoctorsApiController{}, "Get:DeleteVasularAccess")
  36. beego.Router("/api/patient/savepasswayassessment", &DoctorsApiController{}, "Get:SavePassWayAssessment")
  37. beego.Router("/api/patient/getallpasswayassessment", &DoctorsApiController{}, "Get:GetAllPassWayAssessment")
  38. beego.Router("/api/patient/getpasswayassmentbyid", &DoctorsApiController{}, "Get:GetPasswayAssesmentById")
  39. beego.Router("/api/patient/updatepasswayassesment", &DoctorsApiController{}, "Get:UpdatePassWayAssesment")
  40. beego.Router("/api/patient/deletepasswayassessment", &DoctorsApiController{}, "Get:DeleteWayAssessment")
  41. beego.Router("/api/patient/getaccesslist", &DoctorsApiController{}, "Get:GetAccessList")
  42. //阶段小结路由
  43. beego.Router("/api/patient/getinspectionmajoritem", &DoctorsApiController{}, "Get:GetInspectionMajorItem")
  44. beego.Router("/api/patient/getinspectiondetail", &DoctorsApiController{}, "Get:GetInspectionDetailByProject")
  45. beego.Router("/api/patient/getinspectionitemlist", &DoctorsApiController{}, "Get:GetInspectionItemlist")
  46. beego.Router("/api/patient/getinitdatelist", &DoctorsApiController{}, "Get:GetInitDateList")
  47. beego.Router("/api/patient/savecreationinspection", &DoctorsApiController{}, "Post:SaveCreationInspection")
  48. beego.Router("/api/patient/getemlatesummarylist", &DoctorsApiController{}, "Get:GetTemplateSummaryList")
  49. beego.Router("/api/patient/gettemplatesummarydetail", &DoctorsApiController{}, "Get:GetTemplateSummaryDetail")
  50. beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
  51. beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
  52. beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
  53. beego.Router("/api/patient/hospitalsummary", &DoctorsApiController{}, "Post:HospitalSummary")
  54. beego.Router("/api/patient/gethospitalsummarylist", &DoctorsApiController{}, "Get:GetHospitalSummaryList")
  55. beego.Router("/api/patient/gethospitalsummaydetail", &DoctorsApiController{}, "Get:GetHospitalSummaryDetail")
  56. beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Post:UpdateHospitalSummary")
  57. beego.Router("/api/patient/deletehospitalsummary", &DoctorsApiController{}, "Get:DeleteHospitalSummary")
  58. beego.Router("/api/patient/getpatientinfo", &DoctorsApiController{}, "Get:GetPatientInfo")
  59. }
  60. func (c *DoctorsApiController) ScheduleAdvices() {
  61. schedualDate := c.GetString("date")
  62. adviceType, _ := c.GetInt("advice_type")
  63. patientType, _ := c.GetInt("patient_type")
  64. delivery_way := c.GetString("delivery_way")
  65. schedule_type, _ := c.GetInt64("schedule_type")
  66. partition_type, _ := c.GetInt64("partition_type")
  67. patient_id, _ := c.GetInt64("patient_id")
  68. excution_way, _ := c.GetInt64("excution_way")
  69. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  70. adviceType = 0
  71. }
  72. if patientType != 1 && patientType != 2 {
  73. patientType = 0
  74. }
  75. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  76. if parseDateErr != nil {
  77. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  78. return
  79. }
  80. adminUserInfo := c.GetAdminUserInfo()
  81. orgID := adminUserInfo.CurrentOrgId
  82. config, _ := service.GetHisDoctorConfig(orgID)
  83. project_config, _ := service.GetHisProjectConfig(orgID)
  84. if config.IsOpen == 0 || config.IsOpen == 2 {
  85. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, 0)
  86. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  87. if err != nil {
  88. c.ErrorLog("获取排班信息失败:%v", err)
  89. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  90. } else {
  91. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  92. for _, schedual := range scheduals {
  93. if len(schedual.DoctorAdvices) > 0 {
  94. filtedScheduals = append(filtedScheduals, schedual)
  95. }
  96. }
  97. c.ServeSuccessJSON(map[string]interface{}{
  98. "scheduals": filtedScheduals,
  99. "adminUser": adminUser,
  100. "config": config,
  101. "project_config": project_config,
  102. })
  103. }
  104. }
  105. if config.IsOpen == 1 {
  106. hisAdvices, err := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, 0)
  107. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  108. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
  109. for _, item := range project {
  110. index := 0
  111. for _, subItem := range item.HisPrescriptionTeamProject {
  112. if subItem.HisProject.CostClassify != 3 {
  113. subItem.IsCheckTeam = 2
  114. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  115. }
  116. if subItem.HisProject.CostClassify == 3 {
  117. subItem.IsCheckTeam = 1
  118. index = index + 1
  119. if index == 1 {
  120. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  121. }
  122. }
  123. }
  124. }
  125. if err != nil {
  126. c.ErrorLog("获取排班信息失败:%v", err)
  127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  128. } else {
  129. c.ServeSuccessJSON(map[string]interface{}{
  130. "adminUser": adminUser,
  131. "hisAdvices": hisAdvices,
  132. "config": config,
  133. "project_config": project_config,
  134. "project": project,
  135. })
  136. }
  137. }
  138. }
  139. func (c *DoctorsApiController) GetAllDoctorAndNurse() {
  140. adminUserInfo := c.GetAdminUserInfo()
  141. doctors, nursers, _ := service.GetAllDoctorAndNurseSix(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  142. c.ServeSuccessJSON(map[string]interface{}{
  143. "doctors": doctors,
  144. "nursers": nursers,
  145. })
  146. return
  147. }
  148. func (c *DoctorsApiController) GetAllAdminUsers() {
  149. adminUserInfo := c.GetAdminUserInfo()
  150. users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
  151. operators, _ := service.GetAdminUserEsOne(adminUserInfo.CurrentOrgId)
  152. c.ServeSuccessJSON(map[string]interface{}{
  153. "users": users,
  154. "operators": operators,
  155. })
  156. return
  157. }
  158. func (c *DoctorsApiController) GetDryWeightData() {
  159. adminUserInfo := c.GetAdminUserInfo()
  160. orgid := adminUserInfo.CurrentOrgId
  161. patientid, _ := c.GetInt64("patientid")
  162. fmt.Println("patientid", patientid)
  163. id := adminUserInfo.AdminUser.Id
  164. fmt.Println("id", id)
  165. recordDateStr := time.Now().Format("2006-01-02")
  166. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  167. fmt.Scan("parseDateErr", parseDateErr)
  168. nowtime := recordDate.Unix()
  169. fmt.Println("nowtime", nowtime)
  170. pre, err := service.GetDryWeightByPatientId(patientid, orgid)
  171. fmt.Println("错误", err)
  172. c.ServeSuccessJSON(map[string]interface{}{
  173. "pre": pre,
  174. })
  175. }
  176. func (c *DoctorsApiController) GetAllDoctor() {
  177. adminUserInfo := c.GetAdminUserInfo()
  178. orgid := adminUserInfo.CurrentOrgId
  179. appid := adminUserInfo.CurrentAppId
  180. fmt.Println("appid", appid)
  181. appRole, err := service.GetAllDoctor(orgid, appid)
  182. fmt.Println("appRole", appRole)
  183. fmt.Println("错误", err)
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "appRole": appRole,
  186. })
  187. }
  188. func (c *DoctorsApiController) UpdatedDryWeightData() {
  189. adminUserInfo := c.GetAdminUserInfo()
  190. orgid := adminUserInfo.CurrentOrgId
  191. userid := adminUserInfo.AdminUser.Id
  192. dry_weight, _ := c.GetFloat("dry_weight")
  193. doctors, _ := c.GetInt64("doctors")
  194. remarks := c.GetString("remarks")
  195. patientid, _ := c.GetInt64("patient_id")
  196. //透前数据
  197. dryweight, _ := c.GetFloat("dryweight")
  198. var weight = dryweight - dry_weight
  199. weights := fmt.Sprintf("%.1f", weight)
  200. var sum string
  201. _, errcode := service.QueryDryWeight(orgid, patientid)
  202. if errcode == gorm.ErrRecordNotFound {
  203. sum = "/"
  204. patientDryweight := models.SgjPatientDryweight{
  205. DryWeight: dry_weight,
  206. Creator: doctors,
  207. Remakes: remarks,
  208. AdjustedValue: sum,
  209. PatientId: patientid,
  210. Ctime: time.Now().Unix(),
  211. UserOrgId: orgid,
  212. Status: 1,
  213. UserId: userid,
  214. }
  215. err := service.CreatePatientWeight(&patientDryweight)
  216. loc, _ := time.LoadLocation("Local")
  217. nowTime := time.Now()
  218. nowDay := nowTime.Format("2006-01-02")
  219. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  220. redis := service.RedisClient()
  221. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  222. redis.Set(keyTwo, "", time.Second)
  223. prescription := models.PredialysisEvaluation{
  224. DryWeight: dry_weight,
  225. AssessmentDate: dayTime.Unix(),
  226. }
  227. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  228. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  229. fmt.Println(errors)
  230. }
  231. keyThree := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  232. redis.Set(keyThree, "", time.Second)
  233. keyFive := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  234. redis.Set(keyFive, "", time.Second)
  235. redis.Close()
  236. fmt.Println("err", err)
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "patientDryweight": patientDryweight,
  239. })
  240. return
  241. }
  242. fmt.Println("sum", sum)
  243. if weight == 0 {
  244. sum = "/"
  245. }
  246. if weight > 0 {
  247. sum = weights + "(" + "下调" + ")"
  248. }
  249. if weight < 0 {
  250. var sums = dry_weight - dryweight
  251. float := fmt.Sprintf("%.1f", sums)
  252. //float := strconv.FormatFloat(sums, 'E', -1, 64)
  253. sum = float + "(" + "上调" + ")"
  254. }
  255. patientDryweight := models.SgjPatientDryweight{
  256. DryWeight: dry_weight,
  257. Creator: doctors,
  258. Remakes: remarks,
  259. AdjustedValue: sum,
  260. PatientId: patientid,
  261. Ctime: time.Now().Unix(),
  262. UserOrgId: orgid,
  263. Status: 1,
  264. UserId: userid,
  265. }
  266. err := service.CreatePatientWeight(&patientDryweight)
  267. recordDateStr := time.Now().Format("2006-01-02")
  268. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  269. fmt.Scan("parseDateErr", parseDateErr)
  270. nowtime := recordDate.Unix()
  271. fmt.Println("nowtime", nowtime)
  272. loc, _ := time.LoadLocation("Local")
  273. nowTime := time.Now()
  274. nowDay := nowTime.Format("2006-01-02")
  275. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  276. redis := service.RedisClient()
  277. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  278. redis.Set(keyTwo, "", time.Second)
  279. prescription := models.PredialysisEvaluation{
  280. DryWeight: dry_weight,
  281. AssessmentDate: dayTime.Unix(),
  282. }
  283. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  284. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  285. fmt.Println(errors)
  286. }
  287. key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  288. redis.Set(key, "", time.Second)
  289. keySix := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  290. redis.Set(keySix, "", time.Second)
  291. fmt.Println("err", err)
  292. redis.Close()
  293. c.ServeSuccessJSON(map[string]interface{}{
  294. "patientDryweight": patientDryweight,
  295. })
  296. }
  297. func (c *DoctorsApiController) GetAllData() {
  298. id, _ := c.GetInt64("id")
  299. page, _ := c.GetInt64("page")
  300. fmt.Println("page", page)
  301. limit, _ := c.GetInt64("limit")
  302. fmt.Println("limit", limit)
  303. fmt.Println("id", id)
  304. adminUserInfo := c.GetAdminUserInfo()
  305. orgid := adminUserInfo.CurrentOrgId
  306. dry, total, _ := service.GetAllData(orgid, id, page, limit)
  307. c.ServeSuccessJSON(map[string]interface{}{
  308. "dry": dry,
  309. "total": total,
  310. })
  311. }
  312. func (c *DoctorsApiController) GetDryWeightDetail() {
  313. id, _ := c.GetInt64("id")
  314. dryweight, _ := service.GetDryWeightDetailById(id)
  315. c.ServeSuccessJSON(map[string]interface{}{
  316. "dryweight": dryweight,
  317. })
  318. }
  319. func (c *DoctorsApiController) ModifydryWeightData() {
  320. adjustvalue := c.GetString("adjustvalue")
  321. creator, _ := c.GetInt64("creator")
  322. dryweight, _ := c.GetInt64("dryweight")
  323. dry := strconv.FormatInt(dryweight, 10)
  324. dry_weight, _ := strconv.ParseFloat(dry, 64)
  325. id, _ := c.GetInt64("id")
  326. remark := c.GetString("remark")
  327. patientDryweight := models.SgjPatientDryweight{
  328. AdjustedValue: adjustvalue,
  329. Creator: creator,
  330. DryWeight: dry_weight,
  331. Remakes: remark,
  332. }
  333. service.ModifyDryWeightData(&patientDryweight, id)
  334. c.ServeSuccessJSON(map[string]interface{}{
  335. "patientDryweight": patientDryweight,
  336. })
  337. }
  338. func (c *DoctorsApiController) DeleteDryWeight() {
  339. id, _ := c.GetInt64("id")
  340. service.DeleteDryWeight(id)
  341. returnData := make(map[string]interface{}, 0)
  342. returnData["msg"] = "ok"
  343. c.ServeSuccessJSON(returnData)
  344. return
  345. }
  346. func (c *DoctorsApiController) GetDoctorAdviceCount() {
  347. timeLayout := "2006-01-02"
  348. loc, _ := time.LoadLocation("Local")
  349. start_time := c.GetString("start_time")
  350. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  351. end_time := c.GetString("end_time")
  352. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  353. delive_way := c.GetString("delive_way")
  354. adminUserInfo := c.GetAdminUserInfo()
  355. orgId := adminUserInfo.CurrentOrgId
  356. list, _ := service.GetDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  357. if len(list) == 0 {
  358. list, _ := service.GetHisDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  359. c.ServeSuccessJSON(map[string]interface{}{
  360. "list": list,
  361. })
  362. } else {
  363. c.ServeSuccessJSON(map[string]interface{}{
  364. "list": list,
  365. })
  366. }
  367. }
  368. func (this *DoctorsApiController) SaveVasularAccess() {
  369. access_project, _ := this.GetInt64("access_project")
  370. blood_access_part_id := this.GetString("blood_access_part_id")
  371. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  372. first_start_time := this.GetString("first_start_time")
  373. timeLayout := "2006-01-02"
  374. loc, _ := time.LoadLocation("Local")
  375. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  376. inflow_pass := this.GetString("inflow_pass")
  377. remark := this.GetString("remark")
  378. start_time := this.GetString("start_time")
  379. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  380. stop_reason := this.GetString("stop_reason")
  381. user_status, _ := this.GetInt64("user_status")
  382. stop_time := this.GetString("stop_time")
  383. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  384. patient_id, _ := this.GetInt64("patient_id")
  385. other_vascular := this.GetString("other_vascular")
  386. ci_type, _ := this.GetInt64("ci_type")
  387. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  388. sequelae_type, _ := this.GetInt64("sequelae_type")
  389. adminUserInfo := this.GetAdminUserInfo()
  390. orgId := adminUserInfo.CurrentOrgId
  391. creator := adminUserInfo.AdminUser.Id
  392. //查询改日期是否存在
  393. access := models.XtPatientVascularAccess{
  394. AccessProject: access_project,
  395. BloodAccessPartId: blood_access_part_id,
  396. BloodAccessPartOperaId: blood_access_part_opera_id,
  397. FirstStartTime: firstStartTime.Unix(),
  398. InflowPass: inflow_pass,
  399. Remark: remark,
  400. StartTime: startTime.Unix(),
  401. StopReason: stop_reason,
  402. UserStatus: user_status,
  403. Creator: creator,
  404. UserOrgId: orgId,
  405. Status: 1,
  406. Ctime: time.Now().Unix(),
  407. StopTime: stopTime.Unix(),
  408. PatientId: patient_id,
  409. OtherVascular: other_vascular,
  410. CiType: ci_type,
  411. BloodCultupe: blood_cultupe,
  412. SequelaeType: sequelae_type,
  413. }
  414. err := service.SaveVascularAccess(&access)
  415. if err == nil {
  416. this.ServeSuccessJSON(map[string]interface{}{
  417. "access": access,
  418. })
  419. return
  420. //_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  421. //if errcode == gorm.ErrRecordNotFound {
  422. // access := models.XtPatientVascularAccess{
  423. // AccessProject: access_project,
  424. // BloodAccessPartId: blood_access_part_id,
  425. // BloodAccessPartOperaId: blood_access_part_opera_id,
  426. // FirstStartTime: firstStartTime.Unix(),
  427. // InflowPass: inflow_pass,
  428. // Remark: remark,
  429. // StartTime: startTime.Unix(),
  430. // StopReason: stop_reason,
  431. // UserStatus: user_status,
  432. // Creator: creator,
  433. // UserOrgId: orgId,
  434. // Status: 1,
  435. // Ctime: time.Now().Unix(),
  436. // StopTime: stopTime.Unix(),
  437. // PatientId: patient_id,
  438. // OtherVascular: other_vascular,
  439. // CiType: ci_type,
  440. // BloodCultupe: blood_cultupe,
  441. // SequelaeType: sequelae_type,
  442. // }
  443. // err := service.SaveVascularAccess(&access)
  444. // if err == nil {
  445. // this.ServeSuccessJSON(map[string]interface{}{
  446. // "access": access,
  447. // })
  448. // return
  449. // }
  450. //} else if errcode == nil {
  451. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  452. // return
  453. }
  454. }
  455. func (this *DoctorsApiController) GetAllVacualAccessList() {
  456. limit, _ := this.GetInt64("limit")
  457. page, _ := this.GetInt64("page")
  458. patient_id, _ := this.GetInt64("patient_id")
  459. orgId := this.GetAdminUserInfo().CurrentOrgId
  460. appId := this.GetAdminUserInfo().CurrentAppId
  461. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  462. doctor, err := service.GetAllDoctor(orgId, appId)
  463. if err == nil {
  464. this.ServeSuccessJSON(map[string]interface{}{
  465. "list": list,
  466. "total": total,
  467. "doctor": doctor,
  468. })
  469. return
  470. }
  471. }
  472. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  473. id, _ := this.GetInt64("id")
  474. accessDetail, err := service.GetVasularAccessByDetail(id)
  475. orgId := this.GetAdminUserInfo().CurrentOrgId
  476. appId := this.GetAdminUserInfo().CurrentAppId
  477. doctor, err := service.GetAllDoctor(orgId, appId)
  478. if err == nil {
  479. this.ServeSuccessJSON(map[string]interface{}{
  480. "accessDetail": accessDetail,
  481. "doctor": doctor,
  482. })
  483. return
  484. }
  485. }
  486. func (this *DoctorsApiController) UpdateVasularAccess() {
  487. id, _ := this.GetInt64("id")
  488. access_project, _ := this.GetInt64("access_project")
  489. blood_access_part_id := this.GetString("blood_access_part_id")
  490. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  491. first_start_time := this.GetString("first_start_time")
  492. timeLayout := "2006-01-02"
  493. loc, _ := time.LoadLocation("Local")
  494. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  495. inflow_pass := this.GetString("inflow_pass")
  496. remark := this.GetString("remark")
  497. start_time := this.GetString("start_time")
  498. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  499. stop_reason := this.GetString("stop_reason")
  500. user_status, _ := this.GetInt64("user_status")
  501. stop_time := this.GetString("stop_time")
  502. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  503. adminUserInfo := this.GetAdminUserInfo()
  504. orgId := adminUserInfo.CurrentOrgId
  505. creator := adminUserInfo.AdminUser.Id
  506. patientId, _ := this.GetInt64("patient_id")
  507. other_vascular := this.GetString("other_vascular")
  508. ci_type, _ := this.GetInt64("ci_type")
  509. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  510. sequelae_type, _ := this.GetInt64("sequelae_type")
  511. access := models.XtPatientVascularAccess{
  512. AccessProject: access_project,
  513. BloodAccessPartId: blood_access_part_id,
  514. BloodAccessPartOperaId: blood_access_part_opera_id,
  515. FirstStartTime: firstStartTime.Unix(),
  516. InflowPass: inflow_pass,
  517. Remark: remark,
  518. StartTime: startTime.Unix(),
  519. StopReason: stop_reason,
  520. UserStatus: user_status,
  521. Modify: creator,
  522. UserOrgId: orgId,
  523. Status: 1,
  524. StopTime: stopTime.Unix(),
  525. OtherVascular: other_vascular,
  526. CiType: ci_type,
  527. BloodCultupe: blood_cultupe,
  528. SequelaeType: sequelae_type,
  529. PatientId: patientId,
  530. }
  531. err := service.UpdateVascularAccess(&access, id)
  532. if err == nil {
  533. this.ServeSuccessJSON(map[string]interface{}{
  534. "access": access,
  535. })
  536. return
  537. }
  538. //_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  539. //if errcode == gorm.ErrRecordNotFound {
  540. // err := service.UpdateVascularAccess(&access, id)
  541. // if err == nil {
  542. // this.ServeSuccessJSON(map[string]interface{}{
  543. // "access": access,
  544. // })
  545. // return
  546. // }
  547. //} else if errcode == nil {
  548. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  549. // return
  550. //}
  551. }
  552. func (this *DoctorsApiController) DeleteVasularAccess() {
  553. id, _ := this.GetInt64("id")
  554. err := service.DeleteVasularAccess(id)
  555. fmt.Println(err)
  556. returnData := make(map[string]interface{}, 0)
  557. returnData["msg"] = "ok"
  558. this.ServeSuccessJSON(returnData)
  559. return
  560. }
  561. func (this *DoctorsApiController) SavePassWayAssessment() {
  562. blood_dealwidth := this.GetString("blood_dealwith")
  563. blood_project := this.GetString("blood_project")
  564. blood_result := this.GetString("blood_result")
  565. creator, _ := this.GetInt64("creator")
  566. parent_id, _ := this.GetInt64("parent_id")
  567. patient_id, _ := this.GetInt64("patient_id")
  568. start_time := this.GetString("start_time")
  569. timeLayout := "2006-01-02"
  570. loc, _ := time.LoadLocation("Local")
  571. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  572. modify := this.GetAdminUserInfo().AdminUser.Id
  573. orgId := this.GetAdminUserInfo().CurrentOrgId
  574. assessment := models.XtPatientPasswayAssessment{
  575. StartTime: startTime.Unix(),
  576. BloodDealwith: blood_dealwidth,
  577. BloodProject: blood_project,
  578. BloodResult: blood_result,
  579. Creator: creator,
  580. PatientId: patient_id,
  581. ParentId: parent_id,
  582. Modify: modify,
  583. UserOrgId: orgId,
  584. Status: 1,
  585. Ctime: time.Now().Unix(),
  586. }
  587. err := service.CreatePatientWayAssessment(&assessment)
  588. if err == nil {
  589. this.ServeSuccessJSON(map[string]interface{}{
  590. "assessment": assessment,
  591. })
  592. return
  593. }
  594. }
  595. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  596. patient_id, _ := this.GetInt64("patient_id")
  597. parent_id, _ := this.GetInt64("parent_id")
  598. page, _ := this.GetInt64("page")
  599. limit, _ := this.GetInt64("limit")
  600. adminUserInfo := this.GetAdminUserInfo()
  601. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  602. if err == nil {
  603. this.ServeSuccessJSON(map[string]interface{}{
  604. "list": list,
  605. "total": total,
  606. })
  607. return
  608. }
  609. }
  610. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  611. id, _ := this.GetInt64("id")
  612. assessment, err := service.GetPasswayAssesmentById(id)
  613. if err == nil {
  614. this.ServeSuccessJSON(map[string]interface{}{
  615. "assessment": assessment,
  616. })
  617. return
  618. }
  619. }
  620. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  621. id, _ := this.GetInt64("id")
  622. blood_dealwidth := this.GetString("blood_dealwith")
  623. blood_project := this.GetString("blood_project")
  624. blood_result := this.GetString("blood_result")
  625. creator, _ := this.GetInt64("creator")
  626. start_time := this.GetString("start_time")
  627. timeLayout := "2006-01-02"
  628. loc, _ := time.LoadLocation("Local")
  629. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  630. modify := this.GetAdminUserInfo().AdminUser.Id
  631. assessment := models.XtPatientPasswayAssessment{
  632. BloodResult: blood_result,
  633. BloodDealwith: blood_dealwidth,
  634. BloodProject: blood_project,
  635. Creator: creator,
  636. StartTime: startTime.Unix(),
  637. Modify: modify,
  638. }
  639. err := service.UpdatePassWayAssesment(&assessment, id)
  640. if err == nil {
  641. this.ServeSuccessJSON(map[string]interface{}{
  642. "assessment": assessment,
  643. })
  644. return
  645. }
  646. }
  647. func (this *DoctorsApiController) DeleteWayAssessment() {
  648. id, _ := this.GetInt64("id")
  649. err := service.DeleteWayAssessment(id)
  650. fmt.Println(err)
  651. returnData := make(map[string]interface{}, 0)
  652. returnData["msg"] = "ok"
  653. this.ServeSuccessJSON(returnData)
  654. return
  655. }
  656. func (this *DoctorsApiController) GetAccessList() {
  657. adminUserInfo := this.GetAdminUserInfo()
  658. orgId := adminUserInfo.CurrentOrgId
  659. //血管通路
  660. list, err := service.GetAccessList(orgId)
  661. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  662. //血管通路部位
  663. access, err := service.GetBloodAccess(orgId)
  664. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  665. if err == nil {
  666. this.ServeSuccessJSON(map[string]interface{}{
  667. "blood_access_part_opera": blood_access_part_opera,
  668. "blood_access_part": blood_access_part,
  669. })
  670. return
  671. }
  672. }
  673. func (this *DoctorsApiController) GetInspectionMajorItem() {
  674. other_start_time := this.GetString("other_start_time")
  675. last_time := this.GetString("last_time")
  676. timeLayout := "2006-01-02"
  677. loc, _ := time.LoadLocation("Local")
  678. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
  679. lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
  680. patient_id, _ := this.GetInt64("patient_id")
  681. adminUserInfo := this.GetAdminUserInfo()
  682. orgId := adminUserInfo.CurrentOrgId
  683. list, err := service.GetInspectionMajorItem(startTime.Unix(), lastTime.Unix(), orgId, patient_id)
  684. if err == nil {
  685. this.ServeSuccessJSON(map[string]interface{}{
  686. "list": list,
  687. })
  688. return
  689. }
  690. }
  691. func (this *DoctorsApiController) GetInspectionDetailByProject() {
  692. project_id, _ := this.GetInt64("project_id")
  693. patient_id, _ := this.GetInt64("patient_id")
  694. inspect_date, _ := this.GetInt64("inspect_date")
  695. orgId := this.GetAdminUserInfo().CurrentOrgId
  696. list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
  697. if err == nil {
  698. this.ServeSuccessJSON(map[string]interface{}{
  699. "list": list,
  700. })
  701. return
  702. }
  703. }
  704. func (this *DoctorsApiController) GetInspectionItemlist() {
  705. patient_id, _ := this.GetInt64("patient_id")
  706. ids := this.GetString("ids")
  707. inspect_date := this.GetString("inspect_date")
  708. idSplit := strings.Split(ids, ",")
  709. indateSplit := strings.Split(inspect_date, ",")
  710. list, err := service.GetInspectionItemlist(patient_id, indateSplit, idSplit)
  711. if err == nil {
  712. this.ServeSuccessJSON(map[string]interface{}{
  713. "list": list,
  714. })
  715. return
  716. }
  717. }
  718. func (this *DoctorsApiController) GetInitDateList() {
  719. patient_id, _ := this.GetInt64("patient_id")
  720. start_time := this.GetString("start_time")
  721. timeLayout := "2006-01-02"
  722. loc, _ := time.LoadLocation("Local")
  723. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  724. end_time := this.GetString("end_time")
  725. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  726. fmt.Println("endtime2323232233223232332", endTime)
  727. prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id, startTime.Unix(), endTime.Unix())
  728. befor_list, err := service.GetDialysisBeforInitDateList(patient_id, startTime.Unix(), endTime.Unix())
  729. after_list, err := service.GetDialysisAssementAfter(patient_id, startTime.Unix(), endTime.Unix())
  730. orgId := this.GetAdminUserInfo().CurrentOrgId
  731. //统计透析次数
  732. modelist, err := service.GetDialysisDialysisMode(patient_id, startTime.Unix(), endTime.Unix(), orgId)
  733. docList, _ := service.GetAllDoctorThree(orgId)
  734. stockType, err := service.GetStockType(orgId)
  735. summaryList, err := service.GetTemplateSummary(orgId)
  736. planList, err := service.GetTemplatePlan(orgId)
  737. if err == nil {
  738. this.ServeSuccessJSON(map[string]interface{}{
  739. "beforlist": befor_list,
  740. "prescription_list": prescription_list,
  741. "after_list": after_list,
  742. "modelist": modelist,
  743. "docList": docList,
  744. "stockType": stockType,
  745. "summaryList": summaryList,
  746. "planList": planList,
  747. })
  748. return
  749. }
  750. }
  751. func (this *DoctorsApiController) SaveCreationInspection() {
  752. dataBody := make(map[string]interface{}, 0)
  753. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  754. if err != nil {
  755. utils.ErrorLog(err.Error())
  756. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  757. return
  758. }
  759. title := dataBody["title"].(string)
  760. dryWeight := dataBody["dry_weight"].(string)
  761. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  762. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  763. hd_count := int64(dataBody["hd_count"].(float64))
  764. hdf_count := int64(dataBody["hdf_count"].(float64))
  765. hp_count := int64(dataBody["hp_count"].(float64))
  766. other_count := int64(dataBody["other_count"].(float64))
  767. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  768. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  769. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  770. kaliumstr := dataBody["kalium"].(string)
  771. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  772. autunitestr := dataBody["autunite"].(string)
  773. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  774. natriumstr := dataBody["natrium"].(string)
  775. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  776. hour := int64(dataBody["hour"].(float64))
  777. minute := int64(dataBody["minute"].(float64))
  778. beforWeight := dataBody["befor_weight"].(string)
  779. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  780. afterWeight := dataBody["after_weight"].(string)
  781. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  782. befor_pressure := dataBody["befor_pressure"].(string)
  783. template_summary_content := dataBody["template_summary_content"].(string)
  784. template_plan_content := dataBody["template_plan_content"].(string)
  785. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  786. record_time := dataBody["record_time"].(string)
  787. timeLayout := "2006-01-02"
  788. loc, _ := time.LoadLocation("Local")
  789. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  790. after_pressure := dataBody["after_pressure"].(string)
  791. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  792. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  793. patient_id := int64(dataBody["patient_id"].(float64))
  794. orgId := this.GetAdminUserInfo().CurrentOrgId
  795. inspect_date := dataBody["inspect_date"].(string)
  796. project_id := dataBody["project_id"].(string)
  797. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  798. summary := models.XtTemplateSummary{
  799. StartYear: 0,
  800. StartMonth: 0,
  801. Radio: 0,
  802. Quarter: 0,
  803. DryWeight: dry_weight,
  804. DialysisCount: dialysis_count,
  805. HdCount: hd_count,
  806. HdfCount: hdf_count,
  807. HpCount: hp_count,
  808. OtherCount: other_count,
  809. DialzerApparatus: dialzer_apparatus,
  810. PerfusionApparatus: perfusion_apparatus,
  811. Anticoagulant: anticoagulant,
  812. Kalium: kalium,
  813. Autunite: autunite,
  814. Natrium: natrium,
  815. Hour: hour,
  816. Minute: minute,
  817. BeforWeight: befor_weight,
  818. AfterWeight: after_weight,
  819. BeforPressure: befor_pressure,
  820. AfterPressure: after_pressure,
  821. TemplateSummaryId: template_summary_id,
  822. TemplateSummaryContent: template_summary_content,
  823. TemplatePlanId: template_plan_id,
  824. TemplatePlanContent: template_plan_content,
  825. TemplateInspectionId: template_inspection_id,
  826. AdminUserId: admin_user_id,
  827. RecordTime: recordTime.Unix(),
  828. PatientId: patient_id,
  829. UserOrgId: orgId,
  830. Status: 1,
  831. Ctime: time.Now().Unix(),
  832. Mtime: 0,
  833. Title: title,
  834. InspectDate: inspect_date,
  835. ProjectId: project_id,
  836. }
  837. err = service.CreateSummary(&summary)
  838. if err == nil {
  839. this.ServeSuccessJSON(map[string]interface{}{
  840. "summary": summary,
  841. })
  842. return
  843. }
  844. }
  845. func (this *DoctorsApiController) GetTemplateSummaryList() {
  846. patient_id, _ := this.GetInt64("patient_id")
  847. start_time := this.GetString("start_time")
  848. timeLayout := "2006-01-02"
  849. loc, _ := time.LoadLocation("Local")
  850. end_time := this.GetString("end_time")
  851. orgId := this.GetAdminUserInfo().CurrentOrgId
  852. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  853. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  854. list, err := service.GetTemplateSummaryList(patient_id, orgId, startTime.Unix(), endTime.Unix())
  855. if err == nil {
  856. this.ServeSuccessJSON(map[string]interface{}{
  857. "list": list,
  858. })
  859. return
  860. }
  861. }
  862. func (this *DoctorsApiController) GetTemplateSummaryDetail() {
  863. id, _ := this.GetInt64("id")
  864. list, err := service.GetTemplateSummaryDetail(id)
  865. ids := strings.Split(list.ProjectId, ",")
  866. datelist := strings.Split(list.InspectDate, ",")
  867. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  868. if err == nil {
  869. this.ServeSuccessJSON(map[string]interface{}{
  870. "list": list,
  871. "inspectlist": inspectlist,
  872. })
  873. return
  874. }
  875. }
  876. func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
  877. id, _ := this.GetInt64("id")
  878. list, err := service.GetTemplateSummaryPrintDetail(id)
  879. ids := strings.Split(list.ProjectId, ",")
  880. datelist := strings.Split(list.InspectDate, ",")
  881. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  882. orgId := this.GetAdminUserInfo().CurrentOrgId
  883. doctorList, _ := service.GetAllDoctorThree(orgId)
  884. if err == nil {
  885. this.ServeSuccessJSON(map[string]interface{}{
  886. "list": list,
  887. "doctorList": doctorList,
  888. "inspectlist": inspectlist,
  889. })
  890. return
  891. }
  892. }
  893. func (this *DoctorsApiController) UpdateTempalteSummary() {
  894. dataBody := make(map[string]interface{}, 0)
  895. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  896. if err != nil {
  897. utils.ErrorLog(err.Error())
  898. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  899. return
  900. }
  901. id := int64(dataBody["id"].(float64))
  902. title := dataBody["title"].(string)
  903. dryWeight := dataBody["dry_weight"].(string)
  904. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  905. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  906. hd_count := int64(dataBody["hd_count"].(float64))
  907. hdf_count := int64(dataBody["hdf_count"].(float64))
  908. hp_count := int64(dataBody["hp_count"].(float64))
  909. other_count := int64(dataBody["other_count"].(float64))
  910. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  911. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  912. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  913. kaliumstr := dataBody["kalium"].(string)
  914. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  915. autunitestr := dataBody["autunite"].(string)
  916. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  917. natriumstr := dataBody["natrium"].(string)
  918. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  919. hour := int64(dataBody["hour"].(float64))
  920. minute := int64(dataBody["minute"].(float64))
  921. beforWeight := dataBody["befor_weight"].(string)
  922. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  923. afterWeight := dataBody["after_weight"].(string)
  924. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  925. befor_pressure := dataBody["befor_pressure"].(string)
  926. template_summary_content := dataBody["template_summary_content"].(string)
  927. template_plan_content := dataBody["template_plan_content"].(string)
  928. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  929. record_time := dataBody["record_time"].(string)
  930. timeLayout := "2006-01-02"
  931. loc, _ := time.LoadLocation("Local")
  932. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  933. after_pressure := dataBody["after_pressure"].(string)
  934. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  935. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  936. patient_id := int64(dataBody["patient_id"].(float64))
  937. orgId := this.GetAdminUserInfo().CurrentOrgId
  938. inspect_date := dataBody["inspect_date"].(string)
  939. project_id := dataBody["project_id"].(string)
  940. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  941. //dryWeight := this.GetString("dry_weight")
  942. //dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  943. //dialysis_count, _ := this.GetInt64("dialysis_count")
  944. //hd_count, _ := this.GetInt64("hd_count")
  945. //hdf_count, _ := this.GetInt64("hdf_count")
  946. //hp_count, _ := this.GetInt64("hp_count")
  947. //other_count, _ := this.GetInt64("other_count")
  948. //dialzer_apparatus := this.GetString("dialzer_apparatus")
  949. //perfusion_apparatus := this.GetString("perfusion_apparatus")
  950. //anticoagulant, _ := this.GetInt64("anticoagulant")
  951. //kaliumstr := this.GetString("kalium")
  952. //kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  953. //
  954. //autunitestr := this.GetString("autunite")
  955. //autunite, _ := strconv.ParseFloat(autunitestr, 64)
  956. //natriumstr := this.GetString("natrium")
  957. //natrium, _ := strconv.ParseFloat(natriumstr, 64)
  958. //hour, _ := this.GetInt64("hour")
  959. //minute, _ := this.GetInt64("minute")
  960. //beforWeight := this.GetString("befor_weight")
  961. //befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  962. //afterWeight := this.GetString("after_weight")
  963. //after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  964. //befor_pressure := this.GetString("befor_pressure")
  965. //template_summary_content := this.GetString("template_summary_content")
  966. //template_plan_content := this.GetString("template_plan_content")
  967. //admin_user_id, _ := this.GetInt64("admin_user_id")
  968. //record_time := this.GetString("record_time")
  969. //timeLayout := "2006-01-02"
  970. //loc, _ := time.LoadLocation("Local")
  971. //recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  972. //after_pressure := this.GetString("after_pressure")
  973. //template_summary_id, _ := this.GetInt64("template_summary_id")
  974. //template_plan_id, _ := this.GetInt64("template_plan_id")
  975. //template_inspection_id, _ := this.GetInt64("template_inspection_id")
  976. //patient_id, _ := this.GetInt64("patient_id")
  977. //fmt.Println("patient_id", patient_id)
  978. //orgId := this.GetAdminUserInfo().CurrentOrgId
  979. //inspect_date := this.GetString("inspect_date")
  980. //project_id := this.GetString("project_id")
  981. summary := models.XtTemplateSummary{
  982. ID: id,
  983. StartYear: 0,
  984. StartMonth: 0,
  985. Radio: 0,
  986. Quarter: 0,
  987. DryWeight: dry_weight,
  988. DialysisCount: dialysis_count,
  989. HdCount: hd_count,
  990. HdfCount: hdf_count,
  991. HpCount: hp_count,
  992. OtherCount: other_count,
  993. DialzerApparatus: dialzer_apparatus,
  994. PerfusionApparatus: perfusion_apparatus,
  995. Anticoagulant: anticoagulant,
  996. Kalium: kalium,
  997. Autunite: autunite,
  998. Natrium: natrium,
  999. Hour: hour,
  1000. Minute: minute,
  1001. BeforWeight: befor_weight,
  1002. AfterWeight: after_weight,
  1003. BeforPressure: befor_pressure,
  1004. AfterPressure: after_pressure,
  1005. TemplateSummaryId: template_summary_id,
  1006. TemplateSummaryContent: template_summary_content,
  1007. TemplatePlanId: template_plan_id,
  1008. TemplatePlanContent: template_plan_content,
  1009. TemplateInspectionId: template_inspection_id,
  1010. AdminUserId: admin_user_id,
  1011. RecordTime: recordTime.Unix(),
  1012. PatientId: patient_id,
  1013. UserOrgId: orgId,
  1014. Status: 1,
  1015. Ctime: time.Now().Unix(),
  1016. Mtime: 0,
  1017. Title: title,
  1018. ProjectId: project_id,
  1019. InspectDate: inspect_date,
  1020. }
  1021. err = service.UpdateTempalteSummary(&summary)
  1022. if err == nil {
  1023. this.ServeSuccessJSON(map[string]interface{}{
  1024. "list": summary,
  1025. })
  1026. return
  1027. }
  1028. }
  1029. func (this *DoctorsApiController) DeleteSummary() {
  1030. ids := this.GetString("ids")
  1031. idsplit := strings.Split(ids, ",")
  1032. err := service.DeleteSummary(idsplit)
  1033. fmt.Println(err)
  1034. returnData := make(map[string]interface{}, 0)
  1035. returnData["msg"] = "ok"
  1036. this.ServeSuccessJSON(returnData)
  1037. return
  1038. }
  1039. func (this *DoctorsApiController) HospitalSummary() {
  1040. timeLayout := "2006-01-02"
  1041. loc, _ := time.LoadLocation("Local")
  1042. dataBody := make(map[string]interface{}, 0)
  1043. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1044. fmt.Print("err", err)
  1045. admission_time := dataBody["admission_time"].(string)
  1046. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1047. admissiontime := admissionTimes.Unix()
  1048. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1049. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1050. connecticut := dataBody["connecticut"].(string)
  1051. dean := int64(dataBody["dean"].(float64))
  1052. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1053. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1054. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1055. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1056. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1057. discharge_advice := dataBody["discharge_advice"].(string)
  1058. discharge_time := dataBody["discharge_time"].(string)
  1059. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1060. dischargetime := dischargeTimes.Unix()
  1061. doctor := int64(dataBody["doctor"].(float64))
  1062. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1063. illness_discharge := dataBody["illness_discharge"].(string)
  1064. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1065. pathology := dataBody["pathology"].(string)
  1066. record_date := dataBody["record_date"].(string)
  1067. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1068. recordtime := recordDates.Unix()
  1069. sick_personnel := dataBody["sick_personnel"].(string)
  1070. title := dataBody["title"].(string)
  1071. treatment_id := dataBody["treatment_id"].(string)
  1072. treatment := dataBody["treatment"].(string)
  1073. ultrasound := dataBody["ultrasound"].(string)
  1074. xray := dataBody["xray"].(string)
  1075. patient_id := int64(dataBody["patient_id"].(float64))
  1076. orgId := this.GetAdminUserInfo().CurrentOrgId
  1077. summary := models.XtHospitalSummary{
  1078. PatientId: patient_id,
  1079. AdmissionTime: admissiontime,
  1080. DischargeTime: dischargetime,
  1081. SickPersonnel: sick_personnel,
  1082. Xray: xray,
  1083. Connecticut: connecticut,
  1084. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1085. Ultrasound: ultrasound,
  1086. Pathology: pathology,
  1087. AdmittingDiagnosisId: admitting_diagnosis_id,
  1088. AdmittingDiagnosis: admitting_diagnosis,
  1089. DischargeDiagnosis: discharge_diagnosis,
  1090. DiagnosisAdmissionId: diagnosis_admission_id,
  1091. DiagnosisAdmission: diagnosis_admission,
  1092. TreatmentId: treatment_id,
  1093. Treatment: treatment,
  1094. IllnessDischargeId: illness_discharge_id,
  1095. IllnessDischarge: illness_discharge,
  1096. DischargeAdviceId: discharge_advice_id,
  1097. DischargeAdvice: discharge_advice,
  1098. UserOrgId: orgId,
  1099. Status: 1,
  1100. Ctime: time.Now().Unix(),
  1101. Mtime: 0,
  1102. RecordTime: recordtime,
  1103. Title: title,
  1104. Doctor: doctor,
  1105. RecordDate: recordtime,
  1106. DeanId: dean,
  1107. DischargeDiagnosisId: discharge_diagnosis_id,
  1108. }
  1109. service.CreateHisSummary(&summary)
  1110. this.ServeSuccessJSON(map[string]interface{}{
  1111. "list": summary,
  1112. })
  1113. return
  1114. }
  1115. func (this *DoctorsApiController) GetHospitalSummaryList() {
  1116. timeLayout := "2006-01-02"
  1117. loc, _ := time.LoadLocation("Local")
  1118. orgId := this.GetAdminUserInfo().CurrentOrgId
  1119. patient_id, _ := this.GetInt64("patient_id")
  1120. start_time := this.GetString("start_time")
  1121. fmt.Println("start_tim232232323232323232323232332", start_time)
  1122. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1123. startime := dischargeTimes.Unix()
  1124. fmt.Println("startime1111111111111111111111", startime)
  1125. end_time := this.GetString("end_time")
  1126. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1127. endtime := endTimes.Unix()
  1128. list, err := service.GetHospitalSummaryList(orgId, patient_id, startime, endtime)
  1129. if err == nil {
  1130. this.ServeSuccessJSON(map[string]interface{}{
  1131. "list": list,
  1132. })
  1133. return
  1134. }
  1135. }
  1136. func (this *DoctorsApiController) GetHospitalSummaryDetail() {
  1137. id, _ := this.GetInt64("id")
  1138. detail, err := service.GetHospitalSummaryDetail(id)
  1139. if err == nil {
  1140. this.ServeSuccessJSON(map[string]interface{}{
  1141. "detail": detail,
  1142. })
  1143. return
  1144. }
  1145. }
  1146. func (this *DoctorsApiController) UpdateHospitalSummary() {
  1147. timeLayout := "2006-01-02"
  1148. loc, _ := time.LoadLocation("Local")
  1149. dataBody := make(map[string]interface{}, 0)
  1150. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1151. fmt.Print("err", err)
  1152. admission_time := dataBody["admission_time"].(string)
  1153. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1154. admissiontime := admissionTimes.Unix()
  1155. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1156. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1157. connecticut := dataBody["connecticut"].(string)
  1158. dean := int64(dataBody["dean"].(float64))
  1159. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1160. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1161. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1162. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1163. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1164. discharge_advice := dataBody["discharge_advice"].(string)
  1165. discharge_time := dataBody["discharge_time"].(string)
  1166. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1167. dischargetime := dischargeTimes.Unix()
  1168. doctor := int64(dataBody["doctor"].(float64))
  1169. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1170. illness_discharge := dataBody["illness_discharge"].(string)
  1171. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1172. pathology := dataBody["pathology"].(string)
  1173. record_date := dataBody["record_date"].(string)
  1174. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1175. recordtime := recordDates.Unix()
  1176. sick_personnel := dataBody["sick_personnel"].(string)
  1177. title := dataBody["title"].(string)
  1178. treatment_id := dataBody["treatment_id"].(string)
  1179. treatment := dataBody["treatment"].(string)
  1180. ultrasound := dataBody["ultrasound"].(string)
  1181. xray := dataBody["xray"].(string)
  1182. patient_id := int64(dataBody["patient_id"].(float64))
  1183. id := int64(dataBody["id"].(float64))
  1184. summary := models.XtHospitalSummary{
  1185. PatientId: patient_id,
  1186. AdmissionTime: admissiontime,
  1187. DischargeTime: dischargetime,
  1188. SickPersonnel: sick_personnel,
  1189. Xray: xray,
  1190. Connecticut: connecticut,
  1191. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1192. Ultrasound: ultrasound,
  1193. Pathology: pathology,
  1194. AdmittingDiagnosisId: admitting_diagnosis_id,
  1195. AdmittingDiagnosis: admitting_diagnosis,
  1196. DischargeDiagnosis: discharge_diagnosis,
  1197. DiagnosisAdmissionId: diagnosis_admission_id,
  1198. DiagnosisAdmission: diagnosis_admission,
  1199. TreatmentId: treatment_id,
  1200. Treatment: treatment,
  1201. IllnessDischargeId: illness_discharge_id,
  1202. IllnessDischarge: illness_discharge,
  1203. DischargeAdviceId: discharge_advice_id,
  1204. DischargeAdvice: discharge_advice,
  1205. Mtime: time.Now().Unix(),
  1206. RecordTime: recordtime,
  1207. Title: title,
  1208. Doctor: doctor,
  1209. RecordDate: recordtime,
  1210. DeanId: dean,
  1211. DischargeDiagnosisId: discharge_diagnosis_id,
  1212. }
  1213. err = service.UpdateHospital(id, summary)
  1214. if err == nil {
  1215. this.ServeSuccessJSON(map[string]interface{}{
  1216. "detail": summary,
  1217. })
  1218. return
  1219. }
  1220. }
  1221. func (this *DoctorsApiController) DeleteHospitalSummary() {
  1222. schIDStr := this.GetString("ids")
  1223. idStrs := strings.Split(schIDStr, ",")
  1224. err := service.DeleteHospitalSummary(idStrs)
  1225. fmt.Println(err)
  1226. returnData := make(map[string]interface{}, 0)
  1227. returnData["msg"] = "ok"
  1228. this.ServeSuccessJSON(returnData)
  1229. return
  1230. }
  1231. func (this *DoctorsApiController) GetPatientInfo() {
  1232. patient_id, _ := this.GetInt64("patient_id")
  1233. orgId := this.GetAdminUserInfo().CurrentOrgId
  1234. detail, err := service.GetPatientDetail(patient_id, orgId)
  1235. if err == nil {
  1236. this.ServeSuccessJSON(map[string]interface{}{
  1237. "patient": detail,
  1238. })
  1239. return
  1240. }
  1241. }
  1242. func (c *DoctorsApiController) GetScheduleAdvicesList() {
  1243. schedualDate := c.GetString("date")
  1244. adviceType, _ := c.GetInt("advice_type")
  1245. patientType, _ := c.GetInt("patient_type")
  1246. delivery_way := c.GetString("delivery_way")
  1247. schedule_type, _ := c.GetInt64("schedule_type")
  1248. partition_type, _ := c.GetInt64("partition_type")
  1249. patient_id, _ := c.GetInt64("patient_id")
  1250. excution_way, _ := c.GetInt64("excution_way")
  1251. cost_type, _ := c.GetInt64("cost_type")
  1252. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  1253. adviceType = 0
  1254. }
  1255. if patientType != 1 && patientType != 2 {
  1256. patientType = 0
  1257. }
  1258. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  1259. if parseDateErr != nil {
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1261. return
  1262. }
  1263. adminUserInfo := c.GetAdminUserInfo()
  1264. orgID := adminUserInfo.CurrentOrgId
  1265. config, _ := service.GetHisDoctorConfig(orgID)
  1266. project_config, _ := service.GetHisProjectConfig(orgID)
  1267. if config.IsOpen == 0 || config.IsOpen == 2 {
  1268. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type)
  1269. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  1270. if err != nil {
  1271. c.ErrorLog("获取排班信息失败:%v", err)
  1272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. } else {
  1274. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  1275. for _, schedual := range scheduals {
  1276. if len(schedual.DoctorAdvices) > 0 {
  1277. filtedScheduals = append(filtedScheduals, schedual)
  1278. }
  1279. }
  1280. c.ServeSuccessJSON(map[string]interface{}{
  1281. "scheduals": filtedScheduals,
  1282. "adminUser": adminUser,
  1283. "config": config,
  1284. "project_config": project_config,
  1285. })
  1286. }
  1287. }
  1288. if config.IsOpen == 1 {
  1289. hisAdvices, err := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type)
  1290. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  1291. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
  1292. for _, item := range project {
  1293. index := 0
  1294. for _, subItem := range item.HisPrescriptionTeamProject {
  1295. if subItem.HisProject.CostClassify != 3 {
  1296. subItem.IsCheckTeam = 2
  1297. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  1298. }
  1299. if subItem.HisProject.CostClassify == 3 {
  1300. subItem.IsCheckTeam = 1
  1301. index = index + 1
  1302. if index == 1 {
  1303. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  1304. }
  1305. }
  1306. }
  1307. }
  1308. if err != nil {
  1309. c.ErrorLog("获取排班信息失败:%v", err)
  1310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1311. } else {
  1312. c.ServeSuccessJSON(map[string]interface{}{
  1313. "adminUser": adminUser,
  1314. "hisAdvices": hisAdvices,
  1315. "config": config,
  1316. "project_config": project_config,
  1317. "project": project,
  1318. })
  1319. }
  1320. }
  1321. }