his_project_api_controller.go 59KB

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