123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406 |
- package new_mobile_api_controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "crypto/md5"
- "encoding/json"
- "fmt"
- "github.com/jinzhu/gorm"
- "strconv"
- "strings"
- "time"
- )
-
- type NewDialysisApiController struct {
- NewMobileBaseAPIAuthController
- }
-
- func (this *NewDialysisApiController) GetIllnesslist() {
-
- illnesslist, err := service.GetIllnessListTwo()
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "illnesslist": illnesslist,
- })
- }
-
- func (this *NewDialysisApiController) GetPatient() {
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- patient, total, err := service.GetBloodDialysisPatient(orgid, page, limit)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) GetAllPatient() {
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- patient, err := service.GetAllPatient(orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *NewDialysisApiController) GetGeneratedialysisno() {
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- dialysisNo := service.ChechLastDialysisNoTwo(orgid)
- //fmt.Print("机构ID",adminUserInfo.CurrentOrgId)
- if dialysisNo == 0 {
- dialysisNo = 1
- } else {
- dialysisNo++
- }
- no := strconv.FormatInt(dialysisNo, 10)
-
- rep := 3 - len(no)
-
- if rep > 0 {
- no = strings.Repeat("0", rep) + no
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "no": no,
- })
- return
- }
-
- func (this *NewDialysisApiController) GetBloodPatientInfo() {
- adminInfo := this.GetMobileAdminUserInfo()
- orgId := adminInfo.Org.Id
- fmt.Print("机构ID", orgId)
- phone := this.GetString("phone")
- _, errcode := service.GetBloodPatientInfo(orgId, phone)
- fmt.Print("errcode", errcode)
- if errcode == gorm.ErrRecordNotFound {
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- } else if errcode == nil {
- return
- } else {
-
- }
- }
-
- func (this *NewDialysisApiController) GetSlowPatientInfo() {
- adminInfo := this.GetMobileAdminUserInfo()
- orgId := adminInfo.Org.Id
- fmt.Print("机构ID", orgId)
- phone := this.GetString("phone")
- fmt.Print("phone", phone)
- _, errcode := service.GetSlowPatientInfo(orgId, phone)
- fmt.Print("errcode", errcode)
- if errcode == gorm.ErrRecordNotFound {
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- } else if errcode == nil {
- return
- } else {
-
- }
-
- }
-
- func (this *NewDialysisApiController) GetMemberpatientInfo() {
- adminInfo := this.GetMobileAdminUserInfo()
- orgId := adminInfo.Org.Id
- fmt.Print("机构ID", orgId)
- phone := this.GetString("phone")
- fmt.Print("phone", phone)
- _, errcode := service.GetMemberPatientInfo(orgId, phone)
- fmt.Print("errcode", errcode)
- if errcode == gorm.ErrRecordNotFound {
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- } else if errcode == nil {
- return
- } else {
-
- }
- }
-
- func (this *NewDialysisApiController) SavePatient() {
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Print("err", err)
- name := dataBody["name"].(string)
- fmt.Println("姓名", name)
- sex := int64(dataBody["sex"].(float64))
- fmt.Print("性别", sex)
- idCard := dataBody["idCard"].(string)
- fmt.Print("身份证", idCard)
- birthday := dataBody["birthday"].(string)
- births := strings.Split(birthday, "-")
- fmt.Print("生日", birthday)
- birYear, _ := strconv.Atoi(births[0])
- age := time.Now().Year() - birYear
- ages := int64(age)
- fmt.Println("age是多少", ages)
- timeLayout := "2006-01-02 15:04:05"
- theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
- birth := theTime.Unix()
- fmt.Print(birth)
- phone := dataBody["phone"].(string)
- fmt.Print("电话号码", phone)
- patientType := dataBody["result"].([]interface{})
- fmt.Print("患者标签", patientType)
- dialysis := dataBody["dialysis"].(string)
- fmt.Print("透析号", dialysis)
- patientsoure := int64(dataBody["patientsoure"].(float64))
- fmt.Print("患者来源", patientsoure)
- lapseto := int64(dataBody["lapseto"].(float64))
- fmt.Print("留置状态", lapseto)
- contagions := dataBody["resultTwo"].([]interface{})
- fmt.Print("传染病", contagions)
- ids := make([]int64, 0)
- for _, contagion := range contagions {
- id, _ := strconv.ParseInt(contagion.(string), 10, 64)
- ids = append(ids, id)
- }
- fmt.Print("传染病2", contagions)
- is_infectious := int64(dataBody["is_infectious"].(float64))
- fmt.Print("传染病", is_infectious)
- adminssionNumber := dataBody["admissionNumber"].(string)
- fmt.Print("住院号", adminssionNumber)
-
- fistdate := dataBody["fistDate"].(string)
- fmt.Print("首次透析日期", fistdate)
- timeLayouts := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- times, err := time.ParseInLocation(timeLayouts+" 15:04:05", fistdate+" 00:00:00", loc)
- //times, err := utils.ParseTimeStringToTime(timeLayout, fistdate+"00:00:00")
- fisttime := times.Unix()
- fmt.Print(fisttime)
-
- diagonse := dataBody["diagnose"].(string)
- fmt.Print("诊断", diagonse)
- avatar := dataBody["avatar"].(string)
- fmt.Print("头像", avatar)
- //慢性病
- requipmentId := dataBody["requipmentId"].(string)
- fmt.Print("设备ID", requipmentId)
- slowContagions := dataBody["resultThree"].([]interface{})
- fmt.Print("慢性传染病", slowContagions)
- idss := make([]int64, 0)
- for _, contagion := range slowContagions {
- id, _ := strconv.ParseInt(contagion.(string), 10, 64)
- idss = append(ids, id)
- }
- slowDiseases := dataBody["resultFour"].([]interface{})
- idsss := make([]int64, 0)
- for _, contagion := range slowDiseases {
- id, _ := strconv.ParseInt(contagion.(string), 10, 64)
- idsss = append(ids, id)
- }
- fmt.Print("慢性病", slowDiseases)
-
- bloodPatient := int64(dataBody["bloodPatient"].(float64))
- fmt.Print("血透病人", bloodPatient)
- slowpatient := int64(dataBody["slowPatient"].(float64))
- fmt.Print("慢病病人", slowpatient)
- memberpatient := int64(dataBody["memberPatient"].(float64))
- fmt.Print("会员病人", memberpatient)
- //会员
- memberFistDate := dataBody["memberFistDate"].(string)
- fmt.Print("首次透析日期", memberFistDate)
- //membertimes, err := utils.ParseTimeStringToTime(timeLayout, memberFistDate+"00:00:00")
- membertimes, _ := time.ParseInLocation(timeLayouts+" 15:04:05", memberFistDate+" 00:00:00", loc)
- memtime := membertimes.Unix()
- fmt.Print("会员透析日期", memtime)
- patient_type := int64(dataBody["patientType"].(float64))
- fmt.Print("病种", patient_type)
- treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
- fmt.Print("治疗方式", treatmentmethod)
-
- //查询身份证号码是否存在
- thisPatientOne, _ := service.FindPatientByIdCardNoFive(orgid, idCard)
- if thisPatientOne.ID > 0 {
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "身份证号码已存在"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- //查询手机号码是否存在
- thisPatient, err := service.FindPatientByMobileFive(phone, orgid)
- if thisPatient.ID > 0 {
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "手机号码已存在"
- this.ServeSuccessJSON(returnData)
- return
- }
- //如果是血透病人
- if bloodPatient == 1 {
- //查询透析号是否存在
- thisPatientTwo, _ := service.FindPatientByDialysisNoFive(orgid, dialysis)
- if thisPatientTwo.ID > 0 {
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "透析号已存在"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- patients := models.Patients{
- Name: name,
- Gender: sex,
- Birthday: birth,
- Age: ages,
- Phone: phone,
- Lapseto: lapseto,
- AdmissionNumber: adminssionNumber,
- FirstDialysisDate: fisttime,
- Diagnose: diagonse,
- Source: patientsoure,
- DialysisNo: dialysis,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- IdCardNo: idCard,
- IsInfectious: is_infectious,
- }
- err = service.CreateOldPatient(&patients)
- fmt.Print("报错", err)
- patient, err := service.GetLastOldPatient(orgid)
- fmt.Print("病人ID", patient.ID)
- err = service.AddContagions(patient.ID, patient.CreatedTime, patient.UpdatedTime, ids)
- fmt.Println("添加传染病失败", err)
-
- patientsNew := models.XtPatientsNew{
- Name: name,
- Gender: sex,
- Birthday: birth,
- Age: ages,
- Phone: phone,
- Lapseto: lapseto,
- AdmissionNumber: adminssionNumber,
- FirstDialysisDate: fisttime,
- Diagnose: diagonse,
- Source: patientsoure,
- DialysisNo: dialysis,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- MemberPatients: memberpatient,
- BloodPatients: bloodPatient,
- SlowPatients: slowpatient,
- BloodId: patient.ID,
- IsInfectious: is_infectious,
- IdCardNo: idCard,
- }
- err = service.CreateNewPatient(&patientsNew)
- fmt.Print("报错", err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patientsNew,
- })
- }
-
- fmt.Print("slowpatient", slowpatient)
- //如果是慢病病人
- if slowpatient == 1 {
- _, errcodetwo := service.GetSlowPatientData(phone, orgid)
- fmt.Print("查询慢慢是吧", errcodetwo)
- if errcodetwo == gorm.ErrRecordNotFound {
- patients := models.CdmPatients{
- Name: name,
- Gender: sex,
- Birthday: birth,
- Phone: phone,
- Diagnose: diagonse,
- Source: patientsoure,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- IdCardNo: idCard,
- }
- errcodetwo := service.CreateCdmPatient(&patients)
- fmt.Print("报错", errcodetwo)
- slowPatient, errcodetwo := service.GetOldCdmPatient(orgid)
- errcodetwo = service.AddSlowContagions(slowPatient.ID, slowPatient.CreatedTime, slowPatient.UpdatedTime, idss, orgid)
- fmt.Print("添加慢病传染病失败", errcodetwo)
- errcodethree := service.AddSlowDiseases(slowPatient.ID, slowPatient.CreatedTime, slowPatient.UpdatedTime, idsss, orgid)
- fmt.Print("添加慢性病失败", errcodethree)
-
- _, errcodefour := service.GetLastNewSlowPatient(phone, orgid)
- if errcodefour == gorm.ErrRecordNotFound {
- patientsNew := models.XtPatientsNew{
- Name: name,
- Gender: sex,
- Birthday: birth,
- Age: ages,
- Phone: phone,
- Lapseto: lapseto,
- AdmissionNumber: adminssionNumber,
- FirstDialysisDate: fisttime,
- Diagnose: diagonse,
- Source: patientsoure,
- DialysisNo: dialysis,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- MemberPatients: memberpatient,
- BloodPatients: bloodPatient,
- SlowPatients: slowpatient,
- SlowId: slowPatient.ID,
- IsInfectious: is_infectious,
- IdCardNo: idCard,
- EquitmentId: requipmentId,
- }
- err = service.CreateNewPatient(&patientsNew)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patientsNew,
- })
- } else if errcodetwo == nil {
- fmt.Print("病人已存在")
- if memberpatient == 1 {
- fmt.Print("进来没有", memberpatient)
- _, errmembercode := service.GetMemberPatientInfo(orgid, phone)
- if errmembercode == gorm.ErrRecordNotFound {
- customer := models.SgjUserCustomer{
- Name: name,
- UserOrgId: orgid,
- Mobile: phone,
- Gender: sex,
- Birthday: birth,
- IllDate: memtime,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- IllnessId: patient_type,
- TreatType: treatmentmethod,
- }
- errmembercode := service.CreateMemberPatient(&customer)
- fmt.Print("创建会员病人失败", errmembercode)
- _, errmembercodetwo := service.GetMemberNewPatient(phone, orgid)
- fmt.Print("错误", errmembercodetwo)
- //获取机构的最后一条数据
- memberPatient, errmembercode := service.GetLastMemberPatient(orgid)
- if errmembercodetwo == gorm.ErrRecordNotFound {
- patientsNew := models.XtPatientsNew{
- Name: name,
- Gender: sex,
- Birthday: birth,
- Age: ages,
- Phone: phone,
- Lapseto: lapseto,
- AdmissionNumber: adminssionNumber,
- FirstDialysisDate: fisttime,
- Diagnose: diagonse,
- Source: patientsoure,
- DialysisNo: dialysis,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- MemberPatients: memberpatient,
- BloodPatients: bloodPatient,
- SlowPatients: slowpatient,
- MemberId: memberPatient.ID,
- IsInfectious: is_infectious,
- IdCardNo: idCard,
- MemberFistdate: memtime,
- MemberPatienttype: patient_type,
- MemberTreatement: treatmentmethod,
- }
- err = service.CreateNewPatient(&patientsNew)
- fmt.Print("报错", err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patientsNew,
- })
- } else if errmembercode == nil {
- fmt.Print("病人已存在")
- return
- } else {
-
- }
- } else if errmembercode == nil {
- fmt.Print("病人已存在")
- return
- } else {
-
- }
- }
- return
- } else {
-
- }
-
- } else if errcodetwo == nil {
- fmt.Print("病人已存在")
- return
- } else {
-
- }
-
- }
-
- if memberpatient == 1 {
- fmt.Print("进来没有", memberpatient)
- _, errmembercode := service.GetMemberPatientInfo(orgid, phone)
- if errmembercode == gorm.ErrRecordNotFound {
- customer := models.SgjUserCustomer{
- Name: name,
- UserOrgId: orgid,
- Mobile: phone,
- Gender: sex,
- Birthday: birth,
- IllDate: memtime,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- IllnessId: patient_type,
- TreatType: treatmentmethod,
- }
- errmembercode := service.CreateMemberPatient(&customer)
- fmt.Print("创建会员病人失败", errmembercode)
- _, errmembercodetwo := service.GetMemberNewPatient(phone, orgid)
- fmt.Print("错误", errmembercodetwo)
- //获取机构的最后一条数据
- memberPatient, errmembercode := service.GetLastMemberPatient(orgid)
- if errmembercodetwo == gorm.ErrRecordNotFound {
- patientsNew := models.XtPatientsNew{
- Name: name,
- Gender: sex,
- Birthday: birth,
- Age: ages,
- Phone: phone,
- Lapseto: lapseto,
- AdmissionNumber: adminssionNumber,
- FirstDialysisDate: fisttime,
- Diagnose: diagonse,
- Source: patientsoure,
- DialysisNo: dialysis,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- MemberPatients: memberpatient,
- BloodPatients: bloodPatient,
- SlowPatients: slowpatient,
- MemberId: memberPatient.ID,
- IsInfectious: is_infectious,
- IdCardNo: idCard,
- MemberFistdate: memtime,
- MemberPatienttype: patient_type,
- MemberTreatement: treatmentmethod,
- }
- err = service.CreateNewPatient(&patientsNew)
- fmt.Print("报错", err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patientsNew,
- })
- } else if errmembercode == nil {
- fmt.Print("病人已存在")
- return
- } else {
-
- }
- } else if errmembercode == nil {
- fmt.Print("病人已存在")
- return
- } else {
-
- }
- }
-
- }
-
- func (this *NewDialysisApiController) GetPatientDetail() {
- id, _ := this.GetInt64("id")
- //获取病人详情信息
- detail, err := service.GetPatientDetailTwo(id)
- //获取传染病详情
- diseases := service.GetPatientDiseasesTwo(detail.BloodId)
- //获取慢病传染病
- slowDiseases, err := service.GetSlowPatientDiseases(detail.SlowId)
- //获取慢病慢性病
- cronicDiseases, err := service.GetCronicDiseases(detail.SlowId)
- //获取血透医嘱管理
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patientDetail": detail,
- "diseases": diseases,
- "slowDiseases": slowDiseases,
- "cronicDiseases": cronicDiseases,
- })
- }
-
- func (this *NewDialysisApiController) GetDoctorAdvices() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- id, _ := this.GetInt64("id")
- appid := adminInfo.App.Id
- fmt.Print("id", id)
- //跟据新表id获取老表id
- newPatientInfo, _ := service.GetPatientDetailTwo(id)
- //获取病人ID
- doctor_type, _ := this.GetInt64("type")
- fmt.Print("医嘱内型", doctor_type)
- start := this.GetString("startime")
- fmt.Print("start", start)
- startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
- startime := startTimes.Unix()
- fmt.Print("开始时间", startime)
- end := this.GetString("endtime")
- fmt.Print("end", end)
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
- endtime := endTimes.Unix()
- fmt.Print("结束时间", endtime)
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- fmt.Println("病人ID", newPatientInfo.BloodId)
- advice, _, err := service.GetNewDoctorAdvice(newPatientInfo.BloodId, doctor_type, startime, endtime, limit, page, orgid)
- one, total, err := service.GetNewDoctorAdviceOne(newPatientInfo.BloodId, doctor_type, startime, endtime, limit, page, orgid)
- fmt.Println("err------------------------", err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- doctor, err := service.GetAllDoctorTwo(orgid, appid)
- this.ServeSuccessJSON(map[string]interface{}{
- "advice": advice,
- "total": total,
- "doctor": doctor,
- "one": one,
- })
- }
-
- func (this *NewDialysisApiController) GetDryWeight() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- patient, _ := service.GetPatientDetailTwo(id)
- start := this.GetString("startime")
- startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
- startime := startTimes.Unix()
- fmt.Print("startime", startime)
- end := this.GetString("endtime")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
-
- endtime := endTimes.Unix()
- fmt.Print("endtime", endtime)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- dryweight, total, err := service.GetDryWeight(patient.BloodId, startime, endtime, limit, page, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "dryweight": dryweight,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) ToSearch() {
- adminUser := this.GetMobileAdminUserInfo()
- orgId := adminUser.Org.Id
- name := this.GetString("name")
- search, err := service.ToSearch(orgId, name)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "search": search,
- })
- }
-
- func (this *NewDialysisApiController) GetCourseManagement() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- patient, _ := service.GetPatientDetailTwo(id)
- start := this.GetString("startime")
- startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
- startime := startTimes.Unix()
- fmt.Print("startime", startime)
- end := this.GetString("endtime")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
- endtime := endTimes.Unix()
- fmt.Print("endtime", endtime)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- management, total, err := service.GetCourseManagement(patient.BloodId, startime, endtime, limit, page, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "coursemanagement": management,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) DeleteCourseManagement() {
- id, _ := this.GetInt64("id")
- err := service.DeleteCouseManagement(id)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) GetCouseManagentDetail() {
- id, _ := this.GetInt64("id")
- detail, err := service.GetCouseManagentDetail(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "couseDetail": detail,
- })
- }
-
- func (this *NewDialysisApiController) GetAllBloodDialysisPatient() {
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- lapseto, _ := this.GetInt64("patientstatus")
- source, _ := this.GetInt64("source")
- adminUserInfo := this.GetMobileAdminUserInfo()
- orgid := adminUserInfo.Org.Id
- patient, total, err := service.GetAllBloodDialysisPatient(orgid, page, limit, lapseto, source)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "bloodpatient": patient,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) GetAllSlowPatent() {
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- adminUserInfo := this.GetMobileAdminUserInfo()
- orgid := adminUserInfo.Org.Id
- patient, total, err := service.GetAllSlowPatient(orgid, page, limit)
- fmt.Print("err", err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "slowpatient": patient,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) GetAllMemberPatient() {
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- adminUserInfo := this.GetMobileAdminUserInfo()
- orgid := adminUserInfo.Org.Id
- patient, total, err := service.GetAllMemberPatient(orgid, page, limit)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "memberpatient": patient,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) DeleteDryWeight() {
- id, _ := this.GetInt64("id")
- err := service.DeleteDryWeight(id)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) GetDryWeightDetail() {
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- drydetail, err := service.GetDryWeightDetail(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "drydetail": drydetail,
- })
- }
-
- func (this *NewDialysisApiController) GetlongDialysisrecord() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- patient, _ := service.GetPatientDetailTwo(id)
- start := this.GetString("startime")
- startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
- startime := startTimes.Unix()
- fmt.Print("startime", startime)
- end := this.GetString("endtime")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
- endtime := endTimes.Unix()
- fmt.Print("endtime", endtime)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- dialysisrecord, total, err := service.GetlongDialysisrecord(patient.BloodId, startime, endtime, limit, page, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "dialysisrecord": dialysisrecord,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) GetRescuerecord() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- patient, _ := service.GetPatientDetailTwo(id)
- start := this.GetString("startime")
- startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
- startime := startTimes.Unix()
- fmt.Print("startime", startime)
- end := this.GetString("endtime")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
- endtime := endTimes.Unix()
- fmt.Print("endtime", endtime)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- rescuerecord, total, err := service.GetRescuerecord(patient.BloodId, startime, endtime, limit, page, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "rescuerecord": rescuerecord,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) GetScheduling() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- patient, _ := service.GetPatientDetailTwo(id)
- start := this.GetString("startime")
- startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
- startime := startTimes.Unix()
- fmt.Print("startime", startime)
- end := this.GetString("endtime")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
- endtime := endTimes.Unix()
- fmt.Print("endtime", endtime)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- mode_type, _ := this.GetInt64("mode_types")
- fmt.Print("透析模式", mode_type)
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- scheduling, total, err := service.GetScheduling(patient.BloodId, startime, endtime, limit, page, orgid, mode_type)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "scheduling": scheduling,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) GetEducation() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- patient, _ := service.GetPatientDetailTwo(id)
- start := this.GetString("startime")
- startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
- startime := startTimes.Unix()
- fmt.Print("startime", startime)
- end := this.GetString("endtime")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
- endtime := endTimes.Unix()
- fmt.Print("endtime", endtime)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- education, total, err := service.GetEducation(patient.BloodId, startime, endtime, limit, page, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "education": education,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) GetSchedulingDetail() {
- id, _ := this.GetInt64("id")
- detail, err := service.GetSchedulingDetail(id)
- patient, err := service.GetSchedulingTwo(id)
- fmt.Print("errr", err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedulingDetail": detail,
- "patient": patient,
- })
- }
-
- func (this *NewDialysisApiController) DeleteScheduling() {
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- err := service.DeleteScheduling(id)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) GetEducationDetail() {
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- education, err := service.GetEducationDetailOne(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "education": education,
- })
- }
-
- func (this *NewDialysisApiController) DeleteEducation() {
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- err := service.DeleteEducation(id)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) GetRescueRecordDetail() {
- id, _ := this.GetInt64("id")
- recordDetail, err := service.GetRescueRecordDetail(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "recordDetail": recordDetail,
- })
- }
-
- func (this *NewDialysisApiController) DeleteRescueRecord() {
- id, _ := this.GetInt64("id")
- err := service.DeleteRescueRecord(id)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) ToSearchePatient() {
- keyword := this.GetString("keyword")
- fmt.Print("关键字", keyword)
- adminUserinfo := this.GetMobileAdminUserInfo()
- orgid := adminUserinfo.Org.Id
- fmt.Println(orgid)
- patient, err := service.ToSearchePatient(keyword, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *NewDialysisApiController) SearchallPatient() {
- keyword := this.GetString("keyword")
- fmt.Print("关键字", keyword)
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- patient, err := service.SearchallPatient(keyword, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *NewDialysisApiController) GetSearchallBlood() {
- keyword := this.GetString("keyword")
- fmt.Print("关键字", keyword)
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- bloodPatient, err := service.GetSearchallBlood(keyword, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "bloodPatient": bloodPatient,
- })
- }
-
- func (this *NewDialysisApiController) GetSlowSearchePatient() {
- keyword := this.GetString("keyword")
- fmt.Print("关键字", keyword)
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- slowPatient, err := service.GetSlowSearchePatient(keyword, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "slowPatient": slowPatient,
- })
- }
-
- func (this *NewDialysisApiController) GetMemberSearchPatent() {
- keyword := this.GetString("keyword")
- fmt.Print("关键字", keyword)
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- memberPatient, err := service.GetMemberSearchPatient(keyword, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "memberPatient": memberPatient,
- })
- }
-
- func (this *NewDialysisApiController) GetLongDialysisDetail() {
- id, err := this.GetInt64("id")
- longDialysisDetail, err := service.GetLongDialysisDetail(id)
- patient, err := service.GetPatientName(longDialysisDetail.PatientId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "longDialysisDetail": longDialysisDetail,
- "patient": patient,
- })
- }
-
- func (this *NewDialysisApiController) DeleteLongDialysis() {
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- err := service.DeleteLongDialysis(id)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) GetDialysisrecord() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- patient, _ := service.GetPatientDetailTwo(id)
- start := this.GetString("startime")
- startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
- startime := startTimes.Unix()
- fmt.Print("startime", startime)
- end := this.GetString("endtime")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
- endtime := endTimes.Unix()
- fmt.Print("endtime", endtime)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- appid := adminInfo.App.Id
- dislystype, _ := this.GetInt64("dislysType")
- fmt.Print("透析模式", dislystype)
- dialysisrecord, total, err := service.GetDialysisrecord(patient.BloodId, startime, endtime, limit, page, orgid, dislystype)
- doctor, err := service.GetAllDoctorTwo(orgid, appid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "dialysisrecord": dialysisrecord,
- "total": total,
- "doctor": doctor,
- })
- }
-
- func (this *NewDialysisApiController) GetDoctorAdviceDetail() {
-
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- appid := adminUser.App.Id
- id, _ := this.GetInt64("id")
- bloodTwo, _ := service.GetPatientDetailTwo(id)
- fmt.Println("id", bloodTwo.BloodId)
- date, _ := this.GetInt64("date")
- doctorAdvicedetail, err := service.GetDoctorAdviceDetail(date, bloodTwo.BloodId, orgid)
- fmt.Println("err-------------------------------", err)
- doctorDetail, err := service.GetAllDoctorTwo(orgid, appid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "doctorAdvicedetail": doctorAdvicedetail,
- "doctorDetail": doctorDetail,
- })
- }
-
- func (this *NewDialysisApiController) DeleteManagement() {
- groupno, _ := this.GetInt64("id")
- fmt.Print("id是什么", groupno)
- orgId := this.GetMobileAdminUserInfo().Org.Id
- fmt.Print("机构ID", orgId)
- err := service.DeleteManagement(groupno, orgId)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) DeleteChild() {
- id, _ := this.GetInt64("id")
- err := service.DeleteChild(id)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) DeletePatient() {
- id, _ := this.GetInt64("id")
- err := service.DeletePatient(id)
- fmt.Println("错误是什么", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) UpdatedPatient() {
-
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- fmt.Print("机构ID", orgid)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Print("err", err)
- id := int64(dataBody["id"].(float64))
- fmt.Print("id", id)
- name := dataBody["name"].(string)
- fmt.Println("姓名", name)
- sex := int64(dataBody["sex"].(float64))
- fmt.Print("性别", sex)
- idCard := dataBody["idCard"].(string)
- fmt.Print("身份证", idCard)
- birthday := dataBody["birthday"].(string)
- births := strings.Split(birthday, "-")
- fmt.Print("生日", birthday)
- birYear, _ := strconv.Atoi(births[0])
- age := time.Now().Year() - birYear
- ages := int64(age)
- fmt.Println("age是多少", ages)
- timeLayout := "2006-01-02 15:04:05"
- theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
- birth := theTime.Unix()
- fmt.Print(birth)
- phone := dataBody["phone"].(string)
- fmt.Print("电话号码", phone)
- patientType := dataBody["result"].([]interface{})
- fmt.Print("患者标签", patientType)
- dialysis := dataBody["dialysis"].(string)
- fmt.Print("透析号", dialysis)
- patientsoure := int64(dataBody["patientsoure"].(float64))
- fmt.Print("患者来源", patientsoure)
- lapseto := int64(dataBody["lapseto"].(float64))
- fmt.Print("留置状态", lapseto)
- contagions := dataBody["resultTwo"].([]interface{})
- fmt.Print("传染病", contagions)
- ids := make([]int64, 0)
- for _, contagion := range contagions {
- id, _ := strconv.ParseInt(contagion.(string), 10, 64)
- ids = append(ids, id)
- }
- fmt.Print("传染病2", contagions)
- is_infectious := int64(dataBody["is_infectious"].(float64))
- fmt.Print("传染病", is_infectious)
- adminssionNumber := dataBody["admissionNumber"].(string)
- fmt.Print("住院号", adminssionNumber)
-
- fistdate := dataBody["fistDate"].(string)
- fmt.Print("首次透析日期", fistdate)
- timeLayouts := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- times, err := time.ParseInLocation(timeLayouts+" 15:04:05", fistdate+" 00:00:00", loc)
- //times, err := utils.ParseTimeStringToTime(timeLayout, fistdate+"00:00:00")
- fisttime := times.Unix()
- fmt.Print(fisttime)
-
- diagonse := dataBody["diagnose"].(string)
- fmt.Print("诊断", diagonse)
- avatar := dataBody["avatar"].(string)
- fmt.Print("头像", avatar)
- //慢性病
- requipmentId := dataBody["requipmentId"].(string)
- fmt.Print("设备ID", requipmentId)
- slowContagions := dataBody["resultThree"].([]interface{})
- fmt.Print("慢性传染病", slowContagions)
- idss := make([]int64, 0)
- for _, contagion := range slowContagions {
- id, _ := strconv.ParseInt(contagion.(string), 10, 64)
- idss = append(ids, id)
- }
- fmt.Print(idss)
- slowDiseases := dataBody["resultFour"].([]interface{})
- idsss := make([]int64, 0)
- for _, contagion := range slowDiseases {
- id, _ := strconv.ParseInt(contagion.(string), 10, 64)
- idsss = append(ids, id)
- }
- fmt.Print("idsss", idsss)
- fmt.Print("慢性病", slowDiseases)
- bloodPatient := int64(dataBody["bloodPatient"].(float64))
- fmt.Print("血透病人", bloodPatient)
- slowpatient := int64(dataBody["slowPatient"].(float64))
- fmt.Print("慢病病人", slowpatient)
- memberpatient := int64(dataBody["memberPatient"].(float64))
- fmt.Print("会员病人", memberpatient)
- //会员
- memberFistDate := dataBody["memberFistDate"].(string)
- fmt.Print("首次透析日期", memberFistDate)
- //membertimes, err := utils.ParseTimeStringToTime(timeLayout, memberFistDate+"00:00:00")
- membertimes, _ := time.ParseInLocation(timeLayouts+" 15:04:05", memberFistDate+" 00:00:00", loc)
- memtime := membertimes.Unix()
- fmt.Print("会员透析日期", memtime)
- patient_type := int64(dataBody["patientType"].(float64))
- fmt.Print("病种", patient_type)
- treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
- fmt.Print("治疗方式", treatmentmethod)
-
- //如果是血透病人
- if bloodPatient == 1 {
- //根据新表ID获取老表病人ID
- patient, _ := service.GetNewPatient(id)
-
- //判断身份证号是否相同
- thisPatient, _ := service.FindPatientByIdCardNoOne(orgid, idCard, id)
- if thisPatient.ID > 0 && thisPatient.ID != patient.BloodId {
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "身份证号码已存在"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- //查询手机号码是否存在
- thisPatientOne, err := service.FindPatientByMobileOne(phone, orgid, id)
- if thisPatientOne.ID > 0 && thisPatientOne.ID != patient.BloodId {
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "手机号码已存在"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- //查询号透析号是否相同
- thisPatientother, _ := service.FindPatientByDialysisNoOne(orgid, dialysis, id)
- if thisPatientother.ID > 0 && thisPatientother.ID != patient.BloodId {
- fmt.Println("进来没有---------------------------------")
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "透析号码已存在"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- patients := models.Patients{
- Name: name,
- Gender: sex,
- Birthday: birth,
- Age: ages,
- Phone: phone,
- Lapseto: lapseto,
- AdmissionNumber: adminssionNumber,
- FirstDialysisDate: fisttime,
- Diagnose: diagonse,
- Source: patientsoure,
- DialysisNo: dialysis,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- IdCardNo: idCard,
- IsInfectious: is_infectious,
- }
- err = service.UpdatedPatient(patients, patient.BloodId)
- patientsNew := models.XtPatientsNew{
- ID: id,
- Name: name,
- Gender: sex,
- Birthday: birth,
- Age: ages,
- Phone: phone,
- Lapseto: lapseto,
- AdmissionNumber: adminssionNumber,
- FirstDialysisDate: fisttime,
- Diagnose: diagonse,
- Source: patientsoure,
- DialysisNo: dialysis,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- IdCardNo: idCard,
- IsInfectious: is_infectious,
- }
- err = service.UpdateXtPatientNew(patientsNew, id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patients": patientsNew,
- })
- //更改传染病
- updateContagions, err := service.UpdateContagions(patient.BloodId)
- fmt.Print("更新传染病失败", err)
- fmt.Print("up", updateContagions)
- err = service.AddContagions(patient.BloodId, patient.CreatedTime, patient.UpdatedTime, ids)
- fmt.Println("添加传染病失败", err)
- }
- if slowpatient == 1 {
- patient, _ := service.GetNewPatient(id)
- patients := models.CdmPatients{
- Name: name,
- Gender: sex,
- Birthday: birth,
- Phone: phone,
- Diagnose: diagonse,
- Source: patientsoure,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- IdCardNo: idCard,
- }
- err := service.UpdateCustomer(patients, patient.SlowId)
- fmt.Print("更新慢病患者失败", err)
- xtPatientsNew := models.XtPatientsNew{
- ID: id,
- Name: name,
- Gender: sex,
- Birthday: birth,
- Age: ages,
- Phone: phone,
- Lapseto: lapseto,
- AdmissionNumber: adminssionNumber,
- FirstDialysisDate: fisttime,
- Diagnose: diagonse,
- Source: patientsoure,
- DialysisNo: dialysis,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- MemberPatients: memberpatient,
- BloodPatients: bloodPatient,
- SlowPatients: slowpatient,
- IsInfectious: is_infectious,
- IdCardNo: idCard,
- EquitmentId: requipmentId,
- }
- err = service.UpdateXtPatientNew(xtPatientsNew, id)
- fmt.Print("更新失败", err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patients": xtPatientsNew,
- })
- }
-
- if memberpatient == 1 {
- patient, _ := service.GetNewPatient(id)
- customer := models.SgjUserCustomer{
- Name: name,
- UserOrgId: orgid,
- Mobile: phone,
- Gender: sex,
- Birthday: birth,
- IllDate: memtime,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- IllnessId: patient_type,
- TreatType: treatmentmethod,
- }
- err := service.UpdatedCustomer(customer, patient.MemberId)
-
- fmt.Print("更新失败", err)
- patientsNew := models.XtPatientsNew{
- ID: id,
- Name: name,
- Gender: sex,
- Birthday: birth,
- Age: ages,
- Phone: phone,
- Lapseto: lapseto,
- AdmissionNumber: adminssionNumber,
- FirstDialysisDate: fisttime,
- Diagnose: diagonse,
- Source: patientsoure,
- DialysisNo: dialysis,
- UserOrgId: orgid,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Avatar: avatar,
- MemberPatients: memberpatient,
- BloodPatients: bloodPatient,
- SlowPatients: slowpatient,
- IsInfectious: is_infectious,
- IdCardNo: idCard,
- MemberFistdate: memtime,
- MemberPatienttype: patient_type,
- MemberTreatement: treatmentmethod,
- }
- err = service.UpdateXtPatientNewOne(patientsNew, id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patients": patientsNew,
- })
- }
- }
-
- func (this *NewDialysisApiController) GetAllDoctor() {
- orgid := this.GetMobileAdminUserInfo().Org.Id
- id := this.GetMobileAdminUserInfo().App.Id
- doctor, err := service.GetAllDoctorTwo(orgid, id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "doctor": doctor,
- })
- }
-
- func (this *NewDialysisApiController) GetAllInspection() {
-
- //查询该机构是否存在检验检测项目
- orgid := this.GetMobileAdminUserInfo().Org.Id
- fmt.Print("orgid", orgid)
- _, errcode := service.GetInspectionByOrgId(orgid)
- if errcode == gorm.ErrRecordNotFound {
- inspection, err := service.GetAllInspection(0)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "inspection": inspection,
- })
- } else if errcode == nil {
- inspection, err := service.GetAllInspection(orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "inspection": inspection,
- })
- } else {
-
- }
-
- }
-
- func (this *NewDialysisApiController) GetInspection() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- id, _ := this.GetInt64("id")
- fmt.Print("id", id)
- patient, _ := service.GetPatientDetailTwo(id)
- start := this.GetString("startime")
- startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
- startime := startTimes.Unix()
- fmt.Print("startime", startime)
- end := this.GetString("endtime")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
- endtime := endTimes.Unix()
- fmt.Print("endtime", endtime)
- limit, _ := this.GetInt64("limit")
- fmt.Print("limit", limit)
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- projectid, _ := this.GetInt64("projectid")
- fmt.Print("projectid", projectid)
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- fmt.Print("patient", patient)
- fmt.Print("orgid", orgid)
-
- //查询该机构是否存在
- //inspection, _ := service.GetInspectionById(patient.BloodId, startime, endtime, orgid)
- //if len(inspection) == 0 {
- //
- //}
- inspection, total, err := service.GetInspection(patient.BloodId, startime, endtime, limit, page, orgid, projectid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "inspection": inspection,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) GetMyInformation() {
- id, _ := this.GetInt64("id")
- roleInfo, err := service.GetPosition(id)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "roleInfo": roleInfo,
- })
- return
- }
-
- func (this *NewDialysisApiController) GetMyInformationThree() {
- id, _ := this.GetInt64("id")
- roleInfo, err := service.GetPositionOne(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "roleInfo": roleInfo,
- })
- return
- }
-
- func (this *NewDialysisApiController) GetPatientName() {
- id, _ := this.GetInt64("id")
- patients, _ := service.GetPatientDetailTwo(id)
- fmt.Print("paitents", patients.ID)
- patientName, err := service.GetPatientName(patients.BloodId)
- fmt.Print("err", err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patientName": patientName,
- })
- }
-
- func (this *NewDialysisApiController) GetInspectionDetail() {
-
- patientid, _ := this.GetInt64("patientid")
- fmt.Print("patientid", patientid)
- patients, _ := service.GetPatientDetailTwo(patientid)
- date, _ := this.GetInt64("date")
- fmt.Print("date", date)
- projectid, _ := this.GetInt64("projectid")
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- InspectionDetail, err := service.GetInspectionDetail(patients.BloodId, date, orgid, projectid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "InspectionDetail": InspectionDetail,
- })
- }
-
- func (this *NewDialysisApiController) SaveFeed() {
-
- question, _ := this.GetInt64("question")
- fmt.Print("question", question)
- title := this.GetString("title")
- fmt.Print("title", title)
- content := this.GetString("content")
- fmt.Print("content", content)
- phone := this.GetString("phone")
- fmt.Print("phone", phone)
- times, _ := this.GetInt64("time")
- fmt.Print("time", times)
- adminuserid, _ := this.GetInt64("admin_user_id")
- fmt.Println("admin", adminuserid)
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- appid := adminUser.App.Id
- feedback := models.XtPatientFeedback{
- ProblemType: question,
- Title: title,
- Content: content,
- Phone: phone,
- TimeQuantum: times,
- UserOrgId: orgid,
- Ctime: time.Now().Unix(),
- Status: 1,
- AdminUserId: adminuserid,
- AppId: appid,
- }
- err := service.CreateFeedBack(&feedback)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "feedback": feedback,
- })
- }
-
- func (this *NewDialysisApiController) DeleteInspection() {
- admininfo := this.GetMobileAdminUserInfo()
- orgid := admininfo.Org.Id
- date, _ := this.GetInt64("date")
- fmt.Println("date", date)
- err := service.DeleteInspection(date, orgid)
- fmt.Println("删除失败", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "手机号码已存在"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) DeleteChildInspection() {
- admininfo := this.GetMobileAdminUserInfo()
- orgid := admininfo.Org.Id
- name := this.GetString("name")
- fmt.Println("name", name)
- date, _ := this.GetInt64("date")
- fmt.Println("date", date)
- err := service.DeleteChildInspection(name, date, orgid)
- fmt.Println("删除失败", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "手机号码已存在"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) SaveMessage() {
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- message := this.GetString("message")
- fmt.Println("message", message)
- role := models.SgjUserAdminRole{
- Message: message,
- }
- err := service.SaveMessage(id, &role)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "role": role,
- })
- }
-
- func (this *NewDialysisApiController) SaveSex() {
- sex, _ := this.GetInt64("sex")
- fmt.Println("sex", sex)
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- role := models.SgjUserAdminRole{
- Sex: sex,
- }
- err := service.SaveSex(id, &role)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "role": role,
- })
- }
-
- func (this *NewDialysisApiController) SaveBirthday() {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- id := dataBody["id"].(string)
- ids, err := strconv.ParseInt(id, 10, 64)
- fmt.Print("id", id)
- birthday := dataBody["birth"].(string)
- timeLayout := "2006-01-02 15:04:05"
- theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
- birth := theTime.Unix()
- role := models.SgjUserAdminRole{
- Birthday: birth,
- }
- err = service.SaveBirthday(ids, &role)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "role": role,
- })
- }
-
- func (this *NewDialysisApiController) GetOrgName() {
-
- id, _ := this.GetInt64("id")
- name, err := service.GetOrgName(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "name": name,
- })
- }
-
- func (this *NewDialysisApiController) GetRoleName() {
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- orgid, _ := this.GetInt64("orgid")
- fmt.Println("orgid", orgid)
- //跟剧机构ID获取APPID
- app, _ := service.GetAppId(orgid)
- name, err := service.GetRoleName(id, orgid, app.Id)
- //获取管理员
- admin, err := service.GetAdmin(id)
- positionName, err := service.GetPositionName(id, orgid, app.Id)
- role_ids := strings.Split(positionName.RoleIds, ",")
- var names = ""
- for _, item := range role_ids {
- id, _ := strconv.ParseInt(item, 10, 64)
- role, _ := service.GetRole(id)
- if len(role.RoleName) != 0 {
- names = role.RoleName + "," + names
- }
- }
- fmt.Println("role_ids--------------", role_ids)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "name": name,
- "positionName": positionName,
- "admin": admin,
- "names": names,
- })
- }
-
- func (this *NewDialysisApiController) SavePartition() {
- adminInfo := this.GetMobileAdminUserInfo()
- name := this.GetString("name")
- fmt.Println("分区名称", name)
- zonetype, _ := this.GetInt64("type")
- fmt.Println("分区型号", zonetype)
- strInt64 := strconv.FormatInt(zonetype, 10)
- typeid, _ := strconv.Atoi(strInt64)
- zone := models.DeviceZone{
- Name: name,
- Type: typeid,
- OrgID: adminInfo.Org.Id,
- Status: 1,
- CreateTime: time.Now().Unix(),
- }
- err := service.CreatedZone(&zone)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "zone": zone,
- })
- }
-
- func (this *NewDialysisApiController) GetAllZone() {
-
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- page, _ := this.GetInt64("page")
- limit, _ := this.GetInt64("limit")
- zone, total, err := service.GetAllZone(orgid, page, limit)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "zone": zone,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) DeleteZone() {
- id, _ := this.GetInt64("id")
- err := service.DeleteZoneById(id)
- fmt.Println("删除失败", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "删除失败"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) SaveGroup() {
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- name := this.GetString("name")
- fmt.Println("name", name)
- group := models.DeviceGroup{
- Name: name,
- Status: 1,
- CreateTime: time.Now().Unix(),
- OrgID: orgid,
- }
- err := service.SaveGroup(&group)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "group": group,
- })
- }
-
- func (this *NewDialysisApiController) GetAllGroup() {
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- page, _ := this.GetInt64("page")
- fmt.Println("page", page)
- limit, _ := this.GetInt64("limit")
- fmt.Println("limit", limit)
- group, total, err := service.GetAllGroup(orgid, page, limit)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "group": group,
- "total": total,
- })
- }
-
- func (this *NewDialysisApiController) DeleteGroup() {
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- err := service.DeleteGroup(id)
- fmt.Println("删除失败", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "删除失败"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) GetAllGroupOne() {
- admininfo := this.GetMobileAdminUserInfo()
- orgid := admininfo.Org.Id
- zone, _ := service.GetAllZoneOne(orgid)
- group, err := service.GetAllGroupOne(orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "zone": zone,
- "group": group,
- })
- }
-
- func (this *NewDialysisApiController) SaveBed() {
- adminuser := this.GetMobileAdminUserInfo()
- orgid := adminuser.Org.Id
- name := this.GetString("name")
- fmt.Println("name", name)
- zone, _ := this.GetInt64("zone")
- fmt.Print("zone", zone)
- group, _ := this.GetInt64("group")
- fmt.Println("group", group)
- number := models.DeviceNumber{
- Number: name,
- ZoneID: zone,
- GroupID: group,
- OrgID: orgid,
- Status: 1,
- CreateTime: time.Now().Unix(),
- }
- err := service.CreateNumber(&number)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "number": number,
- })
- }
-
- func (this *NewDialysisApiController) GetAllNumber() {
- admininfo := this.GetMobileAdminUserInfo()
- orgid := admininfo.Org.Id
- page, _ := this.GetInt64("page")
- fmt.Print("page", page)
- limit, _ := this.GetInt64("limit")
- fmt.Println("limit", limit)
- number, total, err := service.GetAllNumber(page, limit, orgid)
- zone, _ := service.GetAllZoneOne(orgid)
- group, _ := service.GetAllGroupOne(orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "number": number,
- "total": total,
- "zone": zone,
- "group": group,
- })
- }
-
- func (this *NewDialysisApiController) DeleteBed() {
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- nowDateTime := time.Now()
- nowDate := nowDateTime.Format("2006-01-02")
- nowDate += " 00:00:00"
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
- fmt.Println(theTime.Unix())
- adminInfo := this.GetMobileAdminUserInfo()
- orgid := adminInfo.Org.Id
- _, errcode := service.GetSchedu(id, theTime.Unix(), orgid)
- fmt.Println("errcode", errcode)
- if errcode == gorm.ErrRecordNotFound {
- err := service.DeleteBed(id)
- fmt.Println("删除失败", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "删除失败"
- this.ServeSuccessJSON(returnData)
- return
- } else if errcode == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
-
- func (this *NewDialysisApiController) LoginOut() {
- this.Ctx.SetCookie("logout_cookie", "1")
- this.Ctx.SetCookie("token_cookie", "")
- id, _ := this.GetInt64("id")
- loginLog := models.SgjUserAdminLoginLog{
- AdminUserId: id,
- OrgId: 0,
- AppId: 0,
- Ip: utils.GetIP(this.Ctx.Request),
- OperateType: 2,
- AppType: 0,
- Ctime: time.Now().Unix(),
- }
- err := service.CreateLoginLod(&loginLog)
- fmt.Println("err--------", err)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "删除失败"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *NewDialysisApiController) GetMemberPatient() {
-
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- patient, err := service.GetMemberPatient(orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *NewDialysisApiController) GetSlowPatient() {
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- patient, err := service.GetSlowPatient(orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *NewDialysisApiController) GetBloodPatient() {
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- patient, err := service.GetBloodPatient(orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *NewDialysisApiController) SaveName() {
- id := this.GetString("id")
- ids, _ := strconv.ParseInt(id, 10, 64)
- fmt.Println("id", ids)
- name := this.GetString("name")
- fmt.Println("name", name)
- admin := models.SgjUserAdmin{
- Name: name,
- }
- err := service.SaveName(ids, &admin)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "admin": admin,
- })
- }
-
- func (this *NewDialysisApiController) GetAllOrganization() {
-
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- }
-
- func (this *NewDialysisApiController) GetMyOrganazition() {
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- role, _ := service.GetAdminUserId(id)
- organaziton, err := service.GetMyOrganaziton(role.AdminUserId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "organaziton": organaziton,
- })
- }
-
- func (this *NewDialysisApiController) GetOrgInformation() {
- id, _ := this.GetInt64("id")
- information, err := service.GetOrgInformation(id)
- name, err := service.GetShortName(information.OrgType)
- typeName, err := service.GetTypeName(name.Pid)
- //获取省
- province, err := service.GetOrgProvince(information.Province)
- cityes, err := service.GetOrgProvince(information.City)
- district, err := service.GetOrgProvince(information.District)
- fmt.Print("err", err)
- //if err != nil {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- // return
- //}
- this.ServeSuccessJSON(map[string]interface{}{
- "information": information,
- "name": name,
- "typeName": typeName,
- "province": province,
- "city": cityes,
- "district": district,
- })
- }
-
- func (this *NewDialysisApiController) GetAllOrgType() {
-
- orgType, _ := service.GetAllOrgType()
- returnData := make(map[string]interface{}, 0)
- returnData["orgType"] = orgType
- this.ServeSuccessJSON(returnData)
- }
-
- func (this *NewDialysisApiController) EditOrg() {
- id, _ := this.GetInt64("id")
- fmt.Println("id", id)
- name := this.GetString("org_name")
- fmt.Println("name", name)
- provinceName := this.GetString("provinces_name")
- fmt.Println("provinceName", provinceName)
- cityName := this.GetString("city_name")
- fmt.Println("cityName", cityName)
- districtName := this.GetString("district_name")
- fmt.Println("districtName", districtName)
- address := this.GetString("address")
- fmt.Println("address", address)
- org_type := this.GetString("org_type")
- fmt.Println("org_type", org_type)
- contactName := this.GetString("contact_name")
- fmt.Println("contactName", contactName)
- orgPhone := this.GetString("telephone")
- fmt.Println("orgPhone", orgPhone)
- provinceID := 0
- cityID := 0
- districtID := 0
- province, getProvinceErr := service.GetProvinceWithName(provinceName)
- if getProvinceErr != nil {
- utils.ErrorLog("查询省名失败:%v", getProvinceErr)
- this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- this.ServeJSON()
- return
- } else if province != nil {
- provinceID = int(province.ID)
- city, getCityErr := service.GetCityWithName(province.ID, cityName)
- if getCityErr != nil {
- utils.ErrorLog("查询城市名失败:%v", getCityErr)
- this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- this.ServeJSON()
- return
- } else if city != nil {
- cityID = int(city.ID)
- district, getDistrictErr := service.GetDistrictWithName(city.ID, districtName)
- if getDistrictErr != nil {
- utils.ErrorLog("查询区县名失拜:%v", getDistrictErr)
- this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- this.ServeJSON()
- return
- } else if district != nil {
- districtID = int(district.ID)
- }
- }
- }
-
- orgType := service.GetOrgTypeByName(org_type)
- fmt.Println(provinceID, cityID, districtID)
- org := models.SgjUserOrg{
- OrgName: name,
- OrgShortName: name,
- Province: int64(provinceID),
- City: int64(cityID),
- District: int64(districtID),
- Address: address,
- OrgType: orgType.ID,
- Telephone: orgPhone,
- ContactName: contactName,
- }
-
- fmt.Println("org", org)
- err := service.UpdateOrg(id, org)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "org": org,
- })
- }
-
- func (this *NewDialysisApiController) GetMyInforName() {
- id, _ := this.GetInt64("id")
- Username, err := service.GetAdminName(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "Username": Username,
- })
- }
-
- func (this *NewDialysisApiController) GetMyInformationFour() {
- adminUserInfo := this.GetMobileAdminUserInfo()
- creatId := adminUserInfo.AdminUser.Id
- fmt.Println("创建者ID", creatId)
- orgid := adminUserInfo.Org.Id
- fmt.Println("orgid", orgid)
- Username, err := service.GetMyOrgInformationFour(creatId, orgid)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "Username": Username,
- })
- }
-
- func (this *NewDialysisApiController) GetPartionDetail() {
- id, _ := this.GetInt64("id")
- partionDetail, err := service.GetPartionDetail(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "partionDetail": partionDetail,
- })
- }
-
- func (this *NewDialysisApiController) UpdatePartition() {
- id, _ := this.GetInt64("id")
- name := this.GetString("name")
- zoneType, _ := this.GetInt64("type")
- strInt64 := strconv.FormatInt(zoneType, 10)
- typeid, _ := strconv.Atoi(strInt64)
- zone := models.DeviceZone{
- Name: name,
- Type: typeid,
- }
- err := service.UpdatePartition(id, &zone)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "zone": zone,
- })
- }
-
- func (this *NewDialysisApiController) GetGroupDetail() {
- id, _ := this.GetInt64("id")
- groupDetail, err := service.GetGroupDetail(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "groupDetail": groupDetail,
- })
-
- }
-
- func (this *NewDialysisApiController) UpdateGroup() {
- id, _ := this.GetInt64("id")
- name := this.GetString("name")
- group := models.DeviceGroup{Name: name}
- err := service.UpdateGroup(id, &group)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "group": group,
- })
- }
-
- func (this *NewDialysisApiController) GetBedDetail() {
- adminUser := this.GetMobileAdminUserInfo()
- orgid := adminUser.Org.Id
- id, _ := this.GetInt64("id")
- zone, _ := service.GetAllZoneOne(orgid)
- group, err := service.GetAllGroupOne(orgid)
- bedDetail, err := service.GetBedDetail(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "zone": zone,
- "group": group,
- "bedDetail": bedDetail,
- })
- }
-
- func (this *NewDialysisApiController) UpdatedBed() {
- id, _ := this.GetInt64("id")
- name := this.GetString("name")
- fmt.Println("name", name)
- zone, _ := this.GetInt64("zone")
- fmt.Println("zone", zone)
- group, _ := this.GetInt64("group")
- fmt.Println("group", group)
- number := models.DeviceNumber{
- Number: name,
- ZoneID: zone,
- GroupID: group,
- }
- err := service.UpdatedBed(id, &number)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "number": number,
- })
- }
-
- func (this *NewDialysisApiController) GetMyOrgInformation() {
- creator, _ := this.GetInt64("creator")
- fmt.Println("cretor", creator)
- adminInfo := this.GetMobileAdminUserInfo()
- appId := adminInfo.App.Id
- //fmt.Println("appid------------------------------------",appId)
- information, err := service.GetMyOrgInformation(creator, appId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "information": information,
- })
- }
-
- func (this *NewDialysisApiController) SaveNameTwo() {
- id, _ := this.GetInt64("id")
- name := this.GetString("name")
- fmt.Println("name------------------", name)
- role := models.SgjUserAdminRole{
- UserName: name,
- }
- err := service.SaveNameTwo(id, &role)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "role": role,
- })
- }
-
- func (this *NewDialysisApiController) GetCurrentOrg() {
- nowTime := time.Now().Unix()
- adminInfo := this.GetMobileAdminUserInfo()
- orgId := adminInfo.Org.Id
-
- var key = "kN*5&AHqLP7&IGRKvHoElJm*2YY6Nw*QSScJ4ff&DH&ofGnbfQIks1A1NT9AbIDB"
- stringA := fmt.Sprintf("org_id=%d&time=%d", orgId, nowTime)
- data := []byte(stringA)
- has := md5.Sum(data)
- md5str := fmt.Sprintf("%x", has)
- stringB := fmt.Sprintf("string=%s&key=%s", md5str, key)
- data = []byte(stringB)
- has = md5.Sum(data)
- signToken := fmt.Sprintf("%x", has)
- name, err := service.GetOrgName(orgId)
- //var fxlink = signToken + fmt.Sprintf("&fxtoken=%s&fxorgid=%d×tamp=%d&fxadmin=%d", signToken, orgId, nowTime, name.Creator)
- //fmt.Println(fxlink)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "org": name,
- "nowTime": nowTime,
- "signToken": signToken,
- })
- }
-
- func (this *NewDialysisApiController) GetMyMobile() {
- id, _ := this.GetInt64("id")
- mobile, err := service.GetMyMobile(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "mobile": mobile,
- })
- }
|