his_project_api_controller.go 27KB

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