his_project_api_controller.go 48KB

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