his_project_api_controller.go 59KB

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