his_project_api_controller.go 58KB

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