his_project_api_controller.go 46KB

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