his_project_api_controller.go 54KB

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