12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408 |
- 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.DelSession("mobile_admin_user_info")
- 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,
- })
- }
|