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. fmt.Println("是错2323223322323232323", dayTime.Unix())
  263. redis := service.RedisClient()
  264. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  265. redis.Set(keyTwo, "", time.Second)
  266. prescription := models.PredialysisEvaluation{
  267. DryWeight: dry_weight,
  268. AssessmentDate: dayTime.Unix(),
  269. }
  270. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  271. fmt.Println(errors)
  272. keyThree := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  273. redis.Set(keyThree, "", time.Second)
  274. keyFive := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  275. redis.Set(keyFive, "", time.Second)
  276. redis.Close()
  277. fmt.Println("err", err)
  278. c.ServeSuccessJSON(map[string]interface{}{
  279. "patientDryweight": patientDryweight,
  280. })
  281. return
  282. }
  283. fmt.Println("sum", sum)
  284. if weight == 0 {
  285. sum = "/"
  286. }
  287. if weight > 0 {
  288. sum = weights + "(" + "下调" + ")"
  289. }
  290. if weight < 0 {
  291. var sums = dry_weight - dryweight
  292. float := fmt.Sprintf("%.1f", sums)
  293. //float := strconv.FormatFloat(sums, 'E', -1, 64)
  294. sum = float + "(" + "上调" + ")"
  295. }
  296. patientDryweight := models.SgjPatientDryweight{
  297. DryWeight: dry_weight,
  298. Creator: doctors,
  299. Remakes: remarks,
  300. AdjustedValue: sum,
  301. PatientId: patientid,
  302. Ctime: time.Now().Unix(),
  303. UserOrgId: orgid,
  304. Status: 1,
  305. UserId: userid,
  306. }
  307. err := service.CreatePatientWeight(&patientDryweight)
  308. recordDateStr := time.Now().Format("2006-01-02")
  309. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  310. fmt.Scan("parseDateErr", parseDateErr)
  311. nowtime := recordDate.Unix()
  312. fmt.Println("nowtime", nowtime)
  313. loc, _ := time.LoadLocation("Local")
  314. nowTime := time.Now()
  315. nowDay := nowTime.Format("2006-01-02")
  316. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  317. fmt.Println("是错2323223322323232323", dayTime.Unix())
  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. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  326. key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  327. redis.Set(key, "", time.Second)
  328. keySix := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  329. redis.Set(keySix, "", time.Second)
  330. fmt.Println("error", errors)
  331. fmt.Println("err", err)
  332. redis.Close()
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "patientDryweight": patientDryweight,
  335. })
  336. }
  337. func (c *DoctorsApiController) GetAllData() {
  338. id, _ := c.GetInt64("id")
  339. page, _ := c.GetInt64("page")
  340. fmt.Println("page", page)
  341. limit, _ := c.GetInt64("limit")
  342. fmt.Println("limit", limit)
  343. fmt.Println("id", id)
  344. adminUserInfo := c.GetAdminUserInfo()
  345. orgid := adminUserInfo.CurrentOrgId
  346. dry, total, _ := service.GetAllData(orgid, id, page, limit)
  347. c.ServeSuccessJSON(map[string]interface{}{
  348. "dry": dry,
  349. "total": total,
  350. })
  351. }
  352. func (c *DoctorsApiController) GetDryWeightDetail() {
  353. id, _ := c.GetInt64("id")
  354. dryweight, _ := service.GetDryWeightDetailById(id)
  355. c.ServeSuccessJSON(map[string]interface{}{
  356. "dryweight": dryweight,
  357. })
  358. }
  359. func (c *DoctorsApiController) ModifydryWeightData() {
  360. adjustvalue := c.GetString("adjustvalue")
  361. creator, _ := c.GetInt64("creator")
  362. dryweight, _ := c.GetInt64("dryweight")
  363. dry := strconv.FormatInt(dryweight, 10)
  364. dry_weight, _ := strconv.ParseFloat(dry, 64)
  365. id, _ := c.GetInt64("id")
  366. remark := c.GetString("remark")
  367. patientDryweight := models.SgjPatientDryweight{
  368. AdjustedValue: adjustvalue,
  369. Creator: creator,
  370. DryWeight: dry_weight,
  371. Remakes: remark,
  372. }
  373. service.ModifyDryWeightData(&patientDryweight, id)
  374. c.ServeSuccessJSON(map[string]interface{}{
  375. "patientDryweight": patientDryweight,
  376. })
  377. }
  378. func (c *DoctorsApiController) DeleteDryWeight() {
  379. id, _ := c.GetInt64("id")
  380. service.DeleteDryWeight(id)
  381. returnData := make(map[string]interface{}, 0)
  382. returnData["msg"] = "ok"
  383. c.ServeSuccessJSON(returnData)
  384. return
  385. }
  386. func (c *DoctorsApiController) GetDoctorAdviceCount() {
  387. timeLayout := "2006-01-02"
  388. loc, _ := time.LoadLocation("Local")
  389. start_time := c.GetString("start_time")
  390. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  391. end_time := c.GetString("end_time")
  392. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  393. delive_way := c.GetString("delive_way")
  394. adminUserInfo := c.GetAdminUserInfo()
  395. orgId := adminUserInfo.CurrentOrgId
  396. list, _ := service.GetDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  397. if len(list) == 0 {
  398. list, _ := service.GetHisDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  399. c.ServeSuccessJSON(map[string]interface{}{
  400. "list": list,
  401. })
  402. } else {
  403. c.ServeSuccessJSON(map[string]interface{}{
  404. "list": list,
  405. })
  406. }
  407. }
  408. func (this *DoctorsApiController) SaveVasularAccess() {
  409. access_project, _ := this.GetInt64("access_project")
  410. blood_access_part_id := this.GetString("blood_access_part_id")
  411. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  412. first_start_time := this.GetString("first_start_time")
  413. timeLayout := "2006-01-02"
  414. loc, _ := time.LoadLocation("Local")
  415. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  416. inflow_pass := this.GetString("inflow_pass")
  417. remark := this.GetString("remark")
  418. start_time := this.GetString("start_time")
  419. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  420. stop_reason := this.GetString("stop_reason")
  421. user_status, _ := this.GetInt64("user_status")
  422. stop_time := this.GetString("stop_time")
  423. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  424. patient_id, _ := this.GetInt64("patient_id")
  425. other_vascular := this.GetString("other_vascular")
  426. ci_type, _ := this.GetInt64("ci_type")
  427. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  428. sequelae_type, _ := this.GetInt64("sequelae_type")
  429. adminUserInfo := this.GetAdminUserInfo()
  430. orgId := adminUserInfo.CurrentOrgId
  431. creator := adminUserInfo.AdminUser.Id
  432. //查询改日期是否存在
  433. access := models.XtPatientVascularAccess{
  434. AccessProject: access_project,
  435. BloodAccessPartId: blood_access_part_id,
  436. BloodAccessPartOperaId: blood_access_part_opera_id,
  437. FirstStartTime: firstStartTime.Unix(),
  438. InflowPass: inflow_pass,
  439. Remark: remark,
  440. StartTime: startTime.Unix(),
  441. StopReason: stop_reason,
  442. UserStatus: user_status,
  443. Creator: creator,
  444. UserOrgId: orgId,
  445. Status: 1,
  446. Ctime: time.Now().Unix(),
  447. StopTime: stopTime.Unix(),
  448. PatientId: patient_id,
  449. OtherVascular: other_vascular,
  450. CiType: ci_type,
  451. BloodCultupe: blood_cultupe,
  452. SequelaeType: sequelae_type,
  453. }
  454. err := service.SaveVascularAccess(&access)
  455. if err == nil {
  456. this.ServeSuccessJSON(map[string]interface{}{
  457. "access": access,
  458. })
  459. return
  460. //_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  461. //if errcode == gorm.ErrRecordNotFound {
  462. // access := models.XtPatientVascularAccess{
  463. // AccessProject: access_project,
  464. // BloodAccessPartId: blood_access_part_id,
  465. // BloodAccessPartOperaId: blood_access_part_opera_id,
  466. // FirstStartTime: firstStartTime.Unix(),
  467. // InflowPass: inflow_pass,
  468. // Remark: remark,
  469. // StartTime: startTime.Unix(),
  470. // StopReason: stop_reason,
  471. // UserStatus: user_status,
  472. // Creator: creator,
  473. // UserOrgId: orgId,
  474. // Status: 1,
  475. // Ctime: time.Now().Unix(),
  476. // StopTime: stopTime.Unix(),
  477. // PatientId: patient_id,
  478. // OtherVascular: other_vascular,
  479. // CiType: ci_type,
  480. // BloodCultupe: blood_cultupe,
  481. // SequelaeType: sequelae_type,
  482. // }
  483. // err := service.SaveVascularAccess(&access)
  484. // if err == nil {
  485. // this.ServeSuccessJSON(map[string]interface{}{
  486. // "access": access,
  487. // })
  488. // return
  489. // }
  490. //} else if errcode == nil {
  491. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  492. // return
  493. }
  494. }
  495. func (this *DoctorsApiController) GetAllVacualAccessList() {
  496. limit, _ := this.GetInt64("limit")
  497. page, _ := this.GetInt64("page")
  498. patient_id, _ := this.GetInt64("patient_id")
  499. orgId := this.GetAdminUserInfo().CurrentOrgId
  500. appId := this.GetAdminUserInfo().CurrentAppId
  501. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  502. doctor, err := service.GetAllDoctor(orgId, appId)
  503. if err == nil {
  504. this.ServeSuccessJSON(map[string]interface{}{
  505. "list": list,
  506. "total": total,
  507. "doctor": doctor,
  508. })
  509. return
  510. }
  511. }
  512. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  513. id, _ := this.GetInt64("id")
  514. accessDetail, err := service.GetVasularAccessByDetail(id)
  515. orgId := this.GetAdminUserInfo().CurrentOrgId
  516. appId := this.GetAdminUserInfo().CurrentAppId
  517. doctor, err := service.GetAllDoctor(orgId, appId)
  518. if err == nil {
  519. this.ServeSuccessJSON(map[string]interface{}{
  520. "accessDetail": accessDetail,
  521. "doctor": doctor,
  522. })
  523. return
  524. }
  525. }
  526. func (this *DoctorsApiController) UpdateVasularAccess() {
  527. id, _ := this.GetInt64("id")
  528. access_project, _ := this.GetInt64("access_project")
  529. blood_access_part_id := this.GetString("blood_access_part_id")
  530. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  531. first_start_time := this.GetString("first_start_time")
  532. timeLayout := "2006-01-02"
  533. loc, _ := time.LoadLocation("Local")
  534. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  535. inflow_pass := this.GetString("inflow_pass")
  536. remark := this.GetString("remark")
  537. start_time := this.GetString("start_time")
  538. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  539. stop_reason := this.GetString("stop_reason")
  540. user_status, _ := this.GetInt64("user_status")
  541. stop_time := this.GetString("stop_time")
  542. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  543. adminUserInfo := this.GetAdminUserInfo()
  544. orgId := adminUserInfo.CurrentOrgId
  545. creator := adminUserInfo.AdminUser.Id
  546. patientId, _ := this.GetInt64("patient_id")
  547. other_vascular := this.GetString("other_vascular")
  548. ci_type, _ := this.GetInt64("ci_type")
  549. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  550. sequelae_type, _ := this.GetInt64("sequelae_type")
  551. access := models.XtPatientVascularAccess{
  552. AccessProject: access_project,
  553. BloodAccessPartId: blood_access_part_id,
  554. BloodAccessPartOperaId: blood_access_part_opera_id,
  555. FirstStartTime: firstStartTime.Unix(),
  556. InflowPass: inflow_pass,
  557. Remark: remark,
  558. StartTime: startTime.Unix(),
  559. StopReason: stop_reason,
  560. UserStatus: user_status,
  561. Modify: creator,
  562. UserOrgId: orgId,
  563. Status: 1,
  564. StopTime: stopTime.Unix(),
  565. OtherVascular: other_vascular,
  566. CiType: ci_type,
  567. BloodCultupe: blood_cultupe,
  568. SequelaeType: sequelae_type,
  569. PatientId: patientId,
  570. }
  571. err := service.UpdateVascularAccess(&access, id)
  572. if err == nil {
  573. this.ServeSuccessJSON(map[string]interface{}{
  574. "access": access,
  575. })
  576. return
  577. }
  578. //_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  579. //if errcode == gorm.ErrRecordNotFound {
  580. // err := service.UpdateVascularAccess(&access, id)
  581. // if err == nil {
  582. // this.ServeSuccessJSON(map[string]interface{}{
  583. // "access": access,
  584. // })
  585. // return
  586. // }
  587. //} else if errcode == nil {
  588. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  589. // return
  590. //}
  591. }
  592. func (this *DoctorsApiController) DeleteVasularAccess() {
  593. id, _ := this.GetInt64("id")
  594. err := service.DeleteVasularAccess(id)
  595. fmt.Println(err)
  596. returnData := make(map[string]interface{}, 0)
  597. returnData["msg"] = "ok"
  598. this.ServeSuccessJSON(returnData)
  599. return
  600. }
  601. func (this *DoctorsApiController) SavePassWayAssessment() {
  602. blood_dealwidth := this.GetString("blood_dealwith")
  603. blood_project := this.GetString("blood_project")
  604. blood_result := this.GetString("blood_result")
  605. creator, _ := this.GetInt64("creator")
  606. parent_id, _ := this.GetInt64("parent_id")
  607. patient_id, _ := this.GetInt64("patient_id")
  608. start_time := this.GetString("start_time")
  609. timeLayout := "2006-01-02"
  610. loc, _ := time.LoadLocation("Local")
  611. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  612. modify := this.GetAdminUserInfo().AdminUser.Id
  613. orgId := this.GetAdminUserInfo().CurrentOrgId
  614. assessment := models.XtPatientPasswayAssessment{
  615. StartTime: startTime.Unix(),
  616. BloodDealwith: blood_dealwidth,
  617. BloodProject: blood_project,
  618. BloodResult: blood_result,
  619. Creator: creator,
  620. PatientId: patient_id,
  621. ParentId: parent_id,
  622. Modify: modify,
  623. UserOrgId: orgId,
  624. Status: 1,
  625. Ctime: time.Now().Unix(),
  626. }
  627. err := service.CreatePatientWayAssessment(&assessment)
  628. if err == nil {
  629. this.ServeSuccessJSON(map[string]interface{}{
  630. "assessment": assessment,
  631. })
  632. return
  633. }
  634. }
  635. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  636. patient_id, _ := this.GetInt64("patient_id")
  637. parent_id, _ := this.GetInt64("parent_id")
  638. page, _ := this.GetInt64("page")
  639. limit, _ := this.GetInt64("limit")
  640. adminUserInfo := this.GetAdminUserInfo()
  641. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  642. if err == nil {
  643. this.ServeSuccessJSON(map[string]interface{}{
  644. "list": list,
  645. "total": total,
  646. })
  647. return
  648. }
  649. }
  650. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  651. id, _ := this.GetInt64("id")
  652. assessment, err := service.GetPasswayAssesmentById(id)
  653. if err == nil {
  654. this.ServeSuccessJSON(map[string]interface{}{
  655. "assessment": assessment,
  656. })
  657. return
  658. }
  659. }
  660. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  661. id, _ := this.GetInt64("id")
  662. blood_dealwidth := this.GetString("blood_dealwith")
  663. blood_project := this.GetString("blood_project")
  664. blood_result := this.GetString("blood_result")
  665. creator, _ := this.GetInt64("creator")
  666. start_time := this.GetString("start_time")
  667. timeLayout := "2006-01-02"
  668. loc, _ := time.LoadLocation("Local")
  669. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  670. modify := this.GetAdminUserInfo().AdminUser.Id
  671. assessment := models.XtPatientPasswayAssessment{
  672. BloodResult: blood_result,
  673. BloodDealwith: blood_dealwidth,
  674. BloodProject: blood_project,
  675. Creator: creator,
  676. StartTime: startTime.Unix(),
  677. Modify: modify,
  678. }
  679. err := service.UpdatePassWayAssesment(&assessment, id)
  680. if err == nil {
  681. this.ServeSuccessJSON(map[string]interface{}{
  682. "assessment": assessment,
  683. })
  684. return
  685. }
  686. }
  687. func (this *DoctorsApiController) DeleteWayAssessment() {
  688. id, _ := this.GetInt64("id")
  689. err := service.DeleteWayAssessment(id)
  690. fmt.Println(err)
  691. returnData := make(map[string]interface{}, 0)
  692. returnData["msg"] = "ok"
  693. this.ServeSuccessJSON(returnData)
  694. return
  695. }
  696. func (this *DoctorsApiController) GetAccessList() {
  697. adminUserInfo := this.GetAdminUserInfo()
  698. orgId := adminUserInfo.CurrentOrgId
  699. //血管通路
  700. list, err := service.GetAccessList(orgId)
  701. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  702. //血管通路部位
  703. access, err := service.GetBloodAccess(orgId)
  704. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  705. if err == nil {
  706. this.ServeSuccessJSON(map[string]interface{}{
  707. "blood_access_part_opera": blood_access_part_opera,
  708. "blood_access_part": blood_access_part,
  709. })
  710. return
  711. }
  712. }
  713. func (this *DoctorsApiController) GetInspectionMajorItem() {
  714. other_start_time := this.GetString("other_start_time")
  715. last_time := this.GetString("last_time")
  716. timeLayout := "2006-01-02"
  717. loc, _ := time.LoadLocation("Local")
  718. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
  719. lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
  720. patient_id, _ := this.GetInt64("patient_id")
  721. adminUserInfo := this.GetAdminUserInfo()
  722. orgId := adminUserInfo.CurrentOrgId
  723. list, err := service.GetInspectionMajorItem(startTime.Unix(), lastTime.Unix(), orgId, patient_id)
  724. if err == nil {
  725. this.ServeSuccessJSON(map[string]interface{}{
  726. "list": list,
  727. })
  728. return
  729. }
  730. }
  731. func (this *DoctorsApiController) GetInspectionDetailByProject() {
  732. project_id, _ := this.GetInt64("project_id")
  733. patient_id, _ := this.GetInt64("patient_id")
  734. inspect_date, _ := this.GetInt64("inspect_date")
  735. orgId := this.GetAdminUserInfo().CurrentOrgId
  736. list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
  737. if err == nil {
  738. this.ServeSuccessJSON(map[string]interface{}{
  739. "list": list,
  740. })
  741. return
  742. }
  743. }
  744. func (this *DoctorsApiController) GetInspectionItemlist() {
  745. patient_id, _ := this.GetInt64("patient_id")
  746. ids := this.GetString("ids")
  747. inspect_date := this.GetString("inspect_date")
  748. idSplit := strings.Split(ids, ",")
  749. indateSplit := strings.Split(inspect_date, ",")
  750. list, err := service.GetInspectionItemlist(patient_id, indateSplit, idSplit)
  751. if err == nil {
  752. this.ServeSuccessJSON(map[string]interface{}{
  753. "list": list,
  754. })
  755. return
  756. }
  757. }
  758. func (this *DoctorsApiController) GetInitDateList() {
  759. patient_id, _ := this.GetInt64("patient_id")
  760. start_time := this.GetString("start_time")
  761. timeLayout := "2006-01-02"
  762. loc, _ := time.LoadLocation("Local")
  763. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  764. end_time := this.GetString("end_time")
  765. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  766. fmt.Println("endtime2323232233223232332", endTime)
  767. prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id, startTime.Unix(), endTime.Unix())
  768. befor_list, err := service.GetDialysisBeforInitDateList(patient_id, startTime.Unix(), endTime.Unix())
  769. after_list, err := service.GetDialysisAssementAfter(patient_id, startTime.Unix(), endTime.Unix())
  770. orgId := this.GetAdminUserInfo().CurrentOrgId
  771. //统计透析次数
  772. modelist, err := service.GetDialysisDialysisMode(patient_id, startTime.Unix(), endTime.Unix(), orgId)
  773. docList, _ := service.GetAllDoctorThree(orgId)
  774. stockType, err := service.GetStockType(orgId)
  775. summaryList, err := service.GetTemplateSummary(orgId)
  776. planList, err := service.GetTemplatePlan(orgId)
  777. if err == nil {
  778. this.ServeSuccessJSON(map[string]interface{}{
  779. "beforlist": befor_list,
  780. "prescription_list": prescription_list,
  781. "after_list": after_list,
  782. "modelist": modelist,
  783. "docList": docList,
  784. "stockType": stockType,
  785. "summaryList": summaryList,
  786. "planList": planList,
  787. })
  788. return
  789. }
  790. }
  791. func (this *DoctorsApiController) SaveCreationInspection() {
  792. dataBody := make(map[string]interface{}, 0)
  793. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  794. if err != nil {
  795. utils.ErrorLog(err.Error())
  796. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  797. return
  798. }
  799. title := dataBody["title"].(string)
  800. dryWeight := dataBody["dry_weight"].(string)
  801. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  802. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  803. hd_count := int64(dataBody["hd_count"].(float64))
  804. hdf_count := int64(dataBody["hdf_count"].(float64))
  805. hp_count := int64(dataBody["hp_count"].(float64))
  806. other_count := int64(dataBody["other_count"].(float64))
  807. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  808. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  809. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  810. kaliumstr := dataBody["kalium"].(string)
  811. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  812. autunitestr := dataBody["autunite"].(string)
  813. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  814. natriumstr := dataBody["natrium"].(string)
  815. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  816. hour := int64(dataBody["hour"].(float64))
  817. minute := int64(dataBody["minute"].(float64))
  818. beforWeight := dataBody["befor_weight"].(string)
  819. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  820. afterWeight := dataBody["after_weight"].(string)
  821. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  822. befor_pressure := dataBody["befor_pressure"].(string)
  823. template_summary_content := dataBody["template_summary_content"].(string)
  824. template_plan_content := dataBody["template_plan_content"].(string)
  825. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  826. record_time := dataBody["record_time"].(string)
  827. timeLayout := "2006-01-02"
  828. loc, _ := time.LoadLocation("Local")
  829. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  830. after_pressure := dataBody["after_pressure"].(string)
  831. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  832. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  833. patient_id := int64(dataBody["patient_id"].(float64))
  834. orgId := this.GetAdminUserInfo().CurrentOrgId
  835. inspect_date := dataBody["inspect_date"].(string)
  836. project_id := dataBody["project_id"].(string)
  837. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  838. //title := this.GetString("title")
  839. //dryWeight := this.GetString("dry_weight")
  840. //dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  841. //dialysis_count, _ := this.GetInt64("dialysis_count")
  842. //hd_count, _ := this.GetInt64("hd_count")
  843. //hdf_count, _ := this.GetInt64("hdf_count")
  844. //hp_count, _ := this.GetInt64("hp_count")
  845. //other_count, _ := this.GetInt64("other_count")
  846. //dialzer_apparatus := this.GetString("dialzer_apparatus")
  847. //perfusion_apparatus := this.GetString("perfusion_apparatus")
  848. //anticoagulant, _ := this.GetInt64("anticoagulant")
  849. //kaliumstr := this.GetString("kalium")
  850. //kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  851. //
  852. //autunitestr := this.GetString("autunite")
  853. //autunite, _ := strconv.ParseFloat(autunitestr, 64)
  854. //natriumstr := this.GetString("natrium")
  855. //natrium, _ := strconv.ParseFloat(natriumstr, 64)
  856. //hour, _ := this.GetInt64("hour")
  857. //minute, _ := this.GetInt64("minute")
  858. //beforWeight := this.GetString("befor_weight")
  859. //befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  860. //afterWeight := this.GetString("after_weight")
  861. //after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  862. //befor_pressure := this.GetString("befor_pressure")
  863. //template_summary_content := this.GetString("template_summary_content")
  864. //template_plan_content := this.GetString("template_plan_content")
  865. //admin_user_id, _ := this.GetInt64("admin_user_id")
  866. //record_time := this.GetString("record_time")
  867. //timeLayout := "2006-01-02"
  868. //loc, _ := time.LoadLocation("Local")
  869. //recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  870. //after_pressure := this.GetString("after_pressure")
  871. //template_summary_id, _ := this.GetInt64("template_summary_id")
  872. //template_plan_id, _ := this.GetInt64("template_plan_id")
  873. //template_inspection_id, _ := this.GetInt64("template_inspection_id")
  874. //patient_id, _ := this.GetInt64("patient_id")
  875. //fmt.Println("patient_id", patient_id)
  876. //orgId := this.GetAdminUserInfo().CurrentOrgId
  877. //inspect_date := this.GetString("inspect_date")
  878. //project_id := this.GetString("project_id")
  879. summary := models.XtTemplateSummary{
  880. StartYear: 0,
  881. StartMonth: 0,
  882. Radio: 0,
  883. Quarter: 0,
  884. DryWeight: dry_weight,
  885. DialysisCount: dialysis_count,
  886. HdCount: hd_count,
  887. HdfCount: hdf_count,
  888. HpCount: hp_count,
  889. OtherCount: other_count,
  890. DialzerApparatus: dialzer_apparatus,
  891. PerfusionApparatus: perfusion_apparatus,
  892. Anticoagulant: anticoagulant,
  893. Kalium: kalium,
  894. Autunite: autunite,
  895. Natrium: natrium,
  896. Hour: hour,
  897. Minute: minute,
  898. BeforWeight: befor_weight,
  899. AfterWeight: after_weight,
  900. BeforPressure: befor_pressure,
  901. AfterPressure: after_pressure,
  902. TemplateSummaryId: template_summary_id,
  903. TemplateSummaryContent: template_summary_content,
  904. TemplatePlanId: template_plan_id,
  905. TemplatePlanContent: template_plan_content,
  906. TemplateInspectionId: template_inspection_id,
  907. AdminUserId: admin_user_id,
  908. RecordTime: recordTime.Unix(),
  909. PatientId: patient_id,
  910. UserOrgId: orgId,
  911. Status: 1,
  912. Ctime: time.Now().Unix(),
  913. Mtime: 0,
  914. Title: title,
  915. InspectDate: inspect_date,
  916. ProjectId: project_id,
  917. }
  918. err = service.CreateSummary(&summary)
  919. if err == nil {
  920. this.ServeSuccessJSON(map[string]interface{}{
  921. "summary": summary,
  922. })
  923. return
  924. }
  925. }
  926. func (this *DoctorsApiController) GetTemplateSummaryList() {
  927. patient_id, _ := this.GetInt64("patient_id")
  928. start_time := this.GetString("start_time")
  929. timeLayout := "2006-01-02"
  930. loc, _ := time.LoadLocation("Local")
  931. end_time := this.GetString("end_time")
  932. orgId := this.GetAdminUserInfo().CurrentOrgId
  933. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  934. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  935. list, err := service.GetTemplateSummaryList(patient_id, orgId, startTime.Unix(), endTime.Unix())
  936. if err == nil {
  937. this.ServeSuccessJSON(map[string]interface{}{
  938. "list": list,
  939. })
  940. return
  941. }
  942. }
  943. func (this *DoctorsApiController) GetTemplateSummaryDetail() {
  944. id, _ := this.GetInt64("id")
  945. list, err := service.GetTemplateSummaryDetail(id)
  946. ids := strings.Split(list.ProjectId, ",")
  947. datelist := strings.Split(list.InspectDate, ",")
  948. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  949. if err == nil {
  950. this.ServeSuccessJSON(map[string]interface{}{
  951. "list": list,
  952. "inspectlist": inspectlist,
  953. })
  954. return
  955. }
  956. }
  957. func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
  958. id, _ := this.GetInt64("id")
  959. list, err := service.GetTemplateSummaryPrintDetail(id)
  960. ids := strings.Split(list.ProjectId, ",")
  961. datelist := strings.Split(list.InspectDate, ",")
  962. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  963. orgId := this.GetAdminUserInfo().CurrentOrgId
  964. doctorList, _ := service.GetAllDoctorThree(orgId)
  965. if err == nil {
  966. this.ServeSuccessJSON(map[string]interface{}{
  967. "list": list,
  968. "doctorList": doctorList,
  969. "inspectlist": inspectlist,
  970. })
  971. return
  972. }
  973. }
  974. func (this *DoctorsApiController) UpdateTempalteSummary() {
  975. dataBody := make(map[string]interface{}, 0)
  976. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  977. if err != nil {
  978. utils.ErrorLog(err.Error())
  979. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  980. return
  981. }
  982. id, _ := this.GetInt64("id")
  983. title := this.GetString("title")
  984. dryWeight := this.GetString("dry_weight")
  985. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  986. dialysis_count, _ := this.GetInt64("dialysis_count")
  987. hd_count, _ := this.GetInt64("hd_count")
  988. hdf_count, _ := this.GetInt64("hdf_count")
  989. hp_count, _ := this.GetInt64("hp_count")
  990. other_count, _ := this.GetInt64("other_count")
  991. dialzer_apparatus := this.GetString("dialzer_apparatus")
  992. perfusion_apparatus := this.GetString("perfusion_apparatus")
  993. anticoagulant, _ := this.GetInt64("anticoagulant")
  994. kaliumstr := this.GetString("kalium")
  995. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  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. }