doctors_api_controller.go 66KB

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