his_project_api_controller.go 57KB

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