patient_dataconfig_api_controller.go 88KB

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