his_project_api_controller.go 44KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  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/gettreatlist", &HisProjectApiController{}, "Get:GetTreatmentList")
  46. beego.Router("/api/his/getpatientinformation", &HisProjectApiController{}, "Get:GetPatientInformation")
  47. beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
  48. beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
  49. beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
  50. beego.Router("/api/patient/changepatient", &HisProjectApiController{}, "Get:ChangePatient")
  51. beego.Router("/api/patient/getpatientcasehistory", &HisProjectApiController{}, "Get:GetPatientcaseHistory")
  52. beego.Router("/api/doctorworkstation/gettemplatedetail", &HisProjectApiController{}, "Get:GetTemplateDetail")
  53. beego.Router("/api/doctorworkstation/updaterecordtemplate", &HisProjectApiController{}, "Get:UpdateRecordTemplate")
  54. beego.Router("/api/hispatient/gehispatient", &HisProjectApiController{}, "Get:GetHisPatient")
  55. //获取处方打印单
  56. beego.Router("/api/hispatient/getprescriptionprint", &HisProjectApiController{}, "Get:GetDoctorAdvicePrint")
  57. //获取项目打印单
  58. //beego.Router("/api/hispatient/getprojectprint",&HisApiController{},"Get:GetProjectPrint")
  59. beego.Router("/api/hispatient/postprinthistemplate", &HisProjectApiController{}, "Get:PostPrintHisTemplate")
  60. beego.Router("/api/gethisprinttemplate", &HisProjectApiController{}, "Get:GetHisPrintTemplate")
  61. beego.Router("/api/hispatient/postprescriptiontemplate", &HisProjectApiController{}, "Get:PostPrescriptionTempalte")
  62. beego.Router("/api/hispatient/getprescriptiontemplate", &HisProjectApiController{}, "Get:GetPrescriptionTemplate")
  63. beego.Router("/api/hispatient/posttreatprinttemplate", &HisProjectApiController{}, "Get:PostTreatPrintTemplate")
  64. beego.Router("/api/hispatient/gettreatprinttemplate", &HisProjectApiController{}, "Get:GetTreatPrintTemplate")
  65. beego.Router("/api/hispatient/postchargeprinttemplate", &HisProjectApiController{}, "Get:PostChargePrintTemplate")
  66. beego.Router("/api/hispatient/getchargeprinttemplate", &HisProjectApiController{}, "Get:GetChargePrintTemplate")
  67. beego.Router("/api/hispatient/getallhispatient", &HisProjectApiController{}, "Get:GetAllHisPatient")
  68. beego.Router("/api/hispatient/getchargeprint", &HisProjectApiController{}, "Get:GetChargePrint")
  69. beego.Router("/api/hispatient/gettodayschedulepatient", &HisProjectApiController{}, "Get:GetTodaySchedulePatient")
  70. beego.Router("/api/hispatient/gethispatientdetail", &HisProjectApiController{}, "Get:GetHisPatientDetail")
  71. beego.Router("/api/hispatient/getalldepartmentlist", &HisProjectApiController{}, "Get:GetAllDepartmentList")
  72. beego.Router("/api/hispatient/getprescription", &HisProjectApiController{}, "Get:GetPrescription")
  73. }
  74. func (this *HisProjectApiController) SaveProject() {
  75. project_name := this.GetString("project_name")
  76. pinyin := this.GetString("pinyin")
  77. wubi := this.GetString("wubi")
  78. price := this.GetString("price")
  79. price_float, err := strconv.ParseFloat(price, 64)
  80. unit := this.GetString("unit")
  81. cost_classify, _ := this.GetInt64("cost_classify")
  82. executive_section, _ := this.GetInt64("executive_section")
  83. medical_coverage, _ := this.GetInt64("medical_coverage")
  84. statistical_classification, _ := this.GetInt64("statistical_classification")
  85. disease_directory, _ := this.GetInt64("disease_directory")
  86. is_record, _ := this.GetInt64("is_record")
  87. medical_code := this.GetString("medical_code")
  88. tube_color, _ := this.GetInt64("tube_color")
  89. medical_status, _ := this.GetInt64("medical_status")
  90. remark := this.GetString("remark")
  91. sign, _ := this.GetInt64("sign")
  92. default_number := this.GetString("default_number")
  93. is_charge, _ := this.GetInt64("is_charge")
  94. is_estimate, _ := this.GetInt64("is_estimate")
  95. is_workload, _ := this.GetInt64("is_workload")
  96. sort := this.GetString("sort")
  97. is_advice, _ := this.GetInt64("is_advice")
  98. is_default, _ := this.GetInt64("is_default")
  99. single_dose := this.GetString("single_dose")
  100. delivery_way := this.GetString("delivery_way")
  101. execution_frequency := this.GetString("execution_frequency")
  102. number_days := this.GetString("number_days")
  103. total := this.GetString("total")
  104. adminUserInfo := this.GetAdminUserInfo()
  105. orgId := adminUserInfo.CurrentOrgId
  106. hisProject := models.XtHisProject{
  107. ProjectName: project_name,
  108. Pinyin: pinyin,
  109. Wubi: wubi,
  110. Price: price_float,
  111. Unit: unit,
  112. CostClassify: cost_classify,
  113. ExecutiveSection: executive_section,
  114. MedicalCoverage: medical_coverage,
  115. StatisticalClassification: statistical_classification,
  116. DiseaseDirectory: disease_directory,
  117. IsRecord: is_record,
  118. MedicalCode: medical_code,
  119. TubeColor: tube_color,
  120. MedicalStatus: medical_status,
  121. Remark: remark,
  122. Sign: sign,
  123. DefaultNumber: default_number,
  124. IsCharge: is_charge,
  125. IsEstimate: is_estimate,
  126. IsWorkload: is_workload,
  127. Sort: sort,
  128. DoctorAdvice: is_advice,
  129. IsDefault: is_default,
  130. UserOrgId: orgId,
  131. Status: 1,
  132. CreatedTime: time.Now().Unix(),
  133. SingleDose: single_dose,
  134. DeliveryWay: delivery_way,
  135. ExecutionFrequency: execution_frequency,
  136. NumberDays: number_days,
  137. Total: total,
  138. }
  139. //查询项目名称是否存在
  140. _, errcode := service.GetHisProjectIsExist(project_name, orgId)
  141. if errcode == gorm.ErrRecordNotFound {
  142. err = service.CreateHisProject(&hisProject)
  143. if err != nil {
  144. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  145. return
  146. }
  147. this.ServeSuccessJSON(map[string]interface{}{
  148. "hisProject": hisProject,
  149. })
  150. return
  151. } else if errcode == nil {
  152. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  153. return
  154. }
  155. }
  156. func (this *HisProjectApiController) GetProjectList() {
  157. adminUserInfo := this.GetAdminUserInfo()
  158. orgId := adminUserInfo.CurrentOrgId
  159. limit, _ := this.GetInt64("limit")
  160. page, _ := this.GetInt64("page")
  161. is_charge, _ := this.GetInt64("is_charge")
  162. is_start, _ := this.GetInt64("is_start")
  163. keyword := this.GetString("keyword")
  164. projecList, total, err := service.GetHisProjectList(orgId, limit, page, is_charge, is_start, keyword)
  165. if err != nil {
  166. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  167. return
  168. }
  169. this.ServeSuccessJSON(map[string]interface{}{
  170. "projecList": projecList,
  171. "total": total,
  172. })
  173. return
  174. }
  175. func (this *HisProjectApiController) GetProjectDetail() {
  176. id, _ := this.GetInt64("id")
  177. projectDetail, err := service.GetProjectDetail(id)
  178. if err != nil {
  179. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  180. return
  181. }
  182. this.ServeSuccessJSON(map[string]interface{}{
  183. "projecDetail": projectDetail,
  184. })
  185. return
  186. }
  187. func (this *HisProjectApiController) UpdatedProject() {
  188. id, _ := this.GetInt64("id")
  189. project_name := this.GetString("project_name")
  190. pinyin := this.GetString("pinyin")
  191. wubi := this.GetString("wubi")
  192. price := this.GetString("price")
  193. price_float, _ := strconv.ParseFloat(price, 64)
  194. unit := this.GetString("unit")
  195. cost_classify, _ := this.GetInt64("cost_classify")
  196. executive_section, _ := this.GetInt64("executive_section")
  197. medical_coverage, _ := this.GetInt64("medical_coverage")
  198. statistical_classification, _ := this.GetInt64("statistical_classification")
  199. disease_directory, _ := this.GetInt64("disease_directory")
  200. is_record, _ := this.GetInt64("is_record")
  201. medical_code := this.GetString("medical_code")
  202. tube_color, _ := this.GetInt64("tube_color")
  203. medical_status, _ := this.GetInt64("medical_status")
  204. remark := this.GetString("remark")
  205. sign, _ := this.GetInt64("sign")
  206. default_number := this.GetString("default_number")
  207. is_charge, _ := this.GetInt64("is_charge")
  208. is_estimate, _ := this.GetInt64("is_estimate")
  209. is_workload, _ := this.GetInt64("is_workload")
  210. sort := this.GetString("sort")
  211. is_advice, _ := this.GetInt64("is_advice")
  212. is_default, _ := this.GetInt64("is_default")
  213. single_dose := this.GetString("single_dose")
  214. delivery_way := this.GetString("delivery_way")
  215. execution_frequency := this.GetString("execution_frequency")
  216. number_days := this.GetString("number_days")
  217. total := this.GetString("total")
  218. hisProject := models.XtHisProject{
  219. ProjectName: project_name,
  220. Pinyin: pinyin,
  221. Wubi: wubi,
  222. Price: price_float,
  223. Unit: unit,
  224. CostClassify: cost_classify,
  225. ExecutiveSection: executive_section,
  226. MedicalCoverage: medical_coverage,
  227. StatisticalClassification: statistical_classification,
  228. DiseaseDirectory: disease_directory,
  229. IsRecord: is_record,
  230. MedicalCode: medical_code,
  231. TubeColor: tube_color,
  232. MedicalStatus: medical_status,
  233. Remark: remark,
  234. Sign: sign,
  235. DefaultNumber: default_number,
  236. IsCharge: is_charge,
  237. IsEstimate: is_estimate,
  238. IsWorkload: is_workload,
  239. Sort: sort,
  240. DoctorAdvice: is_advice,
  241. IsDefault: is_default,
  242. UpdatedTime: time.Now().Unix(),
  243. SingleDose: single_dose,
  244. DeliveryWay: delivery_way,
  245. ExecutionFrequency: execution_frequency,
  246. NumberDays: number_days,
  247. Total: total,
  248. }
  249. err := service.UpdatedProject(id, &hisProject)
  250. if err != nil {
  251. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  252. return
  253. }
  254. this.ServeSuccessJSON(map[string]interface{}{
  255. "hisProject": hisProject,
  256. })
  257. return
  258. }
  259. func (this *HisProjectApiController) DeleteHisProject() {
  260. id, _ := this.GetInt64("id")
  261. err := service.DeleteHisProject(id)
  262. if err != nil {
  263. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  264. return
  265. }
  266. returnData := make(map[string]interface{}, 0)
  267. returnData["msg"] = "ok"
  268. this.ServeSuccessJSON(returnData)
  269. return
  270. }
  271. func (this *HisProjectApiController) SaveProjectTeam() {
  272. project_team := this.GetString("project_team")
  273. price := this.GetString("price")
  274. price_float, _ := strconv.ParseFloat(price, 64)
  275. pinyin := this.GetString("pinyin")
  276. wubi := this.GetString("wubi")
  277. tube_color, _ := this.GetInt64("tube_color")
  278. team_type, _ := this.GetInt64("team_type")
  279. remark := this.GetString("remark")
  280. ids := this.GetString("ids")
  281. adminUserInfo := this.GetAdminUserInfo()
  282. orgId := adminUserInfo.CurrentOrgId
  283. projectTeam := models.XtHisProjectTeam{
  284. ProjectTeam: project_team,
  285. Price: price_float,
  286. Pinyin: pinyin,
  287. Wubi: wubi,
  288. TubeColor: tube_color,
  289. TeamType: team_type,
  290. Remark: remark,
  291. UserOrgId: orgId,
  292. Status: 1,
  293. CreatedTime: time.Now().Unix(),
  294. ProjectId: ids,
  295. }
  296. fmt.Println(projectTeam)
  297. _, errcodes := service.GetHisProjectByNameOne(project_team, orgId)
  298. if errcodes == gorm.ErrRecordNotFound {
  299. err := service.CreatedProjectTeam(&projectTeam)
  300. if err != nil {
  301. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  302. return
  303. }
  304. this.ServeSuccessJSON(map[string]interface{}{
  305. "projectTeam": projectTeam,
  306. })
  307. return
  308. } else if errcodes == nil {
  309. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  310. return
  311. }
  312. }
  313. func (this *HisProjectApiController) GetProjectTeamList() {
  314. limit, _ := this.GetInt64("limit")
  315. page, _ := this.GetInt64("page")
  316. keyword := this.GetString("keyword")
  317. adminUserInfo := this.GetAdminUserInfo()
  318. orgId := adminUserInfo.CurrentOrgId
  319. projectTeamList, total, err := service.GetProjectTeamList(limit, page, orgId, keyword)
  320. if err != nil {
  321. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  322. return
  323. }
  324. this.ServeSuccessJSON(map[string]interface{}{
  325. "projectTeamList": projectTeamList,
  326. "total": total,
  327. })
  328. return
  329. }
  330. func (this *HisProjectApiController) GetProjectTeamDetail() {
  331. id, _ := this.GetInt64("id")
  332. projectTeamDetail, err := service.GetProjectTeamDetail(id)
  333. if err != nil {
  334. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  335. return
  336. }
  337. this.ServeSuccessJSON(map[string]interface{}{
  338. "projectTeamDetail": projectTeamDetail,
  339. })
  340. return
  341. }
  342. func (this *HisProjectApiController) UpdatedProjectTeam() {
  343. id, _ := this.GetInt64("id")
  344. project_team := this.GetString("project_team")
  345. price := this.GetString("price")
  346. price_float, _ := strconv.ParseFloat(price, 64)
  347. pinyin := this.GetString("pinyin")
  348. wubi := this.GetString("wubi")
  349. tube_color, _ := this.GetInt64("tube_color")
  350. team_type, _ := this.GetInt64("team_type")
  351. remark := this.GetString("remark")
  352. ids := this.GetString("ids")
  353. projectTeam := models.XtHisProjectTeam{
  354. ProjectTeam: project_team,
  355. Price: price_float,
  356. Pinyin: pinyin,
  357. Wubi: wubi,
  358. TubeColor: tube_color,
  359. TeamType: team_type,
  360. Remark: remark,
  361. ProjectId: ids,
  362. }
  363. err := service.UpdatedProjectTeam(id, &projectTeam)
  364. if err != nil {
  365. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  366. return
  367. }
  368. this.ServeSuccessJSON(map[string]interface{}{
  369. "projectTeam": projectTeam,
  370. })
  371. return
  372. }
  373. func (this *HisProjectApiController) DeleteProjectTeam() {
  374. id, _ := this.GetInt64("id")
  375. err := service.DeleteProjectTeam(id)
  376. if err != nil {
  377. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  378. return
  379. }
  380. returnData := make(map[string]interface{}, 0)
  381. returnData["msg"] = "ok"
  382. this.ServeSuccessJSON(returnData)
  383. return
  384. }
  385. func (this *HisProjectApiController) SaveDePartment() {
  386. name := this.GetString("name")
  387. number := this.GetString("number")
  388. adminUserInfo := this.GetAdminUserInfo()
  389. orgId := adminUserInfo.CurrentOrgId
  390. department := models.XtHisDepartment{
  391. Name: name,
  392. Number: number,
  393. UserOrgId: orgId,
  394. CreatedTime: time.Now().Unix(),
  395. Status: 1,
  396. }
  397. err := service.CreateDePartment(&department)
  398. if err != nil {
  399. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  400. return
  401. }
  402. this.ServeSuccessJSON(map[string]interface{}{
  403. "department": department,
  404. })
  405. return
  406. }
  407. func (this *HisProjectApiController) GetDepartMentList() {
  408. limit, _ := this.GetInt64("limit")
  409. page, _ := this.GetInt64("page")
  410. adminUserInfo := this.GetAdminUserInfo()
  411. orgId := adminUserInfo.CurrentOrgId
  412. departMentList, total, err := service.GetDepartMentList(limit, page, orgId)
  413. if err != nil {
  414. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  415. return
  416. }
  417. this.ServeSuccessJSON(map[string]interface{}{
  418. "departMentList": departMentList,
  419. "total": total,
  420. })
  421. return
  422. }
  423. func (this *HisProjectApiController) GetDepartMentDetail() {
  424. id, _ := this.GetInt64("id")
  425. departDetail, err := service.GetDepartMentDetail(id)
  426. if err != nil {
  427. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  428. return
  429. }
  430. this.ServeSuccessJSON(map[string]interface{}{
  431. "departDetail": departDetail,
  432. })
  433. return
  434. }
  435. func (this *HisProjectApiController) UpdatedDeparment() {
  436. id, _ := this.GetInt64("id")
  437. name := this.GetString("name")
  438. number := this.GetString("number")
  439. department := models.XtHisDepartment{
  440. Name: name,
  441. Number: number,
  442. }
  443. err := service.UpdatedDepartment(id, &department)
  444. if err != nil {
  445. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  446. return
  447. }
  448. this.ServeSuccessJSON(map[string]interface{}{
  449. "department": department,
  450. })
  451. return
  452. }
  453. func (this *HisProjectApiController) DeleteDepartment() {
  454. id, _ := this.GetInt64("id")
  455. err := service.DeleteDepartment(id)
  456. if err != nil {
  457. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  458. return
  459. }
  460. returnData := make(map[string]interface{}, 0)
  461. returnData["msg"] = "ok"
  462. this.ServeSuccessJSON(returnData)
  463. return
  464. }
  465. func (this *HisProjectApiController) GetBloodPatientList() {
  466. adminUserInfo := this.GetAdminUserInfo()
  467. orgId := adminUserInfo.CurrentOrgId
  468. timeStr := time.Now().Format("2006-01-02")
  469. timeLayout := "2006-01-02 15:04:05"
  470. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  471. timenow := timeStringToTime.Unix()
  472. //统计血透排班的患者
  473. scheduleList, err := service.GetBloodPatientList(orgId, timenow)
  474. //统计当日挂号的患者
  475. hisPatient, _ := service.GetHisPatient(orgId, timenow)
  476. //统计今天开处方的患者
  477. prescription, _ := service.GetHisPrescriptionOther(orgId, timenow)
  478. if err != nil {
  479. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  480. return
  481. }
  482. this.ServeSuccessJSON(map[string]interface{}{
  483. "scheduleList": scheduleList,
  484. "hisPatient": hisPatient,
  485. "prescription": prescription,
  486. })
  487. return
  488. }
  489. func (this *HisProjectApiController) GetHisPrescription() {
  490. id, _ := this.GetInt64("id")
  491. timeStr := time.Now().Format("2006-01-02")
  492. timeLayout := "2006-01-02 15:04:05"
  493. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  494. timenow := timeStringToTime.Unix()
  495. prescriptionList, err := service.GetHisPrescriptionByPatientId(id, timenow)
  496. if err != nil {
  497. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  498. return
  499. }
  500. this.ServeSuccessJSON(map[string]interface{}{
  501. "prescriptionList": prescriptionList,
  502. })
  503. return
  504. }
  505. func (this *HisProjectApiController) GetTreatmentList() {
  506. patient_id, _ := this.GetInt64("patient_id")
  507. timeStr := time.Now().Format("2006-01-02")
  508. timeLayout := "2006-01-02 15:04:05"
  509. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  510. timenow := timeStringToTime.Unix()
  511. treatmentList, err := service.GetTreatmentList(patient_id, timenow)
  512. if err != nil {
  513. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  514. return
  515. }
  516. this.ServeSuccessJSON(map[string]interface{}{
  517. "treatmentList": treatmentList,
  518. })
  519. return
  520. }
  521. func (this *HisProjectApiController) GetAllProjectList() {
  522. adminUserInfo := this.GetAdminUserInfo()
  523. orgId := adminUserInfo.CurrentOrgId
  524. projectList, err := service.GetAllProjectList(orgId)
  525. //获取列表数据
  526. hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
  527. if err != nil {
  528. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  529. return
  530. }
  531. this.ServeSuccessJSON(map[string]interface{}{
  532. "projectList": projectList,
  533. "hisprojectlist": hisprojectlist,
  534. })
  535. return
  536. }
  537. func (this *HisProjectApiController) AddProjectList() {
  538. id, _ := this.GetInt64("id")
  539. number, _ := this.GetInt64("number")
  540. adminUserInfo := this.GetAdminUserInfo()
  541. orgId := adminUserInfo.CurrentOrgId
  542. projectList := models.XtHisProjectList{
  543. ProjectId: id,
  544. Number: number,
  545. UserOrgId: orgId,
  546. Status: 1,
  547. CreatedTime: time.Now().Unix(),
  548. }
  549. err := service.CreateProjectList(&projectList)
  550. if err != nil {
  551. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  552. return
  553. }
  554. this.ServeSuccessJSON(map[string]interface{}{
  555. "projectList": projectList,
  556. })
  557. return
  558. }
  559. func (this *HisProjectApiController) GetPatientInformation() {
  560. id, _ := this.GetInt64("id")
  561. information, err := service.GetHisPatientInformation(id)
  562. if err != nil {
  563. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  564. return
  565. }
  566. this.ServeSuccessJSON(map[string]interface{}{
  567. "information": information,
  568. })
  569. return
  570. }
  571. func (this *HisProjectApiController) DeleteProject() {
  572. id, _ := this.GetInt64("id")
  573. err := service.DeleteProjectList(id)
  574. if err != nil {
  575. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  576. return
  577. }
  578. returnData := make(map[string]interface{}, 0)
  579. returnData["msg"] = "ok"
  580. this.ServeSuccessJSON(returnData)
  581. return
  582. }
  583. func (this *HisProjectApiController) GetHisProject() {
  584. adminUserInfo := this.GetAdminUserInfo()
  585. orgId := adminUserInfo.CurrentOrgId
  586. project, err := service.GetHisProject(orgId)
  587. if err != nil {
  588. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  589. return
  590. }
  591. this.ServeSuccessJSON(map[string]interface{}{
  592. "project": project,
  593. })
  594. }
  595. func (this *HisProjectApiController) GetProjectTeam() {
  596. strids := this.GetString("strids")
  597. idStrs := strings.Split(strids, ",")
  598. adminUserInfo := this.GetAdminUserInfo()
  599. orgId := adminUserInfo.CurrentOrgId
  600. team, err := service.GetProjectTeam(idStrs, orgId)
  601. if err != nil {
  602. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  603. return
  604. }
  605. this.ServeSuccessJSON(map[string]interface{}{
  606. "team": team,
  607. })
  608. }
  609. func (this *HisProjectApiController) GetAllDoctorList() {
  610. adminUserInfo := this.GetAdminUserInfo()
  611. orgId := adminUserInfo.CurrentOrgId
  612. appId := adminUserInfo.CurrentAppId
  613. //获取所有的医生
  614. doctor, err := service.GetAllDoctor(orgId, appId)
  615. //获取所有的科室
  616. department, err := service.GetAllDepartMent(orgId)
  617. if err != nil {
  618. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  619. return
  620. }
  621. this.ServeSuccessJSON(map[string]interface{}{
  622. "doctor": doctor,
  623. "department": department,
  624. })
  625. }
  626. func (this *HisProjectApiController) SaveHisPatient() {
  627. timeLayout := "2006-01-02"
  628. loc, _ := time.LoadLocation("Local")
  629. age, _ := this.GetInt64("age")
  630. birthday := this.GetString("birthDay")
  631. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  632. birthUnix := birthdays.Unix()
  633. certificates, _ := this.GetInt64("certificates")
  634. cost_checked, _ := this.GetInt64("costChecked")
  635. cost, _ := this.GetInt64("cost")
  636. costs := strconv.FormatInt(cost, 10)
  637. cost_float, _ := strconv.ParseFloat(costs, 64)
  638. department, _ := this.GetInt64("department")
  639. doctor, _ := this.GetInt64("doctor")
  640. medicalcare, _ := this.GetInt64("medicalCare")
  641. idcard := this.GetString("idCard")
  642. medicalExpenses, _ := this.GetInt64("medicalExpenses")
  643. medicalExpense := strconv.FormatInt(medicalExpenses, 10)
  644. medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
  645. medicalinsurancecard := this.GetString("medicalInsuranceCard")
  646. name := this.GetString("name")
  647. register, _ := this.GetInt64("register")
  648. registrationfee, _ := this.GetInt64("registrationFee")
  649. registrationfees := strconv.FormatInt(registrationfee, 10)
  650. registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
  651. settlementValue, _ := this.GetInt64("settlementValue")
  652. sex, _ := this.GetInt64("sex")
  653. total, _ := this.GetInt64("total")
  654. totals := strconv.FormatInt(total, 10)
  655. totals_float, _ := strconv.ParseFloat(totals, 64)
  656. adminUserInfo := this.GetAdminUserInfo()
  657. orgId := adminUserInfo.CurrentOrgId
  658. recordDateStr := time.Now().Format("2006-01-02")
  659. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  660. nowtime := recordDate.Unix()
  661. phone := this.GetString("phone")
  662. social_type, _ := this.GetInt64("social_type")
  663. bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
  664. if errcode == gorm.ErrRecordNotFound {
  665. patient := models.XtHisPatient{
  666. Age: age,
  667. Birthday: birthUnix,
  668. IdType: certificates,
  669. CostOfProduction: cost_float,
  670. Departments: department,
  671. Doctor: doctor,
  672. AdminUserId: adminUserInfo.AdminUser.Id,
  673. MedicalTreatmentType: medicalcare,
  674. IdCardNo: idcard,
  675. IsNeedCostOfProduction: cost_checked,
  676. TreatmentCost: medicalExpense_float,
  677. MedicalInsuranceNumber: medicalinsurancecard,
  678. Name: name,
  679. RegisterType: register,
  680. RegisterCost: registrationfees_float,
  681. BalanceAccountsType: settlementValue,
  682. Gender: sex,
  683. Total: totals_float,
  684. UserOrgId: orgId,
  685. Status: 1,
  686. RecordDate: nowtime,
  687. IsReturn: 1,
  688. Ctime: time.Now().Unix(),
  689. Phone: phone,
  690. SocialType: social_type,
  691. }
  692. err := service.CreateHisPatient(&patient)
  693. lastPatient, err := service.GetLastPatient(orgId)
  694. timeStr := time.Now().Format("2006-01-02")
  695. timeArr := strings.Split(timeStr, "-")
  696. var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
  697. hisPatient := models.HisPatient{
  698. Number: str,
  699. }
  700. err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
  701. fmt.Println("errr", err)
  702. if err != nil {
  703. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  704. return
  705. }
  706. this.ServeSuccessJSON(map[string]interface{}{
  707. "patient": patient,
  708. })
  709. } else if errcode == nil {
  710. patient := models.XtHisPatient{
  711. Age: age,
  712. Birthday: birthUnix,
  713. IdType: certificates,
  714. CostOfProduction: cost_float,
  715. Departments: department,
  716. AdminUserId: doctor,
  717. MedicalTreatmentType: medicalcare,
  718. IdCardNo: idcard,
  719. IsNeedCostOfProduction: cost_checked,
  720. TreatmentCost: medicalExpense_float,
  721. MedicalInsuranceNumber: medicalinsurancecard,
  722. Name: name,
  723. RegisterType: register,
  724. RegisterCost: registrationfees_float,
  725. BalanceAccountsType: settlementValue,
  726. Gender: sex,
  727. Total: totals_float,
  728. UserOrgId: orgId,
  729. PatientId: bloodPatient.ID,
  730. Ctime: time.Now().Unix(),
  731. Phone: phone,
  732. SocialType: social_type,
  733. }
  734. err := service.CreateHisPatient(&patient)
  735. if err != nil {
  736. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  737. return
  738. }
  739. this.ServeSuccessJSON(map[string]interface{}{
  740. "patient": patient,
  741. })
  742. }
  743. }
  744. func (this *HisProjectApiController) GetAllProjectTeam() {
  745. adminUserInfo := this.GetAdminUserInfo()
  746. orgId := adminUserInfo.CurrentOrgId
  747. team, err := service.GetAllProjectTeam(orgId)
  748. if err != nil {
  749. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  750. return
  751. }
  752. this.ServeSuccessJSON(map[string]interface{}{
  753. "team": team,
  754. })
  755. }
  756. func (this *HisProjectApiController) GetProjectListById() {
  757. adminUserInfo := this.GetAdminUserInfo()
  758. orgId := adminUserInfo.CurrentOrgId
  759. project_id := this.GetString("project_id")
  760. idStrs := strings.Split(project_id, ",")
  761. project, err := service.GetProjectListById(orgId, idStrs)
  762. if err != nil {
  763. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  764. return
  765. }
  766. this.ServeSuccessJSON(map[string]interface{}{
  767. "project": project,
  768. })
  769. }
  770. func (this *HisProjectApiController) GetHisPatientHistory() {
  771. timeLayout := "2006-01-02"
  772. loc, _ := time.LoadLocation("Local")
  773. keyword := this.GetString("keyword")
  774. start_time := this.GetString("start_time")
  775. end_time := this.GetString("end_time")
  776. register_type, _ := this.GetInt64("register_type")
  777. limit, _ := this.GetInt64("limit")
  778. page, _ := this.GetInt64("page")
  779. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  780. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  781. adminUserInfo := this.GetAdminUserInfo()
  782. orgId := adminUserInfo.CurrentOrgId
  783. history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
  784. department, err := service.GetAllDepartMent(orgId)
  785. appId := adminUserInfo.CurrentAppId
  786. doctor, err := service.GetAllDoctor(orgId, appId)
  787. if err != nil {
  788. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  789. return
  790. }
  791. this.ServeSuccessJSON(map[string]interface{}{
  792. "history": history,
  793. "total": total,
  794. "department": department,
  795. "doctor": doctor,
  796. })
  797. }
  798. func (this *HisProjectApiController) ChangePatient() {
  799. id, _ := this.GetInt64("id")
  800. //查询该患者今日是否已经就诊
  801. recordDateStr := time.Now().Format("2006-01-02")
  802. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  803. nowtime := recordDate.Unix()
  804. adminUserInfo := this.GetAdminUserInfo()
  805. orgId := adminUserInfo.CurrentOrgId
  806. _, errcode := service.GetHisPrescriptionTwo(id, orgId, nowtime)
  807. if errcode == gorm.ErrRecordNotFound {
  808. err := service.ChangePatient(id)
  809. if err != nil {
  810. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  811. return
  812. }
  813. returnData := make(map[string]interface{}, 0)
  814. returnData["msg"] = "ok"
  815. this.ServeSuccessJSON(returnData)
  816. return
  817. } else if errcode == nil {
  818. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  819. return
  820. }
  821. }
  822. func (this *HisProjectApiController) GetPatientcaseHistory() {
  823. patient_id, _ := this.GetInt64("patient_id")
  824. patient, _ := service.GetBloodPatientInfoById(patient_id)
  825. history, err := service.GetPatientCaseHistory(patient_id)
  826. hispatient, _ := service.GetHisPatientById(patient_id)
  827. if err != nil {
  828. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  829. return
  830. }
  831. this.ServeSuccessJSON(map[string]interface{}{
  832. "patient": patient,
  833. "history": history,
  834. "hispatient": hispatient,
  835. })
  836. }
  837. func (this *HisProjectApiController) GetTemplateDetail() {
  838. id, _ := this.GetInt64("id")
  839. templateDetail, err := service.GetTemplateDetail(id)
  840. if err != nil {
  841. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  842. return
  843. }
  844. this.ServeSuccessJSON(map[string]interface{}{
  845. "templateDetail": templateDetail,
  846. })
  847. }
  848. func (this *HisProjectApiController) UpdateRecordTemplate() {
  849. id, _ := this.GetInt64("id")
  850. template_name := this.GetString("template_name")
  851. template_remark := this.GetString("template_remark")
  852. diagnostic := this.GetString("diagnostic")
  853. chief_conplaint := this.GetString("chief_conplaint")
  854. history_of_present_illness := this.GetString("history_of_present_illness")
  855. past_history := this.GetString("past_history")
  856. personal_history := this.GetString("personal_history")
  857. family_history := this.GetString("family_history")
  858. adminUserInfo := this.GetAdminUserInfo()
  859. creater := adminUserInfo.AdminUser.Id
  860. historyTemplate := models.HisCaseHistoryTemplate{
  861. HistoryOfPresentIllness: history_of_present_illness,
  862. PastHistory: past_history,
  863. ChiefConplaint: chief_conplaint,
  864. PersonalHistory: personal_history,
  865. FamilyHistory: family_history,
  866. Diagnostic: diagnostic,
  867. Status: 1,
  868. Mtime: time.Now().Unix(),
  869. RecordDate: time.Now().Unix(),
  870. TemplateName: template_name,
  871. TemplateRemark: template_remark,
  872. Modifier: creater,
  873. }
  874. err := service.UpdateCaseHistoryTemplate(&historyTemplate, id)
  875. if err != nil {
  876. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  877. return
  878. }
  879. this.ServeSuccessJSON(map[string]interface{}{
  880. "templateDetail": historyTemplate,
  881. })
  882. }
  883. func (this *HisProjectApiController) GetHisPatient() {
  884. adminUserInfo := this.GetAdminUserInfo()
  885. orgId := adminUserInfo.CurrentOrgId
  886. keyword := this.GetString("keyword")
  887. patient, err := service.GetHistPatient(orgId, keyword)
  888. if err != nil {
  889. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  890. return
  891. }
  892. this.ServeSuccessJSON(map[string]interface{}{
  893. "patient": patient,
  894. })
  895. }
  896. func (this *HisProjectApiController) GetDoctorAdvicePrint() {
  897. patient_id, _ := this.GetInt64("patient_id")
  898. record_date := this.GetString("record_date")
  899. timeLayout := "2006-01-02"
  900. loc, _ := time.LoadLocation("Local")
  901. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  902. recordDateTime := theTime.Unix()
  903. fmt.Println("recordDateTime-----------", recordDateTime)
  904. prescription_id, _ := this.GetInt64("prescription_id")
  905. advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, prescription_id)
  906. doctorPorject, err := service.GetDoctorProjectItem(patient_id, recordDateTime)
  907. patient, err := service.GetBloodPatientByPatient(patient_id)
  908. prescriptionInfo, err := service.GetPrscriptionInfo(patient_id, recordDateTime)
  909. if err != nil {
  910. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  911. return
  912. }
  913. this.ServeSuccessJSON(map[string]interface{}{
  914. "advicePrint": advicePrint,
  915. "patient": patient,
  916. "doctorPorject": doctorPorject,
  917. "prescriptionInfo": prescriptionInfo,
  918. })
  919. }
  920. func (this *HisProjectApiController) GetProjectPrint() {
  921. his_patient_id, _ := this.GetInt64("his_patient_id")
  922. hisPatient, _ := service.GetHisPatientById(his_patient_id)
  923. projectPrint, err := service.GetProjectPrint(his_patient_id)
  924. if err != nil {
  925. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  926. return
  927. }
  928. this.ServeSuccessJSON(map[string]interface{}{
  929. "hisPatient": hisPatient,
  930. "projectPrint": projectPrint,
  931. })
  932. }
  933. func (this *HisProjectApiController) PostPrintHisTemplate() {
  934. template_id, _ := this.GetInt64("template_id")
  935. adminUserInfo := this.GetAdminUserInfo()
  936. orgId := adminUserInfo.CurrentOrgId
  937. _, errcode := service.GetHisTemplateId(template_id, orgId)
  938. fmt.Println("errcode0-------", errcode)
  939. if errcode == gorm.ErrRecordNotFound {
  940. template := models.XtHisTemplate{
  941. TemplateId: template_id,
  942. UserOrgId: orgId,
  943. Status: 1,
  944. Ctime: time.Now().Unix(),
  945. }
  946. err := service.CreateHisTemplate(&template)
  947. if err != nil {
  948. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  949. return
  950. }
  951. this.ServeSuccessJSON(map[string]interface{}{
  952. "template": template,
  953. "template_id": template_id,
  954. })
  955. } else if errcode == nil {
  956. template := models.XtHisTemplate{
  957. TemplateId: template_id,
  958. UserOrgId: orgId,
  959. Status: 1,
  960. Ctime: time.Now().Unix(),
  961. Mtime: time.Now().Unix(),
  962. }
  963. err := service.UpdateHisTemplate(&template)
  964. if err != nil {
  965. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  966. return
  967. }
  968. this.ServeSuccessJSON(map[string]interface{}{
  969. "template": template,
  970. "template_id": template_id,
  971. })
  972. }
  973. }
  974. func (this *HisProjectApiController) GetHisPrintTemplate() {
  975. adminUserInfo := this.GetAdminUserInfo()
  976. orgId := adminUserInfo.CurrentOrgId
  977. template, err := service.GetHisPrintTemplate(orgId)
  978. if err != nil {
  979. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  980. return
  981. }
  982. this.ServeSuccessJSON(map[string]interface{}{
  983. "template": template,
  984. })
  985. }
  986. func (this *HisProjectApiController) PostPrescriptionTempalte() {
  987. template_id, _ := this.GetInt64("template_id")
  988. adminUserInfo := this.GetAdminUserInfo()
  989. orgId := adminUserInfo.CurrentOrgId
  990. _, errcode := service.GetPrescriptionTemplate(template_id, orgId)
  991. if errcode == gorm.ErrRecordNotFound {
  992. template := models.XtHisAdviceTemplate{
  993. TemplateId: template_id,
  994. UserOrgId: orgId,
  995. Status: 1,
  996. Ctime: time.Now().Unix(),
  997. }
  998. err := service.CreatePrescriptionTemplate(&template)
  999. if err != nil {
  1000. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1001. return
  1002. }
  1003. this.ServeSuccessJSON(map[string]interface{}{
  1004. "template": template,
  1005. "template_id": template_id,
  1006. })
  1007. } else if errcode == nil {
  1008. template := models.XtHisAdviceTemplate{
  1009. TemplateId: template_id,
  1010. UserOrgId: orgId,
  1011. Status: 1,
  1012. Ctime: time.Now().Unix(),
  1013. }
  1014. err := service.UpdatePrescriptionTemplate(&template)
  1015. if err != nil {
  1016. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1017. return
  1018. }
  1019. this.ServeSuccessJSON(map[string]interface{}{
  1020. "template": template,
  1021. "template_id": template_id,
  1022. })
  1023. }
  1024. }
  1025. func (this *HisProjectApiController) GetPrescriptionTemplate() {
  1026. adminUserInfo := this.GetAdminUserInfo()
  1027. orgId := adminUserInfo.CurrentOrgId
  1028. template, err := service.GetPrescriptionTemplateById(orgId)
  1029. if err != nil {
  1030. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1031. return
  1032. }
  1033. this.ServeSuccessJSON(map[string]interface{}{
  1034. "template": template,
  1035. })
  1036. }
  1037. func (this *HisProjectApiController) PostTreatPrintTemplate() {
  1038. template_id, _ := this.GetInt64("template_id")
  1039. adminUserInfo := this.GetAdminUserInfo()
  1040. orgId := adminUserInfo.CurrentOrgId
  1041. _, errcode := service.GetTreatPrintTemplate(template_id, orgId)
  1042. if errcode == gorm.ErrRecordNotFound {
  1043. template := models.XtHisTreatmentTemplate{
  1044. TemplateId: template_id,
  1045. UserOrgId: orgId,
  1046. Status: 1,
  1047. Ctime: time.Now().Unix(),
  1048. }
  1049. err := service.CreateTreatPrintTemplate(&template)
  1050. if err != nil {
  1051. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1052. return
  1053. }
  1054. this.ServeSuccessJSON(map[string]interface{}{
  1055. "template": template,
  1056. "template_id": template_id,
  1057. })
  1058. } else if errcode == nil {
  1059. template := models.XtHisTreatmentTemplate{
  1060. TemplateId: template_id,
  1061. UserOrgId: orgId,
  1062. Status: 1,
  1063. Ctime: time.Now().Unix(),
  1064. }
  1065. err := service.UpdatedTreateTemplate(&template)
  1066. if err != nil {
  1067. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1068. return
  1069. }
  1070. this.ServeSuccessJSON(map[string]interface{}{
  1071. "template": template,
  1072. "template_id": template_id,
  1073. })
  1074. }
  1075. }
  1076. func (this *HisProjectApiController) GetTreatPrintTemplate() {
  1077. adminUserInfo := this.GetAdminUserInfo()
  1078. orgId := adminUserInfo.CurrentOrgId
  1079. template, err := service.GetTreatTtreatPrintTemplate(orgId)
  1080. if err != nil {
  1081. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1082. return
  1083. }
  1084. this.ServeSuccessJSON(map[string]interface{}{
  1085. "template": template,
  1086. })
  1087. }
  1088. func (this *HisProjectApiController) PostChargePrintTemplate() {
  1089. template_id, _ := this.GetInt64("template_id")
  1090. adminUserInfo := this.GetAdminUserInfo()
  1091. orgId := adminUserInfo.CurrentOrgId
  1092. _, errcode := service.GetChargeTemplate(template_id, orgId)
  1093. if errcode == gorm.ErrRecordNotFound {
  1094. template := models.XtHisChargeTemplate{
  1095. TemplateId: template_id,
  1096. UserOrgId: orgId,
  1097. Ctime: time.Now().Unix(),
  1098. Status: 1,
  1099. }
  1100. err := service.CreateChargePrintTemplate(&template)
  1101. if err != nil {
  1102. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1103. return
  1104. }
  1105. this.ServeSuccessJSON(map[string]interface{}{
  1106. "template": template,
  1107. "template_id": template_id,
  1108. })
  1109. } else if errcode == nil {
  1110. template := models.XtHisChargeTemplate{
  1111. TemplateId: template_id,
  1112. UserOrgId: orgId,
  1113. Ctime: time.Now().Unix(),
  1114. Status: 1,
  1115. }
  1116. err := service.UpdateChargePrintTemplate(&template)
  1117. if err != nil {
  1118. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1119. return
  1120. }
  1121. this.ServeSuccessJSON(map[string]interface{}{
  1122. "template": template,
  1123. "template_id": template_id,
  1124. })
  1125. }
  1126. }
  1127. func (this *HisProjectApiController) GetChargePrintTemplate() {
  1128. adminUserInfo := this.GetAdminUserInfo()
  1129. orgId := adminUserInfo.CurrentOrgId
  1130. template, err := service.GetChargePrintTemplate(orgId)
  1131. if err != nil {
  1132. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1133. return
  1134. }
  1135. this.ServeSuccessJSON(map[string]interface{}{
  1136. "template": template,
  1137. })
  1138. }
  1139. func (this *HisProjectApiController) GetAllHisPatient() {
  1140. record_date := this.GetString("record_date")
  1141. timeLayout := "2006-01-02"
  1142. loc, _ := time.LoadLocation("Local")
  1143. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1144. recordDateTime := theTime.Unix()
  1145. adminUserInfo := this.GetAdminUserInfo()
  1146. patients, err := service.GetHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime)
  1147. if err != nil {
  1148. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1149. return
  1150. }
  1151. this.ServeSuccessJSON(map[string]interface{}{
  1152. "list": patients,
  1153. })
  1154. }
  1155. func (this *HisProjectApiController) GetChargePrint() {
  1156. record_date := this.GetString("record_date")
  1157. timeLayout := "2006-01-02"
  1158. loc, _ := time.LoadLocation("Local")
  1159. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1160. recordDateTime := theTime.Unix()
  1161. patient_id, _ := this.GetInt64("patient_id")
  1162. prescription_id, _ := this.GetInt64("prescription_id")
  1163. adminUserInfo := this.GetAdminUserInfo()
  1164. chargePrint, err := service.GetChargePrint(recordDateTime, patient_id, adminUserInfo.CurrentOrgId)
  1165. prescription, err := service.GetHisPrescriptionNight(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, prescription_id)
  1166. patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, patient_id)
  1167. if err != nil {
  1168. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1169. return
  1170. }
  1171. this.ServeSuccessJSON(map[string]interface{}{
  1172. "list": chargePrint,
  1173. "prescription": prescription,
  1174. "patient": patient,
  1175. })
  1176. }
  1177. func (this *HisProjectApiController) GetTodaySchedulePatient() {
  1178. adminUserInfo := this.GetAdminUserInfo()
  1179. orgId := adminUserInfo.CurrentOrgId
  1180. recordDateStr := time.Now().Format("2006-01-02")
  1181. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1182. scheduleDate := recordDate.Unix()
  1183. patient, err := service.GetTodaySchedulePatient(orgId, scheduleDate)
  1184. if err != nil {
  1185. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1186. return
  1187. }
  1188. this.ServeSuccessJSON(map[string]interface{}{
  1189. "patient": patient,
  1190. })
  1191. }
  1192. func (this *HisProjectApiController) GetHisPatientDetail() {
  1193. patient_id, _ := this.GetInt64("patient_id")
  1194. hisPatient, err := service.GetHisPatientById(patient_id)
  1195. if err != nil {
  1196. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1197. return
  1198. }
  1199. this.ServeSuccessJSON(map[string]interface{}{
  1200. "hisPatient": hisPatient,
  1201. })
  1202. }
  1203. func (this *HisProjectApiController) GetAllDepartmentList() {
  1204. adminUserInfo := this.GetAdminUserInfo()
  1205. orgId := adminUserInfo.CurrentOrgId
  1206. departMent, err := service.GetAllDepartMent(orgId)
  1207. if err != nil {
  1208. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1209. return
  1210. }
  1211. this.ServeSuccessJSON(map[string]interface{}{
  1212. "departMent": departMent,
  1213. })
  1214. }
  1215. func (this *HisProjectApiController) GetPrescription() {
  1216. patient_id, _ := this.GetInt64("patient_id")
  1217. fmt.Println("patient_id", patient_id)
  1218. timeStr := time.Now().Format("2006-01-02")
  1219. timeLayout := "2006-01-02 15:04:05"
  1220. fmt.Println("timeStr:", timeStr)
  1221. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  1222. timenow := timeStringToTime.Unix()
  1223. list, err := service.GetPrescriptionByPatientId(patient_id, timenow)
  1224. if err != nil {
  1225. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1226. return
  1227. }
  1228. this.ServeSuccessJSON(map[string]interface{}{
  1229. "list": list,
  1230. })
  1231. }