his_project_api_controller.go 49KB

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