doctors_api_controller.go 67KB

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