his_project_api_controller.go 57KB

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