his_project_api_controller.go 56KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728
  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. project, err := service.GetHisProject(orgId)
  739. good_info, err := service.GetGoodInfoMation(orgId)
  740. _, config := service.FindHisStockPriceRecordByOrgId(orgId)
  741. if config.ID > 0 && config.IsOpen == 1 {
  742. //处理耗材不同批号价格问题
  743. for _, item := range good_info {
  744. if len(item.GoodSotckInfo) > 0 {
  745. if item.GoodSotckInfo[0].Price > 0 {
  746. item.PackingPrice = item.GoodSotckInfo[0].Price
  747. }
  748. }
  749. }
  750. }
  751. if err != nil {
  752. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  753. return
  754. }
  755. this.ServeSuccessJSON(map[string]interface{}{
  756. "project": project,
  757. "good_info": good_info,
  758. })
  759. }
  760. func (this *HisProjectApiController) GetProjectTeam() {
  761. strids := this.GetString("strids")
  762. idStrs := strings.Split(strids, ",")
  763. adminUserInfo := this.GetAdminUserInfo()
  764. orgId := adminUserInfo.CurrentOrgId
  765. team, err := service.GetProjectTeam(idStrs, orgId)
  766. if err != nil {
  767. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  768. return
  769. }
  770. this.ServeSuccessJSON(map[string]interface{}{
  771. "team": team,
  772. })
  773. }
  774. func (this *HisProjectApiController) GetAllDoctorList() {
  775. adminUserInfo := this.GetAdminUserInfo()
  776. orgId := adminUserInfo.CurrentOrgId
  777. appId := adminUserInfo.CurrentAppId
  778. //获取所有的医生
  779. doctor, err := service.GetAllDoctor(orgId, appId)
  780. //获取所有的科室
  781. department, err := service.GetAllDepartMent(orgId)
  782. if err != nil {
  783. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  784. return
  785. }
  786. this.ServeSuccessJSON(map[string]interface{}{
  787. "doctor": doctor,
  788. "department": department,
  789. })
  790. }
  791. func (this *HisProjectApiController) SaveHisPatient() {
  792. timeLayout := "2006-01-02"
  793. loc, _ := time.LoadLocation("Local")
  794. age, _ := this.GetInt64("age")
  795. birthday := this.GetString("birthday")
  796. patient_id, _ := this.GetInt64("id")
  797. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  798. birthUnix := birthdays.Unix()
  799. certificates, _ := this.GetInt64("certificates")
  800. cost_checked, _ := this.GetInt64("costChecked")
  801. cost, _ := this.GetInt64("cost")
  802. costs := strconv.FormatInt(cost, 10)
  803. cost_float, _ := strconv.ParseFloat(costs, 64)
  804. department, _ := this.GetInt64("department")
  805. doctor, _ := this.GetInt64("doctor")
  806. medicalcare, _ := this.GetInt64("medical_care")
  807. idcard := this.GetString("id_card")
  808. medicalExpenses, _ := this.GetInt64("medical_expenses")
  809. medicalExpense := strconv.FormatInt(medicalExpenses, 10)
  810. medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
  811. medicalinsurancecard := this.GetString("medical_insurance_card")
  812. name := this.GetString("name")
  813. register, _ := this.GetInt64("register")
  814. registrationfee, _ := this.GetInt64("registration_fee")
  815. registrationfees := strconv.FormatInt(registrationfee, 10)
  816. registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
  817. settlementValue, _ := this.GetInt64("settlement_value")
  818. sex, _ := this.GetInt64("sex")
  819. total, _ := this.GetInt64("total")
  820. totals := strconv.FormatInt(total, 10)
  821. totals_float, _ := strconv.ParseFloat(totals, 64)
  822. adminUserInfo := this.GetAdminUserInfo()
  823. orgId := adminUserInfo.CurrentOrgId
  824. recordDateStr := time.Now().Format("2006-01-02")
  825. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  826. nowtime := recordDate.Unix()
  827. phone := this.GetString("phone")
  828. social_type, _ := this.GetInt64("social_type")
  829. id_card_type, _ := this.GetInt64("id_card_type")
  830. //diagnosis_id, _ := this.GetInt64("diagnosis")
  831. diagnosis_ids := this.GetString("diagnosis")
  832. sick_type, _ := this.GetInt64("sick_type")
  833. reg_type := this.GetString("p_type")
  834. tempPatient, _ := service.GetPatientByIDCardAndName(idcard, adminUserInfo.CurrentOrgId, name)
  835. if tempPatient.ID == 0 {
  836. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoBloodPatientException)
  837. return
  838. }
  839. var patient service.Patients
  840. if patient_id == 0 {
  841. patient, _ = service.GetPatientByIDCard(idcard, adminUserInfo.CurrentOrgId)
  842. } else {
  843. patient, _ = service.GetPatientByIDTwo(adminUserInfo.CurrentOrgId, patient_id)
  844. }
  845. if patient.ID == 0 {
  846. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  847. return
  848. }
  849. if len(patient.IdCardNo) == 0 {
  850. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  851. return
  852. }
  853. timeStr := time.Now().Format("2006-01-02 15:04:05")
  854. fmt.Println(timeStr)
  855. timeArr := strings.Split(timeStr, " ")
  856. timeArrTwo := strings.Split(timeArr[0], "-")
  857. timeArrThree := strings.Split(timeArr[1], ":")
  858. var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(patient.ID, 10)
  859. //his, _ := service.GetHisPatientInfoTwo(adminUserInfo.CurrentOrgId, patient.ID, recordDate.Unix())
  860. //if len(his) >= 1 {
  861. // order, _ := service.GetNewHisOrderTwo(adminUserInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDate.Unix())
  862. // if len(his) >= 1 && order.ID == 0 {
  863. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  864. // return
  865. // }
  866. //}
  867. var hisPatient models.XtHisPatient
  868. //if err == gorm.ErrRecordNotFound || his.ID == 0 {
  869. hisPatient = models.XtHisPatient{
  870. PatientId: patient_id,
  871. Birthday: birthUnix,
  872. IdType: certificates,
  873. CostOfProduction: cost_float,
  874. Departments: department,
  875. Doctor: doctor,
  876. AdminUserId: adminUserInfo.AdminUser.Id,
  877. MedicalTreatmentType: medicalcare,
  878. IdCardNo: idcard,
  879. IsNeedCostOfProduction: cost_checked,
  880. TreatmentCost: medicalExpense_float,
  881. MedicalInsuranceNumber: medicalinsurancecard,
  882. Name: name,
  883. Age: age,
  884. Number: str,
  885. RegisterType: register,
  886. RegisterCost: registrationfees_float,
  887. BalanceAccountsType: settlementValue,
  888. Gender: sex,
  889. Total: totals_float,
  890. UserOrgId: orgId,
  891. Status: 1,
  892. RecordDate: nowtime,
  893. IsReturn: 1,
  894. Ctime: time.Now().Unix(),
  895. Phone: phone,
  896. SocialType: social_type,
  897. IdCardType: id_card_type,
  898. Diagnosis: diagnosis_ids,
  899. PType: reg_type,
  900. SickType: sick_type,
  901. }
  902. service.CreateHisPatient(&hisPatient)
  903. this.ServeSuccessJSON(map[string]interface{}{
  904. "his_info": hisPatient,
  905. })
  906. //}
  907. //else {
  908. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisRegisterException)
  909. // return
  910. //}
  911. }
  912. func (this *HisProjectApiController) GetAllProjectTeam() {
  913. adminUserInfo := this.GetAdminUserInfo()
  914. orgId := adminUserInfo.CurrentOrgId
  915. team, err := service.GetAllProjectTeam(orgId)
  916. if err != nil {
  917. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  918. return
  919. }
  920. this.ServeSuccessJSON(map[string]interface{}{
  921. "team": team,
  922. })
  923. }
  924. func (this *HisProjectApiController) GetProjectListById() {
  925. adminUserInfo := this.GetAdminUserInfo()
  926. orgId := adminUserInfo.CurrentOrgId
  927. project_id := this.GetString("project_id")
  928. idStrs := strings.Split(project_id, ",")
  929. project, err := service.GetProjectListById(orgId, idStrs)
  930. if err != nil {
  931. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  932. return
  933. }
  934. this.ServeSuccessJSON(map[string]interface{}{
  935. "project": project,
  936. })
  937. }
  938. func (this *HisProjectApiController) GetHisPatientHistory() {
  939. timeLayout := "2006-01-02"
  940. loc, _ := time.LoadLocation("Local")
  941. keyword := this.GetString("keyword")
  942. start_time := this.GetString("start_time")
  943. end_time := this.GetString("end_time")
  944. register_type, _ := this.GetInt64("register_type")
  945. limit, _ := this.GetInt64("limit")
  946. page, _ := this.GetInt64("page")
  947. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  948. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  949. adminUserInfo := this.GetAdminUserInfo()
  950. orgId := adminUserInfo.CurrentOrgId
  951. history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
  952. department, err := service.GetAllDepartMent(orgId)
  953. appId := adminUserInfo.CurrentAppId
  954. doctor, err := service.GetAllDoctor(orgId, appId)
  955. if err != nil {
  956. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  957. return
  958. }
  959. this.ServeSuccessJSON(map[string]interface{}{
  960. "history": history,
  961. "total": total,
  962. "department": department,
  963. "doctor": doctor,
  964. })
  965. }
  966. func (this *HisProjectApiController) ChangePatient() {
  967. id, _ := this.GetInt64("id")
  968. //查询该患者今日是否已经就诊
  969. recordDateStr := time.Now().Format("2006-01-02")
  970. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  971. nowtime := recordDate.Unix()
  972. adminUserInfo := this.GetAdminUserInfo()
  973. orgId := adminUserInfo.CurrentOrgId
  974. _, errcode := service.GetHisPrescriptionTwo(id, orgId, nowtime)
  975. if errcode == gorm.ErrRecordNotFound {
  976. err := service.ChangePatient(id)
  977. if err != nil {
  978. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  979. return
  980. }
  981. returnData := make(map[string]interface{}, 0)
  982. returnData["msg"] = "ok"
  983. this.ServeSuccessJSON(returnData)
  984. return
  985. } else if errcode == nil {
  986. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  987. return
  988. }
  989. }
  990. func (this *HisProjectApiController) GetPatientcaseHistory() {
  991. patient_id, _ := this.GetInt64("patient_id")
  992. patient, err := service.GetBloodPatientInfoById(patient_id)
  993. history, _ := service.GetPatientCaseHistory(patient_id)
  994. hispatient, _ := service.GetHisPatientById(patient_id)
  995. if err != nil {
  996. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  997. return
  998. }
  999. this.ServeSuccessJSON(map[string]interface{}{
  1000. "patient": patient,
  1001. "history": history,
  1002. "hispatient": hispatient,
  1003. })
  1004. }
  1005. func (this *HisProjectApiController) GetTemplateDetail() {
  1006. id, _ := this.GetInt64("id")
  1007. templateDetail, err := service.GetTemplateDetail(id)
  1008. if err != nil {
  1009. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1010. return
  1011. }
  1012. this.ServeSuccessJSON(map[string]interface{}{
  1013. "templateDetail": templateDetail,
  1014. })
  1015. }
  1016. func (this *HisProjectApiController) UpdateRecordTemplate() {
  1017. id, _ := this.GetInt64("id")
  1018. template_name := this.GetString("template_name")
  1019. template_remark := this.GetString("template_remark")
  1020. diagnostic := this.GetString("diagnostic")
  1021. chief_conplaint := this.GetString("chief_conplaint")
  1022. history_of_present_illness := this.GetString("history_of_present_illness")
  1023. past_history := this.GetString("past_history")
  1024. personal_history := this.GetString("personal_history")
  1025. family_history := this.GetString("family_history")
  1026. doctor_advice := this.GetString("doctor_advice")
  1027. remark := this.GetString("remark")
  1028. adminUserInfo := this.GetAdminUserInfo()
  1029. creater := adminUserInfo.AdminUser.Id
  1030. historyTemplate := models.HisCaseHistoryTemplate{
  1031. HistoryOfPresentIllness: history_of_present_illness,
  1032. PastHistory: past_history,
  1033. ChiefConplaint: chief_conplaint,
  1034. PersonalHistory: personal_history,
  1035. FamilyHistory: family_history,
  1036. Diagnostic: diagnostic,
  1037. Status: 1,
  1038. Mtime: time.Now().Unix(),
  1039. RecordDate: time.Now().Unix(),
  1040. TemplateName: template_name,
  1041. TemplateRemark: template_remark,
  1042. Modifier: creater,
  1043. DoctorAdvice: doctor_advice,
  1044. Remark: remark,
  1045. }
  1046. err := service.UpdateCaseHistoryTemplate(&historyTemplate, id)
  1047. if err != nil {
  1048. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1049. return
  1050. }
  1051. this.ServeSuccessJSON(map[string]interface{}{
  1052. "templateDetail": historyTemplate,
  1053. })
  1054. }
  1055. func (this *HisProjectApiController) GetHisPatient() {
  1056. adminUserInfo := this.GetAdminUserInfo()
  1057. orgId := adminUserInfo.CurrentOrgId
  1058. keyword := this.GetString("keyword")
  1059. patient, err := service.GetHistPatient(orgId, keyword)
  1060. if err != nil {
  1061. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1062. return
  1063. }
  1064. this.ServeSuccessJSON(map[string]interface{}{
  1065. "patient": patient,
  1066. })
  1067. }
  1068. func (this *HisProjectApiController) GetDoctorAdvicePrint() {
  1069. patient_id, _ := this.GetInt64("patient_id")
  1070. record_date := this.GetString("record_date")
  1071. schIDStr := this.GetString("ids")
  1072. p_type, _ := this.GetInt64("p_type")
  1073. if len(schIDStr) == 0 {
  1074. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1075. return
  1076. }
  1077. idStrs := strings.Split(schIDStr, ",")
  1078. timeLayout := "2006-01-02"
  1079. loc, _ := time.LoadLocation("Local")
  1080. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1081. recordDateTime := theTime.Unix()
  1082. //prescription_id, _ := this.GetInt64("prescription_id")
  1083. adminUserInfo := this.GetAdminUserInfo()
  1084. var temp_p_type int64
  1085. if p_type == 1 {
  1086. temp_p_type = 1
  1087. } else {
  1088. temp_p_type = 2
  1089. }
  1090. advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId, temp_p_type)
  1091. projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId, "")
  1092. his, _ := service.GetLastHisPatient(patient_id, adminUserInfo.CurrentOrgId)
  1093. prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
  1094. //advicePrint, err := service.GetPre(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId, temp_p_type)
  1095. hisPatient, _ := service.GetHisPatientInfo(adminUserInfo.CurrentOrgId, patient_id, recordDateTime)
  1096. //hisPatient, _ := service.GetHisPatientById(patient_id)
  1097. hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
  1098. eles, _ := service.GetNewAdminUserES(adminUserInfo.CurrentOrgId)
  1099. if err != nil {
  1100. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1101. return
  1102. }
  1103. this.ServeSuccessJSON(map[string]interface{}{
  1104. "advicePrint": advicePrint,
  1105. "projectlist": projectlist,
  1106. "hisPatient": hisPatient,
  1107. "his": his,
  1108. "hisHospitalRecord": hisHospitalRecord,
  1109. "info": prescriptionInfo,
  1110. "eles": eles,
  1111. })
  1112. }
  1113. func (this *HisProjectApiController) GetProjectPrint() {
  1114. his_patient_id, _ := this.GetInt64("his_patient_id")
  1115. hisPatient, _ := service.GetHisPatientById(his_patient_id)
  1116. projectPrint, err := service.GetProjectPrint(his_patient_id)
  1117. if err != nil {
  1118. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1119. return
  1120. }
  1121. this.ServeSuccessJSON(map[string]interface{}{
  1122. "hisPatient": hisPatient,
  1123. "projectPrint": projectPrint,
  1124. })
  1125. }
  1126. func (this *HisProjectApiController) PostPrintHisTemplate() {
  1127. template_id, _ := this.GetInt64("template_id")
  1128. adminUserInfo := this.GetAdminUserInfo()
  1129. orgId := adminUserInfo.CurrentOrgId
  1130. _, errcode := service.GetHisTemplateId(template_id, orgId)
  1131. //fmt.Println("errcode", errcode)
  1132. if errcode == gorm.ErrRecordNotFound {
  1133. template := models.XtHisTemplate{
  1134. TemplateId: template_id,
  1135. UserOrgId: orgId,
  1136. Status: 1,
  1137. Ctime: time.Now().Unix(),
  1138. }
  1139. err := service.CreateHisTemplate(&template)
  1140. if err != nil {
  1141. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1142. return
  1143. }
  1144. this.ServeSuccessJSON(map[string]interface{}{
  1145. "template": template,
  1146. "template_id": template_id,
  1147. })
  1148. } else if errcode == nil {
  1149. template := models.XtHisTemplate{
  1150. TemplateId: template_id,
  1151. UserOrgId: orgId,
  1152. Status: 1,
  1153. Ctime: time.Now().Unix(),
  1154. Mtime: time.Now().Unix(),
  1155. }
  1156. err := service.UpdateHisTemplate(&template)
  1157. if err != nil {
  1158. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1159. return
  1160. }
  1161. this.ServeSuccessJSON(map[string]interface{}{
  1162. "template": template,
  1163. "template_id": template_id,
  1164. })
  1165. }
  1166. }
  1167. func (this *HisProjectApiController) GetHisPrintTemplate() {
  1168. adminUserInfo := this.GetAdminUserInfo()
  1169. orgId := adminUserInfo.CurrentOrgId
  1170. template, err := service.GetHisPrintTemplate(orgId)
  1171. if err != nil {
  1172. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1173. return
  1174. }
  1175. this.ServeSuccessJSON(map[string]interface{}{
  1176. "template": template,
  1177. })
  1178. }
  1179. func (this *HisProjectApiController) PostPrescriptionTempalte() {
  1180. template_id, _ := this.GetInt64("template_id")
  1181. adminUserInfo := this.GetAdminUserInfo()
  1182. orgId := adminUserInfo.CurrentOrgId
  1183. _, errcode := service.GetPrescriptionTemplate(template_id, orgId)
  1184. if errcode == gorm.ErrRecordNotFound {
  1185. template := models.XtHisAdviceTemplate{
  1186. TemplateId: template_id,
  1187. UserOrgId: orgId,
  1188. Status: 1,
  1189. Ctime: time.Now().Unix(),
  1190. }
  1191. err := service.CreatePrescriptionTemplate(&template)
  1192. if err != nil {
  1193. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1194. return
  1195. }
  1196. this.ServeSuccessJSON(map[string]interface{}{
  1197. "template": template,
  1198. "template_id": template_id,
  1199. })
  1200. } else if errcode == nil {
  1201. template := models.XtHisAdviceTemplate{
  1202. TemplateId: template_id,
  1203. UserOrgId: orgId,
  1204. Status: 1,
  1205. Ctime: time.Now().Unix(),
  1206. }
  1207. err := service.UpdatePrescriptionTemplate(&template)
  1208. if err != nil {
  1209. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1210. return
  1211. }
  1212. this.ServeSuccessJSON(map[string]interface{}{
  1213. "template": template,
  1214. "template_id": template_id,
  1215. })
  1216. }
  1217. }
  1218. func (this *HisProjectApiController) GetPrescriptionTemplate() {
  1219. adminUserInfo := this.GetAdminUserInfo()
  1220. orgId := adminUserInfo.CurrentOrgId
  1221. template, err := service.GetPrescriptionTemplateById(orgId)
  1222. if err != nil {
  1223. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1224. return
  1225. }
  1226. this.ServeSuccessJSON(map[string]interface{}{
  1227. "template": template,
  1228. })
  1229. }
  1230. func (this *HisProjectApiController) PostTreatPrintTemplate() {
  1231. template_id, _ := this.GetInt64("template_id")
  1232. adminUserInfo := this.GetAdminUserInfo()
  1233. orgId := adminUserInfo.CurrentOrgId
  1234. _, errcode := service.GetTreatPrintTemplate(template_id, orgId)
  1235. if errcode == gorm.ErrRecordNotFound {
  1236. template := models.XtHisTreatmentTemplate{
  1237. TemplateId: template_id,
  1238. UserOrgId: orgId,
  1239. Status: 1,
  1240. Ctime: time.Now().Unix(),
  1241. }
  1242. err := service.CreateTreatPrintTemplate(&template)
  1243. if err != nil {
  1244. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1245. return
  1246. }
  1247. this.ServeSuccessJSON(map[string]interface{}{
  1248. "template": template,
  1249. "template_id": template_id,
  1250. })
  1251. } else if errcode == nil {
  1252. template := models.XtHisTreatmentTemplate{
  1253. TemplateId: template_id,
  1254. UserOrgId: orgId,
  1255. Status: 1,
  1256. Ctime: time.Now().Unix(),
  1257. }
  1258. err := service.UpdatedTreateTemplate(&template)
  1259. if err != nil {
  1260. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1261. return
  1262. }
  1263. this.ServeSuccessJSON(map[string]interface{}{
  1264. "template": template,
  1265. "template_id": template_id,
  1266. })
  1267. }
  1268. }
  1269. func (this *HisProjectApiController) GetTreatPrintTemplate() {
  1270. adminUserInfo := this.GetAdminUserInfo()
  1271. orgId := adminUserInfo.CurrentOrgId
  1272. template, err := service.GetTreatTtreatPrintTemplate(orgId)
  1273. if err != nil {
  1274. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1275. return
  1276. }
  1277. this.ServeSuccessJSON(map[string]interface{}{
  1278. "template": template,
  1279. })
  1280. }
  1281. func (this *HisProjectApiController) PostChargePrintTemplate() {
  1282. template_id, _ := this.GetInt64("template_id")
  1283. adminUserInfo := this.GetAdminUserInfo()
  1284. orgId := adminUserInfo.CurrentOrgId
  1285. _, errcode := service.GetChargeTemplate(template_id, orgId)
  1286. if errcode == gorm.ErrRecordNotFound {
  1287. template := models.XtHisChargeTemplate{
  1288. TemplateId: template_id,
  1289. UserOrgId: orgId,
  1290. Ctime: time.Now().Unix(),
  1291. Status: 1,
  1292. }
  1293. err := service.CreateChargePrintTemplate(&template)
  1294. if err != nil {
  1295. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1296. return
  1297. }
  1298. this.ServeSuccessJSON(map[string]interface{}{
  1299. "template": template,
  1300. "template_id": template_id,
  1301. })
  1302. } else if errcode == nil {
  1303. template := models.XtHisChargeTemplate{
  1304. TemplateId: template_id,
  1305. UserOrgId: orgId,
  1306. Ctime: time.Now().Unix(),
  1307. Status: 1,
  1308. }
  1309. err := service.UpdateChargePrintTemplate(&template)
  1310. if err != nil {
  1311. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1312. return
  1313. }
  1314. this.ServeSuccessJSON(map[string]interface{}{
  1315. "template": template,
  1316. "template_id": template_id,
  1317. })
  1318. }
  1319. }
  1320. func (this *HisProjectApiController) GetChargePrintTemplate() {
  1321. adminUserInfo := this.GetAdminUserInfo()
  1322. orgId := adminUserInfo.CurrentOrgId
  1323. template, err := service.GetChargePrintTemplate(orgId)
  1324. if err != nil {
  1325. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1326. return
  1327. }
  1328. this.ServeSuccessJSON(map[string]interface{}{
  1329. "template": template,
  1330. })
  1331. }
  1332. func (this *HisProjectApiController) GetAllHisPatient() {
  1333. record_date := this.GetString("record_date")
  1334. timeLayout := "2006-01-02"
  1335. loc, _ := time.LoadLocation("Local")
  1336. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1337. recordDateTime := theTime.Unix()
  1338. adminUserInfo := this.GetAdminUserInfo()
  1339. patients, err := service.GetScheduleHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime, 0)
  1340. if err != nil {
  1341. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1342. return
  1343. }
  1344. this.ServeSuccessJSON(map[string]interface{}{
  1345. "list": patients,
  1346. })
  1347. }
  1348. func (this *HisProjectApiController) GetChargePrint() {
  1349. record_date := this.GetString("record_date")
  1350. timeLayout := "2006-01-02"
  1351. loc, _ := time.LoadLocation("Local")
  1352. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1353. recordDateTime := theTime.Unix()
  1354. patient_id, _ := this.GetInt64("patient_id")
  1355. prescription_id, _ := this.GetInt64("prescription_id")
  1356. adminUserInfo := this.GetAdminUserInfo()
  1357. chargePrint, err := service.GetChargePrint(recordDateTime, patient_id, adminUserInfo.CurrentOrgId)
  1358. prescription, err := service.GetHisPrescriptionNight(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, prescription_id)
  1359. patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, patient_id)
  1360. hisPatient, err := service.GetHisPatientById(patient_id)
  1361. if err != nil {
  1362. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1363. return
  1364. }
  1365. this.ServeSuccessJSON(map[string]interface{}{
  1366. "list": chargePrint,
  1367. "prescription": prescription,
  1368. "patient": patient,
  1369. "hisPatient": hisPatient,
  1370. })
  1371. }
  1372. func (this *HisProjectApiController) GetTodaySchedulePatient() {
  1373. adminUserInfo := this.GetAdminUserInfo()
  1374. orgId := adminUserInfo.CurrentOrgId
  1375. recordDateStr := time.Now().Format("2006-01-02")
  1376. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1377. scheduleDate := recordDate.Unix()
  1378. patient, err := service.GetTodaySchedulePatient(orgId, scheduleDate)
  1379. if err != nil {
  1380. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1381. return
  1382. }
  1383. this.ServeSuccessJSON(map[string]interface{}{
  1384. "patient": patient,
  1385. })
  1386. }
  1387. func (this *HisProjectApiController) GetHisPatientDetail() {
  1388. patient_id, _ := this.GetInt64("patient_id")
  1389. hisPatient, err := service.GetHisPatientById(patient_id)
  1390. //service.GetLastHospitalRecordTwo(patient_id,this.GetAdminUserInfo().CurrentOrgId)
  1391. hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, this.GetAdminUserInfo().CurrentOrgId)
  1392. if err != nil {
  1393. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1394. return
  1395. }
  1396. this.ServeSuccessJSON(map[string]interface{}{
  1397. "hisPatient": hisPatient,
  1398. "hisHospitalRecord": hisHospitalRecord,
  1399. })
  1400. }
  1401. func (this *HisProjectApiController) GetAllDepartmentList() {
  1402. adminUserInfo := this.GetAdminUserInfo()
  1403. orgId := adminUserInfo.CurrentOrgId
  1404. departMent, err := service.GetAllDepartMent(orgId)
  1405. if err != nil {
  1406. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1407. return
  1408. }
  1409. this.ServeSuccessJSON(map[string]interface{}{
  1410. "departMent": departMent,
  1411. })
  1412. }
  1413. func (this *HisProjectApiController) GetPrescription() {
  1414. patient_id, _ := this.GetInt64("patient_id")
  1415. p_type, _ := this.GetInt64("p_type")
  1416. record_date := this.GetString("record_date")
  1417. timeLayout := "2006-01-02"
  1418. loc, _ := time.LoadLocation("Local")
  1419. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1420. if err != nil {
  1421. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1422. return
  1423. }
  1424. recordDateTime := theTime.Unix()
  1425. list, err := service.GetPrescriptionByPatientId(patient_id, recordDateTime, p_type)
  1426. if err != nil {
  1427. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1428. return
  1429. }
  1430. this.ServeSuccessJSON(map[string]interface{}{
  1431. "list": list,
  1432. })
  1433. }
  1434. func (this *HisProjectApiController) GetPatientDetail() {
  1435. id, _ := this.GetInt64("id")
  1436. adminUserInfo := this.GetAdminUserInfo()
  1437. patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, id)
  1438. if err != nil {
  1439. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1440. return
  1441. }
  1442. this.ServeSuccessJSON(map[string]interface{}{
  1443. "patient": patient,
  1444. })
  1445. }
  1446. func (this *HisProjectApiController) SaveMainTemplate() {
  1447. title := this.GetString("title")
  1448. content := this.GetString("content")
  1449. remark := this.GetString("remark")
  1450. template_id, _ := this.GetInt64("template_id")
  1451. adminUserInfo := this.GetAdminUserInfo()
  1452. orgId := adminUserInfo.CurrentOrgId
  1453. template := models.XtHisMedicalTemplate{
  1454. Title: title,
  1455. Content: content,
  1456. Remark: remark,
  1457. UserOrgId: orgId,
  1458. TemplateId: template_id,
  1459. Status: 1,
  1460. Ctime: time.Now().Unix(),
  1461. }
  1462. err := service.CreateHisMedicalTemplate(&template)
  1463. if err != nil {
  1464. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1465. return
  1466. }
  1467. this.ServeSuccessJSON(map[string]interface{}{
  1468. "template": template,
  1469. })
  1470. }
  1471. func (this *HisProjectApiController) GetMedicalTempalteList() {
  1472. adminUserInfo := this.GetAdminUserInfo()
  1473. orgId := adminUserInfo.CurrentOrgId
  1474. list, err := service.GetMedicalTemplateList(orgId)
  1475. listOne, err := service.GetMedicalTemplateListOne(orgId)
  1476. listTwo, err := service.GetMedicalTemplateListTwo(orgId)
  1477. listThree, err := service.GetMedicalTemplateListThree(orgId)
  1478. listFour, err := service.GetMedicalTemplateListFour(orgId)
  1479. listFive, err := service.GetMedicalTemplateListFive(orgId)
  1480. listSix, err := service.GetMedicalTemplateListSix(orgId)
  1481. listSeven, err := service.GetMedicalTemplateListSeven(orgId)
  1482. if err != nil {
  1483. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1484. return
  1485. }
  1486. this.ServeSuccessJSON(map[string]interface{}{
  1487. "list": list,
  1488. "listOne": listOne,
  1489. "listTwo": listTwo,
  1490. "listThree": listThree,
  1491. "listFour": listFour,
  1492. "listFive": listFive,
  1493. "listSix": listSix,
  1494. "listSeven": listSeven,
  1495. })
  1496. }
  1497. func (this *HisProjectApiController) GetMainTemplateById() {
  1498. id, _ := this.GetInt64("id")
  1499. template, err := service.GetMainTemplateById(id)
  1500. if err != nil {
  1501. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1502. return
  1503. }
  1504. this.ServeSuccessJSON(map[string]interface{}{
  1505. "template": template,
  1506. })
  1507. }
  1508. func (this *HisProjectApiController) UpdateMainTemplate() {
  1509. title := this.GetString("title")
  1510. content := this.GetString("content")
  1511. remark := this.GetString("remark")
  1512. id, _ := this.GetInt64("id")
  1513. template := models.XtHisMedicalTemplate{
  1514. Title: title,
  1515. Content: content,
  1516. Remark: remark,
  1517. }
  1518. err := service.UpdateMainTemplate(&template, id)
  1519. if err != nil {
  1520. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1521. return
  1522. }
  1523. this.ServeSuccessJSON(map[string]interface{}{
  1524. "template": template,
  1525. })
  1526. }
  1527. func (this *HisProjectApiController) DeleteMainTemplate() {
  1528. id, _ := this.GetInt64("id")
  1529. err := service.DeleteMainTemplateById(id)
  1530. if err != nil {
  1531. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1532. return
  1533. }
  1534. returnData := make(map[string]interface{}, 0)
  1535. returnData["msg"] = "ok"
  1536. this.ServeSuccessJSON(returnData)
  1537. return
  1538. }