doctors_api_controller.go 51KB

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