his_project_api_controller.go 59KB

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