patient_dataconfig_api_controller.go 56KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655
  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. "reflect"
  10. "strconv"
  11. "strings"
  12. "time"
  13. "github.com/astaxie/beego"
  14. )
  15. func PatientDataConfigAPIControllerRegistRouters() {
  16. beego.Router("/api/patient/courses", &PatientDataConfigAPIController{}, "get:Courses")
  17. beego.Router("/api/patient/course/create", &PatientDataConfigAPIController{}, "get:CreateCourse")
  18. beego.Router("/api/patient/course/delete", &PatientDataConfigAPIController{}, "post:DeleteCourse")
  19. beego.Router("/api/patient/course/modify", &PatientDataConfigAPIController{}, "get:ModifyCourse")
  20. beego.Router("/api/patient/rescues", &PatientDataConfigAPIController{}, "get:Rescues")
  21. beego.Router("/api/patient/rescue/create", &PatientDataConfigAPIController{}, "post:CreateRescue")
  22. beego.Router("/api/patient/rescue/delete", &PatientDataConfigAPIController{}, "post:DeleteRescue")
  23. beego.Router("/api/patient/sickhistory", &PatientDataConfigAPIController{}, "get:GetSickHistorys")
  24. beego.Router("/api/patient/sickhistory/create", &PatientDataConfigAPIController{}, "get:CreateSickHistory")
  25. beego.Router("/api/patient/sickhistory/delete", &PatientDataConfigAPIController{}, "post:DeleteSickHistory")
  26. beego.Router("/api/patient/sickhistory/modify", &PatientDataConfigAPIController{}, "get:ModifySickHistory")
  27. beego.Router("/api/patient/physiquecheck", &PatientDataConfigAPIController{}, "get:GetPhysiqueChecks")
  28. beego.Router("/api/patient/physiquecheck/create", &PatientDataConfigAPIController{}, "get:CreatePhysiqueCheck")
  29. beego.Router("/api/patient/physiquecheck/delete", &PatientDataConfigAPIController{}, "post:DeletePhysiqueCheck")
  30. beego.Router("/api/patient/physiquecheck/modify", &PatientDataConfigAPIController{}, "get:ModifyPhysiqueCheck")
  31. beego.Router("/api/patient/sickhistory/print", &PatientDataConfigAPIController{}, "get:GetSickhistoryPrints")
  32. beego.Router("/api/patient/physiquecheck/print", &PatientDataConfigAPIController{}, "get:GetPhysiquecheckPrints")
  33. beego.Router("/api/patient/getpatientdialysisinforlist", &PatientDataConfigAPIController{}, "get:GetPatientDialysisInforList")
  34. beego.Router("/api/patient/getcontextschedulelist", &PatientDataConfigAPIController{}, "Get:GetContextScheduleList")
  35. beego.Router("/api/patient/getpatientallagic", &PatientDataConfigAPIController{}, "Get:GetPatientAllagicList")
  36. beego.Router("/api/patient/savesitemap", &PatientDataConfigAPIController{}, "Post:SaveSiteMap")
  37. beego.Router("/api/patient/getpatientsitemap", &PatientDataConfigAPIController{}, "Get:GetPatientSitemap")
  38. beego.Router("/api/patient/getpatientdetailinformedconsent", &PatientDataConfigAPIController{}, "Get:GetPatientDetailInformedConsent")
  39. beego.Router("/api/patient/getpatientmedicallist", &PatientDataConfigAPIController{}, "Get:GetPatientMedicalList")
  40. //评估工具的接口
  41. beego.Router("/api/patient/fallassement/getallnurselist", &PatientDataConfigAPIController{}, "Get:GetAllNurseList")
  42. beego.Router("/api/patient/fallassment/savefllassessmentlist", &PatientDataConfigAPIController{}, "Post:SaveFllassessmentList")
  43. }
  44. type PatientDataConfigAPIController struct {
  45. BaseAuthAPIController
  46. }
  47. func (this *PatientDataConfigAPIController) GetPhysiquecheckPrints() {
  48. patientID, _ := this.GetInt64("patient_id")
  49. idsStr := this.GetString("ids")
  50. if patientID <= 0 || len(idsStr) == 0 {
  51. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  52. return
  53. }
  54. recordIDStrs := strings.Split(idsStr, ",")
  55. patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
  56. sickHostory, _ := service.GetPatienttPhysiqueByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
  57. this.ServeSuccessJSON(map[string]interface{}{
  58. "patient": patient,
  59. "sickhistorys": sickHostory,
  60. })
  61. }
  62. func (this *PatientDataConfigAPIController) GetSickhistoryPrints() {
  63. patientID, _ := this.GetInt64("patient_id")
  64. idsStr := this.GetString("ids")
  65. if patientID <= 0 || len(idsStr) == 0 {
  66. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  67. return
  68. }
  69. recordIDStrs := strings.Split(idsStr, ",")
  70. patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
  71. sickHostory, _ := service.GetPatientSickHistoryByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
  72. for _, item := range sickHostory {
  73. pc, _ := service.GetLastPatientPhysiqueCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientId, item.RecordDate)
  74. item.XtPatientPhysiqueCheck = pc
  75. }
  76. this.ServeSuccessJSON(map[string]interface{}{
  77. "patient": patient,
  78. "sickhistorys": sickHostory,
  79. })
  80. }
  81. func (this *PatientDataConfigAPIController) GetSickHistorys() {
  82. patientID, _ := this.GetInt64("patient_id")
  83. startTimeYMDStr := this.GetString("start_time")
  84. endTimeYMDStr := this.GetString("end_time")
  85. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  86. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  87. return
  88. }
  89. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  90. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  91. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  92. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  93. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  94. return
  95. }
  96. adminUserInfo := this.GetAdminUserInfo()
  97. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  98. if getPatientErr != nil {
  99. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  100. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  101. return
  102. } else if patient == nil {
  103. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  104. return
  105. }
  106. records, getRecordsErr := service.GetPatientSickHistory(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  107. if getRecordsErr != nil {
  108. this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
  109. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  110. return
  111. }
  112. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  113. if getAllAdminsErr != nil {
  114. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  115. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  116. return
  117. }
  118. this.ServeSuccessJSON(map[string]interface{}{
  119. "records": records,
  120. "doctors": admins,
  121. })
  122. }
  123. func (this *PatientDataConfigAPIController) CreateSickHistory() {
  124. patientID, _ := this.GetInt64("patient_id")
  125. content := this.GetString("content")
  126. record_time_str := this.GetString("record_time")
  127. title := this.GetString("title")
  128. is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
  129. is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
  130. is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
  131. guominyaowu_desc := this.GetString("guominyaowu_desc")
  132. doctor_id, _ := this.GetInt64("doctor_id")
  133. if patientID <= 0 || len(content) == 0 {
  134. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  135. return
  136. }
  137. if len(record_time_str) == 0 {
  138. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  139. return
  140. }
  141. record_date := strings.Split(record_time_str, " ")
  142. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  143. checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
  144. adminUserInfo := this.GetAdminUserInfo()
  145. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  146. if getPatientErr != nil {
  147. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  148. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  149. return
  150. } else if patient == nil {
  151. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  152. return
  153. }
  154. now := time.Now().Unix()
  155. record := models.XtPatientSickHistory{
  156. OrgId: adminUserInfo.CurrentOrgId,
  157. PatientId: patientID,
  158. Recorder: adminUserInfo.AdminUser.Id,
  159. RecordTime: checkDate.Unix(),
  160. Content: content,
  161. Status: 1,
  162. Title: title,
  163. IsShenyizhiHistory: is_shenyizhishi,
  164. IsFumoDialysisHistory: is_fumotouxishi,
  165. HypersusceptibilityDesc: guominyaowu_desc,
  166. IsHypersusceptibility: is_guominyaowu,
  167. Ctime: now,
  168. Mtime: now,
  169. DoctorId: doctor_id,
  170. RecordDate: checkDate_two.Unix(),
  171. }
  172. createErr := service.CreatePatientSickHistory(&record)
  173. if createErr != nil {
  174. this.ErrorLog("创建患者病史记录失败:%v", createErr)
  175. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  176. return
  177. }
  178. this.ServeSuccessJSON(map[string]interface{}{
  179. "record": record,
  180. })
  181. }
  182. func (this *PatientDataConfigAPIController) DeleteSickHistory() {
  183. patientID, _ := this.GetInt64("patient_id")
  184. idsStr := this.GetString("ids")
  185. if patientID <= 0 || len(idsStr) == 0 {
  186. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  187. return
  188. }
  189. adminUserInfo := this.GetAdminUserInfo()
  190. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  191. if getPatientErr != nil {
  192. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  193. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  194. return
  195. } else if patient == nil {
  196. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  197. return
  198. }
  199. recordIDStrs := strings.Split(idsStr, ",")
  200. recordIDs := make([]int64, 0, len(recordIDStrs))
  201. for _, idStr := range recordIDStrs {
  202. id, parseErr := strconv.Atoi(idStr)
  203. if parseErr != nil {
  204. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  205. return
  206. }
  207. recordIDs = append(recordIDs, int64(id))
  208. }
  209. deleteErr := service.DeletePatientSickHistoryInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  210. if deleteErr != nil {
  211. this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
  212. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  213. return
  214. }
  215. this.ServeSuccessJSON(nil)
  216. }
  217. func (this *PatientDataConfigAPIController) ModifySickHistory() {
  218. patientID, _ := this.GetInt64("patient_id")
  219. content := this.GetString("content")
  220. id, _ := this.GetInt64("id", 0)
  221. record_time_str := this.GetString("record_time")
  222. title := this.GetString("title")
  223. is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
  224. is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
  225. is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
  226. guominyaowu_desc := this.GetString("guominyaowu_desc")
  227. doctor_id, _ := this.GetInt64("doctor_id")
  228. if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
  229. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  230. return
  231. }
  232. //timeLayout := "2006-01-02"
  233. //loc, _ := time.LoadLocation("Local")
  234. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  235. fmt.Println("checkDate--------------", checkDate)
  236. adminUserInfo := this.GetAdminUserInfo()
  237. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  238. if getPatientErr != nil {
  239. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  240. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  241. return
  242. } else if patient == nil {
  243. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  244. return
  245. }
  246. now := time.Now().Unix()
  247. record := models.XtPatientSickHistory{
  248. ID: id,
  249. OrgId: adminUserInfo.CurrentOrgId,
  250. PatientId: patientID,
  251. Recorder: adminUserInfo.AdminUser.Id,
  252. Content: content,
  253. Status: 1,
  254. Ctime: now,
  255. Mtime: now,
  256. Title: title,
  257. RecordTime: checkDate.Unix(),
  258. IsShenyizhiHistory: is_shenyizhishi,
  259. IsFumoDialysisHistory: is_fumotouxishi,
  260. HypersusceptibilityDesc: guominyaowu_desc,
  261. IsHypersusceptibility: is_guominyaowu,
  262. DoctorId: doctor_id,
  263. }
  264. createErr := service.ModifyPatientSickHistory(&record)
  265. if createErr != nil {
  266. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  267. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  268. return
  269. }
  270. this.ServeSuccessJSON(map[string]interface{}{
  271. "record": record,
  272. })
  273. }
  274. func (this *PatientDataConfigAPIController) GetPhysiqueChecks() {
  275. patientID, _ := this.GetInt64("patient_id")
  276. startTimeYMDStr := this.GetString("start_time")
  277. endTimeYMDStr := this.GetString("end_time")
  278. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  279. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  280. return
  281. }
  282. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  283. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  284. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  285. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  286. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  287. return
  288. }
  289. adminUserInfo := this.GetAdminUserInfo()
  290. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  291. if getPatientErr != nil {
  292. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  293. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. } else if patient == nil {
  296. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  297. return
  298. }
  299. records, getRecordsErr := service.GetPatientPhysiqueCheck(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  300. if getRecordsErr != nil {
  301. this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
  302. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  303. return
  304. }
  305. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  306. if getAllAdminsErr != nil {
  307. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  308. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. this.ServeSuccessJSON(map[string]interface{}{
  312. "records": records,
  313. "doctors": admins,
  314. })
  315. }
  316. func (this *PatientDataConfigAPIController) CreatePhysiqueCheck() {
  317. patientID, _ := this.GetInt64("patient_id")
  318. doctor_id, _ := this.GetInt64("doctor_id")
  319. record_time_str := this.GetString("record_time")
  320. t := this.GetString("t")
  321. p := this.GetString("p")
  322. r := this.GetString("r")
  323. bp_left := this.GetString("bp_left")
  324. bp_right := this.GetString("bp_right")
  325. pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
  326. tiwei, _ := this.GetInt64("tiwei")
  327. fuzhong, _ := this.GetInt64("fuzhong")
  328. chuxuedian, _ := this.GetInt64("chuxuedian")
  329. fayu, _ := this.GetInt64("fayu")
  330. yinyang, _ := this.GetInt64("yinyang")
  331. shenzhi, _ := this.GetInt64("shenzhi")
  332. pifunianmo, _ := this.GetInt64("pifunianmo")
  333. buwei := this.GetString("buwei")
  334. chengdu := this.GetString("chengdu")
  335. pixiachuxue, _ := this.GetInt64("pixiachuxue")
  336. zidian, _ := this.GetInt64("zidian")
  337. pifuwendu, _ := this.GetInt64("pifuwendu")
  338. qita := this.GetString("qita")
  339. linbazhongda, _ := this.GetInt64("linbazhongda")
  340. linbabuwei := this.GetString("linbabuwei")
  341. yanlian, _ := this.GetInt64("yanlian")
  342. tongkong, _ := this.GetInt64("tongkong")
  343. zuo := this.GetString("zuo")
  344. you := this.GetString("you")
  345. duiguangfanshe := this.GetString("duiguangfanshe")
  346. biantaoti := this.GetString("biantaoti")
  347. yanbu := this.GetString("yanbu")
  348. toubuqita := this.GetString("toubuqita")
  349. huxiyin := this.GetString("huxiyin")
  350. xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
  351. feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
  352. luoyin, _ := this.GetInt64("luoyin")
  353. desc := this.GetString("desc")
  354. xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
  355. xinlv, _ := this.GetInt64("xinlv")
  356. xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
  357. zayin, _ := this.GetInt64("zayin")
  358. fujiayin, _ := this.GetInt64("fujiayin")
  359. xinzangdesc := this.GetString("xinzangdesc")
  360. fushuizheng, _ := this.GetInt64("fushuizheng")
  361. ganjingjingmai := this.GetString("ganjingjingmai")
  362. gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
  363. gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
  364. pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
  365. pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
  366. shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
  367. shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
  368. fubu_desc := this.GetString("fubu_desc")
  369. oth_desc := this.GetString("oth_desc")
  370. if patientID <= 0 {
  371. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  372. return
  373. }
  374. if len(record_time_str) == 0 {
  375. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  376. return
  377. }
  378. record_date := strings.Split(record_time_str, " ")
  379. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  380. checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
  381. adminUserInfo := this.GetAdminUserInfo()
  382. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  383. if getPatientErr != nil {
  384. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  385. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  386. return
  387. } else if patient == nil {
  388. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  389. return
  390. }
  391. now := time.Now().Unix()
  392. record := models.XtPatientPhysiqueCheck{
  393. DoctorId: doctor_id,
  394. OrgId: adminUserInfo.CurrentOrgId,
  395. PatientId: patientID,
  396. Recorder: adminUserInfo.AdminUser.Id,
  397. RecordTime: checkDate.Unix(),
  398. Status: 1,
  399. Ctime: now,
  400. Mtime: now,
  401. T: t,
  402. P: p,
  403. R: r,
  404. BpRight: bp_right,
  405. BpLeft: bp_left,
  406. Pinxuerongmao: pinxuerongmao,
  407. Tiwei: tiwei,
  408. Fuzhong: fuzhong,
  409. Chuxuedian: chuxuedian,
  410. Fayu: fayu,
  411. Yinyang: yinyang,
  412. Shenzhi: shenzhi,
  413. Pifunianmo: pifunianmo,
  414. Buwei: buwei,
  415. Chengdu: chengdu,
  416. Pixiachuxue: pixiachuxue,
  417. Zidian: zidian,
  418. Pifuwendu: pifuwendu,
  419. Qita: qita,
  420. Linbazhongda: linbazhongda,
  421. Linbabuwei: linbabuwei,
  422. Yanlian: yanlian,
  423. Tongkong: tongkong,
  424. Zuo: zuo,
  425. You: you,
  426. Duiguangfanshe: duiguangfanshe,
  427. Biantaoti: biantaoti,
  428. Yanbu: yanbu,
  429. Toubuqita: toubuqita,
  430. Huxiyin: huxiyin,
  431. Xiongmomocayin: xiongmomocayin,
  432. Feizhangbuwei: feizhangbuwei,
  433. Luoyin: luoyin,
  434. Desc: desc,
  435. Xinzangdaxiao: xinzangdaxiao,
  436. Xinlv: xinlv,
  437. Xinbaomocasheng: xinbaomocasheng,
  438. Zayin: zayin,
  439. Fujiayin: fujiayin,
  440. Xinzangdesc: xinzangdesc,
  441. Fushuizheng: fushuizheng,
  442. Ganjingjingmai: ganjingjingmai,
  443. GangzhangYatong: gangzhang_yatong,
  444. GangzhangKoutong: gangzhang_koutong,
  445. PizhangKoutong: pizhang_koutong,
  446. PizhangYatong: pizhang_yatong,
  447. ShenzhangKoutong: shenzhang_koutong,
  448. ShenzhangYatong: shenzhang_yatong,
  449. FubuDesc: fubu_desc,
  450. OthDesc: oth_desc,
  451. RecordDate: checkDate_two.Unix(),
  452. }
  453. createErr := service.CreatePatientPhysiqueCheck(&record)
  454. if createErr != nil {
  455. this.ErrorLog("创建患者病史记录失败:%v", createErr)
  456. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  457. return
  458. }
  459. this.ServeSuccessJSON(map[string]interface{}{
  460. "record": record,
  461. })
  462. }
  463. func (this *PatientDataConfigAPIController) DeletePhysiqueCheck() {
  464. patientID, _ := this.GetInt64("patient_id")
  465. idsStr := this.GetString("ids")
  466. if patientID <= 0 || len(idsStr) == 0 {
  467. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  468. return
  469. }
  470. adminUserInfo := this.GetAdminUserInfo()
  471. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  472. if getPatientErr != nil {
  473. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  474. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  475. return
  476. } else if patient == nil {
  477. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  478. return
  479. }
  480. recordIDStrs := strings.Split(idsStr, ",")
  481. recordIDs := make([]int64, 0, len(recordIDStrs))
  482. for _, idStr := range recordIDStrs {
  483. id, parseErr := strconv.Atoi(idStr)
  484. if parseErr != nil {
  485. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  486. return
  487. }
  488. recordIDs = append(recordIDs, int64(id))
  489. }
  490. deleteErr := service.DeletePatientPhysiqueCheckInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  491. if deleteErr != nil {
  492. this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
  493. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  494. return
  495. }
  496. this.ServeSuccessJSON(nil)
  497. }
  498. func (this *PatientDataConfigAPIController) ModifyPhysiqueCheck() {
  499. patientID, _ := this.GetInt64("patient_id")
  500. id, _ := this.GetInt64("id", 0)
  501. doctor_id, _ := this.GetInt64("doctor_id", 0)
  502. record_time_str := this.GetString("record_time")
  503. if patientID <= 0 || id == 0 || len(record_time_str) == 0 {
  504. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  505. return
  506. }
  507. t := this.GetString("t")
  508. p := this.GetString("p")
  509. r := this.GetString("r")
  510. bp_left := this.GetString("bp_left")
  511. bp_right := this.GetString("bp_right")
  512. pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
  513. tiwei, _ := this.GetInt64("tiwei")
  514. fuzhong, _ := this.GetInt64("fuzhong")
  515. chuxuedian, _ := this.GetInt64("chuxuedian")
  516. fayu, _ := this.GetInt64("fayu")
  517. yinyang, _ := this.GetInt64("yinyang")
  518. shenzhi, _ := this.GetInt64("shenzhi")
  519. pifunianmo, _ := this.GetInt64("pifunianmo")
  520. buwei := this.GetString("buwei")
  521. chengdu := this.GetString("chengdu")
  522. pixiachuxue, _ := this.GetInt64("pixiachuxue")
  523. zidian, _ := this.GetInt64("zidian")
  524. pifuwendu, _ := this.GetInt64("pifuwendu")
  525. qita := this.GetString("qita")
  526. linbazhongda, _ := this.GetInt64("linbazhongda")
  527. linbabuwei := this.GetString("linbabuwei")
  528. yanlian, _ := this.GetInt64("yanlian")
  529. tongkong, _ := this.GetInt64("tongkong")
  530. zuo := this.GetString("zuo")
  531. you := this.GetString("you")
  532. duiguangfanshe := this.GetString("duiguangfanshe")
  533. biantaoti := this.GetString("biantaoti")
  534. yanbu := this.GetString("yanbu")
  535. toubuqita := this.GetString("toubuqita")
  536. huxiyin := this.GetString("huxiyin")
  537. xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
  538. feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
  539. luoyin, _ := this.GetInt64("luoyin")
  540. desc := this.GetString("desc")
  541. xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
  542. xinlv, _ := this.GetInt64("xinlv")
  543. xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
  544. zayin, _ := this.GetInt64("zayin")
  545. fujiayin, _ := this.GetInt64("fujiayin")
  546. xinzangdesc := this.GetString("xinzangdesc")
  547. fushuizheng, _ := this.GetInt64("fushuizheng")
  548. ganjingjingmai := this.GetString("ganjingjingmai")
  549. gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
  550. gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
  551. pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
  552. pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
  553. shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
  554. shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
  555. fubu_desc := this.GetString("fubu_desc")
  556. oth_desc := this.GetString("oth_desc")
  557. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  558. adminUserInfo := this.GetAdminUserInfo()
  559. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  560. if getPatientErr != nil {
  561. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  562. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  563. return
  564. } else if patient == nil {
  565. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  566. return
  567. }
  568. now := time.Now().Unix()
  569. record := models.XtPatientPhysiqueCheck{
  570. ID: id,
  571. OrgId: adminUserInfo.CurrentOrgId,
  572. PatientId: patientID,
  573. Recorder: adminUserInfo.AdminUser.Id,
  574. RecordTime: checkDate.Unix(),
  575. DoctorId: doctor_id,
  576. Status: 1,
  577. Ctime: now,
  578. Mtime: now,
  579. T: t,
  580. P: p,
  581. R: r,
  582. BpRight: bp_right,
  583. BpLeft: bp_left,
  584. Pinxuerongmao: pinxuerongmao,
  585. Tiwei: tiwei,
  586. Fuzhong: fuzhong,
  587. Chuxuedian: chuxuedian,
  588. Fayu: fayu,
  589. Yinyang: yinyang,
  590. Shenzhi: shenzhi,
  591. Pifunianmo: pifunianmo,
  592. Buwei: buwei,
  593. Chengdu: chengdu,
  594. Pixiachuxue: pixiachuxue,
  595. Zidian: zidian,
  596. Pifuwendu: pifuwendu,
  597. Qita: qita,
  598. Linbazhongda: linbazhongda,
  599. Linbabuwei: linbabuwei,
  600. Yanlian: yanlian,
  601. Tongkong: tongkong,
  602. Zuo: zuo,
  603. You: you,
  604. Duiguangfanshe: duiguangfanshe,
  605. Biantaoti: biantaoti,
  606. Yanbu: yanbu,
  607. Toubuqita: toubuqita,
  608. Huxiyin: huxiyin,
  609. Xiongmomocayin: xiongmomocayin,
  610. Feizhangbuwei: feizhangbuwei,
  611. Luoyin: luoyin,
  612. Desc: desc,
  613. Xinzangdaxiao: xinzangdaxiao,
  614. Xinlv: xinlv,
  615. Xinbaomocasheng: xinbaomocasheng,
  616. Zayin: zayin,
  617. Fujiayin: fujiayin,
  618. Xinzangdesc: xinzangdesc,
  619. Fushuizheng: fushuizheng,
  620. Ganjingjingmai: ganjingjingmai,
  621. GangzhangYatong: gangzhang_yatong,
  622. GangzhangKoutong: gangzhang_koutong,
  623. PizhangKoutong: pizhang_koutong,
  624. PizhangYatong: pizhang_yatong,
  625. ShenzhangKoutong: shenzhang_koutong,
  626. ShenzhangYatong: shenzhang_yatong,
  627. FubuDesc: fubu_desc,
  628. OthDesc: oth_desc,
  629. }
  630. createErr := service.ModifyPatientPhysiqueCheck(&record)
  631. if createErr != nil {
  632. this.ErrorLog("修改患者体格检查失败:%v", createErr)
  633. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  634. return
  635. }
  636. this.ServeSuccessJSON(map[string]interface{}{
  637. "record": record,
  638. })
  639. }
  640. // /api/patient/courses [get]
  641. // @param patient_id:int
  642. // @param start_time:string (yyyy-MM-dd)
  643. // @param end_time:string (yyyy-MM-dd)
  644. func (this *PatientDataConfigAPIController) Courses() {
  645. patientID, _ := this.GetInt64("patient_id")
  646. startTimeYMDStr := this.GetString("start_time")
  647. endTimeYMDStr := this.GetString("end_time")
  648. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  649. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  650. return
  651. }
  652. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  653. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  654. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  655. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  656. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  657. return
  658. }
  659. adminUserInfo := this.GetAdminUserInfo()
  660. //patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  661. //if getPatientErr != nil {
  662. // this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  663. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. // return
  665. //} else if patient == nil {
  666. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  667. // return
  668. //}
  669. records, getRecordsErr := service.GetPatientCourseOfDisease(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  670. if getRecordsErr != nil {
  671. this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
  672. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  673. return
  674. }
  675. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  676. if getAllAdminsErr != nil {
  677. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  678. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. this.ServeSuccessJSON(map[string]interface{}{
  682. "records": records,
  683. "doctors": admins,
  684. })
  685. }
  686. // /api/patient/course/create [post]
  687. // @param patient_id:int
  688. // @param content:string
  689. func (this *PatientDataConfigAPIController) CreateCourse() {
  690. patientID, _ := this.GetInt64("patient_id")
  691. fmt.Println(patientID)
  692. content := this.GetString("content")
  693. record_time_str := this.GetString("record_time")
  694. title := this.GetString("title")
  695. if patientID <= 0 || len(content) == 0 {
  696. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  697. return
  698. }
  699. if len(record_time_str) == 0 {
  700. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  701. return
  702. }
  703. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  704. adminUserInfo := this.GetAdminUserInfo()
  705. //patient, _ := service.GetPatientByIDOne(adminUserInfo.CurrentOrgId, patientID)
  706. //if getPatientErr != nil {
  707. // this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  708. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  709. // return
  710. //} else if patient == nil {
  711. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  712. // return
  713. //}
  714. now := time.Now().Unix()
  715. record := models.PatientDiseaseCourse{
  716. OrgID: adminUserInfo.CurrentOrgId,
  717. PatientID: patientID,
  718. Recorder: adminUserInfo.AdminUser.Id,
  719. RecordTime: checkDate.Unix(),
  720. Content: content,
  721. Status: 1,
  722. CreateTime: now,
  723. ModifyTime: now,
  724. Title: title,
  725. }
  726. createErr := service.CreatePatientCourseOfDisease(&record)
  727. if createErr != nil {
  728. this.ErrorLog("创建患者病程记录失败:%v", createErr)
  729. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  730. return
  731. }
  732. this.ServeSuccessJSON(map[string]interface{}{
  733. "record": record,
  734. })
  735. }
  736. // /api/patient/course/delete
  737. // @param patient_id:int
  738. // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
  739. func (this *PatientDataConfigAPIController) DeleteCourse() {
  740. patientID, _ := this.GetInt64("patient_id")
  741. idsStr := this.GetString("ids")
  742. if patientID <= 0 || len(idsStr) == 0 {
  743. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  744. return
  745. }
  746. adminUserInfo := this.GetAdminUserInfo()
  747. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  748. if getPatientErr != nil {
  749. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  750. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  751. return
  752. } else if patient == nil {
  753. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  754. return
  755. }
  756. recordIDStrs := strings.Split(idsStr, ",")
  757. recordIDs := make([]int64, 0, len(recordIDStrs))
  758. for _, idStr := range recordIDStrs {
  759. id, parseErr := strconv.Atoi(idStr)
  760. if parseErr != nil {
  761. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  762. return
  763. }
  764. recordIDs = append(recordIDs, int64(id))
  765. }
  766. deleteErr := service.DeletePatientCoursesInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  767. if deleteErr != nil {
  768. this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
  769. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. this.ServeSuccessJSON(nil)
  773. }
  774. // /api/patient/rescues [get]
  775. // @param patient_id:int
  776. // @param start_time:string (yyyy-MM-dd)
  777. // @param end_time:string (yyyy-MM-dd)
  778. func (this *PatientDataConfigAPIController) Rescues() {
  779. patientID, _ := this.GetInt64("patient_id")
  780. startTimeYMDStr := this.GetString("start_time")
  781. endTimeYMDStr := this.GetString("end_time")
  782. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  783. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  784. return
  785. }
  786. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  787. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  788. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  789. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  790. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  791. return
  792. }
  793. adminUserInfo := this.GetAdminUserInfo()
  794. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  795. if getPatientErr != nil {
  796. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  797. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  798. return
  799. } else if patient == nil {
  800. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  801. return
  802. }
  803. records, getRecordsErr := service.GetPatientRescueRecords(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  804. if getRecordsErr != nil {
  805. this.ErrorLog("获取患者抢救记录失败:%v", getRecordsErr)
  806. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  810. if getAllAdminsErr != nil {
  811. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  812. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. this.ServeSuccessJSON(map[string]interface{}{
  816. "records": records,
  817. "doctors": admins,
  818. })
  819. }
  820. // /api/patient/rescue/create [post]
  821. // @param patient_id:int
  822. // @param content:string
  823. func (this *PatientDataConfigAPIController) CreateRescue() {
  824. patientID, _ := this.GetInt64("patient_id")
  825. content := this.GetString("content")
  826. if patientID <= 0 || len(content) == 0 {
  827. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  828. return
  829. }
  830. adminUserInfo := this.GetAdminUserInfo()
  831. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  832. if getPatientErr != nil {
  833. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  834. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  835. return
  836. } else if patient == nil {
  837. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  838. return
  839. }
  840. now := time.Now().Unix()
  841. record := models.PatientRescueRecord{
  842. OrgID: adminUserInfo.CurrentOrgId,
  843. PatientID: patientID,
  844. Recorder: adminUserInfo.AdminUser.Id,
  845. RecordTime: now,
  846. Content: content,
  847. Status: 1,
  848. CreateTime: now,
  849. ModifyTime: now,
  850. }
  851. createErr := service.CreatePatientRescueRecord(&record)
  852. if createErr != nil {
  853. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  854. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  855. return
  856. }
  857. this.ServeSuccessJSON(map[string]interface{}{
  858. "record": record,
  859. })
  860. }
  861. // /api/patient/rescue/delete
  862. // @param patient_id:int
  863. // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
  864. func (this *PatientDataConfigAPIController) DeleteRescue() {
  865. patientID, _ := this.GetInt64("patient_id")
  866. idsStr := this.GetString("ids")
  867. if patientID <= 0 || len(idsStr) == 0 {
  868. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  869. return
  870. }
  871. adminUserInfo := this.GetAdminUserInfo()
  872. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  873. if getPatientErr != nil {
  874. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  875. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  876. return
  877. } else if patient == nil {
  878. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  879. return
  880. }
  881. recordIDStrs := strings.Split(idsStr, ",")
  882. recordIDs := make([]int64, 0, len(recordIDStrs))
  883. for _, idStr := range recordIDStrs {
  884. id, parseErr := strconv.Atoi(idStr)
  885. if parseErr != nil {
  886. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  887. return
  888. }
  889. recordIDs = append(recordIDs, int64(id))
  890. }
  891. deleteErr := service.DeletePatientResuceRecordsInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  892. if deleteErr != nil {
  893. this.ErrorLog("删除患者抢救记录失败:%v", deleteErr)
  894. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  895. return
  896. }
  897. this.ServeSuccessJSON(nil)
  898. }
  899. func (this *PatientDataConfigAPIController) ModifyCourse() {
  900. patientID, _ := this.GetInt64("patient_id")
  901. content := this.GetString("content")
  902. id, _ := this.GetInt64("id", 0)
  903. record_time_str := this.GetString("record_time")
  904. title := this.GetString("title")
  905. if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
  906. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  907. return
  908. }
  909. //timeLayout := "2006-01-02"
  910. //loc, _ := time.LoadLocation("Local")
  911. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  912. adminUserInfo := this.GetAdminUserInfo()
  913. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  914. if getPatientErr != nil {
  915. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  916. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  917. return
  918. } else if patient == nil {
  919. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  920. return
  921. }
  922. now := time.Now().Unix()
  923. record := models.PatientDiseaseCourse{
  924. ID: id,
  925. OrgID: adminUserInfo.CurrentOrgId,
  926. PatientID: patientID,
  927. Recorder: adminUserInfo.AdminUser.Id,
  928. Content: content,
  929. Status: 1,
  930. CreateTime: now,
  931. ModifyTime: now,
  932. Title: title,
  933. RecordTime: checkDate.Unix(),
  934. }
  935. createErr := service.ModifyPatientCourses(&record)
  936. if createErr != nil {
  937. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  938. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  939. return
  940. }
  941. this.ServeSuccessJSON(map[string]interface{}{
  942. "record": record,
  943. })
  944. }
  945. func (this *PatientDataConfigAPIController) GetPatientDialysisInforList() {
  946. patientID, _ := this.GetInt64("patient_id")
  947. record_date := this.GetString("record_date")
  948. timeLayout := "2006-01-02"
  949. loc, _ := time.LoadLocation("Local")
  950. var startTime int64
  951. if len(record_date) > 0 {
  952. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  953. if err != nil {
  954. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  955. return
  956. }
  957. startTime = theTime.Unix()
  958. }
  959. //获取患者姓名
  960. patient, _ := service.GetPatientName(patientID)
  961. orgId := this.GetAdminUserInfo().CurrentOrgId
  962. //获取透析处方
  963. prescription, _ := service.GetDialysisPrescription(patientID, orgId, startTime)
  964. //获取透前评估
  965. assessmentBefor, _ := service.GetAssessmentBefor(orgId, patientID, startTime)
  966. //透析上机
  967. order, _ := service.GetDialysisOrder(orgId, patientID, startTime)
  968. //透析监测
  969. monitor, _ := service.GetFistMonitorSix(orgId, patientID, startTime)
  970. //透析医嘱
  971. advice, _ := service.GetBloodDoctorAdvice(startTime, orgId, patientID)
  972. //透后评估
  973. afterDislysis, _ := service.GetAssessmentAfterDissData(patientID, orgId, startTime)
  974. this.ServeSuccessJSON(map[string]interface{}{
  975. "patient": patient,
  976. "prescription": prescription,
  977. "assessmentBefor": assessmentBefor,
  978. "order": order,
  979. "monitor": monitor,
  980. "advice": advice,
  981. "afterDislysis": afterDislysis,
  982. })
  983. }
  984. func (this *PatientDataConfigAPIController) GetContextScheduleList() {
  985. limit, _ := this.GetInt64("limit")
  986. page, _ := this.GetInt64("page")
  987. start_time := this.GetString("start_time")
  988. end_time := this.GetString("end_time")
  989. timeLayout := "2006-01-02"
  990. loc, _ := time.LoadLocation("Local")
  991. var startTime int64
  992. if len(start_time) > 0 {
  993. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  994. if err != nil {
  995. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  996. return
  997. }
  998. startTime = theTime.Unix()
  999. }
  1000. var endTime int64
  1001. if len(end_time) > 0 {
  1002. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1003. if err != nil {
  1004. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1005. return
  1006. }
  1007. startTime = theTime.Unix()
  1008. }
  1009. org_id := this.GetAdminUserInfo().CurrentOrgId
  1010. schedule, total, _ := service.GetContextScheduleListGroupPatientId(limit, page, startTime, endTime, org_id)
  1011. list, _, _ := service.GetContextScheduleListPatientId(startTime, endTime, org_id)
  1012. patients, _ := service.GetAllpatientThirty(org_id)
  1013. devicenumber, _ := service.GetAllBedNumber(org_id)
  1014. this.ServeSuccessJSON(map[string]interface{}{
  1015. "schedule": schedule,
  1016. "total": total,
  1017. "list": list,
  1018. "patients": patients,
  1019. "devicenumber": devicenumber,
  1020. })
  1021. }
  1022. func (this *PatientDataConfigAPIController) GetPatientAllagicList() {
  1023. id, _ := this.GetInt64("id")
  1024. orgId := this.GetAdminUserInfo().CurrentOrgId
  1025. list, _ := service.GetPatientAllagicList(id, orgId)
  1026. this.ServeSuccessJSON(map[string]interface{}{
  1027. "list": list,
  1028. })
  1029. }
  1030. func (this *PatientDataConfigAPIController) SaveSiteMap() {
  1031. dataBody := make(map[string]interface{}, 0)
  1032. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1033. if err != nil {
  1034. utils.ErrorLog(err.Error())
  1035. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1036. return
  1037. }
  1038. patient_id := int64(dataBody["patient_id"].(float64))
  1039. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  1040. id := int64(dataBody["id"].(float64))
  1041. if dataBody["a_left"] != nil && reflect.TypeOf(dataBody["a_left"]).String() == "[]interface {}" {
  1042. prescriptions, _ := dataBody["a_left"].([]interface{})
  1043. service.UpdateValsualAleft(patient_id, user_org_id)
  1044. for _, item := range prescriptions {
  1045. var a_num float64
  1046. var mark_num float64
  1047. if item.(map[string]interface{})["a_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_num"]).String() == "float64" {
  1048. a_num = item.(map[string]interface{})["a_num"].(float64)
  1049. }
  1050. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1051. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1052. }
  1053. fmt.Println(a_num, mark_num)
  1054. valsualALeft := models.XtDeviceValsualALeft{
  1055. ANum: a_num,
  1056. MarkNum: mark_num,
  1057. UserOrgId: user_org_id,
  1058. PatientId: patient_id,
  1059. Ctime: time.Now().Unix(),
  1060. Mtime: time.Now().Unix(),
  1061. MapId: 0,
  1062. Status: 1,
  1063. }
  1064. service.CreateValsualAleft(valsualALeft)
  1065. }
  1066. }
  1067. is_append := int64(dataBody["is_append"].(float64))
  1068. is_img_v := int64(dataBody["is_img_v"].(float64))
  1069. is_img_a := int64(dataBody["is_img_a"].(float64))
  1070. a_top := dataBody["a_top"].(float64)
  1071. av_bkx := dataBody["av_bkx"].(float64)
  1072. av_bky := dataBody["av_bky"].(float64)
  1073. if dataBody["fangxiang_a"] != nil && reflect.TypeOf(dataBody["fangxiang_a"]).String() == "[]interface {}" {
  1074. prescriptions, _ := dataBody["fangxiang_a"].([]interface{})
  1075. service.ValsualMapFangxiangA(patient_id, user_org_id)
  1076. for _, item := range prescriptions {
  1077. var a_num float64
  1078. var mark_num float64
  1079. var mark_top float64
  1080. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1081. a_num = item.(map[string]interface{})["left"].(float64)
  1082. }
  1083. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1084. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1085. }
  1086. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1087. mark_top = item.(map[string]interface{})["top"].(float64)
  1088. }
  1089. ValsualMapFangxiangA := models.XtDeviceValsualMapFangxiangA{
  1090. PatientId: patient_id,
  1091. UserOrgId: user_org_id,
  1092. Status: 1,
  1093. Left: a_num,
  1094. MarkNum: mark_num,
  1095. Top: mark_top,
  1096. MapId: 0,
  1097. Ctime: time.Now().Unix(),
  1098. Mtime: time.Now().Unix(),
  1099. }
  1100. service.CreateValsualMapFangxiangA(ValsualMapFangxiangA)
  1101. }
  1102. }
  1103. fangxiang_a_num := dataBody["fangxiang_a_num"].(float64)
  1104. fangxiang_a_top := dataBody["fangxiang_a_top"].(float64)
  1105. fangxiang_v_left := dataBody["fangxiang_v_left"].(float64)
  1106. fangxiang_v_num := dataBody["fangxiang_v_num"].(float64)
  1107. fangxiang_v_top := dataBody["fangxiang_v_top"].(float64)
  1108. if dataBody["fangxiang_v"] != nil && reflect.TypeOf(dataBody["fangxiang_v"]).String() == "[]interface {}" {
  1109. prescriptions, _ := dataBody["fangxiang_v"].([]interface{})
  1110. service.UpdateValsualMapFangxiangV(patient_id, user_org_id)
  1111. for _, item := range prescriptions {
  1112. var a_num float64
  1113. var mark_num float64
  1114. var mark_top float64
  1115. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1116. a_num = item.(map[string]interface{})["left"].(float64)
  1117. }
  1118. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1119. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1120. }
  1121. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1122. mark_top = item.(map[string]interface{})["top"].(float64)
  1123. }
  1124. ValsualMapFangxiangV := models.XtDeviceValsualMapFangxiangV{
  1125. PatientId: patient_id,
  1126. UserOrgId: user_org_id,
  1127. Status: 1,
  1128. Left: a_num,
  1129. MarkNum: mark_num,
  1130. Top: mark_top,
  1131. MapId: 0,
  1132. Ctime: time.Now().Unix(),
  1133. Mtime: time.Now().Unix(),
  1134. }
  1135. service.CreateValsualMapFangxiangV(ValsualMapFangxiangV)
  1136. }
  1137. }
  1138. fangxiang_a_left := dataBody["fangxiang_a_left"].(float64)
  1139. if dataBody["fuzhu_a"] != nil && reflect.TypeOf(dataBody["fuzhu_a"]).String() == "[]interface {}" {
  1140. prescriptions, _ := dataBody["fuzhu_a"].([]interface{})
  1141. service.UpdateValSualFuzhA(patient_id, user_org_id)
  1142. for _, item := range prescriptions {
  1143. var a_left float64
  1144. var a_markNum float64
  1145. var a_top float64
  1146. if item.(map[string]interface{})["a_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_left"]).String() == "float64" {
  1147. a_left = item.(map[string]interface{})["a_left"].(float64)
  1148. }
  1149. if item.(map[string]interface{})["a_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_markNum"]).String() == "float64" {
  1150. a_markNum = item.(map[string]interface{})["a_markNum"].(float64)
  1151. }
  1152. if item.(map[string]interface{})["a_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_top"]).String() == "float64" {
  1153. a_top = item.(map[string]interface{})["a_top"].(float64)
  1154. }
  1155. valsualFuzhuA := models.XtDeviceValsualFuzhuA{
  1156. PatientId: patient_id,
  1157. UserOrgId: user_org_id,
  1158. Status: 1,
  1159. Ctime: time.Now().Unix(),
  1160. Mtime: time.Now().Unix(),
  1161. ALeft: a_left,
  1162. AMarkNum: a_markNum,
  1163. ATop: a_top,
  1164. MapId: 0,
  1165. }
  1166. service.CreateValSualFuzhA(valsualFuzhuA)
  1167. }
  1168. }
  1169. fuzhu_a_left := dataBody["fuzhu_a_left"].(float64)
  1170. fuzhu_a_num := dataBody["fuzhu_a_num"].(float64)
  1171. fuzhu_a_top := dataBody["fuzhu_a_top"].(float64)
  1172. left_a := dataBody["left_a"].(float64)
  1173. left_v := dataBody["left_v"].(float64)
  1174. if dataBody["fuzhu_v"] != nil && reflect.TypeOf(dataBody["fuzhu_v"]).String() == "[]interface {}" {
  1175. prescriptions, _ := dataBody["fuzhu_v"].([]interface{})
  1176. service.UpdateVasuaLfuzhuV(patient_id, user_org_id)
  1177. for _, item := range prescriptions {
  1178. var v_left float64
  1179. var v_markNum float64
  1180. var v_top float64
  1181. if item.(map[string]interface{})["v_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_left"]).String() == "float64" {
  1182. v_left = item.(map[string]interface{})["v_left"].(float64)
  1183. }
  1184. if item.(map[string]interface{})["v_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_markNum"]).String() == "float64" {
  1185. v_markNum = item.(map[string]interface{})["v_markNum"].(float64)
  1186. }
  1187. if item.(map[string]interface{})["v_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_top"]).String() == "float64" {
  1188. v_top = item.(map[string]interface{})["v_top"].(float64)
  1189. }
  1190. fuzhuV := models.XtDeviceValsualFuzhuV{
  1191. PatientId: patient_id,
  1192. UserOrgId: user_org_id,
  1193. Status: 1,
  1194. Ctime: time.Now().Unix(),
  1195. Mtime: 1,
  1196. VMarkNum: v_markNum,
  1197. VLeft: v_left,
  1198. VTop: v_top,
  1199. MapId: 0,
  1200. }
  1201. service.CreateVasuaLfuzhuV(fuzhuV)
  1202. }
  1203. }
  1204. fuzhu_v_left := dataBody["fuzhu_v_left"].(float64)
  1205. fuzhu_v_num := dataBody["fuzhu_v_num"].(float64)
  1206. fuzhu_v_top := dataBody["fuzhu_v_top"].(float64)
  1207. scalea_num := dataBody["scalea_num"].(float64)
  1208. scalev_num := dataBody["scalev_num"].(float64)
  1209. if dataBody["text_arr"] != nil && reflect.TypeOf(dataBody["text_arr"]).String() == "[]interface {}" {
  1210. prescriptions, _ := dataBody["text_arr"].([]interface{})
  1211. service.UpdateTextArr(patient_id, user_org_id)
  1212. for _, item := range prescriptions {
  1213. var left float64
  1214. var text_markNum string
  1215. var v_top float64
  1216. var width float64
  1217. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1218. left = item.(map[string]interface{})["left"].(float64)
  1219. }
  1220. if item.(map[string]interface{})["text"] != nil || reflect.TypeOf(item.(map[string]interface{})["text"]).String() == "string" {
  1221. text_markNum = item.(map[string]interface{})["text"].(string)
  1222. }
  1223. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1224. v_top = item.(map[string]interface{})["top"].(float64)
  1225. }
  1226. if item.(map[string]interface{})["width"] != nil || reflect.TypeOf(item.(map[string]interface{})["width"]).String() == "float64" {
  1227. width = item.(map[string]interface{})["width"].(float64)
  1228. }
  1229. textArr := models.XtDeviceValsualTextArr{
  1230. PatientId: patient_id,
  1231. UserOrgId: user_org_id,
  1232. Ctime: time.Now().Unix(),
  1233. Mtime: 0,
  1234. Status: 1,
  1235. Left: left,
  1236. Text: text_markNum,
  1237. Top: v_top,
  1238. Width: width,
  1239. MapId: 0,
  1240. }
  1241. service.CreateTextArr(textArr)
  1242. }
  1243. text_left := dataBody["text_left"].(float64)
  1244. text_num := dataBody["text_num"].(float64)
  1245. text_top := dataBody["text_top"].(float64)
  1246. if dataBody["v_left"] != nil && reflect.TypeOf(dataBody["v_left"]).String() == "[]interface {}" {
  1247. prescriptions, _ := dataBody["v_left"].([]interface{})
  1248. service.UpdateValsualVleft(patient_id, user_org_id)
  1249. for _, item := range prescriptions {
  1250. var v_num float64
  1251. var markNum float64
  1252. if item.(map[string]interface{})["v_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_num"]).String() == "float64" {
  1253. v_num = item.(map[string]interface{})["v_num"].(float64)
  1254. }
  1255. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1256. markNum = item.(map[string]interface{})["mark_num"].(float64)
  1257. }
  1258. valsualVLeft := models.XtDeviceValsualVLeft{
  1259. PatientId: patient_id,
  1260. UserOrgId: user_org_id,
  1261. Status: 1,
  1262. Ctime: time.Now().Unix(),
  1263. Mtime: time.Now().Unix(),
  1264. MarkNum: markNum,
  1265. VNum: v_num,
  1266. MapId: 0,
  1267. }
  1268. service.CreateValsualVleft(valsualVLeft)
  1269. }
  1270. }
  1271. if dataBody["aarr"] != nil && reflect.TypeOf(dataBody["aarr"]).String() == "[]interface {}" {
  1272. prescriptions, _ := dataBody["aarr"].([]interface{})
  1273. service.UpdateValusalMapArr(patient_id, user_org_id)
  1274. for _, item := range prescriptions {
  1275. var mark_num float64
  1276. var is_status float64
  1277. var left float64
  1278. var top float64
  1279. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1280. mark_num = item.(map[string]interface{})["mark_num"].(float64)
  1281. }
  1282. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1283. is_status = item.(map[string]interface{})["is_status"].(float64)
  1284. }
  1285. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1286. left = item.(map[string]interface{})["left"].(float64)
  1287. }
  1288. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1289. top = item.(map[string]interface{})["top"].(float64)
  1290. }
  1291. mapArr := models.XtDeviceValusalMapArr{
  1292. PatientId: patient_id,
  1293. UserOrgId: user_org_id,
  1294. Status: 1,
  1295. MarkNum: mark_num,
  1296. Left: left,
  1297. Top: top,
  1298. IsStatus: is_status,
  1299. Ctime: time.Now().Unix(),
  1300. Mtime: 0,
  1301. }
  1302. service.CreateDeviceValusalMapArr(mapArr)
  1303. }
  1304. }
  1305. if dataBody["varr"] != nil && reflect.TypeOf(dataBody["varr"]).String() == "[]interface {}" {
  1306. prescriptions, _ := dataBody["varr"].([]interface{})
  1307. service.UpdateDeviceValusalMapVrr(patient_id, user_org_id)
  1308. for _, item := range prescriptions {
  1309. var mark_num float64
  1310. var is_status float64
  1311. var left float64
  1312. var top float64
  1313. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1314. mark_num = item.(map[string]interface{})["mark_num"].(float64)
  1315. }
  1316. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1317. is_status = item.(map[string]interface{})["is_status"].(float64)
  1318. }
  1319. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1320. left = item.(map[string]interface{})["left"].(float64)
  1321. }
  1322. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1323. top = item.(map[string]interface{})["top"].(float64)
  1324. }
  1325. mapVrr := models.XtDeviceValusalMapVrr{
  1326. PatientId: patient_id,
  1327. UserOrgId: user_org_id,
  1328. Status: 1,
  1329. MarkNum: mark_num,
  1330. Left: left,
  1331. Top: top,
  1332. IsStatus: is_status,
  1333. Ctime: time.Now().Unix(),
  1334. Mtime: 0,
  1335. }
  1336. service.CreateDeviceValusalMapVrr(mapVrr)
  1337. }
  1338. }
  1339. v_num := dataBody["v_num"].(float64)
  1340. v_top := dataBody["v_top"].(float64)
  1341. xuanzhuan_a := dataBody["xuanzhuan_a"].(float64)
  1342. xuanzhuan_v := dataBody["xuanzhuan_v"].(float64)
  1343. img_url := dataBody["img_url"].(string)
  1344. deviceValsualMap := models.XtDeviceValsualMap{
  1345. ID: id,
  1346. PatientId: patient_id,
  1347. IsAppend: is_append,
  1348. IsImgV: is_img_v,
  1349. IsImgA: is_img_a,
  1350. VNum: v_num,
  1351. Status: 1,
  1352. UserOrgId: user_org_id,
  1353. ATop: a_top,
  1354. AvBkx: av_bkx,
  1355. AvBky: av_bky,
  1356. FangxiangALeft: fangxiang_a_left,
  1357. FangxiangANum: fangxiang_a_num,
  1358. FangxiangATop: fangxiang_a_top,
  1359. FangxiangVLeft: fangxiang_v_left,
  1360. FangxiangVNum: fangxiang_v_num,
  1361. FangxiangVTop: fangxiang_v_top,
  1362. FuzhuALeft: fuzhu_a_left,
  1363. FuzhuANum: fuzhu_a_num,
  1364. FuzhuATop: fuzhu_a_top,
  1365. FuzhuVLeft: fuzhu_v_left,
  1366. FuzhuVNum: fuzhu_v_num,
  1367. FuzhuVTop: fuzhu_v_top,
  1368. ScaleaNum: scalea_num,
  1369. ScalevNum: scalev_num,
  1370. TextLeft: text_left,
  1371. TextNum: text_num,
  1372. TextTop: text_top,
  1373. VTop: v_top,
  1374. XuanzhuanA: xuanzhuan_a,
  1375. XuanzhuanV: xuanzhuan_v,
  1376. ALeft: left_a,
  1377. VLeft: left_v,
  1378. ImgUrl: img_url,
  1379. }
  1380. err = service.CreateDeviceValsualMap(deviceValsualMap)
  1381. this.ServeSuccessJSON(map[string]interface{}{
  1382. "deviceValsualMap": deviceValsualMap,
  1383. })
  1384. }
  1385. }
  1386. func (this *PatientDataConfigAPIController) GetPatientSitemap() {
  1387. patient_id, _ := this.GetInt64("patient_id")
  1388. orgId := this.GetAdminUserInfo().CurrentOrgId
  1389. sitemap, _ := service.GetPatientSitemap(patient_id, orgId)
  1390. patients, _ := service.GetPatientByIDOne(orgId, patient_id)
  1391. this.ServeSuccessJSON(map[string]interface{}{
  1392. "sitemap": sitemap,
  1393. "patients": patients,
  1394. })
  1395. }
  1396. func (this *PatientDataConfigAPIController) GetPatientDetailInformedConsent() {
  1397. patient_id, _ := this.GetInt64("patient_id")
  1398. orgId := this.GetAdminUserInfo().CurrentOrgId
  1399. patients, _ := service.GetPatientDetailInformedConsent(patient_id, orgId)
  1400. this.ServeSuccessJSON(map[string]interface{}{
  1401. "patients": patients,
  1402. })
  1403. }
  1404. func (this *PatientDataConfigAPIController) GetPatientMedicalList() {
  1405. patient_id, _ := this.GetInt64("patient_id")
  1406. orgId := this.GetAdminUserInfo().CurrentOrgId
  1407. list, _ := service.GetPatientMedicalList(patient_id, orgId)
  1408. this.ServeSuccessJSON(map[string]interface{}{
  1409. "list": list,
  1410. })
  1411. }
  1412. func (this *PatientDataConfigAPIController) GetAllNurseList() {
  1413. orgId := this.GetAdminUserInfo().CurrentOrgId
  1414. appId := this.GetAdminUserInfo().CurrentAppId
  1415. nurseList, _ := service.GetAllNurseList(orgId, appId)
  1416. this.ServeSuccessJSON(map[string]interface{}{
  1417. "nurseList": nurseList,
  1418. })
  1419. }
  1420. func (this *PatientDataConfigAPIController) SaveFllassessmentList() {
  1421. dataBody := make(map[string]interface{}, 0)
  1422. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1423. if err != nil {
  1424. utils.ErrorLog(err.Error())
  1425. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1426. return
  1427. }
  1428. }