doctors_api_controller.go 52KB

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