his_project_api_controller.go 49KB

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