patient_dataconfig_api_controller.go 55KB

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