patient_dataconfig_api_controller.go 100KB

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