12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "encoding/json"
- "fmt"
- "reflect"
- "strconv"
- "strings"
- "time"
-
- "github.com/astaxie/beego"
- )
-
- func PatientDataConfigAPIControllerRegistRouters() {
- beego.Router("/api/patient/courses", &PatientDataConfigAPIController{}, "get:Courses")
- beego.Router("/api/patient/course/create", &PatientDataConfigAPIController{}, "get:CreateCourse")
- beego.Router("/api/patient/course/delete", &PatientDataConfigAPIController{}, "post:DeleteCourse")
- beego.Router("/api/patient/course/modify", &PatientDataConfigAPIController{}, "get:ModifyCourse")
-
- beego.Router("/api/patient/rescues", &PatientDataConfigAPIController{}, "get:Rescues")
- beego.Router("/api/patient/rescue/create", &PatientDataConfigAPIController{}, "post:CreateRescue")
- beego.Router("/api/patient/rescue/delete", &PatientDataConfigAPIController{}, "post:DeleteRescue")
-
- beego.Router("/api/patient/sickhistory", &PatientDataConfigAPIController{}, "get:GetSickHistorys")
- beego.Router("/api/patient/sickhistory/create", &PatientDataConfigAPIController{}, "get:CreateSickHistory")
- beego.Router("/api/patient/sickhistory/delete", &PatientDataConfigAPIController{}, "post:DeleteSickHistory")
- beego.Router("/api/patient/sickhistory/modify", &PatientDataConfigAPIController{}, "get:ModifySickHistory")
-
- beego.Router("/api/patient/physiquecheck", &PatientDataConfigAPIController{}, "get:GetPhysiqueChecks")
- beego.Router("/api/patient/physiquecheck/create", &PatientDataConfigAPIController{}, "get:CreatePhysiqueCheck")
- beego.Router("/api/patient/physiquecheck/delete", &PatientDataConfigAPIController{}, "post:DeletePhysiqueCheck")
- beego.Router("/api/patient/physiquecheck/modify", &PatientDataConfigAPIController{}, "get:ModifyPhysiqueCheck")
-
- beego.Router("/api/patient/sickhistory/print", &PatientDataConfigAPIController{}, "get:GetSickhistoryPrints")
- beego.Router("/api/patient/physiquecheck/print", &PatientDataConfigAPIController{}, "get:GetPhysiquecheckPrints")
-
- beego.Router("/api/patient/getpatientdialysisinforlist", &PatientDataConfigAPIController{}, "get:GetPatientDialysisInforList")
-
- beego.Router("/api/patient/getcontextschedulelist", &PatientDataConfigAPIController{}, "Get:GetContextScheduleList")
-
- beego.Router("/api/patient/getpatientallagic", &PatientDataConfigAPIController{}, "Get:GetPatientAllagicList")
-
- beego.Router("/api/patient/savesitemap", &PatientDataConfigAPIController{}, "Post:SaveSiteMap")
-
- beego.Router("/api/patient/getpatientsitemap", &PatientDataConfigAPIController{}, "Get:GetPatientSitemap")
-
- beego.Router("/api/patient/getpatientdetailinformedconsent", &PatientDataConfigAPIController{}, "Get:GetPatientDetailInformedConsent")
-
- beego.Router("/api/patient/getpatientmedicallist", &PatientDataConfigAPIController{}, "Get:GetPatientMedicalList")
-
- //评估工具的接口
- beego.Router("/api/patient/fallassement/getallnurselist", &PatientDataConfigAPIController{}, "Get:GetAllNurseList")
-
- beego.Router("/api/patient/fallassment/savefllassessmentlist", &PatientDataConfigAPIController{}, "Post:SaveFllassessmentList")
-
- beego.Router("/api/patient/getpatientfallsessmentlist", &PatientDataConfigAPIController{}, "Get:GetPatientFallsessMentList")
-
- beego.Router("/api/patient/getpatientfallssessmentById", &PatientDataConfigAPIController{}, "Get:GetPatientFallsessmentById")
-
- beego.Router("/api/patient/deletepatientfallassessment", &PatientDataConfigAPIController{}, "Get:DeletePatientFallsessment")
-
- beego.Router("/api/patient/updatepatientfallassment", &PatientDataConfigAPIController{}, "Post:UpdatePatientFallassment")
-
- beego.Router("/api/patient/savepediatrcfallassesment", &PatientDataConfigAPIController{}, "Post:SavePediatrcFallassment")
-
- beego.Router("/api/patient/getbeddiatricfallassessmentlist", &PatientDataConfigAPIController{}, "Get:GetBedDiatricFallassessmentList")
-
- beego.Router("/api/patient/getpedpatientfallassessmentbyid", &PatientDataConfigAPIController{}, "Get:GetPedPatientFallassessmentById")
-
- beego.Router("/api/patient/deletepedpatientfallassment", &PatientDataConfigAPIController{}, "Get:DeletePadPatientFallassment")
-
- }
-
- type PatientDataConfigAPIController struct {
- BaseAuthAPIController
- }
-
- func (this *PatientDataConfigAPIController) GetPhysiquecheckPrints() {
-
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDStrs := strings.Split(idsStr, ",")
- patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
- sickHostory, _ := service.GetPatienttPhysiqueByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "sickhistorys": sickHostory,
- })
-
- }
- func (this *PatientDataConfigAPIController) GetSickhistoryPrints() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDStrs := strings.Split(idsStr, ",")
- patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
- sickHostory, _ := service.GetPatientSickHistoryByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
- for _, item := range sickHostory {
- pc, _ := service.GetLastPatientPhysiqueCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientId, item.RecordDate)
- item.XtPatientPhysiqueCheck = pc
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "sickhistorys": sickHostory,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetSickHistorys() {
- patientID, _ := this.GetInt64("patient_id")
- startTimeYMDStr := this.GetString("start_time")
- endTimeYMDStr := this.GetString("end_time")
- if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
- startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
- endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
- if parseStartTimeErr != nil || parseEndTimeErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- records, getRecordsErr := service.GetPatientSickHistory(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
- if getRecordsErr != nil {
- this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getAllAdminsErr != nil {
- this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "records": records,
- "doctors": admins,
- })
- }
- func (this *PatientDataConfigAPIController) CreateSickHistory() {
- patientID, _ := this.GetInt64("patient_id")
- content := this.GetString("content")
- record_time_str := this.GetString("record_time")
- title := this.GetString("title")
- is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
- is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
- is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
- guominyaowu_desc := this.GetString("guominyaowu_desc")
- doctor_id, _ := this.GetInt64("doctor_id")
-
- if patientID <= 0 || len(content) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- record_date := strings.Split(record_time_str, " ")
-
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
- checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
- record := models.XtPatientSickHistory{
- OrgId: adminUserInfo.CurrentOrgId,
- PatientId: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: checkDate.Unix(),
- Content: content,
- Status: 1,
- Title: title,
- IsShenyizhiHistory: is_shenyizhishi,
- IsFumoDialysisHistory: is_fumotouxishi,
- HypersusceptibilityDesc: guominyaowu_desc,
- IsHypersusceptibility: is_guominyaowu,
- Ctime: now,
- Mtime: now,
- DoctorId: doctor_id,
- RecordDate: checkDate_two.Unix(),
- }
-
- createErr := service.CreatePatientSickHistory(&record)
- if createErr != nil {
- this.ErrorLog("创建患者病史记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
- func (this *PatientDataConfigAPIController) DeleteSickHistory() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- recordIDStrs := strings.Split(idsStr, ",")
- recordIDs := make([]int64, 0, len(recordIDStrs))
- for _, idStr := range recordIDStrs {
- id, parseErr := strconv.Atoi(idStr)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDs = append(recordIDs, int64(id))
- }
-
- deleteErr := service.DeletePatientSickHistoryInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
- if deleteErr != nil {
- this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(nil)
- }
- func (this *PatientDataConfigAPIController) ModifySickHistory() {
- patientID, _ := this.GetInt64("patient_id")
- content := this.GetString("content")
- id, _ := this.GetInt64("id", 0)
- record_time_str := this.GetString("record_time")
- title := this.GetString("title")
-
- is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
- is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
- is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
- guominyaowu_desc := this.GetString("guominyaowu_desc")
- doctor_id, _ := this.GetInt64("doctor_id")
-
- if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- //timeLayout := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
-
- fmt.Println("checkDate--------------", checkDate)
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
-
- record := models.XtPatientSickHistory{
- ID: id,
- OrgId: adminUserInfo.CurrentOrgId,
- PatientId: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- Content: content,
- Status: 1,
- Ctime: now,
- Mtime: now,
- Title: title,
- RecordTime: checkDate.Unix(),
- IsShenyizhiHistory: is_shenyizhishi,
- IsFumoDialysisHistory: is_fumotouxishi,
- HypersusceptibilityDesc: guominyaowu_desc,
- IsHypersusceptibility: is_guominyaowu,
- DoctorId: doctor_id,
- }
- createErr := service.ModifyPatientSickHistory(&record)
- if createErr != nil {
- this.ErrorLog("创建患者抢救记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetPhysiqueChecks() {
- patientID, _ := this.GetInt64("patient_id")
- startTimeYMDStr := this.GetString("start_time")
- endTimeYMDStr := this.GetString("end_time")
- if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
- startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
- endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
- if parseStartTimeErr != nil || parseEndTimeErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- records, getRecordsErr := service.GetPatientPhysiqueCheck(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
- if getRecordsErr != nil {
- this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getAllAdminsErr != nil {
- this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "records": records,
- "doctors": admins,
- })
- }
- func (this *PatientDataConfigAPIController) CreatePhysiqueCheck() {
- patientID, _ := this.GetInt64("patient_id")
- doctor_id, _ := this.GetInt64("doctor_id")
- record_time_str := this.GetString("record_time")
- t := this.GetString("t")
- p := this.GetString("p")
- r := this.GetString("r")
- bp_left := this.GetString("bp_left")
- bp_right := this.GetString("bp_right")
- pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
- tiwei, _ := this.GetInt64("tiwei")
- fuzhong, _ := this.GetInt64("fuzhong")
- chuxuedian, _ := this.GetInt64("chuxuedian")
-
- fayu, _ := this.GetInt64("fayu")
- yinyang, _ := this.GetInt64("yinyang")
- shenzhi, _ := this.GetInt64("shenzhi")
- pifunianmo, _ := this.GetInt64("pifunianmo")
- buwei := this.GetString("buwei")
- chengdu := this.GetString("chengdu")
- pixiachuxue, _ := this.GetInt64("pixiachuxue")
- zidian, _ := this.GetInt64("zidian")
- pifuwendu, _ := this.GetInt64("pifuwendu")
- qita := this.GetString("qita")
-
- linbazhongda, _ := this.GetInt64("linbazhongda")
- linbabuwei := this.GetString("linbabuwei")
-
- yanlian, _ := this.GetInt64("yanlian")
- tongkong, _ := this.GetInt64("tongkong")
- zuo := this.GetString("zuo")
- you := this.GetString("you")
-
- duiguangfanshe := this.GetString("duiguangfanshe")
- biantaoti := this.GetString("biantaoti")
- yanbu := this.GetString("yanbu")
- toubuqita := this.GetString("toubuqita")
- huxiyin := this.GetString("huxiyin")
-
- xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
- feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
- luoyin, _ := this.GetInt64("luoyin")
- desc := this.GetString("desc")
-
- xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
- xinlv, _ := this.GetInt64("xinlv")
- xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
- zayin, _ := this.GetInt64("zayin")
- fujiayin, _ := this.GetInt64("fujiayin")
- xinzangdesc := this.GetString("xinzangdesc")
-
- fushuizheng, _ := this.GetInt64("fushuizheng")
- ganjingjingmai := this.GetString("ganjingjingmai")
-
- gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
- gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
- pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
- pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
-
- shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
- shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
- fubu_desc := this.GetString("fubu_desc")
- oth_desc := this.GetString("oth_desc")
-
- if patientID <= 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- record_date := strings.Split(record_time_str, " ")
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
- checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
- record := models.XtPatientPhysiqueCheck{
- DoctorId: doctor_id,
- OrgId: adminUserInfo.CurrentOrgId,
- PatientId: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: checkDate.Unix(),
- Status: 1,
- Ctime: now,
- Mtime: now,
- T: t,
- P: p,
- R: r,
- BpRight: bp_right,
- BpLeft: bp_left,
- Pinxuerongmao: pinxuerongmao,
- Tiwei: tiwei,
- Fuzhong: fuzhong,
- Chuxuedian: chuxuedian,
- Fayu: fayu,
- Yinyang: yinyang,
- Shenzhi: shenzhi,
- Pifunianmo: pifunianmo,
- Buwei: buwei,
- Chengdu: chengdu,
- Pixiachuxue: pixiachuxue,
- Zidian: zidian,
- Pifuwendu: pifuwendu,
- Qita: qita,
- Linbazhongda: linbazhongda,
- Linbabuwei: linbabuwei,
- Yanlian: yanlian,
- Tongkong: tongkong,
- Zuo: zuo,
- You: you,
- Duiguangfanshe: duiguangfanshe,
- Biantaoti: biantaoti,
- Yanbu: yanbu,
- Toubuqita: toubuqita,
- Huxiyin: huxiyin,
- Xiongmomocayin: xiongmomocayin,
- Feizhangbuwei: feizhangbuwei,
- Luoyin: luoyin,
- Desc: desc,
- Xinzangdaxiao: xinzangdaxiao,
- Xinlv: xinlv,
- Xinbaomocasheng: xinbaomocasheng,
- Zayin: zayin,
- Fujiayin: fujiayin,
- Xinzangdesc: xinzangdesc,
- Fushuizheng: fushuizheng,
- Ganjingjingmai: ganjingjingmai,
- GangzhangYatong: gangzhang_yatong,
- GangzhangKoutong: gangzhang_koutong,
- PizhangKoutong: pizhang_koutong,
- PizhangYatong: pizhang_yatong,
- ShenzhangKoutong: shenzhang_koutong,
- ShenzhangYatong: shenzhang_yatong,
- FubuDesc: fubu_desc,
- OthDesc: oth_desc,
- RecordDate: checkDate_two.Unix(),
- }
- createErr := service.CreatePatientPhysiqueCheck(&record)
- if createErr != nil {
- this.ErrorLog("创建患者病史记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
- func (this *PatientDataConfigAPIController) DeletePhysiqueCheck() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- recordIDStrs := strings.Split(idsStr, ",")
- recordIDs := make([]int64, 0, len(recordIDStrs))
- for _, idStr := range recordIDStrs {
- id, parseErr := strconv.Atoi(idStr)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDs = append(recordIDs, int64(id))
- }
-
- deleteErr := service.DeletePatientPhysiqueCheckInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
- if deleteErr != nil {
- this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(nil)
- }
- func (this *PatientDataConfigAPIController) ModifyPhysiqueCheck() {
- patientID, _ := this.GetInt64("patient_id")
- id, _ := this.GetInt64("id", 0)
- doctor_id, _ := this.GetInt64("doctor_id", 0)
-
- record_time_str := this.GetString("record_time")
-
- if patientID <= 0 || id == 0 || len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- t := this.GetString("t")
- p := this.GetString("p")
- r := this.GetString("r")
- bp_left := this.GetString("bp_left")
- bp_right := this.GetString("bp_right")
- pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
- tiwei, _ := this.GetInt64("tiwei")
- fuzhong, _ := this.GetInt64("fuzhong")
- chuxuedian, _ := this.GetInt64("chuxuedian")
-
- fayu, _ := this.GetInt64("fayu")
- yinyang, _ := this.GetInt64("yinyang")
- shenzhi, _ := this.GetInt64("shenzhi")
- pifunianmo, _ := this.GetInt64("pifunianmo")
- buwei := this.GetString("buwei")
- chengdu := this.GetString("chengdu")
- pixiachuxue, _ := this.GetInt64("pixiachuxue")
- zidian, _ := this.GetInt64("zidian")
- pifuwendu, _ := this.GetInt64("pifuwendu")
- qita := this.GetString("qita")
-
- linbazhongda, _ := this.GetInt64("linbazhongda")
- linbabuwei := this.GetString("linbabuwei")
-
- yanlian, _ := this.GetInt64("yanlian")
- tongkong, _ := this.GetInt64("tongkong")
- zuo := this.GetString("zuo")
- you := this.GetString("you")
-
- duiguangfanshe := this.GetString("duiguangfanshe")
- biantaoti := this.GetString("biantaoti")
- yanbu := this.GetString("yanbu")
- toubuqita := this.GetString("toubuqita")
- huxiyin := this.GetString("huxiyin")
-
- xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
- feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
- luoyin, _ := this.GetInt64("luoyin")
- desc := this.GetString("desc")
-
- xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
- xinlv, _ := this.GetInt64("xinlv")
- xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
- zayin, _ := this.GetInt64("zayin")
- fujiayin, _ := this.GetInt64("fujiayin")
- xinzangdesc := this.GetString("xinzangdesc")
-
- fushuizheng, _ := this.GetInt64("fushuizheng")
- ganjingjingmai := this.GetString("ganjingjingmai")
-
- gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
- gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
- pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
- pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
-
- shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
- shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
- fubu_desc := this.GetString("fubu_desc")
- oth_desc := this.GetString("oth_desc")
-
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- now := time.Now().Unix()
-
- record := models.XtPatientPhysiqueCheck{
- ID: id,
- OrgId: adminUserInfo.CurrentOrgId,
- PatientId: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: checkDate.Unix(),
- DoctorId: doctor_id,
- Status: 1,
- Ctime: now,
- Mtime: now,
- T: t,
- P: p,
- R: r,
- BpRight: bp_right,
- BpLeft: bp_left,
- Pinxuerongmao: pinxuerongmao,
- Tiwei: tiwei,
- Fuzhong: fuzhong,
- Chuxuedian: chuxuedian,
- Fayu: fayu,
- Yinyang: yinyang,
- Shenzhi: shenzhi,
- Pifunianmo: pifunianmo,
- Buwei: buwei,
- Chengdu: chengdu,
- Pixiachuxue: pixiachuxue,
- Zidian: zidian,
- Pifuwendu: pifuwendu,
- Qita: qita,
- Linbazhongda: linbazhongda,
- Linbabuwei: linbabuwei,
- Yanlian: yanlian,
- Tongkong: tongkong,
- Zuo: zuo,
- You: you,
- Duiguangfanshe: duiguangfanshe,
- Biantaoti: biantaoti,
- Yanbu: yanbu,
- Toubuqita: toubuqita,
- Huxiyin: huxiyin,
- Xiongmomocayin: xiongmomocayin,
- Feizhangbuwei: feizhangbuwei,
- Luoyin: luoyin,
- Desc: desc,
- Xinzangdaxiao: xinzangdaxiao,
- Xinlv: xinlv,
- Xinbaomocasheng: xinbaomocasheng,
- Zayin: zayin,
- Fujiayin: fujiayin,
- Xinzangdesc: xinzangdesc,
- Fushuizheng: fushuizheng,
- Ganjingjingmai: ganjingjingmai,
- GangzhangYatong: gangzhang_yatong,
- GangzhangKoutong: gangzhang_koutong,
- PizhangKoutong: pizhang_koutong,
- PizhangYatong: pizhang_yatong,
- ShenzhangKoutong: shenzhang_koutong,
- ShenzhangYatong: shenzhang_yatong,
- FubuDesc: fubu_desc,
- OthDesc: oth_desc,
- }
- createErr := service.ModifyPatientPhysiqueCheck(&record)
- if createErr != nil {
- this.ErrorLog("修改患者体格检查失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- // /api/patient/courses [get]
- // @param patient_id:int
- // @param start_time:string (yyyy-MM-dd)
- // @param end_time:string (yyyy-MM-dd)
- func (this *PatientDataConfigAPIController) Courses() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- patientID, _ := this.GetInt64("patient_id")
- start_time := this.GetString("start_time")
-
- dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- startime := dischargeTimes.Unix()
-
- end_time := this.GetString("end_time")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- endtime := endTimes.Unix()
-
- adminUserInfo := this.GetAdminUserInfo()
-
- records, getRecordsErr := service.GetPatientCourseOfDisease(adminUserInfo.CurrentOrgId, patientID, startime, endtime)
- if getRecordsErr != nil {
- this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getAllAdminsErr != nil {
- this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "records": records,
- "doctors": admins,
- })
- }
-
- // /api/patient/course/create [post]
- // @param patient_id:int
- // @param content:string
- func (this *PatientDataConfigAPIController) CreateCourse() {
- patientID, _ := this.GetInt64("patient_id")
- fmt.Println(patientID)
- content := this.GetString("content")
-
- record_time_str := this.GetString("record_time")
- title := this.GetString("title")
-
- if patientID <= 0 || len(content) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
-
- adminUserInfo := this.GetAdminUserInfo()
- //patient, _ := service.GetPatientByIDOne(adminUserInfo.CurrentOrgId, patientID)
- //if getPatientErr != nil {
- // this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- //} else if patient == nil {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- // return
- //}
-
- now := time.Now().Unix()
- record := models.PatientDiseaseCourse{
- OrgID: adminUserInfo.CurrentOrgId,
- PatientID: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: checkDate.Unix(),
- Content: content,
- Status: 1,
- CreateTime: now,
- ModifyTime: now,
- Title: title,
- }
-
- createErr := service.CreatePatientCourseOfDisease(&record)
- if createErr != nil {
- this.ErrorLog("创建患者病程记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- // /api/patient/course/delete
- // @param patient_id:int
- // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
- func (this *PatientDataConfigAPIController) DeleteCourse() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- recordIDStrs := strings.Split(idsStr, ",")
- recordIDs := make([]int64, 0, len(recordIDStrs))
- for _, idStr := range recordIDStrs {
- id, parseErr := strconv.Atoi(idStr)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDs = append(recordIDs, int64(id))
- }
-
- deleteErr := service.DeletePatientCoursesInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
- if deleteErr != nil {
- this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(nil)
- }
-
- // /api/patient/rescues [get]
- // @param patient_id:int
- // @param start_time:string (yyyy-MM-dd)
- // @param end_time:string (yyyy-MM-dd)
- func (this *PatientDataConfigAPIController) Rescues() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- patientID, _ := this.GetInt64("patient_id")
- start_time := this.GetString("start_time")
-
- dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- startime := dischargeTimes.Unix()
-
- end_time := this.GetString("end_time")
- endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- endtime := endTimes.Unix()
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- records, getRecordsErr := service.GetPatientRescueRecords(adminUserInfo.CurrentOrgId, patientID, startime, endtime)
- if getRecordsErr != nil {
- this.ErrorLog("获取患者抢救记录失败:%v", getRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
- if getAllAdminsErr != nil {
- this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "records": records,
- "doctors": admins,
- })
- }
-
- // /api/patient/rescue/create [post]
- // @param patient_id:int
- // @param content:string
- func (this *PatientDataConfigAPIController) CreateRescue() {
- patientID, _ := this.GetInt64("patient_id")
- content := this.GetString("content")
- if patientID <= 0 || len(content) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
- record := models.PatientRescueRecord{
- OrgID: adminUserInfo.CurrentOrgId,
- PatientID: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- RecordTime: now,
- Content: content,
- Status: 1,
- CreateTime: now,
- ModifyTime: now,
- }
-
- createErr := service.CreatePatientRescueRecord(&record)
- if createErr != nil {
- this.ErrorLog("创建患者抢救记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- // /api/patient/rescue/delete
- // @param patient_id:int
- // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
- func (this *PatientDataConfigAPIController) DeleteRescue() {
- patientID, _ := this.GetInt64("patient_id")
- idsStr := this.GetString("ids")
- if patientID <= 0 || len(idsStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- recordIDStrs := strings.Split(idsStr, ",")
- recordIDs := make([]int64, 0, len(recordIDStrs))
- for _, idStr := range recordIDStrs {
- id, parseErr := strconv.Atoi(idStr)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordIDs = append(recordIDs, int64(id))
- }
-
- deleteErr := service.DeletePatientResuceRecordsInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
- if deleteErr != nil {
- this.ErrorLog("删除患者抢救记录失败:%v", deleteErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(nil)
- }
-
- func (this *PatientDataConfigAPIController) ModifyCourse() {
- patientID, _ := this.GetInt64("patient_id")
- content := this.GetString("content")
- id, _ := this.GetInt64("id", 0)
- record_time_str := this.GetString("record_time")
- title := this.GetString("title")
-
- if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- //timeLayout := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
-
- adminUserInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- now := time.Now().Unix()
-
- record := models.PatientDiseaseCourse{
- ID: id,
- OrgID: adminUserInfo.CurrentOrgId,
- PatientID: patientID,
- Recorder: adminUserInfo.AdminUser.Id,
- Content: content,
- Status: 1,
- CreateTime: now,
- ModifyTime: now,
- Title: title,
- RecordTime: checkDate.Unix(),
- }
-
- createErr := service.ModifyPatientCourses(&record)
- if createErr != nil {
- this.ErrorLog("创建患者抢救记录失败:%v", createErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "record": record,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetPatientDialysisInforList() {
-
- patientID, _ := this.GetInt64("patient_id")
- record_date := this.GetString("record_date")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- //获取患者姓名
- patient, _ := service.GetPatientName(patientID)
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- //获取透析处方
- prescription, _ := service.GetDialysisPrescription(patientID, orgId, startTime)
-
- //获取透前评估
- assessmentBefor, _ := service.GetAssessmentBefor(orgId, patientID, startTime)
-
- //透析上机
- order, _ := service.GetDialysisOrder(orgId, patientID, startTime)
-
- //透析监测
- monitor, _ := service.GetFistMonitorSix(orgId, patientID, startTime)
-
- //透析医嘱
- advice, _ := service.GetBloodDoctorAdvice(startTime, orgId, patientID)
-
- //透后评估
- afterDislysis, _ := service.GetAssessmentAfterDissData(patientID, orgId, startTime)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "prescription": prescription,
- "assessmentBefor": assessmentBefor,
- "order": order,
- "monitor": monitor,
- "advice": advice,
- "afterDislysis": afterDislysis,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetContextScheduleList() {
-
- limit, _ := this.GetInt64("limit")
-
- page, _ := this.GetInt64("page")
-
- start_time := this.GetString("start_time")
-
- end_time := this.GetString("end_time")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- org_id := this.GetAdminUserInfo().CurrentOrgId
-
- schedule, total, _ := service.GetContextScheduleListGroupPatientId(limit, page, startTime, endTime, org_id)
-
- list, _, _ := service.GetContextScheduleListPatientId(startTime, endTime, org_id)
-
- patients, _ := service.GetAllpatientThirty(org_id)
-
- devicenumber, _ := service.GetAllBedNumber(org_id)
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": schedule,
- "total": total,
- "list": list,
- "patients": patients,
- "devicenumber": devicenumber,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetPatientAllagicList() {
-
- id, _ := this.GetInt64("id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetPatientAllagicList(id, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *PatientDataConfigAPIController) SaveSiteMap() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- patient_id := int64(dataBody["patient_id"].(float64))
- user_org_id := this.GetAdminUserInfo().CurrentOrgId
- id := int64(dataBody["id"].(float64))
-
- if dataBody["a_left"] != nil && reflect.TypeOf(dataBody["a_left"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["a_left"].([]interface{})
-
- service.UpdateValsualAleft(patient_id, user_org_id)
- for _, item := range prescriptions {
- var a_num float64
- var mark_num float64
- if item.(map[string]interface{})["a_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_num"]).String() == "float64" {
- a_num = item.(map[string]interface{})["a_num"].(float64)
- }
- if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
- mark_num = item.(map[string]interface{})["markNum"].(float64)
- }
- fmt.Println(a_num, mark_num)
-
- valsualALeft := models.XtDeviceValsualALeft{
- ANum: a_num,
- MarkNum: mark_num,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- MapId: 0,
- Status: 1,
- }
-
- service.CreateValsualAleft(valsualALeft)
-
- }
- }
-
- is_append := int64(dataBody["is_append"].(float64))
-
- is_img_v := int64(dataBody["is_img_v"].(float64))
-
- is_img_a := int64(dataBody["is_img_a"].(float64))
-
- a_top := dataBody["a_top"].(float64)
-
- av_bkx := dataBody["av_bkx"].(float64)
-
- av_bky := dataBody["av_bky"].(float64)
-
- if dataBody["fangxiang_a"] != nil && reflect.TypeOf(dataBody["fangxiang_a"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["fangxiang_a"].([]interface{})
- service.ValsualMapFangxiangA(patient_id, user_org_id)
- for _, item := range prescriptions {
- var a_num float64
- var mark_num float64
- var mark_top float64
- if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
- a_num = item.(map[string]interface{})["left"].(float64)
- }
- if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
- mark_num = item.(map[string]interface{})["markNum"].(float64)
- }
-
- if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
- mark_top = item.(map[string]interface{})["top"].(float64)
- }
-
- ValsualMapFangxiangA := models.XtDeviceValsualMapFangxiangA{
-
- PatientId: patient_id,
- UserOrgId: user_org_id,
- Status: 1,
- Left: a_num,
- MarkNum: mark_num,
- Top: mark_top,
- MapId: 0,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- service.CreateValsualMapFangxiangA(ValsualMapFangxiangA)
- }
-
- }
-
- fangxiang_a_num := dataBody["fangxiang_a_num"].(float64)
- fangxiang_a_top := dataBody["fangxiang_a_top"].(float64)
-
- fangxiang_v_left := dataBody["fangxiang_v_left"].(float64)
- fangxiang_v_num := dataBody["fangxiang_v_num"].(float64)
- fangxiang_v_top := dataBody["fangxiang_v_top"].(float64)
-
- if dataBody["fangxiang_v"] != nil && reflect.TypeOf(dataBody["fangxiang_v"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["fangxiang_v"].([]interface{})
- service.UpdateValsualMapFangxiangV(patient_id, user_org_id)
- for _, item := range prescriptions {
- var a_num float64
- var mark_num float64
- var mark_top float64
- if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
- a_num = item.(map[string]interface{})["left"].(float64)
- }
- if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" {
- mark_num = item.(map[string]interface{})["markNum"].(float64)
- }
-
- if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
- mark_top = item.(map[string]interface{})["top"].(float64)
- }
-
- ValsualMapFangxiangV := models.XtDeviceValsualMapFangxiangV{
-
- PatientId: patient_id,
- UserOrgId: user_org_id,
- Status: 1,
- Left: a_num,
- MarkNum: mark_num,
- Top: mark_top,
- MapId: 0,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- service.CreateValsualMapFangxiangV(ValsualMapFangxiangV)
- }
-
- }
-
- fangxiang_a_left := dataBody["fangxiang_a_left"].(float64)
-
- if dataBody["fuzhu_a"] != nil && reflect.TypeOf(dataBody["fuzhu_a"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["fuzhu_a"].([]interface{})
- service.UpdateValSualFuzhA(patient_id, user_org_id)
- for _, item := range prescriptions {
- var a_left float64
- var a_markNum float64
- var a_top float64
- if item.(map[string]interface{})["a_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_left"]).String() == "float64" {
- a_left = item.(map[string]interface{})["a_left"].(float64)
- }
- if item.(map[string]interface{})["a_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_markNum"]).String() == "float64" {
- a_markNum = item.(map[string]interface{})["a_markNum"].(float64)
- }
-
- if item.(map[string]interface{})["a_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_top"]).String() == "float64" {
- a_top = item.(map[string]interface{})["a_top"].(float64)
- }
-
- valsualFuzhuA := models.XtDeviceValsualFuzhuA{
- PatientId: patient_id,
- UserOrgId: user_org_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- ALeft: a_left,
- AMarkNum: a_markNum,
- ATop: a_top,
- MapId: 0,
- }
- service.CreateValSualFuzhA(valsualFuzhuA)
- }
- }
-
- fuzhu_a_left := dataBody["fuzhu_a_left"].(float64)
- fuzhu_a_num := dataBody["fuzhu_a_num"].(float64)
- fuzhu_a_top := dataBody["fuzhu_a_top"].(float64)
-
- left_a := dataBody["left_a"].(float64)
- left_v := dataBody["left_v"].(float64)
-
- if dataBody["fuzhu_v"] != nil && reflect.TypeOf(dataBody["fuzhu_v"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["fuzhu_v"].([]interface{})
-
- service.UpdateVasuaLfuzhuV(patient_id, user_org_id)
- for _, item := range prescriptions {
- var v_left float64
- var v_markNum float64
- var v_top float64
- if item.(map[string]interface{})["v_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_left"]).String() == "float64" {
- v_left = item.(map[string]interface{})["v_left"].(float64)
- }
- if item.(map[string]interface{})["v_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_markNum"]).String() == "float64" {
- v_markNum = item.(map[string]interface{})["v_markNum"].(float64)
- }
-
- if item.(map[string]interface{})["v_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_top"]).String() == "float64" {
- v_top = item.(map[string]interface{})["v_top"].(float64)
- }
-
- fuzhuV := models.XtDeviceValsualFuzhuV{
- PatientId: patient_id,
- UserOrgId: user_org_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 1,
- VMarkNum: v_markNum,
- VLeft: v_left,
- VTop: v_top,
- MapId: 0,
- }
-
- service.CreateVasuaLfuzhuV(fuzhuV)
-
- }
- }
-
- fuzhu_v_left := dataBody["fuzhu_v_left"].(float64)
- fuzhu_v_num := dataBody["fuzhu_v_num"].(float64)
- fuzhu_v_top := dataBody["fuzhu_v_top"].(float64)
-
- scalea_num := dataBody["scalea_num"].(float64)
- scalev_num := dataBody["scalev_num"].(float64)
-
- if dataBody["text_arr"] != nil && reflect.TypeOf(dataBody["text_arr"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["text_arr"].([]interface{})
-
- service.UpdateTextArr(patient_id, user_org_id)
- for _, item := range prescriptions {
- var left float64
- var text_markNum string
- var v_top float64
- var width float64
- if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
- left = item.(map[string]interface{})["left"].(float64)
- }
- if item.(map[string]interface{})["text"] != nil || reflect.TypeOf(item.(map[string]interface{})["text"]).String() == "string" {
- text_markNum = item.(map[string]interface{})["text"].(string)
- }
-
- if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
- v_top = item.(map[string]interface{})["top"].(float64)
- }
-
- if item.(map[string]interface{})["width"] != nil || reflect.TypeOf(item.(map[string]interface{})["width"]).String() == "float64" {
- width = item.(map[string]interface{})["width"].(float64)
- }
-
- textArr := models.XtDeviceValsualTextArr{
- PatientId: patient_id,
- UserOrgId: user_org_id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- Left: left,
- Text: text_markNum,
- Top: v_top,
- Width: width,
- MapId: 0,
- }
-
- service.CreateTextArr(textArr)
- }
-
- text_left := dataBody["text_left"].(float64)
- text_num := dataBody["text_num"].(float64)
- text_top := dataBody["text_top"].(float64)
-
- if dataBody["v_left"] != nil && reflect.TypeOf(dataBody["v_left"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["v_left"].([]interface{})
- service.UpdateValsualVleft(patient_id, user_org_id)
- for _, item := range prescriptions {
- var v_num float64
- var markNum float64
-
- if item.(map[string]interface{})["v_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_num"]).String() == "float64" {
- v_num = item.(map[string]interface{})["v_num"].(float64)
- }
- if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
- markNum = item.(map[string]interface{})["mark_num"].(float64)
- }
-
- valsualVLeft := models.XtDeviceValsualVLeft{
- PatientId: patient_id,
- UserOrgId: user_org_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- MarkNum: markNum,
- VNum: v_num,
- MapId: 0,
- }
-
- service.CreateValsualVleft(valsualVLeft)
-
- }
- }
-
- if dataBody["aarr"] != nil && reflect.TypeOf(dataBody["aarr"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["aarr"].([]interface{})
- service.UpdateValusalMapArr(patient_id, user_org_id)
- for _, item := range prescriptions {
- var mark_num float64
- var is_status float64
- var left float64
- var top float64
-
- if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
- mark_num = item.(map[string]interface{})["mark_num"].(float64)
- }
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = item.(map[string]interface{})["is_status"].(float64)
- }
- if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
- left = item.(map[string]interface{})["left"].(float64)
- }
- if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
- top = item.(map[string]interface{})["top"].(float64)
- }
-
- mapArr := models.XtDeviceValusalMapArr{
- PatientId: patient_id,
- UserOrgId: user_org_id,
- Status: 1,
- MarkNum: mark_num,
- Left: left,
- Top: top,
- IsStatus: is_status,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- }
- service.CreateDeviceValusalMapArr(mapArr)
-
- }
- }
-
- if dataBody["varr"] != nil && reflect.TypeOf(dataBody["varr"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["varr"].([]interface{})
- service.UpdateDeviceValusalMapVrr(patient_id, user_org_id)
- for _, item := range prescriptions {
- var mark_num float64
- var is_status float64
- var left float64
- var top float64
-
- if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" {
- mark_num = item.(map[string]interface{})["mark_num"].(float64)
- }
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = item.(map[string]interface{})["is_status"].(float64)
- }
- if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" {
- left = item.(map[string]interface{})["left"].(float64)
- }
- if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" {
- top = item.(map[string]interface{})["top"].(float64)
- }
-
- mapVrr := models.XtDeviceValusalMapVrr{
- PatientId: patient_id,
- UserOrgId: user_org_id,
- Status: 1,
- MarkNum: mark_num,
- Left: left,
- Top: top,
- IsStatus: is_status,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- }
- service.CreateDeviceValusalMapVrr(mapVrr)
-
- }
- }
-
- v_num := dataBody["v_num"].(float64)
- v_top := dataBody["v_top"].(float64)
- xuanzhuan_a := dataBody["xuanzhuan_a"].(float64)
- xuanzhuan_v := dataBody["xuanzhuan_v"].(float64)
-
- img_url := dataBody["img_url"].(string)
-
- deviceValsualMap := models.XtDeviceValsualMap{
- ID: id,
- PatientId: patient_id,
- IsAppend: is_append,
- IsImgV: is_img_v,
- IsImgA: is_img_a,
- VNum: v_num,
- Status: 1,
- UserOrgId: user_org_id,
- ATop: a_top,
- AvBkx: av_bkx,
- AvBky: av_bky,
- FangxiangALeft: fangxiang_a_left,
- FangxiangANum: fangxiang_a_num,
- FangxiangATop: fangxiang_a_top,
- FangxiangVLeft: fangxiang_v_left,
- FangxiangVNum: fangxiang_v_num,
- FangxiangVTop: fangxiang_v_top,
- FuzhuALeft: fuzhu_a_left,
- FuzhuANum: fuzhu_a_num,
- FuzhuATop: fuzhu_a_top,
- FuzhuVLeft: fuzhu_v_left,
- FuzhuVNum: fuzhu_v_num,
- FuzhuVTop: fuzhu_v_top,
- ScaleaNum: scalea_num,
- ScalevNum: scalev_num,
- TextLeft: text_left,
- TextNum: text_num,
- TextTop: text_top,
- VTop: v_top,
- XuanzhuanA: xuanzhuan_a,
- XuanzhuanV: xuanzhuan_v,
- ALeft: left_a,
- VLeft: left_v,
- ImgUrl: img_url,
- }
-
- err = service.CreateDeviceValsualMap(deviceValsualMap)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "deviceValsualMap": deviceValsualMap,
- })
-
- }
- }
-
- func (this *PatientDataConfigAPIController) GetPatientSitemap() {
-
- patient_id, _ := this.GetInt64("patient_id")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- sitemap, _ := service.GetPatientSitemap(patient_id, orgId)
-
- patients, _ := service.GetPatientByIDOne(orgId, patient_id)
- this.ServeSuccessJSON(map[string]interface{}{
- "sitemap": sitemap,
- "patients": patients,
- })
-
- }
-
- func (this *PatientDataConfigAPIController) GetPatientDetailInformedConsent() {
-
- patient_id, _ := this.GetInt64("patient_id")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- patients, _ := service.GetPatientDetailInformedConsent(patient_id, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
-
- "patients": patients,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetPatientMedicalList() {
-
- patient_id, _ := this.GetInt64("patient_id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetPatientMedicalList(patient_id, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetAllNurseList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- appId := this.GetAdminUserInfo().CurrentAppId
- nurseList, _ := service.GetAllNurseList(orgId, appId)
- this.ServeSuccessJSON(map[string]interface{}{
- "nurseList": nurseList,
- })
- }
-
- func (this *PatientDataConfigAPIController) SaveFllassessmentList() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- user_org_id := this.GetAdminUserInfo().CurrentOrgId
-
- admin_user_id := int64(dataBody["admin_user_id"].(float64))
-
- is_check := int64(dataBody["is_check"].(float64))
-
- is_check_one := int64(dataBody["is_check_one"].(float64))
-
- is_check_two := int64(dataBody["is_check_two"].(float64))
-
- is_check_three := int64(dataBody["is_check_three"].(float64))
-
- is_check_four := int64(dataBody["is_check_four"].(float64))
-
- is_check_five := int64(dataBody["is_check_five"].(float64))
-
- is_check_six := int64(dataBody["is_check_six"].(float64))
-
- is_check_seven := int64(dataBody["is_check_seven"].(float64))
-
- is_check_eight := int64(dataBody["is_check_eight"].(float64))
-
- is_check_night := int64(dataBody["is_check_night"].(float64))
-
- is_check_ten := int64(dataBody["is_check_ten"].(float64))
-
- is_check_eleven := int64(dataBody["is_check_eleven"].(float64))
-
- is_check_twelve := int64(dataBody["is_check_twelve"].(float64))
-
- is_check_thirteen := int64(dataBody["is_check_thirteen"].(float64))
-
- is_check_fourteen := int64(dataBody["is_check_fourteen"].(float64))
-
- is_check_fifteen := int64(dataBody["is_check_fifteen"].(float64))
-
- is_check_sixteen := int64(dataBody["is_check_sixteen"].(float64))
-
- is_check_seventeen := int64(dataBody["is_check_seventeen"].(float64))
-
- is_check_eighteen := int64(dataBody["is_check_eighteen"].(float64))
-
- is_check_nineteen := int64(dataBody["is_check_nineteen"].(float64))
-
- patient_id := int64(dataBody["patient_id"].(float64))
-
- total := int64(dataBody["total"].(float64))
-
- ping_date := dataBody["ping_date"].(string)
-
- record_date := dataBody["record_date"].(string)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var pingDate int64
- if len(ping_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", ping_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- pingDate = theTime.Unix()
- }
-
- var recordDate int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDate = theTime.Unix()
- }
-
- // 开始主事务
- db := service.XTWriteDB()
- tx := db.Begin()
-
- // 在函数结束时处理事务回滚
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- }
- }()
- patientFallassessment := models.XtPatientFallassessment{
- PatientId: patient_id,
- UserOrgId: user_org_id,
- RecordDate: recordDate,
- PingDate: pingDate,
- AdminUserId: admin_user_id,
- Status: 1,
- IsCheck: is_check,
- IsCheckOne: is_check_one,
- IsCheckTwo: is_check_two,
- IsCheckThree: is_check_three,
- IsCheckFour: is_check_four,
- IsCheckFive: is_check_five,
- IsCheckSix: is_check_six,
- IsCheckSeven: is_check_seven,
- IsCheckEight: is_check_eight,
- IsCheckNight: is_check_night,
- IsCheckTen: is_check_ten,
- IsCheckEleven: is_check_eleven,
- IsCheckTwelve: is_check_twelve,
- IsCheckThirteen: is_check_thirteen,
- IsCheckFourteen: is_check_fourteen,
- IsCheckFifteen: is_check_fifteen,
- IsCheckSixteen: is_check_sixteen,
- IsCheckSeventeen: is_check_seventeen,
- IsCheckEighteen: is_check_eighteen,
- IsCheckNineteen: is_check_nineteen,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Total: total,
- }
- service.CreatePatientFallassessment(tx, patientFallassessment)
-
- lastPatientFallassessment, _ := service.GetLastPatientFallassessment(tx, patient_id, user_org_id)
- if dataBody["is_age"] != nil && reflect.TypeOf(dataBody["is_age"]).String() == "[]interface {}" {
- isAgeList, _ := dataBody["is_age"].([]interface{})
-
- fmt.Println("--------------------", len(isAgeList))
- for _, item := range isAgeList {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
-
- fallassessmentAge := models.XtPatientFallassessmentAge{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentAge(tx, fallassessmentAge)
- }
-
- }
-
- if dataBody["is_ganguan"] != nil && reflect.TypeOf(dataBody["is_ganguan"]).String() == "[]interface {}" {
- isGanGuanList, _ := dataBody["is_ganguan"].([]interface{})
-
- for _, item := range isGanGuanList {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentOrgan := models.XtPatientFallassessmentOrgan{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentOrgan(tx, fallassessmentOrgan)
- }
-
- }
-
- if dataBody["is_jiwang"] != nil && reflect.TypeOf(dataBody["is_jiwang"]).String() == "[]interface {}" {
- isJiWangList, _ := dataBody["is_jiwang"].([]interface{})
-
- for _, item := range isJiWangList {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentHistory := models.XtPatientFallassessmentHistory{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentHistory(tx, fallassessmentHistory)
- }
-
- }
-
- if dataBody["is_paixie"] != nil && reflect.TypeOf(dataBody["is_paixie"]).String() == "[]interface {}" {
- isPaiXie, _ := dataBody["is_paixie"].([]interface{})
-
- for _, item := range isPaiXie {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentExcrete := models.XtPatientFallassessmentExcrete{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentExcrete(tx, fallassessmentExcrete)
- }
-
- }
-
- if dataBody["is_shentizk"] != nil && reflect.TypeOf(dataBody["is_shentizk"]).String() == "[]interface {}" {
- isShenTizk, _ := dataBody["is_shentizk"].([]interface{})
-
- for _, item := range isShenTizk {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentBody := models.XtPatientFallassessmentBody{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentBody(tx, fallassessmentBody)
- }
-
- }
-
- if dataBody["is_syyaowu"] != nil && reflect.TypeOf(dataBody["is_syyaowu"]).String() == "[]interface {}" {
- is_syYaoWu, _ := dataBody["is_syyaowu"].([]interface{})
-
- for _, item := range is_syYaoWu {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentBody := models.XtPatientFallassessmentMedical{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentMedical(tx, fallassessmentBody)
- }
-
- }
-
- if dataBody["is_touxidiedao"] != nil && reflect.TypeOf(dataBody["is_touxidiedao"]).String() == "[]interface {}" {
- isTouXiDieDao, _ := dataBody["is_touxidiedao"].([]interface{})
-
- for _, item := range isTouXiDieDao {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentFall := models.XtPatientFallassessmentFall{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentFall(tx, fallassessmentFall)
- }
-
- }
-
- if dataBody["is_xiaoguo"] != nil && reflect.TypeOf(dataBody["is_xiaoguo"]).String() == "[]interface {}" {
- isXiaoGuo, _ := dataBody["is_xiaoguo"].([]interface{})
-
- for _, item := range isXiaoGuo {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentPrevent := models.XtPatientFallassessmentPrevent{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentPrevent(tx, fallassessmentPrevent)
- }
-
- }
-
- if dataBody["is_yishizt"] != nil && reflect.TypeOf(dataBody["is_yishizt"]).String() == "[]interface {}" {
- isYiShiZt, _ := dataBody["is_yishizt"].([]interface{})
-
- for _, item := range isYiShiZt {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentRealize := models.XtPatientFallassessmentRealize{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentPealize(tx, fallassessmentRealize)
- }
-
- }
-
- if dataBody["is_zilin"] != nil && reflect.TypeOf(dataBody["is_zilin"]).String() == "[]interface {}" {
- isZiLin, _ := dataBody["is_zilin"].([]interface{})
-
- for _, item := range isZiLin {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentCare := models.XtPatientFallassessmentCare{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentCare(tx, fallassessmentCare)
- }
-
- }
-
- if dataBody["list"] != nil && reflect.TypeOf(dataBody["list"]).String() == "[]interface {}" {
- list, _ := dataBody["list"].([]interface{})
-
- for _, item := range list {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- PatientFallassessmentAdd := models.XtPatientFallassessmentAdd{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.CreateFallassessmentAdd(tx, PatientFallassessmentAdd)
- }
-
- }
-
- if dataBody["listOne"] != nil && reflect.TypeOf(dataBody["listOne"]).String() == "[]interface {}" {
- listOne, _ := dataBody["listOne"].([]interface{})
-
- for _, item := range listOne {
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- PatientFallassessmentAddCopy := models.XtPatientFallassessmentAddCopy{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.XtPatientFallassessmentAddCopy(tx, PatientFallassessmentAddCopy)
- }
-
- }
- tx.Commit()
- this.ServeSuccessJSON(map[string]interface{}{
- "patientFallassessment": patientFallassessment,
- })
-
- }
-
- func (this *PatientDataConfigAPIController) GetPatientFallsessMentList() {
-
- patient_id, _ := this.GetInt64("patient_id")
-
- limit, _ := this.GetInt64("limit")
-
- page, _ := this.GetInt64("page")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- list, total, _ := service.GetPatientFallsessMentList(patient_id, orgId, limit, page)
- appId := this.GetAdminUserInfo().CurrentAppId
- roleList, _ := service.GetAllNurseList(orgId, appId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "roleList": roleList,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetPatientFallsessmentById() {
-
- id, _ := this.GetInt64("id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- patientFallsessment, _ := service.GetPatientFallsessmentById(id, orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "patientFallsessment": patientFallsessment,
- })
- }
-
- func (this *PatientDataConfigAPIController) DeletePatientFallsessment() {
-
- id, _ := this.GetInt64("id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- service.DeletePatientFallsessment(id, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- }
-
- func (this *PatientDataConfigAPIController) UpdatePatientFallassment() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- user_org_id := this.GetAdminUserInfo().CurrentOrgId
-
- admin_user_id := int64(dataBody["admin_user_id"].(float64))
-
- id := int64(dataBody["id"].(float64))
-
- is_check := int64(dataBody["is_check"].(float64))
-
- is_check_one := int64(dataBody["is_check_one"].(float64))
-
- is_check_two := int64(dataBody["is_check_two"].(float64))
-
- is_check_three := int64(dataBody["is_check_three"].(float64))
-
- is_check_four := int64(dataBody["is_check_four"].(float64))
-
- is_check_five := int64(dataBody["is_check_five"].(float64))
-
- is_check_six := int64(dataBody["is_check_six"].(float64))
-
- is_check_seven := int64(dataBody["is_check_seven"].(float64))
-
- is_check_eight := int64(dataBody["is_check_eight"].(float64))
-
- is_check_night := int64(dataBody["is_check_night"].(float64))
-
- is_check_ten := int64(dataBody["is_check_ten"].(float64))
-
- is_check_eleven := int64(dataBody["is_check_eleven"].(float64))
-
- is_check_twelve := int64(dataBody["is_check_twelve"].(float64))
-
- is_check_thirteen := int64(dataBody["is_check_thirteen"].(float64))
-
- is_check_fourteen := int64(dataBody["is_check_fourteen"].(float64))
-
- is_check_fifteen := int64(dataBody["is_check_fifteen"].(float64))
-
- is_check_sixteen := int64(dataBody["is_check_sixteen"].(float64))
-
- is_check_seventeen := int64(dataBody["is_check_seventeen"].(float64))
-
- is_check_eighteen := int64(dataBody["is_check_eighteen"].(float64))
-
- is_check_nineteen := int64(dataBody["is_check_nineteen"].(float64))
-
- patient_id := int64(dataBody["patient_id"].(float64))
-
- total := int64(dataBody["total"].(float64))
-
- ping_date := dataBody["ping_date"].(string)
-
- record_date := dataBody["record_date"].(string)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var pingDate int64
- if len(ping_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", ping_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- pingDate = theTime.Unix()
- }
-
- var recordDate int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDate = theTime.Unix()
- }
-
- // 开始主事务
- db := service.XTWriteDB()
- tx := db.Begin()
-
- // 在函数结束时处理事务回滚
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- }
- }()
- patientFallassessment := models.XtPatientFallassessment{
- ID: id,
- PatientId: patient_id,
- UserOrgId: user_org_id,
- RecordDate: recordDate,
- PingDate: pingDate,
- AdminUserId: admin_user_id,
- Status: 1,
- IsCheck: is_check,
- IsCheckOne: is_check_one,
- IsCheckTwo: is_check_two,
- IsCheckThree: is_check_three,
- IsCheckFour: is_check_four,
- IsCheckFive: is_check_five,
- IsCheckSix: is_check_six,
- IsCheckSeven: is_check_seven,
- IsCheckEight: is_check_eight,
- IsCheckNight: is_check_night,
- IsCheckTen: is_check_ten,
- IsCheckEleven: is_check_eleven,
- IsCheckTwelve: is_check_twelve,
- IsCheckThirteen: is_check_thirteen,
- IsCheckFourteen: is_check_fourteen,
- IsCheckFifteen: is_check_fifteen,
- IsCheckSixteen: is_check_sixteen,
- IsCheckSeventeen: is_check_seventeen,
- IsCheckEighteen: is_check_eighteen,
- IsCheckNineteen: is_check_nineteen,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Total: total,
- }
- service.SavePatientFallassessment(tx, patientFallassessment)
-
- lastPatientFallassessment, _ := service.GetLastPatientFallassessment(tx, patient_id, user_org_id)
- if dataBody["is_age"] != nil && reflect.TypeOf(dataBody["is_age"]).String() == "[]interface {}" {
- isAgeList, _ := dataBody["is_age"].([]interface{})
- for _, item := range isAgeList {
- var id int64
- var is_status int64
- var is_content string
-
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
-
- fallassessmentAge := models.XtPatientFallassessmentAge{
- ID: id,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.SaveFallassessmentAge(tx, fallassessmentAge)
- }
-
- }
-
- if dataBody["is_ganguan"] != nil && reflect.TypeOf(dataBody["is_ganguan"]).String() == "[]interface {}" {
- isGanGuanList, _ := dataBody["is_ganguan"].([]interface{})
-
- for _, item := range isGanGuanList {
- var id int64
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentOrgan := models.XtPatientFallassessmentOrgan{
- ID: id,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.SaveFallassessmentOrgan(tx, fallassessmentOrgan)
- }
-
- }
-
- if dataBody["is_jiwang"] != nil && reflect.TypeOf(dataBody["is_jiwang"]).String() == "[]interface {}" {
- isJiWangList, _ := dataBody["is_jiwang"].([]interface{})
-
- for _, item := range isJiWangList {
- var id int64
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentHistory := models.XtPatientFallassessmentHistory{
- ID: id,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.SaveFallassessmentHistory(tx, fallassessmentHistory)
- }
-
- }
-
- if dataBody["is_paixie"] != nil && reflect.TypeOf(dataBody["is_paixie"]).String() == "[]interface {}" {
- isPaiXie, _ := dataBody["is_paixie"].([]interface{})
-
- for _, item := range isPaiXie {
- var id int64
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentExcrete := models.XtPatientFallassessmentExcrete{
- ID: id,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.SaveFallassessmentExcrete(tx, fallassessmentExcrete)
- }
-
- }
-
- if dataBody["is_shentizk"] != nil && reflect.TypeOf(dataBody["is_shentizk"]).String() == "[]interface {}" {
- isShenTizk, _ := dataBody["is_shentizk"].([]interface{})
-
- for _, item := range isShenTizk {
- var id int64
- var is_status int64
- var is_content string
-
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentBody := models.XtPatientFallassessmentBody{
- ID: id,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.SaveFallassessmentBody(tx, fallassessmentBody)
- }
-
- }
-
- if dataBody["is_syyaowu"] != nil && reflect.TypeOf(dataBody["is_syyaowu"]).String() == "[]interface {}" {
- is_syYaoWu, _ := dataBody["is_syyaowu"].([]interface{})
-
- for _, item := range is_syYaoWu {
- var id int64
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentBody := models.XtPatientFallassessmentMedical{
- ID: id,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.SaveFallassessmentMedical(tx, fallassessmentBody)
- }
-
- }
-
- if dataBody["is_touxidiedao"] != nil && reflect.TypeOf(dataBody["is_touxidiedao"]).String() == "[]interface {}" {
- isTouXiDieDao, _ := dataBody["is_touxidiedao"].([]interface{})
-
- for _, item := range isTouXiDieDao {
- var is_status int64
- var is_content string
- var id int64
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentFall := models.XtPatientFallassessmentFall{
- ID: id,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.SaveFallassessmentFall(tx, fallassessmentFall)
- }
-
- }
-
- if dataBody["is_xiaoguo"] != nil && reflect.TypeOf(dataBody["is_xiaoguo"]).String() == "[]interface {}" {
- isXiaoGuo, _ := dataBody["is_xiaoguo"].([]interface{})
-
- for _, item := range isXiaoGuo {
- var id int64
- var is_status int64
- var is_content string
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentPrevent := models.XtPatientFallassessmentPrevent{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- ID: id,
- }
-
- service.SaveFallassessmentPrevent(tx, fallassessmentPrevent)
- }
-
- }
-
- if dataBody["is_yishizt"] != nil && reflect.TypeOf(dataBody["is_yishizt"]).String() == "[]interface {}" {
- isYiShiZt, _ := dataBody["is_yishizt"].([]interface{})
-
- for _, item := range isYiShiZt {
- var is_status int64
- var is_content string
- var id int64
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentRealize := models.XtPatientFallassessmentRealize{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- ID: id,
- }
-
- service.SaveFallassessmentPealize(tx, fallassessmentRealize)
- }
-
- }
-
- if dataBody["is_zilin"] != nil && reflect.TypeOf(dataBody["is_zilin"]).String() == "[]interface {}" {
- isZiLin, _ := dataBody["is_zilin"].([]interface{})
-
- for _, item := range isZiLin {
- var is_status int64
- var is_content string
- var id int64
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
-
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- fallassessmentCare := models.XtPatientFallassessmentCare{
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- ID: id,
- }
-
- service.SaveFallassessmentCare(tx, fallassessmentCare)
- }
-
- }
-
- if dataBody["list"] != nil && reflect.TypeOf(dataBody["list"]).String() == "[]interface {}" {
- list, _ := dataBody["list"].([]interface{})
-
- for _, item := range list {
- var is_status int64
- var is_content string
- var id int64
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- PatientFallassessmentAdd := models.XtPatientFallassessmentAdd{
- ID: id,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.SaveFallassessmentAdd(tx, PatientFallassessmentAdd)
- }
-
- }
-
- if dataBody["listOne"] != nil && reflect.TypeOf(dataBody["listOne"]).String() == "[]interface {}" {
- listOne, _ := dataBody["listOne"].([]interface{})
-
- for _, item := range listOne {
- var is_status int64
- var is_content string
- var id int64
- if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" {
- is_status = int64(item.(map[string]interface{})["is_status"].(float64))
- }
- if item.(map[string]interface{})["id"] != nil || reflect.TypeOf(item.(map[string]interface{})["id"]).String() == "float64" {
- id = int64(item.(map[string]interface{})["id"].(float64))
- }
- if item.(map[string]interface{})["content"] != nil || reflect.TypeOf(item.(map[string]interface{})["content"]).String() == "string" {
- is_content = item.(map[string]interface{})["content"].(string)
- }
- PatientFallassessmentAddCopy := models.XtPatientFallassessmentAddCopy{
- ID: id,
- UserOrgId: user_org_id,
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- FassementId: lastPatientFallassessment.ID,
- IsCheckStatus: is_status,
- Content: is_content,
- }
-
- service.SavePatientFallassessmentAddCopy(tx, PatientFallassessmentAddCopy)
- }
-
- }
- tx.Commit()
- this.ServeSuccessJSON(map[string]interface{}{
- "patientFallassessment": patientFallassessment,
- })
- }
-
- func (this *PatientDataConfigAPIController) SavePediatrcFallassment() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- user_org_id := this.GetAdminUserInfo().CurrentOrgId
-
- admin_user_id := int64(dataBody["tumble"].(float64))
-
- patient_id := int64(dataBody["patient_id"].(float64))
-
- record_date := dataBody["date"].(string)
-
- total := int64(dataBody["pedia_Totalpoints"].(float64))
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var recordDate int64
- var str string
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDate = theTime.Unix()
- }
-
- if dataBody["age"] != nil && reflect.TypeOf(dataBody["age"]).String() == "[]interface {}" {
- ageList, _ := dataBody["age"].([]interface{})
-
- for _, item := range ageList {
- //记录日志
- byterequest, _ := json.Marshal(item)
- str += string(byterequest) + ","
- }
- }
-
- if dataBody["cognize"] != nil && reflect.TypeOf(dataBody["cognize"]).String() == "[]interface {}" {
- cognizeList, _ := dataBody["cognize"].([]interface{})
-
- for _, item := range cognizeList {
- //记录日志
- byterequest, _ := json.Marshal(item)
- str += string(byterequest) + ","
- }
- }
-
- if dataBody["diagnosis"] != nil && reflect.TypeOf(dataBody["diagnosis"]).String() == "[]interface {}" {
- diagnosisList, _ := dataBody["diagnosis"].([]interface{})
-
- for _, item := range diagnosisList {
- //记录日志
- byterequest, _ := json.Marshal(item)
- str += string(byterequest) + ","
- }
- }
-
- if dataBody["environment"] != nil && reflect.TypeOf(dataBody["environment"]).String() == "[]interface {}" {
- environmentList, _ := dataBody["environment"].([]interface{})
-
- for _, item := range environmentList {
- //记录日志
- byterequest, _ := json.Marshal(item)
- str += string(byterequest) + ","
- }
- }
-
- if dataBody["medicine"] != nil && reflect.TypeOf(dataBody["medicine"]).String() == "[]interface {}" {
- medicineList, _ := dataBody["medicine"].([]interface{})
-
- for _, item := range medicineList {
- //记录日志
- byterequest, _ := json.Marshal(item)
- str += string(byterequest) + ","
- }
- }
-
- if dataBody["sex"] != nil && reflect.TypeOf(dataBody["sex"]).String() == "[]interface {}" {
- sexList, _ := dataBody["medicine"].([]interface{})
-
- for _, item := range sexList {
- //记录日志
- byterequest, _ := json.Marshal(item)
- str += string(byterequest) + ","
- }
- }
-
- pedFallssessment := models.XtPatientPedFallssessment{
- PatientId: patient_id,
- UserOrgId: user_org_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Text: str,
- RecordDate: recordDate,
- Total: total,
- AdminUserId: admin_user_id,
- Type: 1,
- }
-
- service.CreatePadFallssessment(pedFallssessment)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "pedFallssessment": pedFallssessment,
- })
-
- }
-
- func (this *PatientDataConfigAPIController) GetBedDiatricFallassessmentList() {
-
- patient_id, _ := this.GetInt64("patient_id")
- is_type, _ := this.GetInt64("is_type")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, total, _ := service.GetBedDiatricFallassessmentList(patient_id, is_type, orgId, limit, page)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- })
- }
-
- func (this *PatientDataConfigAPIController) GetPedPatientFallassessmentById() {
-
- id, _ := this.GetInt64("id")
-
- fallassessment, _ := service.GetPedPatientFallassessmentById(id)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "fallassessment": fallassessment,
- })
- }
-
- func (this *PatientDataConfigAPIController) DeletePadPatientFallassment() {
-
- id, _ := this.GetInt64("id")
-
- service.DeletePadPatientFallassment(id)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- }
|