doctors_api_controller.go 51KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/astaxie/beego"
  10. "github.com/jinzhu/gorm"
  11. "strconv"
  12. "strings"
  13. "time"
  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/getdoctoradvicecount", &DoctorsApiController{}, "Get:GetDoctorAdviceCount")
  30. beego.Router("/api/patient/savevasularaccess", &DoctorsApiController{}, "Get:SaveVasularAccess")
  31. beego.Router("/api/patient/getallvascualraccesslist", &DoctorsApiController{}, "Get:GetAllVacualAccessList")
  32. beego.Router("/api/patient/getvascularaccessbydetial", &DoctorsApiController{}, "Get:GetVascularAccessByDetail")
  33. beego.Router("/api/patient/updatevasularaccess", &DoctorsApiController{}, "Get:UpdateVasularAccess")
  34. beego.Router("/api/patient/deletevascularaccess", &DoctorsApiController{}, "Get:DeleteVasularAccess")
  35. beego.Router("/api/patient/savepasswayassessment", &DoctorsApiController{}, "Get:SavePassWayAssessment")
  36. beego.Router("/api/patient/getallpasswayassessment", &DoctorsApiController{}, "Get:GetAllPassWayAssessment")
  37. beego.Router("/api/patient/getpasswayassmentbyid", &DoctorsApiController{}, "Get:GetPasswayAssesmentById")
  38. beego.Router("/api/patient/updatepasswayassesment", &DoctorsApiController{}, "Get:UpdatePassWayAssesment")
  39. beego.Router("/api/patient/deletepasswayassessment", &DoctorsApiController{}, "Get:DeleteWayAssessment")
  40. beego.Router("/api/patient/getaccesslist", &DoctorsApiController{}, "Get:GetAccessList")
  41. //阶段小结路由
  42. beego.Router("/api/patient/getinspectionmajoritem", &DoctorsApiController{}, "Get:GetInspectionMajorItem")
  43. beego.Router("/api/patient/getinspectiondetail", &DoctorsApiController{}, "Get:GetInspectionDetailByProject")
  44. beego.Router("/api/patient/getinspectionitemlist", &DoctorsApiController{}, "Get:GetInspectionItemlist")
  45. beego.Router("/api/patient/getinitdatelist", &DoctorsApiController{}, "Get:GetInitDateList")
  46. beego.Router("/api/patient/savecreationinspection", &DoctorsApiController{}, "Post:SaveCreationInspection")
  47. beego.Router("/api/patient/getemlatesummarylist", &DoctorsApiController{}, "Get:GetTemplateSummaryList")
  48. beego.Router("/api/patient/gettemplatesummarydetail", &DoctorsApiController{}, "Get:GetTemplateSummaryDetail")
  49. beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
  50. beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
  51. beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
  52. beego.Router("/api/patient/hospitalsummary", &DoctorsApiController{}, "Post:HospitalSummary")
  53. beego.Router("/api/patient/gethospitalsummarylist", &DoctorsApiController{}, "Get:GetHospitalSummaryList")
  54. beego.Router("/api/patient/gethospitalsummaydetail", &DoctorsApiController{}, "Get:GetHospitalSummaryDetail")
  55. beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Post:UpdateHospitalSummary")
  56. beego.Router("/api/patient/deletehospitalsummary", &DoctorsApiController{}, "Get:DeleteHospitalSummary")
  57. beego.Router("/api/patient/getpatientinfo", &DoctorsApiController{}, "Get:GetPatientInfo")
  58. }
  59. func (c *DoctorsApiController) ScheduleAdvices() {
  60. schedualDate := c.GetString("date")
  61. adviceType, _ := c.GetInt("advice_type")
  62. patientType, _ := c.GetInt("patient_type")
  63. delivery_way := c.GetString("delivery_way")
  64. schedule_type, _ := c.GetInt64("schedule_type")
  65. partition_type, _ := c.GetInt64("partition_type")
  66. patient_id, _ := c.GetInt64("patient_id")
  67. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  68. adviceType = 0
  69. }
  70. if patientType != 1 && patientType != 2 {
  71. patientType = 0
  72. }
  73. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  74. if parseDateErr != nil {
  75. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  76. return
  77. }
  78. adminUserInfo := c.GetAdminUserInfo()
  79. orgID := adminUserInfo.CurrentOrgId
  80. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id)
  81. hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
  82. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
  83. //project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
  84. for _, item := range project {
  85. index := 0
  86. for _, subItem := range item.HisPrescriptionTeamProject {
  87. if subItem.HisProject.CostClassify != 3 {
  88. subItem.IsCheckTeam = 2
  89. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  90. }
  91. if subItem.HisProject.CostClassify == 3 {
  92. subItem.IsCheckTeam = 1
  93. index = index + 1
  94. if index == 1 {
  95. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  96. }
  97. }
  98. }
  99. }
  100. //for _, item := range project {
  101. // index := 0
  102. // for _, subItem := range item.HisPrescriptionTeamProject {
  103. //
  104. // //获取所有的患者
  105. // patients, _ := service.GetAllPatientListByListTwo(orgID)
  106. //
  107. // //获取所有床位
  108. // numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
  109. //
  110. // //获取透析处方
  111. // prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
  112. //
  113. // //获取上机
  114. // dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
  115. // for key, item := range project {
  116. // for _, patient := range patients {
  117. // if item.PatientId == patient.ID {
  118. // project[key].SchedualPatient = patient
  119. // break
  120. // }
  121. // }
  122. // // 获取床位信息
  123. // for _, it := range numberList {
  124. // if item.BedId == it.ID {
  125. // project[key].DeviceNumber = it
  126. // break
  127. // }
  128. // }
  129. //
  130. // // 获取处方
  131. // for _, it := range prescriptions {
  132. // if item.PatientId == it.PatientId {
  133. // project[key].Prescription = it
  134. // break
  135. // }
  136. // }
  137. //
  138. // //获取上机
  139. // for _, it := range dialysisOrders {
  140. // if item.PatientId == it.PatientId {
  141. // project[key].DialysisOrder = it
  142. // break
  143. // }
  144. // }
  145. // }
  146. // if subItem.HisProject.CostClassify != 3 {
  147. // subItem.IsCheckTeam = 2
  148. // item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  149. // }
  150. //
  151. // if subItem.HisProject.CostClassify == 3 {
  152. // subItem.IsCheckTeam = 1
  153. // index = index + 1
  154. // if index == 1 {
  155. // item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  156. // }
  157. // }
  158. // }
  159. //}
  160. config, _ := service.GetHisDoctorConfig(orgID)
  161. project_config, _ := service.GetHisProjectConfig(orgID)
  162. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  163. if err != nil {
  164. c.ErrorLog("获取排班信息失败:%v", err)
  165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  166. } else {
  167. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  168. for _, schedual := range scheduals {
  169. if len(schedual.DoctorAdvices) > 0 {
  170. filtedScheduals = append(filtedScheduals, schedual)
  171. }
  172. }
  173. c.ServeSuccessJSON(map[string]interface{}{
  174. "scheduals": filtedScheduals,
  175. "adminUser": adminUser,
  176. "hisAdvices": hisAdvices,
  177. "config": config,
  178. "project_config": project_config,
  179. "project": project,
  180. })
  181. }
  182. }
  183. func (c *DoctorsApiController) GetAllDoctorAndNurse() {
  184. adminUserInfo := c.GetAdminUserInfo()
  185. doctors, nursers, _ := service.GetAllDoctorAndNurse(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  186. c.ServeSuccessJSON(map[string]interface{}{
  187. "doctors": doctors,
  188. "nursers": nursers,
  189. })
  190. return
  191. }
  192. func (c *DoctorsApiController) GetAllAdminUsers() {
  193. adminUserInfo := c.GetAdminUserInfo()
  194. users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
  195. c.ServeSuccessJSON(map[string]interface{}{
  196. "users": users,
  197. })
  198. return
  199. }
  200. func (c *DoctorsApiController) GetDryWeightData() {
  201. adminUserInfo := c.GetAdminUserInfo()
  202. orgid := adminUserInfo.CurrentOrgId
  203. patientid, _ := c.GetInt64("patientid")
  204. fmt.Println("patientid", patientid)
  205. id := adminUserInfo.AdminUser.Id
  206. fmt.Println("id", id)
  207. recordDateStr := time.Now().Format("2006-01-02")
  208. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  209. fmt.Scan("parseDateErr", parseDateErr)
  210. nowtime := recordDate.Unix()
  211. fmt.Println("nowtime", nowtime)
  212. pre, err := service.GetDryWeightByPatientId(patientid, orgid)
  213. fmt.Println("错误", err)
  214. c.ServeSuccessJSON(map[string]interface{}{
  215. "pre": pre,
  216. })
  217. }
  218. func (c *DoctorsApiController) GetAllDoctor() {
  219. adminUserInfo := c.GetAdminUserInfo()
  220. orgid := adminUserInfo.CurrentOrgId
  221. appid := adminUserInfo.CurrentAppId
  222. fmt.Println("appid", appid)
  223. appRole, err := service.GetAllDoctor(orgid, appid)
  224. fmt.Println("appRole", appRole)
  225. fmt.Println("错误", err)
  226. c.ServeSuccessJSON(map[string]interface{}{
  227. "appRole": appRole,
  228. })
  229. }
  230. func (c *DoctorsApiController) UpdatedDryWeightData() {
  231. adminUserInfo := c.GetAdminUserInfo()
  232. orgid := adminUserInfo.CurrentOrgId
  233. userid := adminUserInfo.AdminUser.Id
  234. dry_weight, _ := c.GetFloat("dry_weight")
  235. doctors, _ := c.GetInt64("doctors")
  236. remarks := c.GetString("remarks")
  237. patientid, _ := c.GetInt64("patient_id")
  238. //透前数据
  239. dryweight, _ := c.GetFloat("dryweight")
  240. var weight = dryweight - dry_weight
  241. weights := fmt.Sprintf("%.1f", weight)
  242. var sum string
  243. _, errcode := service.QueryDryWeight(orgid, patientid)
  244. if errcode == gorm.ErrRecordNotFound {
  245. sum = "/"
  246. patientDryweight := models.SgjPatientDryweight{
  247. DryWeight: dry_weight,
  248. Creator: doctors,
  249. Remakes: remarks,
  250. AdjustedValue: sum,
  251. PatientId: patientid,
  252. Ctime: time.Now().Unix(),
  253. UserOrgId: orgid,
  254. Status: 1,
  255. UserId: userid,
  256. }
  257. err := service.CreatePatientWeight(&patientDryweight)
  258. loc, _ := time.LoadLocation("Local")
  259. nowTime := time.Now()
  260. nowDay := nowTime.Format("2006-01-02")
  261. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  262. redis := service.RedisClient()
  263. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  264. redis.Set(keyTwo, "", time.Second)
  265. prescription := models.PredialysisEvaluation{
  266. DryWeight: dry_weight,
  267. AssessmentDate: dayTime.Unix(),
  268. }
  269. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  270. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  271. fmt.Println(errors)
  272. }
  273. keyThree := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  274. redis.Set(keyThree, "", time.Second)
  275. keyFive := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  276. redis.Set(keyFive, "", time.Second)
  277. redis.Close()
  278. fmt.Println("err", err)
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "patientDryweight": patientDryweight,
  281. })
  282. return
  283. }
  284. fmt.Println("sum", sum)
  285. if weight == 0 {
  286. sum = "/"
  287. }
  288. if weight > 0 {
  289. sum = weights + "(" + "下调" + ")"
  290. }
  291. if weight < 0 {
  292. var sums = dry_weight - dryweight
  293. float := fmt.Sprintf("%.1f", sums)
  294. //float := strconv.FormatFloat(sums, 'E', -1, 64)
  295. sum = float + "(" + "上调" + ")"
  296. }
  297. patientDryweight := models.SgjPatientDryweight{
  298. DryWeight: dry_weight,
  299. Creator: doctors,
  300. Remakes: remarks,
  301. AdjustedValue: sum,
  302. PatientId: patientid,
  303. Ctime: time.Now().Unix(),
  304. UserOrgId: orgid,
  305. Status: 1,
  306. UserId: userid,
  307. }
  308. err := service.CreatePatientWeight(&patientDryweight)
  309. recordDateStr := time.Now().Format("2006-01-02")
  310. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  311. fmt.Scan("parseDateErr", parseDateErr)
  312. nowtime := recordDate.Unix()
  313. fmt.Println("nowtime", nowtime)
  314. loc, _ := time.LoadLocation("Local")
  315. nowTime := time.Now()
  316. nowDay := nowTime.Format("2006-01-02")
  317. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  318. redis := service.RedisClient()
  319. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  320. redis.Set(keyTwo, "", time.Second)
  321. prescription := models.PredialysisEvaluation{
  322. DryWeight: dry_weight,
  323. AssessmentDate: dayTime.Unix(),
  324. }
  325. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  326. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  327. fmt.Println(errors)
  328. }
  329. key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  330. redis.Set(key, "", time.Second)
  331. keySix := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  332. redis.Set(keySix, "", time.Second)
  333. fmt.Println("err", err)
  334. redis.Close()
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "patientDryweight": patientDryweight,
  337. })
  338. }
  339. func (c *DoctorsApiController) GetAllData() {
  340. id, _ := c.GetInt64("id")
  341. page, _ := c.GetInt64("page")
  342. fmt.Println("page", page)
  343. limit, _ := c.GetInt64("limit")
  344. fmt.Println("limit", limit)
  345. fmt.Println("id", id)
  346. adminUserInfo := c.GetAdminUserInfo()
  347. orgid := adminUserInfo.CurrentOrgId
  348. dry, total, _ := service.GetAllData(orgid, id, page, limit)
  349. c.ServeSuccessJSON(map[string]interface{}{
  350. "dry": dry,
  351. "total": total,
  352. })
  353. }
  354. func (c *DoctorsApiController) GetDryWeightDetail() {
  355. id, _ := c.GetInt64("id")
  356. dryweight, _ := service.GetDryWeightDetailById(id)
  357. c.ServeSuccessJSON(map[string]interface{}{
  358. "dryweight": dryweight,
  359. })
  360. }
  361. func (c *DoctorsApiController) ModifydryWeightData() {
  362. adjustvalue := c.GetString("adjustvalue")
  363. creator, _ := c.GetInt64("creator")
  364. dryweight, _ := c.GetInt64("dryweight")
  365. dry := strconv.FormatInt(dryweight, 10)
  366. dry_weight, _ := strconv.ParseFloat(dry, 64)
  367. id, _ := c.GetInt64("id")
  368. remark := c.GetString("remark")
  369. patientDryweight := models.SgjPatientDryweight{
  370. AdjustedValue: adjustvalue,
  371. Creator: creator,
  372. DryWeight: dry_weight,
  373. Remakes: remark,
  374. }
  375. service.ModifyDryWeightData(&patientDryweight, id)
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "patientDryweight": patientDryweight,
  378. })
  379. }
  380. func (c *DoctorsApiController) DeleteDryWeight() {
  381. id, _ := c.GetInt64("id")
  382. service.DeleteDryWeight(id)
  383. returnData := make(map[string]interface{}, 0)
  384. returnData["msg"] = "ok"
  385. c.ServeSuccessJSON(returnData)
  386. return
  387. }
  388. func (c *DoctorsApiController) GetDoctorAdviceCount() {
  389. timeLayout := "2006-01-02"
  390. loc, _ := time.LoadLocation("Local")
  391. start_time := c.GetString("start_time")
  392. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  393. end_time := c.GetString("end_time")
  394. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  395. delive_way := c.GetString("delive_way")
  396. adminUserInfo := c.GetAdminUserInfo()
  397. orgId := adminUserInfo.CurrentOrgId
  398. list, _ := service.GetDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  399. if len(list) == 0 {
  400. list, _ := service.GetHisDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  401. c.ServeSuccessJSON(map[string]interface{}{
  402. "list": list,
  403. })
  404. } else {
  405. c.ServeSuccessJSON(map[string]interface{}{
  406. "list": list,
  407. })
  408. }
  409. }
  410. func (this *DoctorsApiController) SaveVasularAccess() {
  411. access_project, _ := this.GetInt64("access_project")
  412. blood_access_part_id := this.GetString("blood_access_part_id")
  413. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  414. first_start_time := this.GetString("first_start_time")
  415. timeLayout := "2006-01-02"
  416. loc, _ := time.LoadLocation("Local")
  417. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  418. inflow_pass := this.GetString("inflow_pass")
  419. remark := this.GetString("remark")
  420. start_time := this.GetString("start_time")
  421. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  422. stop_reason := this.GetString("stop_reason")
  423. user_status, _ := this.GetInt64("user_status")
  424. stop_time := this.GetString("stop_time")
  425. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  426. patient_id, _ := this.GetInt64("patient_id")
  427. other_vascular := this.GetString("other_vascular")
  428. ci_type, _ := this.GetInt64("ci_type")
  429. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  430. sequelae_type, _ := this.GetInt64("sequelae_type")
  431. adminUserInfo := this.GetAdminUserInfo()
  432. orgId := adminUserInfo.CurrentOrgId
  433. creator := adminUserInfo.AdminUser.Id
  434. //查询改日期是否存在
  435. access := models.XtPatientVascularAccess{
  436. AccessProject: access_project,
  437. BloodAccessPartId: blood_access_part_id,
  438. BloodAccessPartOperaId: blood_access_part_opera_id,
  439. FirstStartTime: firstStartTime.Unix(),
  440. InflowPass: inflow_pass,
  441. Remark: remark,
  442. StartTime: startTime.Unix(),
  443. StopReason: stop_reason,
  444. UserStatus: user_status,
  445. Creator: creator,
  446. UserOrgId: orgId,
  447. Status: 1,
  448. Ctime: time.Now().Unix(),
  449. StopTime: stopTime.Unix(),
  450. PatientId: patient_id,
  451. OtherVascular: other_vascular,
  452. CiType: ci_type,
  453. BloodCultupe: blood_cultupe,
  454. SequelaeType: sequelae_type,
  455. }
  456. err := service.SaveVascularAccess(&access)
  457. if err == nil {
  458. this.ServeSuccessJSON(map[string]interface{}{
  459. "access": access,
  460. })
  461. return
  462. //_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  463. //if errcode == gorm.ErrRecordNotFound {
  464. // access := models.XtPatientVascularAccess{
  465. // AccessProject: access_project,
  466. // BloodAccessPartId: blood_access_part_id,
  467. // BloodAccessPartOperaId: blood_access_part_opera_id,
  468. // FirstStartTime: firstStartTime.Unix(),
  469. // InflowPass: inflow_pass,
  470. // Remark: remark,
  471. // StartTime: startTime.Unix(),
  472. // StopReason: stop_reason,
  473. // UserStatus: user_status,
  474. // Creator: creator,
  475. // UserOrgId: orgId,
  476. // Status: 1,
  477. // Ctime: time.Now().Unix(),
  478. // StopTime: stopTime.Unix(),
  479. // PatientId: patient_id,
  480. // OtherVascular: other_vascular,
  481. // CiType: ci_type,
  482. // BloodCultupe: blood_cultupe,
  483. // SequelaeType: sequelae_type,
  484. // }
  485. // err := service.SaveVascularAccess(&access)
  486. // if err == nil {
  487. // this.ServeSuccessJSON(map[string]interface{}{
  488. // "access": access,
  489. // })
  490. // return
  491. // }
  492. //} else if errcode == nil {
  493. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  494. // return
  495. }
  496. }
  497. func (this *DoctorsApiController) GetAllVacualAccessList() {
  498. limit, _ := this.GetInt64("limit")
  499. page, _ := this.GetInt64("page")
  500. patient_id, _ := this.GetInt64("patient_id")
  501. orgId := this.GetAdminUserInfo().CurrentOrgId
  502. appId := this.GetAdminUserInfo().CurrentAppId
  503. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  504. doctor, err := service.GetAllDoctor(orgId, appId)
  505. if err == nil {
  506. this.ServeSuccessJSON(map[string]interface{}{
  507. "list": list,
  508. "total": total,
  509. "doctor": doctor,
  510. })
  511. return
  512. }
  513. }
  514. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  515. id, _ := this.GetInt64("id")
  516. accessDetail, err := service.GetVasularAccessByDetail(id)
  517. orgId := this.GetAdminUserInfo().CurrentOrgId
  518. appId := this.GetAdminUserInfo().CurrentAppId
  519. doctor, err := service.GetAllDoctor(orgId, appId)
  520. if err == nil {
  521. this.ServeSuccessJSON(map[string]interface{}{
  522. "accessDetail": accessDetail,
  523. "doctor": doctor,
  524. })
  525. return
  526. }
  527. }
  528. func (this *DoctorsApiController) UpdateVasularAccess() {
  529. id, _ := this.GetInt64("id")
  530. access_project, _ := this.GetInt64("access_project")
  531. blood_access_part_id := this.GetString("blood_access_part_id")
  532. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  533. first_start_time := this.GetString("first_start_time")
  534. timeLayout := "2006-01-02"
  535. loc, _ := time.LoadLocation("Local")
  536. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  537. inflow_pass := this.GetString("inflow_pass")
  538. remark := this.GetString("remark")
  539. start_time := this.GetString("start_time")
  540. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  541. stop_reason := this.GetString("stop_reason")
  542. user_status, _ := this.GetInt64("user_status")
  543. stop_time := this.GetString("stop_time")
  544. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  545. adminUserInfo := this.GetAdminUserInfo()
  546. orgId := adminUserInfo.CurrentOrgId
  547. creator := adminUserInfo.AdminUser.Id
  548. patientId, _ := this.GetInt64("patient_id")
  549. other_vascular := this.GetString("other_vascular")
  550. ci_type, _ := this.GetInt64("ci_type")
  551. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  552. sequelae_type, _ := this.GetInt64("sequelae_type")
  553. access := models.XtPatientVascularAccess{
  554. AccessProject: access_project,
  555. BloodAccessPartId: blood_access_part_id,
  556. BloodAccessPartOperaId: blood_access_part_opera_id,
  557. FirstStartTime: firstStartTime.Unix(),
  558. InflowPass: inflow_pass,
  559. Remark: remark,
  560. StartTime: startTime.Unix(),
  561. StopReason: stop_reason,
  562. UserStatus: user_status,
  563. Modify: creator,
  564. UserOrgId: orgId,
  565. Status: 1,
  566. StopTime: stopTime.Unix(),
  567. OtherVascular: other_vascular,
  568. CiType: ci_type,
  569. BloodCultupe: blood_cultupe,
  570. SequelaeType: sequelae_type,
  571. PatientId: patientId,
  572. }
  573. err := service.UpdateVascularAccess(&access, id)
  574. if err == nil {
  575. this.ServeSuccessJSON(map[string]interface{}{
  576. "access": access,
  577. })
  578. return
  579. }
  580. //_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  581. //if errcode == gorm.ErrRecordNotFound {
  582. // err := service.UpdateVascularAccess(&access, id)
  583. // if err == nil {
  584. // this.ServeSuccessJSON(map[string]interface{}{
  585. // "access": access,
  586. // })
  587. // return
  588. // }
  589. //} else if errcode == nil {
  590. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  591. // return
  592. //}
  593. }
  594. func (this *DoctorsApiController) DeleteVasularAccess() {
  595. id, _ := this.GetInt64("id")
  596. err := service.DeleteVasularAccess(id)
  597. fmt.Println(err)
  598. returnData := make(map[string]interface{}, 0)
  599. returnData["msg"] = "ok"
  600. this.ServeSuccessJSON(returnData)
  601. return
  602. }
  603. func (this *DoctorsApiController) SavePassWayAssessment() {
  604. blood_dealwidth := this.GetString("blood_dealwith")
  605. blood_project := this.GetString("blood_project")
  606. blood_result := this.GetString("blood_result")
  607. creator, _ := this.GetInt64("creator")
  608. parent_id, _ := this.GetInt64("parent_id")
  609. patient_id, _ := this.GetInt64("patient_id")
  610. start_time := this.GetString("start_time")
  611. timeLayout := "2006-01-02"
  612. loc, _ := time.LoadLocation("Local")
  613. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  614. modify := this.GetAdminUserInfo().AdminUser.Id
  615. orgId := this.GetAdminUserInfo().CurrentOrgId
  616. assessment := models.XtPatientPasswayAssessment{
  617. StartTime: startTime.Unix(),
  618. BloodDealwith: blood_dealwidth,
  619. BloodProject: blood_project,
  620. BloodResult: blood_result,
  621. Creator: creator,
  622. PatientId: patient_id,
  623. ParentId: parent_id,
  624. Modify: modify,
  625. UserOrgId: orgId,
  626. Status: 1,
  627. Ctime: time.Now().Unix(),
  628. }
  629. err := service.CreatePatientWayAssessment(&assessment)
  630. if err == nil {
  631. this.ServeSuccessJSON(map[string]interface{}{
  632. "assessment": assessment,
  633. })
  634. return
  635. }
  636. }
  637. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  638. patient_id, _ := this.GetInt64("patient_id")
  639. parent_id, _ := this.GetInt64("parent_id")
  640. page, _ := this.GetInt64("page")
  641. limit, _ := this.GetInt64("limit")
  642. adminUserInfo := this.GetAdminUserInfo()
  643. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  644. if err == nil {
  645. this.ServeSuccessJSON(map[string]interface{}{
  646. "list": list,
  647. "total": total,
  648. })
  649. return
  650. }
  651. }
  652. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  653. id, _ := this.GetInt64("id")
  654. assessment, err := service.GetPasswayAssesmentById(id)
  655. if err == nil {
  656. this.ServeSuccessJSON(map[string]interface{}{
  657. "assessment": assessment,
  658. })
  659. return
  660. }
  661. }
  662. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  663. id, _ := this.GetInt64("id")
  664. blood_dealwidth := this.GetString("blood_dealwith")
  665. blood_project := this.GetString("blood_project")
  666. blood_result := this.GetString("blood_result")
  667. creator, _ := this.GetInt64("creator")
  668. start_time := this.GetString("start_time")
  669. timeLayout := "2006-01-02"
  670. loc, _ := time.LoadLocation("Local")
  671. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  672. modify := this.GetAdminUserInfo().AdminUser.Id
  673. assessment := models.XtPatientPasswayAssessment{
  674. BloodResult: blood_result,
  675. BloodDealwith: blood_dealwidth,
  676. BloodProject: blood_project,
  677. Creator: creator,
  678. StartTime: startTime.Unix(),
  679. Modify: modify,
  680. }
  681. err := service.UpdatePassWayAssesment(&assessment, id)
  682. if err == nil {
  683. this.ServeSuccessJSON(map[string]interface{}{
  684. "assessment": assessment,
  685. })
  686. return
  687. }
  688. }
  689. func (this *DoctorsApiController) DeleteWayAssessment() {
  690. id, _ := this.GetInt64("id")
  691. err := service.DeleteWayAssessment(id)
  692. fmt.Println(err)
  693. returnData := make(map[string]interface{}, 0)
  694. returnData["msg"] = "ok"
  695. this.ServeSuccessJSON(returnData)
  696. return
  697. }
  698. func (this *DoctorsApiController) GetAccessList() {
  699. adminUserInfo := this.GetAdminUserInfo()
  700. orgId := adminUserInfo.CurrentOrgId
  701. //血管通路
  702. list, err := service.GetAccessList(orgId)
  703. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  704. //血管通路部位
  705. access, err := service.GetBloodAccess(orgId)
  706. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  707. if err == nil {
  708. this.ServeSuccessJSON(map[string]interface{}{
  709. "blood_access_part_opera": blood_access_part_opera,
  710. "blood_access_part": blood_access_part,
  711. })
  712. return
  713. }
  714. }
  715. func (this *DoctorsApiController) GetInspectionMajorItem() {
  716. other_start_time := this.GetString("other_start_time")
  717. last_time := this.GetString("last_time")
  718. timeLayout := "2006-01-02"
  719. loc, _ := time.LoadLocation("Local")
  720. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
  721. lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
  722. patient_id, _ := this.GetInt64("patient_id")
  723. adminUserInfo := this.GetAdminUserInfo()
  724. orgId := adminUserInfo.CurrentOrgId
  725. list, err := service.GetInspectionMajorItem(startTime.Unix(), lastTime.Unix(), orgId, patient_id)
  726. if err == nil {
  727. this.ServeSuccessJSON(map[string]interface{}{
  728. "list": list,
  729. })
  730. return
  731. }
  732. }
  733. func (this *DoctorsApiController) GetInspectionDetailByProject() {
  734. project_id, _ := this.GetInt64("project_id")
  735. patient_id, _ := this.GetInt64("patient_id")
  736. inspect_date, _ := this.GetInt64("inspect_date")
  737. orgId := this.GetAdminUserInfo().CurrentOrgId
  738. list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
  739. if err == nil {
  740. this.ServeSuccessJSON(map[string]interface{}{
  741. "list": list,
  742. })
  743. return
  744. }
  745. }
  746. func (this *DoctorsApiController) GetInspectionItemlist() {
  747. patient_id, _ := this.GetInt64("patient_id")
  748. ids := this.GetString("ids")
  749. inspect_date := this.GetString("inspect_date")
  750. idSplit := strings.Split(ids, ",")
  751. indateSplit := strings.Split(inspect_date, ",")
  752. list, err := service.GetInspectionItemlist(patient_id, indateSplit, idSplit)
  753. if err == nil {
  754. this.ServeSuccessJSON(map[string]interface{}{
  755. "list": list,
  756. })
  757. return
  758. }
  759. }
  760. func (this *DoctorsApiController) GetInitDateList() {
  761. patient_id, _ := this.GetInt64("patient_id")
  762. start_time := this.GetString("start_time")
  763. timeLayout := "2006-01-02"
  764. loc, _ := time.LoadLocation("Local")
  765. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  766. end_time := this.GetString("end_time")
  767. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  768. fmt.Println("endtime2323232233223232332", endTime)
  769. prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id, startTime.Unix(), endTime.Unix())
  770. befor_list, err := service.GetDialysisBeforInitDateList(patient_id, startTime.Unix(), endTime.Unix())
  771. after_list, err := service.GetDialysisAssementAfter(patient_id, startTime.Unix(), endTime.Unix())
  772. orgId := this.GetAdminUserInfo().CurrentOrgId
  773. //统计透析次数
  774. modelist, err := service.GetDialysisDialysisMode(patient_id, startTime.Unix(), endTime.Unix(), orgId)
  775. docList, _ := service.GetAllDoctorThree(orgId)
  776. stockType, err := service.GetStockType(orgId)
  777. summaryList, err := service.GetTemplateSummary(orgId)
  778. planList, err := service.GetTemplatePlan(orgId)
  779. if err == nil {
  780. this.ServeSuccessJSON(map[string]interface{}{
  781. "beforlist": befor_list,
  782. "prescription_list": prescription_list,
  783. "after_list": after_list,
  784. "modelist": modelist,
  785. "docList": docList,
  786. "stockType": stockType,
  787. "summaryList": summaryList,
  788. "planList": planList,
  789. })
  790. return
  791. }
  792. }
  793. func (this *DoctorsApiController) SaveCreationInspection() {
  794. dataBody := make(map[string]interface{}, 0)
  795. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  796. if err != nil {
  797. utils.ErrorLog(err.Error())
  798. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  799. return
  800. }
  801. title := dataBody["title"].(string)
  802. dryWeight := dataBody["dry_weight"].(string)
  803. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  804. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  805. hd_count := int64(dataBody["hd_count"].(float64))
  806. hdf_count := int64(dataBody["hdf_count"].(float64))
  807. hp_count := int64(dataBody["hp_count"].(float64))
  808. other_count := int64(dataBody["other_count"].(float64))
  809. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  810. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  811. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  812. kaliumstr := dataBody["kalium"].(string)
  813. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  814. autunitestr := dataBody["autunite"].(string)
  815. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  816. natriumstr := dataBody["natrium"].(string)
  817. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  818. hour := int64(dataBody["hour"].(float64))
  819. minute := int64(dataBody["minute"].(float64))
  820. beforWeight := dataBody["befor_weight"].(string)
  821. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  822. afterWeight := dataBody["after_weight"].(string)
  823. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  824. befor_pressure := dataBody["befor_pressure"].(string)
  825. template_summary_content := dataBody["template_summary_content"].(string)
  826. template_plan_content := dataBody["template_plan_content"].(string)
  827. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  828. record_time := dataBody["record_time"].(string)
  829. timeLayout := "2006-01-02"
  830. loc, _ := time.LoadLocation("Local")
  831. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  832. after_pressure := dataBody["after_pressure"].(string)
  833. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  834. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  835. patient_id := int64(dataBody["patient_id"].(float64))
  836. orgId := this.GetAdminUserInfo().CurrentOrgId
  837. inspect_date := dataBody["inspect_date"].(string)
  838. project_id := dataBody["project_id"].(string)
  839. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  840. summary := models.XtTemplateSummary{
  841. StartYear: 0,
  842. StartMonth: 0,
  843. Radio: 0,
  844. Quarter: 0,
  845. DryWeight: dry_weight,
  846. DialysisCount: dialysis_count,
  847. HdCount: hd_count,
  848. HdfCount: hdf_count,
  849. HpCount: hp_count,
  850. OtherCount: other_count,
  851. DialzerApparatus: dialzer_apparatus,
  852. PerfusionApparatus: perfusion_apparatus,
  853. Anticoagulant: anticoagulant,
  854. Kalium: kalium,
  855. Autunite: autunite,
  856. Natrium: natrium,
  857. Hour: hour,
  858. Minute: minute,
  859. BeforWeight: befor_weight,
  860. AfterWeight: after_weight,
  861. BeforPressure: befor_pressure,
  862. AfterPressure: after_pressure,
  863. TemplateSummaryId: template_summary_id,
  864. TemplateSummaryContent: template_summary_content,
  865. TemplatePlanId: template_plan_id,
  866. TemplatePlanContent: template_plan_content,
  867. TemplateInspectionId: template_inspection_id,
  868. AdminUserId: admin_user_id,
  869. RecordTime: recordTime.Unix(),
  870. PatientId: patient_id,
  871. UserOrgId: orgId,
  872. Status: 1,
  873. Ctime: time.Now().Unix(),
  874. Mtime: 0,
  875. Title: title,
  876. InspectDate: inspect_date,
  877. ProjectId: project_id,
  878. }
  879. err = service.CreateSummary(&summary)
  880. if err == nil {
  881. this.ServeSuccessJSON(map[string]interface{}{
  882. "summary": summary,
  883. })
  884. return
  885. }
  886. }
  887. func (this *DoctorsApiController) GetTemplateSummaryList() {
  888. patient_id, _ := this.GetInt64("patient_id")
  889. start_time := this.GetString("start_time")
  890. timeLayout := "2006-01-02"
  891. loc, _ := time.LoadLocation("Local")
  892. end_time := this.GetString("end_time")
  893. orgId := this.GetAdminUserInfo().CurrentOrgId
  894. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  895. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  896. list, err := service.GetTemplateSummaryList(patient_id, orgId, startTime.Unix(), endTime.Unix())
  897. if err == nil {
  898. this.ServeSuccessJSON(map[string]interface{}{
  899. "list": list,
  900. })
  901. return
  902. }
  903. }
  904. func (this *DoctorsApiController) GetTemplateSummaryDetail() {
  905. id, _ := this.GetInt64("id")
  906. list, err := service.GetTemplateSummaryDetail(id)
  907. ids := strings.Split(list.ProjectId, ",")
  908. datelist := strings.Split(list.InspectDate, ",")
  909. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  910. if err == nil {
  911. this.ServeSuccessJSON(map[string]interface{}{
  912. "list": list,
  913. "inspectlist": inspectlist,
  914. })
  915. return
  916. }
  917. }
  918. func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
  919. id, _ := this.GetInt64("id")
  920. list, err := service.GetTemplateSummaryPrintDetail(id)
  921. ids := strings.Split(list.ProjectId, ",")
  922. datelist := strings.Split(list.InspectDate, ",")
  923. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  924. orgId := this.GetAdminUserInfo().CurrentOrgId
  925. doctorList, _ := service.GetAllDoctorThree(orgId)
  926. if err == nil {
  927. this.ServeSuccessJSON(map[string]interface{}{
  928. "list": list,
  929. "doctorList": doctorList,
  930. "inspectlist": inspectlist,
  931. })
  932. return
  933. }
  934. }
  935. func (this *DoctorsApiController) UpdateTempalteSummary() {
  936. dataBody := make(map[string]interface{}, 0)
  937. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  938. if err != nil {
  939. utils.ErrorLog(err.Error())
  940. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  941. return
  942. }
  943. id := int64(dataBody["id"].(float64))
  944. title := dataBody["title"].(string)
  945. dryWeight := dataBody["dry_weight"].(string)
  946. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  947. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  948. hd_count := int64(dataBody["hd_count"].(float64))
  949. hdf_count := int64(dataBody["hdf_count"].(float64))
  950. hp_count := int64(dataBody["hp_count"].(float64))
  951. other_count := int64(dataBody["other_count"].(float64))
  952. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  953. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  954. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  955. kaliumstr := dataBody["kalium"].(string)
  956. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  957. autunitestr := dataBody["autunite"].(string)
  958. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  959. natriumstr := dataBody["natrium"].(string)
  960. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  961. hour := int64(dataBody["hour"].(float64))
  962. minute := int64(dataBody["minute"].(float64))
  963. beforWeight := dataBody["befor_weight"].(string)
  964. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  965. afterWeight := dataBody["after_weight"].(string)
  966. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  967. befor_pressure := dataBody["befor_pressure"].(string)
  968. template_summary_content := dataBody["template_summary_content"].(string)
  969. template_plan_content := dataBody["template_plan_content"].(string)
  970. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  971. record_time := dataBody["record_time"].(string)
  972. timeLayout := "2006-01-02"
  973. loc, _ := time.LoadLocation("Local")
  974. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  975. after_pressure := dataBody["after_pressure"].(string)
  976. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  977. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  978. patient_id := int64(dataBody["patient_id"].(float64))
  979. orgId := this.GetAdminUserInfo().CurrentOrgId
  980. inspect_date := dataBody["inspect_date"].(string)
  981. project_id := dataBody["project_id"].(string)
  982. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  983. //dryWeight := this.GetString("dry_weight")
  984. //dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  985. //dialysis_count, _ := this.GetInt64("dialysis_count")
  986. //hd_count, _ := this.GetInt64("hd_count")
  987. //hdf_count, _ := this.GetInt64("hdf_count")
  988. //hp_count, _ := this.GetInt64("hp_count")
  989. //other_count, _ := this.GetInt64("other_count")
  990. //dialzer_apparatus := this.GetString("dialzer_apparatus")
  991. //perfusion_apparatus := this.GetString("perfusion_apparatus")
  992. //anticoagulant, _ := this.GetInt64("anticoagulant")
  993. //kaliumstr := this.GetString("kalium")
  994. //kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  995. //
  996. //autunitestr := this.GetString("autunite")
  997. //autunite, _ := strconv.ParseFloat(autunitestr, 64)
  998. //natriumstr := this.GetString("natrium")
  999. //natrium, _ := strconv.ParseFloat(natriumstr, 64)
  1000. //hour, _ := this.GetInt64("hour")
  1001. //minute, _ := this.GetInt64("minute")
  1002. //beforWeight := this.GetString("befor_weight")
  1003. //befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  1004. //afterWeight := this.GetString("after_weight")
  1005. //after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  1006. //befor_pressure := this.GetString("befor_pressure")
  1007. //template_summary_content := this.GetString("template_summary_content")
  1008. //template_plan_content := this.GetString("template_plan_content")
  1009. //admin_user_id, _ := this.GetInt64("admin_user_id")
  1010. //record_time := this.GetString("record_time")
  1011. //timeLayout := "2006-01-02"
  1012. //loc, _ := time.LoadLocation("Local")
  1013. //recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  1014. //after_pressure := this.GetString("after_pressure")
  1015. //template_summary_id, _ := this.GetInt64("template_summary_id")
  1016. //template_plan_id, _ := this.GetInt64("template_plan_id")
  1017. //template_inspection_id, _ := this.GetInt64("template_inspection_id")
  1018. //patient_id, _ := this.GetInt64("patient_id")
  1019. //fmt.Println("patient_id", patient_id)
  1020. //orgId := this.GetAdminUserInfo().CurrentOrgId
  1021. //inspect_date := this.GetString("inspect_date")
  1022. //project_id := this.GetString("project_id")
  1023. summary := models.XtTemplateSummary{
  1024. ID: id,
  1025. StartYear: 0,
  1026. StartMonth: 0,
  1027. Radio: 0,
  1028. Quarter: 0,
  1029. DryWeight: dry_weight,
  1030. DialysisCount: dialysis_count,
  1031. HdCount: hd_count,
  1032. HdfCount: hdf_count,
  1033. HpCount: hp_count,
  1034. OtherCount: other_count,
  1035. DialzerApparatus: dialzer_apparatus,
  1036. PerfusionApparatus: perfusion_apparatus,
  1037. Anticoagulant: anticoagulant,
  1038. Kalium: kalium,
  1039. Autunite: autunite,
  1040. Natrium: natrium,
  1041. Hour: hour,
  1042. Minute: minute,
  1043. BeforWeight: befor_weight,
  1044. AfterWeight: after_weight,
  1045. BeforPressure: befor_pressure,
  1046. AfterPressure: after_pressure,
  1047. TemplateSummaryId: template_summary_id,
  1048. TemplateSummaryContent: template_summary_content,
  1049. TemplatePlanId: template_plan_id,
  1050. TemplatePlanContent: template_plan_content,
  1051. TemplateInspectionId: template_inspection_id,
  1052. AdminUserId: admin_user_id,
  1053. RecordTime: recordTime.Unix(),
  1054. PatientId: patient_id,
  1055. UserOrgId: orgId,
  1056. Status: 1,
  1057. Ctime: time.Now().Unix(),
  1058. Mtime: 0,
  1059. Title: title,
  1060. ProjectId: project_id,
  1061. InspectDate: inspect_date,
  1062. }
  1063. err = service.UpdateTempalteSummary(&summary)
  1064. if err == nil {
  1065. this.ServeSuccessJSON(map[string]interface{}{
  1066. "list": summary,
  1067. })
  1068. return
  1069. }
  1070. }
  1071. func (this *DoctorsApiController) DeleteSummary() {
  1072. ids := this.GetString("ids")
  1073. idsplit := strings.Split(ids, ",")
  1074. err := service.DeleteSummary(idsplit)
  1075. fmt.Println(err)
  1076. returnData := make(map[string]interface{}, 0)
  1077. returnData["msg"] = "ok"
  1078. this.ServeSuccessJSON(returnData)
  1079. return
  1080. }
  1081. func (this *DoctorsApiController) HospitalSummary() {
  1082. timeLayout := "2006-01-02"
  1083. loc, _ := time.LoadLocation("Local")
  1084. dataBody := make(map[string]interface{}, 0)
  1085. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1086. fmt.Print("err", err)
  1087. admission_time := dataBody["admission_time"].(string)
  1088. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1089. admissiontime := admissionTimes.Unix()
  1090. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1091. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1092. connecticut := dataBody["connecticut"].(string)
  1093. dean := int64(dataBody["dean"].(float64))
  1094. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1095. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1096. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1097. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1098. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1099. discharge_advice := dataBody["discharge_advice"].(string)
  1100. discharge_time := dataBody["discharge_time"].(string)
  1101. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1102. dischargetime := dischargeTimes.Unix()
  1103. doctor := int64(dataBody["doctor"].(float64))
  1104. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1105. illness_discharge := dataBody["illness_discharge"].(string)
  1106. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1107. pathology := dataBody["pathology"].(string)
  1108. record_date := dataBody["record_date"].(string)
  1109. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1110. recordtime := recordDates.Unix()
  1111. sick_personnel := dataBody["sick_personnel"].(string)
  1112. title := dataBody["title"].(string)
  1113. treatment_id := dataBody["treatment_id"].(string)
  1114. treatment := dataBody["treatment"].(string)
  1115. ultrasound := dataBody["ultrasound"].(string)
  1116. xray := dataBody["xray"].(string)
  1117. patient_id := int64(dataBody["patient_id"].(float64))
  1118. orgId := this.GetAdminUserInfo().CurrentOrgId
  1119. summary := models.XtHospitalSummary{
  1120. PatientId: patient_id,
  1121. AdmissionTime: admissiontime,
  1122. DischargeTime: dischargetime,
  1123. SickPersonnel: sick_personnel,
  1124. Xray: xray,
  1125. Connecticut: connecticut,
  1126. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1127. Ultrasound: ultrasound,
  1128. Pathology: pathology,
  1129. AdmittingDiagnosisId: admitting_diagnosis_id,
  1130. AdmittingDiagnosis: admitting_diagnosis,
  1131. DischargeDiagnosis: discharge_diagnosis,
  1132. DiagnosisAdmissionId: diagnosis_admission_id,
  1133. DiagnosisAdmission: diagnosis_admission,
  1134. TreatmentId: treatment_id,
  1135. Treatment: treatment,
  1136. IllnessDischargeId: illness_discharge_id,
  1137. IllnessDischarge: illness_discharge,
  1138. DischargeAdviceId: discharge_advice_id,
  1139. DischargeAdvice: discharge_advice,
  1140. UserOrgId: orgId,
  1141. Status: 1,
  1142. Ctime: time.Now().Unix(),
  1143. Mtime: 0,
  1144. RecordTime: recordtime,
  1145. Title: title,
  1146. Doctor: doctor,
  1147. RecordDate: recordtime,
  1148. DeanId: dean,
  1149. DischargeDiagnosisId: discharge_diagnosis_id,
  1150. }
  1151. service.CreateHisSummary(&summary)
  1152. this.ServeSuccessJSON(map[string]interface{}{
  1153. "list": summary,
  1154. })
  1155. return
  1156. }
  1157. func (this *DoctorsApiController) GetHospitalSummaryList() {
  1158. timeLayout := "2006-01-02"
  1159. loc, _ := time.LoadLocation("Local")
  1160. orgId := this.GetAdminUserInfo().CurrentOrgId
  1161. patient_id, _ := this.GetInt64("patient_id")
  1162. start_time := this.GetString("start_time")
  1163. fmt.Println("start_tim232232323232323232323232332", start_time)
  1164. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1165. startime := dischargeTimes.Unix()
  1166. fmt.Println("startime1111111111111111111111", startime)
  1167. end_time := this.GetString("end_time")
  1168. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1169. endtime := endTimes.Unix()
  1170. list, err := service.GetHospitalSummaryList(orgId, patient_id, startime, endtime)
  1171. if err == nil {
  1172. this.ServeSuccessJSON(map[string]interface{}{
  1173. "list": list,
  1174. })
  1175. return
  1176. }
  1177. }
  1178. func (this *DoctorsApiController) GetHospitalSummaryDetail() {
  1179. id, _ := this.GetInt64("id")
  1180. detail, err := service.GetHospitalSummaryDetail(id)
  1181. if err == nil {
  1182. this.ServeSuccessJSON(map[string]interface{}{
  1183. "detail": detail,
  1184. })
  1185. return
  1186. }
  1187. }
  1188. func (this *DoctorsApiController) UpdateHospitalSummary() {
  1189. timeLayout := "2006-01-02"
  1190. loc, _ := time.LoadLocation("Local")
  1191. dataBody := make(map[string]interface{}, 0)
  1192. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1193. fmt.Print("err", err)
  1194. admission_time := dataBody["admission_time"].(string)
  1195. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1196. admissiontime := admissionTimes.Unix()
  1197. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1198. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1199. connecticut := dataBody["connecticut"].(string)
  1200. dean := int64(dataBody["dean"].(float64))
  1201. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1202. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1203. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1204. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1205. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1206. discharge_advice := dataBody["discharge_advice"].(string)
  1207. discharge_time := dataBody["discharge_time"].(string)
  1208. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1209. dischargetime := dischargeTimes.Unix()
  1210. doctor := int64(dataBody["doctor"].(float64))
  1211. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1212. illness_discharge := dataBody["illness_discharge"].(string)
  1213. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1214. pathology := dataBody["pathology"].(string)
  1215. record_date := dataBody["record_date"].(string)
  1216. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1217. recordtime := recordDates.Unix()
  1218. sick_personnel := dataBody["sick_personnel"].(string)
  1219. title := dataBody["title"].(string)
  1220. treatment_id := dataBody["treatment_id"].(string)
  1221. treatment := dataBody["treatment"].(string)
  1222. ultrasound := dataBody["ultrasound"].(string)
  1223. xray := dataBody["xray"].(string)
  1224. patient_id := int64(dataBody["patient_id"].(float64))
  1225. id := int64(dataBody["id"].(float64))
  1226. summary := models.XtHospitalSummary{
  1227. PatientId: patient_id,
  1228. AdmissionTime: admissiontime,
  1229. DischargeTime: dischargetime,
  1230. SickPersonnel: sick_personnel,
  1231. Xray: xray,
  1232. Connecticut: connecticut,
  1233. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1234. Ultrasound: ultrasound,
  1235. Pathology: pathology,
  1236. AdmittingDiagnosisId: admitting_diagnosis_id,
  1237. AdmittingDiagnosis: admitting_diagnosis,
  1238. DischargeDiagnosis: discharge_diagnosis,
  1239. DiagnosisAdmissionId: diagnosis_admission_id,
  1240. DiagnosisAdmission: diagnosis_admission,
  1241. TreatmentId: treatment_id,
  1242. Treatment: treatment,
  1243. IllnessDischargeId: illness_discharge_id,
  1244. IllnessDischarge: illness_discharge,
  1245. DischargeAdviceId: discharge_advice_id,
  1246. DischargeAdvice: discharge_advice,
  1247. Mtime: time.Now().Unix(),
  1248. RecordTime: recordtime,
  1249. Title: title,
  1250. Doctor: doctor,
  1251. RecordDate: recordtime,
  1252. DeanId: dean,
  1253. DischargeDiagnosisId: discharge_diagnosis_id,
  1254. }
  1255. err = service.UpdateHospital(id, summary)
  1256. if err == nil {
  1257. this.ServeSuccessJSON(map[string]interface{}{
  1258. "detail": summary,
  1259. })
  1260. return
  1261. }
  1262. }
  1263. func (this *DoctorsApiController) DeleteHospitalSummary() {
  1264. schIDStr := this.GetString("ids")
  1265. idStrs := strings.Split(schIDStr, ",")
  1266. err := service.DeleteHospitalSummary(idStrs)
  1267. fmt.Println(err)
  1268. returnData := make(map[string]interface{}, 0)
  1269. returnData["msg"] = "ok"
  1270. this.ServeSuccessJSON(returnData)
  1271. return
  1272. }
  1273. func (this *DoctorsApiController) GetPatientInfo() {
  1274. patient_id, _ := this.GetInt64("patient_id")
  1275. orgId := this.GetAdminUserInfo().CurrentOrgId
  1276. detail, err := service.GetPatientDetail(patient_id, orgId)
  1277. if err == nil {
  1278. this.ServeSuccessJSON(map[string]interface{}{
  1279. "patient": detail,
  1280. })
  1281. return
  1282. }
  1283. }