his_project_api_controller.go 45KB

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