his_project_api_controller.go 49KB

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