patient_dataconfig_api_controller.go 54KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617
  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. }
  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. fangxiang_v_left := dataBody["fangxiang_v_left"].(float64)
  1102. fangxiang_v_num := dataBody["fangxiang_v_num"].(float64)
  1103. fangxiang_v_top := dataBody["fangxiang_v_top"].(float64)
  1104. if dataBody["fangxiang_v"] != nil && reflect.TypeOf(dataBody["fangxiang_v"]).String() == "[]interface {}" {
  1105. prescriptions, _ := dataBody["fangxiang_v"].([]interface{})
  1106. service.UpdateValsualMapFangxiangV(patient_id, user_org_id)
  1107. for _, item := range prescriptions {
  1108. var a_num float64
  1109. var mark_num float64
  1110. var mark_top float64
  1111. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1112. a_num = item.(map[string]interface{})["left"].(float64)
  1113. }
  1114. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1115. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1116. }
  1117. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1118. mark_top = item.(map[string]interface{})["top"].(float64)
  1119. }
  1120. ValsualMapFangxiangV := models.XtDeviceValsualMapFangxiangV{
  1121. PatientId: patient_id,
  1122. UserOrgId: user_org_id,
  1123. Status: 1,
  1124. Left: a_num,
  1125. MarkNum: mark_num,
  1126. Top: mark_top,
  1127. MapId: 0,
  1128. Ctime: time.Now().Unix(),
  1129. Mtime: time.Now().Unix(),
  1130. }
  1131. service.CreateValsualMapFangxiangV(ValsualMapFangxiangV)
  1132. }
  1133. }
  1134. fangxiang_a_left := dataBody["fangxiang_a_left"].(float64)
  1135. if dataBody["fuzhu_a"] != nil && reflect.TypeOf(dataBody["fuzhu_a"]).String() == "[]interface {}" {
  1136. prescriptions, _ := dataBody["fuzhu_a"].([]interface{})
  1137. service.UpdateValSualFuzhA(patient_id, user_org_id)
  1138. for _, item := range prescriptions {
  1139. var a_left float64
  1140. var a_markNum float64
  1141. var a_top float64
  1142. if item.(map[string]interface{})["a_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_left"]).String() == "float64" {
  1143. a_left = item.(map[string]interface{})["a_left"].(float64)
  1144. }
  1145. if item.(map[string]interface{})["a_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_markNum"]).String() == "float64" {
  1146. a_markNum = item.(map[string]interface{})["a_markNum"].(float64)
  1147. }
  1148. if item.(map[string]interface{})["a_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_top"]).String() == "float64" {
  1149. a_top = item.(map[string]interface{})["a_top"].(float64)
  1150. }
  1151. valsualFuzhuA := models.XtDeviceValsualFuzhuA{
  1152. PatientId: patient_id,
  1153. UserOrgId: user_org_id,
  1154. Status: 1,
  1155. Ctime: time.Now().Unix(),
  1156. Mtime: time.Now().Unix(),
  1157. ALeft: a_left,
  1158. AMarkNum: a_markNum,
  1159. ATop: a_top,
  1160. MapId: 0,
  1161. }
  1162. service.CreateValSualFuzhA(valsualFuzhuA)
  1163. }
  1164. }
  1165. fuzhu_a_left := dataBody["fuzhu_a_left"].(float64)
  1166. fuzhu_a_num := dataBody["fuzhu_a_num"].(float64)
  1167. fuzhu_a_top := dataBody["fuzhu_a_top"].(float64)
  1168. left_a := dataBody["left_a"].(float64)
  1169. left_v := dataBody["left_v"].(float64)
  1170. if dataBody["fuzhu_v"] != nil && reflect.TypeOf(dataBody["fuzhu_v"]).String() == "[]interface {}" {
  1171. prescriptions, _ := dataBody["fuzhu_v"].([]interface{})
  1172. service.UpdateVasuaLfuzhuV(patient_id, user_org_id)
  1173. for _, item := range prescriptions {
  1174. var v_left float64
  1175. var v_markNum float64
  1176. var v_top float64
  1177. if item.(map[string]interface{})["v_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_left"]).String() == "float64" {
  1178. v_left = item.(map[string]interface{})["v_left"].(float64)
  1179. }
  1180. if item.(map[string]interface{})["v_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_markNum"]).String() == "float64" {
  1181. v_markNum = item.(map[string]interface{})["v_markNum"].(float64)
  1182. }
  1183. if item.(map[string]interface{})["v_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_top"]).String() == "float64" {
  1184. v_top = item.(map[string]interface{})["v_top"].(float64)
  1185. }
  1186. fuzhuV := models.XtDeviceValsualFuzhuV{
  1187. PatientId: patient_id,
  1188. UserOrgId: user_org_id,
  1189. Status: 1,
  1190. Ctime: time.Now().Unix(),
  1191. Mtime: 1,
  1192. VMarkNum: v_markNum,
  1193. VLeft: v_left,
  1194. VTop: v_top,
  1195. MapId: 0,
  1196. }
  1197. service.CreateVasuaLfuzhuV(fuzhuV)
  1198. }
  1199. }
  1200. fuzhu_v_left := dataBody["fuzhu_v_left"].(float64)
  1201. fuzhu_v_num := dataBody["fuzhu_v_num"].(float64)
  1202. fuzhu_v_top := dataBody["fuzhu_v_top"].(float64)
  1203. scalea_num := dataBody["scalea_num"].(float64)
  1204. scalev_num := dataBody["scalev_num"].(float64)
  1205. if dataBody["text_arr"] != nil && reflect.TypeOf(dataBody["text_arr"]).String() == "[]interface {}" {
  1206. prescriptions, _ := dataBody["text_arr"].([]interface{})
  1207. service.UpdateTextArr(patient_id, user_org_id)
  1208. for _, item := range prescriptions {
  1209. var left float64
  1210. var text_markNum string
  1211. var v_top float64
  1212. var width float64
  1213. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1214. left = item.(map[string]interface{})["left"].(float64)
  1215. }
  1216. if item.(map[string]interface{})["text"] != nil || reflect.TypeOf(item.(map[string]interface{})["text"]).String() == "string" {
  1217. text_markNum = item.(map[string]interface{})["text"].(string)
  1218. }
  1219. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1220. v_top = item.(map[string]interface{})["top"].(float64)
  1221. }
  1222. if item.(map[string]interface{})["width"] != nil || reflect.TypeOf(item.(map[string]interface{})["width"]).String() == "float64" {
  1223. width = item.(map[string]interface{})["width"].(float64)
  1224. }
  1225. textArr := models.XtDeviceValsualTextArr{
  1226. PatientId: patient_id,
  1227. UserOrgId: user_org_id,
  1228. Ctime: time.Now().Unix(),
  1229. Mtime: 0,
  1230. Status: 1,
  1231. Left: left,
  1232. Text: text_markNum,
  1233. Top: v_top,
  1234. Width: width,
  1235. MapId: 0,
  1236. }
  1237. service.CreateTextArr(textArr)
  1238. }
  1239. text_left := dataBody["text_left"].(float64)
  1240. text_num := dataBody["text_num"].(float64)
  1241. text_top := dataBody["text_top"].(float64)
  1242. if dataBody["v_left"] != nil && reflect.TypeOf(dataBody["v_left"]).String() == "[]interface {}" {
  1243. prescriptions, _ := dataBody["v_left"].([]interface{})
  1244. service.UpdateValsualVleft(patient_id, user_org_id)
  1245. for _, item := range prescriptions {
  1246. var v_num float64
  1247. var markNum float64
  1248. if item.(map[string]interface{})["v_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_num"]).String() == "float64" {
  1249. v_num = item.(map[string]interface{})["v_num"].(float64)
  1250. }
  1251. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1252. markNum = item.(map[string]interface{})["mark_num"].(float64)
  1253. }
  1254. valsualVLeft := models.XtDeviceValsualVLeft{
  1255. PatientId: patient_id,
  1256. UserOrgId: user_org_id,
  1257. Status: 1,
  1258. Ctime: time.Now().Unix(),
  1259. Mtime: time.Now().Unix(),
  1260. MarkNum: markNum,
  1261. VNum: v_num,
  1262. MapId: 0,
  1263. }
  1264. service.CreateValsualVleft(valsualVLeft)
  1265. }
  1266. }
  1267. if dataBody["aarr"] != nil && reflect.TypeOf(dataBody["aarr"]).String() == "[]interface {}" {
  1268. prescriptions, _ := dataBody["aarr"].([]interface{})
  1269. service.UpdateValusalMapArr(patient_id, user_org_id)
  1270. for _, item := range prescriptions {
  1271. var mark_num float64
  1272. var is_status float64
  1273. var left float64
  1274. var top float64
  1275. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1276. mark_num = item.(map[string]interface{})["mark_num"].(float64)
  1277. }
  1278. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1279. is_status = item.(map[string]interface{})["is_status"].(float64)
  1280. }
  1281. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1282. left = item.(map[string]interface{})["left"].(float64)
  1283. }
  1284. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1285. top = item.(map[string]interface{})["top"].(float64)
  1286. }
  1287. mapArr := models.XtDeviceValusalMapArr{
  1288. PatientId: patient_id,
  1289. UserOrgId: user_org_id,
  1290. Status: 1,
  1291. MarkNum: mark_num,
  1292. Left: left,
  1293. Top: top,
  1294. IsStatus: is_status,
  1295. Ctime: time.Now().Unix(),
  1296. Mtime: 0,
  1297. }
  1298. service.CreateDeviceValusalMapArr(mapArr)
  1299. }
  1300. }
  1301. if dataBody["varr"] != nil && reflect.TypeOf(dataBody["varr"]).String() == "[]interface {}" {
  1302. prescriptions, _ := dataBody["varr"].([]interface{})
  1303. service.UpdateDeviceValusalMapVrr(patient_id, user_org_id)
  1304. for _, item := range prescriptions {
  1305. var mark_num float64
  1306. var is_status float64
  1307. var left float64
  1308. var top float64
  1309. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1310. mark_num = item.(map[string]interface{})["mark_num"].(float64)
  1311. }
  1312. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1313. is_status = item.(map[string]interface{})["is_status"].(float64)
  1314. }
  1315. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1316. left = item.(map[string]interface{})["left"].(float64)
  1317. }
  1318. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1319. top = item.(map[string]interface{})["top"].(float64)
  1320. }
  1321. mapVrr := models.XtDeviceValusalMapVrr{
  1322. PatientId: patient_id,
  1323. UserOrgId: user_org_id,
  1324. Status: 1,
  1325. MarkNum: mark_num,
  1326. Left: left,
  1327. Top: top,
  1328. IsStatus: is_status,
  1329. Ctime: time.Now().Unix(),
  1330. Mtime: 0,
  1331. }
  1332. service.CreateDeviceValusalMapVrr(mapVrr)
  1333. }
  1334. }
  1335. v_num := dataBody["v_num"].(float64)
  1336. v_top := dataBody["v_top"].(float64)
  1337. xuanzhuan_a := dataBody["xuanzhuan_a"].(float64)
  1338. xuanzhuan_v := dataBody["xuanzhuan_v"].(float64)
  1339. img_url := dataBody["img_url"].(string)
  1340. deviceValsualMap := models.XtDeviceValsualMap{
  1341. ID: id,
  1342. PatientId: patient_id,
  1343. IsAppend: is_append,
  1344. IsImgV: is_img_v,
  1345. IsImgA: is_img_a,
  1346. VNum: v_num,
  1347. Status: 1,
  1348. UserOrgId: user_org_id,
  1349. ATop: a_top,
  1350. AvBkx: av_bkx,
  1351. AvBky: av_bky,
  1352. FangxiangALeft: fangxiang_a_left,
  1353. FangxiangANum: fangxiang_a_num,
  1354. FangxiangATop: fangxiang_a_top,
  1355. FangxiangVLeft: fangxiang_v_left,
  1356. FangxiangVNum: fangxiang_v_num,
  1357. FangxiangVTop: fangxiang_v_top,
  1358. FuzhuALeft: fuzhu_a_left,
  1359. FuzhuANum: fuzhu_a_num,
  1360. FuzhuATop: fuzhu_a_top,
  1361. FuzhuVLeft: fuzhu_v_left,
  1362. FuzhuVNum: fuzhu_v_num,
  1363. FuzhuVTop: fuzhu_v_top,
  1364. ScaleaNum: scalea_num,
  1365. ScalevNum: scalev_num,
  1366. TextLeft: text_left,
  1367. TextNum: text_num,
  1368. TextTop: text_top,
  1369. VTop: v_top,
  1370. XuanzhuanA: xuanzhuan_a,
  1371. XuanzhuanV: xuanzhuan_v,
  1372. ALeft: left_a,
  1373. VLeft: left_v,
  1374. ImgUrl: img_url,
  1375. }
  1376. err = service.CreateDeviceValsualMap(deviceValsualMap)
  1377. this.ServeSuccessJSON(map[string]interface{}{
  1378. "deviceValsualMap": deviceValsualMap,
  1379. })
  1380. }
  1381. }
  1382. func (this *PatientDataConfigAPIController) GetPatientSitemap() {
  1383. patient_id, _ := this.GetInt64("patient_id")
  1384. orgId := this.GetAdminUserInfo().CurrentOrgId
  1385. sitemap, _ := service.GetPatientSitemap(patient_id, orgId)
  1386. patients, _ := service.GetPatientByIDOne(orgId, patient_id)
  1387. this.ServeSuccessJSON(map[string]interface{}{
  1388. "sitemap": sitemap,
  1389. "patients": patients,
  1390. })
  1391. }
  1392. func (this *PatientDataConfigAPIController) GetPatientDetailInformedConsent() {
  1393. patient_id, _ := this.GetInt64("patient_id")
  1394. orgId := this.GetAdminUserInfo().CurrentOrgId
  1395. patients, _ := service.GetPatientDetailInformedConsent(patient_id, orgId)
  1396. this.ServeSuccessJSON(map[string]interface{}{
  1397. "patients": patients,
  1398. })
  1399. }