doctors_api_controller.go 61KB

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