patient_dataconfig_api_controller.go 88KB

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