doctors_api_controller.go 65KB

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