his_project_api_controller.go 59KB

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