doctors_api_controller.go 67KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "strconv"
  6. "strings"
  7. "time"
  8. "XT_New/enums"
  9. "XT_New/models"
  10. "XT_New/service"
  11. "XT_New/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/jinzhu/gorm"
  14. )
  15. type DoctorsApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func DoctorApiRegistRouters() {
  19. beego.Router("/api/alldoctors", &DoctorsApiController{}, "get:GetAllDoctorAndNurse")
  20. beego.Router("/api/admin/users", &DoctorsApiController{}, "get:GetAllAdminUsers")
  21. beego.Router("/api/patient/getdryweightdata", &DoctorsApiController{}, "Get:GetDryWeightData")
  22. beego.Router("/api/patient/getAllDoctor", &DoctorsApiController{}, "Get:GetAllDoctor")
  23. beego.Router("/api/patient/updatedryweightdata", &DoctorsApiController{}, "Post:UpdatedDryWeightData")
  24. beego.Router("/api/patient/getalldata", &DoctorsApiController{}, "Get:GetAllData")
  25. beego.Router("/api/paients/getdryweightdetail", &DoctorsApiController{}, "Get:GetDryWeightDetail")
  26. beego.Router("/api/patients/modifydryweightdata", &DoctorsApiController{}, "Get:ModifydryWeightData")
  27. beego.Router("/api/patient/deletedryweight", &DoctorsApiController{}, "Delete:DeleteDryWeight")
  28. beego.Router("/api/schedule/advices", &DoctorsApiController{}, "Get:ScheduleAdvices")
  29. beego.Router("/api/schedule/new/advices", &DoctorsApiController{}, "Get:GetScheduleAdvicesList")
  30. beego.Router("/api/schedule/getdoctoradvicecount", &DoctorsApiController{}, "Get:GetDoctorAdviceCount")
  31. beego.Router("/api/patient/savevasularaccess", &DoctorsApiController{}, "Get:SaveVasularAccess")
  32. beego.Router("/api/patient/getallvascualraccesslist", &DoctorsApiController{}, "Get:GetAllVacualAccessList")
  33. beego.Router("/api/patient/getvascularaccessbydetial", &DoctorsApiController{}, "Get:GetVascularAccessByDetail")
  34. beego.Router("/api/patient/updatevasularaccess", &DoctorsApiController{}, "Get:UpdateVasularAccess")
  35. beego.Router("/api/patient/deletevascularaccess", &DoctorsApiController{}, "Get:DeleteVasularAccess")
  36. beego.Router("/api/patient/savepasswayassessment", &DoctorsApiController{}, "Get:SavePassWayAssessment")
  37. beego.Router("/api/patient/getallpasswayassessment", &DoctorsApiController{}, "Get:GetAllPassWayAssessment")
  38. beego.Router("/api/patient/getpasswayassmentbyid", &DoctorsApiController{}, "Get:GetPasswayAssesmentById")
  39. beego.Router("/api/patient/updatepasswayassesment", &DoctorsApiController{}, "Get:UpdatePassWayAssesment")
  40. beego.Router("/api/patient/deletepasswayassessment", &DoctorsApiController{}, "Get:DeleteWayAssessment")
  41. beego.Router("/api/patient/getaccesslist", &DoctorsApiController{}, "Get:GetAccessList")
  42. //阶段小结路由
  43. beego.Router("/api/patient/getinspectionmajoritem", &DoctorsApiController{}, "Get:GetInspectionMajorItem")
  44. beego.Router("/api/patient/getinspectiondetail", &DoctorsApiController{}, "Get:GetInspectionDetailByProject")
  45. beego.Router("/api/patient/getinspectionitemlist", &DoctorsApiController{}, "Get:GetInspectionItemlist")
  46. beego.Router("/api/patient/getinitdatelist", &DoctorsApiController{}, "Get:GetInitDateList")
  47. beego.Router("/api/patient/savecreationinspection", &DoctorsApiController{}, "Post:SaveCreationInspection")
  48. beego.Router("/api/patient/getemlatesummarylist", &DoctorsApiController{}, "Get:GetTemplateSummaryList")
  49. beego.Router("/api/patient/gettemplatesummarydetail", &DoctorsApiController{}, "Get:GetTemplateSummaryDetail")
  50. beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
  51. beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
  52. beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
  53. beego.Router("/api/patient/hospitalsummary", &DoctorsApiController{}, "Post:HospitalSummary")
  54. beego.Router("/api/patient/gethospitalsummarylist", &DoctorsApiController{}, "Get:GetHospitalSummaryList")
  55. beego.Router("/api/patient/gethospitalsummaydetail", &DoctorsApiController{}, "Get:GetHospitalSummaryDetail")
  56. beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Post:UpdateHospitalSummary")
  57. beego.Router("/api/patient/deletehospitalsummary", &DoctorsApiController{}, "Get:DeleteHospitalSummary")
  58. beego.Router("/api/patient/getpatientinfo", &DoctorsApiController{}, "Get:GetPatientInfo")
  59. beego.Router("/api/patient/createfirstdisease", &DoctorsApiController{}, "Post:CreateFirstDisease")
  60. beego.Router("/api/patient/getfirstdiseaselist", &DoctorsApiController{}, "Get:GetFirstDiseaseList")
  61. beego.Router("/api/patient/getfirstdetailbyid", &DoctorsApiController{}, "Get:GetFirstDetailById")
  62. beego.Router("/api/patient/updatefirstdisease", &DoctorsApiController{}, "Post:UpdateFirstDisease")
  63. beego.Router("/api/patient/deletefirstdisease", &DoctorsApiController{}, "Get:DeleteFirstDisease")
  64. beego.Router("/api/schedule/new/long/advices", &DoctorsApiController{}, "Get:GetLongScheduleAdvicesList")
  65. beego.Router("/api/schedule/getpatientbyname", &DoctorsApiController{}, "Get:GetPatientByName")
  66. beego.Router("/api/schedule/getdocadvicebypatientid", &DoctorsApiController{}, "Get:GetDoctorAdviceByPatientId")
  67. beego.Router("/api/schedule/getdoctoradvicemonthlist", &DoctorsApiController{}, "Get:GetDoctorAdivceMonthList")
  68. beego.Router("/api/schedule/gethisprescriptionprojectmonthlist", &DoctorsApiController{}, "Get:GetHisPrescriptionProjectMonthList")
  69. beego.Router("/api/mobilealldoctors", &DoctorsApiController{}, "Get:GetMobileAllDoctorList")
  70. }
  71. func (c *DoctorsApiController) ScheduleAdvices() {
  72. schedualDate := c.GetString("date")
  73. adviceType, _ := c.GetInt("advice_type")
  74. patientType, _ := c.GetInt("patient_type")
  75. delivery_way := c.GetString("delivery_way")
  76. schedule_type, _ := c.GetInt64("schedule_type")
  77. partition_type, _ := c.GetInt64("partition_type")
  78. patient_id, _ := c.GetInt64("patient_id")
  79. excution_way, _ := c.GetInt64("excution_way")
  80. execution_frequency := c.GetString("execution_frequency")
  81. keyword := c.GetString("keyword")
  82. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  83. adviceType = 0
  84. }
  85. if patientType != 1 && patientType != 2 {
  86. patientType = 0
  87. }
  88. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  89. if parseDateErr != nil {
  90. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. adminUserInfo := c.GetAdminUserInfo()
  94. orgID := adminUserInfo.CurrentOrgId
  95. config, _ := service.GetHisDoctorConfig(orgID)
  96. project_config, _ := service.GetHisProjectConfig(orgID)
  97. drugs, _ := service.GetAllBaseDrugLibListTwo(orgID)
  98. if config.IsOpen == 0 || config.IsOpen == 2 {
  99. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency, keyword)
  100. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  101. if err != nil {
  102. c.ErrorLog("获取排班信息失败:%v", err)
  103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  104. } else {
  105. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  106. for _, schedual := range scheduals {
  107. if len(schedual.DoctorAdvices) > 0 {
  108. filtedScheduals = append(filtedScheduals, schedual)
  109. }
  110. }
  111. c.ServeSuccessJSON(map[string]interface{}{
  112. "scheduals": filtedScheduals,
  113. "adminUser": adminUser,
  114. "config": config,
  115. "project_config": project_config,
  116. "drugs": drugs,
  117. })
  118. }
  119. }
  120. if config.IsOpen == 1 {
  121. hisAdvices, err := service.GetHisDoctorAdvicesTwentyOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency)
  122. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  123. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
  124. drug, _ := service.GetAllBaseDrugListTwenty(orgID)
  125. for _, item := range project {
  126. index := 0
  127. for _, subItem := range item.HisPrescriptionTeamProject {
  128. if subItem.HisProject.CostClassify != 3 {
  129. subItem.IsCheckTeam = 2
  130. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  131. }
  132. if subItem.HisProject.CostClassify == 3 {
  133. subItem.IsCheckTeam = 1
  134. index = index + 1
  135. if index == 1 {
  136. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  137. }
  138. }
  139. }
  140. }
  141. if err != nil {
  142. c.ErrorLog("获取排班信息失败:%v", err)
  143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  144. } else {
  145. c.ServeSuccessJSON(map[string]interface{}{
  146. "adminUser": adminUser,
  147. "hisAdvices": hisAdvices,
  148. "config": config,
  149. "project_config": project_config,
  150. "project": project,
  151. "drug": drug,
  152. "drugs": drugs,
  153. })
  154. }
  155. }
  156. }
  157. func (c *DoctorsApiController) GetAllDoctorAndNurse() {
  158. adminUserInfo := c.GetAdminUserInfo()
  159. doctors, nursers, _ := service.GetAllDoctorAndNurseSeven(adminUserInfo.CurrentOrgId)
  160. signature, _ := service.GetAdminUserEsTwo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  161. c.ServeSuccessJSON(map[string]interface{}{
  162. "doctors": doctors,
  163. "nursers": nursers,
  164. "signature": signature,
  165. })
  166. return
  167. }
  168. func (c *DoctorsApiController) GetAllAdminUsers() {
  169. adminUserInfo := c.GetAdminUserInfo()
  170. users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
  171. operators, _ := service.GetAdminUserEsOne(adminUserInfo.CurrentOrgId)
  172. c.ServeSuccessJSON(map[string]interface{}{
  173. "users": users,
  174. "operators": operators,
  175. })
  176. return
  177. }
  178. func (c *DoctorsApiController) GetDryWeightData() {
  179. adminUserInfo := c.GetAdminUserInfo()
  180. orgid := adminUserInfo.CurrentOrgId
  181. patientid, _ := c.GetInt64("patientid")
  182. fmt.Println("patientid", patientid)
  183. id := adminUserInfo.AdminUser.Id
  184. fmt.Println("id", id)
  185. recordDateStr := time.Now().Format("2006-01-02")
  186. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  187. fmt.Scan("parseDateErr", parseDateErr)
  188. nowtime := recordDate.Unix()
  189. fmt.Println("nowtime", nowtime)
  190. pre, err := service.GetDryWeightByPatientId(patientid, orgid)
  191. fmt.Println("错误", err)
  192. c.ServeSuccessJSON(map[string]interface{}{
  193. "pre": pre,
  194. })
  195. }
  196. func (c *DoctorsApiController) GetAllDoctor() {
  197. adminUserInfo := c.GetAdminUserInfo()
  198. orgid := adminUserInfo.CurrentOrgId
  199. appid := adminUserInfo.CurrentAppId
  200. fmt.Println("appid", appid)
  201. appRole, err := service.GetAllDoctor(orgid, appid)
  202. fmt.Println("appRole", appRole)
  203. fmt.Println("错误", err)
  204. c.ServeSuccessJSON(map[string]interface{}{
  205. "appRole": appRole,
  206. })
  207. }
  208. func (c *DoctorsApiController) UpdatedDryWeightData() {
  209. adminUserInfo := c.GetAdminUserInfo()
  210. orgid := adminUserInfo.CurrentOrgId
  211. userid := adminUserInfo.AdminUser.Id
  212. dry_weight, _ := c.GetFloat("dry_weight")
  213. doctors, _ := c.GetInt64("doctors")
  214. remarks := c.GetString("remarks")
  215. patientid, _ := c.GetInt64("patient_id")
  216. //透前数据
  217. dryweight, _ := c.GetFloat("dryweight")
  218. var weight = dryweight - dry_weight
  219. weights := fmt.Sprintf("%.1f", weight)
  220. var sum string
  221. _, errcode := service.QueryDryWeight(orgid, patientid)
  222. if errcode == gorm.ErrRecordNotFound {
  223. sum = "/"
  224. patientDryweight := models.SgjPatientDryweight{
  225. DryWeight: dry_weight,
  226. Creator: doctors,
  227. Remakes: remarks,
  228. AdjustedValue: sum,
  229. PatientId: patientid,
  230. Ctime: time.Now().Unix(),
  231. UserOrgId: orgid,
  232. Status: 1,
  233. UserId: userid,
  234. }
  235. err := service.CreatePatientWeight(&patientDryweight)
  236. loc, _ := time.LoadLocation("Local")
  237. nowTime := time.Now()
  238. nowDay := nowTime.Format("2006-01-02")
  239. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  240. redis := service.RedisClient()
  241. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  242. redis.Set(keyTwo, "", time.Second)
  243. prescription := models.PredialysisEvaluation{
  244. DryWeight: dry_weight,
  245. AssessmentDate: dayTime.Unix(),
  246. }
  247. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  248. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  249. fmt.Println(errors)
  250. }
  251. keyThree := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  252. redis.Set(keyThree, "", time.Second)
  253. keyFive := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  254. redis.Set(keyFive, "", time.Second)
  255. redis.Close()
  256. fmt.Println("err", err)
  257. c.ServeSuccessJSON(map[string]interface{}{
  258. "patientDryweight": patientDryweight,
  259. })
  260. return
  261. }
  262. fmt.Println("sum", sum)
  263. if weight == 0 {
  264. sum = "/"
  265. }
  266. if weight > 0 {
  267. sum = weights + "(" + "下调" + ")"
  268. }
  269. if weight < 0 {
  270. var sums = dry_weight - dryweight
  271. float := fmt.Sprintf("%.1f", sums)
  272. //float := strconv.FormatFloat(sums, 'E', -1, 64)
  273. sum = float + "(" + "上调" + ")"
  274. }
  275. patientDryweight := models.SgjPatientDryweight{
  276. DryWeight: dry_weight,
  277. Creator: doctors,
  278. Remakes: remarks,
  279. AdjustedValue: sum,
  280. PatientId: patientid,
  281. Ctime: time.Now().Unix(),
  282. UserOrgId: orgid,
  283. Status: 1,
  284. UserId: userid,
  285. }
  286. err := service.CreatePatientWeight(&patientDryweight)
  287. recordDateStr := time.Now().Format("2006-01-02")
  288. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  289. fmt.Scan("parseDateErr", parseDateErr)
  290. nowtime := recordDate.Unix()
  291. fmt.Println("nowtime", nowtime)
  292. loc, _ := time.LoadLocation("Local")
  293. nowTime := time.Now()
  294. nowDay := nowTime.Format("2006-01-02")
  295. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  296. redis := service.RedisClient()
  297. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  298. redis.Set(keyTwo, "", time.Second)
  299. prescription := models.PredialysisEvaluation{
  300. DryWeight: dry_weight,
  301. AssessmentDate: dayTime.Unix(),
  302. }
  303. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  304. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  305. fmt.Println(errors)
  306. }
  307. //康桥
  308. if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10721 {
  309. timeNowStr := time.Now().Format("2006-01-02")
  310. timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
  311. beforAssesment, _ := service.GetPatientAssesmentBefor(patientid, timeNewDate.Unix(), adminUserInfo.CurrentOrgId)
  312. dialysisPrescription, _ := service.GetPatientDialysisPrescription(patientid, timeNewDate.Unix(), adminUserInfo.CurrentOrgId)
  313. if beforAssesment.ID > 0 {
  314. service.UpdatePatientAssesmentBefor(beforAssesment.ID, dry_weight)
  315. var dewater_amount float64
  316. dewater_amount = beforAssesment.WeightBefore - dry_weight - beforAssesment.AdditionalWeight
  317. if adminUserInfo.CurrentOrgId != 10702 {
  318. service.UpdatePatientDialysisPrscription(dialysisPrescription.ID, dewater_amount)
  319. }
  320. if adminUserInfo.CurrentOrgId == 10702 {
  321. service.UpdatePatientDialysisPrscriptionOne(dialysisPrescription.ID, dewater_amount)
  322. }
  323. //获取key,清空redis
  324. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_prescribe"
  325. redis := service.RedisClient()
  326. //清空key 值
  327. redis.Set(key, "", time.Second)
  328. keyOne := "scheduals_" + timeNowStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  329. //清空key 值
  330. redis.Set(keyOne, "", time.Second)
  331. keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_solution"
  332. //清空key 值
  333. redis.Set(keyTwo, "", time.Second)
  334. keySix := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":prescriptions_list_all"
  335. redis.Set(keySix, "", time.Second)
  336. keySeven := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
  337. redis.Set(keySeven, "", time.Second)
  338. }
  339. }
  340. key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  341. redis.Set(key, "", time.Second)
  342. keySix := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  343. redis.Set(keySix, "", time.Second)
  344. fmt.Println("err", err)
  345. redis.Close()
  346. c.ServeSuccessJSON(map[string]interface{}{
  347. "patientDryweight": patientDryweight,
  348. })
  349. }
  350. func (c *DoctorsApiController) GetAllData() {
  351. id, _ := c.GetInt64("id")
  352. page, _ := c.GetInt64("page")
  353. fmt.Println("page", page)
  354. limit, _ := c.GetInt64("limit")
  355. fmt.Println("limit", limit)
  356. fmt.Println("id", id)
  357. adminUserInfo := c.GetAdminUserInfo()
  358. orgid := adminUserInfo.CurrentOrgId
  359. dry, total, _ := service.GetAllData(orgid, id, page, limit)
  360. c.ServeSuccessJSON(map[string]interface{}{
  361. "dry": dry,
  362. "total": total,
  363. })
  364. }
  365. func (c *DoctorsApiController) GetDryWeightDetail() {
  366. id, _ := c.GetInt64("id")
  367. dryweight, _ := service.GetDryWeightDetailById(id)
  368. c.ServeSuccessJSON(map[string]interface{}{
  369. "dryweight": dryweight,
  370. })
  371. }
  372. func (c *DoctorsApiController) ModifydryWeightData() {
  373. adjustvalue := c.GetString("adjustvalue")
  374. creator, _ := c.GetInt64("creator")
  375. dryweight, _ := c.GetInt64("dryweight")
  376. dry := strconv.FormatInt(dryweight, 10)
  377. dry_weight, _ := strconv.ParseFloat(dry, 64)
  378. id, _ := c.GetInt64("id")
  379. remark := c.GetString("remark")
  380. patientDryweight := models.SgjPatientDryweight{
  381. AdjustedValue: adjustvalue,
  382. Creator: creator,
  383. DryWeight: dry_weight,
  384. Remakes: remark,
  385. }
  386. service.ModifyDryWeightData(&patientDryweight, id)
  387. c.ServeSuccessJSON(map[string]interface{}{
  388. "patientDryweight": patientDryweight,
  389. })
  390. }
  391. func (c *DoctorsApiController) DeleteDryWeight() {
  392. id, _ := c.GetInt64("id")
  393. service.DeleteDryWeight(id)
  394. returnData := make(map[string]interface{}, 0)
  395. returnData["msg"] = "ok"
  396. c.ServeSuccessJSON(returnData)
  397. return
  398. }
  399. func (c *DoctorsApiController) GetDoctorAdviceCount() {
  400. timeLayout := "2006-01-02"
  401. loc, _ := time.LoadLocation("Local")
  402. start_time := c.GetString("start_time")
  403. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  404. end_time := c.GetString("end_time")
  405. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  406. delive_way := c.GetString("delive_way")
  407. adminUserInfo := c.GetAdminUserInfo()
  408. orgId := adminUserInfo.CurrentOrgId
  409. list, _ := service.GetDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  410. if len(list) == 0 {
  411. list, _ := service.GetHisDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  412. c.ServeSuccessJSON(map[string]interface{}{
  413. "list": list,
  414. })
  415. } else {
  416. c.ServeSuccessJSON(map[string]interface{}{
  417. "list": list,
  418. })
  419. }
  420. }
  421. func (this *DoctorsApiController) SaveVasularAccess() {
  422. access_project, _ := this.GetInt64("access_project")
  423. blood_access_part_id := this.GetString("blood_access_part_id")
  424. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  425. first_start_time := this.GetString("first_start_time")
  426. timeLayout := "2006-01-02"
  427. loc, _ := time.LoadLocation("Local")
  428. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  429. inflow_pass := this.GetString("inflow_pass")
  430. remark := this.GetString("remark")
  431. start_time := this.GetString("start_time")
  432. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  433. stop_reason := this.GetString("stop_reason")
  434. user_status, _ := this.GetInt64("user_status")
  435. stop_time := this.GetString("stop_time")
  436. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  437. patient_id, _ := this.GetInt64("patient_id")
  438. other_vascular := this.GetString("other_vascular")
  439. ci_type, _ := this.GetInt64("ci_type")
  440. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  441. sequelae_type, _ := this.GetInt64("sequelae_type")
  442. adminUserInfo := this.GetAdminUserInfo()
  443. orgId := adminUserInfo.CurrentOrgId
  444. creator := adminUserInfo.AdminUser.Id
  445. //查询改日期是否存在
  446. access := models.XtPatientVascularAccess{
  447. AccessProject: access_project,
  448. BloodAccessPartId: blood_access_part_id,
  449. BloodAccessPartOperaId: blood_access_part_opera_id,
  450. FirstStartTime: firstStartTime.Unix(),
  451. InflowPass: inflow_pass,
  452. Remark: remark,
  453. StartTime: startTime.Unix(),
  454. StopReason: stop_reason,
  455. UserStatus: user_status,
  456. Creator: creator,
  457. UserOrgId: orgId,
  458. Status: 1,
  459. Ctime: time.Now().Unix(),
  460. StopTime: stopTime.Unix(),
  461. PatientId: patient_id,
  462. OtherVascular: other_vascular,
  463. CiType: ci_type,
  464. BloodCultupe: blood_cultupe,
  465. SequelaeType: sequelae_type,
  466. }
  467. err := service.SaveVascularAccess(&access)
  468. if err == nil {
  469. this.ServeSuccessJSON(map[string]interface{}{
  470. "access": access,
  471. })
  472. return
  473. //_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  474. //if errcode == gorm.ErrRecordNotFound {
  475. // access := models.XtPatientVascularAccess{
  476. // AccessProject: access_project,
  477. // BloodAccessPartId: blood_access_part_id,
  478. // BloodAccessPartOperaId: blood_access_part_opera_id,
  479. // FirstStartTime: firstStartTime.Unix(),
  480. // InflowPass: inflow_pass,
  481. // Remark: remark,
  482. // StartTime: startTime.Unix(),
  483. // StopReason: stop_reason,
  484. // UserStatus: user_status,
  485. // Creator: creator,
  486. // UserOrgId: orgId,
  487. // Status: 1,
  488. // Ctime: time.Now().Unix(),
  489. // StopTime: stopTime.Unix(),
  490. // PatientId: patient_id,
  491. // OtherVascular: other_vascular,
  492. // CiType: ci_type,
  493. // BloodCultupe: blood_cultupe,
  494. // SequelaeType: sequelae_type,
  495. // }
  496. // err := service.SaveVascularAccess(&access)
  497. // if err == nil {
  498. // this.ServeSuccessJSON(map[string]interface{}{
  499. // "access": access,
  500. // })
  501. // return
  502. // }
  503. //} else if errcode == nil {
  504. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  505. // return
  506. }
  507. }
  508. func (this *DoctorsApiController) GetAllVacualAccessList() {
  509. limit, _ := this.GetInt64("limit")
  510. page, _ := this.GetInt64("page")
  511. patient_id, _ := this.GetInt64("patient_id")
  512. orgId := this.GetAdminUserInfo().CurrentOrgId
  513. appId := this.GetAdminUserInfo().CurrentAppId
  514. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  515. doctor, err := service.GetAllDoctor(orgId, appId)
  516. if err == nil {
  517. this.ServeSuccessJSON(map[string]interface{}{
  518. "list": list,
  519. "total": total,
  520. "doctor": doctor,
  521. })
  522. return
  523. }
  524. }
  525. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  526. id, _ := this.GetInt64("id")
  527. accessDetail, err := service.GetVasularAccessByDetail(id)
  528. orgId := this.GetAdminUserInfo().CurrentOrgId
  529. appId := this.GetAdminUserInfo().CurrentAppId
  530. doctor, err := service.GetAllDoctor(orgId, appId)
  531. if err == nil {
  532. this.ServeSuccessJSON(map[string]interface{}{
  533. "accessDetail": accessDetail,
  534. "doctor": doctor,
  535. })
  536. return
  537. }
  538. }
  539. func (this *DoctorsApiController) UpdateVasularAccess() {
  540. id, _ := this.GetInt64("id")
  541. access_project, _ := this.GetInt64("access_project")
  542. blood_access_part_id := this.GetString("blood_access_part_id")
  543. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  544. first_start_time := this.GetString("first_start_time")
  545. timeLayout := "2006-01-02"
  546. loc, _ := time.LoadLocation("Local")
  547. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  548. inflow_pass := this.GetString("inflow_pass")
  549. remark := this.GetString("remark")
  550. start_time := this.GetString("start_time")
  551. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  552. stop_reason := this.GetString("stop_reason")
  553. user_status, _ := this.GetInt64("user_status")
  554. stop_time := this.GetString("stop_time")
  555. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  556. adminUserInfo := this.GetAdminUserInfo()
  557. orgId := adminUserInfo.CurrentOrgId
  558. creator := adminUserInfo.AdminUser.Id
  559. patientId, _ := this.GetInt64("patient_id")
  560. other_vascular := this.GetString("other_vascular")
  561. ci_type, _ := this.GetInt64("ci_type")
  562. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  563. sequelae_type, _ := this.GetInt64("sequelae_type")
  564. access := models.XtPatientVascularAccess{
  565. AccessProject: access_project,
  566. BloodAccessPartId: blood_access_part_id,
  567. BloodAccessPartOperaId: blood_access_part_opera_id,
  568. FirstStartTime: firstStartTime.Unix(),
  569. InflowPass: inflow_pass,
  570. Remark: remark,
  571. StartTime: startTime.Unix(),
  572. StopReason: stop_reason,
  573. UserStatus: user_status,
  574. Modify: creator,
  575. UserOrgId: orgId,
  576. Status: 1,
  577. StopTime: stopTime.Unix(),
  578. OtherVascular: other_vascular,
  579. CiType: ci_type,
  580. BloodCultupe: blood_cultupe,
  581. SequelaeType: sequelae_type,
  582. PatientId: patientId,
  583. }
  584. err := service.UpdateVascularAccess(&access, id)
  585. if err == nil {
  586. this.ServeSuccessJSON(map[string]interface{}{
  587. "access": access,
  588. })
  589. return
  590. }
  591. //_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  592. //if errcode == gorm.ErrRecordNotFound {
  593. // err := service.UpdateVascularAccess(&access, id)
  594. // if err == nil {
  595. // this.ServeSuccessJSON(map[string]interface{}{
  596. // "access": access,
  597. // })
  598. // return
  599. // }
  600. //} else if errcode == nil {
  601. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  602. // return
  603. //}
  604. }
  605. func (this *DoctorsApiController) DeleteVasularAccess() {
  606. id, _ := this.GetInt64("id")
  607. err := service.DeleteVasularAccess(id)
  608. fmt.Println(err)
  609. returnData := make(map[string]interface{}, 0)
  610. returnData["msg"] = "ok"
  611. this.ServeSuccessJSON(returnData)
  612. return
  613. }
  614. func (this *DoctorsApiController) SavePassWayAssessment() {
  615. blood_dealwidth := this.GetString("blood_dealwith")
  616. blood_project := this.GetString("blood_project")
  617. blood_result := this.GetString("blood_result")
  618. creator, _ := this.GetInt64("creator")
  619. parent_id, _ := this.GetInt64("parent_id")
  620. patient_id, _ := this.GetInt64("patient_id")
  621. start_time := this.GetString("start_time")
  622. timeLayout := "2006-01-02"
  623. loc, _ := time.LoadLocation("Local")
  624. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  625. modify := this.GetAdminUserInfo().AdminUser.Id
  626. orgId := this.GetAdminUserInfo().CurrentOrgId
  627. assessment := models.XtPatientPasswayAssessment{
  628. StartTime: startTime.Unix(),
  629. BloodDealwith: blood_dealwidth,
  630. BloodProject: blood_project,
  631. BloodResult: blood_result,
  632. Creator: creator,
  633. PatientId: patient_id,
  634. ParentId: parent_id,
  635. Modify: modify,
  636. UserOrgId: orgId,
  637. Status: 1,
  638. Ctime: time.Now().Unix(),
  639. }
  640. err := service.CreatePatientWayAssessment(&assessment)
  641. if err == nil {
  642. this.ServeSuccessJSON(map[string]interface{}{
  643. "assessment": assessment,
  644. })
  645. return
  646. }
  647. }
  648. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  649. patient_id, _ := this.GetInt64("patient_id")
  650. parent_id, _ := this.GetInt64("parent_id")
  651. page, _ := this.GetInt64("page")
  652. limit, _ := this.GetInt64("limit")
  653. adminUserInfo := this.GetAdminUserInfo()
  654. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  655. if err == nil {
  656. this.ServeSuccessJSON(map[string]interface{}{
  657. "list": list,
  658. "total": total,
  659. })
  660. return
  661. }
  662. }
  663. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  664. id, _ := this.GetInt64("id")
  665. assessment, err := service.GetPasswayAssesmentById(id)
  666. if err == nil {
  667. this.ServeSuccessJSON(map[string]interface{}{
  668. "assessment": assessment,
  669. })
  670. return
  671. }
  672. }
  673. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  674. id, _ := this.GetInt64("id")
  675. blood_dealwidth := this.GetString("blood_dealwith")
  676. blood_project := this.GetString("blood_project")
  677. blood_result := this.GetString("blood_result")
  678. creator, _ := this.GetInt64("creator")
  679. start_time := this.GetString("start_time")
  680. timeLayout := "2006-01-02"
  681. loc, _ := time.LoadLocation("Local")
  682. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  683. modify := this.GetAdminUserInfo().AdminUser.Id
  684. assessment := models.XtPatientPasswayAssessment{
  685. BloodResult: blood_result,
  686. BloodDealwith: blood_dealwidth,
  687. BloodProject: blood_project,
  688. Creator: creator,
  689. StartTime: startTime.Unix(),
  690. Modify: modify,
  691. }
  692. err := service.UpdatePassWayAssesment(&assessment, id)
  693. if err == nil {
  694. this.ServeSuccessJSON(map[string]interface{}{
  695. "assessment": assessment,
  696. })
  697. return
  698. }
  699. }
  700. func (this *DoctorsApiController) DeleteWayAssessment() {
  701. id, _ := this.GetInt64("id")
  702. err := service.DeleteWayAssessment(id)
  703. fmt.Println(err)
  704. returnData := make(map[string]interface{}, 0)
  705. returnData["msg"] = "ok"
  706. this.ServeSuccessJSON(returnData)
  707. return
  708. }
  709. func (this *DoctorsApiController) GetAccessList() {
  710. adminUserInfo := this.GetAdminUserInfo()
  711. orgId := adminUserInfo.CurrentOrgId
  712. //血管通路
  713. list, err := service.GetAccessList(orgId)
  714. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  715. //血管通路部位
  716. access, err := service.GetBloodAccess(orgId)
  717. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  718. if err == nil {
  719. this.ServeSuccessJSON(map[string]interface{}{
  720. "blood_access_part_opera": blood_access_part_opera,
  721. "blood_access_part": blood_access_part,
  722. })
  723. return
  724. }
  725. }
  726. func (this *DoctorsApiController) GetInspectionMajorItem() {
  727. other_start_time := this.GetString("other_start_time")
  728. last_time := this.GetString("last_time")
  729. timeLayout := "2006-01-02"
  730. loc, _ := time.LoadLocation("Local")
  731. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
  732. lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
  733. patient_id, _ := this.GetInt64("patient_id")
  734. adminUserInfo := this.GetAdminUserInfo()
  735. orgId := adminUserInfo.CurrentOrgId
  736. list, err := service.GetInspectionMajorItem(startTime.Unix(), lastTime.Unix(), orgId, patient_id)
  737. if err == nil {
  738. this.ServeSuccessJSON(map[string]interface{}{
  739. "list": list,
  740. })
  741. return
  742. }
  743. }
  744. func (this *DoctorsApiController) GetInspectionDetailByProject() {
  745. project_id, _ := this.GetInt64("project_id")
  746. patient_id, _ := this.GetInt64("patient_id")
  747. inspect_date, _ := this.GetInt64("inspect_date")
  748. orgId := this.GetAdminUserInfo().CurrentOrgId
  749. list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
  750. if err == nil {
  751. this.ServeSuccessJSON(map[string]interface{}{
  752. "list": list,
  753. })
  754. return
  755. }
  756. }
  757. func (this *DoctorsApiController) GetInspectionItemlist() {
  758. patient_id, _ := this.GetInt64("patient_id")
  759. ids := this.GetString("ids")
  760. inspect_date := this.GetString("inspect_date")
  761. idSplit := strings.Split(ids, ",")
  762. indateSplit := strings.Split(inspect_date, ",")
  763. list, err := service.GetInspectionItemlist(patient_id, indateSplit, idSplit)
  764. if err == nil {
  765. this.ServeSuccessJSON(map[string]interface{}{
  766. "list": list,
  767. })
  768. return
  769. }
  770. }
  771. func (this *DoctorsApiController) GetInitDateList() {
  772. patient_id, _ := this.GetInt64("patient_id")
  773. start_time := this.GetString("start_time")
  774. timeLayout := "2006-01-02"
  775. loc, _ := time.LoadLocation("Local")
  776. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  777. end_time := this.GetString("end_time")
  778. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  779. prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id, startTime.Unix(), endTime.Unix())
  780. befor_list, err := service.GetDialysisBeforInitDateList(patient_id, startTime.Unix(), endTime.Unix())
  781. after_list, err := service.GetDialysisAssementAfter(patient_id, startTime.Unix(), endTime.Unix())
  782. orgId := this.GetAdminUserInfo().CurrentOrgId
  783. //统计透析次数
  784. modelist, err := service.GetDialysisDialysisMode(patient_id, startTime.Unix(), endTime.Unix(), orgId)
  785. docList, _ := service.GetAllDoctorThree(orgId)
  786. stockType, err := service.GetStockType(orgId)
  787. summaryList, err := service.GetTemplateSummary(orgId)
  788. planList, err := service.GetTemplatePlan(orgId)
  789. if err == nil {
  790. this.ServeSuccessJSON(map[string]interface{}{
  791. "beforlist": befor_list,
  792. "prescription_list": prescription_list,
  793. "after_list": after_list,
  794. "modelist": modelist,
  795. "docList": docList,
  796. "stockType": stockType,
  797. "summaryList": summaryList,
  798. "planList": planList,
  799. })
  800. return
  801. }
  802. }
  803. func (this *DoctorsApiController) SaveCreationInspection() {
  804. dataBody := make(map[string]interface{}, 0)
  805. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  806. if err != nil {
  807. utils.ErrorLog(err.Error())
  808. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  809. return
  810. }
  811. title := dataBody["title"].(string)
  812. dryWeight := dataBody["dry_weight"].(string)
  813. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  814. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  815. hd_count := int64(dataBody["hd_count"].(float64))
  816. hdf_count := int64(dataBody["hdf_count"].(float64))
  817. hp_count := int64(dataBody["hp_count"].(float64))
  818. other_count := int64(dataBody["other_count"].(float64))
  819. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  820. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  821. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  822. kaliumstr := dataBody["kalium"].(string)
  823. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  824. autunitestr := dataBody["autunite"].(string)
  825. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  826. natriumstr := dataBody["natrium"].(string)
  827. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  828. hour := int64(dataBody["hour"].(float64))
  829. minute := int64(dataBody["minute"].(float64))
  830. beforWeight := dataBody["befor_weight"].(string)
  831. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  832. afterWeight := dataBody["after_weight"].(string)
  833. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  834. befor_pressure := dataBody["befor_pressure"].(string)
  835. template_summary_content := dataBody["template_summary_content"].(string)
  836. template_plan_content := dataBody["template_plan_content"].(string)
  837. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  838. record_time := dataBody["record_time"].(string)
  839. timeLayout := "2006-01-02"
  840. loc, _ := time.LoadLocation("Local")
  841. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  842. after_pressure := dataBody["after_pressure"].(string)
  843. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  844. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  845. patient_id := int64(dataBody["patient_id"].(float64))
  846. orgId := this.GetAdminUserInfo().CurrentOrgId
  847. inspect_date := dataBody["inspect_date"].(string)
  848. project_id := dataBody["project_id"].(string)
  849. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  850. summary := models.XtTemplateSummary{
  851. StartYear: 0,
  852. StartMonth: 0,
  853. Radio: 0,
  854. Quarter: 0,
  855. DryWeight: dry_weight,
  856. DialysisCount: dialysis_count,
  857. HdCount: hd_count,
  858. HdfCount: hdf_count,
  859. HpCount: hp_count,
  860. OtherCount: other_count,
  861. DialzerApparatus: dialzer_apparatus,
  862. PerfusionApparatus: perfusion_apparatus,
  863. Anticoagulant: anticoagulant,
  864. Kalium: kalium,
  865. Autunite: autunite,
  866. Natrium: natrium,
  867. Hour: hour,
  868. Minute: minute,
  869. BeforWeight: befor_weight,
  870. AfterWeight: after_weight,
  871. BeforPressure: befor_pressure,
  872. AfterPressure: after_pressure,
  873. TemplateSummaryId: template_summary_id,
  874. TemplateSummaryContent: template_summary_content,
  875. TemplatePlanId: template_plan_id,
  876. TemplatePlanContent: template_plan_content,
  877. TemplateInspectionId: template_inspection_id,
  878. AdminUserId: admin_user_id,
  879. RecordTime: recordTime.Unix(),
  880. PatientId: patient_id,
  881. UserOrgId: orgId,
  882. Status: 1,
  883. Ctime: time.Now().Unix(),
  884. Mtime: 0,
  885. Title: title,
  886. InspectDate: inspect_date,
  887. ProjectId: project_id,
  888. }
  889. err = service.CreateSummary(&summary)
  890. if err == nil {
  891. this.ServeSuccessJSON(map[string]interface{}{
  892. "summary": summary,
  893. })
  894. return
  895. }
  896. }
  897. func (this *DoctorsApiController) GetTemplateSummaryList() {
  898. patient_id, _ := this.GetInt64("patient_id")
  899. start_time := this.GetString("start_time")
  900. timeLayout := "2006-01-02"
  901. loc, _ := time.LoadLocation("Local")
  902. end_time := this.GetString("end_time")
  903. orgId := this.GetAdminUserInfo().CurrentOrgId
  904. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  905. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  906. list, err := service.GetTemplateSummaryList(patient_id, orgId, startTime.Unix(), endTime.Unix())
  907. if err == nil {
  908. this.ServeSuccessJSON(map[string]interface{}{
  909. "list": list,
  910. })
  911. return
  912. }
  913. }
  914. func (this *DoctorsApiController) GetTemplateSummaryDetail() {
  915. id, _ := this.GetInt64("id")
  916. list, err := service.GetTemplateSummaryDetail(id)
  917. ids := strings.Split(list.ProjectId, ",")
  918. datelist := strings.Split(list.InspectDate, ",")
  919. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  920. if err == nil {
  921. this.ServeSuccessJSON(map[string]interface{}{
  922. "list": list,
  923. "inspectlist": inspectlist,
  924. })
  925. return
  926. }
  927. }
  928. func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
  929. id, _ := this.GetInt64("id")
  930. list, err := service.GetTemplateSummaryPrintDetail(id)
  931. ids := strings.Split(list.ProjectId, ",")
  932. datelist := strings.Split(list.InspectDate, ",")
  933. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  934. orgId := this.GetAdminUserInfo().CurrentOrgId
  935. doctorList, _ := service.GetAllDoctorThree(orgId)
  936. if err == nil {
  937. this.ServeSuccessJSON(map[string]interface{}{
  938. "list": list,
  939. "doctorList": doctorList,
  940. "inspectlist": inspectlist,
  941. })
  942. return
  943. }
  944. }
  945. func (this *DoctorsApiController) UpdateTempalteSummary() {
  946. dataBody := make(map[string]interface{}, 0)
  947. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  948. if err != nil {
  949. utils.ErrorLog(err.Error())
  950. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  951. return
  952. }
  953. id := int64(dataBody["id"].(float64))
  954. title := dataBody["title"].(string)
  955. dryWeight := dataBody["dry_weight"].(string)
  956. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  957. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  958. hd_count := int64(dataBody["hd_count"].(float64))
  959. hdf_count := int64(dataBody["hdf_count"].(float64))
  960. hp_count := int64(dataBody["hp_count"].(float64))
  961. other_count := int64(dataBody["other_count"].(float64))
  962. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  963. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  964. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  965. kaliumstr := dataBody["kalium"].(string)
  966. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  967. autunitestr := dataBody["autunite"].(string)
  968. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  969. natriumstr := dataBody["natrium"].(string)
  970. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  971. hour := int64(dataBody["hour"].(float64))
  972. minute := int64(dataBody["minute"].(float64))
  973. beforWeight := dataBody["befor_weight"].(string)
  974. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  975. afterWeight := dataBody["after_weight"].(string)
  976. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  977. befor_pressure := dataBody["befor_pressure"].(string)
  978. template_summary_content := dataBody["template_summary_content"].(string)
  979. template_plan_content := dataBody["template_plan_content"].(string)
  980. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  981. record_time := dataBody["record_time"].(string)
  982. timeLayout := "2006-01-02"
  983. loc, _ := time.LoadLocation("Local")
  984. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  985. after_pressure := dataBody["after_pressure"].(string)
  986. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  987. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  988. patient_id := int64(dataBody["patient_id"].(float64))
  989. orgId := this.GetAdminUserInfo().CurrentOrgId
  990. inspect_date := dataBody["inspect_date"].(string)
  991. project_id := dataBody["project_id"].(string)
  992. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  993. //dryWeight := this.GetString("dry_weight")
  994. //dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  995. //dialysis_count, _ := this.GetInt64("dialysis_count")
  996. //hd_count, _ := this.GetInt64("hd_count")
  997. //hdf_count, _ := this.GetInt64("hdf_count")
  998. //hp_count, _ := this.GetInt64("hp_count")
  999. //other_count, _ := this.GetInt64("other_count")
  1000. //dialzer_apparatus := this.GetString("dialzer_apparatus")
  1001. //perfusion_apparatus := this.GetString("perfusion_apparatus")
  1002. //anticoagulant, _ := this.GetInt64("anticoagulant")
  1003. //kaliumstr := this.GetString("kalium")
  1004. //kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  1005. //
  1006. //autunitestr := this.GetString("autunite")
  1007. //autunite, _ := strconv.ParseFloat(autunitestr, 64)
  1008. //natriumstr := this.GetString("natrium")
  1009. //natrium, _ := strconv.ParseFloat(natriumstr, 64)
  1010. //hour, _ := this.GetInt64("hour")
  1011. //minute, _ := this.GetInt64("minute")
  1012. //beforWeight := this.GetString("befor_weight")
  1013. //befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  1014. //afterWeight := this.GetString("after_weight")
  1015. //after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  1016. //befor_pressure := this.GetString("befor_pressure")
  1017. //template_summary_content := this.GetString("template_summary_content")
  1018. //template_plan_content := this.GetString("template_plan_content")
  1019. //admin_user_id, _ := this.GetInt64("admin_user_id")
  1020. //record_time := this.GetString("record_time")
  1021. //timeLayout := "2006-01-02"
  1022. //loc, _ := time.LoadLocation("Local")
  1023. //recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  1024. //after_pressure := this.GetString("after_pressure")
  1025. //template_summary_id, _ := this.GetInt64("template_summary_id")
  1026. //template_plan_id, _ := this.GetInt64("template_plan_id")
  1027. //template_inspection_id, _ := this.GetInt64("template_inspection_id")
  1028. //patient_id, _ := this.GetInt64("patient_id")
  1029. //fmt.Println("patient_id", patient_id)
  1030. //orgId := this.GetAdminUserInfo().CurrentOrgId
  1031. //inspect_date := this.GetString("inspect_date")
  1032. //project_id := this.GetString("project_id")
  1033. summary := models.XtTemplateSummary{
  1034. ID: id,
  1035. StartYear: 0,
  1036. StartMonth: 0,
  1037. Radio: 0,
  1038. Quarter: 0,
  1039. DryWeight: dry_weight,
  1040. DialysisCount: dialysis_count,
  1041. HdCount: hd_count,
  1042. HdfCount: hdf_count,
  1043. HpCount: hp_count,
  1044. OtherCount: other_count,
  1045. DialzerApparatus: dialzer_apparatus,
  1046. PerfusionApparatus: perfusion_apparatus,
  1047. Anticoagulant: anticoagulant,
  1048. Kalium: kalium,
  1049. Autunite: autunite,
  1050. Natrium: natrium,
  1051. Hour: hour,
  1052. Minute: minute,
  1053. BeforWeight: befor_weight,
  1054. AfterWeight: after_weight,
  1055. BeforPressure: befor_pressure,
  1056. AfterPressure: after_pressure,
  1057. TemplateSummaryId: template_summary_id,
  1058. TemplateSummaryContent: template_summary_content,
  1059. TemplatePlanId: template_plan_id,
  1060. TemplatePlanContent: template_plan_content,
  1061. TemplateInspectionId: template_inspection_id,
  1062. AdminUserId: admin_user_id,
  1063. RecordTime: recordTime.Unix(),
  1064. PatientId: patient_id,
  1065. UserOrgId: orgId,
  1066. Status: 1,
  1067. Ctime: time.Now().Unix(),
  1068. Mtime: 0,
  1069. Title: title,
  1070. ProjectId: project_id,
  1071. InspectDate: inspect_date,
  1072. }
  1073. err = service.UpdateTempalteSummary(&summary)
  1074. if err == nil {
  1075. this.ServeSuccessJSON(map[string]interface{}{
  1076. "list": summary,
  1077. })
  1078. return
  1079. }
  1080. }
  1081. func (this *DoctorsApiController) DeleteSummary() {
  1082. ids := this.GetString("ids")
  1083. idsplit := strings.Split(ids, ",")
  1084. err := service.DeleteSummary(idsplit)
  1085. fmt.Println(err)
  1086. returnData := make(map[string]interface{}, 0)
  1087. returnData["msg"] = "ok"
  1088. this.ServeSuccessJSON(returnData)
  1089. return
  1090. }
  1091. func (this *DoctorsApiController) HospitalSummary() {
  1092. timeLayout := "2006-01-02"
  1093. loc, _ := time.LoadLocation("Local")
  1094. dataBody := make(map[string]interface{}, 0)
  1095. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1096. fmt.Print("err", err)
  1097. admission_time := dataBody["admission_time"].(string)
  1098. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1099. admissiontime := admissionTimes.Unix()
  1100. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1101. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1102. connecticut := dataBody["connecticut"].(string)
  1103. dean := int64(dataBody["dean"].(float64))
  1104. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1105. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1106. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1107. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1108. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1109. discharge_advice := dataBody["discharge_advice"].(string)
  1110. discharge_time := dataBody["discharge_time"].(string)
  1111. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1112. dischargetime := dischargeTimes.Unix()
  1113. doctor := int64(dataBody["doctor"].(float64))
  1114. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1115. illness_discharge := dataBody["illness_discharge"].(string)
  1116. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1117. pathology := dataBody["pathology"].(string)
  1118. record_date := dataBody["record_date"].(string)
  1119. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1120. recordtime := recordDates.Unix()
  1121. sick_personnel := dataBody["sick_personnel"].(string)
  1122. title := dataBody["title"].(string)
  1123. treatment_id := dataBody["treatment_id"].(string)
  1124. treatment := dataBody["treatment"].(string)
  1125. ultrasound := dataBody["ultrasound"].(string)
  1126. xray := dataBody["xray"].(string)
  1127. patient_id := int64(dataBody["patient_id"].(float64))
  1128. orgId := this.GetAdminUserInfo().CurrentOrgId
  1129. summary := models.XtHospitalSummary{
  1130. PatientId: patient_id,
  1131. AdmissionTime: admissiontime,
  1132. DischargeTime: dischargetime,
  1133. SickPersonnel: sick_personnel,
  1134. Xray: xray,
  1135. Connecticut: connecticut,
  1136. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1137. Ultrasound: ultrasound,
  1138. Pathology: pathology,
  1139. AdmittingDiagnosisId: admitting_diagnosis_id,
  1140. AdmittingDiagnosis: admitting_diagnosis,
  1141. DischargeDiagnosis: discharge_diagnosis,
  1142. DiagnosisAdmissionId: diagnosis_admission_id,
  1143. DiagnosisAdmission: diagnosis_admission,
  1144. TreatmentId: treatment_id,
  1145. Treatment: treatment,
  1146. IllnessDischargeId: illness_discharge_id,
  1147. IllnessDischarge: illness_discharge,
  1148. DischargeAdviceId: discharge_advice_id,
  1149. DischargeAdvice: discharge_advice,
  1150. UserOrgId: orgId,
  1151. Status: 1,
  1152. Ctime: time.Now().Unix(),
  1153. Mtime: 0,
  1154. RecordTime: recordtime,
  1155. Title: title,
  1156. Doctor: doctor,
  1157. RecordDate: recordtime,
  1158. DeanId: dean,
  1159. DischargeDiagnosisId: discharge_diagnosis_id,
  1160. }
  1161. service.CreateHisSummary(&summary)
  1162. this.ServeSuccessJSON(map[string]interface{}{
  1163. "list": summary,
  1164. })
  1165. return
  1166. }
  1167. func (this *DoctorsApiController) GetHospitalSummaryList() {
  1168. timeLayout := "2006-01-02"
  1169. loc, _ := time.LoadLocation("Local")
  1170. orgId := this.GetAdminUserInfo().CurrentOrgId
  1171. patient_id, _ := this.GetInt64("patient_id")
  1172. start_time := this.GetString("start_time")
  1173. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1174. startime := dischargeTimes.Unix()
  1175. end_time := this.GetString("end_time")
  1176. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1177. endtime := endTimes.Unix()
  1178. list, err := service.GetHospitalSummaryList(orgId, patient_id, startime, endtime)
  1179. if err == nil {
  1180. this.ServeSuccessJSON(map[string]interface{}{
  1181. "list": list,
  1182. })
  1183. return
  1184. }
  1185. }
  1186. func (this *DoctorsApiController) GetHospitalSummaryDetail() {
  1187. id, _ := this.GetInt64("id")
  1188. detail, err := service.GetHospitalSummaryDetail(id)
  1189. orgId := this.GetAdminUserInfo().CurrentOrgId
  1190. operators, err := service.GetAdminUserEsOne(orgId)
  1191. if err == nil {
  1192. this.ServeSuccessJSON(map[string]interface{}{
  1193. "detail": detail,
  1194. "operators": operators,
  1195. })
  1196. return
  1197. }
  1198. }
  1199. func (this *DoctorsApiController) UpdateHospitalSummary() {
  1200. timeLayout := "2006-01-02"
  1201. loc, _ := time.LoadLocation("Local")
  1202. dataBody := make(map[string]interface{}, 0)
  1203. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1204. fmt.Print("err", err)
  1205. admission_time := dataBody["admission_time"].(string)
  1206. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1207. admissiontime := admissionTimes.Unix()
  1208. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1209. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1210. connecticut := dataBody["connecticut"].(string)
  1211. dean := int64(dataBody["dean"].(float64))
  1212. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1213. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1214. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1215. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1216. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1217. discharge_advice := dataBody["discharge_advice"].(string)
  1218. discharge_time := dataBody["discharge_time"].(string)
  1219. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1220. dischargetime := dischargeTimes.Unix()
  1221. doctor := int64(dataBody["doctor"].(float64))
  1222. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1223. illness_discharge := dataBody["illness_discharge"].(string)
  1224. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1225. pathology := dataBody["pathology"].(string)
  1226. record_date := dataBody["record_date"].(string)
  1227. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1228. recordtime := recordDates.Unix()
  1229. sick_personnel := dataBody["sick_personnel"].(string)
  1230. title := dataBody["title"].(string)
  1231. treatment_id := dataBody["treatment_id"].(string)
  1232. treatment := dataBody["treatment"].(string)
  1233. ultrasound := dataBody["ultrasound"].(string)
  1234. xray := dataBody["xray"].(string)
  1235. patient_id := int64(dataBody["patient_id"].(float64))
  1236. id := int64(dataBody["id"].(float64))
  1237. summary := models.XtHospitalSummary{
  1238. PatientId: patient_id,
  1239. AdmissionTime: admissiontime,
  1240. DischargeTime: dischargetime,
  1241. SickPersonnel: sick_personnel,
  1242. Xray: xray,
  1243. Connecticut: connecticut,
  1244. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1245. Ultrasound: ultrasound,
  1246. Pathology: pathology,
  1247. AdmittingDiagnosisId: admitting_diagnosis_id,
  1248. AdmittingDiagnosis: admitting_diagnosis,
  1249. DischargeDiagnosis: discharge_diagnosis,
  1250. DiagnosisAdmissionId: diagnosis_admission_id,
  1251. DiagnosisAdmission: diagnosis_admission,
  1252. TreatmentId: treatment_id,
  1253. Treatment: treatment,
  1254. IllnessDischargeId: illness_discharge_id,
  1255. IllnessDischarge: illness_discharge,
  1256. DischargeAdviceId: discharge_advice_id,
  1257. DischargeAdvice: discharge_advice,
  1258. Mtime: time.Now().Unix(),
  1259. RecordTime: recordtime,
  1260. Title: title,
  1261. Doctor: doctor,
  1262. RecordDate: recordtime,
  1263. DeanId: dean,
  1264. DischargeDiagnosisId: discharge_diagnosis_id,
  1265. }
  1266. err = service.UpdateHospital(id, summary)
  1267. if err == nil {
  1268. this.ServeSuccessJSON(map[string]interface{}{
  1269. "detail": summary,
  1270. })
  1271. return
  1272. }
  1273. }
  1274. func (this *DoctorsApiController) DeleteHospitalSummary() {
  1275. schIDStr := this.GetString("ids")
  1276. idStrs := strings.Split(schIDStr, ",")
  1277. err := service.DeleteHospitalSummary(idStrs)
  1278. fmt.Println(err)
  1279. returnData := make(map[string]interface{}, 0)
  1280. returnData["msg"] = "ok"
  1281. this.ServeSuccessJSON(returnData)
  1282. return
  1283. }
  1284. func (this *DoctorsApiController) GetPatientInfo() {
  1285. patient_id, _ := this.GetInt64("patient_id")
  1286. orgId := this.GetAdminUserInfo().CurrentOrgId
  1287. detail, err := service.GetPatientDetail(patient_id, orgId)
  1288. if err == nil {
  1289. this.ServeSuccessJSON(map[string]interface{}{
  1290. "patient": detail,
  1291. })
  1292. return
  1293. }
  1294. }
  1295. func (c *DoctorsApiController) GetScheduleAdvicesList() {
  1296. schedualDate := c.GetString("date")
  1297. adviceType, _ := c.GetInt("advice_type")
  1298. patientType, _ := c.GetInt("patient_type")
  1299. delivery_way := c.GetString("delivery_way")
  1300. schedule_type, _ := c.GetInt64("schedule_type")
  1301. partition_type, _ := c.GetInt64("partition_type")
  1302. patient_id, _ := c.GetInt64("patient_id")
  1303. excution_way, _ := c.GetInt64("excution_way")
  1304. cost_type, _ := c.GetInt64("cost_type")
  1305. execution_frequency := c.GetString("execution_frequency")
  1306. keyword := c.GetString("keyword")
  1307. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  1308. adviceType = 0
  1309. }
  1310. if patientType != 1 && patientType != 2 {
  1311. patientType = 0
  1312. }
  1313. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  1314. if parseDateErr != nil {
  1315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1316. return
  1317. }
  1318. adminUserInfo := c.GetAdminUserInfo()
  1319. orgID := adminUserInfo.CurrentOrgId
  1320. config, _ := service.GetHisDoctorConfig(orgID)
  1321. project_config, _ := service.GetHisProjectConfig(orgID)
  1322. if config.IsOpen == 0 || config.IsOpen == 2 {
  1323. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency, keyword)
  1324. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  1325. if err != nil {
  1326. c.ErrorLog("获取排班信息失败:%v", err)
  1327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1328. } else {
  1329. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  1330. for _, schedual := range scheduals {
  1331. if len(schedual.DoctorAdvices) > 0 {
  1332. filtedScheduals = append(filtedScheduals, schedual)
  1333. }
  1334. }
  1335. c.ServeSuccessJSON(map[string]interface{}{
  1336. "scheduals": filtedScheduals,
  1337. "adminUser": adminUser,
  1338. "config": config,
  1339. "project_config": project_config,
  1340. })
  1341. }
  1342. }
  1343. if config.IsOpen == 1 {
  1344. hisAdvices, err := service.GetHisDoctorAdvicesTwentyOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency)
  1345. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  1346. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
  1347. for _, item := range project {
  1348. index := 0
  1349. for _, subItem := range item.HisPrescriptionTeamProject {
  1350. if subItem.HisProject.CostClassify != 3 {
  1351. subItem.IsCheckTeam = 2
  1352. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  1353. }
  1354. if subItem.HisProject.CostClassify == 3 {
  1355. subItem.IsCheckTeam = 1
  1356. index = index + 1
  1357. if index == 1 {
  1358. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  1359. }
  1360. }
  1361. }
  1362. }
  1363. if err != nil {
  1364. c.ErrorLog("获取排班信息失败:%v", err)
  1365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1366. } else {
  1367. c.ServeSuccessJSON(map[string]interface{}{
  1368. "adminUser": adminUser,
  1369. "hisAdvices": hisAdvices,
  1370. "config": config,
  1371. "project_config": project_config,
  1372. "project": project,
  1373. })
  1374. }
  1375. }
  1376. }
  1377. func (c *DoctorsApiController) CreateFirstDisease() {
  1378. //timeLayout := "2006-01-02"
  1379. //loc, _ := time.LoadLocation("Local")
  1380. dataBody := make(map[string]interface{}, 0)
  1381. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  1382. fmt.Print("err", err)
  1383. doctor := int64(dataBody["doctor"].(float64))
  1384. record_date := dataBody["record_date"].(string)
  1385. recordDates, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_date)
  1386. recordtime := recordDates.Unix()
  1387. patient_id := int64(dataBody["patient_id"].(float64))
  1388. title := dataBody["title"].(string)
  1389. main_content := dataBody["main_content"].(string)
  1390. patient_case := dataBody["patient_case"].(string)
  1391. tentative_diagnosis := dataBody["tentative_diagnosis"].(string)
  1392. diagnostic_basis := dataBody["diagnostic_basis"].(string)
  1393. differential_diagnosis := dataBody["differential_diagnosis"].(string)
  1394. treatment_plan := dataBody["treatment_plan"].(string)
  1395. inspect_date := dataBody["inspect_date"].(string)
  1396. project_id := dataBody["project_id"].(string)
  1397. orgId := c.GetAdminUserInfo().CurrentOrgId
  1398. firstdisease := models.XtPatientFirstDisease{
  1399. Title: title,
  1400. RecordDate: recordtime,
  1401. Doctor: doctor,
  1402. MainContent: main_content,
  1403. PatientCase: patient_case,
  1404. TentativeDiagnosis: tentative_diagnosis,
  1405. DiagnosticBasis: diagnostic_basis,
  1406. DifferentialDiagnosis: differential_diagnosis,
  1407. TreatmentPlan: treatment_plan,
  1408. UserOrgId: orgId,
  1409. PatientId: patient_id,
  1410. Ctime: time.Now().Unix(),
  1411. Mtime: 0,
  1412. Status: 1,
  1413. ProjectId: project_id,
  1414. InspectDate: inspect_date,
  1415. }
  1416. error := service.CreatePatientFirstDisease(firstdisease)
  1417. if error == nil {
  1418. c.ServeSuccessJSON(map[string]interface{}{
  1419. "firstDisease": firstdisease,
  1420. })
  1421. }
  1422. }
  1423. func (c *DoctorsApiController) GetFirstDiseaseList() {
  1424. timeLayout := "2006-01-02"
  1425. loc, _ := time.LoadLocation("Local")
  1426. orgId := c.GetAdminUserInfo().CurrentOrgId
  1427. patient_id, _ := c.GetInt64("patient_id")
  1428. start_time := c.GetString("start_time")
  1429. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1430. startime := dischargeTimes.Unix()
  1431. end_time := c.GetString("end_time")
  1432. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1433. endtime := endTimes.Unix()
  1434. list, err := service.GetPatientDiseaseList(orgId, patient_id, startime, endtime)
  1435. if err == nil {
  1436. c.ServeSuccessJSON(map[string]interface{}{
  1437. "list": list,
  1438. })
  1439. return
  1440. }
  1441. }
  1442. func (c *DoctorsApiController) GetFirstDetailById() {
  1443. id, _ := c.GetInt64("id")
  1444. list, err := service.GetFirstDetailById(id)
  1445. ids := strings.Split(list.ProjectId, ",")
  1446. datelist := strings.Split(list.InspectDate, ",")
  1447. fmt.Println("list232323232323w", datelist)
  1448. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  1449. if err == nil {
  1450. c.ServeSuccessJSON(map[string]interface{}{
  1451. "detail": list,
  1452. "inspectlist": inspectlist,
  1453. })
  1454. return
  1455. }
  1456. }
  1457. func (c *DoctorsApiController) UpdateFirstDisease() {
  1458. //timeLayout := "2006-01-02"
  1459. //loc, _ := time.LoadLocation("Local")
  1460. dataBody := make(map[string]interface{}, 0)
  1461. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  1462. fmt.Print("err", err)
  1463. id := int64(dataBody["id"].(float64))
  1464. doctor := int64(dataBody["doctor"].(float64))
  1465. record_date := dataBody["record_date"].(string)
  1466. recordDates, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_date)
  1467. recordtime := recordDates.Unix()
  1468. patient_id := int64(dataBody["patient_id"].(float64))
  1469. title := dataBody["title"].(string)
  1470. main_content := dataBody["main_content"].(string)
  1471. patient_case := dataBody["patient_case"].(string)
  1472. tentative_diagnosis := dataBody["tentative_diagnosis"].(string)
  1473. diagnostic_basis := dataBody["diagnostic_basis"].(string)
  1474. differential_diagnosis := dataBody["differential_diagnosis"].(string)
  1475. treatment_plan := dataBody["treatment_plan"].(string)
  1476. inspect_date := dataBody["inspect_date"].(string)
  1477. project_id := dataBody["project_id"].(string)
  1478. orgId := c.GetAdminUserInfo().CurrentOrgId
  1479. firstdisease := models.XtPatientFirstDisease{
  1480. Title: title,
  1481. RecordDate: recordtime,
  1482. Doctor: doctor,
  1483. MainContent: main_content,
  1484. PatientCase: patient_case,
  1485. TentativeDiagnosis: tentative_diagnosis,
  1486. DiagnosticBasis: diagnostic_basis,
  1487. DifferentialDiagnosis: differential_diagnosis,
  1488. TreatmentPlan: treatment_plan,
  1489. UserOrgId: orgId,
  1490. PatientId: patient_id,
  1491. Ctime: time.Now().Unix(),
  1492. Mtime: 0,
  1493. Status: 1,
  1494. ID: id,
  1495. InspectDate: inspect_date,
  1496. ProjectId: project_id,
  1497. }
  1498. error := service.UpdatePatientFirstDisease(firstdisease, id)
  1499. if error == nil {
  1500. c.ServeSuccessJSON(map[string]interface{}{
  1501. "firstDisease": firstdisease,
  1502. })
  1503. }
  1504. }
  1505. func (c *DoctorsApiController) DeleteFirstDisease() {
  1506. schIDStr := c.GetString("ids")
  1507. idStrs := strings.Split(schIDStr, ",")
  1508. err := service.DeleteFirstDisease(idStrs)
  1509. fmt.Println(err)
  1510. returnData := make(map[string]interface{}, 0)
  1511. returnData["msg"] = "ok"
  1512. c.ServeSuccessJSON(returnData)
  1513. return
  1514. }
  1515. func (c *DoctorsApiController) GetLongScheduleAdvicesList() {
  1516. schedualDate := c.GetString("date")
  1517. adviceType, _ := c.GetInt("advice_type")
  1518. patientType, _ := c.GetInt("patient_type")
  1519. delivery_way := c.GetString("delivery_way")
  1520. schedule_type, _ := c.GetInt64("schedule_type")
  1521. partition_type, _ := c.GetInt64("partition_type")
  1522. patient_id, _ := c.GetInt64("patient_id")
  1523. excution_way, _ := c.GetInt64("excution_way")
  1524. cost_type, _ := c.GetInt64("cost_type")
  1525. execution_frequency := c.GetString("execution_frequency")
  1526. keyword := c.GetString("keyword")
  1527. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  1528. if parseDateErr != nil {
  1529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1530. return
  1531. }
  1532. adminUserInfo := c.GetAdminUserInfo()
  1533. orgID := adminUserInfo.CurrentOrgId
  1534. scheduals, err := service.MobileGetLongScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency, keyword)
  1535. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  1536. if err != nil {
  1537. c.ErrorLog("获取排班信息失败:%v", err)
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. } else {
  1540. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  1541. for _, schedual := range scheduals {
  1542. if len(schedual.DoctorAdvices) > 0 {
  1543. filtedScheduals = append(filtedScheduals, schedual)
  1544. }
  1545. }
  1546. c.ServeSuccessJSON(map[string]interface{}{
  1547. "scheduals": filtedScheduals,
  1548. "adminUser": adminUser,
  1549. })
  1550. }
  1551. }
  1552. func (c *DoctorsApiController) GetPatientByName() {
  1553. keyword := c.GetString("keyword")
  1554. orgId := c.GetAdminUserInfo().CurrentOrgId
  1555. patients, _ := service.GetPatientByName(keyword, orgId)
  1556. c.ServeSuccessJSON(map[string]interface{}{
  1557. "patients": patients,
  1558. })
  1559. }
  1560. func (c *DoctorsApiController) GetDoctorAdviceByPatientId() {
  1561. patient_id, _ := c.GetInt64("patient_id")
  1562. limit, _ := c.GetInt64("limit")
  1563. page, _ := c.GetInt64("page")
  1564. start_time := c.GetString("start_time")
  1565. orgId := c.GetAdminUserInfo().CurrentOrgId
  1566. end_time := c.GetString("end_time")
  1567. timeLayout := "2006-01-02"
  1568. loc, _ := time.LoadLocation("Local")
  1569. var startTimeUnix int64
  1570. if len(start_time) > 0 {
  1571. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1572. if err != nil {
  1573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1574. return
  1575. }
  1576. startTimeUnix = theTime.Unix()
  1577. }
  1578. var endTimeUnix int64
  1579. if len(end_time) > 0 {
  1580. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1581. if err != nil {
  1582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1583. return
  1584. }
  1585. endTimeUnix = theTime.Unix()
  1586. }
  1587. list, total, _ := service.GetDoctorAdviceByPatientId(patient_id, orgId, startTimeUnix, endTimeUnix, limit, page)
  1588. c.ServeSuccessJSON(map[string]interface{}{
  1589. "list": list,
  1590. "total": total,
  1591. })
  1592. }
  1593. func (c *DoctorsApiController) GetDoctorAdivceMonthList() {
  1594. timeLayout := "2006-01-02"
  1595. loc, _ := time.LoadLocation("Local")
  1596. start_time := c.GetString("start_time")
  1597. orgId := c.GetAdminUserInfo().CurrentOrgId
  1598. end_time := c.GetString("end_time")
  1599. var startTimeUnix int64
  1600. if len(start_time) > 0 {
  1601. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1602. if err != nil {
  1603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1604. return
  1605. }
  1606. startTimeUnix = theTime.Unix()
  1607. }
  1608. var endTimeUnix int64
  1609. if len(end_time) > 0 {
  1610. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1611. if err != nil {
  1612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1613. return
  1614. }
  1615. endTimeUnix = theTime.Unix()
  1616. }
  1617. adviceList, _ := service.GetDoctorAdivceMonthList(orgId, startTimeUnix, endTimeUnix)
  1618. hisAdviceList, _ := service.GetHisDoctorAdivceMonthList(orgId, startTimeUnix, endTimeUnix)
  1619. drugs, _ := service.GetAllBaseDrugLibList(orgId)
  1620. manufacturerList, _ := service.GetAllManufacturerList(orgId)
  1621. _, config := service.FindXTHisRecordByOrgId(orgId)
  1622. c.ServeSuccessJSON(map[string]interface{}{
  1623. "adviceList": adviceList,
  1624. "hisAdviceList": hisAdviceList,
  1625. "config": config,
  1626. "drugs": drugs,
  1627. "manufacturerList": manufacturerList,
  1628. })
  1629. }
  1630. func (c *DoctorsApiController) GetHisPrescriptionProjectMonthList() {
  1631. timeLayout := "2006-01-02"
  1632. loc, _ := time.LoadLocation("Local")
  1633. start_time := c.GetString("start_time")
  1634. orgId := c.GetAdminUserInfo().CurrentOrgId
  1635. end_time := c.GetString("end_time")
  1636. var startTimeUnix int64
  1637. if len(start_time) > 0 {
  1638. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1639. if err != nil {
  1640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1641. return
  1642. }
  1643. startTimeUnix = theTime.Unix()
  1644. }
  1645. var endTimeUnix int64
  1646. if len(end_time) > 0 {
  1647. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1648. if err != nil {
  1649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1650. return
  1651. }
  1652. endTimeUnix = theTime.Unix()
  1653. }
  1654. projectMonthList, _ := service.GetHisPrescriptionProjectMonthList(orgId, startTimeUnix, endTimeUnix)
  1655. c.ServeSuccessJSON(map[string]interface{}{
  1656. "projectMonthList": projectMonthList,
  1657. })
  1658. }
  1659. func (c *DoctorsApiController) GetMobileAllDoctorList() {
  1660. orgId := c.GetAdminUserInfo().CurrentOrgId
  1661. adminRoles, _ := service.GetMobileAllDoctorList(orgId)
  1662. c.ServeSuccessJSON(map[string]interface{}{
  1663. "doctors": adminRoles,
  1664. })
  1665. }