patient_dataconfig_api_controller.go 87KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763
  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. record_date := this.GetString("record_date")
  808. timeLayout := "2006-01-02"
  809. loc, _ := time.LoadLocation("Local")
  810. var theStartTime int64
  811. if len(record_date) > 0 {
  812. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  813. if err != nil {
  814. utils.ErrorLog(err.Error())
  815. }
  816. theStartTime = theTime.Unix()
  817. }
  818. if patientID <= 0 || len(content) == 0 {
  819. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  820. return
  821. }
  822. adminUserInfo := this.GetAdminUserInfo()
  823. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  824. if getPatientErr != nil {
  825. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  826. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  827. return
  828. } else if patient == nil {
  829. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  830. return
  831. }
  832. now := time.Now().Unix()
  833. record := models.PatientRescueRecord{
  834. OrgID: adminUserInfo.CurrentOrgId,
  835. PatientID: patientID,
  836. Recorder: adminUserInfo.AdminUser.Id,
  837. RecordTime: theStartTime,
  838. Content: content,
  839. Status: 1,
  840. CreateTime: now,
  841. ModifyTime: now,
  842. }
  843. createErr := service.CreatePatientRescueRecord(&record)
  844. if createErr != nil {
  845. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  846. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  847. return
  848. }
  849. this.ServeSuccessJSON(map[string]interface{}{
  850. "record": record,
  851. })
  852. }
  853. // /api/patient/rescue/delete
  854. // @param patient_id:int
  855. // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
  856. func (this *PatientDataConfigAPIController) DeleteRescue() {
  857. patientID, _ := this.GetInt64("patient_id")
  858. idsStr := this.GetString("ids")
  859. if patientID <= 0 || len(idsStr) == 0 {
  860. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  861. return
  862. }
  863. adminUserInfo := this.GetAdminUserInfo()
  864. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  865. if getPatientErr != nil {
  866. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  867. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  868. return
  869. } else if patient == nil {
  870. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  871. return
  872. }
  873. recordIDStrs := strings.Split(idsStr, ",")
  874. recordIDs := make([]int64, 0, len(recordIDStrs))
  875. for _, idStr := range recordIDStrs {
  876. id, parseErr := strconv.Atoi(idStr)
  877. if parseErr != nil {
  878. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  879. return
  880. }
  881. recordIDs = append(recordIDs, int64(id))
  882. }
  883. deleteErr := service.DeletePatientResuceRecordsInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  884. if deleteErr != nil {
  885. this.ErrorLog("删除患者抢救记录失败:%v", deleteErr)
  886. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  887. return
  888. }
  889. this.ServeSuccessJSON(nil)
  890. }
  891. func (this *PatientDataConfigAPIController) ModifyCourse() {
  892. patientID, _ := this.GetInt64("patient_id")
  893. content := this.GetString("content")
  894. id, _ := this.GetInt64("id", 0)
  895. record_time_str := this.GetString("record_time")
  896. title := this.GetString("title")
  897. if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
  898. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  899. return
  900. }
  901. //timeLayout := "2006-01-02"
  902. //loc, _ := time.LoadLocation("Local")
  903. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  904. adminUserInfo := this.GetAdminUserInfo()
  905. //patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  906. //if getPatientErr != nil {
  907. // this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  908. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  909. // return
  910. //} else if patient == nil {
  911. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  912. // return
  913. //}
  914. now := time.Now().Unix()
  915. record := models.PatientDiseaseCourse{
  916. ID: id,
  917. OrgID: adminUserInfo.CurrentOrgId,
  918. PatientID: patientID,
  919. Recorder: adminUserInfo.AdminUser.Id,
  920. Content: content,
  921. Status: 1,
  922. CreateTime: now,
  923. ModifyTime: now,
  924. Title: title,
  925. RecordTime: checkDate.Unix(),
  926. }
  927. createErr := service.ModifyPatientCourses(&record)
  928. if createErr != nil {
  929. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  930. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  931. return
  932. }
  933. this.ServeSuccessJSON(map[string]interface{}{
  934. "record": record,
  935. })
  936. }
  937. func (this *PatientDataConfigAPIController) GetPatientDialysisInforList() {
  938. patientID, _ := this.GetInt64("patient_id")
  939. record_date := this.GetString("record_date")
  940. timeLayout := "2006-01-02"
  941. loc, _ := time.LoadLocation("Local")
  942. var startTime int64
  943. if len(record_date) > 0 {
  944. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  945. if err != nil {
  946. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  947. return
  948. }
  949. startTime = theTime.Unix()
  950. }
  951. //获取患者姓名
  952. patient, _ := service.GetPatientName(patientID)
  953. orgId := this.GetAdminUserInfo().CurrentOrgId
  954. //获取透析处方
  955. prescription, _ := service.GetDialysisPrescription(patientID, orgId, startTime)
  956. //获取透前评估
  957. assessmentBefor, _ := service.GetAssessmentBefor(orgId, patientID, startTime)
  958. //透析上机
  959. order, _ := service.GetDialysisOrder(orgId, patientID, startTime)
  960. //透析监测
  961. monitor, _ := service.GetFistMonitorSix(orgId, patientID, startTime)
  962. //透析医嘱
  963. advice, _ := service.GetBloodDoctorAdvice(startTime, orgId, patientID)
  964. //透后评估
  965. afterDislysis, _ := service.GetAssessmentAfterDissData(patientID, orgId, startTime)
  966. this.ServeSuccessJSON(map[string]interface{}{
  967. "patient": patient,
  968. "prescription": prescription,
  969. "assessmentBefor": assessmentBefor,
  970. "order": order,
  971. "monitor": monitor,
  972. "advice": advice,
  973. "afterDislysis": afterDislysis,
  974. })
  975. }
  976. func (this *PatientDataConfigAPIController) GetContextScheduleList() {
  977. limit, _ := this.GetInt64("limit")
  978. page, _ := this.GetInt64("page")
  979. start_time := this.GetString("start_time")
  980. end_time := this.GetString("end_time")
  981. timeLayout := "2006-01-02"
  982. loc, _ := time.LoadLocation("Local")
  983. var startTime int64
  984. if len(start_time) > 0 {
  985. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  986. if err != nil {
  987. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  988. return
  989. }
  990. startTime = theTime.Unix()
  991. }
  992. var endTime int64
  993. if len(end_time) > 0 {
  994. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  995. if err != nil {
  996. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  997. return
  998. }
  999. startTime = theTime.Unix()
  1000. }
  1001. org_id := this.GetAdminUserInfo().CurrentOrgId
  1002. schedule, total, _ := service.GetContextScheduleListGroupPatientId(limit, page, startTime, endTime, org_id)
  1003. list, _, _ := service.GetContextScheduleListPatientId(startTime, endTime, org_id)
  1004. patients, _ := service.GetAllpatientThirty(org_id)
  1005. devicenumber, _ := service.GetAllBedNumber(org_id)
  1006. this.ServeSuccessJSON(map[string]interface{}{
  1007. "schedule": schedule,
  1008. "total": total,
  1009. "list": list,
  1010. "patients": patients,
  1011. "devicenumber": devicenumber,
  1012. })
  1013. }
  1014. func (this *PatientDataConfigAPIController) GetPatientAllagicList() {
  1015. id, _ := this.GetInt64("id")
  1016. orgId := this.GetAdminUserInfo().CurrentOrgId
  1017. list, _ := service.GetPatientAllagicList(id, orgId)
  1018. this.ServeSuccessJSON(map[string]interface{}{
  1019. "list": list,
  1020. })
  1021. }
  1022. func (this *PatientDataConfigAPIController) SaveSiteMap() {
  1023. dataBody := make(map[string]interface{}, 0)
  1024. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1025. if err != nil {
  1026. utils.ErrorLog(err.Error())
  1027. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1028. return
  1029. }
  1030. patient_id := int64(dataBody["patient_id"].(float64))
  1031. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  1032. id := int64(dataBody["id"].(float64))
  1033. if dataBody["a_left"] != nil && reflect.TypeOf(dataBody["a_left"]).String() == "[]interface {}" {
  1034. prescriptions, _ := dataBody["a_left"].([]interface{})
  1035. service.UpdateValsualAleft(patient_id, user_org_id)
  1036. for _, item := range prescriptions {
  1037. var a_num float64
  1038. var mark_num float64
  1039. if item.(map[string]interface{})["a_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_num"]).String() == "float64" {
  1040. a_num = item.(map[string]interface{})["a_num"].(float64)
  1041. }
  1042. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1043. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1044. }
  1045. fmt.Println(a_num, mark_num)
  1046. valsualALeft := models.XtDeviceValsualALeft{
  1047. ANum: a_num,
  1048. MarkNum: mark_num,
  1049. UserOrgId: user_org_id,
  1050. PatientId: patient_id,
  1051. Ctime: time.Now().Unix(),
  1052. Mtime: time.Now().Unix(),
  1053. MapId: 0,
  1054. Status: 1,
  1055. }
  1056. service.CreateValsualAleft(valsualALeft)
  1057. }
  1058. }
  1059. is_append := int64(dataBody["is_append"].(float64))
  1060. is_img_v := int64(dataBody["is_img_v"].(float64))
  1061. is_img_a := int64(dataBody["is_img_a"].(float64))
  1062. a_top := dataBody["a_top"].(float64)
  1063. av_bkx := dataBody["av_bkx"].(float64)
  1064. av_bky := dataBody["av_bky"].(float64)
  1065. if dataBody["fangxiang_a"] != nil && reflect.TypeOf(dataBody["fangxiang_a"]).String() == "[]interface {}" {
  1066. prescriptions, _ := dataBody["fangxiang_a"].([]interface{})
  1067. service.ValsualMapFangxiangA(patient_id, user_org_id)
  1068. for _, item := range prescriptions {
  1069. var a_num float64
  1070. var mark_num float64
  1071. var mark_top float64
  1072. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1073. a_num = item.(map[string]interface{})["left"].(float64)
  1074. }
  1075. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1076. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1077. }
  1078. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1079. mark_top = item.(map[string]interface{})["top"].(float64)
  1080. }
  1081. ValsualMapFangxiangA := models.XtDeviceValsualMapFangxiangA{
  1082. PatientId: patient_id,
  1083. UserOrgId: user_org_id,
  1084. Status: 1,
  1085. Left: a_num,
  1086. MarkNum: mark_num,
  1087. Top: mark_top,
  1088. MapId: 0,
  1089. Ctime: time.Now().Unix(),
  1090. Mtime: time.Now().Unix(),
  1091. }
  1092. service.CreateValsualMapFangxiangA(ValsualMapFangxiangA)
  1093. }
  1094. }
  1095. fangxiang_a_num := dataBody["fangxiang_a_num"].(float64)
  1096. fangxiang_a_top := dataBody["fangxiang_a_top"].(float64)
  1097. fangxiang_v_left := dataBody["fangxiang_v_left"].(float64)
  1098. fangxiang_v_num := dataBody["fangxiang_v_num"].(float64)
  1099. fangxiang_v_top := dataBody["fangxiang_v_top"].(float64)
  1100. if dataBody["fangxiang_v"] != nil && reflect.TypeOf(dataBody["fangxiang_v"]).String() == "[]interface {}" {
  1101. prescriptions, _ := dataBody["fangxiang_v"].([]interface{})
  1102. service.UpdateValsualMapFangxiangV(patient_id, user_org_id)
  1103. for _, item := range prescriptions {
  1104. var a_num float64
  1105. var mark_num float64
  1106. var mark_top float64
  1107. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1108. a_num = item.(map[string]interface{})["left"].(float64)
  1109. }
  1110. if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
  1111. mark_num = item.(map[string]interface{})["markNum"].(float64)
  1112. }
  1113. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1114. mark_top = item.(map[string]interface{})["top"].(float64)
  1115. }
  1116. ValsualMapFangxiangV := models.XtDeviceValsualMapFangxiangV{
  1117. PatientId: patient_id,
  1118. UserOrgId: user_org_id,
  1119. Status: 1,
  1120. Left: a_num,
  1121. MarkNum: mark_num,
  1122. Top: mark_top,
  1123. MapId: 0,
  1124. Ctime: time.Now().Unix(),
  1125. Mtime: time.Now().Unix(),
  1126. }
  1127. service.CreateValsualMapFangxiangV(ValsualMapFangxiangV)
  1128. }
  1129. }
  1130. fangxiang_a_left := dataBody["fangxiang_a_left"].(float64)
  1131. if dataBody["fuzhu_a"] != nil && reflect.TypeOf(dataBody["fuzhu_a"]).String() == "[]interface {}" {
  1132. prescriptions, _ := dataBody["fuzhu_a"].([]interface{})
  1133. service.UpdateValSualFuzhA(patient_id, user_org_id)
  1134. for _, item := range prescriptions {
  1135. var a_left float64
  1136. var a_markNum float64
  1137. var a_top float64
  1138. if item.(map[string]interface{})["a_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_left"]).String() == "float64" {
  1139. a_left = item.(map[string]interface{})["a_left"].(float64)
  1140. }
  1141. if item.(map[string]interface{})["a_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_markNum"]).String() == "float64" {
  1142. a_markNum = item.(map[string]interface{})["a_markNum"].(float64)
  1143. }
  1144. if item.(map[string]interface{})["a_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_top"]).String() == "float64" {
  1145. a_top = item.(map[string]interface{})["a_top"].(float64)
  1146. }
  1147. valsualFuzhuA := models.XtDeviceValsualFuzhuA{
  1148. PatientId: patient_id,
  1149. UserOrgId: user_org_id,
  1150. Status: 1,
  1151. Ctime: time.Now().Unix(),
  1152. Mtime: time.Now().Unix(),
  1153. ALeft: a_left,
  1154. AMarkNum: a_markNum,
  1155. ATop: a_top,
  1156. MapId: 0,
  1157. }
  1158. service.CreateValSualFuzhA(valsualFuzhuA)
  1159. }
  1160. }
  1161. fuzhu_a_left := dataBody["fuzhu_a_left"].(float64)
  1162. fuzhu_a_num := dataBody["fuzhu_a_num"].(float64)
  1163. fuzhu_a_top := dataBody["fuzhu_a_top"].(float64)
  1164. left_a := dataBody["left_a"].(float64)
  1165. left_v := dataBody["left_v"].(float64)
  1166. if dataBody["fuzhu_v"] != nil && reflect.TypeOf(dataBody["fuzhu_v"]).String() == "[]interface {}" {
  1167. prescriptions, _ := dataBody["fuzhu_v"].([]interface{})
  1168. service.UpdateVasuaLfuzhuV(patient_id, user_org_id)
  1169. for _, item := range prescriptions {
  1170. var v_left float64
  1171. var v_markNum float64
  1172. var v_top float64
  1173. if item.(map[string]interface{})["v_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_left"]).String() == "float64" {
  1174. v_left = item.(map[string]interface{})["v_left"].(float64)
  1175. }
  1176. if item.(map[string]interface{})["v_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_markNum"]).String() == "float64" {
  1177. v_markNum = item.(map[string]interface{})["v_markNum"].(float64)
  1178. }
  1179. if item.(map[string]interface{})["v_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_top"]).String() == "float64" {
  1180. v_top = item.(map[string]interface{})["v_top"].(float64)
  1181. }
  1182. fuzhuV := models.XtDeviceValsualFuzhuV{
  1183. PatientId: patient_id,
  1184. UserOrgId: user_org_id,
  1185. Status: 1,
  1186. Ctime: time.Now().Unix(),
  1187. Mtime: 1,
  1188. VMarkNum: v_markNum,
  1189. VLeft: v_left,
  1190. VTop: v_top,
  1191. MapId: 0,
  1192. }
  1193. service.CreateVasuaLfuzhuV(fuzhuV)
  1194. }
  1195. }
  1196. fuzhu_v_left := dataBody["fuzhu_v_left"].(float64)
  1197. fuzhu_v_num := dataBody["fuzhu_v_num"].(float64)
  1198. fuzhu_v_top := dataBody["fuzhu_v_top"].(float64)
  1199. scalea_num := dataBody["scalea_num"].(float64)
  1200. scalev_num := dataBody["scalev_num"].(float64)
  1201. if dataBody["text_arr"] != nil && reflect.TypeOf(dataBody["text_arr"]).String() == "[]interface {}" {
  1202. prescriptions, _ := dataBody["text_arr"].([]interface{})
  1203. service.UpdateTextArr(patient_id, user_org_id)
  1204. for _, item := range prescriptions {
  1205. var left float64
  1206. var text_markNum string
  1207. var v_top float64
  1208. var width float64
  1209. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1210. left = item.(map[string]interface{})["left"].(float64)
  1211. }
  1212. if item.(map[string]interface{})["text"] != nil || reflect.TypeOf(item.(map[string]interface{})["text"]).String() == "string" {
  1213. text_markNum = item.(map[string]interface{})["text"].(string)
  1214. }
  1215. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1216. v_top = item.(map[string]interface{})["top"].(float64)
  1217. }
  1218. if item.(map[string]interface{})["width"] != nil || reflect.TypeOf(item.(map[string]interface{})["width"]).String() == "float64" {
  1219. width = item.(map[string]interface{})["width"].(float64)
  1220. }
  1221. textArr := models.XtDeviceValsualTextArr{
  1222. PatientId: patient_id,
  1223. UserOrgId: user_org_id,
  1224. Ctime: time.Now().Unix(),
  1225. Mtime: 0,
  1226. Status: 1,
  1227. Left: left,
  1228. Text: text_markNum,
  1229. Top: v_top,
  1230. Width: width,
  1231. MapId: 0,
  1232. }
  1233. service.CreateTextArr(textArr)
  1234. }
  1235. text_left := dataBody["text_left"].(float64)
  1236. text_num := dataBody["text_num"].(float64)
  1237. text_top := dataBody["text_top"].(float64)
  1238. if dataBody["v_left"] != nil && reflect.TypeOf(dataBody["v_left"]).String() == "[]interface {}" {
  1239. prescriptions, _ := dataBody["v_left"].([]interface{})
  1240. service.UpdateValsualVleft(patient_id, user_org_id)
  1241. for _, item := range prescriptions {
  1242. var v_num float64
  1243. var markNum float64
  1244. if item.(map[string]interface{})["v_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_num"]).String() == "float64" {
  1245. v_num = item.(map[string]interface{})["v_num"].(float64)
  1246. }
  1247. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1248. markNum = item.(map[string]interface{})["mark_num"].(float64)
  1249. }
  1250. valsualVLeft := models.XtDeviceValsualVLeft{
  1251. PatientId: patient_id,
  1252. UserOrgId: user_org_id,
  1253. Status: 1,
  1254. Ctime: time.Now().Unix(),
  1255. Mtime: time.Now().Unix(),
  1256. MarkNum: markNum,
  1257. VNum: v_num,
  1258. MapId: 0,
  1259. }
  1260. service.CreateValsualVleft(valsualVLeft)
  1261. }
  1262. }
  1263. if dataBody["aarr"] != nil && reflect.TypeOf(dataBody["aarr"]).String() == "[]interface {}" {
  1264. prescriptions, _ := dataBody["aarr"].([]interface{})
  1265. service.UpdateValusalMapArr(patient_id, user_org_id)
  1266. for _, item := range prescriptions {
  1267. var mark_num float64
  1268. var is_status float64
  1269. var left float64
  1270. var top float64
  1271. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1272. mark_num = item.(map[string]interface{})["mark_num"].(float64)
  1273. }
  1274. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1275. is_status = item.(map[string]interface{})["is_status"].(float64)
  1276. }
  1277. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1278. left = item.(map[string]interface{})["left"].(float64)
  1279. }
  1280. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1281. top = item.(map[string]interface{})["top"].(float64)
  1282. }
  1283. mapArr := models.XtDeviceValusalMapArr{
  1284. PatientId: patient_id,
  1285. UserOrgId: user_org_id,
  1286. Status: 1,
  1287. MarkNum: mark_num,
  1288. Left: left,
  1289. Top: top,
  1290. IsStatus: is_status,
  1291. Ctime: time.Now().Unix(),
  1292. Mtime: 0,
  1293. }
  1294. service.CreateDeviceValusalMapArr(mapArr)
  1295. }
  1296. }
  1297. if dataBody["varr"] != nil && reflect.TypeOf(dataBody["varr"]).String() == "[]interface {}" {
  1298. prescriptions, _ := dataBody["varr"].([]interface{})
  1299. service.UpdateDeviceValusalMapVrr(patient_id, user_org_id)
  1300. for _, item := range prescriptions {
  1301. var mark_num float64
  1302. var is_status float64
  1303. var left float64
  1304. var top float64
  1305. if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
  1306. mark_num = item.(map[string]interface{})["mark_num"].(float64)
  1307. }
  1308. if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
  1309. is_status = item.(map[string]interface{})["is_status"].(float64)
  1310. }
  1311. if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
  1312. left = item.(map[string]interface{})["left"].(float64)
  1313. }
  1314. if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
  1315. top = item.(map[string]interface{})["top"].(float64)
  1316. }
  1317. mapVrr := models.XtDeviceValusalMapVrr{
  1318. PatientId: patient_id,
  1319. UserOrgId: user_org_id,
  1320. Status: 1,
  1321. MarkNum: mark_num,
  1322. Left: left,
  1323. Top: top,
  1324. IsStatus: is_status,
  1325. Ctime: time.Now().Unix(),
  1326. Mtime: 0,
  1327. }
  1328. service.CreateDeviceValusalMapVrr(mapVrr)
  1329. }
  1330. }
  1331. v_num := dataBody["v_num"].(float64)
  1332. v_top := dataBody["v_top"].(float64)
  1333. xuanzhuan_a := dataBody["xuanzhuan_a"].(float64)
  1334. xuanzhuan_v := dataBody["xuanzhuan_v"].(float64)
  1335. img_url := dataBody["img_url"].(string)
  1336. deviceValsualMap := models.XtDeviceValsualMap{
  1337. ID: id,
  1338. PatientId: patient_id,
  1339. IsAppend: is_append,
  1340. IsImgV: is_img_v,
  1341. IsImgA: is_img_a,
  1342. VNum: v_num,
  1343. Status: 1,
  1344. UserOrgId: user_org_id,
  1345. ATop: a_top,
  1346. AvBkx: av_bkx,
  1347. AvBky: av_bky,
  1348. FangxiangALeft: fangxiang_a_left,
  1349. FangxiangANum: fangxiang_a_num,
  1350. FangxiangATop: fangxiang_a_top,
  1351. FangxiangVLeft: fangxiang_v_left,
  1352. FangxiangVNum: fangxiang_v_num,
  1353. FangxiangVTop: fangxiang_v_top,
  1354. FuzhuALeft: fuzhu_a_left,
  1355. FuzhuANum: fuzhu_a_num,
  1356. FuzhuATop: fuzhu_a_top,
  1357. FuzhuVLeft: fuzhu_v_left,
  1358. FuzhuVNum: fuzhu_v_num,
  1359. FuzhuVTop: fuzhu_v_top,
  1360. ScaleaNum: scalea_num,
  1361. ScalevNum: scalev_num,
  1362. TextLeft: text_left,
  1363. TextNum: text_num,
  1364. TextTop: text_top,
  1365. VTop: v_top,
  1366. XuanzhuanA: xuanzhuan_a,
  1367. XuanzhuanV: xuanzhuan_v,
  1368. ALeft: left_a,
  1369. VLeft: left_v,
  1370. ImgUrl: img_url,
  1371. }
  1372. err = service.CreateDeviceValsualMap(deviceValsualMap)
  1373. this.ServeSuccessJSON(map[string]interface{}{
  1374. "deviceValsualMap": deviceValsualMap,
  1375. })
  1376. }
  1377. }
  1378. func (this *PatientDataConfigAPIController) GetPatientSitemap() {
  1379. patient_id, _ := this.GetInt64("patient_id")
  1380. orgId := this.GetAdminUserInfo().CurrentOrgId
  1381. sitemap, _ := service.GetPatientSitemap(patient_id, orgId)
  1382. patients, _ := service.GetPatientByIDOne(orgId, patient_id)
  1383. this.ServeSuccessJSON(map[string]interface{}{
  1384. "sitemap": sitemap,
  1385. "patients": patients,
  1386. })
  1387. }
  1388. func (this *PatientDataConfigAPIController) GetPatientDetailInformedConsent() {
  1389. patient_id, _ := this.GetInt64("patient_id")
  1390. orgId := this.GetAdminUserInfo().CurrentOrgId
  1391. patients, _ := service.GetPatientDetailInformedConsent(patient_id, orgId)
  1392. this.ServeSuccessJSON(map[string]interface{}{
  1393. "patients": patients,
  1394. })
  1395. }
  1396. func (this *PatientDataConfigAPIController) GetPatientMedicalList() {
  1397. patient_id, _ := this.GetInt64("patient_id")
  1398. orgId := this.GetAdminUserInfo().CurrentOrgId
  1399. list, _ := service.GetPatientMedicalList(patient_id, orgId)
  1400. this.ServeSuccessJSON(map[string]interface{}{
  1401. "list": list,
  1402. })
  1403. }
  1404. func (this *PatientDataConfigAPIController) GetAllNurseList() {
  1405. orgId := this.GetAdminUserInfo().CurrentOrgId
  1406. appId := this.GetAdminUserInfo().CurrentAppId
  1407. nurseList, _ := service.GetAllNurseList(orgId, appId)
  1408. this.ServeSuccessJSON(map[string]interface{}{
  1409. "nurseList": nurseList,
  1410. })
  1411. }
  1412. func (this *PatientDataConfigAPIController) SaveFllassessmentList() {
  1413. dataBody := make(map[string]interface{}, 0)
  1414. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1415. if err != nil {
  1416. utils.ErrorLog(err.Error())
  1417. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1418. return
  1419. }
  1420. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  1421. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  1422. is_check := int64(dataBody["is_check"].(float64))
  1423. is_check_one := int64(dataBody["is_check_one"].(float64))
  1424. is_check_two := int64(dataBody["is_check_two"].(float64))
  1425. is_check_three := int64(dataBody["is_check_three"].(float64))
  1426. is_check_four := int64(dataBody["is_check_four"].(float64))
  1427. is_check_five := int64(dataBody["is_check_five"].(float64))
  1428. is_check_six := int64(dataBody["is_check_six"].(float64))
  1429. is_check_seven := int64(dataBody["is_check_seven"].(float64))
  1430. is_check_eight := int64(dataBody["is_check_eight"].(float64))
  1431. is_check_night := int64(dataBody["is_check_night"].(float64))
  1432. is_check_ten := int64(dataBody["is_check_ten"].(float64))
  1433. is_check_eleven := int64(dataBody["is_check_eleven"].(float64))
  1434. is_check_twelve := int64(dataBody["is_check_twelve"].(float64))
  1435. is_check_thirteen := int64(dataBody["is_check_thirteen"].(float64))
  1436. is_check_fourteen := int64(dataBody["is_check_fourteen"].(float64))
  1437. is_check_fifteen := int64(dataBody["is_check_fifteen"].(float64))
  1438. is_check_sixteen := int64(dataBody["is_check_sixteen"].(float64))
  1439. is_check_seventeen := int64(dataBody["is_check_seventeen"].(float64))
  1440. is_check_eighteen := int64(dataBody["is_check_eighteen"].(float64))
  1441. is_check_nineteen := int64(dataBody["is_check_nineteen"].(float64))
  1442. patient_id := int64(dataBody["patient_id"].(float64))
  1443. total := int64(dataBody["total"].(float64))
  1444. ping_date := dataBody["ping_date"].(string)
  1445. record_date := dataBody["record_date"].(string)
  1446. content := dataBody["is_age"].(string)
  1447. content_one := dataBody["is_jiwang"].(string)
  1448. content_two := dataBody["is_yishizt"].(string)
  1449. content_three := dataBody["is_ganguan"].(string)
  1450. content_four := dataBody["is_shentizk"].(string)
  1451. content_five := dataBody["is_syyaowu"].(string)
  1452. content_six := dataBody["is_paixie"].(string)
  1453. content_seven := dataBody["is_zilin"].(string)
  1454. content_eight := dataBody["is_xiaoguo"].(string)
  1455. content_night := dataBody["is_touxidiedao"].(string)
  1456. content_add := dataBody["list"].(string)
  1457. content_add_one := dataBody["listOne"].(string)
  1458. timeLayout := "2006-01-02"
  1459. loc, _ := time.LoadLocation("Local")
  1460. var pingDate int64
  1461. if len(ping_date) > 0 {
  1462. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", ping_date+" 00:00:00", loc)
  1463. if err != nil {
  1464. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1465. return
  1466. }
  1467. pingDate = theTime.Unix()
  1468. }
  1469. var recordDate int64
  1470. if len(record_date) > 0 {
  1471. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1472. if err != nil {
  1473. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1474. return
  1475. }
  1476. recordDate = theTime.Unix()
  1477. }
  1478. // 开始主事务
  1479. db := service.XTWriteDB()
  1480. tx := db.Begin()
  1481. // 在函数结束时处理事务回滚
  1482. defer func() {
  1483. if r := recover(); r != nil {
  1484. tx.Rollback()
  1485. }
  1486. }()
  1487. patientFallassessment := models.XtPatientFallassessment{
  1488. PatientId: patient_id,
  1489. UserOrgId: user_org_id,
  1490. RecordDate: recordDate,
  1491. PingDate: pingDate,
  1492. AdminUserId: admin_user_id,
  1493. Status: 1,
  1494. IsCheck: is_check,
  1495. IsCheckOne: is_check_one,
  1496. IsCheckTwo: is_check_two,
  1497. IsCheckThree: is_check_three,
  1498. IsCheckFour: is_check_four,
  1499. IsCheckFive: is_check_five,
  1500. IsCheckSix: is_check_six,
  1501. IsCheckSeven: is_check_seven,
  1502. IsCheckEight: is_check_eight,
  1503. IsCheckNight: is_check_night,
  1504. IsCheckTen: is_check_ten,
  1505. IsCheckEleven: is_check_eleven,
  1506. IsCheckTwelve: is_check_twelve,
  1507. IsCheckThirteen: is_check_thirteen,
  1508. IsCheckFourteen: is_check_fourteen,
  1509. IsCheckFifteen: is_check_fifteen,
  1510. IsCheckSixteen: is_check_sixteen,
  1511. IsCheckSeventeen: is_check_seventeen,
  1512. IsCheckEighteen: is_check_eighteen,
  1513. IsCheckNineteen: is_check_nineteen,
  1514. Ctime: time.Now().Unix(),
  1515. Mtime: time.Now().Unix(),
  1516. Total: total,
  1517. Content: content,
  1518. ContentOne: content_one,
  1519. ContentTwo: content_two,
  1520. ContentThree: content_three,
  1521. ContentFour: content_four,
  1522. ContentFive: content_five,
  1523. ContentSix: content_six,
  1524. ContentSeven: content_seven,
  1525. ContentEight: content_eight,
  1526. ContentNight: content_night,
  1527. ContentAdd: content_add,
  1528. ContentAddOne: content_add_one,
  1529. }
  1530. service.CreatePatientFallassessment(tx, patientFallassessment)
  1531. tx.Commit()
  1532. this.ServeSuccessJSON(map[string]interface{}{
  1533. "patientFallassessment": patientFallassessment,
  1534. })
  1535. }
  1536. func (this *PatientDataConfigAPIController) GetPatientFallsessMentList() {
  1537. patient_id, _ := this.GetInt64("patient_id")
  1538. limit, _ := this.GetInt64("limit")
  1539. page, _ := this.GetInt64("page")
  1540. orgId := this.GetAdminUserInfo().CurrentOrgId
  1541. list, total, _ := service.GetPatientFallsessMentList(patient_id, orgId, limit, page)
  1542. appId := this.GetAdminUserInfo().CurrentAppId
  1543. roleList, _ := service.GetAllNurseList(orgId, appId)
  1544. this.ServeSuccessJSON(map[string]interface{}{
  1545. "list": list,
  1546. "total": total,
  1547. "roleList": roleList,
  1548. })
  1549. }
  1550. func (this *PatientDataConfigAPIController) GetPatientFallsessmentById() {
  1551. id, _ := this.GetInt64("id")
  1552. orgId := this.GetAdminUserInfo().CurrentOrgId
  1553. patientFallsessment, _ := service.GetPatientFallsessmentById(id, orgId)
  1554. this.ServeSuccessJSON(map[string]interface{}{
  1555. "patientFallsessment": patientFallsessment,
  1556. })
  1557. }
  1558. func (this *PatientDataConfigAPIController) DeletePatientFallsessment() {
  1559. id, _ := this.GetInt64("id")
  1560. orgId := this.GetAdminUserInfo().CurrentOrgId
  1561. service.DeletePatientFallsessment(id, orgId)
  1562. this.ServeSuccessJSON(map[string]interface{}{
  1563. "msg": "ok",
  1564. })
  1565. }
  1566. func (this *PatientDataConfigAPIController) UpdatePatientFallassment() {
  1567. dataBody := make(map[string]interface{}, 0)
  1568. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1569. if err != nil {
  1570. utils.ErrorLog(err.Error())
  1571. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1572. return
  1573. }
  1574. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  1575. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  1576. id := int64(dataBody["id"].(float64))
  1577. is_check := int64(dataBody["is_check"].(float64))
  1578. is_check_one := int64(dataBody["is_check_one"].(float64))
  1579. is_check_two := int64(dataBody["is_check_two"].(float64))
  1580. is_check_three := int64(dataBody["is_check_three"].(float64))
  1581. is_check_four := int64(dataBody["is_check_four"].(float64))
  1582. is_check_five := int64(dataBody["is_check_five"].(float64))
  1583. is_check_six := int64(dataBody["is_check_six"].(float64))
  1584. is_check_seven := int64(dataBody["is_check_seven"].(float64))
  1585. is_check_eight := int64(dataBody["is_check_eight"].(float64))
  1586. is_check_night := int64(dataBody["is_check_night"].(float64))
  1587. is_check_ten := int64(dataBody["is_check_ten"].(float64))
  1588. is_check_eleven := int64(dataBody["is_check_eleven"].(float64))
  1589. is_check_twelve := int64(dataBody["is_check_twelve"].(float64))
  1590. is_check_thirteen := int64(dataBody["is_check_thirteen"].(float64))
  1591. is_check_fourteen := int64(dataBody["is_check_fourteen"].(float64))
  1592. is_check_fifteen := int64(dataBody["is_check_fifteen"].(float64))
  1593. is_check_sixteen := int64(dataBody["is_check_sixteen"].(float64))
  1594. is_check_seventeen := int64(dataBody["is_check_seventeen"].(float64))
  1595. is_check_eighteen := int64(dataBody["is_check_eighteen"].(float64))
  1596. is_check_nineteen := int64(dataBody["is_check_nineteen"].(float64))
  1597. patient_id := int64(dataBody["patient_id"].(float64))
  1598. total := int64(dataBody["total"].(float64))
  1599. ping_date := dataBody["ping_date"].(string)
  1600. record_date := dataBody["record_date"].(string)
  1601. timeLayout := "2006-01-02"
  1602. loc, _ := time.LoadLocation("Local")
  1603. var pingDate int64
  1604. if len(ping_date) > 0 {
  1605. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", ping_date+" 00:00:00", loc)
  1606. if err != nil {
  1607. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1608. return
  1609. }
  1610. pingDate = theTime.Unix()
  1611. }
  1612. var recordDate int64
  1613. if len(record_date) > 0 {
  1614. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1615. if err != nil {
  1616. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1617. return
  1618. }
  1619. recordDate = theTime.Unix()
  1620. }
  1621. content := dataBody["is_age"].(string)
  1622. content_one := dataBody["is_jiwang"].(string)
  1623. content_two := dataBody["is_yishizt"].(string)
  1624. content_three := dataBody["is_ganguan"].(string)
  1625. content_four := dataBody["is_shentizk"].(string)
  1626. content_five := dataBody["is_syyaowu"].(string)
  1627. content_six := dataBody["is_paixie"].(string)
  1628. content_seven := dataBody["is_zilin"].(string)
  1629. content_eight := dataBody["is_xiaoguo"].(string)
  1630. content_night := dataBody["is_touxidiedao"].(string)
  1631. content_add := dataBody["list"].(string)
  1632. content_add_one := dataBody["listOne"].(string)
  1633. // 开始主事务
  1634. db := service.XTWriteDB()
  1635. tx := db.Begin()
  1636. // 在函数结束时处理事务回滚
  1637. defer func() {
  1638. if r := recover(); r != nil {
  1639. tx.Rollback()
  1640. }
  1641. }()
  1642. patientFallassessment := models.XtPatientFallassessment{
  1643. ID: id,
  1644. PatientId: patient_id,
  1645. UserOrgId: user_org_id,
  1646. RecordDate: recordDate,
  1647. PingDate: pingDate,
  1648. AdminUserId: admin_user_id,
  1649. Status: 1,
  1650. IsCheck: is_check,
  1651. IsCheckOne: is_check_one,
  1652. IsCheckTwo: is_check_two,
  1653. IsCheckThree: is_check_three,
  1654. IsCheckFour: is_check_four,
  1655. IsCheckFive: is_check_five,
  1656. IsCheckSix: is_check_six,
  1657. IsCheckSeven: is_check_seven,
  1658. IsCheckEight: is_check_eight,
  1659. IsCheckNight: is_check_night,
  1660. IsCheckTen: is_check_ten,
  1661. IsCheckEleven: is_check_eleven,
  1662. IsCheckTwelve: is_check_twelve,
  1663. IsCheckThirteen: is_check_thirteen,
  1664. IsCheckFourteen: is_check_fourteen,
  1665. IsCheckFifteen: is_check_fifteen,
  1666. IsCheckSixteen: is_check_sixteen,
  1667. IsCheckSeventeen: is_check_seventeen,
  1668. IsCheckEighteen: is_check_eighteen,
  1669. IsCheckNineteen: is_check_nineteen,
  1670. Ctime: time.Now().Unix(),
  1671. Mtime: time.Now().Unix(),
  1672. Total: total,
  1673. Content: content,
  1674. ContentOne: content_one,
  1675. ContentTwo: content_two,
  1676. ContentThree: content_three,
  1677. ContentFour: content_four,
  1678. ContentFive: content_five,
  1679. ContentSix: content_six,
  1680. ContentSeven: content_seven,
  1681. ContentEight: content_eight,
  1682. ContentNight: content_night,
  1683. ContentAdd: content_add,
  1684. ContentAddOne: content_add_one,
  1685. }
  1686. service.SavePatientFallassessment(tx, patientFallassessment)
  1687. tx.Commit()
  1688. this.ServeSuccessJSON(map[string]interface{}{
  1689. "patientFallassessment": patientFallassessment,
  1690. })
  1691. }
  1692. func (this *PatientDataConfigAPIController) SavePediatrcFallassment() {
  1693. dataBody := make(map[string]interface{}, 0)
  1694. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1695. if err != nil {
  1696. utils.ErrorLog(err.Error())
  1697. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1698. return
  1699. }
  1700. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  1701. admin_user_id := int64(dataBody["tumble"].(float64))
  1702. patient_id := int64(dataBody["patient_id"].(float64))
  1703. record_date := dataBody["date"].(string)
  1704. total := int64(dataBody["pedia_Totalpoints"].(float64))
  1705. timeLayout := "2006-01-02"
  1706. loc, _ := time.LoadLocation("Local")
  1707. var recordDate int64
  1708. var str string
  1709. if len(record_date) > 0 {
  1710. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1711. if err != nil {
  1712. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1713. return
  1714. }
  1715. recordDate = theTime.Unix()
  1716. }
  1717. //if dataBody["age"] != nil && reflect.TypeOf(dataBody["age"]).String() == "[]interface {}" {
  1718. // ageList, _ := dataBody["age"].([]interface{})
  1719. //
  1720. // for _, item := range ageList {
  1721. // //记录日志
  1722. // byterequest, _ := json.Marshal(item)
  1723. // str += string(byterequest) + ","
  1724. // }
  1725. //}
  1726. //
  1727. //if dataBody["cognize"] != nil && reflect.TypeOf(dataBody["cognize"]).String() == "[]interface {}" {
  1728. // cognizeList, _ := dataBody["cognize"].([]interface{})
  1729. //
  1730. // for _, item := range cognizeList {
  1731. // //记录日志
  1732. // byterequest, _ := json.Marshal(item)
  1733. // str += string(byterequest) + ","
  1734. // }
  1735. //}
  1736. //
  1737. //if dataBody["diagnosis"] != nil && reflect.TypeOf(dataBody["diagnosis"]).String() == "[]interface {}" {
  1738. // diagnosisList, _ := dataBody["diagnosis"].([]interface{})
  1739. //
  1740. // for _, item := range diagnosisList {
  1741. // //记录日志
  1742. // byterequest, _ := json.Marshal(item)
  1743. // str += string(byterequest) + ","
  1744. // }
  1745. //}
  1746. //
  1747. //if dataBody["environment"] != nil && reflect.TypeOf(dataBody["environment"]).String() == "[]interface {}" {
  1748. // environmentList, _ := dataBody["environment"].([]interface{})
  1749. //
  1750. // for _, item := range environmentList {
  1751. // //记录日志
  1752. // byterequest, _ := json.Marshal(item)
  1753. // str += string(byterequest) + ","
  1754. // }
  1755. //}
  1756. //
  1757. //if dataBody["medicine"] != nil && reflect.TypeOf(dataBody["medicine"]).String() == "[]interface {}" {
  1758. // medicineList, _ := dataBody["medicine"].([]interface{})
  1759. //
  1760. // for _, item := range medicineList {
  1761. // //记录日志
  1762. // byterequest, _ := json.Marshal(item)
  1763. // str += string(byterequest) + ","
  1764. // }
  1765. //}
  1766. //
  1767. //if dataBody["sex"] != nil && reflect.TypeOf(dataBody["sex"]).String() == "[]interface {}" {
  1768. // sexList, _ := dataBody["medicine"].([]interface{})
  1769. //
  1770. // for _, item := range sexList {
  1771. // //记录日志
  1772. // byterequest, _ := json.Marshal(item)
  1773. // str += string(byterequest) + ","
  1774. // }
  1775. //}
  1776. age := int64(dataBody["age"].(float64))
  1777. sex := int64(dataBody["sex"].(float64))
  1778. diagnosis := int64(dataBody["diagnosis"].(float64))
  1779. cognize := int64(dataBody["cognize"].(float64))
  1780. environment := int64(dataBody["environment"].(float64))
  1781. medicine := int64(dataBody["medicine"].(float64))
  1782. tumble := int64(dataBody["tumble"].(float64))
  1783. pedFallssessment := models.XtPatientPedFallssessment{
  1784. PatientId: patient_id,
  1785. UserOrgId: user_org_id,
  1786. Status: 1,
  1787. Ctime: time.Now().Unix(),
  1788. Mtime: 0,
  1789. Text: str,
  1790. RecordDate: recordDate,
  1791. Total: total,
  1792. AdminUserId: admin_user_id,
  1793. Type: 1,
  1794. Age: age,
  1795. Sex: sex,
  1796. Diagnosis: diagnosis,
  1797. Environment: environment,
  1798. Medicine: medicine,
  1799. Tumble: tumble,
  1800. Cognize: cognize,
  1801. }
  1802. service.CreatePadFallssessment(pedFallssessment)
  1803. this.ServeSuccessJSON(map[string]interface{}{
  1804. "pedFallssessment": pedFallssessment,
  1805. })
  1806. }
  1807. func (this *PatientDataConfigAPIController) GetBedDiatricFallassessmentList() {
  1808. patient_id, _ := this.GetInt64("patient_id")
  1809. is_type, _ := this.GetInt64("is_type")
  1810. limit, _ := this.GetInt64("limit")
  1811. page, _ := this.GetInt64("page")
  1812. orgId := this.GetAdminUserInfo().CurrentOrgId
  1813. list, total, _ := service.GetBedDiatricFallassessmentList(patient_id, is_type, orgId, limit, page)
  1814. this.ServeSuccessJSON(map[string]interface{}{
  1815. "list": list,
  1816. "total": total,
  1817. })
  1818. }
  1819. func (this *PatientDataConfigAPIController) GetPedPatientFallassessmentById() {
  1820. id, _ := this.GetInt64("id")
  1821. fallassessment, _ := service.GetPedPatientFallassessmentById(id)
  1822. this.ServeSuccessJSON(map[string]interface{}{
  1823. "fallassessment": fallassessment,
  1824. })
  1825. }
  1826. func (this *PatientDataConfigAPIController) DeletePadPatientFallassment() {
  1827. id, _ := this.GetInt64("id")
  1828. service.DeletePadPatientFallassment(id)
  1829. this.ServeSuccessJSON(map[string]interface{}{
  1830. "msg": "ok",
  1831. })
  1832. }
  1833. func (this *PatientDataConfigAPIController) UpdatePedPatientFallassessment() {
  1834. dataBody := make(map[string]interface{}, 0)
  1835. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1836. if err != nil {
  1837. utils.ErrorLog(err.Error())
  1838. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1839. return
  1840. }
  1841. user_org_id := this.GetAdminUserInfo().CurrentOrgId
  1842. id := int64(dataBody["id"].(float64))
  1843. admin_user_id := int64(dataBody["tumble"].(float64))
  1844. patient_id := int64(dataBody["patient_id"].(float64))
  1845. record_date := dataBody["date"].(string)
  1846. total := int64(dataBody["pedia_Totalpoints"].(float64))
  1847. timeLayout := "2006-01-02"
  1848. loc, _ := time.LoadLocation("Local")
  1849. var recordDate int64
  1850. var str string
  1851. if len(record_date) > 0 {
  1852. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1853. if err != nil {
  1854. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1855. return
  1856. }
  1857. recordDate = theTime.Unix()
  1858. }
  1859. age := int64(dataBody["age"].(float64))
  1860. sex := int64(dataBody["sex"].(float64))
  1861. diagnosis := int64(dataBody["diagnosis"].(float64))
  1862. environment := int64(dataBody["environment"].(float64))
  1863. medicine := int64(dataBody["medicine"].(float64))
  1864. tumble := int64(dataBody["tumble"].(float64))
  1865. cognize := int64(dataBody["cognize"].(float64))
  1866. pedFallssessment := models.XtPatientPedFallssessment{
  1867. ID: id,
  1868. PatientId: patient_id,
  1869. UserOrgId: user_org_id,
  1870. Status: 1,
  1871. Ctime: time.Now().Unix(),
  1872. Mtime: 0,
  1873. Text: str,
  1874. RecordDate: recordDate,
  1875. Total: total,
  1876. AdminUserId: admin_user_id,
  1877. Type: 1,
  1878. Age: age,
  1879. Sex: sex,
  1880. Diagnosis: diagnosis,
  1881. Environment: environment,
  1882. Medicine: medicine,
  1883. Tumble: tumble,
  1884. Cognize: cognize,
  1885. }
  1886. service.UpdatePedFallssessment(pedFallssessment)
  1887. this.ServeSuccessJSON(map[string]interface{}{
  1888. "pedFallssessment": pedFallssessment,
  1889. })
  1890. }
  1891. func (this *PatientDataConfigAPIController) SavePatientHpPressuresore() {
  1892. dataBody := make(map[string]interface{}, 0)
  1893. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1894. if err != nil {
  1895. utils.ErrorLog(err.Error())
  1896. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1897. return
  1898. }
  1899. record_date := dataBody["record_date"].(string)
  1900. timeLayout := "2006-01-02"
  1901. loc, _ := time.LoadLocation("Local")
  1902. var recordDate int64
  1903. if len(record_date) > 0 {
  1904. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1905. if err != nil {
  1906. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1907. return
  1908. }
  1909. recordDate = theTime.Unix()
  1910. }
  1911. var str string
  1912. if dataBody["list"] != nil && reflect.TypeOf(dataBody["list"]).String() == "[]interface {}" {
  1913. list, _ := dataBody["list"].([]interface{})
  1914. for _, item := range list {
  1915. byterequest, _ := json.Marshal(item)
  1916. str += string(byterequest)
  1917. }
  1918. }
  1919. patient_id := int64(dataBody["patient_id"].(float64))
  1920. is_type := int64(dataBody["is_type"].(float64))
  1921. var data models.XtPatientPedFallssessment
  1922. json.Unmarshal(this.Ctx.Input.RequestBody, &data)
  1923. orgId := this.GetAdminUserInfo().CurrentOrgId
  1924. pedFallssessment := models.XtPatientPedFallssessment{
  1925. PatientId: patient_id,
  1926. UserOrgId: orgId,
  1927. Status: 1,
  1928. Ctime: time.Now().Unix(),
  1929. Mtime: time.Now().Unix(),
  1930. Text: str,
  1931. RecordDate: recordDate,
  1932. Total: 0,
  1933. AdminUserId: 0,
  1934. Type: is_type,
  1935. Age: 0,
  1936. Cognize: 0,
  1937. Diagnosis: 0,
  1938. Environment: 0,
  1939. Medicine: 0,
  1940. Sex: 0,
  1941. Tumble: 0,
  1942. }
  1943. service.CreatePatientPedList(pedFallssessment)
  1944. this.ServeSuccessJSON(map[string]interface{}{
  1945. "pedFallssessment": pedFallssessment,
  1946. })
  1947. }
  1948. func (this *PatientDataConfigAPIController) GetPatientBedList() {
  1949. patient_id, _ := this.GetInt64("patient_id")
  1950. page, _ := this.GetInt64("page")
  1951. limit, _ := this.GetInt64("limit")
  1952. is_type, _ := this.GetInt64("is_type")
  1953. orgId := this.GetAdminUserInfo().CurrentOrgId
  1954. list, total, _ := service.GetBedDiatricFallassessmentList(patient_id, is_type, orgId, limit, page)
  1955. this.ServeSuccessJSON(map[string]interface{}{
  1956. "list": list,
  1957. "total": total,
  1958. })
  1959. }
  1960. func (this *PatientDataConfigAPIController) UpdateBedPatientList() {
  1961. dataBody := make(map[string]interface{}, 0)
  1962. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1963. if err != nil {
  1964. utils.ErrorLog(err.Error())
  1965. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1966. return
  1967. }
  1968. record_date := dataBody["record_date"].(string)
  1969. timeLayout := "2006-01-02"
  1970. loc, _ := time.LoadLocation("Local")
  1971. var recordDate int64
  1972. if len(record_date) > 0 {
  1973. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1974. if err != nil {
  1975. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1976. return
  1977. }
  1978. recordDate = theTime.Unix()
  1979. }
  1980. var str string
  1981. if dataBody["list"] != nil && reflect.TypeOf(dataBody["list"]).String() == "[]interface {}" {
  1982. list, _ := dataBody["list"].([]interface{})
  1983. for _, item := range list {
  1984. byterequest, _ := json.Marshal(item)
  1985. str += string(byterequest)
  1986. }
  1987. }
  1988. patient_id := int64(dataBody["patient_id"].(float64))
  1989. id := int64(dataBody["id"].(float64))
  1990. is_type := int64(dataBody["is_type"].(float64))
  1991. var data models.XtPatientPedFallssessment
  1992. json.Unmarshal(this.Ctx.Input.RequestBody, &data)
  1993. orgId := this.GetAdminUserInfo().CurrentOrgId
  1994. pedFallssessment := models.XtPatientPedFallssessment{
  1995. ID: id,
  1996. PatientId: patient_id,
  1997. UserOrgId: orgId,
  1998. Status: 1,
  1999. Ctime: time.Now().Unix(),
  2000. Mtime: time.Now().Unix(),
  2001. Text: str,
  2002. RecordDate: recordDate,
  2003. Total: 0,
  2004. AdminUserId: 0,
  2005. Type: is_type,
  2006. Age: 0,
  2007. Cognize: 0,
  2008. Diagnosis: 0,
  2009. Environment: 0,
  2010. Medicine: 0,
  2011. Sex: 0,
  2012. Tumble: 0,
  2013. }
  2014. service.UpdatePatientPedList(pedFallssessment)
  2015. this.ServeSuccessJSON(map[string]interface{}{
  2016. "pedFallssessment": pedFallssessment,
  2017. })
  2018. }
  2019. func (this *PatientDataConfigAPIController) GetPatientFallaessmentListMap() {
  2020. ids := this.GetString("ids")
  2021. patient_id, _ := this.GetInt64("patient_id")
  2022. indateSplit := strings.Split(ids, ",")
  2023. orgId := this.GetAdminUserInfo().CurrentOrgId
  2024. list, _ := service.GetPatientFallsessMentListOne(indateSplit, orgId)
  2025. patients, _ := service.GetPatientName(patient_id)
  2026. this.ServeSuccessJSON(map[string]interface{}{
  2027. "list": list,
  2028. "patients": patients,
  2029. })
  2030. }
  2031. func (this *PatientDataConfigAPIController) GetPatientFallaessmentListOne() {
  2032. ids := this.GetString("ids")
  2033. patient_id, _ := this.GetInt64("patient_id")
  2034. indateSplit := strings.Split(ids, ",")
  2035. orgId := this.GetAdminUserInfo().CurrentOrgId
  2036. service.GetAllPatientListMap(orgId)
  2037. list, _ := service.GetPatientFallsessMentListTwo(indateSplit, orgId)
  2038. patients, _ := service.GetPatientName(patient_id)
  2039. this.ServeSuccessJSON(map[string]interface{}{
  2040. "list": list,
  2041. "patients": patients,
  2042. })
  2043. }
  2044. func (this *PatientDataConfigAPIController) SavePatientBraden() {
  2045. dataBody := make(map[string]interface{}, 0)
  2046. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2047. if err != nil {
  2048. utils.ErrorLog(err.Error())
  2049. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2050. return
  2051. }
  2052. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  2053. famaliy_sign := dataBody["famaliy_sign"].(string)
  2054. leader_sign := dataBody["leader_sign"].(string)
  2055. ping_sign := dataBody["ping_sign"].(string)
  2056. first_check := int64(dataBody["first_check"].(float64))
  2057. two_check := int64(dataBody["two_check"].(float64))
  2058. three_check := int64(dataBody["three_check"].(float64))
  2059. four_check := int64(dataBody["four_check"].(float64))
  2060. five_check := int64(dataBody["five_check"].(float64))
  2061. six_check := int64(dataBody["six_check"].(float64))
  2062. first_lapeso := int64(dataBody["first_lapeso"].(float64))
  2063. two_lapeso := int64(dataBody["two_lapeso"].(float64))
  2064. three_lapeso := int64(dataBody["three_lapeso"].(float64))
  2065. patient_id := int64(dataBody["patient_id"].(float64))
  2066. record_date := dataBody["record_date"].(string)
  2067. timeLayout := "2006-01-02"
  2068. loc, _ := time.LoadLocation("Local")
  2069. var recordDate int64
  2070. if len(record_date) > 0 {
  2071. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  2072. if err != nil {
  2073. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2074. return
  2075. }
  2076. recordDate = theTime.Unix()
  2077. }
  2078. leader_date := dataBody["leader_date"].(string)
  2079. var leaderDate int64
  2080. if len(leader_date) > 0 {
  2081. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", leader_date+" 00:00:00", loc)
  2082. if err != nil {
  2083. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2084. return
  2085. }
  2086. leaderDate = theTime.Unix()
  2087. }
  2088. ping_date := dataBody["ping_date"].(string)
  2089. str := dataBody["list"].(string)
  2090. var pingDate int64
  2091. if len(ping_date) > 0 {
  2092. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", ping_date+" 00:00:00", loc)
  2093. if err != nil {
  2094. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2095. return
  2096. }
  2097. pingDate = theTime.Unix()
  2098. }
  2099. first_pingfen := int64(dataBody["first_pingfen"].(float64))
  2100. two_pingfen := int64(dataBody["two_pingfen"].(float64))
  2101. three_pingfen := int64(dataBody["three_pingfen"].(float64))
  2102. four_pingfen := int64(dataBody["four_pingfen"].(float64))
  2103. five_pingfen := int64(dataBody["five_pingfen"].(float64))
  2104. six_pingfen := int64(dataBody["six_pingfen"].(float64))
  2105. total := int64(dataBody["total"].(float64))
  2106. orgId := this.GetAdminUserInfo().CurrentOrgId
  2107. xtPatientBraden := models.XtPatientBraden{
  2108. PatientId: patient_id,
  2109. UserOrgId: orgId,
  2110. AdminUserId: admin_user_id,
  2111. RecordDate: recordDate,
  2112. Total: total,
  2113. FirstPingfen: first_pingfen,
  2114. TwoPingfen: two_pingfen,
  2115. ThreePingfen: three_pingfen,
  2116. FourPingfen: four_pingfen,
  2117. FivePingfen: five_pingfen,
  2118. SixPingfen: six_pingfen,
  2119. FamaliySign: famaliy_sign,
  2120. PingDate: pingDate,
  2121. FirstLapeso: first_lapeso,
  2122. PingSign: ping_sign,
  2123. LeaderSign: leader_sign,
  2124. LeaderDate: leaderDate,
  2125. Ctime: time.Now().Unix(),
  2126. Mtime: time.Now().Unix(),
  2127. Status: 1,
  2128. FirstCheck: first_check,
  2129. TwoCheck: two_check,
  2130. ThreeCheck: three_check,
  2131. FourCheck: four_check,
  2132. FiveCheck: five_check,
  2133. SixCheck: six_check,
  2134. TwoLapeso: two_lapeso,
  2135. ThreeLapeso: three_lapeso,
  2136. Content: str,
  2137. }
  2138. service.CeatePatientSign(xtPatientBraden)
  2139. this.ServeSuccessJSON(map[string]interface{}{
  2140. "xtPatientBraden": xtPatientBraden,
  2141. })
  2142. }
  2143. func (this *PatientDataConfigAPIController) GetPatientBradenList() {
  2144. patient_id, _ := this.GetInt64("patient_id")
  2145. limt, _ := this.GetInt64("limit")
  2146. page, _ := this.GetInt64("page")
  2147. orgId := this.GetAdminUserInfo().CurrentOrgId
  2148. appId := this.GetAdminUserInfo().CurrentAppId
  2149. list, total, _ := service.GetPatientBradenList(patient_id, limt, page, orgId)
  2150. nurseList, _ := service.GetAllNurseList(orgId, appId)
  2151. this.ServeSuccessJSON(map[string]interface{}{
  2152. "list": list,
  2153. "total": total,
  2154. "nurseList": nurseList,
  2155. })
  2156. }
  2157. func (this *PatientDataConfigAPIController) GetPatientBradenById() {
  2158. id, _ := this.GetInt64("id")
  2159. braden, _ := service.GetPatientBradenById(id)
  2160. orgId := this.GetAdminUserInfo().CurrentOrgId
  2161. appId := this.GetAdminUserInfo().CurrentAppId
  2162. nurseList, _ := service.GetAllNurseList(orgId, appId)
  2163. this.ServeSuccessJSON(map[string]interface{}{
  2164. "braden": braden,
  2165. "nurseList": nurseList,
  2166. })
  2167. }
  2168. func (this *PatientDataConfigAPIController) UpdatePatientBraden() {
  2169. dataBody := make(map[string]interface{}, 0)
  2170. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2171. if err != nil {
  2172. utils.ErrorLog(err.Error())
  2173. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2174. return
  2175. }
  2176. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  2177. famaliy_sign := dataBody["famaliy_sign"].(string)
  2178. leader_sign := dataBody["leader_sign"].(string)
  2179. ping_sign := dataBody["ping_sign"].(string)
  2180. first_check := int64(dataBody["first_check"].(float64))
  2181. two_check := int64(dataBody["two_check"].(float64))
  2182. three_check := int64(dataBody["three_check"].(float64))
  2183. four_check := int64(dataBody["four_check"].(float64))
  2184. five_check := int64(dataBody["five_check"].(float64))
  2185. six_check := int64(dataBody["six_check"].(float64))
  2186. first_lapeso := int64(dataBody["first_lapeso"].(float64))
  2187. two_lapeso := int64(dataBody["two_lapeso"].(float64))
  2188. three_lapeso := int64(dataBody["three_lapeso"].(float64))
  2189. patient_id := int64(dataBody["patient_id"].(float64))
  2190. record_date := dataBody["record_date"].(string)
  2191. timeLayout := "2006-01-02"
  2192. loc, _ := time.LoadLocation("Local")
  2193. var recordDate int64
  2194. if len(record_date) > 0 {
  2195. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  2196. if err != nil {
  2197. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2198. return
  2199. }
  2200. recordDate = theTime.Unix()
  2201. }
  2202. leader_date := dataBody["leader_date"].(string)
  2203. var leaderDate int64
  2204. if len(leader_date) > 0 {
  2205. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", leader_date+" 00:00:00", loc)
  2206. if err != nil {
  2207. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2208. return
  2209. }
  2210. leaderDate = theTime.Unix()
  2211. }
  2212. ping_date := dataBody["ping_date"].(string)
  2213. str := dataBody["list"].(string)
  2214. var pingDate int64
  2215. if len(ping_date) > 0 {
  2216. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", ping_date+" 00:00:00", loc)
  2217. if err != nil {
  2218. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2219. return
  2220. }
  2221. pingDate = theTime.Unix()
  2222. }
  2223. first_pingfen := int64(dataBody["first_pingfen"].(float64))
  2224. two_pingfen := int64(dataBody["two_pingfen"].(float64))
  2225. three_pingfen := int64(dataBody["three_pingfen"].(float64))
  2226. four_pingfen := int64(dataBody["four_pingfen"].(float64))
  2227. five_pingfen := int64(dataBody["five_pingfen"].(float64))
  2228. six_pingfen := int64(dataBody["six_pingfen"].(float64))
  2229. total := int64(dataBody["total"].(float64))
  2230. id := int64(dataBody["id"].(float64))
  2231. orgId := this.GetAdminUserInfo().CurrentOrgId
  2232. xtPatientBraden := models.XtPatientBraden{
  2233. ID: id,
  2234. PatientId: patient_id,
  2235. UserOrgId: orgId,
  2236. AdminUserId: admin_user_id,
  2237. RecordDate: recordDate,
  2238. Total: total,
  2239. FirstPingfen: first_pingfen,
  2240. TwoPingfen: two_pingfen,
  2241. ThreePingfen: three_pingfen,
  2242. FourPingfen: four_pingfen,
  2243. FivePingfen: five_pingfen,
  2244. SixPingfen: six_pingfen,
  2245. FamaliySign: famaliy_sign,
  2246. PingDate: pingDate,
  2247. FirstLapeso: first_lapeso,
  2248. PingSign: ping_sign,
  2249. LeaderSign: leader_sign,
  2250. LeaderDate: leaderDate,
  2251. Ctime: time.Now().Unix(),
  2252. Mtime: time.Now().Unix(),
  2253. Status: 1,
  2254. FirstCheck: first_check,
  2255. TwoCheck: two_check,
  2256. ThreeCheck: three_check,
  2257. FourCheck: four_check,
  2258. FiveCheck: five_check,
  2259. SixCheck: six_check,
  2260. TwoLapeso: two_lapeso,
  2261. ThreeLapeso: three_lapeso,
  2262. Content: str,
  2263. }
  2264. service.SavePatientBraden(xtPatientBraden)
  2265. this.ServeSuccessJSON(map[string]interface{}{
  2266. "xtPatientBraden": xtPatientBraden,
  2267. })
  2268. }
  2269. func (this *PatientDataConfigAPIController) DeletePatientBraden() {
  2270. id, _ := this.GetInt64("id")
  2271. service.DeletePatientBraden(id)
  2272. this.ServeSuccessJSON(map[string]interface{}{
  2273. "msg": "ok",
  2274. })
  2275. }
  2276. func (this *PatientDataConfigAPIController) GetBatchPatientBraden() {
  2277. ids := this.GetString("ids")
  2278. patient_id, _ := this.GetInt64("patient_id")
  2279. orgId := this.GetAdminUserInfo().CurrentOrgId
  2280. indateSplit := strings.Split(ids, ",")
  2281. list, _ := service.GetBatchPatientBraden(indateSplit, orgId)
  2282. patients, _ := service.GetPatientName(patient_id)
  2283. this.ServeSuccessJSON(map[string]interface{}{
  2284. "list": list,
  2285. "patients": patients,
  2286. })
  2287. }