his_project_api_controller.go 54KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671
  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. this.ServeSuccessJSON(map[string]interface{}{
  537. "department": department,
  538. })
  539. return
  540. }
  541. func (this *HisProjectApiController) GetDepartMentList() {
  542. limit, _ := this.GetInt64("limit")
  543. page, _ := this.GetInt64("page")
  544. adminUserInfo := this.GetAdminUserInfo()
  545. orgId := adminUserInfo.CurrentOrgId
  546. departMentList, total, err := service.GetDepartMentList(limit, page, orgId)
  547. if err != nil {
  548. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  549. return
  550. }
  551. this.ServeSuccessJSON(map[string]interface{}{
  552. "departMentList": departMentList,
  553. "total": total,
  554. })
  555. return
  556. }
  557. func (this *HisProjectApiController) GetDepartMentDetail() {
  558. id, _ := this.GetInt64("id")
  559. departDetail, err := service.GetDepartMentDetail(id)
  560. if err != nil {
  561. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  562. return
  563. }
  564. this.ServeSuccessJSON(map[string]interface{}{
  565. "departDetail": departDetail,
  566. })
  567. return
  568. }
  569. func (this *HisProjectApiController) UpdatedDeparment() {
  570. id, _ := this.GetInt64("id")
  571. name := this.GetString("name")
  572. number := this.GetString("number")
  573. department := models.XtHisDepartment{
  574. Name: name,
  575. Number: number,
  576. }
  577. err := service.UpdatedDepartment(id, &department)
  578. if err != nil {
  579. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  580. return
  581. }
  582. this.ServeSuccessJSON(map[string]interface{}{
  583. "department": department,
  584. })
  585. return
  586. }
  587. func (this *HisProjectApiController) DeleteDepartment() {
  588. id, _ := this.GetInt64("id")
  589. err := service.DeleteDepartment(id)
  590. if err != nil {
  591. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  592. return
  593. }
  594. returnData := make(map[string]interface{}, 0)
  595. returnData["msg"] = "ok"
  596. this.ServeSuccessJSON(returnData)
  597. return
  598. }
  599. func (this *HisProjectApiController) GetBloodPatientList() {
  600. adminUserInfo := this.GetAdminUserInfo()
  601. orgId := adminUserInfo.CurrentOrgId
  602. timeStr := time.Now().Format("2006-01-02")
  603. timeLayout := "2006-01-02 15:04:05"
  604. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  605. timenow := timeStringToTime.Unix()
  606. //统计血透排班的患者
  607. scheduleList, err := service.GetBloodPatientList(orgId, timenow)
  608. //统计当日挂号的患者
  609. hisPatient, _ := service.GetHisPatient(orgId, timenow)
  610. //统计今天开处方的患者
  611. prescription, _ := service.GetHisPrescriptionOther(orgId, timenow)
  612. if err != nil {
  613. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  614. return
  615. }
  616. this.ServeSuccessJSON(map[string]interface{}{
  617. "scheduleList": scheduleList,
  618. "hisPatient": hisPatient,
  619. "prescription": prescription,
  620. })
  621. return
  622. }
  623. func (this *HisProjectApiController) GetHisPrescription() {
  624. id, _ := this.GetInt64("id")
  625. timeStr := time.Now().Format("2006-01-02")
  626. timeLayout := "2006-01-02 15:04:05"
  627. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  628. timenow := timeStringToTime.Unix()
  629. prescriptionList, err := service.GetHisPrescriptionByPatientId(id, timenow)
  630. if err != nil {
  631. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  632. return
  633. }
  634. this.ServeSuccessJSON(map[string]interface{}{
  635. "prescriptionList": prescriptionList,
  636. })
  637. return
  638. }
  639. func (this *HisProjectApiController) GetTreatmentList() {
  640. patient_id, _ := this.GetInt64("patient_id")
  641. timeStr := time.Now().Format("2006-01-02")
  642. timeLayout := "2006-01-02 15:04:05"
  643. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  644. timenow := timeStringToTime.Unix()
  645. treatmentList, err := service.GetTreatmentList(patient_id, timenow)
  646. if err != nil {
  647. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  648. return
  649. }
  650. this.ServeSuccessJSON(map[string]interface{}{
  651. "treatmentList": treatmentList,
  652. })
  653. return
  654. }
  655. func (this *HisProjectApiController) GetAllProjectList() {
  656. keyword := this.GetString("keyword")
  657. adminUserInfo := this.GetAdminUserInfo()
  658. orgId := adminUserInfo.CurrentOrgId
  659. projectList, err := service.GetAllProjectList(orgId, keyword)
  660. goodInfos, err := service.GetGoodInfomationList(orgId, keyword)
  661. //获取列表数据
  662. hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
  663. if err != nil {
  664. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  665. return
  666. }
  667. this.ServeSuccessJSON(map[string]interface{}{
  668. "projectList": projectList,
  669. "hisprojectlist": hisprojectlist,
  670. "good_info": goodInfos,
  671. })
  672. return
  673. }
  674. func (this *HisProjectApiController) AddProjectList() {
  675. id, _ := this.GetInt64("id")
  676. number, _ := this.GetInt64("number")
  677. adminUserInfo := this.GetAdminUserInfo()
  678. orgId := adminUserInfo.CurrentOrgId
  679. projectList := models.XtHisProjectList{
  680. ProjectId: id,
  681. Number: number,
  682. UserOrgId: orgId,
  683. Status: 1,
  684. CreatedTime: time.Now().Unix(),
  685. }
  686. err := service.CreateProjectList(&projectList)
  687. detail, _ := service.GetProjectDetail(id)
  688. item, err := service.GetLastItem(orgId)
  689. if err != nil {
  690. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  691. return
  692. }
  693. this.ServeSuccessJSON(map[string]interface{}{
  694. "projectList": detail,
  695. "item": item,
  696. })
  697. return
  698. }
  699. func (this *HisProjectApiController) GetPatientInformation() {
  700. id, _ := this.GetInt64("id")
  701. information, err := service.GetHisPatientInformation(id)
  702. if err != nil {
  703. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  704. return
  705. }
  706. this.ServeSuccessJSON(map[string]interface{}{
  707. "information": information,
  708. })
  709. return
  710. }
  711. func (this *HisProjectApiController) DeleteProject() {
  712. id, _ := this.GetInt64("id")
  713. err := service.DeleteProjectList(id)
  714. if err != nil {
  715. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  716. return
  717. }
  718. returnData := make(map[string]interface{}, 0)
  719. returnData["msg"] = "ok"
  720. this.ServeSuccessJSON(returnData)
  721. return
  722. }
  723. func (this *HisProjectApiController) GetHisProject() {
  724. adminUserInfo := this.GetAdminUserInfo()
  725. orgId := adminUserInfo.CurrentOrgId
  726. project, err := service.GetHisProject(orgId)
  727. good_info, err := service.GetGoodInfoMation(orgId)
  728. if err != nil {
  729. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  730. return
  731. }
  732. this.ServeSuccessJSON(map[string]interface{}{
  733. "project": project,
  734. "good_info": good_info,
  735. })
  736. }
  737. func (this *HisProjectApiController) GetProjectTeam() {
  738. strids := this.GetString("strids")
  739. idStrs := strings.Split(strids, ",")
  740. adminUserInfo := this.GetAdminUserInfo()
  741. orgId := adminUserInfo.CurrentOrgId
  742. team, err := service.GetProjectTeam(idStrs, orgId)
  743. if err != nil {
  744. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  745. return
  746. }
  747. this.ServeSuccessJSON(map[string]interface{}{
  748. "team": team,
  749. })
  750. }
  751. func (this *HisProjectApiController) GetAllDoctorList() {
  752. adminUserInfo := this.GetAdminUserInfo()
  753. orgId := adminUserInfo.CurrentOrgId
  754. appId := adminUserInfo.CurrentAppId
  755. //获取所有的医生
  756. doctor, err := service.GetAllDoctor(orgId, appId)
  757. //获取所有的科室
  758. department, err := service.GetAllDepartMent(orgId)
  759. if err != nil {
  760. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  761. return
  762. }
  763. this.ServeSuccessJSON(map[string]interface{}{
  764. "doctor": doctor,
  765. "department": department,
  766. })
  767. }
  768. func (this *HisProjectApiController) SaveHisPatient() {
  769. timeLayout := "2006-01-02"
  770. loc, _ := time.LoadLocation("Local")
  771. age, _ := this.GetInt64("age")
  772. birthday := this.GetString("birthday")
  773. patient_id, _ := this.GetInt64("id")
  774. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  775. birthUnix := birthdays.Unix()
  776. certificates, _ := this.GetInt64("certificates")
  777. cost_checked, _ := this.GetInt64("costChecked")
  778. cost, _ := this.GetInt64("cost")
  779. costs := strconv.FormatInt(cost, 10)
  780. cost_float, _ := strconv.ParseFloat(costs, 64)
  781. department, _ := this.GetInt64("department")
  782. doctor, _ := this.GetInt64("doctor")
  783. medicalcare, _ := this.GetInt64("medical_care")
  784. idcard := this.GetString("id_card")
  785. medicalExpenses, _ := this.GetInt64("medical_expenses")
  786. medicalExpense := strconv.FormatInt(medicalExpenses, 10)
  787. medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
  788. medicalinsurancecard := this.GetString("medical_insurance_card")
  789. name := this.GetString("name")
  790. register, _ := this.GetInt64("register")
  791. registrationfee, _ := this.GetInt64("registration_fee")
  792. registrationfees := strconv.FormatInt(registrationfee, 10)
  793. registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
  794. settlementValue, _ := this.GetInt64("settlement_value")
  795. sex, _ := this.GetInt64("sex")
  796. total, _ := this.GetInt64("total")
  797. totals := strconv.FormatInt(total, 10)
  798. totals_float, _ := strconv.ParseFloat(totals, 64)
  799. adminUserInfo := this.GetAdminUserInfo()
  800. orgId := adminUserInfo.CurrentOrgId
  801. recordDateStr := time.Now().Format("2006-01-02")
  802. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  803. nowtime := recordDate.Unix()
  804. phone := this.GetString("phone")
  805. social_type, _ := this.GetInt64("social_type")
  806. id_card_type, _ := this.GetInt64("id_card_type")
  807. diagnosis_id, _ := this.GetInt64("diagnosis")
  808. sick_type, _ := this.GetInt64("sick_type")
  809. reg_type := this.GetString("p_type")
  810. tempPatient, _ := service.GetPatientByIDCardAndName(idcard, adminUserInfo.CurrentOrgId, name)
  811. if tempPatient.ID == 0 {
  812. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoBloodPatientException)
  813. return
  814. }
  815. var patient service.Patients
  816. if patient_id == 0 {
  817. patient, _ = service.GetPatientByIDCard(idcard, adminUserInfo.CurrentOrgId)
  818. } else {
  819. patient, _ = service.GetPatientByIDTwo(adminUserInfo.CurrentOrgId, patient_id)
  820. }
  821. if patient.ID == 0 {
  822. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  823. return
  824. }
  825. if len(patient.IdCardNo) == 0 {
  826. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  827. return
  828. }
  829. timeStr := time.Now().Format("2006-01-02 15:04:05")
  830. fmt.Println(timeStr)
  831. timeArr := strings.Split(timeStr, " ")
  832. timeArrTwo := strings.Split(timeArr[0], "-")
  833. timeArrThree := strings.Split(timeArr[1], ":")
  834. var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(patient.ID, 10)
  835. //his, _ := service.GetHisPatientInfoTwo(adminUserInfo.CurrentOrgId, patient.ID, recordDate.Unix())
  836. //if len(his) >= 1 {
  837. // order, _ := service.GetNewHisOrderTwo(adminUserInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDate.Unix())
  838. // if len(his) >= 1 && order.ID == 0 {
  839. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  840. // return
  841. // }
  842. //}
  843. var hisPatient models.XtHisPatient
  844. //if err == gorm.ErrRecordNotFound || his.ID == 0 {
  845. hisPatient = models.XtHisPatient{
  846. PatientId: patient_id,
  847. Birthday: birthUnix,
  848. IdType: certificates,
  849. CostOfProduction: cost_float,
  850. Departments: department,
  851. Doctor: doctor,
  852. AdminUserId: adminUserInfo.AdminUser.Id,
  853. MedicalTreatmentType: medicalcare,
  854. IdCardNo: idcard,
  855. IsNeedCostOfProduction: cost_checked,
  856. TreatmentCost: medicalExpense_float,
  857. MedicalInsuranceNumber: medicalinsurancecard,
  858. Name: name,
  859. Age: age,
  860. Number: str,
  861. RegisterType: register,
  862. RegisterCost: registrationfees_float,
  863. BalanceAccountsType: settlementValue,
  864. Gender: sex,
  865. Total: totals_float,
  866. UserOrgId: orgId,
  867. Status: 1,
  868. RecordDate: nowtime,
  869. IsReturn: 1,
  870. Ctime: time.Now().Unix(),
  871. Phone: phone,
  872. SocialType: social_type,
  873. IdCardType: id_card_type,
  874. Diagnosis: diagnosis_id,
  875. PType: reg_type,
  876. SickType: sick_type,
  877. }
  878. service.CreateHisPatient(&hisPatient)
  879. this.ServeSuccessJSON(map[string]interface{}{
  880. "his_info": hisPatient,
  881. })
  882. //}
  883. //else {
  884. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisRegisterException)
  885. // return
  886. //}
  887. }
  888. func (this *HisProjectApiController) GetAllProjectTeam() {
  889. adminUserInfo := this.GetAdminUserInfo()
  890. orgId := adminUserInfo.CurrentOrgId
  891. team, err := service.GetAllProjectTeam(orgId)
  892. if err != nil {
  893. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  894. return
  895. }
  896. this.ServeSuccessJSON(map[string]interface{}{
  897. "team": team,
  898. })
  899. }
  900. func (this *HisProjectApiController) GetProjectListById() {
  901. adminUserInfo := this.GetAdminUserInfo()
  902. orgId := adminUserInfo.CurrentOrgId
  903. project_id := this.GetString("project_id")
  904. idStrs := strings.Split(project_id, ",")
  905. project, err := service.GetProjectListById(orgId, idStrs)
  906. if err != nil {
  907. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  908. return
  909. }
  910. this.ServeSuccessJSON(map[string]interface{}{
  911. "project": project,
  912. })
  913. }
  914. func (this *HisProjectApiController) GetHisPatientHistory() {
  915. timeLayout := "2006-01-02"
  916. loc, _ := time.LoadLocation("Local")
  917. keyword := this.GetString("keyword")
  918. start_time := this.GetString("start_time")
  919. end_time := this.GetString("end_time")
  920. register_type, _ := this.GetInt64("register_type")
  921. limit, _ := this.GetInt64("limit")
  922. page, _ := this.GetInt64("page")
  923. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  924. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  925. adminUserInfo := this.GetAdminUserInfo()
  926. orgId := adminUserInfo.CurrentOrgId
  927. history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
  928. department, err := service.GetAllDepartMent(orgId)
  929. appId := adminUserInfo.CurrentAppId
  930. doctor, err := service.GetAllDoctor(orgId, appId)
  931. if err != nil {
  932. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  933. return
  934. }
  935. this.ServeSuccessJSON(map[string]interface{}{
  936. "history": history,
  937. "total": total,
  938. "department": department,
  939. "doctor": doctor,
  940. })
  941. }
  942. func (this *HisProjectApiController) ChangePatient() {
  943. id, _ := this.GetInt64("id")
  944. //查询该患者今日是否已经就诊
  945. recordDateStr := time.Now().Format("2006-01-02")
  946. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  947. nowtime := recordDate.Unix()
  948. adminUserInfo := this.GetAdminUserInfo()
  949. orgId := adminUserInfo.CurrentOrgId
  950. _, errcode := service.GetHisPrescriptionTwo(id, orgId, nowtime)
  951. if errcode == gorm.ErrRecordNotFound {
  952. err := service.ChangePatient(id)
  953. if err != nil {
  954. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  955. return
  956. }
  957. returnData := make(map[string]interface{}, 0)
  958. returnData["msg"] = "ok"
  959. this.ServeSuccessJSON(returnData)
  960. return
  961. } else if errcode == nil {
  962. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  963. return
  964. }
  965. }
  966. func (this *HisProjectApiController) GetPatientcaseHistory() {
  967. patient_id, _ := this.GetInt64("patient_id")
  968. patient, err := service.GetBloodPatientInfoById(patient_id)
  969. history, _ := service.GetPatientCaseHistory(patient_id)
  970. hispatient, _ := service.GetHisPatientById(patient_id)
  971. if err != nil {
  972. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  973. return
  974. }
  975. this.ServeSuccessJSON(map[string]interface{}{
  976. "patient": patient,
  977. "history": history,
  978. "hispatient": hispatient,
  979. })
  980. }
  981. func (this *HisProjectApiController) GetTemplateDetail() {
  982. id, _ := this.GetInt64("id")
  983. templateDetail, err := service.GetTemplateDetail(id)
  984. if err != nil {
  985. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  986. return
  987. }
  988. this.ServeSuccessJSON(map[string]interface{}{
  989. "templateDetail": templateDetail,
  990. })
  991. }
  992. func (this *HisProjectApiController) UpdateRecordTemplate() {
  993. id, _ := this.GetInt64("id")
  994. template_name := this.GetString("template_name")
  995. template_remark := this.GetString("template_remark")
  996. diagnostic := this.GetString("diagnostic")
  997. chief_conplaint := this.GetString("chief_conplaint")
  998. history_of_present_illness := this.GetString("history_of_present_illness")
  999. past_history := this.GetString("past_history")
  1000. personal_history := this.GetString("personal_history")
  1001. family_history := this.GetString("family_history")
  1002. doctor_advice := this.GetString("doctor_advice")
  1003. remark := this.GetString("remark")
  1004. adminUserInfo := this.GetAdminUserInfo()
  1005. creater := adminUserInfo.AdminUser.Id
  1006. historyTemplate := models.HisCaseHistoryTemplate{
  1007. HistoryOfPresentIllness: history_of_present_illness,
  1008. PastHistory: past_history,
  1009. ChiefConplaint: chief_conplaint,
  1010. PersonalHistory: personal_history,
  1011. FamilyHistory: family_history,
  1012. Diagnostic: diagnostic,
  1013. Status: 1,
  1014. Mtime: time.Now().Unix(),
  1015. RecordDate: time.Now().Unix(),
  1016. TemplateName: template_name,
  1017. TemplateRemark: template_remark,
  1018. Modifier: creater,
  1019. DoctorAdvice: doctor_advice,
  1020. Remark: remark,
  1021. }
  1022. err := service.UpdateCaseHistoryTemplate(&historyTemplate, id)
  1023. if err != nil {
  1024. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1025. return
  1026. }
  1027. this.ServeSuccessJSON(map[string]interface{}{
  1028. "templateDetail": historyTemplate,
  1029. })
  1030. }
  1031. func (this *HisProjectApiController) GetHisPatient() {
  1032. adminUserInfo := this.GetAdminUserInfo()
  1033. orgId := adminUserInfo.CurrentOrgId
  1034. keyword := this.GetString("keyword")
  1035. patient, err := service.GetHistPatient(orgId, keyword)
  1036. if err != nil {
  1037. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1038. return
  1039. }
  1040. this.ServeSuccessJSON(map[string]interface{}{
  1041. "patient": patient,
  1042. })
  1043. }
  1044. func (this *HisProjectApiController) GetDoctorAdvicePrint() {
  1045. patient_id, _ := this.GetInt64("patient_id")
  1046. record_date := this.GetString("record_date")
  1047. schIDStr := this.GetString("ids")
  1048. if len(schIDStr) == 0 {
  1049. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1050. return
  1051. }
  1052. idStrs := strings.Split(schIDStr, ",")
  1053. timeLayout := "2006-01-02"
  1054. loc, _ := time.LoadLocation("Local")
  1055. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1056. recordDateTime := theTime.Unix()
  1057. //prescription_id, _ := this.GetInt64("prescription_id")
  1058. adminUserInfo := this.GetAdminUserInfo()
  1059. advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId)
  1060. projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId, "")
  1061. //prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
  1062. hisPatient, _ := service.GetHisPatientById(patient_id)
  1063. if err != nil {
  1064. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1065. return
  1066. }
  1067. this.ServeSuccessJSON(map[string]interface{}{
  1068. "advicePrint": advicePrint,
  1069. "projectlist": projectlist,
  1070. "hisPatient": hisPatient,
  1071. })
  1072. }
  1073. func (this *HisProjectApiController) GetProjectPrint() {
  1074. his_patient_id, _ := this.GetInt64("his_patient_id")
  1075. hisPatient, _ := service.GetHisPatientById(his_patient_id)
  1076. projectPrint, err := service.GetProjectPrint(his_patient_id)
  1077. if err != nil {
  1078. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1079. return
  1080. }
  1081. this.ServeSuccessJSON(map[string]interface{}{
  1082. "hisPatient": hisPatient,
  1083. "projectPrint": projectPrint,
  1084. })
  1085. }
  1086. func (this *HisProjectApiController) PostPrintHisTemplate() {
  1087. template_id, _ := this.GetInt64("template_id")
  1088. adminUserInfo := this.GetAdminUserInfo()
  1089. orgId := adminUserInfo.CurrentOrgId
  1090. _, errcode := service.GetHisTemplateId(template_id, orgId)
  1091. //fmt.Println("errcode", errcode)
  1092. if errcode == gorm.ErrRecordNotFound {
  1093. template := models.XtHisTemplate{
  1094. TemplateId: template_id,
  1095. UserOrgId: orgId,
  1096. Status: 1,
  1097. Ctime: time.Now().Unix(),
  1098. }
  1099. err := service.CreateHisTemplate(&template)
  1100. if err != nil {
  1101. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1102. return
  1103. }
  1104. this.ServeSuccessJSON(map[string]interface{}{
  1105. "template": template,
  1106. "template_id": template_id,
  1107. })
  1108. } else if errcode == nil {
  1109. template := models.XtHisTemplate{
  1110. TemplateId: template_id,
  1111. UserOrgId: orgId,
  1112. Status: 1,
  1113. Ctime: time.Now().Unix(),
  1114. Mtime: time.Now().Unix(),
  1115. }
  1116. err := service.UpdateHisTemplate(&template)
  1117. if err != nil {
  1118. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1119. return
  1120. }
  1121. this.ServeSuccessJSON(map[string]interface{}{
  1122. "template": template,
  1123. "template_id": template_id,
  1124. })
  1125. }
  1126. }
  1127. func (this *HisProjectApiController) GetHisPrintTemplate() {
  1128. adminUserInfo := this.GetAdminUserInfo()
  1129. orgId := adminUserInfo.CurrentOrgId
  1130. template, err := service.GetHisPrintTemplate(orgId)
  1131. if err != nil {
  1132. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1133. return
  1134. }
  1135. this.ServeSuccessJSON(map[string]interface{}{
  1136. "template": template,
  1137. })
  1138. }
  1139. func (this *HisProjectApiController) PostPrescriptionTempalte() {
  1140. template_id, _ := this.GetInt64("template_id")
  1141. adminUserInfo := this.GetAdminUserInfo()
  1142. orgId := adminUserInfo.CurrentOrgId
  1143. _, errcode := service.GetPrescriptionTemplate(template_id, orgId)
  1144. if errcode == gorm.ErrRecordNotFound {
  1145. template := models.XtHisAdviceTemplate{
  1146. TemplateId: template_id,
  1147. UserOrgId: orgId,
  1148. Status: 1,
  1149. Ctime: time.Now().Unix(),
  1150. }
  1151. err := service.CreatePrescriptionTemplate(&template)
  1152. if err != nil {
  1153. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1154. return
  1155. }
  1156. this.ServeSuccessJSON(map[string]interface{}{
  1157. "template": template,
  1158. "template_id": template_id,
  1159. })
  1160. } else if errcode == nil {
  1161. template := models.XtHisAdviceTemplate{
  1162. TemplateId: template_id,
  1163. UserOrgId: orgId,
  1164. Status: 1,
  1165. Ctime: time.Now().Unix(),
  1166. }
  1167. err := service.UpdatePrescriptionTemplate(&template)
  1168. if err != nil {
  1169. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1170. return
  1171. }
  1172. this.ServeSuccessJSON(map[string]interface{}{
  1173. "template": template,
  1174. "template_id": template_id,
  1175. })
  1176. }
  1177. }
  1178. func (this *HisProjectApiController) GetPrescriptionTemplate() {
  1179. adminUserInfo := this.GetAdminUserInfo()
  1180. orgId := adminUserInfo.CurrentOrgId
  1181. template, err := service.GetPrescriptionTemplateById(orgId)
  1182. if err != nil {
  1183. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1184. return
  1185. }
  1186. this.ServeSuccessJSON(map[string]interface{}{
  1187. "template": template,
  1188. })
  1189. }
  1190. func (this *HisProjectApiController) PostTreatPrintTemplate() {
  1191. template_id, _ := this.GetInt64("template_id")
  1192. adminUserInfo := this.GetAdminUserInfo()
  1193. orgId := adminUserInfo.CurrentOrgId
  1194. _, errcode := service.GetTreatPrintTemplate(template_id, orgId)
  1195. if errcode == gorm.ErrRecordNotFound {
  1196. template := models.XtHisTreatmentTemplate{
  1197. TemplateId: template_id,
  1198. UserOrgId: orgId,
  1199. Status: 1,
  1200. Ctime: time.Now().Unix(),
  1201. }
  1202. err := service.CreateTreatPrintTemplate(&template)
  1203. if err != nil {
  1204. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1205. return
  1206. }
  1207. this.ServeSuccessJSON(map[string]interface{}{
  1208. "template": template,
  1209. "template_id": template_id,
  1210. })
  1211. } else if errcode == nil {
  1212. template := models.XtHisTreatmentTemplate{
  1213. TemplateId: template_id,
  1214. UserOrgId: orgId,
  1215. Status: 1,
  1216. Ctime: time.Now().Unix(),
  1217. }
  1218. err := service.UpdatedTreateTemplate(&template)
  1219. if err != nil {
  1220. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1221. return
  1222. }
  1223. this.ServeSuccessJSON(map[string]interface{}{
  1224. "template": template,
  1225. "template_id": template_id,
  1226. })
  1227. }
  1228. }
  1229. func (this *HisProjectApiController) GetTreatPrintTemplate() {
  1230. adminUserInfo := this.GetAdminUserInfo()
  1231. orgId := adminUserInfo.CurrentOrgId
  1232. template, err := service.GetTreatTtreatPrintTemplate(orgId)
  1233. if err != nil {
  1234. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1235. return
  1236. }
  1237. this.ServeSuccessJSON(map[string]interface{}{
  1238. "template": template,
  1239. })
  1240. }
  1241. func (this *HisProjectApiController) PostChargePrintTemplate() {
  1242. template_id, _ := this.GetInt64("template_id")
  1243. adminUserInfo := this.GetAdminUserInfo()
  1244. orgId := adminUserInfo.CurrentOrgId
  1245. _, errcode := service.GetChargeTemplate(template_id, orgId)
  1246. if errcode == gorm.ErrRecordNotFound {
  1247. template := models.XtHisChargeTemplate{
  1248. TemplateId: template_id,
  1249. UserOrgId: orgId,
  1250. Ctime: time.Now().Unix(),
  1251. Status: 1,
  1252. }
  1253. err := service.CreateChargePrintTemplate(&template)
  1254. if err != nil {
  1255. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1256. return
  1257. }
  1258. this.ServeSuccessJSON(map[string]interface{}{
  1259. "template": template,
  1260. "template_id": template_id,
  1261. })
  1262. } else if errcode == nil {
  1263. template := models.XtHisChargeTemplate{
  1264. TemplateId: template_id,
  1265. UserOrgId: orgId,
  1266. Ctime: time.Now().Unix(),
  1267. Status: 1,
  1268. }
  1269. err := service.UpdateChargePrintTemplate(&template)
  1270. if err != nil {
  1271. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1272. return
  1273. }
  1274. this.ServeSuccessJSON(map[string]interface{}{
  1275. "template": template,
  1276. "template_id": template_id,
  1277. })
  1278. }
  1279. }
  1280. func (this *HisProjectApiController) GetChargePrintTemplate() {
  1281. adminUserInfo := this.GetAdminUserInfo()
  1282. orgId := adminUserInfo.CurrentOrgId
  1283. template, err := service.GetChargePrintTemplate(orgId)
  1284. if err != nil {
  1285. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1286. return
  1287. }
  1288. this.ServeSuccessJSON(map[string]interface{}{
  1289. "template": template,
  1290. })
  1291. }
  1292. func (this *HisProjectApiController) GetAllHisPatient() {
  1293. record_date := this.GetString("record_date")
  1294. timeLayout := "2006-01-02"
  1295. loc, _ := time.LoadLocation("Local")
  1296. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1297. recordDateTime := theTime.Unix()
  1298. adminUserInfo := this.GetAdminUserInfo()
  1299. patients, err := service.GetScheduleHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime, 0)
  1300. if err != nil {
  1301. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1302. return
  1303. }
  1304. this.ServeSuccessJSON(map[string]interface{}{
  1305. "list": patients,
  1306. })
  1307. }
  1308. func (this *HisProjectApiController) GetChargePrint() {
  1309. record_date := this.GetString("record_date")
  1310. timeLayout := "2006-01-02"
  1311. loc, _ := time.LoadLocation("Local")
  1312. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1313. recordDateTime := theTime.Unix()
  1314. patient_id, _ := this.GetInt64("patient_id")
  1315. prescription_id, _ := this.GetInt64("prescription_id")
  1316. adminUserInfo := this.GetAdminUserInfo()
  1317. chargePrint, err := service.GetChargePrint(recordDateTime, patient_id, adminUserInfo.CurrentOrgId)
  1318. prescription, err := service.GetHisPrescriptionNight(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, prescription_id)
  1319. patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, patient_id)
  1320. hisPatient, err := service.GetHisPatientById(patient_id)
  1321. if err != nil {
  1322. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1323. return
  1324. }
  1325. this.ServeSuccessJSON(map[string]interface{}{
  1326. "list": chargePrint,
  1327. "prescription": prescription,
  1328. "patient": patient,
  1329. "hisPatient": hisPatient,
  1330. })
  1331. }
  1332. func (this *HisProjectApiController) GetTodaySchedulePatient() {
  1333. adminUserInfo := this.GetAdminUserInfo()
  1334. orgId := adminUserInfo.CurrentOrgId
  1335. recordDateStr := time.Now().Format("2006-01-02")
  1336. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1337. scheduleDate := recordDate.Unix()
  1338. patient, err := service.GetTodaySchedulePatient(orgId, scheduleDate)
  1339. if err != nil {
  1340. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1341. return
  1342. }
  1343. this.ServeSuccessJSON(map[string]interface{}{
  1344. "patient": patient,
  1345. })
  1346. }
  1347. func (this *HisProjectApiController) GetHisPatientDetail() {
  1348. patient_id, _ := this.GetInt64("patient_id")
  1349. hisPatient, err := service.GetHisPatientById(patient_id)
  1350. if err != nil {
  1351. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1352. return
  1353. }
  1354. this.ServeSuccessJSON(map[string]interface{}{
  1355. "hisPatient": hisPatient,
  1356. })
  1357. }
  1358. func (this *HisProjectApiController) GetAllDepartmentList() {
  1359. adminUserInfo := this.GetAdminUserInfo()
  1360. orgId := adminUserInfo.CurrentOrgId
  1361. departMent, err := service.GetAllDepartMent(orgId)
  1362. if err != nil {
  1363. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1364. return
  1365. }
  1366. this.ServeSuccessJSON(map[string]interface{}{
  1367. "departMent": departMent,
  1368. })
  1369. }
  1370. func (this *HisProjectApiController) GetPrescription() {
  1371. patient_id, _ := this.GetInt64("patient_id")
  1372. p_type, _ := this.GetInt64("p_type")
  1373. fmt.Println("patient_id", patient_id)
  1374. timeStr := time.Now().Format("2006-01-02")
  1375. timeLayout := "2006-01-02 15:04:05"
  1376. fmt.Println("timeStr:", timeStr)
  1377. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  1378. timenow := timeStringToTime.Unix()
  1379. list, err := service.GetPrescriptionByPatientId(patient_id, timenow, p_type)
  1380. if err != nil {
  1381. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1382. return
  1383. }
  1384. this.ServeSuccessJSON(map[string]interface{}{
  1385. "list": list,
  1386. })
  1387. }
  1388. func (this *HisProjectApiController) GetPatientDetail() {
  1389. id, _ := this.GetInt64("id")
  1390. adminUserInfo := this.GetAdminUserInfo()
  1391. patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, id)
  1392. if err != nil {
  1393. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1394. return
  1395. }
  1396. this.ServeSuccessJSON(map[string]interface{}{
  1397. "patient": patient,
  1398. })
  1399. }
  1400. func (this *HisProjectApiController) SaveMainTemplate() {
  1401. title := this.GetString("title")
  1402. content := this.GetString("content")
  1403. remark := this.GetString("remark")
  1404. template_id, _ := this.GetInt64("template_id")
  1405. adminUserInfo := this.GetAdminUserInfo()
  1406. orgId := adminUserInfo.CurrentOrgId
  1407. template := models.XtHisMedicalTemplate{
  1408. Title: title,
  1409. Content: content,
  1410. Remark: remark,
  1411. UserOrgId: orgId,
  1412. TemplateId: template_id,
  1413. Status: 1,
  1414. Ctime: time.Now().Unix(),
  1415. }
  1416. err := service.CreateHisMedicalTemplate(&template)
  1417. if err != nil {
  1418. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1419. return
  1420. }
  1421. this.ServeSuccessJSON(map[string]interface{}{
  1422. "template": template,
  1423. })
  1424. }
  1425. func (this *HisProjectApiController) GetMedicalTempalteList() {
  1426. adminUserInfo := this.GetAdminUserInfo()
  1427. orgId := adminUserInfo.CurrentOrgId
  1428. list, err := service.GetMedicalTemplateList(orgId)
  1429. listOne, err := service.GetMedicalTemplateListOne(orgId)
  1430. listTwo, err := service.GetMedicalTemplateListTwo(orgId)
  1431. listThree, err := service.GetMedicalTemplateListThree(orgId)
  1432. listFour, err := service.GetMedicalTemplateListFour(orgId)
  1433. listFive, err := service.GetMedicalTemplateListFive(orgId)
  1434. listSix, err := service.GetMedicalTemplateListSix(orgId)
  1435. listSeven, err := service.GetMedicalTemplateListSeven(orgId)
  1436. if err != nil {
  1437. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1438. return
  1439. }
  1440. this.ServeSuccessJSON(map[string]interface{}{
  1441. "list": list,
  1442. "listOne": listOne,
  1443. "listTwo": listTwo,
  1444. "listThree": listThree,
  1445. "listFour": listFour,
  1446. "listFive": listFive,
  1447. "listSix": listSix,
  1448. "listSeven": listSeven,
  1449. })
  1450. }
  1451. func (this *HisProjectApiController) GetMainTemplateById() {
  1452. id, _ := this.GetInt64("id")
  1453. template, err := service.GetMainTemplateById(id)
  1454. if err != nil {
  1455. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1456. return
  1457. }
  1458. this.ServeSuccessJSON(map[string]interface{}{
  1459. "template": template,
  1460. })
  1461. }
  1462. func (this *HisProjectApiController) UpdateMainTemplate() {
  1463. title := this.GetString("title")
  1464. content := this.GetString("content")
  1465. remark := this.GetString("remark")
  1466. id, _ := this.GetInt64("id")
  1467. template := models.XtHisMedicalTemplate{
  1468. Title: title,
  1469. Content: content,
  1470. Remark: remark,
  1471. }
  1472. err := service.UpdateMainTemplate(&template, id)
  1473. if err != nil {
  1474. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1475. return
  1476. }
  1477. this.ServeSuccessJSON(map[string]interface{}{
  1478. "template": template,
  1479. })
  1480. }
  1481. func (this *HisProjectApiController) DeleteMainTemplate() {
  1482. id, _ := this.GetInt64("id")
  1483. err := service.DeleteMainTemplateById(id)
  1484. if err != nil {
  1485. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  1486. return
  1487. }
  1488. returnData := make(map[string]interface{}, 0)
  1489. returnData["msg"] = "ok"
  1490. this.ServeSuccessJSON(returnData)
  1491. return
  1492. }