his_project_api_controller.go 56KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726
  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. _, config := service.FindHisStockPriceRecordByOrgId(orgId)
  741. if config.ID > 0 && config.IsOpen == 1 {
  742. //处理耗材不同批号价格问题
  743. for _, item := range good_info {
  744. if len(item.GoodSotckInfo) > 0 {
  745. if item.GoodSotckInfo[0].Price > 0 {
  746. item.PackingPrice = item.GoodSotckInfo[0].Price
  747. }
  748. }
  749. }
  750. }
  751. if err != nil {
  752. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  753. return
  754. }
  755. this.ServeSuccessJSON(map[string]interface{}{
  756. "project": project,
  757. "good_info": good_info,
  758. })
  759. }
  760. func (this *HisProjectApiController) GetProjectTeam() {
  761. strids := this.GetString("strids")
  762. idStrs := strings.Split(strids, ",")
  763. adminUserInfo := this.GetAdminUserInfo()
  764. orgId := adminUserInfo.CurrentOrgId
  765. team, err := service.GetProjectTeam(idStrs, orgId)
  766. if err != nil {
  767. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  768. return
  769. }
  770. this.ServeSuccessJSON(map[string]interface{}{
  771. "team": team,
  772. })
  773. }
  774. func (this *HisProjectApiController) GetAllDoctorList() {
  775. adminUserInfo := this.GetAdminUserInfo()
  776. orgId := adminUserInfo.CurrentOrgId
  777. appId := adminUserInfo.CurrentAppId
  778. //获取所有的医生
  779. doctor, err := service.GetAllDoctor(orgId, appId)
  780. //获取所有的科室
  781. department, err := service.GetAllDepartMent(orgId)
  782. if err != nil {
  783. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  784. return
  785. }
  786. this.ServeSuccessJSON(map[string]interface{}{
  787. "doctor": doctor,
  788. "department": department,
  789. })
  790. }
  791. func (this *HisProjectApiController) SaveHisPatient() {
  792. timeLayout := "2006-01-02"
  793. loc, _ := time.LoadLocation("Local")
  794. age, _ := this.GetInt64("age")
  795. birthday := this.GetString("birthday")
  796. patient_id, _ := this.GetInt64("id")
  797. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  798. birthUnix := birthdays.Unix()
  799. certificates, _ := this.GetInt64("certificates")
  800. cost_checked, _ := this.GetInt64("costChecked")
  801. cost, _ := this.GetInt64("cost")
  802. costs := strconv.FormatInt(cost, 10)
  803. cost_float, _ := strconv.ParseFloat(costs, 64)
  804. department, _ := this.GetInt64("department")
  805. doctor, _ := this.GetInt64("doctor")
  806. medicalcare, _ := this.GetInt64("medical_care")
  807. idcard := this.GetString("id_card")
  808. medicalExpenses, _ := this.GetInt64("medical_expenses")
  809. medicalExpense := strconv.FormatInt(medicalExpenses, 10)
  810. medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
  811. medicalinsurancecard := this.GetString("medical_insurance_card")
  812. name := this.GetString("name")
  813. register, _ := this.GetInt64("register")
  814. registrationfee, _ := this.GetInt64("registration_fee")
  815. registrationfees := strconv.FormatInt(registrationfee, 10)
  816. registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
  817. settlementValue, _ := this.GetInt64("settlement_value")
  818. sex, _ := this.GetInt64("sex")
  819. total, _ := this.GetInt64("total")
  820. totals := strconv.FormatInt(total, 10)
  821. totals_float, _ := strconv.ParseFloat(totals, 64)
  822. adminUserInfo := this.GetAdminUserInfo()
  823. orgId := adminUserInfo.CurrentOrgId
  824. recordDateStr := time.Now().Format("2006-01-02")
  825. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  826. nowtime := recordDate.Unix()
  827. phone := this.GetString("phone")
  828. social_type, _ := this.GetInt64("social_type")
  829. id_card_type, _ := this.GetInt64("id_card_type")
  830. //diagnosis_id, _ := this.GetInt64("diagnosis")
  831. diagnosis_ids := this.GetString("diagnosis")
  832. sick_type, _ := this.GetInt64("sick_type")
  833. reg_type := this.GetString("p_type")
  834. tempPatient, _ := service.GetPatientByIDCardAndName(idcard, adminUserInfo.CurrentOrgId, name)
  835. if tempPatient.ID == 0 {
  836. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoBloodPatientException)
  837. return
  838. }
  839. var patient service.Patients
  840. if patient_id == 0 {
  841. patient, _ = service.GetPatientByIDCard(idcard, adminUserInfo.CurrentOrgId)
  842. } else {
  843. patient, _ = service.GetPatientByIDTwo(adminUserInfo.CurrentOrgId, patient_id)
  844. }
  845. if patient.ID == 0 {
  846. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  847. return
  848. }
  849. if len(patient.IdCardNo) == 0 {
  850. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  851. return
  852. }
  853. timeStr := time.Now().Format("2006-01-02 15:04:05")
  854. fmt.Println(timeStr)
  855. timeArr := strings.Split(timeStr, " ")
  856. timeArrTwo := strings.Split(timeArr[0], "-")
  857. timeArrThree := strings.Split(timeArr[1], ":")
  858. var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(patient.ID, 10)
  859. //his, _ := service.GetHisPatientInfoTwo(adminUserInfo.CurrentOrgId, patient.ID, recordDate.Unix())
  860. //if len(his) >= 1 {
  861. // order, _ := service.GetNewHisOrderTwo(adminUserInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDate.Unix())
  862. // if len(his) >= 1 && order.ID == 0 {
  863. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  864. // return
  865. // }
  866. //}
  867. var hisPatient models.XtHisPatient
  868. //if err == gorm.ErrRecordNotFound || his.ID == 0 {
  869. hisPatient = models.XtHisPatient{
  870. PatientId: patient_id,
  871. Birthday: birthUnix,
  872. IdType: certificates,
  873. CostOfProduction: cost_float,
  874. Departments: department,
  875. Doctor: doctor,
  876. AdminUserId: adminUserInfo.AdminUser.Id,
  877. MedicalTreatmentType: medicalcare,
  878. IdCardNo: idcard,
  879. IsNeedCostOfProduction: cost_checked,
  880. TreatmentCost: medicalExpense_float,
  881. MedicalInsuranceNumber: medicalinsurancecard,
  882. Name: name,
  883. Age: age,
  884. Number: str,
  885. RegisterType: register,
  886. RegisterCost: registrationfees_float,
  887. BalanceAccountsType: settlementValue,
  888. Gender: sex,
  889. Total: totals_float,
  890. UserOrgId: orgId,
  891. Status: 1,
  892. RecordDate: nowtime,
  893. IsReturn: 1,
  894. Ctime: time.Now().Unix(),
  895. Phone: phone,
  896. SocialType: social_type,
  897. IdCardType: id_card_type,
  898. Diagnosis: diagnosis_ids,
  899. PType: reg_type,
  900. SickType: sick_type,
  901. }
  902. service.CreateHisPatient(&hisPatient)
  903. this.ServeSuccessJSON(map[string]interface{}{
  904. "his_info": hisPatient,
  905. })
  906. //}
  907. //else {
  908. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisRegisterException)
  909. // return
  910. //}
  911. }
  912. func (this *HisProjectApiController) GetAllProjectTeam() {
  913. adminUserInfo := this.GetAdminUserInfo()
  914. orgId := adminUserInfo.CurrentOrgId
  915. team, err := service.GetAllProjectTeam(orgId)
  916. if err != nil {
  917. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  918. return
  919. }
  920. this.ServeSuccessJSON(map[string]interface{}{
  921. "team": team,
  922. })
  923. }
  924. func (this *HisProjectApiController) GetProjectListById() {
  925. adminUserInfo := this.GetAdminUserInfo()
  926. orgId := adminUserInfo.CurrentOrgId
  927. project_id := this.GetString("project_id")
  928. idStrs := strings.Split(project_id, ",")
  929. project, err := service.GetProjectListById(orgId, idStrs)
  930. if err != nil {
  931. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  932. return
  933. }
  934. this.ServeSuccessJSON(map[string]interface{}{
  935. "project": project,
  936. })
  937. }
  938. func (this *HisProjectApiController) GetHisPatientHistory() {
  939. timeLayout := "2006-01-02"
  940. loc, _ := time.LoadLocation("Local")
  941. keyword := this.GetString("keyword")
  942. start_time := this.GetString("start_time")
  943. end_time := this.GetString("end_time")
  944. register_type, _ := this.GetInt64("register_type")
  945. limit, _ := this.GetInt64("limit")
  946. page, _ := this.GetInt64("page")
  947. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+":00", loc)
  948. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+":59", loc)
  949. adminUserInfo := this.GetAdminUserInfo()
  950. orgId := adminUserInfo.CurrentOrgId
  951. history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
  952. department, err := service.GetAllDepartMent(orgId)
  953. appId := adminUserInfo.CurrentAppId
  954. doctor, err := service.GetAllDoctor(orgId, appId)
  955. if err != nil {
  956. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  957. return
  958. }
  959. this.ServeSuccessJSON(map[string]interface{}{
  960. "history": history,
  961. "total": total,
  962. "department": department,
  963. "doctor": doctor,
  964. })
  965. }
  966. func (this *HisProjectApiController) ChangePatient() {
  967. id, _ := this.GetInt64("id")
  968. //查询该患者今日是否已经就诊
  969. recordDateStr := time.Now().Format("2006-01-02")
  970. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  971. nowtime := recordDate.Unix()
  972. adminUserInfo := this.GetAdminUserInfo()
  973. orgId := adminUserInfo.CurrentOrgId
  974. _, errcode := service.GetHisPrescriptionTwo(id, orgId, nowtime)
  975. if errcode == gorm.ErrRecordNotFound {
  976. err := service.ChangePatient(id)
  977. if err != nil {
  978. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  979. return
  980. }
  981. returnData := make(map[string]interface{}, 0)
  982. returnData["msg"] = "ok"
  983. this.ServeSuccessJSON(returnData)
  984. return
  985. } else if errcode == nil {
  986. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  987. return
  988. }
  989. }
  990. func (this *HisProjectApiController) GetPatientcaseHistory() {
  991. patient_id, _ := this.GetInt64("patient_id")
  992. patient, err := service.GetBloodPatientInfoById(patient_id)
  993. history, _ := service.GetPatientCaseHistory(patient_id)
  994. hispatient, _ := service.GetHisPatientById(patient_id)
  995. if err != nil {
  996. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  997. return
  998. }
  999. this.ServeSuccessJSON(map[string]interface{}{
  1000. "patient": patient,
  1001. "history": history,
  1002. "hispatient": hispatient,
  1003. })
  1004. }
  1005. func (this *HisProjectApiController) GetTemplateDetail() {
  1006. id, _ := this.GetInt64("id")
  1007. templateDetail, err := service.GetTemplateDetail(id)
  1008. if err != nil {
  1009. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1010. return
  1011. }
  1012. this.ServeSuccessJSON(map[string]interface{}{
  1013. "templateDetail": templateDetail,
  1014. })
  1015. }
  1016. func (this *HisProjectApiController) UpdateRecordTemplate() {
  1017. id, _ := this.GetInt64("id")
  1018. template_name := this.GetString("template_name")
  1019. template_remark := this.GetString("template_remark")
  1020. diagnostic := this.GetString("diagnostic")
  1021. chief_conplaint := this.GetString("chief_conplaint")
  1022. history_of_present_illness := this.GetString("history_of_present_illness")
  1023. past_history := this.GetString("past_history")
  1024. personal_history := this.GetString("personal_history")
  1025. family_history := this.GetString("family_history")
  1026. doctor_advice := this.GetString("doctor_advice")
  1027. remark := this.GetString("remark")
  1028. adminUserInfo := this.GetAdminUserInfo()
  1029. creater := adminUserInfo.AdminUser.Id
  1030. historyTemplate := models.HisCaseHistoryTemplate{
  1031. HistoryOfPresentIllness: history_of_present_illness,
  1032. PastHistory: past_history,
  1033. ChiefConplaint: chief_conplaint,
  1034. PersonalHistory: personal_history,
  1035. FamilyHistory: family_history,
  1036. Diagnostic: diagnostic,
  1037. Status: 1,
  1038. Mtime: time.Now().Unix(),
  1039. RecordDate: time.Now().Unix(),
  1040. TemplateName: template_name,
  1041. TemplateRemark: template_remark,
  1042. Modifier: creater,
  1043. DoctorAdvice: doctor_advice,
  1044. Remark: remark,
  1045. }
  1046. err := service.UpdateCaseHistoryTemplate(&historyTemplate, id)
  1047. if err != nil {
  1048. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1049. return
  1050. }
  1051. this.ServeSuccessJSON(map[string]interface{}{
  1052. "templateDetail": historyTemplate,
  1053. })
  1054. }
  1055. func (this *HisProjectApiController) GetHisPatient() {
  1056. adminUserInfo := this.GetAdminUserInfo()
  1057. orgId := adminUserInfo.CurrentOrgId
  1058. keyword := this.GetString("keyword")
  1059. patient, err := service.GetHistPatient(orgId, keyword)
  1060. if err != nil {
  1061. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1062. return
  1063. }
  1064. this.ServeSuccessJSON(map[string]interface{}{
  1065. "patient": patient,
  1066. })
  1067. }
  1068. func (this *HisProjectApiController) GetDoctorAdvicePrint() {
  1069. patient_id, _ := this.GetInt64("patient_id")
  1070. his_patient_id, _ := this.GetInt64("his_patient_id")
  1071. record_date := this.GetString("record_date")
  1072. schIDStr := this.GetString("ids")
  1073. p_type, _ := this.GetInt64("p_type")
  1074. if len(schIDStr) == 0 {
  1075. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1076. return
  1077. }
  1078. idStrs := strings.Split(schIDStr, ",")
  1079. timeLayout := "2006-01-02"
  1080. loc, _ := time.LoadLocation("Local")
  1081. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1082. recordDateTime := theTime.Unix()
  1083. //prescription_id, _ := this.GetInt64("prescription_id")
  1084. adminUserInfo := this.GetAdminUserInfo()
  1085. var temp_p_type int64
  1086. if p_type == 1 {
  1087. temp_p_type = 1
  1088. } else {
  1089. temp_p_type = 2
  1090. }
  1091. advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId, temp_p_type)
  1092. projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId, "")
  1093. his, _ := service.GetLastHisPatient(patient_id, adminUserInfo.CurrentOrgId)
  1094. prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
  1095. //advicePrint, err := service.GetPre(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId, temp_p_type)
  1096. hisPatient, _ := service.GetHisPatientInfoFour(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, his_patient_id)
  1097. //hisPatient, _ := service.GetHisPatientById(patient_id)
  1098. hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
  1099. eles, _ := service.GetNewAdminUserES(adminUserInfo.CurrentOrgId)
  1100. if err != nil {
  1101. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1102. return
  1103. }
  1104. this.ServeSuccessJSON(map[string]interface{}{
  1105. "advicePrint": advicePrint,
  1106. "projectlist": projectlist,
  1107. "hisPatient": hisPatient,
  1108. "his": his,
  1109. "hisHospitalRecord": hisHospitalRecord,
  1110. "info": prescriptionInfo,
  1111. "eles": eles,
  1112. })
  1113. }
  1114. func (this *HisProjectApiController) GetProjectPrint() {
  1115. his_patient_id, _ := this.GetInt64("his_patient_id")
  1116. hisPatient, _ := service.GetHisPatientById(his_patient_id)
  1117. projectPrint, err := service.GetProjectPrint(his_patient_id)
  1118. if err != nil {
  1119. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1120. return
  1121. }
  1122. this.ServeSuccessJSON(map[string]interface{}{
  1123. "hisPatient": hisPatient,
  1124. "projectPrint": projectPrint,
  1125. })
  1126. }
  1127. func (this *HisProjectApiController) PostPrintHisTemplate() {
  1128. template_id, _ := this.GetInt64("template_id")
  1129. adminUserInfo := this.GetAdminUserInfo()
  1130. orgId := adminUserInfo.CurrentOrgId
  1131. _, errcode := service.GetHisTemplateId(template_id, orgId)
  1132. //fmt.Println("errcode", errcode)
  1133. if errcode == gorm.ErrRecordNotFound {
  1134. template := models.XtHisTemplate{
  1135. TemplateId: template_id,
  1136. UserOrgId: orgId,
  1137. Status: 1,
  1138. Ctime: time.Now().Unix(),
  1139. }
  1140. err := service.CreateHisTemplate(&template)
  1141. if err != nil {
  1142. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1143. return
  1144. }
  1145. this.ServeSuccessJSON(map[string]interface{}{
  1146. "template": template,
  1147. "template_id": template_id,
  1148. })
  1149. } else if errcode == nil {
  1150. template := models.XtHisTemplate{
  1151. TemplateId: template_id,
  1152. UserOrgId: orgId,
  1153. Status: 1,
  1154. Ctime: time.Now().Unix(),
  1155. Mtime: time.Now().Unix(),
  1156. }
  1157. err := service.UpdateHisTemplate(&template)
  1158. if err != nil {
  1159. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1160. return
  1161. }
  1162. this.ServeSuccessJSON(map[string]interface{}{
  1163. "template": template,
  1164. "template_id": template_id,
  1165. })
  1166. }
  1167. }
  1168. func (this *HisProjectApiController) GetHisPrintTemplate() {
  1169. adminUserInfo := this.GetAdminUserInfo()
  1170. orgId := adminUserInfo.CurrentOrgId
  1171. template, err := service.GetHisPrintTemplate(orgId)
  1172. if err != nil {
  1173. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1174. return
  1175. }
  1176. this.ServeSuccessJSON(map[string]interface{}{
  1177. "template": template,
  1178. })
  1179. }
  1180. func (this *HisProjectApiController) PostPrescriptionTempalte() {
  1181. template_id, _ := this.GetInt64("template_id")
  1182. adminUserInfo := this.GetAdminUserInfo()
  1183. orgId := adminUserInfo.CurrentOrgId
  1184. _, errcode := service.GetPrescriptionTemplate(template_id, orgId)
  1185. if errcode == gorm.ErrRecordNotFound {
  1186. template := models.XtHisAdviceTemplate{
  1187. TemplateId: template_id,
  1188. UserOrgId: orgId,
  1189. Status: 1,
  1190. Ctime: time.Now().Unix(),
  1191. }
  1192. err := service.CreatePrescriptionTemplate(&template)
  1193. if err != nil {
  1194. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1195. return
  1196. }
  1197. this.ServeSuccessJSON(map[string]interface{}{
  1198. "template": template,
  1199. "template_id": template_id,
  1200. })
  1201. } else if errcode == nil {
  1202. template := models.XtHisAdviceTemplate{
  1203. TemplateId: template_id,
  1204. UserOrgId: orgId,
  1205. Status: 1,
  1206. Ctime: time.Now().Unix(),
  1207. }
  1208. err := service.UpdatePrescriptionTemplate(&template)
  1209. if err != nil {
  1210. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1211. return
  1212. }
  1213. this.ServeSuccessJSON(map[string]interface{}{
  1214. "template": template,
  1215. "template_id": template_id,
  1216. })
  1217. }
  1218. }
  1219. func (this *HisProjectApiController) GetPrescriptionTemplate() {
  1220. adminUserInfo := this.GetAdminUserInfo()
  1221. orgId := adminUserInfo.CurrentOrgId
  1222. template, err := service.GetPrescriptionTemplateById(orgId)
  1223. if err != nil {
  1224. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1225. return
  1226. }
  1227. this.ServeSuccessJSON(map[string]interface{}{
  1228. "template": template,
  1229. })
  1230. }
  1231. func (this *HisProjectApiController) PostTreatPrintTemplate() {
  1232. template_id, _ := this.GetInt64("template_id")
  1233. adminUserInfo := this.GetAdminUserInfo()
  1234. orgId := adminUserInfo.CurrentOrgId
  1235. _, errcode := service.GetTreatPrintTemplate(template_id, orgId)
  1236. if errcode == gorm.ErrRecordNotFound {
  1237. template := models.XtHisTreatmentTemplate{
  1238. TemplateId: template_id,
  1239. UserOrgId: orgId,
  1240. Status: 1,
  1241. Ctime: time.Now().Unix(),
  1242. }
  1243. err := service.CreateTreatPrintTemplate(&template)
  1244. if err != nil {
  1245. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1246. return
  1247. }
  1248. this.ServeSuccessJSON(map[string]interface{}{
  1249. "template": template,
  1250. "template_id": template_id,
  1251. })
  1252. } else if errcode == nil {
  1253. template := models.XtHisTreatmentTemplate{
  1254. TemplateId: template_id,
  1255. UserOrgId: orgId,
  1256. Status: 1,
  1257. Ctime: time.Now().Unix(),
  1258. }
  1259. err := service.UpdatedTreateTemplate(&template)
  1260. if err != nil {
  1261. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1262. return
  1263. }
  1264. this.ServeSuccessJSON(map[string]interface{}{
  1265. "template": template,
  1266. "template_id": template_id,
  1267. })
  1268. }
  1269. }
  1270. func (this *HisProjectApiController) GetTreatPrintTemplate() {
  1271. adminUserInfo := this.GetAdminUserInfo()
  1272. orgId := adminUserInfo.CurrentOrgId
  1273. template, err := service.GetTreatTtreatPrintTemplate(orgId)
  1274. if err != nil {
  1275. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1276. return
  1277. }
  1278. this.ServeSuccessJSON(map[string]interface{}{
  1279. "template": template,
  1280. })
  1281. }
  1282. func (this *HisProjectApiController) PostChargePrintTemplate() {
  1283. template_id, _ := this.GetInt64("template_id")
  1284. adminUserInfo := this.GetAdminUserInfo()
  1285. orgId := adminUserInfo.CurrentOrgId
  1286. _, errcode := service.GetChargeTemplate(template_id, orgId)
  1287. if errcode == gorm.ErrRecordNotFound {
  1288. template := models.XtHisChargeTemplate{
  1289. TemplateId: template_id,
  1290. UserOrgId: orgId,
  1291. Ctime: time.Now().Unix(),
  1292. Status: 1,
  1293. }
  1294. err := service.CreateChargePrintTemplate(&template)
  1295. if err != nil {
  1296. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1297. return
  1298. }
  1299. this.ServeSuccessJSON(map[string]interface{}{
  1300. "template": template,
  1301. "template_id": template_id,
  1302. })
  1303. } else if errcode == nil {
  1304. template := models.XtHisChargeTemplate{
  1305. TemplateId: template_id,
  1306. UserOrgId: orgId,
  1307. Ctime: time.Now().Unix(),
  1308. Status: 1,
  1309. }
  1310. err := service.UpdateChargePrintTemplate(&template)
  1311. if err != nil {
  1312. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1313. return
  1314. }
  1315. this.ServeSuccessJSON(map[string]interface{}{
  1316. "template": template,
  1317. "template_id": template_id,
  1318. })
  1319. }
  1320. }
  1321. func (this *HisProjectApiController) GetChargePrintTemplate() {
  1322. adminUserInfo := this.GetAdminUserInfo()
  1323. orgId := adminUserInfo.CurrentOrgId
  1324. template, err := service.GetChargePrintTemplate(orgId)
  1325. if err != nil {
  1326. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1327. return
  1328. }
  1329. this.ServeSuccessJSON(map[string]interface{}{
  1330. "template": template,
  1331. })
  1332. }
  1333. func (this *HisProjectApiController) GetAllHisPatient() {
  1334. record_date := this.GetString("record_date")
  1335. timeLayout := "2006-01-02"
  1336. loc, _ := time.LoadLocation("Local")
  1337. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1338. recordDateTime := theTime.Unix()
  1339. adminUserInfo := this.GetAdminUserInfo()
  1340. patients, err := service.GetScheduleHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime, 0)
  1341. if err != nil {
  1342. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1343. return
  1344. }
  1345. this.ServeSuccessJSON(map[string]interface{}{
  1346. "list": patients,
  1347. })
  1348. }
  1349. func (this *HisProjectApiController) GetChargePrint() {
  1350. record_date := this.GetString("record_date")
  1351. timeLayout := "2006-01-02"
  1352. loc, _ := time.LoadLocation("Local")
  1353. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1354. recordDateTime := theTime.Unix()
  1355. patient_id, _ := this.GetInt64("patient_id")
  1356. prescription_id, _ := this.GetInt64("prescription_id")
  1357. adminUserInfo := this.GetAdminUserInfo()
  1358. chargePrint, err := service.GetChargePrint(recordDateTime, patient_id, adminUserInfo.CurrentOrgId)
  1359. prescription, err := service.GetHisPrescriptionNight(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, prescription_id)
  1360. patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, patient_id)
  1361. hisPatient, err := service.GetHisPatientById(patient_id)
  1362. if err != nil {
  1363. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1364. return
  1365. }
  1366. this.ServeSuccessJSON(map[string]interface{}{
  1367. "list": chargePrint,
  1368. "prescription": prescription,
  1369. "patient": patient,
  1370. "hisPatient": hisPatient,
  1371. })
  1372. }
  1373. func (this *HisProjectApiController) GetTodaySchedulePatient() {
  1374. adminUserInfo := this.GetAdminUserInfo()
  1375. orgId := adminUserInfo.CurrentOrgId
  1376. recordDateStr := time.Now().Format("2006-01-02")
  1377. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1378. scheduleDate := recordDate.Unix()
  1379. patient, err := service.GetTodaySchedulePatient(orgId, scheduleDate)
  1380. if err != nil {
  1381. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1382. return
  1383. }
  1384. this.ServeSuccessJSON(map[string]interface{}{
  1385. "patient": patient,
  1386. })
  1387. }
  1388. func (this *HisProjectApiController) GetHisPatientDetail() {
  1389. patient_id, _ := this.GetInt64("patient_id")
  1390. hisPatient, _ := service.GetHisPatientByIdFour(patient_id)
  1391. //service.GetLastHospitalRecordTwo(patient_id,this.GetAdminUserInfo().CurrentOrgId)
  1392. hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, this.GetAdminUserInfo().CurrentOrgId)
  1393. this.ServeSuccessJSON(map[string]interface{}{
  1394. "hisPatient": hisPatient,
  1395. "hisHospitalRecord": hisHospitalRecord,
  1396. })
  1397. }
  1398. func (this *HisProjectApiController) GetAllDepartmentList() {
  1399. adminUserInfo := this.GetAdminUserInfo()
  1400. orgId := adminUserInfo.CurrentOrgId
  1401. departMent, err := service.GetAllDepartMent(orgId)
  1402. if err != nil {
  1403. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1404. return
  1405. }
  1406. this.ServeSuccessJSON(map[string]interface{}{
  1407. "departMent": departMent,
  1408. })
  1409. }
  1410. func (this *HisProjectApiController) GetPrescription() {
  1411. patient_id, _ := this.GetInt64("patient_id")
  1412. p_type, _ := this.GetInt64("p_type")
  1413. record_date := this.GetString("record_date")
  1414. timeLayout := "2006-01-02"
  1415. loc, _ := time.LoadLocation("Local")
  1416. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1417. if err != nil {
  1418. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1419. return
  1420. }
  1421. recordDateTime := theTime.Unix()
  1422. list, err := service.GetPrescriptionByPatientId(patient_id, recordDateTime, p_type)
  1423. if err != nil {
  1424. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1425. return
  1426. }
  1427. this.ServeSuccessJSON(map[string]interface{}{
  1428. "list": list,
  1429. })
  1430. }
  1431. func (this *HisProjectApiController) GetPatientDetail() {
  1432. id, _ := this.GetInt64("id")
  1433. adminUserInfo := this.GetAdminUserInfo()
  1434. patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, id)
  1435. if err != nil {
  1436. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1437. return
  1438. }
  1439. this.ServeSuccessJSON(map[string]interface{}{
  1440. "patient": patient,
  1441. })
  1442. }
  1443. func (this *HisProjectApiController) SaveMainTemplate() {
  1444. title := this.GetString("title")
  1445. content := this.GetString("content")
  1446. remark := this.GetString("remark")
  1447. template_id, _ := this.GetInt64("template_id")
  1448. adminUserInfo := this.GetAdminUserInfo()
  1449. orgId := adminUserInfo.CurrentOrgId
  1450. template := models.XtHisMedicalTemplate{
  1451. Title: title,
  1452. Content: content,
  1453. Remark: remark,
  1454. UserOrgId: orgId,
  1455. TemplateId: template_id,
  1456. Status: 1,
  1457. Ctime: time.Now().Unix(),
  1458. }
  1459. err := service.CreateHisMedicalTemplate(&template)
  1460. if err != nil {
  1461. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1462. return
  1463. }
  1464. this.ServeSuccessJSON(map[string]interface{}{
  1465. "template": template,
  1466. })
  1467. }
  1468. func (this *HisProjectApiController) GetMedicalTempalteList() {
  1469. adminUserInfo := this.GetAdminUserInfo()
  1470. orgId := adminUserInfo.CurrentOrgId
  1471. list, err := service.GetMedicalTemplateList(orgId)
  1472. listOne, err := service.GetMedicalTemplateListOne(orgId)
  1473. listTwo, err := service.GetMedicalTemplateListTwo(orgId)
  1474. listThree, err := service.GetMedicalTemplateListThree(orgId)
  1475. listFour, err := service.GetMedicalTemplateListFour(orgId)
  1476. listFive, err := service.GetMedicalTemplateListFive(orgId)
  1477. listSix, err := service.GetMedicalTemplateListSix(orgId)
  1478. listSeven, err := service.GetMedicalTemplateListSeven(orgId)
  1479. if err != nil {
  1480. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1481. return
  1482. }
  1483. this.ServeSuccessJSON(map[string]interface{}{
  1484. "list": list,
  1485. "listOne": listOne,
  1486. "listTwo": listTwo,
  1487. "listThree": listThree,
  1488. "listFour": listFour,
  1489. "listFive": listFive,
  1490. "listSix": listSix,
  1491. "listSeven": listSeven,
  1492. })
  1493. }
  1494. func (this *HisProjectApiController) GetMainTemplateById() {
  1495. id, _ := this.GetInt64("id")
  1496. template, err := service.GetMainTemplateById(id)
  1497. if err != nil {
  1498. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1499. return
  1500. }
  1501. this.ServeSuccessJSON(map[string]interface{}{
  1502. "template": template,
  1503. })
  1504. }
  1505. func (this *HisProjectApiController) UpdateMainTemplate() {
  1506. title := this.GetString("title")
  1507. content := this.GetString("content")
  1508. remark := this.GetString("remark")
  1509. id, _ := this.GetInt64("id")
  1510. template := models.XtHisMedicalTemplate{
  1511. Title: title,
  1512. Content: content,
  1513. Remark: remark,
  1514. }
  1515. err := service.UpdateMainTemplate(&template, id)
  1516. if err != nil {
  1517. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1518. return
  1519. }
  1520. this.ServeSuccessJSON(map[string]interface{}{
  1521. "template": template,
  1522. })
  1523. }
  1524. func (this *HisProjectApiController) DeleteMainTemplate() {
  1525. id, _ := this.GetInt64("id")
  1526. err := service.DeleteMainTemplateById(id)
  1527. if err != nil {
  1528. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1529. return
  1530. }
  1531. returnData := make(map[string]interface{}, 0)
  1532. returnData["msg"] = "ok"
  1533. this.ServeSuccessJSON(returnData)
  1534. return
  1535. }