doctors_api_controller.go 62KB

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