patient_dataconfig_api_controller.go 87KB

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