patient_dataconfig_api_controller.go 97KB

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