his_project_api_controller.go 46KB

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