coordinate_controller.go 243KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281
  1. package coordinate
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "encoding/xml"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "io/ioutil"
  14. "math"
  15. "math/rand"
  16. "net/http"
  17. "sort"
  18. "strconv"
  19. "strings"
  20. "time"
  21. )
  22. type CoordinateController struct {
  23. controllers.BaseAuthAPIController
  24. }
  25. type ResultReg struct {
  26. ResultCode string `json:"resultCode"`
  27. ResultDesc string `json:"resultDesc"`
  28. InfoSeq string `json:"infoSeq"`
  29. }
  30. type ResultSettle struct {
  31. ResultCode string `json:"resultCode"`
  32. ResultDesc string `json:"resultDesc"`
  33. }
  34. type ResultCancelSettle struct {
  35. ResultCode string `json:"resultCode"`
  36. ResultDesc string `json:"resultDesc"`
  37. }
  38. type Settle struct {
  39. PatientId string `json:"resultCode"`
  40. DocId string `json:"docId"`
  41. InfoSeq string `json:"infoSeq"`
  42. }
  43. type Refund struct {
  44. PatientId string `json:"resultCode"`
  45. DocId string `json:"docId"`
  46. InfoSeq string `json:"infoSeq"`
  47. }
  48. type RefundDetail struct {
  49. Msg string `json:"msg"`
  50. Result []struct {
  51. ResultMsg string `json:"resultMsg"`
  52. Code string `json:"code"`
  53. Records int `json:"records"`
  54. TotalPage int `json:"totalPage"`
  55. List []struct {
  56. Zae01 int64 `json:"ZAE01"`
  57. } `json:"list"`
  58. RecordsTotal int `json:"recordsTotal"`
  59. Pagenumber int `json:"pagenumber"`
  60. Result string `json:"result"`
  61. Total int `json:"total"`
  62. RecordsFtered int `json:"recordsFtered"`
  63. Page int `json:"page"`
  64. } `json:"result"`
  65. Code string `json:"code"`
  66. }
  67. type RefundDetailtwo struct {
  68. Msg string `json:"msg"`
  69. Code string `json:"code"`
  70. }
  71. type ResultQuery struct {
  72. Msg string `json:"msg"`
  73. Result []struct {
  74. Type string `json:"type"`
  75. Name string `json:"name"`
  76. Vaa01 int `json:"vaa01"`
  77. Vaa07 int `json:"vaa07"`
  78. Visittime string `json:"visittime"`
  79. } `json:"result"`
  80. Code string `json:"code"`
  81. }
  82. type Data struct {
  83. List []ListItem `json:"resultObj"`
  84. Result bool `json:"result"`
  85. Code int `json:"code"`
  86. ResultMsg string `json:"resultMsg"`
  87. Msg string `json:"msg"`
  88. Error bool `json:"error"`
  89. Success bool `json:"success"`
  90. }
  91. type Data10 struct {
  92. List []ListItem10 `json:"resultObj"`
  93. Result bool `json:"result"`
  94. Code int `json:"code"`
  95. ResultMsg string `json:"resultMsg"`
  96. Msg string `json:"msg"`
  97. Error bool `json:"error"`
  98. Success bool `json:"success"`
  99. }
  100. type ListItem10 struct {
  101. Vaf01 int64 `json:"vaf01"`
  102. }
  103. type ListItem struct {
  104. Acf01 int64 `json:"acf01"`
  105. Bcq04 string `json:"bcq04"`
  106. Abw01 string `json:"abw01"`
  107. Aau01 string `json:"aau01"`
  108. Vaa08 string `json:"vaa08"`
  109. Vae11 string `json:"vae11"`
  110. Vaa05 string `json:"vaa05"`
  111. Vaa10 int `json:"vaa10"`
  112. Vaa01 int `json:"vaa01"`
  113. Vaa07 int `json:"vaa07"`
  114. Vaa12 string `json:"vaa12"`
  115. Abbrp string `json:"abbrp"`
  116. Bck01A int `json:"bck01a"`
  117. Bck01B int `json:"bck01b"`
  118. Vaa15 string `json:"vaa15"`
  119. Vaa35 string `json:"vaa35"`
  120. }
  121. type ResultUpload struct {
  122. Code string `json:"code"`
  123. Msg string `json:"msg"`
  124. Result []struct {
  125. List []interface{} `json:"list"`
  126. Page int64 `json:"page"`
  127. Pagenumber int64 `json:"pagenumber"`
  128. Records int64 `json:"records"`
  129. RecordsFiltered int64 `json:"recordsFiltered"`
  130. RecordsTotal int64 `json:"recordsTotal"`
  131. Result string `json:"result"`
  132. ResultMsg string `json:"resultMsg"`
  133. Total int64 `json:"total"`
  134. TotalPage int64 `json:"totalPage"`
  135. Userdata string `json:"userdata"`
  136. } `json:"result"`
  137. }
  138. type ResultUpload2 struct {
  139. Code int64 `json:"code"`
  140. Msg string `json:"msg"`
  141. resultObj interface{} `json:"resultObj"`
  142. }
  143. func CoordinateRcegistRouters() {
  144. //beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
  145. ////坐标挂号
  146. //beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
  147. ////坐标记账
  148. ////beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
  149. ////坐标撤销记账
  150. ////beego.Router("/coordinate/opCancelKeepAccounts", &CoordinateController{}, "get:OpCancelKeepAccounts")
  151. ////坐标结算回调
  152. //beego.Router("/coordinate/settle", &CoordinateController{}, "post:Settle")
  153. ////坐标退费回调
  154. //beego.Router("/coordinate/refund", &CoordinateController{}, "post:Refund")
  155. ////坐标患者查询~上传医嘱~结算功能
  156. ////beego.Router("/coordinate/settleAccount", &CoordinateController{}, "get:SettleAccount")
  157. //beego.Router("/coordinate/other", &CoordinateController{}, "get:NMGother")
  158. ////内蒙古
  159. beego.Router("/nmg/coordinate/settleAccount", &CoordinateController{}, "get:NMGSettleAccount")
  160. beego.Router("/nmg/coordinate/settleAccount/cancel", &CoordinateController{}, "get:NMGCancelSettleAccount")
  161. beego.Router("/nmg/coordinate/querystockdrug", &CoordinateController{}, "get:QuerydrugStock")
  162. beego.Router("/nmg/coordinate/querystockgood", &CoordinateController{}, "get:QuerygoodStock")
  163. //beego.Router("/nmg/coordinate/deladvice", &CoordinateController{}, "get:NMGdeladvice")
  164. //beego.Router("/nmg/coordinate/createadvice", &CoordinateController{}, "get:NMGcreateadvice")
  165. //beego.Router("/nmg/coordinate/querydiagnose", &CoordinateController{}, "get:NMGquerydiagnose")
  166. //beego.Router("/nmg/coordinate/querycheck", &CoordinateController{}, "get:NMGquerycheck")
  167. //beego.Router("/nmg/coordinate/settleAccountone", &CoordinateController{}, "get:NMGSettleAccount")
  168. }
  169. //func (c *CoordinateController) QueryStock(){
  170. // api3 := "http://192.168.100.199:9532/" + "nmg/coordinate/querystock"
  171. // resp3, requestErr3 := http.Get(api3)
  172. // if requestErr3 != nil {
  173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  174. // return
  175. // }
  176. // body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  177. // if ioErr3 != nil {
  178. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  180. // return
  181. // }
  182. // var respJSON3 map[string]interface{}
  183. // if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  184. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  186. // return
  187. // }
  188. //
  189. // //respJSON4 := respJSON3["data"].(map[string]interface{})["drug"].(map[string]interface{})
  190. // //userJSONBytes3, _ := json.Marshal(respJSON4)
  191. // //
  192. // //var drug Medicine
  193. // //err2 := json.Unmarshal(userJSONBytes3, &drug)
  194. // //if err2 != nil {
  195. // // fmt.Println("解析JSON出错:", err2)
  196. // // return
  197. // //}
  198. // //
  199. // //
  200. // //respJSON5 := respJSON3["data"].(map[string]interface{})["project"].(map[string]interface{})
  201. // //userJSONBytes4, _ := json.Marshal(respJSON5)
  202. // //
  203. // //var project ProjectStruct
  204. // //err := json.Unmarshal(userJSONBytes4, &project)
  205. // //if err != nil {
  206. // // fmt.Println("解析JSON出错:", err)
  207. // // return
  208. // //}
  209. // //
  210. // //c.ServeSuccessJSON(map[string]interface{}{
  211. // // "drug": drug.Data,
  212. // // "project": project.Data,
  213. // //})
  214. //
  215. //}
  216. func (c *CoordinateController) QuerydrugStock() {
  217. result, _ := service.GetDrugs()
  218. //result2, _ := service.GetProject()
  219. saveLog(result, "", "查询", "查询", "")
  220. //saveLog(result2, "", "查询", "查询", "")
  221. var drug Medicine
  222. err2 := json.Unmarshal([]byte(result), &drug)
  223. if err2 != nil {
  224. fmt.Println("解析JSON出错:", err2)
  225. return
  226. }
  227. c.ServeSuccessJSON(map[string]interface{}{
  228. "drug": drug.Data,
  229. })
  230. }
  231. func (c *CoordinateController) QuerygoodStock() {
  232. //result, _ := service.GetDrugs()
  233. result2, _ := service.GetProject()
  234. //saveLog(result, "", "查询", "查询", "")
  235. saveLog(result2, "", "查询", "查询", "")
  236. var project ProjectStruct
  237. err := json.Unmarshal([]byte(result2), &project)
  238. if err != nil {
  239. fmt.Println("解析JSON出错:", err)
  240. return
  241. }
  242. c.ServeSuccessJSON(map[string]interface{}{
  243. "project": project.Data,
  244. })
  245. }
  246. //查询检查
  247. func (c *CoordinateController) NMGquerycheck() {
  248. }
  249. type ResultObj struct {
  250. Cbm01 int `json:"cbm01"`
  251. Vaf01List []int `json:"vaf01List"`
  252. }
  253. type Response struct {
  254. ResultObj []ResultObj `json:"resultObj"`
  255. Result bool `json:"result"`
  256. Code int `json:"code"`
  257. ResultMsg string `json:"resultMsg"`
  258. Msg string `json:"msg"`
  259. Error bool `json:"error"`
  260. Success bool `json:"success"`
  261. }
  262. type Responsexml struct {
  263. XMLName xml.Name `xml:"root"`
  264. ErrorCode int `xml:"errorcode"`
  265. ErrorMsg string `xml:"errormsg"`
  266. Data string `xml:"data"`
  267. }
  268. func NMGzhuyuan(c *CoordinateController, name string) (res Data) {
  269. api3 := "http://127.0.0.1:9532/" + "nmg/coordinate/patient?name=" + name
  270. resp3, requestErr3 := http.Get(api3)
  271. if requestErr3 != nil {
  272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  273. return
  274. }
  275. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  276. if ioErr3 != nil {
  277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  279. return
  280. }
  281. var respJSON3 map[string]interface{}
  282. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  285. return
  286. }
  287. respJSON3 = respJSON3["data"].(map[string]interface{})["res"].(map[string]interface{})
  288. userJSONBytes3, _ := json.Marshal(respJSON3)
  289. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  290. utils.ErrorLog("解析失败:%v", err)
  291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  292. return
  293. }
  294. return res
  295. }
  296. func NMGmenzhen(c *CoordinateController, name string) (res Data) {
  297. api3 := "http://127.0.0.1:9532/" + "nmg/coordinate/patienttwo?name=" + name
  298. resp3, requestErr3 := http.Get(api3)
  299. if requestErr3 != nil {
  300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  301. return
  302. }
  303. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  304. if ioErr3 != nil {
  305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  307. return
  308. }
  309. var respJSON3 map[string]interface{}
  310. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  313. return
  314. }
  315. respJSON3 = respJSON3["data"].(map[string]interface{})["res"].(map[string]interface{})
  316. userJSONBytes3, _ := json.Marshal(respJSON3)
  317. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  318. utils.ErrorLog("解析失败:%v", err)
  319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  320. return
  321. }
  322. return res
  323. }
  324. func RemoveRepeatedPurviewElementdoctoradvice(arr []models.HisDoctorAdviceInfo) (newArr []models.HisDoctorAdviceInfo) {
  325. newArr = make([]models.HisDoctorAdviceInfo, 0)
  326. for i := 0; i < len(arr); i++ {
  327. repeat := false
  328. for j := i + 1; j < len(arr); j++ {
  329. if arr[i].Groupno == arr[j].Groupno && arr[i].PrescriptionId == arr[j].PrescriptionId {
  330. repeat = true
  331. break
  332. }
  333. }
  334. if !repeat {
  335. newArr = append(newArr, arr[i])
  336. }
  337. }
  338. return
  339. }
  340. func RemoveRepeatedPurviewElementproject(arr []models.HisPrescriptionProject) (newArr []models.HisPrescriptionProject) {
  341. newArr = make([]models.HisPrescriptionProject, 0)
  342. for i := 0; i < len(arr); i++ {
  343. repeat := false
  344. for j := i + 1; j < len(arr); j++ {
  345. if arr[i].HisProject.ZuobiaoId == arr[j].HisProject.ZuobiaoId && arr[i].HisProject.Bby01 == arr[j].HisProject.Bby01 {
  346. repeat = true
  347. break
  348. }
  349. }
  350. if !repeat {
  351. newArr = append(newArr, arr[i])
  352. }
  353. }
  354. return
  355. }
  356. func RemoveRepeatedPurviewElementgood(arr []models.HisPrescriptionProject) (newArr []models.HisPrescriptionProject) {
  357. newArr = make([]models.HisPrescriptionProject, 0)
  358. for i := 0; i < len(arr); i++ {
  359. repeat := false
  360. for j := i + 1; j < len(arr); j++ {
  361. if arr[i].GoodInfo.ZuobiaoId == arr[j].GoodInfo.ZuobiaoId && arr[i].GoodInfo.Bby01 == arr[j].GoodInfo.Bby01 {
  362. repeat = true
  363. break
  364. }
  365. }
  366. if !repeat {
  367. newArr = append(newArr, arr[i])
  368. }
  369. }
  370. return
  371. }
  372. func RemoveRepeatedPurviewElementdrug(arr []models.HisDoctorAdviceInfo) (newArr []models.HisDoctorAdviceInfo) {
  373. newArr = make([]models.HisDoctorAdviceInfo, 0)
  374. for i := 0; i < len(arr); i++ {
  375. repeat := false
  376. for j := i + 1; j < len(arr); j++ {
  377. if arr[i].BaseDrugLib.ZuobiaoId == arr[j].BaseDrugLib.ZuobiaoId && arr[i].BaseDrugLib.Bby01 == arr[j].BaseDrugLib.Bby01 && arr[i].DeliveryWay ==arr[j].DeliveryWay {
  378. repeat = true
  379. break
  380. }
  381. }
  382. if !repeat {
  383. newArr = append(newArr, arr[i])
  384. }
  385. }
  386. return
  387. }
  388. func RemoveRepeatedPurviewElementdrugtwo(arr []models.HisDoctorAdviceInfo) (newArr []models.HisDoctorAdviceInfo) {
  389. newArr = make([]models.HisDoctorAdviceInfo, 0)
  390. for i := 0; i < len(arr); i++ {
  391. repeat := false
  392. for j := i + 1; j < len(arr); j++ {
  393. if arr[i].Newfn == arr[j].Newfn{
  394. repeat = true
  395. break
  396. }
  397. }
  398. if !repeat {
  399. newArr = append(newArr, arr[i])
  400. }
  401. }
  402. return
  403. }
  404. //func (c *CoordinateController) NMGSettleAccounttwo() {
  405. // patient_id, _ := c.GetInt64("patient_id")
  406. // record_date := c.GetString("record_date")
  407. // admin_user_id, _ := c.GetInt64("admin_user_id")
  408. // diagnosis_id := c.GetString("diagnosis")
  409. // sick_type, _ := c.GetInt64("sick_type")
  410. // reg_type, _ := c.GetInt64("p_type")
  411. // org_id, _ := c.GetInt64("org_id")
  412. // org_id = 10206
  413. // org, _ := service.GetOrgById(org_id)
  414. // patient, _ := service.GetPatientByID(org.Id, patient_id)
  415. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  416. //
  417. // res := NMGzhuyuan(c, patient.Name)
  418. // res8 := NMGmenzhen(c, patient.Name)
  419. //
  420. // //优先查询今天门诊的患者,如果今天没有门诊的患者查询出住院的患者
  421. // if res8.Code == 200 {
  422. // var res9 Data
  423. // res9.List = append(res9.List, res8.List...)
  424. // var li ListItem
  425. // for _, item := range res9.List {
  426. // cure_date := strings.Split(item.Vae11, " ")
  427. // if cure_date[0] == record_date && patient.Name == item.Vaa05 {
  428. // li = item
  429. // }
  430. // }
  431. // if li.Acf01 == 0 && li.Vaa07 == 0 && li.Vaa01 == 0 { //今天没有门诊患者,则查询出最后一个日期的住院患者
  432. // var res10 Data
  433. // //res9.List = append(res9.List, res.List...)
  434. // res10.List = append(res10.List, res.List...)
  435. // layout := "2006-01-02 15:04:05"
  436. // var maxDate time.Time
  437. // for _, item := range res10.List {
  438. // currentDate, err := time.Parse(layout, item.Vae11)
  439. // if err != nil {
  440. // fmt.Println("Error parsing date:", err)
  441. // continue
  442. // }
  443. // if currentDate.After(maxDate) {
  444. // maxDate = currentDate
  445. // }
  446. // if !maxDate.IsZero() {
  447. // fmt.Println("The maximum date is:", maxDate.Format(layout))
  448. // } else {
  449. // fmt.Println("No valid dates found")
  450. // }
  451. // }
  452. // fmt.Println(maxDate.Format("2006-01-02 15:04:05"))
  453. // for _, item := range res10.List {
  454. // if item.Vae11 == maxDate.Format("2006-01-02 15:04:05") && patient.Name == item.Vaa05 {
  455. // li = item
  456. // }
  457. // }
  458. // }
  459. //
  460. // timeLayout := "2006-01-02"
  461. // loc, _ := time.LoadLocation("Local")
  462. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  463. // if err != nil {
  464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  465. // return
  466. // }
  467. // org_id := org.Id
  468. // recordDateTime := theTime.Unix()
  469. // patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  470. // if patientPrescription.ID == 0 {
  471. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  472. // }
  473. // departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  474. // //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  475. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  476. //
  477. // var recordStartTime int64
  478. // var recordEndTime int64
  479. //
  480. // var prescriptions []models.HisPrescription
  481. // if settle_accounts_type == 1 { //日结
  482. // prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, patient_id, recordDateTime, 2)
  483. // } else { //月结
  484. // start_time_str := c.GetString("start_time")
  485. // end_time_str := c.GetString("end_time")
  486. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  487. // if err != nil {
  488. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  489. // return
  490. // }
  491. // recordStartTime = theStartTime.Unix()
  492. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  493. // if err != nil {
  494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  495. // return
  496. // }
  497. // recordEndTime = theEndTime.Unix()
  498. //
  499. // prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime)
  500. // }
  501. //
  502. // var ids []int64
  503. //
  504. // for _, item := range prescriptions {
  505. // ids = append(ids, item.ID)
  506. // }
  507. // var total float64
  508. //
  509. // var customs []*models.NewCustomTwo
  510. // for _, item := range prescriptions {
  511. // if item.Type == 1 { //药品
  512. // for _, subItem := range item.HisDoctorAdviceInfo {
  513. // tempTime := time.Unix(item.PreTime, 0)
  514. // //timeFormat := tempTime.Format("20060102150405")
  515. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  516. // cus := &models.NewCustomTwo{
  517. // AdviceId: subItem.ID,
  518. // ProjectId: 0,
  519. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  520. // Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  521. // FeedetlSn: subItem.FeedetlSn,
  522. // Price: fmt.Sprintf("%.2f", subItem.Price),
  523. // MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  524. // Type: 1,
  525. // ItemId: subItem.BaseDrugLib.ZuobiaoId,
  526. // StartTime: timeFormatOne,
  527. // Content: subItem.AdviceName,
  528. // Bby01: subItem.BaseDrugLib.Bby01,
  529. // }
  530. // customs = append(customs, cus)
  531. // }
  532. // }
  533. // if item.Type == 2 { //项目
  534. // for _, subItem := range item.HisPrescriptionProject {
  535. // if subItem.Type == 2 {
  536. // tempTime := time.Unix(item.PreTime, 0)
  537. // //timeFormat := tempTime.Format("20060102150405")
  538. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  539. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  540. // cus := &models.NewCustomTwo{
  541. // AdviceId: 0,
  542. // ProjectId: subItem.ID,
  543. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  544. // Cut: fmt.Sprintf("%.4f", cnt),
  545. // FeedetlSn: subItem.FeedetlSn,
  546. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  547. // MedListCodg: subItem.HisProject.MedicalCode,
  548. // Type: 2,
  549. // ItemId: subItem.HisProject.ZuobiaoId,
  550. // StartTime: timeFormatOne,
  551. // Content: subItem.HisProject.ProjectName,
  552. // Bby01: subItem.HisProject.Bby01,
  553. // }
  554. // customs = append(customs, cus)
  555. //
  556. // } else {
  557. // tempTime := time.Unix(item.PreTime, 0)
  558. // //timeFormat := tempTime.Format("20060102150405")
  559. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  560. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  561. // cus := &models.NewCustomTwo{
  562. // AdviceId: 0,
  563. // ProjectId: subItem.ID,
  564. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  565. // Cut: fmt.Sprintf("%.4f", cnt),
  566. // FeedetlSn: subItem.FeedetlSn,
  567. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  568. // MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  569. // Type: 3,
  570. // ItemId: subItem.GoodInfo.ZuobiaoId,
  571. // StartTime: timeFormatOne,
  572. // Content: subItem.GoodInfo.GoodName,
  573. // Bby01: subItem.GoodInfo.Bby01,
  574. // }
  575. // customs = append(customs, cus)
  576. // }
  577. //
  578. // }
  579. // }
  580. // }
  581. //
  582. // for _, item := range prescriptions {
  583. // if item.Type == 1 { //药品
  584. // for _, subItem := range item.HisDoctorAdviceInfo {
  585. // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  586. // total_one := price * subItem.PrescribingNumber
  587. //
  588. // total = total + total_one
  589. //
  590. //
  591. // }
  592. // }
  593. // if item.Type == 2 { //项目
  594. //
  595. // for _, subItem := range item.HisPrescriptionProject {
  596. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  597. // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  598. // total_one := price * cnt
  599. // total = total + total_one
  600. // }
  601. // }
  602. // }
  603. //
  604. // //allTotal := fmt.Sprintf("%2f", total)
  605. //
  606. // var info models.UploadInfo
  607. // info.Acf01 = int64(li.Acf01)
  608. // info.Bce01 = "132"
  609. // info.Bck01 = "48"
  610. // info.Vaa07 = int64(li.Vaa07)
  611. // info.Vaa01 = int64(li.Vaa01)
  612. // info.Vaa05 = li.Vaa05
  613. // info.Bce01a = doctor_info.DoctorNumber
  614. //
  615. // for _, item := range customs {
  616. // var cha models.ChargeListtwo
  617. // cnt, _ := strconv.ParseFloat(item.Cut, 64)
  618. //
  619. // Bby01, _ := strconv.ParseInt(item.Bby01, 10, 64)
  620. //
  621. // cha.Bby01 = Bby01
  622. // cha.Vaj25 = cnt
  623. // info.ChargeListtwo = append(info.ChargeListtwo, &cha)
  624. // }
  625. //
  626. // var root models.Root
  627. // var tradeInfo models.TradeInfo
  628. // var cBM1 models.CBM1
  629. // var vAF1 models.VAF1
  630. // var vAO1 models.VAO1
  631. // var vBQ1 models.VBQ1
  632. //
  633. // if li.Acf01 == 1 {
  634. // tradeInfo.PatSource = 1
  635. // tradeInfo.Type = 0
  636. // } else {
  637. // tradeInfo.PatSource = 2
  638. // tradeInfo.Type = 1
  639. //
  640. // }
  641. // tradeInfo.Detpid = departmwnt.Number
  642. // tradeInfo.Empid = doctor_info.DoctorNumber
  643. // tradeInfo.Empno = doctor_info.DoctorCode
  644. // tradeInfo.Empname = doctor_info.UserName
  645. // root.TradeInfo = tradeInfo
  646. //
  647. // //
  648. // //
  649. // //var del_ids []string
  650. // //
  651. // //
  652. // ////信息
  653. // for _, item := range prescriptions {
  654. // departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  655. // var ie_cbm1 models.IEone
  656. // ie_cbm1.CBMID = strconv.FormatInt(item.ID, 10)
  657. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  658. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  659. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  660. // //ie_cbm1.CBM06 = strconv.FormatInt(int64(res.List[0].Acf01), 10)
  661. //
  662. // if li.Acf01 == 1 {
  663. // ie_cbm1.CBM06 = item.MedType
  664. // ie_cbm1.BCK01A = "0"
  665. // } else {
  666. // ie_cbm1.CBM06 = "0"
  667. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10) //病区id
  668. // }
  669. // ie_cbm1.CBM07 = item.MedType
  670. // ie_cbm1.BCK01B = strconv.FormatInt(int64(li.Bck01B), 10)
  671. // ie_cbm1.BCK01C = departmwnt_two.Number
  672. // ie_cbm1.CBM19 = "0"
  673. // cBM1.Ie = append(cBM1.Ie, ie_cbm1)
  674. // }
  675. // root.CBM1 = cBM1
  676. // ////医嘱
  677. // for _, item := range prescriptions {
  678. // departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  679. //
  680. // if item.Type == 1 {
  681. // //组号去重
  682. // //temphisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  683. //
  684. // // 使用 map 来存储 groupno 的数量
  685. // //groupCount := make(map[int64]int64)
  686. //
  687. // // 使用 map 来存储 groupno 的数量和最后一条数据的索引
  688. // groupInfo := make(map[int64]struct {
  689. // Count int64
  690. // LastElement int
  691. // })
  692. //
  693. // // 遍历切片,计算 groupno 的数量和最后一条数据的索引
  694. // for i, obj := range item.HisDoctorAdviceInfo {
  695. // info, ok := groupInfo[obj.Groupno]
  696. // if !ok {
  697. // info = struct {
  698. // Count int64
  699. // LastElement int
  700. // }{}
  701. // }
  702. // info.Count++
  703. // info.LastElement = i
  704. // groupInfo[obj.Groupno] = info
  705. // }
  706. //
  707. // // 根据 groupno 的数量设置字段值
  708. // for i, obj := range item.HisDoctorAdviceInfo {
  709. // info := groupInfo[obj.Groupno]
  710. // if info.Count < 2 {
  711. // item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  712. // } else {
  713. // // 对于数量大于等于 2 的,将最后一条数据设置 1,其他设置为随机数
  714. // if i == info.LastElement {
  715. // item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  716. // } else {
  717. // item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(obj.ID, 10)
  718. // }
  719. // }
  720. // }
  721. //
  722. // for _, subitem := range item.HisDoctorAdviceInfo {
  723. // var ie_cbm1 models.IEtwo
  724. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  725. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  726. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  727. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  728. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  729. // ie_cbm1.ROWNR = subitem.NewGroupno
  730. // ie_cbm1.VAF10 = "1"
  731. // ie_cbm1.VAF11 = "2"
  732. // ie_cbm1.BDA01 = "1" //诊疗类型
  733. // ie_cbm1.BBX01 = subitem.BaseDrugLib.ZuobiaoId
  734. // ie_cbm1.VAF14 = "" //检验样本类型
  735. // ie_cbm1.VAF15 = ""
  736. // ie_cbm1.BBY01 = subitem.BaseDrugLib.Bby01 //药品规格id或材料规格id
  737. //
  738. // if li.Acf01 == 1 {
  739. // ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10)
  740. //
  741. // } else {
  742. // ie_cbm1.VAF17 = "0"
  743. //
  744. // }
  745. //
  746. // ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  747. // ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  748. // ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  749. // ie_cbm1.VAF21 = fmt.Sprintf("%.2f", subitem.PrescribingNumber)
  750. //
  751. // ie_cbm1.VAF22 = subitem.AdviceName + " " + subitem.BaseDrugLib.DrugSpec
  752. // ie_cbm1.Crypt = "0"
  753. // ie_cbm1.VAF23 = ""
  754. // ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  755. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  756. // ie_cbm1.VAF27 = "1"
  757. // ie_cbm1.VAF28 = "1"
  758. // ie_cbm1.VAF29 = "1"
  759. //
  760. // ie_cbm1.VAF30 = ""
  761. // ie_cbm1.VAF31 = "0"
  762. //
  763. // ie_cbm1.VAF32 = "0" //todo
  764. // ie_cbm1.VAF33 = "0"
  765. // ie_cbm1.VAF34 = "0"
  766. // ie_cbm1.VAF35 = "0"
  767. //
  768. // tempTime1 := time.Unix(subitem.StartTime, 0)
  769. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  770. // ie_cbm1.VAF36 = timeFormatOne
  771. // ie_cbm1.VAF37 = "1899-12-30"
  772. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  773. // ie_cbm1.BCK01C = departmwnt_two.Number
  774. //
  775. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  776. // ie_cbm1.BCE03A = doctor_info.UserName
  777. // ie_cbm1.BCE03B = ""
  778. //
  779. // ie_cbm1.VAF53 = "-1"
  780. // ie_cbm1.VAF55 = subitem.Remark
  781. // ie_cbm1.BCK01D = departmwnt_two.Number
  782. // ie_cbm1.VAF58 = "0"
  783. // ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno), 10)
  784. // ie_cbm1.VAF60 = ""
  785. // ie_cbm1.VAF61 = "1"
  786. // ie_cbm1.VAF62 = "0"
  787. // ie_cbm1.LSign = "0"
  788. // ie_cbm1.BDA01A = ie_cbm1.BDA01
  789. // ie_cbm1.LRoute = "0"
  790. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  791. // ie_cbm1.BCE01B = "0"
  792. //
  793. // ie_cbm1.VAF01B = "0"
  794. // ie_cbm1.VCO01 = "0"
  795. // ie_cbm1.BCE01H = "0"
  796. // ie_cbm1.BCE03H = ""
  797. // ie_cbm1.BIW02 = ""
  798. // ie_cbm1.RCurrent = "0"
  799. // ie_cbm1.FCheck = "0"
  800. // ie_cbm1.UnameA = ""
  801. // ie_cbm1.VEH02 = ""
  802. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  803. // }
  804. //
  805. // //hisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  806. //
  807. // //每种药品下的给药途径
  808. // for _, subitem := range item.HisDoctorAdviceInfo {
  809. // //saveLog("", result, "1111", "way", "")
  810. //
  811. // result2 := fmt.Sprintf("%+v", subitem)
  812. // fmt.Println(result2)
  813. //
  814. //
  815. // way, _ := service.GetDrugwayDicByName(subitem.DeliveryWay, c.GetAdminUserInfo().CurrentOrgId)
  816. // result := fmt.Sprintf("%+v", way)
  817. // saveLog("", result, "1111", "way", "")
  818. // var ie_cbm1 models.IEtwo
  819. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  820. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  821. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  822. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  823. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  824. // ie_cbm1.ROWNR = "0"
  825. // ie_cbm1.VAF10 = "1"
  826. // ie_cbm1.VAF11 = "2"
  827. // ie_cbm1.BDA01 = "T" //诊疗类型
  828. // ie_cbm1.BBX01 = way.Code
  829. // ie_cbm1.VAF14 = "" //检验样本类型
  830. // ie_cbm1.VAF15 = "" //检验样本类型
  831. // ie_cbm1.BBY01 = way.Bby01 //药品规格id或材料规格id
  832. // if li.Acf01 == 1 {
  833. // ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10) //药品规格id或材料规格id
  834. // } else {
  835. // ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
  836. // }
  837. //
  838. // ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  839. // ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  840. // ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  841. // //ie_cbm1.VAF21 = fmt.Sprintf("%.2f",subitem.PrescribingNumber)
  842. //
  843. // //ie_cbm1.VAF18 = "" //药品规格id或材料规格id
  844. // //ie_cbm1.VAF19 = ""
  845. // //ie_cbm1.VAF20 = ""
  846. // if subitem.DrugWayCount == "" {
  847. // ie_cbm1.VAF21 = "1"
  848. //
  849. // } else {
  850. // ie_cbm1.VAF21 = subitem.DrugWayCount
  851. //
  852. // }
  853. //
  854. // ie_cbm1.VAF22 = way.Name
  855. // ie_cbm1.Crypt = "0"
  856. // ie_cbm1.VAF23 = ""
  857. // ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  858. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  859. // ie_cbm1.VAF27 = "1"
  860. // ie_cbm1.VAF28 = "1"
  861. // ie_cbm1.VAF29 = "1"
  862. // ie_cbm1.BCK01C = departmwnt_two.Number
  863. //
  864. // ie_cbm1.VAF30 = ""
  865. // ie_cbm1.VAF31 = "0"
  866. //
  867. // ie_cbm1.VAF32 = "1" //todo
  868. // ie_cbm1.VAF33 = "0"
  869. // ie_cbm1.VAF34 = "0"
  870. // ie_cbm1.VAF35 = "0"
  871. //
  872. // tempTime1 := time.Unix(subitem.StartTime, 0)
  873. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  874. // ie_cbm1.VAF36 = timeFormatOne
  875. // ie_cbm1.VAF37 = "1899-12-30"
  876. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  877. //
  878. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  879. // ie_cbm1.BCE03A = doctor_info.UserName
  880. // ie_cbm1.BCE03B = ""
  881. //
  882. // ie_cbm1.VAF53 = "-1"
  883. // ie_cbm1.VAF55 = subitem.Remark
  884. // ie_cbm1.BCK01D = departmwnt_two.Number
  885. // ie_cbm1.VAF58 = "0"
  886. // ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno), 10)
  887. //
  888. // ie_cbm1.VAF60 = ""
  889. // ie_cbm1.VAF61 = "1"
  890. // ie_cbm1.VAF62 = "0"
  891. // ie_cbm1.LSign = "0"
  892. // ie_cbm1.BDA01A = ie_cbm1.BDA01
  893. // ie_cbm1.LRoute = "0"
  894. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  895. // ie_cbm1.BCE01B = "0"
  896. //
  897. // ie_cbm1.VAF01B = "0"
  898. // ie_cbm1.VCO01 = "0"
  899. // ie_cbm1.BCE01H = "0"
  900. // ie_cbm1.BCE03H = ""
  901. // ie_cbm1.BIW02 = ""
  902. // ie_cbm1.RCurrent = "0"
  903. // ie_cbm1.FCheck = "0"
  904. // ie_cbm1.UnameA = ""
  905. // ie_cbm1.VEH02 = ""
  906. // ie_cbm1.VAF07 = "0"
  907. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  908. // }
  909. //
  910. // } else if item.Type == 2 {
  911. // for index, subitem := range item.HisPrescriptionProject {
  912. // if subitem.Type == 2 {
  913. // if subitem.HisProject.CostClassify != 3 {
  914. // var ie_cbm1 models.IEtwo
  915. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  916. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  917. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  918. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  919. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  920. // ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  921. // ie_cbm1.VAF10 = "1"
  922. // ie_cbm1.VAF11 = "2"
  923. // ie_cbm1.BDA01 = "T" //诊疗类型
  924. // ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  925. // ie_cbm1.VAF14 = "" //检验样本类型
  926. // ie_cbm1.VAF15 = "" //检验样本类型
  927. // ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  928. // if li.Acf01 == 1 {
  929. // ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  930. // if len(subitem.Day) == 0 {
  931. // ie_cbm1.VAF17 = "1"
  932. // }
  933. //
  934. // } else {
  935. // ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  936. // }
  937. // if subitem.SingleDose == "" {
  938. //
  939. // subitem.SingleDose = "1"
  940. // }
  941. //
  942. // ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  943. // ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  944. // ie_cbm1.VAF20 = subitem.SingleDose
  945. // ie_cbm1.VAF21 = subitem.Count
  946. //
  947. // ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  948. // ie_cbm1.Crypt = "0"
  949. // ie_cbm1.VAF23 = ""
  950. // ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  951. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  952. // ie_cbm1.VAF27 = "1"
  953. // ie_cbm1.VAF28 = "1"
  954. // ie_cbm1.VAF29 = ""
  955. // ie_cbm1.BCK01C = departmwnt_two.Number
  956. //
  957. // ie_cbm1.VAF30 = ""
  958. // ie_cbm1.VAF31 = "0"
  959. //
  960. // ie_cbm1.VAF32 = "0" //todo
  961. // ie_cbm1.VAF33 = "0"
  962. // ie_cbm1.VAF34 = "0"
  963. // ie_cbm1.VAF35 = "0"
  964. //
  965. // tempTime1 := time.Unix(subitem.StartTime, 0)
  966. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  967. // ie_cbm1.VAF36 = timeFormatOne
  968. // ie_cbm1.VAF37 = "1899-12-30"
  969. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  970. //
  971. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  972. // ie_cbm1.BCE03A = doctor_info.UserName
  973. // ie_cbm1.BCE03B = ""
  974. //
  975. // ie_cbm1.VAF53 = "-1"
  976. // ie_cbm1.VAF55 = subitem.Remark
  977. // ie_cbm1.BCK01D = departmwnt_two.Number
  978. // ie_cbm1.VAF58 = "0"
  979. // ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  980. //
  981. // ie_cbm1.VAF60 = ""
  982. // ie_cbm1.VAF61 = "1"
  983. // ie_cbm1.VAF62 = "0"
  984. // ie_cbm1.LSign = "0"
  985. // ie_cbm1.BDA01A = "" //诊疗类型
  986. // ie_cbm1.LRoute = "0"
  987. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  988. //
  989. // //ie_cbm1.BCE01A = doctor_info.UserName
  990. // ie_cbm1.BCE01B = "0"
  991. //
  992. // ie_cbm1.VAF01B = "0"
  993. // ie_cbm1.VCO01 = "0"
  994. // ie_cbm1.BCE01H = "0"
  995. // ie_cbm1.BCE03H = ""
  996. // ie_cbm1.BIW02 = ""
  997. // ie_cbm1.RCurrent = "0"
  998. // ie_cbm1.FCheck = "0"
  999. // ie_cbm1.UnameA = ""
  1000. // ie_cbm1.VAF07 = "0"
  1001. //
  1002. // ie_cbm1.VEH02 = ""
  1003. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  1004. // }
  1005. // if subitem.HisProject.CostClassify == 3 {
  1006. // var ie_cbm1 models.IEtwo
  1007. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  1008. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  1009. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  1010. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  1011. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  1012. // ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  1013. // ie_cbm1.VAF10 = "1"
  1014. // ie_cbm1.VAF11 = "2"
  1015. // ie_cbm1.BDA01 = "L" //诊疗类型
  1016. // ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  1017. // ie_cbm1.VAF14 = "" //检验样本类型
  1018. // ie_cbm1.VAF15 = "" //检验样本类型
  1019. // ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  1020. // if li.Acf01 == 1 {
  1021. // ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  1022. // } else {
  1023. // ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  1024. // }
  1025. // if subitem.SingleDose == "" {
  1026. //
  1027. // subitem.SingleDose = "1"
  1028. // }
  1029. //
  1030. // ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  1031. // ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  1032. // ie_cbm1.VAF20 = subitem.SingleDose
  1033. // ie_cbm1.VAF21 = subitem.Count
  1034. //
  1035. // ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  1036. // ie_cbm1.Crypt = "0"
  1037. // ie_cbm1.VAF23 = ""
  1038. // ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  1039. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  1040. // ie_cbm1.VAF27 = "1"
  1041. // ie_cbm1.VAF28 = "1"
  1042. // ie_cbm1.VAF29 = ""
  1043. // ie_cbm1.BCK01C = departmwnt_two.Number
  1044. // ie_cbm1.VAF30 = ""
  1045. // ie_cbm1.VAF31 = "0"
  1046. // ie_cbm1.VAF32 = "0" //todo
  1047. // ie_cbm1.VAF33 = "0"
  1048. // ie_cbm1.VAF34 = "0"
  1049. // ie_cbm1.VAF35 = "0"
  1050. // tempTime1 := time.Unix(subitem.StartTime, 0)
  1051. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  1052. // ie_cbm1.VAF36 = timeFormatOne
  1053. // ie_cbm1.VAF37 = "1899-12-30"
  1054. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  1055. //
  1056. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  1057. // ie_cbm1.BCE03A = doctor_info.UserName
  1058. // ie_cbm1.BCE03B = ""
  1059. //
  1060. // ie_cbm1.VAF53 = "-1"
  1061. // ie_cbm1.VAF55 = subitem.Remark
  1062. // ie_cbm1.BCK01D = departmwnt_two.Number
  1063. // ie_cbm1.VAF58 = "0"
  1064. // ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  1065. //
  1066. // ie_cbm1.VAF60 = ""
  1067. // ie_cbm1.VAF61 = "1"
  1068. // ie_cbm1.VAF62 = "0"
  1069. // ie_cbm1.LSign = "0"
  1070. // ie_cbm1.BDA01A = "" //诊疗类型
  1071. // ie_cbm1.LRoute = "0"
  1072. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  1073. // ie_cbm1.VAF07 = "0"
  1074. //
  1075. // //ie_cbm1.BCE01A = doctor_info.UserName
  1076. // ie_cbm1.BCE01B = "0"
  1077. //
  1078. // ie_cbm1.VAF01B = "0"
  1079. // ie_cbm1.VCO01 = "0"
  1080. // ie_cbm1.BCE01H = "0"
  1081. // ie_cbm1.BCE03H = ""
  1082. // ie_cbm1.BIW02 = ""
  1083. // ie_cbm1.RCurrent = "0"
  1084. // ie_cbm1.FCheck = "0"
  1085. // ie_cbm1.UnameA = ""
  1086. // ie_cbm1.VEH02 = ""
  1087. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  1088. // }
  1089. //
  1090. // } else if subitem.Type == 3 {
  1091. // var ie_cbm1 models.IEtwo
  1092. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  1093. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  1094. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  1095. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  1096. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  1097. // ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  1098. //
  1099. // ie_cbm1.VAF10 = "1"
  1100. // ie_cbm1.VAF11 = "2"
  1101. // ie_cbm1.BDA01 = "4" //诊疗类型
  1102. // ie_cbm1.BBX01 = subitem.GoodInfo.ZuobiaoId
  1103. // ie_cbm1.VAF14 = "" //检验样本类型
  1104. // ie_cbm1.VAF15 = "" //检验样本类型
  1105. // ie_cbm1.BBY01 = subitem.GoodInfo.Bby01 //药品规格id或材料规格id
  1106. //
  1107. // if li.Acf01 == 1 {
  1108. // ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  1109. //
  1110. // } else {
  1111. // ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
  1112. //
  1113. // }
  1114. // if subitem.SingleDose == "" {
  1115. // subitem.SingleDose = "1"
  1116. // }
  1117. //
  1118. // ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  1119. // ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  1120. // ie_cbm1.VAF20 = subitem.SingleDose
  1121. // ie_cbm1.VAF21 = subitem.Count
  1122. // ie_cbm1.BCK01C = departmwnt_two.Number
  1123. //
  1124. // ie_cbm1.VAF22 = subitem.GoodInfo.GoodName + " " + subitem.GoodInfo.SpecificationName
  1125. // ie_cbm1.Crypt = "0"
  1126. // ie_cbm1.VAF23 = ""
  1127. // ie_cbm1.BCK01B = subitem.GoodInfo.Bck01b
  1128. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  1129. // ie_cbm1.VAF27 = ""
  1130. // ie_cbm1.VAF28 = "1"
  1131. // ie_cbm1.VAF29 = ""
  1132. // ie_cbm1.VAF07 = "0"
  1133. //
  1134. // ie_cbm1.VAF30 = ""
  1135. // ie_cbm1.VAF31 = "0"
  1136. //
  1137. // ie_cbm1.VAF32 = "0" //todo
  1138. // ie_cbm1.VAF33 = "0"
  1139. // ie_cbm1.VAF34 = "0"
  1140. // ie_cbm1.VAF35 = "0"
  1141. //
  1142. // tempTime1 := time.Unix(subitem.StartTime, 0)
  1143. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  1144. // ie_cbm1.VAF36 = timeFormatOne
  1145. // ie_cbm1.VAF37 = "1899-12-30"
  1146. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  1147. //
  1148. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  1149. // ie_cbm1.BCE03A = doctor_info.UserName
  1150. // ie_cbm1.BCE03B = ""
  1151. // ie_cbm1.BCK01C = departmwnt_two.Number
  1152. //
  1153. // ie_cbm1.VAF53 = "-1"
  1154. // ie_cbm1.VAF55 = subitem.Remark
  1155. // ie_cbm1.BCK01D = departmwnt_two.Number
  1156. // ie_cbm1.VAF58 = "0"
  1157. // ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  1158. // ie_cbm1.VAF60 = ""
  1159. // ie_cbm1.VAF61 = "1"
  1160. // ie_cbm1.VAF62 = "0"
  1161. // ie_cbm1.LSign = "0"
  1162. // ie_cbm1.BDA01A = "" //诊疗类型
  1163. // ie_cbm1.LRoute = "0"
  1164. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  1165. // ie_cbm1.BCE01B = "0"
  1166. // ie_cbm1.VAF01B = "0"
  1167. // ie_cbm1.VCO01 = "0"
  1168. // ie_cbm1.BCE01H = "0"
  1169. // ie_cbm1.BCE03H = ""
  1170. // ie_cbm1.BIW02 = ""
  1171. // ie_cbm1.RCurrent = "0"
  1172. // ie_cbm1.FCheck = "0"
  1173. // ie_cbm1.UnameA = ""
  1174. // ie_cbm1.VEH02 = ""
  1175. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  1176. // }
  1177. // }
  1178. // }
  1179. //
  1180. // }
  1181. // root.VAF1 = vAF1
  1182. // for _, item := range prescriptions {
  1183. // sick, _ := service.FindSickById(sick_type)
  1184. //
  1185. // dias := strings.Split(item.VMHisPrescriptionInfo.Diagnosis, ",")
  1186. // //service.get
  1187. //
  1188. // //诊断
  1189. // for index, subitem := range dias {
  1190. // diagnosisConfig, _ := service.FindDiagnoseByIdtwo(subitem)
  1191. // if index == 0 {
  1192. // var ie_cbm1 models.IEthree
  1193. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  1194. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  1195. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  1196. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  1197. // ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  1198. // ie_cbm1.VAO07 = "1"
  1199. // ie_cbm1.VAO10 = "0"
  1200. // ie_cbm1.VAO11 = "1"
  1201. // ie_cbm1.BAK01A = sick.ContentCode
  1202. // ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  1203. // ie_cbm1.VAO15 = diagnosisConfig.ClassName
  1204. // ie_cbm1.VAO18 = "0"
  1205. // ie_cbm1.VAO22 = "1"
  1206. // ie_cbm1.IAA01 = ""
  1207. // ie_cbm1.IAD03 = ""
  1208. // ie_cbm1.BAK01B = ""
  1209. // ie_cbm1.VAO26 = ""
  1210. // ie_cbm1.IAD04 = ""
  1211. // ie_cbm1.IAD01 = ""
  1212. // ie_cbm1.VAO25 = "1"
  1213. // ie_cbm1.VAO35 = ""
  1214. // vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  1215. //
  1216. // } else {
  1217. // var ie_cbm1 models.IEthree
  1218. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  1219. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  1220. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  1221. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  1222. // ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  1223. // ie_cbm1.VAO07 = "1"
  1224. // ie_cbm1.VAO10 = "0"
  1225. // ie_cbm1.VAO11 = "1"
  1226. // ie_cbm1.BAK01A = sick.ContentCode
  1227. // ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  1228. // ie_cbm1.VAO15 = diagnosisConfig.ClassName
  1229. // ie_cbm1.VAO18 = "0"
  1230. // ie_cbm1.VAO22 = "1"
  1231. // ie_cbm1.IAA01 = ""
  1232. // ie_cbm1.IAD03 = ""
  1233. // ie_cbm1.BAK01B = ""
  1234. // ie_cbm1.VAO26 = ""
  1235. // ie_cbm1.IAD04 = ""
  1236. // ie_cbm1.IAD01 = ""
  1237. // ie_cbm1.VAO25 = "2"
  1238. // ie_cbm1.VAO35 = ""
  1239. // vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  1240. // }
  1241. // }
  1242. // }
  1243. // ////
  1244. // //////检验检查医嘱
  1245. // //for _, item := range prescriptions{
  1246. // // fmt.Println("6666666666666")
  1247. // // if item.Type == 2{
  1248. // // for _, subitem := range item.HisPrescriptionProject {
  1249. // // if subitem.Type == 2{
  1250. // // if subitem.HisProject.CostClassify == 3 {
  1251. // // var ie_cbm1 models.IEfour
  1252. // // ie_cbm1.VBQ01 = strconv.FormatInt(int64(item.ID), 10)
  1253. // // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  1254. // // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  1255. // // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  1256. // // ie_cbm1.VAP01 = "0"
  1257. // // ie_cbm1.VBQ07 = "0"
  1258. // // ie_cbm1.BCK01A = departmwnt.Number
  1259. // // ie_cbm1.BCK01B= "0"
  1260. // // ie_cbm1.BCE03A= ""
  1261. // // ie_cbm1.BCE01A= "0"
  1262. // // ie_cbm1.VBQ27= subitem.HisProject.ProjectName
  1263. // // ie_cbm1.VBQ28= patientPrescription.Diagnosis
  1264. // // ie_cbm1.VBQ29= ""
  1265. // // ie_cbm1.VBQ30= ""
  1266. // // vBQ1.Ie = append(vBQ1.Ie, ie_cbm1)
  1267. // // }
  1268. // //
  1269. // // }
  1270. // //
  1271. // // }
  1272. // // }
  1273. // //}
  1274. //
  1275. // root.VAO1 = vAO1
  1276. // root.VBQ1 = vBQ1
  1277. //
  1278. // //zuobiao, _ := service.Getzuobiao(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1279. //
  1280. // //is_success := true
  1281. // //failed_mag := ""
  1282. // //查询出对应的坐标系统医嘱id,先进行删除操作,在创建医嘱。如果没有医嘱id,则直接创建医嘱
  1283. // //if zuobiao.ID > 0 {
  1284. // // cbm01s := strings.Split(zuobiao.Cbm01, ",")
  1285. // // fmt.Println(cbm01s)
  1286. // //
  1287. // // for _, iditem := range cbm01s {
  1288. // // fmt.Println(iditem)
  1289. // // var root2 models.Root2
  1290. // // var tradeInfo2 models.TradeInfo
  1291. // // if li.Acf01 == 1 {
  1292. // // tradeInfo2.PatSource = 1
  1293. // // tradeInfo2.Type = 0
  1294. // // } else {
  1295. // // tradeInfo2.PatSource = 2
  1296. // // tradeInfo2.Type = 1
  1297. // //
  1298. // // }
  1299. // // tradeInfo2.Detpid = departmwnt.Number
  1300. // // tradeInfo2.Empid = doctor_info.DoctorNumber
  1301. // // tradeInfo2.Empno = doctor_info.DoctorCode
  1302. // // tradeInfo2.Empname = doctor_info.UserName
  1303. // // var vaf01 models.VAF10
  1304. // // var ie1111 models.IEfive
  1305. // // ie1111.VAF01 = iditem
  1306. // // vaf01.Ie = append(vaf01.Ie, ie1111)
  1307. // // root2.TradeInfo = tradeInfo2
  1308. // // root2.VAF1 = vaf01
  1309. // // xmlStr2, err := xml.MarshalIndent(root2, "", " ")
  1310. // // if err != nil {
  1311. // // fmt.Println("转换为XML时发生错误:", err)
  1312. // // return
  1313. // // }
  1314. // // data := make(map[string]interface{})
  1315. // // data["xmlStr"] = string(xmlStr2)
  1316. // // bytesData, _ := json.Marshal(data)
  1317. // // client := &http.Client{}
  1318. // //
  1319. // // var req *http.Request
  1320. // //
  1321. // //
  1322. // // req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/del", bytes.NewReader(bytesData))
  1323. // // resp, _ := client.Do(req)
  1324. // // defer resp.Body.Close()
  1325. // // body, ioErr := ioutil.ReadAll(resp.Body)
  1326. // // if ioErr != nil {
  1327. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1328. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1329. // // return
  1330. // // }
  1331. // // var respJSON map[string]interface{}
  1332. // // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1333. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1334. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1335. // // return
  1336. // // }
  1337. // //
  1338. // // respJSON2 := respJSON["data"].(map[string]interface{})["msg"].(string)
  1339. // // fmt.Println( respJSON)
  1340. // // fmt.Println( respJSON["data"].(map[string]interface{}))
  1341. // // fmt.Println(respJSON2)
  1342. // //
  1343. // // if respJSON2 != "成功"{
  1344. // // //is_success = false
  1345. // // failed_mag = respJSON2
  1346. // // }
  1347. // // }
  1348. // //}
  1349. //
  1350. // xmlStr2, err := xml.MarshalIndent(root, "", " ")
  1351. // if err != nil {
  1352. // fmt.Println("转换为XML时发生错误:", err)
  1353. // return
  1354. // }
  1355. // data := make(map[string]interface{})
  1356. // data["xmlStr"] = string(xmlStr2)
  1357. // bytesData, _ := json.Marshal(data)
  1358. // var req *http.Request
  1359. // client := &http.Client{}
  1360. // saveLog("", string(xmlStr2), "1111", "上传明细xml", "")
  1361. //
  1362. // req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/upload", bytes.NewReader(bytesData))
  1363. // resp, _ := client.Do(req)
  1364. // defer resp.Body.Close()
  1365. // body, ioErr := ioutil.ReadAll(resp.Body)
  1366. // if ioErr != nil {
  1367. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1369. // return
  1370. // }
  1371. // var respJSON map[string]interface{}
  1372. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1373. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1375. // return
  1376. // }
  1377. //
  1378. // respJSON3 := respJSON["data"].(map[string]interface{})["msg"].(string)
  1379. // respJSON4 := respJSON["data"].(map[string]interface{})["res"].(string)
  1380. //
  1381. // if respJSON3 == "成功" {
  1382. //
  1383. // if li.Acf01 != 1 {
  1384. // //记账
  1385. // result2, request2 := service.NMGSettleForCoordinate(info)
  1386. // saveLog(result2, request2, "记账", "记账", org.OrgName)
  1387. //
  1388. // //data := make(map[string]interface{})
  1389. // //data["info"] = &info
  1390. // //
  1391. // //fmt.Println(data)
  1392. // //
  1393. // //bytesData, _ := json.Marshal(data)
  1394. // //var req *http.Request
  1395. // //
  1396. // //client := &http.Client{}
  1397. // //
  1398. // //req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/settle", bytes.NewReader(bytesData))
  1399. // //resp, _ := client.Do(req)
  1400. // //defer resp.Body.Close()
  1401. // //body, ioErr := ioutil.ReadAll(resp.Body)
  1402. // //if ioErr != nil {
  1403. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1404. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. // // return
  1406. // //}
  1407. // //var respJSON map[string]interface{}
  1408. // //if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1409. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1410. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1411. // // return
  1412. // //}
  1413. // //
  1414. // //respJSON = respJSON["data"].(map[string]interface{})["res"].(map[string]interface{})
  1415. // //userJSONBytes, _ := json.Marshal(respJSON)
  1416. // //
  1417. // //var res2 ResultUpload2
  1418. // //if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1419. // // utils.ErrorLog("解析失败:%v", err)
  1420. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1421. // // return
  1422. // //}
  1423. // //if res2.Code == 500{
  1424. // // c.ServeSuccessJSON(map[string]interface{}{
  1425. // // "failed_code": -10,
  1426. // // "msg": res2.Msg,
  1427. // // })
  1428. // // return
  1429. // //}
  1430. // }
  1431. // timestamp := time.Now().Unix()
  1432. // tempTime := time.Unix(timestamp, 0)
  1433. // timeFormat := tempTime.Format("20060102150405")
  1434. // chrgBchno := rand.Intn(100000) + 10000
  1435. // ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
  1436. // his := models.VMHisPatient{
  1437. // Name: patient.Name,
  1438. // Gender: patient.Gender,
  1439. // Birthday: patient.Birthday,
  1440. // MedicalTreatmentType: 0,
  1441. // IdType: 1,
  1442. // IdCardNo: patient.IdCardNo,
  1443. // BalanceAccountsType: 1,
  1444. // MedicalInsuranceNumber: "",
  1445. // RegisterType: 0,
  1446. // RegisterCost: 0,
  1447. // TreatmentCost: 0,
  1448. // Status: 0,
  1449. // Ctime: time.Now().Unix(),
  1450. // Mtime: time.Now().Unix(),
  1451. // PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  1452. // PsnCertType: "",
  1453. // Certno: patient.IdCardNo,
  1454. // PsnName: patient.Name,
  1455. // Gend: "",
  1456. // Naty: "",
  1457. // Brdy: "",
  1458. // Age: 0,
  1459. // Iinfo: "",
  1460. // Idetinfo: "",
  1461. // PatientId: patient.ID,
  1462. // RecordDate: theTime.Unix(),
  1463. //
  1464. // UserOrgId: org_id,
  1465. // AdminUserId: admin_user_id,
  1466. // IsReturn: 1,
  1467. // Doctor: patientPrescription.DoctorId,
  1468. // Departments: patientPrescription.Departments,
  1469. // IptOtpNo: ipt_otp_no,
  1470. // Number: strconv.FormatInt(int64(li.Vaa07), 10),
  1471. // PhoneNumber: patient.Phone,
  1472. // }
  1473. // service.UpdateHisPatientStatusten(&his)
  1474. // service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
  1475. // tm := time.Unix(time.Now().Unix(), 0)
  1476. //
  1477. // order := &models.HisOrder{
  1478. // PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  1479. // UserOrgId: org_id,
  1480. // PatientId: patient_id,
  1481. // SettleAccountsDate: recordDateTime,
  1482. // Ctime: time.Now().Unix(),
  1483. // Mtime: time.Now().Unix(),
  1484. // Status: 1,
  1485. // OrderStatus: 1,
  1486. // MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  1487. // Number: strconv.FormatInt(int64(li.Vaa07), 10),
  1488. // SetlId: respJSON4,
  1489. // MedfeeSumamt: total,
  1490. // MedType: strconv.Itoa(int(reg_type)),
  1491. // SettleType: settle_accounts_type,
  1492. // Diagnosis: diagnosis_id,
  1493. // PType: int64(li.Acf01),
  1494. // SetlTime: tm.Format("2006-01-02 15:04:05"),
  1495. // SettleStartTime: recordStartTime,
  1496. // SettleEndTime: recordEndTime,
  1497. // }
  1498. // err = service.CreateOrder(order)
  1499. // if err != nil {
  1500. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  1501. // return
  1502. // }
  1503. //
  1504. // for _, item := range customs {
  1505. // var advice_id int64 = 0
  1506. // var project_id int64 = 0
  1507. // //var item_id int64 = 0
  1508. //
  1509. // var types int64 = 0
  1510. //
  1511. // if item.Type == 1 {
  1512. // advice_id = item.AdviceId
  1513. // project_id = 0
  1514. // //item_id = 0.
  1515. // } else if item.Type == 2 {
  1516. // advice_id = 0
  1517. // //item_id = 0
  1518. // project_id = item.ProjectId
  1519. // }
  1520. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  1521. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  1522. // pric, _ := strconv.ParseFloat(item.Price, 32)
  1523. // info := &models.HisOrderInfo{
  1524. // OrderNumber: order.Number,
  1525. // UploadDate: time.Now().Unix(),
  1526. // AdviceId: advice_id,
  1527. // DetItemFeeSumamt: detItemFeeSumamt,
  1528. // Cnt: cut,
  1529. // Pric: pric,
  1530. // PatientId: patient_id,
  1531. // Status: 1,
  1532. // Mtime: time.Now().Unix(),
  1533. // Ctime: time.Now().Unix(),
  1534. // UserOrgId: org_id,
  1535. // HisPatientId: his.ID,
  1536. // OrderId: order.ID,
  1537. // ProjectId: project_id,
  1538. // Type: types,
  1539. // //ItemId: item_id,
  1540. // }
  1541. // service.CreateOrderInfo(info)
  1542. // }
  1543. // his.Diagnosis = diagnosis_id
  1544. // his.SickType = sick_type
  1545. // his.RegisterType = reg_type
  1546. // his.MedicalTreatmentType = reg_type
  1547. // service.UpdataHisPateintTwo(&his)
  1548. // err = service.UpDatePrescriptionNumber(org_id, ids, strconv.FormatInt(int64(li.Vaa07), 10))
  1549. // err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  1550. // err = service.UpdataOrderStatusThreef(strconv.FormatInt(int64(li.Vaa07), 10), org_id)
  1551. //
  1552. // var zuobiao_advice models.HisZuobiaoAdvice
  1553. // zuobiao_advice.Status = 1
  1554. // zuobiao_advice.RecordDate = recordDateTime
  1555. // zuobiao_advice.PatientId = patient_id
  1556. // zuobiao_advice.Cbm01 = respJSON4
  1557. // zuobiao_advice.Ctime = time.Now().Unix()
  1558. // zuobiao_advice.Mtime = time.Now().Unix()
  1559. // zuobiao_advice.Oid = order.ID
  1560. // zuobiao_advice.StartTime = recordStartTime
  1561. // zuobiao_advice.EndTime = recordEndTime
  1562. // zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  1563. // zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  1564. // zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  1565. // service.Createzuobiao(&zuobiao_advice)
  1566. //
  1567. // c.ServeSuccessJSON(map[string]interface{}{
  1568. // "msg": "成功",
  1569. // })
  1570. //
  1571. // } else {
  1572. // c.ServeSuccessJSON(map[string]interface{}{
  1573. // "failed_code": -10,
  1574. // "msg": respJSON3,
  1575. // })
  1576. //
  1577. // }
  1578. //
  1579. // } else {
  1580. //
  1581. // c.ServeSuccessJSON(map[string]interface{}{
  1582. // "failed_code": -10,
  1583. // "msg": res.Msg,
  1584. // })
  1585. // }
  1586. //}
  1587. //func (c *CoordinateController) NMGSettleAccountthree() {
  1588. // patient_id, _ := c.GetInt64("patient_id")
  1589. // record_date := c.GetString("record_date")
  1590. // //admin_user_id, _ := c.GetInt64("admin_user_id")
  1591. // diagnosis_id := c.GetString("diagnosis")
  1592. // sick_type, _ := c.GetInt64("sick_type")
  1593. // reg_type, _ := c.GetInt64("p_type")
  1594. // org_id, _ := c.GetInt64("org_id")
  1595. // org_id = 10206
  1596. // org, _ := service.GetOrgById(org_id)
  1597. // patient, _ := service.GetPatientByID(org.Id, patient_id)
  1598. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1599. //
  1600. // res := NMGzhuyuan(c, patient.Name)
  1601. // res8 := NMGmenzhen(c, patient.Name)
  1602. //
  1603. // //优先查询今天门诊的患者,如果今天没有门诊的患者查询出住院的患者
  1604. // if res8.Code == 200 {
  1605. // var res9 Data
  1606. // res9.List = append(res9.List, res8.List...)
  1607. // var li ListItem
  1608. // // 获取当前时间
  1609. // //var maxTimestamp int64
  1610. //
  1611. // // 定义一个变量来保存离当前时间最近的数据
  1612. // //var closestData MyData
  1613. // //var closestTimeDiff time.Duration
  1614. //
  1615. // // 遍历切片,找到离当前时间最近的数据
  1616. // //for _, data := range res9.List {
  1617. // // // 将时间字符串解析为 time.Time 类型
  1618. // // timeObj, err := time.Parse("2006-01-02 15:04:05", data.Vae11)
  1619. // // if err != nil {
  1620. // // fmt.Println("时间解析错误:", err)
  1621. // // continue
  1622. // // }
  1623. // // // 获取时间戳
  1624. // // timestamp := timeObj.Unix()
  1625. // // // 比较时间戳
  1626. // // if timestamp > maxTimestamp {
  1627. // // maxTimestamp = timestamp
  1628. // // }
  1629. // //}
  1630. // //
  1631. // //fmt.Println(maxTimestamp)
  1632. //
  1633. // sort.Slice(res9.List, func(i, j int) bool {
  1634. // // 将时间字符串解析为 time.Time 类型
  1635. // timeObj1, err1 := time.Parse("2006-01-02 15:04:05", res9.List[i].Vae11)
  1636. // timeObj2, err2 := time.Parse("2006-01-02 15:04:05", res9.List[j].Vae11)
  1637. //
  1638. // // 错误处理
  1639. // if err1 != nil || err2 != nil {
  1640. // fmt.Println("时间解析错误:", err1, err2)
  1641. // return false
  1642. // }
  1643. //
  1644. // // 比较时间
  1645. // return timeObj1.Before(timeObj2)
  1646. // })
  1647. //
  1648. // cure_date := strings.Split(res9.List[len(res9.List)-1].Vae11, " ")
  1649. // if cure_date[0] == record_date && patient.Name == res9.List[len(res9.List)-1].Vaa05 {
  1650. // li = res9.List[len(res9.List)-1]
  1651. // }
  1652. // fmt.Println("按照时间排序后的数据:", li)
  1653. // if li.Acf01 == 0 && li.Vaa07 == 0 && li.Vaa01 == 0 { //今天没有门诊患者,则查询出最后一个日期的住院患者
  1654. // var res10 Data
  1655. // //res9.List = append(res9.List, res.List...)
  1656. // res10.List = append(res10.List, res.List...)
  1657. // layout := "2006-01-02 15:04:05"
  1658. // var maxDate time.Time
  1659. // for _, item := range res10.List {
  1660. // currentDate, err := time.Parse(layout, item.Vae11)
  1661. // if err != nil {
  1662. // fmt.Println("Error parsing date:", err)
  1663. // continue
  1664. // }
  1665. // if currentDate.After(maxDate) {
  1666. // maxDate = currentDate
  1667. // }
  1668. // if !maxDate.IsZero() {
  1669. // fmt.Println("The maximum date is:", maxDate.Format(layout))
  1670. // } else {
  1671. // fmt.Println("No valid dates found")
  1672. // }
  1673. // }
  1674. // fmt.Println(maxDate.Format("2006-01-02 15:04:05"))
  1675. // for _, item := range res10.List {
  1676. // if item.Vae11 == maxDate.Format("2006-01-02 15:04:05") && patient.Name == item.Vaa05 {
  1677. // li = item
  1678. // }
  1679. // }
  1680. // }
  1681. // fmt.Println(li)
  1682. //
  1683. // timeLayout := "2006-01-02"
  1684. // loc, _ := time.LoadLocation("Local")
  1685. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1686. // if err != nil {
  1687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1688. // return
  1689. // }
  1690. // org_id := org.Id
  1691. // recordDateTime := theTime.Unix()
  1692. // patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  1693. // if patientPrescription.ID == 0 {
  1694. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  1695. // }
  1696. // departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1697. // //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  1698. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  1699. //
  1700. // var recordStartTime int64
  1701. // var recordEndTime int64
  1702. //
  1703. // var prescriptions []models.HisPrescription
  1704. // if settle_accounts_type == 1 { //日结
  1705. // prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, patient_id, recordDateTime, 2)
  1706. // } else { //月结
  1707. // start_time_str := c.GetString("start_time")
  1708. // end_time_str := c.GetString("end_time")
  1709. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1710. // if err != nil {
  1711. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1712. // return
  1713. // }
  1714. // recordStartTime = theStartTime.Unix()
  1715. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1716. // if err != nil {
  1717. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1718. // return
  1719. // }
  1720. // recordEndTime = theEndTime.Unix()
  1721. //
  1722. // prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime)
  1723. // }
  1724. //
  1725. // var total float64
  1726. //
  1727. // var customs []*models.NewCustomTwo
  1728. // for _, item := range prescriptions {
  1729. // if item.Type == 1 { //药品
  1730. // for _, subItem := range item.HisDoctorAdviceInfo {
  1731. // tempTime := time.Unix(item.PreTime, 0)
  1732. // //timeFormat := tempTime.Format("20060102150405")
  1733. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1734. // cus := &models.NewCustomTwo{
  1735. // AdviceId: subItem.ID,
  1736. // ProjectId: 0,
  1737. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1738. // Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1739. // FeedetlSn: subItem.FeedetlSn,
  1740. // Price: fmt.Sprintf("%.2f", subItem.Price),
  1741. // MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1742. // Type: 1,
  1743. // ItemId: subItem.BaseDrugLib.ZuobiaoId,
  1744. // StartTime: timeFormatOne,
  1745. // Content: subItem.AdviceName,
  1746. // Bby01: subItem.BaseDrugLib.Bby01,
  1747. // }
  1748. // customs = append(customs, cus)
  1749. // }
  1750. // }
  1751. // if item.Type == 2 { //项目
  1752. // for _, subItem := range item.HisPrescriptionProject {
  1753. // if subItem.Type == 2 {
  1754. // tempTime := time.Unix(item.PreTime, 0)
  1755. // //timeFormat := tempTime.Format("20060102150405")
  1756. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1757. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1758. // cus := &models.NewCustomTwo{
  1759. // AdviceId: 0,
  1760. // ProjectId: subItem.ID,
  1761. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1762. // Cut: fmt.Sprintf("%.4f", cnt),
  1763. // FeedetlSn: subItem.FeedetlSn,
  1764. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1765. // MedListCodg: subItem.HisProject.MedicalCode,
  1766. // Type: 2,
  1767. // ItemId: subItem.HisProject.ZuobiaoId,
  1768. // StartTime: timeFormatOne,
  1769. // Content: subItem.HisProject.ProjectName,
  1770. // Bby01: subItem.HisProject.Bby01,
  1771. // }
  1772. // customs = append(customs, cus)
  1773. //
  1774. // } else {
  1775. // tempTime := time.Unix(item.PreTime, 0)
  1776. // //timeFormat := tempTime.Format("20060102150405")
  1777. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1778. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1779. // cus := &models.NewCustomTwo{
  1780. // AdviceId: 0,
  1781. // ProjectId: subItem.ID,
  1782. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1783. // Cut: fmt.Sprintf("%.4f", cnt),
  1784. // FeedetlSn: subItem.FeedetlSn,
  1785. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1786. // MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1787. // Type: 3,
  1788. // ItemId: subItem.GoodInfo.ZuobiaoId,
  1789. // StartTime: timeFormatOne,
  1790. // Content: subItem.GoodInfo.GoodName,
  1791. // Bby01: subItem.GoodInfo.Bby01,
  1792. // }
  1793. // customs = append(customs, cus)
  1794. // }
  1795. //
  1796. // }
  1797. // }
  1798. // }
  1799. //
  1800. // for _, item := range prescriptions {
  1801. // if item.Type == 1 { //药品
  1802. // for _, subItem := range item.HisDoctorAdviceInfo {
  1803. // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  1804. // total_one := price * subItem.PrescribingNumber
  1805. // fmt.Println("subItem")
  1806. // fmt.Println(subItem.Price)
  1807. // fmt.Println("price")
  1808. // fmt.Println(price)
  1809. // fmt.Println("total_one")
  1810. // fmt.Println(total_one)
  1811. // total = total + total_one
  1812. // fmt.Println(total)
  1813. //
  1814. // }
  1815. // }
  1816. // if item.Type == 2 { //项目
  1817. //
  1818. // for _, subItem := range item.HisPrescriptionProject {
  1819. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1820. // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  1821. // total_one := price * cnt
  1822. // total = total + total_one
  1823. // }
  1824. // }
  1825. // }
  1826. //
  1827. // //allTotal := fmt.Sprintf("%2f", total)
  1828. //
  1829. // var info models.UploadInfo
  1830. // info.Acf01 = int64(li.Acf01)
  1831. // info.Bce01 = "132"
  1832. // info.Bck01 = "48"
  1833. // info.Vaa07 = int64(li.Vaa07)
  1834. // info.Vaa01 = int64(li.Vaa01)
  1835. // info.Vaa05 = li.Vaa05
  1836. // info.Bce01a = doctor_info.DoctorNumber
  1837. //
  1838. // for _, item := range customs {
  1839. // var cha models.ChargeListtwo
  1840. // cnt, _ := strconv.ParseFloat(item.Cut, 64)
  1841. //
  1842. // Bby01, _ := strconv.ParseInt(item.Bby01, 10, 64)
  1843. //
  1844. // cha.Bby01 = Bby01
  1845. // cha.Vaj25 = cnt
  1846. // info.ChargeListtwo = append(info.ChargeListtwo, &cha)
  1847. // }
  1848. //
  1849. // //
  1850. // //
  1851. // //var del_ids []string
  1852. // //
  1853. // //
  1854. // ////信息
  1855. // var is_upload_success bool = true
  1856. // var curpage int
  1857. // var pagesize int = 8
  1858. // var start int = 1
  1859. // var stop int
  1860. // var zuobiao_ids string
  1861. // var err_msg string
  1862. // var idss []int64
  1863. //
  1864. // //pagecount := 10
  1865. // pagecount := int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  1866. //
  1867. // for curpage = 1; curpage <= pagecount; curpage++ {
  1868. // var root models.Root
  1869. // var tradeInfo models.TradeInfo
  1870. // var cBM1 models.CBM1
  1871. // var vAF1 models.VAF1
  1872. // var vAO1 models.VAO1
  1873. // var vBQ1 models.VBQ1
  1874. //
  1875. // if li.Acf01 == 1 {
  1876. // tradeInfo.PatSource = 1
  1877. // tradeInfo.Type = 0
  1878. // } else {
  1879. // tradeInfo.PatSource = 2
  1880. // tradeInfo.Type = 1
  1881. //
  1882. // }
  1883. // tradeInfo.Detpid = departmwnt.Number
  1884. // tradeInfo.Empid = doctor_info.DoctorNumber
  1885. // tradeInfo.Empno = doctor_info.DoctorCode
  1886. // tradeInfo.Empname = doctor_info.UserName
  1887. // root.TradeInfo = tradeInfo
  1888. //
  1889. // if curpage == 1 {
  1890. // start = 1
  1891. // } else {
  1892. // start = (curpage-1)*pagesize + 1
  1893. // }
  1894. // stop = curpage * pagesize
  1895. // if stop > len(prescriptions) {
  1896. // stop = len(prescriptions)
  1897. // }
  1898. //
  1899. // var ids []int64
  1900. //
  1901. // for _, item := range prescriptions[start-1 : stop] {
  1902. // ids = append(ids, item.ID)
  1903. // }
  1904. //
  1905. // for _, item := range prescriptions[start-1 : stop] {
  1906. // departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  1907. // var ie_cbm1 models.IEone
  1908. // ie_cbm1.CBMID = strconv.FormatInt(item.ID, 10)
  1909. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  1910. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  1911. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  1912. // //ie_cbm1.CBM06 = strconv.FormatInt(int64(res.List[0].Acf01), 10)
  1913. //
  1914. // if li.Acf01 == 1 {
  1915. // ie_cbm1.CBM06 = item.MedType
  1916. // ie_cbm1.BCK01A = "0"
  1917. // } else {
  1918. // ie_cbm1.CBM06 = "0"
  1919. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10) //病区id
  1920. // }
  1921. // ie_cbm1.CBM07 = item.MedType
  1922. // ie_cbm1.BCK01B = strconv.FormatInt(int64(li.Bck01B), 10)
  1923. // ie_cbm1.BCK01C = departmwnt_two.Number
  1924. // ie_cbm1.CBM19 = "0"
  1925. // cBM1.Ie = append(cBM1.Ie, ie_cbm1)
  1926. // }
  1927. // root.CBM1 = cBM1
  1928. // ////医嘱
  1929. // for _, item := range prescriptions[start-1 : stop] {
  1930. // departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  1931. //
  1932. // if item.Type == 1 {
  1933. // //组号去重
  1934. // //temphisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  1935. //
  1936. // // 使用 map 来存储 groupno 的数量
  1937. // //groupCount := make(map[int64]int64)
  1938. //
  1939. // // 使用 map 来存储 groupno 的数量和最后一条数据的索引
  1940. // groupInfo := make(map[int64]struct {
  1941. // Count int64
  1942. // LastElement int
  1943. // })
  1944. //
  1945. // // 遍历切片,计算 groupno 的数量和最后一条数据的索引
  1946. // for i, obj := range item.HisDoctorAdviceInfo {
  1947. // info, ok := groupInfo[obj.Groupno]
  1948. // if !ok {
  1949. // info = struct {
  1950. // Count int64
  1951. // LastElement int
  1952. // }{}
  1953. // }
  1954. // info.Count++
  1955. // info.LastElement = i
  1956. // groupInfo[obj.Groupno] = info
  1957. // }
  1958. //
  1959. // // 根据 groupno 的数量设置字段值
  1960. // for i, obj := range item.HisDoctorAdviceInfo {
  1961. // info := groupInfo[obj.Groupno]
  1962. // if info.Count < 2 {
  1963. // item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  1964. // } else {
  1965. // // 对于数量大于等于 2 的,将最后一条数据设置 1,其他设置为随机数
  1966. // if i == info.LastElement {
  1967. // item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  1968. // } else {
  1969. // item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(obj.ID, 10)
  1970. // }
  1971. // }
  1972. // }
  1973. //
  1974. // for _, subitem := range item.HisDoctorAdviceInfo {
  1975. // var ie_cbm1 models.IEtwo
  1976. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  1977. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  1978. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  1979. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  1980. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  1981. // ie_cbm1.ROWNR = subitem.NewGroupno
  1982. // ie_cbm1.VAF10 = "1"
  1983. // ie_cbm1.VAF11 = "2"
  1984. // ie_cbm1.BDA01 = "1" //诊疗类型
  1985. // ie_cbm1.BBX01 = subitem.BaseDrugLib.ZuobiaoId
  1986. // ie_cbm1.VAF14 = "" //检验样本类型
  1987. // ie_cbm1.VAF15 = ""
  1988. // ie_cbm1.BBY01 = subitem.BaseDrugLib.Bby01 //药品规格id或材料规格id
  1989. //
  1990. // if li.Acf01 == 1 {
  1991. // ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10)
  1992. //
  1993. // } else {
  1994. // ie_cbm1.VAF17 = "0"
  1995. //
  1996. // }
  1997. //
  1998. // ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  1999. // ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  2000. // ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  2001. // ie_cbm1.VAF21 = fmt.Sprintf("%.2f", subitem.PrescribingNumber)
  2002. //
  2003. // ie_cbm1.VAF22 = subitem.AdviceName + " " + subitem.BaseDrugLib.DrugSpec
  2004. // ie_cbm1.Crypt = "0"
  2005. // ie_cbm1.VAF23 = ""
  2006. // ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  2007. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  2008. // ie_cbm1.VAF27 = "1"
  2009. // ie_cbm1.VAF28 = "1"
  2010. // ie_cbm1.VAF29 = "1"
  2011. //
  2012. // ie_cbm1.VAF30 = ""
  2013. // ie_cbm1.VAF31 = "0"
  2014. //
  2015. // ie_cbm1.VAF32 = "0" //todo
  2016. // ie_cbm1.VAF33 = "0"
  2017. // ie_cbm1.VAF34 = "0"
  2018. // ie_cbm1.VAF35 = "0"
  2019. //
  2020. // tempTime1 := time.Unix(subitem.StartTime, 0)
  2021. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  2022. // ie_cbm1.VAF36 = timeFormatOne
  2023. // ie_cbm1.VAF37 = "1899-12-30"
  2024. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  2025. // ie_cbm1.BCK01C = departmwnt_two.Number
  2026. //
  2027. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  2028. // ie_cbm1.BCE03A = doctor_info.UserName
  2029. // ie_cbm1.BCE03B = ""
  2030. //
  2031. // ie_cbm1.VAF53 = "-1"
  2032. // ie_cbm1.VAF55 = subitem.Remark
  2033. // ie_cbm1.BCK01D = departmwnt_two.Number
  2034. // ie_cbm1.VAF58 = "0"
  2035. // ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno), 10)
  2036. // ie_cbm1.VAF60 = ""
  2037. // ie_cbm1.VAF61 = "1"
  2038. // ie_cbm1.VAF62 = "0"
  2039. // ie_cbm1.LSign = "0"
  2040. // ie_cbm1.BDA01A = ie_cbm1.BDA01
  2041. // ie_cbm1.LRoute = "0"
  2042. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  2043. // ie_cbm1.BCE01B = "0"
  2044. //
  2045. // ie_cbm1.VAF01B = "0"
  2046. // ie_cbm1.VCO01 = "0"
  2047. // ie_cbm1.BCE01H = "0"
  2048. // ie_cbm1.BCE03H = ""
  2049. // ie_cbm1.BIW02 = ""
  2050. // ie_cbm1.RCurrent = "0"
  2051. // ie_cbm1.FCheck = "0"
  2052. // ie_cbm1.UnameA = ""
  2053. // ie_cbm1.VEH02 = ""
  2054. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  2055. // }
  2056. //
  2057. // hisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  2058. //
  2059. // //每种药品下的给药途径
  2060. // for _, subitem := range hisDoctorAdviceInfo {
  2061. // way, _ := service.GetDrugwayDicByName(subitem.DeliveryWay, c.GetAdminUserInfo().CurrentOrgId)
  2062. // var ie_cbm1 models.IEtwo
  2063. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  2064. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  2065. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  2066. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  2067. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  2068. // ie_cbm1.ROWNR = "0"
  2069. // ie_cbm1.VAF10 = "1"
  2070. // ie_cbm1.VAF11 = "2"
  2071. // ie_cbm1.BDA01 = "T" //诊疗类型
  2072. // ie_cbm1.BBX01 = way.Code
  2073. // ie_cbm1.VAF14 = "" //检验样本类型
  2074. // ie_cbm1.VAF15 = "" //检验样本类型
  2075. // ie_cbm1.BBY01 = way.Bby01 //药品规格id或材料规格id
  2076. // if li.Acf01 == 1 {
  2077. // ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10) //药品规格id或材料规格id
  2078. // } else {
  2079. // ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
  2080. // }
  2081. //
  2082. // ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  2083. // ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  2084. // ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  2085. // //ie_cbm1.VAF21 = fmt.Sprintf("%.2f",subitem.PrescribingNumber)
  2086. //
  2087. // //ie_cbm1.VAF18 = "" //药品规格id或材料规格id
  2088. // //ie_cbm1.VAF19 = ""
  2089. // //ie_cbm1.VAF20 = ""
  2090. // if subitem.DrugWayCount == "" {
  2091. // ie_cbm1.VAF21 = "1"
  2092. //
  2093. // } else {
  2094. // ie_cbm1.VAF21 = subitem.DrugWayCount
  2095. //
  2096. // }
  2097. //
  2098. // ie_cbm1.VAF22 = way.Name
  2099. // ie_cbm1.Crypt = "0"
  2100. // ie_cbm1.VAF23 = ""
  2101. // ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  2102. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  2103. // ie_cbm1.VAF27 = "1"
  2104. // ie_cbm1.VAF28 = "1"
  2105. // ie_cbm1.VAF29 = "1"
  2106. // ie_cbm1.BCK01C = departmwnt_two.Number
  2107. //
  2108. // ie_cbm1.VAF30 = ""
  2109. // ie_cbm1.VAF31 = "0"
  2110. //
  2111. // ie_cbm1.VAF32 = "1" //todo
  2112. // ie_cbm1.VAF33 = "0"
  2113. // ie_cbm1.VAF34 = "0"
  2114. // ie_cbm1.VAF35 = "0"
  2115. //
  2116. // tempTime1 := time.Unix(subitem.StartTime, 0)
  2117. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  2118. // ie_cbm1.VAF36 = timeFormatOne
  2119. // ie_cbm1.VAF37 = "1899-12-30"
  2120. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  2121. //
  2122. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  2123. // ie_cbm1.BCE03A = doctor_info.UserName
  2124. // ie_cbm1.BCE03B = ""
  2125. //
  2126. // ie_cbm1.VAF53 = "-1"
  2127. // ie_cbm1.VAF55 = subitem.Remark
  2128. // ie_cbm1.BCK01D = departmwnt_two.Number
  2129. // ie_cbm1.VAF58 = "0"
  2130. // ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno), 10)
  2131. //
  2132. // ie_cbm1.VAF60 = ""
  2133. // ie_cbm1.VAF61 = "1"
  2134. // ie_cbm1.VAF62 = "0"
  2135. // ie_cbm1.LSign = "0"
  2136. // ie_cbm1.BDA01A = ie_cbm1.BDA01
  2137. // ie_cbm1.LRoute = "0"
  2138. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  2139. // ie_cbm1.BCE01B = "0"
  2140. //
  2141. // ie_cbm1.VAF01B = "0"
  2142. // ie_cbm1.VCO01 = "0"
  2143. // ie_cbm1.BCE01H = "0"
  2144. // ie_cbm1.BCE03H = ""
  2145. // ie_cbm1.BIW02 = ""
  2146. // ie_cbm1.RCurrent = "0"
  2147. // ie_cbm1.FCheck = "0"
  2148. // ie_cbm1.UnameA = ""
  2149. // ie_cbm1.VEH02 = ""
  2150. // ie_cbm1.VAF07 = "0"
  2151. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  2152. // }
  2153. //
  2154. // } else if item.Type == 2 {
  2155. // for index, subitem := range item.HisPrescriptionProject {
  2156. // if subitem.Type == 2 {
  2157. // if subitem.HisProject.CostClassify != 3 {
  2158. // var ie_cbm1 models.IEtwo
  2159. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  2160. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  2161. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  2162. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  2163. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  2164. // ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  2165. // ie_cbm1.VAF10 = "1"
  2166. // ie_cbm1.VAF11 = "2"
  2167. // ie_cbm1.BDA01 = "T" //诊疗类型
  2168. // ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  2169. // ie_cbm1.VAF14 = "" //检验样本类型
  2170. // ie_cbm1.VAF15 = "" //检验样本类型
  2171. // ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  2172. // if li.Acf01 == 1 {
  2173. // ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  2174. // if len(subitem.Day) == 0 {
  2175. // ie_cbm1.VAF17 = "1"
  2176. // }
  2177. //
  2178. // } else {
  2179. // ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  2180. // }
  2181. // if subitem.SingleDose == "" {
  2182. //
  2183. // subitem.SingleDose = "1"
  2184. // }
  2185. //
  2186. // ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  2187. // ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  2188. // ie_cbm1.VAF20 = subitem.SingleDose
  2189. // ie_cbm1.VAF21 = subitem.Count
  2190. //
  2191. // ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  2192. // ie_cbm1.Crypt = "0"
  2193. // ie_cbm1.VAF23 = ""
  2194. // ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  2195. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  2196. // ie_cbm1.VAF27 = "1"
  2197. // ie_cbm1.VAF28 = "1"
  2198. // ie_cbm1.VAF29 = ""
  2199. // ie_cbm1.BCK01C = departmwnt_two.Number
  2200. //
  2201. // ie_cbm1.VAF30 = ""
  2202. // ie_cbm1.VAF31 = "0"
  2203. //
  2204. // ie_cbm1.VAF32 = "0" //todo
  2205. // ie_cbm1.VAF33 = "0"
  2206. // ie_cbm1.VAF34 = "0"
  2207. // ie_cbm1.VAF35 = "0"
  2208. //
  2209. // tempTime1 := time.Unix(subitem.StartTime, 0)
  2210. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  2211. // ie_cbm1.VAF36 = timeFormatOne
  2212. // ie_cbm1.VAF37 = "1899-12-30"
  2213. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  2214. //
  2215. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  2216. // ie_cbm1.BCE03A = doctor_info.UserName
  2217. // ie_cbm1.BCE03B = ""
  2218. //
  2219. // ie_cbm1.VAF53 = "-1"
  2220. // ie_cbm1.VAF55 = subitem.Remark
  2221. // ie_cbm1.BCK01D = departmwnt_two.Number
  2222. // ie_cbm1.VAF58 = "0"
  2223. // ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  2224. //
  2225. // ie_cbm1.VAF60 = ""
  2226. // ie_cbm1.VAF61 = "1"
  2227. // ie_cbm1.VAF62 = "0"
  2228. // ie_cbm1.LSign = "0"
  2229. // ie_cbm1.BDA01A = "" //诊疗类型
  2230. // ie_cbm1.LRoute = "0"
  2231. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  2232. //
  2233. // //ie_cbm1.BCE01A = doctor_info.UserName
  2234. // ie_cbm1.BCE01B = "0"
  2235. //
  2236. // ie_cbm1.VAF01B = "0"
  2237. // ie_cbm1.VCO01 = "0"
  2238. // ie_cbm1.BCE01H = "0"
  2239. // ie_cbm1.BCE03H = ""
  2240. // ie_cbm1.BIW02 = ""
  2241. // ie_cbm1.RCurrent = "0"
  2242. // ie_cbm1.FCheck = "0"
  2243. // ie_cbm1.UnameA = ""
  2244. // ie_cbm1.VAF07 = "0"
  2245. //
  2246. // ie_cbm1.VEH02 = ""
  2247. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  2248. // }
  2249. // if subitem.HisProject.CostClassify == 3 {
  2250. // var ie_cbm1 models.IEtwo
  2251. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  2252. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  2253. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  2254. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  2255. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  2256. // ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  2257. // ie_cbm1.VAF10 = "1"
  2258. // ie_cbm1.VAF11 = "2"
  2259. // ie_cbm1.BDA01 = "L" //诊疗类型
  2260. // ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  2261. // ie_cbm1.VAF14 = "" //检验样本类型
  2262. // ie_cbm1.VAF15 = "" //检验样本类型
  2263. // ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  2264. // if li.Acf01 == 1 {
  2265. // ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  2266. // } else {
  2267. // ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  2268. // }
  2269. // if subitem.SingleDose == "" {
  2270. //
  2271. // subitem.SingleDose = "1"
  2272. // }
  2273. //
  2274. // ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  2275. // ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  2276. // ie_cbm1.VAF20 = subitem.SingleDose
  2277. // ie_cbm1.VAF21 = subitem.Count
  2278. //
  2279. // ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  2280. // ie_cbm1.Crypt = "0"
  2281. // ie_cbm1.VAF23 = ""
  2282. // ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  2283. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  2284. // ie_cbm1.VAF27 = "1"
  2285. // ie_cbm1.VAF28 = "1"
  2286. // ie_cbm1.VAF29 = ""
  2287. // ie_cbm1.BCK01C = departmwnt_two.Number
  2288. // ie_cbm1.VAF30 = ""
  2289. // ie_cbm1.VAF31 = "0"
  2290. // ie_cbm1.VAF32 = "0" //todo
  2291. // ie_cbm1.VAF33 = "0"
  2292. // ie_cbm1.VAF34 = "0"
  2293. // ie_cbm1.VAF35 = "0"
  2294. // tempTime1 := time.Unix(subitem.StartTime, 0)
  2295. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  2296. // ie_cbm1.VAF36 = timeFormatOne
  2297. // ie_cbm1.VAF37 = "1899-12-30"
  2298. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  2299. //
  2300. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  2301. // ie_cbm1.BCE03A = doctor_info.UserName
  2302. // ie_cbm1.BCE03B = ""
  2303. //
  2304. // ie_cbm1.VAF53 = "-1"
  2305. // ie_cbm1.VAF55 = subitem.Remark
  2306. // ie_cbm1.BCK01D = departmwnt_two.Number
  2307. // ie_cbm1.VAF58 = "0"
  2308. // ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  2309. //
  2310. // ie_cbm1.VAF60 = ""
  2311. // ie_cbm1.VAF61 = "1"
  2312. // ie_cbm1.VAF62 = "0"
  2313. // ie_cbm1.LSign = "0"
  2314. // ie_cbm1.BDA01A = "" //诊疗类型
  2315. // ie_cbm1.LRoute = "0"
  2316. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  2317. // ie_cbm1.VAF07 = "0"
  2318. //
  2319. // //ie_cbm1.BCE01A = doctor_info.UserName
  2320. // ie_cbm1.BCE01B = "0"
  2321. //
  2322. // ie_cbm1.VAF01B = "0"
  2323. // ie_cbm1.VCO01 = "0"
  2324. // ie_cbm1.BCE01H = "0"
  2325. // ie_cbm1.BCE03H = ""
  2326. // ie_cbm1.BIW02 = ""
  2327. // ie_cbm1.RCurrent = "0"
  2328. // ie_cbm1.FCheck = "0"
  2329. // ie_cbm1.UnameA = ""
  2330. // ie_cbm1.VEH02 = ""
  2331. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  2332. // }
  2333. //
  2334. // } else if subitem.Type == 3 {
  2335. // var ie_cbm1 models.IEtwo
  2336. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  2337. // ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  2338. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  2339. // ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  2340. // ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
  2341. // ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  2342. //
  2343. // ie_cbm1.VAF10 = "1"
  2344. // ie_cbm1.VAF11 = "2"
  2345. // ie_cbm1.BDA01 = "4" //诊疗类型
  2346. // ie_cbm1.BBX01 = subitem.GoodInfo.ZuobiaoId
  2347. // ie_cbm1.VAF14 = "" //检验样本类型
  2348. // ie_cbm1.VAF15 = "" //检验样本类型
  2349. // ie_cbm1.BBY01 = subitem.GoodInfo.Bby01 //药品规格id或材料规格id
  2350. // if li.Acf01 == 1 {
  2351. // ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  2352. // if len(subitem.Day) == 0 {
  2353. // ie_cbm1.VAF17 = "1"
  2354. // }
  2355. //
  2356. // } else {
  2357. // ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  2358. // }
  2359. // if subitem.SingleDose == "" {
  2360. //
  2361. // subitem.SingleDose = "1"
  2362. // }
  2363. //
  2364. // ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  2365. // ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  2366. // ie_cbm1.VAF20 = subitem.SingleDose
  2367. // ie_cbm1.VAF21 = subitem.Count
  2368. // ie_cbm1.BCK01C = departmwnt_two.Number
  2369. //
  2370. // ie_cbm1.VAF22 = subitem.GoodInfo.GoodName + " " + subitem.GoodInfo.SpecificationName
  2371. // ie_cbm1.Crypt = "0"
  2372. // ie_cbm1.VAF23 = ""
  2373. // ie_cbm1.BCK01B = subitem.GoodInfo.Bck01b
  2374. // ie_cbm1.VAF26 = subitem.ExecutionFrequency
  2375. // ie_cbm1.VAF27 = "1"
  2376. // ie_cbm1.VAF28 = "1"
  2377. // ie_cbm1.VAF29 = ""
  2378. // ie_cbm1.VAF07 = "0"
  2379. //
  2380. // ie_cbm1.VAF30 = ""
  2381. // ie_cbm1.VAF31 = "0"
  2382. //
  2383. // ie_cbm1.VAF32 = "0" //todo
  2384. // ie_cbm1.VAF33 = "0"
  2385. // ie_cbm1.VAF34 = "0"
  2386. // ie_cbm1.VAF35 = "0"
  2387. //
  2388. // tempTime1 := time.Unix(subitem.StartTime, 0)
  2389. // timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  2390. // ie_cbm1.VAF36 = timeFormatOne
  2391. // ie_cbm1.VAF37 = "1899-12-30"
  2392. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
  2393. //
  2394. // ie_cbm1.BCE02A = doctor_info.DoctorCode
  2395. // ie_cbm1.BCE03A = doctor_info.UserName
  2396. // ie_cbm1.BCE03B = ""
  2397. // ie_cbm1.BCK01C = departmwnt_two.Number
  2398. //
  2399. // ie_cbm1.VAF53 = "-1"
  2400. // ie_cbm1.VAF55 = subitem.Remark
  2401. // ie_cbm1.BCK01D = departmwnt_two.Number
  2402. // ie_cbm1.VAF58 = "0"
  2403. // ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  2404. // ie_cbm1.VAF60 = ""
  2405. // ie_cbm1.VAF61 = "1"
  2406. // ie_cbm1.VAF62 = "0"
  2407. // ie_cbm1.LSign = "0"
  2408. // ie_cbm1.BDA01A = "" //诊疗类型
  2409. // ie_cbm1.LRoute = "0"
  2410. // ie_cbm1.BCE01A = doctor_info.DoctorNumber
  2411. // ie_cbm1.BCE01B = "0"
  2412. // ie_cbm1.VAF01B = "0"
  2413. // ie_cbm1.VCO01 = "0"
  2414. // ie_cbm1.BCE01H = "0"
  2415. // ie_cbm1.BCE03H = ""
  2416. // ie_cbm1.BIW02 = ""
  2417. // ie_cbm1.RCurrent = "0"
  2418. // ie_cbm1.FCheck = "0"
  2419. // ie_cbm1.UnameA = ""
  2420. // ie_cbm1.VEH02 = ""
  2421. // vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  2422. // }
  2423. // }
  2424. // }
  2425. //
  2426. // }
  2427. // root.VAF1 = vAF1
  2428. // for _, item := range prescriptions[start-1 : stop] {
  2429. // sick, _ := service.FindSickById(sick_type)
  2430. //
  2431. // dias := strings.Split(item.VMHisPrescriptionInfo.Diagnosis, ",")
  2432. // //service.get
  2433. //
  2434. // //诊断
  2435. // for index, subitem := range dias {
  2436. // diagnosisConfig, _ := service.FindDiagnoseByIdtwo(subitem)
  2437. // if index == 0 {
  2438. // var ie_cbm1 models.IEthree
  2439. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  2440. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  2441. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  2442. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  2443. // ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  2444. // ie_cbm1.VAO07 = "1"
  2445. // ie_cbm1.VAO10 = "0"
  2446. // ie_cbm1.VAO11 = "1"
  2447. // ie_cbm1.BAK01A = sick.ContentCode
  2448. // ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  2449. // ie_cbm1.VAO15 = diagnosisConfig.ClassName
  2450. // ie_cbm1.VAO18 = "0"
  2451. // ie_cbm1.VAO22 = "1"
  2452. // ie_cbm1.IAA01 = ""
  2453. // ie_cbm1.IAD03 = ""
  2454. // ie_cbm1.BAK01B = ""
  2455. // ie_cbm1.VAO26 = ""
  2456. // ie_cbm1.IAD04 = ""
  2457. // ie_cbm1.IAD01 = ""
  2458. // ie_cbm1.VAO25 = "1"
  2459. // ie_cbm1.VAO35 = ""
  2460. // vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  2461. //
  2462. // } else {
  2463. // var ie_cbm1 models.IEthree
  2464. // ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  2465. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  2466. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  2467. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  2468. // ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  2469. // ie_cbm1.VAO07 = "1"
  2470. // ie_cbm1.VAO10 = "0"
  2471. // ie_cbm1.VAO11 = "1"
  2472. // ie_cbm1.BAK01A = sick.ContentCode
  2473. // ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  2474. // ie_cbm1.VAO15 = diagnosisConfig.ClassName
  2475. // ie_cbm1.VAO18 = "0"
  2476. // ie_cbm1.VAO22 = "1"
  2477. // ie_cbm1.IAA01 = ""
  2478. // ie_cbm1.IAD03 = ""
  2479. // ie_cbm1.BAK01B = ""
  2480. // ie_cbm1.VAO26 = ""
  2481. // ie_cbm1.IAD04 = ""
  2482. // ie_cbm1.IAD01 = ""
  2483. // ie_cbm1.VAO25 = "2"
  2484. // ie_cbm1.VAO35 = ""
  2485. // vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  2486. // }
  2487. // }
  2488. // }
  2489. // ////
  2490. // //////检验检查医嘱
  2491. // //for _, item := range prescriptions{
  2492. // // fmt.Println("6666666666666")
  2493. // // if item.Type == 2{
  2494. // // for _, subitem := range item.HisPrescriptionProject {
  2495. // // if subitem.Type == 2{
  2496. // // if subitem.HisProject.CostClassify == 3 {
  2497. // // var ie_cbm1 models.IEfour
  2498. // // ie_cbm1.VBQ01 = strconv.FormatInt(int64(item.ID), 10)
  2499. // // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  2500. // // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  2501. // // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  2502. // // ie_cbm1.VAP01 = "0"
  2503. // // ie_cbm1.VBQ07 = "0"
  2504. // // ie_cbm1.BCK01A = departmwnt.Number
  2505. // // ie_cbm1.BCK01B= "0"
  2506. // // ie_cbm1.BCE03A= ""
  2507. // // ie_cbm1.BCE01A= "0"
  2508. // // ie_cbm1.VBQ27= subitem.HisProject.ProjectName
  2509. // // ie_cbm1.VBQ28= patientPrescription.Diagnosis
  2510. // // ie_cbm1.VBQ29= ""
  2511. // // ie_cbm1.VBQ30= ""
  2512. // // vBQ1.Ie = append(vBQ1.Ie, ie_cbm1)
  2513. // // }
  2514. // //
  2515. // // }
  2516. // //
  2517. // // }
  2518. // // }
  2519. // //}
  2520. //
  2521. // root.VAO1 = vAO1
  2522. // root.VBQ1 = vBQ1
  2523. //
  2524. // xmlStr2, err := xml.MarshalIndent(root, "", " ")
  2525. // if err != nil {
  2526. // fmt.Println("转换为XML时发生错误:", err)
  2527. // return
  2528. // }
  2529. // data := make(map[string]interface{})
  2530. // data["xmlStr"] = string(xmlStr2)
  2531. // bytesData, _ := json.Marshal(data)
  2532. // var req *http.Request
  2533. // client := &http.Client{}
  2534. // fmt.Println(string(xmlStr2))
  2535. // saveLog("", string(xmlStr2), "1111", "上传明细xml", "")
  2536. //
  2537. // req, _ = http.NewRequest("POST", "http://127.0.0.1:9532/"+"nmg/coordinate/upload", bytes.NewBufferString(string(bytesData)))
  2538. // resp, _ := client.Do(req)
  2539. // defer resp.Body.Close()
  2540. // body, ioErr := ioutil.ReadAll(resp.Body)
  2541. // if ioErr != nil {
  2542. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2544. // return
  2545. // }
  2546. // var respJSON map[string]interface{}
  2547. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2548. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2550. // return
  2551. // }
  2552. //
  2553. // respJSON3 := respJSON["data"].(map[string]interface{})["msg"].(string)
  2554. // respJSON4 := respJSON["data"].(map[string]interface{})["res"].(string)
  2555. //
  2556. // if respJSON3 == "成功" {
  2557. //
  2558. // //if li.Acf01 != 1{
  2559. // // //记账
  2560. // // result2, request2 := service.NMGSettleForCoordinate(info)
  2561. // // saveLog(result2, request2, "记账", "记账", org.OrgName)
  2562. // //
  2563. // //
  2564. // // //data := make(map[string]interface{})
  2565. // // //data["info"] = &info
  2566. // // //
  2567. // // //fmt.Println(data)
  2568. // // //
  2569. // // //bytesData, _ := json.Marshal(data)
  2570. // // //var req *http.Request
  2571. // // //
  2572. // // //client := &http.Client{}
  2573. // // //
  2574. // // //req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/settle", bytes.NewReader(bytesData))
  2575. // // //resp, _ := client.Do(req)
  2576. // // //defer resp.Body.Close()
  2577. // // //body, ioErr := ioutil.ReadAll(resp.Body)
  2578. // // //if ioErr != nil {
  2579. // // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2580. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2581. // // // return
  2582. // // //}
  2583. // // //var respJSON map[string]interface{}
  2584. // // //if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2585. // // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2586. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2587. // // // return
  2588. // // //}
  2589. // // //
  2590. // // //respJSON = respJSON["data"].(map[string]interface{})["res"].(map[string]interface{})
  2591. // // //userJSONBytes, _ := json.Marshal(respJSON)
  2592. // // //
  2593. // // //var res2 ResultUpload2
  2594. // // //if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  2595. // // // utils.ErrorLog("解析失败:%v", err)
  2596. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. // // // return
  2598. // // //}
  2599. // // //if res2.Code == 500{
  2600. // // // c.ServeSuccessJSON(map[string]interface{}{
  2601. // // // "failed_code": -10,
  2602. // // // "msg": res2.Msg,
  2603. // // // })
  2604. // // // return
  2605. // // //}
  2606. // //}
  2607. // if len(zuobiao_ids) == 0 {
  2608. // zuobiao_ids = respJSON4
  2609. // } else {
  2610. // zuobiao_ids = zuobiao_ids + "," + respJSON4
  2611. // }
  2612. //
  2613. // idss = append(idss, ids...)
  2614. //
  2615. // continue
  2616. //
  2617. // } else {
  2618. // err_msg = respJSON3
  2619. // is_upload_success = false
  2620. // if len(zuobiao_ids) > 0 {
  2621. // tm := time.Unix(time.Now().Unix(), 0)
  2622. // order := &models.HisOrder{
  2623. // PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  2624. // UserOrgId: org_id,
  2625. // PatientId: patient_id,
  2626. // SettleAccountsDate: recordDateTime,
  2627. // Ctime: time.Now().Unix(),
  2628. // Mtime: time.Now().Unix(),
  2629. // Status: 1,
  2630. // OrderStatus: 1,
  2631. // MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  2632. // Number: zuobiao_ids,
  2633. // SetlId: zuobiao_ids,
  2634. // MedfeeSumamt: total,
  2635. // MedType: strconv.Itoa(int(reg_type)),
  2636. // SettleType: settle_accounts_type,
  2637. // Diagnosis: diagnosis_id,
  2638. // PType: int64(li.Acf01),
  2639. // SetlTime: tm.Format("2006-01-02 15:04:05"),
  2640. // SettleStartTime: prescriptions[start-1 : stop][0].RecordDate,
  2641. // SettleEndTime: prescriptions[start-1 : stop][len(prescriptions[start-1:stop])-1].RecordDate,
  2642. // }
  2643. // err = service.CreateOrder(order)
  2644. // if err != nil {
  2645. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  2646. // return
  2647. // }
  2648. // fmt.Println(idss)
  2649. // err = service.UpDatePrescriptionNumber(org_id, idss, zuobiao_ids)
  2650. // //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  2651. // err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  2652. //
  2653. // var zuobiao_advice models.HisZuobiaoAdvice
  2654. // zuobiao_advice.Status = 1
  2655. // zuobiao_advice.RecordDate = recordDateTime
  2656. // zuobiao_advice.PatientId = patient_id
  2657. // zuobiao_advice.Cbm01 = zuobiao_ids
  2658. // zuobiao_advice.Ctime = time.Now().Unix()
  2659. // zuobiao_advice.Mtime = time.Now().Unix()
  2660. // zuobiao_advice.Oid = order.ID
  2661. // zuobiao_advice.StartTime = recordStartTime
  2662. // zuobiao_advice.EndTime = recordEndTime
  2663. // zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  2664. // zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  2665. // zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  2666. // service.Createzuobiao(&zuobiao_advice)
  2667. // }
  2668. // }
  2669. // if is_upload_success == false {
  2670. // if len(zuobiao_ids) > 0 {
  2671. // c.ServeSuccessJSON(map[string]interface{}{
  2672. // "failed_code": -10,
  2673. // "msg": "部分处方数据上传成功,可在已上传或者在坐标系统查看。其余上传失败原因: " + err_msg,
  2674. // })
  2675. // return
  2676. //
  2677. // } else {
  2678. // c.ServeSuccessJSON(map[string]interface{}{
  2679. // "failed_code": -10,
  2680. // "msg": err_msg,
  2681. // })
  2682. // return
  2683. //
  2684. // }
  2685. //
  2686. // }
  2687. // }
  2688. //
  2689. // if is_upload_success {
  2690. // if len(zuobiao_ids) > 0 {
  2691. // tm := time.Unix(time.Now().Unix(), 0)
  2692. // order := &models.HisOrder{
  2693. // PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  2694. // UserOrgId: org_id,
  2695. // PatientId: patient_id,
  2696. // SettleAccountsDate: recordDateTime,
  2697. // Ctime: time.Now().Unix(),
  2698. // Mtime: time.Now().Unix(),
  2699. // Status: 1,
  2700. // OrderStatus: 1,
  2701. // MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  2702. // Number: zuobiao_ids,
  2703. // SetlId: zuobiao_ids,
  2704. // MedfeeSumamt: total,
  2705. // MedType: strconv.Itoa(int(reg_type)),
  2706. // SettleType: settle_accounts_type,
  2707. // Diagnosis: diagnosis_id,
  2708. // PType: int64(li.Acf01),
  2709. // SetlTime: tm.Format("2006-01-02 15:04:05"),
  2710. // SettleStartTime: prescriptions[start-1 : stop][0].RecordDate,
  2711. // SettleEndTime: prescriptions[start-1 : stop][len(prescriptions[start-1:stop])-1].RecordDate,
  2712. // }
  2713. // err = service.CreateOrder(order)
  2714. // if err != nil {
  2715. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  2716. // return
  2717. // }
  2718. // err = service.UpDatePrescriptionNumber(org_id, idss, zuobiao_ids)
  2719. // //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  2720. // err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  2721. //
  2722. // var zuobiao_advice models.HisZuobiaoAdvice
  2723. // zuobiao_advice.Status = 1
  2724. // zuobiao_advice.RecordDate = recordDateTime
  2725. // zuobiao_advice.PatientId = patient_id
  2726. // zuobiao_advice.Cbm01 = zuobiao_ids
  2727. // zuobiao_advice.Ctime = time.Now().Unix()
  2728. // zuobiao_advice.Mtime = time.Now().Unix()
  2729. // zuobiao_advice.Oid = order.ID
  2730. // zuobiao_advice.StartTime = recordStartTime
  2731. // zuobiao_advice.EndTime = recordEndTime
  2732. // zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  2733. // zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  2734. // zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  2735. // service.Createzuobiao(&zuobiao_advice)
  2736. // }
  2737. //
  2738. // c.ServeSuccessJSON(map[string]interface{}{
  2739. // "msg": "上传成功",
  2740. // })
  2741. //
  2742. // } else {
  2743. // c.ServeSuccessJSON(map[string]interface{}{
  2744. // "failed_code": -10,
  2745. // "msg": err_msg,
  2746. // })
  2747. //
  2748. // }
  2749. //
  2750. // //zuobiao, _ := service.Getzuobiao(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2751. //
  2752. // //is_success := true
  2753. // //failed_mag := ""
  2754. // //查询出对应的坐标系统医嘱id,先进行删除操作,在创建医嘱。如果没有医嘱id,则直接创建医嘱
  2755. // //if zuobiao.ID > 0 {
  2756. // // cbm01s := strings.Split(zuobiao.Cbm01, ",")
  2757. // // fmt.Println(cbm01s)
  2758. // //
  2759. // // for _, iditem := range cbm01s {
  2760. // // fmt.Println(iditem)
  2761. // // var root2 models.Root2
  2762. // // var tradeInfo2 models.TradeInfo
  2763. // // if li.Acf01 == 1 {
  2764. // // tradeInfo2.PatSource = 1
  2765. // // tradeInfo2.Type = 0
  2766. // // } else {
  2767. // // tradeInfo2.PatSource = 2
  2768. // // tradeInfo2.Type = 1
  2769. // //
  2770. // // }
  2771. // // tradeInfo2.Detpid = departmwnt.Number
  2772. // // tradeInfo2.Empid = doctor_info.DoctorNumber
  2773. // // tradeInfo2.Empno = doctor_info.DoctorCode
  2774. // // tradeInfo2.Empname = doctor_info.UserName
  2775. // // var vaf01 models.VAF10
  2776. // // var ie1111 models.IEfive
  2777. // // ie1111.VAF01 = iditem
  2778. // // vaf01.Ie = append(vaf01.Ie, ie1111)
  2779. // // root2.TradeInfo = tradeInfo2
  2780. // // root2.VAF1 = vaf01
  2781. // // xmlStr2, err := xml.MarshalIndent(root2, "", " ")
  2782. // // if err != nil {
  2783. // // fmt.Println("转换为XML时发生错误:", err)
  2784. // // return
  2785. // // }
  2786. // // data := make(map[string]interface{})
  2787. // // data["xmlStr"] = string(xmlStr2)
  2788. // // bytesData, _ := json.Marshal(data)
  2789. // // client := &http.Client{}
  2790. // //
  2791. // // var req *http.Request
  2792. // //
  2793. // //
  2794. // // req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/del", bytes.NewReader(bytesData))
  2795. // // resp, _ := client.Do(req)
  2796. // // defer resp.Body.Close()
  2797. // // body, ioErr := ioutil.ReadAll(resp.Body)
  2798. // // if ioErr != nil {
  2799. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2800. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2801. // // return
  2802. // // }
  2803. // // var respJSON map[string]interface{}
  2804. // // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2805. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2806. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2807. // // return
  2808. // // }
  2809. // //
  2810. // // respJSON2 := respJSON["data"].(map[string]interface{})["msg"].(string)
  2811. // // fmt.Println( respJSON)
  2812. // // fmt.Println( respJSON["data"].(map[string]interface{}))
  2813. // // fmt.Println(respJSON2)
  2814. // //
  2815. // // if respJSON2 != "成功"{
  2816. // // //is_success = false
  2817. // // failed_mag = respJSON2
  2818. // // }
  2819. // // }
  2820. // //}
  2821. //
  2822. // } else {
  2823. //
  2824. // c.ServeSuccessJSON(map[string]interface{}{
  2825. // "failed_code": -10,
  2826. // "msg": res.Msg,
  2827. // })
  2828. // }
  2829. //}
  2830. func classifyPrescriptions(prescriptions []models.HisPrescription) (drugPrescriptions, consumablePrescriptions []models.HisPrescription) {
  2831. for _, prescription := range prescriptions {
  2832. switch prescription.Type {
  2833. case 1:
  2834. drugPrescriptions = append(drugPrescriptions, prescription)
  2835. case 2:
  2836. consumablePrescriptions = append(consumablePrescriptions, prescription)
  2837. }
  2838. }
  2839. return drugPrescriptions, consumablePrescriptions
  2840. }
  2841. func summarizePrescriptions(prescriptions []models.HisPrescription) []models.HisDoctorAdviceInfo {
  2842. ungroupedDrugs := make([]models.HisDoctorAdviceInfo, 0)
  2843. groupedPrescriptions := make([]models.HisPrescription, 0)
  2844. for _, prescription := range prescriptions {
  2845. groupedDrugsInPrescription, ungroupedDrugsInPrescription := splitDrugsByGroup(prescription.HisDoctorAdviceInfo)
  2846. // 将没有同组药的药品汇总到一张处方
  2847. ungroupedDrugs = append(ungroupedDrugs, ungroupedDrugsInPrescription...)
  2848. //将有同组药的每组药品拆分成一张处方
  2849. for _, group := range groupedDrugsInPrescription {
  2850. fmt.Println("333333")
  2851. fmt.Println(group)
  2852. groupedPrescriptions = append(groupedPrescriptions, models.HisPrescription{
  2853. HisDoctorAdviceInfo: group,
  2854. })
  2855. }
  2856. }
  2857. return ungroupedDrugs
  2858. }
  2859. func summarizePrescriptionsTwo(prescriptions []models.HisPrescription) []models.HisPrescription {
  2860. //ungroupedDrugs := make([]models.HisDoctorAdviceInfo, 0)
  2861. groupedPrescriptions := make([]models.HisPrescription, 0)
  2862. for _, prescription := range prescriptions {
  2863. groupedDrugsInPrescription, _ := splitDrugsByGroup(prescription.HisDoctorAdviceInfo)
  2864. //fmt.Println("111111")
  2865. //fmt.Println(len(ungroupedDrugsInPrescription))
  2866. //fmt.Println(len(groupedDrugsInPrescription))
  2867. // 将没有同组药的药品汇总到一张处方
  2868. //ungroupedDrugs = append(ungroupedDrugs, ungroupedDrugsInPrescription...)
  2869. //将有同组药的每组药品拆分成一张处方
  2870. for _, group := range groupedDrugsInPrescription {
  2871. groupedPrescriptions = append(groupedPrescriptions, models.HisPrescription{
  2872. HisDoctorAdviceInfo: group,
  2873. })
  2874. }
  2875. }
  2876. return groupedPrescriptions
  2877. }
  2878. func splitDrugsByGroup(drugs []models.HisDoctorAdviceInfo) (groupedDrugs [][]models.HisDoctorAdviceInfo, ungroupedDrugs []models.HisDoctorAdviceInfo) {
  2879. groups := make(map[int64][]models.HisDoctorAdviceInfo)
  2880. // 将药品按照组号分组
  2881. for _, drug := range drugs {
  2882. groups[drug.Groupno] = append(groups[drug.Groupno], drug)
  2883. }
  2884. // 遍历分组,将同组药和没有同组药的分开
  2885. for _, group := range groups {
  2886. if len(group) > 1 {
  2887. // 同组药
  2888. groupedDrugs = append(groupedDrugs, group)
  2889. } else {
  2890. // 没有同组药
  2891. ungroupedDrugs = append(ungroupedDrugs, group...)
  2892. }
  2893. }
  2894. return groupedDrugs, ungroupedDrugs
  2895. }
  2896. //上传费用
  2897. func (c *CoordinateController) NMGSettleAccount() {
  2898. patient_id, _ := c.GetInt64("patient_id")
  2899. record_date := c.GetString("record_date")
  2900. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2901. diagnosis_id := c.GetString("diagnosis")
  2902. sick_type, _ := c.GetInt64("sick_type")
  2903. reg_type, _ := c.GetInt64("p_type")
  2904. org_id, _ := c.GetInt64("org_id")
  2905. p_id, _ := c.GetInt64("p_id")
  2906. charge_type, _ := c.GetInt64("charge_type")
  2907. org_id = 10206
  2908. org, _ := service.GetOrgById(org_id)
  2909. patient, _ := service.GetPatientByID(org.Id, patient_id)
  2910. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2911. var res8 Data
  2912. var li ListItem
  2913. if charge_type == 1{
  2914. res8 = NMGmenzhen(c, patient.Name)
  2915. var res9 Data
  2916. var res11 Data
  2917. res9.List = append(res9.List, res8.List...)
  2918. // 获取当前时间
  2919. //var maxTimestamp int64
  2920. // 定义一个变量来保存离当前时间最近的数据
  2921. //var closestData MyData
  2922. //var closestTimeDiff time.Duration
  2923. // 遍历切片,找到离当前时间最近的数据
  2924. //for _, data := range res9.List {
  2925. // // 将时间字符串解析为 time.Time 类型
  2926. // timeObj, err := time.Parse("2006-01-02 15:04:05", data.Vae11)
  2927. // if err != nil {
  2928. // fmt.Println("时间解析错误:", err)
  2929. // continue
  2930. // }
  2931. // // 获取时间戳
  2932. // timestamp := timeObj.Unix()
  2933. // // 比较时间戳
  2934. // if timestamp > maxTimestamp {
  2935. // maxTimestamp = timestamp
  2936. // }
  2937. //}
  2938. //
  2939. //fmt.Println(maxTimestamp)
  2940. for _,item := range res9.List{
  2941. if item.Bck01B == 38{
  2942. res11.List = append(res11.List,item)
  2943. }
  2944. }
  2945. sort.Slice(res11.List, func(i, j int) bool {
  2946. // 将时间字符串解析为 time.Time 类型
  2947. timeObj1, err1 := time.Parse("2006-01-02 15:04:05", res11.List[i].Vae11)
  2948. timeObj2, err2 := time.Parse("2006-01-02 15:04:05", res11.List[j].Vae11)
  2949. // 错误处理
  2950. if err1 != nil || err2 != nil {
  2951. fmt.Println("时间解析错误:", err1, err2)
  2952. return false
  2953. }
  2954. // 比较时间
  2955. return timeObj1.Before(timeObj2)
  2956. })
  2957. fmt.Println("按照时间排序qian的数据:", res11.List)
  2958. cure_date := strings.Split(res11.List[len(res11.List)-1].Vae11, " ")
  2959. // 将日期字符串解析为 time.Time 类型
  2960. date1, err := time.Parse("2006-01-02", cure_date[0])
  2961. if err != nil {
  2962. fmt.Println("日期解析错误:", err)
  2963. return
  2964. }
  2965. currentTime := time.Now()
  2966. // 使用 Format 方法格式化输出为 yyyy-mm-dd
  2967. formattedDate := currentTime.Format("2006-01-02")
  2968. date2, err := time.Parse("2006-01-02", formattedDate)
  2969. if err != nil {
  2970. fmt.Println("日期解析错误:", err)
  2971. return
  2972. }
  2973. duration := date2.Sub(date1)
  2974. fmt.Println("cha:", duration)
  2975. if duration.Hours() < 72 && patient.Name == res11.List[len(res11.List)-1].Vaa05 {
  2976. li = res11.List[len(res11.List)-1]
  2977. }
  2978. }else{
  2979. res8 = NMGzhuyuan(c, patient.Name)
  2980. var res10 Data
  2981. //res9.List = append(res9.List, res.List...)
  2982. res10.List = append(res10.List, res8.List...)
  2983. layout := "2006-01-02 15:04:05"
  2984. var maxDate time.Time
  2985. for _, item := range res10.List {
  2986. currentDate, err := time.Parse(layout, item.Vae11)
  2987. if err != nil {
  2988. fmt.Println("Error parsing date:", err)
  2989. continue
  2990. }
  2991. if currentDate.After(maxDate) {
  2992. maxDate = currentDate
  2993. }
  2994. if !maxDate.IsZero() {
  2995. fmt.Println("The maximum date is:", maxDate.Format(layout))
  2996. } else {
  2997. fmt.Println("No valid dates found")
  2998. }
  2999. }
  3000. fmt.Println(maxDate.Format("2006-01-02 15:04:05"))
  3001. for _, item := range res10.List {
  3002. if item.Vae11 == maxDate.Format("2006-01-02 15:04:05") && patient.Name == item.Vaa05 {
  3003. li = item
  3004. }
  3005. }
  3006. }
  3007. if res8.Code == 200 {
  3008. timeLayout := "2006-01-02"
  3009. loc, _ := time.LoadLocation("Local")
  3010. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  3011. if err != nil {
  3012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3013. return
  3014. }
  3015. org_id := org.Id
  3016. recordDateTime := theTime.Unix()
  3017. patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  3018. if patientPrescription.ID == 0 {
  3019. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  3020. }
  3021. departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3022. //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  3023. doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  3024. var recordStartTime int64
  3025. var recordEndTime int64
  3026. var prescriptions []models.HisPrescription
  3027. if settle_accounts_type == 1 { //日结
  3028. prescriptions, _ = service.GetUnSettleHisPrescriptionFiveone(p_id)
  3029. var total float64
  3030. var customs []*models.NewCustomTwo
  3031. for _, item := range prescriptions {
  3032. if item.Type == 1 { //药品
  3033. for _, subItem := range item.HisDoctorAdviceInfo {
  3034. tempTime := time.Unix(item.PreTime, 0)
  3035. //timeFormat := tempTime.Format("20060102150405")
  3036. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3037. cus := &models.NewCustomTwo{
  3038. AdviceId: subItem.ID,
  3039. ProjectId: 0,
  3040. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  3041. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  3042. FeedetlSn: subItem.FeedetlSn,
  3043. Price: fmt.Sprintf("%.2f", subItem.Price),
  3044. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  3045. Type: 1,
  3046. ItemId: subItem.BaseDrugLib.ZuobiaoId,
  3047. StartTime: timeFormatOne,
  3048. Content: subItem.AdviceName,
  3049. Bby01: subItem.BaseDrugLib.Bby01,
  3050. }
  3051. customs = append(customs, cus)
  3052. }
  3053. }
  3054. if item.Type == 2 { //项目
  3055. for _, subItem := range item.HisPrescriptionProject {
  3056. if subItem.Type == 2 {
  3057. tempTime := time.Unix(item.PreTime, 0)
  3058. //timeFormat := tempTime.Format("20060102150405")
  3059. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3060. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3061. cus := &models.NewCustomTwo{
  3062. AdviceId: 0,
  3063. ProjectId: subItem.ID,
  3064. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  3065. Cut: fmt.Sprintf("%.4f", cnt),
  3066. FeedetlSn: subItem.FeedetlSn,
  3067. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  3068. MedListCodg: subItem.HisProject.MedicalCode,
  3069. Type: 2,
  3070. ItemId: subItem.HisProject.ZuobiaoId,
  3071. StartTime: timeFormatOne,
  3072. Content: subItem.HisProject.ProjectName,
  3073. Bby01: subItem.HisProject.Bby01,
  3074. }
  3075. customs = append(customs, cus)
  3076. } else {
  3077. tempTime := time.Unix(item.PreTime, 0)
  3078. //timeFormat := tempTime.Format("20060102150405")
  3079. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3080. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3081. cus := &models.NewCustomTwo{
  3082. AdviceId: 0,
  3083. ProjectId: subItem.ID,
  3084. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  3085. Cut: fmt.Sprintf("%.4f", cnt),
  3086. FeedetlSn: subItem.FeedetlSn,
  3087. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  3088. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  3089. Type: 3,
  3090. ItemId: subItem.GoodInfo.ZuobiaoId,
  3091. StartTime: timeFormatOne,
  3092. Content: subItem.GoodInfo.GoodName,
  3093. Bby01: subItem.GoodInfo.Bby01,
  3094. }
  3095. customs = append(customs, cus)
  3096. }
  3097. }
  3098. }
  3099. }
  3100. for _, item := range prescriptions {
  3101. if item.Type == 1 { //药品
  3102. for _, subItem := range item.HisDoctorAdviceInfo {
  3103. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  3104. total_one := price * subItem.PrescribingNumber
  3105. fmt.Println("subItem")
  3106. fmt.Println(subItem.Price)
  3107. fmt.Println("price")
  3108. fmt.Println(price)
  3109. fmt.Println("total_one")
  3110. fmt.Println(total_one)
  3111. total = total + total_one
  3112. fmt.Println(total)
  3113. }
  3114. }
  3115. if item.Type == 2 { //项目
  3116. for _, subItem := range item.HisPrescriptionProject {
  3117. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3118. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  3119. total_one := price * cnt
  3120. total = total + total_one
  3121. }
  3122. }
  3123. }
  3124. //allTotal := fmt.Sprintf("%2f", total)
  3125. var info models.UploadInfo
  3126. info.Acf01 = int64(li.Acf01)
  3127. info.Bce01 = "132"
  3128. info.Bck01 = "48"
  3129. info.Vaa07 = int64(li.Vaa07)
  3130. info.Vaa01 = int64(li.Vaa01)
  3131. info.Vaa05 = li.Vaa05
  3132. info.Bce01a = doctor_info.DoctorNumber
  3133. for _, item := range customs {
  3134. var cha models.ChargeListtwo
  3135. cnt, _ := strconv.ParseFloat(item.Cut, 64)
  3136. Bby01, _ := strconv.ParseInt(item.Bby01, 10, 64)
  3137. cha.Bby01 = Bby01
  3138. cha.Vaj25 = cnt
  3139. info.ChargeListtwo = append(info.ChargeListtwo, &cha)
  3140. }
  3141. //日结处方进行拆分处理
  3142. var big_ps []models.HisPrescription
  3143. drugPrescriptions, consumablePrescriptions := classifyPrescriptions(prescriptions)
  3144. groupDrugPrescriptions := summarizePrescriptionsTwo(drugPrescriptions)
  3145. //非没同组药品,汇总处理
  3146. var doc_two []models.HisDoctorAdviceInfo
  3147. var doc []models.HisDoctorAdviceInfo
  3148. doc = summarizePrescriptions(drugPrescriptions)
  3149. fmt.Println(groupDrugPrescriptions)
  3150. fmt.Println(doc)
  3151. fmt.Println(consumablePrescriptions)
  3152. var no_group_drug_ps models.HisPrescription
  3153. no_group_drug_ps.MedType = "110"
  3154. no_group_drug_ps.ID = int64(rand.Intn(90000) + 10000)
  3155. no_group_drug_ps.Type = 1
  3156. for _ ,sumitem := range doc{
  3157. rand.Seed(time.Now().UnixNano())
  3158. // 生成4位随机数
  3159. randomNumber := rand.Intn(9000) + 1000
  3160. sumitem.Groupno = sumitem.Groupno + int64(randomNumber)
  3161. //doc = append(doc, sumitem.HisDoctorAdviceInfo...)
  3162. }
  3163. doc_two = RemoveRepeatedPurviewElementdrug(doc)
  3164. var dos []models.HisDoctorAdviceInfo
  3165. for _, pro := range doc_two {
  3166. var ppp models.HisDoctorAdviceInfo
  3167. var count float64
  3168. var drugWayCount float64
  3169. for _, pro_two := range doc {
  3170. if pro.BaseDrugLib.ZuobiaoId == pro_two.BaseDrugLib.ZuobiaoId && pro.BaseDrugLib.Bby01 == pro_two.BaseDrugLib.Bby01 && pro.DeliveryWay == pro_two.DeliveryWay {
  3171. ppp = pro_two
  3172. count = count + pro_two.PrescribingNumber
  3173. if len(pro_two.DrugWayCount) == 0{
  3174. pro_two.DrugWayCount = "1"
  3175. }
  3176. result, _ := strconv.ParseFloat(pro_two.DrugWayCount, 64)
  3177. drugWayCount = drugWayCount + result
  3178. }
  3179. }
  3180. ppp.PrescribingNumber = count
  3181. ppp.DrugWayCount = strconv.FormatFloat(drugWayCount, 'f', -1, 64)
  3182. dos = append(dos, ppp)
  3183. }
  3184. if len(dos) > 0 {
  3185. no_group_drug_ps.HisDoctorAdviceInfo = dos
  3186. big_ps = append(big_ps, no_group_drug_ps)
  3187. }
  3188. //同组药品不需要进行汇总
  3189. for _, item := range groupDrugPrescriptions {
  3190. if len(item.HisDoctorAdviceInfo) > 0 {
  3191. var group_drug_ps models.HisPrescription
  3192. group_drug_ps.MedType = "110"
  3193. group_drug_ps.ID = int64(rand.Intn(90000) + 10000)
  3194. group_drug_ps.Type = 1
  3195. group_drug_ps.HisDoctorAdviceInfo = item.HisDoctorAdviceInfo
  3196. big_ps = append(big_ps, group_drug_ps)
  3197. }
  3198. }
  3199. //耗材和项目汇总
  3200. var projects []models.HisPrescriptionProject
  3201. var goods []models.HisPrescriptionProject
  3202. var checks []models.HisPrescriptionProject
  3203. var projects_two []models.HisPrescriptionProject
  3204. var goods_two []models.HisPrescriptionProject
  3205. for _, item := range consumablePrescriptions {
  3206. for _, subitem := range item.HisPrescriptionProject {
  3207. if subitem.Type == 2 {
  3208. if subitem.HisProject.CostClassify == 3{
  3209. checks = append(checks, subitem)
  3210. }else{
  3211. projects = append(projects, subitem)
  3212. }
  3213. } else if subitem.Type == 3 {
  3214. goods = append(goods, subitem)
  3215. }
  3216. }
  3217. }
  3218. projects_two = RemoveRepeatedPurviewElementproject(projects)
  3219. goods_two = RemoveRepeatedPurviewElementgood(goods)
  3220. //checks_two = RemoveRepeatedPurviewElementgood(checks)
  3221. var new_pros []models.HisPrescriptionProject
  3222. var new_goods []models.HisPrescriptionProject
  3223. var new_checks []models.HisPrescriptionProject
  3224. for _, pro := range projects_two {
  3225. var ppp models.HisPrescriptionProject
  3226. var count float64
  3227. for _, pro_two := range projects {
  3228. if pro.HisProject.ZuobiaoId == pro_two.HisProject.ZuobiaoId && pro.HisProject.Bby01 == pro_two.HisProject.Bby01 {
  3229. ppp = pro_two
  3230. result, _ := strconv.ParseFloat(pro_two.Count, 64)
  3231. count = count + result
  3232. }
  3233. }
  3234. ppp.Count = strconv.FormatFloat(count, 'f', -1, 64)
  3235. new_pros = append(new_pros, ppp)
  3236. }
  3237. for _, good := range goods_two {
  3238. var ppp models.HisPrescriptionProject
  3239. var count float64
  3240. for _, good_two := range goods {
  3241. if good.GoodInfo.ZuobiaoId == good_two.GoodInfo.ZuobiaoId && good.GoodInfo.Bby01 == good_two.GoodInfo.Bby01 {
  3242. ppp = good_two
  3243. result, _ := strconv.ParseFloat(good_two.Count, 64)
  3244. count = count + result
  3245. }
  3246. }
  3247. ppp.Count = strconv.FormatFloat(count, 'f', -1, 64)
  3248. new_goods = append(new_goods, ppp)
  3249. }
  3250. for _, check := range checks {
  3251. var ppp models.HisPrescriptionProject
  3252. ppp = check
  3253. ppp.Count = check.Count
  3254. new_checks = append(new_checks, ppp)
  3255. }
  3256. if len(new_goods) > 0 {
  3257. var ps1 models.HisPrescription
  3258. ps1.MedType = "120"
  3259. ps1.ID = int64(rand.Intn(90000) + 10000)
  3260. ps1.Type = 2
  3261. ps1.HisPrescriptionProject = append(ps1.HisPrescriptionProject, new_goods...)
  3262. big_ps = append(big_ps, ps1)
  3263. }
  3264. if len(new_pros) > 0 {
  3265. var ps2 models.HisPrescription
  3266. ps2.MedType = "130"
  3267. ps2.Type = 2
  3268. ps2.ID = int64(rand.Intn(90000) + 10000)
  3269. ps2.HisPrescriptionProject = append(ps2.HisPrescriptionProject, new_pros...)
  3270. big_ps = append(big_ps, ps2)
  3271. }
  3272. if len(new_checks) > 0 {
  3273. var ps3 models.HisPrescription
  3274. ps3.MedType = "140"
  3275. ps3.Type = 2
  3276. ps3.ID = int64(rand.Intn(90000) + 10000)
  3277. ps3.HisPrescriptionProject = append(ps3.HisPrescriptionProject, new_checks...)
  3278. big_ps = append(big_ps, ps3)
  3279. }
  3280. ////信息
  3281. var is_upload_success bool = true
  3282. var curpage int
  3283. var pagesize int = len(big_ps)
  3284. var start int = 1
  3285. var stop int
  3286. var zuobiao_ids string
  3287. var err_msg string
  3288. var idss []int64
  3289. //pagecount := 10
  3290. pagecount := int(math.Ceil(float64(len(big_ps)) / float64(pagesize)))
  3291. for curpage = 1; curpage <= pagecount; curpage++ {
  3292. var root models.Root
  3293. var tradeInfo models.TradeInfo
  3294. var cBM1 models.CBM1
  3295. var vAF1 models.VAF1
  3296. var vAO1 models.VAO1
  3297. var vBQ1 models.VBQ1
  3298. if li.Acf01 == 1 {
  3299. tradeInfo.PatSource = 1
  3300. tradeInfo.Type = 0
  3301. } else {
  3302. tradeInfo.PatSource = 2
  3303. tradeInfo.Type = 1
  3304. }
  3305. tradeInfo.Detpid = departmwnt.Number
  3306. tradeInfo.Empid = doctor_info.DoctorNumber
  3307. tradeInfo.Empno = doctor_info.DoctorCode
  3308. tradeInfo.Empname = doctor_info.UserName
  3309. root.TradeInfo = tradeInfo
  3310. if curpage == 1 {
  3311. start = 1
  3312. } else {
  3313. start = (curpage-1)*pagesize + 1
  3314. }
  3315. stop = curpage * pagesize
  3316. if stop > len(big_ps) {
  3317. stop = len(big_ps)
  3318. }
  3319. //var ids []int64
  3320. //
  3321. //for _, item := range prescriptions[start-1 : stop] {
  3322. // ids = append(ids, item.ID)
  3323. //}
  3324. for _, item := range big_ps[start-1 : stop] {
  3325. //departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  3326. var ie_cbm1 models.IEone
  3327. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3328. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3329. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  3330. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  3331. //ie_cbm1.CBM06 = strconv.FormatInt(int64(res.List[0].Acf01), 10)
  3332. if li.Acf01 == 1 {
  3333. if item.MedType == "140"{
  3334. ie_cbm1.CBM06 = "9"
  3335. }
  3336. if item.MedType == "110"{
  3337. ie_cbm1.CBM06 = "1"
  3338. }
  3339. if item.MedType == "120"{
  3340. ie_cbm1.CBM06 = "1"
  3341. }
  3342. if item.MedType == "130"{
  3343. ie_cbm1.CBM06 = "6"
  3344. }
  3345. ie_cbm1.BCK01A = "0"
  3346. } else {
  3347. ie_cbm1.CBM06 = "0"
  3348. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10) //病区id
  3349. }
  3350. if item.MedType == "140"{
  3351. ie_cbm1.CBM07 = "10"
  3352. }
  3353. if item.MedType == "110"{
  3354. ie_cbm1.CBM07 = "1"
  3355. }
  3356. if item.MedType == "120"{
  3357. ie_cbm1.CBM07 = "1"
  3358. }
  3359. if item.MedType == "130"{
  3360. ie_cbm1.CBM07 = "12"
  3361. }
  3362. ie_cbm1.BCK01B = strconv.FormatInt(int64(li.Bck01B), 10)
  3363. ie_cbm1.BCK01C = "38"
  3364. ie_cbm1.CBM19 = "0"
  3365. cBM1.Ie = append(cBM1.Ie, ie_cbm1)
  3366. }
  3367. root.CBM1 = cBM1
  3368. ////医嘱
  3369. for _, item := range big_ps[start-1 : stop] {
  3370. //departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  3371. if item.Type == 1 {
  3372. //组号去重
  3373. //temphisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  3374. // 使用 map 来存储 groupno 的数量
  3375. //groupCount := make(map[int64]int64)
  3376. // 使用 map 来存储 groupno 的数量和最后一条数据的索引
  3377. groupInfo := make(map[int64]struct {
  3378. Count int64
  3379. LastElement int
  3380. })
  3381. // 遍历切片,计算 groupno 的数量和最后一条数据的索引
  3382. for i, obj := range item.HisDoctorAdviceInfo {
  3383. info, ok := groupInfo[obj.Groupno]
  3384. if !ok {
  3385. info = struct {
  3386. Count int64
  3387. LastElement int
  3388. }{}
  3389. }
  3390. info.Count++
  3391. info.LastElement = i
  3392. groupInfo[obj.Groupno] = info
  3393. }
  3394. // 根据 groupno 的数量设置字段值
  3395. for i, obj := range item.HisDoctorAdviceInfo {
  3396. info := groupInfo[obj.Groupno]
  3397. if info.Count < 2 {
  3398. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  3399. } else {
  3400. // 对于数量大于等于 2 的,将最后一条数据设置 1,其他设置为随机数
  3401. if i == info.LastElement {
  3402. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  3403. } else {
  3404. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(obj.ID, 10)
  3405. }
  3406. }
  3407. }
  3408. for _, subitem := range item.HisDoctorAdviceInfo {
  3409. var ie_cbm1 models.IEtwo
  3410. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3411. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  3412. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3413. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  3414. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  3415. ie_cbm1.ROWNR = subitem.NewGroupno
  3416. ie_cbm1.VAF10 = "1"
  3417. ie_cbm1.VAF11 = "2"
  3418. ie_cbm1.BDA01 = "1" //诊疗类型
  3419. ie_cbm1.BBX01 = subitem.BaseDrugLib.ZuobiaoId
  3420. ie_cbm1.VAF14 = "" //检验样本类型
  3421. ie_cbm1.VAF15 = ""
  3422. ie_cbm1.BBY01 = subitem.BaseDrugLib.Bby01 //药品规格id或材料规格id
  3423. if li.Acf01 == 1 {
  3424. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10)
  3425. } else {
  3426. ie_cbm1.VAF17 = "0"
  3427. }
  3428. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  3429. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  3430. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  3431. ie_cbm1.VAF21 = fmt.Sprintf("%.2f", subitem.PrescribingNumber)
  3432. ie_cbm1.VAF22 = subitem.AdviceName + " " + subitem.BaseDrugLib.DrugSpec
  3433. ie_cbm1.Crypt = "0"
  3434. ie_cbm1.VAF23 = ""
  3435. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  3436. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  3437. ie_cbm1.VAF27 = "1"
  3438. ie_cbm1.VAF28 = "1"
  3439. ie_cbm1.VAF29 = "1"
  3440. ie_cbm1.VAF30 = ""
  3441. ie_cbm1.VAF31 = "0"
  3442. ie_cbm1.VAF32 = "0" //todo
  3443. ie_cbm1.VAF33 = "0"
  3444. ie_cbm1.VAF34 = "0"
  3445. ie_cbm1.VAF35 = "0"
  3446. tempTime1 := time.Unix(subitem.StartTime, 0)
  3447. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  3448. ie_cbm1.VAF36 = timeFormatOne
  3449. ie_cbm1.VAF37 = "1899-12-30"
  3450. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  3451. ie_cbm1.BCK01C = "38"
  3452. ie_cbm1.BCE02A = doctor_info.DoctorCode
  3453. ie_cbm1.BCE03A = doctor_info.UserName
  3454. ie_cbm1.BCE03B = ""
  3455. ie_cbm1.VAF53 = "-1"
  3456. ie_cbm1.VAF55 = subitem.Remark
  3457. ie_cbm1.BCK01D = "38"
  3458. ie_cbm1.VAF58 = "0"
  3459. ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno), 10)
  3460. ie_cbm1.VAF60 = ""
  3461. ie_cbm1.VAF61 = "1"
  3462. ie_cbm1.VAF62 = "0"
  3463. ie_cbm1.LSign = "0"
  3464. ie_cbm1.BDA01A = ie_cbm1.BDA01
  3465. ie_cbm1.LRoute = "0"
  3466. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  3467. ie_cbm1.BCE01B = "0"
  3468. ie_cbm1.VAF01B = "0"
  3469. ie_cbm1.VCO01 = "0"
  3470. ie_cbm1.BCE01H = "0"
  3471. ie_cbm1.BCE03H = ""
  3472. ie_cbm1.BIW02 = ""
  3473. ie_cbm1.RCurrent = "0"
  3474. ie_cbm1.FCheck = "0"
  3475. ie_cbm1.UnameA = ""
  3476. ie_cbm1.VEH02 = ""
  3477. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  3478. }
  3479. hisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  3480. //每种药品下的给药途径
  3481. for _, subitem := range hisDoctorAdviceInfo {
  3482. way, _ := service.GetDrugwayDicByName(subitem.DeliveryWay, c.GetAdminUserInfo().CurrentOrgId)
  3483. var ie_cbm1 models.IEtwo
  3484. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3485. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  3486. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3487. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  3488. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  3489. ie_cbm1.ROWNR = "0"
  3490. ie_cbm1.VAF10 = "1"
  3491. ie_cbm1.VAF11 = "2"
  3492. ie_cbm1.BDA01 = "T" //诊疗类型
  3493. ie_cbm1.BBX01 = way.Code
  3494. ie_cbm1.VAF14 = "" //检验样本类型
  3495. ie_cbm1.VAF15 = "" //检验样本类型
  3496. ie_cbm1.BBY01 = way.Bby01 //药品规格id或材料规格id
  3497. if li.Acf01 == 1 {
  3498. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10) //药品规格id或材料规格id
  3499. } else {
  3500. ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
  3501. }
  3502. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  3503. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  3504. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  3505. //ie_cbm1.VAF21 = fmt.Sprintf("%.2f",subitem.PrescribingNumber)
  3506. //ie_cbm1.VAF18 = "" //药品规格id或材料规格id
  3507. //ie_cbm1.VAF19 = ""
  3508. //ie_cbm1.VAF20 = ""
  3509. if subitem.DrugWayCount == "" {
  3510. ie_cbm1.VAF21 = "1"
  3511. } else {
  3512. ie_cbm1.VAF21 = subitem.DrugWayCount
  3513. }
  3514. ie_cbm1.VAF22 = way.Name
  3515. ie_cbm1.Crypt = "0"
  3516. ie_cbm1.VAF23 = ""
  3517. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  3518. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  3519. ie_cbm1.VAF27 = "1"
  3520. ie_cbm1.VAF28 = "1"
  3521. ie_cbm1.VAF29 = "1"
  3522. ie_cbm1.BCK01C = "38"
  3523. ie_cbm1.VAF30 = ""
  3524. ie_cbm1.VAF31 = "0"
  3525. ie_cbm1.VAF32 = "1" //todo
  3526. ie_cbm1.VAF33 = "0"
  3527. ie_cbm1.VAF34 = "0"
  3528. ie_cbm1.VAF35 = "0"
  3529. tempTime1 := time.Unix(subitem.StartTime, 0)
  3530. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  3531. ie_cbm1.VAF36 = timeFormatOne
  3532. ie_cbm1.VAF37 = "1899-12-30"
  3533. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  3534. ie_cbm1.BCE02A = doctor_info.DoctorCode
  3535. ie_cbm1.BCE03A = doctor_info.UserName
  3536. ie_cbm1.BCE03B = ""
  3537. ie_cbm1.VAF53 = "-1"
  3538. ie_cbm1.VAF55 = subitem.Remark
  3539. ie_cbm1.BCK01D = "38"
  3540. ie_cbm1.VAF58 = "0"
  3541. //ie_cbm1.VAF59 =strconv.FormatInt(int64(subitem.ID ), 10)
  3542. ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno), 10)
  3543. ie_cbm1.VAF60 = ""
  3544. ie_cbm1.VAF61 = "1"
  3545. ie_cbm1.VAF62 = "0"
  3546. ie_cbm1.LSign = "0"
  3547. ie_cbm1.BDA01A = ie_cbm1.BDA01
  3548. ie_cbm1.LRoute = "0"
  3549. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  3550. ie_cbm1.BCE01B = "0"
  3551. ie_cbm1.VAF01B = "0"
  3552. ie_cbm1.VCO01 = "0"
  3553. ie_cbm1.BCE01H = "0"
  3554. ie_cbm1.BCE03H = ""
  3555. ie_cbm1.BIW02 = ""
  3556. ie_cbm1.RCurrent = "0"
  3557. ie_cbm1.FCheck = "0"
  3558. ie_cbm1.UnameA = ""
  3559. ie_cbm1.VEH02 = ""
  3560. ie_cbm1.VAF07 = "0"
  3561. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  3562. }
  3563. } else if item.Type == 2 {
  3564. for index, subitem := range item.HisPrescriptionProject {
  3565. if subitem.Type == 2 {
  3566. if subitem.HisProject.CostClassify != 3 {
  3567. var ie_cbm1 models.IEtwo
  3568. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3569. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  3570. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3571. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  3572. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  3573. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  3574. ie_cbm1.VAF10 = "1"
  3575. ie_cbm1.VAF11 = "2"
  3576. ie_cbm1.BDA01 = "T" //诊疗类型
  3577. ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  3578. ie_cbm1.VAF14 = "" //检验样本类型
  3579. ie_cbm1.VAF15 = "" //检验样本类型
  3580. ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  3581. if li.Acf01 == 1 {
  3582. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  3583. if len(subitem.Day) == 0 {
  3584. ie_cbm1.VAF17 = "1"
  3585. }
  3586. } else {
  3587. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  3588. }
  3589. if subitem.SingleDose == "" {
  3590. subitem.SingleDose = "1"
  3591. }
  3592. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  3593. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  3594. ie_cbm1.VAF20 = subitem.SingleDose
  3595. ie_cbm1.VAF21 = subitem.Count
  3596. ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  3597. ie_cbm1.Crypt = "0"
  3598. ie_cbm1.VAF23 = ""
  3599. ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  3600. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  3601. ie_cbm1.VAF27 = "1"
  3602. ie_cbm1.VAF28 = "1"
  3603. ie_cbm1.VAF29 = ""
  3604. ie_cbm1.BCK01C = "38"
  3605. ie_cbm1.VAF30 = ""
  3606. ie_cbm1.VAF31 = "0"
  3607. ie_cbm1.VAF32 = "0" //todo
  3608. ie_cbm1.VAF33 = "0"
  3609. ie_cbm1.VAF34 = "0"
  3610. ie_cbm1.VAF35 = "0"
  3611. tempTime1 := time.Unix(subitem.StartTime, 0)
  3612. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  3613. ie_cbm1.VAF36 = timeFormatOne
  3614. ie_cbm1.VAF37 = "1899-12-30"
  3615. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  3616. ie_cbm1.BCE02A = doctor_info.DoctorCode
  3617. ie_cbm1.BCE03A = doctor_info.UserName
  3618. ie_cbm1.BCE03B = ""
  3619. ie_cbm1.VAF53 = "-1"
  3620. ie_cbm1.VAF55 = subitem.Remark
  3621. ie_cbm1.BCK01D = "38"
  3622. ie_cbm1.VAF58 = "0"
  3623. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  3624. ie_cbm1.VAF60 = ""
  3625. ie_cbm1.VAF61 = "1"
  3626. ie_cbm1.VAF62 = "0"
  3627. ie_cbm1.LSign = "0"
  3628. ie_cbm1.BDA01A = "" //诊疗类型
  3629. ie_cbm1.LRoute = "0"
  3630. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  3631. //ie_cbm1.BCE01A = doctor_info.UserName
  3632. ie_cbm1.BCE01B = "0"
  3633. ie_cbm1.VAF01B = "0"
  3634. ie_cbm1.VCO01 = "0"
  3635. ie_cbm1.BCE01H = "0"
  3636. ie_cbm1.BCE03H = ""
  3637. ie_cbm1.BIW02 = ""
  3638. ie_cbm1.RCurrent = "0"
  3639. ie_cbm1.FCheck = "0"
  3640. ie_cbm1.UnameA = ""
  3641. ie_cbm1.VAF07 = "0"
  3642. ie_cbm1.VEH02 = ""
  3643. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  3644. }
  3645. if subitem.HisProject.CostClassify == 3 {
  3646. var ie_cbm1 models.IEtwo
  3647. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3648. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  3649. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3650. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  3651. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  3652. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  3653. ie_cbm1.VAF10 = "1"
  3654. ie_cbm1.VAF11 = "2"
  3655. ie_cbm1.BDA01 = "L" //诊疗类型
  3656. ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  3657. ie_cbm1.VAF14 = subitem.HisProject.Vaf14 //检验样本类型
  3658. ie_cbm1.VAF15 = "" //检验样本类型
  3659. ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  3660. if li.Acf01 == 1 {
  3661. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  3662. } else {
  3663. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  3664. }
  3665. if subitem.SingleDose == "" {
  3666. subitem.SingleDose = "1"
  3667. }
  3668. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  3669. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  3670. ie_cbm1.VAF20 = subitem.SingleDose
  3671. ie_cbm1.VAF21 = subitem.Count
  3672. ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  3673. ie_cbm1.Crypt = "0"
  3674. ie_cbm1.VAF23 = ""
  3675. ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  3676. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  3677. ie_cbm1.VAF27 = "1"
  3678. ie_cbm1.VAF28 = "1"
  3679. ie_cbm1.VAF29 = ""
  3680. ie_cbm1.BCK01C = "38"
  3681. ie_cbm1.VAF30 = ""
  3682. ie_cbm1.VAF31 = "0"
  3683. ie_cbm1.VAF32 = "0" //todo
  3684. ie_cbm1.VAF33 = "0"
  3685. ie_cbm1.VAF34 = "0"
  3686. ie_cbm1.VAF35 = "0"
  3687. tempTime1 := time.Unix(subitem.StartTime, 0)
  3688. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  3689. ie_cbm1.VAF36 = timeFormatOne
  3690. ie_cbm1.VAF37 = "1899-12-30"
  3691. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  3692. ie_cbm1.BCE02A = doctor_info.DoctorCode
  3693. ie_cbm1.BCE03A = doctor_info.UserName
  3694. ie_cbm1.BCE03B = ""
  3695. ie_cbm1.VAF53 = "-1"
  3696. ie_cbm1.VAF55 = subitem.Remark
  3697. ie_cbm1.BCK01D = "38"
  3698. ie_cbm1.VAF58 = "0"
  3699. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  3700. ie_cbm1.VAF60 = ""
  3701. ie_cbm1.VAF61 = "1"
  3702. ie_cbm1.VAF62 = "0"
  3703. ie_cbm1.LSign = "0"
  3704. ie_cbm1.BDA01A = "" //诊疗类型
  3705. ie_cbm1.LRoute = "0"
  3706. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  3707. ie_cbm1.VAF07 = "0"
  3708. //ie_cbm1.BCE01A = doctor_info.UserName
  3709. ie_cbm1.BCE01B = "0"
  3710. ie_cbm1.VAF01B = "0"
  3711. ie_cbm1.VCO01 = "0"
  3712. ie_cbm1.BCE01H = "0"
  3713. ie_cbm1.BCE03H = ""
  3714. ie_cbm1.BIW02 = ""
  3715. ie_cbm1.RCurrent = "0"
  3716. ie_cbm1.FCheck = "0"
  3717. ie_cbm1.UnameA = ""
  3718. ie_cbm1.VEH02 = ""
  3719. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  3720. }
  3721. } else if subitem.Type == 3 {
  3722. var ie_cbm1 models.IEtwo
  3723. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3724. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  3725. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3726. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  3727. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  3728. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  3729. ie_cbm1.VAF10 = "1"
  3730. ie_cbm1.VAF11 = "2"
  3731. ie_cbm1.BDA01 = "4" //诊疗类型
  3732. ie_cbm1.BBX01 = subitem.GoodInfo.ZuobiaoId
  3733. ie_cbm1.VAF15 = "" //检验样本类型
  3734. ie_cbm1.BBY01 = subitem.GoodInfo.Bby01 //药品规格id或材料规格id
  3735. if li.Acf01 == 1 {
  3736. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  3737. if len(subitem.Day) == 0 {
  3738. ie_cbm1.VAF17 = "1"
  3739. }
  3740. } else {
  3741. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  3742. }
  3743. if subitem.SingleDose == "" {
  3744. subitem.SingleDose = "1"
  3745. }
  3746. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  3747. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  3748. ie_cbm1.VAF20 = subitem.SingleDose
  3749. ie_cbm1.VAF21 = subitem.Count
  3750. ie_cbm1.BCK01C = "38"
  3751. ie_cbm1.VAF22 = subitem.GoodInfo.GoodName + " " + subitem.GoodInfo.SpecificationName
  3752. ie_cbm1.Crypt = "0"
  3753. ie_cbm1.VAF23 = ""
  3754. ie_cbm1.BCK01B = subitem.GoodInfo.Bck01b
  3755. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  3756. ie_cbm1.VAF27 = "1"
  3757. ie_cbm1.VAF28 = "1"
  3758. ie_cbm1.VAF29 = ""
  3759. ie_cbm1.VAF07 = "0"
  3760. ie_cbm1.VAF14 = "" //检验样本类型
  3761. ie_cbm1.VAF30 = ""
  3762. ie_cbm1.VAF31 = "0"
  3763. ie_cbm1.VAF32 = "0" //todo
  3764. ie_cbm1.VAF33 = "0"
  3765. ie_cbm1.VAF34 = "0"
  3766. ie_cbm1.VAF35 = "0"
  3767. tempTime1 := time.Unix(subitem.StartTime, 0)
  3768. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  3769. ie_cbm1.VAF36 = timeFormatOne
  3770. ie_cbm1.VAF37 = "1899-12-30"
  3771. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  3772. ie_cbm1.BCE02A = doctor_info.DoctorCode
  3773. ie_cbm1.BCE03A = doctor_info.UserName
  3774. ie_cbm1.BCE03B = ""
  3775. ie_cbm1.BCK01C = "38"
  3776. ie_cbm1.VAF53 = "-1"
  3777. ie_cbm1.VAF55 = subitem.Remark
  3778. ie_cbm1.BCK01D ="38"
  3779. ie_cbm1.VAF58 = "0"
  3780. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  3781. ie_cbm1.VAF60 = ""
  3782. ie_cbm1.VAF61 = "1"
  3783. ie_cbm1.VAF62 = "0"
  3784. ie_cbm1.LSign = "0"
  3785. ie_cbm1.BDA01A = "" //诊疗类型
  3786. ie_cbm1.LRoute = "0"
  3787. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  3788. ie_cbm1.BCE01B = "0"
  3789. ie_cbm1.VAF01B = "0"
  3790. ie_cbm1.VCO01 = "0"
  3791. ie_cbm1.BCE01H = "0"
  3792. ie_cbm1.BCE03H = ""
  3793. ie_cbm1.BIW02 = ""
  3794. ie_cbm1.RCurrent = "0"
  3795. ie_cbm1.FCheck = "0"
  3796. ie_cbm1.UnameA = ""
  3797. ie_cbm1.VEH02 = ""
  3798. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  3799. }
  3800. }
  3801. }
  3802. }
  3803. root.VAF1 = vAF1
  3804. for index, item := range big_ps[start-1 : stop] {
  3805. sick, _ := service.FindSickById(sick_type)
  3806. item.VMHisPrescriptionInfo.Diagnosis = "716"
  3807. dias := strings.Split(item.VMHisPrescriptionInfo.Diagnosis, ",")
  3808. //service.get
  3809. //诊断
  3810. for _, subitem := range dias {
  3811. diagnosisConfig, _ := service.FindDiagnoseByIdtwo(subitem)
  3812. if index == 0 {
  3813. var ie_cbm1 models.IEthree
  3814. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3815. //ie_cbm1.CBMID = strconv.FormatInt(int64(index+1), 10)
  3816. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3817. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  3818. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  3819. ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  3820. ie_cbm1.VAO07 = "1"
  3821. ie_cbm1.VAO10 = "0"
  3822. ie_cbm1.VAO11 = "1"
  3823. ie_cbm1.BAK01A = sick.ContentCode
  3824. ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  3825. ie_cbm1.VAO15 = diagnosisConfig.ClassName
  3826. ie_cbm1.VAO18 = "0"
  3827. ie_cbm1.VAO22 = "1"
  3828. ie_cbm1.IAA01 = ""
  3829. ie_cbm1.IAD03 = ""
  3830. ie_cbm1.BAK01B = ""
  3831. ie_cbm1.VAO26 = ""
  3832. ie_cbm1.IAD04 = ""
  3833. ie_cbm1.IAD01 = ""
  3834. ie_cbm1.VAO25 = "1"
  3835. ie_cbm1.VAO35 = ""
  3836. vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  3837. } else {
  3838. var ie_cbm1 models.IEthree
  3839. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3840. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3841. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  3842. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  3843. ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  3844. ie_cbm1.VAO07 = "1"
  3845. ie_cbm1.VAO10 = "0"
  3846. ie_cbm1.VAO11 = "1"
  3847. ie_cbm1.BAK01A = sick.ContentCode
  3848. ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  3849. ie_cbm1.VAO15 = diagnosisConfig.ClassName
  3850. ie_cbm1.VAO18 = "0"
  3851. ie_cbm1.VAO22 = "1"
  3852. ie_cbm1.IAA01 = ""
  3853. ie_cbm1.IAD03 = ""
  3854. ie_cbm1.BAK01B = ""
  3855. ie_cbm1.VAO26 = ""
  3856. ie_cbm1.IAD04 = ""
  3857. ie_cbm1.IAD01 = ""
  3858. ie_cbm1.VAO25 = "2"
  3859. ie_cbm1.VAO35 = ""
  3860. vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  3861. }
  3862. }
  3863. }
  3864. ////
  3865. //////检验检查医嘱
  3866. //for _, item := range prescriptions{
  3867. // fmt.Println("6666666666666")
  3868. // if item.Type == 2{
  3869. // for _, subitem := range item.HisPrescriptionProject {
  3870. // if subitem.Type == 2{
  3871. // if subitem.HisProject.CostClassify == 3 {
  3872. // var ie_cbm1 models.IEfour
  3873. // ie_cbm1.VBQ01 = strconv.FormatInt(int64(item.ID), 10)
  3874. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3875. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  3876. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  3877. // ie_cbm1.VAP01 = "0"
  3878. // ie_cbm1.VBQ07 = "0"
  3879. // ie_cbm1.BCK01A = departmwnt.Number
  3880. // ie_cbm1.BCK01B= "0"
  3881. // ie_cbm1.BCE03A= ""
  3882. // ie_cbm1.BCE01A= "0"
  3883. // ie_cbm1.VBQ27= subitem.HisProject.ProjectName
  3884. // ie_cbm1.VBQ28= patientPrescription.Diagnosis
  3885. // ie_cbm1.VBQ29= ""
  3886. // ie_cbm1.VBQ30= ""
  3887. // vBQ1.Ie = append(vBQ1.Ie, ie_cbm1)
  3888. // }
  3889. //
  3890. // }
  3891. //
  3892. // }
  3893. // }
  3894. //}
  3895. root.VAO1 = vAO1
  3896. root.VBQ1 = vBQ1
  3897. xmlStr2, err := xml.MarshalIndent(root, "", " ")
  3898. if err != nil {
  3899. fmt.Println("转换为XML时发生错误:", err)
  3900. return
  3901. }
  3902. data := make(map[string]interface{})
  3903. data["xmlStr"] = string(xmlStr2)
  3904. bytesData, _ := json.Marshal(data)
  3905. var req *http.Request
  3906. client := &http.Client{}
  3907. fmt.Println(string(xmlStr2))
  3908. saveLog("", string(xmlStr2), "1111", "上传明细xml", "")
  3909. req, _ = http.NewRequest("POST", "http://127.0.0.1:9532/"+"nmg/coordinate/upload", bytes.NewBufferString(string(bytesData)))
  3910. resp, _ := client.Do(req)
  3911. defer resp.Body.Close()
  3912. body, ioErr := ioutil.ReadAll(resp.Body)
  3913. if ioErr != nil {
  3914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3916. return
  3917. }
  3918. var respJSON map[string]interface{}
  3919. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3922. return
  3923. }
  3924. respJSON3 := respJSON["data"].(map[string]interface{})["msg"].(string)
  3925. respJSON4 := respJSON["data"].(map[string]interface{})["res"].(string)
  3926. if respJSON3 == "成功" {
  3927. //if li.Acf01 != 1{
  3928. // //记账
  3929. // result2, request2 := service.NMGSettleForCoordinate(info)
  3930. // saveLog(result2, request2, "记账", "记账", org.OrgName)
  3931. //
  3932. //
  3933. // //data := make(map[string]interface{})
  3934. // //data["info"] = &info
  3935. // //
  3936. // //fmt.Println(data)
  3937. // //
  3938. // //bytesData, _ := json.Marshal(data)
  3939. // //var req *http.Request
  3940. // //
  3941. // //client := &http.Client{}
  3942. // //
  3943. // //req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/settle", bytes.NewReader(bytesData))
  3944. // //resp, _ := client.Do(req)
  3945. // //defer resp.Body.Close()
  3946. // //body, ioErr := ioutil.ReadAll(resp.Body)
  3947. // //if ioErr != nil {
  3948. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3949. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3950. // // return
  3951. // //}
  3952. // //var respJSON map[string]interface{}
  3953. // //if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3954. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3955. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3956. // // return
  3957. // //}
  3958. // //
  3959. // //respJSON = respJSON["data"].(map[string]interface{})["res"].(map[string]interface{})
  3960. // //userJSONBytes, _ := json.Marshal(respJSON)
  3961. // //
  3962. // //var res2 ResultUpload2
  3963. // //if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3964. // // utils.ErrorLog("解析失败:%v", err)
  3965. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3966. // // return
  3967. // //}
  3968. // //if res2.Code == 500{
  3969. // // c.ServeSuccessJSON(map[string]interface{}{
  3970. // // "failed_code": -10,
  3971. // // "msg": res2.Msg,
  3972. // // })
  3973. // // return
  3974. // //}
  3975. //}
  3976. if len(zuobiao_ids) == 0 {
  3977. zuobiao_ids = respJSON4
  3978. } else {
  3979. zuobiao_ids = zuobiao_ids + "," + respJSON4
  3980. }
  3981. continue
  3982. } else {
  3983. err_msg = respJSON3
  3984. is_upload_success = false
  3985. if len(zuobiao_ids) > 0 {
  3986. tm := time.Unix(time.Now().Unix(), 0)
  3987. order := &models.HisOrder{
  3988. PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  3989. UserOrgId: org_id,
  3990. PatientId: patient_id,
  3991. SettleAccountsDate: recordDateTime,
  3992. Ctime: time.Now().Unix(),
  3993. Mtime: time.Now().Unix(),
  3994. Status: 1,
  3995. OrderStatus: 1,
  3996. MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  3997. Number: zuobiao_ids,
  3998. SetlId: zuobiao_ids,
  3999. MedfeeSumamt: total,
  4000. MedType: strconv.Itoa(int(reg_type)),
  4001. SettleType: settle_accounts_type,
  4002. Diagnosis: diagnosis_id,
  4003. PType: int64(li.Acf01),
  4004. SetlTime: tm.Format("2006-01-02 15:04:05"),
  4005. SettleStartTime: recordStartTime,
  4006. SettleEndTime: recordEndTime,
  4007. }
  4008. err = service.CreateOrder(order)
  4009. if err != nil {
  4010. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  4011. return
  4012. }
  4013. fmt.Println(idss)
  4014. if settle_accounts_type == 1{
  4015. err = service.UpDatePrescriptionNumber222(org_id, p_id, zuobiao_ids,patient_id)
  4016. }else{
  4017. err = service.UpDatePrescriptionNumber111(org_id, recordStartTime,recordEndTime, zuobiao_ids,patient_id)
  4018. }
  4019. //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  4020. err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  4021. var zuobiao_advice models.HisZuobiaoAdvice
  4022. zuobiao_advice.Status = 1
  4023. zuobiao_advice.RecordDate = recordDateTime
  4024. zuobiao_advice.PatientId = patient_id
  4025. zuobiao_advice.Cbm01 = zuobiao_ids
  4026. zuobiao_advice.Ctime = time.Now().Unix()
  4027. zuobiao_advice.Mtime = time.Now().Unix()
  4028. zuobiao_advice.Oid = order.ID
  4029. zuobiao_advice.StartTime = recordStartTime
  4030. zuobiao_advice.EndTime = recordEndTime
  4031. zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4032. zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  4033. zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  4034. service.Createzuobiao(&zuobiao_advice)
  4035. }
  4036. }
  4037. if is_upload_success == false {
  4038. if len(zuobiao_ids) > 0 {
  4039. c.ServeSuccessJSON(map[string]interface{}{
  4040. "failed_code": -10,
  4041. "msg": "部分处方数据上传成功,可在已上传或者在坐标系统查看。其余上传失败原因: " + err_msg,
  4042. })
  4043. return
  4044. } else {
  4045. c.ServeSuccessJSON(map[string]interface{}{
  4046. "failed_code": -10,
  4047. "msg": err_msg,
  4048. })
  4049. return
  4050. }
  4051. }
  4052. }
  4053. if is_upload_success {
  4054. if len(zuobiao_ids) > 0 {
  4055. tm := time.Unix(time.Now().Unix(), 0)
  4056. order := &models.HisOrder{
  4057. PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  4058. UserOrgId: org_id,
  4059. PatientId: patient_id,
  4060. SettleAccountsDate: recordDateTime,
  4061. Ctime: time.Now().Unix(),
  4062. Mtime: time.Now().Unix(),
  4063. Status: 1,
  4064. OrderStatus: 1,
  4065. MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  4066. Number: zuobiao_ids,
  4067. SetlId: zuobiao_ids,
  4068. MedfeeSumamt: total,
  4069. MedType: strconv.Itoa(int(reg_type)),
  4070. SettleType: settle_accounts_type,
  4071. Diagnosis: diagnosis_id,
  4072. PType: int64(li.Acf01),
  4073. SetlTime: tm.Format("2006-01-02 15:04:05"),
  4074. SettleStartTime: recordStartTime,
  4075. SettleEndTime: recordEndTime,
  4076. }
  4077. err = service.CreateOrder(order)
  4078. if err != nil {
  4079. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  4080. return
  4081. }
  4082. err = service.UpDatePrescriptionNumber222(org_id, p_id, zuobiao_ids,patient_id)
  4083. //err = service.UpDatePrescriptionNumber111(org_id, recordStartTime,recordEndTime, zuobiao_ids,patient_id)
  4084. //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  4085. err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  4086. //err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  4087. var zuobiao_advice models.HisZuobiaoAdvice
  4088. zuobiao_advice.Status = 1
  4089. zuobiao_advice.RecordDate = recordDateTime
  4090. zuobiao_advice.PatientId = patient_id
  4091. zuobiao_advice.Cbm01 = zuobiao_ids
  4092. zuobiao_advice.Ctime = time.Now().Unix()
  4093. zuobiao_advice.Mtime = time.Now().Unix()
  4094. zuobiao_advice.Oid = order.ID
  4095. zuobiao_advice.StartTime = recordStartTime
  4096. zuobiao_advice.EndTime = recordEndTime
  4097. zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4098. zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  4099. zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  4100. service.Createzuobiao(&zuobiao_advice)
  4101. }
  4102. c.ServeSuccessJSON(map[string]interface{}{
  4103. "msg": "上传成功",
  4104. })
  4105. } else {
  4106. c.ServeSuccessJSON(map[string]interface{}{
  4107. "failed_code": -10,
  4108. "msg": err_msg,
  4109. })
  4110. }
  4111. } else { //月结
  4112. start_time_str := c.GetString("start_time")
  4113. end_time_str := c.GetString("end_time")
  4114. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4115. if err != nil {
  4116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4117. return
  4118. }
  4119. recordStartTime = theStartTime.Unix()
  4120. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4121. if err != nil {
  4122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4123. return
  4124. }
  4125. recordEndTime = theEndTime.Unix()
  4126. prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime)
  4127. var total float64
  4128. var customs []*models.NewCustomTwo
  4129. for _, item := range prescriptions {
  4130. if item.Type == 1 { //药品
  4131. for _, subItem := range item.HisDoctorAdviceInfo {
  4132. tempTime := time.Unix(item.PreTime, 0)
  4133. //timeFormat := tempTime.Format("20060102150405")
  4134. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4135. cus := &models.NewCustomTwo{
  4136. AdviceId: subItem.ID,
  4137. ProjectId: 0,
  4138. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  4139. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  4140. FeedetlSn: subItem.FeedetlSn,
  4141. Price: fmt.Sprintf("%.2f", subItem.Price),
  4142. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  4143. Type: 1,
  4144. ItemId: subItem.BaseDrugLib.ZuobiaoId,
  4145. StartTime: timeFormatOne,
  4146. Content: subItem.AdviceName,
  4147. Bby01: subItem.BaseDrugLib.Bby01,
  4148. }
  4149. customs = append(customs, cus)
  4150. }
  4151. }
  4152. if item.Type == 2 { //项目
  4153. for _, subItem := range item.HisPrescriptionProject {
  4154. if subItem.Type == 2 {
  4155. tempTime := time.Unix(item.PreTime, 0)
  4156. //timeFormat := tempTime.Format("20060102150405")
  4157. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4158. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4159. cus := &models.NewCustomTwo{
  4160. AdviceId: 0,
  4161. ProjectId: subItem.ID,
  4162. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  4163. Cut: fmt.Sprintf("%.4f", cnt),
  4164. FeedetlSn: subItem.FeedetlSn,
  4165. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  4166. MedListCodg: subItem.HisProject.MedicalCode,
  4167. Type: 2,
  4168. ItemId: subItem.HisProject.ZuobiaoId,
  4169. StartTime: timeFormatOne,
  4170. Content: subItem.HisProject.ProjectName,
  4171. Bby01: subItem.HisProject.Bby01,
  4172. }
  4173. customs = append(customs, cus)
  4174. } else {
  4175. tempTime := time.Unix(item.PreTime, 0)
  4176. //timeFormat := tempTime.Format("20060102150405")
  4177. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4178. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4179. cus := &models.NewCustomTwo{
  4180. AdviceId: 0,
  4181. ProjectId: subItem.ID,
  4182. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  4183. Cut: fmt.Sprintf("%.4f", cnt),
  4184. FeedetlSn: subItem.FeedetlSn,
  4185. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  4186. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  4187. Type: 3,
  4188. ItemId: subItem.GoodInfo.ZuobiaoId,
  4189. StartTime: timeFormatOne,
  4190. Content: subItem.GoodInfo.GoodName,
  4191. Bby01: subItem.GoodInfo.Bby01,
  4192. }
  4193. customs = append(customs, cus)
  4194. }
  4195. }
  4196. }
  4197. }
  4198. for _, item := range prescriptions {
  4199. if item.Type == 1 { //药品
  4200. for _, subItem := range item.HisDoctorAdviceInfo {
  4201. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  4202. total_one := price * subItem.PrescribingNumber
  4203. total = total + total_one
  4204. }
  4205. }
  4206. if item.Type == 2 { //项目
  4207. for _, subItem := range item.HisPrescriptionProject {
  4208. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4209. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  4210. total_one := price * cnt
  4211. total = total + total_one
  4212. }
  4213. }
  4214. }
  4215. //allTotal := fmt.Sprintf("%2f", total)
  4216. var info models.UploadInfo
  4217. info.Acf01 = int64(li.Acf01)
  4218. info.Bce01 = "132"
  4219. info.Bck01 = "48"
  4220. info.Vaa07 = int64(li.Vaa07)
  4221. info.Vaa01 = int64(li.Vaa01)
  4222. info.Vaa05 = li.Vaa05
  4223. info.Bce01a = doctor_info.DoctorNumber
  4224. for _, item := range customs {
  4225. var cha models.ChargeListtwo
  4226. cnt, _ := strconv.ParseFloat(item.Cut, 64)
  4227. Bby01, _ := strconv.ParseInt(item.Bby01, 10, 64)
  4228. cha.Bby01 = Bby01
  4229. cha.Vaj25 = cnt
  4230. info.ChargeListtwo = append(info.ChargeListtwo, &cha)
  4231. }
  4232. //汇总逻辑,坐标id相同的汇总成一条医嘱,数量累加
  4233. var big_ps []models.HisPrescription
  4234. drugPrescriptions, consumablePrescriptions := classifyPrescriptions(prescriptions)
  4235. //药品处方需要和非没同组药品的分出同组药品的
  4236. //var noGroupdrugPrescriptions models.HisPrescription
  4237. var groupdrugPrescriptions []models.HisPrescription
  4238. //同组药处方集合
  4239. groupdrugPrescriptions = summarizePrescriptionsTwo(drugPrescriptions)
  4240. //不同组药汇总到一个处方
  4241. //noGroupdrugPrescriptions = summarizePrescriptions(drugPrescriptions)
  4242. //noGroupdrugPrescriptions.HisDoctorAdviceInfo = append(noGroupdrugPrescriptions.HisDoctorAdviceInfo,summarizePrescriptions(drugPrescriptions)...)
  4243. //非没同组药品,汇总处理
  4244. var doc_two []models.HisDoctorAdviceInfo
  4245. var doc []models.HisDoctorAdviceInfo
  4246. doc = summarizePrescriptions(drugPrescriptions)
  4247. var no_group_drug_ps models.HisPrescription
  4248. no_group_drug_ps.MedType = "110"
  4249. no_group_drug_ps.ID = int64(rand.Intn(90000) + 10000)
  4250. no_group_drug_ps.Type = 1
  4251. // 设置随机种子
  4252. for _ ,sumitem := range doc{
  4253. rand.Seed(time.Now().UnixNano())
  4254. // 生成4位随机数
  4255. randomNumber := rand.Intn(9000) + 1000
  4256. sumitem.Groupno = sumitem.Groupno + int64(randomNumber)
  4257. //doc = append(doc, sumitem.HisDoctorAdviceInfo...)
  4258. }
  4259. doc_two = RemoveRepeatedPurviewElementdrug(doc)
  4260. var dos []models.HisDoctorAdviceInfo
  4261. for _, pro := range doc_two {
  4262. var ppp models.HisDoctorAdviceInfo
  4263. var count float64
  4264. var drugWayCount float64
  4265. for _, pro_two := range doc {
  4266. if pro.BaseDrugLib.ZuobiaoId == pro_two.BaseDrugLib.ZuobiaoId && pro.BaseDrugLib.Bby01 == pro_two.BaseDrugLib.Bby01 && pro.DeliveryWay == pro_two.DeliveryWay{
  4267. ppp = pro_two
  4268. count = count + pro_two.PrescribingNumber
  4269. if len(pro_two.DrugWayCount) == 0{
  4270. pro_two.DrugWayCount = "1"
  4271. }
  4272. result, _ := strconv.ParseFloat(pro_two.DrugWayCount, 64)
  4273. drugWayCount = drugWayCount + result
  4274. }
  4275. }
  4276. //fmt.Println(strconv.FormatFloat(drugWayCount, 'f', -1, 64))
  4277. ppp.PrescribingNumber = count
  4278. ppp.DrugWayCount = strconv.FormatFloat(drugWayCount, 'f', -1, 64)
  4279. dos = append(dos, ppp)
  4280. }
  4281. no_group_drug_ps.HisDoctorAdviceInfo = dos
  4282. if len(dos) > 0 {
  4283. big_ps = append(big_ps, no_group_drug_ps)
  4284. }
  4285. jsonString, err := json.Marshal(big_ps)
  4286. if err != nil {
  4287. fmt.Println("转换失败:", err)
  4288. return
  4289. }
  4290. // 输出JSON字符串
  4291. fmt.Println(string(jsonString))
  4292. saveLog("", string(jsonString), "1111333", "122222224444", "")
  4293. //var hds []models.HisDoctorAdviceInfo
  4294. ////同组药品不需要进行汇总
  4295. for _, item := range groupdrugPrescriptions {
  4296. var group_drug_ps models.HisPrescription
  4297. group_drug_ps.MedType = "190"
  4298. group_drug_ps.ID = int64(rand.Intn(90000) + 10000)
  4299. group_drug_ps.Type = 1
  4300. group_drug_ps.HisDoctorAdviceInfo = item.HisDoctorAdviceInfo
  4301. big_ps = append(big_ps, group_drug_ps)
  4302. }
  4303. //jsonString2, err := json.Marshal(big_ps)
  4304. //if err != nil {
  4305. // fmt.Println("转换失败:", err)
  4306. // return
  4307. //}
  4308. // 输出JSON字符串
  4309. //fmt.Println(string(jsonString2))
  4310. //saveLog("", string(jsonString2), "222222", "33334444444", "")
  4311. //return
  4312. //
  4313. //hds = RemoveRepeatedPurviewElementdrugtwo(hds)
  4314. //
  4315. //for _,item := range hds{
  4316. // for _,subitem := range hds{
  4317. // if item.Newfn == subitem.Newfn{
  4318. //
  4319. //
  4320. // }
  4321. // }
  4322. //}
  4323. //if len(item.HisDoctorAdviceInfo) > 0 {
  4324. //
  4325. // var group_drug_ps models.HisPrescription
  4326. // group_drug_ps.MedType = "110"
  4327. // group_drug_ps.ID = int64(rand.Intn(90000) + 10000)
  4328. // group_drug_ps.Type = 1
  4329. // group_drug_ps.HisDoctorAdviceInfo = item.HisDoctorAdviceInfo
  4330. // big_ps = append(big_ps, group_drug_ps)
  4331. //}
  4332. //耗材和项目汇总
  4333. var projects []models.HisPrescriptionProject
  4334. var goods []models.HisPrescriptionProject
  4335. var checks []models.HisPrescriptionProject
  4336. var projects_two []models.HisPrescriptionProject
  4337. var goods_two []models.HisPrescriptionProject
  4338. //var checks_two []models.HisPrescriptionProject
  4339. for _, item := range consumablePrescriptions {
  4340. for _, subitem := range item.HisPrescriptionProject {
  4341. if subitem.Type == 2 {
  4342. if subitem.HisProject.CostClassify == 3{
  4343. checks = append(checks, subitem)
  4344. }else{
  4345. projects = append(projects, subitem)
  4346. }
  4347. } else if subitem.Type == 3 {
  4348. goods = append(goods, subitem)
  4349. }
  4350. }
  4351. }
  4352. projects_two = RemoveRepeatedPurviewElementproject(projects)
  4353. goods_two = RemoveRepeatedPurviewElementgood(goods)
  4354. //checks_two = RemoveRepeatedPurviewElementproject(checks)
  4355. var new_pros []models.HisPrescriptionProject
  4356. var new_goods []models.HisPrescriptionProject
  4357. var new_checks []models.HisPrescriptionProject
  4358. for _, pro := range projects_two {
  4359. var ppp models.HisPrescriptionProject
  4360. var count float64
  4361. for _, pro_two := range projects {
  4362. if pro.HisProject.ZuobiaoId == pro_two.HisProject.ZuobiaoId && pro.HisProject.Bby01 == pro_two.HisProject.Bby01 {
  4363. ppp = pro_two
  4364. result, _ := strconv.ParseFloat(pro_two.Count, 64)
  4365. count = count + result
  4366. }
  4367. }
  4368. ppp.Count = strconv.FormatFloat(count, 'f', -1, 64)
  4369. new_pros = append(new_pros, ppp)
  4370. }
  4371. for _, good := range goods_two {
  4372. var ppp models.HisPrescriptionProject
  4373. var count float64
  4374. for _, good_two := range goods {
  4375. if good.GoodInfo.ZuobiaoId == good_two.GoodInfo.ZuobiaoId && good.GoodInfo.Bby01 == good_two.GoodInfo.Bby01 {
  4376. ppp = good_two
  4377. result, _ := strconv.ParseFloat(good_two.Count, 64)
  4378. count = count + result
  4379. }
  4380. }
  4381. ppp.Count = strconv.FormatFloat(count, 'f', -1, 64)
  4382. new_goods = append(new_goods, ppp)
  4383. }
  4384. for _, check := range checks {
  4385. var ppp models.HisPrescriptionProject
  4386. ppp = check
  4387. ppp.Count = check.Count
  4388. new_checks = append(new_checks, ppp)
  4389. }
  4390. if len(new_goods) > 0 {
  4391. var ps1 models.HisPrescription
  4392. ps1.MedType = "120"
  4393. ps1.ID = int64(rand.Intn(90000) + 10000)
  4394. ps1.Type = 2
  4395. ps1.HisPrescriptionProject = append(ps1.HisPrescriptionProject, new_goods...)
  4396. big_ps = append(big_ps, ps1)
  4397. }
  4398. if len(new_pros) > 0 {
  4399. var ps2 models.HisPrescription
  4400. ps2.MedType = "130"
  4401. ps2.Type = 2
  4402. ps2.ID = int64(rand.Intn(90000) + 10000)
  4403. ps2.HisPrescriptionProject = append(ps2.HisPrescriptionProject, new_pros...)
  4404. big_ps = append(big_ps, ps2)
  4405. }
  4406. if len(new_checks) > 0 {
  4407. var ps3 models.HisPrescription
  4408. ps3.MedType = "140"
  4409. ps3.Type = 2
  4410. ps3.ID = int64(rand.Intn(90000) + 10000)
  4411. ps3.HisPrescriptionProject = append(ps3.HisPrescriptionProject, new_checks...)
  4412. big_ps = append(big_ps, ps3)
  4413. }
  4414. ////信息
  4415. var is_upload_success bool = true
  4416. var curpage int
  4417. var pagesize int = len(big_ps)
  4418. var start int = 1
  4419. var stop int
  4420. var zuobiao_ids string
  4421. var err_msg string
  4422. var idss []int64
  4423. //pagecount := 10
  4424. pagecount := int(math.Ceil(float64(len(big_ps)) / float64(pagesize)))
  4425. for curpage = 1; curpage <= pagecount; curpage++ {
  4426. var root models.Root
  4427. var tradeInfo models.TradeInfo
  4428. var cBM1 models.CBM1
  4429. var vAF1 models.VAF1
  4430. var vAO1 models.VAO1
  4431. var vBQ1 models.VBQ1
  4432. if li.Acf01 == 1 {
  4433. tradeInfo.PatSource = 1
  4434. tradeInfo.Type = 0
  4435. } else {
  4436. tradeInfo.PatSource = 2
  4437. tradeInfo.Type = 1
  4438. }
  4439. tradeInfo.Detpid = departmwnt.Number
  4440. tradeInfo.Empid = doctor_info.DoctorNumber
  4441. tradeInfo.Empno = doctor_info.DoctorCode
  4442. tradeInfo.Empname = doctor_info.UserName
  4443. root.TradeInfo = tradeInfo
  4444. if curpage == 1 {
  4445. start = 1
  4446. } else {
  4447. start = (curpage-1)*pagesize + 1
  4448. }
  4449. stop = curpage * pagesize
  4450. if stop > len(big_ps) {
  4451. stop = len(big_ps)
  4452. }
  4453. //var ids []int64
  4454. //
  4455. //for _, item := range prescriptions[start-1 : stop] {
  4456. // ids = append(ids, item.ID)
  4457. //}
  4458. for _, item := range big_ps[start-1 : stop] {
  4459. //departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  4460. var ie_cbm1 models.IEone
  4461. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4462. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4463. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  4464. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  4465. //ie_cbm1.CBM06 = strconv.FormatInt(int64(res.List[0].Acf01), 10)
  4466. if li.Acf01 == 1 {
  4467. if item.MedType == "110" {
  4468. ie_cbm1.CBM06 = "1"
  4469. }
  4470. if item.MedType == "120"{
  4471. ie_cbm1.CBM06 = "5"
  4472. }
  4473. if item.MedType == "130"{
  4474. ie_cbm1.CBM06 = "0"
  4475. }
  4476. if item.MedType == "140"{
  4477. ie_cbm1.CBM06 = "9"
  4478. }
  4479. if item.MedType == "190"{
  4480. ie_cbm1.CBM06 = "1"
  4481. }
  4482. ie_cbm1.BCK01A = "0"
  4483. } else {
  4484. ie_cbm1.CBM06 = "0"
  4485. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10) //病区id
  4486. }
  4487. if item.MedType == "110" {
  4488. ie_cbm1.CBM07 = "1"
  4489. }
  4490. if item.MedType == "120"{
  4491. ie_cbm1.CBM07 = "5"
  4492. }
  4493. if item.MedType == "130"{
  4494. ie_cbm1.CBM07 = "0"
  4495. }
  4496. if item.MedType == "140"{
  4497. ie_cbm1.CBM07 = "10"
  4498. }
  4499. if item.MedType == "190"{
  4500. ie_cbm1.CBM06 = "1"
  4501. }
  4502. ie_cbm1.BCK01B = strconv.FormatInt(int64(li.Bck01B), 10)
  4503. ie_cbm1.BCK01C = "38"
  4504. ie_cbm1.CBM19 = "0"
  4505. cBM1.Ie = append(cBM1.Ie, ie_cbm1)
  4506. }
  4507. root.CBM1 = cBM1
  4508. ////医嘱
  4509. for _, item := range big_ps[start-1 : stop] {
  4510. //departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  4511. if item.Type == 1 {
  4512. if item.MedType == "190"{
  4513. //组号去重
  4514. //temphisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  4515. // 使用 map 来存储 groupno 的数量
  4516. //groupCount := make(map[int64]int64)
  4517. // 使用 map 来存储 groupno 的数量和最后一条数据的索引
  4518. groupInfo := make(map[string]struct {
  4519. Count int64
  4520. LastElement int
  4521. })
  4522. // 遍历切片,计算 groupno 的数量和最后一条数据的索引
  4523. for i, obj := range item.HisDoctorAdviceInfo {
  4524. fmt.Println("转换失败1:", strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10))
  4525. info, ok := groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)]
  4526. fmt.Println("转换失败2:",info)
  4527. if !ok {
  4528. info = struct {
  4529. Count int64
  4530. LastElement int
  4531. }{}
  4532. }
  4533. info.Count++
  4534. info.LastElement = i
  4535. groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)] = info
  4536. fmt.Println("转换失败3:",groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)])
  4537. }
  4538. fmt.Println("转换失败4:",groupInfo)
  4539. // 根据 groupno 的数量设置字段值
  4540. for i, obj := range item.HisDoctorAdviceInfo {
  4541. info := groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)]
  4542. if info.Count < 2 {
  4543. fmt.Println("转换失败555:")
  4544. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  4545. //item.HisDoctorAdviceInfo[i].Groupno = int64(rand.Intn(90000) + 10000)
  4546. } else {
  4547. // 对于数量大于等于 2 的,将最后一条数据设置 1,其他设置为随机数
  4548. if i == info.LastElement {
  4549. fmt.Println("转换失败6666:")
  4550. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  4551. //item.HisDoctorAdviceInfo[i].Groupno = int64(rand.Intn(90000) + 10000)
  4552. } else {
  4553. fmt.Println("转换失败777777:")
  4554. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(obj.ID, 10)
  4555. }
  4556. }
  4557. }
  4558. for _, subitem := range item.HisDoctorAdviceInfo {
  4559. fmt.Println("转换失败777777:", subitem.NewGroupno)
  4560. var ie_cbm1 models.IEtwo
  4561. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4562. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4563. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4564. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4565. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4566. ie_cbm1.ROWNR = subitem.NewGroupno
  4567. ie_cbm1.VAF10 = "1"
  4568. ie_cbm1.VAF11 = "2"
  4569. ie_cbm1.BDA01 = "1" //诊疗类型
  4570. ie_cbm1.BBX01 = subitem.BaseDrugLib.ZuobiaoId
  4571. ie_cbm1.VAF14 = "" //检验样本类型
  4572. ie_cbm1.VAF15 = ""
  4573. ie_cbm1.BBY01 = subitem.BaseDrugLib.Bby01 //药品规格id或材料规格id
  4574. if li.Acf01 == 1 {
  4575. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10)
  4576. } else {
  4577. ie_cbm1.VAF17 = "0"
  4578. }
  4579. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  4580. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  4581. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  4582. ie_cbm1.VAF21 = fmt.Sprintf("%.2f", subitem.PrescribingNumber)
  4583. ie_cbm1.VAF22 = subitem.AdviceName + " " + subitem.BaseDrugLib.DrugSpec
  4584. ie_cbm1.Crypt = "0"
  4585. ie_cbm1.VAF23 = ""
  4586. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  4587. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4588. ie_cbm1.VAF27 = "1"
  4589. ie_cbm1.VAF28 = "1"
  4590. ie_cbm1.VAF29 = "1"
  4591. ie_cbm1.VAF30 = ""
  4592. ie_cbm1.VAF31 = "0"
  4593. ie_cbm1.VAF32 = "0" //todo
  4594. ie_cbm1.VAF33 = "0"
  4595. ie_cbm1.VAF34 = "0"
  4596. ie_cbm1.VAF35 = "0"
  4597. tempTime1 := time.Unix(subitem.StartTime, 0)
  4598. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4599. ie_cbm1.VAF36 = timeFormatOne
  4600. ie_cbm1.VAF37 = "1899-12-30"
  4601. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4602. ie_cbm1.BCK01C = "38"
  4603. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4604. ie_cbm1.BCE03A = doctor_info.UserName
  4605. ie_cbm1.BCE03B = ""
  4606. ie_cbm1.VAF53 = "-1"
  4607. ie_cbm1.VAF55 = subitem.Remark
  4608. ie_cbm1.BCK01D = "38"
  4609. ie_cbm1.VAF58 = "0"
  4610. ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno ), 10)
  4611. ie_cbm1.VAF60 = ""
  4612. ie_cbm1.VAF61 = "1"
  4613. ie_cbm1.VAF62 = "0"
  4614. ie_cbm1.LSign = "0"
  4615. ie_cbm1.BDA01A = ie_cbm1.BDA01
  4616. ie_cbm1.LRoute = "0"
  4617. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4618. ie_cbm1.BCE01B = "0"
  4619. ie_cbm1.VAF01B = "0"
  4620. ie_cbm1.VCO01 = "0"
  4621. ie_cbm1.BCE01H = "0"
  4622. ie_cbm1.BCE03H = ""
  4623. ie_cbm1.BIW02 = ""
  4624. ie_cbm1.RCurrent = "0"
  4625. ie_cbm1.FCheck = "0"
  4626. ie_cbm1.UnameA = ""
  4627. ie_cbm1.VEH02 = ""
  4628. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  4629. }
  4630. //hisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  4631. //每种药品下的给药途径
  4632. for _, subitem := range item.HisDoctorAdviceInfo {
  4633. way, _ := service.GetDrugwayDicByName(subitem.DeliveryWay, c.GetAdminUserInfo().CurrentOrgId)
  4634. var ie_cbm1 models.IEtwo
  4635. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4636. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4637. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4638. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4639. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4640. ie_cbm1.ROWNR = "0"
  4641. ie_cbm1.VAF10 = "1"
  4642. ie_cbm1.VAF11 = "2"
  4643. ie_cbm1.BDA01 = "T" //诊疗类型
  4644. ie_cbm1.BBX01 = way.Code
  4645. ie_cbm1.VAF14 = "" //检验样本类型
  4646. ie_cbm1.VAF15 = "" //检验样本类型
  4647. ie_cbm1.BBY01 = way.Bby01 //药品规格id或材料规格id
  4648. if li.Acf01 == 1 {
  4649. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10) //药品规格id或材料规格id
  4650. } else {
  4651. ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
  4652. }
  4653. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  4654. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  4655. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  4656. //ie_cbm1.VAF21 = fmt.Sprintf("%.2f",subitem.PrescribingNumber)
  4657. //ie_cbm1.VAF18 = "" //药品规格id或材料规格id
  4658. //ie_cbm1.VAF19 = ""
  4659. //ie_cbm1.VAF20 = ""
  4660. if subitem.DrugWayCount == "" {
  4661. ie_cbm1.VAF21 = "1"
  4662. } else {
  4663. ie_cbm1.VAF21 = subitem.DrugWayCount
  4664. }
  4665. ie_cbm1.VAF22 = way.Name
  4666. ie_cbm1.Crypt = "0"
  4667. ie_cbm1.VAF23 = ""
  4668. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  4669. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4670. ie_cbm1.VAF27 = "1"
  4671. ie_cbm1.VAF28 = "1"
  4672. ie_cbm1.VAF29 = "1"
  4673. ie_cbm1.BCK01C = "38"
  4674. ie_cbm1.VAF30 = ""
  4675. ie_cbm1.VAF31 = "0"
  4676. ie_cbm1.VAF32 = "1" //todo
  4677. ie_cbm1.VAF33 = "0"
  4678. ie_cbm1.VAF34 = "0"
  4679. ie_cbm1.VAF35 = "0"
  4680. tempTime1 := time.Unix(subitem.StartTime, 0)
  4681. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4682. ie_cbm1.VAF36 = timeFormatOne
  4683. ie_cbm1.VAF37 = "1899-12-30"
  4684. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4685. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4686. ie_cbm1.BCE03A = doctor_info.UserName
  4687. ie_cbm1.BCE03B = ""
  4688. ie_cbm1.VAF53 = "-1"
  4689. ie_cbm1.VAF55 = subitem.Remark
  4690. ie_cbm1.BCK01D = "38"
  4691. ie_cbm1.VAF58 = "0"
  4692. ie_cbm1.VAF59 =strconv.FormatInt(int64(subitem.Groupno ), 10)
  4693. ie_cbm1.VAF60 = ""
  4694. ie_cbm1.VAF61 = "1"
  4695. ie_cbm1.VAF62 = "0"
  4696. ie_cbm1.LSign = "0"
  4697. ie_cbm1.BDA01A = ie_cbm1.BDA01
  4698. ie_cbm1.LRoute = "0"
  4699. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4700. ie_cbm1.BCE01B = "0"
  4701. ie_cbm1.VAF01B = "0"
  4702. ie_cbm1.VCO01 = "0"
  4703. ie_cbm1.BCE01H = "0"
  4704. ie_cbm1.BCE03H = ""
  4705. ie_cbm1.BIW02 = ""
  4706. ie_cbm1.RCurrent = "0"
  4707. ie_cbm1.FCheck = "0"
  4708. ie_cbm1.UnameA = ""
  4709. ie_cbm1.VEH02 = ""
  4710. ie_cbm1.VAF07 = "0"
  4711. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  4712. }
  4713. }else{
  4714. //组号去重
  4715. //temphisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  4716. // 使用 map 来存储 groupno 的数量
  4717. //groupCount := make(map[int64]int64)
  4718. // 使用 map 来存储 groupno 的数量和最后一条数据的索引
  4719. groupInfo := make(map[string]struct {
  4720. Count int64
  4721. LastElement int
  4722. })
  4723. // 遍历切片,计算 groupno 的数量和最后一条数据的索引
  4724. for i, obj := range item.HisDoctorAdviceInfo {
  4725. fmt.Println("转换失败1:", strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10))
  4726. info, ok := groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)]
  4727. fmt.Println("转换失败2:",info)
  4728. if !ok {
  4729. info = struct {
  4730. Count int64
  4731. LastElement int
  4732. }{}
  4733. }
  4734. info.Count++
  4735. info.LastElement = i
  4736. groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)] = info
  4737. fmt.Println("转换失败3:",groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)])
  4738. }
  4739. fmt.Println("转换失败4:",groupInfo)
  4740. // 根据 groupno 的数量设置字段值
  4741. for i, obj := range item.HisDoctorAdviceInfo {
  4742. info := groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)]
  4743. if info.Count < 2 {
  4744. fmt.Println("转换失败555:")
  4745. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  4746. item.HisDoctorAdviceInfo[i].Groupno = int64(rand.Intn(90000) + 10000)
  4747. } else {
  4748. // 对于数量大于等于 2 的,将最后一条数据设置 1,其他设置为随机数
  4749. if i == info.LastElement {
  4750. fmt.Println("转换失败6666:")
  4751. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  4752. item.HisDoctorAdviceInfo[i].Groupno = int64(rand.Intn(90000) + 10000)
  4753. } else {
  4754. fmt.Println("转换失败777777:")
  4755. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(obj.ID, 10)
  4756. }
  4757. }
  4758. }
  4759. for _, subitem := range item.HisDoctorAdviceInfo {
  4760. fmt.Println("转换失败777777:", subitem.NewGroupno)
  4761. var ie_cbm1 models.IEtwo
  4762. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4763. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4764. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4765. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4766. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4767. ie_cbm1.ROWNR = subitem.NewGroupno
  4768. ie_cbm1.VAF10 = "1"
  4769. ie_cbm1.VAF11 = "2"
  4770. ie_cbm1.BDA01 = "1" //诊疗类型
  4771. ie_cbm1.BBX01 = subitem.BaseDrugLib.ZuobiaoId
  4772. ie_cbm1.VAF14 = "" //检验样本类型
  4773. ie_cbm1.VAF15 = ""
  4774. ie_cbm1.BBY01 = subitem.BaseDrugLib.Bby01 //药品规格id或材料规格id
  4775. if li.Acf01 == 1 {
  4776. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10)
  4777. } else {
  4778. ie_cbm1.VAF17 = "0"
  4779. }
  4780. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  4781. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  4782. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  4783. ie_cbm1.VAF21 = fmt.Sprintf("%.2f", subitem.PrescribingNumber)
  4784. ie_cbm1.VAF22 = subitem.AdviceName + " " + subitem.BaseDrugLib.DrugSpec
  4785. ie_cbm1.Crypt = "0"
  4786. ie_cbm1.VAF23 = ""
  4787. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  4788. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4789. ie_cbm1.VAF27 = "1"
  4790. ie_cbm1.VAF28 = "1"
  4791. ie_cbm1.VAF29 = "1"
  4792. ie_cbm1.VAF30 = ""
  4793. ie_cbm1.VAF31 = "0"
  4794. ie_cbm1.VAF32 = "0" //todo
  4795. ie_cbm1.VAF33 = "0"
  4796. ie_cbm1.VAF34 = "0"
  4797. ie_cbm1.VAF35 = "0"
  4798. tempTime1 := time.Unix(subitem.StartTime, 0)
  4799. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4800. ie_cbm1.VAF36 = timeFormatOne
  4801. ie_cbm1.VAF37 = "1899-12-30"
  4802. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4803. ie_cbm1.BCK01C = "38"
  4804. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4805. ie_cbm1.BCE03A = doctor_info.UserName
  4806. ie_cbm1.BCE03B = ""
  4807. ie_cbm1.VAF53 = "-1"
  4808. ie_cbm1.VAF55 = subitem.Remark
  4809. ie_cbm1.BCK01D = "38"
  4810. ie_cbm1.VAF58 = "0"
  4811. ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno ), 10)
  4812. ie_cbm1.VAF60 = ""
  4813. ie_cbm1.VAF61 = "1"
  4814. ie_cbm1.VAF62 = "0"
  4815. ie_cbm1.LSign = "0"
  4816. ie_cbm1.BDA01A = ie_cbm1.BDA01
  4817. ie_cbm1.LRoute = "0"
  4818. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4819. ie_cbm1.BCE01B = "0"
  4820. ie_cbm1.VAF01B = "0"
  4821. ie_cbm1.VCO01 = "0"
  4822. ie_cbm1.BCE01H = "0"
  4823. ie_cbm1.BCE03H = ""
  4824. ie_cbm1.BIW02 = ""
  4825. ie_cbm1.RCurrent = "0"
  4826. ie_cbm1.FCheck = "0"
  4827. ie_cbm1.UnameA = ""
  4828. ie_cbm1.VEH02 = ""
  4829. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  4830. }
  4831. //hisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  4832. //每种药品下的给药途径
  4833. for _, subitem := range item.HisDoctorAdviceInfo {
  4834. way, _ := service.GetDrugwayDicByName(subitem.DeliveryWay, c.GetAdminUserInfo().CurrentOrgId)
  4835. var ie_cbm1 models.IEtwo
  4836. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4837. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4838. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4839. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4840. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4841. ie_cbm1.ROWNR = "0"
  4842. ie_cbm1.VAF10 = "1"
  4843. ie_cbm1.VAF11 = "2"
  4844. ie_cbm1.BDA01 = "T" //诊疗类型
  4845. ie_cbm1.BBX01 = way.Code
  4846. ie_cbm1.VAF14 = "" //检验样本类型
  4847. ie_cbm1.VAF15 = "" //检验样本类型
  4848. ie_cbm1.BBY01 = way.Bby01 //药品规格id或材料规格id
  4849. if li.Acf01 == 1 {
  4850. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10) //药品规格id或材料规格id
  4851. } else {
  4852. ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
  4853. }
  4854. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  4855. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  4856. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  4857. //ie_cbm1.VAF21 = fmt.Sprintf("%.2f",subitem.PrescribingNumber)
  4858. //ie_cbm1.VAF18 = "" //药品规格id或材料规格id
  4859. //ie_cbm1.VAF19 = ""
  4860. //ie_cbm1.VAF20 = ""
  4861. if subitem.DrugWayCount == "" {
  4862. ie_cbm1.VAF21 = "1"
  4863. } else {
  4864. ie_cbm1.VAF21 = subitem.DrugWayCount
  4865. }
  4866. ie_cbm1.VAF22 = way.Name
  4867. ie_cbm1.Crypt = "0"
  4868. ie_cbm1.VAF23 = ""
  4869. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  4870. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4871. ie_cbm1.VAF27 = "1"
  4872. ie_cbm1.VAF28 = "1"
  4873. ie_cbm1.VAF29 = "1"
  4874. ie_cbm1.BCK01C = "38"
  4875. ie_cbm1.VAF30 = ""
  4876. ie_cbm1.VAF31 = "0"
  4877. ie_cbm1.VAF32 = "1" //todo
  4878. ie_cbm1.VAF33 = "0"
  4879. ie_cbm1.VAF34 = "0"
  4880. ie_cbm1.VAF35 = "0"
  4881. tempTime1 := time.Unix(subitem.StartTime, 0)
  4882. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4883. ie_cbm1.VAF36 = timeFormatOne
  4884. ie_cbm1.VAF37 = "1899-12-30"
  4885. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4886. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4887. ie_cbm1.BCE03A = doctor_info.UserName
  4888. ie_cbm1.BCE03B = ""
  4889. ie_cbm1.VAF53 = "-1"
  4890. ie_cbm1.VAF55 = subitem.Remark
  4891. ie_cbm1.BCK01D = "38"
  4892. ie_cbm1.VAF58 = "0"
  4893. ie_cbm1.VAF59 =strconv.FormatInt(int64(subitem.Groupno ), 10)
  4894. ie_cbm1.VAF60 = ""
  4895. ie_cbm1.VAF61 = "1"
  4896. ie_cbm1.VAF62 = "0"
  4897. ie_cbm1.LSign = "0"
  4898. ie_cbm1.BDA01A = ie_cbm1.BDA01
  4899. ie_cbm1.LRoute = "0"
  4900. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4901. ie_cbm1.BCE01B = "0"
  4902. ie_cbm1.VAF01B = "0"
  4903. ie_cbm1.VCO01 = "0"
  4904. ie_cbm1.BCE01H = "0"
  4905. ie_cbm1.BCE03H = ""
  4906. ie_cbm1.BIW02 = ""
  4907. ie_cbm1.RCurrent = "0"
  4908. ie_cbm1.FCheck = "0"
  4909. ie_cbm1.UnameA = ""
  4910. ie_cbm1.VEH02 = ""
  4911. ie_cbm1.VAF07 = "0"
  4912. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  4913. }
  4914. }
  4915. } else if item.Type == 2 {
  4916. for index, subitem := range item.HisPrescriptionProject {
  4917. if subitem.Type == 2 {
  4918. if subitem.HisProject.CostClassify != 3 {
  4919. var ie_cbm1 models.IEtwo
  4920. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4921. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4922. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4923. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4924. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4925. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  4926. ie_cbm1.VAF10 = "1"
  4927. ie_cbm1.VAF11 = "2"
  4928. ie_cbm1.BDA01 = "T" //诊疗类型
  4929. ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  4930. ie_cbm1.VAF14 = "" //检验样本类型
  4931. ie_cbm1.VAF15 = "" //检验样本类型
  4932. ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  4933. if li.Acf01 == 1 {
  4934. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  4935. if len(subitem.Day) == 0 {
  4936. ie_cbm1.VAF17 = "1"
  4937. }
  4938. } else {
  4939. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  4940. }
  4941. if subitem.SingleDose == "" {
  4942. subitem.SingleDose = "1"
  4943. }
  4944. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  4945. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  4946. ie_cbm1.VAF20 = subitem.SingleDose
  4947. ie_cbm1.VAF21 = subitem.Count
  4948. ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  4949. ie_cbm1.Crypt = "0"
  4950. ie_cbm1.VAF23 = ""
  4951. ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  4952. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4953. ie_cbm1.VAF27 = "1"
  4954. ie_cbm1.VAF28 = "1"
  4955. ie_cbm1.VAF29 = ""
  4956. ie_cbm1.BCK01C = "38"
  4957. ie_cbm1.VAF30 = ""
  4958. ie_cbm1.VAF31 = "0"
  4959. ie_cbm1.VAF32 = "0" //todo
  4960. ie_cbm1.VAF33 = "0"
  4961. ie_cbm1.VAF34 = "0"
  4962. ie_cbm1.VAF35 = "0"
  4963. tempTime1 := time.Unix(subitem.StartTime, 0)
  4964. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4965. ie_cbm1.VAF36 = timeFormatOne
  4966. ie_cbm1.VAF37 = "1899-12-30"
  4967. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4968. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4969. ie_cbm1.BCE03A = doctor_info.UserName
  4970. ie_cbm1.BCE03B = ""
  4971. ie_cbm1.VAF53 = "-1"
  4972. ie_cbm1.VAF55 = subitem.Remark
  4973. ie_cbm1.BCK01D = "38"
  4974. ie_cbm1.VAF58 = "0"
  4975. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  4976. ie_cbm1.VAF60 = ""
  4977. ie_cbm1.VAF61 = "1"
  4978. ie_cbm1.VAF62 = "0"
  4979. ie_cbm1.LSign = "0"
  4980. ie_cbm1.BDA01A = "" //诊疗类型
  4981. ie_cbm1.LRoute = "0"
  4982. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4983. //ie_cbm1.BCE01A = doctor_info.UserName
  4984. ie_cbm1.BCE01B = "0"
  4985. ie_cbm1.VAF01B = "0"
  4986. ie_cbm1.VCO01 = "0"
  4987. ie_cbm1.BCE01H = "0"
  4988. ie_cbm1.BCE03H = ""
  4989. ie_cbm1.BIW02 = ""
  4990. ie_cbm1.RCurrent = "0"
  4991. ie_cbm1.FCheck = "0"
  4992. ie_cbm1.UnameA = ""
  4993. ie_cbm1.VAF07 = "0"
  4994. ie_cbm1.VEH02 = ""
  4995. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  4996. }
  4997. if subitem.HisProject.CostClassify == 3 {
  4998. var ie_cbm1 models.IEtwo
  4999. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  5000. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  5001. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5002. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  5003. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  5004. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  5005. ie_cbm1.VAF10 = "1"
  5006. ie_cbm1.VAF11 = "2"
  5007. ie_cbm1.BDA01 = "L" //诊疗类型
  5008. ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  5009. ie_cbm1.VAF14 = subitem.HisProject.Vaf14 //检验样本类型
  5010. ie_cbm1.VAF15 = "" //检验样本类型
  5011. ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  5012. if li.Acf01 == 1 {
  5013. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  5014. } else {
  5015. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  5016. }
  5017. if subitem.SingleDose == "" {
  5018. subitem.SingleDose = "1"
  5019. }
  5020. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  5021. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  5022. ie_cbm1.VAF20 = subitem.SingleDose
  5023. ie_cbm1.VAF21 = subitem.Count
  5024. ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  5025. ie_cbm1.Crypt = "0"
  5026. ie_cbm1.VAF23 = ""
  5027. ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  5028. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  5029. ie_cbm1.VAF27 = "1"
  5030. ie_cbm1.VAF28 = "1"
  5031. ie_cbm1.VAF29 = ""
  5032. ie_cbm1.BCK01C = "38"
  5033. ie_cbm1.VAF30 = ""
  5034. ie_cbm1.VAF31 = "0"
  5035. ie_cbm1.VAF32 = "0" //todo
  5036. ie_cbm1.VAF33 = "0"
  5037. ie_cbm1.VAF34 = "0"
  5038. ie_cbm1.VAF35 = "0"
  5039. tempTime1 := time.Unix(subitem.StartTime, 0)
  5040. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  5041. ie_cbm1.VAF36 = timeFormatOne
  5042. ie_cbm1.VAF37 = "1899-12-30"
  5043. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  5044. ie_cbm1.BCE02A = doctor_info.DoctorCode
  5045. ie_cbm1.BCE03A = doctor_info.UserName
  5046. ie_cbm1.BCE03B = ""
  5047. ie_cbm1.VAF53 = "-1"
  5048. ie_cbm1.VAF55 = subitem.Remark
  5049. ie_cbm1.BCK01D = "38"
  5050. ie_cbm1.VAF58 = "0"
  5051. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  5052. ie_cbm1.VAF60 = ""
  5053. ie_cbm1.VAF61 = "1"
  5054. ie_cbm1.VAF62 = "0"
  5055. ie_cbm1.LSign = "0"
  5056. ie_cbm1.BDA01A = "" //诊疗类型
  5057. ie_cbm1.LRoute = "0"
  5058. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  5059. ie_cbm1.VAF07 = "0"
  5060. //ie_cbm1.BCE01A = doctor_info.UserName
  5061. ie_cbm1.BCE01B = "0"
  5062. ie_cbm1.VAF01B = "0"
  5063. ie_cbm1.VCO01 = "0"
  5064. ie_cbm1.BCE01H = "0"
  5065. ie_cbm1.BCE03H = ""
  5066. ie_cbm1.BIW02 = ""
  5067. ie_cbm1.RCurrent = "0"
  5068. ie_cbm1.FCheck = "0"
  5069. ie_cbm1.UnameA = ""
  5070. ie_cbm1.VEH02 = ""
  5071. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  5072. }
  5073. } else if subitem.Type == 3 {
  5074. var ie_cbm1 models.IEtwo
  5075. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  5076. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  5077. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5078. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  5079. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  5080. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  5081. ie_cbm1.VAF10 = "1"
  5082. ie_cbm1.VAF11 = "2"
  5083. ie_cbm1.BDA01 = "4" //诊疗类型
  5084. ie_cbm1.BBX01 = subitem.GoodInfo.ZuobiaoId
  5085. ie_cbm1.VAF14 = "" //检验样本类型
  5086. ie_cbm1.VAF15 = "" //检验样本类型
  5087. ie_cbm1.BBY01 = subitem.GoodInfo.Bby01 //药品规格id或材料规格id
  5088. if li.Acf01 == 1 {
  5089. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  5090. if len(subitem.Day) == 0 {
  5091. ie_cbm1.VAF17 = "1"
  5092. }
  5093. } else {
  5094. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  5095. }
  5096. if subitem.SingleDose == "" {
  5097. subitem.SingleDose = "1"
  5098. }
  5099. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  5100. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  5101. ie_cbm1.VAF20 = subitem.SingleDose
  5102. ie_cbm1.VAF21 = subitem.Count
  5103. ie_cbm1.BCK01C = "38"
  5104. ie_cbm1.VAF22 = subitem.GoodInfo.GoodName + " " + subitem.GoodInfo.SpecificationName
  5105. ie_cbm1.Crypt = "0"
  5106. ie_cbm1.VAF23 = ""
  5107. ie_cbm1.BCK01B = subitem.GoodInfo.Bck01b
  5108. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  5109. ie_cbm1.VAF27 = "1"
  5110. ie_cbm1.VAF28 = "1"
  5111. ie_cbm1.VAF29 = ""
  5112. ie_cbm1.VAF07 = "0"
  5113. ie_cbm1.VAF30 = ""
  5114. ie_cbm1.VAF31 = "0"
  5115. ie_cbm1.VAF32 = "0" //todo
  5116. ie_cbm1.VAF33 = "0"
  5117. ie_cbm1.VAF34 = "0"
  5118. ie_cbm1.VAF35 = "0"
  5119. tempTime1 := time.Unix(subitem.StartTime, 0)
  5120. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  5121. ie_cbm1.VAF36 = timeFormatOne
  5122. ie_cbm1.VAF37 = "1899-12-30"
  5123. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  5124. ie_cbm1.BCE02A = doctor_info.DoctorCode
  5125. ie_cbm1.BCE03A = doctor_info.UserName
  5126. ie_cbm1.BCE03B = ""
  5127. ie_cbm1.BCK01C = "38"
  5128. ie_cbm1.VAF53 = "-1"
  5129. ie_cbm1.VAF55 = subitem.Remark
  5130. ie_cbm1.BCK01D ="38"
  5131. ie_cbm1.VAF58 = "0"
  5132. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  5133. ie_cbm1.VAF60 = ""
  5134. ie_cbm1.VAF61 = "1"
  5135. ie_cbm1.VAF62 = "0"
  5136. ie_cbm1.LSign = "0"
  5137. ie_cbm1.BDA01A = "" //诊疗类型
  5138. ie_cbm1.LRoute = "0"
  5139. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  5140. ie_cbm1.BCE01B = "0"
  5141. ie_cbm1.VAF01B = "0"
  5142. ie_cbm1.VCO01 = "0"
  5143. ie_cbm1.BCE01H = "0"
  5144. ie_cbm1.BCE03H = ""
  5145. ie_cbm1.BIW02 = ""
  5146. ie_cbm1.RCurrent = "0"
  5147. ie_cbm1.FCheck = "0"
  5148. ie_cbm1.UnameA = ""
  5149. ie_cbm1.VEH02 = ""
  5150. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  5151. }
  5152. }
  5153. }
  5154. }
  5155. root.VAF1 = vAF1
  5156. for index, item := range big_ps[start-1 : stop] {
  5157. sick, _ := service.FindSickById(sick_type)
  5158. item.VMHisPrescriptionInfo.Diagnosis = "716"
  5159. dias := strings.Split(item.VMHisPrescriptionInfo.Diagnosis, ",")
  5160. //service.get
  5161. //诊断
  5162. for _, subitem := range dias {
  5163. diagnosisConfig, _ := service.FindDiagnoseByIdtwo(subitem)
  5164. if index == 0 {
  5165. var ie_cbm1 models.IEthree
  5166. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  5167. //ie_cbm1.CBMID = strconv.FormatInt(int64(index+1), 10)
  5168. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5169. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5170. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  5171. ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  5172. ie_cbm1.VAO07 = "1"
  5173. ie_cbm1.VAO10 = "0"
  5174. ie_cbm1.VAO11 = "1"
  5175. ie_cbm1.BAK01A = sick.ContentCode
  5176. ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  5177. ie_cbm1.VAO15 = diagnosisConfig.ClassName
  5178. ie_cbm1.VAO18 = "0"
  5179. ie_cbm1.VAO22 = "1"
  5180. ie_cbm1.IAA01 = ""
  5181. ie_cbm1.IAD03 = ""
  5182. ie_cbm1.BAK01B = ""
  5183. ie_cbm1.VAO26 = ""
  5184. ie_cbm1.IAD04 = ""
  5185. ie_cbm1.IAD01 = ""
  5186. ie_cbm1.VAO25 = "1"
  5187. ie_cbm1.VAO35 = ""
  5188. vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  5189. } else {
  5190. var ie_cbm1 models.IEthree
  5191. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  5192. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5193. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5194. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  5195. ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  5196. ie_cbm1.VAO07 = "1"
  5197. ie_cbm1.VAO10 = "0"
  5198. ie_cbm1.VAO11 = "1"
  5199. ie_cbm1.BAK01A = sick.ContentCode
  5200. ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  5201. ie_cbm1.VAO15 = diagnosisConfig.ClassName
  5202. ie_cbm1.VAO18 = "0"
  5203. ie_cbm1.VAO22 = "1"
  5204. ie_cbm1.IAA01 = ""
  5205. ie_cbm1.IAD03 = ""
  5206. ie_cbm1.BAK01B = ""
  5207. ie_cbm1.VAO26 = ""
  5208. ie_cbm1.IAD04 = ""
  5209. ie_cbm1.IAD01 = ""
  5210. ie_cbm1.VAO25 = "2"
  5211. ie_cbm1.VAO35 = ""
  5212. vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  5213. }
  5214. }
  5215. }
  5216. ////
  5217. //////检验检查医嘱
  5218. //for _, item := range prescriptions{
  5219. // fmt.Println("6666666666666")
  5220. // if item.Type == 2{
  5221. // for _, subitem := range item.HisPrescriptionProject {
  5222. // if subitem.Type == 2{
  5223. // if subitem.HisProject.CostClassify == 3 {
  5224. // var ie_cbm1 models.IEfour
  5225. // ie_cbm1.VBQ01 = strconv.FormatInt(int64(item.ID), 10)
  5226. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5227. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5228. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  5229. // ie_cbm1.VAP01 = "0"
  5230. // ie_cbm1.VBQ07 = "0"
  5231. // ie_cbm1.BCK01A = departmwnt.Number
  5232. // ie_cbm1.BCK01B= "0"
  5233. // ie_cbm1.BCE03A= ""
  5234. // ie_cbm1.BCE01A= "0"
  5235. // ie_cbm1.VBQ27= subitem.HisProject.ProjectName
  5236. // ie_cbm1.VBQ28= patientPrescription.Diagnosis
  5237. // ie_cbm1.VBQ29= ""
  5238. // ie_cbm1.VBQ30= ""
  5239. // vBQ1.Ie = append(vBQ1.Ie, ie_cbm1)
  5240. // }
  5241. //
  5242. // }
  5243. //
  5244. // }
  5245. // }
  5246. //}
  5247. root.VAO1 = vAO1
  5248. root.VBQ1 = vBQ1
  5249. xmlStr2, err := xml.MarshalIndent(root, "", " ")
  5250. if err != nil {
  5251. fmt.Println("转换为XML时发生错误:", err)
  5252. return
  5253. }
  5254. data := make(map[string]interface{})
  5255. data["xmlStr"] = string(xmlStr2)
  5256. bytesData, _ := json.Marshal(data)
  5257. var req *http.Request
  5258. client := &http.Client{}
  5259. fmt.Println(string(xmlStr2))
  5260. saveLog("", string(xmlStr2), "1111", "上传明细xml", "")
  5261. req, _ = http.NewRequest("POST", "http://127.0.0.1:9532/"+"nmg/coordinate/upload", bytes.NewBufferString(string(bytesData)))
  5262. resp, _ := client.Do(req)
  5263. defer resp.Body.Close()
  5264. body, ioErr := ioutil.ReadAll(resp.Body)
  5265. if ioErr != nil {
  5266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5268. return
  5269. }
  5270. var respJSON map[string]interface{}
  5271. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5274. return
  5275. }
  5276. respJSON3 := respJSON["data"].(map[string]interface{})["msg"].(string)
  5277. respJSON4 := respJSON["data"].(map[string]interface{})["res"].(string)
  5278. if respJSON3 == "成功" {
  5279. //if li.Acf01 != 1{
  5280. // //记账
  5281. // result2, request2 := service.NMGSettleForCoordinate(info)
  5282. // saveLog(result2, request2, "记账", "记账", org.OrgName)
  5283. //
  5284. //
  5285. // //data := make(map[string]interface{})
  5286. // //data["info"] = &info
  5287. // //
  5288. // //fmt.Println(data)
  5289. // //
  5290. // //bytesData, _ := json.Marshal(data)
  5291. // //var req *http.Request
  5292. // //
  5293. // //client := &http.Client{}
  5294. // //
  5295. // //req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/settle", bytes.NewReader(bytesData))
  5296. // //resp, _ := client.Do(req)
  5297. // //defer resp.Body.Close()
  5298. // //body, ioErr := ioutil.ReadAll(resp.Body)
  5299. // //if ioErr != nil {
  5300. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5301. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5302. // // return
  5303. // //}
  5304. // //var respJSON map[string]interface{}
  5305. // //if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5306. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5307. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5308. // // return
  5309. // //}
  5310. // //
  5311. // //respJSON = respJSON["data"].(map[string]interface{})["res"].(map[string]interface{})
  5312. // //userJSONBytes, _ := json.Marshal(respJSON)
  5313. // //
  5314. // //var res2 ResultUpload2
  5315. // //if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5316. // // utils.ErrorLog("解析失败:%v", err)
  5317. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5318. // // return
  5319. // //}
  5320. // //if res2.Code == 500{
  5321. // // c.ServeSuccessJSON(map[string]interface{}{
  5322. // // "failed_code": -10,
  5323. // // "msg": res2.Msg,
  5324. // // })
  5325. // // return
  5326. // //}
  5327. //}
  5328. if len(zuobiao_ids) == 0 {
  5329. zuobiao_ids = respJSON4
  5330. } else {
  5331. zuobiao_ids = zuobiao_ids + "," + respJSON4
  5332. }
  5333. continue
  5334. } else {
  5335. err_msg = respJSON3
  5336. is_upload_success = false
  5337. if len(zuobiao_ids) > 0 {
  5338. tm := time.Unix(time.Now().Unix(), 0)
  5339. order := &models.HisOrder{
  5340. PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  5341. UserOrgId: org_id,
  5342. PatientId: patient_id,
  5343. SettleAccountsDate: recordDateTime,
  5344. Ctime: time.Now().Unix(),
  5345. Mtime: time.Now().Unix(),
  5346. Status: 1,
  5347. OrderStatus: 1,
  5348. MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  5349. Number: zuobiao_ids,
  5350. SetlId: zuobiao_ids,
  5351. MedfeeSumamt: total,
  5352. MedType: strconv.Itoa(int(reg_type)),
  5353. SettleType: settle_accounts_type,
  5354. Diagnosis: diagnosis_id,
  5355. PType: int64(li.Acf01),
  5356. SetlTime: tm.Format("2006-01-02 15:04:05"),
  5357. SettleStartTime: recordStartTime,
  5358. SettleEndTime: recordEndTime,
  5359. }
  5360. err = service.CreateOrder(order)
  5361. if err != nil {
  5362. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  5363. return
  5364. }
  5365. fmt.Println(idss)
  5366. if settle_accounts_type == 1{
  5367. err = service.UpDatePrescriptionNumber222(org_id, p_id, zuobiao_ids,patient_id)
  5368. }else{
  5369. err = service.UpDatePrescriptionNumber111(org_id, recordStartTime,recordEndTime, zuobiao_ids,patient_id)
  5370. }
  5371. //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  5372. err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  5373. var zuobiao_advice models.HisZuobiaoAdvice
  5374. zuobiao_advice.Status = 1
  5375. zuobiao_advice.RecordDate = recordDateTime
  5376. zuobiao_advice.PatientId = patient_id
  5377. zuobiao_advice.Cbm01 = zuobiao_ids
  5378. zuobiao_advice.Ctime = time.Now().Unix()
  5379. zuobiao_advice.Mtime = time.Now().Unix()
  5380. zuobiao_advice.Oid = order.ID
  5381. zuobiao_advice.StartTime = recordStartTime
  5382. zuobiao_advice.EndTime = recordEndTime
  5383. zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5384. zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5385. zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  5386. service.Createzuobiao(&zuobiao_advice)
  5387. }
  5388. }
  5389. if is_upload_success == false {
  5390. if len(zuobiao_ids) > 0 {
  5391. c.ServeSuccessJSON(map[string]interface{}{
  5392. "failed_code": -10,
  5393. "msg": "部分处方数据上传成功,可在已上传或者在坐标系统查看。其余上传失败原因: " + err_msg,
  5394. })
  5395. return
  5396. } else {
  5397. c.ServeSuccessJSON(map[string]interface{}{
  5398. "failed_code": -10,
  5399. "msg": err_msg,
  5400. })
  5401. return
  5402. }
  5403. }
  5404. }
  5405. if is_upload_success {
  5406. if len(zuobiao_ids) > 0 {
  5407. tm := time.Unix(time.Now().Unix(), 0)
  5408. order := &models.HisOrder{
  5409. PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  5410. UserOrgId: org_id,
  5411. PatientId: patient_id,
  5412. SettleAccountsDate: recordDateTime,
  5413. Ctime: time.Now().Unix(),
  5414. Mtime: time.Now().Unix(),
  5415. Status: 1,
  5416. OrderStatus: 1,
  5417. MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  5418. Number: zuobiao_ids,
  5419. SetlId: zuobiao_ids,
  5420. MedfeeSumamt: total,
  5421. MedType: strconv.Itoa(int(reg_type)),
  5422. SettleType: settle_accounts_type,
  5423. Diagnosis: diagnosis_id,
  5424. PType: int64(li.Acf01),
  5425. SetlTime: tm.Format("2006-01-02 15:04:05"),
  5426. SettleStartTime: recordStartTime,
  5427. SettleEndTime: recordEndTime,
  5428. }
  5429. err = service.CreateOrder(order)
  5430. if err != nil {
  5431. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  5432. return
  5433. }
  5434. err = service.UpDatePrescriptionNumber111(org_id, recordStartTime,recordEndTime, zuobiao_ids,patient_id)
  5435. //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  5436. err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  5437. var zuobiao_advice models.HisZuobiaoAdvice
  5438. zuobiao_advice.Status = 1
  5439. zuobiao_advice.RecordDate = recordDateTime
  5440. zuobiao_advice.PatientId = patient_id
  5441. zuobiao_advice.Cbm01 = zuobiao_ids
  5442. zuobiao_advice.Ctime = time.Now().Unix()
  5443. zuobiao_advice.Mtime = time.Now().Unix()
  5444. zuobiao_advice.Oid = order.ID
  5445. zuobiao_advice.StartTime = recordStartTime
  5446. zuobiao_advice.EndTime = recordEndTime
  5447. zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5448. zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5449. zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  5450. service.Createzuobiao(&zuobiao_advice)
  5451. }
  5452. c.ServeSuccessJSON(map[string]interface{}{
  5453. "msg": "上传成功",
  5454. })
  5455. } else {
  5456. c.ServeSuccessJSON(map[string]interface{}{
  5457. "failed_code": -10,
  5458. "msg": err_msg,
  5459. })
  5460. }
  5461. }
  5462. //
  5463. //zuobiao, _ := service.Getzuobiao(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  5464. //
  5465. //is_success := true
  5466. //failed_mag := ""
  5467. //查询出对应的坐标系统医嘱id,先进行删除操作,在创建医嘱。如果没有医嘱id,则直接创建医嘱
  5468. //if zuobiao.ID > 0 {
  5469. // cbm01s := strings.Split(zuobiao.Cbm01, ",")
  5470. // fmt.Println(cbm01s)
  5471. //
  5472. // for _, iditem := range cbm01s {
  5473. // fmt.Println(iditem)
  5474. // var root2 models.Root2
  5475. // var tradeInfo2 models.TradeInfo
  5476. // if li.Acf01 == 1 {
  5477. // tradeInfo2.PatSource = 1
  5478. // tradeInfo2.Type = 0
  5479. // } else {
  5480. // tradeInfo2.PatSource = 2
  5481. // tradeInfo2.Type = 1
  5482. //
  5483. // }
  5484. // tradeInfo2.Detpid = departmwnt.Number
  5485. // tradeInfo2.Empid = doctor_info.DoctorNumber
  5486. // tradeInfo2.Empno = doctor_info.DoctorCode
  5487. // tradeInfo2.Empname = doctor_info.UserName
  5488. // var vaf01 models.VAF10
  5489. // var ie1111 models.IEfive
  5490. // ie1111.VAF01 = iditem
  5491. // vaf01.Ie = append(vaf01.Ie, ie1111)
  5492. // root2.TradeInfo = tradeInfo2
  5493. // root2.VAF1 = vaf01
  5494. // xmlStr2, err := xml.MarshalIndent(root2, "", " ")
  5495. // if err != nil {
  5496. // fmt.Println("转换为XML时发生错误:", err)
  5497. // return
  5498. // }
  5499. // data := make(map[string]interface{})
  5500. // data["xmlStr"] = string(xmlStr2)
  5501. // bytesData, _ := json.Marshal(data)
  5502. // client := &http.Client{}
  5503. //
  5504. // var req *http.Request
  5505. //
  5506. //
  5507. // req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/del", bytes.NewReader(bytesData))
  5508. // resp, _ := client.Do(req)
  5509. // defer resp.Body.Close()
  5510. // body, ioErr := ioutil.ReadAll(resp.Body)
  5511. // if ioErr != nil {
  5512. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5514. // return
  5515. // }
  5516. // var respJSON map[string]interface{}
  5517. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5518. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5520. // return
  5521. // }
  5522. //
  5523. // respJSON2 := respJSON["data"].(map[string]interface{})["msg"].(string)
  5524. // fmt.Println( respJSON)
  5525. // fmt.Println( respJSON["data"].(map[string]interface{}))
  5526. // fmt.Println(respJSON2)
  5527. //
  5528. // if respJSON2 != "成功"{
  5529. // //is_success = false
  5530. // failed_mag = respJSON2
  5531. // }
  5532. // }
  5533. //}
  5534. } else {
  5535. c.ServeSuccessJSON(map[string]interface{}{
  5536. "failed_code": -10,
  5537. "msg": res8.Msg,
  5538. })
  5539. }
  5540. }
  5541. type Result struct {
  5542. ResultObj []struct {
  5543. Vaf01 int `json:"vaf01"`
  5544. Vaf10 int `json:"vaf10"`
  5545. } `json:"resultObj"`
  5546. Result bool `json:"result"`
  5547. Code int `json:"code"`
  5548. ResultMsg string `json:"resultMsg"`
  5549. Msg string `json:"msg"`
  5550. Error bool `json:"error"`
  5551. Success bool `json:"success"`
  5552. }
  5553. func (c *CoordinateController) NMGCancelSettleAccount() {
  5554. zuobiao_id, _ := c.GetInt64("id")
  5555. zuobiao, _ := service.Getzuobiaobyid(zuobiao_id)
  5556. admin_user_id, _ := c.GetInt64("admin_user_id")
  5557. order, _ := service.GetHisOrderByID(zuobiao.Oid)
  5558. admin_user_info, _ := service.GetAdminUserInfoByID(order.UserOrgId, admin_user_id)
  5559. is_success := true
  5560. var failed_mag string
  5561. if zuobiao.ID > 0 {
  5562. cbm01s := strings.Split(zuobiao.Cbm01, ",")
  5563. var p_type int64
  5564. //for _, iditem := range cbm01s{
  5565. if order.PType == 1 {
  5566. p_type = 1
  5567. } else {
  5568. p_type = 2
  5569. }
  5570. is_del := true
  5571. for _, iditem := range cbm01s {
  5572. var vaf01List []string
  5573. a, _ := service.QueryNMGPrescriptionForCoordinate(p_type, vaf01List, iditem)
  5574. var result Result
  5575. err := json.Unmarshal([]byte(a), &result)
  5576. fmt.Println("Error:", result)
  5577. fmt.Println("Error:", err)
  5578. if err != nil {
  5579. fmt.Println("Error:", err)
  5580. return
  5581. }
  5582. for _,item := range result.ResultObj{
  5583. if item.Vaf10 != 4 {
  5584. is_del = false
  5585. }
  5586. }
  5587. }
  5588. if is_del{
  5589. err := service.UpdataOrderStatustwo(order.ID, zuobiao.Cbm01, order.UserOrgId)
  5590. zuobiao.Status = 0
  5591. service.Createzuobiao(&zuobiao)
  5592. if err == nil {
  5593. c.ServeSuccessJSON(map[string]interface{}{
  5594. "msg": "撤销记账成功",
  5595. })
  5596. } else {
  5597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5598. return
  5599. }
  5600. c.ServeSuccessJSON(map[string]interface{}{
  5601. "msg": "撤销成功",
  5602. })
  5603. }else{
  5604. for _, iditem := range cbm01s {
  5605. var root2 models.Root2
  5606. var tradeInfo2 models.TradeInfo
  5607. if order.PType == 1 {
  5608. tradeInfo2.PatSource = 1
  5609. tradeInfo2.Type = 0
  5610. } else {
  5611. tradeInfo2.PatSource = 2
  5612. tradeInfo2.Type = 1
  5613. }
  5614. tradeInfo2.Detpid = "38"
  5615. tradeInfo2.Empid = admin_user_info.DoctorNumber
  5616. tradeInfo2.Empno = admin_user_info.DoctorCode
  5617. tradeInfo2.Empname = admin_user_info.UserName
  5618. var vaf01 models.VAF10
  5619. var ie1111 models.IEfive
  5620. ie1111.VAF01 = iditem
  5621. vaf01.Ie = append(vaf01.Ie, ie1111)
  5622. root2.TradeInfo = tradeInfo2
  5623. root2.VAF1 = vaf01
  5624. xmlStr2, err := xml.MarshalIndent(root2, "", " ")
  5625. if err != nil {
  5626. fmt.Println("转换为XML时发生错误:", err)
  5627. return
  5628. }
  5629. data := make(map[string]interface{})
  5630. data["xmlStr"] = string(xmlStr2)
  5631. bytesData, _ := json.Marshal(data)
  5632. client := &http.Client{}
  5633. var req *http.Request
  5634. req, _ = http.NewRequest("POST", "http://127.0.0.1:9532/"+"nmg/coordinate/del", bytes.NewReader(bytesData))
  5635. resp, _ := client.Do(req)
  5636. defer resp.Body.Close()
  5637. body, ioErr := ioutil.ReadAll(resp.Body)
  5638. if ioErr != nil {
  5639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5641. return
  5642. }
  5643. var respJSON map[string]interface{}
  5644. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5647. return
  5648. }
  5649. respJSON2 := respJSON["data"].(map[string]interface{})["msg"].(string)
  5650. if respJSON2 != "成功" {
  5651. is_success = false
  5652. if len(failed_mag) == 0 {
  5653. failed_mag = respJSON2
  5654. } else {
  5655. failed_mag = failed_mag + "---" + respJSON2
  5656. }
  5657. }
  5658. if strings.Contains(failed_mag, "医嘱已执行收款,不允许在取消医嘱") {
  5659. is_success = false
  5660. }
  5661. }
  5662. if is_success {
  5663. err := service.UpdataOrderStatustwo(order.ID, zuobiao.Cbm01, order.UserOrgId)
  5664. zuobiao.Status = 0
  5665. service.Createzuobiao(&zuobiao)
  5666. if err == nil {
  5667. c.ServeSuccessJSON(map[string]interface{}{
  5668. "msg": "撤销记账成功",
  5669. })
  5670. } else {
  5671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5672. return
  5673. }
  5674. c.ServeSuccessJSON(map[string]interface{}{
  5675. "msg": "撤销成功",
  5676. })
  5677. } else {
  5678. c.ServeSuccessJSON(map[string]interface{}{
  5679. "failed_code": -10,
  5680. "msg": failed_mag,
  5681. })
  5682. }
  5683. }
  5684. //} else {
  5685. // c.ServeSuccessJSON(map[string]interface{}{
  5686. // "failed_code": -10,
  5687. // "msg": "查询不到可删除的数据",
  5688. // })
  5689. //}
  5690. }
  5691. }
  5692. //func (c *CoordinateController)NMGgetcheck(){
  5693. // patient_id, _ := c.GetInt64("patient_id")
  5694. // record_date := c.GetString("record_date")
  5695. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5696. // //diagnosis_id := c.GetString("diagnosis")
  5697. // //sick_type, _ := c.GetInt64("sick_type")
  5698. // //reg_type, _ := c.GetInt64("p_type")
  5699. // org_id, _ := c.GetInt64("org_id")
  5700. // org_id = 10454
  5701. // org, _ := service.GetOrgById(org_id)
  5702. // patient, _ := service.GetPatientByID(org.Id, patient_id)
  5703. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5704. // result, request := service.GetNMGHisPatientForCoordinate(0,0,2,patient.Name)
  5705. // result5, request5 := service.GetNMGHisPatientForCoordinate(0,0,1,patient.Name)
  5706. //
  5707. // saveLog(result, request, "查询", "查询", "")
  5708. // saveLog(result5, request5, "查询", "查询", "")
  5709. //
  5710. // var res Data
  5711. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  5712. // utils.ErrorLog("解析失败:%v", err)
  5713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5714. // return
  5715. // }
  5716. //
  5717. // var res8 Data
  5718. // if err := json.Unmarshal([]byte(result5), &res8); err != nil {
  5719. // utils.ErrorLog("解析失败:%v", err)
  5720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5721. // return
  5722. // }
  5723. //
  5724. // if res.Code == 200 || res8.Code == 200 {
  5725. // var res9 Data
  5726. // res9.List = append(res9.List,res.List...)
  5727. // res9.List = append(res9.List,res8.List...)
  5728. //
  5729. //
  5730. // var li ListItem
  5731. // for _, item := range res9.List{
  5732. // cure_date := strings.Split(item.Vae11, " ")
  5733. // if cure_date[0] == record_date && patient.Name == item.Vaa05{
  5734. // li = item
  5735. // }
  5736. // }
  5737. // fmt.Println("11111111")
  5738. // fmt.Println(li)
  5739. // fmt.Println("11111111")
  5740. // timeLayout := "2006-01-02"
  5741. // loc, _ := time.LoadLocation("Local")
  5742. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5743. // if err != nil {
  5744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5745. // return
  5746. // }
  5747. // org_id := org.Id
  5748. // recordDateTime := theTime.Unix()
  5749. // patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  5750. // if patientPrescription.ID == 0 {
  5751. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  5752. // }
  5753. // //departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5754. // //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  5755. // //doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  5756. //
  5757. //
  5758. //
  5759. //
  5760. // //service.QueryNMGChenckForCoordinate(li.Acf01,li.Vaa01,li.Vaa07,"")
  5761. //
  5762. //
  5763. // } else {
  5764. // c.ServeSuccessJSON(map[string]interface{}{
  5765. // "failed_code": -10,
  5766. // "msg": res.Msg,
  5767. // })
  5768. // }
  5769. //
  5770. //
  5771. //}
  5772. //func (c *CoordinateController) SettleAccount() {
  5773. // patient_id, _ := c.GetInt64("patient_id")
  5774. // record_date := c.GetString("record_date")
  5775. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5776. // diagnosis_id := c.GetString("diagnosis")
  5777. // sick_type, _ := c.GetInt64("sick_type")
  5778. // reg_type, _ := c.GetInt64("p_type")
  5779. // org_id, _ := c.GetInt64("org_id")
  5780. // org_id = 3877
  5781. // org, _ := service.GetOrgById(org_id)
  5782. // patient, _ := service.GetPatientByID(org.Id, patient_id)
  5783. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5784. //
  5785. // result, request := service.GetHisPatientForCoordinate(patient.IdCardNo)
  5786. // saveLog(result, request, "查询", "查询", org.OrgName)
  5787. // var res ResultQuery
  5788. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  5789. // utils.ErrorLog("解析失败:%v", err)
  5790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5791. // return
  5792. // }
  5793. // if res.Code == "10000" {
  5794. // if len(res.Result) == 0 {
  5795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientNoRegException)
  5796. // return
  5797. // }
  5798. // timeLayout := "2006-01-02"
  5799. // loc, _ := time.LoadLocation("Local")
  5800. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5801. // if err != nil {
  5802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5803. // return
  5804. // }
  5805. // org_id := org.Id
  5806. // recordDateTime := theTime.Unix()
  5807. // patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  5808. // if patientPrescription.ID == 0 {
  5809. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  5810. // }
  5811. // departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5812. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  5813. // //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  5814. //
  5815. // var prescriptions []*models.HisPrescription
  5816. //
  5817. // if settle_accounts_type == 1 { //日结
  5818. // prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, patient_id, recordDateTime, 2)
  5819. // } else { //月结
  5820. //
  5821. // start_time_str := c.GetString("start_time")
  5822. // end_time_str := c.GetString("end_time")
  5823. // timeLayout := "2006-01-02"
  5824. // loc, _ := time.LoadLocation("Local")
  5825. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5826. // if err != nil {
  5827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5828. // return
  5829. // }
  5830. // recordStartTime := theStartTime.Unix()
  5831. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5832. // if err != nil {
  5833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5834. // return
  5835. // }
  5836. // recordEndTime := theEndTime.Unix()
  5837. // prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime)
  5838. // }
  5839. // var total float64
  5840. //
  5841. // for _, item := range prescriptions {
  5842. // fmt.Println(item)
  5843. // if item.Type == 1 { //药品
  5844. // for _, subItem := range item.HisDoctorAdviceInfo {
  5845. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5846. // }
  5847. // }
  5848. // if item.Type == 2 { //项目
  5849. // for _, subItem := range item.HisPrescriptionProject {
  5850. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5851. // total = total + (subItem.Price * cnt)
  5852. // }
  5853. // }
  5854. //
  5855. // }
  5856. //
  5857. // var ids []int64
  5858. //
  5859. // for _, item := range prescriptions {
  5860. // ids = append(ids, item.ID)
  5861. // }
  5862. //
  5863. // var customs []*models.NewCustomTwo
  5864. // for _, item := range prescriptions {
  5865. // if item.Type == 1 { //药品
  5866. // for _, subItem := range item.HisDoctorAdviceInfo {
  5867. // cus := &models.NewCustomTwo{
  5868. // AdviceId: subItem.ID,
  5869. // ProjectId: 0,
  5870. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  5871. // Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  5872. // FeedetlSn: subItem.FeedetlSn,
  5873. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5874. // MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  5875. // Type: 1,
  5876. // }
  5877. // customs = append(customs, cus)
  5878. // }
  5879. // }
  5880. // if item.Type == 2 { //项目
  5881. // for _, subItem := range item.HisPrescriptionProject {
  5882. // if subItem.Type == 2 {
  5883. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5884. // cus := &models.NewCustomTwo{
  5885. // AdviceId: 0,
  5886. // ProjectId: subItem.ID,
  5887. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  5888. // Cut: fmt.Sprintf("%.4f", cnt),
  5889. // FeedetlSn: subItem.FeedetlSn,
  5890. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  5891. // MedListCodg: subItem.HisProject.MedicalCode,
  5892. // Type: 2,
  5893. // }
  5894. // customs = append(customs, cus)
  5895. //
  5896. // } else {
  5897. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5898. // cus := &models.NewCustomTwo{
  5899. // AdviceId: 0,
  5900. // ProjectId: subItem.ID,
  5901. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  5902. // Cut: fmt.Sprintf("%.4f", cnt),
  5903. // FeedetlSn: subItem.FeedetlSn,
  5904. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  5905. // MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  5906. // Type: 3,
  5907. // }
  5908. // customs = append(customs, cus)
  5909. // }
  5910. //
  5911. // }
  5912. // }
  5913. // }
  5914. //
  5915. // var info models.UploadInfo
  5916. // info.Vaa01 = int64(res.Result[0].Vaa01)
  5917. // info.Fasong = "1"
  5918. // info.Vaa07 = int64(res.Result[0].Vaa07)
  5919. // info.Bck01c = departmwnt.Number
  5920. // info.Bce02a = doctor_info.DoctorNumber
  5921. //
  5922. // diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5923. // var config []*models.HisXtDiagnoseConfig
  5924. // for _, item := range diagnosis_ids {
  5925. // id, _ := strconv.ParseInt(item, 10, 64)
  5926. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5927. // config = append(config, &diagnosisConfig)
  5928. // }
  5929. // for index, item := range config {
  5930. // var diag models.Diag
  5931. // diag.Vao06 = strconv.FormatInt(int64(index+1), 10)
  5932. // diag.Bak02 = item.CountryCode
  5933. // info.Diag = append(info.Diag, &diag)
  5934. // }
  5935. // var presInfos []*models.PresInfo
  5936. // var presDetails []*models.PresDetail
  5937. // for index, item := range prescriptions {
  5938. // var presDetail models.PresDetail
  5939. // var presInfo models.PresInfo
  5940. // presInfo.Cbmid = strconv.FormatInt(item.ID, 10)
  5941. // if item.Type == 1 {
  5942. // presInfo.Cbm06 = "0"
  5943. // } else {
  5944. // presInfo.Cbm06 = "5"
  5945. // }
  5946. //
  5947. // if item.Type == 1 {
  5948. // presInfo.Cbm07 = item.MedType
  5949. // } else {
  5950. // presInfo.Cbm07 = item.MedType
  5951. // }
  5952. //
  5953. // presDetail.Vaf59 = strconv.FormatInt(int64(index+1), 10)
  5954. // var infoItems []*models.Item
  5955. // for _, subItem := range item.HisDoctorAdviceInfo {
  5956. // ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
  5957. //
  5958. // var infoItem models.Item
  5959. // infoItem.Rownr = "0"
  5960. // infoItem.Vaf11 = "1"
  5961. // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
  5962. // infoItem.Bbx01 = subItem.BaseDrugLib.MedicalInsuranceNumber
  5963. // infoItem.Bda01 = "1"
  5964. // infoItem.Bby01 = ""
  5965. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  5966. // infoItem.Vaf22 = subItem.BaseDrugLib.DrugName + " " + subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5967. // }
  5968. // infoItem.Vaf14 = subItem.BaseDrugLib.DrugName
  5969. // infoItem.Bdi01 = ef.Code
  5970. // infoItem.Vaf17 = strconv.FormatInt(subItem.Day, 10)
  5971. // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
  5972. // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5973. // infoItem.Vaf35 = "0"
  5974. // infoItem.Vaf32 = "0"
  5975. // infoItem.Bck01b = departmwnt.Number
  5976. // infoItem.Bck01d = departmwnt.Number
  5977. // infoItem.Vaf58 = "0"
  5978. // infoItem.Vaf61 = "1"
  5979. // infoItems = append(infoItems, &infoItem)
  5980. // }
  5981. // for _, subItem := range item.HisPrescriptionProject {
  5982. // ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
  5983. //
  5984. // if subItem.Type == 2 {
  5985. // var infoItem models.Item
  5986. // infoItem.Rownr = "0"
  5987. // infoItem.Vaf11 = "1"
  5988. // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
  5989. // infoItem.Bbx01 = subItem.HisProject.MedicalCode
  5990. //
  5991. // if subItem.HisProject.CostClassify == 2 {
  5992. // infoItem.Bda01 = "T"
  5993. // } else if subItem.HisProject.CostClassify == 3 {
  5994. // infoItem.Bda01 = "L"
  5995. // } else {
  5996. // infoItem.Bda01 = "T"
  5997. // }
  5998. // infoItem.Bby01 = ""
  5999. // infoItem.Vaf22 = subItem.HisProject.ProjectName
  6000. // infoItem.Bdi01 = ef.Code
  6001. // infoItem.Vaf17 = subItem.Day
  6002. // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
  6003. // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.Count)
  6004. // infoItem.Vaf35 = "0"
  6005. // infoItem.Vaf18 = "0"
  6006. // infoItem.Vaf32 = "0"
  6007. // infoItem.Bck01b = departmwnt.Number
  6008. // infoItem.Bck01d = departmwnt.Number
  6009. // infoItem.Vaf58 = "0"
  6010. // infoItem.Vaf61 = "1"
  6011. // infoItems = append(infoItems, &infoItem)
  6012. //
  6013. // } else {
  6014. // var infoItem models.Item
  6015. // infoItem.Rownr = "0"
  6016. // infoItem.Vaf11 = "1"
  6017. // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
  6018. // infoItem.Bbx01 = subItem.GoodInfo.MedicalInsuranceNumber
  6019. // infoItem.Bda01 = "M"
  6020. // infoItem.Bby01 = ""
  6021. // infoItem.Vaf22 = subItem.GoodInfo.GoodName + " " + subItem.GoodInfo.SpecificationName
  6022. // infoItem.Bdi01 = ef.Code
  6023. // infoItem.Vaf17 = subItem.Day
  6024. // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
  6025. // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.Count)
  6026. // infoItem.Vaf35 = "0"
  6027. // infoItem.Vaf32 = "0"
  6028. // infoItem.Bck01b = departmwnt.Number
  6029. // infoItem.Bck01d = departmwnt.Number
  6030. // infoItem.Vaf58 = "0"
  6031. // infoItem.Vaf61 = "1"
  6032. // infoItems = append(infoItems, &infoItem)
  6033. //
  6034. // }
  6035. //
  6036. // }
  6037. // presDetail.Item = infoItems
  6038. // presDetails = append(presDetails, &presDetail)
  6039. // presInfo.PresDetail = presDetails
  6040. // presInfos = append(presInfos, &presInfo)
  6041. // }
  6042. // info.PresInfo = presInfos
  6043. //
  6044. // result2, request2 := service.UploadPrescriptionForCoordinate(info)
  6045. // saveLog(result2, request2, "上传明细", "上传明细", org.OrgName)
  6046. //
  6047. // var res2 ResultUpload
  6048. // if err := json.Unmarshal([]byte(result2), &res2); err != nil {
  6049. // utils.ErrorLog("解析失败:%v", err)
  6050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. // return
  6052. // }
  6053. // if res2.Code == "10000" {
  6054. //
  6055. // timestamp := time.Now().Unix()
  6056. // tempTime := time.Unix(timestamp, 0)
  6057. // timeFormat := tempTime.Format("20060102150405")
  6058. // chrgBchno := rand.Intn(100000) + 10000
  6059. // ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
  6060. // his := models.VMHisPatient{
  6061. // Name: patient.Name,
  6062. // Gender: patient.Gender,
  6063. // Birthday: patient.Birthday,
  6064. // MedicalTreatmentType: 0,
  6065. // IdType: 1,
  6066. // IdCardNo: patient.IdCardNo,
  6067. // BalanceAccountsType: 1,
  6068. // MedicalInsuranceNumber: "",
  6069. // RegisterType: 0,
  6070. // RegisterCost: 0,
  6071. // TreatmentCost: 0,
  6072. // Status: 1,
  6073. // Ctime: time.Now().Unix(),
  6074. // Mtime: time.Now().Unix(),
  6075. // PsnNo: strconv.FormatInt(int64(res.Result[0].Vaa01), 10),
  6076. // PsnCertType: "",
  6077. // Certno: patient.IdCardNo,
  6078. // PsnName: patient.Name,
  6079. // Gend: "",
  6080. // Naty: "",
  6081. // Brdy: "",
  6082. // Age: 0,
  6083. // Iinfo: "",
  6084. // Idetinfo: "",
  6085. // PatientId: patient.ID,
  6086. // RecordDate: theTime.Unix(),
  6087. // UserOrgId: org_id,
  6088. // AdminUserId: admin_user_id,
  6089. // IsReturn: 1,
  6090. // Doctor: patientPrescription.DoctorId,
  6091. // Departments: patientPrescription.Departments,
  6092. // IptOtpNo: ipt_otp_no,
  6093. // Number: strconv.FormatInt(int64(res.Result[0].Vaa07), 10),
  6094. // PhoneNumber: patient.Phone,
  6095. // }
  6096. // service.UpdateHisPatientStatusten(&his)
  6097. // service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
  6098. // tm := time.Unix(time.Now().Unix(), 0)
  6099. //
  6100. // order := &models.HisOrder{
  6101. // PsnNo: his.PsnNo,
  6102. // UserOrgId: org_id,
  6103. // HisPatientId: his.ID,
  6104. // PatientId: patient_id,
  6105. // SettleAccountsDate: recordDateTime,
  6106. // Ctime: time.Now().Unix(),
  6107. // Mtime: time.Now().Unix(),
  6108. // Status: 1,
  6109. // OrderStatus: 1,
  6110. // MdtrtId: his.Number,
  6111. // Number: ipt_otp_no,
  6112. // SetlId: "",
  6113. // MedfeeSumamt: total,
  6114. // MedType: strconv.Itoa(int(reg_type)),
  6115. // SettleEndTime: 0,
  6116. // SettleStartTime: 0,
  6117. // SettleType: settle_accounts_type,
  6118. // Diagnosis: diagnosis_id,
  6119. // PType: 2,
  6120. // SetlTime: tm.Format("2006-01-02 15:04:05"),
  6121. // }
  6122. // err = service.CreateOrder(order)
  6123. // if err != nil {
  6124. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  6125. // return
  6126. // }
  6127. //
  6128. // for _, item := range customs {
  6129. // var advice_id int64 = 0
  6130. // var project_id int64 = 0
  6131. // var item_id int64 = 0
  6132. //
  6133. // var types int64 = 0
  6134. //
  6135. // if item.Type == 1 {
  6136. // advice_id = item.AdviceId
  6137. // project_id = 0
  6138. // item_id = 0
  6139. // } else if item.Type == 2 {
  6140. // advice_id = 0
  6141. // item_id = 0
  6142. //
  6143. // project_id = item.ProjectId
  6144. // } else if item.Type == 3 {
  6145. // advice_id = 0
  6146. // item_id = item.ItemId
  6147. // project_id = 0
  6148. // }
  6149. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6150. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6151. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6152. // info := &models.HisOrderInfo{
  6153. // OrderNumber: order.Number,
  6154. // UploadDate: time.Now().Unix(),
  6155. // AdviceId: advice_id,
  6156. // DetItemFeeSumamt: detItemFeeSumamt,
  6157. // Cnt: cut,
  6158. // Pric: pric,
  6159. // PatientId: patient_id,
  6160. // Status: 1,
  6161. // Mtime: time.Now().Unix(),
  6162. // Ctime: time.Now().Unix(),
  6163. // UserOrgId: org_id,
  6164. // HisPatientId: his.ID,
  6165. // OrderId: order.ID,
  6166. // ProjectId: project_id,
  6167. // Type: types,
  6168. // ItemId: item_id,
  6169. // }
  6170. // service.CreateOrderInfo(info)
  6171. // }
  6172. // his.Diagnosis = diagnosis_id
  6173. // his.SickType = sick_type
  6174. // his.RegisterType = reg_type
  6175. // his.MedicalTreatmentType = reg_type
  6176. // service.UpdataHisPateintTwo(&his)
  6177. // err = service.UpDatePrescriptionNumber(org_id, ids, strconv.FormatInt(int64(chrgBchno), 10))
  6178. // err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(chrgBchno), 10), recordDateTime, his.ID)
  6179. // err = service.UpdataOrderStatusThreef(strconv.FormatInt(int64(chrgBchno), 10), org_id)
  6180. //
  6181. // c.ServeSuccessJSON(map[string]interface{}{
  6182. // "msg": "医嘱保存成功",
  6183. // })
  6184. //
  6185. // } else {
  6186. // c.ServeSuccessJSON(map[string]interface{}{
  6187. // "failed_code": -10,
  6188. // "msg": res.Msg,
  6189. // })
  6190. //
  6191. // }
  6192. //
  6193. // } else {
  6194. // c.ServeSuccessJSON(map[string]interface{}{
  6195. // "failed_code": -10,
  6196. // "msg": res.Msg,
  6197. // })
  6198. //
  6199. // }
  6200. //
  6201. //}
  6202. func (c *CoordinateController) Settle() {
  6203. //参数1 patient_id
  6204. //参数2 就诊号
  6205. //参数3 单据id
  6206. fmt.Println(c.Ctx.Request.Body)
  6207. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  6208. fmt.Println(string(body))
  6209. var respJSON map[string]interface{}
  6210. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6212. return
  6213. }
  6214. patien_id := respJSON["vaa01"].(float64)
  6215. infoSeq := respJSON["vaa07"].(float64)
  6216. //strconv.For(patien_id, 10)
  6217. vaa001 := fmt.Sprintf("%f", patien_id)
  6218. vaa007 := fmt.Sprintf("%f", infoSeq)
  6219. setl_id := respJSON["setl_id"].(string)
  6220. order, _ := service.GetHisOrderFour(vaa001, vaa007, "")
  6221. order.SetlId = setl_id
  6222. if order.ID == 0 {
  6223. json := make(map[string]interface{})
  6224. json["msg"] = "结算记录不存在,请检查参数是否正确"
  6225. json["code"] = "-1"
  6226. c.Data["json"] = json
  6227. c.ServeJSON()
  6228. return
  6229. }
  6230. order.OrderStatus = 2
  6231. service.UpDateOrder(order)
  6232. service.UpdataOrderStatusTwo(order.Number, order.UserOrgId)
  6233. json := make(map[string]interface{})
  6234. json["msg"] = "结算成功"
  6235. json["code"] = "0"
  6236. c.Data["json"] = json
  6237. c.ServeJSON()
  6238. return
  6239. }
  6240. func (c *CoordinateController) Refund() {
  6241. //参数1 patient_id
  6242. //参数2 就诊号
  6243. //参数3 单据id
  6244. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  6245. var respJSON map[string]interface{}
  6246. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6248. return
  6249. }
  6250. patien_id := respJSON["vaa01"].(float64)
  6251. infoSeq := respJSON["vaa07"].(float64)
  6252. //strconv.For(patien_id, 10)
  6253. vaa001 := fmt.Sprintf("%f", patien_id)
  6254. vaa007 := fmt.Sprintf("%f", infoSeq)
  6255. docId := respJSON["setl_id"].(string)
  6256. order, _ := service.GetHisOrderFour(vaa001, vaa007, docId)
  6257. if order.ID == 0 {
  6258. json := make(map[string]interface{})
  6259. json["msg"] = "结算记录不存在,请检查参数是否正确"
  6260. json["code"] = "-1"
  6261. c.Data["json"] = json
  6262. c.ServeJSON()
  6263. return
  6264. }
  6265. service.UpdataOrderStatustwo(order.ID, order.Number, order.UserOrgId)
  6266. json := make(map[string]interface{})
  6267. json["msg"] = "退费成功"
  6268. json["code"] = "0"
  6269. c.Data["json"] = json
  6270. c.ServeJSON()
  6271. return
  6272. }
  6273. func (c *CoordinateController) SavePatientMessageInfo() {
  6274. result, request_log := service.SavePatientMessageInfo()
  6275. fmt.Println(result)
  6276. fmt.Println(request_log)
  6277. }
  6278. func (c *CoordinateController) checkpatient() {
  6279. }
  6280. func (c *CoordinateController) Register() {
  6281. patient_id, _ := c.GetInt64("patient_id")
  6282. diagnosis_time := c.GetString("diagnosis_time")
  6283. record_date := c.GetString("record_date")
  6284. admin_user_id, _ := c.GetInt64("admin_user_id")
  6285. org_id, _ := c.GetInt64("org_id")
  6286. patient, _ := service.GetPatientByID(org_id, patient_id)
  6287. org, _ := service.GetOrgById(org_id)
  6288. timeLayout := "2006-01-02"
  6289. loc, _ := time.LoadLocation("Local")
  6290. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  6291. if err != nil {
  6292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6293. return
  6294. }
  6295. if len(patient.ZbPatientId) == 0 {
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnNoEmpty)
  6297. return
  6298. }
  6299. recordDateTime := theTime.Unix()
  6300. patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  6301. if patientPrescription.ID == 0 {
  6302. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  6303. }
  6304. doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  6305. admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  6306. reg := models.Reg{
  6307. DeptId: "0112",
  6308. PatientId: patient.ZbPatientId,
  6309. PatientName: patient.Name,
  6310. DoctorId: doctor_info.DoctorNumber,
  6311. RegDate: strings.Split(diagnosis_time, " ")[0],
  6312. RegFee: "0",
  6313. TreatFee: "0",
  6314. OperatorId: admin_user_info.UserName,
  6315. IdCardNo: patient.IdCardNo,
  6316. }
  6317. result, request_log := service.SaveReg(reg)
  6318. fmt.Println(result)
  6319. fmt.Println(request_log)
  6320. saveLog(result, request_log, "登记", "登记", org.OrgName)
  6321. var res ResultReg
  6322. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6323. utils.ErrorLog("解析失败:%v", err)
  6324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6325. return
  6326. }
  6327. if res.ResultCode == "0" {
  6328. timestamp := time.Now().Unix()
  6329. tempTime := time.Unix(timestamp, 0)
  6330. timeFormat := tempTime.Format("20060102150405")
  6331. chrgBchno := rand.Intn(100000) + 10000
  6332. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
  6333. his := models.VMHisPatient{
  6334. Name: patient.Name,
  6335. Gender: patient.Gender,
  6336. Birthday: patient.Birthday,
  6337. MedicalTreatmentType: 0,
  6338. IdType: 1,
  6339. IdCardNo: patient.IdCardNo,
  6340. BalanceAccountsType: 1,
  6341. MedicalInsuranceNumber: "",
  6342. RegisterType: 0,
  6343. RegisterCost: 0,
  6344. TreatmentCost: 0,
  6345. Status: 1,
  6346. Ctime: time.Now().Unix(),
  6347. Mtime: time.Now().Unix(),
  6348. PsnNo: patient.ZbPatientId,
  6349. PsnCertType: "",
  6350. Certno: patient.IdCardNo,
  6351. PsnName: patient.Name,
  6352. Gend: "",
  6353. Naty: "",
  6354. Brdy: "",
  6355. Age: 0,
  6356. Iinfo: "",
  6357. Idetinfo: "",
  6358. PatientId: patient.ID,
  6359. RecordDate: theTime.Unix(),
  6360. UserOrgId: org_id,
  6361. AdminUserId: admin_user_id,
  6362. IsReturn: 1,
  6363. Doctor: patientPrescription.DoctorId,
  6364. Departments: patientPrescription.Departments,
  6365. IptOtpNo: ipt_otp_no,
  6366. Number: res.InfoSeq,
  6367. PhoneNumber: patient.Phone,
  6368. }
  6369. service.UpdateHisPatientStatus(&his)
  6370. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
  6371. c.ServeSuccessJSON(map[string]interface{}{
  6372. "his_info": his,
  6373. })
  6374. } else {
  6375. c.ServeSuccessJSON(map[string]interface{}{
  6376. "failed_code": -10,
  6377. "msg": res.ResultDesc,
  6378. })
  6379. }
  6380. }
  6381. //func (c *CoordinateController) GetWaitPayDetail() {
  6382. // result, request_log := service.GetWaitPayDetail()
  6383. // fmt.Println(result)
  6384. // fmt.Println(request_log)
  6385. //
  6386. //}
  6387. //func (c *CoordinateController) OpKeepAccounts() {
  6388. // id, _ := c.GetInt64("id")
  6389. // record_time := c.GetString("record_time")
  6390. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6391. // timeLayout := "2006-01-02"
  6392. // loc, _ := time.LoadLocation("Local")
  6393. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6394. // fapiao_code := c.GetString("fapiao_code")
  6395. // fapiao_number := c.GetString("fapiao_number")
  6396. // diagnosis_id := c.GetString("diagnosis")
  6397. // sick_type, _ := c.GetInt64("sick_type")
  6398. // reg_type, _ := c.GetInt64("p_type")
  6399. // org_id, _ := c.GetInt64("org_id")
  6400. // org, _ := service.GetOrgById(org_id)
  6401. //
  6402. // his, _ := service.GetHisPatientByIdThree(his_patient_id)
  6403. //
  6404. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6405. // if err != nil {
  6406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6407. // return
  6408. // }
  6409. // recordDateTime := theTime.Unix()
  6410. // //adminUser := c.GetAdminUserInfo()
  6411. // var prescriptions []*models.HisPrescription
  6412. // var start_time int64
  6413. // var end_time int64
  6414. //
  6415. // //ids_str := c.GetString("ids")
  6416. // //ids_arr := strings.Split(ids_str, ",")
  6417. //
  6418. // if settle_accounts_type == 1 { //日结
  6419. // //fmt.Println(reg_type)
  6420. // prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, id, recordDateTime, 2)
  6421. //
  6422. // } else { //月结
  6423. //
  6424. // start_time_str := c.GetString("start_time")
  6425. // end_time_str := c.GetString("end_time")
  6426. // timeLayout := "2006-01-02"
  6427. // loc, _ := time.LoadLocation("Local")
  6428. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6429. // if err != nil {
  6430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6431. // return
  6432. // }
  6433. // recordStartTime := theStartTime.Unix()
  6434. // start_time = recordStartTime
  6435. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6436. // if err != nil {
  6437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6438. // return
  6439. // }
  6440. // recordEndTime := theEndTime.Unix()
  6441. // end_time = recordEndTime
  6442. // prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, id, recordStartTime, recordEndTime)
  6443. // }
  6444. //
  6445. // timestamp := time.Now().Unix()
  6446. // tempTime := time.Unix(timestamp, 0)
  6447. // timeFormat := tempTime.Format("20060102150405")
  6448. // chrgBchno := rand.Intn(100000) + 10000
  6449. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6450. // strconv.FormatInt(his.PatientId, 10)
  6451. //
  6452. // var ids []int64
  6453. //
  6454. // for _, item := range prescriptions {
  6455. // ids = append(ids, item.ID)
  6456. // }
  6457. // var total float64
  6458. //
  6459. // for _, item := range prescriptions {
  6460. // fmt.Println(item)
  6461. // if item.Type == 1 { //药品
  6462. // for _, subItem := range item.HisDoctorAdviceInfo {
  6463. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6464. // }
  6465. // }
  6466. // if item.Type == 2 { //项目
  6467. // for _, subItem := range item.HisPrescriptionProject {
  6468. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6469. // total = total + (subItem.Price * cnt)
  6470. // }
  6471. // }
  6472. //
  6473. // for _, subItem := range item.HisAdditionalCharge {
  6474. // total = total + (subItem.Price * float64(subItem.Count))
  6475. // }
  6476. // }
  6477. //
  6478. // tm := time.Unix(time.Now().Unix(), 0)
  6479. //
  6480. // var customs []*models.NewCustomTwo
  6481. // for _, item := range prescriptions {
  6482. // if item.Type == 1 { //药品
  6483. // for _, subItem := range item.HisDoctorAdviceInfo {
  6484. // cus := &models.NewCustomTwo{
  6485. // AdviceId: subItem.ID,
  6486. // ProjectId: 0,
  6487. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  6488. // Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  6489. // FeedetlSn: subItem.FeedetlSn,
  6490. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6491. // MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  6492. // Type: 1,
  6493. // }
  6494. // customs = append(customs, cus)
  6495. // }
  6496. // }
  6497. // if item.Type == 2 { //项目
  6498. // for _, subItem := range item.HisPrescriptionProject {
  6499. // if subItem.Type == 2 {
  6500. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6501. // cus := &models.NewCustomTwo{
  6502. // AdviceId: 0,
  6503. // ProjectId: subItem.ID,
  6504. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  6505. // Cut: fmt.Sprintf("%.4f", cnt),
  6506. // FeedetlSn: subItem.FeedetlSn,
  6507. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  6508. // MedListCodg: subItem.HisProject.MedicalCode,
  6509. // Type: 2,
  6510. // }
  6511. // customs = append(customs, cus)
  6512. //
  6513. // } else {
  6514. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6515. // cus := &models.NewCustomTwo{
  6516. // AdviceId: 0,
  6517. // ProjectId: subItem.ID,
  6518. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  6519. // Cut: fmt.Sprintf("%.4f", cnt),
  6520. // FeedetlSn: subItem.FeedetlSn,
  6521. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  6522. // MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  6523. // Type: 3,
  6524. // }
  6525. // customs = append(customs, cus)
  6526. //
  6527. // }
  6528. //
  6529. // }
  6530. // }
  6531. // for _, item := range item.HisAdditionalCharge {
  6532. // cus := &models.NewCustomTwo{
  6533. // ItemId: item.ID,
  6534. // AdviceId: 0,
  6535. // ProjectId: 0,
  6536. // DetItemFeeSumamt: fmt.Sprintf("%.4f", item.Price),
  6537. // Cut: fmt.Sprintf("%.4f", float64(item.Count)),
  6538. // FeedetlSn: item.FeedetlSn,
  6539. // Price: fmt.Sprintf("%.4f", float64(item.Price)),
  6540. // MedListCodg: item.XtHisAddtionConfig.Code,
  6541. // Type: 3,
  6542. // }
  6543. // customs = append(customs, cus)
  6544. // }
  6545. // }
  6546. // result, request_log := service.OpKeepAccounts(his.Number, customs)
  6547. // saveLog(result, request_log, "记账", "记账", org.OrgName)
  6548. //
  6549. // var res ResultSettle
  6550. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  6551. // utils.ErrorLog("解析失败:%v", err)
  6552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6553. // return
  6554. // }
  6555. // if res.ResultCode == "0" {
  6556. //
  6557. // //totals, _ := strconv.ParseFloat(total, 64)
  6558. // order := &models.HisOrder{
  6559. // PsnNo: his.PsnNo,
  6560. // UserOrgId: org_id,
  6561. // HisPatientId: his.ID,
  6562. // PatientId: id,
  6563. // SettleAccountsDate: recordDateTime,
  6564. // Ctime: time.Now().Unix(),
  6565. // Mtime: time.Now().Unix(),
  6566. // Status: 1,
  6567. // OrderStatus: 1,
  6568. // MdtrtId: his.Number,
  6569. // Number: chrg_bchno,
  6570. // SetlId: "",
  6571. // MedfeeSumamt: total,
  6572. // MedType: strconv.Itoa(int(reg_type)),
  6573. // SettleEndTime: end_time,
  6574. // SettleStartTime: start_time,
  6575. // SettleType: settle_accounts_type,
  6576. // FaPiaoCode: fapiao_code,
  6577. // FaPiaoNumber: fapiao_number,
  6578. // Diagnosis: diagnosis_id,
  6579. // PType: 2,
  6580. // SetlTime: tm.Format("2006-01-02 15:04:05"),
  6581. // }
  6582. // err = service.CreateOrder(order)
  6583. // if err != nil {
  6584. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  6585. // return
  6586. // }
  6587. //
  6588. // for _, item := range customs {
  6589. // var advice_id int64 = 0
  6590. // var project_id int64 = 0
  6591. // var item_id int64 = 0
  6592. //
  6593. // var types int64 = 0
  6594. //
  6595. // if item.Type == 1 {
  6596. // advice_id = item.AdviceId
  6597. // project_id = 0
  6598. // item_id = 0
  6599. // } else if item.Type == 2 {
  6600. // advice_id = 0
  6601. // item_id = 0
  6602. //
  6603. // project_id = item.ProjectId
  6604. // } else if item.Type == 3 {
  6605. // advice_id = 0
  6606. // item_id = item.ItemId
  6607. // project_id = 0
  6608. // }
  6609. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6610. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6611. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6612. // info := &models.HisOrderInfo{
  6613. // OrderNumber: order.Number,
  6614. // UploadDate: time.Now().Unix(),
  6615. // AdviceId: advice_id,
  6616. // DetItemFeeSumamt: detItemFeeSumamt,
  6617. // Cnt: cut,
  6618. // Pric: pric,
  6619. // PatientId: id,
  6620. // Status: 1,
  6621. // Mtime: time.Now().Unix(),
  6622. // Ctime: time.Now().Unix(),
  6623. // UserOrgId: org_id,
  6624. // HisPatientId: his.ID,
  6625. // OrderId: order.ID,
  6626. // ProjectId: project_id,
  6627. // Type: types,
  6628. // ItemId: item_id,
  6629. // }
  6630. // service.CreateOrderInfo(info)
  6631. // }
  6632. // his.Diagnosis = diagnosis_id
  6633. // his.SickType = sick_type
  6634. // his.RegisterType = reg_type
  6635. // his.MedicalTreatmentType = reg_type
  6636. // service.UpdataHisPateintThree(&his)
  6637. // err = service.UpDatePrescriptionNumber(org_id, ids, chrg_bchno)
  6638. // err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, id, chrg_bchno, recordDateTime, his_patient_id)
  6639. // err = service.UpdataOrderStatusThreef(chrg_bchno, org_id)
  6640. // if err == nil {
  6641. // c.ServeSuccessJSON(map[string]interface{}{
  6642. // "msg": "记账成功",
  6643. // })
  6644. // }
  6645. // } else {
  6646. // c.ServeSuccessJSON(map[string]interface{}{
  6647. // "failed_code": -10,
  6648. // "msg": res.ResultDesc,
  6649. // })
  6650. // }
  6651. //
  6652. //}
  6653. //
  6654. //func (c *CoordinateController) OpCancelKeepAccounts() {
  6655. // order_id, _ := c.GetInt64("order_id")
  6656. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6657. // org_id, _ := c.GetInt64("org_id")
  6658. // org, _ := service.GetOrgById(org_id)
  6659. //
  6660. // order, _ := service.GetHisOrderByID(order_id)
  6661. // if order.ID == 0 {
  6662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6663. // return
  6664. // }
  6665. //
  6666. // role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  6667. // result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
  6668. // saveLog(result, request_log, "撤销记账", "撤销记账", org.OrgName)
  6669. // var res RefundDetail
  6670. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  6671. // utils.ErrorLog("解析失败:%v", err)
  6672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6673. // return
  6674. // }
  6675. // fmt.Println(result)
  6676. // fmt.Println(request_log)
  6677. // fmt.Println(res)
  6678. // flag := 0
  6679. // isSuccess := false
  6680. // for _, item := range res.Result {
  6681. // if item.Code == "200" {
  6682. // flag = flag + 1
  6683. // }
  6684. // }
  6685. // if len(res.Result) == flag {
  6686. // isSuccess = true
  6687. // }
  6688. // var errMsg string
  6689. // for _, item := range res.Result {
  6690. // errMsg = errMsg + "\n" + item.ResultMsg
  6691. // }
  6692. //
  6693. // if isSuccess {
  6694. // err := service.UpdataOrderStatustwo(order_id, order.Number, org_id)
  6695. // if err == nil {
  6696. // c.ServeSuccessJSON(map[string]interface{}{
  6697. // "msg": "撤销记账成功",
  6698. // })
  6699. // } else {
  6700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6701. // return
  6702. // }
  6703. // } else {
  6704. // c.ServeSuccessJSON(map[string]interface{}{
  6705. // "failed_code": -10,
  6706. // "msg": errMsg,
  6707. // })
  6708. //
  6709. // }
  6710. //}
  6711. //func saveLog(result string, request string, infno string, desc string) {
  6712. //
  6713. // org_id, _ := beego.AppConfig.Int64("org_id")
  6714. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6715. // dir := miConfig.OrgName + "日志"
  6716. // utils.Mkdir(dir)
  6717. // month := time.Unix(1557042972, 0).Format("1")
  6718. // year := time.Now().Format("2006")
  6719. // month = time.Now().Format("01")
  6720. // day := time.Now().Format("02")
  6721. // hour := time.Now().Format("15")
  6722. // min := time.Now().Format("04")
  6723. // sec := time.Now().Format("05")
  6724. //
  6725. // result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  6726. //
  6727. // file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  6728. // file_name := file + ".txt"
  6729. // file_path := miConfig.OrgName + "日志" + "/" + file_name
  6730. // exist, _ := utils.PathExists(file_path)
  6731. // if exist { //存在
  6732. // fmt.Println("存在")
  6733. // f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  6734. // if err != nil {
  6735. // fmt.Println("read fail")
  6736. // }
  6737. // content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  6738. // n, _ := f.Seek(0, 2)
  6739. // _, err = f.WriteAt([]byte(content), n)
  6740. //
  6741. // } else { //不存在
  6742. // fmt.Println("文件不存在,创建文件")
  6743. // f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  6744. // defer f.Close()
  6745. // if err != nil {
  6746. // } else {
  6747. // _, err = f.Write([]byte("记录日志"))
  6748. // }
  6749. // }
  6750. //
  6751. //}
  6752. func generateRandomNumber() int64 {
  6753. rand.Seed(time.Now().UnixNano())
  6754. return int64(rand.Intn(90000) + 10000)
  6755. }