new_dialysis_api_controller.go 68KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288
  1. package new_mobile_api_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/jinzhu/gorm"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. type NewDialysisApiController struct {
  15. NewMobileBaseAPIAuthController
  16. }
  17. func (this *NewDialysisApiController) GetIllnesslist() {
  18. illnesslist, err := service.GetIllnessListTwo()
  19. if err != nil {
  20. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  21. return
  22. }
  23. this.ServeSuccessJSON(map[string]interface{}{
  24. "illnesslist": illnesslist,
  25. })
  26. }
  27. func (this *NewDialysisApiController) GetPatient() {
  28. adminInfo := this.GetMobileAdminUserInfo()
  29. orgid := adminInfo.Org.Id
  30. page, _ := this.GetInt64("page")
  31. limit, _ := this.GetInt64("limit")
  32. patient, total, err := service.GetBloodDialysisPatient(orgid, page, limit)
  33. if err != nil {
  34. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  35. return
  36. }
  37. this.ServeSuccessJSON(map[string]interface{}{
  38. "patient": patient,
  39. "total": total,
  40. })
  41. }
  42. func (this *NewDialysisApiController) GetAllPatient() {
  43. adminInfo := this.GetMobileAdminUserInfo()
  44. orgid := adminInfo.Org.Id
  45. page, _ := this.GetInt64("page")
  46. fmt.Print("page", page)
  47. limit, _ := this.GetInt64("limit")
  48. fmt.Print("limit", limit)
  49. patient, err := service.GetAllPatient(orgid)
  50. if err != nil {
  51. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  52. return
  53. }
  54. this.ServeSuccessJSON(map[string]interface{}{
  55. "patient": patient,
  56. })
  57. }
  58. func (this *NewDialysisApiController) GetGeneratedialysisno() {
  59. adminInfo := this.GetMobileAdminUserInfo()
  60. orgid := adminInfo.Org.Id
  61. dialysisNo := service.ChechLastDialysisNoTwo(orgid)
  62. //fmt.Print("机构ID",adminUserInfo.CurrentOrgId)
  63. if dialysisNo == 0 {
  64. dialysisNo = 1
  65. } else {
  66. dialysisNo++
  67. }
  68. no := strconv.FormatInt(dialysisNo, 10)
  69. rep := 3 - len(no)
  70. if rep > 0 {
  71. no = strings.Repeat("0", rep) + no
  72. }
  73. this.ServeSuccessJSON(map[string]interface{}{
  74. "no": no,
  75. })
  76. return
  77. }
  78. func (this *NewDialysisApiController) GetBloodPatientInfo() {
  79. adminInfo := this.GetMobileAdminUserInfo()
  80. orgId := adminInfo.Org.Id
  81. fmt.Print("机构ID", orgId)
  82. phone := this.GetString("phone")
  83. _, errcode := service.GetBloodPatientInfo(orgId, phone)
  84. fmt.Print("errcode", errcode)
  85. if errcode == gorm.ErrRecordNotFound {
  86. returnData := make(map[string]interface{}, 0)
  87. returnData["msg"] = "ok"
  88. this.ServeSuccessJSON(returnData)
  89. return
  90. } else if errcode == nil {
  91. return
  92. } else {
  93. }
  94. }
  95. func (this *NewDialysisApiController) GetSlowPatientInfo() {
  96. adminInfo := this.GetMobileAdminUserInfo()
  97. orgId := adminInfo.Org.Id
  98. fmt.Print("机构ID", orgId)
  99. phone := this.GetString("phone")
  100. fmt.Print("phone", phone)
  101. _, errcode := service.GetSlowPatientInfo(orgId, phone)
  102. fmt.Print("errcode", errcode)
  103. if errcode == gorm.ErrRecordNotFound {
  104. returnData := make(map[string]interface{}, 0)
  105. returnData["msg"] = "ok"
  106. this.ServeSuccessJSON(returnData)
  107. return
  108. } else if errcode == nil {
  109. return
  110. } else {
  111. }
  112. }
  113. func (this *NewDialysisApiController) GetMemberpatientInfo() {
  114. adminInfo := this.GetMobileAdminUserInfo()
  115. orgId := adminInfo.Org.Id
  116. fmt.Print("机构ID", orgId)
  117. phone := this.GetString("phone")
  118. fmt.Print("phone", phone)
  119. _, errcode := service.GetMemberPatientInfo(orgId, phone)
  120. fmt.Print("errcode", errcode)
  121. if errcode == gorm.ErrRecordNotFound {
  122. returnData := make(map[string]interface{}, 0)
  123. returnData["msg"] = "ok"
  124. this.ServeSuccessJSON(returnData)
  125. return
  126. } else if errcode == nil {
  127. return
  128. } else {
  129. }
  130. }
  131. func (this *NewDialysisApiController) SavePatient() {
  132. adminInfo := this.GetMobileAdminUserInfo()
  133. orgid := adminInfo.Org.Id
  134. dataBody := make(map[string]interface{}, 0)
  135. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  136. fmt.Print("err", err)
  137. name := dataBody["name"].(string)
  138. fmt.Println("姓名", name)
  139. sex := int64(dataBody["sex"].(float64))
  140. fmt.Print("性别", sex)
  141. idCard := dataBody["idCard"].(string)
  142. fmt.Print("身份证", idCard)
  143. birthday := dataBody["birthday"].(string)
  144. births := strings.Split(birthday, "-")
  145. fmt.Print("生日", birthday)
  146. birYear, _ := strconv.Atoi(births[0])
  147. age := time.Now().Year() - birYear
  148. ages := int64(age)
  149. fmt.Println("age是多少", ages)
  150. timeLayout := "2006-01-02 15:04:05"
  151. theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
  152. birth := theTime.Unix()
  153. fmt.Print(birth)
  154. phone := dataBody["phone"].(string)
  155. fmt.Print("电话号码", phone)
  156. patientType := dataBody["result"].([]interface{})
  157. fmt.Print("患者标签", patientType)
  158. dialysis := dataBody["dialysis"].(string)
  159. fmt.Print("透析号", dialysis)
  160. patientsoure := int64(dataBody["patientsoure"].(float64))
  161. fmt.Print("患者来源", patientsoure)
  162. lapseto := int64(dataBody["lapseto"].(float64))
  163. fmt.Print("留置状态", lapseto)
  164. contagions := dataBody["resultTwo"].([]interface{})
  165. fmt.Print("传染病", contagions)
  166. ids := make([]int64, 0)
  167. for _, contagion := range contagions {
  168. id, _ := strconv.ParseInt(contagion.(string), 10, 64)
  169. ids = append(ids, id)
  170. }
  171. fmt.Print("传染病2", contagions)
  172. is_infectious := int64(dataBody["is_infectious"].(float64))
  173. fmt.Print("传染病", is_infectious)
  174. adminssionNumber := dataBody["admissionNumber"].(string)
  175. fmt.Print("住院号", adminssionNumber)
  176. fistdate := dataBody["fistDate"].(string)
  177. fmt.Print("首次透析日期", fistdate)
  178. timeLayouts := "2006-01-02"
  179. loc, _ := time.LoadLocation("Local")
  180. times, err := time.ParseInLocation(timeLayouts+" 15:04:05", fistdate+" 00:00:00", loc)
  181. //times, err := utils.ParseTimeStringToTime(timeLayout, fistdate+"00:00:00")
  182. fisttime := times.Unix()
  183. fmt.Print(fisttime)
  184. diagonse := dataBody["diagnose"].(string)
  185. fmt.Print("诊断", diagonse)
  186. avatar := dataBody["avatar"].(string)
  187. fmt.Print("头像", avatar)
  188. //慢性病
  189. requipmentId := dataBody["requipmentId"].(string)
  190. fmt.Print("设备ID", requipmentId)
  191. slowContagions := dataBody["resultThree"].([]interface{})
  192. fmt.Print("慢性传染病", slowContagions)
  193. idss := make([]int64, 0)
  194. for _, contagion := range slowContagions {
  195. id, _ := strconv.ParseInt(contagion.(string), 10, 64)
  196. idss = append(ids, id)
  197. }
  198. slowDiseases := dataBody["resultFour"].([]interface{})
  199. idsss := make([]int64, 0)
  200. for _, contagion := range slowDiseases {
  201. id, _ := strconv.ParseInt(contagion.(string), 10, 64)
  202. idsss = append(ids, id)
  203. }
  204. fmt.Print("慢性病", slowDiseases)
  205. bloodPatient := int64(dataBody["bloodPatient"].(float64))
  206. fmt.Print("血透病人", bloodPatient)
  207. slowpatient := int64(dataBody["slowPatient"].(float64))
  208. fmt.Print("慢病病人", slowpatient)
  209. memberpatient := int64(dataBody["memberPatient"].(float64))
  210. fmt.Print("会员病人", memberpatient)
  211. //会员
  212. memberFistDate := dataBody["memberFistDate"].(string)
  213. fmt.Print("首次透析日期", memberFistDate)
  214. //membertimes, err := utils.ParseTimeStringToTime(timeLayout, memberFistDate+"00:00:00")
  215. membertimes, _ := time.ParseInLocation(timeLayouts+" 15:04:05", memberFistDate+" 00:00:00", loc)
  216. memtime := membertimes.Unix()
  217. fmt.Print("会员透析日期", memtime)
  218. patient_type := int64(dataBody["patientType"].(float64))
  219. fmt.Print("病种", patient_type)
  220. treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
  221. fmt.Print("治疗方式", treatmentmethod)
  222. //查询身份证号码是否存在
  223. thisPatientOne, _ := service.FindPatientByIdCardNoOne(orgid, idCard)
  224. if thisPatientOne.ID > 0 {
  225. returnData := make(map[string]interface{}, 0)
  226. returnData["msg"] = "身份证号码已存在"
  227. this.ServeSuccessJSON(returnData)
  228. return
  229. }
  230. //查询手机号码是否存在
  231. thisPatient, err := service.FindPatientByMobileOne(phone, orgid)
  232. if thisPatient.ID > 0 {
  233. returnData := make(map[string]interface{}, 0)
  234. returnData["msg"] = "手机号码已存在"
  235. this.ServeSuccessJSON(returnData)
  236. return
  237. }
  238. //如果是血透病人
  239. if bloodPatient == 1 {
  240. //查询透析号是否存在
  241. thisPatientTwo, _ := service.FindPatientByDialysisNoOne(orgid, dialysis)
  242. if thisPatientTwo.ID > 0 {
  243. returnData := make(map[string]interface{}, 0)
  244. returnData["msg"] = "透析号已存在"
  245. this.ServeSuccessJSON(returnData)
  246. return
  247. }
  248. patients := models.Patients{
  249. Name: name,
  250. Gender: sex,
  251. Birthday: birth,
  252. Age: ages,
  253. Phone: phone,
  254. Lapseto: lapseto,
  255. AdmissionNumber: adminssionNumber,
  256. FirstDialysisDate: fisttime,
  257. Diagnose: diagonse,
  258. Source: patientsoure,
  259. DialysisNo: dialysis,
  260. UserOrgId: orgid,
  261. Status: 1,
  262. CreatedTime: time.Now().Unix(),
  263. Avatar: avatar,
  264. IdCardNo: idCard,
  265. IsInfectious: is_infectious,
  266. }
  267. err = service.CreateOldPatient(&patients)
  268. fmt.Print("报错", err)
  269. patient, err := service.GetLastOldPatient(orgid)
  270. fmt.Print("病人ID", patient.ID)
  271. err = service.AddContagions(patient.ID, patient.CreatedTime, patient.UpdatedTime, ids)
  272. fmt.Println("添加传染病失败", err)
  273. patientsNew := models.XtPatientsNew{
  274. Name: name,
  275. Gender: sex,
  276. Birthday: birth,
  277. Age: ages,
  278. Phone: phone,
  279. Lapseto: lapseto,
  280. AdmissionNumber: adminssionNumber,
  281. FirstDialysisDate: fisttime,
  282. Diagnose: diagonse,
  283. Source: patientsoure,
  284. DialysisNo: dialysis,
  285. UserOrgId: orgid,
  286. Status: 1,
  287. CreatedTime: time.Now().Unix(),
  288. Avatar: avatar,
  289. MemberPatients: memberpatient,
  290. BloodPatients: bloodPatient,
  291. SlowPatients: slowpatient,
  292. BloodId: patient.ID,
  293. IsInfectious: is_infectious,
  294. IdCardNo: idCard,
  295. }
  296. err = service.CreateNewPatient(&patientsNew)
  297. fmt.Print("报错", err)
  298. if err != nil {
  299. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  300. return
  301. }
  302. this.ServeSuccessJSON(map[string]interface{}{
  303. "patient": patientsNew,
  304. })
  305. }
  306. fmt.Print("slowpatient", slowpatient)
  307. //如果是慢病病人
  308. if slowpatient == 1 {
  309. _, errcodetwo := service.GetSlowPatientData(phone, orgid)
  310. fmt.Print("查询慢慢是吧", errcodetwo)
  311. if errcodetwo == gorm.ErrRecordNotFound {
  312. patients := models.CdmPatients{
  313. Name: name,
  314. Gender: sex,
  315. Birthday: birth,
  316. Phone: phone,
  317. Diagnose: diagonse,
  318. Source: patientsoure,
  319. UserOrgId: orgid,
  320. Status: 1,
  321. CreatedTime: time.Now().Unix(),
  322. Avatar: avatar,
  323. IdCardNo: idCard,
  324. }
  325. errcodetwo := service.CreateCdmPatient(&patients)
  326. fmt.Print("报错", errcodetwo)
  327. slowPatient, errcodetwo := service.GetOldCdmPatient(orgid)
  328. errcodetwo = service.AddSlowContagions(slowPatient.ID, slowPatient.CreatedTime, slowPatient.UpdatedTime, idss, orgid)
  329. fmt.Print("添加慢病传染病失败", errcodetwo)
  330. errcodethree := service.AddSlowDiseases(slowPatient.ID, slowPatient.CreatedTime, slowPatient.UpdatedTime, idsss, orgid)
  331. fmt.Print("添加慢性病失败", errcodethree)
  332. _, errcodefour := service.GetLastNewSlowPatient(phone, orgid)
  333. if errcodefour == gorm.ErrRecordNotFound {
  334. patientsNew := models.XtPatientsNew{
  335. Name: name,
  336. Gender: sex,
  337. Birthday: birth,
  338. Age: ages,
  339. Phone: phone,
  340. Lapseto: lapseto,
  341. AdmissionNumber: adminssionNumber,
  342. FirstDialysisDate: fisttime,
  343. Diagnose: diagonse,
  344. Source: patientsoure,
  345. DialysisNo: dialysis,
  346. UserOrgId: orgid,
  347. Status: 1,
  348. CreatedTime: time.Now().Unix(),
  349. Avatar: avatar,
  350. MemberPatients: memberpatient,
  351. BloodPatients: bloodPatient,
  352. SlowPatients: slowpatient,
  353. SlowId: slowPatient.ID,
  354. IsInfectious: is_infectious,
  355. IdCardNo: idCard,
  356. EquitmentId: requipmentId,
  357. }
  358. err = service.CreateNewPatient(&patientsNew)
  359. if err != nil {
  360. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  361. return
  362. }
  363. this.ServeSuccessJSON(map[string]interface{}{
  364. "patient": patientsNew,
  365. })
  366. } else if errcodetwo == nil {
  367. fmt.Print("病人已存在")
  368. if memberpatient == 1 {
  369. fmt.Print("进来没有", memberpatient)
  370. _, errmembercode := service.GetMemberPatientInfo(orgid, phone)
  371. if errmembercode == gorm.ErrRecordNotFound {
  372. customer := models.SgjUserCustomer{
  373. Name: name,
  374. UserOrgId: orgid,
  375. Mobile: phone,
  376. Gender: sex,
  377. Birthday: birth,
  378. IllDate: memtime,
  379. Status: 1,
  380. CreatedTime: time.Now().Unix(),
  381. Avatar: avatar,
  382. IllnessId: patient_type,
  383. TreatType: treatmentmethod,
  384. }
  385. errmembercode := service.CreateMemberPatient(&customer)
  386. fmt.Print("创建会员病人失败", errmembercode)
  387. _, errmembercodetwo := service.GetMemberNewPatient(phone, orgid)
  388. fmt.Print("错误", errmembercodetwo)
  389. //获取机构的最后一条数据
  390. memberPatient, errmembercode := service.GetLastMemberPatient(orgid)
  391. if errmembercodetwo == gorm.ErrRecordNotFound {
  392. patientsNew := models.XtPatientsNew{
  393. Name: name,
  394. Gender: sex,
  395. Birthday: birth,
  396. Age: ages,
  397. Phone: phone,
  398. Lapseto: lapseto,
  399. AdmissionNumber: adminssionNumber,
  400. FirstDialysisDate: fisttime,
  401. Diagnose: diagonse,
  402. Source: patientsoure,
  403. DialysisNo: dialysis,
  404. UserOrgId: orgid,
  405. Status: 1,
  406. CreatedTime: time.Now().Unix(),
  407. Avatar: avatar,
  408. MemberPatients: memberpatient,
  409. BloodPatients: bloodPatient,
  410. SlowPatients: slowpatient,
  411. MemberId: memberPatient.ID,
  412. IsInfectious: is_infectious,
  413. IdCardNo: idCard,
  414. MemberFistdate: memtime,
  415. MemberPatienttype: patient_type,
  416. MemberTreatement: treatmentmethod,
  417. }
  418. err = service.CreateNewPatient(&patientsNew)
  419. fmt.Print("报错", err)
  420. if err != nil {
  421. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  422. return
  423. }
  424. this.ServeSuccessJSON(map[string]interface{}{
  425. "patient": patientsNew,
  426. })
  427. } else if errmembercode == nil {
  428. fmt.Print("病人已存在")
  429. return
  430. } else {
  431. }
  432. } else if errmembercode == nil {
  433. fmt.Print("病人已存在")
  434. return
  435. } else {
  436. }
  437. }
  438. return
  439. } else {
  440. }
  441. } else if errcodetwo == nil {
  442. fmt.Print("病人已存在")
  443. return
  444. } else {
  445. }
  446. }
  447. if memberpatient == 1 {
  448. fmt.Print("进来没有", memberpatient)
  449. _, errmembercode := service.GetMemberPatientInfo(orgid, phone)
  450. if errmembercode == gorm.ErrRecordNotFound {
  451. customer := models.SgjUserCustomer{
  452. Name: name,
  453. UserOrgId: orgid,
  454. Mobile: phone,
  455. Gender: sex,
  456. Birthday: birth,
  457. IllDate: memtime,
  458. Status: 1,
  459. CreatedTime: time.Now().Unix(),
  460. Avatar: avatar,
  461. IllnessId: patient_type,
  462. TreatType: treatmentmethod,
  463. }
  464. errmembercode := service.CreateMemberPatient(&customer)
  465. fmt.Print("创建会员病人失败", errmembercode)
  466. _, errmembercodetwo := service.GetMemberNewPatient(phone, orgid)
  467. fmt.Print("错误", errmembercodetwo)
  468. //获取机构的最后一条数据
  469. memberPatient, errmembercode := service.GetLastMemberPatient(orgid)
  470. if errmembercodetwo == gorm.ErrRecordNotFound {
  471. patientsNew := models.XtPatientsNew{
  472. Name: name,
  473. Gender: sex,
  474. Birthday: birth,
  475. Age: ages,
  476. Phone: phone,
  477. Lapseto: lapseto,
  478. AdmissionNumber: adminssionNumber,
  479. FirstDialysisDate: fisttime,
  480. Diagnose: diagonse,
  481. Source: patientsoure,
  482. DialysisNo: dialysis,
  483. UserOrgId: orgid,
  484. Status: 1,
  485. CreatedTime: time.Now().Unix(),
  486. Avatar: avatar,
  487. MemberPatients: memberpatient,
  488. BloodPatients: bloodPatient,
  489. SlowPatients: slowpatient,
  490. MemberId: memberPatient.ID,
  491. IsInfectious: is_infectious,
  492. IdCardNo: idCard,
  493. MemberFistdate: memtime,
  494. MemberPatienttype: patient_type,
  495. MemberTreatement: treatmentmethod,
  496. }
  497. err = service.CreateNewPatient(&patientsNew)
  498. fmt.Print("报错", err)
  499. if err != nil {
  500. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  501. return
  502. }
  503. this.ServeSuccessJSON(map[string]interface{}{
  504. "patient": patientsNew,
  505. })
  506. } else if errmembercode == nil {
  507. fmt.Print("病人已存在")
  508. return
  509. } else {
  510. }
  511. } else if errmembercode == nil {
  512. fmt.Print("病人已存在")
  513. return
  514. } else {
  515. }
  516. }
  517. }
  518. func (this *NewDialysisApiController) GetPatientDetail() {
  519. id, _ := this.GetInt64("id")
  520. //获取病人详情信息
  521. detail, err := service.GetPatientDetailTwo(id)
  522. //获取传染病详情
  523. diseases := service.GetPatientDiseasesTwo(detail.BloodId)
  524. //获取慢病传染病
  525. slowDiseases, err := service.GetSlowPatientDiseases(detail.SlowId)
  526. //获取慢病慢性病
  527. cronicDiseases, err := service.GetCronicDiseases(detail.SlowId)
  528. //获取血透医嘱管理
  529. if err != nil {
  530. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  531. return
  532. }
  533. this.ServeSuccessJSON(map[string]interface{}{
  534. "patientDetail": detail,
  535. "diseases": diseases,
  536. "slowDiseases": slowDiseases,
  537. "cronicDiseases": cronicDiseases,
  538. })
  539. }
  540. func (this *NewDialysisApiController) GetDoctorAdvices() {
  541. timeLayout := "2006-01-02"
  542. loc, _ := time.LoadLocation("Local")
  543. adminInfo := this.GetMobileAdminUserInfo()
  544. orgid := adminInfo.Org.Id
  545. id, _ := this.GetInt64("id")
  546. appid := adminInfo.App.Id
  547. fmt.Print("id", id)
  548. //跟据新表id获取老表id
  549. newPatientInfo, _ := service.GetPatientDetailTwo(id)
  550. //获取病人ID
  551. doctor_type, _ := this.GetInt64("type")
  552. fmt.Print("医嘱内型", doctor_type)
  553. start := this.GetString("startime")
  554. fmt.Print("start", start)
  555. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
  556. startime := startTimes.Unix()
  557. fmt.Print("开始时间", startime)
  558. end := this.GetString("endtime")
  559. fmt.Print("end", end)
  560. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
  561. endtime := endTimes.Unix()
  562. fmt.Print("结束时间", endtime)
  563. limit, _ := this.GetInt64("limit")
  564. page, _ := this.GetInt64("page")
  565. fmt.Println("病人ID", newPatientInfo.BloodId)
  566. advice, _, err := service.GetNewDoctorAdvice(newPatientInfo.BloodId, doctor_type, startime, endtime, limit, page, orgid)
  567. one, total, err := service.GetNewDoctorAdviceOne(newPatientInfo.BloodId, doctor_type, startime, endtime, limit, page, orgid)
  568. fmt.Println("err------------------------", err)
  569. if err != nil {
  570. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  571. return
  572. }
  573. doctor, err := service.GetAllDoctorTwo(orgid, appid)
  574. this.ServeSuccessJSON(map[string]interface{}{
  575. "advice": advice,
  576. "total": total,
  577. "doctor": doctor,
  578. "one": one,
  579. })
  580. }
  581. func (this *NewDialysisApiController) GetDryWeight() {
  582. timeLayout := "2006-01-02"
  583. loc, _ := time.LoadLocation("Local")
  584. id, _ := this.GetInt64("id")
  585. fmt.Print("id", id)
  586. patient, _ := service.GetPatientDetailTwo(id)
  587. start := this.GetString("startime")
  588. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
  589. startime := startTimes.Unix()
  590. fmt.Print("startime", startime)
  591. end := this.GetString("endtime")
  592. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
  593. endtime := endTimes.Unix()
  594. fmt.Print("endtime", endtime)
  595. limit, _ := this.GetInt64("limit")
  596. fmt.Print("limit", limit)
  597. page, _ := this.GetInt64("page")
  598. fmt.Print("page", page)
  599. adminInfo := this.GetMobileAdminUserInfo()
  600. orgid := adminInfo.Org.Id
  601. dryweight, total, err := service.GetDryWeight(patient.BloodId, startime, endtime, limit, page, orgid)
  602. if err != nil {
  603. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  604. return
  605. }
  606. this.ServeSuccessJSON(map[string]interface{}{
  607. "dryweight": dryweight,
  608. "total": total,
  609. })
  610. }
  611. func (this *NewDialysisApiController) ToSearch() {
  612. adminUser := this.GetMobileAdminUserInfo()
  613. orgId := adminUser.Org.Id
  614. name := this.GetString("name")
  615. search, err := service.ToSearch(orgId, name)
  616. if err != nil {
  617. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  618. return
  619. }
  620. this.ServeSuccessJSON(map[string]interface{}{
  621. "search": search,
  622. })
  623. }
  624. func (this *NewDialysisApiController) GetCourseManagement() {
  625. timeLayout := "2006-01-02"
  626. loc, _ := time.LoadLocation("Local")
  627. id, _ := this.GetInt64("id")
  628. fmt.Print("id", id)
  629. patient, _ := service.GetPatientDetailTwo(id)
  630. start := this.GetString("startime")
  631. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
  632. startime := startTimes.Unix()
  633. fmt.Print("startime", startime)
  634. end := this.GetString("endtime")
  635. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
  636. endtime := endTimes.Unix()
  637. fmt.Print("endtime", endtime)
  638. limit, _ := this.GetInt64("limit")
  639. fmt.Print("limit", limit)
  640. page, _ := this.GetInt64("page")
  641. fmt.Print("page", page)
  642. adminInfo := this.GetMobileAdminUserInfo()
  643. orgid := adminInfo.Org.Id
  644. management, total, err := service.GetCourseManagement(patient.BloodId, startime, endtime, limit, page, orgid)
  645. if err != nil {
  646. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  647. return
  648. }
  649. this.ServeSuccessJSON(map[string]interface{}{
  650. "coursemanagement": management,
  651. "total": total,
  652. })
  653. }
  654. func (this *NewDialysisApiController) DeleteCourseManagement() {
  655. id, _ := this.GetInt64("id")
  656. err := service.DeleteCouseManagement(id)
  657. fmt.Println("错误是什么", err)
  658. returnData := make(map[string]interface{}, 0)
  659. returnData["msg"] = "ok"
  660. this.ServeSuccessJSON(returnData)
  661. return
  662. }
  663. func (this *NewDialysisApiController) GetCouseManagentDetail() {
  664. id, _ := this.GetInt64("id")
  665. detail, err := service.GetCouseManagentDetail(id)
  666. if err != nil {
  667. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  668. return
  669. }
  670. this.ServeSuccessJSON(map[string]interface{}{
  671. "couseDetail": detail,
  672. })
  673. }
  674. func (this *NewDialysisApiController) GetAllBloodDialysisPatient() {
  675. page, _ := this.GetInt64("page")
  676. fmt.Print("page", page)
  677. limit, _ := this.GetInt64("limit")
  678. fmt.Print("limit", limit)
  679. lapseto, _ := this.GetInt64("patientstatus")
  680. source, _ := this.GetInt64("source")
  681. adminUserInfo := this.GetMobileAdminUserInfo()
  682. orgid := adminUserInfo.Org.Id
  683. patient, total, err := service.GetAllBloodDialysisPatient(orgid, page, limit, lapseto, source)
  684. if err != nil {
  685. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  686. return
  687. }
  688. this.ServeSuccessJSON(map[string]interface{}{
  689. "bloodpatient": patient,
  690. "total": total,
  691. })
  692. }
  693. func (this *NewDialysisApiController) GetAllSlowPatent() {
  694. page, _ := this.GetInt64("page")
  695. fmt.Print("page", page)
  696. limit, _ := this.GetInt64("limit")
  697. fmt.Print("limit", limit)
  698. adminUserInfo := this.GetMobileAdminUserInfo()
  699. orgid := adminUserInfo.Org.Id
  700. patient, total, err := service.GetAllSlowPatient(orgid, page, limit)
  701. fmt.Print("err", err)
  702. if err != nil {
  703. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  704. return
  705. }
  706. this.ServeSuccessJSON(map[string]interface{}{
  707. "slowpatient": patient,
  708. "total": total,
  709. })
  710. }
  711. func (this *NewDialysisApiController) GetAllMemberPatient() {
  712. page, _ := this.GetInt64("page")
  713. fmt.Print("page", page)
  714. limit, _ := this.GetInt64("limit")
  715. fmt.Print("limit", limit)
  716. adminUserInfo := this.GetMobileAdminUserInfo()
  717. orgid := adminUserInfo.Org.Id
  718. patient, total, err := service.GetAllMemberPatient(orgid, page, limit)
  719. if err != nil {
  720. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  721. return
  722. }
  723. this.ServeSuccessJSON(map[string]interface{}{
  724. "memberpatient": patient,
  725. "total": total,
  726. })
  727. }
  728. func (this *NewDialysisApiController) DeleteDryWeight() {
  729. id, _ := this.GetInt64("id")
  730. err := service.DeleteDryWeight(id)
  731. fmt.Println("错误是什么", err)
  732. returnData := make(map[string]interface{}, 0)
  733. returnData["msg"] = "ok"
  734. this.ServeSuccessJSON(returnData)
  735. return
  736. }
  737. func (this *NewDialysisApiController) GetDryWeightDetail() {
  738. id, _ := this.GetInt64("id")
  739. fmt.Print("id", id)
  740. drydetail, err := service.GetDryWeightDetail(id)
  741. if err != nil {
  742. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  743. return
  744. }
  745. this.ServeSuccessJSON(map[string]interface{}{
  746. "drydetail": drydetail,
  747. })
  748. }
  749. func (this *NewDialysisApiController) GetlongDialysisrecord() {
  750. timeLayout := "2006-01-02"
  751. loc, _ := time.LoadLocation("Local")
  752. id, _ := this.GetInt64("id")
  753. fmt.Print("id", id)
  754. patient, _ := service.GetPatientDetailTwo(id)
  755. start := this.GetString("startime")
  756. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
  757. startime := startTimes.Unix()
  758. fmt.Print("startime", startime)
  759. end := this.GetString("endtime")
  760. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
  761. endtime := endTimes.Unix()
  762. fmt.Print("endtime", endtime)
  763. limit, _ := this.GetInt64("limit")
  764. fmt.Print("limit", limit)
  765. page, _ := this.GetInt64("page")
  766. fmt.Print("page", page)
  767. adminInfo := this.GetMobileAdminUserInfo()
  768. orgid := adminInfo.Org.Id
  769. dialysisrecord, total, err := service.GetlongDialysisrecord(patient.BloodId, startime, endtime, limit, page, orgid)
  770. if err != nil {
  771. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  772. return
  773. }
  774. this.ServeSuccessJSON(map[string]interface{}{
  775. "dialysisrecord": dialysisrecord,
  776. "total": total,
  777. })
  778. }
  779. func (this *NewDialysisApiController) GetRescuerecord() {
  780. timeLayout := "2006-01-02"
  781. loc, _ := time.LoadLocation("Local")
  782. id, _ := this.GetInt64("id")
  783. fmt.Print("id", id)
  784. patient, _ := service.GetPatientDetailTwo(id)
  785. start := this.GetString("startime")
  786. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
  787. startime := startTimes.Unix()
  788. fmt.Print("startime", startime)
  789. end := this.GetString("endtime")
  790. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
  791. endtime := endTimes.Unix()
  792. fmt.Print("endtime", endtime)
  793. limit, _ := this.GetInt64("limit")
  794. fmt.Print("limit", limit)
  795. page, _ := this.GetInt64("page")
  796. fmt.Print("page", page)
  797. adminInfo := this.GetMobileAdminUserInfo()
  798. orgid := adminInfo.Org.Id
  799. rescuerecord, total, err := service.GetRescuerecord(patient.BloodId, startime, endtime, limit, page, orgid)
  800. if err != nil {
  801. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  802. return
  803. }
  804. this.ServeSuccessJSON(map[string]interface{}{
  805. "rescuerecord": rescuerecord,
  806. "total": total,
  807. })
  808. }
  809. func (this *NewDialysisApiController) GetScheduling() {
  810. timeLayout := "2006-01-02"
  811. loc, _ := time.LoadLocation("Local")
  812. id, _ := this.GetInt64("id")
  813. fmt.Print("id", id)
  814. patient, _ := service.GetPatientDetailTwo(id)
  815. start := this.GetString("startime")
  816. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
  817. startime := startTimes.Unix()
  818. fmt.Print("startime", startime)
  819. end := this.GetString("endtime")
  820. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
  821. endtime := endTimes.Unix()
  822. fmt.Print("endtime", endtime)
  823. limit, _ := this.GetInt64("limit")
  824. fmt.Print("limit", limit)
  825. page, _ := this.GetInt64("page")
  826. fmt.Print("page", page)
  827. mode_type, _ := this.GetInt64("mode_types")
  828. fmt.Print("透析模式", mode_type)
  829. adminInfo := this.GetMobileAdminUserInfo()
  830. orgid := adminInfo.Org.Id
  831. scheduling, total, err := service.GetScheduling(patient.BloodId, startime, endtime, limit, page, orgid, mode_type)
  832. if err != nil {
  833. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  834. return
  835. }
  836. this.ServeSuccessJSON(map[string]interface{}{
  837. "scheduling": scheduling,
  838. "total": total,
  839. })
  840. }
  841. func (this *NewDialysisApiController) GetEducation() {
  842. timeLayout := "2006-01-02"
  843. loc, _ := time.LoadLocation("Local")
  844. id, _ := this.GetInt64("id")
  845. fmt.Print("id", id)
  846. patient, _ := service.GetPatientDetailTwo(id)
  847. start := this.GetString("startime")
  848. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
  849. startime := startTimes.Unix()
  850. fmt.Print("startime", startime)
  851. end := this.GetString("endtime")
  852. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
  853. endtime := endTimes.Unix()
  854. fmt.Print("endtime", endtime)
  855. limit, _ := this.GetInt64("limit")
  856. fmt.Print("limit", limit)
  857. page, _ := this.GetInt64("page")
  858. fmt.Print("page", page)
  859. adminInfo := this.GetMobileAdminUserInfo()
  860. orgid := adminInfo.Org.Id
  861. education, total, err := service.GetEducation(patient.BloodId, startime, endtime, limit, page, orgid)
  862. if err != nil {
  863. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  864. return
  865. }
  866. this.ServeSuccessJSON(map[string]interface{}{
  867. "education": education,
  868. "total": total,
  869. })
  870. }
  871. func (this *NewDialysisApiController) GetSchedulingDetail() {
  872. id, _ := this.GetInt64("id")
  873. detail, err := service.GetSchedulingDetail(id)
  874. patient, err := service.GetSchedulingTwo(id)
  875. fmt.Print("errr", err)
  876. if err != nil {
  877. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  878. return
  879. }
  880. this.ServeSuccessJSON(map[string]interface{}{
  881. "schedulingDetail": detail,
  882. "patient": patient,
  883. })
  884. }
  885. func (this *NewDialysisApiController) DeleteScheduling() {
  886. id, _ := this.GetInt64("id")
  887. fmt.Print("id", id)
  888. err := service.DeleteScheduling(id)
  889. fmt.Println("错误是什么", err)
  890. returnData := make(map[string]interface{}, 0)
  891. returnData["msg"] = "ok"
  892. this.ServeSuccessJSON(returnData)
  893. return
  894. }
  895. func (this *NewDialysisApiController) GetEducationDetail() {
  896. id, _ := this.GetInt64("id")
  897. fmt.Print("id", id)
  898. education, err := service.GetEducationDetailOne(id)
  899. if err != nil {
  900. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  901. return
  902. }
  903. this.ServeSuccessJSON(map[string]interface{}{
  904. "education": education,
  905. })
  906. }
  907. func (this *NewDialysisApiController) DeleteEducation() {
  908. id, _ := this.GetInt64("id")
  909. fmt.Print("id", id)
  910. err := service.DeleteEducation(id)
  911. fmt.Println("错误是什么", err)
  912. returnData := make(map[string]interface{}, 0)
  913. returnData["msg"] = "ok"
  914. this.ServeSuccessJSON(returnData)
  915. return
  916. }
  917. func (this *NewDialysisApiController) GetRescueRecordDetail() {
  918. id, _ := this.GetInt64("id")
  919. recordDetail, err := service.GetRescueRecordDetail(id)
  920. if err != nil {
  921. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  922. return
  923. }
  924. this.ServeSuccessJSON(map[string]interface{}{
  925. "recordDetail": recordDetail,
  926. })
  927. }
  928. func (this *NewDialysisApiController) DeleteRescueRecord() {
  929. id, _ := this.GetInt64("id")
  930. err := service.DeleteRescueRecord(id)
  931. fmt.Println("错误是什么", err)
  932. returnData := make(map[string]interface{}, 0)
  933. returnData["msg"] = "ok"
  934. this.ServeSuccessJSON(returnData)
  935. return
  936. }
  937. func (this *NewDialysisApiController) ToSearchePatient() {
  938. keyword := this.GetString("keyword")
  939. fmt.Print("关键字", keyword)
  940. adminUserinfo := this.GetMobileAdminUserInfo()
  941. orgid := adminUserinfo.Org.Id
  942. patient, err := service.ToSearchePatient(keyword, orgid)
  943. if err != nil {
  944. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  945. return
  946. }
  947. this.ServeSuccessJSON(map[string]interface{}{
  948. "patient": patient,
  949. })
  950. }
  951. func (this *NewDialysisApiController) SearchallPatient() {
  952. keyword := this.GetString("keyword")
  953. fmt.Print("关键字", keyword)
  954. adminUser := this.GetMobileAdminUserInfo()
  955. orgid := adminUser.Org.Id
  956. patient, err := service.SearchallPatient(keyword, orgid)
  957. if err != nil {
  958. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  959. return
  960. }
  961. this.ServeSuccessJSON(map[string]interface{}{
  962. "patient": patient,
  963. })
  964. }
  965. func (this *NewDialysisApiController) GetSearchallBlood() {
  966. keyword := this.GetString("keyword")
  967. fmt.Print("关键字", keyword)
  968. adminUser := this.GetMobileAdminUserInfo()
  969. orgid := adminUser.Org.Id
  970. bloodPatient, err := service.GetSearchallBlood(keyword, orgid)
  971. if err != nil {
  972. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  973. return
  974. }
  975. this.ServeSuccessJSON(map[string]interface{}{
  976. "bloodPatient": bloodPatient,
  977. })
  978. }
  979. func (this *NewDialysisApiController) GetSlowSearchePatient() {
  980. keyword := this.GetString("keyword")
  981. fmt.Print("关键字", keyword)
  982. adminUser := this.GetMobileAdminUserInfo()
  983. orgid := adminUser.Org.Id
  984. slowPatient, err := service.GetSlowSearchePatient(keyword, orgid)
  985. if err != nil {
  986. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  987. return
  988. }
  989. this.ServeSuccessJSON(map[string]interface{}{
  990. "slowPatient": slowPatient,
  991. })
  992. }
  993. func (this *NewDialysisApiController) GetMemberSearchPatent() {
  994. keyword := this.GetString("keyword")
  995. fmt.Print("关键字", keyword)
  996. adminUser := this.GetMobileAdminUserInfo()
  997. orgid := adminUser.Org.Id
  998. memberPatient, err := service.GetMemberSearchPatient(keyword, orgid)
  999. if err != nil {
  1000. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1001. return
  1002. }
  1003. this.ServeSuccessJSON(map[string]interface{}{
  1004. "memberPatient": memberPatient,
  1005. })
  1006. }
  1007. func (this *NewDialysisApiController) GetLongDialysisDetail() {
  1008. id, err := this.GetInt64("id")
  1009. longDialysisDetail, err := service.GetLongDialysisDetail(id)
  1010. patient, err := service.GetPatientName(longDialysisDetail.PatientId)
  1011. if err != nil {
  1012. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1013. return
  1014. }
  1015. this.ServeSuccessJSON(map[string]interface{}{
  1016. "longDialysisDetail": longDialysisDetail,
  1017. "patient": patient,
  1018. })
  1019. }
  1020. func (this *NewDialysisApiController) DeleteLongDialysis() {
  1021. id, _ := this.GetInt64("id")
  1022. fmt.Print("id", id)
  1023. err := service.DeleteLongDialysis(id)
  1024. fmt.Println("错误是什么", err)
  1025. returnData := make(map[string]interface{}, 0)
  1026. returnData["msg"] = "ok"
  1027. this.ServeSuccessJSON(returnData)
  1028. return
  1029. }
  1030. func (this *NewDialysisApiController) GetDialysisrecord() {
  1031. timeLayout := "2006-01-02"
  1032. loc, _ := time.LoadLocation("Local")
  1033. id, _ := this.GetInt64("id")
  1034. fmt.Print("id", id)
  1035. patient, _ := service.GetPatientDetailTwo(id)
  1036. start := this.GetString("startime")
  1037. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
  1038. startime := startTimes.Unix()
  1039. fmt.Print("startime", startime)
  1040. end := this.GetString("endtime")
  1041. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
  1042. endtime := endTimes.Unix()
  1043. fmt.Print("endtime", endtime)
  1044. limit, _ := this.GetInt64("limit")
  1045. fmt.Print("limit", limit)
  1046. page, _ := this.GetInt64("page")
  1047. fmt.Print("page", page)
  1048. adminInfo := this.GetMobileAdminUserInfo()
  1049. orgid := adminInfo.Org.Id
  1050. appid := adminInfo.App.Id
  1051. dislystype, _ := this.GetInt64("dislysType")
  1052. fmt.Print("透析模式", dislystype)
  1053. dialysisrecord, total, err := service.GetDialysisrecord(patient.BloodId, startime, endtime, limit, page, orgid, dislystype)
  1054. doctor, err := service.GetAllDoctorTwo(orgid, appid)
  1055. if err != nil {
  1056. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1057. return
  1058. }
  1059. this.ServeSuccessJSON(map[string]interface{}{
  1060. "dialysisrecord": dialysisrecord,
  1061. "total": total,
  1062. "doctor": doctor,
  1063. })
  1064. }
  1065. func (this *NewDialysisApiController) GetDoctorAdviceDetail() {
  1066. adminUser := this.GetMobileAdminUserInfo()
  1067. orgid := adminUser.Org.Id
  1068. appid := adminUser.App.Id
  1069. id, _ := this.GetInt64("id")
  1070. doctorAdvicedetail, err := service.GetDoctorAdviceDetail(id, orgid)
  1071. doctorDetail, err := service.GetAllDoctorTwo(orgid, appid)
  1072. if err != nil {
  1073. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1074. return
  1075. }
  1076. this.ServeSuccessJSON(map[string]interface{}{
  1077. "doctorAdvicedetail": doctorAdvicedetail,
  1078. "doctorDetail": doctorDetail,
  1079. })
  1080. }
  1081. func (this *NewDialysisApiController) DeleteManagement() {
  1082. groupno, _ := this.GetInt64("id")
  1083. fmt.Print("id是什么", groupno)
  1084. orgId := this.GetMobileAdminUserInfo().Org.Id
  1085. fmt.Print("机构ID", orgId)
  1086. err := service.DeleteManagement(groupno, orgId)
  1087. fmt.Println("错误是什么", err)
  1088. returnData := make(map[string]interface{}, 0)
  1089. returnData["msg"] = "ok"
  1090. this.ServeSuccessJSON(returnData)
  1091. return
  1092. }
  1093. func (this *NewDialysisApiController) DeleteChild() {
  1094. id, _ := this.GetInt64("id")
  1095. err := service.DeleteChild(id)
  1096. fmt.Println("错误是什么", err)
  1097. returnData := make(map[string]interface{}, 0)
  1098. returnData["msg"] = "ok"
  1099. this.ServeSuccessJSON(returnData)
  1100. return
  1101. }
  1102. func (this *NewDialysisApiController) DeletePatient() {
  1103. id, _ := this.GetInt64("id")
  1104. err := service.DeletePatient(id)
  1105. fmt.Println("错误是什么", err)
  1106. returnData := make(map[string]interface{}, 0)
  1107. returnData["msg"] = "ok"
  1108. this.ServeSuccessJSON(returnData)
  1109. return
  1110. }
  1111. func (this *NewDialysisApiController) UpdatedPatient() {
  1112. adminInfo := this.GetMobileAdminUserInfo()
  1113. orgid := adminInfo.Org.Id
  1114. fmt.Print("机构ID", orgid)
  1115. dataBody := make(map[string]interface{}, 0)
  1116. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1117. fmt.Print("err", err)
  1118. id := int64(dataBody["id"].(float64))
  1119. fmt.Print("id", id)
  1120. name := dataBody["name"].(string)
  1121. fmt.Println("姓名", name)
  1122. sex := int64(dataBody["sex"].(float64))
  1123. fmt.Print("性别", sex)
  1124. idCard := dataBody["idCard"].(string)
  1125. fmt.Print("身份证", idCard)
  1126. birthday := dataBody["birthday"].(string)
  1127. births := strings.Split(birthday, "-")
  1128. fmt.Print("生日", birthday)
  1129. birYear, _ := strconv.Atoi(births[0])
  1130. age := time.Now().Year() - birYear
  1131. ages := int64(age)
  1132. fmt.Println("age是多少", ages)
  1133. timeLayout := "2006-01-02 15:04:05"
  1134. theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
  1135. birth := theTime.Unix()
  1136. fmt.Print(birth)
  1137. phone := dataBody["phone"].(string)
  1138. fmt.Print("电话号码", phone)
  1139. patientType := dataBody["result"].([]interface{})
  1140. fmt.Print("患者标签", patientType)
  1141. dialysis := dataBody["dialysis"].(string)
  1142. fmt.Print("透析号", dialysis)
  1143. patientsoure := int64(dataBody["patientsoure"].(float64))
  1144. fmt.Print("患者来源", patientsoure)
  1145. lapseto := int64(dataBody["lapseto"].(float64))
  1146. fmt.Print("留置状态", lapseto)
  1147. contagions := dataBody["resultTwo"].([]interface{})
  1148. fmt.Print("传染病", contagions)
  1149. ids := make([]int64, 0)
  1150. for _, contagion := range contagions {
  1151. id, _ := strconv.ParseInt(contagion.(string), 10, 64)
  1152. ids = append(ids, id)
  1153. }
  1154. fmt.Print("传染病2", contagions)
  1155. is_infectious := int64(dataBody["is_infectious"].(float64))
  1156. fmt.Print("传染病", is_infectious)
  1157. adminssionNumber := dataBody["admissionNumber"].(string)
  1158. fmt.Print("住院号", adminssionNumber)
  1159. fistdate := dataBody["fistDate"].(string)
  1160. fmt.Print("首次透析日期", fistdate)
  1161. timeLayouts := "2006-01-02"
  1162. loc, _ := time.LoadLocation("Local")
  1163. times, err := time.ParseInLocation(timeLayouts+" 15:04:05", fistdate+" 00:00:00", loc)
  1164. //times, err := utils.ParseTimeStringToTime(timeLayout, fistdate+"00:00:00")
  1165. fisttime := times.Unix()
  1166. fmt.Print(fisttime)
  1167. diagonse := dataBody["diagnose"].(string)
  1168. fmt.Print("诊断", diagonse)
  1169. avatar := dataBody["avatar"].(string)
  1170. fmt.Print("头像", avatar)
  1171. //慢性病
  1172. requipmentId := dataBody["requipmentId"].(string)
  1173. fmt.Print("设备ID", requipmentId)
  1174. slowContagions := dataBody["resultThree"].([]interface{})
  1175. fmt.Print("慢性传染病", slowContagions)
  1176. idss := make([]int64, 0)
  1177. for _, contagion := range slowContagions {
  1178. id, _ := strconv.ParseInt(contagion.(string), 10, 64)
  1179. idss = append(ids, id)
  1180. }
  1181. fmt.Print(idss)
  1182. slowDiseases := dataBody["resultFour"].([]interface{})
  1183. idsss := make([]int64, 0)
  1184. for _, contagion := range slowDiseases {
  1185. id, _ := strconv.ParseInt(contagion.(string), 10, 64)
  1186. idsss = append(ids, id)
  1187. }
  1188. fmt.Print("idsss", idsss)
  1189. fmt.Print("慢性病", slowDiseases)
  1190. bloodPatient := int64(dataBody["bloodPatient"].(float64))
  1191. fmt.Print("血透病人", bloodPatient)
  1192. slowpatient := int64(dataBody["slowPatient"].(float64))
  1193. fmt.Print("慢病病人", slowpatient)
  1194. memberpatient := int64(dataBody["memberPatient"].(float64))
  1195. fmt.Print("会员病人", memberpatient)
  1196. //会员
  1197. memberFistDate := dataBody["memberFistDate"].(string)
  1198. fmt.Print("首次透析日期", memberFistDate)
  1199. //membertimes, err := utils.ParseTimeStringToTime(timeLayout, memberFistDate+"00:00:00")
  1200. membertimes, _ := time.ParseInLocation(timeLayouts+" 15:04:05", memberFistDate+" 00:00:00", loc)
  1201. memtime := membertimes.Unix()
  1202. fmt.Print("会员透析日期", memtime)
  1203. patient_type := int64(dataBody["patientType"].(float64))
  1204. fmt.Print("病种", patient_type)
  1205. treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
  1206. fmt.Print("治疗方式", treatmentmethod)
  1207. //如果是血透病人
  1208. if bloodPatient == 1 {
  1209. //根据新表ID获取老表病人ID
  1210. patient, _ := service.GetNewPatient(id)
  1211. //判断身份证号是否相同
  1212. thisPatient, _ := service.FindPatientByIdCardNoOne(orgid, idCard)
  1213. if thisPatient.ID > 0 && thisPatient.ID != patient.BloodId {
  1214. returnData := make(map[string]interface{}, 0)
  1215. returnData["msg"] = "身份证号码已存在"
  1216. this.ServeSuccessJSON(returnData)
  1217. return
  1218. }
  1219. //查询手机号码是否存在
  1220. thisPatientOne, err := service.FindPatientByMobileOne(phone, orgid)
  1221. if thisPatientOne.ID > 0 && thisPatientOne.ID != patient.BloodId {
  1222. returnData := make(map[string]interface{}, 0)
  1223. returnData["msg"] = "手机号码已存在"
  1224. this.ServeSuccessJSON(returnData)
  1225. return
  1226. }
  1227. //查询号透析号是否相同
  1228. thisPatientother, _ := service.FindPatientByDialysisNoOne(orgid, dialysis)
  1229. if thisPatientother.ID > 0 && thisPatientother.ID != patient.BloodId {
  1230. returnData := make(map[string]interface{}, 0)
  1231. returnData["msg"] = "透析号码已存在"
  1232. this.ServeSuccessJSON(returnData)
  1233. return
  1234. }
  1235. patients := models.Patients{
  1236. Name: name,
  1237. Gender: sex,
  1238. Birthday: birth,
  1239. Age: ages,
  1240. Phone: phone,
  1241. Lapseto: lapseto,
  1242. AdmissionNumber: adminssionNumber,
  1243. FirstDialysisDate: fisttime,
  1244. Diagnose: diagonse,
  1245. Source: patientsoure,
  1246. DialysisNo: dialysis,
  1247. UserOrgId: orgid,
  1248. Status: 1,
  1249. CreatedTime: time.Now().Unix(),
  1250. Avatar: avatar,
  1251. IdCardNo: idCard,
  1252. IsInfectious: is_infectious,
  1253. }
  1254. err = service.UpdatedPatient(patients, patient.BloodId)
  1255. patientsNew := models.XtPatientsNew{
  1256. ID: id,
  1257. Name: name,
  1258. Gender: sex,
  1259. Birthday: birth,
  1260. Age: ages,
  1261. Phone: phone,
  1262. Lapseto: lapseto,
  1263. AdmissionNumber: adminssionNumber,
  1264. FirstDialysisDate: fisttime,
  1265. Diagnose: diagonse,
  1266. Source: patientsoure,
  1267. DialysisNo: dialysis,
  1268. UserOrgId: orgid,
  1269. Status: 1,
  1270. CreatedTime: time.Now().Unix(),
  1271. Avatar: avatar,
  1272. IdCardNo: idCard,
  1273. IsInfectious: is_infectious,
  1274. }
  1275. err = service.UpdateXtPatientNew(patientsNew, id)
  1276. if err != nil {
  1277. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1278. return
  1279. }
  1280. this.ServeSuccessJSON(map[string]interface{}{
  1281. "patients": patientsNew,
  1282. })
  1283. //更改传染病
  1284. updateContagions, err := service.UpdateContagions(patient.BloodId)
  1285. fmt.Print("更新传染病失败", err)
  1286. fmt.Print("up", updateContagions)
  1287. err = service.AddContagions(patient.BloodId, patient.CreatedTime, patient.UpdatedTime, ids)
  1288. fmt.Println("添加传染病失败", err)
  1289. }
  1290. if slowpatient == 1 {
  1291. patient, _ := service.GetNewPatient(id)
  1292. patients := models.CdmPatients{
  1293. Name: name,
  1294. Gender: sex,
  1295. Birthday: birth,
  1296. Phone: phone,
  1297. Diagnose: diagonse,
  1298. Source: patientsoure,
  1299. UserOrgId: orgid,
  1300. Status: 1,
  1301. CreatedTime: time.Now().Unix(),
  1302. Avatar: avatar,
  1303. IdCardNo: idCard,
  1304. }
  1305. err := service.UpdateCustomer(patients, patient.SlowId)
  1306. fmt.Print("更新慢病患者失败", err)
  1307. xtPatientsNew := models.XtPatientsNew{
  1308. ID: id,
  1309. Name: name,
  1310. Gender: sex,
  1311. Birthday: birth,
  1312. Age: ages,
  1313. Phone: phone,
  1314. Lapseto: lapseto,
  1315. AdmissionNumber: adminssionNumber,
  1316. FirstDialysisDate: fisttime,
  1317. Diagnose: diagonse,
  1318. Source: patientsoure,
  1319. DialysisNo: dialysis,
  1320. UserOrgId: orgid,
  1321. Status: 1,
  1322. CreatedTime: time.Now().Unix(),
  1323. Avatar: avatar,
  1324. MemberPatients: memberpatient,
  1325. BloodPatients: bloodPatient,
  1326. SlowPatients: slowpatient,
  1327. IsInfectious: is_infectious,
  1328. IdCardNo: idCard,
  1329. EquitmentId: requipmentId,
  1330. }
  1331. err = service.UpdateXtPatientNew(xtPatientsNew, id)
  1332. fmt.Print("更新失败", err)
  1333. if err != nil {
  1334. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1335. return
  1336. }
  1337. this.ServeSuccessJSON(map[string]interface{}{
  1338. "patients": xtPatientsNew,
  1339. })
  1340. }
  1341. if memberpatient == 1 {
  1342. patient, _ := service.GetNewPatient(id)
  1343. customer := models.SgjUserCustomer{
  1344. Name: name,
  1345. UserOrgId: orgid,
  1346. Mobile: phone,
  1347. Gender: sex,
  1348. Birthday: birth,
  1349. IllDate: memtime,
  1350. Status: 1,
  1351. CreatedTime: time.Now().Unix(),
  1352. Avatar: avatar,
  1353. IllnessId: patient_type,
  1354. TreatType: treatmentmethod,
  1355. }
  1356. err := service.UpdatedCustomer(customer, patient.MemberId)
  1357. fmt.Print("更新失败", err)
  1358. patientsNew := models.XtPatientsNew{
  1359. ID: id,
  1360. Name: name,
  1361. Gender: sex,
  1362. Birthday: birth,
  1363. Age: ages,
  1364. Phone: phone,
  1365. Lapseto: lapseto,
  1366. AdmissionNumber: adminssionNumber,
  1367. FirstDialysisDate: fisttime,
  1368. Diagnose: diagonse,
  1369. Source: patientsoure,
  1370. DialysisNo: dialysis,
  1371. UserOrgId: orgid,
  1372. Status: 1,
  1373. CreatedTime: time.Now().Unix(),
  1374. Avatar: avatar,
  1375. MemberPatients: memberpatient,
  1376. BloodPatients: bloodPatient,
  1377. SlowPatients: slowpatient,
  1378. IsInfectious: is_infectious,
  1379. IdCardNo: idCard,
  1380. MemberFistdate: memtime,
  1381. MemberPatienttype: patient_type,
  1382. MemberTreatement: treatmentmethod,
  1383. }
  1384. err = service.UpdateXtPatientNewOne(patientsNew, id)
  1385. if err != nil {
  1386. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1387. return
  1388. }
  1389. this.ServeSuccessJSON(map[string]interface{}{
  1390. "patients": patientsNew,
  1391. })
  1392. }
  1393. }
  1394. func (this *NewDialysisApiController) GetAllDoctor() {
  1395. orgid := this.GetMobileAdminUserInfo().Org.Id
  1396. id := this.GetMobileAdminUserInfo().App.Id
  1397. doctor, err := service.GetAllDoctorTwo(orgid, id)
  1398. if err != nil {
  1399. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1400. return
  1401. }
  1402. this.ServeSuccessJSON(map[string]interface{}{
  1403. "doctor": doctor,
  1404. })
  1405. }
  1406. func (this *NewDialysisApiController) GetAllInspection() {
  1407. //查询该机构是否存在检验检测项目
  1408. orgid := this.GetMobileAdminUserInfo().Org.Id
  1409. fmt.Print("orgid", orgid)
  1410. _, errcode := service.GetInspectionByOrgId(orgid)
  1411. if errcode == gorm.ErrRecordNotFound {
  1412. inspection, err := service.GetAllInspection(0)
  1413. if err != nil {
  1414. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1415. return
  1416. }
  1417. this.ServeSuccessJSON(map[string]interface{}{
  1418. "inspection": inspection,
  1419. })
  1420. } else if errcode == nil {
  1421. inspection, err := service.GetAllInspection(orgid)
  1422. if err != nil {
  1423. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1424. return
  1425. }
  1426. this.ServeSuccessJSON(map[string]interface{}{
  1427. "inspection": inspection,
  1428. })
  1429. } else {
  1430. }
  1431. }
  1432. func (this *NewDialysisApiController) GetInspection() {
  1433. timeLayout := "2006-01-02"
  1434. loc, _ := time.LoadLocation("Local")
  1435. id, _ := this.GetInt64("id")
  1436. fmt.Print("id", id)
  1437. patient, _ := service.GetPatientDetailTwo(id)
  1438. start := this.GetString("startime")
  1439. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
  1440. startime := startTimes.Unix()
  1441. fmt.Print("startime", startime)
  1442. end := this.GetString("endtime")
  1443. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
  1444. endtime := endTimes.Unix()
  1445. fmt.Print("endtime", endtime)
  1446. limit, _ := this.GetInt64("limit")
  1447. fmt.Print("limit", limit)
  1448. page, _ := this.GetInt64("page")
  1449. fmt.Print("page", page)
  1450. projectid, _ := this.GetInt64("projectid")
  1451. fmt.Print("projectid", projectid)
  1452. adminInfo := this.GetMobileAdminUserInfo()
  1453. orgid := adminInfo.Org.Id
  1454. fmt.Print("patient", patient)
  1455. fmt.Print("orgid", orgid)
  1456. //查询该机构是否存在
  1457. //inspection, _ := service.GetInspectionById(patient.BloodId, startime, endtime, orgid)
  1458. //if len(inspection) == 0 {
  1459. //
  1460. //}
  1461. inspection, total, err := service.GetInspection(patient.BloodId, startime, endtime, limit, page, orgid, projectid)
  1462. if err != nil {
  1463. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1464. return
  1465. }
  1466. this.ServeSuccessJSON(map[string]interface{}{
  1467. "inspection": inspection,
  1468. "total": total,
  1469. })
  1470. }
  1471. func (this *NewDialysisApiController) GetMyInformation() {
  1472. id, _ := this.GetInt64("id")
  1473. roleInfo, err := service.GetPosition(id)
  1474. if err != nil {
  1475. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1476. return
  1477. }
  1478. this.ServeSuccessJSON(map[string]interface{}{
  1479. "roleInfo": roleInfo,
  1480. })
  1481. return
  1482. }
  1483. func (this *NewDialysisApiController) GetPatientName() {
  1484. id, _ := this.GetInt64("id")
  1485. patients, _ := service.GetPatientDetailTwo(id)
  1486. fmt.Print("paitents", patients.ID)
  1487. patientName, err := service.GetPatientName(patients.BloodId)
  1488. fmt.Print("err", err)
  1489. if err != nil {
  1490. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1491. return
  1492. }
  1493. this.ServeSuccessJSON(map[string]interface{}{
  1494. "patientName": patientName,
  1495. })
  1496. }
  1497. func (this *NewDialysisApiController) GetInspectionDetail() {
  1498. patientid, _ := this.GetInt64("patientid")
  1499. fmt.Print("patientid", patientid)
  1500. patients, _ := service.GetPatientDetailTwo(patientid)
  1501. date, _ := this.GetInt64("date")
  1502. fmt.Print("date", date)
  1503. projectid, _ := this.GetInt64("projectid")
  1504. adminUser := this.GetMobileAdminUserInfo()
  1505. orgid := adminUser.Org.Id
  1506. InspectionDetail, err := service.GetInspectionDetail(patients.BloodId, date, orgid, projectid)
  1507. if err != nil {
  1508. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1509. return
  1510. }
  1511. this.ServeSuccessJSON(map[string]interface{}{
  1512. "InspectionDetail": InspectionDetail,
  1513. })
  1514. }
  1515. func (this *NewDialysisApiController) SaveFeed() {
  1516. question, _ := this.GetInt64("question")
  1517. fmt.Print("question", question)
  1518. title := this.GetString("title")
  1519. fmt.Print("title", title)
  1520. content := this.GetString("content")
  1521. fmt.Print("content", content)
  1522. phone := this.GetString("phone")
  1523. fmt.Print("phone", phone)
  1524. times, _ := this.GetInt64("time")
  1525. fmt.Print("time", times)
  1526. adminuserid, _ := this.GetInt64("admin_user_id")
  1527. fmt.Println("admin", adminuserid)
  1528. adminUser := this.GetMobileAdminUserInfo()
  1529. orgid := adminUser.Org.Id
  1530. appid := adminUser.App.Id
  1531. feedback := models.XtPatientFeedback{
  1532. ProblemType: question,
  1533. Title: title,
  1534. Content: content,
  1535. Phone: phone,
  1536. TimeQuantum: times,
  1537. UserOrgId: orgid,
  1538. Ctime: time.Now().Unix(),
  1539. Status: 1,
  1540. AdminUserId: adminuserid,
  1541. AppId: appid,
  1542. }
  1543. err := service.CreateFeedBack(&feedback)
  1544. if err != nil {
  1545. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1546. return
  1547. }
  1548. this.ServeSuccessJSON(map[string]interface{}{
  1549. "feedback": feedback,
  1550. })
  1551. }
  1552. func (this *NewDialysisApiController) DeleteInspection() {
  1553. admininfo := this.GetMobileAdminUserInfo()
  1554. orgid := admininfo.Org.Id
  1555. date, _ := this.GetInt64("date")
  1556. fmt.Println("date", date)
  1557. err := service.DeleteInspection(date, orgid)
  1558. fmt.Println("删除失败", err)
  1559. returnData := make(map[string]interface{}, 0)
  1560. returnData["msg"] = "手机号码已存在"
  1561. this.ServeSuccessJSON(returnData)
  1562. return
  1563. }
  1564. func (this *NewDialysisApiController) DeleteChildInspection() {
  1565. admininfo := this.GetMobileAdminUserInfo()
  1566. orgid := admininfo.Org.Id
  1567. name := this.GetString("name")
  1568. fmt.Println("name", name)
  1569. date, _ := this.GetInt64("date")
  1570. fmt.Println("date", date)
  1571. err := service.DeleteChildInspection(name, date, orgid)
  1572. fmt.Println("删除失败", err)
  1573. returnData := make(map[string]interface{}, 0)
  1574. returnData["msg"] = "手机号码已存在"
  1575. this.ServeSuccessJSON(returnData)
  1576. return
  1577. }
  1578. func (this *NewDialysisApiController) SaveMessage() {
  1579. id, _ := this.GetInt64("id")
  1580. fmt.Println("id", id)
  1581. message := this.GetString("message")
  1582. fmt.Println("message", message)
  1583. role := models.SgjUserAdminRole{
  1584. Message: message,
  1585. }
  1586. err := service.SaveMessage(id, &role)
  1587. if err != nil {
  1588. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1589. return
  1590. }
  1591. this.ServeSuccessJSON(map[string]interface{}{
  1592. "role": role,
  1593. })
  1594. }
  1595. func (this *NewDialysisApiController) SaveSex() {
  1596. sex, _ := this.GetInt64("sex")
  1597. fmt.Println("sex", sex)
  1598. id, _ := this.GetInt64("id")
  1599. fmt.Println("id", id)
  1600. role := models.SgjUserAdminRole{
  1601. Sex: sex,
  1602. }
  1603. err := service.SaveSex(id, &role)
  1604. if err != nil {
  1605. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1606. return
  1607. }
  1608. this.ServeSuccessJSON(map[string]interface{}{
  1609. "role": role,
  1610. })
  1611. }
  1612. func (this *NewDialysisApiController) SaveBirthday() {
  1613. dataBody := make(map[string]interface{}, 0)
  1614. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1615. fmt.Println(err)
  1616. id := dataBody["id"].(string)
  1617. ids, err := strconv.ParseInt(id, 10, 64)
  1618. fmt.Print("id", id)
  1619. birthday := dataBody["birth"].(string)
  1620. timeLayout := "2006-01-02 15:04:05"
  1621. theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
  1622. birth := theTime.Unix()
  1623. role := models.SgjUserAdminRole{
  1624. Birthday: birth,
  1625. }
  1626. err = service.SaveBirthday(ids, &role)
  1627. if err != nil {
  1628. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1629. return
  1630. }
  1631. this.ServeSuccessJSON(map[string]interface{}{
  1632. "role": role,
  1633. })
  1634. }
  1635. func (this *NewDialysisApiController) GetOrgName() {
  1636. id, _ := this.GetInt64("id")
  1637. name, err := service.GetOrgName(id)
  1638. if err != nil {
  1639. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1640. return
  1641. }
  1642. this.ServeSuccessJSON(map[string]interface{}{
  1643. "name": name,
  1644. })
  1645. }
  1646. func (this *NewDialysisApiController) GetRoleName() {
  1647. id, _ := this.GetInt64("id")
  1648. fmt.Println("id", id)
  1649. orgid := this.GetMobileAdminUserInfo().Org.Id
  1650. fmt.Println("orgid", orgid)
  1651. appid := this.GetMobileAdminUserInfo().App.Id
  1652. fmt.Println("appid", appid)
  1653. name, err := service.GetRoleName(id, orgid, appid)
  1654. positionName, err := service.GetPositionName(id, orgid, appid)
  1655. if err != nil {
  1656. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1657. return
  1658. }
  1659. this.ServeSuccessJSON(map[string]interface{}{
  1660. "name": name,
  1661. "positionName": positionName,
  1662. })
  1663. }
  1664. func (this *NewDialysisApiController) SavePartition() {
  1665. adminInfo := this.GetMobileAdminUserInfo()
  1666. name := this.GetString("name")
  1667. fmt.Println("分区名称", name)
  1668. zonetype, _ := this.GetInt64("type")
  1669. fmt.Println("分区型号", zonetype)
  1670. strInt64 := strconv.FormatInt(zonetype, 10)
  1671. typeid, _ := strconv.Atoi(strInt64)
  1672. zone := models.DeviceZone{
  1673. Name: name,
  1674. Type: typeid,
  1675. OrgID: adminInfo.Org.Id,
  1676. Status: 1,
  1677. CreateTime: time.Now().Unix(),
  1678. }
  1679. err := service.CreatedZone(&zone)
  1680. if err != nil {
  1681. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1682. return
  1683. }
  1684. this.ServeSuccessJSON(map[string]interface{}{
  1685. "zone": zone,
  1686. })
  1687. }
  1688. func (this *NewDialysisApiController) GetAllZone() {
  1689. adminUser := this.GetMobileAdminUserInfo()
  1690. orgid := adminUser.Org.Id
  1691. page, _ := this.GetInt64("page")
  1692. limit, _ := this.GetInt64("limit")
  1693. zone, total, err := service.GetAllZone(orgid, page, limit)
  1694. if err != nil {
  1695. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1696. return
  1697. }
  1698. this.ServeSuccessJSON(map[string]interface{}{
  1699. "zone": zone,
  1700. "total": total,
  1701. })
  1702. }
  1703. func (this *NewDialysisApiController) DeleteZone() {
  1704. id, _ := this.GetInt64("id")
  1705. err := service.DeleteZoneById(id)
  1706. fmt.Println("删除失败", err)
  1707. returnData := make(map[string]interface{}, 0)
  1708. returnData["msg"] = "删除失败"
  1709. this.ServeSuccessJSON(returnData)
  1710. return
  1711. }
  1712. func (this *NewDialysisApiController) SaveGroup() {
  1713. adminUser := this.GetMobileAdminUserInfo()
  1714. orgid := adminUser.Org.Id
  1715. name := this.GetString("name")
  1716. fmt.Println("name", name)
  1717. group := models.DeviceGroup{
  1718. Name: name,
  1719. Status: 1,
  1720. CreateTime: time.Now().Unix(),
  1721. OrgID: orgid,
  1722. }
  1723. err := service.SaveGroup(&group)
  1724. if err != nil {
  1725. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1726. return
  1727. }
  1728. this.ServeSuccessJSON(map[string]interface{}{
  1729. "group": group,
  1730. })
  1731. }
  1732. func (this *NewDialysisApiController) GetAllGroup() {
  1733. adminUser := this.GetMobileAdminUserInfo()
  1734. orgid := adminUser.Org.Id
  1735. page, _ := this.GetInt64("page")
  1736. fmt.Println("page", page)
  1737. limit, _ := this.GetInt64("limit")
  1738. fmt.Println("limit", limit)
  1739. group, total, err := service.GetAllGroup(orgid, page, limit)
  1740. if err != nil {
  1741. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1742. return
  1743. }
  1744. this.ServeSuccessJSON(map[string]interface{}{
  1745. "group": group,
  1746. "total": total,
  1747. })
  1748. }
  1749. func (this *NewDialysisApiController) DeleteGroup() {
  1750. id, _ := this.GetInt64("id")
  1751. fmt.Println("id", id)
  1752. err := service.DeleteGroup(id)
  1753. fmt.Println("删除失败", err)
  1754. returnData := make(map[string]interface{}, 0)
  1755. returnData["msg"] = "删除失败"
  1756. this.ServeSuccessJSON(returnData)
  1757. return
  1758. }
  1759. func (this *NewDialysisApiController) GetAllGroupOne() {
  1760. admininfo := this.GetMobileAdminUserInfo()
  1761. orgid := admininfo.Org.Id
  1762. zone, _ := service.GetAllZoneOne(orgid)
  1763. group, err := service.GetAllGroupOne(orgid)
  1764. if err != nil {
  1765. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1766. return
  1767. }
  1768. this.ServeSuccessJSON(map[string]interface{}{
  1769. "zone": zone,
  1770. "group": group,
  1771. })
  1772. }
  1773. func (this *NewDialysisApiController) SaveBed() {
  1774. adminuser := this.GetMobileAdminUserInfo()
  1775. orgid := adminuser.Org.Id
  1776. name := this.GetString("name")
  1777. fmt.Println("name", name)
  1778. zone, _ := this.GetInt64("zone")
  1779. fmt.Print("zone", zone)
  1780. group, _ := this.GetInt64("group")
  1781. fmt.Println("group", group)
  1782. number := models.DeviceNumber{
  1783. Number: name,
  1784. ZoneID: zone,
  1785. GroupID: group,
  1786. OrgID: orgid,
  1787. Status: 1,
  1788. CreateTime: time.Now().Unix(),
  1789. }
  1790. err := service.CreateNumber(&number)
  1791. if err != nil {
  1792. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1793. return
  1794. }
  1795. this.ServeSuccessJSON(map[string]interface{}{
  1796. "number": number,
  1797. })
  1798. }
  1799. func (this *NewDialysisApiController) GetAllNumber() {
  1800. admininfo := this.GetMobileAdminUserInfo()
  1801. orgid := admininfo.Org.Id
  1802. page, _ := this.GetInt64("page")
  1803. fmt.Print("page", page)
  1804. limit, _ := this.GetInt64("limit")
  1805. fmt.Println("limit", limit)
  1806. number, total, err := service.GetAllNumber(page, limit, orgid)
  1807. zone, _ := service.GetAllZoneOne(orgid)
  1808. group, _ := service.GetAllGroupOne(orgid)
  1809. if err != nil {
  1810. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1811. return
  1812. }
  1813. this.ServeSuccessJSON(map[string]interface{}{
  1814. "number": number,
  1815. "total": total,
  1816. "zone": zone,
  1817. "group": group,
  1818. })
  1819. }
  1820. func (this *NewDialysisApiController) DeleteBed() {
  1821. id, _ := this.GetInt64("id")
  1822. fmt.Println("id", id)
  1823. nowDateTime := time.Now()
  1824. nowDate := nowDateTime.Format("2006-01-02")
  1825. nowDate += " 00:00:00"
  1826. timeLayout := "2006-01-02"
  1827. loc, _ := time.LoadLocation("Local")
  1828. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
  1829. fmt.Println(theTime.Unix())
  1830. adminInfo := this.GetMobileAdminUserInfo()
  1831. orgid := adminInfo.Org.Id
  1832. _, errcode := service.GetSchedu(id, theTime.Unix(), orgid)
  1833. fmt.Println("errcode", errcode)
  1834. if errcode == gorm.ErrRecordNotFound {
  1835. err := service.DeleteBed(id)
  1836. fmt.Println("删除失败", err)
  1837. returnData := make(map[string]interface{}, 0)
  1838. returnData["msg"] = "删除失败"
  1839. this.ServeSuccessJSON(returnData)
  1840. return
  1841. } else if errcode == nil {
  1842. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1843. return
  1844. }
  1845. }
  1846. func (this *NewDialysisApiController) LoginOut() {
  1847. this.DelSession("mobile_admin_user_info")
  1848. this.Ctx.SetCookie("token_cookie", "")
  1849. id, _ := this.GetInt64("id")
  1850. fmt.Println("id------------------------------------------", id)
  1851. loginLog := models.SgjUserAdminLoginLog{
  1852. AdminUserId: id,
  1853. OrgId: 0,
  1854. AppId: 0,
  1855. Ip: utils.GetIP(this.Ctx.Request),
  1856. OperateType: 2,
  1857. AppType: 0,
  1858. Ctime: time.Now().Unix(),
  1859. }
  1860. err := service.CreateLoginLod(&loginLog)
  1861. fmt.Println("err--------", err)
  1862. returnData := make(map[string]interface{}, 0)
  1863. returnData["msg"] = "删除失败"
  1864. this.ServeSuccessJSON(returnData)
  1865. return
  1866. }
  1867. func (this *NewDialysisApiController) GetMemberPatient() {
  1868. adminUser := this.GetMobileAdminUserInfo()
  1869. orgid := adminUser.Org.Id
  1870. patient, err := service.GetMemberPatient(orgid)
  1871. if err != nil {
  1872. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1873. return
  1874. }
  1875. this.ServeSuccessJSON(map[string]interface{}{
  1876. "patient": patient,
  1877. })
  1878. }
  1879. func (this *NewDialysisApiController) GetSlowPatient() {
  1880. adminUser := this.GetMobileAdminUserInfo()
  1881. orgid := adminUser.Org.Id
  1882. patient, err := service.GetSlowPatient(orgid)
  1883. if err != nil {
  1884. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1885. return
  1886. }
  1887. this.ServeSuccessJSON(map[string]interface{}{
  1888. "patient": patient,
  1889. })
  1890. }
  1891. func (this *NewDialysisApiController) GetBloodPatient() {
  1892. adminUser := this.GetMobileAdminUserInfo()
  1893. orgid := adminUser.Org.Id
  1894. patient, err := service.GetBloodPatient(orgid)
  1895. if err != nil {
  1896. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1897. return
  1898. }
  1899. this.ServeSuccessJSON(map[string]interface{}{
  1900. "patient": patient,
  1901. })
  1902. }
  1903. func (this *NewDialysisApiController) SaveName() {
  1904. id := this.GetString("id")
  1905. ids, _ := strconv.ParseInt(id, 10, 64)
  1906. fmt.Println("id", ids)
  1907. name := this.GetString("name")
  1908. fmt.Println("name", name)
  1909. role := models.SgjUserAdminRole{
  1910. UserName: name,
  1911. }
  1912. err := service.SaveName(ids, &role)
  1913. if err != nil {
  1914. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1915. return
  1916. }
  1917. this.ServeSuccessJSON(map[string]interface{}{
  1918. "role": role,
  1919. })
  1920. }
  1921. func (this *NewDialysisApiController) GetAllOrganization() {
  1922. id, _ := this.GetInt64("id")
  1923. fmt.Println("id", id)
  1924. }
  1925. func (this *NewDialysisApiController) GetMyOrganazition() {
  1926. id, _ := this.GetInt64("id")
  1927. fmt.Println("id", id)
  1928. role, _ := service.GetAdminUserId(id)
  1929. organaziton, err := service.GetMyOrganaziton(role.AdminUserId)
  1930. if err != nil {
  1931. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1932. return
  1933. }
  1934. this.ServeSuccessJSON(map[string]interface{}{
  1935. "organaziton": organaziton,
  1936. })
  1937. }
  1938. func (this *NewDialysisApiController) GetOrgInformation() {
  1939. id, _ := this.GetInt64("id")
  1940. information, err := service.GetOrgInformation(id)
  1941. name, err := service.GetShortName(information.OrgType)
  1942. typeName, err := service.GetTypeName(name.Pid)
  1943. //获取省
  1944. province, err := service.GetOrgProvince(information.Province)
  1945. cityes, err := service.GetOrgProvince(information.City)
  1946. district, err := service.GetOrgProvince(information.District)
  1947. fmt.Print("err", err)
  1948. //if err != nil {
  1949. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1950. // return
  1951. //}
  1952. this.ServeSuccessJSON(map[string]interface{}{
  1953. "information": information,
  1954. "name": name,
  1955. "typeName": typeName,
  1956. "province": province,
  1957. "city": cityes,
  1958. "district": district,
  1959. })
  1960. }
  1961. func (this *NewDialysisApiController) GetAllOrgType() {
  1962. orgType, _ := service.GetAllOrgType()
  1963. returnData := make(map[string]interface{}, 0)
  1964. returnData["orgType"] = orgType
  1965. this.ServeSuccessJSON(returnData)
  1966. }
  1967. func (this *NewDialysisApiController) EditOrg() {
  1968. id, _ := this.GetInt64("id")
  1969. fmt.Println("id", id)
  1970. name := this.GetString("org_name")
  1971. fmt.Println("name", name)
  1972. provinceName := this.GetString("provinces_name")
  1973. fmt.Println("provinceName", provinceName)
  1974. cityName := this.GetString("city_name")
  1975. fmt.Println("cityName", cityName)
  1976. districtName := this.GetString("district_name")
  1977. fmt.Println("districtName", districtName)
  1978. address := this.GetString("address")
  1979. fmt.Println("address", address)
  1980. org_type := this.GetString("org_type")
  1981. fmt.Println("org_type", org_type)
  1982. contactName := this.GetString("contact_name")
  1983. fmt.Println("contactName", contactName)
  1984. orgPhone := this.GetString("telephone")
  1985. fmt.Println("orgPhone", orgPhone)
  1986. provinceID := 0
  1987. cityID := 0
  1988. districtID := 0
  1989. province, getProvinceErr := service.GetProvinceWithName(provinceName)
  1990. if getProvinceErr != nil {
  1991. utils.ErrorLog("查询省名失败:%v", getProvinceErr)
  1992. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1993. this.ServeJSON()
  1994. return
  1995. } else if province != nil {
  1996. provinceID = int(province.ID)
  1997. city, getCityErr := service.GetCityWithName(province.ID, cityName)
  1998. if getCityErr != nil {
  1999. utils.ErrorLog("查询城市名失败:%v", getCityErr)
  2000. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2001. this.ServeJSON()
  2002. return
  2003. } else if city != nil {
  2004. cityID = int(city.ID)
  2005. district, getDistrictErr := service.GetDistrictWithName(city.ID, districtName)
  2006. if getDistrictErr != nil {
  2007. utils.ErrorLog("查询区县名失败:%v", getDistrictErr)
  2008. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2009. this.ServeJSON()
  2010. return
  2011. } else if district != nil {
  2012. districtID = int(district.ID)
  2013. }
  2014. }
  2015. }
  2016. orgType := service.GetOrgTypeByName(org_type)
  2017. fmt.Println(provinceID, cityID, districtID)
  2018. org := models.SgjUserOrg{
  2019. OrgName: name,
  2020. OrgShortName: name,
  2021. Province: int64(provinceID),
  2022. City: int64(cityID),
  2023. District: int64(districtID),
  2024. Address: address,
  2025. OrgType: orgType.ID,
  2026. Telephone: orgPhone,
  2027. ContactName: contactName,
  2028. }
  2029. fmt.Println("org", org)
  2030. err := service.UpdateOrg(id, org)
  2031. if err != nil {
  2032. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2033. return
  2034. }
  2035. this.ServeSuccessJSON(map[string]interface{}{
  2036. "org": org,
  2037. })
  2038. }
  2039. func (this *NewDialysisApiController) GetMyInforName() {
  2040. id, _ := this.GetInt64("id")
  2041. Rolename, err := service.GetMyInfoName(id)
  2042. Username, err := service.GetAdminName(Rolename.AdminUserId)
  2043. if err != nil {
  2044. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2045. return
  2046. }
  2047. this.ServeSuccessJSON(map[string]interface{}{
  2048. "Rolename": Rolename,
  2049. "Username": Username,
  2050. })
  2051. }
  2052. func (this *NewDialysisApiController) GetPartionDetail() {
  2053. id, _ := this.GetInt64("id")
  2054. partionDetail, err := service.GetPartionDetail(id)
  2055. if err != nil {
  2056. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2057. return
  2058. }
  2059. this.ServeSuccessJSON(map[string]interface{}{
  2060. "partionDetail": partionDetail,
  2061. })
  2062. }
  2063. func (this *NewDialysisApiController) UpdatePartition() {
  2064. id, _ := this.GetInt64("id")
  2065. name := this.GetString("name")
  2066. zoneType, _ := this.GetInt64("type")
  2067. strInt64 := strconv.FormatInt(zoneType, 10)
  2068. typeid, _ := strconv.Atoi(strInt64)
  2069. zone := models.DeviceZone{
  2070. Name: name,
  2071. Type: typeid,
  2072. }
  2073. err := service.UpdatePartition(id, &zone)
  2074. if err != nil {
  2075. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2076. return
  2077. }
  2078. this.ServeSuccessJSON(map[string]interface{}{
  2079. "zone": zone,
  2080. })
  2081. }
  2082. func (this *NewDialysisApiController) GetGroupDetail() {
  2083. id, _ := this.GetInt64("id")
  2084. groupDetail, err := service.GetGroupDetail(id)
  2085. if err != nil {
  2086. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2087. return
  2088. }
  2089. this.ServeSuccessJSON(map[string]interface{}{
  2090. "groupDetail": groupDetail,
  2091. })
  2092. }
  2093. func (this *NewDialysisApiController) UpdateGroup() {
  2094. id, _ := this.GetInt64("id")
  2095. name := this.GetString("name")
  2096. group := models.DeviceGroup{Name: name}
  2097. err := service.UpdateGroup(id, &group)
  2098. if err != nil {
  2099. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2100. return
  2101. }
  2102. this.ServeSuccessJSON(map[string]interface{}{
  2103. "group": group,
  2104. })
  2105. }
  2106. func (this *NewDialysisApiController) GetBedDetail() {
  2107. adminUser := this.GetMobileAdminUserInfo()
  2108. orgid := adminUser.Org.Id
  2109. id, _ := this.GetInt64("id")
  2110. zone, _ := service.GetAllZoneOne(orgid)
  2111. group, err := service.GetAllGroupOne(orgid)
  2112. bedDetail, err := service.GetBedDetail(id)
  2113. if err != nil {
  2114. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2115. return
  2116. }
  2117. this.ServeSuccessJSON(map[string]interface{}{
  2118. "zone": zone,
  2119. "group": group,
  2120. "bedDetail": bedDetail,
  2121. })
  2122. }
  2123. func (this *NewDialysisApiController) UpdatedBed() {
  2124. id, _ := this.GetInt64("id")
  2125. name := this.GetString("name")
  2126. fmt.Println("name", name)
  2127. zone, _ := this.GetInt64("zone")
  2128. fmt.Println("zone", zone)
  2129. group, _ := this.GetInt64("group")
  2130. fmt.Println("group", group)
  2131. number := models.DeviceNumber{
  2132. Number: name,
  2133. ZoneID: zone,
  2134. GroupID: group,
  2135. }
  2136. err := service.UpdatedBed(id, &number)
  2137. if err != nil {
  2138. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2139. return
  2140. }
  2141. this.ServeSuccessJSON(map[string]interface{}{
  2142. "number": number,
  2143. })
  2144. }