doctors_api_controller.go 67KB

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