patient_dataconfig_api_controller.go 59KB

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