his_project_api_controller.go 58KB

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