coordinate_controller.go 250KB

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