coordinate_controller.go 243KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289
  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. if subitem.TeamId > 0{
  3648. //ie_cbm1.BBX01 = subitem.HisProject.
  3649. team := service.GetBbx01ByTeamID(subitem.TeamId)
  3650. ie_cbm1.BBX01 = team.Bbx01
  3651. }else{
  3652. ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  3653. }
  3654. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3655. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  3656. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3657. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  3658. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  3659. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  3660. ie_cbm1.VAF10 = "1"
  3661. ie_cbm1.VAF11 = "2"
  3662. ie_cbm1.BDA01 = "L" //诊疗类型
  3663. ie_cbm1.VAF14 = subitem.HisProject.Vaf14 //检验样本类型
  3664. ie_cbm1.VAF15 = "" //检验样本类型
  3665. ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  3666. if li.Acf01 == 1 {
  3667. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  3668. } else {
  3669. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  3670. }
  3671. if subitem.SingleDose == "" {
  3672. subitem.SingleDose = "1"
  3673. }
  3674. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  3675. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  3676. ie_cbm1.VAF20 = subitem.SingleDose
  3677. ie_cbm1.VAF21 = subitem.Count
  3678. ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  3679. ie_cbm1.Crypt = "0"
  3680. ie_cbm1.VAF23 = ""
  3681. ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  3682. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  3683. ie_cbm1.VAF27 = "1"
  3684. ie_cbm1.VAF28 = "1"
  3685. ie_cbm1.VAF29 = ""
  3686. ie_cbm1.BCK01C = "38"
  3687. ie_cbm1.VAF30 = ""
  3688. ie_cbm1.VAF31 = "0"
  3689. ie_cbm1.VAF32 = "0" //todo
  3690. ie_cbm1.VAF33 = "0"
  3691. ie_cbm1.VAF34 = "0"
  3692. ie_cbm1.VAF35 = "0"
  3693. tempTime1 := time.Unix(subitem.StartTime, 0)
  3694. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  3695. ie_cbm1.VAF36 = timeFormatOne
  3696. ie_cbm1.VAF37 = "1899-12-30"
  3697. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  3698. ie_cbm1.BCE02A = doctor_info.DoctorCode
  3699. ie_cbm1.BCE03A = doctor_info.UserName
  3700. ie_cbm1.BCE03B = ""
  3701. ie_cbm1.VAF53 = "-1"
  3702. ie_cbm1.VAF55 = subitem.Remark
  3703. ie_cbm1.BCK01D = "38"
  3704. ie_cbm1.VAF58 = "0"
  3705. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  3706. ie_cbm1.VAF60 = ""
  3707. ie_cbm1.VAF61 = "1"
  3708. ie_cbm1.VAF62 = "0"
  3709. ie_cbm1.LSign = "0"
  3710. ie_cbm1.BDA01A = "" //诊疗类型
  3711. ie_cbm1.LRoute = "0"
  3712. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  3713. ie_cbm1.VAF07 = "0"
  3714. //ie_cbm1.BCE01A = doctor_info.UserName
  3715. ie_cbm1.BCE01B = "0"
  3716. ie_cbm1.VAF01B = "0"
  3717. ie_cbm1.VCO01 = "0"
  3718. ie_cbm1.BCE01H = "0"
  3719. ie_cbm1.BCE03H = ""
  3720. ie_cbm1.BIW02 = ""
  3721. ie_cbm1.RCurrent = "0"
  3722. ie_cbm1.FCheck = "0"
  3723. ie_cbm1.UnameA = ""
  3724. ie_cbm1.VEH02 = ""
  3725. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  3726. }
  3727. } else if subitem.Type == 3 {
  3728. var ie_cbm1 models.IEtwo
  3729. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3730. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  3731. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3732. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  3733. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  3734. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  3735. ie_cbm1.VAF10 = "1"
  3736. ie_cbm1.VAF11 = "2"
  3737. ie_cbm1.BDA01 = "4" //诊疗类型
  3738. ie_cbm1.BBX01 = subitem.GoodInfo.ZuobiaoId
  3739. ie_cbm1.VAF15 = "" //检验样本类型
  3740. ie_cbm1.BBY01 = subitem.GoodInfo.Bby01 //药品规格id或材料规格id
  3741. if li.Acf01 == 1 {
  3742. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  3743. if len(subitem.Day) == 0 {
  3744. ie_cbm1.VAF17 = "1"
  3745. }
  3746. } else {
  3747. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  3748. }
  3749. if subitem.SingleDose == "" {
  3750. subitem.SingleDose = "1"
  3751. }
  3752. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  3753. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  3754. ie_cbm1.VAF20 = subitem.SingleDose
  3755. ie_cbm1.VAF21 = subitem.Count
  3756. ie_cbm1.BCK01C = "38"
  3757. ie_cbm1.VAF22 = subitem.GoodInfo.GoodName + " " + subitem.GoodInfo.SpecificationName
  3758. ie_cbm1.Crypt = "0"
  3759. ie_cbm1.VAF23 = ""
  3760. ie_cbm1.BCK01B = subitem.GoodInfo.Bck01b
  3761. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  3762. ie_cbm1.VAF27 = "1"
  3763. ie_cbm1.VAF28 = "1"
  3764. ie_cbm1.VAF29 = ""
  3765. ie_cbm1.VAF07 = "0"
  3766. ie_cbm1.VAF14 = "" //检验样本类型
  3767. ie_cbm1.VAF30 = ""
  3768. ie_cbm1.VAF31 = "0"
  3769. ie_cbm1.VAF32 = "0" //todo
  3770. ie_cbm1.VAF33 = "0"
  3771. ie_cbm1.VAF34 = "0"
  3772. ie_cbm1.VAF35 = "0"
  3773. tempTime1 := time.Unix(subitem.StartTime, 0)
  3774. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  3775. ie_cbm1.VAF36 = timeFormatOne
  3776. ie_cbm1.VAF37 = "1899-12-30"
  3777. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  3778. ie_cbm1.BCE02A = doctor_info.DoctorCode
  3779. ie_cbm1.BCE03A = doctor_info.UserName
  3780. ie_cbm1.BCE03B = ""
  3781. ie_cbm1.BCK01C = "38"
  3782. ie_cbm1.VAF53 = "-1"
  3783. ie_cbm1.VAF55 = subitem.Remark
  3784. ie_cbm1.BCK01D ="38"
  3785. ie_cbm1.VAF58 = "0"
  3786. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  3787. ie_cbm1.VAF60 = ""
  3788. ie_cbm1.VAF61 = "1"
  3789. ie_cbm1.VAF62 = "0"
  3790. ie_cbm1.LSign = "0"
  3791. ie_cbm1.BDA01A = "" //诊疗类型
  3792. ie_cbm1.LRoute = "0"
  3793. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  3794. ie_cbm1.BCE01B = "0"
  3795. ie_cbm1.VAF01B = "0"
  3796. ie_cbm1.VCO01 = "0"
  3797. ie_cbm1.BCE01H = "0"
  3798. ie_cbm1.BCE03H = ""
  3799. ie_cbm1.BIW02 = ""
  3800. ie_cbm1.RCurrent = "0"
  3801. ie_cbm1.FCheck = "0"
  3802. ie_cbm1.UnameA = ""
  3803. ie_cbm1.VEH02 = ""
  3804. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  3805. }
  3806. }
  3807. }
  3808. }
  3809. root.VAF1 = vAF1
  3810. for index, item := range big_ps[start-1 : stop] {
  3811. sick, _ := service.FindSickById(sick_type)
  3812. item.VMHisPrescriptionInfo.Diagnosis = "716"
  3813. dias := strings.Split(item.VMHisPrescriptionInfo.Diagnosis, ",")
  3814. //service.get
  3815. //诊断
  3816. for _, subitem := range dias {
  3817. diagnosisConfig, _ := service.FindDiagnoseByIdtwo(subitem)
  3818. if index == 0 {
  3819. var ie_cbm1 models.IEthree
  3820. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3821. //ie_cbm1.CBMID = strconv.FormatInt(int64(index+1), 10)
  3822. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3823. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  3824. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  3825. ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  3826. ie_cbm1.VAO07 = "1"
  3827. ie_cbm1.VAO10 = "0"
  3828. ie_cbm1.VAO11 = "1"
  3829. ie_cbm1.BAK01A = sick.ContentCode
  3830. ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  3831. ie_cbm1.VAO15 = diagnosisConfig.ClassName
  3832. ie_cbm1.VAO18 = "0"
  3833. ie_cbm1.VAO22 = "1"
  3834. ie_cbm1.IAA01 = ""
  3835. ie_cbm1.IAD03 = ""
  3836. ie_cbm1.BAK01B = ""
  3837. ie_cbm1.VAO26 = ""
  3838. ie_cbm1.IAD04 = ""
  3839. ie_cbm1.IAD01 = ""
  3840. ie_cbm1.VAO25 = "1"
  3841. ie_cbm1.VAO35 = ""
  3842. vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  3843. } else {
  3844. var ie_cbm1 models.IEthree
  3845. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  3846. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3847. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  3848. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  3849. ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  3850. ie_cbm1.VAO07 = "1"
  3851. ie_cbm1.VAO10 = "0"
  3852. ie_cbm1.VAO11 = "1"
  3853. ie_cbm1.BAK01A = sick.ContentCode
  3854. ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  3855. ie_cbm1.VAO15 = diagnosisConfig.ClassName
  3856. ie_cbm1.VAO18 = "0"
  3857. ie_cbm1.VAO22 = "1"
  3858. ie_cbm1.IAA01 = ""
  3859. ie_cbm1.IAD03 = ""
  3860. ie_cbm1.BAK01B = ""
  3861. ie_cbm1.VAO26 = ""
  3862. ie_cbm1.IAD04 = ""
  3863. ie_cbm1.IAD01 = ""
  3864. ie_cbm1.VAO25 = "2"
  3865. ie_cbm1.VAO35 = ""
  3866. vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  3867. }
  3868. }
  3869. }
  3870. ////
  3871. //////检验检查医嘱
  3872. //for _, item := range prescriptions{
  3873. // fmt.Println("6666666666666")
  3874. // if item.Type == 2{
  3875. // for _, subitem := range item.HisPrescriptionProject {
  3876. // if subitem.Type == 2{
  3877. // if subitem.HisProject.CostClassify == 3 {
  3878. // var ie_cbm1 models.IEfour
  3879. // ie_cbm1.VBQ01 = strconv.FormatInt(int64(item.ID), 10)
  3880. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  3881. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  3882. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  3883. // ie_cbm1.VAP01 = "0"
  3884. // ie_cbm1.VBQ07 = "0"
  3885. // ie_cbm1.BCK01A = departmwnt.Number
  3886. // ie_cbm1.BCK01B= "0"
  3887. // ie_cbm1.BCE03A= ""
  3888. // ie_cbm1.BCE01A= "0"
  3889. // ie_cbm1.VBQ27= subitem.HisProject.ProjectName
  3890. // ie_cbm1.VBQ28= patientPrescription.Diagnosis
  3891. // ie_cbm1.VBQ29= ""
  3892. // ie_cbm1.VBQ30= ""
  3893. // vBQ1.Ie = append(vBQ1.Ie, ie_cbm1)
  3894. // }
  3895. //
  3896. // }
  3897. //
  3898. // }
  3899. // }
  3900. //}
  3901. root.VAO1 = vAO1
  3902. root.VBQ1 = vBQ1
  3903. xmlStr2, err := xml.MarshalIndent(root, "", " ")
  3904. if err != nil {
  3905. fmt.Println("转换为XML时发生错误:", err)
  3906. return
  3907. }
  3908. data := make(map[string]interface{})
  3909. data["xmlStr"] = string(xmlStr2)
  3910. bytesData, _ := json.Marshal(data)
  3911. var req *http.Request
  3912. client := &http.Client{}
  3913. fmt.Println(string(xmlStr2))
  3914. saveLog("", string(xmlStr2), "1111", "上传明细xml", "")
  3915. req, _ = http.NewRequest("POST", "http://127.0.0.1:9532/"+"nmg/coordinate/upload", bytes.NewBufferString(string(bytesData)))
  3916. resp, _ := client.Do(req)
  3917. defer resp.Body.Close()
  3918. body, ioErr := ioutil.ReadAll(resp.Body)
  3919. if ioErr != nil {
  3920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3922. return
  3923. }
  3924. var respJSON map[string]interface{}
  3925. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3928. return
  3929. }
  3930. respJSON3 := respJSON["data"].(map[string]interface{})["msg"].(string)
  3931. respJSON4 := respJSON["data"].(map[string]interface{})["res"].(string)
  3932. if respJSON3 == "成功" {
  3933. //if li.Acf01 != 1{
  3934. // //记账
  3935. // result2, request2 := service.NMGSettleForCoordinate(info)
  3936. // saveLog(result2, request2, "记账", "记账", org.OrgName)
  3937. //
  3938. //
  3939. // //data := make(map[string]interface{})
  3940. // //data["info"] = &info
  3941. // //
  3942. // //fmt.Println(data)
  3943. // //
  3944. // //bytesData, _ := json.Marshal(data)
  3945. // //var req *http.Request
  3946. // //
  3947. // //client := &http.Client{}
  3948. // //
  3949. // //req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/settle", bytes.NewReader(bytesData))
  3950. // //resp, _ := client.Do(req)
  3951. // //defer resp.Body.Close()
  3952. // //body, ioErr := ioutil.ReadAll(resp.Body)
  3953. // //if ioErr != nil {
  3954. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3955. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3956. // // return
  3957. // //}
  3958. // //var respJSON map[string]interface{}
  3959. // //if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3960. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3961. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. // // return
  3963. // //}
  3964. // //
  3965. // //respJSON = respJSON["data"].(map[string]interface{})["res"].(map[string]interface{})
  3966. // //userJSONBytes, _ := json.Marshal(respJSON)
  3967. // //
  3968. // //var res2 ResultUpload2
  3969. // //if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3970. // // utils.ErrorLog("解析失败:%v", err)
  3971. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3972. // // return
  3973. // //}
  3974. // //if res2.Code == 500{
  3975. // // c.ServeSuccessJSON(map[string]interface{}{
  3976. // // "failed_code": -10,
  3977. // // "msg": res2.Msg,
  3978. // // })
  3979. // // return
  3980. // //}
  3981. //}
  3982. if len(zuobiao_ids) == 0 {
  3983. zuobiao_ids = respJSON4
  3984. } else {
  3985. zuobiao_ids = zuobiao_ids + "," + respJSON4
  3986. }
  3987. continue
  3988. } else {
  3989. err_msg = respJSON3
  3990. is_upload_success = false
  3991. if len(zuobiao_ids) > 0 {
  3992. tm := time.Unix(time.Now().Unix(), 0)
  3993. order := &models.HisOrder{
  3994. PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  3995. UserOrgId: org_id,
  3996. PatientId: patient_id,
  3997. SettleAccountsDate: recordDateTime,
  3998. Ctime: time.Now().Unix(),
  3999. Mtime: time.Now().Unix(),
  4000. Status: 1,
  4001. OrderStatus: 1,
  4002. MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  4003. Number: zuobiao_ids,
  4004. SetlId: zuobiao_ids,
  4005. MedfeeSumamt: total,
  4006. MedType: strconv.Itoa(int(reg_type)),
  4007. SettleType: settle_accounts_type,
  4008. Diagnosis: diagnosis_id,
  4009. PType: int64(li.Acf01),
  4010. SetlTime: tm.Format("2006-01-02 15:04:05"),
  4011. SettleStartTime: recordStartTime,
  4012. SettleEndTime: recordEndTime,
  4013. }
  4014. err = service.CreateOrder(order)
  4015. if err != nil {
  4016. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  4017. return
  4018. }
  4019. fmt.Println(idss)
  4020. if settle_accounts_type == 1{
  4021. err = service.UpDatePrescriptionNumber222(org_id, p_id, zuobiao_ids,patient_id)
  4022. }else{
  4023. err = service.UpDatePrescriptionNumber111(org_id, recordStartTime,recordEndTime, zuobiao_ids,patient_id)
  4024. }
  4025. //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  4026. err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  4027. var zuobiao_advice models.HisZuobiaoAdvice
  4028. zuobiao_advice.Status = 1
  4029. zuobiao_advice.RecordDate = recordDateTime
  4030. zuobiao_advice.PatientId = patient_id
  4031. zuobiao_advice.Cbm01 = zuobiao_ids
  4032. zuobiao_advice.Ctime = time.Now().Unix()
  4033. zuobiao_advice.Mtime = time.Now().Unix()
  4034. zuobiao_advice.Oid = order.ID
  4035. zuobiao_advice.StartTime = recordStartTime
  4036. zuobiao_advice.EndTime = recordEndTime
  4037. zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4038. zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  4039. zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  4040. service.Createzuobiao(&zuobiao_advice)
  4041. }
  4042. }
  4043. if is_upload_success == false {
  4044. if len(zuobiao_ids) > 0 {
  4045. c.ServeSuccessJSON(map[string]interface{}{
  4046. "failed_code": -10,
  4047. "msg": "部分处方数据上传成功,可在已上传或者在坐标系统查看。其余上传失败原因: " + err_msg,
  4048. })
  4049. return
  4050. } else {
  4051. c.ServeSuccessJSON(map[string]interface{}{
  4052. "failed_code": -10,
  4053. "msg": err_msg,
  4054. })
  4055. return
  4056. }
  4057. }
  4058. }
  4059. if is_upload_success {
  4060. if len(zuobiao_ids) > 0 {
  4061. tm := time.Unix(time.Now().Unix(), 0)
  4062. order := &models.HisOrder{
  4063. PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  4064. UserOrgId: org_id,
  4065. PatientId: patient_id,
  4066. SettleAccountsDate: recordDateTime,
  4067. Ctime: time.Now().Unix(),
  4068. Mtime: time.Now().Unix(),
  4069. Status: 1,
  4070. OrderStatus: 1,
  4071. MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  4072. Number: zuobiao_ids,
  4073. SetlId: zuobiao_ids,
  4074. MedfeeSumamt: total,
  4075. MedType: strconv.Itoa(int(reg_type)),
  4076. SettleType: settle_accounts_type,
  4077. Diagnosis: diagnosis_id,
  4078. PType: int64(li.Acf01),
  4079. SetlTime: tm.Format("2006-01-02 15:04:05"),
  4080. SettleStartTime: recordStartTime,
  4081. SettleEndTime: recordEndTime,
  4082. }
  4083. err = service.CreateOrder(order)
  4084. if err != nil {
  4085. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  4086. return
  4087. }
  4088. err = service.UpDatePrescriptionNumber222(org_id, p_id, zuobiao_ids,patient_id)
  4089. //err = service.UpDatePrescriptionNumber111(org_id, recordStartTime,recordEndTime, zuobiao_ids,patient_id)
  4090. //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  4091. err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  4092. //err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  4093. var zuobiao_advice models.HisZuobiaoAdvice
  4094. zuobiao_advice.Status = 1
  4095. zuobiao_advice.RecordDate = recordDateTime
  4096. zuobiao_advice.PatientId = patient_id
  4097. zuobiao_advice.Cbm01 = zuobiao_ids
  4098. zuobiao_advice.Ctime = time.Now().Unix()
  4099. zuobiao_advice.Mtime = time.Now().Unix()
  4100. zuobiao_advice.Oid = order.ID
  4101. zuobiao_advice.StartTime = recordStartTime
  4102. zuobiao_advice.EndTime = recordEndTime
  4103. zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4104. zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  4105. zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  4106. service.Createzuobiao(&zuobiao_advice)
  4107. }
  4108. c.ServeSuccessJSON(map[string]interface{}{
  4109. "msg": "上传成功",
  4110. })
  4111. } else {
  4112. c.ServeSuccessJSON(map[string]interface{}{
  4113. "failed_code": -10,
  4114. "msg": err_msg,
  4115. })
  4116. }
  4117. } else { //月结
  4118. start_time_str := c.GetString("start_time")
  4119. end_time_str := c.GetString("end_time")
  4120. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4121. if err != nil {
  4122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4123. return
  4124. }
  4125. recordStartTime = theStartTime.Unix()
  4126. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4127. if err != nil {
  4128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4129. return
  4130. }
  4131. recordEndTime = theEndTime.Unix()
  4132. prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime)
  4133. var total float64
  4134. var customs []*models.NewCustomTwo
  4135. for _, item := range prescriptions {
  4136. if item.Type == 1 { //药品
  4137. for _, subItem := range item.HisDoctorAdviceInfo {
  4138. tempTime := time.Unix(item.PreTime, 0)
  4139. //timeFormat := tempTime.Format("20060102150405")
  4140. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4141. cus := &models.NewCustomTwo{
  4142. AdviceId: subItem.ID,
  4143. ProjectId: 0,
  4144. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  4145. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  4146. FeedetlSn: subItem.FeedetlSn,
  4147. Price: fmt.Sprintf("%.2f", subItem.Price),
  4148. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  4149. Type: 1,
  4150. ItemId: subItem.BaseDrugLib.ZuobiaoId,
  4151. StartTime: timeFormatOne,
  4152. Content: subItem.AdviceName,
  4153. Bby01: subItem.BaseDrugLib.Bby01,
  4154. }
  4155. customs = append(customs, cus)
  4156. }
  4157. }
  4158. if item.Type == 2 { //项目
  4159. for _, subItem := range item.HisPrescriptionProject {
  4160. if subItem.Type == 2 {
  4161. tempTime := time.Unix(item.PreTime, 0)
  4162. //timeFormat := tempTime.Format("20060102150405")
  4163. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4164. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4165. cus := &models.NewCustomTwo{
  4166. AdviceId: 0,
  4167. ProjectId: subItem.ID,
  4168. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  4169. Cut: fmt.Sprintf("%.4f", cnt),
  4170. FeedetlSn: subItem.FeedetlSn,
  4171. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  4172. MedListCodg: subItem.HisProject.MedicalCode,
  4173. Type: 2,
  4174. ItemId: subItem.HisProject.ZuobiaoId,
  4175. StartTime: timeFormatOne,
  4176. Content: subItem.HisProject.ProjectName,
  4177. Bby01: subItem.HisProject.Bby01,
  4178. }
  4179. customs = append(customs, cus)
  4180. } else {
  4181. tempTime := time.Unix(item.PreTime, 0)
  4182. //timeFormat := tempTime.Format("20060102150405")
  4183. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4184. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4185. cus := &models.NewCustomTwo{
  4186. AdviceId: 0,
  4187. ProjectId: subItem.ID,
  4188. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  4189. Cut: fmt.Sprintf("%.4f", cnt),
  4190. FeedetlSn: subItem.FeedetlSn,
  4191. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  4192. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  4193. Type: 3,
  4194. ItemId: subItem.GoodInfo.ZuobiaoId,
  4195. StartTime: timeFormatOne,
  4196. Content: subItem.GoodInfo.GoodName,
  4197. Bby01: subItem.GoodInfo.Bby01,
  4198. }
  4199. customs = append(customs, cus)
  4200. }
  4201. }
  4202. }
  4203. }
  4204. for _, item := range prescriptions {
  4205. if item.Type == 1 { //药品
  4206. for _, subItem := range item.HisDoctorAdviceInfo {
  4207. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  4208. total_one := price * subItem.PrescribingNumber
  4209. total = total + total_one
  4210. }
  4211. }
  4212. if item.Type == 2 { //项目
  4213. for _, subItem := range item.HisPrescriptionProject {
  4214. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4215. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  4216. total_one := price * cnt
  4217. total = total + total_one
  4218. }
  4219. }
  4220. }
  4221. //allTotal := fmt.Sprintf("%2f", total)
  4222. var info models.UploadInfo
  4223. info.Acf01 = int64(li.Acf01)
  4224. info.Bce01 = "132"
  4225. info.Bck01 = "48"
  4226. info.Vaa07 = int64(li.Vaa07)
  4227. info.Vaa01 = int64(li.Vaa01)
  4228. info.Vaa05 = li.Vaa05
  4229. info.Bce01a = doctor_info.DoctorNumber
  4230. for _, item := range customs {
  4231. var cha models.ChargeListtwo
  4232. cnt, _ := strconv.ParseFloat(item.Cut, 64)
  4233. Bby01, _ := strconv.ParseInt(item.Bby01, 10, 64)
  4234. cha.Bby01 = Bby01
  4235. cha.Vaj25 = cnt
  4236. info.ChargeListtwo = append(info.ChargeListtwo, &cha)
  4237. }
  4238. //汇总逻辑,坐标id相同的汇总成一条医嘱,数量累加
  4239. var big_ps []models.HisPrescription
  4240. drugPrescriptions, consumablePrescriptions := classifyPrescriptions(prescriptions)
  4241. //药品处方需要和非没同组药品的分出同组药品的
  4242. //var noGroupdrugPrescriptions models.HisPrescription
  4243. var groupdrugPrescriptions []models.HisPrescription
  4244. //同组药处方集合
  4245. groupdrugPrescriptions = summarizePrescriptionsTwo(drugPrescriptions)
  4246. //不同组药汇总到一个处方
  4247. //noGroupdrugPrescriptions = summarizePrescriptions(drugPrescriptions)
  4248. //noGroupdrugPrescriptions.HisDoctorAdviceInfo = append(noGroupdrugPrescriptions.HisDoctorAdviceInfo,summarizePrescriptions(drugPrescriptions)...)
  4249. //非没同组药品,汇总处理
  4250. var doc_two []models.HisDoctorAdviceInfo
  4251. var doc []models.HisDoctorAdviceInfo
  4252. doc = summarizePrescriptions(drugPrescriptions)
  4253. var no_group_drug_ps models.HisPrescription
  4254. no_group_drug_ps.MedType = "110"
  4255. no_group_drug_ps.ID = int64(rand.Intn(90000) + 10000)
  4256. no_group_drug_ps.Type = 1
  4257. // 设置随机种子
  4258. for _ ,sumitem := range doc{
  4259. rand.Seed(time.Now().UnixNano())
  4260. // 生成4位随机数
  4261. randomNumber := rand.Intn(9000) + 1000
  4262. sumitem.Groupno = sumitem.Groupno + int64(randomNumber)
  4263. //doc = append(doc, sumitem.HisDoctorAdviceInfo...)
  4264. }
  4265. doc_two = RemoveRepeatedPurviewElementdrug(doc)
  4266. var dos []models.HisDoctorAdviceInfo
  4267. for _, pro := range doc_two {
  4268. var ppp models.HisDoctorAdviceInfo
  4269. var count float64
  4270. var drugWayCount float64
  4271. for _, pro_two := range doc {
  4272. if pro.BaseDrugLib.ZuobiaoId == pro_two.BaseDrugLib.ZuobiaoId && pro.BaseDrugLib.Bby01 == pro_two.BaseDrugLib.Bby01 && pro.DeliveryWay == pro_two.DeliveryWay{
  4273. ppp = pro_two
  4274. count = count + pro_two.PrescribingNumber
  4275. if len(pro_two.DrugWayCount) == 0{
  4276. pro_two.DrugWayCount = "1"
  4277. }
  4278. result, _ := strconv.ParseFloat(pro_two.DrugWayCount, 64)
  4279. drugWayCount = drugWayCount + result
  4280. }
  4281. }
  4282. //fmt.Println(strconv.FormatFloat(drugWayCount, 'f', -1, 64))
  4283. ppp.PrescribingNumber = count
  4284. ppp.DrugWayCount = strconv.FormatFloat(drugWayCount, 'f', -1, 64)
  4285. dos = append(dos, ppp)
  4286. }
  4287. no_group_drug_ps.HisDoctorAdviceInfo = dos
  4288. if len(dos) > 0 {
  4289. big_ps = append(big_ps, no_group_drug_ps)
  4290. }
  4291. jsonString, err := json.Marshal(big_ps)
  4292. if err != nil {
  4293. fmt.Println("转换失败:", err)
  4294. return
  4295. }
  4296. // 输出JSON字符串
  4297. fmt.Println(string(jsonString))
  4298. saveLog("", string(jsonString), "1111333", "122222224444", "")
  4299. //var hds []models.HisDoctorAdviceInfo
  4300. ////同组药品不需要进行汇总
  4301. for _, item := range groupdrugPrescriptions {
  4302. var group_drug_ps models.HisPrescription
  4303. group_drug_ps.MedType = "190"
  4304. group_drug_ps.ID = int64(rand.Intn(90000) + 10000)
  4305. group_drug_ps.Type = 1
  4306. group_drug_ps.HisDoctorAdviceInfo = item.HisDoctorAdviceInfo
  4307. big_ps = append(big_ps, group_drug_ps)
  4308. }
  4309. //jsonString2, err := json.Marshal(big_ps)
  4310. //if err != nil {
  4311. // fmt.Println("转换失败:", err)
  4312. // return
  4313. //}
  4314. // 输出JSON字符串
  4315. //fmt.Println(string(jsonString2))
  4316. //saveLog("", string(jsonString2), "222222", "33334444444", "")
  4317. //return
  4318. //
  4319. //hds = RemoveRepeatedPurviewElementdrugtwo(hds)
  4320. //
  4321. //for _,item := range hds{
  4322. // for _,subitem := range hds{
  4323. // if item.Newfn == subitem.Newfn{
  4324. //
  4325. //
  4326. // }
  4327. // }
  4328. //}
  4329. //if len(item.HisDoctorAdviceInfo) > 0 {
  4330. //
  4331. // var group_drug_ps models.HisPrescription
  4332. // group_drug_ps.MedType = "110"
  4333. // group_drug_ps.ID = int64(rand.Intn(90000) + 10000)
  4334. // group_drug_ps.Type = 1
  4335. // group_drug_ps.HisDoctorAdviceInfo = item.HisDoctorAdviceInfo
  4336. // big_ps = append(big_ps, group_drug_ps)
  4337. //}
  4338. //耗材和项目汇总
  4339. var projects []models.HisPrescriptionProject
  4340. var goods []models.HisPrescriptionProject
  4341. var checks []models.HisPrescriptionProject
  4342. var projects_two []models.HisPrescriptionProject
  4343. var goods_two []models.HisPrescriptionProject
  4344. //var checks_two []models.HisPrescriptionProject
  4345. for _, item := range consumablePrescriptions {
  4346. for _, subitem := range item.HisPrescriptionProject {
  4347. if subitem.Type == 2 {
  4348. if subitem.HisProject.CostClassify == 3{
  4349. checks = append(checks, subitem)
  4350. }else{
  4351. projects = append(projects, subitem)
  4352. }
  4353. } else if subitem.Type == 3 {
  4354. goods = append(goods, subitem)
  4355. }
  4356. }
  4357. }
  4358. projects_two = RemoveRepeatedPurviewElementproject(projects)
  4359. goods_two = RemoveRepeatedPurviewElementgood(goods)
  4360. //checks_two = RemoveRepeatedPurviewElementproject(checks)
  4361. var new_pros []models.HisPrescriptionProject
  4362. var new_goods []models.HisPrescriptionProject
  4363. var new_checks []models.HisPrescriptionProject
  4364. for _, pro := range projects_two {
  4365. var ppp models.HisPrescriptionProject
  4366. var count float64
  4367. for _, pro_two := range projects {
  4368. if pro.HisProject.ZuobiaoId == pro_two.HisProject.ZuobiaoId && pro.HisProject.Bby01 == pro_two.HisProject.Bby01 {
  4369. ppp = pro_two
  4370. result, _ := strconv.ParseFloat(pro_two.Count, 64)
  4371. count = count + result
  4372. }
  4373. }
  4374. ppp.Count = strconv.FormatFloat(count, 'f', -1, 64)
  4375. new_pros = append(new_pros, ppp)
  4376. }
  4377. for _, good := range goods_two {
  4378. var ppp models.HisPrescriptionProject
  4379. var count float64
  4380. for _, good_two := range goods {
  4381. if good.GoodInfo.ZuobiaoId == good_two.GoodInfo.ZuobiaoId && good.GoodInfo.Bby01 == good_two.GoodInfo.Bby01 {
  4382. ppp = good_two
  4383. result, _ := strconv.ParseFloat(good_two.Count, 64)
  4384. count = count + result
  4385. }
  4386. }
  4387. ppp.Count = strconv.FormatFloat(count, 'f', -1, 64)
  4388. new_goods = append(new_goods, ppp)
  4389. }
  4390. for _, check := range checks {
  4391. var ppp models.HisPrescriptionProject
  4392. ppp = check
  4393. ppp.Count = check.Count
  4394. new_checks = append(new_checks, ppp)
  4395. }
  4396. if len(new_goods) > 0 {
  4397. var ps1 models.HisPrescription
  4398. ps1.MedType = "120"
  4399. ps1.ID = int64(rand.Intn(90000) + 10000)
  4400. ps1.Type = 2
  4401. ps1.HisPrescriptionProject = append(ps1.HisPrescriptionProject, new_goods...)
  4402. big_ps = append(big_ps, ps1)
  4403. }
  4404. if len(new_pros) > 0 {
  4405. var ps2 models.HisPrescription
  4406. ps2.MedType = "130"
  4407. ps2.Type = 2
  4408. ps2.ID = int64(rand.Intn(90000) + 10000)
  4409. ps2.HisPrescriptionProject = append(ps2.HisPrescriptionProject, new_pros...)
  4410. big_ps = append(big_ps, ps2)
  4411. }
  4412. if len(new_checks) > 0 {
  4413. var ps3 models.HisPrescription
  4414. ps3.MedType = "140"
  4415. ps3.Type = 2
  4416. ps3.ID = int64(rand.Intn(90000) + 10000)
  4417. ps3.HisPrescriptionProject = append(ps3.HisPrescriptionProject, new_checks...)
  4418. big_ps = append(big_ps, ps3)
  4419. }
  4420. ////信息
  4421. var is_upload_success bool = true
  4422. var curpage int
  4423. var pagesize int = len(big_ps)
  4424. var start int = 1
  4425. var stop int
  4426. var zuobiao_ids string
  4427. var err_msg string
  4428. var idss []int64
  4429. //pagecount := 10
  4430. pagecount := int(math.Ceil(float64(len(big_ps)) / float64(pagesize)))
  4431. for curpage = 1; curpage <= pagecount; curpage++ {
  4432. var root models.Root
  4433. var tradeInfo models.TradeInfo
  4434. var cBM1 models.CBM1
  4435. var vAF1 models.VAF1
  4436. var vAO1 models.VAO1
  4437. var vBQ1 models.VBQ1
  4438. if li.Acf01 == 1 {
  4439. tradeInfo.PatSource = 1
  4440. tradeInfo.Type = 0
  4441. } else {
  4442. tradeInfo.PatSource = 2
  4443. tradeInfo.Type = 1
  4444. }
  4445. tradeInfo.Detpid = departmwnt.Number
  4446. tradeInfo.Empid = doctor_info.DoctorNumber
  4447. tradeInfo.Empno = doctor_info.DoctorCode
  4448. tradeInfo.Empname = doctor_info.UserName
  4449. root.TradeInfo = tradeInfo
  4450. if curpage == 1 {
  4451. start = 1
  4452. } else {
  4453. start = (curpage-1)*pagesize + 1
  4454. }
  4455. stop = curpage * pagesize
  4456. if stop > len(big_ps) {
  4457. stop = len(big_ps)
  4458. }
  4459. //var ids []int64
  4460. //
  4461. //for _, item := range prescriptions[start-1 : stop] {
  4462. // ids = append(ids, item.ID)
  4463. //}
  4464. for _, item := range big_ps[start-1 : stop] {
  4465. //departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  4466. var ie_cbm1 models.IEone
  4467. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4468. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4469. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  4470. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  4471. //ie_cbm1.CBM06 = strconv.FormatInt(int64(res.List[0].Acf01), 10)
  4472. if li.Acf01 == 1 {
  4473. if item.MedType == "110" {
  4474. ie_cbm1.CBM06 = "1"
  4475. }
  4476. if item.MedType == "120"{
  4477. ie_cbm1.CBM06 = "5"
  4478. }
  4479. if item.MedType == "130"{
  4480. ie_cbm1.CBM06 = "0"
  4481. }
  4482. if item.MedType == "140"{
  4483. ie_cbm1.CBM06 = "9"
  4484. }
  4485. if item.MedType == "190"{
  4486. ie_cbm1.CBM06 = "1"
  4487. }
  4488. ie_cbm1.BCK01A = "0"
  4489. } else {
  4490. ie_cbm1.CBM06 = "0"
  4491. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10) //病区id
  4492. }
  4493. if item.MedType == "110" {
  4494. ie_cbm1.CBM07 = "1"
  4495. }
  4496. if item.MedType == "120"{
  4497. ie_cbm1.CBM07 = "5"
  4498. }
  4499. if item.MedType == "130"{
  4500. ie_cbm1.CBM07 = "0"
  4501. }
  4502. if item.MedType == "140"{
  4503. ie_cbm1.CBM07 = "10"
  4504. }
  4505. if item.MedType == "190"{
  4506. ie_cbm1.CBM06 = "1"
  4507. }
  4508. ie_cbm1.BCK01B = strconv.FormatInt(int64(li.Bck01B), 10)
  4509. ie_cbm1.BCK01C = "38"
  4510. ie_cbm1.CBM19 = "0"
  4511. cBM1.Ie = append(cBM1.Ie, ie_cbm1)
  4512. }
  4513. root.CBM1 = cBM1
  4514. ////医嘱
  4515. for _, item := range big_ps[start-1 : stop] {
  4516. //departmwnt_two, _ := service.GetDepartMentDetail(item.VMHisPrescriptionInfo.Departments)
  4517. if item.Type == 1 {
  4518. if item.MedType == "190"{
  4519. //组号去重
  4520. //temphisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  4521. // 使用 map 来存储 groupno 的数量
  4522. //groupCount := make(map[int64]int64)
  4523. // 使用 map 来存储 groupno 的数量和最后一条数据的索引
  4524. groupInfo := make(map[string]struct {
  4525. Count int64
  4526. LastElement int
  4527. })
  4528. // 遍历切片,计算 groupno 的数量和最后一条数据的索引
  4529. for i, obj := range item.HisDoctorAdviceInfo {
  4530. fmt.Println("转换失败1:", strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10))
  4531. info, ok := groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)]
  4532. fmt.Println("转换失败2:",info)
  4533. if !ok {
  4534. info = struct {
  4535. Count int64
  4536. LastElement int
  4537. }{}
  4538. }
  4539. info.Count++
  4540. info.LastElement = i
  4541. groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)] = info
  4542. fmt.Println("转换失败3:",groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)])
  4543. }
  4544. fmt.Println("转换失败4:",groupInfo)
  4545. // 根据 groupno 的数量设置字段值
  4546. for i, obj := range item.HisDoctorAdviceInfo {
  4547. info := groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)]
  4548. if info.Count < 2 {
  4549. fmt.Println("转换失败555:")
  4550. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  4551. //item.HisDoctorAdviceInfo[i].Groupno = int64(rand.Intn(90000) + 10000)
  4552. } else {
  4553. // 对于数量大于等于 2 的,将最后一条数据设置 1,其他设置为随机数
  4554. if i == info.LastElement {
  4555. fmt.Println("转换失败6666:")
  4556. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  4557. //item.HisDoctorAdviceInfo[i].Groupno = int64(rand.Intn(90000) + 10000)
  4558. } else {
  4559. fmt.Println("转换失败777777:")
  4560. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(obj.ID, 10)
  4561. }
  4562. }
  4563. }
  4564. for _, subitem := range item.HisDoctorAdviceInfo {
  4565. fmt.Println("转换失败777777:", subitem.NewGroupno)
  4566. var ie_cbm1 models.IEtwo
  4567. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4568. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4569. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4570. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4571. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4572. ie_cbm1.ROWNR = subitem.NewGroupno
  4573. ie_cbm1.VAF10 = "1"
  4574. ie_cbm1.VAF11 = "2"
  4575. ie_cbm1.BDA01 = "1" //诊疗类型
  4576. ie_cbm1.BBX01 = subitem.BaseDrugLib.ZuobiaoId
  4577. ie_cbm1.VAF14 = "" //检验样本类型
  4578. ie_cbm1.VAF15 = ""
  4579. ie_cbm1.BBY01 = subitem.BaseDrugLib.Bby01 //药品规格id或材料规格id
  4580. if li.Acf01 == 1 {
  4581. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10)
  4582. } else {
  4583. ie_cbm1.VAF17 = "0"
  4584. }
  4585. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  4586. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  4587. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  4588. ie_cbm1.VAF21 = fmt.Sprintf("%.2f", subitem.PrescribingNumber)
  4589. ie_cbm1.VAF22 = subitem.AdviceName + " " + subitem.BaseDrugLib.DrugSpec
  4590. ie_cbm1.Crypt = "0"
  4591. ie_cbm1.VAF23 = ""
  4592. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  4593. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4594. ie_cbm1.VAF27 = "1"
  4595. ie_cbm1.VAF28 = "1"
  4596. ie_cbm1.VAF29 = "1"
  4597. ie_cbm1.VAF30 = ""
  4598. ie_cbm1.VAF31 = "0"
  4599. ie_cbm1.VAF32 = "0" //todo
  4600. ie_cbm1.VAF33 = "0"
  4601. ie_cbm1.VAF34 = "0"
  4602. ie_cbm1.VAF35 = "0"
  4603. tempTime1 := time.Unix(subitem.StartTime, 0)
  4604. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4605. ie_cbm1.VAF36 = timeFormatOne
  4606. ie_cbm1.VAF37 = "1899-12-30"
  4607. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4608. ie_cbm1.BCK01C = "38"
  4609. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4610. ie_cbm1.BCE03A = doctor_info.UserName
  4611. ie_cbm1.BCE03B = ""
  4612. ie_cbm1.VAF53 = "-1"
  4613. ie_cbm1.VAF55 = subitem.Remark
  4614. ie_cbm1.BCK01D = "38"
  4615. ie_cbm1.VAF58 = "0"
  4616. ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno ), 10)
  4617. ie_cbm1.VAF60 = ""
  4618. ie_cbm1.VAF61 = "1"
  4619. ie_cbm1.VAF62 = "0"
  4620. ie_cbm1.LSign = "0"
  4621. ie_cbm1.BDA01A = ie_cbm1.BDA01
  4622. ie_cbm1.LRoute = "0"
  4623. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4624. ie_cbm1.BCE01B = "0"
  4625. ie_cbm1.VAF01B = "0"
  4626. ie_cbm1.VCO01 = "0"
  4627. ie_cbm1.BCE01H = "0"
  4628. ie_cbm1.BCE03H = ""
  4629. ie_cbm1.BIW02 = ""
  4630. ie_cbm1.RCurrent = "0"
  4631. ie_cbm1.FCheck = "0"
  4632. ie_cbm1.UnameA = ""
  4633. ie_cbm1.VEH02 = ""
  4634. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  4635. }
  4636. //hisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  4637. //每种药品下的给药途径
  4638. for _, subitem := range item.HisDoctorAdviceInfo {
  4639. way, _ := service.GetDrugwayDicByName(subitem.DeliveryWay, c.GetAdminUserInfo().CurrentOrgId)
  4640. var ie_cbm1 models.IEtwo
  4641. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4642. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4643. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4644. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4645. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4646. ie_cbm1.ROWNR = "0"
  4647. ie_cbm1.VAF10 = "1"
  4648. ie_cbm1.VAF11 = "2"
  4649. ie_cbm1.BDA01 = "T" //诊疗类型
  4650. ie_cbm1.BBX01 = way.Code
  4651. ie_cbm1.VAF14 = "" //检验样本类型
  4652. ie_cbm1.VAF15 = "" //检验样本类型
  4653. ie_cbm1.BBY01 = way.Bby01 //药品规格id或材料规格id
  4654. if li.Acf01 == 1 {
  4655. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10) //药品规格id或材料规格id
  4656. } else {
  4657. ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
  4658. }
  4659. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  4660. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  4661. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  4662. //ie_cbm1.VAF21 = fmt.Sprintf("%.2f",subitem.PrescribingNumber)
  4663. //ie_cbm1.VAF18 = "" //药品规格id或材料规格id
  4664. //ie_cbm1.VAF19 = ""
  4665. //ie_cbm1.VAF20 = ""
  4666. if subitem.DrugWayCount == "" {
  4667. ie_cbm1.VAF21 = "1"
  4668. } else {
  4669. ie_cbm1.VAF21 = subitem.DrugWayCount
  4670. }
  4671. ie_cbm1.VAF22 = way.Name
  4672. ie_cbm1.Crypt = "0"
  4673. ie_cbm1.VAF23 = ""
  4674. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  4675. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4676. ie_cbm1.VAF27 = "1"
  4677. ie_cbm1.VAF28 = "1"
  4678. ie_cbm1.VAF29 = "1"
  4679. ie_cbm1.BCK01C = "38"
  4680. ie_cbm1.VAF30 = ""
  4681. ie_cbm1.VAF31 = "0"
  4682. ie_cbm1.VAF32 = "1" //todo
  4683. ie_cbm1.VAF33 = "0"
  4684. ie_cbm1.VAF34 = "0"
  4685. ie_cbm1.VAF35 = "0"
  4686. tempTime1 := time.Unix(subitem.StartTime, 0)
  4687. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4688. ie_cbm1.VAF36 = timeFormatOne
  4689. ie_cbm1.VAF37 = "1899-12-30"
  4690. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4691. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4692. ie_cbm1.BCE03A = doctor_info.UserName
  4693. ie_cbm1.BCE03B = ""
  4694. ie_cbm1.VAF53 = "-1"
  4695. ie_cbm1.VAF55 = subitem.Remark
  4696. ie_cbm1.BCK01D = "38"
  4697. ie_cbm1.VAF58 = "0"
  4698. ie_cbm1.VAF59 =strconv.FormatInt(int64(subitem.Groupno ), 10)
  4699. ie_cbm1.VAF60 = ""
  4700. ie_cbm1.VAF61 = "1"
  4701. ie_cbm1.VAF62 = "0"
  4702. ie_cbm1.LSign = "0"
  4703. ie_cbm1.BDA01A = ie_cbm1.BDA01
  4704. ie_cbm1.LRoute = "0"
  4705. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4706. ie_cbm1.BCE01B = "0"
  4707. ie_cbm1.VAF01B = "0"
  4708. ie_cbm1.VCO01 = "0"
  4709. ie_cbm1.BCE01H = "0"
  4710. ie_cbm1.BCE03H = ""
  4711. ie_cbm1.BIW02 = ""
  4712. ie_cbm1.RCurrent = "0"
  4713. ie_cbm1.FCheck = "0"
  4714. ie_cbm1.UnameA = ""
  4715. ie_cbm1.VEH02 = ""
  4716. ie_cbm1.VAF07 = "0"
  4717. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  4718. }
  4719. }else{
  4720. //组号去重
  4721. //temphisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  4722. // 使用 map 来存储 groupno 的数量
  4723. //groupCount := make(map[int64]int64)
  4724. // 使用 map 来存储 groupno 的数量和最后一条数据的索引
  4725. groupInfo := make(map[string]struct {
  4726. Count int64
  4727. LastElement int
  4728. })
  4729. // 遍历切片,计算 groupno 的数量和最后一条数据的索引
  4730. for i, obj := range item.HisDoctorAdviceInfo {
  4731. fmt.Println("转换失败1:", strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10))
  4732. info, ok := groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)]
  4733. fmt.Println("转换失败2:",info)
  4734. if !ok {
  4735. info = struct {
  4736. Count int64
  4737. LastElement int
  4738. }{}
  4739. }
  4740. info.Count++
  4741. info.LastElement = i
  4742. groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)] = info
  4743. fmt.Println("转换失败3:",groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)])
  4744. }
  4745. fmt.Println("转换失败4:",groupInfo)
  4746. // 根据 groupno 的数量设置字段值
  4747. for i, obj := range item.HisDoctorAdviceInfo {
  4748. info := groupInfo[strconv.FormatInt(int64(obj.Groupno), 10) +"-"+strconv.FormatInt(int64(obj.PrescriptionId), 10)]
  4749. if info.Count < 2 {
  4750. fmt.Println("转换失败555:")
  4751. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  4752. item.HisDoctorAdviceInfo[i].Groupno = int64(rand.Intn(90000) + 10000)
  4753. } else {
  4754. // 对于数量大于等于 2 的,将最后一条数据设置 1,其他设置为随机数
  4755. if i == info.LastElement {
  4756. fmt.Println("转换失败6666:")
  4757. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(int64(1), 10)
  4758. item.HisDoctorAdviceInfo[i].Groupno = int64(rand.Intn(90000) + 10000)
  4759. } else {
  4760. fmt.Println("转换失败777777:")
  4761. item.HisDoctorAdviceInfo[i].NewGroupno = strconv.FormatInt(obj.ID, 10)
  4762. }
  4763. }
  4764. }
  4765. for _, subitem := range item.HisDoctorAdviceInfo {
  4766. fmt.Println("转换失败777777:", subitem.NewGroupno)
  4767. var ie_cbm1 models.IEtwo
  4768. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4769. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4770. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4771. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4772. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4773. ie_cbm1.ROWNR = subitem.NewGroupno
  4774. ie_cbm1.VAF10 = "1"
  4775. ie_cbm1.VAF11 = "2"
  4776. ie_cbm1.BDA01 = "1" //诊疗类型
  4777. ie_cbm1.BBX01 = subitem.BaseDrugLib.ZuobiaoId
  4778. ie_cbm1.VAF14 = "" //检验样本类型
  4779. ie_cbm1.VAF15 = ""
  4780. ie_cbm1.BBY01 = subitem.BaseDrugLib.Bby01 //药品规格id或材料规格id
  4781. if li.Acf01 == 1 {
  4782. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10)
  4783. } else {
  4784. ie_cbm1.VAF17 = "0"
  4785. }
  4786. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  4787. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  4788. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  4789. ie_cbm1.VAF21 = fmt.Sprintf("%.2f", subitem.PrescribingNumber)
  4790. ie_cbm1.VAF22 = subitem.AdviceName + " " + subitem.BaseDrugLib.DrugSpec
  4791. ie_cbm1.Crypt = "0"
  4792. ie_cbm1.VAF23 = ""
  4793. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  4794. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4795. ie_cbm1.VAF27 = "1"
  4796. ie_cbm1.VAF28 = "1"
  4797. ie_cbm1.VAF29 = "1"
  4798. ie_cbm1.VAF30 = ""
  4799. ie_cbm1.VAF31 = "0"
  4800. ie_cbm1.VAF32 = "0" //todo
  4801. ie_cbm1.VAF33 = "0"
  4802. ie_cbm1.VAF34 = "0"
  4803. ie_cbm1.VAF35 = "0"
  4804. tempTime1 := time.Unix(subitem.StartTime, 0)
  4805. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4806. ie_cbm1.VAF36 = timeFormatOne
  4807. ie_cbm1.VAF37 = "1899-12-30"
  4808. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4809. ie_cbm1.BCK01C = "38"
  4810. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4811. ie_cbm1.BCE03A = doctor_info.UserName
  4812. ie_cbm1.BCE03B = ""
  4813. ie_cbm1.VAF53 = "-1"
  4814. ie_cbm1.VAF55 = subitem.Remark
  4815. ie_cbm1.BCK01D = "38"
  4816. ie_cbm1.VAF58 = "0"
  4817. ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno ), 10)
  4818. ie_cbm1.VAF60 = ""
  4819. ie_cbm1.VAF61 = "1"
  4820. ie_cbm1.VAF62 = "0"
  4821. ie_cbm1.LSign = "0"
  4822. ie_cbm1.BDA01A = ie_cbm1.BDA01
  4823. ie_cbm1.LRoute = "0"
  4824. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4825. ie_cbm1.BCE01B = "0"
  4826. ie_cbm1.VAF01B = "0"
  4827. ie_cbm1.VCO01 = "0"
  4828. ie_cbm1.BCE01H = "0"
  4829. ie_cbm1.BCE03H = ""
  4830. ie_cbm1.BIW02 = ""
  4831. ie_cbm1.RCurrent = "0"
  4832. ie_cbm1.FCheck = "0"
  4833. ie_cbm1.UnameA = ""
  4834. ie_cbm1.VEH02 = ""
  4835. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  4836. }
  4837. //hisDoctorAdviceInfo := RemoveRepeatedPurviewElementdoctoradvice(item.HisDoctorAdviceInfo)
  4838. //每种药品下的给药途径
  4839. for _, subitem := range item.HisDoctorAdviceInfo {
  4840. way, _ := service.GetDrugwayDicByName(subitem.DeliveryWay, c.GetAdminUserInfo().CurrentOrgId)
  4841. var ie_cbm1 models.IEtwo
  4842. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4843. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4844. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4845. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4846. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4847. ie_cbm1.ROWNR = "0"
  4848. ie_cbm1.VAF10 = "1"
  4849. ie_cbm1.VAF11 = "2"
  4850. ie_cbm1.BDA01 = "T" //诊疗类型
  4851. ie_cbm1.BBX01 = way.Code
  4852. ie_cbm1.VAF14 = "" //检验样本类型
  4853. ie_cbm1.VAF15 = "" //检验样本类型
  4854. ie_cbm1.BBY01 = way.Bby01 //药品规格id或材料规格id
  4855. if li.Acf01 == 1 {
  4856. ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10) //药品规格id或材料规格id
  4857. } else {
  4858. ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
  4859. }
  4860. ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
  4861. ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
  4862. ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
  4863. //ie_cbm1.VAF21 = fmt.Sprintf("%.2f",subitem.PrescribingNumber)
  4864. //ie_cbm1.VAF18 = "" //药品规格id或材料规格id
  4865. //ie_cbm1.VAF19 = ""
  4866. //ie_cbm1.VAF20 = ""
  4867. if subitem.DrugWayCount == "" {
  4868. ie_cbm1.VAF21 = "1"
  4869. } else {
  4870. ie_cbm1.VAF21 = subitem.DrugWayCount
  4871. }
  4872. ie_cbm1.VAF22 = way.Name
  4873. ie_cbm1.Crypt = "0"
  4874. ie_cbm1.VAF23 = ""
  4875. ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
  4876. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4877. ie_cbm1.VAF27 = "1"
  4878. ie_cbm1.VAF28 = "1"
  4879. ie_cbm1.VAF29 = "1"
  4880. ie_cbm1.BCK01C = "38"
  4881. ie_cbm1.VAF30 = ""
  4882. ie_cbm1.VAF31 = "0"
  4883. ie_cbm1.VAF32 = "1" //todo
  4884. ie_cbm1.VAF33 = "0"
  4885. ie_cbm1.VAF34 = "0"
  4886. ie_cbm1.VAF35 = "0"
  4887. tempTime1 := time.Unix(subitem.StartTime, 0)
  4888. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4889. ie_cbm1.VAF36 = timeFormatOne
  4890. ie_cbm1.VAF37 = "1899-12-30"
  4891. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4892. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4893. ie_cbm1.BCE03A = doctor_info.UserName
  4894. ie_cbm1.BCE03B = ""
  4895. ie_cbm1.VAF53 = "-1"
  4896. ie_cbm1.VAF55 = subitem.Remark
  4897. ie_cbm1.BCK01D = "38"
  4898. ie_cbm1.VAF58 = "0"
  4899. ie_cbm1.VAF59 =strconv.FormatInt(int64(subitem.Groupno ), 10)
  4900. ie_cbm1.VAF60 = ""
  4901. ie_cbm1.VAF61 = "1"
  4902. ie_cbm1.VAF62 = "0"
  4903. ie_cbm1.LSign = "0"
  4904. ie_cbm1.BDA01A = ie_cbm1.BDA01
  4905. ie_cbm1.LRoute = "0"
  4906. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4907. ie_cbm1.BCE01B = "0"
  4908. ie_cbm1.VAF01B = "0"
  4909. ie_cbm1.VCO01 = "0"
  4910. ie_cbm1.BCE01H = "0"
  4911. ie_cbm1.BCE03H = ""
  4912. ie_cbm1.BIW02 = ""
  4913. ie_cbm1.RCurrent = "0"
  4914. ie_cbm1.FCheck = "0"
  4915. ie_cbm1.UnameA = ""
  4916. ie_cbm1.VEH02 = ""
  4917. ie_cbm1.VAF07 = "0"
  4918. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  4919. }
  4920. }
  4921. } else if item.Type == 2 {
  4922. for index, subitem := range item.HisPrescriptionProject {
  4923. if subitem.Type == 2 {
  4924. if subitem.HisProject.CostClassify != 3 {
  4925. var ie_cbm1 models.IEtwo
  4926. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  4927. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  4928. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  4929. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  4930. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  4931. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  4932. ie_cbm1.VAF10 = "1"
  4933. ie_cbm1.VAF11 = "2"
  4934. ie_cbm1.BDA01 = "T" //诊疗类型
  4935. ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  4936. ie_cbm1.VAF14 = "" //检验样本类型
  4937. ie_cbm1.VAF15 = "" //检验样本类型
  4938. ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  4939. if li.Acf01 == 1 {
  4940. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  4941. if len(subitem.Day) == 0 {
  4942. ie_cbm1.VAF17 = "1"
  4943. }
  4944. } else {
  4945. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  4946. }
  4947. if subitem.SingleDose == "" {
  4948. subitem.SingleDose = "1"
  4949. }
  4950. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  4951. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  4952. ie_cbm1.VAF20 = subitem.SingleDose
  4953. ie_cbm1.VAF21 = subitem.Count
  4954. ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  4955. ie_cbm1.Crypt = "0"
  4956. ie_cbm1.VAF23 = ""
  4957. ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  4958. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  4959. ie_cbm1.VAF27 = "1"
  4960. ie_cbm1.VAF28 = "1"
  4961. ie_cbm1.VAF29 = ""
  4962. ie_cbm1.BCK01C = "38"
  4963. ie_cbm1.VAF30 = ""
  4964. ie_cbm1.VAF31 = "0"
  4965. ie_cbm1.VAF32 = "0" //todo
  4966. ie_cbm1.VAF33 = "0"
  4967. ie_cbm1.VAF34 = "0"
  4968. ie_cbm1.VAF35 = "0"
  4969. tempTime1 := time.Unix(subitem.StartTime, 0)
  4970. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  4971. ie_cbm1.VAF36 = timeFormatOne
  4972. ie_cbm1.VAF37 = "1899-12-30"
  4973. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  4974. ie_cbm1.BCE02A = doctor_info.DoctorCode
  4975. ie_cbm1.BCE03A = doctor_info.UserName
  4976. ie_cbm1.BCE03B = ""
  4977. ie_cbm1.VAF53 = "-1"
  4978. ie_cbm1.VAF55 = subitem.Remark
  4979. ie_cbm1.BCK01D = "38"
  4980. ie_cbm1.VAF58 = "0"
  4981. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  4982. ie_cbm1.VAF60 = ""
  4983. ie_cbm1.VAF61 = "1"
  4984. ie_cbm1.VAF62 = "0"
  4985. ie_cbm1.LSign = "0"
  4986. ie_cbm1.BDA01A = "" //诊疗类型
  4987. ie_cbm1.LRoute = "0"
  4988. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  4989. //ie_cbm1.BCE01A = doctor_info.UserName
  4990. ie_cbm1.BCE01B = "0"
  4991. ie_cbm1.VAF01B = "0"
  4992. ie_cbm1.VCO01 = "0"
  4993. ie_cbm1.BCE01H = "0"
  4994. ie_cbm1.BCE03H = ""
  4995. ie_cbm1.BIW02 = ""
  4996. ie_cbm1.RCurrent = "0"
  4997. ie_cbm1.FCheck = "0"
  4998. ie_cbm1.UnameA = ""
  4999. ie_cbm1.VAF07 = "0"
  5000. ie_cbm1.VEH02 = ""
  5001. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  5002. }
  5003. if subitem.HisProject.CostClassify == 3 {
  5004. var ie_cbm1 models.IEtwo
  5005. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  5006. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  5007. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5008. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  5009. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  5010. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  5011. ie_cbm1.VAF10 = "1"
  5012. ie_cbm1.VAF11 = "2"
  5013. ie_cbm1.BDA01 = "L" //诊疗类型
  5014. ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
  5015. ie_cbm1.VAF14 = subitem.HisProject.Vaf14 //检验样本类型
  5016. ie_cbm1.VAF15 = "" //检验样本类型
  5017. ie_cbm1.BBY01 = subitem.HisProject.Bby01 //药品规格id或材料规格id
  5018. if li.Acf01 == 1 {
  5019. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  5020. } else {
  5021. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  5022. }
  5023. if subitem.SingleDose == "" {
  5024. subitem.SingleDose = "1"
  5025. }
  5026. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  5027. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  5028. ie_cbm1.VAF20 = subitem.SingleDose
  5029. ie_cbm1.VAF21 = subitem.Count
  5030. ie_cbm1.VAF22 = subitem.HisProject.ProjectName
  5031. ie_cbm1.Crypt = "0"
  5032. ie_cbm1.VAF23 = ""
  5033. ie_cbm1.BCK01B = subitem.HisProject.Bck01b
  5034. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  5035. ie_cbm1.VAF27 = "1"
  5036. ie_cbm1.VAF28 = "1"
  5037. ie_cbm1.VAF29 = ""
  5038. ie_cbm1.BCK01C = "38"
  5039. ie_cbm1.VAF30 = ""
  5040. ie_cbm1.VAF31 = "0"
  5041. ie_cbm1.VAF32 = "0" //todo
  5042. ie_cbm1.VAF33 = "0"
  5043. ie_cbm1.VAF34 = "0"
  5044. ie_cbm1.VAF35 = "0"
  5045. tempTime1 := time.Unix(subitem.StartTime, 0)
  5046. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  5047. ie_cbm1.VAF36 = timeFormatOne
  5048. ie_cbm1.VAF37 = "1899-12-30"
  5049. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  5050. ie_cbm1.BCE02A = doctor_info.DoctorCode
  5051. ie_cbm1.BCE03A = doctor_info.UserName
  5052. ie_cbm1.BCE03B = ""
  5053. ie_cbm1.VAF53 = "-1"
  5054. ie_cbm1.VAF55 = subitem.Remark
  5055. ie_cbm1.BCK01D = "38"
  5056. ie_cbm1.VAF58 = "0"
  5057. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  5058. ie_cbm1.VAF60 = ""
  5059. ie_cbm1.VAF61 = "1"
  5060. ie_cbm1.VAF62 = "0"
  5061. ie_cbm1.LSign = "0"
  5062. ie_cbm1.BDA01A = "" //诊疗类型
  5063. ie_cbm1.LRoute = "0"
  5064. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  5065. ie_cbm1.VAF07 = "0"
  5066. //ie_cbm1.BCE01A = doctor_info.UserName
  5067. ie_cbm1.BCE01B = "0"
  5068. ie_cbm1.VAF01B = "0"
  5069. ie_cbm1.VCO01 = "0"
  5070. ie_cbm1.BCE01H = "0"
  5071. ie_cbm1.BCE03H = ""
  5072. ie_cbm1.BIW02 = ""
  5073. ie_cbm1.RCurrent = "0"
  5074. ie_cbm1.FCheck = "0"
  5075. ie_cbm1.UnameA = ""
  5076. ie_cbm1.VEH02 = ""
  5077. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  5078. }
  5079. } else if subitem.Type == 3 {
  5080. var ie_cbm1 models.IEtwo
  5081. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  5082. ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
  5083. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5084. ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
  5085. ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01B), 10)
  5086. ie_cbm1.ROWNR = strconv.FormatInt(int64(index+1), 10)
  5087. ie_cbm1.VAF10 = "1"
  5088. ie_cbm1.VAF11 = "2"
  5089. ie_cbm1.BDA01 = "4" //诊疗类型
  5090. ie_cbm1.BBX01 = subitem.GoodInfo.ZuobiaoId
  5091. ie_cbm1.VAF14 = "" //检验样本类型
  5092. ie_cbm1.VAF15 = "" //检验样本类型
  5093. ie_cbm1.BBY01 = subitem.GoodInfo.Bby01 //药品规格id或材料规格id
  5094. if li.Acf01 == 1 {
  5095. ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
  5096. if len(subitem.Day) == 0 {
  5097. ie_cbm1.VAF17 = "1"
  5098. }
  5099. } else {
  5100. ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
  5101. }
  5102. if subitem.SingleDose == "" {
  5103. subitem.SingleDose = "1"
  5104. }
  5105. ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
  5106. ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
  5107. ie_cbm1.VAF20 = subitem.SingleDose
  5108. ie_cbm1.VAF21 = subitem.Count
  5109. ie_cbm1.BCK01C = "38"
  5110. ie_cbm1.VAF22 = subitem.GoodInfo.GoodName + " " + subitem.GoodInfo.SpecificationName
  5111. ie_cbm1.Crypt = "0"
  5112. ie_cbm1.VAF23 = ""
  5113. ie_cbm1.BCK01B = subitem.GoodInfo.Bck01b
  5114. ie_cbm1.VAF26 = subitem.ExecutionFrequency
  5115. ie_cbm1.VAF27 = "1"
  5116. ie_cbm1.VAF28 = "1"
  5117. ie_cbm1.VAF29 = ""
  5118. ie_cbm1.VAF07 = "0"
  5119. ie_cbm1.VAF30 = ""
  5120. ie_cbm1.VAF31 = "0"
  5121. ie_cbm1.VAF32 = "0" //todo
  5122. ie_cbm1.VAF33 = "0"
  5123. ie_cbm1.VAF34 = "0"
  5124. ie_cbm1.VAF35 = "0"
  5125. tempTime1 := time.Unix(subitem.StartTime, 0)
  5126. timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
  5127. ie_cbm1.VAF36 = timeFormatOne
  5128. ie_cbm1.VAF37 = "1899-12-30"
  5129. doctor_info, _ := service.GetAdminUserInfoByID(org_id, 4270)
  5130. ie_cbm1.BCE02A = doctor_info.DoctorCode
  5131. ie_cbm1.BCE03A = doctor_info.UserName
  5132. ie_cbm1.BCE03B = ""
  5133. ie_cbm1.BCK01C = "38"
  5134. ie_cbm1.VAF53 = "-1"
  5135. ie_cbm1.VAF55 = subitem.Remark
  5136. ie_cbm1.BCK01D ="38"
  5137. ie_cbm1.VAF58 = "0"
  5138. ie_cbm1.VAF59 = strconv.FormatInt(int64(index+1), 10)
  5139. ie_cbm1.VAF60 = ""
  5140. ie_cbm1.VAF61 = "1"
  5141. ie_cbm1.VAF62 = "0"
  5142. ie_cbm1.LSign = "0"
  5143. ie_cbm1.BDA01A = "" //诊疗类型
  5144. ie_cbm1.LRoute = "0"
  5145. ie_cbm1.BCE01A = doctor_info.DoctorNumber
  5146. ie_cbm1.BCE01B = "0"
  5147. ie_cbm1.VAF01B = "0"
  5148. ie_cbm1.VCO01 = "0"
  5149. ie_cbm1.BCE01H = "0"
  5150. ie_cbm1.BCE03H = ""
  5151. ie_cbm1.BIW02 = ""
  5152. ie_cbm1.RCurrent = "0"
  5153. ie_cbm1.FCheck = "0"
  5154. ie_cbm1.UnameA = ""
  5155. ie_cbm1.VEH02 = ""
  5156. vAF1.Ie = append(vAF1.Ie, ie_cbm1)
  5157. }
  5158. }
  5159. }
  5160. }
  5161. root.VAF1 = vAF1
  5162. for index, item := range big_ps[start-1 : stop] {
  5163. sick, _ := service.FindSickById(sick_type)
  5164. item.VMHisPrescriptionInfo.Diagnosis = "716"
  5165. dias := strings.Split(item.VMHisPrescriptionInfo.Diagnosis, ",")
  5166. //service.get
  5167. //诊断
  5168. for _, subitem := range dias {
  5169. diagnosisConfig, _ := service.FindDiagnoseByIdtwo(subitem)
  5170. if index == 0 {
  5171. var ie_cbm1 models.IEthree
  5172. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  5173. //ie_cbm1.CBMID = strconv.FormatInt(int64(index+1), 10)
  5174. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5175. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5176. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  5177. ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  5178. ie_cbm1.VAO07 = "1"
  5179. ie_cbm1.VAO10 = "0"
  5180. ie_cbm1.VAO11 = "1"
  5181. ie_cbm1.BAK01A = sick.ContentCode
  5182. ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  5183. ie_cbm1.VAO15 = diagnosisConfig.ClassName
  5184. ie_cbm1.VAO18 = "0"
  5185. ie_cbm1.VAO22 = "1"
  5186. ie_cbm1.IAA01 = ""
  5187. ie_cbm1.IAD03 = ""
  5188. ie_cbm1.BAK01B = ""
  5189. ie_cbm1.VAO26 = ""
  5190. ie_cbm1.IAD04 = ""
  5191. ie_cbm1.IAD01 = ""
  5192. ie_cbm1.VAO25 = "1"
  5193. ie_cbm1.VAO35 = ""
  5194. vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  5195. } else {
  5196. var ie_cbm1 models.IEthree
  5197. ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
  5198. ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5199. ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5200. ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  5201. ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
  5202. ie_cbm1.VAO07 = "1"
  5203. ie_cbm1.VAO10 = "0"
  5204. ie_cbm1.VAO11 = "1"
  5205. ie_cbm1.BAK01A = sick.ContentCode
  5206. ie_cbm1.CAM01 = diagnosisConfig.ContentCode
  5207. ie_cbm1.VAO15 = diagnosisConfig.ClassName
  5208. ie_cbm1.VAO18 = "0"
  5209. ie_cbm1.VAO22 = "1"
  5210. ie_cbm1.IAA01 = ""
  5211. ie_cbm1.IAD03 = ""
  5212. ie_cbm1.BAK01B = ""
  5213. ie_cbm1.VAO26 = ""
  5214. ie_cbm1.IAD04 = ""
  5215. ie_cbm1.IAD01 = ""
  5216. ie_cbm1.VAO25 = "2"
  5217. ie_cbm1.VAO35 = ""
  5218. vAO1.Ie = append(vAO1.Ie, ie_cbm1)
  5219. }
  5220. }
  5221. }
  5222. ////
  5223. //////检验检查医嘱
  5224. //for _, item := range prescriptions{
  5225. // fmt.Println("6666666666666")
  5226. // if item.Type == 2{
  5227. // for _, subitem := range item.HisPrescriptionProject {
  5228. // if subitem.Type == 2{
  5229. // if subitem.HisProject.CostClassify == 3 {
  5230. // var ie_cbm1 models.IEfour
  5231. // ie_cbm1.VBQ01 = strconv.FormatInt(int64(item.ID), 10)
  5232. // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5233. // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5234. // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
  5235. // ie_cbm1.VAP01 = "0"
  5236. // ie_cbm1.VBQ07 = "0"
  5237. // ie_cbm1.BCK01A = departmwnt.Number
  5238. // ie_cbm1.BCK01B= "0"
  5239. // ie_cbm1.BCE03A= ""
  5240. // ie_cbm1.BCE01A= "0"
  5241. // ie_cbm1.VBQ27= subitem.HisProject.ProjectName
  5242. // ie_cbm1.VBQ28= patientPrescription.Diagnosis
  5243. // ie_cbm1.VBQ29= ""
  5244. // ie_cbm1.VBQ30= ""
  5245. // vBQ1.Ie = append(vBQ1.Ie, ie_cbm1)
  5246. // }
  5247. //
  5248. // }
  5249. //
  5250. // }
  5251. // }
  5252. //}
  5253. root.VAO1 = vAO1
  5254. root.VBQ1 = vBQ1
  5255. xmlStr2, err := xml.MarshalIndent(root, "", " ")
  5256. if err != nil {
  5257. fmt.Println("转换为XML时发生错误:", err)
  5258. return
  5259. }
  5260. data := make(map[string]interface{})
  5261. data["xmlStr"] = string(xmlStr2)
  5262. bytesData, _ := json.Marshal(data)
  5263. var req *http.Request
  5264. client := &http.Client{}
  5265. fmt.Println(string(xmlStr2))
  5266. saveLog("", string(xmlStr2), "1111", "上传明细xml", "")
  5267. req, _ = http.NewRequest("POST", "http://127.0.0.1:9532/"+"nmg/coordinate/upload", bytes.NewBufferString(string(bytesData)))
  5268. resp, _ := client.Do(req)
  5269. defer resp.Body.Close()
  5270. body, ioErr := ioutil.ReadAll(resp.Body)
  5271. if ioErr != nil {
  5272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5274. return
  5275. }
  5276. var respJSON map[string]interface{}
  5277. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5280. return
  5281. }
  5282. respJSON3 := respJSON["data"].(map[string]interface{})["msg"].(string)
  5283. respJSON4 := respJSON["data"].(map[string]interface{})["res"].(string)
  5284. if respJSON3 == "成功" {
  5285. //if li.Acf01 != 1{
  5286. // //记账
  5287. // result2, request2 := service.NMGSettleForCoordinate(info)
  5288. // saveLog(result2, request2, "记账", "记账", org.OrgName)
  5289. //
  5290. //
  5291. // //data := make(map[string]interface{})
  5292. // //data["info"] = &info
  5293. // //
  5294. // //fmt.Println(data)
  5295. // //
  5296. // //bytesData, _ := json.Marshal(data)
  5297. // //var req *http.Request
  5298. // //
  5299. // //client := &http.Client{}
  5300. // //
  5301. // //req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/settle", bytes.NewReader(bytesData))
  5302. // //resp, _ := client.Do(req)
  5303. // //defer resp.Body.Close()
  5304. // //body, ioErr := ioutil.ReadAll(resp.Body)
  5305. // //if ioErr != nil {
  5306. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5307. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5308. // // return
  5309. // //}
  5310. // //var respJSON map[string]interface{}
  5311. // //if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5312. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5313. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5314. // // return
  5315. // //}
  5316. // //
  5317. // //respJSON = respJSON["data"].(map[string]interface{})["res"].(map[string]interface{})
  5318. // //userJSONBytes, _ := json.Marshal(respJSON)
  5319. // //
  5320. // //var res2 ResultUpload2
  5321. // //if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5322. // // utils.ErrorLog("解析失败:%v", err)
  5323. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5324. // // return
  5325. // //}
  5326. // //if res2.Code == 500{
  5327. // // c.ServeSuccessJSON(map[string]interface{}{
  5328. // // "failed_code": -10,
  5329. // // "msg": res2.Msg,
  5330. // // })
  5331. // // return
  5332. // //}
  5333. //}
  5334. if len(zuobiao_ids) == 0 {
  5335. zuobiao_ids = respJSON4
  5336. } else {
  5337. zuobiao_ids = zuobiao_ids + "," + respJSON4
  5338. }
  5339. continue
  5340. } else {
  5341. err_msg = respJSON3
  5342. is_upload_success = false
  5343. if len(zuobiao_ids) > 0 {
  5344. tm := time.Unix(time.Now().Unix(), 0)
  5345. order := &models.HisOrder{
  5346. PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  5347. UserOrgId: org_id,
  5348. PatientId: patient_id,
  5349. SettleAccountsDate: recordDateTime,
  5350. Ctime: time.Now().Unix(),
  5351. Mtime: time.Now().Unix(),
  5352. Status: 1,
  5353. OrderStatus: 1,
  5354. MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  5355. Number: zuobiao_ids,
  5356. SetlId: zuobiao_ids,
  5357. MedfeeSumamt: total,
  5358. MedType: strconv.Itoa(int(reg_type)),
  5359. SettleType: settle_accounts_type,
  5360. Diagnosis: diagnosis_id,
  5361. PType: int64(li.Acf01),
  5362. SetlTime: tm.Format("2006-01-02 15:04:05"),
  5363. SettleStartTime: recordStartTime,
  5364. SettleEndTime: recordEndTime,
  5365. }
  5366. err = service.CreateOrder(order)
  5367. if err != nil {
  5368. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  5369. return
  5370. }
  5371. fmt.Println(idss)
  5372. if settle_accounts_type == 1{
  5373. err = service.UpDatePrescriptionNumber222(org_id, p_id, zuobiao_ids,patient_id)
  5374. }else{
  5375. err = service.UpDatePrescriptionNumber111(org_id, recordStartTime,recordEndTime, zuobiao_ids,patient_id)
  5376. }
  5377. //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  5378. err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  5379. var zuobiao_advice models.HisZuobiaoAdvice
  5380. zuobiao_advice.Status = 1
  5381. zuobiao_advice.RecordDate = recordDateTime
  5382. zuobiao_advice.PatientId = patient_id
  5383. zuobiao_advice.Cbm01 = zuobiao_ids
  5384. zuobiao_advice.Ctime = time.Now().Unix()
  5385. zuobiao_advice.Mtime = time.Now().Unix()
  5386. zuobiao_advice.Oid = order.ID
  5387. zuobiao_advice.StartTime = recordStartTime
  5388. zuobiao_advice.EndTime = recordEndTime
  5389. zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5390. zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5391. zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  5392. service.Createzuobiao(&zuobiao_advice)
  5393. }
  5394. }
  5395. if is_upload_success == false {
  5396. if len(zuobiao_ids) > 0 {
  5397. c.ServeSuccessJSON(map[string]interface{}{
  5398. "failed_code": -10,
  5399. "msg": "部分处方数据上传成功,可在已上传或者在坐标系统查看。其余上传失败原因: " + err_msg,
  5400. })
  5401. return
  5402. } else {
  5403. c.ServeSuccessJSON(map[string]interface{}{
  5404. "failed_code": -10,
  5405. "msg": err_msg,
  5406. })
  5407. return
  5408. }
  5409. }
  5410. }
  5411. if is_upload_success {
  5412. if len(zuobiao_ids) > 0 {
  5413. tm := time.Unix(time.Now().Unix(), 0)
  5414. order := &models.HisOrder{
  5415. PsnNo: strconv.FormatInt(int64(li.Vaa01), 10),
  5416. UserOrgId: org_id,
  5417. PatientId: patient_id,
  5418. SettleAccountsDate: recordDateTime,
  5419. Ctime: time.Now().Unix(),
  5420. Mtime: time.Now().Unix(),
  5421. Status: 1,
  5422. OrderStatus: 1,
  5423. MdtrtId: strconv.FormatInt(int64(li.Vaa07), 10),
  5424. Number: zuobiao_ids,
  5425. SetlId: zuobiao_ids,
  5426. MedfeeSumamt: total,
  5427. MedType: strconv.Itoa(int(reg_type)),
  5428. SettleType: settle_accounts_type,
  5429. Diagnosis: diagnosis_id,
  5430. PType: int64(li.Acf01),
  5431. SetlTime: tm.Format("2006-01-02 15:04:05"),
  5432. SettleStartTime: recordStartTime,
  5433. SettleEndTime: recordEndTime,
  5434. }
  5435. err = service.CreateOrder(order)
  5436. if err != nil {
  5437. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  5438. return
  5439. }
  5440. err = service.UpDatePrescriptionNumber111(org_id, recordStartTime,recordEndTime, zuobiao_ids,patient_id)
  5441. //err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(li.Vaa07), 10), recordDateTime, his.ID)
  5442. err = service.UpdataOrderStatusThreef(zuobiao_ids, org_id)
  5443. var zuobiao_advice models.HisZuobiaoAdvice
  5444. zuobiao_advice.Status = 1
  5445. zuobiao_advice.RecordDate = recordDateTime
  5446. zuobiao_advice.PatientId = patient_id
  5447. zuobiao_advice.Cbm01 = zuobiao_ids
  5448. zuobiao_advice.Ctime = time.Now().Unix()
  5449. zuobiao_advice.Mtime = time.Now().Unix()
  5450. zuobiao_advice.Oid = order.ID
  5451. zuobiao_advice.StartTime = recordStartTime
  5452. zuobiao_advice.EndTime = recordEndTime
  5453. zuobiao_advice.Vaa01 = strconv.FormatInt(int64(li.Vaa01), 10)
  5454. zuobiao_advice.Vaa07 = strconv.FormatInt(int64(li.Vaa07), 10)
  5455. zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  5456. service.Createzuobiao(&zuobiao_advice)
  5457. }
  5458. c.ServeSuccessJSON(map[string]interface{}{
  5459. "msg": "上传成功",
  5460. })
  5461. } else {
  5462. c.ServeSuccessJSON(map[string]interface{}{
  5463. "failed_code": -10,
  5464. "msg": err_msg,
  5465. })
  5466. }
  5467. }
  5468. //
  5469. //zuobiao, _ := service.Getzuobiao(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  5470. //
  5471. //is_success := true
  5472. //failed_mag := ""
  5473. //查询出对应的坐标系统医嘱id,先进行删除操作,在创建医嘱。如果没有医嘱id,则直接创建医嘱
  5474. //if zuobiao.ID > 0 {
  5475. // cbm01s := strings.Split(zuobiao.Cbm01, ",")
  5476. // fmt.Println(cbm01s)
  5477. //
  5478. // for _, iditem := range cbm01s {
  5479. // fmt.Println(iditem)
  5480. // var root2 models.Root2
  5481. // var tradeInfo2 models.TradeInfo
  5482. // if li.Acf01 == 1 {
  5483. // tradeInfo2.PatSource = 1
  5484. // tradeInfo2.Type = 0
  5485. // } else {
  5486. // tradeInfo2.PatSource = 2
  5487. // tradeInfo2.Type = 1
  5488. //
  5489. // }
  5490. // tradeInfo2.Detpid = departmwnt.Number
  5491. // tradeInfo2.Empid = doctor_info.DoctorNumber
  5492. // tradeInfo2.Empno = doctor_info.DoctorCode
  5493. // tradeInfo2.Empname = doctor_info.UserName
  5494. // var vaf01 models.VAF10
  5495. // var ie1111 models.IEfive
  5496. // ie1111.VAF01 = iditem
  5497. // vaf01.Ie = append(vaf01.Ie, ie1111)
  5498. // root2.TradeInfo = tradeInfo2
  5499. // root2.VAF1 = vaf01
  5500. // xmlStr2, err := xml.MarshalIndent(root2, "", " ")
  5501. // if err != nil {
  5502. // fmt.Println("转换为XML时发生错误:", err)
  5503. // return
  5504. // }
  5505. // data := make(map[string]interface{})
  5506. // data["xmlStr"] = string(xmlStr2)
  5507. // bytesData, _ := json.Marshal(data)
  5508. // client := &http.Client{}
  5509. //
  5510. // var req *http.Request
  5511. //
  5512. //
  5513. // req, _ = http.NewRequest("POST", "http://192.168.100.199:9532/"+"nmg/coordinate/del", bytes.NewReader(bytesData))
  5514. // resp, _ := client.Do(req)
  5515. // defer resp.Body.Close()
  5516. // body, ioErr := ioutil.ReadAll(resp.Body)
  5517. // if ioErr != nil {
  5518. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5520. // return
  5521. // }
  5522. // var respJSON map[string]interface{}
  5523. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5524. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5526. // return
  5527. // }
  5528. //
  5529. // respJSON2 := respJSON["data"].(map[string]interface{})["msg"].(string)
  5530. // fmt.Println( respJSON)
  5531. // fmt.Println( respJSON["data"].(map[string]interface{}))
  5532. // fmt.Println(respJSON2)
  5533. //
  5534. // if respJSON2 != "成功"{
  5535. // //is_success = false
  5536. // failed_mag = respJSON2
  5537. // }
  5538. // }
  5539. //}
  5540. } else {
  5541. c.ServeSuccessJSON(map[string]interface{}{
  5542. "failed_code": -10,
  5543. "msg": res8.Msg,
  5544. })
  5545. }
  5546. }
  5547. type Result struct {
  5548. ResultObj []struct {
  5549. Vaf01 int `json:"vaf01"`
  5550. Vaf10 int `json:"vaf10"`
  5551. } `json:"resultObj"`
  5552. Result bool `json:"result"`
  5553. Code int `json:"code"`
  5554. ResultMsg string `json:"resultMsg"`
  5555. Msg string `json:"msg"`
  5556. Error bool `json:"error"`
  5557. Success bool `json:"success"`
  5558. }
  5559. func (c *CoordinateController) NMGCancelSettleAccount() {
  5560. zuobiao_id, _ := c.GetInt64("id")
  5561. zuobiao, _ := service.Getzuobiaobyid(zuobiao_id)
  5562. admin_user_id, _ := c.GetInt64("admin_user_id")
  5563. order, _ := service.GetHisOrderByID(zuobiao.Oid)
  5564. admin_user_info, _ := service.GetAdminUserInfoByID(order.UserOrgId, admin_user_id)
  5565. is_success := true
  5566. var failed_mag string
  5567. if zuobiao.ID > 0 {
  5568. cbm01s := strings.Split(zuobiao.Cbm01, ",")
  5569. var p_type int64
  5570. //for _, iditem := range cbm01s{
  5571. if order.PType == 1 {
  5572. p_type = 1
  5573. } else {
  5574. p_type = 2
  5575. }
  5576. is_del := true
  5577. for _, iditem := range cbm01s {
  5578. var vaf01List []string
  5579. a, _ := service.QueryNMGPrescriptionForCoordinate(p_type, vaf01List, iditem)
  5580. var result Result
  5581. err := json.Unmarshal([]byte(a), &result)
  5582. fmt.Println("Error:", result)
  5583. fmt.Println("Error:", err)
  5584. if err != nil {
  5585. fmt.Println("Error:", err)
  5586. return
  5587. }
  5588. for _,item := range result.ResultObj{
  5589. if item.Vaf10 != 4 {
  5590. is_del = false
  5591. }
  5592. }
  5593. }
  5594. if is_del{
  5595. err := service.UpdataOrderStatustwo(order.ID, zuobiao.Cbm01, order.UserOrgId)
  5596. zuobiao.Status = 0
  5597. service.Createzuobiao(&zuobiao)
  5598. if err == nil {
  5599. c.ServeSuccessJSON(map[string]interface{}{
  5600. "msg": "撤销记账成功",
  5601. })
  5602. } else {
  5603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5604. return
  5605. }
  5606. c.ServeSuccessJSON(map[string]interface{}{
  5607. "msg": "撤销成功",
  5608. })
  5609. }else{
  5610. for _, iditem := range cbm01s {
  5611. var root2 models.Root2
  5612. var tradeInfo2 models.TradeInfo
  5613. if order.PType == 1 {
  5614. tradeInfo2.PatSource = 1
  5615. tradeInfo2.Type = 0
  5616. } else {
  5617. tradeInfo2.PatSource = 2
  5618. tradeInfo2.Type = 1
  5619. }
  5620. tradeInfo2.Detpid = "38"
  5621. tradeInfo2.Empid = admin_user_info.DoctorNumber
  5622. tradeInfo2.Empno = admin_user_info.DoctorCode
  5623. tradeInfo2.Empname = admin_user_info.UserName
  5624. var vaf01 models.VAF10
  5625. var ie1111 models.IEfive
  5626. ie1111.VAF01 = iditem
  5627. vaf01.Ie = append(vaf01.Ie, ie1111)
  5628. root2.TradeInfo = tradeInfo2
  5629. root2.VAF1 = vaf01
  5630. xmlStr2, err := xml.MarshalIndent(root2, "", " ")
  5631. if err != nil {
  5632. fmt.Println("转换为XML时发生错误:", err)
  5633. return
  5634. }
  5635. data := make(map[string]interface{})
  5636. data["xmlStr"] = string(xmlStr2)
  5637. bytesData, _ := json.Marshal(data)
  5638. client := &http.Client{}
  5639. var req *http.Request
  5640. req, _ = http.NewRequest("POST", "http://127.0.0.1:9532/"+"nmg/coordinate/del", bytes.NewReader(bytesData))
  5641. resp, _ := client.Do(req)
  5642. defer resp.Body.Close()
  5643. body, ioErr := ioutil.ReadAll(resp.Body)
  5644. if ioErr != nil {
  5645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5647. return
  5648. }
  5649. var respJSON map[string]interface{}
  5650. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5653. return
  5654. }
  5655. respJSON2 := respJSON["data"].(map[string]interface{})["msg"].(string)
  5656. if respJSON2 != "成功" {
  5657. is_success = false
  5658. if len(failed_mag) == 0 {
  5659. failed_mag = respJSON2
  5660. } else {
  5661. failed_mag = failed_mag + "---" + respJSON2
  5662. }
  5663. }
  5664. if strings.Contains(failed_mag, "医嘱已执行收款,不允许在取消医嘱") {
  5665. is_success = false
  5666. }
  5667. }
  5668. if is_success {
  5669. err := service.UpdataOrderStatustwo(order.ID, zuobiao.Cbm01, order.UserOrgId)
  5670. zuobiao.Status = 0
  5671. service.Createzuobiao(&zuobiao)
  5672. if err == nil {
  5673. c.ServeSuccessJSON(map[string]interface{}{
  5674. "msg": "撤销记账成功",
  5675. })
  5676. } else {
  5677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5678. return
  5679. }
  5680. c.ServeSuccessJSON(map[string]interface{}{
  5681. "msg": "撤销成功",
  5682. })
  5683. } else {
  5684. c.ServeSuccessJSON(map[string]interface{}{
  5685. "failed_code": -10,
  5686. "msg": failed_mag,
  5687. })
  5688. }
  5689. }
  5690. //} else {
  5691. // c.ServeSuccessJSON(map[string]interface{}{
  5692. // "failed_code": -10,
  5693. // "msg": "查询不到可删除的数据",
  5694. // })
  5695. //}
  5696. }
  5697. }
  5698. //func (c *CoordinateController)NMGgetcheck(){
  5699. // patient_id, _ := c.GetInt64("patient_id")
  5700. // record_date := c.GetString("record_date")
  5701. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5702. // //diagnosis_id := c.GetString("diagnosis")
  5703. // //sick_type, _ := c.GetInt64("sick_type")
  5704. // //reg_type, _ := c.GetInt64("p_type")
  5705. // org_id, _ := c.GetInt64("org_id")
  5706. // org_id = 10454
  5707. // org, _ := service.GetOrgById(org_id)
  5708. // patient, _ := service.GetPatientByID(org.Id, patient_id)
  5709. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5710. // result, request := service.GetNMGHisPatientForCoordinate(0,0,2,patient.Name)
  5711. // result5, request5 := service.GetNMGHisPatientForCoordinate(0,0,1,patient.Name)
  5712. //
  5713. // saveLog(result, request, "查询", "查询", "")
  5714. // saveLog(result5, request5, "查询", "查询", "")
  5715. //
  5716. // var res Data
  5717. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  5718. // utils.ErrorLog("解析失败:%v", err)
  5719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5720. // return
  5721. // }
  5722. //
  5723. // var res8 Data
  5724. // if err := json.Unmarshal([]byte(result5), &res8); err != nil {
  5725. // utils.ErrorLog("解析失败:%v", err)
  5726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5727. // return
  5728. // }
  5729. //
  5730. // if res.Code == 200 || res8.Code == 200 {
  5731. // var res9 Data
  5732. // res9.List = append(res9.List,res.List...)
  5733. // res9.List = append(res9.List,res8.List...)
  5734. //
  5735. //
  5736. // var li ListItem
  5737. // for _, item := range res9.List{
  5738. // cure_date := strings.Split(item.Vae11, " ")
  5739. // if cure_date[0] == record_date && patient.Name == item.Vaa05{
  5740. // li = item
  5741. // }
  5742. // }
  5743. // fmt.Println("11111111")
  5744. // fmt.Println(li)
  5745. // fmt.Println("11111111")
  5746. // timeLayout := "2006-01-02"
  5747. // loc, _ := time.LoadLocation("Local")
  5748. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5749. // if err != nil {
  5750. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5751. // return
  5752. // }
  5753. // org_id := org.Id
  5754. // recordDateTime := theTime.Unix()
  5755. // patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  5756. // if patientPrescription.ID == 0 {
  5757. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  5758. // }
  5759. // //departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5760. // //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  5761. // //doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  5762. //
  5763. //
  5764. //
  5765. //
  5766. // //service.QueryNMGChenckForCoordinate(li.Acf01,li.Vaa01,li.Vaa07,"")
  5767. //
  5768. //
  5769. // } else {
  5770. // c.ServeSuccessJSON(map[string]interface{}{
  5771. // "failed_code": -10,
  5772. // "msg": res.Msg,
  5773. // })
  5774. // }
  5775. //
  5776. //
  5777. //}
  5778. //func (c *CoordinateController) SettleAccount() {
  5779. // patient_id, _ := c.GetInt64("patient_id")
  5780. // record_date := c.GetString("record_date")
  5781. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5782. // diagnosis_id := c.GetString("diagnosis")
  5783. // sick_type, _ := c.GetInt64("sick_type")
  5784. // reg_type, _ := c.GetInt64("p_type")
  5785. // org_id, _ := c.GetInt64("org_id")
  5786. // org_id = 3877
  5787. // org, _ := service.GetOrgById(org_id)
  5788. // patient, _ := service.GetPatientByID(org.Id, patient_id)
  5789. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5790. //
  5791. // result, request := service.GetHisPatientForCoordinate(patient.IdCardNo)
  5792. // saveLog(result, request, "查询", "查询", org.OrgName)
  5793. // var res ResultQuery
  5794. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  5795. // utils.ErrorLog("解析失败:%v", err)
  5796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5797. // return
  5798. // }
  5799. // if res.Code == "10000" {
  5800. // if len(res.Result) == 0 {
  5801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientNoRegException)
  5802. // return
  5803. // }
  5804. // timeLayout := "2006-01-02"
  5805. // loc, _ := time.LoadLocation("Local")
  5806. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5807. // if err != nil {
  5808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5809. // return
  5810. // }
  5811. // org_id := org.Id
  5812. // recordDateTime := theTime.Unix()
  5813. // patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  5814. // if patientPrescription.ID == 0 {
  5815. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  5816. // }
  5817. // departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5818. // doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  5819. // //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  5820. //
  5821. // var prescriptions []*models.HisPrescription
  5822. //
  5823. // if settle_accounts_type == 1 { //日结
  5824. // prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, patient_id, recordDateTime, 2)
  5825. // } else { //月结
  5826. //
  5827. // start_time_str := c.GetString("start_time")
  5828. // end_time_str := c.GetString("end_time")
  5829. // timeLayout := "2006-01-02"
  5830. // loc, _ := time.LoadLocation("Local")
  5831. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5832. // if err != nil {
  5833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5834. // return
  5835. // }
  5836. // recordStartTime := theStartTime.Unix()
  5837. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5838. // if err != nil {
  5839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5840. // return
  5841. // }
  5842. // recordEndTime := theEndTime.Unix()
  5843. // prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime)
  5844. // }
  5845. // var total float64
  5846. //
  5847. // for _, item := range prescriptions {
  5848. // fmt.Println(item)
  5849. // if item.Type == 1 { //药品
  5850. // for _, subItem := range item.HisDoctorAdviceInfo {
  5851. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5852. // }
  5853. // }
  5854. // if item.Type == 2 { //项目
  5855. // for _, subItem := range item.HisPrescriptionProject {
  5856. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5857. // total = total + (subItem.Price * cnt)
  5858. // }
  5859. // }
  5860. //
  5861. // }
  5862. //
  5863. // var ids []int64
  5864. //
  5865. // for _, item := range prescriptions {
  5866. // ids = append(ids, item.ID)
  5867. // }
  5868. //
  5869. // var customs []*models.NewCustomTwo
  5870. // for _, item := range prescriptions {
  5871. // if item.Type == 1 { //药品
  5872. // for _, subItem := range item.HisDoctorAdviceInfo {
  5873. // cus := &models.NewCustomTwo{
  5874. // AdviceId: subItem.ID,
  5875. // ProjectId: 0,
  5876. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  5877. // Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  5878. // FeedetlSn: subItem.FeedetlSn,
  5879. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5880. // MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  5881. // Type: 1,
  5882. // }
  5883. // customs = append(customs, cus)
  5884. // }
  5885. // }
  5886. // if item.Type == 2 { //项目
  5887. // for _, subItem := range item.HisPrescriptionProject {
  5888. // if subItem.Type == 2 {
  5889. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5890. // cus := &models.NewCustomTwo{
  5891. // AdviceId: 0,
  5892. // ProjectId: subItem.ID,
  5893. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  5894. // Cut: fmt.Sprintf("%.4f", cnt),
  5895. // FeedetlSn: subItem.FeedetlSn,
  5896. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  5897. // MedListCodg: subItem.HisProject.MedicalCode,
  5898. // Type: 2,
  5899. // }
  5900. // customs = append(customs, cus)
  5901. //
  5902. // } else {
  5903. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5904. // cus := &models.NewCustomTwo{
  5905. // AdviceId: 0,
  5906. // ProjectId: subItem.ID,
  5907. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  5908. // Cut: fmt.Sprintf("%.4f", cnt),
  5909. // FeedetlSn: subItem.FeedetlSn,
  5910. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  5911. // MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  5912. // Type: 3,
  5913. // }
  5914. // customs = append(customs, cus)
  5915. // }
  5916. //
  5917. // }
  5918. // }
  5919. // }
  5920. //
  5921. // var info models.UploadInfo
  5922. // info.Vaa01 = int64(res.Result[0].Vaa01)
  5923. // info.Fasong = "1"
  5924. // info.Vaa07 = int64(res.Result[0].Vaa07)
  5925. // info.Bck01c = departmwnt.Number
  5926. // info.Bce02a = doctor_info.DoctorNumber
  5927. //
  5928. // diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5929. // var config []*models.HisXtDiagnoseConfig
  5930. // for _, item := range diagnosis_ids {
  5931. // id, _ := strconv.ParseInt(item, 10, 64)
  5932. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5933. // config = append(config, &diagnosisConfig)
  5934. // }
  5935. // for index, item := range config {
  5936. // var diag models.Diag
  5937. // diag.Vao06 = strconv.FormatInt(int64(index+1), 10)
  5938. // diag.Bak02 = item.CountryCode
  5939. // info.Diag = append(info.Diag, &diag)
  5940. // }
  5941. // var presInfos []*models.PresInfo
  5942. // var presDetails []*models.PresDetail
  5943. // for index, item := range prescriptions {
  5944. // var presDetail models.PresDetail
  5945. // var presInfo models.PresInfo
  5946. // presInfo.Cbmid = strconv.FormatInt(item.ID, 10)
  5947. // if item.Type == 1 {
  5948. // presInfo.Cbm06 = "0"
  5949. // } else {
  5950. // presInfo.Cbm06 = "5"
  5951. // }
  5952. //
  5953. // if item.Type == 1 {
  5954. // presInfo.Cbm07 = item.MedType
  5955. // } else {
  5956. // presInfo.Cbm07 = item.MedType
  5957. // }
  5958. //
  5959. // presDetail.Vaf59 = strconv.FormatInt(int64(index+1), 10)
  5960. // var infoItems []*models.Item
  5961. // for _, subItem := range item.HisDoctorAdviceInfo {
  5962. // ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
  5963. //
  5964. // var infoItem models.Item
  5965. // infoItem.Rownr = "0"
  5966. // infoItem.Vaf11 = "1"
  5967. // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
  5968. // infoItem.Bbx01 = subItem.BaseDrugLib.MedicalInsuranceNumber
  5969. // infoItem.Bda01 = "1"
  5970. // infoItem.Bby01 = ""
  5971. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  5972. // infoItem.Vaf22 = subItem.BaseDrugLib.DrugName + " " + subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5973. // }
  5974. // infoItem.Vaf14 = subItem.BaseDrugLib.DrugName
  5975. // infoItem.Bdi01 = ef.Code
  5976. // infoItem.Vaf17 = strconv.FormatInt(subItem.Day, 10)
  5977. // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
  5978. // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5979. // infoItem.Vaf35 = "0"
  5980. // infoItem.Vaf32 = "0"
  5981. // infoItem.Bck01b = departmwnt.Number
  5982. // infoItem.Bck01d = departmwnt.Number
  5983. // infoItem.Vaf58 = "0"
  5984. // infoItem.Vaf61 = "1"
  5985. // infoItems = append(infoItems, &infoItem)
  5986. // }
  5987. // for _, subItem := range item.HisPrescriptionProject {
  5988. // ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
  5989. //
  5990. // if subItem.Type == 2 {
  5991. // var infoItem models.Item
  5992. // infoItem.Rownr = "0"
  5993. // infoItem.Vaf11 = "1"
  5994. // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
  5995. // infoItem.Bbx01 = subItem.HisProject.MedicalCode
  5996. //
  5997. // if subItem.HisProject.CostClassify == 2 {
  5998. // infoItem.Bda01 = "T"
  5999. // } else if subItem.HisProject.CostClassify == 3 {
  6000. // infoItem.Bda01 = "L"
  6001. // } else {
  6002. // infoItem.Bda01 = "T"
  6003. // }
  6004. // infoItem.Bby01 = ""
  6005. // infoItem.Vaf22 = subItem.HisProject.ProjectName
  6006. // infoItem.Bdi01 = ef.Code
  6007. // infoItem.Vaf17 = subItem.Day
  6008. // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
  6009. // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.Count)
  6010. // infoItem.Vaf35 = "0"
  6011. // infoItem.Vaf18 = "0"
  6012. // infoItem.Vaf32 = "0"
  6013. // infoItem.Bck01b = departmwnt.Number
  6014. // infoItem.Bck01d = departmwnt.Number
  6015. // infoItem.Vaf58 = "0"
  6016. // infoItem.Vaf61 = "1"
  6017. // infoItems = append(infoItems, &infoItem)
  6018. //
  6019. // } else {
  6020. // var infoItem models.Item
  6021. // infoItem.Rownr = "0"
  6022. // infoItem.Vaf11 = "1"
  6023. // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
  6024. // infoItem.Bbx01 = subItem.GoodInfo.MedicalInsuranceNumber
  6025. // infoItem.Bda01 = "M"
  6026. // infoItem.Bby01 = ""
  6027. // infoItem.Vaf22 = subItem.GoodInfo.GoodName + " " + subItem.GoodInfo.SpecificationName
  6028. // infoItem.Bdi01 = ef.Code
  6029. // infoItem.Vaf17 = subItem.Day
  6030. // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
  6031. // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.Count)
  6032. // infoItem.Vaf35 = "0"
  6033. // infoItem.Vaf32 = "0"
  6034. // infoItem.Bck01b = departmwnt.Number
  6035. // infoItem.Bck01d = departmwnt.Number
  6036. // infoItem.Vaf58 = "0"
  6037. // infoItem.Vaf61 = "1"
  6038. // infoItems = append(infoItems, &infoItem)
  6039. //
  6040. // }
  6041. //
  6042. // }
  6043. // presDetail.Item = infoItems
  6044. // presDetails = append(presDetails, &presDetail)
  6045. // presInfo.PresDetail = presDetails
  6046. // presInfos = append(presInfos, &presInfo)
  6047. // }
  6048. // info.PresInfo = presInfos
  6049. //
  6050. // result2, request2 := service.UploadPrescriptionForCoordinate(info)
  6051. // saveLog(result2, request2, "上传明细", "上传明细", org.OrgName)
  6052. //
  6053. // var res2 ResultUpload
  6054. // if err := json.Unmarshal([]byte(result2), &res2); err != nil {
  6055. // utils.ErrorLog("解析失败:%v", err)
  6056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6057. // return
  6058. // }
  6059. // if res2.Code == "10000" {
  6060. //
  6061. // timestamp := time.Now().Unix()
  6062. // tempTime := time.Unix(timestamp, 0)
  6063. // timeFormat := tempTime.Format("20060102150405")
  6064. // chrgBchno := rand.Intn(100000) + 10000
  6065. // ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
  6066. // his := models.VMHisPatient{
  6067. // Name: patient.Name,
  6068. // Gender: patient.Gender,
  6069. // Birthday: patient.Birthday,
  6070. // MedicalTreatmentType: 0,
  6071. // IdType: 1,
  6072. // IdCardNo: patient.IdCardNo,
  6073. // BalanceAccountsType: 1,
  6074. // MedicalInsuranceNumber: "",
  6075. // RegisterType: 0,
  6076. // RegisterCost: 0,
  6077. // TreatmentCost: 0,
  6078. // Status: 1,
  6079. // Ctime: time.Now().Unix(),
  6080. // Mtime: time.Now().Unix(),
  6081. // PsnNo: strconv.FormatInt(int64(res.Result[0].Vaa01), 10),
  6082. // PsnCertType: "",
  6083. // Certno: patient.IdCardNo,
  6084. // PsnName: patient.Name,
  6085. // Gend: "",
  6086. // Naty: "",
  6087. // Brdy: "",
  6088. // Age: 0,
  6089. // Iinfo: "",
  6090. // Idetinfo: "",
  6091. // PatientId: patient.ID,
  6092. // RecordDate: theTime.Unix(),
  6093. // UserOrgId: org_id,
  6094. // AdminUserId: admin_user_id,
  6095. // IsReturn: 1,
  6096. // Doctor: patientPrescription.DoctorId,
  6097. // Departments: patientPrescription.Departments,
  6098. // IptOtpNo: ipt_otp_no,
  6099. // Number: strconv.FormatInt(int64(res.Result[0].Vaa07), 10),
  6100. // PhoneNumber: patient.Phone,
  6101. // }
  6102. // service.UpdateHisPatientStatusten(&his)
  6103. // service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
  6104. // tm := time.Unix(time.Now().Unix(), 0)
  6105. //
  6106. // order := &models.HisOrder{
  6107. // PsnNo: his.PsnNo,
  6108. // UserOrgId: org_id,
  6109. // HisPatientId: his.ID,
  6110. // PatientId: patient_id,
  6111. // SettleAccountsDate: recordDateTime,
  6112. // Ctime: time.Now().Unix(),
  6113. // Mtime: time.Now().Unix(),
  6114. // Status: 1,
  6115. // OrderStatus: 1,
  6116. // MdtrtId: his.Number,
  6117. // Number: ipt_otp_no,
  6118. // SetlId: "",
  6119. // MedfeeSumamt: total,
  6120. // MedType: strconv.Itoa(int(reg_type)),
  6121. // SettleEndTime: 0,
  6122. // SettleStartTime: 0,
  6123. // SettleType: settle_accounts_type,
  6124. // Diagnosis: diagnosis_id,
  6125. // PType: 2,
  6126. // SetlTime: tm.Format("2006-01-02 15:04:05"),
  6127. // }
  6128. // err = service.CreateOrder(order)
  6129. // if err != nil {
  6130. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  6131. // return
  6132. // }
  6133. //
  6134. // for _, item := range customs {
  6135. // var advice_id int64 = 0
  6136. // var project_id int64 = 0
  6137. // var item_id int64 = 0
  6138. //
  6139. // var types int64 = 0
  6140. //
  6141. // if item.Type == 1 {
  6142. // advice_id = item.AdviceId
  6143. // project_id = 0
  6144. // item_id = 0
  6145. // } else if item.Type == 2 {
  6146. // advice_id = 0
  6147. // item_id = 0
  6148. //
  6149. // project_id = item.ProjectId
  6150. // } else if item.Type == 3 {
  6151. // advice_id = 0
  6152. // item_id = item.ItemId
  6153. // project_id = 0
  6154. // }
  6155. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6156. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6157. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6158. // info := &models.HisOrderInfo{
  6159. // OrderNumber: order.Number,
  6160. // UploadDate: time.Now().Unix(),
  6161. // AdviceId: advice_id,
  6162. // DetItemFeeSumamt: detItemFeeSumamt,
  6163. // Cnt: cut,
  6164. // Pric: pric,
  6165. // PatientId: patient_id,
  6166. // Status: 1,
  6167. // Mtime: time.Now().Unix(),
  6168. // Ctime: time.Now().Unix(),
  6169. // UserOrgId: org_id,
  6170. // HisPatientId: his.ID,
  6171. // OrderId: order.ID,
  6172. // ProjectId: project_id,
  6173. // Type: types,
  6174. // ItemId: item_id,
  6175. // }
  6176. // service.CreateOrderInfo(info)
  6177. // }
  6178. // his.Diagnosis = diagnosis_id
  6179. // his.SickType = sick_type
  6180. // his.RegisterType = reg_type
  6181. // his.MedicalTreatmentType = reg_type
  6182. // service.UpdataHisPateintTwo(&his)
  6183. // err = service.UpDatePrescriptionNumber(org_id, ids, strconv.FormatInt(int64(chrgBchno), 10))
  6184. // err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(chrgBchno), 10), recordDateTime, his.ID)
  6185. // err = service.UpdataOrderStatusThreef(strconv.FormatInt(int64(chrgBchno), 10), org_id)
  6186. //
  6187. // c.ServeSuccessJSON(map[string]interface{}{
  6188. // "msg": "医嘱保存成功",
  6189. // })
  6190. //
  6191. // } else {
  6192. // c.ServeSuccessJSON(map[string]interface{}{
  6193. // "failed_code": -10,
  6194. // "msg": res.Msg,
  6195. // })
  6196. //
  6197. // }
  6198. //
  6199. // } else {
  6200. // c.ServeSuccessJSON(map[string]interface{}{
  6201. // "failed_code": -10,
  6202. // "msg": res.Msg,
  6203. // })
  6204. //
  6205. // }
  6206. //
  6207. //}
  6208. func (c *CoordinateController) Settle() {
  6209. //参数1 patient_id
  6210. //参数2 就诊号
  6211. //参数3 单据id
  6212. fmt.Println(c.Ctx.Request.Body)
  6213. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  6214. fmt.Println(string(body))
  6215. var respJSON map[string]interface{}
  6216. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6218. return
  6219. }
  6220. patien_id := respJSON["vaa01"].(float64)
  6221. infoSeq := respJSON["vaa07"].(float64)
  6222. //strconv.For(patien_id, 10)
  6223. vaa001 := fmt.Sprintf("%f", patien_id)
  6224. vaa007 := fmt.Sprintf("%f", infoSeq)
  6225. setl_id := respJSON["setl_id"].(string)
  6226. order, _ := service.GetHisOrderFour(vaa001, vaa007, "")
  6227. order.SetlId = setl_id
  6228. if order.ID == 0 {
  6229. json := make(map[string]interface{})
  6230. json["msg"] = "结算记录不存在,请检查参数是否正确"
  6231. json["code"] = "-1"
  6232. c.Data["json"] = json
  6233. c.ServeJSON()
  6234. return
  6235. }
  6236. order.OrderStatus = 2
  6237. service.UpDateOrder(order)
  6238. service.UpdataOrderStatusTwo(order.Number, order.UserOrgId)
  6239. json := make(map[string]interface{})
  6240. json["msg"] = "结算成功"
  6241. json["code"] = "0"
  6242. c.Data["json"] = json
  6243. c.ServeJSON()
  6244. return
  6245. }
  6246. func (c *CoordinateController) Refund() {
  6247. //参数1 patient_id
  6248. //参数2 就诊号
  6249. //参数3 单据id
  6250. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  6251. var respJSON map[string]interface{}
  6252. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6254. return
  6255. }
  6256. patien_id := respJSON["vaa01"].(float64)
  6257. infoSeq := respJSON["vaa07"].(float64)
  6258. //strconv.For(patien_id, 10)
  6259. vaa001 := fmt.Sprintf("%f", patien_id)
  6260. vaa007 := fmt.Sprintf("%f", infoSeq)
  6261. docId := respJSON["setl_id"].(string)
  6262. order, _ := service.GetHisOrderFour(vaa001, vaa007, docId)
  6263. if order.ID == 0 {
  6264. json := make(map[string]interface{})
  6265. json["msg"] = "结算记录不存在,请检查参数是否正确"
  6266. json["code"] = "-1"
  6267. c.Data["json"] = json
  6268. c.ServeJSON()
  6269. return
  6270. }
  6271. service.UpdataOrderStatustwo(order.ID, order.Number, order.UserOrgId)
  6272. json := make(map[string]interface{})
  6273. json["msg"] = "退费成功"
  6274. json["code"] = "0"
  6275. c.Data["json"] = json
  6276. c.ServeJSON()
  6277. return
  6278. }
  6279. func (c *CoordinateController) SavePatientMessageInfo() {
  6280. result, request_log := service.SavePatientMessageInfo()
  6281. fmt.Println(result)
  6282. fmt.Println(request_log)
  6283. }
  6284. func (c *CoordinateController) checkpatient() {
  6285. }
  6286. func (c *CoordinateController) Register() {
  6287. patient_id, _ := c.GetInt64("patient_id")
  6288. diagnosis_time := c.GetString("diagnosis_time")
  6289. record_date := c.GetString("record_date")
  6290. admin_user_id, _ := c.GetInt64("admin_user_id")
  6291. org_id, _ := c.GetInt64("org_id")
  6292. patient, _ := service.GetPatientByID(org_id, patient_id)
  6293. org, _ := service.GetOrgById(org_id)
  6294. timeLayout := "2006-01-02"
  6295. loc, _ := time.LoadLocation("Local")
  6296. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  6297. if err != nil {
  6298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6299. return
  6300. }
  6301. if len(patient.ZbPatientId) == 0 {
  6302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnNoEmpty)
  6303. return
  6304. }
  6305. recordDateTime := theTime.Unix()
  6306. patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
  6307. if patientPrescription.ID == 0 {
  6308. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
  6309. }
  6310. doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
  6311. admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  6312. reg := models.Reg{
  6313. DeptId: "0112",
  6314. PatientId: patient.ZbPatientId,
  6315. PatientName: patient.Name,
  6316. DoctorId: doctor_info.DoctorNumber,
  6317. RegDate: strings.Split(diagnosis_time, " ")[0],
  6318. RegFee: "0",
  6319. TreatFee: "0",
  6320. OperatorId: admin_user_info.UserName,
  6321. IdCardNo: patient.IdCardNo,
  6322. }
  6323. result, request_log := service.SaveReg(reg)
  6324. fmt.Println(result)
  6325. fmt.Println(request_log)
  6326. saveLog(result, request_log, "登记", "登记", org.OrgName)
  6327. var res ResultReg
  6328. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6329. utils.ErrorLog("解析失败:%v", err)
  6330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6331. return
  6332. }
  6333. if res.ResultCode == "0" {
  6334. timestamp := time.Now().Unix()
  6335. tempTime := time.Unix(timestamp, 0)
  6336. timeFormat := tempTime.Format("20060102150405")
  6337. chrgBchno := rand.Intn(100000) + 10000
  6338. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
  6339. his := models.VMHisPatient{
  6340. Name: patient.Name,
  6341. Gender: patient.Gender,
  6342. Birthday: patient.Birthday,
  6343. MedicalTreatmentType: 0,
  6344. IdType: 1,
  6345. IdCardNo: patient.IdCardNo,
  6346. BalanceAccountsType: 1,
  6347. MedicalInsuranceNumber: "",
  6348. RegisterType: 0,
  6349. RegisterCost: 0,
  6350. TreatmentCost: 0,
  6351. Status: 1,
  6352. Ctime: time.Now().Unix(),
  6353. Mtime: time.Now().Unix(),
  6354. PsnNo: patient.ZbPatientId,
  6355. PsnCertType: "",
  6356. Certno: patient.IdCardNo,
  6357. PsnName: patient.Name,
  6358. Gend: "",
  6359. Naty: "",
  6360. Brdy: "",
  6361. Age: 0,
  6362. Iinfo: "",
  6363. Idetinfo: "",
  6364. PatientId: patient.ID,
  6365. RecordDate: theTime.Unix(),
  6366. UserOrgId: org_id,
  6367. AdminUserId: admin_user_id,
  6368. IsReturn: 1,
  6369. Doctor: patientPrescription.DoctorId,
  6370. Departments: patientPrescription.Departments,
  6371. IptOtpNo: ipt_otp_no,
  6372. Number: res.InfoSeq,
  6373. PhoneNumber: patient.Phone,
  6374. }
  6375. service.UpdateHisPatientStatus(&his)
  6376. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
  6377. c.ServeSuccessJSON(map[string]interface{}{
  6378. "his_info": his,
  6379. })
  6380. } else {
  6381. c.ServeSuccessJSON(map[string]interface{}{
  6382. "failed_code": -10,
  6383. "msg": res.ResultDesc,
  6384. })
  6385. }
  6386. }
  6387. //func (c *CoordinateController) GetWaitPayDetail() {
  6388. // result, request_log := service.GetWaitPayDetail()
  6389. // fmt.Println(result)
  6390. // fmt.Println(request_log)
  6391. //
  6392. //}
  6393. //func (c *CoordinateController) OpKeepAccounts() {
  6394. // id, _ := c.GetInt64("id")
  6395. // record_time := c.GetString("record_time")
  6396. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6397. // timeLayout := "2006-01-02"
  6398. // loc, _ := time.LoadLocation("Local")
  6399. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6400. // fapiao_code := c.GetString("fapiao_code")
  6401. // fapiao_number := c.GetString("fapiao_number")
  6402. // diagnosis_id := c.GetString("diagnosis")
  6403. // sick_type, _ := c.GetInt64("sick_type")
  6404. // reg_type, _ := c.GetInt64("p_type")
  6405. // org_id, _ := c.GetInt64("org_id")
  6406. // org, _ := service.GetOrgById(org_id)
  6407. //
  6408. // his, _ := service.GetHisPatientByIdThree(his_patient_id)
  6409. //
  6410. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6411. // if err != nil {
  6412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6413. // return
  6414. // }
  6415. // recordDateTime := theTime.Unix()
  6416. // //adminUser := c.GetAdminUserInfo()
  6417. // var prescriptions []*models.HisPrescription
  6418. // var start_time int64
  6419. // var end_time int64
  6420. //
  6421. // //ids_str := c.GetString("ids")
  6422. // //ids_arr := strings.Split(ids_str, ",")
  6423. //
  6424. // if settle_accounts_type == 1 { //日结
  6425. // //fmt.Println(reg_type)
  6426. // prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, id, recordDateTime, 2)
  6427. //
  6428. // } else { //月结
  6429. //
  6430. // start_time_str := c.GetString("start_time")
  6431. // end_time_str := c.GetString("end_time")
  6432. // timeLayout := "2006-01-02"
  6433. // loc, _ := time.LoadLocation("Local")
  6434. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6435. // if err != nil {
  6436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6437. // return
  6438. // }
  6439. // recordStartTime := theStartTime.Unix()
  6440. // start_time = recordStartTime
  6441. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6442. // if err != nil {
  6443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6444. // return
  6445. // }
  6446. // recordEndTime := theEndTime.Unix()
  6447. // end_time = recordEndTime
  6448. // prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, id, recordStartTime, recordEndTime)
  6449. // }
  6450. //
  6451. // timestamp := time.Now().Unix()
  6452. // tempTime := time.Unix(timestamp, 0)
  6453. // timeFormat := tempTime.Format("20060102150405")
  6454. // chrgBchno := rand.Intn(100000) + 10000
  6455. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6456. // strconv.FormatInt(his.PatientId, 10)
  6457. //
  6458. // var ids []int64
  6459. //
  6460. // for _, item := range prescriptions {
  6461. // ids = append(ids, item.ID)
  6462. // }
  6463. // var total float64
  6464. //
  6465. // for _, item := range prescriptions {
  6466. // fmt.Println(item)
  6467. // if item.Type == 1 { //药品
  6468. // for _, subItem := range item.HisDoctorAdviceInfo {
  6469. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6470. // }
  6471. // }
  6472. // if item.Type == 2 { //项目
  6473. // for _, subItem := range item.HisPrescriptionProject {
  6474. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6475. // total = total + (subItem.Price * cnt)
  6476. // }
  6477. // }
  6478. //
  6479. // for _, subItem := range item.HisAdditionalCharge {
  6480. // total = total + (subItem.Price * float64(subItem.Count))
  6481. // }
  6482. // }
  6483. //
  6484. // tm := time.Unix(time.Now().Unix(), 0)
  6485. //
  6486. // var customs []*models.NewCustomTwo
  6487. // for _, item := range prescriptions {
  6488. // if item.Type == 1 { //药品
  6489. // for _, subItem := range item.HisDoctorAdviceInfo {
  6490. // cus := &models.NewCustomTwo{
  6491. // AdviceId: subItem.ID,
  6492. // ProjectId: 0,
  6493. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  6494. // Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  6495. // FeedetlSn: subItem.FeedetlSn,
  6496. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6497. // MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  6498. // Type: 1,
  6499. // }
  6500. // customs = append(customs, cus)
  6501. // }
  6502. // }
  6503. // if item.Type == 2 { //项目
  6504. // for _, subItem := range item.HisPrescriptionProject {
  6505. // if subItem.Type == 2 {
  6506. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6507. // cus := &models.NewCustomTwo{
  6508. // AdviceId: 0,
  6509. // ProjectId: subItem.ID,
  6510. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  6511. // Cut: fmt.Sprintf("%.4f", cnt),
  6512. // FeedetlSn: subItem.FeedetlSn,
  6513. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  6514. // MedListCodg: subItem.HisProject.MedicalCode,
  6515. // Type: 2,
  6516. // }
  6517. // customs = append(customs, cus)
  6518. //
  6519. // } else {
  6520. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6521. // cus := &models.NewCustomTwo{
  6522. // AdviceId: 0,
  6523. // ProjectId: subItem.ID,
  6524. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  6525. // Cut: fmt.Sprintf("%.4f", cnt),
  6526. // FeedetlSn: subItem.FeedetlSn,
  6527. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  6528. // MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  6529. // Type: 3,
  6530. // }
  6531. // customs = append(customs, cus)
  6532. //
  6533. // }
  6534. //
  6535. // }
  6536. // }
  6537. // for _, item := range item.HisAdditionalCharge {
  6538. // cus := &models.NewCustomTwo{
  6539. // ItemId: item.ID,
  6540. // AdviceId: 0,
  6541. // ProjectId: 0,
  6542. // DetItemFeeSumamt: fmt.Sprintf("%.4f", item.Price),
  6543. // Cut: fmt.Sprintf("%.4f", float64(item.Count)),
  6544. // FeedetlSn: item.FeedetlSn,
  6545. // Price: fmt.Sprintf("%.4f", float64(item.Price)),
  6546. // MedListCodg: item.XtHisAddtionConfig.Code,
  6547. // Type: 3,
  6548. // }
  6549. // customs = append(customs, cus)
  6550. // }
  6551. // }
  6552. // result, request_log := service.OpKeepAccounts(his.Number, customs)
  6553. // saveLog(result, request_log, "记账", "记账", org.OrgName)
  6554. //
  6555. // var res ResultSettle
  6556. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  6557. // utils.ErrorLog("解析失败:%v", err)
  6558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6559. // return
  6560. // }
  6561. // if res.ResultCode == "0" {
  6562. //
  6563. // //totals, _ := strconv.ParseFloat(total, 64)
  6564. // order := &models.HisOrder{
  6565. // PsnNo: his.PsnNo,
  6566. // UserOrgId: org_id,
  6567. // HisPatientId: his.ID,
  6568. // PatientId: id,
  6569. // SettleAccountsDate: recordDateTime,
  6570. // Ctime: time.Now().Unix(),
  6571. // Mtime: time.Now().Unix(),
  6572. // Status: 1,
  6573. // OrderStatus: 1,
  6574. // MdtrtId: his.Number,
  6575. // Number: chrg_bchno,
  6576. // SetlId: "",
  6577. // MedfeeSumamt: total,
  6578. // MedType: strconv.Itoa(int(reg_type)),
  6579. // SettleEndTime: end_time,
  6580. // SettleStartTime: start_time,
  6581. // SettleType: settle_accounts_type,
  6582. // FaPiaoCode: fapiao_code,
  6583. // FaPiaoNumber: fapiao_number,
  6584. // Diagnosis: diagnosis_id,
  6585. // PType: 2,
  6586. // SetlTime: tm.Format("2006-01-02 15:04:05"),
  6587. // }
  6588. // err = service.CreateOrder(order)
  6589. // if err != nil {
  6590. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  6591. // return
  6592. // }
  6593. //
  6594. // for _, item := range customs {
  6595. // var advice_id int64 = 0
  6596. // var project_id int64 = 0
  6597. // var item_id int64 = 0
  6598. //
  6599. // var types int64 = 0
  6600. //
  6601. // if item.Type == 1 {
  6602. // advice_id = item.AdviceId
  6603. // project_id = 0
  6604. // item_id = 0
  6605. // } else if item.Type == 2 {
  6606. // advice_id = 0
  6607. // item_id = 0
  6608. //
  6609. // project_id = item.ProjectId
  6610. // } else if item.Type == 3 {
  6611. // advice_id = 0
  6612. // item_id = item.ItemId
  6613. // project_id = 0
  6614. // }
  6615. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6616. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6617. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6618. // info := &models.HisOrderInfo{
  6619. // OrderNumber: order.Number,
  6620. // UploadDate: time.Now().Unix(),
  6621. // AdviceId: advice_id,
  6622. // DetItemFeeSumamt: detItemFeeSumamt,
  6623. // Cnt: cut,
  6624. // Pric: pric,
  6625. // PatientId: id,
  6626. // Status: 1,
  6627. // Mtime: time.Now().Unix(),
  6628. // Ctime: time.Now().Unix(),
  6629. // UserOrgId: org_id,
  6630. // HisPatientId: his.ID,
  6631. // OrderId: order.ID,
  6632. // ProjectId: project_id,
  6633. // Type: types,
  6634. // ItemId: item_id,
  6635. // }
  6636. // service.CreateOrderInfo(info)
  6637. // }
  6638. // his.Diagnosis = diagnosis_id
  6639. // his.SickType = sick_type
  6640. // his.RegisterType = reg_type
  6641. // his.MedicalTreatmentType = reg_type
  6642. // service.UpdataHisPateintThree(&his)
  6643. // err = service.UpDatePrescriptionNumber(org_id, ids, chrg_bchno)
  6644. // err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, id, chrg_bchno, recordDateTime, his_patient_id)
  6645. // err = service.UpdataOrderStatusThreef(chrg_bchno, org_id)
  6646. // if err == nil {
  6647. // c.ServeSuccessJSON(map[string]interface{}{
  6648. // "msg": "记账成功",
  6649. // })
  6650. // }
  6651. // } else {
  6652. // c.ServeSuccessJSON(map[string]interface{}{
  6653. // "failed_code": -10,
  6654. // "msg": res.ResultDesc,
  6655. // })
  6656. // }
  6657. //
  6658. //}
  6659. //
  6660. //func (c *CoordinateController) OpCancelKeepAccounts() {
  6661. // order_id, _ := c.GetInt64("order_id")
  6662. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6663. // org_id, _ := c.GetInt64("org_id")
  6664. // org, _ := service.GetOrgById(org_id)
  6665. //
  6666. // order, _ := service.GetHisOrderByID(order_id)
  6667. // if order.ID == 0 {
  6668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6669. // return
  6670. // }
  6671. //
  6672. // role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  6673. // result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
  6674. // saveLog(result, request_log, "撤销记账", "撤销记账", org.OrgName)
  6675. // var res RefundDetail
  6676. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  6677. // utils.ErrorLog("解析失败:%v", err)
  6678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. // return
  6680. // }
  6681. // fmt.Println(result)
  6682. // fmt.Println(request_log)
  6683. // fmt.Println(res)
  6684. // flag := 0
  6685. // isSuccess := false
  6686. // for _, item := range res.Result {
  6687. // if item.Code == "200" {
  6688. // flag = flag + 1
  6689. // }
  6690. // }
  6691. // if len(res.Result) == flag {
  6692. // isSuccess = true
  6693. // }
  6694. // var errMsg string
  6695. // for _, item := range res.Result {
  6696. // errMsg = errMsg + "\n" + item.ResultMsg
  6697. // }
  6698. //
  6699. // if isSuccess {
  6700. // err := service.UpdataOrderStatustwo(order_id, order.Number, org_id)
  6701. // if err == nil {
  6702. // c.ServeSuccessJSON(map[string]interface{}{
  6703. // "msg": "撤销记账成功",
  6704. // })
  6705. // } else {
  6706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6707. // return
  6708. // }
  6709. // } else {
  6710. // c.ServeSuccessJSON(map[string]interface{}{
  6711. // "failed_code": -10,
  6712. // "msg": errMsg,
  6713. // })
  6714. //
  6715. // }
  6716. //}
  6717. //func saveLog(result string, request string, infno string, desc string) {
  6718. //
  6719. // org_id, _ := beego.AppConfig.Int64("org_id")
  6720. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6721. // dir := miConfig.OrgName + "日志"
  6722. // utils.Mkdir(dir)
  6723. // month := time.Unix(1557042972, 0).Format("1")
  6724. // year := time.Now().Format("2006")
  6725. // month = time.Now().Format("01")
  6726. // day := time.Now().Format("02")
  6727. // hour := time.Now().Format("15")
  6728. // min := time.Now().Format("04")
  6729. // sec := time.Now().Format("05")
  6730. //
  6731. // result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  6732. //
  6733. // file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  6734. // file_name := file + ".txt"
  6735. // file_path := miConfig.OrgName + "日志" + "/" + file_name
  6736. // exist, _ := utils.PathExists(file_path)
  6737. // if exist { //存在
  6738. // fmt.Println("存在")
  6739. // f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  6740. // if err != nil {
  6741. // fmt.Println("read fail")
  6742. // }
  6743. // content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  6744. // n, _ := f.Seek(0, 2)
  6745. // _, err = f.WriteAt([]byte(content), n)
  6746. //
  6747. // } else { //不存在
  6748. // fmt.Println("文件不存在,创建文件")
  6749. // f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  6750. // defer f.Close()
  6751. // if err != nil {
  6752. // } else {
  6753. // _, err = f.Write([]byte("记录日志"))
  6754. // }
  6755. // }
  6756. //
  6757. //}
  6758. func generateRandomNumber() int64 {
  6759. rand.Seed(time.Now().UnixNano())
  6760. return int64(rand.Intn(90000) + 10000)
  6761. }