his_project_api_controller.go 60KB

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