doctors_api_controller.go 67KB

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