patient_dataconfig_api_controller.go 104KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "encoding/json"
  8. "fmt"
  9. "reflect"
  10. "strconv"
  11. "strings"
  12. "time"
  13. "github.com/astaxie/beego"
  14. )
  15. func PatientDataConfigAPIControllerRegistRouters() {
  16. beego.Router("/api/patient/courses", &PatientDataConfigAPIController{}, "get:Courses")
  17. beego.Router("/api/patient/course/create", &PatientDataConfigAPIController{}, "get:CreateCourse")
  18. beego.Router("/api/patient/course/delete", &PatientDataConfigAPIController{}, "post:DeleteCourse")
  19. beego.Router("/api/patient/course/modify", &PatientDataConfigAPIController{}, "get:ModifyCourse")
  20. beego.Router("/api/patient/rescues", &PatientDataConfigAPIController{}, "get:Rescues")
  21. beego.Router("/api/patient/rescue/create", &PatientDataConfigAPIController{}, "post:CreateRescue")
  22. beego.Router("/api/patient/rescue/delete", &PatientDataConfigAPIController{}, "post:DeleteRescue")
  23. beego.Router("/api/patient/sickhistory", &PatientDataConfigAPIController{}, "get:GetSickHistorys")
  24. beego.Router("/api/patient/sickhistory/create", &PatientDataConfigAPIController{}, "get:CreateSickHistory")
  25. beego.Router("/api/patient/sickhistory/delete", &PatientDataConfigAPIController{}, "post:DeleteSickHistory")
  26. beego.Router("/api/patient/sickhistory/modify", &PatientDataConfigAPIController{}, "get:ModifySickHistory")
  27. beego.Router("/api/patient/physiquecheck", &PatientDataConfigAPIController{}, "get:GetPhysiqueChecks")
  28. beego.Router("/api/patient/physiquecheck/create", &PatientDataConfigAPIController{}, "get:CreatePhysiqueCheck")
  29. beego.Router("/api/patient/physiquecheck/delete", &PatientDataConfigAPIController{}, "post:DeletePhysiqueCheck")
  30. beego.Router("/api/patient/physiquecheck/modify", &PatientDataConfigAPIController{}, "get:ModifyPhysiqueCheck")
  31. beego.Router("/api/patient/sickhistory/print", &PatientDataConfigAPIController{}, "get:GetSickhistoryPrints")
  32. beego.Router("/api/patient/physiquecheck/print", &PatientDataConfigAPIController{}, "get:GetPhysiquecheckPrints")
  33. beego.Router("/api/patient/getpatientdialysisinforlist", &PatientDataConfigAPIController{}, "get:GetPatientDialysisInforList")
  34. beego.Router("/api/patient/getcontextschedulelist", &PatientDataConfigAPIController{}, "Get:GetContextScheduleList")
  35. beego.Router("/api/patient/getpatientallagic", &PatientDataConfigAPIController{}, "Get:GetPatientAllagicList")
  36. beego.Router("/api/patient/savesitemap", &PatientDataConfigAPIController{}, "Post:SaveSiteMap")
  37. beego.Router("/api/patient/getpatientsitemap", &PatientDataConfigAPIController{}, "Get:GetPatientSitemap")
  38. beego.Router("/api/patient/getpatientdetailinformedconsent", &PatientDataConfigAPIController{}, "Get:GetPatientDetailInformedConsent")
  39. beego.Router("/api/patient/getpatientmedicallist", &PatientDataConfigAPIController{}, "Get:GetPatientMedicalList")
  40. //评估工具的接口
  41. beego.Router("/api/patient/fallassement/getallnurselist", &PatientDataConfigAPIController{}, "Get:GetAllNurseList")
  42. beego.Router("/api/patient/fallassment/savefllassessmentlist", &PatientDataConfigAPIController{}, "Post:SaveFllassessmentList")
  43. beego.Router("/api/patient/getpatientfallsessmentlist", &PatientDataConfigAPIController{}, "Get:GetPatientFallsessMentList")
  44. beego.Router("/api/patient/getpatientfallssessmentById", &PatientDataConfigAPIController{}, "Get:GetPatientFallsessmentById")
  45. beego.Router("/api/patient/deletepatientfallassessment", &PatientDataConfigAPIController{}, "Get:DeletePatientFallsessment")
  46. beego.Router("/api/patient/updatepatientfallassment", &PatientDataConfigAPIController{}, "Post:UpdatePatientFallassment")
  47. beego.Router("/api/patient/savepediatrcfallassesment", &PatientDataConfigAPIController{}, "Post:SavePediatrcFallassment")
  48. beego.Router("/api/patient/getbeddiatricfallassessmentlist", &PatientDataConfigAPIController{}, "Get:GetBedDiatricFallassessmentList")
  49. beego.Router("/api/patient/getpedpatientfallassessmentbyid", &PatientDataConfigAPIController{}, "Get:GetPedPatientFallassessmentById")
  50. beego.Router("/api/patient/updatepatientfallassessmentbyid", &PatientDataConfigAPIController{}, "Post:UpdatePedPatientFallassessment")
  51. beego.Router("/api/patient/deletepedpatientfallassment", &PatientDataConfigAPIController{}, "Get:DeletePadPatientFallassment")
  52. beego.Router("/api/patient/savepatientpressuresore", &PatientDataConfigAPIController{}, "Post:SavePatientPressuresore")
  53. beego.Router("/api/patient/savepatienthpressuresore", &PatientDataConfigAPIController{}, "Post:SavePatientHpPressuresore")
  54. beego.Router("/api/patient/getpatientbedlist", &PatientDataConfigAPIController{}, "Get:GetPatientBedList")
  55. beego.Router("/api/patient/updatebedpatientlist", &PatientDataConfigAPIController{}, "Post:UpdateBedPatientList")
  56. }
  57. type PatientDataConfigAPIController struct {
  58. BaseAuthAPIController
  59. }
  60. func (this *PatientDataConfigAPIController) GetPhysiquecheckPrints() {
  61. patientID, _ := this.GetInt64("patient_id")
  62. idsStr := this.GetString("ids")
  63. if patientID <= 0 || len(idsStr) == 0 {
  64. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  65. return
  66. }
  67. recordIDStrs := strings.Split(idsStr, ",")
  68. patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
  69. sickHostory, _ := service.GetPatienttPhysiqueByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
  70. this.ServeSuccessJSON(map[string]interface{}{
  71. "patient": patient,
  72. "sickhistorys": sickHostory,
  73. })
  74. }
  75. func (this *PatientDataConfigAPIController) GetSickhistoryPrints() {
  76. patientID, _ := this.GetInt64("patient_id")
  77. idsStr := this.GetString("ids")
  78. if patientID <= 0 || len(idsStr) == 0 {
  79. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  80. return
  81. }
  82. recordIDStrs := strings.Split(idsStr, ",")
  83. patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
  84. sickHostory, _ := service.GetPatientSickHistoryByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
  85. for _, item := range sickHostory {
  86. pc, _ := service.GetLastPatientPhysiqueCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientId, item.RecordDate)
  87. item.XtPatientPhysiqueCheck = pc
  88. }
  89. this.ServeSuccessJSON(map[string]interface{}{
  90. "patient": patient,
  91. "sickhistorys": sickHostory,
  92. })
  93. }
  94. func (this *PatientDataConfigAPIController) GetSickHistorys() {
  95. patientID, _ := this.GetInt64("patient_id")
  96. startTimeYMDStr := this.GetString("start_time")
  97. endTimeYMDStr := this.GetString("end_time")
  98. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  99. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  100. return
  101. }
  102. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  103. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  104. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  105. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  106. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  107. return
  108. }
  109. adminUserInfo := this.GetAdminUserInfo()
  110. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  111. if getPatientErr != nil {
  112. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  113. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  114. return
  115. } else if patient == nil {
  116. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  117. return
  118. }
  119. records, getRecordsErr := service.GetPatientSickHistory(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  120. if getRecordsErr != nil {
  121. this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
  122. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  123. return
  124. }
  125. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  126. if getAllAdminsErr != nil {
  127. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  128. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  129. return
  130. }
  131. this.ServeSuccessJSON(map[string]interface{}{
  132. "records": records,
  133. "doctors": admins,
  134. })
  135. }
  136. func (this *PatientDataConfigAPIController) CreateSickHistory() {
  137. patientID, _ := this.GetInt64("patient_id")
  138. content := this.GetString("content")
  139. record_time_str := this.GetString("record_time")
  140. title := this.GetString("title")
  141. is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
  142. is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
  143. is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
  144. guominyaowu_desc := this.GetString("guominyaowu_desc")
  145. doctor_id, _ := this.GetInt64("doctor_id")
  146. if patientID <= 0 || len(content) == 0 {
  147. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  148. return
  149. }
  150. if len(record_time_str) == 0 {
  151. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  152. return
  153. }
  154. record_date := strings.Split(record_time_str, " ")
  155. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  156. checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
  157. adminUserInfo := this.GetAdminUserInfo()
  158. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  159. if getPatientErr != nil {
  160. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  161. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  162. return
  163. } else if patient == nil {
  164. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  165. return
  166. }
  167. now := time.Now().Unix()
  168. record := models.XtPatientSickHistory{
  169. OrgId: adminUserInfo.CurrentOrgId,
  170. PatientId: patientID,
  171. Recorder: adminUserInfo.AdminUser.Id,
  172. RecordTime: checkDate.Unix(),
  173. Content: content,
  174. Status: 1,
  175. Title: title,
  176. IsShenyizhiHistory: is_shenyizhishi,
  177. IsFumoDialysisHistory: is_fumotouxishi,
  178. HypersusceptibilityDesc: guominyaowu_desc,
  179. IsHypersusceptibility: is_guominyaowu,
  180. Ctime: now,
  181. Mtime: now,
  182. DoctorId: doctor_id,
  183. RecordDate: checkDate_two.Unix(),
  184. }
  185. createErr := service.CreatePatientSickHistory(&record)
  186. if createErr != nil {
  187. this.ErrorLog("创建患者病史记录失败:%v", createErr)
  188. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  189. return
  190. }
  191. this.ServeSuccessJSON(map[string]interface{}{
  192. "record": record,
  193. })
  194. }
  195. func (this *PatientDataConfigAPIController) DeleteSickHistory() {
  196. patientID, _ := this.GetInt64("patient_id")
  197. idsStr := this.GetString("ids")
  198. if patientID <= 0 || len(idsStr) == 0 {
  199. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  200. return
  201. }
  202. adminUserInfo := this.GetAdminUserInfo()
  203. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  204. if getPatientErr != nil {
  205. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  206. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  207. return
  208. } else if patient == nil {
  209. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  210. return
  211. }
  212. recordIDStrs := strings.Split(idsStr, ",")
  213. recordIDs := make([]int64, 0, len(recordIDStrs))
  214. for _, idStr := range recordIDStrs {
  215. id, parseErr := strconv.Atoi(idStr)
  216. if parseErr != nil {
  217. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  218. return
  219. }
  220. recordIDs = append(recordIDs, int64(id))
  221. }
  222. deleteErr := service.DeletePatientSickHistoryInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  223. if deleteErr != nil {
  224. this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
  225. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  226. return
  227. }
  228. this.ServeSuccessJSON(nil)
  229. }
  230. func (this *PatientDataConfigAPIController) ModifySickHistory() {
  231. patientID, _ := this.GetInt64("patient_id")
  232. content := this.GetString("content")
  233. id, _ := this.GetInt64("id", 0)
  234. record_time_str := this.GetString("record_time")
  235. title := this.GetString("title")
  236. is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
  237. is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
  238. is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
  239. guominyaowu_desc := this.GetString("guominyaowu_desc")
  240. doctor_id, _ := this.GetInt64("doctor_id")
  241. if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
  242. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  243. return
  244. }
  245. //timeLayout := "2006-01-02"
  246. //loc, _ := time.LoadLocation("Local")
  247. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  248. fmt.Println("checkDate--------------", checkDate)
  249. adminUserInfo := this.GetAdminUserInfo()
  250. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  251. if getPatientErr != nil {
  252. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  253. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  254. return
  255. } else if patient == nil {
  256. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  257. return
  258. }
  259. now := time.Now().Unix()
  260. record := models.XtPatientSickHistory{
  261. ID: id,
  262. OrgId: adminUserInfo.CurrentOrgId,
  263. PatientId: patientID,
  264. Recorder: adminUserInfo.AdminUser.Id,
  265. Content: content,
  266. Status: 1,
  267. Ctime: now,
  268. Mtime: now,
  269. Title: title,
  270. RecordTime: checkDate.Unix(),
  271. IsShenyizhiHistory: is_shenyizhishi,
  272. IsFumoDialysisHistory: is_fumotouxishi,
  273. HypersusceptibilityDesc: guominyaowu_desc,
  274. IsHypersusceptibility: is_guominyaowu,
  275. DoctorId: doctor_id,
  276. }
  277. createErr := service.ModifyPatientSickHistory(&record)
  278. if createErr != nil {
  279. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  280. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  281. return
  282. }
  283. this.ServeSuccessJSON(map[string]interface{}{
  284. "record": record,
  285. })
  286. }
  287. func (this *PatientDataConfigAPIController) GetPhysiqueChecks() {
  288. patientID, _ := this.GetInt64("patient_id")
  289. startTimeYMDStr := this.GetString("start_time")
  290. endTimeYMDStr := this.GetString("end_time")
  291. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  292. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  293. return
  294. }
  295. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  296. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  297. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  298. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  299. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  300. return
  301. }
  302. adminUserInfo := this.GetAdminUserInfo()
  303. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  304. if getPatientErr != nil {
  305. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  306. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  307. return
  308. } else if patient == nil {
  309. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  310. return
  311. }
  312. records, getRecordsErr := service.GetPatientPhysiqueCheck(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  313. if getRecordsErr != nil {
  314. this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
  315. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  316. return
  317. }
  318. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  319. if getAllAdminsErr != nil {
  320. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  321. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  322. return
  323. }
  324. this.ServeSuccessJSON(map[string]interface{}{
  325. "records": records,
  326. "doctors": admins,
  327. })
  328. }
  329. func (this *PatientDataConfigAPIController) CreatePhysiqueCheck() {
  330. patientID, _ := this.GetInt64("patient_id")
  331. doctor_id, _ := this.GetInt64("doctor_id")
  332. record_time_str := this.GetString("record_time")
  333. t := this.GetString("t")
  334. p := this.GetString("p")
  335. r := this.GetString("r")
  336. bp_left := this.GetString("bp_left")
  337. bp_right := this.GetString("bp_right")
  338. pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
  339. tiwei, _ := this.GetInt64("tiwei")
  340. fuzhong, _ := this.GetInt64("fuzhong")
  341. chuxuedian, _ := this.GetInt64("chuxuedian")
  342. fayu, _ := this.GetInt64("fayu")
  343. yinyang, _ := this.GetInt64("yinyang")
  344. shenzhi, _ := this.GetInt64("shenzhi")
  345. pifunianmo, _ := this.GetInt64("pifunianmo")
  346. buwei := this.GetString("buwei")
  347. chengdu := this.GetString("chengdu")
  348. pixiachuxue, _ := this.GetInt64("pixiachuxue")
  349. zidian, _ := this.GetInt64("zidian")
  350. pifuwendu, _ := this.GetInt64("pifuwendu")
  351. qita := this.GetString("qita")
  352. linbazhongda, _ := this.GetInt64("linbazhongda")
  353. linbabuwei := this.GetString("linbabuwei")
  354. yanlian, _ := this.GetInt64("yanlian")
  355. tongkong, _ := this.GetInt64("tongkong")
  356. zuo := this.GetString("zuo")
  357. you := this.GetString("you")
  358. duiguangfanshe := this.GetString("duiguangfanshe")
  359. biantaoti := this.GetString("biantaoti")
  360. yanbu := this.GetString("yanbu")
  361. toubuqita := this.GetString("toubuqita")
  362. huxiyin := this.GetString("huxiyin")
  363. xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
  364. feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
  365. luoyin, _ := this.GetInt64("luoyin")
  366. desc := this.GetString("desc")
  367. xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
  368. xinlv, _ := this.GetInt64("xinlv")
  369. xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
  370. zayin, _ := this.GetInt64("zayin")
  371. fujiayin, _ := this.GetInt64("fujiayin")
  372. xinzangdesc := this.GetString("xinzangdesc")
  373. fushuizheng, _ := this.GetInt64("fushuizheng")
  374. ganjingjingmai := this.GetString("ganjingjingmai")
  375. gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
  376. gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
  377. pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
  378. pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
  379. shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
  380. shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
  381. fubu_desc := this.GetString("fubu_desc")
  382. oth_desc := this.GetString("oth_desc")
  383. if patientID <= 0 {
  384. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  385. return
  386. }
  387. if len(record_time_str) == 0 {
  388. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  389. return
  390. }
  391. record_date := strings.Split(record_time_str, " ")
  392. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  393. checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
  394. adminUserInfo := this.GetAdminUserInfo()
  395. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  396. if getPatientErr != nil {
  397. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  398. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  399. return
  400. } else if patient == nil {
  401. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  402. return
  403. }
  404. now := time.Now().Unix()
  405. record := models.XtPatientPhysiqueCheck{
  406. DoctorId: doctor_id,
  407. OrgId: adminUserInfo.CurrentOrgId,
  408. PatientId: patientID,
  409. Recorder: adminUserInfo.AdminUser.Id,
  410. RecordTime: checkDate.Unix(),
  411. Status: 1,
  412. Ctime: now,
  413. Mtime: now,
  414. T: t,
  415. P: p,
  416. R: r,
  417. BpRight: bp_right,
  418. BpLeft: bp_left,
  419. Pinxuerongmao: pinxuerongmao,
  420. Tiwei: tiwei,
  421. Fuzhong: fuzhong,
  422. Chuxuedian: chuxuedian,
  423. Fayu: fayu,
  424. Yinyang: yinyang,
  425. Shenzhi: shenzhi,
  426. Pifunianmo: pifunianmo,
  427. Buwei: buwei,
  428. Chengdu: chengdu,
  429. Pixiachuxue: pixiachuxue,
  430. Zidian: zidian,
  431. Pifuwendu: pifuwendu,
  432. Qita: qita,
  433. Linbazhongda: linbazhongda,
  434. Linbabuwei: linbabuwei,
  435. Yanlian: yanlian,
  436. Tongkong: tongkong,
  437. Zuo: zuo,
  438. You: you,
  439. Duiguangfanshe: duiguangfanshe,
  440. Biantaoti: biantaoti,
  441. Yanbu: yanbu,
  442. Toubuqita: toubuqita,
  443. Huxiyin: huxiyin,
  444. Xiongmomocayin: xiongmomocayin,
  445. Feizhangbuwei: feizhangbuwei,
  446. Luoyin: luoyin,
  447. Desc: desc,
  448. Xinzangdaxiao: xinzangdaxiao,
  449. Xinlv: xinlv,
  450. Xinbaomocasheng: xinbaomocasheng,
  451. Zayin: zayin,
  452. Fujiayin: fujiayin,
  453. Xinzangdesc: xinzangdesc,
  454. Fushuizheng: fushuizheng,
  455. Ganjingjingmai: ganjingjingmai,
  456. GangzhangYatong: gangzhang_yatong,
  457. GangzhangKoutong: gangzhang_koutong,
  458. PizhangKoutong: pizhang_koutong,
  459. PizhangYatong: pizhang_yatong,
  460. ShenzhangKoutong: shenzhang_koutong,
  461. ShenzhangYatong: shenzhang_yatong,
  462. FubuDesc: fubu_desc,
  463. OthDesc: oth_desc,
  464. RecordDate: checkDate_two.Unix(),
  465. }
  466. createErr := service.CreatePatientPhysiqueCheck(&record)
  467. if createErr != nil {
  468. this.ErrorLog("创建患者病史记录失败:%v", createErr)
  469. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  470. return
  471. }
  472. this.ServeSuccessJSON(map[string]interface{}{
  473. "record": record,
  474. })
  475. }
  476. func (this *PatientDataConfigAPIController) DeletePhysiqueCheck() {
  477. patientID, _ := this.GetInt64("patient_id")
  478. idsStr := this.GetString("ids")
  479. if patientID <= 0 || len(idsStr) == 0 {
  480. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  481. return
  482. }
  483. adminUserInfo := this.GetAdminUserInfo()
  484. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  485. if getPatientErr != nil {
  486. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  487. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  488. return
  489. } else if patient == nil {
  490. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  491. return
  492. }
  493. recordIDStrs := strings.Split(idsStr, ",")
  494. recordIDs := make([]int64, 0, len(recordIDStrs))
  495. for _, idStr := range recordIDStrs {
  496. id, parseErr := strconv.Atoi(idStr)
  497. if parseErr != nil {
  498. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  499. return
  500. }
  501. recordIDs = append(recordIDs, int64(id))
  502. }
  503. deleteErr := service.DeletePatientPhysiqueCheckInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  504. if deleteErr != nil {
  505. this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
  506. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  507. return
  508. }
  509. this.ServeSuccessJSON(nil)
  510. }
  511. func (this *PatientDataConfigAPIController) ModifyPhysiqueCheck() {
  512. patientID, _ := this.GetInt64("patient_id")
  513. id, _ := this.GetInt64("id", 0)
  514. doctor_id, _ := this.GetInt64("doctor_id", 0)
  515. record_time_str := this.GetString("record_time")
  516. if patientID <= 0 || id == 0 || len(record_time_str) == 0 {
  517. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  518. return
  519. }
  520. t := this.GetString("t")
  521. p := this.GetString("p")
  522. r := this.GetString("r")
  523. bp_left := this.GetString("bp_left")
  524. bp_right := this.GetString("bp_right")
  525. pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
  526. tiwei, _ := this.GetInt64("tiwei")
  527. fuzhong, _ := this.GetInt64("fuzhong")
  528. chuxuedian, _ := this.GetInt64("chuxuedian")
  529. fayu, _ := this.GetInt64("fayu")
  530. yinyang, _ := this.GetInt64("yinyang")
  531. shenzhi, _ := this.GetInt64("shenzhi")
  532. pifunianmo, _ := this.GetInt64("pifunianmo")
  533. buwei := this.GetString("buwei")
  534. chengdu := this.GetString("chengdu")
  535. pixiachuxue, _ := this.GetInt64("pixiachuxue")
  536. zidian, _ := this.GetInt64("zidian")
  537. pifuwendu, _ := this.GetInt64("pifuwendu")
  538. qita := this.GetString("qita")
  539. linbazhongda, _ := this.GetInt64("linbazhongda")
  540. linbabuwei := this.GetString("linbabuwei")
  541. yanlian, _ := this.GetInt64("yanlian")
  542. tongkong, _ := this.GetInt64("tongkong")
  543. zuo := this.GetString("zuo")
  544. you := this.GetString("you")
  545. duiguangfanshe := this.GetString("duiguangfanshe")
  546. biantaoti := this.GetString("biantaoti")
  547. yanbu := this.GetString("yanbu")
  548. toubuqita := this.GetString("toubuqita")
  549. huxiyin := this.GetString("huxiyin")
  550. xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
  551. feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
  552. luoyin, _ := this.GetInt64("luoyin")
  553. desc := this.GetString("desc")
  554. xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
  555. xinlv, _ := this.GetInt64("xinlv")
  556. xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
  557. zayin, _ := this.GetInt64("zayin")
  558. fujiayin, _ := this.GetInt64("fujiayin")
  559. xinzangdesc := this.GetString("xinzangdesc")
  560. fushuizheng, _ := this.GetInt64("fushuizheng")
  561. ganjingjingmai := this.GetString("ganjingjingmai")
  562. gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
  563. gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
  564. pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
  565. pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
  566. shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
  567. shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
  568. fubu_desc := this.GetString("fubu_desc")
  569. oth_desc := this.GetString("oth_desc")
  570. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  571. adminUserInfo := this.GetAdminUserInfo()
  572. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  573. if getPatientErr != nil {
  574. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  575. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  576. return
  577. } else if patient == nil {
  578. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  579. return
  580. }
  581. now := time.Now().Unix()
  582. record := models.XtPatientPhysiqueCheck{
  583. ID: id,
  584. OrgId: adminUserInfo.CurrentOrgId,
  585. PatientId: patientID,
  586. Recorder: adminUserInfo.AdminUser.Id,
  587. RecordTime: checkDate.Unix(),
  588. DoctorId: doctor_id,
  589. Status: 1,
  590. Ctime: now,
  591. Mtime: now,
  592. T: t,
  593. P: p,
  594. R: r,
  595. BpRight: bp_right,
  596. BpLeft: bp_left,
  597. Pinxuerongmao: pinxuerongmao,
  598. Tiwei: tiwei,
  599. Fuzhong: fuzhong,
  600. Chuxuedian: chuxuedian,
  601. Fayu: fayu,
  602. Yinyang: yinyang,
  603. Shenzhi: shenzhi,
  604. Pifunianmo: pifunianmo,
  605. Buwei: buwei,
  606. Chengdu: chengdu,
  607. Pixiachuxue: pixiachuxue,
  608. Zidian: zidian,
  609. Pifuwendu: pifuwendu,
  610. Qita: qita,
  611. Linbazhongda: linbazhongda,
  612. Linbabuwei: linbabuwei,
  613. Yanlian: yanlian,
  614. Tongkong: tongkong,
  615. Zuo: zuo,
  616. You: you,
  617. Duiguangfanshe: duiguangfanshe,
  618. Biantaoti: biantaoti,
  619. Yanbu: yanbu,
  620. Toubuqita: toubuqita,
  621. Huxiyin: huxiyin,
  622. Xiongmomocayin: xiongmomocayin,
  623. Feizhangbuwei: feizhangbuwei,
  624. Luoyin: luoyin,
  625. Desc: desc,
  626. Xinzangdaxiao: xinzangdaxiao,
  627. Xinlv: xinlv,
  628. Xinbaomocasheng: xinbaomocasheng,
  629. Zayin: zayin,
  630. Fujiayin: fujiayin,
  631. Xinzangdesc: xinzangdesc,
  632. Fushuizheng: fushuizheng,
  633. Ganjingjingmai: ganjingjingmai,
  634. GangzhangYatong: gangzhang_yatong,
  635. GangzhangKoutong: gangzhang_koutong,
  636. PizhangKoutong: pizhang_koutong,
  637. PizhangYatong: pizhang_yatong,
  638. ShenzhangKoutong: shenzhang_koutong,
  639. ShenzhangYatong: shenzhang_yatong,
  640. FubuDesc: fubu_desc,
  641. OthDesc: oth_desc,
  642. }
  643. createErr := service.ModifyPatientPhysiqueCheck(&record)
  644. if createErr != nil {
  645. this.ErrorLog("修改患者体格检查失败:%v", createErr)
  646. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. this.ServeSuccessJSON(map[string]interface{}{
  650. "record": record,
  651. })
  652. }
  653. // /api/patient/courses [get]
  654. // @param patient_id:int
  655. // @param start_time:string (yyyy-MM-dd)
  656. // @param end_time:string (yyyy-MM-dd)
  657. func (this *PatientDataConfigAPIController) Courses() {
  658. timeLayout := "2006-01-02"
  659. loc, _ := time.LoadLocation("Local")
  660. patientID, _ := this.GetInt64("patient_id")
  661. start_time := this.GetString("start_time")
  662. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  663. startime := dischargeTimes.Unix()
  664. end_time := this.GetString("end_time")
  665. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  666. endtime := endTimes.Unix()
  667. adminUserInfo := this.GetAdminUserInfo()
  668. records, getRecordsErr := service.GetPatientCourseOfDisease(adminUserInfo.CurrentOrgId, patientID, startime, endtime)
  669. if getRecordsErr != nil {
  670. this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
  671. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  672. return
  673. }
  674. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  675. if getAllAdminsErr != nil {
  676. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  677. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  678. return
  679. }
  680. this.ServeSuccessJSON(map[string]interface{}{
  681. "records": records,
  682. "doctors": admins,
  683. })
  684. }
  685. // /api/patient/course/create [post]
  686. // @param patient_id:int
  687. // @param content:string
  688. func (this *PatientDataConfigAPIController) CreateCourse() {
  689. patientID, _ := this.GetInt64("patient_id")
  690. fmt.Println(patientID)
  691. content := this.GetString("content")
  692. record_time_str := this.GetString("record_time")
  693. title := this.GetString("title")
  694. if patientID <= 0 || len(content) == 0 {
  695. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  696. return
  697. }
  698. if len(record_time_str) == 0 {
  699. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  700. return
  701. }
  702. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  703. adminUserInfo := this.GetAdminUserInfo()
  704. //patient, _ := service.GetPatientByIDOne(adminUserInfo.CurrentOrgId, patientID)
  705. //if getPatientErr != nil {
  706. // this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  707. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  708. // return
  709. //} else if patient == nil {
  710. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  711. // return
  712. //}
  713. now := time.Now().Unix()
  714. record := models.PatientDiseaseCourse{
  715. OrgID: adminUserInfo.CurrentOrgId,
  716. PatientID: patientID,
  717. Recorder: adminUserInfo.AdminUser.Id,
  718. RecordTime: checkDate.Unix(),
  719. Content: content,
  720. Status: 1,
  721. CreateTime: now,
  722. ModifyTime: now,
  723. Title: title,
  724. }
  725. createErr := service.CreatePatientCourseOfDisease(&record)
  726. if createErr != nil {
  727. this.ErrorLog("创建患者病程记录失败:%v", createErr)
  728. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  729. return
  730. }
  731. this.ServeSuccessJSON(map[string]interface{}{
  732. "record": record,
  733. })
  734. }
  735. // /api/patient/course/delete
  736. // @param patient_id:int
  737. // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
  738. func (this *PatientDataConfigAPIController) DeleteCourse() {
  739. patientID, _ := this.GetInt64("patient_id")
  740. idsStr := this.GetString("ids")
  741. if patientID <= 0 || len(idsStr) == 0 {
  742. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  743. return
  744. }
  745. adminUserInfo := this.GetAdminUserInfo()
  746. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  747. if getPatientErr != nil {
  748. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  749. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  750. return
  751. } else if patient == nil {
  752. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  753. return
  754. }
  755. recordIDStrs := strings.Split(idsStr, ",")
  756. recordIDs := make([]int64, 0, len(recordIDStrs))
  757. for _, idStr := range recordIDStrs {
  758. id, parseErr := strconv.Atoi(idStr)
  759. if parseErr != nil {
  760. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  761. return
  762. }
  763. recordIDs = append(recordIDs, int64(id))
  764. }
  765. deleteErr := service.DeletePatientCoursesInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  766. if deleteErr != nil {
  767. this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
  768. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  769. return
  770. }
  771. this.ServeSuccessJSON(nil)
  772. }
  773. // /api/patient/rescues [get]
  774. // @param patient_id:int
  775. // @param start_time:string (yyyy-MM-dd)
  776. // @param end_time:string (yyyy-MM-dd)
  777. func (this *PatientDataConfigAPIController) Rescues() {
  778. timeLayout := "2006-01-02"
  779. loc, _ := time.LoadLocation("Local")
  780. patientID, _ := this.GetInt64("patient_id")
  781. start_time := this.GetString("start_time")
  782. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  783. startime := dischargeTimes.Unix()
  784. end_time := this.GetString("end_time")
  785. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  786. endtime := endTimes.Unix()
  787. adminUserInfo := this.GetAdminUserInfo()
  788. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  789. if getPatientErr != nil {
  790. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  791. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  792. return
  793. } else if patient == nil {
  794. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  795. return
  796. }
  797. records, getRecordsErr := service.GetPatientRescueRecords(adminUserInfo.CurrentOrgId, patientID, startime, endtime)
  798. if getRecordsErr != nil {
  799. this.ErrorLog("获取患者抢救记录失败:%v", getRecordsErr)
  800. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  801. return
  802. }
  803. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  804. if getAllAdminsErr != nil {
  805. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  806. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. this.ServeSuccessJSON(map[string]interface{}{
  810. "records": records,
  811. "doctors": admins,
  812. })
  813. }
  814. // /api/patient/rescue/create [post]
  815. // @param patient_id:int
  816. // @param content:string
  817. func (this *PatientDataConfigAPIController) CreateRescue() {
  818. patientID, _ := this.GetInt64("patient_id")
  819. content := this.GetString("content")
  820. if patientID <= 0 || len(content) == 0 {
  821. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  822. return
  823. }
  824. adminUserInfo := this.GetAdminUserInfo()
  825. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  826. if getPatientErr != nil {
  827. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  828. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  829. return
  830. } else if patient == nil {
  831. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  832. return
  833. }
  834. now := time.Now().Unix()
  835. record := models.PatientRescueRecord{
  836. OrgID: adminUserInfo.CurrentOrgId,
  837. PatientID: patientID,
  838. Recorder: adminUserInfo.AdminUser.Id,
  839. RecordTime: now,
  840. Content: content,
  841. Status: 1,
  842. CreateTime: now,
  843. ModifyTime: now,
  844. }
  845. createErr := service.CreatePatientRescueRecord(&record)
  846. if createErr != nil {
  847. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  848. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  849. return
  850. }
  851. this.ServeSuccessJSON(map[string]interface{}{
  852. "record": record,
  853. })
  854. }
  855. // /api/patient/rescue/delete
  856. // @param patient_id:int
  857. // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
  858. func (this *PatientDataConfigAPIController) DeleteRescue() {
  859. patientID, _ := this.GetInt64("patient_id")
  860. idsStr := this.GetString("ids")
  861. if patientID <= 0 || len(idsStr) == 0 {
  862. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  863. return
  864. }
  865. adminUserInfo := this.GetAdminUserInfo()
  866. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  867. if getPatientErr != nil {
  868. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  869. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  870. return
  871. } else if patient == nil {
  872. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  873. return
  874. }
  875. recordIDStrs := strings.Split(idsStr, ",")
  876. recordIDs := make([]int64, 0, len(recordIDStrs))
  877. for _, idStr := range recordIDStrs {
  878. id, parseErr := strconv.Atoi(idStr)
  879. if parseErr != nil {
  880. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  881. return
  882. }
  883. recordIDs = append(recordIDs, int64(id))
  884. }
  885. deleteErr := service.DeletePatientResuceRecordsInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  886. if deleteErr != nil {
  887. this.ErrorLog("删除患者抢救记录失败:%v", deleteErr)
  888. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  889. return
  890. }
  891. this.ServeSuccessJSON(nil)
  892. }
  893. func (this *PatientDataConfigAPIController) ModifyCourse() {
  894. patientID, _ := this.GetInt64("patient_id")
  895. content := this.GetString("content")
  896. id, _ := this.GetInt64("id", 0)
  897. record_time_str := this.GetString("record_time")
  898. title := this.GetString("title")
  899. if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
  900. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  901. return
  902. }
  903. //timeLayout := "2006-01-02"
  904. //loc, _ := time.LoadLocation("Local")
  905. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  906. adminUserInfo := this.GetAdminUserInfo()
  907. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  908. if getPatientErr != nil {
  909. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  910. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. } else if patient == nil {
  913. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  914. return
  915. }
  916. now := time.Now().Unix()
  917. record := models.PatientDiseaseCourse{
  918. ID: id,
  919. OrgID: adminUserInfo.CurrentOrgId,
  920. PatientID: patientID,
  921. Recorder: adminUserInfo.AdminUser.Id,
  922. Content: content,
  923. Status: 1,
  924. CreateTime: now,
  925. ModifyTime: now,
  926. Title: title,
  927. RecordTime: checkDate.Unix(),
  928. }
  929. createErr := service.ModifyPatientCourses(&record)
  930. if createErr != nil {
  931. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  932. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  933. return
  934. }
  935. this.ServeSuccessJSON(map[string]interface{}{
  936. "record": record,
  937. })
  938. }
  939. func (this *PatientDataConfigAPIController) GetPatientDialysisInforList() {
  940. patientID, _ := this.GetInt64("patient_id")
  941. record_date := this.GetString("record_date")
  942. timeLayout := "2006-01-02"
  943. loc, _ := time.LoadLocation("Local")
  944. var startTime int64
  945. if len(record_date) > 0 {
  946. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  947. if err != nil {
  948. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  949. return
  950. }
  951. startTime = theTime.Unix()
  952. }
  953. //获取患者姓名
  954. patient, _ := service.GetPatientName(patientID)
  955. orgId := this.GetAdminUserInfo().CurrentOrgId
  956. //获取透析处方
  957. prescription, _ := service.GetDialysisPrescription(patientID, orgId, startTime)
  958. //获取透前评估
  959. assessmentBefor, _ := service.GetAssessmentBefor(orgId, patientID, startTime)
  960. //透析上机
  961. order, _ := service.GetDialysisOrder(orgId, patientID, startTime)
  962. //透析监测
  963. monitor, _ := service.GetFistMonitorSix(orgId, patientID, startTime)
  964. //透析医嘱
  965. advice, _ := service.GetBloodDoctorAdvice(startTime, orgId, patientID)
  966. //透后评估
  967. afterDislysis, _ := service.GetAssessmentAfterDissData(patientID, orgId, startTime)
  968. this.ServeSuccessJSON(map[string]interface{}{
  969. "patient": patient,
  970. "prescription": prescription,
  971. "assessmentBefor": assessmentBefor,
  972. "order": order,
  973. "monitor": monitor,
  974. "advice": advice,
  975. "afterDislysis": afterDislysis,
  976. })
  977. }
  978. func (this *PatientDataConfigAPIController) GetContextScheduleList() {
  979. limit, _ := this.GetInt64("limit")
  980. page, _ := this.GetInt64("page")
  981. start_time := this.GetString("start_time")
  982. end_time := this.GetString("end_time")
  983. timeLayout := "2006-01-02"
  984. loc, _ := time.LoadLocation("Local")
  985. var startTime int64
  986. if len(start_time) > 0 {
  987. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  988. if err != nil {
  989. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  990. return
  991. }
  992. startTime = theTime.Unix()
  993. }
  994. var endTime int64
  995. if len(end_time) > 0 {
  996. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  997. if err != nil {
  998. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  999. return
  1000. }
  1001. startTime = theTime.Unix()
  1002. }
  1003. org_id := this.GetAdminUserInfo().CurrentOrgId
  1004. schedule, total, _ := service.GetContextScheduleListGroupPatientId(limit, page, startTime, endTime, org_id)
  1005. list, _, _ := service.GetContextScheduleListPatientId(startTime, endTime, org_id)
  1006. patients, _ := service.GetAllpatientThirty(org_id)
  1007. devicenumber, _ := service.GetAllBedNumber(org_id)
  1008. this.ServeSuccessJSON(map[string]interface{}{
  1009. "schedule": schedule,
  1010. "total": total,
  1011. "list": list,
  1012. "patients": patients,
  1013. "devicenumber": devicenumber,
  1014. })
  1015. }
  1016. func (this *PatientDataConfigAPIController) GetPatientAllagicList() {
  1017. id, _ := this.GetInt64("id")
  1018. orgId := this.GetAdminUserInfo().CurrentOrgId
  1019. list, _ := service.GetPatientAllagicList(id, orgId)
  1020. this.ServeSuccessJSON(map[string]interface{}{
  1021. "list": list,
  1022. })
  1023. }
  1024. func (this *PatientDataConfigAPIController) SaveSiteMap() {
  1025. dataBody := make(map[string]interface{}, 0)
  1026. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1027. if err != nil {
  1028. utils.ErrorLog(err.Error())
  1029. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1030. return
  1031. }
  1032. patient_id := int64(dataBody["patient_id"].(float64))
  1033. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  1034. id := int64(dataBody["id"].(float64))
  1035. if dataBody["a_left"] != nil && reflect.TypeOf(dataBody["a_left"]).String() == "[]interface {}" {
  1036. prescriptions, _ := dataBody["a_left"].([]interface{})
  1037. service.UpdateValsualAleft(patient_id, user_org_id)
  1038. for _, item := range prescriptions {
  1039. var a_num float64
  1040. var mark_num float64
  1041. if item.(map[string]interface{})["a_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_num"]).String() == "float64" {
  1042. a_num = item.(map[string]interface{})["a_num"].(float64)
  1043. }
  1044. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1045. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1046. }
  1047. fmt.Println(a_num, mark_num)
  1048. valsualALeft := models.XtDeviceValsualALeft{
  1049. ANum: a_num,
  1050. MarkNum: mark_num,
  1051. UserOrgId: user_org_id,
  1052. PatientId: patient_id,
  1053. Ctime: time.Now().Unix(),
  1054. Mtime: time.Now().Unix(),
  1055. MapId: 0,
  1056. Status: 1,
  1057. }
  1058. service.CreateValsualAleft(valsualALeft)
  1059. }
  1060. }
  1061. is_append := int64(dataBody["is_append"].(float64))
  1062. is_img_v := int64(dataBody["is_img_v"].(float64))
  1063. is_img_a := int64(dataBody["is_img_a"].(float64))
  1064. a_top := dataBody["a_top"].(float64)
  1065. av_bkx := dataBody["av_bkx"].(float64)
  1066. av_bky := dataBody["av_bky"].(float64)
  1067. if dataBody["fangxiang_a"] != nil && reflect.TypeOf(dataBody["fangxiang_a"]).String() == "[]interface {}" {
  1068. prescriptions, _ := dataBody["fangxiang_a"].([]interface{})
  1069. service.ValsualMapFangxiangA(patient_id, user_org_id)
  1070. for _, item := range prescriptions {
  1071. var a_num float64
  1072. var mark_num float64
  1073. var mark_top float64
  1074. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1075. a_num = item.(map[string]interface{})["left"].(float64)
  1076. }
  1077. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1078. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1079. }
  1080. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1081. mark_top = item.(map[string]interface{})["top"].(float64)
  1082. }
  1083. ValsualMapFangxiangA := models.XtDeviceValsualMapFangxiangA{
  1084. PatientId: patient_id,
  1085. UserOrgId: user_org_id,
  1086. Status: 1,
  1087. Left: a_num,
  1088. MarkNum: mark_num,
  1089. Top: mark_top,
  1090. MapId: 0,
  1091. Ctime: time.Now().Unix(),
  1092. Mtime: time.Now().Unix(),
  1093. }
  1094. service.CreateValsualMapFangxiangA(ValsualMapFangxiangA)
  1095. }
  1096. }
  1097. fangxiang_a_num := dataBody["fangxiang_a_num"].(float64)
  1098. fangxiang_a_top := dataBody["fangxiang_a_top"].(float64)
  1099. fangxiang_v_left := dataBody["fangxiang_v_left"].(float64)
  1100. fangxiang_v_num := dataBody["fangxiang_v_num"].(float64)
  1101. fangxiang_v_top := dataBody["fangxiang_v_top"].(float64)
  1102. if dataBody["fangxiang_v"] != nil && reflect.TypeOf(dataBody["fangxiang_v"]).String() == "[]interface {}" {
  1103. prescriptions, _ := dataBody["fangxiang_v"].([]interface{})
  1104. service.UpdateValsualMapFangxiangV(patient_id, user_org_id)
  1105. for _, item := range prescriptions {
  1106. var a_num float64
  1107. var mark_num float64
  1108. var mark_top float64
  1109. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1110. a_num = item.(map[string]interface{})["left"].(float64)
  1111. }
  1112. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1113. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1114. }
  1115. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1116. mark_top = item.(map[string]interface{})["top"].(float64)
  1117. }
  1118. ValsualMapFangxiangV := models.XtDeviceValsualMapFangxiangV{
  1119. PatientId: patient_id,
  1120. UserOrgId: user_org_id,
  1121. Status: 1,
  1122. Left: a_num,
  1123. MarkNum: mark_num,
  1124. Top: mark_top,
  1125. MapId: 0,
  1126. Ctime: time.Now().Unix(),
  1127. Mtime: time.Now().Unix(),
  1128. }
  1129. service.CreateValsualMapFangxiangV(ValsualMapFangxiangV)
  1130. }
  1131. }
  1132. fangxiang_a_left := dataBody["fangxiang_a_left"].(float64)
  1133. if dataBody["fuzhu_a"] != nil && reflect.TypeOf(dataBody["fuzhu_a"]).String() == "[]interface {}" {
  1134. prescriptions, _ := dataBody["fuzhu_a"].([]interface{})
  1135. service.UpdateValSualFuzhA(patient_id, user_org_id)
  1136. for _, item := range prescriptions {
  1137. var a_left float64
  1138. var a_markNum float64
  1139. var a_top float64
  1140. if item.(map[string]interface{})["a_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_left"]).String() == "float64" {
  1141. a_left = item.(map[string]interface{})["a_left"].(float64)
  1142. }
  1143. if item.(map[string]interface{})["a_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_markNum"]).String() == "float64" {
  1144. a_markNum = item.(map[string]interface{})["a_markNum"].(float64)
  1145. }
  1146. if item.(map[string]interface{})["a_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_top"]).String() == "float64" {
  1147. a_top = item.(map[string]interface{})["a_top"].(float64)
  1148. }
  1149. valsualFuzhuA := models.XtDeviceValsualFuzhuA{
  1150. PatientId: patient_id,
  1151. UserOrgId: user_org_id,
  1152. Status: 1,
  1153. Ctime: time.Now().Unix(),
  1154. Mtime: time.Now().Unix(),
  1155. ALeft: a_left,
  1156. AMarkNum: a_markNum,
  1157. ATop: a_top,
  1158. MapId: 0,
  1159. }
  1160. service.CreateValSualFuzhA(valsualFuzhuA)
  1161. }
  1162. }
  1163. fuzhu_a_left := dataBody["fuzhu_a_left"].(float64)
  1164. fuzhu_a_num := dataBody["fuzhu_a_num"].(float64)
  1165. fuzhu_a_top := dataBody["fuzhu_a_top"].(float64)
  1166. left_a := dataBody["left_a"].(float64)
  1167. left_v := dataBody["left_v"].(float64)
  1168. if dataBody["fuzhu_v"] != nil && reflect.TypeOf(dataBody["fuzhu_v"]).String() == "[]interface {}" {
  1169. prescriptions, _ := dataBody["fuzhu_v"].([]interface{})
  1170. service.UpdateVasuaLfuzhuV(patient_id, user_org_id)
  1171. for _, item := range prescriptions {
  1172. var v_left float64
  1173. var v_markNum float64
  1174. var v_top float64
  1175. if item.(map[string]interface{})["v_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_left"]).String() == "float64" {
  1176. v_left = item.(map[string]interface{})["v_left"].(float64)
  1177. }
  1178. if item.(map[string]interface{})["v_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_markNum"]).String() == "float64" {
  1179. v_markNum = item.(map[string]interface{})["v_markNum"].(float64)
  1180. }
  1181. if item.(map[string]interface{})["v_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_top"]).String() == "float64" {
  1182. v_top = item.(map[string]interface{})["v_top"].(float64)
  1183. }
  1184. fuzhuV := models.XtDeviceValsualFuzhuV{
  1185. PatientId: patient_id,
  1186. UserOrgId: user_org_id,
  1187. Status: 1,
  1188. Ctime: time.Now().Unix(),
  1189. Mtime: 1,
  1190. VMarkNum: v_markNum,
  1191. VLeft: v_left,
  1192. VTop: v_top,
  1193. MapId: 0,
  1194. }
  1195. service.CreateVasuaLfuzhuV(fuzhuV)
  1196. }
  1197. }
  1198. fuzhu_v_left := dataBody["fuzhu_v_left"].(float64)
  1199. fuzhu_v_num := dataBody["fuzhu_v_num"].(float64)
  1200. fuzhu_v_top := dataBody["fuzhu_v_top"].(float64)
  1201. scalea_num := dataBody["scalea_num"].(float64)
  1202. scalev_num := dataBody["scalev_num"].(float64)
  1203. if dataBody["text_arr"] != nil && reflect.TypeOf(dataBody["text_arr"]).String() == "[]interface {}" {
  1204. prescriptions, _ := dataBody["text_arr"].([]interface{})
  1205. service.UpdateTextArr(patient_id, user_org_id)
  1206. for _, item := range prescriptions {
  1207. var left float64
  1208. var text_markNum string
  1209. var v_top float64
  1210. var width float64
  1211. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1212. left = item.(map[string]interface{})["left"].(float64)
  1213. }
  1214. if item.(map[string]interface{})["text"] != nil || reflect.TypeOf(item.(map[string]interface{})["text"]).String() == "string" {
  1215. text_markNum = item.(map[string]interface{})["text"].(string)
  1216. }
  1217. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1218. v_top = item.(map[string]interface{})["top"].(float64)
  1219. }
  1220. if item.(map[string]interface{})["width"] != nil || reflect.TypeOf(item.(map[string]interface{})["width"]).String() == "float64" {
  1221. width = item.(map[string]interface{})["width"].(float64)
  1222. }
  1223. textArr := models.XtDeviceValsualTextArr{
  1224. PatientId: patient_id,
  1225. UserOrgId: user_org_id,
  1226. Ctime: time.Now().Unix(),
  1227. Mtime: 0,
  1228. Status: 1,
  1229. Left: left,
  1230. Text: text_markNum,
  1231. Top: v_top,
  1232. Width: width,
  1233. MapId: 0,
  1234. }
  1235. service.CreateTextArr(textArr)
  1236. }
  1237. text_left := dataBody["text_left"].(float64)
  1238. text_num := dataBody["text_num"].(float64)
  1239. text_top := dataBody["text_top"].(float64)
  1240. if dataBody["v_left"] != nil && reflect.TypeOf(dataBody["v_left"]).String() == "[]interface {}" {
  1241. prescriptions, _ := dataBody["v_left"].([]interface{})
  1242. service.UpdateValsualVleft(patient_id, user_org_id)
  1243. for _, item := range prescriptions {
  1244. var v_num float64
  1245. var markNum float64
  1246. if item.(map[string]interface{})["v_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_num"]).String() == "float64" {
  1247. v_num = item.(map[string]interface{})["v_num"].(float64)
  1248. }
  1249. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1250. markNum = item.(map[string]interface{})["mark_num"].(float64)
  1251. }
  1252. valsualVLeft := models.XtDeviceValsualVLeft{
  1253. PatientId: patient_id,
  1254. UserOrgId: user_org_id,
  1255. Status: 1,
  1256. Ctime: time.Now().Unix(),
  1257. Mtime: time.Now().Unix(),
  1258. MarkNum: markNum,
  1259. VNum: v_num,
  1260. MapId: 0,
  1261. }
  1262. service.CreateValsualVleft(valsualVLeft)
  1263. }
  1264. }
  1265. if dataBody["aarr"] != nil && reflect.TypeOf(dataBody["aarr"]).String() == "[]interface {}" {
  1266. prescriptions, _ := dataBody["aarr"].([]interface{})
  1267. service.UpdateValusalMapArr(patient_id, user_org_id)
  1268. for _, item := range prescriptions {
  1269. var mark_num float64
  1270. var is_status float64
  1271. var left float64
  1272. var top float64
  1273. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1274. mark_num = item.(map[string]interface{})["mark_num"].(float64)
  1275. }
  1276. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1277. is_status = item.(map[string]interface{})["is_status"].(float64)
  1278. }
  1279. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1280. left = item.(map[string]interface{})["left"].(float64)
  1281. }
  1282. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1283. top = item.(map[string]interface{})["top"].(float64)
  1284. }
  1285. mapArr := models.XtDeviceValusalMapArr{
  1286. PatientId: patient_id,
  1287. UserOrgId: user_org_id,
  1288. Status: 1,
  1289. MarkNum: mark_num,
  1290. Left: left,
  1291. Top: top,
  1292. IsStatus: is_status,
  1293. Ctime: time.Now().Unix(),
  1294. Mtime: 0,
  1295. }
  1296. service.CreateDeviceValusalMapArr(mapArr)
  1297. }
  1298. }
  1299. if dataBody["varr"] != nil && reflect.TypeOf(dataBody["varr"]).String() == "[]interface {}" {
  1300. prescriptions, _ := dataBody["varr"].([]interface{})
  1301. service.UpdateDeviceValusalMapVrr(patient_id, user_org_id)
  1302. for _, item := range prescriptions {
  1303. var mark_num float64
  1304. var is_status float64
  1305. var left float64
  1306. var top float64
  1307. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1308. mark_num = item.(map[string]interface{})["mark_num"].(float64)
  1309. }
  1310. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1311. is_status = item.(map[string]interface{})["is_status"].(float64)
  1312. }
  1313. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1314. left = item.(map[string]interface{})["left"].(float64)
  1315. }
  1316. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1317. top = item.(map[string]interface{})["top"].(float64)
  1318. }
  1319. mapVrr := models.XtDeviceValusalMapVrr{
  1320. PatientId: patient_id,
  1321. UserOrgId: user_org_id,
  1322. Status: 1,
  1323. MarkNum: mark_num,
  1324. Left: left,
  1325. Top: top,
  1326. IsStatus: is_status,
  1327. Ctime: time.Now().Unix(),
  1328. Mtime: 0,
  1329. }
  1330. service.CreateDeviceValusalMapVrr(mapVrr)
  1331. }
  1332. }
  1333. v_num := dataBody["v_num"].(float64)
  1334. v_top := dataBody["v_top"].(float64)
  1335. xuanzhuan_a := dataBody["xuanzhuan_a"].(float64)
  1336. xuanzhuan_v := dataBody["xuanzhuan_v"].(float64)
  1337. img_url := dataBody["img_url"].(string)
  1338. deviceValsualMap := models.XtDeviceValsualMap{
  1339. ID: id,
  1340. PatientId: patient_id,
  1341. IsAppend: is_append,
  1342. IsImgV: is_img_v,
  1343. IsImgA: is_img_a,
  1344. VNum: v_num,
  1345. Status: 1,
  1346. UserOrgId: user_org_id,
  1347. ATop: a_top,
  1348. AvBkx: av_bkx,
  1349. AvBky: av_bky,
  1350. FangxiangALeft: fangxiang_a_left,
  1351. FangxiangANum: fangxiang_a_num,
  1352. FangxiangATop: fangxiang_a_top,
  1353. FangxiangVLeft: fangxiang_v_left,
  1354. FangxiangVNum: fangxiang_v_num,
  1355. FangxiangVTop: fangxiang_v_top,
  1356. FuzhuALeft: fuzhu_a_left,
  1357. FuzhuANum: fuzhu_a_num,
  1358. FuzhuATop: fuzhu_a_top,
  1359. FuzhuVLeft: fuzhu_v_left,
  1360. FuzhuVNum: fuzhu_v_num,
  1361. FuzhuVTop: fuzhu_v_top,
  1362. ScaleaNum: scalea_num,
  1363. ScalevNum: scalev_num,
  1364. TextLeft: text_left,
  1365. TextNum: text_num,
  1366. TextTop: text_top,
  1367. VTop: v_top,
  1368. XuanzhuanA: xuanzhuan_a,
  1369. XuanzhuanV: xuanzhuan_v,
  1370. ALeft: left_a,
  1371. VLeft: left_v,
  1372. ImgUrl: img_url,
  1373. }
  1374. err = service.CreateDeviceValsualMap(deviceValsualMap)
  1375. this.ServeSuccessJSON(map[string]interface{}{
  1376. "deviceValsualMap": deviceValsualMap,
  1377. })
  1378. }
  1379. }
  1380. func (this *PatientDataConfigAPIController) GetPatientSitemap() {
  1381. patient_id, _ := this.GetInt64("patient_id")
  1382. orgId := this.GetAdminUserInfo().CurrentOrgId
  1383. sitemap, _ := service.GetPatientSitemap(patient_id, orgId)
  1384. patients, _ := service.GetPatientByIDOne(orgId, patient_id)
  1385. this.ServeSuccessJSON(map[string]interface{}{
  1386. "sitemap": sitemap,
  1387. "patients": patients,
  1388. })
  1389. }
  1390. func (this *PatientDataConfigAPIController) GetPatientDetailInformedConsent() {
  1391. patient_id, _ := this.GetInt64("patient_id")
  1392. orgId := this.GetAdminUserInfo().CurrentOrgId
  1393. patients, _ := service.GetPatientDetailInformedConsent(patient_id, orgId)
  1394. this.ServeSuccessJSON(map[string]interface{}{
  1395. "patients": patients,
  1396. })
  1397. }
  1398. func (this *PatientDataConfigAPIController) GetPatientMedicalList() {
  1399. patient_id, _ := this.GetInt64("patient_id")
  1400. orgId := this.GetAdminUserInfo().CurrentOrgId
  1401. list, _ := service.GetPatientMedicalList(patient_id, orgId)
  1402. this.ServeSuccessJSON(map[string]interface{}{
  1403. "list": list,
  1404. })
  1405. }
  1406. func (this *PatientDataConfigAPIController) GetAllNurseList() {
  1407. orgId := this.GetAdminUserInfo().CurrentOrgId
  1408. appId := this.GetAdminUserInfo().CurrentAppId
  1409. nurseList, _ := service.GetAllNurseList(orgId, appId)
  1410. this.ServeSuccessJSON(map[string]interface{}{
  1411. "nurseList": nurseList,
  1412. })
  1413. }
  1414. func (this *PatientDataConfigAPIController) SaveFllassessmentList() {
  1415. dataBody := make(map[string]interface{}, 0)
  1416. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1417. if err != nil {
  1418. utils.ErrorLog(err.Error())
  1419. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1420. return
  1421. }
  1422. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  1423. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  1424. is_check := int64(dataBody["is_check"].(float64))
  1425. is_check_one := int64(dataBody["is_check_one"].(float64))
  1426. is_check_two := int64(dataBody["is_check_two"].(float64))
  1427. is_check_three := int64(dataBody["is_check_three"].(float64))
  1428. is_check_four := int64(dataBody["is_check_four"].(float64))
  1429. is_check_five := int64(dataBody["is_check_five"].(float64))
  1430. is_check_six := int64(dataBody["is_check_six"].(float64))
  1431. is_check_seven := int64(dataBody["is_check_seven"].(float64))
  1432. is_check_eight := int64(dataBody["is_check_eight"].(float64))
  1433. is_check_night := int64(dataBody["is_check_night"].(float64))
  1434. is_check_ten := int64(dataBody["is_check_ten"].(float64))
  1435. is_check_eleven := int64(dataBody["is_check_eleven"].(float64))
  1436. is_check_twelve := int64(dataBody["is_check_twelve"].(float64))
  1437. is_check_thirteen := int64(dataBody["is_check_thirteen"].(float64))
  1438. is_check_fourteen := int64(dataBody["is_check_fourteen"].(float64))
  1439. is_check_fifteen := int64(dataBody["is_check_fifteen"].(float64))
  1440. is_check_sixteen := int64(dataBody["is_check_sixteen"].(float64))
  1441. is_check_seventeen := int64(dataBody["is_check_seventeen"].(float64))
  1442. is_check_eighteen := int64(dataBody["is_check_eighteen"].(float64))
  1443. is_check_nineteen := int64(dataBody["is_check_nineteen"].(float64))
  1444. patient_id := int64(dataBody["patient_id"].(float64))
  1445. total := int64(dataBody["total"].(float64))
  1446. ping_date := dataBody["ping_date"].(string)
  1447. record_date := dataBody["record_date"].(string)
  1448. timeLayout := "2006-01-02"
  1449. loc, _ := time.LoadLocation("Local")
  1450. var pingDate int64
  1451. if len(ping_date) > 0 {
  1452. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", ping_date+" 00:00:00", loc)
  1453. if err != nil {
  1454. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1455. return
  1456. }
  1457. pingDate = theTime.Unix()
  1458. }
  1459. var recordDate int64
  1460. if len(record_date) > 0 {
  1461. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1462. if err != nil {
  1463. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1464. return
  1465. }
  1466. recordDate = theTime.Unix()
  1467. }
  1468. // 开始主事务
  1469. db := service.XTWriteDB()
  1470. tx := db.Begin()
  1471. // 在函数结束时处理事务回滚
  1472. defer func() {
  1473. if r := recover(); r != nil {
  1474. tx.Rollback()
  1475. }
  1476. }()
  1477. patientFallassessment := models.XtPatientFallassessment{
  1478. PatientId: patient_id,
  1479. UserOrgId: user_org_id,
  1480. RecordDate: recordDate,
  1481. PingDate: pingDate,
  1482. AdminUserId: admin_user_id,
  1483. Status: 1,
  1484. IsCheck: is_check,
  1485. IsCheckOne: is_check_one,
  1486. IsCheckTwo: is_check_two,
  1487. IsCheckThree: is_check_three,
  1488. IsCheckFour: is_check_four,
  1489. IsCheckFive: is_check_five,
  1490. IsCheckSix: is_check_six,
  1491. IsCheckSeven: is_check_seven,
  1492. IsCheckEight: is_check_eight,
  1493. IsCheckNight: is_check_night,
  1494. IsCheckTen: is_check_ten,
  1495. IsCheckEleven: is_check_eleven,
  1496. IsCheckTwelve: is_check_twelve,
  1497. IsCheckThirteen: is_check_thirteen,
  1498. IsCheckFourteen: is_check_fourteen,
  1499. IsCheckFifteen: is_check_fifteen,
  1500. IsCheckSixteen: is_check_sixteen,
  1501. IsCheckSeventeen: is_check_seventeen,
  1502. IsCheckEighteen: is_check_eighteen,
  1503. IsCheckNineteen: is_check_nineteen,
  1504. Ctime: time.Now().Unix(),
  1505. Mtime: time.Now().Unix(),
  1506. Total: total,
  1507. }
  1508. service.CreatePatientFallassessment(tx, patientFallassessment)
  1509. lastPatientFallassessment, _ := service.GetLastPatientFallassessment(tx, patient_id, user_org_id)
  1510. if dataBody["is_age"] != nil && reflect.TypeOf(dataBody["is_age"]).String() == "[]interface {}" {
  1511. isAgeList, _ := dataBody["is_age"].([]interface{})
  1512. fmt.Println("--------------------", len(isAgeList))
  1513. for _, item := range isAgeList {
  1514. var is_status int64
  1515. var is_content string
  1516. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1517. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1518. }
  1519. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1520. is_content = item.(map[string]interface{})["content"].(string)
  1521. }
  1522. fallassessmentAge := models.XtPatientFallassessmentAge{
  1523. UserOrgId: user_org_id,
  1524. PatientId: patient_id,
  1525. Status: 1,
  1526. Ctime: time.Now().Unix(),
  1527. Mtime: time.Now().Unix(),
  1528. FassementId: lastPatientFallassessment.ID,
  1529. IsCheckStatus: is_status,
  1530. Content: is_content,
  1531. }
  1532. service.CreateFallassessmentAge(tx, fallassessmentAge)
  1533. }
  1534. }
  1535. if dataBody["is_ganguan"] != nil && reflect.TypeOf(dataBody["is_ganguan"]).String() == "[]interface {}" {
  1536. isGanGuanList, _ := dataBody["is_ganguan"].([]interface{})
  1537. for _, item := range isGanGuanList {
  1538. var is_status int64
  1539. var is_content string
  1540. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1541. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1542. }
  1543. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1544. is_content = item.(map[string]interface{})["content"].(string)
  1545. }
  1546. fallassessmentOrgan := models.XtPatientFallassessmentOrgan{
  1547. UserOrgId: user_org_id,
  1548. PatientId: patient_id,
  1549. Status: 1,
  1550. Ctime: time.Now().Unix(),
  1551. Mtime: time.Now().Unix(),
  1552. FassementId: lastPatientFallassessment.ID,
  1553. IsCheckStatus: is_status,
  1554. Content: is_content,
  1555. }
  1556. service.CreateFallassessmentOrgan(tx, fallassessmentOrgan)
  1557. }
  1558. }
  1559. if dataBody["is_jiwang"] != nil && reflect.TypeOf(dataBody["is_jiwang"]).String() == "[]interface {}" {
  1560. isJiWangList, _ := dataBody["is_jiwang"].([]interface{})
  1561. for _, item := range isJiWangList {
  1562. var is_status int64
  1563. var is_content string
  1564. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1565. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1566. }
  1567. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1568. is_content = item.(map[string]interface{})["content"].(string)
  1569. }
  1570. fallassessmentHistory := models.XtPatientFallassessmentHistory{
  1571. UserOrgId: user_org_id,
  1572. PatientId: patient_id,
  1573. Status: 1,
  1574. Ctime: time.Now().Unix(),
  1575. Mtime: time.Now().Unix(),
  1576. FassementId: lastPatientFallassessment.ID,
  1577. IsCheckStatus: is_status,
  1578. Content: is_content,
  1579. }
  1580. service.CreateFallassessmentHistory(tx, fallassessmentHistory)
  1581. }
  1582. }
  1583. if dataBody["is_paixie"] != nil && reflect.TypeOf(dataBody["is_paixie"]).String() == "[]interface {}" {
  1584. isPaiXie, _ := dataBody["is_paixie"].([]interface{})
  1585. for _, item := range isPaiXie {
  1586. var is_status int64
  1587. var is_content string
  1588. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1589. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1590. }
  1591. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1592. is_content = item.(map[string]interface{})["content"].(string)
  1593. }
  1594. fallassessmentExcrete := models.XtPatientFallassessmentExcrete{
  1595. UserOrgId: user_org_id,
  1596. PatientId: patient_id,
  1597. Status: 1,
  1598. Ctime: time.Now().Unix(),
  1599. Mtime: time.Now().Unix(),
  1600. FassementId: lastPatientFallassessment.ID,
  1601. IsCheckStatus: is_status,
  1602. Content: is_content,
  1603. }
  1604. service.CreateFallassessmentExcrete(tx, fallassessmentExcrete)
  1605. }
  1606. }
  1607. if dataBody["is_shentizk"] != nil && reflect.TypeOf(dataBody["is_shentizk"]).String() == "[]interface {}" {
  1608. isShenTizk, _ := dataBody["is_shentizk"].([]interface{})
  1609. for _, item := range isShenTizk {
  1610. var is_status int64
  1611. var is_content string
  1612. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1613. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1614. }
  1615. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1616. is_content = item.(map[string]interface{})["content"].(string)
  1617. }
  1618. fallassessmentBody := models.XtPatientFallassessmentBody{
  1619. UserOrgId: user_org_id,
  1620. PatientId: patient_id,
  1621. Status: 1,
  1622. Ctime: time.Now().Unix(),
  1623. Mtime: time.Now().Unix(),
  1624. FassementId: lastPatientFallassessment.ID,
  1625. IsCheckStatus: is_status,
  1626. Content: is_content,
  1627. }
  1628. service.CreateFallassessmentBody(tx, fallassessmentBody)
  1629. }
  1630. }
  1631. if dataBody["is_syyaowu"] != nil && reflect.TypeOf(dataBody["is_syyaowu"]).String() == "[]interface {}" {
  1632. is_syYaoWu, _ := dataBody["is_syyaowu"].([]interface{})
  1633. for _, item := range is_syYaoWu {
  1634. var is_status int64
  1635. var is_content string
  1636. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1637. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1638. }
  1639. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1640. is_content = item.(map[string]interface{})["content"].(string)
  1641. }
  1642. fallassessmentBody := models.XtPatientFallassessmentMedical{
  1643. UserOrgId: user_org_id,
  1644. PatientId: patient_id,
  1645. Status: 1,
  1646. Ctime: time.Now().Unix(),
  1647. Mtime: time.Now().Unix(),
  1648. FassementId: lastPatientFallassessment.ID,
  1649. IsCheckStatus: is_status,
  1650. Content: is_content,
  1651. }
  1652. service.CreateFallassessmentMedical(tx, fallassessmentBody)
  1653. }
  1654. }
  1655. if dataBody["is_touxidiedao"] != nil && reflect.TypeOf(dataBody["is_touxidiedao"]).String() == "[]interface {}" {
  1656. isTouXiDieDao, _ := dataBody["is_touxidiedao"].([]interface{})
  1657. for _, item := range isTouXiDieDao {
  1658. var is_status int64
  1659. var is_content string
  1660. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1661. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1662. }
  1663. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1664. is_content = item.(map[string]interface{})["content"].(string)
  1665. }
  1666. fallassessmentFall := models.XtPatientFallassessmentFall{
  1667. UserOrgId: user_org_id,
  1668. PatientId: patient_id,
  1669. Status: 1,
  1670. Ctime: time.Now().Unix(),
  1671. Mtime: time.Now().Unix(),
  1672. FassementId: lastPatientFallassessment.ID,
  1673. IsCheckStatus: is_status,
  1674. Content: is_content,
  1675. }
  1676. service.CreateFallassessmentFall(tx, fallassessmentFall)
  1677. }
  1678. }
  1679. if dataBody["is_xiaoguo"] != nil && reflect.TypeOf(dataBody["is_xiaoguo"]).String() == "[]interface {}" {
  1680. isXiaoGuo, _ := dataBody["is_xiaoguo"].([]interface{})
  1681. for _, item := range isXiaoGuo {
  1682. var is_status int64
  1683. var is_content string
  1684. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1685. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1686. }
  1687. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1688. is_content = item.(map[string]interface{})["content"].(string)
  1689. }
  1690. fallassessmentPrevent := models.XtPatientFallassessmentPrevent{
  1691. UserOrgId: user_org_id,
  1692. PatientId: patient_id,
  1693. Status: 1,
  1694. Ctime: time.Now().Unix(),
  1695. Mtime: time.Now().Unix(),
  1696. FassementId: lastPatientFallassessment.ID,
  1697. IsCheckStatus: is_status,
  1698. Content: is_content,
  1699. }
  1700. service.CreateFallassessmentPrevent(tx, fallassessmentPrevent)
  1701. }
  1702. }
  1703. if dataBody["is_yishizt"] != nil && reflect.TypeOf(dataBody["is_yishizt"]).String() == "[]interface {}" {
  1704. isYiShiZt, _ := dataBody["is_yishizt"].([]interface{})
  1705. for _, item := range isYiShiZt {
  1706. var is_status int64
  1707. var is_content string
  1708. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1709. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1710. }
  1711. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1712. is_content = item.(map[string]interface{})["content"].(string)
  1713. }
  1714. fallassessmentRealize := models.XtPatientFallassessmentRealize{
  1715. UserOrgId: user_org_id,
  1716. PatientId: patient_id,
  1717. Status: 1,
  1718. Ctime: time.Now().Unix(),
  1719. Mtime: time.Now().Unix(),
  1720. FassementId: lastPatientFallassessment.ID,
  1721. IsCheckStatus: is_status,
  1722. Content: is_content,
  1723. }
  1724. service.CreateFallassessmentPealize(tx, fallassessmentRealize)
  1725. }
  1726. }
  1727. if dataBody["is_zilin"] != nil && reflect.TypeOf(dataBody["is_zilin"]).String() == "[]interface {}" {
  1728. isZiLin, _ := dataBody["is_zilin"].([]interface{})
  1729. for _, item := range isZiLin {
  1730. var is_status int64
  1731. var is_content string
  1732. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1733. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1734. }
  1735. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1736. is_content = item.(map[string]interface{})["content"].(string)
  1737. }
  1738. fallassessmentCare := models.XtPatientFallassessmentCare{
  1739. UserOrgId: user_org_id,
  1740. PatientId: patient_id,
  1741. Status: 1,
  1742. Ctime: time.Now().Unix(),
  1743. Mtime: time.Now().Unix(),
  1744. FassementId: lastPatientFallassessment.ID,
  1745. IsCheckStatus: is_status,
  1746. Content: is_content,
  1747. }
  1748. service.CreateFallassessmentCare(tx, fallassessmentCare)
  1749. }
  1750. }
  1751. if dataBody["list"] != nil && reflect.TypeOf(dataBody["list"]).String() == "[]interface {}" {
  1752. list, _ := dataBody["list"].([]interface{})
  1753. for _, item := range list {
  1754. var is_status int64
  1755. var is_content string
  1756. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1757. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1758. }
  1759. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1760. is_content = item.(map[string]interface{})["content"].(string)
  1761. }
  1762. PatientFallassessmentAdd := models.XtPatientFallassessmentAdd{
  1763. UserOrgId: user_org_id,
  1764. PatientId: patient_id,
  1765. Status: 1,
  1766. Ctime: time.Now().Unix(),
  1767. Mtime: time.Now().Unix(),
  1768. FassementId: lastPatientFallassessment.ID,
  1769. IsCheckStatus: is_status,
  1770. Content: is_content,
  1771. }
  1772. service.CreateFallassessmentAdd(tx, PatientFallassessmentAdd)
  1773. }
  1774. }
  1775. if dataBody["listOne"] != nil && reflect.TypeOf(dataBody["listOne"]).String() == "[]interface {}" {
  1776. listOne, _ := dataBody["listOne"].([]interface{})
  1777. for _, item := range listOne {
  1778. var is_status int64
  1779. var is_content string
  1780. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1781. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1782. }
  1783. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1784. is_content = item.(map[string]interface{})["content"].(string)
  1785. }
  1786. PatientFallassessmentAddCopy := models.XtPatientFallassessmentAddCopy{
  1787. UserOrgId: user_org_id,
  1788. PatientId: patient_id,
  1789. Status: 1,
  1790. Ctime: time.Now().Unix(),
  1791. Mtime: time.Now().Unix(),
  1792. FassementId: lastPatientFallassessment.ID,
  1793. IsCheckStatus: is_status,
  1794. Content: is_content,
  1795. }
  1796. service.XtPatientFallassessmentAddCopy(tx, PatientFallassessmentAddCopy)
  1797. }
  1798. }
  1799. tx.Commit()
  1800. this.ServeSuccessJSON(map[string]interface{}{
  1801. "patientFallassessment": patientFallassessment,
  1802. })
  1803. }
  1804. func (this *PatientDataConfigAPIController) GetPatientFallsessMentList() {
  1805. patient_id, _ := this.GetInt64("patient_id")
  1806. limit, _ := this.GetInt64("limit")
  1807. page, _ := this.GetInt64("page")
  1808. orgId := this.GetAdminUserInfo().CurrentOrgId
  1809. list, total, _ := service.GetPatientFallsessMentList(patient_id, orgId, limit, page)
  1810. appId := this.GetAdminUserInfo().CurrentAppId
  1811. roleList, _ := service.GetAllNurseList(orgId, appId)
  1812. this.ServeSuccessJSON(map[string]interface{}{
  1813. "list": list,
  1814. "total": total,
  1815. "roleList": roleList,
  1816. })
  1817. }
  1818. func (this *PatientDataConfigAPIController) GetPatientFallsessmentById() {
  1819. id, _ := this.GetInt64("id")
  1820. orgId := this.GetAdminUserInfo().CurrentOrgId
  1821. patientFallsessment, _ := service.GetPatientFallsessmentById(id, orgId)
  1822. this.ServeSuccessJSON(map[string]interface{}{
  1823. "patientFallsessment": patientFallsessment,
  1824. })
  1825. }
  1826. func (this *PatientDataConfigAPIController) DeletePatientFallsessment() {
  1827. id, _ := this.GetInt64("id")
  1828. orgId := this.GetAdminUserInfo().CurrentOrgId
  1829. service.DeletePatientFallsessment(id, orgId)
  1830. this.ServeSuccessJSON(map[string]interface{}{
  1831. "msg": "ok",
  1832. })
  1833. }
  1834. func (this *PatientDataConfigAPIController) UpdatePatientFallassment() {
  1835. dataBody := make(map[string]interface{}, 0)
  1836. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1837. if err != nil {
  1838. utils.ErrorLog(err.Error())
  1839. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1840. return
  1841. }
  1842. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  1843. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  1844. id := int64(dataBody["id"].(float64))
  1845. is_check := int64(dataBody["is_check"].(float64))
  1846. is_check_one := int64(dataBody["is_check_one"].(float64))
  1847. is_check_two := int64(dataBody["is_check_two"].(float64))
  1848. is_check_three := int64(dataBody["is_check_three"].(float64))
  1849. is_check_four := int64(dataBody["is_check_four"].(float64))
  1850. is_check_five := int64(dataBody["is_check_five"].(float64))
  1851. is_check_six := int64(dataBody["is_check_six"].(float64))
  1852. is_check_seven := int64(dataBody["is_check_seven"].(float64))
  1853. is_check_eight := int64(dataBody["is_check_eight"].(float64))
  1854. is_check_night := int64(dataBody["is_check_night"].(float64))
  1855. is_check_ten := int64(dataBody["is_check_ten"].(float64))
  1856. is_check_eleven := int64(dataBody["is_check_eleven"].(float64))
  1857. is_check_twelve := int64(dataBody["is_check_twelve"].(float64))
  1858. is_check_thirteen := int64(dataBody["is_check_thirteen"].(float64))
  1859. is_check_fourteen := int64(dataBody["is_check_fourteen"].(float64))
  1860. is_check_fifteen := int64(dataBody["is_check_fifteen"].(float64))
  1861. is_check_sixteen := int64(dataBody["is_check_sixteen"].(float64))
  1862. is_check_seventeen := int64(dataBody["is_check_seventeen"].(float64))
  1863. is_check_eighteen := int64(dataBody["is_check_eighteen"].(float64))
  1864. is_check_nineteen := int64(dataBody["is_check_nineteen"].(float64))
  1865. patient_id := int64(dataBody["patient_id"].(float64))
  1866. total := int64(dataBody["total"].(float64))
  1867. ping_date := dataBody["ping_date"].(string)
  1868. record_date := dataBody["record_date"].(string)
  1869. timeLayout := "2006-01-02"
  1870. loc, _ := time.LoadLocation("Local")
  1871. var pingDate int64
  1872. if len(ping_date) > 0 {
  1873. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", ping_date+" 00:00:00", loc)
  1874. if err != nil {
  1875. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1876. return
  1877. }
  1878. pingDate = theTime.Unix()
  1879. }
  1880. var recordDate int64
  1881. if len(record_date) > 0 {
  1882. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1883. if err != nil {
  1884. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1885. return
  1886. }
  1887. recordDate = theTime.Unix()
  1888. }
  1889. // 开始主事务
  1890. db := service.XTWriteDB()
  1891. tx := db.Begin()
  1892. // 在函数结束时处理事务回滚
  1893. defer func() {
  1894. if r := recover(); r != nil {
  1895. tx.Rollback()
  1896. }
  1897. }()
  1898. patientFallassessment := models.XtPatientFallassessment{
  1899. ID: id,
  1900. PatientId: patient_id,
  1901. UserOrgId: user_org_id,
  1902. RecordDate: recordDate,
  1903. PingDate: pingDate,
  1904. AdminUserId: admin_user_id,
  1905. Status: 1,
  1906. IsCheck: is_check,
  1907. IsCheckOne: is_check_one,
  1908. IsCheckTwo: is_check_two,
  1909. IsCheckThree: is_check_three,
  1910. IsCheckFour: is_check_four,
  1911. IsCheckFive: is_check_five,
  1912. IsCheckSix: is_check_six,
  1913. IsCheckSeven: is_check_seven,
  1914. IsCheckEight: is_check_eight,
  1915. IsCheckNight: is_check_night,
  1916. IsCheckTen: is_check_ten,
  1917. IsCheckEleven: is_check_eleven,
  1918. IsCheckTwelve: is_check_twelve,
  1919. IsCheckThirteen: is_check_thirteen,
  1920. IsCheckFourteen: is_check_fourteen,
  1921. IsCheckFifteen: is_check_fifteen,
  1922. IsCheckSixteen: is_check_sixteen,
  1923. IsCheckSeventeen: is_check_seventeen,
  1924. IsCheckEighteen: is_check_eighteen,
  1925. IsCheckNineteen: is_check_nineteen,
  1926. Ctime: time.Now().Unix(),
  1927. Mtime: time.Now().Unix(),
  1928. Total: total,
  1929. }
  1930. service.SavePatientFallassessment(tx, patientFallassessment)
  1931. lastPatientFallassessment, _ := service.GetLastPatientFallassessment(tx, patient_id, user_org_id)
  1932. if dataBody["is_age"] != nil && reflect.TypeOf(dataBody["is_age"]).String() == "[]interface {}" {
  1933. isAgeList, _ := dataBody["is_age"].([]interface{})
  1934. for _, item := range isAgeList {
  1935. var id int64
  1936. var is_status int64
  1937. var is_content string
  1938. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  1939. id = int64(item.(map[string]interface{})["id"].(float64))
  1940. }
  1941. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1942. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1943. }
  1944. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1945. is_content = item.(map[string]interface{})["content"].(string)
  1946. }
  1947. fallassessmentAge := models.XtPatientFallassessmentAge{
  1948. ID: id,
  1949. UserOrgId: user_org_id,
  1950. PatientId: patient_id,
  1951. Status: 1,
  1952. Ctime: time.Now().Unix(),
  1953. Mtime: time.Now().Unix(),
  1954. FassementId: lastPatientFallassessment.ID,
  1955. IsCheckStatus: is_status,
  1956. Content: is_content,
  1957. }
  1958. service.SaveFallassessmentAge(tx, fallassessmentAge)
  1959. }
  1960. }
  1961. if dataBody["is_ganguan"] != nil && reflect.TypeOf(dataBody["is_ganguan"]).String() == "[]interface {}" {
  1962. isGanGuanList, _ := dataBody["is_ganguan"].([]interface{})
  1963. for _, item := range isGanGuanList {
  1964. var id int64
  1965. var is_status int64
  1966. var is_content string
  1967. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  1968. id = int64(item.(map[string]interface{})["id"].(float64))
  1969. }
  1970. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1971. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1972. }
  1973. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  1974. is_content = item.(map[string]interface{})["content"].(string)
  1975. }
  1976. fallassessmentOrgan := models.XtPatientFallassessmentOrgan{
  1977. ID: id,
  1978. UserOrgId: user_org_id,
  1979. PatientId: patient_id,
  1980. Status: 1,
  1981. Ctime: time.Now().Unix(),
  1982. Mtime: time.Now().Unix(),
  1983. FassementId: lastPatientFallassessment.ID,
  1984. IsCheckStatus: is_status,
  1985. Content: is_content,
  1986. }
  1987. service.SaveFallassessmentOrgan(tx, fallassessmentOrgan)
  1988. }
  1989. }
  1990. if dataBody["is_jiwang"] != nil && reflect.TypeOf(dataBody["is_jiwang"]).String() == "[]interface {}" {
  1991. isJiWangList, _ := dataBody["is_jiwang"].([]interface{})
  1992. for _, item := range isJiWangList {
  1993. var id int64
  1994. var is_status int64
  1995. var is_content string
  1996. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1997. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  1998. }
  1999. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  2000. id = int64(item.(map[string]interface{})["id"].(float64))
  2001. }
  2002. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2003. is_content = item.(map[string]interface{})["content"].(string)
  2004. }
  2005. fallassessmentHistory := models.XtPatientFallassessmentHistory{
  2006. ID: id,
  2007. UserOrgId: user_org_id,
  2008. PatientId: patient_id,
  2009. Status: 1,
  2010. Ctime: time.Now().Unix(),
  2011. Mtime: time.Now().Unix(),
  2012. FassementId: lastPatientFallassessment.ID,
  2013. IsCheckStatus: is_status,
  2014. Content: is_content,
  2015. }
  2016. service.SaveFallassessmentHistory(tx, fallassessmentHistory)
  2017. }
  2018. }
  2019. if dataBody["is_paixie"] != nil && reflect.TypeOf(dataBody["is_paixie"]).String() == "[]interface {}" {
  2020. isPaiXie, _ := dataBody["is_paixie"].([]interface{})
  2021. for _, item := range isPaiXie {
  2022. var id int64
  2023. var is_status int64
  2024. var is_content string
  2025. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  2026. id = int64(item.(map[string]interface{})["id"].(float64))
  2027. }
  2028. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  2029. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  2030. }
  2031. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2032. is_content = item.(map[string]interface{})["content"].(string)
  2033. }
  2034. fallassessmentExcrete := models.XtPatientFallassessmentExcrete{
  2035. ID: id,
  2036. UserOrgId: user_org_id,
  2037. PatientId: patient_id,
  2038. Status: 1,
  2039. Ctime: time.Now().Unix(),
  2040. Mtime: time.Now().Unix(),
  2041. FassementId: lastPatientFallassessment.ID,
  2042. IsCheckStatus: is_status,
  2043. Content: is_content,
  2044. }
  2045. service.SaveFallassessmentExcrete(tx, fallassessmentExcrete)
  2046. }
  2047. }
  2048. if dataBody["is_shentizk"] != nil && reflect.TypeOf(dataBody["is_shentizk"]).String() == "[]interface {}" {
  2049. isShenTizk, _ := dataBody["is_shentizk"].([]interface{})
  2050. for _, item := range isShenTizk {
  2051. var id int64
  2052. var is_status int64
  2053. var is_content string
  2054. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  2055. id = int64(item.(map[string]interface{})["id"].(float64))
  2056. }
  2057. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  2058. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  2059. }
  2060. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2061. is_content = item.(map[string]interface{})["content"].(string)
  2062. }
  2063. fallassessmentBody := models.XtPatientFallassessmentBody{
  2064. ID: id,
  2065. UserOrgId: user_org_id,
  2066. PatientId: patient_id,
  2067. Status: 1,
  2068. Ctime: time.Now().Unix(),
  2069. Mtime: time.Now().Unix(),
  2070. FassementId: lastPatientFallassessment.ID,
  2071. IsCheckStatus: is_status,
  2072. Content: is_content,
  2073. }
  2074. service.SaveFallassessmentBody(tx, fallassessmentBody)
  2075. }
  2076. }
  2077. if dataBody["is_syyaowu"] != nil && reflect.TypeOf(dataBody["is_syyaowu"]).String() == "[]interface {}" {
  2078. is_syYaoWu, _ := dataBody["is_syyaowu"].([]interface{})
  2079. for _, item := range is_syYaoWu {
  2080. var id int64
  2081. var is_status int64
  2082. var is_content string
  2083. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  2084. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  2085. }
  2086. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  2087. id = int64(item.(map[string]interface{})["id"].(float64))
  2088. }
  2089. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2090. is_content = item.(map[string]interface{})["content"].(string)
  2091. }
  2092. fallassessmentBody := models.XtPatientFallassessmentMedical{
  2093. ID: id,
  2094. UserOrgId: user_org_id,
  2095. PatientId: patient_id,
  2096. Status: 1,
  2097. Ctime: time.Now().Unix(),
  2098. Mtime: time.Now().Unix(),
  2099. FassementId: lastPatientFallassessment.ID,
  2100. IsCheckStatus: is_status,
  2101. Content: is_content,
  2102. }
  2103. service.SaveFallassessmentMedical(tx, fallassessmentBody)
  2104. }
  2105. }
  2106. if dataBody["is_touxidiedao"] != nil && reflect.TypeOf(dataBody["is_touxidiedao"]).String() == "[]interface {}" {
  2107. isTouXiDieDao, _ := dataBody["is_touxidiedao"].([]interface{})
  2108. for _, item := range isTouXiDieDao {
  2109. var is_status int64
  2110. var is_content string
  2111. var id int64
  2112. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  2113. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  2114. }
  2115. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  2116. id = int64(item.(map[string]interface{})["id"].(float64))
  2117. }
  2118. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2119. is_content = item.(map[string]interface{})["content"].(string)
  2120. }
  2121. fallassessmentFall := models.XtPatientFallassessmentFall{
  2122. ID: id,
  2123. UserOrgId: user_org_id,
  2124. PatientId: patient_id,
  2125. Status: 1,
  2126. Ctime: time.Now().Unix(),
  2127. Mtime: time.Now().Unix(),
  2128. FassementId: lastPatientFallassessment.ID,
  2129. IsCheckStatus: is_status,
  2130. Content: is_content,
  2131. }
  2132. service.SaveFallassessmentFall(tx, fallassessmentFall)
  2133. }
  2134. }
  2135. if dataBody["is_xiaoguo"] != nil && reflect.TypeOf(dataBody["is_xiaoguo"]).String() == "[]interface {}" {
  2136. isXiaoGuo, _ := dataBody["is_xiaoguo"].([]interface{})
  2137. for _, item := range isXiaoGuo {
  2138. var id int64
  2139. var is_status int64
  2140. var is_content string
  2141. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  2142. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  2143. }
  2144. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  2145. id = int64(item.(map[string]interface{})["id"].(float64))
  2146. }
  2147. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2148. is_content = item.(map[string]interface{})["content"].(string)
  2149. }
  2150. fallassessmentPrevent := models.XtPatientFallassessmentPrevent{
  2151. UserOrgId: user_org_id,
  2152. PatientId: patient_id,
  2153. Status: 1,
  2154. Ctime: time.Now().Unix(),
  2155. Mtime: time.Now().Unix(),
  2156. FassementId: lastPatientFallassessment.ID,
  2157. IsCheckStatus: is_status,
  2158. Content: is_content,
  2159. ID: id,
  2160. }
  2161. service.SaveFallassessmentPrevent(tx, fallassessmentPrevent)
  2162. }
  2163. }
  2164. if dataBody["is_yishizt"] != nil && reflect.TypeOf(dataBody["is_yishizt"]).String() == "[]interface {}" {
  2165. isYiShiZt, _ := dataBody["is_yishizt"].([]interface{})
  2166. for _, item := range isYiShiZt {
  2167. var is_status int64
  2168. var is_content string
  2169. var id int64
  2170. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  2171. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  2172. }
  2173. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2174. is_content = item.(map[string]interface{})["content"].(string)
  2175. }
  2176. fallassessmentRealize := models.XtPatientFallassessmentRealize{
  2177. UserOrgId: user_org_id,
  2178. PatientId: patient_id,
  2179. Status: 1,
  2180. Ctime: time.Now().Unix(),
  2181. Mtime: time.Now().Unix(),
  2182. FassementId: lastPatientFallassessment.ID,
  2183. IsCheckStatus: is_status,
  2184. Content: is_content,
  2185. ID: id,
  2186. }
  2187. service.SaveFallassessmentPealize(tx, fallassessmentRealize)
  2188. }
  2189. }
  2190. if dataBody["is_zilin"] != nil && reflect.TypeOf(dataBody["is_zilin"]).String() == "[]interface {}" {
  2191. isZiLin, _ := dataBody["is_zilin"].([]interface{})
  2192. for _, item := range isZiLin {
  2193. var is_status int64
  2194. var is_content string
  2195. var id int64
  2196. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  2197. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  2198. }
  2199. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  2200. id = int64(item.(map[string]interface{})["id"].(float64))
  2201. }
  2202. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2203. is_content = item.(map[string]interface{})["content"].(string)
  2204. }
  2205. fallassessmentCare := models.XtPatientFallassessmentCare{
  2206. UserOrgId: user_org_id,
  2207. PatientId: patient_id,
  2208. Status: 1,
  2209. Ctime: time.Now().Unix(),
  2210. Mtime: time.Now().Unix(),
  2211. FassementId: lastPatientFallassessment.ID,
  2212. IsCheckStatus: is_status,
  2213. Content: is_content,
  2214. ID: id,
  2215. }
  2216. service.SaveFallassessmentCare(tx, fallassessmentCare)
  2217. }
  2218. }
  2219. if dataBody["list"] != nil && reflect.TypeOf(dataBody["list"]).String() == "[]interface {}" {
  2220. list, _ := dataBody["list"].([]interface{})
  2221. for _, item := range list {
  2222. var is_status int64
  2223. var is_content string
  2224. var id int64
  2225. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  2226. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  2227. }
  2228. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2229. is_content = item.(map[string]interface{})["content"].(string)
  2230. }
  2231. PatientFallassessmentAdd := models.XtPatientFallassessmentAdd{
  2232. ID: id,
  2233. UserOrgId: user_org_id,
  2234. PatientId: patient_id,
  2235. Status: 1,
  2236. Ctime: time.Now().Unix(),
  2237. Mtime: time.Now().Unix(),
  2238. FassementId: lastPatientFallassessment.ID,
  2239. IsCheckStatus: is_status,
  2240. Content: is_content,
  2241. }
  2242. service.SaveFallassessmentAdd(tx, PatientFallassessmentAdd)
  2243. }
  2244. }
  2245. if dataBody["listOne"] != nil && reflect.TypeOf(dataBody["listOne"]).String() == "[]interface {}" {
  2246. listOne, _ := dataBody["listOne"].([]interface{})
  2247. for _, item := range listOne {
  2248. var is_status int64
  2249. var is_content string
  2250. var id int64
  2251. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  2252. is_status = int64(item.(map[string]interface{})["is_status"].(float64))
  2253. }
  2254. if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
  2255. id = int64(item.(map[string]interface{})["id"].(float64))
  2256. }
  2257. if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
  2258. is_content = item.(map[string]interface{})["content"].(string)
  2259. }
  2260. PatientFallassessmentAddCopy := models.XtPatientFallassessmentAddCopy{
  2261. ID: id,
  2262. UserOrgId: user_org_id,
  2263. PatientId: patient_id,
  2264. Status: 1,
  2265. Ctime: time.Now().Unix(),
  2266. Mtime: time.Now().Unix(),
  2267. FassementId: lastPatientFallassessment.ID,
  2268. IsCheckStatus: is_status,
  2269. Content: is_content,
  2270. }
  2271. service.SavePatientFallassessmentAddCopy(tx, PatientFallassessmentAddCopy)
  2272. }
  2273. }
  2274. tx.Commit()
  2275. this.ServeSuccessJSON(map[string]interface{}{
  2276. "patientFallassessment": patientFallassessment,
  2277. })
  2278. }
  2279. func (this *PatientDataConfigAPIController) SavePediatrcFallassment() {
  2280. dataBody := make(map[string]interface{}, 0)
  2281. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2282. if err != nil {
  2283. utils.ErrorLog(err.Error())
  2284. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2285. return
  2286. }
  2287. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  2288. admin_user_id := int64(dataBody["tumble"].(float64))
  2289. patient_id := int64(dataBody["patient_id"].(float64))
  2290. record_date := dataBody["date"].(string)
  2291. total := int64(dataBody["pedia_Totalpoints"].(float64))
  2292. timeLayout := "2006-01-02"
  2293. loc, _ := time.LoadLocation("Local")
  2294. var recordDate int64
  2295. var str string
  2296. if len(record_date) > 0 {
  2297. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  2298. if err != nil {
  2299. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2300. return
  2301. }
  2302. recordDate = theTime.Unix()
  2303. }
  2304. //if dataBody["age"] != nil && reflect.TypeOf(dataBody["age"]).String() == "[]interface {}" {
  2305. // ageList, _ := dataBody["age"].([]interface{})
  2306. //
  2307. // for _, item := range ageList {
  2308. // //记录日志
  2309. // byterequest, _ := json.Marshal(item)
  2310. // str += string(byterequest) + ","
  2311. // }
  2312. //}
  2313. //
  2314. //if dataBody["cognize"] != nil && reflect.TypeOf(dataBody["cognize"]).String() == "[]interface {}" {
  2315. // cognizeList, _ := dataBody["cognize"].([]interface{})
  2316. //
  2317. // for _, item := range cognizeList {
  2318. // //记录日志
  2319. // byterequest, _ := json.Marshal(item)
  2320. // str += string(byterequest) + ","
  2321. // }
  2322. //}
  2323. //
  2324. //if dataBody["diagnosis"] != nil && reflect.TypeOf(dataBody["diagnosis"]).String() == "[]interface {}" {
  2325. // diagnosisList, _ := dataBody["diagnosis"].([]interface{})
  2326. //
  2327. // for _, item := range diagnosisList {
  2328. // //记录日志
  2329. // byterequest, _ := json.Marshal(item)
  2330. // str += string(byterequest) + ","
  2331. // }
  2332. //}
  2333. //
  2334. //if dataBody["environment"] != nil && reflect.TypeOf(dataBody["environment"]).String() == "[]interface {}" {
  2335. // environmentList, _ := dataBody["environment"].([]interface{})
  2336. //
  2337. // for _, item := range environmentList {
  2338. // //记录日志
  2339. // byterequest, _ := json.Marshal(item)
  2340. // str += string(byterequest) + ","
  2341. // }
  2342. //}
  2343. //
  2344. //if dataBody["medicine"] != nil && reflect.TypeOf(dataBody["medicine"]).String() == "[]interface {}" {
  2345. // medicineList, _ := dataBody["medicine"].([]interface{})
  2346. //
  2347. // for _, item := range medicineList {
  2348. // //记录日志
  2349. // byterequest, _ := json.Marshal(item)
  2350. // str += string(byterequest) + ","
  2351. // }
  2352. //}
  2353. //
  2354. //if dataBody["sex"] != nil && reflect.TypeOf(dataBody["sex"]).String() == "[]interface {}" {
  2355. // sexList, _ := dataBody["medicine"].([]interface{})
  2356. //
  2357. // for _, item := range sexList {
  2358. // //记录日志
  2359. // byterequest, _ := json.Marshal(item)
  2360. // str += string(byterequest) + ","
  2361. // }
  2362. //}
  2363. age := int64(dataBody["age"].(float64))
  2364. sex := int64(dataBody["sex"].(float64))
  2365. diagnosis := int64(dataBody["diagnosis"].(float64))
  2366. cognize := int64(dataBody["cognize"].(float64))
  2367. environment := int64(dataBody["environment"].(float64))
  2368. medicine := int64(dataBody["medicine"].(float64))
  2369. tumble := int64(dataBody["tumble"].(float64))
  2370. pedFallssessment := models.XtPatientPedFallssessment{
  2371. PatientId: patient_id,
  2372. UserOrgId: user_org_id,
  2373. Status: 1,
  2374. Ctime: time.Now().Unix(),
  2375. Mtime: 0,
  2376. Text: str,
  2377. RecordDate: recordDate,
  2378. Total: total,
  2379. AdminUserId: admin_user_id,
  2380. Type: 1,
  2381. Age: age,
  2382. Sex: sex,
  2383. Diagnosis: diagnosis,
  2384. Environment: environment,
  2385. Medicine: medicine,
  2386. Tumble: tumble,
  2387. Cognize: cognize,
  2388. }
  2389. service.CreatePadFallssessment(pedFallssessment)
  2390. this.ServeSuccessJSON(map[string]interface{}{
  2391. "pedFallssessment": pedFallssessment,
  2392. })
  2393. }
  2394. func (this *PatientDataConfigAPIController) GetBedDiatricFallassessmentList() {
  2395. patient_id, _ := this.GetInt64("patient_id")
  2396. is_type, _ := this.GetInt64("is_type")
  2397. limit, _ := this.GetInt64("limit")
  2398. page, _ := this.GetInt64("page")
  2399. orgId := this.GetAdminUserInfo().CurrentOrgId
  2400. list, total, _ := service.GetBedDiatricFallassessmentList(patient_id, is_type, orgId, limit, page)
  2401. this.ServeSuccessJSON(map[string]interface{}{
  2402. "list": list,
  2403. "total": total,
  2404. })
  2405. }
  2406. func (this *PatientDataConfigAPIController) GetPedPatientFallassessmentById() {
  2407. id, _ := this.GetInt64("id")
  2408. fallassessment, _ := service.GetPedPatientFallassessmentById(id)
  2409. this.ServeSuccessJSON(map[string]interface{}{
  2410. "fallassessment": fallassessment,
  2411. })
  2412. }
  2413. func (this *PatientDataConfigAPIController) UpdatePatientFallassessmentById() {
  2414. }
  2415. func (this *PatientDataConfigAPIController) DeletePadPatientFallassment() {
  2416. id, _ := this.GetInt64("id")
  2417. service.DeletePadPatientFallassment(id)
  2418. this.ServeSuccessJSON(map[string]interface{}{
  2419. "msg": "ok",
  2420. })
  2421. }
  2422. func (this *PatientDataConfigAPIController) SavePatientPressuresore() {
  2423. }
  2424. func (this *PatientDataConfigAPIController) UpdatePedPatientFallassessment() {
  2425. dataBody := make(map[string]interface{}, 0)
  2426. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2427. if err != nil {
  2428. utils.ErrorLog(err.Error())
  2429. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2430. return
  2431. }
  2432. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  2433. id := int64(dataBody["id"].(float64))
  2434. admin_user_id := int64(dataBody["tumble"].(float64))
  2435. patient_id := int64(dataBody["patient_id"].(float64))
  2436. record_date := dataBody["date"].(string)
  2437. total := int64(dataBody["pedia_Totalpoints"].(float64))
  2438. timeLayout := "2006-01-02"
  2439. loc, _ := time.LoadLocation("Local")
  2440. var recordDate int64
  2441. var str string
  2442. if len(record_date) > 0 {
  2443. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  2444. if err != nil {
  2445. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2446. return
  2447. }
  2448. recordDate = theTime.Unix()
  2449. }
  2450. age := int64(dataBody["age"].(float64))
  2451. sex := int64(dataBody["sex"].(float64))
  2452. diagnosis := int64(dataBody["diagnosis"].(float64))
  2453. environment := int64(dataBody["environment"].(float64))
  2454. medicine := int64(dataBody["medicine"].(float64))
  2455. tumble := int64(dataBody["tumble"].(float64))
  2456. cognize := int64(dataBody["cognize"].(float64))
  2457. pedFallssessment := models.XtPatientPedFallssessment{
  2458. ID: id,
  2459. PatientId: patient_id,
  2460. UserOrgId: user_org_id,
  2461. Status: 1,
  2462. Ctime: time.Now().Unix(),
  2463. Mtime: 0,
  2464. Text: str,
  2465. RecordDate: recordDate,
  2466. Total: total,
  2467. AdminUserId: admin_user_id,
  2468. Type: 1,
  2469. Age: age,
  2470. Sex: sex,
  2471. Diagnosis: diagnosis,
  2472. Environment: environment,
  2473. Medicine: medicine,
  2474. Tumble: tumble,
  2475. Cognize: cognize,
  2476. }
  2477. service.UpdatePedFallssessment(pedFallssessment)
  2478. this.ServeSuccessJSON(map[string]interface{}{
  2479. "pedFallssessment": pedFallssessment,
  2480. })
  2481. }
  2482. func (this *PatientDataConfigAPIController) SavePatientHpPressuresore() {
  2483. dataBody := make(map[string]interface{}, 0)
  2484. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2485. if err != nil {
  2486. utils.ErrorLog(err.Error())
  2487. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2488. return
  2489. }
  2490. record_date := dataBody["record_date"].(string)
  2491. timeLayout := "2006-01-02"
  2492. loc, _ := time.LoadLocation("Local")
  2493. var recordDate int64
  2494. if len(record_date) > 0 {
  2495. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  2496. if err != nil {
  2497. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2498. return
  2499. }
  2500. recordDate = theTime.Unix()
  2501. }
  2502. var str string
  2503. if dataBody["list"] != nil && reflect.TypeOf(dataBody["list"]).String() == "[]interface {}" {
  2504. list, _ := dataBody["list"].([]interface{})
  2505. for _, item := range list {
  2506. byterequest, _ := json.Marshal(item)
  2507. str += string(byterequest)
  2508. }
  2509. }
  2510. patient_id := int64(dataBody["patient_id"].(float64))
  2511. is_type := int64(dataBody["is_type"].(float64))
  2512. var data models.XtPatientPedFallssessment
  2513. json.Unmarshal(this.Ctx.Input.RequestBody, &data)
  2514. orgId := this.GetAdminUserInfo().CurrentOrgId
  2515. pedFallssessment := models.XtPatientPedFallssessment{
  2516. PatientId: patient_id,
  2517. UserOrgId: orgId,
  2518. Status: 1,
  2519. Ctime: time.Now().Unix(),
  2520. Mtime: time.Now().Unix(),
  2521. Text: str,
  2522. RecordDate: recordDate,
  2523. Total: 0,
  2524. AdminUserId: 0,
  2525. Type: is_type,
  2526. Age: 0,
  2527. Cognize: 0,
  2528. Diagnosis: 0,
  2529. Environment: 0,
  2530. Medicine: 0,
  2531. Sex: 0,
  2532. Tumble: 0,
  2533. }
  2534. service.CreatePatientPedList(pedFallssessment)
  2535. this.ServeSuccessJSON(map[string]interface{}{
  2536. "pedFallssessment": pedFallssessment,
  2537. })
  2538. }
  2539. func (this *PatientDataConfigAPIController) GetPatientBedList() {
  2540. patient_id, _ := this.GetInt64("patient_id")
  2541. page, _ := this.GetInt64("page")
  2542. limit, _ := this.GetInt64("limit")
  2543. is_type, _ := this.GetInt64("is_type")
  2544. orgId := this.GetAdminUserInfo().CurrentOrgId
  2545. list, total, _ := service.GetBedDiatricFallassessmentList(patient_id, is_type, orgId, limit, page)
  2546. this.ServeSuccessJSON(map[string]interface{}{
  2547. "list": list,
  2548. "total": total,
  2549. })
  2550. }
  2551. func (this *PatientDataConfigAPIController) UpdateBedPatientList() {
  2552. dataBody := make(map[string]interface{}, 0)
  2553. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2554. if err != nil {
  2555. utils.ErrorLog(err.Error())
  2556. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2557. return
  2558. }
  2559. record_date := dataBody["record_date"].(string)
  2560. timeLayout := "2006-01-02"
  2561. loc, _ := time.LoadLocation("Local")
  2562. var recordDate int64
  2563. if len(record_date) > 0 {
  2564. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  2565. if err != nil {
  2566. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2567. return
  2568. }
  2569. recordDate = theTime.Unix()
  2570. }
  2571. var str string
  2572. if dataBody["list"] != nil && reflect.TypeOf(dataBody["list"]).String() == "[]interface {}" {
  2573. list, _ := dataBody["list"].([]interface{})
  2574. for _, item := range list {
  2575. byterequest, _ := json.Marshal(item)
  2576. str += string(byterequest)
  2577. }
  2578. }
  2579. patient_id := int64(dataBody["patient_id"].(float64))
  2580. id := int64(dataBody["id"].(float64))
  2581. is_type := int64(dataBody["is_type"].(float64))
  2582. var data models.XtPatientPedFallssessment
  2583. json.Unmarshal(this.Ctx.Input.RequestBody, &data)
  2584. orgId := this.GetAdminUserInfo().CurrentOrgId
  2585. pedFallssessment := models.XtPatientPedFallssessment{
  2586. ID: id,
  2587. PatientId: patient_id,
  2588. UserOrgId: orgId,
  2589. Status: 1,
  2590. Ctime: time.Now().Unix(),
  2591. Mtime: time.Now().Unix(),
  2592. Text: str,
  2593. RecordDate: recordDate,
  2594. Total: 0,
  2595. AdminUserId: 0,
  2596. Type: is_type,
  2597. Age: 0,
  2598. Cognize: 0,
  2599. Diagnosis: 0,
  2600. Environment: 0,
  2601. Medicine: 0,
  2602. Sex: 0,
  2603. Tumble: 0,
  2604. }
  2605. service.UpdatePatientPedList(pedFallssessment)
  2606. this.ServeSuccessJSON(map[string]interface{}{
  2607. "pedFallssessment": pedFallssessment,
  2608. })
  2609. }