his_project_api_controller.go 57KB

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