doctors_api_controller.go 58KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612
  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. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. type DoctorsApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func DoctorApiRegistRouters() {
  19. beego.Router("/api/alldoctors", &DoctorsApiController{}, "get:GetAllDoctorAndNurse")
  20. beego.Router("/api/admin/users", &DoctorsApiController{}, "get:GetAllAdminUsers")
  21. beego.Router("/api/patient/getdryweightdata", &DoctorsApiController{}, "Get:GetDryWeightData")
  22. beego.Router("/api/patient/getAllDoctor", &DoctorsApiController{}, "Get:GetAllDoctor")
  23. beego.Router("/api/patient/updatedryweightdata", &DoctorsApiController{}, "Post:UpdatedDryWeightData")
  24. beego.Router("/api/patient/getalldata", &DoctorsApiController{}, "Get:GetAllData")
  25. beego.Router("/api/paients/getdryweightdetail", &DoctorsApiController{}, "Get:GetDryWeightDetail")
  26. beego.Router("/api/patients/modifydryweightdata", &DoctorsApiController{}, "Get:ModifydryWeightData")
  27. beego.Router("/api/patient/deletedryweight", &DoctorsApiController{}, "Delete:DeleteDryWeight")
  28. beego.Router("/api/schedule/advices", &DoctorsApiController{}, "Get:ScheduleAdvices")
  29. beego.Router("/api/schedule/new/advices", &DoctorsApiController{}, "Get:GetScheduleAdvicesList")
  30. beego.Router("/api/schedule/getdoctoradvicecount", &DoctorsApiController{}, "Get:GetDoctorAdviceCount")
  31. beego.Router("/api/patient/savevasularaccess", &DoctorsApiController{}, "Get:SaveVasularAccess")
  32. beego.Router("/api/patient/getallvascualraccesslist", &DoctorsApiController{}, "Get:GetAllVacualAccessList")
  33. beego.Router("/api/patient/getvascularaccessbydetial", &DoctorsApiController{}, "Get:GetVascularAccessByDetail")
  34. beego.Router("/api/patient/updatevasularaccess", &DoctorsApiController{}, "Get:UpdateVasularAccess")
  35. beego.Router("/api/patient/deletevascularaccess", &DoctorsApiController{}, "Get:DeleteVasularAccess")
  36. beego.Router("/api/patient/savepasswayassessment", &DoctorsApiController{}, "Get:SavePassWayAssessment")
  37. beego.Router("/api/patient/getallpasswayassessment", &DoctorsApiController{}, "Get:GetAllPassWayAssessment")
  38. beego.Router("/api/patient/getpasswayassmentbyid", &DoctorsApiController{}, "Get:GetPasswayAssesmentById")
  39. beego.Router("/api/patient/updatepasswayassesment", &DoctorsApiController{}, "Get:UpdatePassWayAssesment")
  40. beego.Router("/api/patient/deletepasswayassessment", &DoctorsApiController{}, "Get:DeleteWayAssessment")
  41. beego.Router("/api/patient/getaccesslist", &DoctorsApiController{}, "Get:GetAccessList")
  42. //阶段小结路由
  43. beego.Router("/api/patient/getinspectionmajoritem", &DoctorsApiController{}, "Get:GetInspectionMajorItem")
  44. beego.Router("/api/patient/getinspectiondetail", &DoctorsApiController{}, "Get:GetInspectionDetailByProject")
  45. beego.Router("/api/patient/getinspectionitemlist", &DoctorsApiController{}, "Get:GetInspectionItemlist")
  46. beego.Router("/api/patient/getinitdatelist", &DoctorsApiController{}, "Get:GetInitDateList")
  47. beego.Router("/api/patient/savecreationinspection", &DoctorsApiController{}, "Post:SaveCreationInspection")
  48. beego.Router("/api/patient/getemlatesummarylist", &DoctorsApiController{}, "Get:GetTemplateSummaryList")
  49. beego.Router("/api/patient/gettemplatesummarydetail", &DoctorsApiController{}, "Get:GetTemplateSummaryDetail")
  50. beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
  51. beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
  52. beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
  53. beego.Router("/api/patient/hospitalsummary", &DoctorsApiController{}, "Post:HospitalSummary")
  54. beego.Router("/api/patient/gethospitalsummarylist", &DoctorsApiController{}, "Get:GetHospitalSummaryList")
  55. beego.Router("/api/patient/gethospitalsummaydetail", &DoctorsApiController{}, "Get:GetHospitalSummaryDetail")
  56. beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Post:UpdateHospitalSummary")
  57. beego.Router("/api/patient/deletehospitalsummary", &DoctorsApiController{}, "Get:DeleteHospitalSummary")
  58. beego.Router("/api/patient/getpatientinfo", &DoctorsApiController{}, "Get:GetPatientInfo")
  59. beego.Router("/api/patient/createfirstdisease", &DoctorsApiController{}, "Post:CreateFirstDisease")
  60. beego.Router("/api/patient/getfirstdiseaselist", &DoctorsApiController{}, "Get:GetFirstDiseaseList")
  61. beego.Router("/api/patient/getfirstdetailbyid", &DoctorsApiController{}, "Get:GetFirstDetailById")
  62. beego.Router("/api/patient/updatefirstdisease", &DoctorsApiController{}, "Post:UpdateFirstDisease")
  63. beego.Router("/api/patient/deletefirstdisease", &DoctorsApiController{}, "Get:DeleteFirstDisease")
  64. }
  65. func (c *DoctorsApiController) ScheduleAdvices() {
  66. schedualDate := c.GetString("date")
  67. adviceType, _ := c.GetInt("advice_type")
  68. patientType, _ := c.GetInt("patient_type")
  69. delivery_way := c.GetString("delivery_way")
  70. schedule_type, _ := c.GetInt64("schedule_type")
  71. partition_type, _ := c.GetInt64("partition_type")
  72. patient_id, _ := c.GetInt64("patient_id")
  73. excution_way, _ := c.GetInt64("excution_way")
  74. execution_frequency := c.GetString("execution_frequency")
  75. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  76. adviceType = 0
  77. }
  78. if patientType != 1 && patientType != 2 {
  79. patientType = 0
  80. }
  81. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  82. if parseDateErr != nil {
  83. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  84. return
  85. }
  86. adminUserInfo := c.GetAdminUserInfo()
  87. orgID := adminUserInfo.CurrentOrgId
  88. config, _ := service.GetHisDoctorConfig(orgID)
  89. project_config, _ := service.GetHisProjectConfig(orgID)
  90. if config.IsOpen == 0 || config.IsOpen == 2 {
  91. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency)
  92. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  93. if err != nil {
  94. c.ErrorLog("获取排班信息失败:%v", err)
  95. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  96. } else {
  97. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  98. for _, schedual := range scheduals {
  99. if len(schedual.DoctorAdvices) > 0 {
  100. filtedScheduals = append(filtedScheduals, schedual)
  101. }
  102. }
  103. c.ServeSuccessJSON(map[string]interface{}{
  104. "scheduals": filtedScheduals,
  105. "adminUser": adminUser,
  106. "config": config,
  107. "project_config": project_config,
  108. })
  109. }
  110. }
  111. if config.IsOpen == 1 {
  112. hisAdvices, err := service.GetHisDoctorAdvicesTwentyOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency)
  113. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  114. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
  115. for _, item := range project {
  116. index := 0
  117. for _, subItem := range item.HisPrescriptionTeamProject {
  118. if subItem.HisProject.CostClassify != 3 {
  119. subItem.IsCheckTeam = 2
  120. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  121. }
  122. if subItem.HisProject.CostClassify == 3 {
  123. subItem.IsCheckTeam = 1
  124. index = index + 1
  125. if index == 1 {
  126. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  127. }
  128. }
  129. }
  130. }
  131. if err != nil {
  132. c.ErrorLog("获取排班信息失败:%v", err)
  133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  134. } else {
  135. c.ServeSuccessJSON(map[string]interface{}{
  136. "adminUser": adminUser,
  137. "hisAdvices": hisAdvices,
  138. "config": config,
  139. "project_config": project_config,
  140. "project": project,
  141. })
  142. }
  143. }
  144. }
  145. func (c *DoctorsApiController) GetAllDoctorAndNurse() {
  146. adminUserInfo := c.GetAdminUserInfo()
  147. doctors, nursers, _ := service.GetAllDoctorAndNurseSix(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  148. c.ServeSuccessJSON(map[string]interface{}{
  149. "doctors": doctors,
  150. "nursers": nursers,
  151. })
  152. return
  153. }
  154. func (c *DoctorsApiController) GetAllAdminUsers() {
  155. adminUserInfo := c.GetAdminUserInfo()
  156. users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
  157. operators, _ := service.GetAdminUserEsOne(adminUserInfo.CurrentOrgId)
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "users": users,
  160. "operators": operators,
  161. })
  162. return
  163. }
  164. func (c *DoctorsApiController) GetDryWeightData() {
  165. adminUserInfo := c.GetAdminUserInfo()
  166. orgid := adminUserInfo.CurrentOrgId
  167. patientid, _ := c.GetInt64("patientid")
  168. fmt.Println("patientid", patientid)
  169. id := adminUserInfo.AdminUser.Id
  170. fmt.Println("id", id)
  171. recordDateStr := time.Now().Format("2006-01-02")
  172. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  173. fmt.Scan("parseDateErr", parseDateErr)
  174. nowtime := recordDate.Unix()
  175. fmt.Println("nowtime", nowtime)
  176. pre, err := service.GetDryWeightByPatientId(patientid, orgid)
  177. fmt.Println("错误", err)
  178. c.ServeSuccessJSON(map[string]interface{}{
  179. "pre": pre,
  180. })
  181. }
  182. func (c *DoctorsApiController) GetAllDoctor() {
  183. adminUserInfo := c.GetAdminUserInfo()
  184. orgid := adminUserInfo.CurrentOrgId
  185. appid := adminUserInfo.CurrentAppId
  186. fmt.Println("appid", appid)
  187. appRole, err := service.GetAllDoctor(orgid, appid)
  188. fmt.Println("appRole", appRole)
  189. fmt.Println("错误", err)
  190. c.ServeSuccessJSON(map[string]interface{}{
  191. "appRole": appRole,
  192. })
  193. }
  194. func (c *DoctorsApiController) UpdatedDryWeightData() {
  195. adminUserInfo := c.GetAdminUserInfo()
  196. orgid := adminUserInfo.CurrentOrgId
  197. userid := adminUserInfo.AdminUser.Id
  198. dry_weight, _ := c.GetFloat("dry_weight")
  199. doctors, _ := c.GetInt64("doctors")
  200. remarks := c.GetString("remarks")
  201. patientid, _ := c.GetInt64("patient_id")
  202. //透前数据
  203. dryweight, _ := c.GetFloat("dryweight")
  204. var weight = dryweight - dry_weight
  205. weights := fmt.Sprintf("%.1f", weight)
  206. var sum string
  207. _, errcode := service.QueryDryWeight(orgid, patientid)
  208. if errcode == gorm.ErrRecordNotFound {
  209. sum = "/"
  210. patientDryweight := models.SgjPatientDryweight{
  211. DryWeight: dry_weight,
  212. Creator: doctors,
  213. Remakes: remarks,
  214. AdjustedValue: sum,
  215. PatientId: patientid,
  216. Ctime: time.Now().Unix(),
  217. UserOrgId: orgid,
  218. Status: 1,
  219. UserId: userid,
  220. }
  221. err := service.CreatePatientWeight(&patientDryweight)
  222. loc, _ := time.LoadLocation("Local")
  223. nowTime := time.Now()
  224. nowDay := nowTime.Format("2006-01-02")
  225. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  226. redis := service.RedisClient()
  227. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  228. redis.Set(keyTwo, "", time.Second)
  229. prescription := models.PredialysisEvaluation{
  230. DryWeight: dry_weight,
  231. AssessmentDate: dayTime.Unix(),
  232. }
  233. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  234. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  235. fmt.Println(errors)
  236. }
  237. keyThree := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  238. redis.Set(keyThree, "", time.Second)
  239. keyFive := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  240. redis.Set(keyFive, "", time.Second)
  241. redis.Close()
  242. fmt.Println("err", err)
  243. c.ServeSuccessJSON(map[string]interface{}{
  244. "patientDryweight": patientDryweight,
  245. })
  246. return
  247. }
  248. fmt.Println("sum", sum)
  249. if weight == 0 {
  250. sum = "/"
  251. }
  252. if weight > 0 {
  253. sum = weights + "(" + "下调" + ")"
  254. }
  255. if weight < 0 {
  256. var sums = dry_weight - dryweight
  257. float := fmt.Sprintf("%.1f", sums)
  258. //float := strconv.FormatFloat(sums, 'E', -1, 64)
  259. sum = float + "(" + "上调" + ")"
  260. }
  261. patientDryweight := models.SgjPatientDryweight{
  262. DryWeight: dry_weight,
  263. Creator: doctors,
  264. Remakes: remarks,
  265. AdjustedValue: sum,
  266. PatientId: patientid,
  267. Ctime: time.Now().Unix(),
  268. UserOrgId: orgid,
  269. Status: 1,
  270. UserId: userid,
  271. }
  272. err := service.CreatePatientWeight(&patientDryweight)
  273. recordDateStr := time.Now().Format("2006-01-02")
  274. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  275. fmt.Scan("parseDateErr", parseDateErr)
  276. nowtime := recordDate.Unix()
  277. fmt.Println("nowtime", nowtime)
  278. loc, _ := time.LoadLocation("Local")
  279. nowTime := time.Now()
  280. nowDay := nowTime.Format("2006-01-02")
  281. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  282. redis := service.RedisClient()
  283. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  284. redis.Set(keyTwo, "", time.Second)
  285. prescription := models.PredialysisEvaluation{
  286. DryWeight: dry_weight,
  287. AssessmentDate: dayTime.Unix(),
  288. }
  289. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  290. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  291. fmt.Println(errors)
  292. }
  293. key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  294. redis.Set(key, "", time.Second)
  295. keySix := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  296. redis.Set(keySix, "", time.Second)
  297. fmt.Println("err", err)
  298. redis.Close()
  299. c.ServeSuccessJSON(map[string]interface{}{
  300. "patientDryweight": patientDryweight,
  301. })
  302. }
  303. func (c *DoctorsApiController) GetAllData() {
  304. id, _ := c.GetInt64("id")
  305. page, _ := c.GetInt64("page")
  306. fmt.Println("page", page)
  307. limit, _ := c.GetInt64("limit")
  308. fmt.Println("limit", limit)
  309. fmt.Println("id", id)
  310. adminUserInfo := c.GetAdminUserInfo()
  311. orgid := adminUserInfo.CurrentOrgId
  312. dry, total, _ := service.GetAllData(orgid, id, page, limit)
  313. c.ServeSuccessJSON(map[string]interface{}{
  314. "dry": dry,
  315. "total": total,
  316. })
  317. }
  318. func (c *DoctorsApiController) GetDryWeightDetail() {
  319. id, _ := c.GetInt64("id")
  320. dryweight, _ := service.GetDryWeightDetailById(id)
  321. c.ServeSuccessJSON(map[string]interface{}{
  322. "dryweight": dryweight,
  323. })
  324. }
  325. func (c *DoctorsApiController) ModifydryWeightData() {
  326. adjustvalue := c.GetString("adjustvalue")
  327. creator, _ := c.GetInt64("creator")
  328. dryweight, _ := c.GetInt64("dryweight")
  329. dry := strconv.FormatInt(dryweight, 10)
  330. dry_weight, _ := strconv.ParseFloat(dry, 64)
  331. id, _ := c.GetInt64("id")
  332. remark := c.GetString("remark")
  333. patientDryweight := models.SgjPatientDryweight{
  334. AdjustedValue: adjustvalue,
  335. Creator: creator,
  336. DryWeight: dry_weight,
  337. Remakes: remark,
  338. }
  339. service.ModifyDryWeightData(&patientDryweight, id)
  340. c.ServeSuccessJSON(map[string]interface{}{
  341. "patientDryweight": patientDryweight,
  342. })
  343. }
  344. func (c *DoctorsApiController) DeleteDryWeight() {
  345. id, _ := c.GetInt64("id")
  346. service.DeleteDryWeight(id)
  347. returnData := make(map[string]interface{}, 0)
  348. returnData["msg"] = "ok"
  349. c.ServeSuccessJSON(returnData)
  350. return
  351. }
  352. func (c *DoctorsApiController) GetDoctorAdviceCount() {
  353. timeLayout := "2006-01-02"
  354. loc, _ := time.LoadLocation("Local")
  355. start_time := c.GetString("start_time")
  356. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  357. end_time := c.GetString("end_time")
  358. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  359. delive_way := c.GetString("delive_way")
  360. adminUserInfo := c.GetAdminUserInfo()
  361. orgId := adminUserInfo.CurrentOrgId
  362. list, _ := service.GetDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  363. if len(list) == 0 {
  364. list, _ := service.GetHisDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  365. c.ServeSuccessJSON(map[string]interface{}{
  366. "list": list,
  367. })
  368. } else {
  369. c.ServeSuccessJSON(map[string]interface{}{
  370. "list": list,
  371. })
  372. }
  373. }
  374. func (this *DoctorsApiController) SaveVasularAccess() {
  375. access_project, _ := this.GetInt64("access_project")
  376. blood_access_part_id := this.GetString("blood_access_part_id")
  377. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  378. first_start_time := this.GetString("first_start_time")
  379. timeLayout := "2006-01-02"
  380. loc, _ := time.LoadLocation("Local")
  381. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  382. inflow_pass := this.GetString("inflow_pass")
  383. remark := this.GetString("remark")
  384. start_time := this.GetString("start_time")
  385. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  386. stop_reason := this.GetString("stop_reason")
  387. user_status, _ := this.GetInt64("user_status")
  388. stop_time := this.GetString("stop_time")
  389. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  390. patient_id, _ := this.GetInt64("patient_id")
  391. other_vascular := this.GetString("other_vascular")
  392. ci_type, _ := this.GetInt64("ci_type")
  393. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  394. sequelae_type, _ := this.GetInt64("sequelae_type")
  395. adminUserInfo := this.GetAdminUserInfo()
  396. orgId := adminUserInfo.CurrentOrgId
  397. creator := adminUserInfo.AdminUser.Id
  398. //查询改日期是否存在
  399. access := models.XtPatientVascularAccess{
  400. AccessProject: access_project,
  401. BloodAccessPartId: blood_access_part_id,
  402. BloodAccessPartOperaId: blood_access_part_opera_id,
  403. FirstStartTime: firstStartTime.Unix(),
  404. InflowPass: inflow_pass,
  405. Remark: remark,
  406. StartTime: startTime.Unix(),
  407. StopReason: stop_reason,
  408. UserStatus: user_status,
  409. Creator: creator,
  410. UserOrgId: orgId,
  411. Status: 1,
  412. Ctime: time.Now().Unix(),
  413. StopTime: stopTime.Unix(),
  414. PatientId: patient_id,
  415. OtherVascular: other_vascular,
  416. CiType: ci_type,
  417. BloodCultupe: blood_cultupe,
  418. SequelaeType: sequelae_type,
  419. }
  420. err := service.SaveVascularAccess(&access)
  421. if err == nil {
  422. this.ServeSuccessJSON(map[string]interface{}{
  423. "access": access,
  424. })
  425. return
  426. //_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  427. //if errcode == gorm.ErrRecordNotFound {
  428. // access := models.XtPatientVascularAccess{
  429. // AccessProject: access_project,
  430. // BloodAccessPartId: blood_access_part_id,
  431. // BloodAccessPartOperaId: blood_access_part_opera_id,
  432. // FirstStartTime: firstStartTime.Unix(),
  433. // InflowPass: inflow_pass,
  434. // Remark: remark,
  435. // StartTime: startTime.Unix(),
  436. // StopReason: stop_reason,
  437. // UserStatus: user_status,
  438. // Creator: creator,
  439. // UserOrgId: orgId,
  440. // Status: 1,
  441. // Ctime: time.Now().Unix(),
  442. // StopTime: stopTime.Unix(),
  443. // PatientId: patient_id,
  444. // OtherVascular: other_vascular,
  445. // CiType: ci_type,
  446. // BloodCultupe: blood_cultupe,
  447. // SequelaeType: sequelae_type,
  448. // }
  449. // err := service.SaveVascularAccess(&access)
  450. // if err == nil {
  451. // this.ServeSuccessJSON(map[string]interface{}{
  452. // "access": access,
  453. // })
  454. // return
  455. // }
  456. //} else if errcode == nil {
  457. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  458. // return
  459. }
  460. }
  461. func (this *DoctorsApiController) GetAllVacualAccessList() {
  462. limit, _ := this.GetInt64("limit")
  463. page, _ := this.GetInt64("page")
  464. patient_id, _ := this.GetInt64("patient_id")
  465. orgId := this.GetAdminUserInfo().CurrentOrgId
  466. appId := this.GetAdminUserInfo().CurrentAppId
  467. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  468. doctor, err := service.GetAllDoctor(orgId, appId)
  469. if err == nil {
  470. this.ServeSuccessJSON(map[string]interface{}{
  471. "list": list,
  472. "total": total,
  473. "doctor": doctor,
  474. })
  475. return
  476. }
  477. }
  478. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  479. id, _ := this.GetInt64("id")
  480. accessDetail, err := service.GetVasularAccessByDetail(id)
  481. orgId := this.GetAdminUserInfo().CurrentOrgId
  482. appId := this.GetAdminUserInfo().CurrentAppId
  483. doctor, err := service.GetAllDoctor(orgId, appId)
  484. if err == nil {
  485. this.ServeSuccessJSON(map[string]interface{}{
  486. "accessDetail": accessDetail,
  487. "doctor": doctor,
  488. })
  489. return
  490. }
  491. }
  492. func (this *DoctorsApiController) UpdateVasularAccess() {
  493. id, _ := this.GetInt64("id")
  494. access_project, _ := this.GetInt64("access_project")
  495. blood_access_part_id := this.GetString("blood_access_part_id")
  496. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  497. first_start_time := this.GetString("first_start_time")
  498. timeLayout := "2006-01-02"
  499. loc, _ := time.LoadLocation("Local")
  500. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  501. inflow_pass := this.GetString("inflow_pass")
  502. remark := this.GetString("remark")
  503. start_time := this.GetString("start_time")
  504. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  505. stop_reason := this.GetString("stop_reason")
  506. user_status, _ := this.GetInt64("user_status")
  507. stop_time := this.GetString("stop_time")
  508. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  509. adminUserInfo := this.GetAdminUserInfo()
  510. orgId := adminUserInfo.CurrentOrgId
  511. creator := adminUserInfo.AdminUser.Id
  512. patientId, _ := this.GetInt64("patient_id")
  513. other_vascular := this.GetString("other_vascular")
  514. ci_type, _ := this.GetInt64("ci_type")
  515. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  516. sequelae_type, _ := this.GetInt64("sequelae_type")
  517. access := models.XtPatientVascularAccess{
  518. AccessProject: access_project,
  519. BloodAccessPartId: blood_access_part_id,
  520. BloodAccessPartOperaId: blood_access_part_opera_id,
  521. FirstStartTime: firstStartTime.Unix(),
  522. InflowPass: inflow_pass,
  523. Remark: remark,
  524. StartTime: startTime.Unix(),
  525. StopReason: stop_reason,
  526. UserStatus: user_status,
  527. Modify: creator,
  528. UserOrgId: orgId,
  529. Status: 1,
  530. StopTime: stopTime.Unix(),
  531. OtherVascular: other_vascular,
  532. CiType: ci_type,
  533. BloodCultupe: blood_cultupe,
  534. SequelaeType: sequelae_type,
  535. PatientId: patientId,
  536. }
  537. err := service.UpdateVascularAccess(&access, id)
  538. if err == nil {
  539. this.ServeSuccessJSON(map[string]interface{}{
  540. "access": access,
  541. })
  542. return
  543. }
  544. //_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  545. //if errcode == gorm.ErrRecordNotFound {
  546. // err := service.UpdateVascularAccess(&access, id)
  547. // if err == nil {
  548. // this.ServeSuccessJSON(map[string]interface{}{
  549. // "access": access,
  550. // })
  551. // return
  552. // }
  553. //} else if errcode == nil {
  554. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  555. // return
  556. //}
  557. }
  558. func (this *DoctorsApiController) DeleteVasularAccess() {
  559. id, _ := this.GetInt64("id")
  560. err := service.DeleteVasularAccess(id)
  561. fmt.Println(err)
  562. returnData := make(map[string]interface{}, 0)
  563. returnData["msg"] = "ok"
  564. this.ServeSuccessJSON(returnData)
  565. return
  566. }
  567. func (this *DoctorsApiController) SavePassWayAssessment() {
  568. blood_dealwidth := this.GetString("blood_dealwith")
  569. blood_project := this.GetString("blood_project")
  570. blood_result := this.GetString("blood_result")
  571. creator, _ := this.GetInt64("creator")
  572. parent_id, _ := this.GetInt64("parent_id")
  573. patient_id, _ := this.GetInt64("patient_id")
  574. start_time := this.GetString("start_time")
  575. timeLayout := "2006-01-02"
  576. loc, _ := time.LoadLocation("Local")
  577. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  578. modify := this.GetAdminUserInfo().AdminUser.Id
  579. orgId := this.GetAdminUserInfo().CurrentOrgId
  580. assessment := models.XtPatientPasswayAssessment{
  581. StartTime: startTime.Unix(),
  582. BloodDealwith: blood_dealwidth,
  583. BloodProject: blood_project,
  584. BloodResult: blood_result,
  585. Creator: creator,
  586. PatientId: patient_id,
  587. ParentId: parent_id,
  588. Modify: modify,
  589. UserOrgId: orgId,
  590. Status: 1,
  591. Ctime: time.Now().Unix(),
  592. }
  593. err := service.CreatePatientWayAssessment(&assessment)
  594. if err == nil {
  595. this.ServeSuccessJSON(map[string]interface{}{
  596. "assessment": assessment,
  597. })
  598. return
  599. }
  600. }
  601. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  602. patient_id, _ := this.GetInt64("patient_id")
  603. parent_id, _ := this.GetInt64("parent_id")
  604. page, _ := this.GetInt64("page")
  605. limit, _ := this.GetInt64("limit")
  606. adminUserInfo := this.GetAdminUserInfo()
  607. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  608. if err == nil {
  609. this.ServeSuccessJSON(map[string]interface{}{
  610. "list": list,
  611. "total": total,
  612. })
  613. return
  614. }
  615. }
  616. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  617. id, _ := this.GetInt64("id")
  618. assessment, err := service.GetPasswayAssesmentById(id)
  619. if err == nil {
  620. this.ServeSuccessJSON(map[string]interface{}{
  621. "assessment": assessment,
  622. })
  623. return
  624. }
  625. }
  626. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  627. id, _ := this.GetInt64("id")
  628. blood_dealwidth := this.GetString("blood_dealwith")
  629. blood_project := this.GetString("blood_project")
  630. blood_result := this.GetString("blood_result")
  631. creator, _ := this.GetInt64("creator")
  632. start_time := this.GetString("start_time")
  633. timeLayout := "2006-01-02"
  634. loc, _ := time.LoadLocation("Local")
  635. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  636. modify := this.GetAdminUserInfo().AdminUser.Id
  637. assessment := models.XtPatientPasswayAssessment{
  638. BloodResult: blood_result,
  639. BloodDealwith: blood_dealwidth,
  640. BloodProject: blood_project,
  641. Creator: creator,
  642. StartTime: startTime.Unix(),
  643. Modify: modify,
  644. }
  645. err := service.UpdatePassWayAssesment(&assessment, id)
  646. if err == nil {
  647. this.ServeSuccessJSON(map[string]interface{}{
  648. "assessment": assessment,
  649. })
  650. return
  651. }
  652. }
  653. func (this *DoctorsApiController) DeleteWayAssessment() {
  654. id, _ := this.GetInt64("id")
  655. err := service.DeleteWayAssessment(id)
  656. fmt.Println(err)
  657. returnData := make(map[string]interface{}, 0)
  658. returnData["msg"] = "ok"
  659. this.ServeSuccessJSON(returnData)
  660. return
  661. }
  662. func (this *DoctorsApiController) GetAccessList() {
  663. adminUserInfo := this.GetAdminUserInfo()
  664. orgId := adminUserInfo.CurrentOrgId
  665. //血管通路
  666. list, err := service.GetAccessList(orgId)
  667. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  668. //血管通路部位
  669. access, err := service.GetBloodAccess(orgId)
  670. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  671. if err == nil {
  672. this.ServeSuccessJSON(map[string]interface{}{
  673. "blood_access_part_opera": blood_access_part_opera,
  674. "blood_access_part": blood_access_part,
  675. })
  676. return
  677. }
  678. }
  679. func (this *DoctorsApiController) GetInspectionMajorItem() {
  680. other_start_time := this.GetString("other_start_time")
  681. last_time := this.GetString("last_time")
  682. timeLayout := "2006-01-02"
  683. loc, _ := time.LoadLocation("Local")
  684. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
  685. lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
  686. patient_id, _ := this.GetInt64("patient_id")
  687. adminUserInfo := this.GetAdminUserInfo()
  688. orgId := adminUserInfo.CurrentOrgId
  689. list, err := service.GetInspectionMajorItem(startTime.Unix(), lastTime.Unix(), orgId, patient_id)
  690. if err == nil {
  691. this.ServeSuccessJSON(map[string]interface{}{
  692. "list": list,
  693. })
  694. return
  695. }
  696. }
  697. func (this *DoctorsApiController) GetInspectionDetailByProject() {
  698. project_id, _ := this.GetInt64("project_id")
  699. patient_id, _ := this.GetInt64("patient_id")
  700. inspect_date, _ := this.GetInt64("inspect_date")
  701. orgId := this.GetAdminUserInfo().CurrentOrgId
  702. list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
  703. if err == nil {
  704. this.ServeSuccessJSON(map[string]interface{}{
  705. "list": list,
  706. })
  707. return
  708. }
  709. }
  710. func (this *DoctorsApiController) GetInspectionItemlist() {
  711. patient_id, _ := this.GetInt64("patient_id")
  712. ids := this.GetString("ids")
  713. inspect_date := this.GetString("inspect_date")
  714. idSplit := strings.Split(ids, ",")
  715. indateSplit := strings.Split(inspect_date, ",")
  716. list, err := service.GetInspectionItemlist(patient_id, indateSplit, idSplit)
  717. if err == nil {
  718. this.ServeSuccessJSON(map[string]interface{}{
  719. "list": list,
  720. })
  721. return
  722. }
  723. }
  724. func (this *DoctorsApiController) GetInitDateList() {
  725. patient_id, _ := this.GetInt64("patient_id")
  726. start_time := this.GetString("start_time")
  727. timeLayout := "2006-01-02"
  728. loc, _ := time.LoadLocation("Local")
  729. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  730. end_time := this.GetString("end_time")
  731. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  732. fmt.Println("endtime2323232233223232332", endTime)
  733. prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id, startTime.Unix(), endTime.Unix())
  734. befor_list, err := service.GetDialysisBeforInitDateList(patient_id, startTime.Unix(), endTime.Unix())
  735. after_list, err := service.GetDialysisAssementAfter(patient_id, startTime.Unix(), endTime.Unix())
  736. orgId := this.GetAdminUserInfo().CurrentOrgId
  737. //统计透析次数
  738. modelist, err := service.GetDialysisDialysisMode(patient_id, startTime.Unix(), endTime.Unix(), orgId)
  739. docList, _ := service.GetAllDoctorThree(orgId)
  740. stockType, err := service.GetStockType(orgId)
  741. summaryList, err := service.GetTemplateSummary(orgId)
  742. planList, err := service.GetTemplatePlan(orgId)
  743. if err == nil {
  744. this.ServeSuccessJSON(map[string]interface{}{
  745. "beforlist": befor_list,
  746. "prescription_list": prescription_list,
  747. "after_list": after_list,
  748. "modelist": modelist,
  749. "docList": docList,
  750. "stockType": stockType,
  751. "summaryList": summaryList,
  752. "planList": planList,
  753. })
  754. return
  755. }
  756. }
  757. func (this *DoctorsApiController) SaveCreationInspection() {
  758. dataBody := make(map[string]interface{}, 0)
  759. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  760. if err != nil {
  761. utils.ErrorLog(err.Error())
  762. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  763. return
  764. }
  765. title := dataBody["title"].(string)
  766. dryWeight := dataBody["dry_weight"].(string)
  767. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  768. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  769. hd_count := int64(dataBody["hd_count"].(float64))
  770. hdf_count := int64(dataBody["hdf_count"].(float64))
  771. hp_count := int64(dataBody["hp_count"].(float64))
  772. other_count := int64(dataBody["other_count"].(float64))
  773. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  774. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  775. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  776. kaliumstr := dataBody["kalium"].(string)
  777. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  778. autunitestr := dataBody["autunite"].(string)
  779. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  780. natriumstr := dataBody["natrium"].(string)
  781. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  782. hour := int64(dataBody["hour"].(float64))
  783. minute := int64(dataBody["minute"].(float64))
  784. beforWeight := dataBody["befor_weight"].(string)
  785. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  786. afterWeight := dataBody["after_weight"].(string)
  787. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  788. befor_pressure := dataBody["befor_pressure"].(string)
  789. template_summary_content := dataBody["template_summary_content"].(string)
  790. template_plan_content := dataBody["template_plan_content"].(string)
  791. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  792. record_time := dataBody["record_time"].(string)
  793. timeLayout := "2006-01-02"
  794. loc, _ := time.LoadLocation("Local")
  795. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  796. after_pressure := dataBody["after_pressure"].(string)
  797. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  798. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  799. patient_id := int64(dataBody["patient_id"].(float64))
  800. orgId := this.GetAdminUserInfo().CurrentOrgId
  801. inspect_date := dataBody["inspect_date"].(string)
  802. project_id := dataBody["project_id"].(string)
  803. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  804. summary := models.XtTemplateSummary{
  805. StartYear: 0,
  806. StartMonth: 0,
  807. Radio: 0,
  808. Quarter: 0,
  809. DryWeight: dry_weight,
  810. DialysisCount: dialysis_count,
  811. HdCount: hd_count,
  812. HdfCount: hdf_count,
  813. HpCount: hp_count,
  814. OtherCount: other_count,
  815. DialzerApparatus: dialzer_apparatus,
  816. PerfusionApparatus: perfusion_apparatus,
  817. Anticoagulant: anticoagulant,
  818. Kalium: kalium,
  819. Autunite: autunite,
  820. Natrium: natrium,
  821. Hour: hour,
  822. Minute: minute,
  823. BeforWeight: befor_weight,
  824. AfterWeight: after_weight,
  825. BeforPressure: befor_pressure,
  826. AfterPressure: after_pressure,
  827. TemplateSummaryId: template_summary_id,
  828. TemplateSummaryContent: template_summary_content,
  829. TemplatePlanId: template_plan_id,
  830. TemplatePlanContent: template_plan_content,
  831. TemplateInspectionId: template_inspection_id,
  832. AdminUserId: admin_user_id,
  833. RecordTime: recordTime.Unix(),
  834. PatientId: patient_id,
  835. UserOrgId: orgId,
  836. Status: 1,
  837. Ctime: time.Now().Unix(),
  838. Mtime: 0,
  839. Title: title,
  840. InspectDate: inspect_date,
  841. ProjectId: project_id,
  842. }
  843. err = service.CreateSummary(&summary)
  844. if err == nil {
  845. this.ServeSuccessJSON(map[string]interface{}{
  846. "summary": summary,
  847. })
  848. return
  849. }
  850. }
  851. func (this *DoctorsApiController) GetTemplateSummaryList() {
  852. patient_id, _ := this.GetInt64("patient_id")
  853. start_time := this.GetString("start_time")
  854. timeLayout := "2006-01-02"
  855. loc, _ := time.LoadLocation("Local")
  856. end_time := this.GetString("end_time")
  857. orgId := this.GetAdminUserInfo().CurrentOrgId
  858. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  859. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  860. list, err := service.GetTemplateSummaryList(patient_id, orgId, startTime.Unix(), endTime.Unix())
  861. if err == nil {
  862. this.ServeSuccessJSON(map[string]interface{}{
  863. "list": list,
  864. })
  865. return
  866. }
  867. }
  868. func (this *DoctorsApiController) GetTemplateSummaryDetail() {
  869. id, _ := this.GetInt64("id")
  870. list, err := service.GetTemplateSummaryDetail(id)
  871. ids := strings.Split(list.ProjectId, ",")
  872. datelist := strings.Split(list.InspectDate, ",")
  873. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  874. if err == nil {
  875. this.ServeSuccessJSON(map[string]interface{}{
  876. "list": list,
  877. "inspectlist": inspectlist,
  878. })
  879. return
  880. }
  881. }
  882. func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
  883. id, _ := this.GetInt64("id")
  884. list, err := service.GetTemplateSummaryPrintDetail(id)
  885. ids := strings.Split(list.ProjectId, ",")
  886. datelist := strings.Split(list.InspectDate, ",")
  887. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  888. orgId := this.GetAdminUserInfo().CurrentOrgId
  889. doctorList, _ := service.GetAllDoctorThree(orgId)
  890. if err == nil {
  891. this.ServeSuccessJSON(map[string]interface{}{
  892. "list": list,
  893. "doctorList": doctorList,
  894. "inspectlist": inspectlist,
  895. })
  896. return
  897. }
  898. }
  899. func (this *DoctorsApiController) UpdateTempalteSummary() {
  900. dataBody := make(map[string]interface{}, 0)
  901. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  902. if err != nil {
  903. utils.ErrorLog(err.Error())
  904. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  905. return
  906. }
  907. id := int64(dataBody["id"].(float64))
  908. title := dataBody["title"].(string)
  909. dryWeight := dataBody["dry_weight"].(string)
  910. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  911. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  912. hd_count := int64(dataBody["hd_count"].(float64))
  913. hdf_count := int64(dataBody["hdf_count"].(float64))
  914. hp_count := int64(dataBody["hp_count"].(float64))
  915. other_count := int64(dataBody["other_count"].(float64))
  916. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  917. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  918. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  919. kaliumstr := dataBody["kalium"].(string)
  920. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  921. autunitestr := dataBody["autunite"].(string)
  922. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  923. natriumstr := dataBody["natrium"].(string)
  924. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  925. hour := int64(dataBody["hour"].(float64))
  926. minute := int64(dataBody["minute"].(float64))
  927. beforWeight := dataBody["befor_weight"].(string)
  928. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  929. afterWeight := dataBody["after_weight"].(string)
  930. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  931. befor_pressure := dataBody["befor_pressure"].(string)
  932. template_summary_content := dataBody["template_summary_content"].(string)
  933. template_plan_content := dataBody["template_plan_content"].(string)
  934. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  935. record_time := dataBody["record_time"].(string)
  936. timeLayout := "2006-01-02"
  937. loc, _ := time.LoadLocation("Local")
  938. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  939. after_pressure := dataBody["after_pressure"].(string)
  940. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  941. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  942. patient_id := int64(dataBody["patient_id"].(float64))
  943. orgId := this.GetAdminUserInfo().CurrentOrgId
  944. inspect_date := dataBody["inspect_date"].(string)
  945. project_id := dataBody["project_id"].(string)
  946. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  947. //dryWeight := this.GetString("dry_weight")
  948. //dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  949. //dialysis_count, _ := this.GetInt64("dialysis_count")
  950. //hd_count, _ := this.GetInt64("hd_count")
  951. //hdf_count, _ := this.GetInt64("hdf_count")
  952. //hp_count, _ := this.GetInt64("hp_count")
  953. //other_count, _ := this.GetInt64("other_count")
  954. //dialzer_apparatus := this.GetString("dialzer_apparatus")
  955. //perfusion_apparatus := this.GetString("perfusion_apparatus")
  956. //anticoagulant, _ := this.GetInt64("anticoagulant")
  957. //kaliumstr := this.GetString("kalium")
  958. //kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  959. //
  960. //autunitestr := this.GetString("autunite")
  961. //autunite, _ := strconv.ParseFloat(autunitestr, 64)
  962. //natriumstr := this.GetString("natrium")
  963. //natrium, _ := strconv.ParseFloat(natriumstr, 64)
  964. //hour, _ := this.GetInt64("hour")
  965. //minute, _ := this.GetInt64("minute")
  966. //beforWeight := this.GetString("befor_weight")
  967. //befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  968. //afterWeight := this.GetString("after_weight")
  969. //after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  970. //befor_pressure := this.GetString("befor_pressure")
  971. //template_summary_content := this.GetString("template_summary_content")
  972. //template_plan_content := this.GetString("template_plan_content")
  973. //admin_user_id, _ := this.GetInt64("admin_user_id")
  974. //record_time := this.GetString("record_time")
  975. //timeLayout := "2006-01-02"
  976. //loc, _ := time.LoadLocation("Local")
  977. //recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  978. //after_pressure := this.GetString("after_pressure")
  979. //template_summary_id, _ := this.GetInt64("template_summary_id")
  980. //template_plan_id, _ := this.GetInt64("template_plan_id")
  981. //template_inspection_id, _ := this.GetInt64("template_inspection_id")
  982. //patient_id, _ := this.GetInt64("patient_id")
  983. //fmt.Println("patient_id", patient_id)
  984. //orgId := this.GetAdminUserInfo().CurrentOrgId
  985. //inspect_date := this.GetString("inspect_date")
  986. //project_id := this.GetString("project_id")
  987. summary := models.XtTemplateSummary{
  988. ID: id,
  989. StartYear: 0,
  990. StartMonth: 0,
  991. Radio: 0,
  992. Quarter: 0,
  993. DryWeight: dry_weight,
  994. DialysisCount: dialysis_count,
  995. HdCount: hd_count,
  996. HdfCount: hdf_count,
  997. HpCount: hp_count,
  998. OtherCount: other_count,
  999. DialzerApparatus: dialzer_apparatus,
  1000. PerfusionApparatus: perfusion_apparatus,
  1001. Anticoagulant: anticoagulant,
  1002. Kalium: kalium,
  1003. Autunite: autunite,
  1004. Natrium: natrium,
  1005. Hour: hour,
  1006. Minute: minute,
  1007. BeforWeight: befor_weight,
  1008. AfterWeight: after_weight,
  1009. BeforPressure: befor_pressure,
  1010. AfterPressure: after_pressure,
  1011. TemplateSummaryId: template_summary_id,
  1012. TemplateSummaryContent: template_summary_content,
  1013. TemplatePlanId: template_plan_id,
  1014. TemplatePlanContent: template_plan_content,
  1015. TemplateInspectionId: template_inspection_id,
  1016. AdminUserId: admin_user_id,
  1017. RecordTime: recordTime.Unix(),
  1018. PatientId: patient_id,
  1019. UserOrgId: orgId,
  1020. Status: 1,
  1021. Ctime: time.Now().Unix(),
  1022. Mtime: 0,
  1023. Title: title,
  1024. ProjectId: project_id,
  1025. InspectDate: inspect_date,
  1026. }
  1027. err = service.UpdateTempalteSummary(&summary)
  1028. if err == nil {
  1029. this.ServeSuccessJSON(map[string]interface{}{
  1030. "list": summary,
  1031. })
  1032. return
  1033. }
  1034. }
  1035. func (this *DoctorsApiController) DeleteSummary() {
  1036. ids := this.GetString("ids")
  1037. idsplit := strings.Split(ids, ",")
  1038. err := service.DeleteSummary(idsplit)
  1039. fmt.Println(err)
  1040. returnData := make(map[string]interface{}, 0)
  1041. returnData["msg"] = "ok"
  1042. this.ServeSuccessJSON(returnData)
  1043. return
  1044. }
  1045. func (this *DoctorsApiController) HospitalSummary() {
  1046. timeLayout := "2006-01-02"
  1047. loc, _ := time.LoadLocation("Local")
  1048. dataBody := make(map[string]interface{}, 0)
  1049. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1050. fmt.Print("err", err)
  1051. admission_time := dataBody["admission_time"].(string)
  1052. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1053. admissiontime := admissionTimes.Unix()
  1054. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1055. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1056. connecticut := dataBody["connecticut"].(string)
  1057. dean := int64(dataBody["dean"].(float64))
  1058. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1059. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1060. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1061. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1062. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1063. discharge_advice := dataBody["discharge_advice"].(string)
  1064. discharge_time := dataBody["discharge_time"].(string)
  1065. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1066. dischargetime := dischargeTimes.Unix()
  1067. doctor := int64(dataBody["doctor"].(float64))
  1068. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1069. illness_discharge := dataBody["illness_discharge"].(string)
  1070. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1071. pathology := dataBody["pathology"].(string)
  1072. record_date := dataBody["record_date"].(string)
  1073. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1074. recordtime := recordDates.Unix()
  1075. sick_personnel := dataBody["sick_personnel"].(string)
  1076. title := dataBody["title"].(string)
  1077. treatment_id := dataBody["treatment_id"].(string)
  1078. treatment := dataBody["treatment"].(string)
  1079. ultrasound := dataBody["ultrasound"].(string)
  1080. xray := dataBody["xray"].(string)
  1081. patient_id := int64(dataBody["patient_id"].(float64))
  1082. orgId := this.GetAdminUserInfo().CurrentOrgId
  1083. summary := models.XtHospitalSummary{
  1084. PatientId: patient_id,
  1085. AdmissionTime: admissiontime,
  1086. DischargeTime: dischargetime,
  1087. SickPersonnel: sick_personnel,
  1088. Xray: xray,
  1089. Connecticut: connecticut,
  1090. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1091. Ultrasound: ultrasound,
  1092. Pathology: pathology,
  1093. AdmittingDiagnosisId: admitting_diagnosis_id,
  1094. AdmittingDiagnosis: admitting_diagnosis,
  1095. DischargeDiagnosis: discharge_diagnosis,
  1096. DiagnosisAdmissionId: diagnosis_admission_id,
  1097. DiagnosisAdmission: diagnosis_admission,
  1098. TreatmentId: treatment_id,
  1099. Treatment: treatment,
  1100. IllnessDischargeId: illness_discharge_id,
  1101. IllnessDischarge: illness_discharge,
  1102. DischargeAdviceId: discharge_advice_id,
  1103. DischargeAdvice: discharge_advice,
  1104. UserOrgId: orgId,
  1105. Status: 1,
  1106. Ctime: time.Now().Unix(),
  1107. Mtime: 0,
  1108. RecordTime: recordtime,
  1109. Title: title,
  1110. Doctor: doctor,
  1111. RecordDate: recordtime,
  1112. DeanId: dean,
  1113. DischargeDiagnosisId: discharge_diagnosis_id,
  1114. }
  1115. service.CreateHisSummary(&summary)
  1116. this.ServeSuccessJSON(map[string]interface{}{
  1117. "list": summary,
  1118. })
  1119. return
  1120. }
  1121. func (this *DoctorsApiController) GetHospitalSummaryList() {
  1122. timeLayout := "2006-01-02"
  1123. loc, _ := time.LoadLocation("Local")
  1124. orgId := this.GetAdminUserInfo().CurrentOrgId
  1125. patient_id, _ := this.GetInt64("patient_id")
  1126. start_time := this.GetString("start_time")
  1127. fmt.Println("start_tim232232323232323232323232332", start_time)
  1128. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1129. startime := dischargeTimes.Unix()
  1130. fmt.Println("startime1111111111111111111111", startime)
  1131. end_time := this.GetString("end_time")
  1132. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1133. endtime := endTimes.Unix()
  1134. list, err := service.GetHospitalSummaryList(orgId, patient_id, startime, endtime)
  1135. if err == nil {
  1136. this.ServeSuccessJSON(map[string]interface{}{
  1137. "list": list,
  1138. })
  1139. return
  1140. }
  1141. }
  1142. func (this *DoctorsApiController) GetHospitalSummaryDetail() {
  1143. id, _ := this.GetInt64("id")
  1144. detail, err := service.GetHospitalSummaryDetail(id)
  1145. if err == nil {
  1146. this.ServeSuccessJSON(map[string]interface{}{
  1147. "detail": detail,
  1148. })
  1149. return
  1150. }
  1151. }
  1152. func (this *DoctorsApiController) UpdateHospitalSummary() {
  1153. timeLayout := "2006-01-02"
  1154. loc, _ := time.LoadLocation("Local")
  1155. dataBody := make(map[string]interface{}, 0)
  1156. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1157. fmt.Print("err", err)
  1158. admission_time := dataBody["admission_time"].(string)
  1159. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1160. admissiontime := admissionTimes.Unix()
  1161. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1162. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1163. connecticut := dataBody["connecticut"].(string)
  1164. dean := int64(dataBody["dean"].(float64))
  1165. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1166. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1167. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1168. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1169. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1170. discharge_advice := dataBody["discharge_advice"].(string)
  1171. discharge_time := dataBody["discharge_time"].(string)
  1172. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1173. dischargetime := dischargeTimes.Unix()
  1174. doctor := int64(dataBody["doctor"].(float64))
  1175. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1176. illness_discharge := dataBody["illness_discharge"].(string)
  1177. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1178. pathology := dataBody["pathology"].(string)
  1179. record_date := dataBody["record_date"].(string)
  1180. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1181. recordtime := recordDates.Unix()
  1182. sick_personnel := dataBody["sick_personnel"].(string)
  1183. title := dataBody["title"].(string)
  1184. treatment_id := dataBody["treatment_id"].(string)
  1185. treatment := dataBody["treatment"].(string)
  1186. ultrasound := dataBody["ultrasound"].(string)
  1187. xray := dataBody["xray"].(string)
  1188. patient_id := int64(dataBody["patient_id"].(float64))
  1189. id := int64(dataBody["id"].(float64))
  1190. summary := models.XtHospitalSummary{
  1191. PatientId: patient_id,
  1192. AdmissionTime: admissiontime,
  1193. DischargeTime: dischargetime,
  1194. SickPersonnel: sick_personnel,
  1195. Xray: xray,
  1196. Connecticut: connecticut,
  1197. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1198. Ultrasound: ultrasound,
  1199. Pathology: pathology,
  1200. AdmittingDiagnosisId: admitting_diagnosis_id,
  1201. AdmittingDiagnosis: admitting_diagnosis,
  1202. DischargeDiagnosis: discharge_diagnosis,
  1203. DiagnosisAdmissionId: diagnosis_admission_id,
  1204. DiagnosisAdmission: diagnosis_admission,
  1205. TreatmentId: treatment_id,
  1206. Treatment: treatment,
  1207. IllnessDischargeId: illness_discharge_id,
  1208. IllnessDischarge: illness_discharge,
  1209. DischargeAdviceId: discharge_advice_id,
  1210. DischargeAdvice: discharge_advice,
  1211. Mtime: time.Now().Unix(),
  1212. RecordTime: recordtime,
  1213. Title: title,
  1214. Doctor: doctor,
  1215. RecordDate: recordtime,
  1216. DeanId: dean,
  1217. DischargeDiagnosisId: discharge_diagnosis_id,
  1218. }
  1219. err = service.UpdateHospital(id, summary)
  1220. if err == nil {
  1221. this.ServeSuccessJSON(map[string]interface{}{
  1222. "detail": summary,
  1223. })
  1224. return
  1225. }
  1226. }
  1227. func (this *DoctorsApiController) DeleteHospitalSummary() {
  1228. schIDStr := this.GetString("ids")
  1229. idStrs := strings.Split(schIDStr, ",")
  1230. err := service.DeleteHospitalSummary(idStrs)
  1231. fmt.Println(err)
  1232. returnData := make(map[string]interface{}, 0)
  1233. returnData["msg"] = "ok"
  1234. this.ServeSuccessJSON(returnData)
  1235. return
  1236. }
  1237. func (this *DoctorsApiController) GetPatientInfo() {
  1238. patient_id, _ := this.GetInt64("patient_id")
  1239. orgId := this.GetAdminUserInfo().CurrentOrgId
  1240. detail, err := service.GetPatientDetail(patient_id, orgId)
  1241. if err == nil {
  1242. this.ServeSuccessJSON(map[string]interface{}{
  1243. "patient": detail,
  1244. })
  1245. return
  1246. }
  1247. }
  1248. func (c *DoctorsApiController) GetScheduleAdvicesList() {
  1249. schedualDate := c.GetString("date")
  1250. adviceType, _ := c.GetInt("advice_type")
  1251. patientType, _ := c.GetInt("patient_type")
  1252. delivery_way := c.GetString("delivery_way")
  1253. schedule_type, _ := c.GetInt64("schedule_type")
  1254. partition_type, _ := c.GetInt64("partition_type")
  1255. patient_id, _ := c.GetInt64("patient_id")
  1256. excution_way, _ := c.GetInt64("excution_way")
  1257. cost_type, _ := c.GetInt64("cost_type")
  1258. execution_frequency := c.GetString("execution_frequency")
  1259. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  1260. adviceType = 0
  1261. }
  1262. if patientType != 1 && patientType != 2 {
  1263. patientType = 0
  1264. }
  1265. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  1266. if parseDateErr != nil {
  1267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1268. return
  1269. }
  1270. adminUserInfo := c.GetAdminUserInfo()
  1271. orgID := adminUserInfo.CurrentOrgId
  1272. config, _ := service.GetHisDoctorConfig(orgID)
  1273. project_config, _ := service.GetHisProjectConfig(orgID)
  1274. if config.IsOpen == 0 || config.IsOpen == 2 {
  1275. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency)
  1276. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  1277. if err != nil {
  1278. c.ErrorLog("获取排班信息失败:%v", err)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. } else {
  1281. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  1282. for _, schedual := range scheduals {
  1283. if len(schedual.DoctorAdvices) > 0 {
  1284. filtedScheduals = append(filtedScheduals, schedual)
  1285. }
  1286. }
  1287. c.ServeSuccessJSON(map[string]interface{}{
  1288. "scheduals": filtedScheduals,
  1289. "adminUser": adminUser,
  1290. "config": config,
  1291. "project_config": project_config,
  1292. })
  1293. }
  1294. }
  1295. if config.IsOpen == 1 {
  1296. hisAdvices, err := service.GetHisDoctorAdvicesTwentyOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency)
  1297. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  1298. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
  1299. for _, item := range project {
  1300. index := 0
  1301. for _, subItem := range item.HisPrescriptionTeamProject {
  1302. if subItem.HisProject.CostClassify != 3 {
  1303. subItem.IsCheckTeam = 2
  1304. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  1305. }
  1306. if subItem.HisProject.CostClassify == 3 {
  1307. subItem.IsCheckTeam = 1
  1308. index = index + 1
  1309. if index == 1 {
  1310. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  1311. }
  1312. }
  1313. }
  1314. }
  1315. if err != nil {
  1316. c.ErrorLog("获取排班信息失败:%v", err)
  1317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1318. } else {
  1319. c.ServeSuccessJSON(map[string]interface{}{
  1320. "adminUser": adminUser,
  1321. "hisAdvices": hisAdvices,
  1322. "config": config,
  1323. "project_config": project_config,
  1324. "project": project,
  1325. })
  1326. }
  1327. }
  1328. }
  1329. func (c *DoctorsApiController) CreateFirstDisease() {
  1330. //timeLayout := "2006-01-02"
  1331. //loc, _ := time.LoadLocation("Local")
  1332. dataBody := make(map[string]interface{}, 0)
  1333. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  1334. fmt.Print("err", err)
  1335. doctor := int64(dataBody["doctor"].(float64))
  1336. record_date := dataBody["record_date"].(string)
  1337. recordDates, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_date)
  1338. recordtime := recordDates.Unix()
  1339. patient_id := int64(dataBody["patient_id"].(float64))
  1340. title := dataBody["title"].(string)
  1341. main_content := dataBody["main_content"].(string)
  1342. patient_case := dataBody["patient_case"].(string)
  1343. tentative_diagnosis := dataBody["tentative_diagnosis"].(string)
  1344. diagnostic_basis := dataBody["diagnostic_basis"].(string)
  1345. differential_diagnosis := dataBody["differential_diagnosis"].(string)
  1346. treatment_plan := dataBody["treatment_plan"].(string)
  1347. orgId := c.GetAdminUserInfo().CurrentOrgId
  1348. firstdisease := models.XtPatientFirstDisease{
  1349. Title: title,
  1350. RecordDate: recordtime,
  1351. Doctor: doctor,
  1352. MainContent: main_content,
  1353. PatientCase: patient_case,
  1354. TentativeDiagnosis: tentative_diagnosis,
  1355. DiagnosticBasis: diagnostic_basis,
  1356. DifferentialDiagnosis: differential_diagnosis,
  1357. TreatmentPlan: treatment_plan,
  1358. UserOrgId: orgId,
  1359. PatientId: patient_id,
  1360. Ctime: time.Now().Unix(),
  1361. Mtime: 0,
  1362. Status: 1,
  1363. }
  1364. error := service.CreatePatientFirstDisease(firstdisease)
  1365. if error == nil {
  1366. c.ServeSuccessJSON(map[string]interface{}{
  1367. "firstDisease": firstdisease,
  1368. })
  1369. }
  1370. }
  1371. func (c *DoctorsApiController) GetFirstDiseaseList() {
  1372. timeLayout := "2006-01-02"
  1373. loc, _ := time.LoadLocation("Local")
  1374. orgId := c.GetAdminUserInfo().CurrentOrgId
  1375. patient_id, _ := c.GetInt64("patient_id")
  1376. start_time := c.GetString("start_time")
  1377. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1378. startime := dischargeTimes.Unix()
  1379. end_time := c.GetString("end_time")
  1380. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1381. endtime := endTimes.Unix()
  1382. list, err := service.GetPatientDiseaseList(orgId, patient_id, startime, endtime)
  1383. if err == nil {
  1384. c.ServeSuccessJSON(map[string]interface{}{
  1385. "list": list,
  1386. })
  1387. return
  1388. }
  1389. }
  1390. func (c *DoctorsApiController) GetFirstDetailById() {
  1391. id, _ := c.GetInt64("id")
  1392. list, err := service.GetFirstDetailById(id)
  1393. if err == nil {
  1394. c.ServeSuccessJSON(map[string]interface{}{
  1395. "detail": list,
  1396. })
  1397. return
  1398. }
  1399. }
  1400. func (c *DoctorsApiController) UpdateFirstDisease() {
  1401. //timeLayout := "2006-01-02"
  1402. //loc, _ := time.LoadLocation("Local")
  1403. dataBody := make(map[string]interface{}, 0)
  1404. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  1405. fmt.Print("err", err)
  1406. id := int64(dataBody["id"].(float64))
  1407. doctor := int64(dataBody["doctor"].(float64))
  1408. record_date := dataBody["record_date"].(string)
  1409. recordDates, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_date)
  1410. recordtime := recordDates.Unix()
  1411. patient_id := int64(dataBody["patient_id"].(float64))
  1412. title := dataBody["title"].(string)
  1413. main_content := dataBody["main_content"].(string)
  1414. patient_case := dataBody["patient_case"].(string)
  1415. tentative_diagnosis := dataBody["tentative_diagnosis"].(string)
  1416. diagnostic_basis := dataBody["diagnostic_basis"].(string)
  1417. differential_diagnosis := dataBody["differential_diagnosis"].(string)
  1418. treatment_plan := dataBody["treatment_plan"].(string)
  1419. orgId := c.GetAdminUserInfo().CurrentOrgId
  1420. firstdisease := models.XtPatientFirstDisease{
  1421. Title: title,
  1422. RecordDate: recordtime,
  1423. Doctor: doctor,
  1424. MainContent: main_content,
  1425. PatientCase: patient_case,
  1426. TentativeDiagnosis: tentative_diagnosis,
  1427. DiagnosticBasis: diagnostic_basis,
  1428. DifferentialDiagnosis: differential_diagnosis,
  1429. TreatmentPlan: treatment_plan,
  1430. UserOrgId: orgId,
  1431. PatientId: patient_id,
  1432. Ctime: time.Now().Unix(),
  1433. Mtime: 0,
  1434. Status: 1,
  1435. ID: id,
  1436. }
  1437. error := service.UpdatePatientFirstDisease(firstdisease, id)
  1438. if error == nil {
  1439. c.ServeSuccessJSON(map[string]interface{}{
  1440. "firstDisease": firstdisease,
  1441. })
  1442. }
  1443. }
  1444. func (c *DoctorsApiController) DeleteFirstDisease() {
  1445. schIDStr := c.GetString("ids")
  1446. idStrs := strings.Split(schIDStr, ",")
  1447. err := service.DeleteFirstDisease(idStrs)
  1448. fmt.Println(err)
  1449. returnData := make(map[string]interface{}, 0)
  1450. returnData["msg"] = "ok"
  1451. c.ServeSuccessJSON(returnData)
  1452. return
  1453. }