doctors_api_controller.go 52KB

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