his_project_api_controller.go 50KB

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