his_project_api_controller.go 58KB

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