doctors_api_controller.go 59KB

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