new_dialysis_api_controller.go 71KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406
  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.Ctx.SetCookie("logout_cookie", "1")
  1881. this.Ctx.SetCookie("token_cookie", "")
  1882. id, _ := this.GetInt64("id")
  1883. loginLog := models.SgjUserAdminLoginLog{
  1884. AdminUserId: id,
  1885. OrgId: 0,
  1886. AppId: 0,
  1887. Ip: utils.GetIP(this.Ctx.Request),
  1888. OperateType: 2,
  1889. AppType: 0,
  1890. Ctime: time.Now().Unix(),
  1891. }
  1892. err := service.CreateLoginLod(&loginLog)
  1893. fmt.Println("err--------", err)
  1894. returnData := make(map[string]interface{}, 0)
  1895. returnData["msg"] = "删除失败"
  1896. this.ServeSuccessJSON(returnData)
  1897. return
  1898. }
  1899. func (this *NewDialysisApiController) GetMemberPatient() {
  1900. adminUser := this.GetMobileAdminUserInfo()
  1901. orgid := adminUser.Org.Id
  1902. patient, err := service.GetMemberPatient(orgid)
  1903. if err != nil {
  1904. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1905. return
  1906. }
  1907. this.ServeSuccessJSON(map[string]interface{}{
  1908. "patient": patient,
  1909. })
  1910. }
  1911. func (this *NewDialysisApiController) GetSlowPatient() {
  1912. adminUser := this.GetMobileAdminUserInfo()
  1913. orgid := adminUser.Org.Id
  1914. patient, err := service.GetSlowPatient(orgid)
  1915. if err != nil {
  1916. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1917. return
  1918. }
  1919. this.ServeSuccessJSON(map[string]interface{}{
  1920. "patient": patient,
  1921. })
  1922. }
  1923. func (this *NewDialysisApiController) GetBloodPatient() {
  1924. adminUser := this.GetMobileAdminUserInfo()
  1925. orgid := adminUser.Org.Id
  1926. patient, err := service.GetBloodPatient(orgid)
  1927. if err != nil {
  1928. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1929. return
  1930. }
  1931. this.ServeSuccessJSON(map[string]interface{}{
  1932. "patient": patient,
  1933. })
  1934. }
  1935. func (this *NewDialysisApiController) SaveName() {
  1936. id := this.GetString("id")
  1937. ids, _ := strconv.ParseInt(id, 10, 64)
  1938. fmt.Println("id", ids)
  1939. name := this.GetString("name")
  1940. fmt.Println("name", name)
  1941. admin := models.SgjUserAdmin{
  1942. Name: name,
  1943. }
  1944. err := service.SaveName(ids, &admin)
  1945. if err != nil {
  1946. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1947. return
  1948. }
  1949. this.ServeSuccessJSON(map[string]interface{}{
  1950. "admin": admin,
  1951. })
  1952. }
  1953. func (this *NewDialysisApiController) GetAllOrganization() {
  1954. id, _ := this.GetInt64("id")
  1955. fmt.Println("id", id)
  1956. }
  1957. func (this *NewDialysisApiController) GetMyOrganazition() {
  1958. id, _ := this.GetInt64("id")
  1959. fmt.Println("id", id)
  1960. role, _ := service.GetAdminUserId(id)
  1961. organaziton, err := service.GetMyOrganaziton(role.AdminUserId)
  1962. if err != nil {
  1963. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1964. return
  1965. }
  1966. this.ServeSuccessJSON(map[string]interface{}{
  1967. "organaziton": organaziton,
  1968. })
  1969. }
  1970. func (this *NewDialysisApiController) GetOrgInformation() {
  1971. id, _ := this.GetInt64("id")
  1972. information, err := service.GetOrgInformation(id)
  1973. name, err := service.GetShortName(information.OrgType)
  1974. typeName, err := service.GetTypeName(name.Pid)
  1975. //获取省
  1976. province, err := service.GetOrgProvince(information.Province)
  1977. cityes, err := service.GetOrgProvince(information.City)
  1978. district, err := service.GetOrgProvince(information.District)
  1979. fmt.Print("err", err)
  1980. //if err != nil {
  1981. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1982. // return
  1983. //}
  1984. this.ServeSuccessJSON(map[string]interface{}{
  1985. "information": information,
  1986. "name": name,
  1987. "typeName": typeName,
  1988. "province": province,
  1989. "city": cityes,
  1990. "district": district,
  1991. })
  1992. }
  1993. func (this *NewDialysisApiController) GetAllOrgType() {
  1994. orgType, _ := service.GetAllOrgType()
  1995. returnData := make(map[string]interface{}, 0)
  1996. returnData["orgType"] = orgType
  1997. this.ServeSuccessJSON(returnData)
  1998. }
  1999. func (this *NewDialysisApiController) EditOrg() {
  2000. id, _ := this.GetInt64("id")
  2001. fmt.Println("id", id)
  2002. name := this.GetString("org_name")
  2003. fmt.Println("name", name)
  2004. provinceName := this.GetString("provinces_name")
  2005. fmt.Println("provinceName", provinceName)
  2006. cityName := this.GetString("city_name")
  2007. fmt.Println("cityName", cityName)
  2008. districtName := this.GetString("district_name")
  2009. fmt.Println("districtName", districtName)
  2010. address := this.GetString("address")
  2011. fmt.Println("address", address)
  2012. org_type := this.GetString("org_type")
  2013. fmt.Println("org_type", org_type)
  2014. contactName := this.GetString("contact_name")
  2015. fmt.Println("contactName", contactName)
  2016. orgPhone := this.GetString("telephone")
  2017. fmt.Println("orgPhone", orgPhone)
  2018. provinceID := 0
  2019. cityID := 0
  2020. districtID := 0
  2021. province, getProvinceErr := service.GetProvinceWithName(provinceName)
  2022. if getProvinceErr != nil {
  2023. utils.ErrorLog("查询省名失败:%v", getProvinceErr)
  2024. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2025. this.ServeJSON()
  2026. return
  2027. } else if province != nil {
  2028. provinceID = int(province.ID)
  2029. city, getCityErr := service.GetCityWithName(province.ID, cityName)
  2030. if getCityErr != nil {
  2031. utils.ErrorLog("查询城市名失败:%v", getCityErr)
  2032. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2033. this.ServeJSON()
  2034. return
  2035. } else if city != nil {
  2036. cityID = int(city.ID)
  2037. district, getDistrictErr := service.GetDistrictWithName(city.ID, districtName)
  2038. if getDistrictErr != nil {
  2039. utils.ErrorLog("查询区县名失拜:%v", getDistrictErr)
  2040. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2041. this.ServeJSON()
  2042. return
  2043. } else if district != nil {
  2044. districtID = int(district.ID)
  2045. }
  2046. }
  2047. }
  2048. orgType := service.GetOrgTypeByName(org_type)
  2049. fmt.Println(provinceID, cityID, districtID)
  2050. org := models.SgjUserOrg{
  2051. OrgName: name,
  2052. OrgShortName: name,
  2053. Province: int64(provinceID),
  2054. City: int64(cityID),
  2055. District: int64(districtID),
  2056. Address: address,
  2057. OrgType: orgType.ID,
  2058. Telephone: orgPhone,
  2059. ContactName: contactName,
  2060. }
  2061. fmt.Println("org", org)
  2062. err := service.UpdateOrg(id, org)
  2063. if err != nil {
  2064. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2065. return
  2066. }
  2067. this.ServeSuccessJSON(map[string]interface{}{
  2068. "org": org,
  2069. })
  2070. }
  2071. func (this *NewDialysisApiController) GetMyInforName() {
  2072. id, _ := this.GetInt64("id")
  2073. Username, err := service.GetAdminName(id)
  2074. if err != nil {
  2075. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2076. return
  2077. }
  2078. this.ServeSuccessJSON(map[string]interface{}{
  2079. "Username": Username,
  2080. })
  2081. }
  2082. func (this *NewDialysisApiController) GetMyInformationFour() {
  2083. adminUserInfo := this.GetMobileAdminUserInfo()
  2084. creatId := adminUserInfo.AdminUser.Id
  2085. fmt.Println("创建者ID", creatId)
  2086. orgid := adminUserInfo.Org.Id
  2087. fmt.Println("orgid", orgid)
  2088. Username, err := service.GetMyOrgInformationFour(creatId, orgid)
  2089. if err != nil {
  2090. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2091. return
  2092. }
  2093. this.ServeSuccessJSON(map[string]interface{}{
  2094. "Username": Username,
  2095. })
  2096. }
  2097. func (this *NewDialysisApiController) GetPartionDetail() {
  2098. id, _ := this.GetInt64("id")
  2099. partionDetail, err := service.GetPartionDetail(id)
  2100. if err != nil {
  2101. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2102. return
  2103. }
  2104. this.ServeSuccessJSON(map[string]interface{}{
  2105. "partionDetail": partionDetail,
  2106. })
  2107. }
  2108. func (this *NewDialysisApiController) UpdatePartition() {
  2109. id, _ := this.GetInt64("id")
  2110. name := this.GetString("name")
  2111. zoneType, _ := this.GetInt64("type")
  2112. strInt64 := strconv.FormatInt(zoneType, 10)
  2113. typeid, _ := strconv.Atoi(strInt64)
  2114. zone := models.DeviceZone{
  2115. Name: name,
  2116. Type: typeid,
  2117. }
  2118. err := service.UpdatePartition(id, &zone)
  2119. if err != nil {
  2120. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2121. return
  2122. }
  2123. this.ServeSuccessJSON(map[string]interface{}{
  2124. "zone": zone,
  2125. })
  2126. }
  2127. func (this *NewDialysisApiController) GetGroupDetail() {
  2128. id, _ := this.GetInt64("id")
  2129. groupDetail, err := service.GetGroupDetail(id)
  2130. if err != nil {
  2131. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2132. return
  2133. }
  2134. this.ServeSuccessJSON(map[string]interface{}{
  2135. "groupDetail": groupDetail,
  2136. })
  2137. }
  2138. func (this *NewDialysisApiController) UpdateGroup() {
  2139. id, _ := this.GetInt64("id")
  2140. name := this.GetString("name")
  2141. group := models.DeviceGroup{Name: name}
  2142. err := service.UpdateGroup(id, &group)
  2143. if err != nil {
  2144. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2145. return
  2146. }
  2147. this.ServeSuccessJSON(map[string]interface{}{
  2148. "group": group,
  2149. })
  2150. }
  2151. func (this *NewDialysisApiController) GetBedDetail() {
  2152. adminUser := this.GetMobileAdminUserInfo()
  2153. orgid := adminUser.Org.Id
  2154. id, _ := this.GetInt64("id")
  2155. zone, _ := service.GetAllZoneOne(orgid)
  2156. group, err := service.GetAllGroupOne(orgid)
  2157. bedDetail, err := service.GetBedDetail(id)
  2158. if err != nil {
  2159. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2160. return
  2161. }
  2162. this.ServeSuccessJSON(map[string]interface{}{
  2163. "zone": zone,
  2164. "group": group,
  2165. "bedDetail": bedDetail,
  2166. })
  2167. }
  2168. func (this *NewDialysisApiController) UpdatedBed() {
  2169. id, _ := this.GetInt64("id")
  2170. name := this.GetString("name")
  2171. fmt.Println("name", name)
  2172. zone, _ := this.GetInt64("zone")
  2173. fmt.Println("zone", zone)
  2174. group, _ := this.GetInt64("group")
  2175. fmt.Println("group", group)
  2176. number := models.DeviceNumber{
  2177. Number: name,
  2178. ZoneID: zone,
  2179. GroupID: group,
  2180. }
  2181. err := service.UpdatedBed(id, &number)
  2182. if err != nil {
  2183. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2184. return
  2185. }
  2186. this.ServeSuccessJSON(map[string]interface{}{
  2187. "number": number,
  2188. })
  2189. }
  2190. func (this *NewDialysisApiController) GetMyOrgInformation() {
  2191. creator, _ := this.GetInt64("creator")
  2192. fmt.Println("cretor", creator)
  2193. adminInfo := this.GetMobileAdminUserInfo()
  2194. appId := adminInfo.App.Id
  2195. //fmt.Println("appid------------------------------------",appId)
  2196. information, err := service.GetMyOrgInformation(creator, appId)
  2197. if err != nil {
  2198. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2199. return
  2200. }
  2201. this.ServeSuccessJSON(map[string]interface{}{
  2202. "information": information,
  2203. })
  2204. }
  2205. func (this *NewDialysisApiController) SaveNameTwo() {
  2206. id, _ := this.GetInt64("id")
  2207. name := this.GetString("name")
  2208. fmt.Println("name------------------", name)
  2209. role := models.SgjUserAdminRole{
  2210. UserName: name,
  2211. }
  2212. err := service.SaveNameTwo(id, &role)
  2213. if err != nil {
  2214. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2215. return
  2216. }
  2217. this.ServeSuccessJSON(map[string]interface{}{
  2218. "role": role,
  2219. })
  2220. }
  2221. func (this *NewDialysisApiController) GetCurrentOrg() {
  2222. nowTime := time.Now().Unix()
  2223. adminInfo := this.GetMobileAdminUserInfo()
  2224. orgId := adminInfo.Org.Id
  2225. var key = "kN*5&AHqLP7&IGRKvHoElJm*2YY6Nw*QSScJ4ff&DH&ofGnbfQIks1A1NT9AbIDB"
  2226. stringA := fmt.Sprintf("org_id=%d&time=%d", orgId, nowTime)
  2227. data := []byte(stringA)
  2228. has := md5.Sum(data)
  2229. md5str := fmt.Sprintf("%x", has)
  2230. stringB := fmt.Sprintf("string=%s&key=%s", md5str, key)
  2231. data = []byte(stringB)
  2232. has = md5.Sum(data)
  2233. signToken := fmt.Sprintf("%x", has)
  2234. name, err := service.GetOrgName(orgId)
  2235. //var fxlink = signToken + fmt.Sprintf("&fxtoken=%s&fxorgid=%d&timestamp=%d&fxadmin=%d", signToken, orgId, nowTime, name.Creator)
  2236. //fmt.Println(fxlink)
  2237. if err != nil {
  2238. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2239. return
  2240. }
  2241. this.ServeSuccessJSON(map[string]interface{}{
  2242. "org": name,
  2243. "nowTime": nowTime,
  2244. "signToken": signToken,
  2245. })
  2246. }
  2247. func (this *NewDialysisApiController) GetMyMobile() {
  2248. id, _ := this.GetInt64("id")
  2249. mobile, err := service.GetMyMobile(id)
  2250. if err != nil {
  2251. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2252. return
  2253. }
  2254. this.ServeSuccessJSON(map[string]interface{}{
  2255. "mobile": mobile,
  2256. })
  2257. }