12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825 |
- package controllers
-
- import (
- "bytes"
- "encoding/json"
- "fmt"
- "io/ioutil"
- "log"
- "os"
- "path"
- "reflect"
- "regexp"
- "runtime"
- "strconv"
- "strings"
- "time"
-
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "github.com/jinzhu/gorm"
-
- "github.com/astaxie/beego"
- )
-
- type GobalConfigApiController struct {
- BaseAuthAPIController
- }
-
- func GobalConfigRegistRouters() {
- beego.Router("/api/stock/automaticreduce/isopen", &GobalConfigApiController{}, "post:PostStockConfig")
- beego.Router("/api/drugstock/automaticreduce/isopen", &GobalConfigApiController{}, "post:PostDrugStockConfig")
-
- beego.Router("/api/automaticreduce/get", &GobalConfigApiController{}, "get:GetConfig")
- beego.Router("/api/drugstockautomaticreduce/get", &GobalConfigApiController{}, "get:GetDrugStockConfig")
-
- beego.Router("/api/print/template/commit", &GobalConfigApiController{}, "post:PostPrintTemplateTwo")
-
- beego.Router("/api/print/template/get", &GobalConfigApiController{}, "get:GetPrintTemplate")
-
- beego.Router("/api/dataupload/config/commit", &GobalConfigApiController{}, "post:PostConfig")
- beego.Router("/api/dataupload/config/modify", &GobalConfigApiController{}, "post:ModifyConfig")
- beego.Router("/api/dataupload/config/get", &GobalConfigApiController{}, "get:GetDataUploadConfig")
- beego.Router("/api/dataupload/is_docking/get", &GobalConfigApiController{}, "get:GetDataUploadIsDocking")
-
- beego.Router("/api/adviceconfig/isopen", &GobalConfigApiController{}, "post:PostDoctorAdviceConfig")
- beego.Router("/api/adviceconfig/get", &GobalConfigApiController{}, "get:GetDoctorAdviceConfig")
-
- beego.Router("/api/advicetemplate/init/commit", &GobalConfigApiController{}, "post:PostInitAdviceTemplate")
- beego.Router("/api/advicetemplate/init/get", &GobalConfigApiController{}, "get:GetAdviceInitConfig")
-
- beego.Router("/api/systemprescription/commit", &GobalConfigApiController{}, "post:CreateSystemPrescription")
- beego.Router("/api/systemprescription/update", &GobalConfigApiController{}, "post:UpdateSystemPrescription")
-
- beego.Router("/api/systemprescription/all", &GobalConfigApiController{}, "get:GetAllSystemPrescription")
- beego.Router("/api/systemprescription/get", &GobalConfigApiController{}, "get:GetSystemPrescription")
-
- beego.Router("/api/advicetemplate/getprintinfo", &GobalConfigApiController{}, "post:GetPrintInfo")
-
- beego.Router("/api/public/orgs", &GobalConfigApiController{}, "get:GetOrgs")
- beego.Router("/api/org/change", &GobalConfigApiController{}, "post:ChangeOrg")
-
- beego.Router("/api/log/generate", &GobalConfigApiController{}, "get:GenerateLog")
-
- beego.Router("/api/patients/search", &GobalConfigApiController{}, "Post:GetPatientsByKeyWord")
-
- beego.Router("/api/xtconfig/get", &GobalConfigApiController{}, "get:GetXTHisConfig")
- beego.Router("/api/xtconfig/isopen", &GobalConfigApiController{}, "post:PostXTHisConfig")
-
- beego.Router("/api/hisstockpriceconfig/get", &GobalConfigApiController{}, "get:GetHisStockPriceConfig")
- beego.Router("/api/hisstockpriceconfig/isopen", &GobalConfigApiController{}, "post:PostHisStockPriceConfig")
-
- beego.Router("/api/xtconfigproject/isopen", &GobalConfigApiController{}, "post:PostXTHisProjectConfig")
-
- beego.Router("/api/isopen/init", &GobalConfigApiController{}, "get:GetAllIsOpenConfig")
-
- beego.Router("/api/passdetail/export", &GobalConfigApiController{}, "get:GetPassExportData")
- beego.Router("/api/consumedetail/export", &GobalConfigApiController{}, "get:GetExportData")
-
- beego.Router("/api/drugstock/getdrugindetail", &GobalConfigApiController{}, "get:GetDrugInDetail")
-
- beego.Router("/api/drugstock/getdrugcancelorder", &GobalConfigApiController{}, "get:GetDrugCancelOrder")
-
- beego.Router("/api/drugstock/getdrugoutdetail", &GobalConfigApiController{}, "get:GetDrugOutDetail")
-
- beego.Router("/api/drugstock/getdrugcanceldetail", &GobalConfigApiController{}, "get:GetDrugCancelDetail")
-
- beego.Router("/api/monitor/open", &GobalConfigApiController{}, "get:AddMonitorOpen")
- beego.Router("/api/monitor/getmonitorconfig", &GobalConfigApiController{}, "Get:GetMonitorConfig")
- beego.Router("/api/order/addorderconfig", &GobalConfigApiController{}, "Get:AddOrderConfig")
- beego.Router("/api/order/getorderconfig", &GobalConfigApiController{}, "Get:GetOrderConfig")
- beego.Router("/api/drugstock/getdrugautomaticlist", &GobalConfigApiController{}, "Get:GetDrugAutoMaticList")
- beego.Router("/api/drugstock/getdrugwarehouseorderinfo", &GobalConfigApiController{}, "Get:GetDrugWarehuseOrderInfo")
-
- //新接口
- beego.Router("/api/drugstock/drugstocklist", &GobalConfigApiController{}, "Get:GetDrugStockList")
- beego.Router("/api/drugstock/getdrugstockflow", &GobalConfigApiController{}, "Get:GetDrugStockFllow")
-
- beego.Router("/api/drugoutstock/getoutdrugstockflow", &GobalConfigApiController{}, "Get:GetDrugOutStockFlow")
- beego.Router("/api/drug/getbatchorderdetail", &GobalConfigApiController{}, "Get:GetBatchOrderDetail")
-
- beego.Router("/api/drug/getdrugcountlist", &GobalConfigApiController{}, "Get:GetDrugCountList")
- beego.Router("/api/drug/getsingleorderdetail", &GobalConfigApiController{}, "Get:GetSingleOrderDetail")
- beego.Router("/api/drug/getautodrugdetial", &GobalConfigApiController{}, "Get:GetAutoDrugDetail")
- beego.Router("/api/drug/getdrugorderinprint", &GobalConfigApiController{}, "Get:GetDrugOrderInPrint")
- beego.Router("/api/drug/getdrugoutorderdetailprint", &GobalConfigApiController{}, "Get:GetDrugOutOrderPrint")
- beego.Router("/api/drug/getdrugbatchnumber", &GobalConfigApiController{}, "Get:GetDrugBatchNumber")
- beego.Router("/api/drug/exportdruglist", &GobalConfigApiController{}, "Get:ExportDrugList")
- beego.Router("/api/drug/getexportoutorderdruglist", &GobalConfigApiController{}, "Get:GetExportOutOrderDrugList")
- beego.Router("/api/drug/getdrugflow", &GobalConfigApiController{}, "Get:GetDrugFlow")
- beego.Router("/api/drug/getcancelstockdetail", &GobalConfigApiController{}, "Get:GetCancelStockDetail")
-
- beego.Router("/api/changestocksetting/isopen", &GobalConfigApiController{}, "Get:ChangeStockSetting")
-
- beego.Router("/api/changeadviceconfig", &GobalConfigApiController{}, "Get:ChangeAdviceConfig")
-
- beego.Router("/api/changeprescriptionconfig", &GobalConfigApiController{}, "Get:ChangePrescriptionConfig")
-
- beego.Router("/api/changedrugopenconfig", &GobalConfigApiController{}, "Get:ChangeDrugOpenConfig")
-
- beego.Router("/api/changesettleopenconfig", &GobalConfigApiController{}, "Get:ChangeSettleOpenConfig")
-
- beego.Router("/api/changegoodoutopen", &GobalConfigApiController{}, "Get:ChangeGoodOutOpen")
-
- beego.Router("/api/schedule/config/commit", &GobalConfigApiController{}, "post:PostScheduleConfig")
- beego.Router("/api/schedule/config/get", &GobalConfigApiController{}, "get:GetScheduleConfig")
-
- beego.Router("/api/checkremind/config/commit", &GobalConfigApiController{}, "post:PostCheckRemindConfig")
- beego.Router("/api/checkremind/config/get", &GobalConfigApiController{}, "get:GetCheckRemindConfig")
-
- beego.Router("/api/changeselfprescriptionopen", &GobalConfigApiController{}, "Get:ChangeSelfPrescriptionOpen")
-
- beego.Router("/api/changeselfprescriptionoutopen", &GobalConfigApiController{}, "Get:ChangeSelfPrescriptionOutOpen")
-
- beego.Router("/api/getselfprintlist", &GobalConfigApiController{}, "Get:GetSelfPrintList")
-
- beego.Router("/api/changedrugcodeopen", &GobalConfigApiController{}, "Get:ChangeDrugCodeOpen")
- }
-
- //provinces, _ := service.GetDistrictsByUpid(0)21
-
- func (c *GobalConfigApiController) PostCheckRemindConfig() {
- is_open, _ := c.GetInt64("is_open", 0)
- id, _ := c.GetInt64("id", 0)
-
- config, _ := service.GetCheckRemindConfigByIdTwo(id)
- var err error
- if config.ID == 0 {
- config.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
- config.Ctime = time.Now().Unix()
- config.Mtime = time.Now().Unix()
- config.Status = 1
- config.IsOpen = is_open
- err = service.CreateCheckRemindConfig(&config)
- } else {
- config.IsOpen = is_open
- config.Mtime = time.Now().Unix()
- err = service.SaveCheckRemindConfig(&config)
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
- }
-
- func (c *GobalConfigApiController) GetCheckRemindConfig() {
- config, _ := service.GetCheckRemindConfigById(c.GetAdminUserInfo().CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
-
- func (c *GobalConfigApiController) PostScheduleConfig() {
- is_show_mode, _ := c.GetInt64("is_show_mode", 0)
- is_show_machine, _ := c.GetInt64("is_show_machine", 0)
- id, _ := c.GetInt64("id", 0)
-
- config, _ := service.GetScheduleConfigById(id)
- var err error
- if config.ID == 0 {
- config.IsShowMode = is_show_mode
- config.IsShowMachine = is_show_machine
- config.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
- config.Ctime = time.Now().Unix()
- config.Mtime = time.Now().Unix()
- config.Status = 1
- err = service.CreateScheduleConfig(config)
- } else {
- config.IsShowMachine = is_show_machine
- config.IsShowMode = is_show_mode
- config.Mtime = time.Now().Unix()
- err = service.SaveScheduleConfig(config)
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
- }
-
- func (c *GobalConfigApiController) GetScheduleConfig() {
- config, _ := service.GetScheduleConfigByOrgId(c.GetAdminUserInfo().CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
-
- func (c *GobalConfigApiController) PostStockConfig() {
- is_open, _ := c.GetInt64("is_open", 0)
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- config := models.GobalConfig{
- OrgId: org_id,
- IsOpen: is_open,
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- IsOpenRemind: 0,
- }
-
- errs, configs := service.FindAutomaticReduceRecordByOrgId(org_id)
-
- if errs == gorm.ErrRecordNotFound {
- err := service.CreateAutomaticReduceRecord(&config)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- } else if errs == nil {
- modifyConfig := models.GobalConfig{
- ID: configs.ID,
- OrgId: org_id,
- IsOpen: is_open,
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- IsOpenRemind: configs.IsOpenRemind,
- }
-
- err := service.UpdateAutomaticReduceRecord(&modifyConfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- }
-
- if is_open == 1 {
- service.UpdateGobalConfig(org_id)
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "is_open": is_open,
- })
-
- return
- }
-
- func (c *GobalConfigApiController) PostDrugStockConfig() {
- is_open, _ := c.GetInt64("is_open", 0)
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- config := models.DrugStockConfig{
- OrgId: org_id,
- IsOpen: is_open,
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- }
-
- errs, configs := service.FindDrugStockAutomaticReduceRecordByOrgId(org_id)
- if is_open == 1 {
- service.UpdateSettleOpenConfigOne(org_id, 2)
- }
- if errs == gorm.ErrRecordNotFound {
- err := service.CreateDrugAutomaticReduceRecord(&config)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- } else if errs == nil {
- modifyConfig := models.DrugStockConfig{
- ID: configs.ID,
- OrgId: org_id,
- IsOpen: is_open,
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- }
- err := service.UpdateDrugStockAutomaticReduceRecord(&modifyConfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "is_open": is_open,
- })
-
- return
- }
-
- func (c *GobalConfigApiController) GetConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugStockConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
-
- func (c *GobalConfigApiController) PostPrintTemplate() {
- template_id, _ := c.GetInt64("template_id", 0)
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- template := models.GobalTemplate{
- OrgId: org_id,
- TemplateId: template_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- errs, templates := service.FindPrintTemplateByOrgId(org_id)
-
- if errs == gorm.ErrRecordNotFound {
- err := service.CreatePrintTemplateRecord(&template)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- } else if errs == nil {
- templates := models.GobalTemplate{
- ID: templates.ID,
- OrgId: org_id,
- TemplateId: template_id,
- Status: 1,
- Ctime: templates.Ctime,
- Mtime: time.Now().Unix(),
- }
-
- err := service.UpdatePrintTemplate(&templates)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "template_id": template_id,
- })
- return
- }
-
- func (c *GobalConfigApiController) PostPrintTemplateTwo() {
- template_id, _ := c.GetInt64("template_id", 0)
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- template := models.GobalTemplate{
- OrgId: org_id,
- TemplateId: template_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- errs, templates := service.FindPrintTemplateByOrgId(org_id)
-
- if errs == gorm.ErrRecordNotFound {
- err := service.CreatePrintTemplateRecord(&template)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- if err == nil { //处理模版切换,显示配置处理逻辑
- //service.FindAllConfig
- //先将所有数据设置为显示
- updateErr := service.UpdateFiledConfig(adminUserInfo.CurrentOrgId)
- if updateErr == nil {
- //查出该模版对应显示配置字段中所有隐藏的字段
- _, config := service.FindAllHideFiledConfig(template_id)
-
- var fileds []string
- for _, item := range config {
- fileds = append(fileds, item.FiledName)
- }
- service.UpdateShowFieldConfig(adminUserInfo.CurrentOrgId, fileds)
- }
- }
- FiledList, _ := service.FindFiledByOrgId(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "template_id": template_id,
- "fileds": FiledList,
- })
-
- } else if errs == nil {
- templates := models.GobalTemplate{
- ID: templates.ID,
- OrgId: org_id,
- TemplateId: template_id,
- Status: 1,
- Ctime: templates.Ctime,
- Mtime: time.Now().Unix(),
- }
-
- err := service.UpdatePrintTemplate(&templates)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- if err == nil { //处理模版切换,显示配置处理逻辑
- //service.FindAllConfig
- //先将所有数据设置为显示
- updateErr := service.UpdateFiledConfig(adminUserInfo.CurrentOrgId)
- if updateErr == nil {
- //查出该模版对应显示配置字段中所有隐藏的字段
- _, config := service.FindAllHideFiledConfig(template_id)
- var fileds []string
- for _, item := range config {
- fileds = append(fileds, item.FiledName)
- }
- service.UpdateShowFieldConfig(adminUserInfo.CurrentOrgId, fileds)
-
- }
-
- }
- FiledList, _ := service.FindFiledByOrgId(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "template_id": template_id,
- "fileds": FiledList,
- })
- return
- }
- }
-
- func (c *GobalConfigApiController) GetPrintTemplate() {
- adminUserInfo := c.GetAdminUserInfo()
- _, template := service.FindPrintTemplateByOrgId(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- }
-
- func (c *GobalConfigApiController) PostConfig() {
- gateway_address := c.GetString("gateway_address")
- app_id := c.GetString("app_id")
- key := c.GetString("key")
- config_type, _ := c.GetInt64("config_type")
- time_type, _ := c.GetInt64("time_type")
- province, _ := c.GetInt64("province")
- city, _ := c.GetInt64("city")
-
- if config_type > 1 {
- _, err := service.GetDockingStatus(config_type, province, city)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotDocking)
- return
- }
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- config := &models.DataUploadConfig{
- OrgId: org_id,
- ProvinceId: province,
- CityId: city,
- GatewayAddress: gateway_address,
- AppId: app_id,
- Key: key,
- Status: 1,
- CreateTime: time.Now().Unix(),
- ModifyTime: time.Now().Unix(),
- TimeQuantum: time_type,
- ConfigType: config_type,
- }
- err := service.CreateConfigData(config)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *GobalConfigApiController) GetDataUploadConfig() {
- config_type, _ := c.GetInt64("config_type")
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- config, err := service.GetConfigData(org_id, config_type)
- fmt.Println(err)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
-
- func (c *GobalConfigApiController) GetDataUploadIsDocking() {
- config_type, _ := c.GetInt64("config_type")
- province, _ := c.GetInt64("province")
- city, _ := c.GetInt64("city")
-
- config, err := service.GetDockingStatus(config_type, province, city)
- fmt.Println(config)
- fmt.Println(err)
- if err == gorm.ErrRecordNotFound {
- c.ServeSuccessJSON(map[string]interface{}{
- "is_docking": 2,
- })
-
- } else if err == nil {
- if config.ID > 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "is_docking": 1,
- })
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "is_docking": 2,
- })
-
- }
- }
- }
-
- func (c *GobalConfigApiController) ModifyConfig() {
- id, _ := c.GetInt64("id")
- gateway_address := c.GetString("gateway_address")
- app_id := c.GetString("app_id")
- key := c.GetString("key")
- config_type, _ := c.GetInt64("config_type")
- time_type, _ := c.GetInt64("time_type")
- province, _ := c.GetInt64("province")
- city, _ := c.GetInt64("city")
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
-
- if config_type > 1 {
- _, err := service.GetDockingStatus(config_type, province, city)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotDocking)
- return
- }
- }
-
- tempConfig, _ := service.GetConfigDataById(id)
-
- config := &models.DataUploadConfig{
- ID: tempConfig.ID,
- OrgId: org_id,
- ProvinceId: province,
- CityId: city,
- GatewayAddress: gateway_address,
- AppId: app_id,
- Key: key,
- Status: 1,
- CreateTime: tempConfig.CreateTime,
- ModifyTime: time.Now().Unix(),
- TimeQuantum: time_type,
- ConfigType: config_type,
- }
- err := service.SaveConfigData(config)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *GobalConfigApiController) PostDoctorAdviceConfig() {
- is_open_remind, _ := c.GetInt64("is_open_remind", 0)
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- config := models.DoctorAdviceConfig{
- UserOrgId: org_id,
- IsOpenRemind: is_open_remind,
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- }
-
- errs, configs := service.FindDoctorAdviceRecordByOrgId(org_id)
-
- if errs == gorm.ErrRecordNotFound {
- err := service.CreateDoctorAdviceRecord(&config)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- } else if errs == nil {
- modifyConfig := models.DoctorAdviceConfig{
- ID: configs.ID,
- UserOrgId: org_id,
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- IsOpenRemind: is_open_remind,
- }
-
- err := service.UpdateDoctorAdviceRecord(&modifyConfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "is_open_remind": is_open_remind,
- })
-
- return
- }
-
- func (c *GobalConfigApiController) GetDoctorAdviceConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
-
- // SF6090214798525
- func (c *GobalConfigApiController) Load(filename string, v interface{}) {
- //ReadFile函数会读取文件的全部内容,并将结果以[]byte类型返回
- data, err := ioutil.ReadFile(filename)
- if err != nil {
- return
- }
- //读取的数据为json格式,需要进行解码
- err = json.Unmarshal(data, v)
- if err != nil {
- return
- }
- }
-
- type Config struct {
- Parent_template []*models.VMDoctorAdviceParentTemplate "json:parent_template"
- }
-
- func LoadConfig(dataFile string) *Config {
- var config Config
- _, filename, _, _ := runtime.Caller(1)
- datapath := path.Join(path.Dir(filename), dataFile)
- config_file, err := os.Open(datapath)
- if err != nil {
- emit("Failed to open config file '%s': %s\n", datapath, err)
- return &config
- }
-
- fi, _ := config_file.Stat()
-
- buffer := make([]byte, fi.Size())
- _, err = config_file.Read(buffer)
-
- buffer, err = StripComments(buffer) //去掉注释
- if err != nil {
- emit("Failed to strip comments from json: %s\n", err)
- return &config
- }
-
- buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
- err = json.Unmarshal(buffer, &config) //解析json格式数据
- if err != nil {
- emit("Failed unmarshalling json: %s\n", err)
- return &config
- }
- return &config
- }
-
- func StripComments(data []byte) ([]byte, error) {
- data = bytes.Replace(data, []byte("\r"), []byte(""), 0) // Windows
- lines := bytes.Split(data, []byte("\n")) //split to muli lines
- filtered := make([][]byte, 0)
-
- for _, line := range lines {
- match, err := regexp.Match(`^\s*#`, line)
- if err != nil {
- return nil, err
- }
- if !match {
- filtered = append(filtered, line)
- }
- }
-
- return bytes.Join(filtered, []byte("\n")), nil
- }
-
- func emit(msgfmt string, args ...interface{}) {
- log.Printf(msgfmt, args...)
- }
-
- func (c *GobalConfigApiController) GetAdviceInitConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- advice_init, _ := service.FindAdviceInitConfig(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "advice_init": advice_init,
- })
- }
-
- func (c *GobalConfigApiController) PostInitAdviceTemplate() {
- is_init, _ := c.GetInt64("is_init")
- adminUserInfo := c.GetAdminUserInfo()
- adviceInit := &models.AdviceInit{
- UserOrgId: adminUserInfo.CurrentOrgId,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- Status: 1,
- IsInit: is_init,
- }
-
- adviceParentTemplate := LoadConfig("./advice_template.json").Parent_template
- for _, item := range adviceParentTemplate {
- parentTemplate := &models.DoctorAdviceParentTemplate{
- OrgId: adminUserInfo.CurrentOrgId,
- Name: item.Name,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- AdviceType: item.AdviceType,
- }
-
- createErr := service.CreateDoctorParentTemplate(parentTemplate)
- fmt.Println(parentTemplate.ID)
- if createErr == nil {
- for _, adviceTemplateItem := range item.DoctorAdviceTemplate {
- adviceTeplate := &models.DoctorAdviceTemplate{
- OrgId: adminUserInfo.CurrentOrgId,
- AdviceName: adviceTemplateItem.AdviceName,
- AdviceDesc: adviceTemplateItem.AdviceDesc,
- SingleDose: adviceTemplateItem.SingleDose,
- SingleDoseUnit: adviceTemplateItem.SingleDoseUnit,
- PrescribingNumber: adviceTemplateItem.PrescribingNumber,
- PrescribingNumberUnit: adviceTemplateItem.PrescribingNumberUnit,
- DeliveryWay: adviceTemplateItem.DeliveryWay,
- ExecutionFrequency: adviceTemplateItem.ExecutionFrequency,
- AdviceDoctor: adviceTemplateItem.AdviceDoctor,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- TemplateId: parentTemplate.ID,
- DrugSpec: adviceTemplateItem.DrugSpec,
- DrugSpecUnit: adviceTemplateItem.DrugSpecUnit,
- ParentId: adviceTemplateItem.ParentId,
- AdviceType: adviceTemplateItem.AdviceType,
- DayCount: adviceTemplateItem.DayCount,
- WeekDays: adviceTemplateItem.WeekDays,
- FrequencyType: adviceTemplateItem.FrequencyType,
- }
- createErr := service.CreateDoctorTemplate(adviceTeplate)
-
- if createErr == nil {
- for _, childItem := range adviceTemplateItem.SubDoctorAdviceTemplate {
- adviceTeplate := &models.DoctorAdviceTemplate{
- OrgId: adminUserInfo.CurrentOrgId,
- AdviceName: childItem.AdviceName,
- AdviceDesc: childItem.AdviceDesc,
- SingleDose: childItem.SingleDose,
- SingleDoseUnit: childItem.SingleDoseUnit,
- PrescribingNumber: childItem.PrescribingNumber,
- PrescribingNumberUnit: childItem.PrescribingNumberUnit,
- DeliveryWay: childItem.DeliveryWay,
- ExecutionFrequency: childItem.ExecutionFrequency,
- AdviceDoctor: childItem.AdviceDoctor,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- TemplateId: parentTemplate.ID,
- DrugSpec: childItem.DrugSpec,
- DrugSpecUnit: childItem.DrugSpecUnit,
- ParentId: adviceTeplate.ID,
- AdviceType: childItem.AdviceType,
- DayCount: childItem.DayCount,
- WeekDays: childItem.WeekDays,
- FrequencyType: childItem.FrequencyType,
- }
- service.CreateDoctorTemplate(adviceTeplate)
- }
- }
- }
- }
- }
- err := service.CreateAdviceInitConfig(adviceInit)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "init_config": adviceInit,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *GobalConfigApiController) CreateSystemPrescription() {
- adminUserInfo := c.GetAdminUserInfo()
- var solution models.SystemPrescription
- code := defaultSystemSolutionFormData(&solution, c.Ctx.Input.RequestBody, "create")
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- solution.RegistrarsId = adminUserInfo.AdminUser.Id
- solution.Doctor = adminUserInfo.AdminUser.Id
- solution.Status = 1
- solution.CreatedTime = time.Now().Unix()
- solution.UserOrgId = adminUserInfo.CurrentOrgId
- solution.UpdatedTime = time.Now().Unix()
-
- err := service.CreateSystemDialysisSolution(&solution)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionCreate)
- return
- }
-
- prescriptions, _ := service.FindAllSystemPrescription(adminUserInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "prescription": solution,
- "prescriptions": prescriptions,
- })
- return
- }
-
- func (c *GobalConfigApiController) UpdateSystemPrescription() {
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- solution, _ := service.FindSystemDialysisSolution(adminUserInfo.CurrentOrgId, id)
- if solution.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionNotExist)
- return
- }
-
- code := defaultSystemSolutionFormData(&solution, c.Ctx.Input.RequestBody, "edit")
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- solution.UpdatedTime = time.Now().Unix()
- solution.Doctor = adminUserInfo.AdminUser.Id
- solution.RegistrarsId = adminUserInfo.AdminUser.Id
-
- err := service.UpdateSystemDialysisSolution(&solution)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "prescription": solution,
- })
- return
- }
-
- func (c *GobalConfigApiController) GetAllSystemPrescription() {
- adminUserInfo := c.GetAdminUserInfo()
- prescriptions, _ := service.FindAllSystemPrescription(adminUserInfo.CurrentOrgId)
-
- stockType, _ := service.GetStockType(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "prescriptions": prescriptions,
- "stockType": stockType,
- })
- }
-
- func (c *GobalConfigApiController) GetSystemPrescription() {
- adminUserInfo := c.GetAdminUserInfo()
- id, _ := c.GetInt64("id", 0)
- prescription, _ := service.FindSystemDialysisPrescriptionByMode(adminUserInfo.CurrentOrgId, id)
- c.ServeSuccessJSON(map[string]interface{}{
- "prescription": prescription,
- })
-
- }
-
- func defaultSystemSolutionFormData(solution *models.SystemPrescription, data []byte, method string) (code int) {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &dataBody)
- utils.InfoLog(string(data))
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
-
- if method == "create" {
- if dataBody["mode"] == nil || reflect.TypeOf(dataBody["mode"]).String() != "float64" {
- utils.ErrorLog("mode")
- code = enums.ErrorCodeParamWrong
- return
- }
- mode := int64(dataBody["mode"].(float64))
- if mode <= 0 {
- utils.ErrorLog("mode <= 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- solution.ModeId = mode
-
- }
-
- if dataBody["dialysis_duration"] != nil && reflect.TypeOf(dataBody["dialysis_duration"]).String() == "string" {
- dialysisDuration, _ := strconv.ParseFloat(dataBody["dialysis_duration"].(string), 64)
- solution.DialysisDuration = dialysisDuration
- }
-
- if dataBody["target_ultrafiltration"] != nil && reflect.TypeOf(dataBody["target_ultrafiltration"]).String() == "string" {
- targetUltrafiltration, _ := strconv.ParseFloat(dataBody["target_ultrafiltration"].(string), 64)
- solution.TargetUltrafiltration = targetUltrafiltration
- }
-
- if dataBody["dialysate_formulation"] != nil && reflect.TypeOf(dataBody["dialysate_formulation"]).String() == "float64" {
- dialysateFormulation := int64(dataBody["dialysate_formulation"].(float64))
- solution.DialysateFormulation = dialysateFormulation
- }
-
- if dataBody["dialysis_duration_hour"] != nil && reflect.TypeOf(dataBody["dialysis_duration_hour"]).String() == "string" {
- dialysisDurationHour, _ := strconv.ParseFloat(dataBody["dialysis_duration_hour"].(string), 64)
- solution.DialysisDurationHour = int64(dialysisDurationHour)
- }
-
- if dataBody["dialysis_duration_minute"] != nil && reflect.TypeOf(dataBody["dialysis_duration_minute"]).String() == "string" {
- dialysisDurationMinute, _ := strconv.ParseFloat(dataBody["dialysis_duration_minute"].(string), 64)
- solution.DialysisDurationMinute = int64(dialysisDurationMinute)
- }
-
- if dataBody["hemodialysis_machine"] != nil && reflect.TypeOf(dataBody["hemodialysis_machine"]).String() == "float64" {
- hemodialysisMachine := int64(dataBody["hemodialysis_machine"].(float64))
- solution.HemodialysisMachine = hemodialysisMachine
- }
- if dataBody["dialyzer"] != nil && reflect.TypeOf(dataBody["dialyzer"]).String() == "float64" {
- dialyzer := int64(dataBody["dialyzer"].(float64))
- solution.Dialyzer = dialyzer
- }
-
- if dataBody["perfusion_apparatus"] != nil && reflect.TypeOf(dataBody["perfusion_apparatus"]).String() == "float64" {
- perfusionApparatus := int64(dataBody["perfusion_apparatus"].(float64))
- solution.PerfusionApparatus = perfusionApparatus
- }
-
- if dataBody["blood_flow_volume"] != nil && reflect.TypeOf(dataBody["blood_flow_volume"]).String() == "string" {
- bloodFlowVolume, _ := strconv.ParseFloat(dataBody["blood_flow_volume"].(string), 64)
- solution.BloodFlowVolume = bloodFlowVolume
- }
-
- if dataBody["dewater"] != nil && reflect.TypeOf(dataBody["dewater"]).String() == "string" {
- dewater, _ := strconv.ParseFloat(dataBody["dewater"].(string), 64)
- solution.Dewater = dewater
- }
-
- if dataBody["displace_liqui"] != nil && reflect.TypeOf(dataBody["displace_liqui"]).String() == "string" {
- displaceLiqui, _ := strconv.ParseFloat(dataBody["displace_liqui"].(string), 64)
- solution.DisplaceLiqui = displaceLiqui
- }
-
- if dataBody["replacement_way"] != nil && reflect.TypeOf(dataBody["replacement_way"]).String() == "float64" {
- replacementWay := int64(dataBody["replacement_way"].(float64))
- solution.ReplacementWay = replacementWay
- }
-
- if dataBody["anticoagulant"] != nil && reflect.TypeOf(dataBody["anticoagulant"]).String() == "float64" {
- anticoagulant := int64(dataBody["anticoagulant"].(float64))
- solution.Anticoagulant = anticoagulant
- }
-
- if dataBody["anticoagulant_shouji"] != nil && reflect.TypeOf(dataBody["anticoagulant_shouji"]).String() == "string" {
- anticoagulantShouji, _ := strconv.ParseFloat(dataBody["anticoagulant_shouji"].(string), 64)
- solution.AnticoagulantShouji = anticoagulantShouji
- }
-
- if dataBody["anticoagulant_weichi"] != nil && reflect.TypeOf(dataBody["anticoagulant_weichi"]).String() == "string" {
- anticoagulantWeichi, _ := strconv.ParseFloat(dataBody["anticoagulant_weichi"].(string), 64)
- solution.AnticoagulantWeichi = anticoagulantWeichi
- }
-
- if dataBody["anticoagulant_zongliang"] != nil && reflect.TypeOf(dataBody["anticoagulant_zongliang"]).String() == "string" {
- anticoagulantZongliang, _ := strconv.ParseFloat(dataBody["anticoagulant_zongliang"].(string), 64)
- solution.AnticoagulantZongliang = anticoagulantZongliang
- }
-
- if dataBody["anticoagulant_gaimingcheng"] != nil && reflect.TypeOf(dataBody["anticoagulant_gaimingcheng"]).String() == "string" {
- anticoagulantGaimingcheng, _ := dataBody["anticoagulant_gaimingcheng"].(string)
- solution.AnticoagulantGaimingcheng = anticoagulantGaimingcheng
- }
-
- if dataBody["anticoagulant_gaijiliang"] != nil && reflect.TypeOf(dataBody["anticoagulant_gaijiliang"]).String() == "string" {
- anticoagulantGaijiliang, _ := dataBody["anticoagulant_gaijiliang"].(string)
- solution.AnticoagulantGaijiliang = anticoagulantGaijiliang
- }
-
- if dataBody["kalium"] != nil && reflect.TypeOf(dataBody["kalium"]).String() == "string" {
- kalium, _ := strconv.ParseFloat(dataBody["kalium"].(string), 64)
- solution.Kalium = kalium
- }
-
- if dataBody["sodium"] != nil && reflect.TypeOf(dataBody["sodium"]).String() == "string" {
- sodium, _ := strconv.ParseFloat(dataBody["sodium"].(string), 64)
- solution.Sodium = sodium
- }
-
- if dataBody["calcium"] != nil && reflect.TypeOf(dataBody["calcium"]).String() == "string" {
- calcium, _ := strconv.ParseFloat(dataBody["calcium"].(string), 64)
- solution.Calcium = calcium
- }
-
- if dataBody["bicarbonate"] != nil && reflect.TypeOf(dataBody["bicarbonate"]).String() == "string" {
- bicarbonate, _ := strconv.ParseFloat(dataBody["bicarbonate"].(string), 64)
- solution.Bicarbonate = bicarbonate
- }
-
- if dataBody["glucose"] != nil && reflect.TypeOf(dataBody["glucose"]).String() == "string" {
- glucose, _ := strconv.ParseFloat(dataBody["glucose"].(string), 64)
- solution.Glucose = glucose
- }
-
- // if dataBody["dry_weight"] != nil && reflect.TypeOf(dataBody["dry_weight"]).String() == "string" {
- // dryWeight, _ := strconv.ParseFloat(dataBody["dry_weight"].(string), 64)
- // solution.DryWeight = dryWeight
- // }
-
- if dataBody["dialysate_flow"] != nil && reflect.TypeOf(dataBody["dialysate_flow"]).String() == "string" {
- dialysateFlow, _ := strconv.ParseFloat(dataBody["dialysate_flow"].(string), 64)
- solution.DialysateFlow = dialysateFlow
- }
-
- if dataBody["dialysate_temperature"] != nil && reflect.TypeOf(dataBody["dialysate_temperature"]).String() == "string" {
- dialysateTemperature, _ := strconv.ParseFloat(dataBody["dialysate_temperature"].(string), 64)
- solution.DialysateTemperature = dialysateTemperature
- }
-
- if dataBody["conductivity"] != nil && reflect.TypeOf(dataBody["conductivity"]).String() == "string" {
- conductivity, _ := strconv.ParseFloat(dataBody["conductivity"].(string), 64)
- solution.Conductivity = conductivity
- }
-
- if dataBody["replacement_total"] != nil && reflect.TypeOf(dataBody["replacement_total"]).String() == "string" {
- replacementTotal, _ := strconv.ParseFloat(dataBody["replacement_total"].(string), 64)
- solution.ReplacementTotal = replacementTotal
- }
-
- if dataBody["dialyzer_perfusion_apparatus"] != nil && reflect.TypeOf(dataBody["dialyzer_perfusion_apparatus"]).String() == "string" {
- dialyzer_perfusion_apparatus := dataBody["dialyzer_perfusion_apparatus"].(string)
- solution.DialyzerPerfusionApparatus = dialyzer_perfusion_apparatus
- }
-
- if dataBody["body_fluid"] != nil && reflect.TypeOf(dataBody["body_fluid"]).String() == "float64" {
- body_fluid := int64(dataBody["body_fluid"].(float64))
- solution.BodyFluid = body_fluid
- }
-
- if dataBody["body_fluid_other"] != nil && reflect.TypeOf(dataBody["body_fluid_other"]).String() == "string" {
- body_fluid_other := dataBody["body_fluid_other"].(string)
- solution.BodyFluidOther = body_fluid_other
- }
-
- if dataBody["special_medicine"] != nil && reflect.TypeOf(dataBody["special_medicine"]).String() == "float64" {
- special_medicine := int64(dataBody["special_medicine"].(float64))
- solution.SpecialMedicine = special_medicine
- }
-
- if dataBody["special_medicine_other"] != nil && reflect.TypeOf(dataBody["special_medicine_other"]).String() == "string" {
- special_medicine_other := dataBody["special_medicine_other"].(string)
- solution.SpecialMedicineOther = special_medicine_other
- }
-
- if dataBody["displace_liqui_part"] != nil && reflect.TypeOf(dataBody["displace_liqui_part"]).String() == "float64" {
- displace_liqui_part := int64(dataBody["displace_liqui_part"].(float64))
- solution.DisplaceLiquiPart = displace_liqui_part
- }
- if dataBody["displace_liqui_value"] != nil && reflect.TypeOf(dataBody["displace_liqui_value"]).String() == "string" {
- displace_liqui_value, _ := strconv.ParseFloat(dataBody["displace_liqui_value"].(string), 64)
- solution.DisplaceLiquiValue = displace_liqui_value
- }
- if dataBody["blood_access"] != nil && reflect.TypeOf(dataBody["blood_access"]).String() == "float64" {
- blood_access := int64(dataBody["blood_access"].(float64))
- solution.BloodAccess = blood_access
- }
-
- if dataBody["ultrafiltration"] != nil && reflect.TypeOf(dataBody["ultrafiltration"]).String() == "string" {
- ultrafiltration, _ := strconv.ParseFloat(dataBody["ultrafiltration"].(string), 64)
- solution.Ultrafiltration = ultrafiltration
- }
-
- if dataBody["target_ktv"] != nil && reflect.TypeOf(dataBody["target_ktv"]).String() == "string" {
- target_ktv, _ := strconv.ParseFloat(dataBody["target_ktv"].(string), 64)
- solution.TargetKtv = target_ktv
- }
-
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
- remark := dataBody["remark"].(string)
- solution.Remark = remark
- }
-
- if dataBody["dialysis_dialyszers"] != nil && reflect.TypeOf(dataBody["dialysis_dialyszers"]).String() == "string" {
- dialysisDialyszers := dataBody["dialysis_dialyszers"].(string)
- fmt.Println("dialysisDialysis22222222222", dialysisDialyszers)
- solution.DialysisDialyszers = dialysisDialyszers
- }
-
- if dataBody["dialysis_irrigation"] != nil && reflect.TypeOf(dataBody["dialysis_irrigation"]).String() == "string" {
- dialysisIrrigation := dataBody["dialysis_irrigation"].(string)
- solution.DialysisIrrigation = dialysisIrrigation
- }
-
- if dataBody["blood_access_part_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_id"]).String() == "string" {
- blood_access_part_id := dataBody["blood_access_part_id"].(string)
- solution.BloodAccessPartId = blood_access_part_id
- }
-
- return
- }
-
- func (c *GobalConfigApiController) GetPrintInfo() {
- adminUserInfo := c.GetAdminUserInfo()
- OrgID := adminUserInfo.CurrentOrgId
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- idsInters := dataBody["ids"].([]interface{})
- advice_type, _ := c.GetInt64("advice_type")
- stop_type, _ := c.GetInt64("stop_type")
- if len(idsInters) == 0 {
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
- return
- }
- }
- ids := make([]int64, 0)
- for _, idsInter := range idsInters {
- id := int64(idsInter.(float64))
- ids = append(ids, id)
- }
- getPrint, err := service.GetPrint(ids, OrgID, advice_type, stop_type)
- c.ServeSuccessJSON(map[string]interface{}{
- "doctoradvice": getPrint,
- })
- }
-
- func (c *GobalConfigApiController) GetOrgs() {
- adminUserInfo := c.GetAdminUserInfo()
- //获取当前人姓名
- var id = adminUserInfo.AdminUser.Id
- orgId := adminUserInfo.CurrentOrgId
- var orgs []*models.Org
- adminUser, err := service.GetHomeData(adminUserInfo.AdminUser.Id)
- creator, err := service.GetCreator(id, orgId)
- admin, err := service.GetSuperAdmin(id)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- for _, item := range adminUser.Org {
- orgs = append(orgs, item)
- }
- for _, item := range adminUser.VMApp_Role {
- for _, subItem := range item.Org {
- orgs = append(orgs, subItem)
- }
- }
- orgs = RemoveRepeatedOrgElement(orgs)
- fmt.Println("~~~~")
- role, _ := service.GetAdminUserInfoByID(orgId, id)
- miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "orgs": orgs,
- "adminUser": adminUser,
- "creator": creator,
- "admin": admin,
- "role": role,
- "org_config": miConfig,
- })
-
- }
-
- func (this *GobalConfigApiController) ChangeOrg() {
- org_id, _ := this.GetInt64("org_id")
- adminUserInfo := this.GetAdminUserInfo()
- tempOrg, err := service.GetOrgById(org_id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- if tempOrg == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoExist)
- return
- }
-
- mobile := adminUserInfo.AdminUser.Mobile
- // 只取最近被创建的 admin_role
- adminUser, getAdminErr := service.GetValidAdminUserByMobileReturnErr(mobile) //账号信息唯一值
- if getAdminErr != nil {
- utils.ErrorLog("获取管理员失败:%v", getAdminErr)
- this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- this.ServeJSON()
- return
- } else if adminUser == nil {
- utils.ErrorLog("查找不到 mobile = %v 的用户", mobile)
- this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
- this.ServeJSON()
- return
- } else {
-
- adminUserInfo.CurrentOrgId = tempOrg.Id
- orgApp, _ := service.GetOrgApp(tempOrg.Id, 3)
- subscibe, _ := service.GetOrgSubscibe(tempOrg.Id)
- adminUserInfo.CurrentAppId = orgApp.Id
- appRole, _ := service.GetAppRole(tempOrg.Id, orgApp.Id, adminUserInfo.AdminUser.Id)
- var FiledList []*models.FiledConfig
- FiledList, _ = service.FindFiledByOrgId(tempOrg.Id)
- if len(FiledList) == 0 {
- err := service.BatchInsertFiledConfig(tempOrg.Id)
- if err == nil {
- FiledList, _ = service.FindFiledByOrgId(tempOrg.Id)
-
- } else {
- utils.ErrorLog("字段批量插入失败:%v", err)
- }
- }
-
- //产寻该机构是否有收缩压和舒张压
- pressure, err := service.GetDefaultSystolicPressure(tempOrg.Id)
- fmt.Println(err)
- if len(pressure) == 0 {
- err = service.BathInsertQualityControlTwo(tempOrg.Id)
- } else {
- utils.ErrorLog("字段批量插入失败:%v", err)
- }
- major, err := service.GetInspectionMajor(tempOrg.Id)
- if len(major) == 0 {
- QualityeList, err := service.FindQualityByOrgId(tempOrg.Id)
- if len(QualityeList) == 0 {
- err = service.BatchInsertQualityControl(tempOrg.Id)
- } else {
- utils.ErrorLog("字段批量插入失败:%v", err)
- }
-
- InspectionList, err := service.FindeInspectionByOrgId(tempOrg.Id)
- if len(InspectionList) == 0 {
- err = service.BatchInspectionConfiguration(tempOrg.Id)
- } else {
- utils.ErrorLog("字段批量插入失败:%v", err)
- }
- } else {
- utils.ErrorLog("字段批量插入失败:%v", err)
- }
-
- //查询该机构是否存在医护排班
- _, errcode := service.GetDoctorScheduleByOrgId(tempOrg.Id)
- //如果没有就插入
- if errcode == gorm.ErrRecordNotFound {
- err = service.BatchInsertDoctorSchedule(tempOrg.Id)
- } else {
- utils.ErrorLog("医护排班默认数据插入失败:%v", err)
- }
-
- var didRegistedForSCRM bool = false
- var didRegistedForCDM bool = false
- var didRegistedForMall bool = false
-
- var curAppUrlfors []string
- var pruviews []*models.Purview
-
- if len(curAppUrlfors) == 0 {
- if adminUser.Id == tempOrg.Creator {
- urlfors_xt, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(3)
- urlfors_cdm, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(4)
- urlfors_scrm, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(6)
- urlfors_mall, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(7)
- curAppUrlfors = append(curAppUrlfors, urlfors_xt...)
- curAppUrlfors = append(curAppUrlfors, urlfors_scrm...)
- curAppUrlfors = append(curAppUrlfors, urlfors_cdm...)
- curAppUrlfors = append(curAppUrlfors, urlfors_mall...)
-
- didRegistedForSCRM = true
- didRegistedForCDM = true
- didRegistedForMall = true
-
- } else {
- appRole, _ := service.FindAdminUserIDA(appRole.Id)
- if appRole.Id > 0 && len(appRole.RoleIds) > 0 {
- role_arr := strings.Split(appRole.RoleIds, ",")
- var ids string
- for _, role_id := range role_arr {
- id, _ := strconv.ParseInt(role_id, 10, 64)
- purview_ids, _ := service.GetRolePurviewIds(id)
- if len(ids) == 0 {
- ids = purview_ids
- } else {
- ids = ids + "," + purview_ids
- }
- }
- if len(ids) != 0 {
- pruviews, _ = service.GetPurviewById(ids)
- for _, item := range pruviews {
- if item.Module == 3 && item.Parentid > 0 {
- fmt.Println(item.Urlfor)
- curAppUrlfors = append(curAppUrlfors, item.Urlfor)
- }
- }
- } else {
-
- curAppUrlfors = append(curAppUrlfors, "")
- }
- } else {
- curAppUrlfors = append(curAppUrlfors, "")
-
- }
- for _, item := range pruviews {
- if item.Module == 6 {
- didRegistedForSCRM = true
- }
- if item.Module == 4 {
- didRegistedForCDM = true
- }
- if item.Module == 7 {
- didRegistedForMall = true
- }
- }
- }
- }
-
- userInfo := map[string]interface{}{
- "id": adminUser.Id,
- "mobile": adminUser.Mobile,
- "user_name": appRole.UserName,
- "avatar": appRole.Avatar,
- "intro": appRole.Intro,
- "user_type": appRole.UserType,
- "user_title": appRole.UserTitle,
- }
- org := map[string]interface{}{
- "id": tempOrg.Id,
- "org_name": tempOrg.OrgName,
- "org_short_name": tempOrg.OrgShortName,
- "org_intro": tempOrg.OrgIntroduction,
- "org_logo": tempOrg.OrgLogo,
- "province": tempOrg.Province,
- "city": tempOrg.City,
- "district": tempOrg.District,
- "address": tempOrg.Address,
- }
-
- tempInfo, _ := service.GetOrgInfoTemplate(tempOrg.Id)
- template_info := map[string]interface{}{
- "id": tempInfo.ID,
- "org_id": tempInfo.OrgId,
- "template_id": tempInfo.TemplateId,
- }
-
- if tempOrg != nil && appRole != nil {
- // 插入一条登录记录
- ip := this.GetString("ip")
- loginLog := &models.AdminUserLoginLog{
- AdminUserId: adminUser.Id,
- OrgId: tempOrg.Id,
- AppId: appRole.AppId,
- IP: ip,
- OperateType: 3,
- AppType: 3,
- CreateTime: time.Now().Unix(),
- }
- if insertErr := service.InsertLoginLog(loginLog); insertErr != nil {
- utils.ErrorLog("为手机号为%v的用户插入一条登录记录失败:%v", mobile, insertErr)
- }
- }
-
- this.SetSession("admin_user_info", adminUserInfo)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "user": userInfo,
- "org": org,
- "urlfors": curAppUrlfors,
- "current_org_id": adminUserInfo.CurrentOrgId,
- "current_app_id": adminUserInfo.CurrentAppId,
- "subscibe": subscibe,
- "template_info": template_info,
- "fileds": FiledList,
- "scrm_role_exist": didRegistedForSCRM,
- "cdm_role_exist": didRegistedForCDM,
- "mall_role_exist": didRegistedForMall,
- })
-
- }
-
- }
-
- func RemoveRepeatedOrgElement(orgs []*models.Org) (newOrgs []*models.Org) {
- newOrgs = make([]*models.Org, 0)
- for i := 0; i < len(orgs); i++ {
- repeat := false
- for j := i + 1; j < len(orgs); j++ {
- if orgs[i].Id == orgs[j].Id {
- repeat = true
- break
- }
- }
- if !repeat {
- newOrgs = append(newOrgs, orgs[i])
- }
- }
- return
- }
-
- func (this *GobalConfigApiController) GenerateLog() {
-
- log_type, _ := this.GetInt64("log_type", 0)
- logs, err := service.GetExportLogByType(this.GetAdminUserInfo().CurrentOrgId, log_type)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "logs": logs,
- })
-
- }
-
- func (this *GobalConfigApiController) GetPatientsByKeyWord() {
- keyWord := this.GetString("keyword")
- adminUserInfo := this.GetAdminUserInfo()
- patient, err := service.GetPatientsByKey(adminUserInfo.CurrentOrgId, keyWord)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (c *GobalConfigApiController) PostXTHisConfig() {
- is_open, _ := c.GetBool("is_open", false)
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- isOpen := 0
-
- if is_open {
- isOpen = 1
- } else {
- isOpen = 2
- }
-
- config := models.XtHisConfig{
- UserOrgId: org_id,
- IsOpen: int64(isOpen),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- errs, configs := service.FindXTHisRecordByOrgId(org_id)
-
- if errs == gorm.ErrRecordNotFound {
- err := service.CreateXTHisRecord(&config)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- } else if errs == nil {
- modifyConfig := models.XtHisConfig{
- ID: configs.ID,
- UserOrgId: org_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- IsOpen: int64(isOpen),
- }
-
- err := service.UpdateXTHisRecord(&modifyConfig)
- redis := service.RedisClient()
- defer redis.Close()
- key := strconv.FormatInt(org_id, 10) + ":" + ":his_config"
- redis.Set(key, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "is_open": is_open,
- })
-
- return
- }
-
- func (c *GobalConfigApiController) PostHisStockPriceConfig() {
- is_open, _ := c.GetBool("is_open", false)
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- isOpen := 0
-
- if is_open {
- isOpen = 1
- } else {
- isOpen = 2
- }
-
- config := models.HisStockPriceConfig{
- UserOrgId: org_id,
- IsOpen: int64(isOpen),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- errs, configs := service.FindHisStockPriceRecordByOrgId(org_id)
-
- if errs == gorm.ErrRecordNotFound {
- err := service.CreateHisStockPriceRecord(&config)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- } else if errs == nil {
- modifyConfig := models.HisStockPriceConfig{
- ID: configs.ID,
- UserOrgId: org_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- IsOpen: int64(isOpen),
- }
-
- err := service.UpdateHisStockPriceRecord(&modifyConfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "is_open": is_open,
- })
-
- return
- }
-
- func (c *GobalConfigApiController) PostXTHisProjectConfig() {
- is_open, _ := c.GetBool("is_open", false)
- adminUserInfo := c.GetAdminUserInfo()
- org_id := adminUserInfo.CurrentOrgId
- isOpen := 0
-
- if is_open {
- isOpen = 1
- } else {
- isOpen = 2
- }
-
- config := models.XtHisProjectConfig{
- UserOrgId: org_id,
- IsOpen: int64(isOpen),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- errs, configs := service.FindXTHisProjectByOrgId(org_id)
-
- if errs == gorm.ErrRecordNotFound {
- err := service.CreateXTHisProjectRecord(&config)
- redis := service.RedisClient()
- key := strconv.FormatInt(org_id, 10) + ":his_project_config"
- redis.Set(key, "", time.Second)
- defer redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- } else if errs == nil {
- modifyConfig := models.XtHisProjectConfig{
- ID: configs.ID,
- UserOrgId: org_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- IsOpen: int64(isOpen),
- }
-
- err := service.UpdateXTHisProjectRecord(&modifyConfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "is_open": is_open,
- })
-
- return
- }
-
- func (c *GobalConfigApiController) GetXTHisConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
- _, project_config := service.FindXTHisProjectByOrgId(adminUserInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- "project_config": project_config,
- })
- }
-
- func (c *GobalConfigApiController) GetHisStockPriceConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindHisStockPriceRecordByOrgId(adminUserInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
-
- func (c *GobalConfigApiController) GetAllIsOpenConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
- _, project_config := service.FindXTHisProjectByOrgIdOne(adminUserInfo.CurrentOrgId)
-
- stockSetting, _ := service.FindStockSettingById(adminUserInfo.CurrentOrgId)
- adviceSetting, _ := service.FindAdviceSettingById(adminUserInfo.CurrentOrgId)
-
- prescriptionConfig, _ := service.FindPrescriptionConfigById(adminUserInfo.CurrentOrgId)
-
- drugOutConfig, _ := service.FindDrugOutConfigById(adminUserInfo.CurrentOrgId)
-
- drugSettleConfig, _ := service.FindeDrugSettleConfigById(adminUserInfo.CurrentOrgId)
-
- goodOutConfig, _ := service.FindGoodOutConfigById(adminUserInfo.CurrentOrgId)
-
- drugCodeOpen, _ := service.GetDrugCodeOpen(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "is_open_xt_his": config.IsOpen,
- "is_open_xt_his_project": project_config.IsOpen,
- "is_open_stock": stockSetting.IsType,
- "is_open_advice": adviceSetting.IsAdviceOpen,
- "is_prescription_advice": prescriptionConfig.IsOpen,
- "is_open": drugOutConfig.IsOpen,
- "is_seetle_open": drugSettleConfig.IsOpen,
- "is_out_open": goodOutConfig.IsOpen,
- "is_code_open": drugCodeOpen.IsOpen,
- })
-
- }
-
- func (c *GobalConfigApiController) GetPassExportData() {
-
- }
-
- func (c *GobalConfigApiController) GetExportData() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- p_type, _ := c.GetInt64("p_type")
- ex_type, _ := c.GetInt64("sort_type")
-
- 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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- adminInfo := c.GetAdminUserInfo()
- var order []*models.HisOrder
- if ex_type == 1 {
- order, _ = service.GetExportHisOrderList(adminInfo.CurrentOrgId, startTime, endTime, p_type)
- } else {
- order, _ = service.GetExportHisOrderListBySetlTIME(adminInfo.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", p_type)
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- })
-
- }
-
- func (c *GobalConfigApiController) GetDrugInDetail() {
-
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- storehouse_id, _ := c.GetInt64("storehouse_id")
- 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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- adminInfo := c.GetAdminUserInfo()
- order_type, _ := c.GetInt64("order_type")
- manufacturer_id, _ := c.GetInt64("manufacturer_id")
- keyword := c.GetString("keyword")
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
-
- detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
-
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
- houseList, _ := service.GetAllStorehouseName(adminInfo.CurrentOrgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "detail": detail,
- "total": total,
- "drugTypeParent": drugTypeList,
- "houseList": houseList,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugCancelOrder() {
-
- start_time := c.GetString("start_time")
- end_time := c.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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- adminInfo := c.GetAdminUserInfo()
- order_type, _ := c.GetInt64("order_type")
- manufacturer_id, _ := c.GetInt64("manufacturer_id")
- keyword := c.GetString("keyword")
- limit, _ := c.GetInt64("limit")
- page, _ := c.GetInt64("page")
-
- order, total, err := service.GetDrugReturnOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, limit, page)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "total": total,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugOutDetail() {
-
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- storehouse_id, _ := c.GetInt64("storehouse_id")
- 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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- adminInfo := c.GetAdminUserInfo()
- order_type, _ := c.GetInt64("order_type")
- manufacturer_id, _ := c.GetInt64("manufacturer_id")
- keyword := c.GetString("keyword")
- limit, _ := c.GetInt64("limit")
- page, _ := c.GetInt64("page")
- order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
-
- houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
- patientsList, _ := service.GetAllpatient(adminInfo.CurrentOrgId)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "total": total,
- "drugTypeList": drugTypeList,
- "houseList": houseList,
- "patientsList": patientsList,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugCancelDetail() {
-
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- storehouse_id, _ := c.GetInt64("storehouse_id")
- 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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- adminInfo := c.GetAdminUserInfo()
- order_type, _ := c.GetInt64("order_type")
- manufacturer_id, _ := c.GetInt64("manufacturer_id")
- keyword := c.GetString("keyword")
- limit, _ := c.GetInt64("limit")
- page, _ := c.GetInt64("page")
- orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, storehouse_id)
- order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
- houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
- dealerList, _ := service.GetAllDealerList(adminInfo.CurrentOrgId)
- manufacturerList, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
- patientsList, _ := service.GetAllpatient(adminInfo.CurrentOrgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "total": total,
- "orderPrint": orderPrint,
- "drugTypeList": drugTypeList,
- "houseList": houseList,
- "dealerList": dealerList,
- "manufacturerList": manufacturerList,
- "patientsList": patientsList,
- })
- }
-
- func (c *GobalConfigApiController) AddMonitorOpen() {
-
- is_open, _ := c.GetInt64("is_open")
- fmt.Println("is_open22222222", is_open)
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- config := models.XtMonitorConfig{
- IsOpen: is_open,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- //查询该机构是否存在
- _, errcode := service.GetMonitorConfigById(orgId)
- if errcode == gorm.ErrRecordNotFound {
- err := service.AddMonitorOpen(&config)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- } else if errcode == nil {
- err := service.UpdateMonitorOpen(orgId, &config)
- fmt.Println("err", err)
- }
-
- }
-
- func (c *GobalConfigApiController) GetMonitorConfig() {
-
- userInfo := c.GetAdminUserInfo()
- orgId := userInfo.CurrentOrgId
-
- config, err := service.GetMonitorConfig(orgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
-
- }
-
- func (c *GobalConfigApiController) AddOrderConfig() {
-
- is_open, _ := c.GetInt64("is_open")
- fmt.Println("344555555555555", is_open)
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- config := models.XtOrderConfig{
- IsOpen: is_open,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- //查询
- _, errcode := service.GetOrderConfigById(orgId)
- if errcode == gorm.ErrRecordNotFound {
- err := service.AddOrderConfig(&config)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- } else if errcode == nil {
-
- err := service.UpdateOrderConfig(orgId, &config)
- fmt.Println("2222", err)
- }
-
- }
-
- func (c *GobalConfigApiController) GetOrderConfig() {
-
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- config, err := service.GetOrderConfig(orgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugAutoMaticList() {
-
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- warehous_out_id, _ := c.GetInt64("warehous_out_id")
- record_time, _ := c.GetInt64("record_time")
- warehouse_out_order_number := c.GetString("warehouse_out_order_number")
- drugConfig, _ := service.GetDrugStockConfig(orgId)
- list, err := service.GetDrugAutoMaticList(orgId, warehous_out_id, record_time, warehouse_out_order_number)
- drugList, err := service.GetAllBaseDrugList(orgId)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "drugConfig": drugConfig,
- "drugList": drugList,
- "manufacturerList": manufacturerList,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugWarehuseOrderInfo() {
-
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- list, _ := service.GetDrugWarehuseOrderInfo(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugStockList() {
-
- page, _ := c.GetInt64("page", -1)
- limit, _ := c.GetInt64("limit", -1)
- keyword := c.GetString("keyword")
- drug_type, _ := c.GetInt64("drug_type")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- storehouse_id, _ := c.GetInt64("storehouse_id")
- drug_id, _ := c.GetInt64("drug_id")
- 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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- adminUserInfo := c.GetAdminUserInfo()
-
- list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId, storehouse_id, drug_id)
-
- manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
-
- houseList, _ := service.GetAllStoreHouseListOne(adminUserInfo.CurrentOrgId)
-
- medicalList, _ := service.GetAllBaseDrugStockList(adminUserInfo.CurrentOrgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "manufacturerList": manufacturerList,
- "houseList": houseList,
- "medicalList": medicalList,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugStockFllow() {
-
- drug_id, _ := c.GetInt64("drug_id")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- stock_type, _ := c.GetInt64("stock_type")
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
-
- 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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- orgId := c.GetAdminUserInfo().CurrentOrgId
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- medical, _ := service.GetBaseDrugMedical(drug_id)
- //查询入库数据
- if stock_type == 3 || stock_type == 0 {
- list, total, err := service.GetDrugStockFlow(drug_id, startTime, endTime, page, limit, orgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "manufacturerList": manufacturerList,
- "drug": medical,
- })
- }
-
- }
-
- func (c *GobalConfigApiController) GetDrugOutStockFlow() {
- drug_id, _ := c.GetInt64("drug_id")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- stock_type, _ := c.GetInt64("stock_type")
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
-
- 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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- outList, total, err := service.GetDrugStockOutFlow(drug_id, startTime, endTime, page, limit, orgId, stock_type)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "outList": outList,
- "total": total,
- })
-
- }
-
- func (c *GobalConfigApiController) GetBatchOrderDetail() {
-
- drug_id, _ := c.GetInt64("drug_id")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- limit, _ := c.GetInt64("limit")
- page, _ := c.GetInt64("page")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- start_first_time := c.GetString("start_first_time")
- end_first_time := c.GetString("end_first_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 {
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- var startFistTime int64
- if len(start_first_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_first_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startFistTime = theTime.Unix()
- }
- var endFirstTime int64
- if len(end_first_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_first_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endFirstTime = theTime.Unix()
- }
- detail, total, err := service.GetBatchOrderDetail(drug_id, orgId, page, limit, startTime, endTime, startFistTime, endFirstTime)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
-
- drug, _ := service.GetBaseDrugMedical(drug_id)
- houseList, _ := service.GetAllStoreHouseList(orgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "detail": detail,
- "total": total,
- "manufacturerList": manufacturerList,
- "drug": drug,
- "houseList": houseList,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugCountList() {
-
- start_time := c.GetString("start_time")
-
- end_time := c.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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- countList, err := service.GetMinCountList(startTime, endTime, orgId)
- outCountList, _ := service.GetOutDrugCountList(startTime, endTime, orgId)
- auCountList, err := service.GetAutoDrugCountList(startTime, endTime, orgId)
- info, _ := service.GetDrugWarehouOrderInfo(startTime, endTime, orgId)
- cancelCountList, _ := service.GetCancelDrugCountList(startTime, endTime, orgId)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
-
- "outCountList": outCountList,
- "auCountList": auCountList,
- "minCount": countList,
- "info": info,
- "cancelCountList": cancelCountList,
- })
- }
-
- func (c *GobalConfigApiController) GetSingleOrderDetail() {
-
- id, _ := c.GetInt64("id")
- start_time, _ := c.GetInt64("start_time")
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- list, err := service.GetSingleOrderDetail(id, orgId)
-
- drugoutlist, _ := service.GetDrugWarehouseOutDetailNighty(id, orgId)
-
- dealerList, err := service.GetAllDealerList(orgId)
- manufacturerList, err := service.GetAllManufacturerList(orgId)
- drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
- flowlist, _ := service.GetSingeOrderFlow(id, orgId)
- drugList, _ := service.GetDrugFlowList(id, orgId)
- drugListOne, _ := service.GetDrugFlowListGroupByIdOne(id, orgId)
- drugListFlow, err := service.GetDrugFlowListGroupById(id, orgId)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "dealerList": dealerList,
- "manufacturerList": manufacturerList,
- "drugFlowList": drugFlowList,
- "flowlist": flowlist,
- "drugList": drugList,
- "drugListFlow": drugListFlow,
- "drugListOne": drugListOne,
- "drugoutlist": drugoutlist,
- })
- }
-
- func (c *GobalConfigApiController) GetAutoDrugDetail() {
-
- warehouse_out_id, _ := c.GetInt64("warehouse_out_id")
- id, _ := c.GetInt64("drug_id")
- record_time, _ := c.GetInt64("record_time")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- //获取自动出库
- list, err, total := service.FindDrugStockUserDetailByIdThree(id, record_time, orgId)
- //获取手动出库
- outList, err := service.FindeDrugWarehouserInfo(warehouse_out_id, id, orgId)
-
- batchNumber, err := service.GetDrugFlowBatch(warehouse_out_id, id, orgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "outList": outList,
- "batchNumber": batchNumber,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugOrderInPrint() {
-
- id := c.GetString("id")
- ids := strings.Split(id, ",")
- admin := c.GetAdminUserInfo()
-
- info, _ := service.FindDrugWarehousingByIdOne(ids, admin.CurrentOrgId)
- manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
-
- warehousingInfo, _ := service.FindDrugWarehousingInfoByIdOne(ids, admin.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "info": info,
- "warehousing": warehousingInfo,
- "manufacturerList": manufacturerList,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugOutOrderPrint() {
- id := c.GetString("id")
- ids := strings.Split(id, ",")
- admin := c.GetAdminUserInfo()
- info, _ := service.FindeDrugWarehouseOutOrder(ids, admin.CurrentOrgId)
-
- manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
-
- warehousing, _ := service.GetExportOutOrderDrugListOne(ids, admin.CurrentOrgId)
-
- drug_warhouse_out, _ := service.GetDrugWarehouseOutTenty(ids, admin.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "info": info,
- "warehousing": warehousing,
- "manufacturerList": manufacturerList,
- "drug_warhouse_out": drug_warhouse_out,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugBatchNumber() {
-
- id, _ := c.GetInt64("id")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetDrugBatchNumber(id, orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (c *GobalConfigApiController) ExportDrugList() {
-
- orderId := c.GetString("order_id")
- ids := strings.Split(orderId, ",")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- list, _ := service.ExportDrugList(ids, orgId)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
- }
-
- func (c *GobalConfigApiController) GetExportOutOrderDrugList() {
-
- orderId := c.GetString("order_id")
- ids := strings.Split(orderId, ",")
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- list, _ := service.GetExportOutOrderDrugListOne(ids, orgId)
- outInfoList, _ := service.GetDrugOutListFlow(ids, orgId)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "outInfoList": outInfoList,
- })
- }
-
- func (c *GobalConfigApiController) GetDrugFlow() {
-
- start_time := c.GetString("start_time")
- end_time := c.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 {
- fmt.Println(err)
- c.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+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- orgId := c.GetAdminUserInfo().CurrentOrgId
- drug_id, _ := c.GetInt64("drug_id")
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
- stock_type, _ := c.GetInt64("stock_type")
-
- list, total, _ := service.GetDrugFlow(drug_id, orgId, limit, page, startTime, endTime, stock_type)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- medical, _ := service.GetBaseDrugMedical(drug_id)
- houseList, _ := service.GetAllStoreHouseList(orgId)
- patientList, _ := service.GetAllPatientListSix(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- "drug": medical,
- "houseList": houseList,
- "patientList": patientList,
- })
- }
-
- func (c *GobalConfigApiController) GetCancelStockDetail() {
-
- id, _ := c.GetInt64("id")
- list, _ := service.GetCancelStockDetail(id)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (c *GobalConfigApiController) ChangeStockSetting() {
-
- is_type, _ := c.GetInt64("is_type")
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
- setting := models.XtStockSetting{
- IsType: is_type,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- }
-
- //查询机该机构是否已经配置
- _, errcode := service.GetStockSettingIsExsit(orgId)
- if errcode == gorm.ErrRecordNotFound {
- service.CreateStockSetting(setting)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- } else if errcode == nil {
- service.UpdateStockSetting(orgId, setting)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- }
- }
-
- func (c *GobalConfigApiController) ChangeAdviceConfig() {
-
- is_advice_open, _ := c.GetInt64("is_advice_open")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- setting := models.XtAdviceSetting{
- IsAdviceOpen: is_advice_open,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- }
-
- //查询是否存在
- _, errcode := service.GetAdviceConfig(orgId)
- if errcode == gorm.ErrRecordNotFound {
- service.CreateAdviceSetting(setting)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- } else if errcode == nil {
- service.UpdateAdviceSetting(orgId, setting)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- }
-
- }
-
- func (c *GobalConfigApiController) ChangePrescriptionConfig() {
-
- is_open_prescription_xt_his, _ := c.GetInt64("is_open_prescription_xt_his")
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- _, errcode := service.GetPrescriptionConfig(orgId)
-
- if errcode == gorm.ErrRecordNotFound {
-
- config := models.XtPrescriptionConfig{
- UserOrgId: orgId,
- IsOpen: is_open_prescription_xt_his,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- service.CreatePrescriptionConfig(config)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- } else if errcode == nil {
- config := models.XtPrescriptionConfig{
- UserOrgId: orgId,
- IsOpen: is_open_prescription_xt_his,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- service.UpdatePrescriptionConfig(orgId, config)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- }
-
- }
-
- func (c *GobalConfigApiController) ChangeDrugOpenConfig() {
-
- drug_out_open, _ := c.GetInt64("drug_out_open")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- if drug_out_open == 1 {
- service.UpdateDrugStockAutomaticReduceRecordOne(orgId, 2)
- service.UpdatePharyConfig(orgId, 2)
- service.UpdateSettleOpenConfigOne(orgId, 2)
- }
- _, errcode := service.GetDrugOpenConfig(orgId)
- if errcode == gorm.ErrRecordNotFound {
- config := models.DrugOutConfig{
- UserOrgId: orgId,
- IsOpen: drug_out_open,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- service.CreateDrugOutConfig(config)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- } else if errcode == nil {
- service.UpdateDrugOutConfig(orgId, drug_out_open)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- }
- }
-
- func (this *GobalConfigApiController) ChangeSettleOpenConfig() {
-
- drug_out_open, _ := this.GetInt64("drug_settle_open")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- config := models.HisSettleStockConfig{
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- IsOpen: drug_out_open,
- }
-
- if drug_out_open == 1 {
- service.UpdateDrugOutConfig(orgId, 2)
- service.UpdateDrugStockAutomaticReduceRecordOne(orgId, 2)
- service.UpdatePharyConfig(orgId, 2)
- service.UpdateGoodAutoConfig(orgId)
- service.UpdateGoodOutConfig(orgId)
- }
- openConfig, errcode := service.GetSettleOpenConfig(orgId)
- if errcode == gorm.ErrRecordNotFound {
- service.CreateSettleOpenConfig(config)
- } else if errcode == nil {
- service.UpdateSettleOpenConfig(openConfig.ID, config)
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- }
-
- func (this *GobalConfigApiController) ChangeGoodOutOpen() {
-
- good_open, _ := this.GetInt64("good_open")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- config, errcode := service.GetGoodOutOpenConfig(orgId)
-
- outConfig := models.XtGoodOutConfig{
- UserOrgId: orgId,
- IsOpen: good_open,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- if good_open == 1 {
- service.UpdateGoodAutoConfig(orgId)
- service.UpdateSettleOpenConfigTwo(orgId, 2)
- }
-
- if errcode == gorm.ErrRecordNotFound {
- service.CreateGoodOutOpenConfig(outConfig)
- } else if errcode == nil {
- service.UpdateGoodOutOpenConfig(config.ID, outConfig)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": 1,
- })
- }
-
- func (this *GobalConfigApiController) ChangeSelfPrescriptionOpen() {
-
- is_open, _ := this.GetInt64("is_open")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- selfPrescriptionOpen, _ := service.GeteSelfPrescriptionOpen(orgId)
-
- config := models.XtSelfDrugInfoConfig{
- ID: selfPrescriptionOpen.ID,
- UserOrgId: orgId,
- Status: 1,
- IsOpen: is_open,
- }
-
- if selfPrescriptionOpen.ID == 0 {
- service.CreaterSelfConfig(config)
- }
-
- if selfPrescriptionOpen.ID > 0 {
- service.SaveSelfConfig(config)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "selfPrescriptionOpen": selfPrescriptionOpen,
- })
- }
-
- func (this *GobalConfigApiController) ChangeSelfPrescriptionOutOpen() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- is_open, _ := this.GetInt64("is_open")
-
- selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(orgId)
-
- config := models.XtSelfDrugOutConfig{
- ID: selfPrescriptionOutOpen.ID,
- UserOrgId: orgId,
- IsOpen: is_open,
- Status: 1,
- }
-
- if config.ID == 0 {
-
- service.CreateSelfDrugOutConfig(config)
- }
-
- if config.ID > 0 {
-
- service.UpdateSelfDrugOutConfig(config)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "selfPrescriptionOutOpen": selfPrescriptionOutOpen,
- })
- }
-
- func (this *GobalConfigApiController) GetSelfPrintList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- selfPrescriptionOpen, _ := service.GeteSelfPrescriptionOpen(orgId)
-
- selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "selfPrescriptionOpen": selfPrescriptionOpen,
- "selfPrescriptionOutOpen": selfPrescriptionOutOpen,
- })
- }
-
- func (this *GobalConfigApiController) ChangeDrugCodeOpen() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- is_open, _ := this.GetInt64("is_open")
- drugCodeOpen, _ := service.GetDrugCodeOpen(orgId)
-
- if drugCodeOpen.ID == 0 {
-
- codeOpen := models.XtDrugCodeOpen{
- UserOrgId: orgId,
- IsOpen: is_open,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- service.CreateDrugOpen(codeOpen)
- }
-
- if drugCodeOpen.ID == 1 {
-
- codeOpen := models.XtDrugCodeOpen{
- ID: drugCodeOpen.ID,
- UserOrgId: orgId,
- IsOpen: is_open,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
-
- service.SaveDrugOpen(codeOpen)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "drugCodeOpen": drugCodeOpen,
- })
- }
|