his_project_api_controller.go 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "fmt"
  8. "github.com/astaxie/beego"
  9. "github.com/jinzhu/gorm"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. type HisProjectApiController struct {
  15. BaseAuthAPIController
  16. }
  17. func HisProjectRouters() {
  18. beego.Router("/api/his/saveproject", &HisProjectApiController{}, "Get:SaveProject")
  19. beego.Router("/api/his/getprojectlist", &HisProjectApiController{}, "Get:GetProjectList")
  20. beego.Router("/api/his/getprojectdetail", &HisProjectApiController{}, "Get:GetProjectDetail")
  21. beego.Router("/api/his/updatedproject", &HisProjectApiController{}, "Get:UpdatedProject")
  22. beego.Router("/api/his/deletehisproject", &HisProjectApiController{}, "Get:DeleteHisProject")
  23. beego.Router("/api/his/saveprojectteam", &HisProjectApiController{}, "Get:SaveProjectTeam")
  24. beego.Router("/api/his/getprojectteamlist", &HisProjectApiController{}, "Get:GetProjectTeamList")
  25. beego.Router("/api/his/getprojectteamdetail", &HisProjectApiController{}, "Get:GetProjectTeamDetail")
  26. beego.Router("/api/his/updateprojectteam", &HisProjectApiController{}, "Get:UpdatedProjectTeam")
  27. beego.Router("/api/his/deleteprojectteam", &HisProjectApiController{}, "Get:DeleteProjectTeam")
  28. beego.Router("/api/his/savedepartment", &HisProjectApiController{}, "Get:SaveDePartment")
  29. beego.Router("/api/his/getdepartmentlist", &HisProjectApiController{}, "Get:GetDepartMentList")
  30. beego.Router("/api/his/getdepartmentdetail", &HisProjectApiController{}, "Get:GetDepartMentDetail")
  31. beego.Router("/api/his/updagtedepartment", &HisProjectApiController{}, "Get:UpdatedDeparment")
  32. beego.Router("/api/his/deletedeparment", &HisProjectApiController{}, "Get:DeleteDepartment")
  33. beego.Router("/api/his/getallprojectlist", &HisProjectApiController{}, "Get:GetAllProjectList")
  34. beego.Router("/api/his/addprojectlist", &HisProjectApiController{}, "Get:AddProjectList")
  35. beego.Router("/api/his/deleteproject", &HisProjectApiController{}, "Get:DeleteProject")
  36. beego.Router("/api/his/gethisproject", &HisProjectApiController{}, "Get:GetHisProject")
  37. beego.Router("/api/his/getprojectteam", &HisProjectApiController{}, "Get:GetProjectTeam")
  38. beego.Router("/api/his/getalldoctorlist", &HisProjectApiController{}, "Get:GetAllDoctorList")
  39. beego.Router("/api/his/savehispatient", &HisProjectApiController{}, "Get:SaveHisPatient")
  40. //获取今日血透排班的患者
  41. beego.Router("/api/his/getbloodpatient", &HisProjectApiController{}, "Get:GetBloodPatientList")
  42. //获取患者的今日透析处方
  43. beego.Router("/api/his/gethisprescription", &HisProjectApiController{}, "Get:GetHisPrescription")
  44. //新增附加费用
  45. beego.Router("/api/his/additionalcharge", &HisProjectApiController{}, "Post:AdditionalCharge")
  46. //获取治疗单
  47. beego.Router("/api/his/gettreatlist", &HisProjectApiController{}, "Get:GetTreatmentList")
  48. beego.Router("/api/his/getpatientinformation", &HisProjectApiController{}, "Get:GetPatientInformation")
  49. beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
  50. beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
  51. beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
  52. }
  53. func (this *HisProjectApiController) SaveProject() {
  54. project_name := this.GetString("project_name")
  55. pinyin := this.GetString("pinyin")
  56. wubi := this.GetString("wubi")
  57. price := this.GetString("price")
  58. price_float, err := strconv.ParseFloat(price, 64)
  59. unit := this.GetString("unit")
  60. cost_classify, _ := this.GetInt64("cost_classify")
  61. executive_section, _ := this.GetInt64("executive_section")
  62. medical_coverage, _ := this.GetInt64("medical_coverage")
  63. statistical_classification, _ := this.GetInt64("statistical_classification")
  64. disease_directory, _ := this.GetInt64("disease_directory")
  65. is_record, _ := this.GetInt64("is_record")
  66. medical_code := this.GetString("medical_code")
  67. tube_color, _ := this.GetInt64("tube_color")
  68. medical_status, _ := this.GetInt64("medical_status")
  69. remark := this.GetString("remark")
  70. sign, _ := this.GetInt64("sign")
  71. default_number := this.GetString("default_number")
  72. is_charge, _ := this.GetInt64("is_charge")
  73. is_estimate, _ := this.GetInt64("is_estimate")
  74. is_workload, _ := this.GetInt64("is_workload")
  75. sort := this.GetString("sort")
  76. is_advice, _ := this.GetInt64("is_advice")
  77. is_default, _ := this.GetInt64("is_default")
  78. single_dose := this.GetString("single_dose")
  79. delivery_way := this.GetString("delivery_way")
  80. execution_frequency := this.GetString("execution_frequency")
  81. number_days := this.GetString("number_days")
  82. total := this.GetString("total")
  83. adminUserInfo := this.GetAdminUserInfo()
  84. orgId := adminUserInfo.CurrentOrgId
  85. hisProject := models.XtHisProject{
  86. ProjectName: project_name,
  87. Pinyin: pinyin,
  88. Wubi: wubi,
  89. Price: price_float,
  90. Unit: unit,
  91. CostClassify: cost_classify,
  92. ExecutiveSection: executive_section,
  93. MedicalCoverage: medical_coverage,
  94. StatisticalClassification: statistical_classification,
  95. DiseaseDirectory: disease_directory,
  96. IsRecord: is_record,
  97. MedicalCode: medical_code,
  98. TubeColor: tube_color,
  99. MedicalStatus: medical_status,
  100. Remark: remark,
  101. Sign: sign,
  102. DefaultNumber: default_number,
  103. IsCharge: is_charge,
  104. IsEstimate: is_estimate,
  105. IsWorkload: is_workload,
  106. Sort: sort,
  107. DoctorAdvice: is_advice,
  108. IsDefault: is_default,
  109. UserOrgId: orgId,
  110. Status: 1,
  111. CreatedTime: time.Now().Unix(),
  112. SingleDose: single_dose,
  113. DeliveryWay: delivery_way,
  114. ExecutionFrequency: execution_frequency,
  115. NumberDays: number_days,
  116. Total: total,
  117. }
  118. //查询项目名称是否存在
  119. _, errcode := service.GetHisProjectIsExist(project_name, orgId)
  120. fmt.Println("9999999999999", errcode)
  121. if errcode == gorm.ErrRecordNotFound {
  122. fmt.Println("222")
  123. err = service.CreateHisProject(&hisProject)
  124. if err != nil {
  125. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  126. return
  127. }
  128. this.ServeSuccessJSON(map[string]interface{}{
  129. "hisProject": hisProject,
  130. })
  131. return
  132. } else if errcode == nil {
  133. fmt.Println("3333")
  134. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  135. return
  136. }
  137. }
  138. func (this *HisProjectApiController) GetProjectList() {
  139. adminUserInfo := this.GetAdminUserInfo()
  140. orgId := adminUserInfo.CurrentOrgId
  141. limit, _ := this.GetInt64("limit")
  142. page, _ := this.GetInt64("page")
  143. is_charge, _ := this.GetInt64("is_charge")
  144. is_start, _ := this.GetInt64("is_start")
  145. keyword := this.GetString("keyword")
  146. projecList, total, err := service.GetHisProjectList(orgId, limit, page, is_charge, is_start, keyword)
  147. fmt.Println("err", err)
  148. if err != nil {
  149. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  150. return
  151. }
  152. this.ServeSuccessJSON(map[string]interface{}{
  153. "projecList": projecList,
  154. "total": total,
  155. })
  156. return
  157. }
  158. func (this *HisProjectApiController) GetProjectDetail() {
  159. id, _ := this.GetInt64("id")
  160. projectDetail, err := service.GetProjectDetail(id)
  161. if err != nil {
  162. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  163. return
  164. }
  165. this.ServeSuccessJSON(map[string]interface{}{
  166. "projecDetail": projectDetail,
  167. })
  168. return
  169. }
  170. func (this *HisProjectApiController) UpdatedProject() {
  171. id, _ := this.GetInt64("id")
  172. project_name := this.GetString("project_name")
  173. pinyin := this.GetString("pinyin")
  174. wubi := this.GetString("wubi")
  175. price := this.GetString("price")
  176. price_float, _ := strconv.ParseFloat(price, 64)
  177. unit := this.GetString("unit")
  178. cost_classify, _ := this.GetInt64("cost_classify")
  179. executive_section, _ := this.GetInt64("executive_section")
  180. medical_coverage, _ := this.GetInt64("medical_coverage")
  181. statistical_classification, _ := this.GetInt64("statistical_classification")
  182. disease_directory, _ := this.GetInt64("disease_directory")
  183. is_record, _ := this.GetInt64("is_record")
  184. medical_code := this.GetString("medical_code")
  185. tube_color, _ := this.GetInt64("tube_color")
  186. medical_status, _ := this.GetInt64("medical_status")
  187. remark := this.GetString("remark")
  188. sign, _ := this.GetInt64("sign")
  189. default_number := this.GetString("default_number")
  190. is_charge, _ := this.GetInt64("is_charge")
  191. is_estimate, _ := this.GetInt64("is_estimate")
  192. is_workload, _ := this.GetInt64("is_workload")
  193. sort := this.GetString("sort")
  194. is_advice, _ := this.GetInt64("is_advice")
  195. is_default, _ := this.GetInt64("is_default")
  196. single_dose := this.GetString("single_dose")
  197. delivery_way := this.GetString("delivery_way")
  198. execution_frequency := this.GetString("execution_frequency")
  199. number_days := this.GetString("number_days")
  200. total := this.GetString("total")
  201. hisProject := models.XtHisProject{
  202. ProjectName: project_name,
  203. Pinyin: pinyin,
  204. Wubi: wubi,
  205. Price: price_float,
  206. Unit: unit,
  207. CostClassify: cost_classify,
  208. ExecutiveSection: executive_section,
  209. MedicalCoverage: medical_coverage,
  210. StatisticalClassification: statistical_classification,
  211. DiseaseDirectory: disease_directory,
  212. IsRecord: is_record,
  213. MedicalCode: medical_code,
  214. TubeColor: tube_color,
  215. MedicalStatus: medical_status,
  216. Remark: remark,
  217. Sign: sign,
  218. DefaultNumber: default_number,
  219. IsCharge: is_charge,
  220. IsEstimate: is_estimate,
  221. IsWorkload: is_workload,
  222. Sort: sort,
  223. DoctorAdvice: is_advice,
  224. IsDefault: is_default,
  225. UpdatedTime: time.Now().Unix(),
  226. SingleDose: single_dose,
  227. DeliveryWay: delivery_way,
  228. ExecutionFrequency: execution_frequency,
  229. NumberDays: number_days,
  230. Total: total,
  231. }
  232. err := service.UpdatedProject(id, &hisProject)
  233. if err != nil {
  234. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  235. return
  236. }
  237. this.ServeSuccessJSON(map[string]interface{}{
  238. "hisProject": hisProject,
  239. })
  240. return
  241. }
  242. func (this *HisProjectApiController) DeleteHisProject() {
  243. id, _ := this.GetInt64("id")
  244. err := service.DeleteHisProject(id)
  245. if err != nil {
  246. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  247. return
  248. }
  249. returnData := make(map[string]interface{}, 0)
  250. returnData["msg"] = "ok"
  251. this.ServeSuccessJSON(returnData)
  252. return
  253. }
  254. func (this *HisProjectApiController) SaveProjectTeam() {
  255. project_team := this.GetString("project_team")
  256. price := this.GetString("price")
  257. price_float, _ := strconv.ParseFloat(price, 64)
  258. pinyin := this.GetString("pinyin")
  259. wubi := this.GetString("wubi")
  260. tube_color, _ := this.GetInt64("tube_color")
  261. team_type, _ := this.GetInt64("team_type")
  262. remark := this.GetString("remark")
  263. ids := this.GetString("ids")
  264. adminUserInfo := this.GetAdminUserInfo()
  265. orgId := adminUserInfo.CurrentOrgId
  266. projectTeam := models.XtHisProjectTeam{
  267. ProjectTeam: project_team,
  268. Price: price_float,
  269. Pinyin: pinyin,
  270. Wubi: wubi,
  271. TubeColor: tube_color,
  272. TeamType: team_type,
  273. Remark: remark,
  274. UserOrgId: orgId,
  275. Status: 1,
  276. CreatedTime: time.Now().Unix(),
  277. ProjectId: ids,
  278. }
  279. fmt.Println(projectTeam)
  280. _, errcodes := service.GetHisProjectByNameOne(project_team, orgId)
  281. if errcodes == gorm.ErrRecordNotFound {
  282. err := service.CreatedProjectTeam(&projectTeam)
  283. if err != nil {
  284. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  285. return
  286. }
  287. this.ServeSuccessJSON(map[string]interface{}{
  288. "projectTeam": projectTeam,
  289. })
  290. return
  291. } else if errcodes == nil {
  292. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  293. return
  294. }
  295. }
  296. func (this *HisProjectApiController) GetProjectTeamList() {
  297. limit, _ := this.GetInt64("limit")
  298. page, _ := this.GetInt64("page")
  299. keyword := this.GetString("keyword")
  300. adminUserInfo := this.GetAdminUserInfo()
  301. orgId := adminUserInfo.CurrentOrgId
  302. projectTeamList, total, err := service.GetProjectTeamList(limit, page, orgId, keyword)
  303. if err != nil {
  304. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  305. return
  306. }
  307. this.ServeSuccessJSON(map[string]interface{}{
  308. "projectTeamList": projectTeamList,
  309. "total": total,
  310. })
  311. return
  312. }
  313. func (this *HisProjectApiController) GetProjectTeamDetail() {
  314. id, _ := this.GetInt64("id")
  315. projectTeamDetail, err := service.GetProjectTeamDetail(id)
  316. if err != nil {
  317. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  318. return
  319. }
  320. this.ServeSuccessJSON(map[string]interface{}{
  321. "projectTeamDetail": projectTeamDetail,
  322. })
  323. return
  324. }
  325. func (this *HisProjectApiController) UpdatedProjectTeam() {
  326. id, _ := this.GetInt64("id")
  327. project_team := this.GetString("project_team")
  328. price := this.GetString("price")
  329. price_float, _ := strconv.ParseFloat(price, 64)
  330. pinyin := this.GetString("pinyin")
  331. wubi := this.GetString("wubi")
  332. tube_color, _ := this.GetInt64("tube_color")
  333. team_type, _ := this.GetInt64("team_type")
  334. remark := this.GetString("remark")
  335. ids := this.GetString("ids")
  336. projectTeam := models.XtHisProjectTeam{
  337. ProjectTeam: project_team,
  338. Price: price_float,
  339. Pinyin: pinyin,
  340. Wubi: wubi,
  341. TubeColor: tube_color,
  342. TeamType: team_type,
  343. Remark: remark,
  344. ProjectId: ids,
  345. }
  346. err := service.UpdatedProjectTeam(id, &projectTeam)
  347. if err != nil {
  348. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  349. return
  350. }
  351. this.ServeSuccessJSON(map[string]interface{}{
  352. "projectTeam": projectTeam,
  353. })
  354. return
  355. }
  356. func (this *HisProjectApiController) DeleteProjectTeam() {
  357. id, _ := this.GetInt64("id")
  358. err := service.DeleteProjectTeam(id)
  359. if err != nil {
  360. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  361. return
  362. }
  363. returnData := make(map[string]interface{}, 0)
  364. returnData["msg"] = "ok"
  365. this.ServeSuccessJSON(returnData)
  366. return
  367. }
  368. func (this *HisProjectApiController) SaveDePartment() {
  369. name := this.GetString("name")
  370. number := this.GetString("number")
  371. adminUserInfo := this.GetAdminUserInfo()
  372. orgId := adminUserInfo.CurrentOrgId
  373. department := models.XtHisDepartment{
  374. Name: name,
  375. Number: number,
  376. UserOrgId: orgId,
  377. CreatedTime: time.Now().Unix(),
  378. Status: 1,
  379. }
  380. err := service.CreateDePartment(&department)
  381. if err != nil {
  382. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  383. return
  384. }
  385. this.ServeSuccessJSON(map[string]interface{}{
  386. "department": department,
  387. })
  388. return
  389. }
  390. func (this *HisProjectApiController) GetDepartMentList() {
  391. limit, _ := this.GetInt64("limit")
  392. page, _ := this.GetInt64("page")
  393. adminUserInfo := this.GetAdminUserInfo()
  394. orgId := adminUserInfo.CurrentOrgId
  395. departMentList, total, err := service.GetDepartMentList(limit, page, orgId)
  396. if err != nil {
  397. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  398. return
  399. }
  400. this.ServeSuccessJSON(map[string]interface{}{
  401. "departMentList": departMentList,
  402. "total": total,
  403. })
  404. return
  405. }
  406. func (this *HisProjectApiController) GetDepartMentDetail() {
  407. id, _ := this.GetInt64("id")
  408. departDetail, err := service.GetDepartMentDetail(id)
  409. if err != nil {
  410. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  411. return
  412. }
  413. this.ServeSuccessJSON(map[string]interface{}{
  414. "departDetail": departDetail,
  415. })
  416. return
  417. }
  418. func (this *HisProjectApiController) UpdatedDeparment() {
  419. id, _ := this.GetInt64("id")
  420. name := this.GetString("name")
  421. number := this.GetString("number")
  422. department := models.XtHisDepartment{
  423. Name: name,
  424. Number: number,
  425. }
  426. err := service.UpdatedDepartment(id, &department)
  427. if err != nil {
  428. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  429. return
  430. }
  431. this.ServeSuccessJSON(map[string]interface{}{
  432. "department": department,
  433. })
  434. return
  435. }
  436. func (this *HisProjectApiController) DeleteDepartment() {
  437. id, _ := this.GetInt64("id")
  438. err := service.DeleteDepartment(id)
  439. if err != nil {
  440. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  441. return
  442. }
  443. returnData := make(map[string]interface{}, 0)
  444. returnData["msg"] = "ok"
  445. this.ServeSuccessJSON(returnData)
  446. return
  447. }
  448. func (this *HisProjectApiController) GetBloodPatientList() {
  449. adminUserInfo := this.GetAdminUserInfo()
  450. orgId := adminUserInfo.CurrentOrgId
  451. fmt.Println("org", orgId)
  452. timeStr := time.Now().Format("2006-01-02")
  453. timeLayout := "2006-01-02 15:04:05"
  454. fmt.Println("timeStr:", timeStr)
  455. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  456. timenow := timeStringToTime.Unix()
  457. //统计血透排班的患者
  458. scheduleList, err := service.GetBloodPatientList(orgId, timenow)
  459. //统计当日挂号的患者
  460. hisPatient, _ := service.GetHisPatient(orgId, timenow)
  461. //统计今天开处方的患者
  462. prescription, _ := service.GetHisPrescriptionOther(orgId, timenow)
  463. if err != nil {
  464. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  465. return
  466. }
  467. this.ServeSuccessJSON(map[string]interface{}{
  468. "scheduleList": scheduleList,
  469. "hisPatient": hisPatient,
  470. "prescription": prescription,
  471. })
  472. return
  473. }
  474. func (this *HisProjectApiController) GetHisPrescription() {
  475. id, _ := this.GetInt64("id")
  476. timeStr := time.Now().Format("2006-01-02")
  477. timeLayout := "2006-01-02 15:04:05"
  478. fmt.Println("timeStr:", timeStr)
  479. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  480. timenow := timeStringToTime.Unix()
  481. prescriptionList, err := service.GetHisPrescriptionByPatientId(id, timenow)
  482. if err != nil {
  483. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  484. return
  485. }
  486. this.ServeSuccessJSON(map[string]interface{}{
  487. "prescriptionList": prescriptionList,
  488. })
  489. return
  490. }
  491. func (this *HisProjectApiController) AdditionalCharge() {
  492. //dataBody := make(map[string]interface{}, 0)
  493. //err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  494. //fmt.Println(err)
  495. //patient_id := int64(dataBody["patient_id"].(float64))
  496. //fmt.Println("patient_id2222222222", patient_id)
  497. //medicineData, _ := dataBody["medicineData"].([]interface{})
  498. //adminUserInfo := this.GetAdminUserInfo()
  499. //orgId := adminUserInfo.CurrentOrgId
  500. //admin_user_id := adminUserInfo.AdminUser.Id
  501. //timeStr := time.Now().Format("2006-01-02")
  502. //timeLayout := "2006-01-02 15:04:05"
  503. //fmt.Println("timeStr:", timeStr)
  504. //timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  505. //timenow := timeStringToTime.Unix()
  506. //for _, item := range medicineData {
  507. // //items := item.(map[string]interface{})
  508. // //drug_id := int64(items["id"].(float64))
  509. // //money := int64(items["money"].(float64))
  510. // //monStr := strconv.FormatInt(money, 10)
  511. // //monneyStr, _ := strconv.ParseFloat(monStr, 64)
  512. // additionalCharge := models.HisAdditionalCharge{
  513. // //DrugId: drug_id,
  514. // UserOrgId: orgId,
  515. // PatientId: patient_id,
  516. // RecordDate: timenow,
  517. // //Money: monneyStr,
  518. // Status: 1,
  519. // AdminUserId: admin_user_id,
  520. // CreatedTime: time.Now().Unix(),
  521. // }
  522. //
  523. // err := service.CreateAdditionalCharge(&additionalCharge)
  524. // if err != nil {
  525. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  526. // return
  527. // }
  528. // this.ServeSuccessJSON(map[string]interface{}{
  529. // "additionalCharge": additionalCharge,
  530. // })
  531. // return
  532. //}
  533. }
  534. func (this *HisProjectApiController) GetTreatmentList() {
  535. patient_id, _ := this.GetInt64("patient_id")
  536. timeStr := time.Now().Format("2006-01-02")
  537. timeLayout := "2006-01-02 15:04:05"
  538. fmt.Println("timeStr:", timeStr)
  539. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  540. timenow := timeStringToTime.Unix()
  541. treatmentList, err := service.GetTreatmentList(patient_id, timenow)
  542. if err != nil {
  543. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  544. return
  545. }
  546. this.ServeSuccessJSON(map[string]interface{}{
  547. "treatmentList": treatmentList,
  548. })
  549. return
  550. }
  551. func (this *HisProjectApiController) GetAllProjectList() {
  552. adminUserInfo := this.GetAdminUserInfo()
  553. orgId := adminUserInfo.CurrentOrgId
  554. projectList, err := service.GetAllProjectList(orgId)
  555. //获取列表数据
  556. hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
  557. if err != nil {
  558. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  559. return
  560. }
  561. this.ServeSuccessJSON(map[string]interface{}{
  562. "projectList": projectList,
  563. "hisprojectlist": hisprojectlist,
  564. })
  565. return
  566. }
  567. func (this *HisProjectApiController) AddProjectList() {
  568. id, _ := this.GetInt64("id")
  569. number, _ := this.GetInt64("number")
  570. adminUserInfo := this.GetAdminUserInfo()
  571. orgId := adminUserInfo.CurrentOrgId
  572. projectList := models.XtHisProjectList{
  573. ProjectId: id,
  574. Number: number,
  575. UserOrgId: orgId,
  576. Status: 1,
  577. CreatedTime: time.Now().Unix(),
  578. }
  579. err := service.CreateProjectList(&projectList)
  580. if err != nil {
  581. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  582. return
  583. }
  584. this.ServeSuccessJSON(map[string]interface{}{
  585. "projectList": projectList,
  586. })
  587. return
  588. }
  589. func (this *HisProjectApiController) GetPatientInformation() {
  590. id, _ := this.GetInt64("id")
  591. information, err := service.GetHisPatientInformation(id)
  592. if err != nil {
  593. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  594. return
  595. }
  596. this.ServeSuccessJSON(map[string]interface{}{
  597. "information": information,
  598. })
  599. return
  600. }
  601. func (this *HisProjectApiController) DeleteProject() {
  602. id, _ := this.GetInt64("id")
  603. err := service.DeleteProjectList(id)
  604. if err != nil {
  605. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  606. return
  607. }
  608. returnData := make(map[string]interface{}, 0)
  609. returnData["msg"] = "ok"
  610. this.ServeSuccessJSON(returnData)
  611. return
  612. }
  613. func (this *HisProjectApiController) GetHisProject() {
  614. adminUserInfo := this.GetAdminUserInfo()
  615. orgId := adminUserInfo.CurrentOrgId
  616. project, err := service.GetHisProject(orgId)
  617. if err != nil {
  618. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  619. return
  620. }
  621. this.ServeSuccessJSON(map[string]interface{}{
  622. "project": project,
  623. })
  624. }
  625. func (this *HisProjectApiController) GetProjectTeam() {
  626. strids := this.GetString("strids")
  627. idStrs := strings.Split(strids, ",")
  628. adminUserInfo := this.GetAdminUserInfo()
  629. orgId := adminUserInfo.CurrentOrgId
  630. team, err := service.GetProjectTeam(idStrs, orgId)
  631. if err != nil {
  632. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  633. return
  634. }
  635. this.ServeSuccessJSON(map[string]interface{}{
  636. "team": team,
  637. })
  638. }
  639. func (this *HisProjectApiController) GetAllDoctorList() {
  640. adminUserInfo := this.GetAdminUserInfo()
  641. orgId := adminUserInfo.CurrentOrgId
  642. appId := adminUserInfo.CurrentAppId
  643. //获取所有的医生
  644. doctor, err := service.GetAllDoctor(orgId, appId)
  645. //获取所有的科室
  646. department, err := service.GetAllDepartMent(orgId)
  647. if err != nil {
  648. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  649. return
  650. }
  651. this.ServeSuccessJSON(map[string]interface{}{
  652. "doctor": doctor,
  653. "department": department,
  654. })
  655. }
  656. func (this *HisProjectApiController) SaveHisPatient() {
  657. timeLayout := "2006-01-02"
  658. loc, _ := time.LoadLocation("Local")
  659. age, _ := this.GetInt64("age")
  660. birthday := this.GetString("birthDay")
  661. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  662. birthUnix := birthdays.Unix()
  663. certificates, _ := this.GetInt64("certificates")
  664. cost_checked, _ := this.GetInt64("costChecked")
  665. cost, _ := this.GetInt64("cost")
  666. costs := strconv.FormatInt(cost, 10)
  667. cost_float, _ := strconv.ParseFloat(costs, 64)
  668. department, _ := this.GetInt64("department")
  669. doctor, _ := this.GetInt64("doctor")
  670. medicalcare, _ := this.GetInt64("medicalCare")
  671. idcard := this.GetString("idCard")
  672. medicalExpenses, _ := this.GetInt64("medicalExpenses")
  673. medicalExpense := strconv.FormatInt(medicalExpenses, 10)
  674. medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
  675. medicalinsurancecard := this.GetString("medicalInsuranceCard")
  676. name := this.GetString("name")
  677. register, _ := this.GetInt64("register")
  678. registrationfee, _ := this.GetInt64("registrationFee")
  679. registrationfees := strconv.FormatInt(registrationfee, 10)
  680. registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
  681. settlementValue, _ := this.GetInt64("settlementValue")
  682. sex, _ := this.GetInt64("sex")
  683. total, _ := this.GetInt64("total")
  684. totals := strconv.FormatInt(total, 10)
  685. totals_float, _ := strconv.ParseFloat(totals, 64)
  686. adminUserInfo := this.GetAdminUserInfo()
  687. orgId := adminUserInfo.CurrentOrgId
  688. bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
  689. if errcode == gorm.ErrRecordNotFound {
  690. patient := models.XtHisPatient{
  691. Age: age,
  692. Birthday: birthUnix,
  693. IdType: certificates,
  694. CostOfProduction: cost_float,
  695. Departments: department,
  696. AdminUserId: doctor,
  697. MedicalTreatmentType: medicalcare,
  698. IdCardNo: idcard,
  699. IsNeedCostOfProduction: cost_checked,
  700. TreatmentCost: medicalExpense_float,
  701. MedicalInsuranceNumber: medicalinsurancecard,
  702. Name: name,
  703. RegisterType: register,
  704. RegisterCost: registrationfees_float,
  705. BalanceAccountsType: settlementValue,
  706. Gender: sex,
  707. Total: totals_float,
  708. UserOrgId: orgId,
  709. }
  710. err := service.CreateHisPatient(&patient)
  711. if err != nil {
  712. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  713. return
  714. }
  715. this.ServeSuccessJSON(map[string]interface{}{
  716. "patient": patient,
  717. })
  718. } else if errcode == nil {
  719. patient := models.XtHisPatient{
  720. Age: age,
  721. Birthday: birthUnix,
  722. IdType: certificates,
  723. CostOfProduction: cost_float,
  724. Departments: department,
  725. AdminUserId: doctor,
  726. MedicalTreatmentType: medicalcare,
  727. IdCardNo: idcard,
  728. IsNeedCostOfProduction: cost_checked,
  729. TreatmentCost: medicalExpense_float,
  730. MedicalInsuranceNumber: medicalinsurancecard,
  731. Name: name,
  732. RegisterType: register,
  733. RegisterCost: registrationfees_float,
  734. BalanceAccountsType: settlementValue,
  735. Gender: sex,
  736. Total: totals_float,
  737. UserOrgId: orgId,
  738. PatientId: bloodPatient.ID,
  739. }
  740. err := service.CreateHisPatient(&patient)
  741. if err != nil {
  742. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  743. return
  744. }
  745. this.ServeSuccessJSON(map[string]interface{}{
  746. "patient": patient,
  747. })
  748. }
  749. }
  750. func (this *HisProjectApiController) GetAllProjectTeam() {
  751. adminUserInfo := this.GetAdminUserInfo()
  752. orgId := adminUserInfo.CurrentOrgId
  753. fmt.Println("aaa")
  754. team, err := service.GetAllProjectTeam(orgId)
  755. if err != nil {
  756. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  757. return
  758. }
  759. this.ServeSuccessJSON(map[string]interface{}{
  760. "team": team,
  761. })
  762. }
  763. func (this *HisProjectApiController) GetProjectListById() {
  764. adminUserInfo := this.GetAdminUserInfo()
  765. orgId := adminUserInfo.CurrentOrgId
  766. project_id := this.GetString("project_id")
  767. idStrs := strings.Split(project_id, ",")
  768. project, err := service.GetProjectListById(orgId, idStrs)
  769. if err != nil {
  770. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  771. return
  772. }
  773. this.ServeSuccessJSON(map[string]interface{}{
  774. "project": project,
  775. })
  776. }
  777. func (this *HisProjectApiController) GetHisPatientHistory() {
  778. timeLayout := "2006-01-02"
  779. loc, _ := time.LoadLocation("Local")
  780. keyword := this.GetString("keyword")
  781. start_time := this.GetString("start_time")
  782. end_time := this.GetString("end_time")
  783. register_type, _ := this.GetInt64("register_type")
  784. limit, _ := this.GetInt64("limit")
  785. page, _ := this.GetInt64("page")
  786. fmt.Println(keyword, start_time, end_time, register_type, limit, page)
  787. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  788. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  789. history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page)
  790. if err != nil {
  791. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  792. return
  793. }
  794. this.ServeSuccessJSON(map[string]interface{}{
  795. "history": history,
  796. "total": total,
  797. })
  798. }