his_project_api_controller.go 55KB

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