new_dialysis_api_controller.go 71KB

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