doctors_api_controller.go 62KB

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