his_api_controller.go 630KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  82. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  83. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  84. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  85. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  86. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  87. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  88. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  89. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  90. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  91. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  92. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  93. }
  94. func (c *HisApiController) Get2505() {
  95. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  96. service.Gdyb2505("44120000000010585742", "高慧裕", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-12-23 09:00:00", "2023-12-31 23:00:00")
  97. }
  98. func (c *HisApiController) Get4201A() {
  99. order_id, _ := c.GetInt64("order_id")
  100. admin_user_id, _ := c.GetInt64("admin_user_id")
  101. order, _ := service.GetHisOrderByIDTwo(order_id)
  102. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  103. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  104. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  105. //order_info = append(order_info, order_info_two...)
  106. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  108. department, _ := service.GetDepartMentDetail(his.Departments)
  109. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  110. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  111. if order.ID == 0 {
  112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  113. return
  114. }
  115. var struct4201A models.Struct4201A
  116. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  117. for _, items := range order_info {
  118. memo := make(map[string]interface{})
  119. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  120. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  121. fsiOPFLD.MedType = "14"
  122. fsiOPFLD.BkkpSn = items.FeedetlSn
  123. fsiOPFLD.FixmedinsCode = miConfig.Code
  124. fsiOPFLD.FixmedinsName = miConfig.OrgName
  125. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  126. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  127. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  128. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  129. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  130. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  131. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  132. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  133. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  134. fsiOPFLD.BilgDeptName = department.Name
  135. fsiOPFLD.BilgDeptCodg = department.Number
  136. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  137. fsiOPFLD.BilgDrName = doctor.UserName
  138. fsiOPFLD.MedChrgitmType = "09"
  139. memo["hosp_appr_flag"] = "1"
  140. memo["invoice_no"] = order.MdtrtId
  141. memo["memo"] = "自费"
  142. bytesData, _ := json.Marshal(memo)
  143. fsiOPFLD.Memo = string(bytesData)
  144. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  145. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  146. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  147. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  148. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  149. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  150. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  151. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  152. fsiOPFLD.BilgDeptName = department.Name
  153. fsiOPFLD.BilgDeptCodg = department.Number
  154. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  155. fsiOPFLD.BilgDrName = doctor.UserName
  156. switch items.HisPrescriptionProject.HisProject.CostClassify {
  157. case 0:
  158. break
  159. case 1:
  160. fsiOPFLD.MedChrgitmType = "14"
  161. break
  162. case 2:
  163. fsiOPFLD.MedChrgitmType = "05"
  164. break
  165. case 3:
  166. fsiOPFLD.MedChrgitmType = "03"
  167. break
  168. case 4:
  169. fsiOPFLD.MedChrgitmType = "03"
  170. break
  171. case 5:
  172. fsiOPFLD.MedChrgitmType = "08"
  173. break
  174. case 6:
  175. fsiOPFLD.MedChrgitmType = "14"
  176. break
  177. case 7:
  178. fsiOPFLD.MedChrgitmType = "14"
  179. break
  180. case 8:
  181. fsiOPFLD.MedChrgitmType = "03"
  182. break
  183. case 9:
  184. fsiOPFLD.MedChrgitmType = "14"
  185. break
  186. case 10:
  187. fsiOPFLD.MedChrgitmType = "14"
  188. break
  189. case 11:
  190. fsiOPFLD.MedChrgitmType = "06"
  191. break
  192. case 12:
  193. fsiOPFLD.MedChrgitmType = "12"
  194. break
  195. case 13:
  196. fsiOPFLD.MedChrgitmType = "01"
  197. break
  198. case 14:
  199. fsiOPFLD.MedChrgitmType = "04"
  200. break
  201. case 15:
  202. fsiOPFLD.MedChrgitmType = "14"
  203. break
  204. }
  205. memo["hosp_appr_flag"] = "1"
  206. memo["invoice_no"] = order.MdtrtId
  207. memo["memo"] = "自费"
  208. bytesData, _ := json.Marshal(memo)
  209. fsiOPFLD.Memo = string(bytesData)
  210. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  211. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  212. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  213. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  214. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  215. fsiOPFLD.BilgDeptName = department.Name
  216. fsiOPFLD.BilgDeptCodg = department.Number
  217. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  218. fsiOPFLD.BilgDrName = doctor.UserName
  219. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  220. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  221. fsiOPFLD.MedChrgitmType = "08"
  222. memo["hosp_appr_flag"] = "1"
  223. memo["invoice_no"] = order.MdtrtId
  224. memo["memo"] = "自费"
  225. bytesData, _ := json.Marshal(memo)
  226. fsiOPFLD.Memo = string(bytesData)
  227. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  228. }
  229. }
  230. }
  231. for _, items := range order_info_two {
  232. memo := make(map[string]interface{})
  233. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  234. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  235. fsiOPFLD.MedType = "14"
  236. fsiOPFLD.BkkpSn = items.FeedetlSn
  237. fsiOPFLD.FixmedinsCode = miConfig.Code
  238. fsiOPFLD.FixmedinsName = miConfig.OrgName
  239. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  240. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  241. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  242. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  243. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  244. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  245. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  246. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  247. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  248. fsiOPFLD.BilgDeptName = department.Name
  249. fsiOPFLD.BilgDeptCodg = department.Number
  250. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  251. fsiOPFLD.BilgDrName = doctor.UserName
  252. fsiOPFLD.MedChrgitmType = "09"
  253. memo["hosp_appr_flag"] = "1"
  254. memo["invoice_no"] = order.MdtrtId
  255. memo["memo"] = "自费"
  256. bytesData, _ := json.Marshal(memo)
  257. fsiOPFLD.Memo = string(bytesData)
  258. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  259. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  260. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  261. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  262. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  263. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  264. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  265. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  266. fsiOPFLD.BilgDeptName = department.Name
  267. fsiOPFLD.BilgDeptCodg = department.Number
  268. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  269. fsiOPFLD.BilgDrName = doctor.UserName
  270. switch items.HisPrescriptionProject.HisProject.CostClassify {
  271. case 0:
  272. break
  273. case 1:
  274. fsiOPFLD.MedChrgitmType = "14"
  275. break
  276. case 2:
  277. fsiOPFLD.MedChrgitmType = "05"
  278. break
  279. case 3:
  280. fsiOPFLD.MedChrgitmType = "03"
  281. break
  282. case 4:
  283. fsiOPFLD.MedChrgitmType = "03"
  284. break
  285. case 5:
  286. fsiOPFLD.MedChrgitmType = "08"
  287. break
  288. case 6:
  289. fsiOPFLD.MedChrgitmType = "14"
  290. break
  291. case 7:
  292. fsiOPFLD.MedChrgitmType = "14"
  293. break
  294. case 8:
  295. fsiOPFLD.MedChrgitmType = "03"
  296. break
  297. case 9:
  298. fsiOPFLD.MedChrgitmType = "14"
  299. break
  300. case 10:
  301. fsiOPFLD.MedChrgitmType = "14"
  302. break
  303. case 11:
  304. fsiOPFLD.MedChrgitmType = "06"
  305. break
  306. case 12:
  307. fsiOPFLD.MedChrgitmType = "12"
  308. break
  309. case 13:
  310. fsiOPFLD.MedChrgitmType = "01"
  311. break
  312. case 14:
  313. fsiOPFLD.MedChrgitmType = "04"
  314. break
  315. case 15:
  316. fsiOPFLD.MedChrgitmType = "14"
  317. break
  318. }
  319. memo["hosp_appr_flag"] = "1"
  320. memo["invoice_no"] = order.MdtrtId
  321. memo["memo"] = "自费"
  322. bytesData, _ := json.Marshal(memo)
  323. fsiOPFLD.Memo = string(bytesData)
  324. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  325. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  326. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  327. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  328. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  329. fsiOPFLD.BilgDeptName = department.Name
  330. fsiOPFLD.BilgDeptCodg = department.Number
  331. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  332. fsiOPFLD.BilgDrName = doctor.UserName
  333. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  334. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  335. fsiOPFLD.MedChrgitmType = "08"
  336. memo["hosp_appr_flag"] = "1"
  337. memo["invoice_no"] = order.MdtrtId
  338. memo["memo"] = "自费"
  339. bytesData, _ := json.Marshal(memo)
  340. fsiOPFLD.Memo = string(bytesData)
  341. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  342. }
  343. }
  344. }
  345. fmt.Println(fsiOPFLDs)
  346. struct4201A.Fopfd = fsiOPFLDs
  347. fmt.Println(struct4201A.Fopfd)
  348. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  349. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  350. var res2 ResultSix
  351. var respJSON2 map[string]interface{}
  352. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  355. return
  356. }
  357. userJSONBytes2, _ := json.Marshal(respJSON2)
  358. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  359. utils.ErrorLog("解析失败:%v", err)
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  361. return
  362. }
  363. if res2.Infcode != 0 {
  364. c.ServeSuccessJSON(map[string]interface{}{
  365. "failed_code": -10,
  366. "msg": res2.ErrMsg,
  367. })
  368. return
  369. } else {
  370. order.IsUploadOrderInfo = 1
  371. service.UpdateOrder(order)
  372. c.ServeSuccessJSON(map[string]interface{}{
  373. "msg": "上传成功",
  374. })
  375. }
  376. }
  377. func (c *HisApiController) Get4202() {
  378. order_id, _ := c.GetInt64("order_id")
  379. admin_user_id, _ := c.GetInt64("admin_user_id")
  380. order, _ := service.GetHisOrderByIDTwo(order_id)
  381. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  382. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  383. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  384. if order.ID == 0 {
  385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  386. return
  387. }
  388. var struct4202 models.Struct4202
  389. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  390. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  391. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  392. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  393. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  394. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  395. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  396. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  397. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  398. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  399. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  400. var config []*models.HisXtDiagnoseConfig
  401. for _, item := range diagnosis_ids {
  402. id, _ := strconv.ParseInt(item, 10, 64)
  403. diagnosisConfig, _ := service.FindDiagnoseById(id)
  404. config = append(config, &diagnosisConfig)
  405. }
  406. var tempDiaginfos []models.OwnPayPatnDiagListD
  407. for index, item := range config {
  408. if index == 0 {
  409. var tempDiaginfo models.OwnPayPatnDiagListD
  410. tempDiaginfo.InoutDiagType = "1"
  411. tempDiaginfo.DiagCode = item.CountryCode
  412. tempDiaginfo.DiagName = item.CountryContentName
  413. tempDiaginfo.DiagType = "1"
  414. tempDiaginfo.DiagSrtNo = "1"
  415. tempDiaginfo.MaindiagFlag = "1"
  416. tempDiaginfo.ValiFlag = "1"
  417. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  418. } else {
  419. var tempDiaginfo models.OwnPayPatnDiagListD
  420. tempDiaginfo.DiagCode = item.CountryCode
  421. tempDiaginfo.DiagName = item.CountryContentName
  422. tempDiaginfo.DiagType = "2"
  423. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  424. tempDiaginfo.MaindiagFlag = "0"
  425. tempDiaginfo.ValiFlag = "1"
  426. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  427. }
  428. }
  429. struct4202.ODiagListD = tempDiaginfos
  430. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  431. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  432. var res2 ResultSix
  433. var respJSON2 map[string]interface{}
  434. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  437. return
  438. }
  439. userJSONBytes2, _ := json.Marshal(respJSON2)
  440. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  441. utils.ErrorLog("解析失败:%v", err)
  442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  443. return
  444. }
  445. if res2.Infcode != 0 {
  446. c.ServeSuccessJSON(map[string]interface{}{
  447. "failed_code": -10,
  448. "msg": res2.ErrMsg,
  449. })
  450. return
  451. } else {
  452. order.IsUploadDiagnose = 1
  453. service.UpdateOrder(order)
  454. c.ServeSuccessJSON(map[string]interface{}{
  455. "msg": "上传成功",
  456. })
  457. }
  458. }
  459. func (c *HisApiController) Get4203() {
  460. admin_user_id, _ := c.GetInt64("admin_user_id")
  461. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  462. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  463. order_id, _ := c.GetInt64("order_id")
  464. order, _ := service.GetHisOrderByIDTwo(order_id)
  465. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  466. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, his.Number)
  467. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  468. var res2 ResultSix
  469. var respJSON2 map[string]interface{}
  470. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  473. return
  474. }
  475. userJSONBytes2, _ := json.Marshal(respJSON2)
  476. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  477. utils.ErrorLog("解析失败:%v", err)
  478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  479. return
  480. }
  481. if res2.Infcode != 0 {
  482. c.ServeSuccessJSON(map[string]interface{}{
  483. "failed_code": -10,
  484. "msg": res2.ErrMsg,
  485. })
  486. return
  487. } else {
  488. order.IsUploadSuccess = 1
  489. service.UpdateOrder(order)
  490. c.ServeSuccessJSON(map[string]interface{}{
  491. "msg": "上传成功",
  492. })
  493. }
  494. }
  495. func (c *HisApiController) Get4205() {
  496. order_id, _ := c.GetInt64("order_id")
  497. admin_user_id, _ := c.GetInt64("admin_user_id")
  498. order, _ := service.GetHisOrderByIDTwo(order_id)
  499. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  500. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  501. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  502. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  503. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  504. //order_info = append(order_info, order_info_two...)
  505. department, _ := service.GetDepartMentDetail(his.Departments)
  506. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  507. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  508. if order.ID == 0 {
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  510. return
  511. }
  512. var struct4201A models.Struct4201A
  513. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  514. for _, items := range order_info {
  515. memo := make(map[string]interface{})
  516. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  517. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  518. fsiOPFLD.MedType = "14"
  519. fsiOPFLD.BkkpSn = items.FeedetlSn
  520. fsiOPFLD.FixmedinsCode = miConfig.Code
  521. fsiOPFLD.FixmedinsName = miConfig.OrgName
  522. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  523. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  524. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  525. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  526. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  527. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  528. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  529. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  530. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  531. fsiOPFLD.BilgDeptName = department.Name
  532. fsiOPFLD.BilgDeptCodg = department.Number
  533. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  534. fsiOPFLD.BilgDrName = doctor.UserName
  535. fsiOPFLD.MedChrgitmType = "09"
  536. memo["hosp_appr_flag"] = "1"
  537. memo["invoice_no"] = order.MdtrtId
  538. memo["memo"] = "自费"
  539. bytesData, _ := json.Marshal(memo)
  540. fsiOPFLD.Memo = string(bytesData)
  541. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  542. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  543. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  544. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  545. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  546. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  547. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  548. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  549. fsiOPFLD.BilgDeptName = department.Name
  550. fsiOPFLD.BilgDeptCodg = department.Number
  551. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  552. fsiOPFLD.BilgDrName = doctor.UserName
  553. switch items.HisPrescriptionProject.HisProject.CostClassify {
  554. case 0:
  555. break
  556. case 1:
  557. fsiOPFLD.MedChrgitmType = "14"
  558. break
  559. case 2:
  560. fsiOPFLD.MedChrgitmType = "05"
  561. break
  562. case 3:
  563. fsiOPFLD.MedChrgitmType = "03"
  564. break
  565. case 4:
  566. fsiOPFLD.MedChrgitmType = "03"
  567. break
  568. case 5:
  569. fsiOPFLD.MedChrgitmType = "08"
  570. break
  571. case 6:
  572. fsiOPFLD.MedChrgitmType = "14"
  573. break
  574. case 7:
  575. fsiOPFLD.MedChrgitmType = "14"
  576. break
  577. case 8:
  578. fsiOPFLD.MedChrgitmType = "03"
  579. break
  580. case 9:
  581. fsiOPFLD.MedChrgitmType = "14"
  582. break
  583. case 10:
  584. fsiOPFLD.MedChrgitmType = "14"
  585. break
  586. case 11:
  587. fsiOPFLD.MedChrgitmType = "06"
  588. break
  589. case 12:
  590. fsiOPFLD.MedChrgitmType = "12"
  591. break
  592. case 13:
  593. fsiOPFLD.MedChrgitmType = "01"
  594. break
  595. case 14:
  596. fsiOPFLD.MedChrgitmType = "04"
  597. break
  598. case 15:
  599. fsiOPFLD.MedChrgitmType = "14"
  600. break
  601. }
  602. memo["hosp_appr_flag"] = "1"
  603. memo["invoice_no"] = order.MdtrtId
  604. memo["memo"] = "自费"
  605. bytesData, _ := json.Marshal(memo)
  606. fsiOPFLD.Memo = string(bytesData)
  607. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  608. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  609. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  610. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  611. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  612. fsiOPFLD.BilgDeptName = department.Name
  613. fsiOPFLD.BilgDeptCodg = department.Number
  614. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  615. fsiOPFLD.BilgDrName = doctor.UserName
  616. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  617. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  618. fsiOPFLD.MedChrgitmType = "08"
  619. memo["hosp_appr_flag"] = "1"
  620. memo["invoice_no"] = order.MdtrtId
  621. memo["memo"] = "自费"
  622. bytesData, _ := json.Marshal(memo)
  623. fsiOPFLD.Memo = string(bytesData)
  624. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  625. }
  626. }
  627. }
  628. for _, items := range order_info_two {
  629. memo := make(map[string]interface{})
  630. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  631. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  632. fsiOPFLD.MedType = "14"
  633. fsiOPFLD.BkkpSn = items.FeedetlSn
  634. fsiOPFLD.FixmedinsCode = miConfig.Code
  635. fsiOPFLD.FixmedinsName = miConfig.OrgName
  636. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  637. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  638. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  639. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  640. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  641. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  642. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  643. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  644. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  645. fsiOPFLD.BilgDeptName = department.Name
  646. fsiOPFLD.BilgDeptCodg = department.Number
  647. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  648. fsiOPFLD.BilgDrName = doctor.UserName
  649. fsiOPFLD.MedChrgitmType = "09"
  650. memo["hosp_appr_flag"] = "1"
  651. memo["invoice_no"] = order.MdtrtId
  652. memo["memo"] = "自费"
  653. bytesData, _ := json.Marshal(memo)
  654. fsiOPFLD.Memo = string(bytesData)
  655. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  656. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  657. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  658. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  659. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  660. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  661. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  662. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  663. fsiOPFLD.BilgDeptName = department.Name
  664. fsiOPFLD.BilgDeptCodg = department.Number
  665. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  666. fsiOPFLD.BilgDrName = doctor.UserName
  667. switch items.HisPrescriptionProject.HisProject.CostClassify {
  668. case 0:
  669. break
  670. case 1:
  671. fsiOPFLD.MedChrgitmType = "14"
  672. break
  673. case 2:
  674. fsiOPFLD.MedChrgitmType = "05"
  675. break
  676. case 3:
  677. fsiOPFLD.MedChrgitmType = "03"
  678. break
  679. case 4:
  680. fsiOPFLD.MedChrgitmType = "03"
  681. break
  682. case 5:
  683. fsiOPFLD.MedChrgitmType = "08"
  684. break
  685. case 6:
  686. fsiOPFLD.MedChrgitmType = "14"
  687. break
  688. case 7:
  689. fsiOPFLD.MedChrgitmType = "14"
  690. break
  691. case 8:
  692. fsiOPFLD.MedChrgitmType = "03"
  693. break
  694. case 9:
  695. fsiOPFLD.MedChrgitmType = "14"
  696. break
  697. case 10:
  698. fsiOPFLD.MedChrgitmType = "14"
  699. break
  700. case 11:
  701. fsiOPFLD.MedChrgitmType = "06"
  702. break
  703. case 12:
  704. fsiOPFLD.MedChrgitmType = "12"
  705. break
  706. case 13:
  707. fsiOPFLD.MedChrgitmType = "01"
  708. break
  709. case 14:
  710. fsiOPFLD.MedChrgitmType = "04"
  711. break
  712. case 15:
  713. fsiOPFLD.MedChrgitmType = "14"
  714. break
  715. }
  716. memo["hosp_appr_flag"] = "1"
  717. memo["invoice_no"] = order.MdtrtId
  718. memo["memo"] = "自费"
  719. bytesData, _ := json.Marshal(memo)
  720. fsiOPFLD.Memo = string(bytesData)
  721. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  722. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  723. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  724. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  725. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  726. fsiOPFLD.BilgDeptName = department.Name
  727. fsiOPFLD.BilgDeptCodg = department.Number
  728. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  729. fsiOPFLD.BilgDrName = doctor.UserName
  730. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  731. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  732. fsiOPFLD.MedChrgitmType = "08"
  733. memo["hosp_appr_flag"] = "1"
  734. memo["invoice_no"] = order.MdtrtId
  735. memo["memo"] = "自费"
  736. bytesData, _ := json.Marshal(memo)
  737. fsiOPFLD.Memo = string(bytesData)
  738. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  739. }
  740. }
  741. }
  742. fmt.Println(fsiOPFLDs)
  743. struct4201A.Fopfd = fsiOPFLDs
  744. fmt.Println(struct4201A.Fopfd)
  745. var struct4202 models.Struct4202
  746. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  747. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  748. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  749. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  750. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  751. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  752. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  753. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  754. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  755. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  756. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  757. var config []*models.HisXtDiagnoseConfig
  758. for _, item := range diagnosis_ids {
  759. id, _ := strconv.ParseInt(item, 10, 64)
  760. diagnosisConfig, _ := service.FindDiagnoseById(id)
  761. config = append(config, &diagnosisConfig)
  762. }
  763. var tempDiaginfos []models.OwnPayPatnDiagListD
  764. for index, item := range config {
  765. if index == 0 {
  766. var tempDiaginfo models.OwnPayPatnDiagListD
  767. tempDiaginfo.InoutDiagType = "1"
  768. tempDiaginfo.DiagCode = item.CountryCode
  769. tempDiaginfo.DiagName = item.CountryContentName
  770. tempDiaginfo.DiagType = "1"
  771. tempDiaginfo.DiagSrtNo = "1"
  772. tempDiaginfo.MaindiagFlag = "1"
  773. tempDiaginfo.ValiFlag = "1"
  774. tempDiaginfo.DiagDrName = doctor.UserName
  775. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  776. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  777. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  778. } else {
  779. var tempDiaginfo models.OwnPayPatnDiagListD
  780. tempDiaginfo.DiagCode = item.CountryCode
  781. tempDiaginfo.DiagName = item.CountryContentName
  782. tempDiaginfo.DiagType = "2"
  783. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  784. tempDiaginfo.MaindiagFlag = "0"
  785. tempDiaginfo.ValiFlag = "1"
  786. tempDiaginfo.DiagDrName = doctor.UserName
  787. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  788. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  789. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  790. }
  791. }
  792. struct4202.ODiagListD = tempDiaginfos
  793. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  794. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  795. var res2 ResultSix
  796. var respJSON2 map[string]interface{}
  797. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  800. return
  801. }
  802. userJSONBytes2, _ := json.Marshal(respJSON2)
  803. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  804. utils.ErrorLog("解析失败:%v", err)
  805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  806. return
  807. }
  808. if res2.Infcode != 0 {
  809. c.ServeSuccessJSON(map[string]interface{}{
  810. "failed_code": -10,
  811. "msg": res2.ErrMsg,
  812. })
  813. return
  814. } else {
  815. order.IsUploadDiagnose = 1
  816. order.IsUploadOrderInfo = 1
  817. service.UpdateOrder(order)
  818. c.ServeSuccessJSON(map[string]interface{}{
  819. "msg": "上传成功",
  820. })
  821. }
  822. }
  823. func (c *HisApiController) Get4207() {
  824. admin_user_id, _ := c.GetInt64("admin_user_id")
  825. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  826. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  827. order_id, _ := c.GetInt64("order_id")
  828. order, _ := service.GetHisOrderByIDTwo(order_id)
  829. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  830. var struct4207 models.Struct4207
  831. struct4207.PageNum = "1"
  832. struct4207.PageSize = "1000"
  833. struct4207.FixmedinsCode = miConfig.Code
  834. struct4207.FixmedinsMdtrtID = order.Number
  835. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  836. saveLog(result, requestLog, "4207", "查询")
  837. var res2 ResultSix
  838. var respJSON2 map[string]interface{}
  839. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  842. return
  843. }
  844. userJSONBytes2, _ := json.Marshal(respJSON2)
  845. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  846. utils.ErrorLog("解析失败:%v", err)
  847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  848. return
  849. }
  850. if res2.Infcode != 0 {
  851. c.ServeSuccessJSON(map[string]interface{}{
  852. "failed_code": -10,
  853. "msg": res2.ErrMsg,
  854. })
  855. return
  856. } else {
  857. c.ServeSuccessJSON(map[string]interface{}{
  858. "msg": "查询成功",
  859. })
  860. }
  861. }
  862. func (c *HisApiController) Get4208() {
  863. admin_user_id, _ := c.GetInt64("admin_user_id")
  864. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  865. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  866. order_id, _ := c.GetInt64("order_id")
  867. order, _ := service.GetHisOrderByIDTwo(order_id)
  868. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  869. var struct4208 models.Struct4208
  870. struct4208.PageNum = "1"
  871. struct4208.PageSize = "1000"
  872. struct4208.PsnCertType = "01"
  873. struct4208.Certno = his.Certno
  874. struct4208.MedType = order.MedType
  875. struct4208.PsnName = his.Name
  876. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  877. saveLog(result, requestLog, "4208", "查询")
  878. var res2 ResultSix
  879. var respJSON2 map[string]interface{}
  880. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  883. return
  884. }
  885. userJSONBytes2, _ := json.Marshal(respJSON2)
  886. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  887. utils.ErrorLog("解析失败:%v", err)
  888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  889. return
  890. }
  891. if res2.Infcode != 0 {
  892. c.ServeSuccessJSON(map[string]interface{}{
  893. "failed_code": -10,
  894. "msg": res2.ErrMsg,
  895. })
  896. return
  897. } else {
  898. c.ServeSuccessJSON(map[string]interface{}{
  899. "msg": "查询成功",
  900. })
  901. }
  902. }
  903. func (c *HisApiController) Get4209() {
  904. admin_user_id, _ := c.GetInt64("admin_user_id")
  905. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  906. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  907. order_id, _ := c.GetInt64("order_id")
  908. order, _ := service.GetHisOrderByIDTwo(order_id)
  909. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  910. var struct4209 models.Struct4209
  911. struct4209.FixmedinsMdtrtID = order.Number
  912. struct4209.FixmedinsCode = miConfig.Code
  913. struct4209.PageSize = "1000"
  914. struct4209.PageNum = "1"
  915. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  916. saveLog(result, requestLog, "4209", "查询")
  917. var res2 ResultSix
  918. var respJSON2 map[string]interface{}
  919. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  922. return
  923. }
  924. userJSONBytes2, _ := json.Marshal(respJSON2)
  925. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  926. utils.ErrorLog("解析失败:%v", err)
  927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  928. return
  929. }
  930. if res2.Infcode != 0 {
  931. c.ServeSuccessJSON(map[string]interface{}{
  932. "failed_code": -10,
  933. "msg": res2.ErrMsg,
  934. })
  935. return
  936. } else {
  937. c.ServeSuccessJSON(map[string]interface{}{
  938. "msg": "查询成功",
  939. })
  940. }
  941. }
  942. type Result3101 struct {
  943. Infcode string `json:"infcode"`
  944. InfRefmsgid string `json:"inf_refmsgid"`
  945. RefmsgTime string `json:"refmsg_time"`
  946. RespondTime string `json:"respond_time"`
  947. Enctype string `json:"enctype"`
  948. Signtype string `json:"signtype"`
  949. ErrMsg string `json:"err_msg"`
  950. Output struct {
  951. Result []struct {
  952. JudgeResultDetailDtos []struct {
  953. VolaItemType string `json:"vola_item_type"`
  954. MdtrtID string `json:"mdtrt_id"`
  955. JrdID string `json:"jrd_id"`
  956. PatnID string `json:"patn_id"`
  957. RxID string `json:"rx_id"`
  958. VolaAmt interface{} `json:"vola_amt"`
  959. } `json:"judge_result_detail_dtos"`
  960. RuleID string `json:"rule_id"`
  961. VolaEvid string `json:"vola_evid"`
  962. MdtrtID string `json:"mdtrt_id"`
  963. RuleName string `json:"rule_name"`
  964. VolaAmtStas string `json:"vola_amt_stas"`
  965. JrID string `json:"jr_id"`
  966. PatnID string `json:"patn_id"`
  967. SevDeg string `json:"sev_deg"`
  968. VolaAmt float64 `json:"vola_amt"`
  969. VolaBhvrType string `json:"vola_bhvr_type"`
  970. VolaCont string `json:"vola_cont"`
  971. } `json:"result"`
  972. } `json:"output"`
  973. }
  974. func (c *HisApiController) ReadEleToken() {
  975. admin_user_id, _ := c.GetInt64("admin_user_id")
  976. his_patient_id, _ := c.GetInt64("his_patient_id")
  977. adminUser := c.GetAdminUserInfo()
  978. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  979. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  980. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  981. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  982. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  983. if len(tokens) > 0 {
  984. c.ServeSuccessJSON(map[string]interface{}{
  985. "msg": "读取成功",
  986. })
  987. } else {
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": "读取失败",
  991. })
  992. }
  993. } else if miConfig.MdtrtareaAdmvs == "350500" {
  994. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  995. if len(errMsg) == 0 {
  996. type ELeData struct {
  997. Data struct {
  998. IdNo string `json:"idNo"`
  999. IdType string `json:"idType"`
  1000. UserName string `json:"userName"`
  1001. EcToken string `json:"ecToken"`
  1002. InsuOrg string `json:"insuOrg"`
  1003. Gender string `json:"gender"`
  1004. Birthday string `json:"birthday"`
  1005. Nationality string `json:"nationality"`
  1006. Email string `json:"email"`
  1007. Extra string `json:"extra"`
  1008. } `json:"data"`
  1009. Code int `json:"code"`
  1010. Message string `json:"message"`
  1011. }
  1012. var ele ELeData
  1013. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1014. if err != nil {
  1015. utils.ErrorLog("解析失败:%v", err)
  1016. }
  1017. token := ele.Data.EcToken
  1018. if len(token) > 0 {
  1019. psn := &models.HisPsn{
  1020. PsnNo: his.PsnNo,
  1021. Age: 0,
  1022. PatientId: his.PatientId,
  1023. Certno: his.Certno,
  1024. Brdy: his.Brdy,
  1025. Gend: his.Gend,
  1026. Naty: his.Naty,
  1027. PsnCertType: his.PsnCertType,
  1028. PsnName: his.PsnName,
  1029. Idetinfo: his.Idetinfo,
  1030. Insuinfo: his.Iinfo,
  1031. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1032. CardInfo: outPutInfo,
  1033. VerifyNumber: token,
  1034. }
  1035. service.CreateHisPsn(psn)
  1036. }
  1037. if len(token) > 0 {
  1038. c.ServeSuccessJSON(map[string]interface{}{
  1039. "msg": "读取成功",
  1040. })
  1041. } else {
  1042. c.ServeSuccessJSON(map[string]interface{}{
  1043. "failed_code": -10,
  1044. "msg": "读取失败",
  1045. })
  1046. }
  1047. }
  1048. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1049. if initFlag == 0 {
  1050. c.TestGetJiangXiBasBaseInit()
  1051. }
  1052. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1053. type ELeData struct {
  1054. Data struct {
  1055. IdNo string `json:"idNo"`
  1056. IdType string `json:"idType"`
  1057. UserName string `json:"userName"`
  1058. EcToken string `json:"ecToken"`
  1059. InsuOrg string `json:"insuOrg"`
  1060. Gender string `json:"gender"`
  1061. Birthday string `json:"birthday"`
  1062. Nationality string `json:"nationality"`
  1063. Email string `json:"email"`
  1064. Extra string `json:"extra"`
  1065. } `json:"data"`
  1066. Code int `json:"code"`
  1067. Message string `json:"message"`
  1068. }
  1069. var ele ELeData
  1070. err := json.Unmarshal([]byte(json_result), &ele)
  1071. if err != nil {
  1072. utils.ErrorLog("解析失败:%v", err)
  1073. }
  1074. token := ele.Data.EcToken
  1075. token = Remove0000(token)
  1076. fmt.Println(ele.Data.UserName)
  1077. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  1078. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1079. var res ResultTwo
  1080. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1081. utils.ErrorLog("解析失败:%v", err)
  1082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1083. return
  1084. }
  1085. if res.Infcode == 0 {
  1086. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1087. if err == gorm.ErrRecordNotFound {
  1088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1089. return
  1090. } else if err != nil {
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1092. return
  1093. } else {
  1094. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1095. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1096. infoStr := string(Iinfos)
  1097. idetinfoStr := string(Idetinfos)
  1098. psn := &models.HisPsn{
  1099. PsnNo: res.Output.Baseinfo.PsnNo,
  1100. Age: res.Output.Baseinfo.Age,
  1101. PatientId: patient.ID,
  1102. Certno: res.Output.Baseinfo.Certno,
  1103. Brdy: res.Output.Baseinfo.Brdy,
  1104. Gend: res.Output.Baseinfo.Gend,
  1105. Naty: res.Output.Baseinfo.Naty,
  1106. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1107. PsnName: res.Output.Baseinfo.PsnName,
  1108. Idetinfo: idetinfoStr,
  1109. Insuinfo: infoStr,
  1110. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1111. CardInfo: "",
  1112. VerifyNumber: token,
  1113. }
  1114. service.CreateHisPsn(psn)
  1115. c.ServeSuccessJSON(map[string]interface{}{
  1116. "patient": patient,
  1117. "number": token,
  1118. })
  1119. }
  1120. } else {
  1121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1122. return
  1123. }
  1124. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1125. if initFlag == 0 {
  1126. c.TestGetJiangXiBasBaseInit()
  1127. }
  1128. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1129. type ELeData struct {
  1130. Data struct {
  1131. IdNo string `json:"idNo"`
  1132. IdType string `json:"idType"`
  1133. UserName string `json:"userName"`
  1134. EcToken string `json:"ecToken"`
  1135. InsuOrg string `json:"insuOrg"`
  1136. Gender string `json:"gender"`
  1137. Birthday string `json:"birthday"`
  1138. Nationality string `json:"nationality"`
  1139. Email string `json:"email"`
  1140. Extra string `json:"extra"`
  1141. } `json:"data"`
  1142. Code int `json:"code"`
  1143. Message string `json:"message"`
  1144. }
  1145. var ele ELeData
  1146. err := json.Unmarshal([]byte(json_result), &ele)
  1147. if err != nil {
  1148. utils.ErrorLog("解析失败:%v", err)
  1149. }
  1150. token := ele.Data.EcToken
  1151. token = Remove0000(token)
  1152. fmt.Println(ele.Data.UserName)
  1153. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  1154. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1155. var res ResultTwo
  1156. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1157. utils.ErrorLog("解析失败:%v", err)
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1159. return
  1160. }
  1161. if res.Infcode == 0 {
  1162. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1163. if err == gorm.ErrRecordNotFound {
  1164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1165. return
  1166. } else if err != nil {
  1167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1168. return
  1169. } else {
  1170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1171. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1172. infoStr := string(Iinfos)
  1173. idetinfoStr := string(Idetinfos)
  1174. psn := &models.HisPsn{
  1175. PsnNo: res.Output.Baseinfo.PsnNo,
  1176. Age: res.Output.Baseinfo.Age,
  1177. PatientId: patient.ID,
  1178. Certno: res.Output.Baseinfo.Certno,
  1179. Brdy: res.Output.Baseinfo.Brdy,
  1180. Gend: res.Output.Baseinfo.Gend,
  1181. Naty: res.Output.Baseinfo.Naty,
  1182. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1183. PsnName: res.Output.Baseinfo.PsnName,
  1184. Idetinfo: idetinfoStr,
  1185. Insuinfo: infoStr,
  1186. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1187. CardInfo: "",
  1188. VerifyNumber: token,
  1189. }
  1190. service.CreateHisPsn(psn)
  1191. c.ServeSuccessJSON(map[string]interface{}{
  1192. "patient": patient,
  1193. "number": token,
  1194. })
  1195. }
  1196. } else {
  1197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1198. return
  1199. }
  1200. } else {
  1201. if initFlag == 0 {
  1202. c.TestGetBasBaseInit()
  1203. }
  1204. token := c.GetEleBaseInfo()
  1205. token = Remove0000(token)
  1206. if len(token) > 0 {
  1207. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  1208. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1209. var res ResultTwo
  1210. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1211. utils.ErrorLog("解析失败:%v", err)
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. if res.Infcode == 0 {
  1216. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1217. if err == gorm.ErrRecordNotFound {
  1218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1219. return
  1220. } else if err != nil {
  1221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1222. return
  1223. } else {
  1224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1226. infoStr := string(Iinfos)
  1227. idetinfoStr := string(Idetinfos)
  1228. psn := &models.HisPsn{
  1229. PsnNo: res.Output.Baseinfo.PsnNo,
  1230. Age: res.Output.Baseinfo.Age,
  1231. PatientId: patient.ID,
  1232. Certno: res.Output.Baseinfo.Certno,
  1233. Brdy: res.Output.Baseinfo.Brdy,
  1234. Gend: res.Output.Baseinfo.Gend,
  1235. Naty: res.Output.Baseinfo.Naty,
  1236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1237. PsnName: res.Output.Baseinfo.PsnName,
  1238. Idetinfo: idetinfoStr,
  1239. Insuinfo: infoStr,
  1240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1241. CardInfo: "",
  1242. VerifyNumber: token,
  1243. }
  1244. service.CreateHisPsn(psn)
  1245. c.ServeSuccessJSON(map[string]interface{}{
  1246. "msg": "读取成功",
  1247. })
  1248. }
  1249. } else {
  1250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1251. return
  1252. }
  1253. } else {
  1254. c.ServeSuccessJSON(map[string]interface{}{
  1255. "failed_code": -10,
  1256. "msg": "读取失败",
  1257. })
  1258. }
  1259. }
  1260. }
  1261. func (c *HisApiController) Get9001() {
  1262. adminUser := c.GetAdminUserInfo()
  1263. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1264. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  1265. if miConfig.MdtrtareaAdmvs == "350500" {
  1266. service.GetFjAuthorizationInfo(miConfig.Code)
  1267. } else if miConfig.MdtrtareaAdmvs == "131023" {
  1268. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1269. var dat map[string]interface{}
  1270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1271. fmt.Println(dat)
  1272. } else {
  1273. fmt.Println(err)
  1274. }
  1275. userJSONBytes, _ := json.Marshal(dat)
  1276. var res models.Result9001
  1277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1278. utils.ErrorLog("解析失败:%v", err)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. return
  1281. }
  1282. } else {
  1283. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1284. var dat map[string]interface{}
  1285. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1286. fmt.Println(dat)
  1287. } else {
  1288. fmt.Println(err)
  1289. }
  1290. userJSONBytes, _ := json.Marshal(dat)
  1291. var res models.Result9001
  1292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1293. utils.ErrorLog("解析失败:%v", err)
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1295. return
  1296. }
  1297. }
  1298. }
  1299. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  1300. var res Result3101
  1301. adminUser := c.GetAdminUserInfo()
  1302. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1303. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1304. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1305. //record_time := c.GetString("record_time")
  1306. //trig_scen := c.GetString("trig_scen")
  1307. timeLayout := "2006-01-02"
  1308. loc, _ := time.LoadLocation("Local")
  1309. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1310. if err != nil {
  1311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1312. return res
  1313. }
  1314. recordDateTime := theTime.Unix()
  1315. var patientPrescription models.HisPrescriptionInfo
  1316. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1317. //if patientPrescription.ID == 0 {
  1318. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1319. //}
  1320. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1321. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1322. //
  1323. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1324. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1325. var pp models.PublicParams
  1326. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1327. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1328. pp.FixmedinsName = miConfig.OrgName
  1329. pp.FixmedinsCode = miConfig.Code
  1330. pp.RequestUrl = miConfig.Url
  1331. pp.Cainfo = miConfig.Cainfo
  1332. pp.SecretKey = miConfig.SecretKey
  1333. pp.AccessKey = miConfig.AccessKey
  1334. pp.OpterName = roles.UserName
  1335. var config []*models.HisXtDiagnoseConfig
  1336. for _, item := range diagnosis_ids {
  1337. id, _ := strconv.ParseInt(item, 10, 64)
  1338. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1339. config = append(config, &diagnosisConfig)
  1340. }
  1341. var pd models.PatientDtos
  1342. pd.PatnID = his.PsnNo
  1343. pd.PatnName = his.Name
  1344. pd.Gend = his.Gend
  1345. pd.Brdy = his.Brdy
  1346. pd.Poolarea = miConfig.MdtrtareaAdmvs
  1347. pd.CurrMdtrtID = his.Number
  1348. var fed models.FsiEncounterDtos
  1349. fed.MdtrtID = his.Number
  1350. fed.MedinsID = miConfig.Code
  1351. fed.MedinsName = miConfig.OrgName
  1352. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1353. fed.MedMdtrtType = "1"
  1354. fed.MedinsType = "1"
  1355. fed.MedinsLv = "11"
  1356. tm := time.Unix(his.RecordDate, 0)
  1357. s_tm := tm.Format("2006-01-02 15:04:05")
  1358. fed.AdmDate = s_tm
  1359. fed.DscgDate = s_tm
  1360. fed.DscgMainDiseCodg = config[0].CountryCode
  1361. fed.DscgMainDiseName = config[0].CountryContentName
  1362. //诊断信息
  1363. var fdds []*models.FsiDiagnoseDtos
  1364. for index, item := range config {
  1365. if index == 0 {
  1366. var fdd models.FsiDiagnoseDtos
  1367. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1368. fdd.InoutDiseType = "1"
  1369. fdd.MaindiseFlag = "1"
  1370. fdd.DiseDate = s_tm
  1371. fdd.DiasSrtNo = "1"
  1372. fdd.DiseName = item.CountryContentName
  1373. fdd.DiseCodg = item.CountryCode
  1374. fdds = append(fdds, &fdd)
  1375. } else {
  1376. var fdd models.FsiDiagnoseDtos
  1377. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1378. fdd.InoutDiseType = "1"
  1379. fdd.MaindiseFlag = "1"
  1380. fdd.DiseDate = s_tm
  1381. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1382. fdd.DiseName = item.CountryContentName
  1383. fdd.DiseCodg = item.CountryCode
  1384. fdds = append(fdds, &fdd)
  1385. }
  1386. }
  1387. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1388. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1389. fed.AdmDeptName = department.Name
  1390. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1391. fed.DscgDeptName = department.Name
  1392. fed.MedMdtrtType = "1"
  1393. fed.MedType = "11"
  1394. //if his.Insutype == "390" {
  1395. // fed.MedType = "1402"
  1396. //} else {
  1397. // fed.MedType = "9933"
  1398. //}
  1399. var orders []*models.FsiOrderDtos
  1400. if trig_scen == "2" {
  1401. //处方医嘱信息
  1402. for _, item := range prescriptions {
  1403. for _, subItem := range item.HisDoctorAdviceInfo {
  1404. var order models.FsiOrderDtos
  1405. order.RxID = strconv.FormatInt(item.ID, 10)
  1406. order.Rxno = strconv.FormatInt(item.ID, 10)
  1407. order.LongDrordFlag = "0"
  1408. order.HilistType = "1"
  1409. order.ChrgType = "1"
  1410. order.DrordBhvr = "-"
  1411. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1412. order.HosplistName = subItem.BaseDrugLib.DrugName
  1413. order.HilistLv = "1"
  1414. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1415. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1416. order.HosplistName = subItem.BaseDrugLib.DrugName
  1417. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1418. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1419. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1420. order.OwnpayAmt = ""
  1421. order.SelfpayAmt = ""
  1422. order.Spec = ""
  1423. order.SpecUnt = ""
  1424. order.DrordBegnDate = s_tm
  1425. order.DrordStopDate = ""
  1426. order.DrordDrCodg = "1"
  1427. order.DrordDeptName = department.Name
  1428. order.DrordDrCodg = "1"
  1429. order.DrordDrName = doctor_info.UserName
  1430. order.DrordDrProfttl = ""
  1431. order.CurrDrordFlag = "1"
  1432. orders = append(orders, &order)
  1433. }
  1434. for _, subItem := range item.HisPrescriptionProject {
  1435. if subItem.Type == 2 {
  1436. var order models.FsiOrderDtos
  1437. order.RxID = strconv.FormatInt(item.ID, 10)
  1438. order.Rxno = strconv.FormatInt(item.ID, 10)
  1439. order.LongDrordFlag = "0"
  1440. order.HilistType = "1"
  1441. order.ChrgType = "1"
  1442. order.DrordBhvr = "-"
  1443. order.HilistCode = subItem.HisProject.MedicalCode
  1444. order.HosplistName = subItem.HisProject.ProjectName
  1445. order.HilistLv = "1"
  1446. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1447. order.HosplistCode = subItem.HisProject.MedicalCode
  1448. order.HosplistName = subItem.HisProject.ProjectName
  1449. order.Cnt = subItem.Count
  1450. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1451. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1452. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1453. order.OwnpayAmt = ""
  1454. order.SelfpayAmt = ""
  1455. order.Spec = ""
  1456. order.SpecUnt = ""
  1457. order.DrordBegnDate = s_tm
  1458. order.DrordStopDate = ""
  1459. order.DrordDrCodg = "1"
  1460. order.DrordDeptName = department.Name
  1461. order.DrordDrCodg = "1"
  1462. order.DrordDrName = doctor_info.UserName
  1463. order.DrordDrProfttl = ""
  1464. order.CurrDrordFlag = "1"
  1465. orders = append(orders, &order)
  1466. }
  1467. if subItem.Type == 3 {
  1468. var order models.FsiOrderDtos
  1469. order.RxID = strconv.FormatInt(item.ID, 10)
  1470. order.Rxno = strconv.FormatInt(item.ID, 10)
  1471. order.LongDrordFlag = "0"
  1472. order.HilistType = "1"
  1473. order.ChrgType = "1"
  1474. order.DrordBhvr = "-"
  1475. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1476. order.HosplistName = subItem.GoodInfo.GoodName
  1477. order.HilistLv = "1"
  1478. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1479. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1480. order.HosplistName = subItem.GoodInfo.GoodName
  1481. order.Cnt = subItem.Count
  1482. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1483. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1484. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1485. order.OwnpayAmt = ""
  1486. order.SelfpayAmt = ""
  1487. order.Spec = ""
  1488. order.SpecUnt = ""
  1489. order.DrordBegnDate = s_tm
  1490. order.DrordStopDate = ""
  1491. order.DrordDrCodg = "1"
  1492. order.DrordDeptName = department.Name
  1493. order.DrordDrCodg = "1"
  1494. order.DrordDrName = doctor_info.UserName
  1495. order.DrordDrProfttl = ""
  1496. order.CurrDrordFlag = "1"
  1497. orders = append(orders, &order)
  1498. }
  1499. }
  1500. }
  1501. //处方医嘱信息
  1502. }
  1503. fed.MatnStas = "0"
  1504. fed.MedfeeSumamt = "0"
  1505. fed.OwnpayAmt = "0"
  1506. fed.SelfpayAmt = "0"
  1507. fed.AcctPayamt = "0"
  1508. fed.MaAmt = "0"
  1509. fed.HifpPayamt = "0"
  1510. fed.SetlTotlnum = "1"
  1511. fed.Insutype = his.Insutype
  1512. fed.ReimFlag = "0"
  1513. fed.OutSetlFlag = "0"
  1514. var fopd []*models.FsiOperationDtosData
  1515. data := make(map[string]interface{})
  1516. data["fed"] = fed
  1517. data["fdd"] = fdds
  1518. data["fod"] = orders
  1519. data["pd"] = pd
  1520. data["pp"] = pp
  1521. data["fopd"] = fopd
  1522. data["trig_scen"] = trig_scen
  1523. fmt.Println(data)
  1524. fmt.Println(fed)
  1525. fmt.Println(fdds)
  1526. fmt.Println(orders)
  1527. fmt.Println(pd)
  1528. fmt.Println(pp)
  1529. fmt.Println(fopd)
  1530. client := &http.Client{}
  1531. bytesData, _ := json.Marshal(data)
  1532. var req *http.Request
  1533. if miConfig.MdtrtareaAdmvs == "320921" {
  1534. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1535. } else {
  1536. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1537. }
  1538. resp, _ := client.Do(req)
  1539. defer resp.Body.Close()
  1540. body, ioErr := ioutil.ReadAll(resp.Body)
  1541. if ioErr != nil {
  1542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1544. return res
  1545. }
  1546. var respJSON map[string]interface{}
  1547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1550. return res
  1551. }
  1552. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1553. fmt.Println(respJSON)
  1554. result, _ := json.Marshal(respJSON)
  1555. fmt.Println(result)
  1556. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1557. utils.ErrorLog("解析失败:%v", err)
  1558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1559. return res
  1560. }
  1561. return res
  1562. }
  1563. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  1564. adminUser := c.GetAdminUserInfo()
  1565. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1566. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1567. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1568. //record_time := c.GetString("record_time")
  1569. //trig_scen := c.GetString("trig_scen")
  1570. timeLayout := "2006-01-02"
  1571. loc, _ := time.LoadLocation("Local")
  1572. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1573. if err != nil {
  1574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1575. return res
  1576. }
  1577. recordDateTime := theTime.Unix()
  1578. var patientPrescription models.HisPrescriptionInfo
  1579. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1580. if patientPrescription.ID == 0 {
  1581. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1582. }
  1583. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1584. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1585. //
  1586. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1587. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1588. var pp models.PublicParams
  1589. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1590. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1591. pp.FixmedinsName = miConfig.OrgName
  1592. pp.FixmedinsCode = miConfig.Code
  1593. pp.RequestUrl = miConfig.Url
  1594. pp.Cainfo = miConfig.Cainfo
  1595. pp.SecretKey = miConfig.SecretKey
  1596. pp.AccessKey = miConfig.AccessKey
  1597. pp.OpterName = roles.UserName
  1598. var config []*models.HisXtDiagnoseConfig
  1599. for _, item := range diagnosis_ids {
  1600. id, _ := strconv.ParseInt(item, 10, 64)
  1601. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1602. config = append(config, &diagnosisConfig)
  1603. }
  1604. var pd models.PatientDtos
  1605. pd.PatnID = his.PsnNo
  1606. pd.PatnName = his.Name
  1607. pd.Gend = his.Gend
  1608. pd.Brdy = his.Brdy
  1609. pd.Poolarea = his.InsuplcAdmdvs
  1610. pd.CurrMdtrtID = his.Number
  1611. var fed models.FsiEncounterDtos
  1612. fed.MdtrtID = his.Number
  1613. fed.MedinsID = miConfig.Code
  1614. fed.MedinsName = miConfig.OrgName
  1615. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1616. fed.MedMdtrtType = "1"
  1617. fed.MedinsType = "1"
  1618. fed.MedinsLv = "11"
  1619. tm := time.Unix(his.RecordDate, 0)
  1620. s_tm := tm.Format("2006-01-02 15:04:05")
  1621. fed.AdmDate = s_tm
  1622. fed.DscgDate = s_tm
  1623. fed.DscgMainDiseCodg = config[0].CountryCode
  1624. fed.DscgMainDiseName = config[0].CountryContentName
  1625. //诊断信息
  1626. var fdds []*models.FsiDiagnoseDtos
  1627. for index, item := range config {
  1628. if index == 0 {
  1629. var fdd models.FsiDiagnoseDtos
  1630. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1631. fdd.InoutDiseType = "1"
  1632. fdd.MaindiseFlag = "1"
  1633. fdd.DiseDate = s_tm
  1634. fdd.DiasSrtNo = "1"
  1635. fdd.DiseName = item.CountryContentName
  1636. fdd.DiseCodg = item.CountryCode
  1637. fdds = append(fdds, &fdd)
  1638. } else {
  1639. var fdd models.FsiDiagnoseDtos
  1640. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1641. fdd.InoutDiseType = "1"
  1642. fdd.MaindiseFlag = "1"
  1643. fdd.DiseDate = s_tm
  1644. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1645. fdd.DiseName = item.CountryContentName
  1646. fdd.DiseCodg = item.CountryCode
  1647. fdds = append(fdds, &fdd)
  1648. }
  1649. }
  1650. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1651. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1652. fed.AdmDeptName = department.Name
  1653. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1654. fed.DscgDeptName = department.Name
  1655. fed.MedMdtrtType = "1"
  1656. fed.MedType = "11"
  1657. //if his.Insutype == "390" {
  1658. // fed.MedType = "1402"
  1659. //} else {
  1660. // fed.MedType = "9933"
  1661. //}
  1662. var orders []*models.FsiOrderDtos
  1663. if trig_scen == "2" {
  1664. //处方医嘱信息
  1665. for _, item := range prescriptions {
  1666. for _, subItem := range item.HisDoctorAdviceInfo {
  1667. var order models.FsiOrderDtos
  1668. order.RxID = strconv.FormatInt(item.ID, 10)
  1669. order.Rxno = strconv.FormatInt(item.ID, 10)
  1670. order.LongDrordFlag = "0"
  1671. order.HilistType = "1"
  1672. order.ChrgType = "1"
  1673. order.DrordBhvr = "-"
  1674. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1675. order.HosplistName = subItem.BaseDrugLib.DrugName
  1676. order.HilistLv = "1"
  1677. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1678. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1679. order.HosplistName = subItem.BaseDrugLib.DrugName
  1680. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1681. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1682. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1683. order.OwnpayAmt = ""
  1684. order.SelfpayAmt = ""
  1685. order.Spec = ""
  1686. order.SpecUnt = ""
  1687. order.DrordBegnDate = s_tm
  1688. order.DrordStopDate = ""
  1689. order.DrordDrCodg = "1"
  1690. order.DrordDeptName = department.Name
  1691. order.DrordDrCodg = "1"
  1692. order.DrordDrName = doctor_info.UserName
  1693. order.DrordDrProfttl = ""
  1694. order.CurrDrordFlag = "1"
  1695. orders = append(orders, &order)
  1696. }
  1697. for _, subItem := range item.HisPrescriptionProject {
  1698. if subItem.Type == 2 {
  1699. var order models.FsiOrderDtos
  1700. order.RxID = strconv.FormatInt(item.ID, 10)
  1701. order.Rxno = strconv.FormatInt(item.ID, 10)
  1702. order.LongDrordFlag = "0"
  1703. order.HilistType = "1"
  1704. order.ChrgType = "1"
  1705. order.DrordBhvr = "-"
  1706. order.HilistCode = subItem.HisProject.MedicalCode
  1707. order.HosplistName = subItem.HisProject.ProjectName
  1708. order.HilistLv = "1"
  1709. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1710. order.HosplistCode = subItem.HisProject.MedicalCode
  1711. order.HosplistName = subItem.HisProject.ProjectName
  1712. order.Cnt = subItem.Count
  1713. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1714. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1715. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1716. order.OwnpayAmt = ""
  1717. order.SelfpayAmt = ""
  1718. order.Spec = ""
  1719. order.SpecUnt = ""
  1720. order.DrordBegnDate = s_tm
  1721. order.DrordStopDate = ""
  1722. order.DrordDrCodg = "1"
  1723. order.DrordDeptName = department.Name
  1724. order.DrordDrCodg = "1"
  1725. order.DrordDrName = doctor_info.UserName
  1726. order.DrordDrProfttl = ""
  1727. order.CurrDrordFlag = "1"
  1728. orders = append(orders, &order)
  1729. }
  1730. if subItem.Type == 3 {
  1731. var order models.FsiOrderDtos
  1732. order.RxID = strconv.FormatInt(item.ID, 10)
  1733. order.Rxno = strconv.FormatInt(item.ID, 10)
  1734. order.LongDrordFlag = "0"
  1735. order.HilistType = "1"
  1736. order.ChrgType = "1"
  1737. order.DrordBhvr = "-"
  1738. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1739. order.HosplistName = subItem.GoodInfo.GoodName
  1740. order.HilistLv = "1"
  1741. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1742. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1743. order.HosplistName = subItem.GoodInfo.GoodName
  1744. order.Cnt = subItem.Count
  1745. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1746. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1747. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1748. order.OwnpayAmt = ""
  1749. order.SelfpayAmt = ""
  1750. order.Spec = ""
  1751. order.SpecUnt = ""
  1752. order.DrordBegnDate = s_tm
  1753. order.DrordStopDate = ""
  1754. order.DrordDrCodg = "1"
  1755. order.DrordDeptName = department.Name
  1756. order.DrordDrCodg = "1"
  1757. order.DrordDrName = doctor_info.UserName
  1758. order.DrordDrProfttl = ""
  1759. order.CurrDrordFlag = "1"
  1760. orders = append(orders, &order)
  1761. }
  1762. }
  1763. }
  1764. //处方医嘱信息
  1765. }
  1766. fed.MatnStas = "0"
  1767. fed.MedfeeSumamt = "0"
  1768. fed.OwnpayAmt = "0"
  1769. fed.SelfpayAmt = "0"
  1770. fed.AcctPayamt = "0"
  1771. fed.MaAmt = "0"
  1772. fed.HifpPayamt = "0"
  1773. fed.SetlTotlnum = "1"
  1774. fed.Insutype = his.Insutype
  1775. fed.ReimFlag = "0"
  1776. fed.OutSetlFlag = "0"
  1777. var fopd []*models.FsiOperationDtosData
  1778. data := make(map[string]interface{})
  1779. data["fed"] = fed
  1780. data["fdd"] = fdds
  1781. data["fod"] = orders
  1782. data["pd"] = pd
  1783. data["pp"] = pp
  1784. data["fopd"] = fopd
  1785. data["trig_scen"] = trig_scen
  1786. fmt.Println(data)
  1787. fmt.Println(fed)
  1788. fmt.Println(fdds)
  1789. fmt.Println(orders)
  1790. fmt.Println(pd)
  1791. fmt.Println(pp)
  1792. fmt.Println(fopd)
  1793. client := &http.Client{}
  1794. bytesData, _ := json.Marshal(data)
  1795. var req *http.Request
  1796. if miConfig.MdtrtareaAdmvs == "320921" {
  1797. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1798. } else {
  1799. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1800. }
  1801. resp, _ := client.Do(req)
  1802. defer resp.Body.Close()
  1803. body, ioErr := ioutil.ReadAll(resp.Body)
  1804. if ioErr != nil {
  1805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1807. return res
  1808. }
  1809. var respJSON map[string]interface{}
  1810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1813. return res
  1814. }
  1815. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1816. result, _ := json.Marshal(respJSON)
  1817. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1818. utils.ErrorLog("解析失败:%v", err)
  1819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1820. return res
  1821. }
  1822. return res
  1823. }
  1824. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1825. ////patient_id, _ := c.GetInt64("patient_id")
  1826. //order_id, _ := c.GetInt64("order_id")
  1827. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1828. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1829. //trig_scen := c.GetString("trig_scen")
  1830. adminUser := c.GetAdminUserInfo()
  1831. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1832. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1833. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1834. record_time := c.GetString("record_time")
  1835. order, _ := service.GetHisOrderByID(order_id)
  1836. timeLayout := "2006-01-02"
  1837. loc, _ := time.LoadLocation("Local")
  1838. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1839. if err != nil {
  1840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1841. return
  1842. }
  1843. recordDateTime := theTime.Unix()
  1844. var patientPrescription models.HisPrescriptionInfo
  1845. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1846. if patientPrescription.ID == 0 {
  1847. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1848. }
  1849. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1850. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1851. //
  1852. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1853. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1854. var pp models.PublicParams
  1855. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1856. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1857. pp.FixmedinsName = miConfig.OrgName
  1858. pp.FixmedinsCode = miConfig.Code
  1859. pp.RequestUrl = miConfig.Url
  1860. pp.Cainfo = miConfig.Cainfo
  1861. pp.SecretKey = miConfig.SecretKey
  1862. pp.AccessKey = miConfig.AccessKey
  1863. pp.OpterName = roles.UserName
  1864. var config []*models.HisXtDiagnoseConfig
  1865. for _, item := range diagnosis_ids {
  1866. id, _ := strconv.ParseInt(item, 10, 64)
  1867. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1868. config = append(config, &diagnosisConfig)
  1869. }
  1870. var pd models.PatientDtos
  1871. pd.PatnID = his.PsnNo
  1872. pd.PatnName = his.Name
  1873. pd.Gend = his.Gend
  1874. pd.Brdy = his.Brdy
  1875. pd.Poolarea = his.InsuplcAdmdvs
  1876. pd.CurrMdtrtID = his.Number
  1877. var fed models.FsiEncounterDtos
  1878. fed.MdtrtID = his.Number
  1879. fed.MedinsID = miConfig.Code
  1880. fed.MedinsName = miConfig.OrgName
  1881. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1882. fed.MedMdtrtType = "1"
  1883. fed.MedinsType = "1"
  1884. fed.MedinsLv = "11"
  1885. tm := time.Unix(his.RecordDate, 0)
  1886. s_tm := tm.Format("2006-01-02 15:04:05")
  1887. fed.AdmDate = s_tm
  1888. fed.DscgDate = s_tm
  1889. fed.DscgMainDiseCodg = config[0].CountryCode
  1890. fed.DscgMainDiseName = config[0].CountryContentName
  1891. //诊断信息
  1892. var fdds []*models.FsiDiagnoseDtos
  1893. for index, item := range config {
  1894. if index == 0 {
  1895. var fdd models.FsiDiagnoseDtos
  1896. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1897. fdd.InoutDiseType = "1"
  1898. fdd.MaindiseFlag = "1"
  1899. fdd.DiseDate = s_tm
  1900. fdd.DiasSrtNo = "1"
  1901. fdd.DiseName = item.CountryContentName
  1902. fdd.DiseCodg = item.CountryCode
  1903. fdds = append(fdds, &fdd)
  1904. } else {
  1905. var fdd models.FsiDiagnoseDtos
  1906. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1907. fdd.InoutDiseType = "1"
  1908. fdd.MaindiseFlag = "1"
  1909. fdd.DiseDate = s_tm
  1910. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1911. fdd.DiseName = item.CountryContentName
  1912. fdd.DiseCodg = item.CountryCode
  1913. fdds = append(fdds, &fdd)
  1914. }
  1915. }
  1916. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1917. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1918. fed.AdmDeptName = department.Name
  1919. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1920. fed.DscgDeptName = department.Name
  1921. fed.MedType = order.MedType
  1922. //处方医嘱信息
  1923. var orders []*models.FsiOrderDtos
  1924. //for _, item := range prescriptions {
  1925. // for _, subItem := range item.HisDoctorAdviceInfo {
  1926. // var order models.FsiOrderDtos
  1927. // order.RxID = strconv.FormatInt(item.ID, 10)
  1928. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1929. // order.LongDrordFlag = "0"
  1930. // order.HilistType = "1"
  1931. // order.ChrgType = "1"
  1932. // order.DrordBhvr = "-"
  1933. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1934. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1935. // order.HilistLv = "1"
  1936. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1937. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1938. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1939. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1940. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1941. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1942. // order.OwnpayAmt = ""
  1943. // order.SelfpayAmt = ""
  1944. // order.Spec = ""
  1945. // order.SpecUnt = ""
  1946. // order.DrordBegnDate = s_tm
  1947. // order.DrordStopDate = ""
  1948. // order.DrordDrCodg = "1"
  1949. // order.DrordDeptName = department.Name
  1950. // order.DrordDrCodg = "1"
  1951. // order.DrordDrName = doctor_info.UserName
  1952. // order.DrordDrProfttl = ""
  1953. // order.CurrDrordFlag = "1"
  1954. // orders = append(orders, &order)
  1955. // }
  1956. // for _, subItem := range item.HisPrescriptionProject {
  1957. // if subItem.Type == 2 {
  1958. // var order models.FsiOrderDtos
  1959. // order.RxID = strconv.FormatInt(item.ID, 10)
  1960. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1961. // order.LongDrordFlag = "0"
  1962. // order.HilistType = "1"
  1963. // order.ChrgType = "1"
  1964. // order.DrordBhvr = "-"
  1965. // order.HilistCode = subItem.HisProject.MedicalCode
  1966. // order.HosplistName = subItem.HisProject.ProjectName
  1967. // order.HilistLv = "1"
  1968. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1969. // order.HosplistCode = subItem.HisProject.MedicalCode
  1970. // order.HosplistName = subItem.HisProject.ProjectName
  1971. // order.Cnt = subItem.Count
  1972. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1973. //
  1974. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1975. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1976. // order.OwnpayAmt = ""
  1977. // order.SelfpayAmt = ""
  1978. // order.Spec = ""
  1979. // order.SpecUnt = ""
  1980. // order.DrordBegnDate = s_tm
  1981. // order.DrordStopDate = ""
  1982. // order.DrordDrCodg = "1"
  1983. // order.DrordDeptName = department.Name
  1984. // order.DrordDrCodg = "1"
  1985. // order.DrordDrName = doctor_info.UserName
  1986. // order.DrordDrProfttl = ""
  1987. // order.CurrDrordFlag = "1"
  1988. // orders = append(orders, &order)
  1989. //
  1990. // }
  1991. // if subItem.Type == 3 {
  1992. //
  1993. // var order models.FsiOrderDtos
  1994. // order.RxID = strconv.FormatInt(item.ID, 10)
  1995. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1996. // order.LongDrordFlag = "0"
  1997. // order.HilistType = "1"
  1998. // order.ChrgType = "1"
  1999. // order.DrordBhvr = "-"
  2000. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2001. // order.HosplistName = subItem.GoodInfo.GoodName
  2002. // order.HilistLv = "1"
  2003. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2004. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2005. // order.HosplistName = subItem.GoodInfo.GoodName
  2006. // order.Cnt = subItem.Count
  2007. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2008. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2009. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2010. // order.OwnpayAmt = ""
  2011. // order.SelfpayAmt = ""
  2012. // order.Spec = ""
  2013. // order.SpecUnt = ""
  2014. // order.DrordBegnDate = s_tm
  2015. // order.DrordStopDate = ""
  2016. // order.DrordDrCodg = "1"
  2017. // order.DrordDeptName = department.Name
  2018. // order.DrordDrCodg = "1"
  2019. // order.DrordDrName = doctor_info.UserName
  2020. // order.DrordDrProfttl = ""
  2021. // order.CurrDrordFlag = "1"
  2022. // orders = append(orders, &order)
  2023. //
  2024. // }
  2025. // }
  2026. //}
  2027. for _, item := range prescriptions {
  2028. for _, subItem := range item.HisDoctorAdviceInfo {
  2029. var order models.FsiOrderDtos
  2030. order.RxID = strconv.FormatInt(item.ID, 10)
  2031. order.Rxno = strconv.FormatInt(item.ID, 10)
  2032. order.LongDrordFlag = "0"
  2033. order.HilistType = "1"
  2034. order.ChrgType = "1"
  2035. order.DrordBhvr = "-"
  2036. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2037. order.HosplistName = subItem.BaseDrugLib.DrugName
  2038. order.HilistLv = "1"
  2039. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2040. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2041. order.HosplistName = subItem.BaseDrugLib.DrugName
  2042. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2043. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2044. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2045. order.OwnpayAmt = ""
  2046. order.SelfpayAmt = ""
  2047. order.Spec = ""
  2048. order.SpecUnt = ""
  2049. order.DrordBegnDate = s_tm
  2050. order.DrordStopDate = ""
  2051. order.DrordDrCodg = "1"
  2052. order.DrordDeptName = department.Name
  2053. order.DrordDrCodg = "1"
  2054. order.DrordDrName = doctor_info.UserName
  2055. order.DrordDrProfttl = ""
  2056. order.CurrDrordFlag = "1"
  2057. orders = append(orders, &order)
  2058. }
  2059. for _, subItem := range item.HisPrescriptionProject {
  2060. if subItem.Type == 2 {
  2061. var order models.FsiOrderDtos
  2062. order.RxID = strconv.FormatInt(item.ID, 10)
  2063. order.Rxno = strconv.FormatInt(item.ID, 10)
  2064. order.LongDrordFlag = "0"
  2065. order.HilistType = "1"
  2066. order.ChrgType = "1"
  2067. order.DrordBhvr = "-"
  2068. order.HilistCode = subItem.HisProject.MedicalCode
  2069. order.HosplistName = subItem.HisProject.ProjectName
  2070. order.HilistLv = "1"
  2071. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2072. order.HosplistCode = subItem.HisProject.MedicalCode
  2073. order.HosplistName = subItem.HisProject.ProjectName
  2074. order.Cnt = subItem.Count
  2075. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2076. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2077. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2078. order.OwnpayAmt = ""
  2079. order.SelfpayAmt = ""
  2080. order.Spec = ""
  2081. order.SpecUnt = ""
  2082. order.DrordBegnDate = s_tm
  2083. order.DrordStopDate = ""
  2084. order.DrordDrCodg = "1"
  2085. order.DrordDeptName = department.Name
  2086. order.DrordDrCodg = "1"
  2087. order.DrordDrName = doctor_info.UserName
  2088. order.DrordDrProfttl = ""
  2089. order.CurrDrordFlag = "1"
  2090. orders = append(orders, &order)
  2091. }
  2092. if subItem.Type == 3 {
  2093. var order models.FsiOrderDtos
  2094. order.RxID = strconv.FormatInt(item.ID, 10)
  2095. order.Rxno = strconv.FormatInt(item.ID, 10)
  2096. order.LongDrordFlag = "0"
  2097. order.HilistType = "1"
  2098. order.ChrgType = "1"
  2099. order.DrordBhvr = "-"
  2100. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2101. order.HosplistName = subItem.GoodInfo.GoodName
  2102. order.HilistLv = "1"
  2103. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2104. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2105. order.HosplistName = subItem.GoodInfo.GoodName
  2106. order.Cnt = subItem.Count
  2107. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2108. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2109. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2110. order.OwnpayAmt = ""
  2111. order.SelfpayAmt = ""
  2112. order.Spec = ""
  2113. order.SpecUnt = ""
  2114. order.DrordBegnDate = s_tm
  2115. order.DrordStopDate = ""
  2116. order.DrordDrCodg = "1"
  2117. order.DrordDeptName = department.Name
  2118. order.DrordDrCodg = "1"
  2119. order.DrordDrName = doctor_info.UserName
  2120. order.DrordDrProfttl = ""
  2121. order.CurrDrordFlag = "1"
  2122. orders = append(orders, &order)
  2123. }
  2124. }
  2125. }
  2126. //处方医嘱信息
  2127. fed.MatnStas = "0"
  2128. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2129. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  2130. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  2131. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  2132. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  2133. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  2134. fed.SetlTotlnum = "1"
  2135. fed.Insutype = his.Insutype
  2136. fed.ReimFlag = "0"
  2137. fed.OutSetlFlag = "0"
  2138. var fopd []*models.FsiOperationDtosData
  2139. data := make(map[string]interface{})
  2140. data["fed"] = fed
  2141. data["fdd"] = fdds
  2142. data["fod"] = orders
  2143. data["pd"] = pd
  2144. data["pp"] = pp
  2145. data["fopd"] = fopd
  2146. data["trig_scen"] = trig_scen
  2147. client := &http.Client{}
  2148. bytesData, _ := json.Marshal(data)
  2149. var req *http.Request
  2150. if miConfig.MdtrtareaAdmvs == "320921" {
  2151. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2152. } else {
  2153. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2154. }
  2155. resp, _ := client.Do(req)
  2156. defer resp.Body.Close()
  2157. body, ioErr := ioutil.ReadAll(resp.Body)
  2158. if ioErr != nil {
  2159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2161. return res
  2162. }
  2163. var respJSON map[string]interface{}
  2164. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2167. return res
  2168. }
  2169. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2170. result, _ := json.Marshal(respJSON)
  2171. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2172. utils.ErrorLog("解析失败:%v", err)
  2173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2174. return res
  2175. }
  2176. return res
  2177. //手术操作集合
  2178. //手术操作集合
  2179. }
  2180. func (c *HisApiController) Check() {
  2181. psn_no := c.GetString("psn_no")
  2182. in := c.GetString("in")
  2183. mt := c.GetString("mt")
  2184. baseParams := models.BaseParams{
  2185. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  2186. FixmedinsCode: "H15049901371",
  2187. InsuplcAdmdvs: "150499",
  2188. MdtrtareaAdmvs: "150499",
  2189. OrgName: "赤峰费森血液透析中心",
  2190. Doctor: "1111",
  2191. }
  2192. service.Gdyb2001(baseParams, psn_no, in, mt)
  2193. }
  2194. func (c *HisApiController) GetPsnNcdsInfo() {
  2195. admin_user_id, _ := c.GetInt64("admin_user_id")
  2196. patient_id, _ := c.GetInt64("patient_id")
  2197. id, _ := c.GetInt64("id")
  2198. adminUser := c.GetAdminUserInfo()
  2199. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2200. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2201. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  2202. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2203. psn_record, _ := service.GetPsnNCDSRecordById(id)
  2204. //
  2205. //if psn_record.ID == 0 {
  2206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  2207. // return
  2208. //}
  2209. var res Result5301
  2210. var res10265 Result5301For10265
  2211. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2212. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2213. var api string
  2214. if miConfig.MdtrtareaAdmvs == "320921" {
  2215. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  2216. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2217. } else {
  2218. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  2219. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2220. }
  2221. resp, requestErr := http.Get(api)
  2222. if requestErr != nil {
  2223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2224. return
  2225. }
  2226. body, ioErr := ioutil.ReadAll(resp.Body)
  2227. if ioErr != nil {
  2228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2230. return
  2231. }
  2232. var respJSON map[string]interface{}
  2233. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2236. return
  2237. }
  2238. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2239. result, _ := json.Marshal(respJSON)
  2240. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2241. utils.ErrorLog("解析失败:%v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. return
  2244. }
  2245. res.ErrMsg = res10265.ErrMsg
  2246. res.Output = res10265.Output
  2247. res.InfRefmsgid = res10265.InfRefmsgid
  2248. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2249. res.Infcode = infocode
  2250. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2251. p, _ := service.GetHisPatientById(patient_id)
  2252. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2253. var dat map[string]interface{}
  2254. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2255. fmt.Println(dat)
  2256. } else {
  2257. fmt.Println(err)
  2258. }
  2259. userJSONBytes, _ := json.Marshal(dat)
  2260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2261. utils.ErrorLog("解析失败:%v", err)
  2262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2263. return
  2264. }
  2265. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2266. p, _ := service.GetHisPatientById(patient_id)
  2267. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2268. var dat map[string]interface{}
  2269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2270. fmt.Println(dat)
  2271. } else {
  2272. fmt.Println(err)
  2273. }
  2274. userJSONBytes, _ := json.Marshal(dat)
  2275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2276. utils.ErrorLog("解析失败:%v", err)
  2277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2278. return
  2279. }
  2280. } else {
  2281. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2282. var dat map[string]interface{}
  2283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2284. fmt.Println(dat)
  2285. } else {
  2286. fmt.Println(err)
  2287. }
  2288. userJSONBytes, _ := json.Marshal(dat)
  2289. if miConfig.Code == "H15049901371" {
  2290. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  2291. utils.ErrorLog("解析失败:%v", err)
  2292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2293. return
  2294. }
  2295. res.InfRefmsgid = res10265.InfRefmsgid
  2296. res.Output = res10265.Output
  2297. res.ErrMsg = res10265.ErrMsg
  2298. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2299. res.Infcode = infocode
  2300. } else {
  2301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2302. utils.ErrorLog("解析失败:%v", err)
  2303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2304. return
  2305. }
  2306. }
  2307. }
  2308. if res.Infcode == 0 {
  2309. c.ServeSuccessJSON(map[string]interface{}{
  2310. "result": res.Output.Result,
  2311. })
  2312. }
  2313. }
  2314. func (c *HisApiController) CheckInsutype() {
  2315. his_patient_id, _ := c.GetInt64("his_patient_id")
  2316. admin_user_id, _ := c.GetInt64("admin_user_id")
  2317. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2318. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2319. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2320. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2321. var dat map[string]interface{}
  2322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2323. fmt.Println(dat)
  2324. } else {
  2325. fmt.Println(err)
  2326. }
  2327. userJSONBytes, _ := json.Marshal(dat)
  2328. var res Result90100
  2329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2330. utils.ErrorLog("解析失败:%v", err)
  2331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2332. return
  2333. }
  2334. if res.Infcode != 0 {
  2335. c.ServeSuccessJSON(map[string]interface{}{
  2336. "failed_code": -10,
  2337. "msg": res.ErrMsg,
  2338. })
  2339. return
  2340. } else {
  2341. fmt.Println(res)
  2342. }
  2343. }
  2344. func (c *HisApiController) CheckCardPWD() {
  2345. card_pwd := c.GetString("card_pwd")
  2346. his_patient_id, _ := c.GetInt64("his_patient_id")
  2347. admin_user_id, _ := c.GetInt64("admin_user_id")
  2348. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2349. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2350. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2351. psn, _ := service.GetPsnByPatientId(his.PatientId)
  2352. bas := strings.Split(psn.CardInfo, "|")
  2353. basNumber := bas[2]
  2354. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  2355. var dat map[string]interface{}
  2356. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2357. fmt.Println(dat)
  2358. } else {
  2359. fmt.Println(err)
  2360. }
  2361. userJSONBytes, _ := json.Marshal(dat)
  2362. var res Result90991
  2363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2364. utils.ErrorLog("解析失败:%v", err)
  2365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2366. return
  2367. }
  2368. if res.Infcode != 0 {
  2369. c.ServeSuccessJSON(map[string]interface{}{
  2370. "failed_code": -10,
  2371. "msg": res.ErrMsg,
  2372. })
  2373. return
  2374. } else {
  2375. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  2376. var msg string
  2377. switch res.Output.Result.CardStat {
  2378. case "00":
  2379. msg = "未激活"
  2380. break
  2381. case "10":
  2382. msg = "激活"
  2383. break
  2384. case "20":
  2385. msg = "窗口挂失"
  2386. break
  2387. case "21":
  2388. msg = "电话挂失"
  2389. break
  2390. case "22":
  2391. msg = "单位网上申报挂失"
  2392. break
  2393. case "23":
  2394. msg = "保健办挂失"
  2395. break
  2396. case "24":
  2397. msg = "个人网上挂失"
  2398. break
  2399. case "25":
  2400. msg = "网上服务大厅挂失"
  2401. break
  2402. case "30":
  2403. msg = "注销"
  2404. break
  2405. case "40":
  2406. msg = "回收"
  2407. break
  2408. case "99":
  2409. msg = "制卡中(无效卡)"
  2410. break
  2411. }
  2412. c.ServeSuccessJSON(map[string]interface{}{
  2413. "failed_code": -10,
  2414. "msg": msg,
  2415. })
  2416. return
  2417. } else {
  2418. c.ServeSuccessJSON(map[string]interface{}{
  2419. "msg": "校验成功",
  2420. })
  2421. return
  2422. }
  2423. }
  2424. }
  2425. func (c *HisApiController) CheckCardPWDTwo() {
  2426. //card_pwd := c.GetString("card_pwd")
  2427. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2428. admin_user_id, _ := c.GetInt64("admin_user_id")
  2429. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2430. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2431. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  2432. var dat map[string]interface{}
  2433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2434. fmt.Println(dat)
  2435. } else {
  2436. fmt.Println(err)
  2437. }
  2438. userJSONBytes, _ := json.Marshal(dat)
  2439. var res Result90991
  2440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2441. utils.ErrorLog("解析失败:%v", err)
  2442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2443. return
  2444. }
  2445. if res.Infcode != 0 {
  2446. c.ServeSuccessJSON(map[string]interface{}{
  2447. "failed_code": -10,
  2448. "msg": res.ErrMsg,
  2449. })
  2450. return
  2451. } else {
  2452. if res.Output.Result.SscnoCheckStat == "0" {
  2453. var msg string
  2454. switch res.Output.Result.CardStat {
  2455. case "00":
  2456. msg = "未激活"
  2457. break
  2458. case "10":
  2459. msg = "激活"
  2460. break
  2461. case "20":
  2462. msg = "窗口挂失"
  2463. break
  2464. case "21":
  2465. msg = "电话挂失"
  2466. break
  2467. case "22":
  2468. msg = "单位网上申报挂失"
  2469. break
  2470. case "23":
  2471. msg = "保健办挂失"
  2472. break
  2473. case "24":
  2474. msg = "个人网上挂失"
  2475. break
  2476. case "25":
  2477. msg = "网上服务大厅挂失"
  2478. break
  2479. case "30":
  2480. msg = "注销"
  2481. break
  2482. case "40":
  2483. msg = "回收"
  2484. break
  2485. case "99":
  2486. msg = "制卡中(无效卡)"
  2487. break
  2488. }
  2489. c.ServeSuccessJSON(map[string]interface{}{
  2490. "failed_code": -10,
  2491. "msg": msg,
  2492. })
  2493. return
  2494. } else {
  2495. c.ServeSuccessJSON(map[string]interface{}{
  2496. "msg": "校验成功",
  2497. })
  2498. return
  2499. }
  2500. }
  2501. }
  2502. type ELeCertData struct {
  2503. Data struct {
  2504. Extra string `json:"extra"`
  2505. IDNo string `json:"idNo"`
  2506. IDType string `json:"idType"`
  2507. EcToken string `json:"ecToken"`
  2508. InsuOrg string `json:"insuOrg"`
  2509. UserName string `json:"userName"`
  2510. EcIndexNo string `json:"ecIndexNo"`
  2511. Gender string `json:"gender"`
  2512. Birthday string `json:"birthday"`
  2513. Nationality string `json:"nationality"`
  2514. Email string `json:"email"`
  2515. } `json:"OutData"`
  2516. }
  2517. func (c *HisApiController) ReadCard() {
  2518. id_card_type, _ := c.GetInt64("id_card_type")
  2519. admin_user_id, _ := c.GetInt64("admin_user_id")
  2520. certificates, _ := c.GetInt64("certificates")
  2521. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2522. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2523. switch id_card_type {
  2524. case 1:
  2525. if miConfig.MdtrtareaAdmvs == "421300" {
  2526. var res ResultTwo
  2527. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  2528. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2529. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  2530. resp, requestErr := http.Get(api)
  2531. if requestErr != nil {
  2532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. return
  2534. }
  2535. body, ioErr := ioutil.ReadAll(resp.Body)
  2536. if ioErr != nil {
  2537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2539. return
  2540. }
  2541. var respJSON map[string]interface{}
  2542. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2545. return
  2546. }
  2547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2548. result, _ := json.Marshal(respJSON)
  2549. fmt.Println("log")
  2550. fmt.Println(string(result))
  2551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2552. utils.ErrorLog("解析失败:%v", err)
  2553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2554. return
  2555. }
  2556. if res.Infcode == 0 {
  2557. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2558. if err == gorm.ErrRecordNotFound {
  2559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2560. return
  2561. } else if err != nil {
  2562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2563. return
  2564. } else {
  2565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2566. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2567. infoStr := string(Iinfos)
  2568. idetinfoStr := string(Idetinfos)
  2569. psn := &models.HisPsn{
  2570. PsnNo: res.Output.Baseinfo.PsnNo,
  2571. Age: res.Output.Baseinfo.Age,
  2572. PatientId: patient.ID,
  2573. Certno: res.Output.Baseinfo.Certno,
  2574. Brdy: res.Output.Baseinfo.Brdy,
  2575. Gend: res.Output.Baseinfo.Gend,
  2576. Naty: res.Output.Baseinfo.Naty,
  2577. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2578. PsnName: res.Output.Baseinfo.PsnName,
  2579. Idetinfo: idetinfoStr,
  2580. Insuinfo: infoStr,
  2581. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2582. }
  2583. service.CreateHisPsn(psn)
  2584. c.ServeSuccessJSON(map[string]interface{}{
  2585. "patient": patient,
  2586. "number": res.Output.Baseinfo.Certno,
  2587. })
  2588. }
  2589. } else {
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2591. return
  2592. }
  2593. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2594. var api string
  2595. if miConfig.MdtrtareaAdmvs == "320921" {
  2596. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2597. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2598. fmt.Println(api)
  2599. } else {
  2600. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2601. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  2602. }
  2603. resp, requestErr := http.Get(api)
  2604. if requestErr != nil {
  2605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2606. return
  2607. }
  2608. body, ioErr := ioutil.ReadAll(resp.Body)
  2609. if ioErr != nil {
  2610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2612. return
  2613. }
  2614. var respJSON map[string]interface{}
  2615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2618. return
  2619. }
  2620. var status string
  2621. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2622. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2623. //console.log()
  2624. fmt.Println("type===")
  2625. fmt.Println(card_type)
  2626. var token string
  2627. var res ResultTwo //1101结果
  2628. var res10265 ResultTwo10265 //1101结果
  2629. var card_info string //卡信息
  2630. var busi_card_info string
  2631. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2632. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2633. if status == "0" { //读卡成功
  2634. if card_type == "1" {
  2635. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2636. result, _ := json.Marshal(respJSON)
  2637. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2638. utils.ErrorLog("解析失败:%v", err)
  2639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2640. return
  2641. }
  2642. res.ErrMsg = res10265.ErrMsg
  2643. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2644. res.Infcode = infocode
  2645. res.Output = res10265.Output
  2646. res.InfRefmsgid = res10265.InfRefmsgid
  2647. } else {
  2648. //var card_info string //卡信息
  2649. //var busi_card_info string
  2650. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2651. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2652. //fmt.Println(card_info)
  2653. //fmt.Println(busi_card_info)
  2654. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2655. result, _ := json.Marshal(respJSON)
  2656. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2657. utils.ErrorLog("解析失败:%v", err)
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. res.ErrMsg = res10265.ErrMsg
  2662. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2663. res.Infcode = infocode
  2664. res.Output = res10265.Output
  2665. res.InfRefmsgid = res10265.InfRefmsgid
  2666. }
  2667. if res.Infcode == 0 {
  2668. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2669. if err == gorm.ErrRecordNotFound {
  2670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2671. return
  2672. } else if err != nil {
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2674. return
  2675. } else {
  2676. if card_type == "1" {
  2677. bas := strings.Split(card_info, "|")
  2678. basNumber := bas[2]
  2679. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2680. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2681. infoStr := string(Iinfos)
  2682. idetinfoStr := string(Idetinfos)
  2683. psn := &models.HisPsn{
  2684. PsnNo: res.Output.Baseinfo.PsnNo,
  2685. Age: res.Output.Baseinfo.Age,
  2686. PatientId: patient.ID,
  2687. Certno: res.Output.Baseinfo.Certno,
  2688. Brdy: res.Output.Baseinfo.Brdy,
  2689. Gend: res.Output.Baseinfo.Gend,
  2690. Naty: res.Output.Baseinfo.Naty,
  2691. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2692. PsnName: res.Output.Baseinfo.PsnName,
  2693. Idetinfo: idetinfoStr,
  2694. Insuinfo: infoStr,
  2695. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2696. CardInfo: card_info,
  2697. VerifyNumber: busi_card_info,
  2698. }
  2699. service.CreateHisPsn(psn)
  2700. var rf []*ResultFive
  2701. json.Unmarshal([]byte(infoStr), &rf)
  2702. var insutypes []*ResultFive
  2703. var insutype string
  2704. var is390 int = 0
  2705. var is310 int = 0
  2706. for _, item := range rf {
  2707. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2708. insutypes = append(insutypes, item)
  2709. }
  2710. }
  2711. if len(insutypes) == 1 {
  2712. insutype = insutypes[0].Insutype
  2713. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2714. } else {
  2715. for _, i := range insutypes {
  2716. if i.Insutype == "390" {
  2717. is390 = 1
  2718. }
  2719. if i.Insutype == "310" {
  2720. is310 = 1
  2721. }
  2722. }
  2723. }
  2724. if is390 == 1 {
  2725. insutype = "390"
  2726. }
  2727. if is310 == 1 {
  2728. insutype = "310"
  2729. }
  2730. if len(insutypes) == 0 {
  2731. insutype = "310"
  2732. }
  2733. c.ServeSuccessJSON(map[string]interface{}{
  2734. "patient": patient,
  2735. "number": basNumber,
  2736. "insutype": insutype,
  2737. })
  2738. } else {
  2739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2741. infoStr := string(Iinfos)
  2742. idetinfoStr := string(Idetinfos)
  2743. psn := &models.HisPsn{
  2744. PsnNo: res.Output.Baseinfo.PsnNo,
  2745. Age: res.Output.Baseinfo.Age,
  2746. PatientId: patient.ID,
  2747. Certno: res.Output.Baseinfo.Certno,
  2748. Brdy: res.Output.Baseinfo.Brdy,
  2749. Gend: res.Output.Baseinfo.Gend,
  2750. Naty: res.Output.Baseinfo.Naty,
  2751. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2752. PsnName: res.Output.Baseinfo.PsnName,
  2753. Idetinfo: idetinfoStr,
  2754. Insuinfo: infoStr,
  2755. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2756. CardInfo: card_info,
  2757. VerifyNumber: token,
  2758. }
  2759. service.CreateHisPsn(psn)
  2760. c.ServeSuccessJSON(map[string]interface{}{
  2761. "patient": patient,
  2762. "number": token,
  2763. })
  2764. }
  2765. }
  2766. } else {
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2768. return
  2769. }
  2770. } else { //读卡失败
  2771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2772. return
  2773. }
  2774. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2775. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2776. cardnum = DeleteExtraSpaceTwo(cardnum)
  2777. cardCode = DeleteExtraSpaceTwo(cardCode)
  2778. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2779. name = DeleteExtraSpaceTwo(name)
  2780. errmsg = DeleteExtraSpaceTwo(errmsg)
  2781. cardnum = Remove0000(cardnum)
  2782. cardCode = Remove0000(cardCode)
  2783. id_card_no = Remove0000(id_card_no)
  2784. name = Remove0000(name)
  2785. errmsg = Remove0000(errmsg)
  2786. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  2787. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2788. result2, requestLog2, errMsgLog2 := service.FJybidcomfirm(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  2789. fmt.Println(result2)
  2790. fmt.Println(requestLog2)
  2791. fmt.Println(errMsgLog2)
  2792. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  2793. saveLog(result, requestLog, "1101", "获取人员信息")
  2794. fmt.Println(errMsgLog)
  2795. if len(errMsgLog) > 0 {
  2796. } else {
  2797. var dat map[string]interface{}
  2798. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2799. fmt.Println(dat)
  2800. } else {
  2801. fmt.Println(err)
  2802. }
  2803. userJSONBytes, _ := json.Marshal(dat)
  2804. var res ResultTwo
  2805. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2806. utils.ErrorLog("解析失败:%v", err)
  2807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2808. return
  2809. }
  2810. res.ErrMsg = errMsgLog
  2811. if res.Infcode == 0 {
  2812. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2813. if err == gorm.ErrRecordNotFound {
  2814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2815. return
  2816. } else if err != nil {
  2817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2818. return
  2819. } else {
  2820. fmt.Println(res)
  2821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2822. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2823. infoStr := string(Iinfos)
  2824. idetinfoStr := string(Idetinfos)
  2825. psn := &models.HisPsn{
  2826. PsnNo: res.Output.Baseinfo.PsnNo,
  2827. Age: res.Output.Baseinfo.Age,
  2828. PatientId: patient.ID,
  2829. Certno: res.Output.Baseinfo.Certno,
  2830. Brdy: res.Output.Baseinfo.Brdy,
  2831. Gend: res.Output.Baseinfo.Gend,
  2832. Naty: res.Output.Baseinfo.Naty,
  2833. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2834. PsnName: res.Output.Baseinfo.PsnName,
  2835. Idetinfo: idetinfoStr,
  2836. Insuinfo: infoStr,
  2837. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2838. CardInfo: basStr,
  2839. VerifyNumber: "",
  2840. }
  2841. service.CreateHisPsn(psn)
  2842. var rf []*ResultFive
  2843. json.Unmarshal([]byte(infoStr), &rf)
  2844. var insutypes []*ResultFive
  2845. var insutype string
  2846. var is390 int = 0
  2847. var is310 int = 0
  2848. for _, item := range rf {
  2849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2850. insutypes = append(insutypes, item)
  2851. }
  2852. }
  2853. if len(insutypes) == 1 {
  2854. insutype = insutypes[0].Insutype
  2855. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2856. } else {
  2857. for _, i := range insutypes {
  2858. if i.Insutype == "390" {
  2859. is390 = 1
  2860. }
  2861. if i.Insutype == "310" {
  2862. is310 = 1
  2863. }
  2864. }
  2865. }
  2866. if is390 == 1 {
  2867. insutype = "390"
  2868. }
  2869. if is310 == 1 {
  2870. insutype = "310"
  2871. }
  2872. if len(insutypes) == 0 {
  2873. insutype = "390"
  2874. }
  2875. c.ServeSuccessJSON(map[string]interface{}{
  2876. "patient": patient,
  2877. "number": cardnum,
  2878. "insutype": insutype,
  2879. })
  2880. }
  2881. } else {
  2882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2883. return
  2884. }
  2885. }
  2886. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2887. fmt.Println(initFlag)
  2888. fmt.Println("initFlag")
  2889. if initFlag == 0 {
  2890. c.TestGetJiangXiBasBaseInit()
  2891. }
  2892. basStr := c.GetBasBaseInfo()
  2893. if len(basStr) == 0 {
  2894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2895. return
  2896. }
  2897. fmt.Println(basStr)
  2898. bas := strings.Split(basStr, "|")
  2899. basNumber := bas[1]
  2900. fmt.Println(basNumber)
  2901. card_sn := bas[3]
  2902. fmt.Println(card_sn)
  2903. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  2904. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2905. var dat map[string]interface{}
  2906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2907. fmt.Println(dat)
  2908. } else {
  2909. fmt.Println(err)
  2910. }
  2911. userJSONBytes, _ := json.Marshal(dat)
  2912. var res ResultTwo
  2913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2914. utils.ErrorLog("解析失败:%v", err)
  2915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2916. return
  2917. }
  2918. if res.Infcode == 0 {
  2919. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2920. if err == gorm.ErrRecordNotFound {
  2921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2922. return
  2923. } else if err != nil {
  2924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2925. return
  2926. } else {
  2927. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2928. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2929. infoStr := string(Iinfos)
  2930. idetinfoStr := string(Idetinfos)
  2931. psn := &models.HisPsn{
  2932. PsnNo: res.Output.Baseinfo.PsnNo,
  2933. Age: res.Output.Baseinfo.Age,
  2934. PatientId: patient.ID,
  2935. Certno: res.Output.Baseinfo.Certno,
  2936. Brdy: res.Output.Baseinfo.Brdy,
  2937. Gend: res.Output.Baseinfo.Gend,
  2938. Naty: res.Output.Baseinfo.Naty,
  2939. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2940. PsnName: res.Output.Baseinfo.PsnName,
  2941. Idetinfo: idetinfoStr,
  2942. Insuinfo: infoStr,
  2943. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2944. CardInfo: basStr,
  2945. VerifyNumber: "",
  2946. }
  2947. service.CreateHisPsn(psn)
  2948. var rf []*ResultFive
  2949. json.Unmarshal([]byte(infoStr), &rf)
  2950. var insutypes []*ResultFive
  2951. var insutype string
  2952. var is390 int = 0
  2953. var is310 int = 0
  2954. for _, item := range rf {
  2955. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2956. insutypes = append(insutypes, item)
  2957. }
  2958. }
  2959. if len(insutypes) == 1 {
  2960. insutype = insutypes[0].Insutype
  2961. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2962. } else {
  2963. for _, i := range insutypes {
  2964. if i.Insutype == "390" {
  2965. is390 = 1
  2966. }
  2967. if i.Insutype == "310" {
  2968. is310 = 1
  2969. }
  2970. }
  2971. }
  2972. if is390 == 1 {
  2973. insutype = "390"
  2974. }
  2975. if is310 == 1 {
  2976. insutype = "310"
  2977. }
  2978. if len(insutypes) == 0 {
  2979. insutype = "310"
  2980. }
  2981. c.ServeSuccessJSON(map[string]interface{}{
  2982. "patient": patient,
  2983. "number": basNumber,
  2984. "insutype": insutype,
  2985. })
  2986. }
  2987. } else {
  2988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2989. return
  2990. }
  2991. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2992. fmt.Println(initFlag)
  2993. fmt.Println("initFlag")
  2994. if initFlag == 0 {
  2995. c.TestGetHnBasBaseInit()
  2996. }
  2997. basStr := c.GetBasBaseInfo()
  2998. if len(basStr) == 0 {
  2999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3000. return
  3001. }
  3002. fmt.Println(basStr)
  3003. bas := strings.Split(basStr, "|")
  3004. basNumber := bas[1]
  3005. fmt.Println(basNumber)
  3006. card_sn := bas[3]
  3007. card_no := bas[2]
  3008. fmt.Println(card_sn)
  3009. name := bas[4]
  3010. name = ConvertToString(name, "gbk", "utf-8")
  3011. result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
  3012. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3013. var dat map[string]interface{}
  3014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3015. fmt.Println(dat)
  3016. } else {
  3017. fmt.Println(err)
  3018. }
  3019. userJSONBytes, _ := json.Marshal(dat)
  3020. var res ResultTwo
  3021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3022. utils.ErrorLog("解析失败:%v", err)
  3023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3024. return
  3025. }
  3026. if res.Infcode == 0 {
  3027. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3028. if err == gorm.ErrRecordNotFound {
  3029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3030. return
  3031. } else if err != nil {
  3032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3033. return
  3034. } else {
  3035. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3036. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3037. infoStr := string(Iinfos)
  3038. idetinfoStr := string(Idetinfos)
  3039. psn := &models.HisPsn{
  3040. PsnNo: res.Output.Baseinfo.PsnNo,
  3041. Age: res.Output.Baseinfo.Age,
  3042. PatientId: patient.ID,
  3043. Certno: res.Output.Baseinfo.Certno,
  3044. Brdy: res.Output.Baseinfo.Brdy,
  3045. Gend: res.Output.Baseinfo.Gend,
  3046. Naty: res.Output.Baseinfo.Naty,
  3047. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3048. PsnName: res.Output.Baseinfo.PsnName,
  3049. Idetinfo: idetinfoStr,
  3050. Insuinfo: infoStr,
  3051. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3052. CardInfo: basStr,
  3053. VerifyNumber: "",
  3054. }
  3055. service.CreateHisPsn(psn)
  3056. var rf []*ResultFive
  3057. json.Unmarshal([]byte(infoStr), &rf)
  3058. var insutypes []*ResultFive
  3059. var insutype string
  3060. var is390 int = 0
  3061. var is310 int = 0
  3062. for _, item := range rf {
  3063. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3064. insutypes = append(insutypes, item)
  3065. }
  3066. }
  3067. if len(insutypes) == 1 {
  3068. insutype = insutypes[0].Insutype
  3069. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3070. } else {
  3071. for _, i := range insutypes {
  3072. if i.Insutype == "390" {
  3073. is390 = 1
  3074. }
  3075. if i.Insutype == "310" {
  3076. is310 = 1
  3077. }
  3078. }
  3079. }
  3080. if is390 == 1 {
  3081. insutype = "390"
  3082. }
  3083. if is310 == 1 {
  3084. insutype = "310"
  3085. }
  3086. if len(insutypes) == 0 {
  3087. insutype = "310"
  3088. }
  3089. c.ServeSuccessJSON(map[string]interface{}{
  3090. "patient": patient,
  3091. "number": basNumber,
  3092. "insutype": insutype,
  3093. })
  3094. }
  3095. } else {
  3096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3097. return
  3098. }
  3099. } else {
  3100. if initFlag == 0 {
  3101. c.TestGetBasBaseInit()
  3102. }
  3103. basStr := c.GetBasBaseInfo()
  3104. if len(basStr) == 0 {
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3106. return
  3107. }
  3108. fmt.Println(basStr)
  3109. bas := strings.Split(basStr, "|")
  3110. basNumber := bas[1]
  3111. fmt.Println(basNumber)
  3112. card_sn := bas[3]
  3113. fmt.Println(card_sn)
  3114. cardNumber := bas[2]
  3115. fmt.Println(cardNumber)
  3116. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  3117. result := service.Gdyb1101f(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  3118. var dat map[string]interface{}
  3119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3120. fmt.Println(dat)
  3121. } else {
  3122. fmt.Println(err)
  3123. }
  3124. userJSONBytes, _ := json.Marshal(dat)
  3125. var res ResultTwo
  3126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3127. utils.ErrorLog("解析失败:%v", err)
  3128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3129. return
  3130. }
  3131. if res.Infcode == 0 {
  3132. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3133. if err == gorm.ErrRecordNotFound {
  3134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3135. return
  3136. } else if err != nil {
  3137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3138. return
  3139. } else {
  3140. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3141. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3142. infoStr := string(Iinfos)
  3143. idetinfoStr := string(Idetinfos)
  3144. var rf []*ResultFive
  3145. json.Unmarshal([]byte(infoStr), &rf)
  3146. var insutypes []*ResultFive
  3147. var insutype string
  3148. var is390 int = 0
  3149. var is310 int = 0
  3150. var insuplc_admdvs string
  3151. for _, item := range rf {
  3152. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3153. insutypes = append(insutypes, item)
  3154. }
  3155. }
  3156. if len(insutypes) == 1 {
  3157. insutype = insutypes[0].Insutype
  3158. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3159. } else {
  3160. for _, i := range insutypes {
  3161. if i.Insutype == "390" {
  3162. is390 = 1
  3163. }
  3164. if i.Insutype == "310" {
  3165. is310 = 1
  3166. }
  3167. }
  3168. }
  3169. if is390 == 1 {
  3170. insutype = "390"
  3171. }
  3172. if is310 == 1 {
  3173. insutype = "310"
  3174. }
  3175. if len(insutypes) == 0 {
  3176. insutype = "310"
  3177. }
  3178. for _, item := range rf {
  3179. if item.Insutype == insutype {
  3180. insuplc_admdvs = item.InsuplcAdmdvs
  3181. }
  3182. }
  3183. psn := &models.HisPsn{
  3184. PsnNo: res.Output.Baseinfo.PsnNo,
  3185. Age: res.Output.Baseinfo.Age,
  3186. PatientId: patient.ID,
  3187. Certno: res.Output.Baseinfo.Certno,
  3188. Brdy: res.Output.Baseinfo.Brdy,
  3189. Gend: res.Output.Baseinfo.Gend,
  3190. Naty: res.Output.Baseinfo.Naty,
  3191. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3192. PsnName: res.Output.Baseinfo.PsnName,
  3193. Idetinfo: idetinfoStr,
  3194. Insuinfo: infoStr,
  3195. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3196. CardInfo: basStr,
  3197. VerifyNumber: "",
  3198. InsuplcAdmdvs: insuplc_admdvs,
  3199. }
  3200. service.CreateHisPsn(psn)
  3201. c.ServeSuccessJSON(map[string]interface{}{
  3202. "patient": patient,
  3203. "number": basNumber,
  3204. })
  3205. }
  3206. } else {
  3207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3208. return
  3209. }
  3210. break
  3211. }
  3212. case 2:
  3213. if miConfig.MdtrtareaAdmvs == "430800" {
  3214. if initFlag == 0 {
  3215. c.TestGetHnBasBaseInit()
  3216. }
  3217. SFZStr := c.GetSFZBaseInfo()
  3218. if len(SFZStr) == 0 {
  3219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3220. return
  3221. }
  3222. fmt.Println(SFZStr)
  3223. id_card_str := strings.Split(SFZStr, "^")
  3224. card_no := id_card_str[0]
  3225. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3226. //name := id_card_str[1]
  3227. //name = ConvertToString(name, "gbk", "utf-8")
  3228. result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", patient.Name, card_no)
  3229. var dat map[string]interface{}
  3230. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3231. fmt.Println(dat)
  3232. } else {
  3233. fmt.Println(err)
  3234. }
  3235. userJSONBytes, _ := json.Marshal(dat)
  3236. var res ResultTwo
  3237. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3238. utils.ErrorLog("解析失败:%v", err)
  3239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3240. return
  3241. }
  3242. if res.Infcode == 0 {
  3243. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3244. if err == gorm.ErrRecordNotFound {
  3245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3246. return
  3247. } else if err != nil {
  3248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3249. return
  3250. } else {
  3251. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3252. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3253. infoStr := string(Iinfos)
  3254. idetinfoStr := string(Idetinfos)
  3255. psn := &models.HisPsn{
  3256. PsnNo: res.Output.Baseinfo.PsnNo,
  3257. Age: res.Output.Baseinfo.Age,
  3258. PatientId: patient.ID,
  3259. Certno: res.Output.Baseinfo.Certno,
  3260. Brdy: res.Output.Baseinfo.Brdy,
  3261. Gend: res.Output.Baseinfo.Gend,
  3262. Naty: res.Output.Baseinfo.Naty,
  3263. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3264. PsnName: res.Output.Baseinfo.PsnName,
  3265. Idetinfo: idetinfoStr,
  3266. Insuinfo: infoStr,
  3267. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3268. CardInfo: SFZStr,
  3269. VerifyNumber: "",
  3270. }
  3271. service.CreateHisPsn(psn)
  3272. var rf []*ResultFive
  3273. json.Unmarshal([]byte(infoStr), &rf)
  3274. var insutypes []*ResultFive
  3275. var insutype string
  3276. var is390 int = 0
  3277. var is310 int = 0
  3278. for _, item := range rf {
  3279. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3280. insutypes = append(insutypes, item)
  3281. }
  3282. }
  3283. if len(insutypes) == 1 {
  3284. insutype = insutypes[0].Insutype
  3285. } else {
  3286. for _, i := range insutypes {
  3287. if i.Insutype == "390" {
  3288. is390 = 1
  3289. }
  3290. if i.Insutype == "310" {
  3291. is310 = 1
  3292. }
  3293. }
  3294. }
  3295. if is390 == 1 {
  3296. insutype = "390"
  3297. }
  3298. if is310 == 1 {
  3299. insutype = "310"
  3300. }
  3301. if len(insutypes) == 0 {
  3302. insutype = "310"
  3303. }
  3304. c.ServeSuccessJSON(map[string]interface{}{
  3305. "patient": patient,
  3306. "number": card_no,
  3307. "insutype": insutype,
  3308. })
  3309. }
  3310. } else {
  3311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3312. return
  3313. }
  3314. } else {
  3315. SFZStr := c.GetSFZBaseInfo()
  3316. id_card_str := strings.Split(SFZStr, "^")
  3317. id_card_number := id_card_str[0]
  3318. card_sn := ""
  3319. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  3320. var dat map[string]interface{}
  3321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3322. fmt.Println(dat)
  3323. } else {
  3324. fmt.Println(err)
  3325. }
  3326. userJSONBytes, _ := json.Marshal(dat)
  3327. var res ResultTwo
  3328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3329. utils.ErrorLog("解析失败:%v", err)
  3330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3331. return
  3332. }
  3333. if res.Infcode == 0 {
  3334. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  3335. if err == gorm.ErrRecordNotFound {
  3336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3337. return
  3338. } else if err != nil {
  3339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3340. return
  3341. } else {
  3342. c.ServeSuccessJSON(map[string]interface{}{
  3343. "patient": patient,
  3344. "number": id_card_number,
  3345. })
  3346. }
  3347. } else {
  3348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3349. return
  3350. }
  3351. }
  3352. break
  3353. case 3:
  3354. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3355. var api string
  3356. if miConfig.MdtrtareaAdmvs == "320921" {
  3357. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3358. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  3359. fmt.Println(api)
  3360. } else {
  3361. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3362. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  3363. }
  3364. resp, requestErr := http.Get(api)
  3365. if requestErr != nil {
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. body, ioErr := ioutil.ReadAll(resp.Body)
  3370. if ioErr != nil {
  3371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. var respJSON map[string]interface{}
  3376. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3379. return
  3380. }
  3381. var status string
  3382. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3383. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3384. var token string
  3385. var res ResultTwo //1101结果
  3386. var res10265 ResultTwo10265 //1101结果
  3387. var card_info string //卡信息
  3388. var busi_card_info string
  3389. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3390. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3391. if status == "0" { //读卡成功
  3392. if card_type == "1" {
  3393. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3394. result, _ := json.Marshal(respJSON)
  3395. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3396. utils.ErrorLog("解析失败:%v", err)
  3397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3398. return
  3399. }
  3400. res.ErrMsg = res10265.ErrMsg
  3401. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3402. res.Infcode = infocode
  3403. res.Output = res10265.Output
  3404. res.InfRefmsgid = res10265.InfRefmsgid
  3405. } else {
  3406. //var card_info string //卡信息
  3407. //var busi_card_info string
  3408. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3409. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3410. //fmt.Println(card_info)
  3411. //fmt.Println(busi_card_info)
  3412. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3413. result, _ := json.Marshal(respJSON)
  3414. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3415. utils.ErrorLog("解析失败:%v", err)
  3416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3417. return
  3418. }
  3419. res.ErrMsg = res10265.ErrMsg
  3420. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3421. res.Infcode = infocode
  3422. res.Output = res10265.Output
  3423. res.InfRefmsgid = res10265.InfRefmsgid
  3424. }
  3425. if res.Infcode == 0 {
  3426. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3427. if err == gorm.ErrRecordNotFound {
  3428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3429. return
  3430. } else if err != nil {
  3431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3432. return
  3433. } else {
  3434. if card_type == "1" {
  3435. bas := strings.Split(card_info, "|")
  3436. basNumber := bas[2]
  3437. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3438. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3439. infoStr := string(Iinfos)
  3440. idetinfoStr := string(Idetinfos)
  3441. psn := &models.HisPsn{
  3442. PsnNo: res.Output.Baseinfo.PsnNo,
  3443. Age: res.Output.Baseinfo.Age,
  3444. PatientId: patient.ID,
  3445. Certno: res.Output.Baseinfo.Certno,
  3446. Brdy: res.Output.Baseinfo.Brdy,
  3447. Gend: res.Output.Baseinfo.Gend,
  3448. Naty: res.Output.Baseinfo.Naty,
  3449. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3450. PsnName: res.Output.Baseinfo.PsnName,
  3451. Idetinfo: idetinfoStr,
  3452. Insuinfo: infoStr,
  3453. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3454. CardInfo: card_info,
  3455. VerifyNumber: busi_card_info,
  3456. }
  3457. service.CreateHisPsn(psn)
  3458. c.ServeSuccessJSON(map[string]interface{}{
  3459. "patient": patient,
  3460. "number": basNumber,
  3461. })
  3462. } else {
  3463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3465. infoStr := string(Iinfos)
  3466. idetinfoStr := string(Idetinfos)
  3467. psn := &models.HisPsn{
  3468. PsnNo: res.Output.Baseinfo.PsnNo,
  3469. Age: res.Output.Baseinfo.Age,
  3470. PatientId: patient.ID,
  3471. Certno: res.Output.Baseinfo.Certno,
  3472. Brdy: res.Output.Baseinfo.Brdy,
  3473. Gend: res.Output.Baseinfo.Gend,
  3474. Naty: res.Output.Baseinfo.Naty,
  3475. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3476. PsnName: res.Output.Baseinfo.PsnName,
  3477. Idetinfo: idetinfoStr,
  3478. Insuinfo: infoStr,
  3479. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3480. CardInfo: card_info,
  3481. VerifyNumber: token,
  3482. }
  3483. service.CreateHisPsn(psn)
  3484. var rf []*ResultFive
  3485. json.Unmarshal([]byte(infoStr), &rf)
  3486. var insutypes []*ResultFive
  3487. var insutype string
  3488. var is390 int = 0
  3489. var is310 int = 0
  3490. for _, item := range rf {
  3491. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3492. insutypes = append(insutypes, item)
  3493. }
  3494. }
  3495. if len(insutypes) == 1 {
  3496. insutype = insutypes[0].Insutype
  3497. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3498. } else {
  3499. for _, i := range insutypes {
  3500. if i.Insutype == "390" {
  3501. is390 = 1
  3502. }
  3503. if i.Insutype == "310" {
  3504. is310 = 1
  3505. }
  3506. }
  3507. }
  3508. if is390 == 1 {
  3509. insutype = "390"
  3510. }
  3511. if is310 == 1 {
  3512. insutype = "310"
  3513. }
  3514. if len(insutypes) == 0 {
  3515. insutype = "310"
  3516. }
  3517. c.ServeSuccessJSON(map[string]interface{}{
  3518. "patient": patient,
  3519. "number": token,
  3520. "insutype": insutype,
  3521. })
  3522. }
  3523. }
  3524. } else {
  3525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3526. return
  3527. }
  3528. } else { //读卡失败
  3529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3530. return
  3531. }
  3532. }
  3533. break
  3534. case 4:
  3535. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3536. var api string
  3537. if miConfig.MdtrtareaAdmvs == "320921" {
  3538. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3539. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  3540. fmt.Println(api)
  3541. } else {
  3542. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3543. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  3544. }
  3545. resp, requestErr := http.Get(api)
  3546. if requestErr != nil {
  3547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3548. return
  3549. }
  3550. body, ioErr := ioutil.ReadAll(resp.Body)
  3551. if ioErr != nil {
  3552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3554. return
  3555. }
  3556. var respJSON map[string]interface{}
  3557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3560. return
  3561. }
  3562. var status string
  3563. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3564. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3565. var token string
  3566. var res ResultTwo //1101结果
  3567. var res10265 ResultTwo10265 //1101结果
  3568. if status == "0" { //读卡成功
  3569. var card_info string //卡信息
  3570. var busi_card_info string
  3571. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3572. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3573. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3574. fmt.Println(card_info)
  3575. fmt.Println(busi_card_info)
  3576. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3577. result, _ := json.Marshal(respJSON)
  3578. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3579. utils.ErrorLog("解析失败:%v", err)
  3580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3581. return
  3582. }
  3583. res.ErrMsg = res10265.ErrMsg
  3584. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3585. res.Infcode = infocode
  3586. res.Output = res10265.Output
  3587. res.InfRefmsgid = res10265.InfRefmsgid
  3588. if res.Infcode == 0 {
  3589. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3590. if err == gorm.ErrRecordNotFound {
  3591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3592. return
  3593. } else if err != nil {
  3594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3595. return
  3596. } else {
  3597. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3598. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3599. infoStr := string(Iinfos)
  3600. idetinfoStr := string(Idetinfos)
  3601. psn := &models.HisPsn{
  3602. PsnNo: res.Output.Baseinfo.PsnNo,
  3603. Age: res.Output.Baseinfo.Age,
  3604. PatientId: patient.ID,
  3605. Certno: res.Output.Baseinfo.Certno,
  3606. Brdy: res.Output.Baseinfo.Brdy,
  3607. Gend: res.Output.Baseinfo.Gend,
  3608. Naty: res.Output.Baseinfo.Naty,
  3609. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3610. PsnName: res.Output.Baseinfo.PsnName,
  3611. Idetinfo: idetinfoStr,
  3612. Insuinfo: infoStr,
  3613. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3614. CardInfo: card_info,
  3615. VerifyNumber: token,
  3616. }
  3617. var rf []*ResultFive
  3618. json.Unmarshal([]byte(infoStr), &rf)
  3619. var insutypes []*ResultFive
  3620. var insutype string
  3621. var is390 int = 0
  3622. var is310 int = 0
  3623. for _, item := range rf {
  3624. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3625. insutypes = append(insutypes, item)
  3626. }
  3627. }
  3628. if len(insutypes) == 1 {
  3629. insutype = insutypes[0].Insutype
  3630. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3631. } else {
  3632. for _, i := range insutypes {
  3633. if i.Insutype == "390" {
  3634. is390 = 1
  3635. }
  3636. if i.Insutype == "310" {
  3637. is310 = 1
  3638. }
  3639. }
  3640. }
  3641. if is390 == 1 {
  3642. insutype = "390"
  3643. }
  3644. if is310 == 1 {
  3645. insutype = "310"
  3646. }
  3647. if len(insutypes) == 0 {
  3648. insutype = "310"
  3649. }
  3650. service.CreateHisPsn(psn)
  3651. c.ServeSuccessJSON(map[string]interface{}{
  3652. "patient": patient,
  3653. "number": token,
  3654. "insutype": insutype,
  3655. })
  3656. }
  3657. } else {
  3658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3659. return
  3660. }
  3661. } else { //读卡失败
  3662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3663. return
  3664. }
  3665. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3666. _, result := GetHnEleBaseInfo(miConfig.Code, admin_user_id, roles.UserName)
  3667. fmt.Println(result)
  3668. //token = Remove0000(token)
  3669. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  3670. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  3671. ////
  3672. //var res ResultTwo
  3673. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3674. // utils.ErrorLog("解析失败:%v", err)
  3675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3676. // return
  3677. //}
  3678. //
  3679. //if res.Infcode == 0 {
  3680. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3681. // if err == gorm.ErrRecordNotFound {
  3682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3683. // return
  3684. // } else if err != nil {
  3685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3686. // return
  3687. //
  3688. // } else {
  3689. //
  3690. // //month := time.Unix(1557042972, 0).Format("1")
  3691. // //year := time.Now().Format("2006")
  3692. // //month = time.Now().Format("01")
  3693. // //day := time.Now().Format("02")
  3694. // //date := year+"-"+month+"-"+day + " "+"00:00:00"
  3695. //
  3696. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3697. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3698. // infoStr := string(Iinfos)
  3699. // idetinfoStr := string(Idetinfos)
  3700. // psn := &models.HisPsn{
  3701. // PsnNo: res.Output.Baseinfo.PsnNo,
  3702. // Age: res.Output.Baseinfo.Age,
  3703. // PatientId: patient.ID,
  3704. // Certno: res.Output.Baseinfo.Certno,
  3705. // Brdy: res.Output.Baseinfo.Brdy,
  3706. // Gend: res.Output.Baseinfo.Gend,
  3707. // Naty: res.Output.Baseinfo.Naty,
  3708. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  3709. // PsnName: res.Output.Baseinfo.PsnName,
  3710. // Idetinfo: idetinfoStr,
  3711. // Insuinfo: infoStr,
  3712. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3713. // CardInfo: "",
  3714. // Stage: "1",
  3715. // //RecordDate:
  3716. // VerifyNumber: token,
  3717. // }
  3718. // service.CreateHisPsn(psn)
  3719. //
  3720. // c.ServeSuccessJSON(map[string]interface{}{
  3721. // "patient": patient,
  3722. // "number": token,
  3723. // })
  3724. // }
  3725. //} else {
  3726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3727. // return
  3728. //}
  3729. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3730. //if initFlag == 0 {
  3731. c.TestGetJiangXiBasBaseInit()
  3732. //}
  3733. //if initEleFlag == 0 {
  3734. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3735. //}
  3736. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3737. type ELeData struct {
  3738. Data struct {
  3739. IdNo string `json:"idNo"`
  3740. IdType string `json:"idType"`
  3741. UserName string `json:"userName"`
  3742. EcToken string `json:"ecToken"`
  3743. InsuOrg string `json:"insuOrg"`
  3744. Gender string `json:"gender"`
  3745. Birthday string `json:"birthday"`
  3746. Nationality string `json:"nationality"`
  3747. Email string `json:"email"`
  3748. Extra string `json:"extra"`
  3749. } `json:"data"`
  3750. Code int `json:"code"`
  3751. Message string `json:"message"`
  3752. }
  3753. var ele ELeData
  3754. err := json.Unmarshal([]byte(json_result), &ele)
  3755. if err != nil {
  3756. utils.ErrorLog("解析失败:%v", err)
  3757. }
  3758. token := ele.Data.EcToken
  3759. token = Remove0000(token)
  3760. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  3761. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3762. var res ResultTwo
  3763. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3764. utils.ErrorLog("解析失败:%v", err)
  3765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3766. return
  3767. }
  3768. if res.Infcode == 0 {
  3769. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3770. if err == gorm.ErrRecordNotFound {
  3771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3772. return
  3773. } else if err != nil {
  3774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3775. return
  3776. } else {
  3777. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3778. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3779. infoStr := string(Iinfos)
  3780. idetinfoStr := string(Idetinfos)
  3781. psn := &models.HisPsn{
  3782. PsnNo: res.Output.Baseinfo.PsnNo,
  3783. Age: res.Output.Baseinfo.Age,
  3784. PatientId: patient.ID,
  3785. Certno: res.Output.Baseinfo.Certno,
  3786. Brdy: res.Output.Baseinfo.Brdy,
  3787. Gend: res.Output.Baseinfo.Gend,
  3788. Naty: res.Output.Baseinfo.Naty,
  3789. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3790. PsnName: res.Output.Baseinfo.PsnName,
  3791. Idetinfo: idetinfoStr,
  3792. Insuinfo: infoStr,
  3793. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3794. CardInfo: "",
  3795. //RecordDate:
  3796. VerifyNumber: token,
  3797. }
  3798. service.CreateHisPsn(psn)
  3799. var rf []*ResultFive
  3800. json.Unmarshal([]byte(infoStr), &rf)
  3801. var insutypes []*ResultFive
  3802. var insutype string
  3803. var is390 int = 0
  3804. var is310 int = 0
  3805. for _, item := range rf {
  3806. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3807. insutypes = append(insutypes, item)
  3808. }
  3809. }
  3810. if len(insutypes) == 1 {
  3811. insutype = insutypes[0].Insutype
  3812. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3813. } else {
  3814. for _, i := range insutypes {
  3815. if i.Insutype == "390" {
  3816. is390 = 1
  3817. }
  3818. if i.Insutype == "310" {
  3819. is310 = 1
  3820. }
  3821. }
  3822. }
  3823. if is390 == 1 {
  3824. insutype = "390"
  3825. }
  3826. if is310 == 1 {
  3827. insutype = "310"
  3828. }
  3829. if len(insutypes) == 0 {
  3830. insutype = "310"
  3831. }
  3832. c.ServeSuccessJSON(map[string]interface{}{
  3833. "patient": patient,
  3834. "number": token,
  3835. "insutype": insutype,
  3836. })
  3837. }
  3838. } else {
  3839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3840. return
  3841. }
  3842. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3843. //if initFlag == 0 {
  3844. c.TestGetJiangXiBasBaseInit()
  3845. //}
  3846. //if initEleFlag == 0 {
  3847. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3848. //}
  3849. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3850. type ELeData struct {
  3851. Data struct {
  3852. IdNo string `json:"idNo"`
  3853. IdType string `json:"idType"`
  3854. UserName string `json:"userName"`
  3855. EcToken string `json:"ecToken"`
  3856. InsuOrg string `json:"insuOrg"`
  3857. Gender string `json:"gender"`
  3858. Birthday string `json:"birthday"`
  3859. Nationality string `json:"nationality"`
  3860. Email string `json:"email"`
  3861. Extra string `json:"extra"`
  3862. } `json:"data"`
  3863. Code int `json:"code"`
  3864. Message string `json:"message"`
  3865. }
  3866. var ele ELeData
  3867. err := json.Unmarshal([]byte(json_result), &ele)
  3868. if err != nil {
  3869. utils.ErrorLog("解析失败:%v", err)
  3870. }
  3871. token := ele.Data.EcToken
  3872. token = Remove0000(token)
  3873. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  3874. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3875. var res ResultTwo
  3876. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3877. utils.ErrorLog("解析失败:%v", err)
  3878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3879. return
  3880. }
  3881. if res.Infcode == 0 {
  3882. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3883. if err == gorm.ErrRecordNotFound {
  3884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3885. return
  3886. } else if err != nil {
  3887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3888. return
  3889. } else {
  3890. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3891. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3892. infoStr := string(Iinfos)
  3893. idetinfoStr := string(Idetinfos)
  3894. psn := &models.HisPsn{
  3895. PsnNo: res.Output.Baseinfo.PsnNo,
  3896. Age: res.Output.Baseinfo.Age,
  3897. PatientId: patient.ID,
  3898. Certno: res.Output.Baseinfo.Certno,
  3899. Brdy: res.Output.Baseinfo.Brdy,
  3900. Gend: res.Output.Baseinfo.Gend,
  3901. Naty: res.Output.Baseinfo.Naty,
  3902. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3903. PsnName: res.Output.Baseinfo.PsnName,
  3904. Idetinfo: idetinfoStr,
  3905. Insuinfo: infoStr,
  3906. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3907. CardInfo: "",
  3908. VerifyNumber: token,
  3909. }
  3910. service.CreateHisPsn(psn)
  3911. var rf []*ResultFive
  3912. json.Unmarshal([]byte(infoStr), &rf)
  3913. var insutypes []*ResultFive
  3914. var insutype string
  3915. var is390 int = 0
  3916. var is310 int = 0
  3917. for _, item := range rf {
  3918. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3919. insutypes = append(insutypes, item)
  3920. }
  3921. }
  3922. if len(insutypes) == 1 {
  3923. insutype = insutypes[0].Insutype
  3924. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3925. } else {
  3926. for _, i := range insutypes {
  3927. if i.Insutype == "390" {
  3928. is390 = 1
  3929. }
  3930. if i.Insutype == "310" {
  3931. is310 = 1
  3932. }
  3933. }
  3934. }
  3935. if is390 == 1 {
  3936. insutype = "390"
  3937. }
  3938. if is310 == 1 {
  3939. insutype = "310"
  3940. }
  3941. if len(insutypes) == 0 {
  3942. insutype = "310"
  3943. }
  3944. c.ServeSuccessJSON(map[string]interface{}{
  3945. "patient": patient,
  3946. "number": token,
  3947. "insutype": insutype,
  3948. })
  3949. }
  3950. } else {
  3951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3952. return
  3953. }
  3954. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3955. type ELeData struct {
  3956. Code string `json:"code"`
  3957. Data struct {
  3958. Aac002 string `json:"aac002"`
  3959. Aaz500 string `json:"aaz500"`
  3960. ActCardNo string `json:"actCardNo"`
  3961. Bab520 string `json:"bab520"`
  3962. Bkz543 string `json:"bkz543"`
  3963. BusinessType string `json:"businessType"`
  3964. CertfCodg string `json:"certfCodg"`
  3965. EcIndexNo string `json:"ecIndexNo"`
  3966. EcToken string `json:"ecToken"`
  3967. ID0000 string `json:"id0000"`
  3968. IDNo string `json:"idNo"`
  3969. IDType string `json:"idType"`
  3970. Idcode string `json:"idcode"`
  3971. IdentityToken string `json:"identity_token"`
  3972. InsuOrg string `json:"insuOrg"`
  3973. OfficeID string `json:"officeId"`
  3974. OfficeName string `json:"officeName"`
  3975. OperatorID string `json:"operatorId"`
  3976. OperatorName string `json:"operatorName"`
  3977. OrgID string `json:"orgId"`
  3978. UserName string `json:"userName"`
  3979. } `json:"data"`
  3980. Infno interface{} `json:"infno"`
  3981. Message string `json:"message"`
  3982. OrgID string `json:"orgId"`
  3983. TransType string `json:"transType"`
  3984. }
  3985. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3986. outPutInfo = Remove0000(outPutInfo)
  3987. if len(outPutInfo) > 0 {
  3988. var ele ELeData
  3989. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3990. if err != nil {
  3991. utils.ErrorLog("解析失败:%v", err)
  3992. }
  3993. token := ele.Data.EcToken
  3994. fmt.Println(inputInfo)
  3995. fmt.Println(outPutInfo)
  3996. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  3997. saveLog(result, requestLog, "1101", "获取人员信息")
  3998. var dat map[string]interface{}
  3999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4000. fmt.Println(dat)
  4001. } else {
  4002. fmt.Println(err)
  4003. }
  4004. userJSONBytes, _ := json.Marshal(dat)
  4005. var res ResultTwo
  4006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4007. utils.ErrorLog("解析失败:%v", err)
  4008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4009. return
  4010. }
  4011. res.ErrMsg = errMsgLog
  4012. if res.Infcode == 0 {
  4013. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4014. if err == gorm.ErrRecordNotFound {
  4015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4016. return
  4017. } else if err != nil {
  4018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4019. return
  4020. } else {
  4021. fmt.Println(res)
  4022. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4023. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4024. infoStr := string(Iinfos)
  4025. idetinfoStr := string(Idetinfos)
  4026. psn := &models.HisPsn{
  4027. PsnNo: res.Output.Baseinfo.PsnNo,
  4028. Age: res.Output.Baseinfo.Age,
  4029. PatientId: patient.ID,
  4030. Certno: res.Output.Baseinfo.Certno,
  4031. Brdy: res.Output.Baseinfo.Brdy,
  4032. Gend: res.Output.Baseinfo.Gend,
  4033. Naty: res.Output.Baseinfo.Naty,
  4034. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4035. PsnName: res.Output.Baseinfo.PsnName,
  4036. Idetinfo: idetinfoStr,
  4037. Insuinfo: infoStr,
  4038. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4039. CardInfo: outPutInfo,
  4040. VerifyNumber: token,
  4041. InsuplcAdmdvs: ele.Data.InsuOrg,
  4042. }
  4043. service.CreateHisPsn(psn)
  4044. var rf []*ResultFive
  4045. json.Unmarshal([]byte(infoStr), &rf)
  4046. var insutypes []*ResultFive
  4047. var insutype string
  4048. var is390 int = 0
  4049. var is310 int = 0
  4050. for _, item := range rf {
  4051. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4052. insutypes = append(insutypes, item)
  4053. }
  4054. }
  4055. if len(insutypes) == 1 {
  4056. insutype = insutypes[0].Insutype
  4057. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4058. } else {
  4059. for _, i := range insutypes {
  4060. if i.Insutype == "390" {
  4061. is390 = 1
  4062. }
  4063. if i.Insutype == "310" {
  4064. is310 = 1
  4065. }
  4066. }
  4067. }
  4068. if is390 == 1 {
  4069. insutype = "390"
  4070. }
  4071. if is310 == 1 {
  4072. insutype = "310"
  4073. }
  4074. if len(insutypes) == 0 {
  4075. insutype = "310"
  4076. }
  4077. c.ServeSuccessJSON(map[string]interface{}{
  4078. "patient": patient,
  4079. "number": token,
  4080. "insutype": insutype,
  4081. })
  4082. }
  4083. } else {
  4084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4085. return
  4086. }
  4087. }
  4088. } else {
  4089. if initFlag == 0 {
  4090. c.TestGetBasBaseInit()
  4091. }
  4092. token := c.GetEleBaseInfo()
  4093. token = Remove0000(token)
  4094. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  4095. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4096. //
  4097. var res ResultTwo
  4098. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4099. utils.ErrorLog("解析失败:%v", err)
  4100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4101. return
  4102. }
  4103. if res.Infcode == 0 {
  4104. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4105. if err == gorm.ErrRecordNotFound {
  4106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4107. return
  4108. } else if err != nil {
  4109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4110. return
  4111. } else {
  4112. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4113. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4114. infoStr := string(Iinfos)
  4115. idetinfoStr := string(Idetinfos)
  4116. psn := &models.HisPsn{
  4117. PsnNo: res.Output.Baseinfo.PsnNo,
  4118. Age: res.Output.Baseinfo.Age,
  4119. PatientId: patient.ID,
  4120. Certno: res.Output.Baseinfo.Certno,
  4121. Brdy: res.Output.Baseinfo.Brdy,
  4122. Gend: res.Output.Baseinfo.Gend,
  4123. Naty: res.Output.Baseinfo.Naty,
  4124. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4125. PsnName: res.Output.Baseinfo.PsnName,
  4126. Idetinfo: idetinfoStr,
  4127. Insuinfo: infoStr,
  4128. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4129. CardInfo: "",
  4130. VerifyNumber: token,
  4131. }
  4132. service.CreateHisPsn(psn)
  4133. c.ServeSuccessJSON(map[string]interface{}{
  4134. "patient": patient,
  4135. "number": token,
  4136. })
  4137. }
  4138. } else {
  4139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4140. return
  4141. }
  4142. }
  4143. break
  4144. }
  4145. }
  4146. var initFlag int64 = 0
  4147. var initEleFlag int64 = 0
  4148. func (c *HisApiController) TestGetBasBaseInit() {
  4149. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4150. Iinit := DllDef.MustFindProc("Init")
  4151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4152. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  4153. if ret != 0 {
  4154. fmt.Println("SSCard的报错原因:", err)
  4155. fmt.Println("SSCard的运算结果为:", ret)
  4156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4157. return
  4158. }
  4159. result := int(ret)
  4160. fmt.Println("SSCard的运算结果为1:", result)
  4161. initFlag = 1
  4162. return
  4163. }
  4164. func (c *HisApiController) HandleJiangXiReadCard() {
  4165. fmt.Println("~~~~~~")
  4166. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4167. admin_user_id, _ := c.GetInt64("admin_user_id")
  4168. id_card_type, _ := c.GetInt64("id_card_type")
  4169. //certificates, _ := c.GetInt64("certificates")
  4170. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4171. if initFlag == 0 {
  4172. c.TestGetJiangXiBasBaseInit()
  4173. }
  4174. basStr := c.GetBasBaseInfo()
  4175. if len(basStr) == 0 {
  4176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4177. return
  4178. }
  4179. fmt.Println(basStr)
  4180. bas := strings.Split(basStr, "|")
  4181. basNumber := bas[1]
  4182. fmt.Println(basNumber)
  4183. card_sn := bas[3]
  4184. fmt.Println(card_sn)
  4185. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  4186. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4187. var dat map[string]interface{}
  4188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4189. fmt.Println(dat)
  4190. } else {
  4191. fmt.Println(err)
  4192. }
  4193. userJSONBytes, _ := json.Marshal(dat)
  4194. var res ResultTwo
  4195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4196. utils.ErrorLog("解析失败:%v", err)
  4197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4198. return
  4199. }
  4200. if res.Infcode == 0 {
  4201. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4202. if err == gorm.ErrRecordNotFound {
  4203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4204. return
  4205. } else if err != nil {
  4206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4207. return
  4208. } else {
  4209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4211. infoStr := string(Iinfos)
  4212. idetinfoStr := string(Idetinfos)
  4213. psn := &models.HisPsn{
  4214. PsnNo: res.Output.Baseinfo.PsnNo,
  4215. Age: res.Output.Baseinfo.Age,
  4216. PatientId: patient.ID,
  4217. Certno: res.Output.Baseinfo.Certno,
  4218. Brdy: res.Output.Baseinfo.Brdy,
  4219. Gend: res.Output.Baseinfo.Gend,
  4220. Naty: res.Output.Baseinfo.Naty,
  4221. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4222. PsnName: res.Output.Baseinfo.PsnName,
  4223. Idetinfo: idetinfoStr,
  4224. Insuinfo: infoStr,
  4225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4226. CardInfo: basStr,
  4227. VerifyNumber: "",
  4228. }
  4229. service.CreateHisPsn(psn)
  4230. c.ServeSuccessJSON(map[string]interface{}{
  4231. "patient": patient,
  4232. "number": basNumber,
  4233. })
  4234. }
  4235. } else {
  4236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4237. return
  4238. }
  4239. }
  4240. func (c *HisApiController) TestGetHnBasBaseInit() {
  4241. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4242. Iinit := DllDef.MustFindProc("Init")
  4243. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4244. //http://10.77.211.236/CSB/hsa-fsi-1303
  4245. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  4246. if ret != 0 {
  4247. fmt.Println("SSCard的报错原因:", err)
  4248. fmt.Println("SSCard的运算结果为:", ret)
  4249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4250. return
  4251. }
  4252. result := int(ret)
  4253. fmt.Println("SSCard的运算结果为1:", result)
  4254. initFlag = 1
  4255. return
  4256. }
  4257. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  4258. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4259. Iinit := DllDef.MustFindProc("Init")
  4260. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4261. //http://10.77.211.236/CSB/hsa-fsi-1303
  4262. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  4263. if ret != 0 {
  4264. fmt.Println("SSCard的报错原因:", err)
  4265. fmt.Println("SSCard的运算结果为:", ret)
  4266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4267. return
  4268. }
  4269. result := int(ret)
  4270. fmt.Println("SSCard的运算结果为1:", result)
  4271. initFlag = 1
  4272. return
  4273. }
  4274. func (c *HisApiController) GetSFZBaseInfo() string {
  4275. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4276. readCard := DllDef.MustFindProc("ReadSFZ")
  4277. if readCard == nil {
  4278. fmt.Println("readcard is nil")
  4279. readCard = DllDef.MustFindProc("ReadSFZ")
  4280. }
  4281. str := make([]byte, 8096)
  4282. str1 := make([]byte, 8096)
  4283. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  4284. fmt.Println(r)
  4285. return Remove0000(string(str))
  4286. }
  4287. func (c *HisApiController) GetEleBaseInfo() string {
  4288. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4289. readCard := DllDef.MustFindProc("GetQRBase")
  4290. fmt.Println(readCard)
  4291. if readCard == nil {
  4292. fmt.Println("readcard is nil")
  4293. readCard = DllDef.MustFindProc("GetQRBase")
  4294. }
  4295. str := make([]byte, 1024)
  4296. str1 := make([]byte, 1024)
  4297. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4298. fmt.Println(ret2)
  4299. fmt.Println(string(str1))
  4300. fmt.Println(string(str))
  4301. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4302. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4303. if ret2 != 0 {
  4304. return ""
  4305. }
  4306. return string(str)
  4307. }
  4308. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  4309. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  4310. readCard := DllDef.MustFindProc("NationEcTrans")
  4311. fmt.Println(readCard)
  4312. fmt.Println("!!!!!")
  4313. pBusiCardInfo := make([]byte, 2048)
  4314. input := make(map[string]interface{})
  4315. inputData := make(map[string]interface{})
  4316. inputData["orgId"] = code
  4317. inputData["businessType"] = "01101"
  4318. inputData["operatorId"] = operator_id
  4319. inputData["operatorName"] = operator_name
  4320. inputData["officeId"] = "001"
  4321. inputData["officeName"] = "血透室"
  4322. inputData["deviceType"] = ""
  4323. input["data"] = inputData
  4324. input["orgId"] = code
  4325. input["transType"] = "ec.query"
  4326. bytesData, _ := json.Marshal(input)
  4327. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  4328. fmt.Println(ret2)
  4329. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  4330. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  4331. if ret2 != 0 {
  4332. return "", ""
  4333. }
  4334. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  4335. }
  4336. func GetJxEleBaseInfo(org_id int64) string {
  4337. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4338. readCard := DllDef.MustFindProc("NationEcTrans")
  4339. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4340. if readCard == nil {
  4341. fmt.Println("readcard is nil")
  4342. readCard = DllDef.MustFindProc("NationEcTrans")
  4343. }
  4344. str1 := make([]byte, 1024)
  4345. data := make(map[string]interface{})
  4346. inputData := make(map[string]interface{})
  4347. inputData["orgId"] = miConfig.Code
  4348. inputData["businessType"] = "01101"
  4349. inputData["operatorId"] = "test001"
  4350. inputData["operatorName"] = "cn"
  4351. inputData["officeId"] = "32760"
  4352. inputData["officeName"] = "waike"
  4353. inputData["deviceType"] = ""
  4354. data["data"] = inputData
  4355. data["transType"] = "ec.query"
  4356. data["extra "] = ""
  4357. data["orgId"] = miConfig.Code
  4358. bytesData, _ := json.Marshal(data)
  4359. //bytesData, _ := json.Marshal(data)
  4360. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4361. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4362. fmt.Println(ret2)
  4363. fmt.Println(string(str1))
  4364. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4365. if ret2 != 0 {
  4366. return ""
  4367. }
  4368. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4369. }
  4370. func GetJxEleBaseInitInfo(org_id int64) string {
  4371. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4372. readCard := DllDef.MustFindProc("NationEcTrans")
  4373. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4374. if readCard == nil {
  4375. fmt.Println("readcard is nil")
  4376. readCard = DllDef.MustFindProc("NationEcTrans")
  4377. }
  4378. str1 := make([]byte, 2048)
  4379. data := make(map[string]interface{})
  4380. inputData := make(map[string]interface{})
  4381. inputData["orgId"] = miConfig.Code
  4382. inputData["businessType"] = "01101"
  4383. inputData["operatorId"] = "1"
  4384. inputData["operatorName"] = "huangchuang"
  4385. inputData["officeId"] = "101"
  4386. inputData["officeName"] = "xuetou"
  4387. inputData["deviceType"] = ""
  4388. data["data"] = inputData
  4389. data["transType"] = "ec.query"
  4390. data["orgId"] = miConfig.Code
  4391. bytesData, _ := json.Marshal(data)
  4392. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4393. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4394. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  4395. fmt.Println(ret2)
  4396. fmt.Println(string(str1))
  4397. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4398. if ret2 != 0 {
  4399. return ""
  4400. }
  4401. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  4402. initEleFlag = 1
  4403. }
  4404. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4405. }
  4406. func (c *HisApiController) GetBasBaseInfo() string {
  4407. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4408. readCard := DllDef.MustFindProc("ReadCardBas")
  4409. if readCard == nil {
  4410. fmt.Println("readcard is nil")
  4411. readCard = DllDef.MustFindProc("ReadCardBas")
  4412. }
  4413. str := make([]byte, 1024)
  4414. str1 := make([]byte, 1024)
  4415. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4416. fmt.Println(string(str1))
  4417. fmt.Println(string(str))
  4418. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4419. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4420. if ret2 != 0 {
  4421. return ""
  4422. }
  4423. return string(str)
  4424. }
  4425. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  4426. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  4427. readCard := DllDef.MustFindProc("read_cardinfo")
  4428. if readCard == nil {
  4429. fmt.Println("readcard is nil")
  4430. readCard = DllDef.MustFindProc("read_cardinfo")
  4431. }
  4432. str := make([]byte, 1024) //卡号
  4433. str1 := make([]byte, 1024) //卡识别码
  4434. str2 := make([]byte, 1024) //身份证号
  4435. str3 := make([]byte, 1024) //姓名
  4436. str4 := make([]byte, 1024) //错误信息
  4437. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  4438. fmt.Println(string(str1))
  4439. fmt.Println(string(str))
  4440. fmt.Println(string(str2))
  4441. fmt.Println(string(str3))
  4442. fmt.Println(string(str4))
  4443. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4444. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4445. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  4446. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  4447. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  4448. if ret2 != 0 {
  4449. return "", "", "", "", ""
  4450. }
  4451. return string(str), string(str1), string(str2), string(str3), string(str4)
  4452. }
  4453. type CustomFundPay struct {
  4454. FundPayType string `json:"fund_pay_type"`
  4455. FundPayamt float64 `json:"fund_payamt"`
  4456. }
  4457. func (c *HisApiController) GetSettleList() {
  4458. order_id, _ := c.GetInt64("order_id")
  4459. admin_user_id, _ := c.GetInt64("admin_user_id")
  4460. order, _ := service.GetHisOrderByIDTwo(order_id)
  4461. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4462. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4463. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4464. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4465. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4466. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4467. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4468. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4469. if order.ID == 0 {
  4470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4471. return
  4472. }
  4473. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4474. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4475. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4476. //fmt.Println(count)
  4477. //var zero string
  4478. //number := count + 1
  4479. //if number >= 1000 {
  4480. // zero = "0000" + strconv.FormatInt(number, 10)
  4481. //} else if number >= 10000 {
  4482. // zero = "000" + strconv.FormatInt(number, 10)
  4483. //} else if number >= 100000 {
  4484. // zero = "00" + strconv.FormatInt(number, 10)
  4485. //} else if number >= 1000000 {
  4486. // zero = "0" + strconv.FormatInt(number, 10)
  4487. //} else {
  4488. // zero = strconv.FormatInt(number, 10)
  4489. //}
  4490. //fmt.Println(zero)
  4491. struct4101 := service.Struct4101{
  4492. PsnNo: order.PsnNo,
  4493. MdtrtId: order.MdtrtId,
  4494. SetlId: order.SetlId,
  4495. PsnName: order.PsnName,
  4496. Gend: order.Gend,
  4497. Brdy: his.Brdy,
  4498. Age: his.Age,
  4499. Naty: order.Naty,
  4500. PatnCertType: "01",
  4501. Certno: order.Certno,
  4502. Prfs: "90",
  4503. ConerName: roles[0].UserName,
  4504. PatnRlts: "99",
  4505. ConerAddr: miConfig.OrgName,
  4506. ConerTel: admin.Mobile,
  4507. HiType: order.Insutype,
  4508. Insuplc: miConfig.InsuplcAdmdvs,
  4509. MaindiagFlag: "1",
  4510. BillCode: order.SetlId,
  4511. BillNo: order.SetlId,
  4512. BizSn: order.Number,
  4513. PsnSelfPay: order.PsnPartAmt,
  4514. PsnOwnPay: order.PsnPartAmt,
  4515. AcctPay: order.AcctPay,
  4516. PsnCashpay: order.PsnCashPay,
  4517. HiPaymtd: "1",
  4518. Hsorg: miConfig.InsuplcAdmdvs,
  4519. HsorgOpter: miConfig.InsuplcAdmdvs,
  4520. MedinsFillPsn: curRoles.UserName,
  4521. MedinsFillDept: depart.Name,
  4522. IptMedType: "2",
  4523. }
  4524. struct4101.SetlBegnDate = order.SetlTime
  4525. struct4101.SetlEndDate = order.SetlTime
  4526. time_arr := strings.Split(order.SetlTime, " ")
  4527. struct4101.AdmTime = time_arr[0]
  4528. struct4101.AdmEndTime = time_arr[0]
  4529. var rf []CustomFundPay
  4530. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4531. var tempFunPays []service.CustomStruct
  4532. for _, item := range rf {
  4533. var tempFunPay service.CustomStruct
  4534. tempFunPay.FundPayamt = item.FundPayamt
  4535. tempFunPay.FundPayType = item.FundPayType
  4536. tempFunPays = append(tempFunPays, tempFunPay)
  4537. }
  4538. struct4101.CustomStruct = tempFunPays
  4539. var tempDiaginfos []service.DiaginfoStructTwo
  4540. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4541. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4542. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4543. var config []*models.HisXtDiagnoseConfig
  4544. for _, item := range diagnosis_ids {
  4545. id, _ := strconv.ParseInt(item, 10, 64)
  4546. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4547. config = append(config, &diagnosisConfig)
  4548. }
  4549. for index, item := range config {
  4550. if index == 0 {
  4551. var tempDiaginfo service.DiaginfoStructTwo
  4552. tempDiaginfo.DiagCode = item.CountryCode
  4553. tempDiaginfo.DiagName = item.CountryContentName
  4554. tempDiaginfo.DiagType = "1"
  4555. tempDiaginfo.MaindiagFlag = "1"
  4556. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4557. } else {
  4558. var tempDiaginfo service.DiaginfoStructTwo
  4559. tempDiaginfo.DiagCode = item.CountryCode
  4560. tempDiaginfo.DiagName = item.CountryContentName
  4561. tempDiaginfo.DiagType = "2"
  4562. tempDiaginfo.MaindiagFlag = "0"
  4563. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4564. }
  4565. }
  4566. struct4101.Diseinfo = tempDiaginfos
  4567. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4568. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4569. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4570. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  4571. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  4572. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4573. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4574. var iteminfo service.IteminfoStruct
  4575. var bedCostTotal float64 = 0 //床位总费
  4576. var bedCostSelfTotal float64 = 0 //床位自费
  4577. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4578. var operationCostTotal float64 = 0 //手术费
  4579. var operationCostSelfTotal float64 = 0 //手术费
  4580. var operationCostPartSelfTotal float64 = 0 //手术费
  4581. var otherCostTotal float64 = 0 //其他费用
  4582. var otherCostSelfTotal float64 = 0 //其他费用
  4583. var otherCostPartSelfTotal float64 = 0 //其他费用
  4584. var materialCostTotal float64 = 0 //材料费
  4585. var materialCostSelfTotal float64 = 0 //材料费
  4586. var materialCostPartSelfTotal float64 = 0 //材料费
  4587. var westernMedicineCostTotal float64 = 0 //西药费
  4588. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4589. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4590. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4591. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4592. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4593. var checkCostTotal float64 = 0 //检查费
  4594. var checkCostSelfTotal float64 = 0 //检查费
  4595. var checkCostPartSelfTotal float64 = 0 //检查费
  4596. var laboratoryCostTotal float64 = 0 //化验费
  4597. var laboratoryCostSelfTotal float64 = 0 //化验费
  4598. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4599. var treatCostTotal float64 = 0 //治疗费用
  4600. var treatCostSelfTotal float64 = 0 //治疗费用
  4601. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4602. decimal.DivisionPrecision = 2
  4603. var bed_fulamt_ownpay_amt float64 = 0
  4604. var operation_fulamt_ownpay_amt float64 = 0
  4605. var other_fulamt_ownpay_amt float64 = 0
  4606. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4607. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4608. var check_fulamt_ownpay_amt float64 = 0
  4609. var material_fulamt_ownpay_amt float64 = 0
  4610. var laboratory_fulamt_ownpay_amt float64 = 0
  4611. var treat_fulamt_ownpay_amt float64 = 0
  4612. var bed_claa_sunmfee float64 = 0
  4613. var bed_clab_amt float64 = 0
  4614. var bed_other_amt float64 = 0
  4615. var operation_claa_sunmfee float64 = 0
  4616. var operation_clab_amt float64 = 0
  4617. var operation_other_amt float64 = 0
  4618. var other_claa_sunmfee float64 = 0
  4619. var other_clab_amt float64 = 0
  4620. var other_other_amt float64 = 0
  4621. var westernMedicine_claa_sunmfee float64 = 0
  4622. var westernMedicine_clab_amt float64 = 0
  4623. var westernMedicine_other_amt float64 = 0
  4624. var chineseTraditional_claa_sunmfee float64 = 0
  4625. var chineseTraditional_clab_amt float64 = 0
  4626. var chineseTraditional_other_amt float64 = 0
  4627. var check_claa_sunmfee float64 = 0
  4628. var check_clab_amt float64 = 0
  4629. var check_other_amt float64 = 0
  4630. var material_claa_sunmfee float64 = 0
  4631. var material_clab_amt float64 = 0
  4632. var material_other_amt float64 = 0
  4633. var laboratory_claa_sunmfee float64 = 0
  4634. var laboratory_clab_amt float64 = 0
  4635. var laboratory_other_amt float64 = 0
  4636. var treat_claa_sunmfee float64 = 0
  4637. var treat_clab_amt float64 = 0
  4638. var treat_other_amt float64 = 0
  4639. for _, item := range order.HisOrderInfo {
  4640. if item.MedChrgitmType == "01" { //床位费
  4641. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4642. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4643. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4644. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4645. if item.ChrgitmLv == "1" {
  4646. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4647. }
  4648. if item.ChrgitmLv == "2" {
  4649. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4650. }
  4651. if item.ChrgitmLv == "3" {
  4652. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4653. }
  4654. }
  4655. if item.MedChrgitmType == "03" { //检查费
  4656. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4657. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4658. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4659. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4660. if item.ChrgitmLv == "1" {
  4661. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4662. }
  4663. if item.ChrgitmLv == "2" {
  4664. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4665. }
  4666. if item.ChrgitmLv == "3" {
  4667. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4668. }
  4669. }
  4670. if item.MedChrgitmType == "04" { //化验费
  4671. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4672. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4673. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4674. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4675. if item.ChrgitmLv == "1" {
  4676. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4677. }
  4678. if item.ChrgitmLv == "2" {
  4679. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4680. }
  4681. if item.ChrgitmLv == "3" {
  4682. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4683. }
  4684. }
  4685. if item.MedChrgitmType == "05" { //治疗费
  4686. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4687. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4688. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4689. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4690. if item.ChrgitmLv == "1" {
  4691. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4692. }
  4693. if item.ChrgitmLv == "2" {
  4694. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4695. }
  4696. if item.ChrgitmLv == "3" {
  4697. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4698. }
  4699. }
  4700. if item.MedChrgitmType == "06" { //手术费
  4701. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4702. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4703. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4704. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4705. if item.ChrgitmLv == "1" {
  4706. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4707. }
  4708. if item.ChrgitmLv == "2" {
  4709. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4710. }
  4711. if item.ChrgitmLv == "3" {
  4712. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4713. }
  4714. }
  4715. if item.MedChrgitmType == "08" { //材料费
  4716. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4717. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4718. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4719. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4720. if item.ChrgitmLv == "1" {
  4721. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4722. }
  4723. if item.ChrgitmLv == "2" {
  4724. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4725. }
  4726. if item.ChrgitmLv == "3" {
  4727. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4728. }
  4729. }
  4730. if item.MedChrgitmType == "09" { //西药费
  4731. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4732. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4733. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4734. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4735. if item.ChrgitmLv == "1" {
  4736. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4737. }
  4738. if item.ChrgitmLv == "2" {
  4739. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4740. }
  4741. if item.ChrgitmLv == "3" {
  4742. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4743. }
  4744. }
  4745. if item.MedChrgitmType == "11" { //中成费
  4746. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4747. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4748. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4749. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4750. if item.ChrgitmLv == "1" {
  4751. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4752. }
  4753. if item.ChrgitmLv == "2" {
  4754. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4755. }
  4756. if item.ChrgitmLv == "3" {
  4757. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4758. }
  4759. }
  4760. if item.MedChrgitmType == "14" { //其他费
  4761. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4762. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4763. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4764. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4765. if item.ChrgitmLv == "1" {
  4766. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4767. }
  4768. if item.ChrgitmLv == "2" {
  4769. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4770. }
  4771. if item.ChrgitmLv == "3" {
  4772. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4773. }
  4774. }
  4775. }
  4776. var iteminfoStructs []service.IteminfoStruct
  4777. if bedCostTotal != 0 {
  4778. iteminfo.MedChrgitm = "01"
  4779. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4780. iteminfo.Amt = bedCostTotal
  4781. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4782. iteminfo.ClabAmt = bed_clab_amt
  4783. iteminfo.OthAmt = bed_other_amt
  4784. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4785. }
  4786. if checkCostTotal != 0 {
  4787. iteminfo.MedChrgitm = "03"
  4788. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4789. iteminfo.Amt = checkCostTotal
  4790. iteminfo.ClaaSumfee = check_claa_sunmfee
  4791. iteminfo.ClabAmt = check_clab_amt
  4792. iteminfo.OthAmt = check_other_amt
  4793. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4794. }
  4795. if laboratoryCostTotal != 0 {
  4796. iteminfo.MedChrgitm = "04"
  4797. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4798. iteminfo.Amt = laboratoryCostTotal
  4799. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4800. iteminfo.ClabAmt = laboratory_clab_amt
  4801. iteminfo.OthAmt = laboratory_other_amt
  4802. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4803. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4804. }
  4805. if treatCostTotal != 0 {
  4806. iteminfo.MedChrgitm = "05"
  4807. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4808. iteminfo.Amt = treatCostTotal
  4809. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4810. iteminfo.ClabAmt = treat_clab_amt
  4811. iteminfo.OthAmt = treat_other_amt
  4812. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4813. //(struct4101.IteminfoStruct, iteminfo)
  4814. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4815. }
  4816. if operationCostTotal != 0 {
  4817. iteminfo.MedChrgitm = "06"
  4818. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4819. iteminfo.Amt = operationCostTotal
  4820. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4821. iteminfo.ClabAmt = operation_clab_amt
  4822. iteminfo.OthAmt = operation_other_amt
  4823. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4824. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4825. }
  4826. if materialCostTotal != 0 {
  4827. iteminfo.MedChrgitm = "08"
  4828. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4829. iteminfo.Amt = materialCostTotal
  4830. iteminfo.ClaaSumfee = material_claa_sunmfee
  4831. iteminfo.ClabAmt = material_clab_amt
  4832. iteminfo.OthAmt = material_other_amt
  4833. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4834. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4835. }
  4836. if westernMedicineCostTotal != 0 {
  4837. iteminfo.MedChrgitm = "09"
  4838. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4839. iteminfo.Amt = westernMedicineCostTotal
  4840. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4841. iteminfo.ClabAmt = westernMedicine_clab_amt
  4842. iteminfo.OthAmt = westernMedicine_other_amt
  4843. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4844. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4845. }
  4846. if chineseTraditionalMedicineCostTotal != 0 {
  4847. iteminfo.MedChrgitm = "11"
  4848. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4849. iteminfo.Amt = westernMedicineCostTotal
  4850. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4851. iteminfo.ClabAmt = westernMedicine_clab_amt
  4852. iteminfo.OthAmt = westernMedicine_other_amt
  4853. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4854. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4855. }
  4856. if otherCostTotal != 0 {
  4857. iteminfo.MedChrgitm = "14"
  4858. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4859. iteminfo.Amt = otherCostTotal
  4860. iteminfo.ClaaSumfee = other_claa_sunmfee
  4861. iteminfo.ClabAmt = other_clab_amt
  4862. iteminfo.OthAmt = other_other_amt
  4863. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4864. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4865. }
  4866. struct4101.IteminfoStruct = iteminfoStructs
  4867. struct4101.Ntly = "中国"
  4868. struct4101.AdmCaty = "A03.06"
  4869. struct4101.DoctorName = doctor.UserName
  4870. struct4101.DoctorCode = doctor.DoctorNumber
  4871. var res ResultSeventeen
  4872. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4873. struct4101.BillCode = order.Number
  4874. struct4101.BillNo = order.SetlId
  4875. var resOther ResultSeventeenOther
  4876. var pp models.PublicParams
  4877. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4878. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4879. pp.FixmedinsName = miConfig.OrgName
  4880. pp.FixmedinsCode = miConfig.Code
  4881. pp.RequestUrl = miConfig.Url
  4882. pp.Cainfo = miConfig.Cainfo
  4883. pp.SecretKey = miConfig.SecretKey
  4884. pp.AccessKey = miConfig.AccessKey
  4885. pp.OpterName = curRoles.UserName
  4886. client := &http.Client{}
  4887. var req *http.Request
  4888. data := make(map[string]interface{})
  4889. data["struct4101"] = struct4101
  4890. data["pp"] = pp
  4891. bytesData, _ := json.Marshal(data)
  4892. if miConfig.MdtrtareaAdmvs == "320921" {
  4893. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4894. } else {
  4895. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4896. }
  4897. resp, _ := client.Do(req)
  4898. defer resp.Body.Close()
  4899. body, ioErr := ioutil.ReadAll(resp.Body)
  4900. if ioErr != nil {
  4901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4903. return
  4904. }
  4905. var respJSON map[string]interface{}
  4906. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4909. return
  4910. }
  4911. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4912. userJSONBytes, _ := json.Marshal(respJSON)
  4913. fmt.Println("log")
  4914. fmt.Println(string(userJSONBytes))
  4915. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4916. utils.ErrorLog("解析失败:%v", err)
  4917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4918. return
  4919. }
  4920. res.InfRefmsgid = resOther.InfRefmsgid
  4921. res.Output = resOther.Output
  4922. res.ErrMsg = resOther.ErrMsg
  4923. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4924. res.Infcode = infocode
  4925. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4926. var pp models.PublicParams
  4927. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4928. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4929. pp.FixmedinsName = miConfig.OrgName
  4930. pp.FixmedinsCode = miConfig.Code
  4931. pp.RequestUrl = miConfig.Url
  4932. pp.Cainfo = miConfig.Cainfo
  4933. pp.SecretKey = miConfig.SecretKey
  4934. pp.AccessKey = miConfig.AccessKey
  4935. pp.OpterName = curRoles.UserName
  4936. result, _ := service.Jxyb4101(struct4101, pp)
  4937. var dat map[string]interface{}
  4938. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4939. fmt.Println(dat)
  4940. } else {
  4941. fmt.Println(err)
  4942. }
  4943. userJSONBytes, _ := json.Marshal(dat)
  4944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4945. utils.ErrorLog("解析失败:%v", err)
  4946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4947. return
  4948. }
  4949. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4950. var pp models.PublicParams
  4951. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4952. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4953. pp.FixmedinsName = miConfig.OrgName
  4954. pp.FixmedinsCode = miConfig.Code
  4955. pp.RequestUrl = miConfig.Url
  4956. pp.Cainfo = miConfig.Cainfo
  4957. pp.SecretKey = miConfig.SecretKey
  4958. pp.AccessKey = miConfig.AccessKey
  4959. pp.OpterName = curRoles.UserName
  4960. result, _ := service.Hnyb4101(struct4101, pp)
  4961. var dat map[string]interface{}
  4962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4963. fmt.Println(dat)
  4964. } else {
  4965. fmt.Println(err)
  4966. }
  4967. userJSONBytes, _ := json.Marshal(dat)
  4968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4969. utils.ErrorLog("解析失败:%v", err)
  4970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4971. return
  4972. }
  4973. } else {
  4974. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4975. var dat map[string]interface{}
  4976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4977. fmt.Println(dat)
  4978. } else {
  4979. fmt.Println(err)
  4980. }
  4981. userJSONBytes, _ := json.Marshal(dat)
  4982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4983. utils.ErrorLog("解析失败:%v", err)
  4984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4985. return
  4986. }
  4987. }
  4988. if res.Infcode != 0 {
  4989. c.ServeSuccessJSON(map[string]interface{}{
  4990. "failed_code": -10,
  4991. "msg": res.ErrMsg,
  4992. })
  4993. return
  4994. } else {
  4995. //order.FaPiaoNumber = zero
  4996. //order.FaPiaoCode = last_order.FaPiaoCode
  4997. //service.UpdateOrder(order)
  4998. hisFundSettleListResult := &models.HisFundSettleListResult{
  4999. Number: res.Output.SetlListId,
  5000. Status: 1,
  5001. Ctime: time.Now().Unix(),
  5002. Mtime: time.Now().Unix(),
  5003. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5004. IsUpload: 1,
  5005. OrderId: order_id,
  5006. }
  5007. service.CreateUploadRecord(hisFundSettleListResult)
  5008. c.ServeSuccessJSON(map[string]interface{}{
  5009. "msg": "上传成功",
  5010. "result": hisFundSettleListResult,
  5011. })
  5012. return
  5013. }
  5014. }
  5015. func (c *HisApiController) GetSettleListHospital() {
  5016. order_id, _ := c.GetInt64("order_id")
  5017. admin_user_id, _ := c.GetInt64("admin_user_id")
  5018. order, _ := service.GetHisOrderByIDTwo(order_id)
  5019. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5020. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5021. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5022. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5023. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5024. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5025. if order.ID == 0 {
  5026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5027. return
  5028. }
  5029. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5030. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5031. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5032. fmt.Println(count)
  5033. var zero string
  5034. number := count + 1
  5035. if number >= 1000 {
  5036. zero = "0000" + strconv.FormatInt(number, 10)
  5037. } else if number >= 10000 {
  5038. zero = "000" + strconv.FormatInt(number, 10)
  5039. } else if number >= 100000 {
  5040. zero = "00" + strconv.FormatInt(number, 10)
  5041. } else if number >= 1000000 {
  5042. zero = "0" + strconv.FormatInt(number, 10)
  5043. } else {
  5044. zero = strconv.FormatInt(number, 10)
  5045. }
  5046. fmt.Println(zero)
  5047. struct4101 := service.Struct4101{
  5048. PsnNo: order.PsnNo,
  5049. MdtrtId: order.MdtrtId,
  5050. SetlId: order.SetlId,
  5051. PsnName: order.PsnName,
  5052. Gend: order.Gend,
  5053. Brdy: his.Brdy,
  5054. Age: int64(order.Age),
  5055. Naty: order.Naty,
  5056. PatnCertType: "01",
  5057. Certno: order.Certno,
  5058. Prfs: "90",
  5059. ConerName: roles[0].UserName,
  5060. PatnRlts: "99",
  5061. ConerAddr: miConfig.OrgName,
  5062. ConerTel: admin.Mobile,
  5063. HiType: order.Insutype,
  5064. Insuplc: miConfig.InsuplcAdmdvs,
  5065. MaindiagFlag: "1",
  5066. BillCode: order.SetlId,
  5067. BillNo: order.SetlId,
  5068. BizSn: order.Number,
  5069. PsnSelfPay: order.PsnPartAmt,
  5070. PsnOwnPay: order.PsnPartAmt,
  5071. AcctPay: order.AcctPay,
  5072. PsnCashpay: order.PsnCashPay,
  5073. HiPaymtd: "1",
  5074. Hsorg: miConfig.InsuplcAdmdvs,
  5075. HsorgOpter: miConfig.InsuplcAdmdvs,
  5076. MedinsFillPsn: curRoles.UserName,
  5077. MedinsFillDept: depart.Name,
  5078. IptMedType: "2",
  5079. AdmTime: his.InHosptialTime,
  5080. AdmEndTime: his.OutHosptialTime,
  5081. }
  5082. struct4101.SetlBegnDate = order.SetlTime
  5083. struct4101.SetlEndDate = order.SetlTime
  5084. var rf []CustomFundPay
  5085. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5086. var tempFunPays []service.CustomStruct
  5087. for _, item := range rf {
  5088. var tempFunPay service.CustomStruct
  5089. tempFunPay.FundPayamt = item.FundPayamt
  5090. tempFunPay.FundPayType = item.FundPayType
  5091. tempFunPays = append(tempFunPays, tempFunPay)
  5092. }
  5093. struct4101.CustomStruct = tempFunPays
  5094. var tempDiaginfos []service.DiaginfoStructTwo
  5095. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5096. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5097. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5098. var config []*models.HisXtDiagnoseConfig
  5099. for _, item := range diagnosis_ids {
  5100. id, _ := strconv.ParseInt(item, 10, 64)
  5101. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5102. config = append(config, &diagnosisConfig)
  5103. }
  5104. for index, item := range config {
  5105. if index == 0 {
  5106. var tempDiaginfo service.DiaginfoStructTwo
  5107. tempDiaginfo.DiagCode = item.CountryCode
  5108. tempDiaginfo.DiagName = item.CountryContentName
  5109. tempDiaginfo.DiagType = "1"
  5110. tempDiaginfo.MaindiagFlag = "1"
  5111. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5112. } else {
  5113. var tempDiaginfo service.DiaginfoStructTwo
  5114. tempDiaginfo.DiagCode = item.CountryCode
  5115. tempDiaginfo.DiagName = item.CountryContentName
  5116. tempDiaginfo.DiagType = "2"
  5117. tempDiaginfo.MaindiagFlag = "0"
  5118. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5119. }
  5120. }
  5121. struct4101.Diseinfo = tempDiaginfos
  5122. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5123. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5124. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5125. tempOpspdiseinfo2.OprnOprtCode = ""
  5126. tempOpspdiseinfo2.OprnOprtName = ""
  5127. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5128. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5129. var iteminfo service.IteminfoStruct
  5130. var bedCostTotal float64 = 0 //床位总费
  5131. var bedCostSelfTotal float64 = 0 //床位自费
  5132. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5133. var operationCostTotal float64 = 0 //手术费
  5134. var operationCostSelfTotal float64 = 0 //手术费
  5135. var operationCostPartSelfTotal float64 = 0 //手术费
  5136. var otherCostTotal float64 = 0 //其他费用
  5137. var otherCostSelfTotal float64 = 0 //其他费用
  5138. var otherCostPartSelfTotal float64 = 0 //其他费用
  5139. var materialCostTotal float64 = 0 //材料费
  5140. var materialCostSelfTotal float64 = 0 //材料费
  5141. var materialCostPartSelfTotal float64 = 0 //材料费
  5142. var westernMedicineCostTotal float64 = 0 //西药费
  5143. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5144. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5145. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5146. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5147. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5148. var checkCostTotal float64 = 0 //检查费
  5149. var checkCostSelfTotal float64 = 0 //检查费
  5150. var checkCostPartSelfTotal float64 = 0 //检查费
  5151. var laboratoryCostTotal float64 = 0 //化验费
  5152. var laboratoryCostSelfTotal float64 = 0 //化验费
  5153. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5154. var treatCostTotal float64 = 0 //治疗费用
  5155. var treatCostSelfTotal float64 = 0 //治疗费用
  5156. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5157. decimal.DivisionPrecision = 2
  5158. var bed_fulamt_ownpay_amt float64 = 0
  5159. var operation_fulamt_ownpay_amt float64 = 0
  5160. var other_fulamt_ownpay_amt float64 = 0
  5161. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5162. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5163. var check_fulamt_ownpay_amt float64 = 0
  5164. var material_fulamt_ownpay_amt float64 = 0
  5165. var laboratory_fulamt_ownpay_amt float64 = 0
  5166. var treat_fulamt_ownpay_amt float64 = 0
  5167. var bed_claa_sunmfee float64 = 0
  5168. var bed_clab_amt float64 = 0
  5169. var bed_other_amt float64 = 0
  5170. var operation_claa_sunmfee float64 = 0
  5171. var operation_clab_amt float64 = 0
  5172. var operation_other_amt float64 = 0
  5173. var other_claa_sunmfee float64 = 0
  5174. var other_clab_amt float64 = 0
  5175. var other_other_amt float64 = 0
  5176. var westernMedicine_claa_sunmfee float64 = 0
  5177. var westernMedicine_clab_amt float64 = 0
  5178. var westernMedicine_other_amt float64 = 0
  5179. var chineseTraditional_claa_sunmfee float64 = 0
  5180. var chineseTraditional_clab_amt float64 = 0
  5181. var chineseTraditional_other_amt float64 = 0
  5182. var check_claa_sunmfee float64 = 0
  5183. var check_clab_amt float64 = 0
  5184. var check_other_amt float64 = 0
  5185. var material_claa_sunmfee float64 = 0
  5186. var material_clab_amt float64 = 0
  5187. var material_other_amt float64 = 0
  5188. var laboratory_claa_sunmfee float64 = 0
  5189. var laboratory_clab_amt float64 = 0
  5190. var laboratory_other_amt float64 = 0
  5191. var treat_claa_sunmfee float64 = 0
  5192. var treat_clab_amt float64 = 0
  5193. var treat_other_amt float64 = 0
  5194. for _, item := range order.HisOrderInfo {
  5195. if item.MedChrgitmType == "01" { //床位费
  5196. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5197. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5198. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5199. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5200. if item.ChrgitmLv == "1" {
  5201. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5202. }
  5203. if item.ChrgitmLv == "2" {
  5204. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5205. }
  5206. if item.ChrgitmLv == "3" {
  5207. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5208. }
  5209. }
  5210. if item.MedChrgitmType == "03" { //检查费
  5211. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5212. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5213. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5214. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5215. if item.ChrgitmLv == "1" {
  5216. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5217. }
  5218. if item.ChrgitmLv == "2" {
  5219. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5220. }
  5221. if item.ChrgitmLv == "3" {
  5222. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5223. }
  5224. }
  5225. if item.MedChrgitmType == "04" { //化验费
  5226. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5227. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5228. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5229. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5230. if item.ChrgitmLv == "1" {
  5231. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5232. }
  5233. if item.ChrgitmLv == "2" {
  5234. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5235. }
  5236. if item.ChrgitmLv == "3" {
  5237. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5238. }
  5239. }
  5240. if item.MedChrgitmType == "05" { //治疗费
  5241. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5242. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5243. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5244. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5245. if item.ChrgitmLv == "1" {
  5246. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5247. }
  5248. if item.ChrgitmLv == "2" {
  5249. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5250. }
  5251. if item.ChrgitmLv == "3" {
  5252. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5253. }
  5254. }
  5255. if item.MedChrgitmType == "06" { //手术费
  5256. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5257. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5258. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5259. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5260. if item.ChrgitmLv == "1" {
  5261. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5262. }
  5263. if item.ChrgitmLv == "2" {
  5264. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5265. }
  5266. if item.ChrgitmLv == "3" {
  5267. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5268. }
  5269. }
  5270. if item.MedChrgitmType == "08" { //材料费
  5271. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5272. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5273. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5274. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5275. if item.ChrgitmLv == "1" {
  5276. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5277. }
  5278. if item.ChrgitmLv == "2" {
  5279. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5280. }
  5281. if item.ChrgitmLv == "3" {
  5282. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5283. }
  5284. }
  5285. if item.MedChrgitmType == "09" { //西药费
  5286. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5287. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5288. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5289. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5290. if item.ChrgitmLv == "1" {
  5291. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5292. }
  5293. if item.ChrgitmLv == "2" {
  5294. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5295. }
  5296. if item.ChrgitmLv == "3" {
  5297. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5298. }
  5299. }
  5300. if item.MedChrgitmType == "11" { //中成费
  5301. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5302. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5303. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5304. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5305. if item.ChrgitmLv == "1" {
  5306. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5307. }
  5308. if item.ChrgitmLv == "2" {
  5309. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5310. }
  5311. if item.ChrgitmLv == "3" {
  5312. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5313. }
  5314. }
  5315. if item.MedChrgitmType == "14" { //其他费
  5316. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5317. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5318. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5319. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5320. if item.ChrgitmLv == "1" {
  5321. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5322. }
  5323. if item.ChrgitmLv == "2" {
  5324. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5325. }
  5326. if item.ChrgitmLv == "3" {
  5327. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5328. }
  5329. }
  5330. }
  5331. var iteminfoStructs []service.IteminfoStruct
  5332. if bedCostTotal != 0 {
  5333. iteminfo.MedChrgitm = "01"
  5334. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5335. iteminfo.Amt = bedCostTotal
  5336. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5337. iteminfo.ClabAmt = bed_clab_amt
  5338. iteminfo.OthAmt = bed_other_amt
  5339. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5340. }
  5341. if checkCostTotal != 0 {
  5342. iteminfo.MedChrgitm = "03"
  5343. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5344. iteminfo.Amt = checkCostTotal
  5345. iteminfo.ClaaSumfee = check_claa_sunmfee
  5346. iteminfo.ClabAmt = check_clab_amt
  5347. iteminfo.OthAmt = check_other_amt
  5348. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5349. }
  5350. if laboratoryCostTotal != 0 {
  5351. iteminfo.MedChrgitm = "04"
  5352. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5353. iteminfo.Amt = laboratoryCostTotal
  5354. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5355. iteminfo.ClabAmt = laboratory_clab_amt
  5356. iteminfo.OthAmt = laboratory_other_amt
  5357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5358. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5359. }
  5360. if treatCostTotal != 0 {
  5361. iteminfo.MedChrgitm = "05"
  5362. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5363. iteminfo.Amt = treatCostTotal
  5364. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5365. iteminfo.ClabAmt = treat_clab_amt
  5366. iteminfo.OthAmt = treat_other_amt
  5367. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5368. //(struct4101.IteminfoStruct, iteminfo)
  5369. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5370. }
  5371. if operationCostTotal != 0 {
  5372. iteminfo.MedChrgitm = "06"
  5373. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5374. iteminfo.Amt = operationCostTotal
  5375. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5376. iteminfo.ClabAmt = operation_clab_amt
  5377. iteminfo.OthAmt = operation_other_amt
  5378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5379. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5380. }
  5381. if materialCostTotal != 0 {
  5382. iteminfo.MedChrgitm = "08"
  5383. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5384. iteminfo.Amt = materialCostTotal
  5385. iteminfo.ClaaSumfee = material_claa_sunmfee
  5386. iteminfo.ClabAmt = material_clab_amt
  5387. iteminfo.OthAmt = material_other_amt
  5388. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5389. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5390. }
  5391. if westernMedicineCostTotal != 0 {
  5392. iteminfo.MedChrgitm = "09"
  5393. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5394. iteminfo.Amt = westernMedicineCostTotal
  5395. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5396. iteminfo.ClabAmt = westernMedicine_clab_amt
  5397. iteminfo.OthAmt = westernMedicine_other_amt
  5398. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5399. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5400. }
  5401. if chineseTraditionalMedicineCostTotal != 0 {
  5402. iteminfo.MedChrgitm = "11"
  5403. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5404. iteminfo.Amt = westernMedicineCostTotal
  5405. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5406. iteminfo.ClabAmt = westernMedicine_clab_amt
  5407. iteminfo.OthAmt = westernMedicine_other_amt
  5408. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5409. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5410. }
  5411. if otherCostTotal != 0 {
  5412. iteminfo.MedChrgitm = "14"
  5413. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5414. iteminfo.Amt = otherCostTotal
  5415. iteminfo.ClaaSumfee = other_claa_sunmfee
  5416. iteminfo.ClabAmt = other_clab_amt
  5417. iteminfo.OthAmt = other_other_amt
  5418. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5419. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5420. }
  5421. struct4101.IteminfoStruct = iteminfoStructs
  5422. struct4101.Ntly = "中国"
  5423. struct4101.AdmCaty = "A03.06"
  5424. var resOther ResultSeventeenOther
  5425. var res ResultSeventeen
  5426. if miConfig.MdtrtareaAdmvs == "150499" {
  5427. var pp models.PublicParams
  5428. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5429. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5430. pp.FixmedinsName = miConfig.OrgName
  5431. pp.FixmedinsCode = miConfig.Code
  5432. pp.RequestUrl = miConfig.Url
  5433. pp.Cainfo = miConfig.Cainfo
  5434. pp.SecretKey = miConfig.SecretKey
  5435. pp.AccessKey = miConfig.AccessKey
  5436. pp.OpterName = curRoles.UserName
  5437. client := &http.Client{}
  5438. var req *http.Request
  5439. data := make(map[string]interface{})
  5440. data["struct4101"] = struct4101
  5441. data["pp"] = pp
  5442. bytesData, _ := json.Marshal(data)
  5443. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  5444. resp, _ := client.Do(req)
  5445. defer resp.Body.Close()
  5446. body, ioErr := ioutil.ReadAll(resp.Body)
  5447. if ioErr != nil {
  5448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5450. return
  5451. }
  5452. var respJSON map[string]interface{}
  5453. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5456. return
  5457. }
  5458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5459. userJSONBytes, _ := json.Marshal(respJSON)
  5460. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  5461. utils.ErrorLog("解析失败:%v", err)
  5462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5463. return
  5464. }
  5465. res.InfRefmsgid = resOther.InfRefmsgid
  5466. res.Output = resOther.Output
  5467. res.ErrMsg = resOther.ErrMsg
  5468. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  5469. res.Infcode = infocode
  5470. } else {
  5471. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  5472. var dat map[string]interface{}
  5473. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5474. fmt.Println(dat)
  5475. } else {
  5476. fmt.Println(err)
  5477. }
  5478. userJSONBytes, _ := json.Marshal(dat)
  5479. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5480. utils.ErrorLog("解析失败:%v", err)
  5481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5482. return
  5483. }
  5484. }
  5485. if res.Infcode != 0 {
  5486. c.ServeSuccessJSON(map[string]interface{}{
  5487. "failed_code": -10,
  5488. "msg": res.ErrMsg,
  5489. })
  5490. return
  5491. } else {
  5492. if miConfig.MdtrtareaAdmvs != "150499" {
  5493. order.FaPiaoNumber = zero
  5494. order.FaPiaoCode = last_order.FaPiaoCode
  5495. service.UpdateOrder(order)
  5496. }
  5497. hisFundSettleListResult := &models.HisFundSettleListResult{
  5498. Number: res.Output.SetlListId,
  5499. Status: 1,
  5500. Ctime: time.Now().Unix(),
  5501. Mtime: time.Now().Unix(),
  5502. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5503. IsUpload: 1,
  5504. OrderId: order_id,
  5505. }
  5506. service.CreateUploadRecord(hisFundSettleListResult)
  5507. c.ServeSuccessJSON(map[string]interface{}{
  5508. "msg": "上传成功",
  5509. "result": hisFundSettleListResult,
  5510. })
  5511. return
  5512. }
  5513. }
  5514. func (c *HisApiController) GetBatchSettleList() {
  5515. orders, _ := service.GetAllHisOrder(10106)
  5516. for _, item := range orders {
  5517. order_id := item.ID
  5518. order, _ := service.GetHisOrderByIDTwo(order_id)
  5519. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5520. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5521. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5522. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  5523. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5524. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5525. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5526. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5527. if order.ID == 0 {
  5528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5529. return
  5530. }
  5531. if his.BalanceAccountsType == 2 {
  5532. continue
  5533. }
  5534. struct4101 := service.Struct4101{
  5535. PsnNo: order.PsnNo,
  5536. MdtrtId: order.MdtrtId,
  5537. SetlId: order.SetlId,
  5538. PsnName: order.PsnName,
  5539. Gend: order.Gend,
  5540. Brdy: his.Brdy,
  5541. Age: his.Age,
  5542. Naty: order.Naty,
  5543. PatnCertType: "01",
  5544. Certno: order.Certno,
  5545. Prfs: "90",
  5546. ConerName: roles[0].UserName,
  5547. PatnRlts: "99",
  5548. ConerAddr: miConfig.OrgName,
  5549. ConerTel: admin.Mobile,
  5550. HiType: order.Insutype,
  5551. Insuplc: his.InsuplcAdmdvs,
  5552. MaindiagFlag: "1",
  5553. BillCode: order.SetlId,
  5554. BillNo: order.SetlId,
  5555. BizSn: order.Number,
  5556. PsnSelfPay: order.PsnPartAmt,
  5557. PsnOwnPay: order.PsnPartAmt,
  5558. AcctPay: order.AcctPay,
  5559. PsnCashpay: order.PsnCashPay,
  5560. HiPaymtd: "1",
  5561. Hsorg: his.InsuplcAdmdvs,
  5562. HsorgOpter: his.InsuplcAdmdvs,
  5563. MedinsFillPsn: curRoles.UserName,
  5564. MedinsFillDept: depart.Name,
  5565. IptMedType: "2",
  5566. }
  5567. struct4101.SetlBegnDate = order.SetlTime
  5568. struct4101.SetlEndDate = order.SetlTime
  5569. //if order.SettleType == 1 {
  5570. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  5571. // dateStr := t.Format("2006-01-02")
  5572. // struct4101.SetlBegnDate = dateStr
  5573. // struct4101.SetlEndDate = dateStr
  5574. //} else {
  5575. // t := time.Unix(int64(order.SettleStartTime), 0)
  5576. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  5577. // dateStartStr := t.Format("2006-01-02")
  5578. // dateEndStr := t2.Format("2006-01-02")
  5579. // struct4101.SetlBegnDate = dateStartStr
  5580. // struct4101.SetlEndDate = dateEndStr
  5581. //}
  5582. var rf []CustomFundPay
  5583. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5584. var tempFunPays []service.CustomStruct
  5585. var tempFunPay610100 service.CustomStruct
  5586. for _, item := range rf {
  5587. if item.FundPayType == "610100" {
  5588. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  5589. tempFunPay610100.FundPayType = item.FundPayType
  5590. } else {
  5591. var tempFunPay service.CustomStruct
  5592. tempFunPay.FundPayamt = item.FundPayamt
  5593. tempFunPay.FundPayType = item.FundPayType
  5594. tempFunPays = append(tempFunPays, tempFunPay)
  5595. }
  5596. }
  5597. tempFunPays = append(tempFunPays, tempFunPay610100)
  5598. struct4101.CustomStruct = tempFunPays
  5599. var tempDiaginfos []service.DiaginfoStructTwo
  5600. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5601. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5602. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5603. var config []*models.HisXtDiagnoseConfig
  5604. for _, item := range diagnosis_ids {
  5605. id, _ := strconv.ParseInt(item, 10, 64)
  5606. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5607. config = append(config, &diagnosisConfig)
  5608. }
  5609. for index, item := range config {
  5610. if index == 0 {
  5611. var tempDiaginfo service.DiaginfoStructTwo
  5612. tempDiaginfo.DiagCode = item.CountryCode
  5613. tempDiaginfo.DiagName = item.CountryContentName
  5614. tempDiaginfo.DiagType = "1"
  5615. tempDiaginfo.MaindiagFlag = "1"
  5616. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5617. } else {
  5618. var tempDiaginfo service.DiaginfoStructTwo
  5619. tempDiaginfo.DiagCode = item.CountryCode
  5620. tempDiaginfo.DiagName = item.CountryContentName
  5621. tempDiaginfo.DiagType = "2"
  5622. tempDiaginfo.MaindiagFlag = "0"
  5623. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5624. }
  5625. }
  5626. struct4101.Diseinfo = tempDiaginfos
  5627. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5628. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5629. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5630. tempOpspdiseinfo2.OprnOprtCode = ""
  5631. tempOpspdiseinfo2.OprnOprtName = ""
  5632. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5633. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5634. var iteminfo service.IteminfoStruct
  5635. var bedCostTotal float64 = 0 //床位总费
  5636. var bedCostSelfTotal float64 = 0 //床位自费
  5637. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5638. var examineCostTotal float64 = 0 //诊查总费
  5639. var examineCostSelfTotal float64 = 0 //诊查自费
  5640. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  5641. var nursingCostTotal float64 = 0 //护理总费
  5642. var nursingCostSelfTotal float64 = 0 //护理自费
  5643. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  5644. var chineseMedicineCostTotal float64 = 0 //中成药
  5645. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  5646. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  5647. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  5648. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  5649. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  5650. var registerCostTotal float64 = 0 //一般诊疗费
  5651. var registerCostSelfTotal float64 = 0 //一般诊疗费
  5652. var registerPartSelfTotal float64 = 0 //一般诊疗费
  5653. var operationCostTotal float64 = 0 //手术费
  5654. var operationCostSelfTotal float64 = 0 //手术费
  5655. var operationCostPartSelfTotal float64 = 0 //手术费
  5656. var otherCostTotal float64 = 0 //其他费用
  5657. var otherCostSelfTotal float64 = 0 //其他费用
  5658. var otherCostPartSelfTotal float64 = 0 //其他费用
  5659. var materialCostTotal float64 = 0 //材料费
  5660. var materialCostSelfTotal float64 = 0 //材料费
  5661. var materialCostPartSelfTotal float64 = 0 //材料费
  5662. var westernMedicineCostTotal float64 = 0 //西药费
  5663. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5664. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5665. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5666. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5667. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5668. var checkCostTotal float64 = 0 //检查费
  5669. var checkCostSelfTotal float64 = 0 //检查费
  5670. var checkCostPartSelfTotal float64 = 0 //检查费
  5671. var laboratoryCostTotal float64 = 0 //化验费
  5672. var laboratoryCostSelfTotal float64 = 0 //化验费
  5673. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5674. var treatCostTotal float64 = 0 //治疗费用
  5675. var treatCostSelfTotal float64 = 0 //治疗费用
  5676. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5677. decimal.DivisionPrecision = 2
  5678. var bed_fulamt_ownpay_amt float64 = 0
  5679. var examine_fulamt_ownpay_amt float64 = 0
  5680. var nursing_fulamt_ownpay_amt float64 = 0
  5681. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  5682. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  5683. var register_fulamt_ownpay_amt float64 = 0
  5684. var operation_fulamt_ownpay_amt float64 = 0
  5685. var other_fulamt_ownpay_amt float64 = 0
  5686. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5687. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5688. var check_fulamt_ownpay_amt float64 = 0
  5689. var material_fulamt_ownpay_amt float64 = 0
  5690. var laboratory_fulamt_ownpay_amt float64 = 0
  5691. var treat_fulamt_ownpay_amt float64 = 0
  5692. var bed_claa_sunmfee float64 = 0
  5693. var bed_clab_amt float64 = 0
  5694. var bed_other_amt float64 = 0
  5695. var examine_claa_sunmfee float64 = 0
  5696. var examine_clab_amt float64 = 0
  5697. var examine_other_amt float64 = 0
  5698. var nursing_claa_sunmfee float64 = 0
  5699. var nursing_clab_amt float64 = 0
  5700. var nursing_other_amt float64 = 0
  5701. var chinese_medicine_claa_sunmfee float64 = 0
  5702. var chinese_medicine_clab_amt float64 = 0
  5703. var chinese_medicine_other_amt float64 = 0
  5704. var commonly_treatment_claa_sunmfee float64 = 0
  5705. var commonly_treatment_clab_amt float64 = 0
  5706. var commonly_treatment_other_amt float64 = 0
  5707. var operation_claa_sunmfee float64 = 0
  5708. var operation_clab_amt float64 = 0
  5709. var operation_other_amt float64 = 0
  5710. var other_claa_sunmfee float64 = 0
  5711. var other_clab_amt float64 = 0
  5712. var other_other_amt float64 = 0
  5713. var westernMedicine_claa_sunmfee float64 = 0
  5714. var westernMedicine_clab_amt float64 = 0
  5715. var westernMedicine_other_amt float64 = 0
  5716. var chineseTraditional_claa_sunmfee float64 = 0
  5717. var chineseTraditional_clab_amt float64 = 0
  5718. var chineseTraditional_other_amt float64 = 0
  5719. var check_claa_sunmfee float64 = 0
  5720. var check_clab_amt float64 = 0
  5721. var check_other_amt float64 = 0
  5722. var material_claa_sunmfee float64 = 0
  5723. var material_clab_amt float64 = 0
  5724. var material_other_amt float64 = 0
  5725. var laboratory_claa_sunmfee float64 = 0
  5726. var laboratory_clab_amt float64 = 0
  5727. var laboratory_other_amt float64 = 0
  5728. var treat_claa_sunmfee float64 = 0
  5729. var treat_clab_amt float64 = 0
  5730. var treat_other_amt float64 = 0
  5731. var register_claa_sunmfee float64 = 0
  5732. var register_clab_amt float64 = 0
  5733. var register_other_amt float64 = 0
  5734. for _, item := range order.HisOrderInfo {
  5735. if item.MedChrgitmType == "01" { //床位费
  5736. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5737. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5738. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5739. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5740. if item.ChrgitmLv == "1" {
  5741. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5742. }
  5743. if item.ChrgitmLv == "2" {
  5744. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5745. }
  5746. if item.ChrgitmLv == "3" {
  5747. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5748. }
  5749. }
  5750. if item.MedChrgitmType == "02" { //诊查
  5751. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5752. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5753. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5754. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5755. if item.ChrgitmLv == "1" {
  5756. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5757. }
  5758. if item.ChrgitmLv == "2" {
  5759. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5760. }
  5761. if item.ChrgitmLv == "3" {
  5762. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5763. }
  5764. }
  5765. if item.MedChrgitmType == "03" { //检查费
  5766. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5767. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5768. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5769. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5770. if item.ChrgitmLv == "1" {
  5771. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5772. }
  5773. if item.ChrgitmLv == "2" {
  5774. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5775. }
  5776. if item.ChrgitmLv == "3" {
  5777. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5778. }
  5779. }
  5780. if item.MedChrgitmType == "04" { //化验费
  5781. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5782. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5783. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5784. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5785. if item.ChrgitmLv == "1" {
  5786. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5787. }
  5788. if item.ChrgitmLv == "2" {
  5789. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5790. }
  5791. if item.ChrgitmLv == "3" {
  5792. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5793. }
  5794. }
  5795. if item.MedChrgitmType == "05" { //治疗费
  5796. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5797. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5798. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5799. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5800. if item.ChrgitmLv == "1" {
  5801. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5802. }
  5803. if item.ChrgitmLv == "2" {
  5804. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5805. }
  5806. if item.ChrgitmLv == "3" {
  5807. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5808. }
  5809. }
  5810. if item.MedChrgitmType == "06" { //手术费
  5811. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5812. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5813. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5814. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5815. if item.ChrgitmLv == "1" {
  5816. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5817. }
  5818. if item.ChrgitmLv == "2" {
  5819. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5820. }
  5821. if item.ChrgitmLv == "3" {
  5822. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5823. }
  5824. }
  5825. if item.MedChrgitmType == "07" { //手术费
  5826. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5827. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5828. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5829. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5830. if item.ChrgitmLv == "1" {
  5831. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5832. }
  5833. if item.ChrgitmLv == "2" {
  5834. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5835. }
  5836. if item.ChrgitmLv == "3" {
  5837. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5838. }
  5839. }
  5840. if item.MedChrgitmType == "08" { //材料费
  5841. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5842. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5843. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5844. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5845. if item.ChrgitmLv == "1" {
  5846. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5847. }
  5848. if item.ChrgitmLv == "2" {
  5849. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5850. }
  5851. if item.ChrgitmLv == "3" {
  5852. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5853. }
  5854. }
  5855. if item.MedChrgitmType == "09" { //西药费
  5856. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5857. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5858. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5859. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5860. if item.ChrgitmLv == "1" {
  5861. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5862. }
  5863. if item.ChrgitmLv == "2" {
  5864. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5865. }
  5866. if item.ChrgitmLv == "3" {
  5867. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5868. }
  5869. }
  5870. if item.MedChrgitmType == "10" { //中药饮片
  5871. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5872. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5873. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5874. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5875. if item.ChrgitmLv == "1" {
  5876. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5877. }
  5878. if item.ChrgitmLv == "2" {
  5879. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5880. }
  5881. if item.ChrgitmLv == "3" {
  5882. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5883. }
  5884. }
  5885. if item.MedChrgitmType == "11" { //中成费
  5886. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5887. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5888. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5889. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5890. if item.ChrgitmLv == "1" {
  5891. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5892. }
  5893. if item.ChrgitmLv == "2" {
  5894. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5895. }
  5896. if item.ChrgitmLv == "3" {
  5897. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5898. }
  5899. }
  5900. if item.MedChrgitmType == "12" { //中成费
  5901. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5902. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5903. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5904. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5905. if item.ChrgitmLv == "1" {
  5906. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5907. }
  5908. if item.ChrgitmLv == "2" {
  5909. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5910. }
  5911. if item.ChrgitmLv == "3" {
  5912. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5913. }
  5914. }
  5915. if item.MedChrgitmType == "13" { //中成费
  5916. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5917. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5918. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5919. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5920. if item.ChrgitmLv == "1" {
  5921. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5922. }
  5923. if item.ChrgitmLv == "2" {
  5924. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5925. }
  5926. if item.ChrgitmLv == "3" {
  5927. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5928. }
  5929. }
  5930. if item.MedChrgitmType == "14" { //其他费
  5931. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5932. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5933. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5934. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5935. if item.ChrgitmLv == "1" {
  5936. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5937. }
  5938. if item.ChrgitmLv == "2" {
  5939. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5940. }
  5941. if item.ChrgitmLv == "3" {
  5942. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5943. }
  5944. }
  5945. }
  5946. var iteminfoStructs []service.IteminfoStruct
  5947. if bedCostTotal != 0 {
  5948. iteminfo.MedChrgitm = "01"
  5949. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5950. iteminfo.Amt = bedCostTotal
  5951. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5952. iteminfo.ClabAmt = bed_clab_amt
  5953. iteminfo.OthAmt = bed_other_amt
  5954. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5955. }
  5956. if examineCostTotal != 0 {
  5957. iteminfo.MedChrgitm = "02"
  5958. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5959. iteminfo.Amt = examineCostTotal
  5960. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5961. iteminfo.ClabAmt = examine_clab_amt
  5962. iteminfo.OthAmt = examine_other_amt
  5963. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5964. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5965. }
  5966. if checkCostTotal != 0 {
  5967. iteminfo.MedChrgitm = "03"
  5968. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5969. iteminfo.Amt = checkCostTotal
  5970. iteminfo.ClaaSumfee = check_claa_sunmfee
  5971. iteminfo.ClabAmt = check_clab_amt
  5972. iteminfo.OthAmt = check_other_amt
  5973. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5974. }
  5975. if laboratoryCostTotal != 0 {
  5976. iteminfo.MedChrgitm = "04"
  5977. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5978. iteminfo.Amt = laboratoryCostTotal
  5979. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5980. iteminfo.ClabAmt = laboratory_clab_amt
  5981. iteminfo.OthAmt = laboratory_other_amt
  5982. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5983. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5984. }
  5985. if treatCostTotal != 0 {
  5986. iteminfo.MedChrgitm = "05"
  5987. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5988. iteminfo.Amt = treatCostTotal
  5989. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5990. iteminfo.ClabAmt = treat_clab_amt
  5991. iteminfo.OthAmt = treat_other_amt
  5992. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5993. //(struct4101.IteminfoStruct, iteminfo)
  5994. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5995. }
  5996. if operationCostTotal != 0 {
  5997. iteminfo.MedChrgitm = "06"
  5998. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5999. iteminfo.Amt = operationCostTotal
  6000. iteminfo.ClaaSumfee = operation_claa_sunmfee
  6001. iteminfo.ClabAmt = operation_clab_amt
  6002. iteminfo.OthAmt = operation_other_amt
  6003. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6004. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6005. }
  6006. if nursingCostTotal != 0 {
  6007. iteminfo.MedChrgitm = "07"
  6008. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  6009. iteminfo.Amt = nursingCostTotal
  6010. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  6011. iteminfo.ClabAmt = nursing_clab_amt
  6012. iteminfo.OthAmt = nursing_other_amt
  6013. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6014. }
  6015. if materialCostTotal != 0 {
  6016. iteminfo.MedChrgitm = "08"
  6017. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6018. iteminfo.Amt = materialCostTotal
  6019. iteminfo.ClaaSumfee = material_claa_sunmfee
  6020. iteminfo.ClabAmt = material_clab_amt
  6021. iteminfo.OthAmt = material_other_amt
  6022. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6023. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6024. }
  6025. if westernMedicineCostTotal != 0 {
  6026. iteminfo.MedChrgitm = "09"
  6027. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6028. iteminfo.Amt = westernMedicineCostTotal
  6029. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6030. iteminfo.ClabAmt = westernMedicine_clab_amt
  6031. iteminfo.OthAmt = westernMedicine_other_amt
  6032. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6033. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6034. }
  6035. if chineseMedicineCostTotal != 0 {
  6036. iteminfo.MedChrgitm = "10"
  6037. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  6038. iteminfo.Amt = chineseMedicineCostTotal
  6039. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  6040. iteminfo.ClabAmt = chinese_medicine_clab_amt
  6041. iteminfo.OthAmt = chinese_medicine_other_amt
  6042. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6043. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6044. }
  6045. if chineseTraditionalMedicineCostTotal != 0 {
  6046. iteminfo.MedChrgitm = "11"
  6047. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6048. iteminfo.Amt = westernMedicineCostTotal
  6049. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6050. iteminfo.ClabAmt = westernMedicine_clab_amt
  6051. iteminfo.OthAmt = westernMedicine_other_amt
  6052. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6053. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6054. }
  6055. if commonlyTreatmentCostTotal != 0 {
  6056. iteminfo.MedChrgitm = "12"
  6057. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  6058. iteminfo.Amt = commonlyTreatmentCostTotal
  6059. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  6060. iteminfo.ClabAmt = commonly_treatment_clab_amt
  6061. iteminfo.OthAmt = commonly_treatment_other_amt
  6062. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6063. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6064. }
  6065. if registerCostTotal != 0 {
  6066. iteminfo.MedChrgitm = "13"
  6067. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  6068. iteminfo.Amt = registerCostTotal
  6069. iteminfo.ClaaSumfee = register_claa_sunmfee
  6070. iteminfo.ClabAmt = register_clab_amt
  6071. iteminfo.OthAmt = register_other_amt
  6072. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6073. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6074. }
  6075. if otherCostTotal != 0 {
  6076. iteminfo.MedChrgitm = "14"
  6077. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6078. iteminfo.Amt = otherCostTotal
  6079. iteminfo.ClaaSumfee = other_claa_sunmfee
  6080. iteminfo.ClabAmt = other_clab_amt
  6081. iteminfo.OthAmt = other_other_amt
  6082. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6083. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6084. }
  6085. struct4101.IteminfoStruct = iteminfoStructs
  6086. time_arr := strings.Split(order.SetlTime, " ")
  6087. struct4101.AdmTime = time_arr[0]
  6088. struct4101.AdmEndTime = time_arr[0]
  6089. struct4101.DoctorName = doctor.UserName
  6090. struct4101.DoctorCode = doctor.DoctorNumber
  6091. struct4101.Ntly = "中国"
  6092. struct4101.AdmCaty = "A03.06"
  6093. var res ResultSeventeen
  6094. if miConfig.MdtrtareaAdmvs == "421300" {
  6095. data := make(map[string]interface{})
  6096. data["struct4101"] = struct4101
  6097. data["secret_key"] = miConfig.SecretKey
  6098. data["org_name"] = miConfig.OrgName
  6099. data["opera"] = curRoles.UserName
  6100. data["code"] = miConfig.Code
  6101. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6102. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6103. client := &http.Client{}
  6104. bytesData, _ := json.Marshal(data)
  6105. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  6106. resp, _ := client.Do(req)
  6107. defer resp.Body.Close()
  6108. body, ioErr := ioutil.ReadAll(resp.Body)
  6109. if ioErr != nil {
  6110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6112. return
  6113. }
  6114. var respJSON map[string]interface{}
  6115. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6118. return
  6119. }
  6120. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6121. userJSONBytes, _ := json.Marshal(respJSON)
  6122. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6123. utils.ErrorLog("解析失败:%v", err)
  6124. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6125. adminUser := c.GetAdminUserInfo()
  6126. errlog := &models.HisOrderError{
  6127. UserOrgId: adminUser.CurrentOrgId,
  6128. Ctime: time.Now().Unix(),
  6129. Mtime: time.Now().Unix(),
  6130. ErrMsg: res.ErrMsg + "解析失败",
  6131. Status: 1,
  6132. PatientId: order_id,
  6133. Stage: 10088,
  6134. }
  6135. service.CreateErrMsgLog(errlog)
  6136. continue
  6137. }
  6138. } else {
  6139. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  6140. fmt.Println(result)
  6141. var dat map[string]interface{}
  6142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6143. fmt.Println(dat)
  6144. } else {
  6145. fmt.Println(err)
  6146. }
  6147. userJSONBytes, _ := json.Marshal(dat)
  6148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6149. utils.ErrorLog("解析失败:%v", err)
  6150. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6151. adminUser := c.GetAdminUserInfo()
  6152. errlog := &models.HisOrderError{
  6153. UserOrgId: adminUser.CurrentOrgId,
  6154. Ctime: time.Now().Unix(),
  6155. Mtime: time.Now().Unix(),
  6156. ErrMsg: res.ErrMsg + "解析失败",
  6157. Status: 1,
  6158. PatientId: order_id,
  6159. Stage: 10106,
  6160. }
  6161. service.CreateErrMsgLog(errlog)
  6162. continue
  6163. }
  6164. }
  6165. if res.Infcode != 0 {
  6166. adminUser := c.GetAdminUserInfo()
  6167. errlog := &models.HisOrderError{
  6168. UserOrgId: adminUser.CurrentOrgId,
  6169. Ctime: time.Now().Unix(),
  6170. Mtime: time.Now().Unix(),
  6171. ErrMsg: res.ErrMsg,
  6172. Status: 1,
  6173. PatientId: order_id,
  6174. Stage: 10106,
  6175. }
  6176. service.CreateErrMsgLog(errlog)
  6177. continue
  6178. } else {
  6179. hisFundSettleListResult := &models.HisFundSettleListResult{
  6180. Number: res.Output.SetlListId,
  6181. Status: 1,
  6182. Ctime: time.Now().Unix(),
  6183. Mtime: time.Now().Unix(),
  6184. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6185. IsUpload: 1,
  6186. OrderId: order_id,
  6187. }
  6188. service.CreateUploadRecord(hisFundSettleListResult)
  6189. continue
  6190. }
  6191. }
  6192. }
  6193. func (c *HisApiController) GetOrgInfo() {
  6194. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  6195. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  6196. }
  6197. func (c *HisApiController) GetHisPatientInfo() {
  6198. medical_insurance_card := c.GetString("medical_insurance_card")
  6199. id_card_type, _ := c.GetInt64("id_card_type")
  6200. id_card := c.GetString("id_card")
  6201. adminInfo := c.GetAdminUserInfo()
  6202. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6203. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6204. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  6205. IdCardNo := ""
  6206. if id_card_type == 1 {
  6207. IdCardNo = medical_insurance_card
  6208. } else if id_card_type == 2 {
  6209. IdCardNo = id_card
  6210. }
  6211. if config.IsOpen == 1 {
  6212. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6213. resp, requestErr := http.Get(api)
  6214. if requestErr != nil {
  6215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6216. return
  6217. }
  6218. defer resp.Body.Close()
  6219. body, ioErr := ioutil.ReadAll(resp.Body)
  6220. if ioErr != nil {
  6221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6223. return
  6224. }
  6225. var respJSON map[string]interface{}
  6226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6229. return
  6230. }
  6231. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6232. userJSONBytes, _ := json.Marshal(userJSON)
  6233. var res ResultTwo
  6234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6235. utils.ErrorLog("解析失败:%v", err)
  6236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6237. return
  6238. }
  6239. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6240. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6241. infoStr := string(Iinfos)
  6242. idetinfoStr := string(Idetinfos)
  6243. if res.Infcode == 0 {
  6244. his := models.VMHisPatient{
  6245. Status: 1,
  6246. Ctime: time.Now().Unix(),
  6247. Mtime: time.Now().Unix(),
  6248. PsnNo: res.Output.Baseinfo.PsnNo,
  6249. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6250. Certno: res.Output.Baseinfo.Certno,
  6251. PsnName: res.Output.Baseinfo.PsnName,
  6252. Gend: res.Output.Baseinfo.Gend,
  6253. Naty: res.Output.Baseinfo.Naty,
  6254. Brdy: res.Output.Baseinfo.Brdy,
  6255. Age: res.Output.Baseinfo.Age,
  6256. Iinfo: infoStr,
  6257. Idetinfo: idetinfoStr,
  6258. UserOrgId: adminInfo.CurrentOrgId,
  6259. IsReturn: 1,
  6260. IdCardType: id_card_type,
  6261. }
  6262. c.ServeSuccessJSON(map[string]interface{}{
  6263. "info": his,
  6264. })
  6265. } else {
  6266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6267. return
  6268. }
  6269. }
  6270. }
  6271. //func GetBasBaseInfo() (jsonStr string, err error) {
  6272. //
  6273. // handle := syscall.NewLazyDLL("SSCard.dll")
  6274. // add := handle.NewProc("ReadCardBas")
  6275. // str := make([]byte, 1024)
  6276. // str1 := make([]byte, 1024)
  6277. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6278. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  6279. //
  6280. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  6281. //
  6282. // fmt.Println("> Add(4,5)的结果为:", ret)
  6283. // handle.Release()
  6284. //
  6285. // return "", nil
  6286. //
  6287. //}
  6288. //func GetQRBaseInfo() (jsonStr string, err error) {
  6289. // handle := syscall.LoadDLL("SSCard.dll")
  6290. // ReadCardBas := handle.FindProc("GetQRBase")
  6291. //
  6292. // str := make([]byte, 256)
  6293. // str1 := make([]byte, 256)
  6294. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6295. //
  6296. // fmt.Println(string(str))
  6297. // fmt.Println(r)
  6298. // return string(str), nil
  6299. //}
  6300. //func CardInit() int {
  6301. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  6302. // add := DllTestDef.MustFindProc("Init")
  6303. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6304. // if err != nil {
  6305. // fmt.Println("SSCard的运算结果为:", ret)
  6306. // }
  6307. // result := int(ret)
  6308. // return result
  6309. //}
  6310. //func CardInit() int {
  6311. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6312. // if err != nil {
  6313. // fmt.Println("SSCard的运算结果为:", ret)
  6314. // }
  6315. // fmt.Println(err)
  6316. // result := int(ret)
  6317. // return result
  6318. //}
  6319. func IntPtr(n int) uintptr {
  6320. return uintptr(n)
  6321. }
  6322. func StrPtr(s string) uintptr {
  6323. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  6324. }
  6325. type Result2001 struct {
  6326. Cainfo interface{} `json:"cainfo"`
  6327. ErrMsg string `json:"err_msg"`
  6328. InfRefmsgid string `json:"inf_refmsgid"`
  6329. Infcode int64 `json:"infcode"`
  6330. Output struct {
  6331. Trtinfo struct {
  6332. PsnNo string `json:"psn_no"`
  6333. TrtChkType string `json:"trt_chk_type"`
  6334. FundPayType string `json:"fund_pay_type"`
  6335. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6336. Begndate string `json:"begndate"`
  6337. Enddate string `json:"enddate"`
  6338. TrtChkRslt string `json:"trt_chk_rslt"`
  6339. } `json:"trtinfo"`
  6340. } `json:"output"`
  6341. RefmsgTime string `json:"refmsg_time"`
  6342. RespondTime string `json:"respond_time"`
  6343. Signtype interface{} `json:"signtype"`
  6344. WarnMsg interface{} `json:"warn_msg"`
  6345. }
  6346. type Result2001Org10265 struct {
  6347. Cainfo interface{} `json:"cainfo"`
  6348. ErrMsg string `json:"err_msg"`
  6349. InfRefmsgid string `json:"inf_refmsgid"`
  6350. Infcode string `json:"infcode"`
  6351. Output struct {
  6352. Trtinfo struct {
  6353. PsnNo string `json:"psn_no"`
  6354. TrtChkType string `json:"trt_chk_type"`
  6355. FundPayType string `json:"fund_pay_type"`
  6356. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6357. Begndate string `json:"begndate"`
  6358. Enddate string `json:"enddate"`
  6359. TrtChkRslt string `json:"trt_chk_rslt"`
  6360. } `json:"trtinfo"`
  6361. } `json:"output"`
  6362. RefmsgTime string `json:"refmsg_time"`
  6363. RespondTime string `json:"respond_time"`
  6364. Signtype interface{} `json:"signtype"`
  6365. WarnMsg interface{} `json:"warn_msg"`
  6366. }
  6367. type ResultTwo struct {
  6368. ErrMsg string `json:"err_msg"`
  6369. InfRefmsgid string `json:"inf_refmsgid"`
  6370. Infcode int64 `json:"infcode"`
  6371. Output struct {
  6372. Baseinfo struct {
  6373. Age float64 `json:"age"`
  6374. Brdy string `json:"brdy"`
  6375. Certno string `json:"certno"`
  6376. Gend string `json:"gend"`
  6377. Naty string `json:"naty"`
  6378. PsnCertType string `json:"psn_cert_type"`
  6379. PsnName string `json:"psn_name"`
  6380. PsnNo string `json:"psn_no"`
  6381. } `json:"baseinfo"`
  6382. Idetinfo []interface{} `json:"idetinfo"`
  6383. Iinfo []struct {
  6384. Balc float64 `json:"balc"`
  6385. CvlservFlag string `json:"cvlserv_flag"`
  6386. EmpName string `json:"emp_name"`
  6387. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6388. Insutype string `json:"insutype"`
  6389. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6390. PausInsuDate string `json:"paus_insu_date"`
  6391. PsnInsuDate string `json:"psn_insu_date"`
  6392. PsnInsuStas string `json:"psn_insu_stas"`
  6393. PsnType string `json:"psn_type"`
  6394. } `json:"insuinfo"`
  6395. } `json:"output"`
  6396. RefmsgTime string `json:"refmsg_time"`
  6397. RespondTime string `json:"respond_time"`
  6398. Signtype interface{} `json:"signtype"`
  6399. WarnInfo interface{} `json:"warn_info"`
  6400. }
  6401. type ResultTwo10265 struct {
  6402. ErrMsg string `json:"err_msg"`
  6403. InfRefmsgid string `json:"inf_refmsgid"`
  6404. Infcode string `json:"infcode"`
  6405. Output struct {
  6406. Baseinfo struct {
  6407. Age float64 `json:"age"`
  6408. Brdy string `json:"brdy"`
  6409. Certno string `json:"certno"`
  6410. Gend string `json:"gend"`
  6411. Naty string `json:"naty"`
  6412. PsnCertType string `json:"psn_cert_type"`
  6413. PsnName string `json:"psn_name"`
  6414. PsnNo string `json:"psn_no"`
  6415. } `json:"baseinfo"`
  6416. Idetinfo []interface{} `json:"idetinfo"`
  6417. Iinfo []struct {
  6418. Balc float64 `json:"balc"`
  6419. CvlservFlag string `json:"cvlserv_flag"`
  6420. EmpName string `json:"emp_name"`
  6421. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6422. Insutype string `json:"insutype"`
  6423. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6424. PausInsuDate string `json:"paus_insu_date"`
  6425. PsnInsuDate string `json:"psn_insu_date"`
  6426. PsnInsuStas string `json:"psn_insu_stas"`
  6427. PsnType string `json:"psn_type"`
  6428. } `json:"insuinfo"`
  6429. } `json:"output"`
  6430. RefmsgTime string `json:"refmsg_time"`
  6431. RespondTime string `json:"respond_time"`
  6432. Signtype interface{} `json:"signtype"`
  6433. WarnInfo interface{} `json:"warn_info"`
  6434. }
  6435. type ResultThree struct {
  6436. Cainfo interface{} `json:"cainfo"`
  6437. ErrMsg string `json:"err_msg"`
  6438. InfRefmsgid string `json:"inf_refmsgid"`
  6439. Infcode int64 `json:"infcode"`
  6440. Output struct {
  6441. Data struct {
  6442. IptOtpNo string `json:"ipt_otp_no"`
  6443. MdtrtID string `json:"mdtrt_id"`
  6444. PsnNo string `json:"psn_no"`
  6445. } `json:"data"`
  6446. } `json:"output"`
  6447. RefmsgTime string `json:"refmsg_time"`
  6448. RespondTime string `json:"respond_time"`
  6449. Signtype interface{} `json:"signtype"`
  6450. WarnMsg interface{} `json:"warn_msg"`
  6451. }
  6452. type ResultThree10265 struct {
  6453. Cainfo interface{} `json:"cainfo"`
  6454. ErrMsg string `json:"err_msg"`
  6455. InfRefmsgid string `json:"inf_refmsgid"`
  6456. Infcode string `json:"infcode"`
  6457. Output struct {
  6458. Data struct {
  6459. IptOtpNo string `json:"ipt_otp_no"`
  6460. MdtrtID string `json:"mdtrt_id"`
  6461. PsnNo string `json:"psn_no"`
  6462. } `json:"data"`
  6463. } `json:"output"`
  6464. RefmsgTime string `json:"refmsg_time"`
  6465. RespondTime string `json:"respond_time"`
  6466. Signtype interface{} `json:"signtype"`
  6467. WarnMsg interface{} `json:"warn_msg"`
  6468. }
  6469. type ResultFour struct {
  6470. Cainfo string `json:"cainfo"`
  6471. ErrMsg string `json:"err_msg"`
  6472. InfRefmsgid string `json:"inf_refmsgid"`
  6473. Infcode int64 `json:"infcode"`
  6474. Output struct {
  6475. Result []struct {
  6476. BasMednFlag string `json:"bas_medn_flag"`
  6477. ChldMedcFlag string `json:"chld_medc_flag"`
  6478. ChrgitmLv string `json:"chrgitm_lv"`
  6479. Cnt float64 `json:"cnt"`
  6480. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6481. DrtReimFlag string `json:"drt_reim_flag"`
  6482. FeedetlSn string `json:"feedetl_sn"`
  6483. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6484. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6485. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6486. ListSpItemFlag string `json:"list_sp_item_flag"`
  6487. LmtUsedFlag string `json:"lmt_used_flag"`
  6488. MedChrgitmType string `json:"med_chrgitm_type"`
  6489. Memo string `json:"memo"`
  6490. OverlmtAmt float64 `json:"overlmt_amt"`
  6491. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6492. Pric float64 `json:"pric"`
  6493. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6494. SelfpayProp float64 `json:"selfpay_prop"`
  6495. } `json:"result"`
  6496. } `json:"output"`
  6497. RefmsgTime string `json:"refmsg_time"`
  6498. RespondTime string `json:"respond_time"`
  6499. Signtype string `json:"signtype"`
  6500. WarnMsg string `json:"warn_msg"`
  6501. }
  6502. type ResultFour10265 struct {
  6503. Cainfo string `json:"cainfo"`
  6504. ErrMsg string `json:"err_msg"`
  6505. InfRefmsgid string `json:"inf_refmsgid"`
  6506. Infcode string `json:"infcode"`
  6507. Output struct {
  6508. Result []struct {
  6509. BasMednFlag string `json:"bas_medn_flag"`
  6510. ChldMedcFlag string `json:"chld_medc_flag"`
  6511. ChrgitmLv string `json:"chrgitm_lv"`
  6512. Cnt float64 `json:"cnt"`
  6513. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6514. DrtReimFlag string `json:"drt_reim_flag"`
  6515. FeedetlSn string `json:"feedetl_sn"`
  6516. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6517. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6518. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6519. ListSpItemFlag string `json:"list_sp_item_flag"`
  6520. LmtUsedFlag string `json:"lmt_used_flag"`
  6521. MedChrgitmType string `json:"med_chrgitm_type"`
  6522. Memo string `json:"memo"`
  6523. OverlmtAmt float64 `json:"overlmt_amt"`
  6524. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6525. Pric float64 `json:"pric"`
  6526. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6527. SelfpayProp float64 `json:"selfpay_prop"`
  6528. } `json:"result"`
  6529. } `json:"output"`
  6530. RefmsgTime string `json:"refmsg_time"`
  6531. RespondTime string `json:"respond_time"`
  6532. Signtype string `json:"signtype"`
  6533. WarnMsg string `json:"warn_msg"`
  6534. }
  6535. type ResultMemo struct {
  6536. InsuAdmdvs string `json:"insuAdmdvs"`
  6537. }
  6538. // [{"begntime":"2022-01-01 00:00:00","endtime":"2022-12-31 00:00:00","memo":"{\"matIdetCode\":\"20\",\"insuAdmdvs\":\"350481\"}","psn_idet_type":"23","psn_type_lv":null}]
  6539. type ResultIDInfo struct {
  6540. Begntime string `json:"begntime"`
  6541. Endtime string `json:"endtime"`
  6542. Memo string `json:"memo"`
  6543. }
  6544. type ResultFive struct {
  6545. Balc float64 `json:"balc"`
  6546. CvlservFlag string `json:"cvlserv_flag"`
  6547. EmpName string `json:"emp_name"`
  6548. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6549. Insutype string `json:"insutype"`
  6550. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6551. PausInsuDate string `json:"paus_insu_date"`
  6552. PsnInsuDate string `json:"psn_insu_date"`
  6553. PsnInsuStas string `json:"psn_insu_stas"`
  6554. PsnType string `json:"psn_type"`
  6555. }
  6556. type ResultSix struct {
  6557. Cainfo interface{} `json:"cainfo"`
  6558. ErrMsg string `json:"err_msg"`
  6559. InfRefmsgid string `json:"inf_refmsgid"`
  6560. Infcode int64 `json:"infcode"`
  6561. Output struct {
  6562. } `json:"output"`
  6563. RefmsgTime string `json:"refmsg_time"`
  6564. RespondTime string `json:"respond_time"`
  6565. Signtype interface{} `json:"signtype"`
  6566. WarnMsg interface{} `json:"warn_msg"`
  6567. }
  6568. type ResultSix10265 struct {
  6569. Cainfo interface{} `json:"cainfo"`
  6570. ErrMsg string `json:"err_msg"`
  6571. InfRefmsgid string `json:"inf_refmsgid"`
  6572. Infcode string `json:"infcode"`
  6573. Output struct {
  6574. } `json:"output"`
  6575. RefmsgTime string `json:"refmsg_time"`
  6576. RespondTime string `json:"respond_time"`
  6577. Signtype interface{} `json:"signtype"`
  6578. WarnMsg interface{} `json:"warn_msg"`
  6579. }
  6580. type ResultSeven struct {
  6581. Cainfo string `json:"cainfo"`
  6582. ErrMsg string `json:"err_msg"`
  6583. InfRefmsgid string `json:"inf_refmsgid"`
  6584. Infcode int64 `json:"infcode"`
  6585. Output struct {
  6586. Setldetail []interface{} `json:"setldetail"`
  6587. Setlinfo struct {
  6588. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6589. AcctPay float64 `json:"acct_pay"`
  6590. ActPayDedc float64 `json:"act_pay_dedc"`
  6591. Age float64 `json:"age"`
  6592. Balc float64 `json:"balc"`
  6593. Brdy string `json:"brdy"`
  6594. Certno string `json:"certno"`
  6595. ClrOptins string `json:"clr_optins"`
  6596. ClrType string `json:"clr_type"`
  6597. ClrWay string `json:"clr_way"`
  6598. CvlservFlag string `json:"cvlserv_flag"`
  6599. CvlservPay float64 `json:"cvlserv_pay"`
  6600. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6601. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6602. Gend string `json:"gend"`
  6603. HifesPay float64 `json:"hifes_pay"`
  6604. HifmiPay float64 `json:"hifmi_pay"`
  6605. HifpPay float64 `json:"hifp_pay"`
  6606. HospPartAmt float64 `json:"hosp_part_amt"`
  6607. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6608. Insutype string `json:"insutype"`
  6609. MafPay float64 `json:"maf_pay"`
  6610. MdtrtCertType string `json:"mdtrt_cert_type"`
  6611. HifobPay float64 `json:"hifob_pay"`
  6612. MdtrtID string `json:"mdtrt_id"`
  6613. MedType string `json:"med_type"`
  6614. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6615. MedinsSetlID string `json:"medins_setl_id"`
  6616. Naty string `json:"naty"`
  6617. OthPay float64 `json:"oth_pay"`
  6618. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6619. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6620. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6621. PsnCashPay float64 `json:"psn_cash_pay"`
  6622. PsnCertType string `json:"psn_cert_type"`
  6623. PsnName string `json:"psn_name"`
  6624. PsnNo string `json:"psn_no"`
  6625. PsnPartAmt float64 `json:"psn_part_amt"`
  6626. PsnType string `json:"psn_type"`
  6627. SetlID string `json:"setl_id"`
  6628. SetlTime string `json:"setl_time"`
  6629. } `json:"setlinfo"`
  6630. } `json:"output"`
  6631. RefmsgTime string `json:"refmsg_time"`
  6632. RespondTime string `json:"respond_time"`
  6633. Signtype interface{} `json:"signtype"`
  6634. WarnMsg interface{} `json:"warn_msg"`
  6635. }
  6636. type ResultSeven10265 struct {
  6637. Cainfo string `json:"cainfo"`
  6638. ErrMsg string `json:"err_msg"`
  6639. InfRefmsgid string `json:"inf_refmsgid"`
  6640. Infcode string `json:"infcode"`
  6641. Output struct {
  6642. Setldetail []interface{} `json:"setldetail"`
  6643. Setlinfo struct {
  6644. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6645. AcctPay float64 `json:"acct_pay"`
  6646. ActPayDedc float64 `json:"act_pay_dedc"`
  6647. Age float64 `json:"age"`
  6648. Balc float64 `json:"balc"`
  6649. Brdy string `json:"brdy"`
  6650. Certno string `json:"certno"`
  6651. ClrOptins string `json:"clr_optins"`
  6652. ClrType string `json:"clr_type"`
  6653. ClrWay string `json:"clr_way"`
  6654. CvlservFlag string `json:"cvlserv_flag"`
  6655. CvlservPay float64 `json:"cvlserv_pay"`
  6656. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6657. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6658. Gend string `json:"gend"`
  6659. HifesPay float64 `json:"hifes_pay"`
  6660. HifmiPay float64 `json:"hifmi_pay"`
  6661. HifpPay float64 `json:"hifp_pay"`
  6662. HospPartAmt float64 `json:"hosp_part_amt"`
  6663. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6664. Insutype string `json:"insutype"`
  6665. MafPay float64 `json:"maf_pay"`
  6666. MdtrtCertType string `json:"mdtrt_cert_type"`
  6667. HifobPay float64 `json:"hifob_pay"`
  6668. MdtrtID string `json:"mdtrt_id"`
  6669. MedType string `json:"med_type"`
  6670. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6671. MedinsSetlID string `json:"medins_setl_id"`
  6672. Naty string `json:"naty"`
  6673. OthPay float64 `json:"oth_pay"`
  6674. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6675. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6676. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6677. PsnCashPay float64 `json:"psn_cash_pay"`
  6678. PsnCertType string `json:"psn_cert_type"`
  6679. PsnName string `json:"psn_name"`
  6680. PsnNo string `json:"psn_no"`
  6681. PsnPartAmt float64 `json:"psn_part_amt"`
  6682. PsnType string `json:"psn_type"`
  6683. SetlID string `json:"setl_id"`
  6684. SetlTime string `json:"setl_time"`
  6685. } `json:"setlinfo"`
  6686. } `json:"output"`
  6687. RefmsgTime string `json:"refmsg_time"`
  6688. RespondTime string `json:"respond_time"`
  6689. Signtype interface{} `json:"signtype"`
  6690. WarnMsg interface{} `json:"warn_msg"`
  6691. }
  6692. type ResultEight struct {
  6693. Cainfo string `json:"cainfo"`
  6694. ErrMsg string `json:"err_msg"`
  6695. InfRefmsgid string `json:"inf_refmsgid"`
  6696. Infcode int64 `json:"infcode"`
  6697. Output struct {
  6698. Stmtinfo struct {
  6699. SetlOptins string `json:"setl_optins"`
  6700. StmtRslt string `json:"stmt_rslt"`
  6701. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6702. } `json:"stmtinfo"`
  6703. } `json:"output"`
  6704. RefmsgTime string `json:"refmsg_time"`
  6705. RespondTime string `json:"respond_time"`
  6706. Signtype interface{} `json:"signtype"`
  6707. WarnMsg interface{} `json:"warn_msg"`
  6708. }
  6709. type ResultEightFor10188 struct {
  6710. Cainfo string `json:"cainfo"`
  6711. ErrMsg string `json:"err_msg"`
  6712. InfRefmsgid string `json:"inf_refmsgid"`
  6713. Infcode string `json:"infcode"`
  6714. Output struct {
  6715. Stmtinfo struct {
  6716. SetlOptins string `json:"setl_optins"`
  6717. StmtRslt string `json:"stmt_rslt"`
  6718. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6719. } `json:"stmtinfo"`
  6720. } `json:"output"`
  6721. RefmsgTime string `json:"refmsg_time"`
  6722. RespondTime string `json:"respond_time"`
  6723. Signtype interface{} `json:"signtype"`
  6724. WarnMsg interface{} `json:"warn_msg"`
  6725. }
  6726. type ResultNine struct {
  6727. Cainfo string `json:"cainfo"`
  6728. ErrMsg string `json:"err_msg"`
  6729. InfRefmsgid string `json:"inf_refmsgid"`
  6730. Infcode int64 `json:"infcode"`
  6731. Output struct {
  6732. FileQuryNo string `json:"file_qury_no"`
  6733. } `json:"output"`
  6734. RefmsgTime string `json:"refmsg_time"`
  6735. RespondTime string `json:"respond_time"`
  6736. Signtype interface{} `json:"signtype"`
  6737. WarnMsg interface{} `json:"warn_msg"`
  6738. }
  6739. type ResultTen struct {
  6740. Cainfo string `json:"cainfo"`
  6741. ErrMsg string `json:"err_msg"`
  6742. InfRefmsgid string `json:"inf_refmsgid"`
  6743. Infcode int64 `json:"infcode"`
  6744. Output struct {
  6745. DldEndtime string `json:"dld_endtime"`
  6746. FileQuryNo string `json:"file_qury_no"`
  6747. Filename string `json:"filename"`
  6748. } `json:"output"`
  6749. RefmsgTime string `json:"refmsg_time"`
  6750. RespondTime string `json:"respond_time"`
  6751. Signtype interface{} `json:"signtype"`
  6752. WarnMsg interface{} `json:"warn_msg"`
  6753. }
  6754. //type Autogenerated struct {
  6755. // Output struct {
  6756. // Setlinfo struct {
  6757. // SetlTime string `json:"setl_time"`
  6758. // CvlservPay float64 `json:"cvlserv_pay"`
  6759. // Year string `json:"year"`
  6760. // MedType string `json:"med_type"`
  6761. // PsnPay float64 `json:"psn_pay"`
  6762. // OpterID string `json:"opter_id"`
  6763. // Begndate string `json:"begndate"`
  6764. // FlxempeFlag string `json:"flxempe_flag"`
  6765. // HifmiPay float64 `json:"hifmi_pay"`
  6766. // PsnNo string `json:"psn_no"`
  6767. // ActPayDedc float64 `json:"act_pay_dedc"`
  6768. // MedinsSetlID interface{} `json:"medins_setl_id"`
  6769. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6770. // ClrWay string `json:"clr_way"`
  6771. // OthPay float64 `json:"oth_pay"`
  6772. // Gend string `json:"gend"`
  6773. // MdtrtID string `json:"mdtrt_id"`
  6774. // AcctPay float64 `json:"acct_pay"`
  6775. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  6776. // Insutype string `json:"insutype"`
  6777. // Invono interface{} `json:"invono"`
  6778. // Enddate string `json:"enddate"`
  6779. // CashPayamt float64 `json:"cash_payamt"`
  6780. // PsnType string `json:"psn_type"`
  6781. // FixmedinsName string `json:"fixmedins_name"`
  6782. // HifpPay float64 `json:"hifp_pay"`
  6783. // NewFlag interface{} `json:"new_flag"`
  6784. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6785. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  6786. // PayLoc string `json:"pay_loc"`
  6787. // ClrType string `json:"clr_type"`
  6788. // RefdSetlFlag string `json:"refd_setl_flag"`
  6789. // CvlservFlag string `json:"cvlserv_flag"`
  6790. // EmpName string `json:"emp_name"`
  6791. // Brdy string `json:"brdy"`
  6792. // Naty string `json:"naty"`
  6793. // Certno string `json:"certno"`
  6794. // DiseCode string `json:"dise_code"`
  6795. // FixmedinsCode string `json:"fixmedins_code"`
  6796. // DedcHospLv string `json:"dedc_hosp_lv"`
  6797. // OpterName string `json:"opter_name"`
  6798. // Balc float64 `json:"balc"`
  6799. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6800. // PsnCertType string `json:"psn_cert_type"`
  6801. // HifobPay float64 `json:"hifob_pay"`
  6802. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  6803. // HifesPay float64 `json:"hifes_pay"`
  6804. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6805. // OptTime string `json:"opt_time"`
  6806. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6807. // SetlID string `json:"setl_id"`
  6808. // MafPay float64 `json:"maf_pay"`
  6809. // PsnName string `json:"psn_name"`
  6810. // InsuOptins interface{} `json:"insu_optins"`
  6811. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6812. // ClrOptins string `json:"clr_optins"`
  6813. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6814. // DiseName string `json:"dise_name"`
  6815. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6816. // Age float64 `json:"age"`
  6817. // DtrtCertType string `json:"dtrt_cert_type"`
  6818. // HospLv string `json:"hosp_lv"`
  6819. // } `json:"setlinfo"`
  6820. // Setldetail []struct {
  6821. // FundPayType string `json:"fund_pay_type"`
  6822. // FundPayamt float64 `json:"fund_payamt"`
  6823. // SetlProcInfo interface{} `json:"setl_proc_info"`
  6824. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  6825. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  6826. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  6827. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6828. // } `json:"setldetail"`
  6829. // } `json:"output"`
  6830. // Infcode int `json:"infcode"`
  6831. // WarnMsg interface{} `json:"warn_msg"`
  6832. // Cainfo interface{} `json:"cainfo"`
  6833. // ErrMsg interface{} `json:"err_msg"`
  6834. // RefmsgTime string `json:"refmsg_time"`
  6835. // Signtype interface{} `json:"signtype"`
  6836. // RespondTime string `json:"respond_time"`
  6837. // InfRefmsgid string `json:"inf_refmsgid"`
  6838. //}
  6839. type ResultEleven struct {
  6840. Cainfo string `json:"cainfo"`
  6841. ErrMsg string `json:"err_msg"`
  6842. InfRefmsgid string `json:"inf_refmsgid"`
  6843. Infcode int64 `json:"infcode"`
  6844. Output struct {
  6845. Setlinfo struct {
  6846. SetlTime string `json:"setl_time"`
  6847. CvlservPay float64 `json:"cvlserv_pay"`
  6848. Year string `json:"year"`
  6849. MedType string `json:"med_type"`
  6850. PsnPay float64 `json:"psn_pay"`
  6851. OpterID string `json:"opter_id"`
  6852. Begndate string `json:"begndate"`
  6853. FlxempeFlag string `json:"flxempe_flag"`
  6854. HifmiPay float64 `json:"hifmi_pay"`
  6855. PsnNo string `json:"psn_no"`
  6856. ActPayDedc float64 `json:"act_pay_dedc"`
  6857. MedinsSetlID interface{} `json:"medins_setl_id"`
  6858. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6859. ClrWay string `json:"clr_way"`
  6860. OthPay float64 `json:"oth_pay"`
  6861. Gend string `json:"gend"`
  6862. MdtrtID string `json:"mdtrt_id"`
  6863. AcctPay float64 `json:"acct_pay"`
  6864. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6865. Insutype string `json:"insutype"`
  6866. Invono interface{} `json:"invono"`
  6867. Enddate string `json:"enddate"`
  6868. CashPayamt float64 `json:"cash_payamt"`
  6869. PsnType string `json:"psn_type"`
  6870. FixmedinsName string `json:"fixmedins_name"`
  6871. HifpPay float64 `json:"hifp_pay"`
  6872. NewFlag interface{} `json:"new_flag"`
  6873. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6874. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6875. PayLoc string `json:"pay_loc"`
  6876. ClrType string `json:"clr_type"`
  6877. RefdSetlFlag string `json:"refd_setl_flag"`
  6878. CvlservFlag string `json:"cvlserv_flag"`
  6879. EmpName string `json:"emp_name"`
  6880. Brdy string `json:"brdy"`
  6881. Naty string `json:"naty"`
  6882. Certno string `json:"certno"`
  6883. DiseCode string `json:"dise_code"`
  6884. FixmedinsCode string `json:"fixmedins_code"`
  6885. DedcHospLv string `json:"dedc_hosp_lv"`
  6886. OpterName string `json:"opter_name"`
  6887. Balc float64 `json:"balc"`
  6888. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6889. PsnCertType string `json:"psn_cert_type"`
  6890. HifobPay float64 `json:"hifob_pay"`
  6891. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6892. HifesPay float64 `json:"hifes_pay"`
  6893. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6894. OptTime string `json:"opt_time"`
  6895. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6896. SetlID string `json:"setl_id"`
  6897. MafPay float64 `json:"maf_pay"`
  6898. PsnName string `json:"psn_name"`
  6899. InsuOptins interface{} `json:"insu_optins"`
  6900. PrefFundPay interface{} `json:"pref_fund_pay"`
  6901. ClrOptins string `json:"clr_optins"`
  6902. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6903. DiseName string `json:"dise_name"`
  6904. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6905. Age float64 `json:"age"`
  6906. DtrtCertType string `json:"dtrt_cert_type"`
  6907. HospLv string `json:"hosp_lv"`
  6908. PsnCashPay float64
  6909. } `json:"setlinfo"`
  6910. } `json:"output"`
  6911. RefmsgTime string `json:"refmsg_time"`
  6912. RespondTime string `json:"respond_time"`
  6913. Signtype interface{} `json:"signtype"`
  6914. WarnMsg interface{} `json:"warn_msg"`
  6915. }
  6916. type ResultEleven10265 struct {
  6917. Cainfo string `json:"cainfo"`
  6918. ErrMsg string `json:"err_msg"`
  6919. InfRefmsgid string `json:"inf_refmsgid"`
  6920. Infcode string `json:"infcode"`
  6921. Output struct {
  6922. Setlinfo struct {
  6923. SetlTime string `json:"setl_time"`
  6924. CvlservPay float64 `json:"cvlserv_pay"`
  6925. Year string `json:"year"`
  6926. MedType string `json:"med_type"`
  6927. PsnPay float64 `json:"psn_pay"`
  6928. OpterID string `json:"opter_id"`
  6929. Begndate string `json:"begndate"`
  6930. FlxempeFlag string `json:"flxempe_flag"`
  6931. HifmiPay float64 `json:"hifmi_pay"`
  6932. PsnNo string `json:"psn_no"`
  6933. ActPayDedc float64 `json:"act_pay_dedc"`
  6934. MedinsSetlID interface{} `json:"medins_setl_id"`
  6935. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6936. ClrWay string `json:"clr_way"`
  6937. OthPay float64 `json:"oth_pay"`
  6938. Gend string `json:"gend"`
  6939. MdtrtID string `json:"mdtrt_id"`
  6940. AcctPay float64 `json:"acct_pay"`
  6941. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6942. Insutype string `json:"insutype"`
  6943. Invono interface{} `json:"invono"`
  6944. Enddate string `json:"enddate"`
  6945. CashPayamt float64 `json:"cash_payamt"`
  6946. PsnType string `json:"psn_type"`
  6947. FixmedinsName string `json:"fixmedins_name"`
  6948. HifpPay float64 `json:"hifp_pay"`
  6949. NewFlag interface{} `json:"new_flag"`
  6950. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6951. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6952. PayLoc string `json:"pay_loc"`
  6953. ClrType string `json:"clr_type"`
  6954. RefdSetlFlag string `json:"refd_setl_flag"`
  6955. CvlservFlag string `json:"cvlserv_flag"`
  6956. EmpName string `json:"emp_name"`
  6957. Brdy string `json:"brdy"`
  6958. Naty string `json:"naty"`
  6959. Certno string `json:"certno"`
  6960. DiseCode string `json:"dise_code"`
  6961. FixmedinsCode string `json:"fixmedins_code"`
  6962. DedcHospLv string `json:"dedc_hosp_lv"`
  6963. OpterName string `json:"opter_name"`
  6964. Balc float64 `json:"balc"`
  6965. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6966. PsnCertType string `json:"psn_cert_type"`
  6967. HifobPay float64 `json:"hifob_pay"`
  6968. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6969. HifesPay float64 `json:"hifes_pay"`
  6970. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6971. OptTime string `json:"opt_time"`
  6972. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6973. SetlID string `json:"setl_id"`
  6974. MafPay float64 `json:"maf_pay"`
  6975. PsnName string `json:"psn_name"`
  6976. InsuOptins interface{} `json:"insu_optins"`
  6977. PrefFundPay interface{} `json:"pref_fund_pay"`
  6978. ClrOptins string `json:"clr_optins"`
  6979. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6980. DiseName string `json:"dise_name"`
  6981. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6982. Age float64 `json:"age"`
  6983. DtrtCertType string `json:"dtrt_cert_type"`
  6984. HospLv string `json:"hosp_lv"`
  6985. PsnCashPay float64
  6986. } `json:"setlinfo"`
  6987. } `json:"output"`
  6988. RefmsgTime string `json:"refmsg_time"`
  6989. RespondTime string `json:"respond_time"`
  6990. Signtype interface{} `json:"signtype"`
  6991. WarnMsg interface{} `json:"warn_msg"`
  6992. }
  6993. type ResultTwelve struct {
  6994. Cainfo string `json:"cainfo"`
  6995. ErrMsg string `json:"err_msg"`
  6996. InfRefmsgid string `json:"inf_refmsgid"`
  6997. Infcode int64 `json:"infcode"`
  6998. Output struct {
  6999. MdtrtId string `json:"mdtrt_id"`
  7000. ChrgBchno string `json:"chrg_bchno"`
  7001. PsnNo string `json:"psn_no"`
  7002. } `json:"output"`
  7003. RefmsgTime string `json:"refmsg_time"`
  7004. RespondTime string `json:"respond_time"`
  7005. Signtype interface{} `json:"signtype"`
  7006. WarnMsg interface{} `json:"warn_msg"`
  7007. }
  7008. type ResultThirteen struct {
  7009. ErrMsg string `json:"err_msg"`
  7010. InfRefmsgid string `json:"inf_refmsgid"`
  7011. Infcode int64 `json:"infcode"`
  7012. Output struct {
  7013. Result struct {
  7014. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7015. } `json:"result"`
  7016. } `json:"output"`
  7017. RefmsgTime string `json:"refmsg_time"`
  7018. RespondTime string `json:"respond_time"`
  7019. Signtype interface{} `json:"signtype"`
  7020. WarnInfo interface{} `json:"warn_info"`
  7021. }
  7022. type ResultThirteen10265 struct {
  7023. ErrMsg string `json:"err_msg"`
  7024. InfRefmsgid string `json:"inf_refmsgid"`
  7025. Infcode string `json:"infcode"`
  7026. Output struct {
  7027. Result struct {
  7028. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7029. } `json:"result"`
  7030. } `json:"output"`
  7031. RefmsgTime string `json:"refmsg_time"`
  7032. RespondTime string `json:"respond_time"`
  7033. Signtype interface{} `json:"signtype"`
  7034. WarnInfo interface{} `json:"warn_info"`
  7035. }
  7036. type ResultFourteen struct {
  7037. ErrMsg string `json:"err_msg"`
  7038. InfRefmsgid string `json:"inf_refmsgid"`
  7039. Infcode int64 `json:"infcode"`
  7040. Output struct {
  7041. } `json:"output"`
  7042. RefmsgTime string `json:"refmsg_time"`
  7043. RespondTime string `json:"respond_time"`
  7044. Signtype interface{} `json:"signtype"`
  7045. WarnInfo interface{} `json:"warn_info"`
  7046. }
  7047. type ResultFourteen10265 struct {
  7048. ErrMsg string `json:"err_msg"`
  7049. InfRefmsgid string `json:"inf_refmsgid"`
  7050. Infcode string `json:"infcode"`
  7051. Output struct {
  7052. } `json:"output"`
  7053. RefmsgTime string `json:"refmsg_time"`
  7054. RespondTime string `json:"respond_time"`
  7055. Signtype interface{} `json:"signtype"`
  7056. WarnInfo interface{} `json:"warn_info"`
  7057. }
  7058. type ResultSixteen struct {
  7059. Cainfo string `json:"cainfo"`
  7060. ErrMsg string `json:"err_msg"`
  7061. InfRefmsgid string `json:"inf_refmsgid"`
  7062. Infcode int64 `json:"infcode"`
  7063. Output struct {
  7064. Setldetail []interface{} `json:"setldetail"`
  7065. Setlinfo struct {
  7066. MdtrtID string `json:"mdtrt_id"`
  7067. SetlID string `json:"setl_id"`
  7068. ClrOptins string `json:"clr_optins"`
  7069. SetlTime string `json:"setl_time"`
  7070. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7071. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7072. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7073. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7074. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7075. ActPayDedc float64 `json:"act_pay_dedc"`
  7076. HifpPay float64 `json:"hifp_pay"`
  7077. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7078. Lfpay float64 `json:"selfpay"`
  7079. CvlservPay float64 `json:"cvlserv_pay"`
  7080. HifesPay float64 `json:"hifes_pay"`
  7081. HifmiPay float64 `json:"hifmi_pay"`
  7082. HifobPay float64 `json:"hifob_pay"`
  7083. MafPay float64 `json:"maf_pay"`
  7084. OthPay float64 `json:"oth_pay"`
  7085. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7086. PsnPartAmt float64 `json:"psn_part_amt"`
  7087. AcctPay float64 `json:"acct_pay"`
  7088. Balc float64 `json:"balc"`
  7089. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7090. HospPartAmt float64 `json:"hosp_part_amt"`
  7091. MedinsSetlID string `json:"medins_setl_id"`
  7092. PdnCashPay string `json:"pdn_cash_pay"`
  7093. } `json:"setlinfo"`
  7094. } `json:"output"`
  7095. RefmsgTime string `json:"refmsg_time"`
  7096. RespondTime string `json:"respond_time"`
  7097. Signtype interface{} `json:"signtype"`
  7098. WarnMsg interface{} `json:"warn_msg"`
  7099. }
  7100. type ResultSixteen10265 struct {
  7101. Cainfo string `json:"cainfo"`
  7102. ErrMsg string `json:"err_msg"`
  7103. InfRefmsgid string `json:"inf_refmsgid"`
  7104. Infcode string `json:"infcode"`
  7105. Output struct {
  7106. Setldetail []interface{} `json:"setldetail"`
  7107. Setlinfo struct {
  7108. MdtrtID string `json:"mdtrt_id"`
  7109. SetlID string `json:"setl_id"`
  7110. ClrOptins string `json:"clr_optins"`
  7111. SetlTime string `json:"setl_time"`
  7112. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7113. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7114. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7115. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7116. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7117. ActPayDedc float64 `json:"act_pay_dedc"`
  7118. HifpPay float64 `json:"hifp_pay"`
  7119. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7120. Lfpay float64 `json:"selfpay"`
  7121. CvlservPay float64 `json:"cvlserv_pay"`
  7122. HifesPay float64 `json:"hifes_pay"`
  7123. HifmiPay float64 `json:"hifmi_pay"`
  7124. HifobPay float64 `json:"hifob_pay"`
  7125. MafPay float64 `json:"maf_pay"`
  7126. OthPay float64 `json:"oth_pay"`
  7127. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7128. PsnPartAmt float64 `json:"psn_part_amt"`
  7129. AcctPay float64 `json:"acct_pay"`
  7130. Balc float64 `json:"balc"`
  7131. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7132. HospPartAmt float64 `json:"hosp_part_amt"`
  7133. MedinsSetlID string `json:"medins_setl_id"`
  7134. PdnCashPay string `json:"pdn_cash_pay"`
  7135. } `json:"setlinfo"`
  7136. } `json:"output"`
  7137. RefmsgTime string `json:"refmsg_time"`
  7138. RespondTime string `json:"respond_time"`
  7139. Signtype interface{} `json:"signtype"`
  7140. WarnMsg interface{} `json:"warn_msg"`
  7141. }
  7142. type ResultSeventeen struct {
  7143. ErrMsg string `json:"err_msg"`
  7144. InfRefmsgid string `json:"inf_refmsgid"`
  7145. Infcode int64 `json:"infcode"`
  7146. Output struct {
  7147. SetlListId string `json:"setl_list_id"`
  7148. } `json:"output"`
  7149. RefmsgTime string `json:"refmsg_time"`
  7150. RespondTime string `json:"respond_time"`
  7151. Signtype string `json:"signtype"`
  7152. WarnInfo string `json:"warn_info"`
  7153. }
  7154. type ResultSeventeenOther struct {
  7155. ErrMsg string `json:"err_msg"`
  7156. InfRefmsgid string `json:"inf_refmsgid"`
  7157. Infcode string `json:"infcode"`
  7158. Output struct {
  7159. SetlListId string `json:"setl_list_id"`
  7160. } `json:"output"`
  7161. RefmsgTime string `json:"refmsg_time"`
  7162. RespondTime string `json:"respond_time"`
  7163. Signtype string `json:"signtype"`
  7164. WarnInfo string `json:"warn_info"`
  7165. }
  7166. type Result90991 struct {
  7167. ErrMsg string `json:"err_msg"`
  7168. InfRefmsgid string `json:"inf_refmsgid"`
  7169. Infcode int64 `json:"infcode"`
  7170. Output struct {
  7171. Result struct {
  7172. PsnNo string `json:"psn_no"`
  7173. CardStat string `json:"card_stat"`
  7174. Certno string `json:"certno"`
  7175. PsnName string `json:"psn_name"`
  7176. CheckStat string `json:"check_stat"`
  7177. SscnoCheckStat string `json:"sscno_check_stat"`
  7178. } `json:"result"`
  7179. } `json:"output"`
  7180. RefmsgTime string `json:"refmsg_time"`
  7181. RespondTime string `json:"respond_time"`
  7182. Signtype interface{} `json:"signtype"`
  7183. WarnInfo interface{} `json:"warn_info"`
  7184. }
  7185. type Result90100 struct {
  7186. ErrMsg string `json:"err_msg"`
  7187. InfRefmsgid string `json:"inf_refmsgid"`
  7188. Infcode int64 `json:"infcode"`
  7189. Output struct {
  7190. PoolareaNo string `json:"poolarea_no"`
  7191. PoolareaNoName string `json:"poolarea_no_name"`
  7192. Insutype string `json:"insutype"`
  7193. InsutypeName string `json:"insutype_name"`
  7194. ClctType string `json:"clct_type"`
  7195. ClctTypeName string `json:"clct_type_name"`
  7196. ClctFlag string `json:"clct_flag"`
  7197. ClctFlagName string `json:"clct_flag_name"`
  7198. AccrymBegn string `json:"accrym_begn"`
  7199. AccrymEnd string `json:"accrym_end"`
  7200. ClctTime string `json:"clct_time"`
  7201. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  7202. } `json:"output"`
  7203. RefmsgTime string `json:"refmsg_time"`
  7204. RespondTime string `json:"respond_time"`
  7205. Signtype interface{} `json:"signtype"`
  7206. WarnInfo interface{} `json:"warn_info"`
  7207. }
  7208. type Custom struct {
  7209. DetItemFeeSumamt string
  7210. Cut string
  7211. FeedetlSn string
  7212. Price string
  7213. MedListCodg string
  7214. Type int64
  7215. AdviceId int64
  7216. ProjectId int64
  7217. ItemId int64
  7218. }
  7219. type Result5301 struct {
  7220. ErrMsg string `json:"err_msg"`
  7221. InfRefmsgid string `json:"inf_refmsgid"`
  7222. Infcode int64 `json:"infcode"`
  7223. Output struct {
  7224. Result []struct {
  7225. OpspDiseCode string `json:"opsp_dise_code"`
  7226. OpspDiseName string `json:"opsp_dise_name"`
  7227. Begndate string `json:"begndate"`
  7228. Enddate string `json:"enddate"`
  7229. } `json:"feedetail"`
  7230. } `json:"output"`
  7231. RefmsgTime string `json:"refmsg_time"`
  7232. RespondTime string `json:"respond_time"`
  7233. Signtype interface{} `json:"signtype"`
  7234. WarnInfo interface{} `json:"warn_info"`
  7235. }
  7236. type Result5301For10265 struct {
  7237. ErrMsg string `json:"err_msg"`
  7238. InfRefmsgid string `json:"inf_refmsgid"`
  7239. Infcode string `json:"infcode"`
  7240. Output struct {
  7241. Result []struct {
  7242. OpspDiseCode string `json:"opsp_dise_code"`
  7243. OpspDiseName string `json:"opsp_dise_name"`
  7244. Begndate string `json:"begndate"`
  7245. Enddate string `json:"enddate"`
  7246. } `json:"feedetail"`
  7247. } `json:"output"`
  7248. RefmsgTime string `json:"refmsg_time"`
  7249. RespondTime string `json:"respond_time"`
  7250. Signtype interface{} `json:"signtype"`
  7251. WarnInfo interface{} `json:"warn_info"`
  7252. }
  7253. //获取个人信息----挂号-----上传就诊信息
  7254. func (c *HisApiController) GetRegisterInfo() {
  7255. id, _ := c.GetInt64("id")
  7256. record_time := c.GetString("record_time")
  7257. settlementValue, _ := c.GetInt64("settlement_value")
  7258. medical_insurance_card := c.GetString("medical_insurance_card")
  7259. name := c.GetString("name")
  7260. id_card_type, _ := c.GetInt64("id_card_type")
  7261. certificates, _ := c.GetInt64("certificates")
  7262. medical_care, _ := c.GetInt64("medical_care")
  7263. birthday := c.GetString("birthday")
  7264. id_card := c.GetString("id_card")
  7265. register_type, _ := c.GetInt64("register")
  7266. doctor, _ := c.GetInt64("doctor")
  7267. department, _ := c.GetInt64("department")
  7268. gender, _ := c.GetInt64("sex")
  7269. registration_fee, _ := c.GetFloat("registration_fee")
  7270. medical_expenses, _ := c.GetFloat("medical_expenses")
  7271. social_type, _ := c.GetInt64("social_type")
  7272. med_type := c.GetString("social_type")
  7273. admin_user_id, _ := c.GetInt64("admin_user_id")
  7274. insuplc_admdvs := c.GetString("insuplc_admdvs")
  7275. mdtrt_type := c.GetString("mdtrt_type")
  7276. timeLayout := "2006-01-02"
  7277. loc, _ := time.LoadLocation("Local")
  7278. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  7279. birthUnix := birthdays.Unix()
  7280. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7281. if err != nil {
  7282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7283. return
  7284. }
  7285. recordDateTime := theTime.Unix()
  7286. adminInfo := c.GetAdminUserInfo()
  7287. var patient service.Patients
  7288. if id == 0 {
  7289. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  7290. } else {
  7291. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  7292. }
  7293. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7294. if patientPrescription.ID == 0 {
  7295. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7296. }
  7297. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7298. if patient.ID == 0 {
  7299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7300. return
  7301. }
  7302. if len(patient.IdCardNo) == 0 {
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7304. return
  7305. }
  7306. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7307. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  7308. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  7309. //就诊结算未完成,不能进行二次挂号
  7310. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  7311. if len(his) >= 1 {
  7312. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  7313. if len(his) >= 1 && order.ID == 0 {
  7314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  7315. return
  7316. }
  7317. }
  7318. //var register_log string
  7319. if config.IsOpen == 1 {
  7320. var res ResultTwo
  7321. var res10265 ResultTwo10265
  7322. var PsnNo string
  7323. var PsnCertType string
  7324. var Certno string
  7325. var PsnName string
  7326. var Gend string
  7327. var Naty string
  7328. var Brdy string
  7329. var Age float64
  7330. var infoStr string
  7331. var idetinfoStr string
  7332. var infocode int64
  7333. var verify_number string
  7334. fmt.Println(verify_number)
  7335. if miConfig.MdtrtareaAdmvs == "421300" {
  7336. psn_info, _ := service.GetPsnByPatientId(id)
  7337. PsnNo = psn_info.PsnNo
  7338. PsnCertType = psn_info.PsnCertType
  7339. Certno = psn_info.Certno
  7340. PsnName = psn_info.PsnName
  7341. Gend = psn_info.Gend
  7342. Naty = psn_info.Naty
  7343. Brdy = psn_info.Brdy
  7344. Age = psn_info.Age
  7345. infoStr = psn_info.Insuinfo
  7346. idetinfoStr = psn_info.Idetinfo
  7347. infocode = 0
  7348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7349. psn_info, _ := service.GetPsnByPatientId(id)
  7350. PsnNo = psn_info.PsnNo
  7351. PsnCertType = psn_info.PsnCertType
  7352. Certno = psn_info.Certno
  7353. PsnName = psn_info.PsnName
  7354. Gend = psn_info.Gend
  7355. Naty = psn_info.Naty
  7356. Brdy = psn_info.Brdy
  7357. Age = psn_info.Age
  7358. infoStr = psn_info.Insuinfo
  7359. idetinfoStr = psn_info.Idetinfo
  7360. infocode = 0
  7361. verify_number = psn_info.VerifyNumber
  7362. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7363. if id_card_type == 1 {
  7364. psn_info, _ := service.GetPsnByPatientId(id)
  7365. PsnNo = psn_info.PsnNo
  7366. PsnCertType = psn_info.PsnCertType
  7367. Certno = psn_info.Certno
  7368. PsnName = psn_info.PsnName
  7369. Gend = psn_info.Gend
  7370. Naty = psn_info.Naty
  7371. Brdy = psn_info.Brdy
  7372. Age = psn_info.Age
  7373. infoStr = psn_info.Insuinfo
  7374. idetinfoStr = psn_info.Idetinfo
  7375. infocode = 0
  7376. verify_number = psn_info.VerifyNumber
  7377. } else if id_card_type == 2 {
  7378. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, "")
  7379. fmt.Println(errMsgLog)
  7380. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7381. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7382. utils.ErrorLog("解析失败:%v", err)
  7383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7384. return
  7385. }
  7386. PsnNo = res.Output.Baseinfo.PsnNo
  7387. PsnCertType = res.Output.Baseinfo.PsnCertType
  7388. Certno = res.Output.Baseinfo.Certno
  7389. PsnName = res.Output.Baseinfo.PsnName
  7390. Gend = res.Output.Baseinfo.Gend
  7391. Naty = res.Output.Baseinfo.Naty
  7392. Brdy = res.Output.Baseinfo.Brdy
  7393. Age = res.Output.Baseinfo.Age
  7394. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7395. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7396. infoStr = string(Iinfos)
  7397. idetinfoStr = string(Idetinfos)
  7398. infocode = res.Infcode
  7399. }
  7400. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7401. if id_card_type == 1 {
  7402. psn_info, _ := service.GetPsnByPatientId(id)
  7403. PsnNo = psn_info.PsnNo
  7404. PsnCertType = psn_info.PsnCertType
  7405. Certno = psn_info.Certno
  7406. PsnName = psn_info.PsnName
  7407. Gend = psn_info.Gend
  7408. Naty = psn_info.Naty
  7409. Brdy = psn_info.Brdy
  7410. Age = psn_info.Age
  7411. infoStr = psn_info.Insuinfo
  7412. idetinfoStr = psn_info.Idetinfo
  7413. infocode = 0
  7414. verify_number = psn_info.VerifyNumber
  7415. } else if id_card_type == 2 {
  7416. result, requestLog := service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "")
  7417. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7418. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7419. utils.ErrorLog("解析失败:%v", err)
  7420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7421. return
  7422. }
  7423. PsnNo = res.Output.Baseinfo.PsnNo
  7424. PsnCertType = res.Output.Baseinfo.PsnCertType
  7425. Certno = res.Output.Baseinfo.Certno
  7426. PsnName = res.Output.Baseinfo.PsnName
  7427. Gend = res.Output.Baseinfo.Gend
  7428. Naty = res.Output.Baseinfo.Naty
  7429. Brdy = res.Output.Baseinfo.Brdy
  7430. Age = res.Output.Baseinfo.Age
  7431. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7432. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7433. infoStr = string(Iinfos)
  7434. idetinfoStr = string(Idetinfos)
  7435. infocode = res.Infcode
  7436. }
  7437. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7438. if id_card_type == 1 {
  7439. psn_info, _ := service.GetPsnByPatientId(id)
  7440. PsnNo = psn_info.PsnNo
  7441. PsnCertType = psn_info.PsnCertType
  7442. Certno = psn_info.Certno
  7443. PsnName = psn_info.PsnName
  7444. Gend = psn_info.Gend
  7445. Naty = psn_info.Naty
  7446. Brdy = psn_info.Brdy
  7447. Age = psn_info.Age
  7448. infoStr = psn_info.Insuinfo
  7449. idetinfoStr = psn_info.Idetinfo
  7450. infocode = 0
  7451. verify_number = psn_info.VerifyNumber
  7452. } else if id_card_type == 2 {
  7453. result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", "", Certno)
  7454. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7455. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7456. utils.ErrorLog("解析失败:%v", err)
  7457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7458. return
  7459. }
  7460. PsnNo = res.Output.Baseinfo.PsnNo
  7461. PsnCertType = res.Output.Baseinfo.PsnCertType
  7462. Certno = res.Output.Baseinfo.Certno
  7463. PsnName = res.Output.Baseinfo.PsnName
  7464. Gend = res.Output.Baseinfo.Gend
  7465. Naty = res.Output.Baseinfo.Naty
  7466. Brdy = res.Output.Baseinfo.Brdy
  7467. Age = res.Output.Baseinfo.Age
  7468. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7469. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7470. infoStr = string(Iinfos)
  7471. idetinfoStr = string(Idetinfos)
  7472. infocode = res.Infcode
  7473. }
  7474. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7475. var result string
  7476. var requestLog string
  7477. result, requestLog = service.HeBeiyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), "")
  7478. if id_card_type == 4 {
  7479. psn_info, _ := service.GetPsnByPatientId(id)
  7480. PsnNo = psn_info.PsnNo
  7481. PsnCertType = psn_info.PsnCertType
  7482. Certno = psn_info.Certno
  7483. PsnName = psn_info.PsnName
  7484. Gend = psn_info.Gend
  7485. Naty = psn_info.Naty
  7486. Brdy = psn_info.Brdy
  7487. Age = psn_info.Age
  7488. infoStr = psn_info.Insuinfo
  7489. idetinfoStr = psn_info.Idetinfo
  7490. infocode = 0
  7491. verify_number = psn_info.VerifyNumber
  7492. } else {
  7493. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7494. if miConfig.Code == "H15049901371" {
  7495. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7496. utils.ErrorLog("解析失败:%v", err)
  7497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7498. return
  7499. }
  7500. res.ErrMsg = res10265.ErrMsg
  7501. res.Output = res10265.Output
  7502. res.InfRefmsgid = res10265.InfRefmsgid
  7503. } else {
  7504. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7505. utils.ErrorLog("解析失败:%v", err)
  7506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7507. return
  7508. }
  7509. }
  7510. PsnNo = res.Output.Baseinfo.PsnNo
  7511. PsnCertType = res.Output.Baseinfo.PsnCertType
  7512. Certno = res.Output.Baseinfo.Certno
  7513. PsnName = res.Output.Baseinfo.PsnName
  7514. Gend = res.Output.Baseinfo.Gend
  7515. Naty = res.Output.Baseinfo.Naty
  7516. Brdy = res.Output.Baseinfo.Brdy
  7517. Age = res.Output.Baseinfo.Age
  7518. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7519. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7520. infoStr = string(Iinfos)
  7521. idetinfoStr = string(Idetinfos)
  7522. if miConfig.Code == "H15049901371" {
  7523. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7524. } else {
  7525. infocode = res.Infcode
  7526. }
  7527. }
  7528. } else {
  7529. var result string
  7530. var requestLog string
  7531. if miConfig.UserOrgId == 10138 {
  7532. if id_card_type != 4 || id_card_type != 1 {
  7533. var insa string
  7534. if len(patient.InsuplcAdmdvs) > 0 {
  7535. insa = patient.InsuplcAdmdvs
  7536. } else {
  7537. insa = miConfig.InsuplcAdmdvs
  7538. }
  7539. //psn_info, _ := service.GetPsnByPatientId(id)
  7540. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  7541. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  7542. }
  7543. } else {
  7544. var insa string
  7545. if len(patient.InsuplcAdmdvs) > 0 {
  7546. insa = patient.InsuplcAdmdvs
  7547. } else {
  7548. insa = miConfig.InsuplcAdmdvs
  7549. }
  7550. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  7551. }
  7552. if id_card_type == 4 || id_card_type == 1 {
  7553. psn_info, _ := service.GetPsnByPatientId(id)
  7554. PsnNo = psn_info.PsnNo
  7555. PsnCertType = psn_info.PsnCertType
  7556. Certno = psn_info.Certno
  7557. PsnName = psn_info.PsnName
  7558. Gend = psn_info.Gend
  7559. Naty = psn_info.Naty
  7560. Brdy = psn_info.Brdy
  7561. Age = psn_info.Age
  7562. infoStr = psn_info.Insuinfo
  7563. idetinfoStr = psn_info.Idetinfo
  7564. infocode = 0
  7565. verify_number = psn_info.VerifyNumber
  7566. } else {
  7567. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7568. if miConfig.Code == "H15049901371" {
  7569. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7570. utils.ErrorLog("解析失败:%v", err)
  7571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7572. return
  7573. }
  7574. res.ErrMsg = res10265.ErrMsg
  7575. res.Output = res10265.Output
  7576. res.InfRefmsgid = res10265.InfRefmsgid
  7577. } else {
  7578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7579. utils.ErrorLog("解析失败:%v", err)
  7580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7581. return
  7582. }
  7583. }
  7584. PsnNo = res.Output.Baseinfo.PsnNo
  7585. PsnCertType = res.Output.Baseinfo.PsnCertType
  7586. Certno = res.Output.Baseinfo.Certno
  7587. PsnName = res.Output.Baseinfo.PsnName
  7588. Gend = res.Output.Baseinfo.Gend
  7589. Naty = res.Output.Baseinfo.Naty
  7590. Brdy = res.Output.Baseinfo.Brdy
  7591. Age = res.Output.Baseinfo.Age
  7592. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7593. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7594. infoStr = string(Iinfos)
  7595. idetinfoStr = string(Idetinfos)
  7596. if miConfig.Code == "H15049901371" {
  7597. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7598. } else {
  7599. infocode = res.Infcode
  7600. }
  7601. }
  7602. }
  7603. if infocode == 0 {
  7604. his := models.VMHisPatient{
  7605. Name: name,
  7606. Gender: gender,
  7607. Birthday: birthUnix,
  7608. MedicalTreatmentType: medical_care,
  7609. IdType: certificates,
  7610. IdCardNo: id_card,
  7611. BalanceAccountsType: settlementValue,
  7612. SocialType: social_type,
  7613. MedicalInsuranceNumber: medical_insurance_card,
  7614. RegisterType: register_type,
  7615. RegisterCost: registration_fee,
  7616. TreatmentCost: medical_expenses,
  7617. Status: 1,
  7618. Ctime: time.Now().Unix(),
  7619. Mtime: time.Now().Unix(),
  7620. PsnNo: PsnNo,
  7621. PsnCertType: PsnCertType,
  7622. Certno: Certno,
  7623. PsnName: PsnName,
  7624. Gend: Gend,
  7625. Naty: Naty,
  7626. Brdy: Brdy,
  7627. Age: Age,
  7628. Iinfo: infoStr,
  7629. Idetinfo: idetinfoStr,
  7630. PatientId: patient.ID,
  7631. RecordDate: theTime.Unix(),
  7632. UserOrgId: adminInfo.CurrentOrgId,
  7633. AdminUserId: admin_user_id,
  7634. IsReturn: 1,
  7635. IdCardType: id_card_type,
  7636. Doctor: doctor,
  7637. Departments: department,
  7638. MdtrtGrpType: mdtrt_type,
  7639. }
  7640. timestamp := time.Now().Unix()
  7641. tempTime := time.Unix(timestamp, 0)
  7642. timeFormat := tempTime.Format("20060102150405")
  7643. chrgBchno := rand.Intn(100000) + 10000
  7644. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7645. his.Number = ipt_otp_no
  7646. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  7647. department, _ := service.GetDepartMentDetail(department)
  7648. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  7649. IdCardNo := ""
  7650. if id_card_type == 1 {
  7651. // IdCardNo = medical_insurance_card
  7652. IdCardNo = patient.IdCardNo
  7653. } else {
  7654. IdCardNo = patient.IdCardNo
  7655. }
  7656. var rf []*ResultFive
  7657. json.Unmarshal([]byte(his.Iinfo), &rf)
  7658. var insutypes []*ResultFive
  7659. var insutype string
  7660. var insuplc_admdvs_temp string
  7661. var is390 int = 0
  7662. var is310 int = 0
  7663. for _, item := range rf {
  7664. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7665. insutypes = append(insutypes, item)
  7666. }
  7667. }
  7668. if len(insutypes) == 1 {
  7669. insutype = insutypes[0].Insutype
  7670. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7671. } else {
  7672. for _, i := range insutypes {
  7673. if i.Insutype == "390" {
  7674. is390 = 1
  7675. }
  7676. if i.Insutype == "310" {
  7677. is310 = 1
  7678. }
  7679. }
  7680. }
  7681. if is390 == 1 {
  7682. insutype = "390"
  7683. }
  7684. if is310 == 1 {
  7685. insutype = "310"
  7686. }
  7687. if len(insutypes) == 0 {
  7688. insutype = "390"
  7689. }
  7690. if len(insutypes) == 2 {
  7691. insutype = med_type
  7692. }
  7693. if len(med_type) > 0 {
  7694. insutype = med_type
  7695. }
  7696. var infocode int64
  7697. var resThree ResultThree
  7698. var resThree10265 ResultThree10265
  7699. if len(insuplc_admdvs) == 0 {
  7700. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  7701. } else {
  7702. insuplc_admdvs_temp = insuplc_admdvs
  7703. }
  7704. if miConfig.MdtrtareaAdmvs == "350500" {
  7705. var rf []*ResultIDInfo
  7706. json.Unmarshal([]byte(idetinfoStr), &rf)
  7707. if len(rf) > 0 {
  7708. if len(rf[0].Memo) > 0 {
  7709. content := rf[0].Memo[1:len(rf[0].Memo)]
  7710. content2 := content[:len(content)-1]
  7711. fmt.Println(content2)
  7712. //var rf2 ResultMemo
  7713. //json.Unmarshal([]byte(content2), &rf2)
  7714. //fmt.Println(rf2)
  7715. //fmt.Println(rf2.InsuAdmdvs)
  7716. arr := strings.Split(content2, ",")
  7717. var tarstring string
  7718. for _, item := range arr {
  7719. if find := strings.Contains(item, "insuAdmdvs"); find {
  7720. tarstring = item
  7721. }
  7722. }
  7723. fmt.Println(tarstring)
  7724. if len(tarstring) > 0 {
  7725. arr := strings.Split(tarstring, ":")
  7726. insuplc_admdvs_temp = strings.Replace(arr[1], "\"", "", -1)
  7727. //insuplc_admdvs_temp = arr[1]
  7728. }
  7729. }
  7730. }
  7731. }
  7732. if miConfig.MdtrtareaAdmvs == "421300" {
  7733. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  7734. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  7735. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7736. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  7737. resp, requestErr := http.Get(api)
  7738. if requestErr != nil {
  7739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7740. return
  7741. }
  7742. body, ioErr := ioutil.ReadAll(resp.Body)
  7743. if ioErr != nil {
  7744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7746. return
  7747. }
  7748. var respJSON map[string]interface{}
  7749. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. return
  7753. }
  7754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7755. result, _ := json.Marshal(respJSON)
  7756. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7757. utils.ErrorLog("解析失败:%v", err)
  7758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7759. return
  7760. }
  7761. infocode = resThree.Infcode
  7762. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7763. psn_info, _ := service.GetPsnByPatientId(id)
  7764. his.PsnNo = psn_info.PsnNo
  7765. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7766. var cert_no string
  7767. if id_card_type == 3 {
  7768. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  7769. cert_no = IdCardNo
  7770. } else if id_card_type == 4 {
  7771. cert_no = IdCardNo
  7772. psn_info.VerifyNumber = psn_info.VerifyNumber
  7773. } else {
  7774. bas := strings.Split(psn_info.CardInfo, "|")
  7775. cert_no = bas[2]
  7776. }
  7777. var hisPrescription []*models.HisPrescription
  7778. for _, item := range rf {
  7779. if item.Insutype == insutype {
  7780. //insuplc_admdvs = item.InsuplcAdmdvs
  7781. his.InsuplcAdmdvs = insuplc_admdvs
  7782. }
  7783. }
  7784. his.Insutype = insutype
  7785. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  7786. fmt.Println(res3101)
  7787. fmt.Println(res3101.Infcode)
  7788. if res3101.Infcode == "0" {
  7789. fmt.Println("33333333")
  7790. if len(res3101.Output.Result) > 0 {
  7791. fmt.Println("222222")
  7792. for _, item := range res3101.Output.Result {
  7793. if len(res3101.ErrMsg) == 0 {
  7794. res3101.ErrMsg = item.VolaCont
  7795. } else {
  7796. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  7797. }
  7798. }
  7799. c.ServeSuccessJSON(map[string]interface{}{
  7800. "failed_code": -10,
  7801. "msg": res3101.ErrMsg,
  7802. })
  7803. return
  7804. } else {
  7805. fmt.Println("11111")
  7806. var api string
  7807. if miConfig.MdtrtareaAdmvs == "320921" {
  7808. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7809. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7810. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7811. } else {
  7812. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7813. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7814. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7815. }
  7816. resp, requestErr := http.Get(api)
  7817. if requestErr != nil {
  7818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7819. return
  7820. }
  7821. body, ioErr := ioutil.ReadAll(resp.Body)
  7822. if ioErr != nil {
  7823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7825. return
  7826. }
  7827. var respJSON map[string]interface{}
  7828. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7831. return
  7832. }
  7833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7834. result, _ := json.Marshal(respJSON)
  7835. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7836. utils.ErrorLog("解析失败:%v", err)
  7837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7838. return
  7839. }
  7840. resThree.ErrMsg = resThree10265.ErrMsg
  7841. resThree.Output = resThree10265.Output
  7842. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7843. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7844. }
  7845. } else if res3101.Infcode != "0" {
  7846. c.ServeSuccessJSON(map[string]interface{}{
  7847. "failed_code": -10,
  7848. "msg": res3101.ErrMsg,
  7849. })
  7850. return
  7851. }
  7852. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7853. psn_info, _ := service.GetPsnByPatientId(id)
  7854. var cert_no string
  7855. if id_card_type == 1 {
  7856. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7857. } else if id_card_type == 4 {
  7858. cert_no = psn_info.VerifyNumber
  7859. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7860. } else {
  7861. cert_no = psn_info.VerifyNumber
  7862. }
  7863. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no, record_time)
  7864. saveLog(result, requestLog, "2201", "挂号")
  7865. if miConfig.Code == "H15049901371" {
  7866. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7867. utils.ErrorLog("解析失败:%v", err)
  7868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7869. return
  7870. }
  7871. resThree.ErrMsg = resThree10265.ErrMsg
  7872. resThree.Output = resThree10265.Output
  7873. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7874. } else {
  7875. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7876. utils.ErrorLog("解析失败:%v", err)
  7877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7878. return
  7879. }
  7880. }
  7881. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7882. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7883. psn_info, _ := service.GetPsnByPatientId(id)
  7884. var result string
  7885. var requestLog string
  7886. if id_card_type == 1 {
  7887. bas := strings.Split(psn_info.CardInfo, "|")
  7888. basNumber := bas[2]
  7889. card_sn := bas[3]
  7890. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  7891. saveLog(result, requestLog, "2201A", "挂号")
  7892. } else if id_card_type == 2 {
  7893. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  7894. saveLog(result, requestLog, "2201A", "挂号")
  7895. } else {
  7896. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "")
  7897. saveLog(result, requestLog, "2201A", "挂号")
  7898. }
  7899. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7900. utils.ErrorLog("解析失败:%v", err)
  7901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7902. return
  7903. }
  7904. infocode = resThree.Infcode
  7905. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7906. psn_info, _ := service.GetPsnByPatientId(id)
  7907. var result string
  7908. var requestLog string
  7909. if id_card_type == 1 {
  7910. bas := strings.Split(psn_info.CardInfo, "|")
  7911. basNumber := bas[2]
  7912. card_sn := bas[3]
  7913. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  7914. saveLog(result, requestLog, "2201A", "挂号")
  7915. } else if id_card_type == 2 {
  7916. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  7917. saveLog(result, requestLog, "2201A", "挂号")
  7918. } else {
  7919. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "")
  7920. saveLog(result, requestLog, "2201A", "挂号")
  7921. }
  7922. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7923. utils.ErrorLog("解析失败:%v", err)
  7924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7925. return
  7926. }
  7927. infocode = resThree.Infcode
  7928. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7929. psn_info, _ := service.GetPsnByPatientId(id)
  7930. result, requestLog := service.HeBeiyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  7931. saveLog(result, requestLog, "2201A", "挂号")
  7932. if miConfig.Code == "H15049901371" {
  7933. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7934. utils.ErrorLog("解析失败:%v", err)
  7935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. return
  7937. }
  7938. resThree.ErrMsg = resThree10265.ErrMsg
  7939. resThree.Output = resThree10265.Output
  7940. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7941. } else {
  7942. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7943. utils.ErrorLog("解析失败:%v", err)
  7944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7945. return
  7946. }
  7947. }
  7948. if miConfig.Code == "H15049901371" {
  7949. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7950. } else {
  7951. infocode = resThree.Infcode
  7952. }
  7953. } else {
  7954. psn_info, _ := service.GetPsnByPatientId(id)
  7955. if id_card_type == 4 || id_card_type == 1 {
  7956. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7957. }
  7958. var rf []*ResultFive
  7959. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  7960. var insutypes []*ResultFive
  7961. var insutype string
  7962. var is390 int = 0
  7963. var is310 int = 0
  7964. for _, item := range rf {
  7965. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7966. insutypes = append(insutypes, item)
  7967. }
  7968. }
  7969. if len(insutypes) == 1 {
  7970. insutype = insutypes[0].Insutype
  7971. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7972. } else {
  7973. for _, i := range insutypes {
  7974. if i.Insutype == "390" {
  7975. is390 = 1
  7976. }
  7977. if i.Insutype == "310" {
  7978. is310 = 1
  7979. }
  7980. }
  7981. }
  7982. if is390 == 1 {
  7983. insutype = "390"
  7984. }
  7985. if is310 == 1 {
  7986. insutype = "310"
  7987. }
  7988. if len(insutypes) == 0 {
  7989. insutype = "310"
  7990. }
  7991. result, requestLog := service.Gdyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  7992. saveLog(result, requestLog, "2201A", "挂号")
  7993. if miConfig.Code == "H15049901371" {
  7994. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7995. utils.ErrorLog("解析失败:%v", err)
  7996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7997. return
  7998. }
  7999. resThree.ErrMsg = resThree10265.ErrMsg
  8000. resThree.Output = resThree10265.Output
  8001. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8002. } else {
  8003. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8004. utils.ErrorLog("解析失败:%v", err)
  8005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. return
  8007. }
  8008. }
  8009. if miConfig.Code == "H15049901371" {
  8010. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8011. } else {
  8012. infocode = resThree.Infcode
  8013. }
  8014. }
  8015. if infocode != 0 {
  8016. adminUser := c.GetAdminUserInfo()
  8017. errlog := &models.HisOrderError{
  8018. UserOrgId: adminUser.CurrentOrgId,
  8019. Ctime: time.Now().Unix(),
  8020. Mtime: time.Now().Unix(),
  8021. ErrMsg: resThree.ErrMsg,
  8022. Status: 1,
  8023. PatientId: id,
  8024. RecordTime: recordDateTime,
  8025. Stage: 2,
  8026. }
  8027. service.CreateErrMsgLog(errlog)
  8028. c.ServeSuccessJSON(map[string]interface{}{
  8029. "failed_code": -10,
  8030. "msg": resThree.ErrMsg,
  8031. })
  8032. return
  8033. }
  8034. his.Number = resThree.Output.Data.MdtrtID
  8035. his.PsnNo = resThree.Output.Data.PsnNo
  8036. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  8037. his.IdCardNo = patient.IdCardNo
  8038. his.PhoneNumber = patient.Phone
  8039. his.UserOrgId = adminInfo.CurrentOrgId
  8040. his.Insutype = insutype
  8041. his.Ctime = time.Now().Unix()
  8042. his.Mtime = time.Now().Unix()
  8043. his.InsuplcAdmdvs = insuplc_admdvs_temp
  8044. his.Status = 1
  8045. his.MdtrtGrpType = mdtrt_type
  8046. service.UpdateHisPatientStatus(&his)
  8047. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  8048. c.ServeSuccessJSON(map[string]interface{}{
  8049. "his_info": his,
  8050. })
  8051. } else {
  8052. adminUser := c.GetAdminUserInfo()
  8053. errlog := &models.HisOrderError{
  8054. UserOrgId: adminUser.CurrentOrgId,
  8055. Ctime: time.Now().Unix(),
  8056. Mtime: time.Now().Unix(),
  8057. ErrMsg: res.ErrMsg,
  8058. Status: 1,
  8059. PatientId: id,
  8060. RecordTime: recordDateTime,
  8061. Stage: 1,
  8062. }
  8063. service.CreateErrMsgLog(errlog)
  8064. c.ServeSuccessJSON(map[string]interface{}{
  8065. "failed_code": -10,
  8066. "msg": res.ErrMsg,
  8067. })
  8068. return
  8069. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8070. }
  8071. }
  8072. }
  8073. func (c *HisApiController) GetUploadInfo() {
  8074. id, _ := c.GetInt64("id")
  8075. record_time := c.GetString("record_time")
  8076. his_patient_id, _ := c.GetInt64("his_patient_id")
  8077. order_id, _ := c.GetInt64("order_id")
  8078. pay_way, _ := c.GetInt64("pay_way")
  8079. pay_ways := c.GetString("pay_ways")
  8080. oth_desc := c.GetString("oth_desc")
  8081. pay_price, _ := c.GetFloat("pay_price")
  8082. pay_card_no := c.GetString("pay_card_no")
  8083. discount_price, _ := c.GetFloat("discount_price")
  8084. preferential_price, _ := c.GetFloat("preferential_price")
  8085. reality_price, _ := c.GetFloat("reality_price")
  8086. found_price, _ := c.GetFloat("found_price")
  8087. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  8088. private_price, _ := c.GetFloat("private_price")
  8089. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8090. admin_user_id, _ := c.GetInt64("admin_user_id")
  8091. fapiao_code := c.GetString("fapiao_code")
  8092. fapiao_number := c.GetString("fapiao_number")
  8093. diagnosis_id := c.GetString("diagnosis")
  8094. sick_type, _ := c.GetInt64("sick_type")
  8095. reg_type, _ := c.GetInt64("p_type")
  8096. begin_time := c.GetString("begin_time")
  8097. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  8098. cash_pay := c.GetString("cash_pay")
  8099. band_card_pay := c.GetString("band_card_pay")
  8100. wechat_pay := c.GetString("wechat_pay")
  8101. ali_pay := c.GetString("ali_pay")
  8102. jifen_pay := c.GetString("jifen_pay")
  8103. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  8104. fmt.Println(acct_used_flag)
  8105. id_str := c.GetString("ids")
  8106. ids_arr := strings.Split(id_str, ",")
  8107. timeLayout := "2006-01-02"
  8108. loc, _ := time.LoadLocation("Local")
  8109. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8110. if err != nil {
  8111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8112. return
  8113. }
  8114. recordDateTime := theTime.Unix()
  8115. adminUser := c.GetAdminUserInfo()
  8116. var tempOrder models.HisOrder
  8117. tempOrder, _ = service.GetHisOrderByID(order_id)
  8118. var prescriptions []*models.HisPrescription
  8119. var start_time int64
  8120. var end_time int64
  8121. //押金模块
  8122. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  8123. tmp_decimal := c.GetString("tmp_decimal")
  8124. var decimal float64 //本次使用的押金
  8125. var errmsg error
  8126. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  8127. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  8128. return
  8129. }
  8130. if len(tmp_decimal) > 0 {
  8131. if tmp_decimal[0] == 45 {
  8132. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  8133. return
  8134. }
  8135. }
  8136. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  8137. fmt.Println(errs)
  8138. decimal = tt
  8139. //if adminUser.CurrentOrgId == 10106{
  8140. // if len(fapiao_code) == 0{
  8141. // fapiao_code = "144072080589"
  8142. // }
  8143. // if len(fapiao_number) == 0{
  8144. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  8145. // if order.ID == 0{
  8146. // fapiao_number = "00001520"
  8147. // }else{
  8148. // //fapiao_code = "00001520"
  8149. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  8150. // var zero string
  8151. // if fpNumber >= 1000{
  8152. // zero = "0000" + strconv.Itoa(fpNumber)
  8153. // }else if fpNumber >= 10000{
  8154. // zero = "000" + strconv.Itoa(fpNumber)
  8155. // } else if fpNumber >= 100000{
  8156. // zero = "00" + strconv.Itoa(fpNumber)
  8157. // } else if fpNumber >= 1000000{
  8158. // zero = "0" + strconv.Itoa(fpNumber)
  8159. // }else {
  8160. // zero = strconv.Itoa(fpNumber)
  8161. // }
  8162. // fapiao_number = zero
  8163. // }
  8164. // }
  8165. //}
  8166. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8167. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8168. var patientPrescription models.HisPrescriptionInfo
  8169. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8170. if patientPrescription.ID == 0 {
  8171. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8172. }
  8173. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8174. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8175. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8176. diagnosis_ids := strings.Split(diagnosis_id, ",")
  8177. var config []*models.HisXtDiagnoseConfig
  8178. for _, item := range diagnosis_ids {
  8179. id, _ := strconv.ParseInt(item, 10, 64)
  8180. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8181. config = append(config, &diagnosisConfig)
  8182. }
  8183. sickConfig, _ := service.FindSickById(sick_type)
  8184. //if tempOrder.ID == 0 {
  8185. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  8186. //}
  8187. if tempOrder.ID == 0 {
  8188. var result string
  8189. var requestLog string
  8190. var res2 ResultSix
  8191. var ressix10265 ResultSix10265
  8192. if miConfig.MdtrtareaAdmvs == "421300" {
  8193. data := make(map[string]interface{})
  8194. client := &http.Client{}
  8195. data["psn_no"] = his.PsnNo
  8196. data["mdtrt_id"] = his.Number
  8197. data["opter"] = roles.UserName
  8198. data["org_name"] = miConfig.OrgName
  8199. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8200. data["doctor_id"] = doctor_info.DoctorNumber
  8201. data["doctor_name"] = doctor_info.UserName
  8202. data["department"] = department.Name
  8203. data["fixmedins_code"] = miConfig.Code
  8204. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8205. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8206. data["secret_key"] = miConfig.SecretKey
  8207. data["sick_code"] = sickConfig.CountryCode
  8208. data["sick_name"] = sickConfig.ClassName
  8209. data["dept"] = strconv.FormatInt(department.ID, 10)
  8210. data["config"] = config
  8211. data["begin_time"] = begin_time
  8212. bytesData, _ := json.Marshal(data)
  8213. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  8214. resp, _ := client.Do(req)
  8215. defer resp.Body.Close()
  8216. body, ioErr := ioutil.ReadAll(resp.Body)
  8217. if ioErr != nil {
  8218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8220. return
  8221. }
  8222. var respJSON map[string]interface{}
  8223. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8226. return
  8227. }
  8228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8229. userJSONBytes, _ := json.Marshal(respJSON)
  8230. fmt.Println("log")
  8231. fmt.Println(string(userJSONBytes))
  8232. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8233. utils.ErrorLog("解析失败:%v", err)
  8234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8235. return
  8236. }
  8237. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8238. data := make(map[string]interface{})
  8239. client := &http.Client{}
  8240. data["psn_no"] = his.PsnNo
  8241. data["mdtrt_id"] = his.Number
  8242. data["doctor"] = roles.UserName
  8243. data["department"] = department.Name
  8244. data["org_name"] = miConfig.OrgName
  8245. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8246. data["doctor_id"] = doctor_info.DoctorNumber
  8247. data["new_doctor_name"] = doctor_info.UserName
  8248. data["fixmedins_code"] = miConfig.Code
  8249. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8250. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8251. data["secret_key"] = miConfig.SecretKey
  8252. data["sick_code"] = sickConfig.CountryCode
  8253. data["sick_name"] = sickConfig.ClassName
  8254. data["url"] = miConfig.Url
  8255. data["ak"] = miConfig.AccessKey
  8256. data["begin_time"] = begin_time
  8257. data["cainfo"] = miConfig.Cainfo
  8258. data["dept"] = strconv.FormatInt(department.ID, 10)
  8259. data["config"] = config
  8260. bytesData, _ := json.Marshal(data)
  8261. var req *http.Request
  8262. if miConfig.MdtrtareaAdmvs == "320921" {
  8263. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8264. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8265. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  8266. } else {
  8267. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8268. }
  8269. resp, _ := client.Do(req)
  8270. defer resp.Body.Close()
  8271. body, ioErr := ioutil.ReadAll(resp.Body)
  8272. if ioErr != nil {
  8273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8275. return
  8276. }
  8277. var respJSON map[string]interface{}
  8278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8281. return
  8282. }
  8283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8284. userJSONBytes, _ := json.Marshal(respJSON)
  8285. fmt.Println("log")
  8286. fmt.Println(string(userJSONBytes))
  8287. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  8288. utils.ErrorLog("解析失败:%v", err)
  8289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8290. return
  8291. }
  8292. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8293. res2.Output = ressix10265.Output
  8294. res2.ErrMsg = ressix10265.ErrMsg
  8295. res2.Cainfo = ressix10265.Cainfo
  8296. res2.WarnMsg = ressix10265.WarnMsg
  8297. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8298. res2.Infcode = infocode
  8299. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8300. result, requestLog, _ = service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8301. saveLog(result, requestLog, "2203", "上传就诊信息")
  8302. var respJSON2 map[string]interface{}
  8303. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8306. return
  8307. }
  8308. userJSONBytes2, _ := json.Marshal(respJSON2)
  8309. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8310. utils.ErrorLog("解析失败:%v", err)
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8312. return
  8313. }
  8314. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8315. fmt.Println(result2)
  8316. fmt.Println(src_request)
  8317. } else {
  8318. if miConfig.MdtrtareaAdmvs == "440781" { //
  8319. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  8320. } else {
  8321. if miConfig.Code == "H15049901371" {
  8322. //赤峰地区国家医保医疗类别
  8323. //职工透析:医疗类别选特殊情况门诊990502
  8324. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8325. var med_type string
  8326. if his.Insutype == "390" {
  8327. if reg_type == 14 {
  8328. med_type = "9933"
  8329. } else if reg_type == 11 {
  8330. med_type = "11"
  8331. }
  8332. } else if his.Insutype == "310" {
  8333. if reg_type == 14 {
  8334. med_type = "990502"
  8335. } else if reg_type == 11 {
  8336. med_type = "11"
  8337. }
  8338. }
  8339. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  8340. } else {
  8341. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  8342. }
  8343. }
  8344. saveLog(result, requestLog, "2203", "上传就诊信息")
  8345. var respJSON2 map[string]interface{}
  8346. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8349. return
  8350. }
  8351. userJSONBytes2, _ := json.Marshal(respJSON2)
  8352. if miConfig.Code == "H15049901371" {
  8353. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  8354. utils.ErrorLog("解析失败:%v", err)
  8355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8356. return
  8357. }
  8358. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8359. res2.Output = ressix10265.Output
  8360. res2.ErrMsg = ressix10265.ErrMsg
  8361. res2.Cainfo = ressix10265.Cainfo
  8362. res2.WarnMsg = ressix10265.WarnMsg
  8363. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8364. res2.Infcode = infocode
  8365. } else {
  8366. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8367. utils.ErrorLog("解析失败:%v", err)
  8368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8369. return
  8370. }
  8371. }
  8372. }
  8373. if res2.Infcode != 0 {
  8374. adminUser := c.GetAdminUserInfo()
  8375. errlog := &models.HisOrderError{
  8376. UserOrgId: adminUser.CurrentOrgId,
  8377. Ctime: time.Now().Unix(),
  8378. Mtime: time.Now().Unix(),
  8379. ErrMsg: res2.ErrMsg,
  8380. Status: 1,
  8381. PatientId: id,
  8382. RecordTime: recordDateTime,
  8383. Stage: 3,
  8384. }
  8385. service.CreateErrMsgLog(errlog)
  8386. c.ServeSuccessJSON(map[string]interface{}{
  8387. "failed_code": -10,
  8388. "msg": res2.ErrMsg,
  8389. })
  8390. return
  8391. } else {
  8392. his.Diagnosis = diagnosis_id
  8393. his.SickType = sickConfig.ID
  8394. //var p_type int64
  8395. //if reg_type == 1111 || reg_type == 1112 {
  8396. // p_type = 11
  8397. //
  8398. //}
  8399. his.PType = fmt.Sprintf("%d", reg_type)
  8400. service.UpdateHisPatientThree(&his)
  8401. data := make(map[string]interface{})
  8402. if settle_accounts_type == 1 { //日结
  8403. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  8404. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  8405. } else {
  8406. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  8407. }
  8408. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  8409. data["pre"] = prescriptions
  8410. } else { //月结
  8411. start_time_str := c.GetString("start_time")
  8412. end_time_str := c.GetString("end_time")
  8413. timeLayout := "2006-01-02"
  8414. loc, _ := time.LoadLocation("Local")
  8415. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8416. if err != nil {
  8417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8418. return
  8419. }
  8420. recordStartTime := theStartTime.Unix()
  8421. start_time = recordStartTime
  8422. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8423. if err != nil {
  8424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8425. return
  8426. }
  8427. recordEndTime := theEndTime.Unix()
  8428. end_time = recordEndTime
  8429. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  8430. data["pre"] = prescriptions
  8431. }
  8432. timestamp := time.Now().Unix()
  8433. tempTime := time.Unix(timestamp, 0)
  8434. timeFormat := tempTime.Format("20060102150405")
  8435. chrgBchno := rand.Intn(100000) + 10000
  8436. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8437. strconv.FormatInt(his.PatientId, 10)
  8438. client := &http.Client{}
  8439. data["psn_no"] = his.PsnNo
  8440. data["mdtrt_id"] = his.Number
  8441. data["chrg_bchno"] = chrg_bchno
  8442. data["org_name"] = miConfig.OrgName
  8443. data["doctor"] = doctor_info.UserName
  8444. data["doctor_id"] = doctor_info.DoctorNumber
  8445. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8446. data["fixmedins_code"] = miConfig.Code
  8447. data["opter"] = roles.UserName
  8448. data["dept_code"] = department.Number
  8449. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8450. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8451. data["secret_key"] = miConfig.SecretKey
  8452. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  8453. data["url"] = miConfig.Url
  8454. data["ak"] = miConfig.AccessKey
  8455. data["new_doctor_name"] = patientPrescription.Doctor
  8456. data["diag_code"] = sickConfig.CountryCode
  8457. data["cainfo"] = miConfig.Cainfo
  8458. data["opter"] = roles.UserName
  8459. var ids []int64
  8460. for _, item := range prescriptions {
  8461. ids = append(ids, item.ID)
  8462. }
  8463. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8464. if config.IsOpen == 1 { //对接了医保,走医保流程
  8465. var res ResultFour
  8466. var resFour10265 ResultFour10265
  8467. if miConfig.MdtrtareaAdmvs == "421300" {
  8468. bytesData, _ := json.Marshal(data)
  8469. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  8470. resp, _ := client.Do(req)
  8471. defer resp.Body.Close()
  8472. body, ioErr := ioutil.ReadAll(resp.Body)
  8473. if ioErr != nil {
  8474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8476. return
  8477. }
  8478. var respJSON map[string]interface{}
  8479. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8482. return
  8483. }
  8484. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8485. userJSONBytes, _ := json.Marshal(respJSON)
  8486. fmt.Println("log")
  8487. fmt.Println(string(userJSONBytes))
  8488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8489. utils.ErrorLog("解析失败:%v", err)
  8490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8491. return
  8492. }
  8493. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8494. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  8495. if result3101.Infcode == "0" {
  8496. if len(result3101.Output.Result) > 0 {
  8497. var errMsgs []string
  8498. for _, item := range result3101.Output.Result {
  8499. errMsgs = append(errMsgs, item.VolaCont)
  8500. }
  8501. c.ServeSuccessJSON(map[string]interface{}{
  8502. "failed_code": -10,
  8503. "msg": errMsgs,
  8504. })
  8505. return
  8506. }
  8507. }
  8508. if miConfig.MdtrtareaAdmvs == "320921" {
  8509. data["doctor_id"] = "D320923012139"
  8510. } else {
  8511. data["doctor_id"] = "D371621008686"
  8512. }
  8513. bytesData, _ := json.Marshal(data)
  8514. var req *http.Request
  8515. if miConfig.MdtrtareaAdmvs == "320921" {
  8516. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8517. } else {
  8518. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8519. }
  8520. resp, _ := client.Do(req)
  8521. defer resp.Body.Close()
  8522. body, ioErr := ioutil.ReadAll(resp.Body)
  8523. if ioErr != nil {
  8524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. var respJSON map[string]interface{}
  8529. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8532. return
  8533. }
  8534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8535. userJSONBytes, _ := json.Marshal(respJSON)
  8536. fmt.Println("log")
  8537. fmt.Println(string(userJSONBytes))
  8538. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8539. utils.ErrorLog("解析失败:%v", err)
  8540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8541. return
  8542. }
  8543. res.InfRefmsgid = resFour10265.InfRefmsgid
  8544. res.Output = resFour10265.Output
  8545. res.ErrMsg = resFour10265.ErrMsg
  8546. res.Cainfo = resFour10265.Cainfo
  8547. res.WarnMsg = resFour10265.WarnMsg
  8548. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8549. res.Infcode = infocode
  8550. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8551. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  8552. var dat map[string]interface{}
  8553. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8554. fmt.Println(dat)
  8555. } else {
  8556. fmt.Println(err)
  8557. }
  8558. saveLog(result, request_log, "2204", "上传费用明细")
  8559. userJSONBytes, _ := json.Marshal(dat)
  8560. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8561. utils.ErrorLog("解析失败:%v", err)
  8562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8563. return
  8564. }
  8565. res.InfRefmsgid = resFour10265.InfRefmsgid
  8566. res.Output = resFour10265.Output
  8567. res.ErrMsg = resFour10265.ErrMsg
  8568. res.Cainfo = resFour10265.Cainfo
  8569. res.WarnMsg = resFour10265.WarnMsg
  8570. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8571. res.Infcode = infocode
  8572. } else {
  8573. if miConfig.Code == "H15049901371" {
  8574. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  8575. var dat map[string]interface{}
  8576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8577. fmt.Println(dat)
  8578. } else {
  8579. fmt.Println(err)
  8580. }
  8581. saveLog(result, request_log, "2204", "上传费用明细")
  8582. userJSONBytes, _ := json.Marshal(dat)
  8583. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8584. utils.ErrorLog("解析失败:%v", err)
  8585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8586. return
  8587. }
  8588. res.InfRefmsgid = resFour10265.InfRefmsgid
  8589. res.Output = resFour10265.Output
  8590. res.ErrMsg = resFour10265.ErrMsg
  8591. res.Cainfo = resFour10265.Cainfo
  8592. res.WarnMsg = resFour10265.WarnMsg
  8593. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8594. res.Infcode = infocode
  8595. } else {
  8596. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  8597. var dat map[string]interface{}
  8598. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8599. fmt.Println(dat)
  8600. } else {
  8601. fmt.Println(err)
  8602. }
  8603. saveLog(result, request_log, "2204", "上传费用明细")
  8604. userJSONBytes, _ := json.Marshal(dat)
  8605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8606. utils.ErrorLog("解析失败:%v", err)
  8607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8608. return
  8609. }
  8610. }
  8611. }
  8612. if res.Infcode == 0 {
  8613. order := &models.HisOrder{
  8614. UserOrgId: adminUser.CurrentOrgId,
  8615. HisPatientId: his.ID,
  8616. PatientId: his.PatientId,
  8617. SettleAccountsDate: recordDateTime,
  8618. MdtrtId: his.Number,
  8619. PsnNo: his.PsnNo,
  8620. MedType: strconv.FormatInt(reg_type, 10),
  8621. Ctime: time.Now().Unix(),
  8622. Mtime: time.Now().Unix(),
  8623. Status: 1,
  8624. Number: chrg_bchno,
  8625. Infcode: res.Infcode,
  8626. WarnMsg: res.WarnMsg,
  8627. Cainfo: res.Cainfo,
  8628. ErrMsg: res.ErrMsg,
  8629. RespondTime: res.RefmsgTime,
  8630. InfRefmsgid: res.InfRefmsgid,
  8631. OrderStatus: 1,
  8632. PayWay: pay_way,
  8633. PayWays: pay_ways,
  8634. OthDesc: oth_desc,
  8635. PayPrice: pay_price,
  8636. PayCardNo: pay_card_no,
  8637. DiscountPrice: discount_price,
  8638. PreferentialPrice: preferential_price,
  8639. RealityPrice: reality_price,
  8640. FoundPrice: found_price,
  8641. MedicalInsurancePrice: medical_insurance_price,
  8642. PrivatePrice: private_price,
  8643. IsMedicineInsurance: 1,
  8644. SettleType: settle_accounts_type,
  8645. SettleStartTime: start_time,
  8646. SettleEndTime: end_time,
  8647. Creator: roles.AdminUserId,
  8648. Modify: roles.AdminUserId,
  8649. FaPiaoNumber: fapiao_number,
  8650. FaPiaoCode: fapiao_code,
  8651. PType: 2,
  8652. Diagnosis: diagnosis_id,
  8653. CashPay: cash_pay,
  8654. WechatPay: wechat_pay,
  8655. AliPay: ali_pay,
  8656. JifenPay: jifen_pay,
  8657. BandCardPay: band_card_pay,
  8658. }
  8659. err = service.CreateOrder(order)
  8660. if err != nil {
  8661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8662. return
  8663. }
  8664. for _, item := range res.Output.Result {
  8665. temp := strings.Split(item.FeedetlSn, "-")
  8666. var advice_id int64 = 0
  8667. var project_id int64 = 0
  8668. var types int64 = 0
  8669. id, _ := strconv.ParseInt(temp[2], 10, 64)
  8670. types, _ = strconv.ParseInt(temp[1], 10, 64)
  8671. if temp[1] == "1" {
  8672. advice_id = id
  8673. project_id = 0
  8674. } else if temp[1] == "2" {
  8675. advice_id = 0
  8676. project_id = id
  8677. }
  8678. if item.MedChrgitmType == "9" {
  8679. item.MedChrgitmType = "09"
  8680. }
  8681. info := &models.HisOrderInfo{
  8682. OrderNumber: order.Number,
  8683. FeedetlSn: item.FeedetlSn,
  8684. UploadDate: time.Now().Unix(),
  8685. AdviceId: advice_id,
  8686. DetItemFeeSumamt: item.DetItemFeeSumamt,
  8687. Cnt: item.Cnt,
  8688. Pric: float64(item.Pric),
  8689. PatientId: his.PatientId,
  8690. PricUplmtAmt: item.PricUplmtAmt,
  8691. SelfpayProp: item.SelfpayProp,
  8692. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8693. OverlmtAmt: item.OverlmtAmt,
  8694. PreselfpayAmt: item.PreselfpayAmt,
  8695. BasMednFlag: item.BasMednFlag,
  8696. MedChrgitmType: item.MedChrgitmType,
  8697. HiNegoDrugFlag: item.HiNegoDrugFlag,
  8698. Status: 1,
  8699. Memo: item.Memo,
  8700. Mtime: time.Now().Unix(),
  8701. InscpScpAmt: item.InscpScpAmt,
  8702. DrtReimFlag: item.DrtReimFlag,
  8703. Ctime: time.Now().Unix(),
  8704. ListSpItemFlag: item.ListSpItemFlag,
  8705. ChldMedcFlag: item.ChldMedcFlag,
  8706. LmtUsedFlag: item.LmtUsedFlag,
  8707. ChrgitmLv: item.ChrgitmLv,
  8708. UserOrgId: adminUser.CurrentOrgId,
  8709. HisPatientId: his.ID,
  8710. OrderId: order.ID,
  8711. ProjectId: project_id,
  8712. Type: types,
  8713. }
  8714. service.CreateOrderInfo(info)
  8715. }
  8716. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8717. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  8718. var total float64
  8719. for _, item := range prescriptions {
  8720. if item.Type == 1 { //药品
  8721. for _, subItem := range item.HisDoctorAdviceInfo {
  8722. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  8723. total_one := price * subItem.PrescribingNumber
  8724. total = total + total_one
  8725. }
  8726. }
  8727. if item.Type == 2 { //项目
  8728. for _, subItem := range item.HisPrescriptionProject {
  8729. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8730. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  8731. total_one := price * cnt
  8732. total = total + total_one
  8733. }
  8734. }
  8735. }
  8736. allTotal := fmt.Sprintf("%f", total)
  8737. //if adminUser.CurrentOrgId == 9919 {
  8738. //
  8739. // allTotal = fmt.Sprintf("%.2f", total)
  8740. //
  8741. //} else {
  8742. //
  8743. // allTotal = fmt.Sprintf("%.2f", total)
  8744. //
  8745. //}
  8746. if res.Infcode == 0 {
  8747. var rf []*ResultFive
  8748. json.Unmarshal([]byte(his.Iinfo), &rf)
  8749. chrg_bchno := chrg_bchno
  8750. cert_no := his.Certno
  8751. var insutypes []string
  8752. var insutype string
  8753. var is390 int = 0
  8754. var is310 int = 0
  8755. for _, item := range rf {
  8756. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8757. insutypes = append(insutypes, item.Insutype)
  8758. }
  8759. }
  8760. if len(insutypes) == 1 {
  8761. insutype = insutypes[0]
  8762. } else {
  8763. for _, i := range insutypes {
  8764. if i == "390" {
  8765. is390 = 1
  8766. }
  8767. if i == "310" {
  8768. is310 = 1
  8769. }
  8770. }
  8771. }
  8772. if is390 == 1 {
  8773. insutype = "390"
  8774. }
  8775. if is310 == 1 {
  8776. insutype = "310"
  8777. }
  8778. if len(insutypes) == 0 {
  8779. insutype = "310"
  8780. }
  8781. if len(insutypes) == 2 {
  8782. insutype = strconv.FormatInt(his.SocialType, 10)
  8783. }
  8784. insutype = strconv.FormatInt(his.SocialType, 10)
  8785. //insutype = "390"
  8786. if his.IdCardType == 1 {
  8787. // cert_no = his.MedicalInsuranceNumber
  8788. cert_no = his.Certno
  8789. } else {
  8790. cert_no = his.Certno
  8791. }
  8792. var res ResultSeven
  8793. var resSeven10265 ResultSeven10265
  8794. var src_resquest string
  8795. var result2 string
  8796. if miConfig.MdtrtareaAdmvs == "421300" {
  8797. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8798. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8799. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8800. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8801. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8802. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8803. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8804. resp, requestErr := http.Get(api)
  8805. if requestErr != nil {
  8806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8807. return
  8808. }
  8809. body, ioErr := ioutil.ReadAll(resp.Body)
  8810. if ioErr != nil {
  8811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8813. return
  8814. }
  8815. var respJSON map[string]interface{}
  8816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8819. return
  8820. }
  8821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8822. result, _ := json.Marshal(respJSON)
  8823. if miConfig.Code == "H15049901371" {
  8824. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8825. utils.ErrorLog("解析失败:%v", err)
  8826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8827. return
  8828. }
  8829. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8830. res.Output = resSeven10265.Output
  8831. res.ErrMsg = resSeven10265.ErrMsg
  8832. res.Cainfo = resSeven10265.Cainfo
  8833. res.WarnMsg = resSeven10265.WarnMsg
  8834. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8835. res.Infcode = infocode
  8836. } else {
  8837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8838. utils.ErrorLog("解析失败:%v", err)
  8839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8840. return
  8841. }
  8842. }
  8843. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8844. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  8845. if result3101.Infcode == "0" {
  8846. if len(result3101.Output.Result) > 0 {
  8847. var errMsgs []string
  8848. for _, item := range result3101.Output.Result {
  8849. errMsgs = append(errMsgs, item.VolaCont)
  8850. }
  8851. c.ServeSuccessJSON(map[string]interface{}{
  8852. "failed_code": -10,
  8853. "msg": errMsgs,
  8854. })
  8855. return
  8856. } else {
  8857. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8858. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8859. bas := strings.Split(psn_info.CardInfo, "|")
  8860. if his.IdCardType == 1 {
  8861. cert_no = bas[2]
  8862. } else if his.IdCardType == 3 {
  8863. cert_no = his.Certno
  8864. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8865. } else if his.IdCardType == 4 {
  8866. cert_no = his.Certno
  8867. psn_info.VerifyNumber = psn_info.VerifyNumber
  8868. }
  8869. var api string
  8870. if miConfig.MdtrtareaAdmvs == "320921" {
  8871. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8872. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8873. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8874. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8875. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8876. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8877. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  8878. } else {
  8879. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8880. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8881. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8882. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8883. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8884. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8885. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  8886. }
  8887. resp, requestErr := http.Get(api)
  8888. if requestErr != nil {
  8889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8890. return
  8891. }
  8892. body, ioErr := ioutil.ReadAll(resp.Body)
  8893. if ioErr != nil {
  8894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8896. return
  8897. }
  8898. var respJSON map[string]interface{}
  8899. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8902. return
  8903. }
  8904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8905. result, _ := json.Marshal(respJSON)
  8906. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8907. utils.ErrorLog("解析失败:%v", err)
  8908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8909. return
  8910. }
  8911. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8912. res.Output = resSeven10265.Output
  8913. res.ErrMsg = resSeven10265.ErrMsg
  8914. res.Cainfo = resSeven10265.Cainfo
  8915. res.WarnMsg = resSeven10265.WarnMsg
  8916. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8917. res.Infcode = infocode
  8918. }
  8919. }
  8920. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8921. var cert_no string
  8922. if his.IdCardType == 4 {
  8923. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8924. cert_no = psn_info.VerifyNumber
  8925. result2, src_resquest, _ = service.FJyb2207ForToken(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8926. } else if his.IdCardType == 1 {
  8927. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8928. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8929. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8930. }
  8931. //result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, acct_used_flag)
  8932. var dat map[string]interface{}
  8933. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8934. fmt.Println(dat)
  8935. } else {
  8936. fmt.Println(err)
  8937. }
  8938. saveLog(result2, src_resquest, "2207", "结算")
  8939. userJSONBytes, _ := json.Marshal(dat)
  8940. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8941. utils.ErrorLog("解析失败:%v", err)
  8942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8943. return
  8944. }
  8945. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8946. res.Output = resSeven10265.Output
  8947. res.ErrMsg = resSeven10265.ErrMsg
  8948. res.Cainfo = resSeven10265.Cainfo
  8949. res.WarnMsg = resSeven10265.WarnMsg
  8950. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8951. res.Infcode = infocode
  8952. } else {
  8953. if miConfig.Code == "H15049901371" {
  8954. //赤峰地区国家医保医疗类别
  8955. //职工透析:医疗类别选特殊情况门诊990502
  8956. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8957. var med_type string
  8958. if his.Insutype == "390" {
  8959. if reg_type == 14 {
  8960. med_type = "9933"
  8961. } else if reg_type == 11 {
  8962. med_type = "11"
  8963. }
  8964. } else if his.Insutype == "310" {
  8965. if reg_type == 14 {
  8966. med_type = "990502"
  8967. } else if reg_type == 11 {
  8968. med_type = "11"
  8969. }
  8970. }
  8971. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "")
  8972. } else {
  8973. if his.IdCardType == 4 {
  8974. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8975. var token string
  8976. token = psn_info.VerifyNumber
  8977. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token)
  8978. } else {
  8979. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "")
  8980. }
  8981. }
  8982. //result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, acct_used_flag)
  8983. var dat map[string]interface{}
  8984. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8985. fmt.Println(dat)
  8986. } else {
  8987. fmt.Println(err)
  8988. }
  8989. saveLog(result2, src_resquest, "2207", "结算")
  8990. userJSONBytes, _ := json.Marshal(dat)
  8991. if miConfig.Code == "H15049901371" {
  8992. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8993. utils.ErrorLog("解析失败:%v", err)
  8994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8995. return
  8996. }
  8997. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8998. res.Output = resSeven10265.Output
  8999. res.ErrMsg = resSeven10265.ErrMsg
  9000. res.Cainfo = resSeven10265.Cainfo
  9001. res.WarnMsg = resSeven10265.WarnMsg
  9002. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9003. res.Infcode = infocode
  9004. } else {
  9005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9006. utils.ErrorLog("解析失败:%v", err)
  9007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9008. return
  9009. }
  9010. }
  9011. }
  9012. if res.Infcode != 0 {
  9013. errlog := &models.HisOrderError{
  9014. UserOrgId: adminUser.CurrentOrgId,
  9015. Ctime: time.Now().Unix(),
  9016. Mtime: time.Now().Unix(),
  9017. Number: chrg_bchno,
  9018. ErrMsg: res.ErrMsg,
  9019. Status: 1,
  9020. PatientId: id,
  9021. RecordTime: recordDateTime,
  9022. Stage: 6,
  9023. }
  9024. service.CreateErrMsgLog(errlog)
  9025. c.ServeSuccessJSON(map[string]interface{}{
  9026. "failed_code": -10,
  9027. "msg": res.ErrMsg,
  9028. })
  9029. return
  9030. } else {
  9031. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9032. order.OrderStatus = 2
  9033. order.Status = 1
  9034. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9035. order.SetlId = res.Output.Setlinfo.SetlID
  9036. order.PsnNo = res.Output.Setlinfo.PsnNo
  9037. order.PsnName = res.Output.Setlinfo.PsnName
  9038. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9039. order.Certno = res.Output.Setlinfo.Certno
  9040. order.Gend = res.Output.Setlinfo.Gend
  9041. order.Naty = res.Output.Setlinfo.Naty
  9042. order.Age = res.Output.Setlinfo.Age
  9043. order.Insutype = res.Output.Setlinfo.Insutype
  9044. order.PsnType = res.Output.Setlinfo.PsnType
  9045. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9046. order.SetlTime = res.Output.Setlinfo.SetlTime
  9047. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9048. if res.Output.Setlinfo.MedType == "140101" {
  9049. order.MedType = "14"
  9050. } else {
  9051. order.MedType = res.Output.Setlinfo.MedType
  9052. }
  9053. if reg_type == 1112 {
  9054. order.MedType = "1112"
  9055. }
  9056. if reg_type == 1111 {
  9057. order.MedType = "1111"
  9058. }
  9059. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9060. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9061. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9062. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9063. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9064. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9065. order.HifpPay = res.Output.Setlinfo.HifpPay
  9066. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9067. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9068. order.HifesPay = res.Output.Setlinfo.HifesPay
  9069. order.HifobPay = res.Output.Setlinfo.HifobPay
  9070. order.MafPay = res.Output.Setlinfo.MafPay
  9071. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9072. order.OthPay = res.Output.Setlinfo.OthPay
  9073. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9074. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9075. order.AcctPay = res.Output.Setlinfo.AcctPay
  9076. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9077. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9078. order.Balc = res.Output.Setlinfo.Balc
  9079. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9080. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9081. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9082. order.ClrType = res.Output.Setlinfo.ClrType
  9083. order.ClrWay = res.Output.Setlinfo.ClrWay
  9084. order.Creator = order.Creator
  9085. order.Modify = roles.AdminUserId
  9086. order.RequestLog = src_resquest
  9087. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9088. detailStr := string(setlDetail)
  9089. order.SetlDetail = detailStr
  9090. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9091. err = service.UpDateOrder(order)
  9092. if err == nil {
  9093. //判断是否使用了押金
  9094. if dec_way == "true" {
  9095. tmpstring := strconv.FormatInt(order.ID, 10)
  9096. order.Decimal = decimal
  9097. service.UpDateOrder(order)
  9098. //扣押金
  9099. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9100. if errmsg != nil {
  9101. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9102. return
  9103. }
  9104. }
  9105. c.ServeSuccessJSON(map[string]interface{}{
  9106. "msg": "结算成功",
  9107. })
  9108. } else {
  9109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9110. return
  9111. }
  9112. }
  9113. } else {
  9114. adminUser := c.GetAdminUserInfo()
  9115. errlog := &models.HisOrderError{
  9116. UserOrgId: adminUser.CurrentOrgId,
  9117. Ctime: time.Now().Unix(),
  9118. Mtime: time.Now().Unix(),
  9119. ErrMsg: res.ErrMsg,
  9120. Status: 1,
  9121. PatientId: id,
  9122. RecordTime: recordDateTime,
  9123. Stage: 4,
  9124. }
  9125. service.CreateErrMsgLog(errlog)
  9126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9127. return
  9128. }
  9129. } else {
  9130. adminUser := c.GetAdminUserInfo()
  9131. errlog := &models.HisOrderError{
  9132. UserOrgId: adminUser.CurrentOrgId,
  9133. Ctime: time.Now().Unix(),
  9134. Mtime: time.Now().Unix(),
  9135. ErrMsg: res.ErrMsg,
  9136. Status: 1,
  9137. PatientId: id,
  9138. RecordTime: recordDateTime,
  9139. Stage: 4,
  9140. }
  9141. service.CreateErrMsgLog(errlog)
  9142. c.ServeSuccessJSON(map[string]interface{}{
  9143. "failed_code": -10,
  9144. "msg": res.ErrMsg,
  9145. })
  9146. return
  9147. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9148. //return
  9149. }
  9150. }
  9151. }
  9152. } else if tempOrder.ID > 0 {
  9153. if tempOrder.IsPre == 1 {
  9154. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  9155. var rf []*ResultFive
  9156. json.Unmarshal([]byte(his.Iinfo), &rf)
  9157. chrg_bchno := tempOrder.Number
  9158. cert_no := his.Certno
  9159. var insutypes []string
  9160. var insutype string
  9161. var is390 int = 0
  9162. var is310 int = 0
  9163. for _, item := range rf {
  9164. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9165. insutypes = append(insutypes, item.Insutype)
  9166. }
  9167. }
  9168. if len(insutypes) == 1 {
  9169. insutype = insutypes[0]
  9170. } else {
  9171. for _, i := range insutypes {
  9172. if i == "390" {
  9173. is390 = 1
  9174. }
  9175. if i == "310" {
  9176. is310 = 1
  9177. }
  9178. }
  9179. }
  9180. if is390 == 1 {
  9181. insutype = "390"
  9182. }
  9183. if is310 == 1 {
  9184. insutype = "310"
  9185. }
  9186. if len(insutypes) == 0 {
  9187. insutype = "310"
  9188. }
  9189. if len(insutypes) == 2 {
  9190. insutype = strconv.FormatInt(his.SocialType, 10)
  9191. }
  9192. //insutype = "390"
  9193. if his.IdCardType == 1 {
  9194. // cert_no = his.MedicalInsuranceNumber
  9195. cert_no = his.Certno
  9196. } else {
  9197. cert_no = his.Certno
  9198. }
  9199. var res ResultSeven
  9200. var resSeven10265 ResultSeven10265
  9201. var src_resquest string
  9202. var result2 string
  9203. if miConfig.MdtrtareaAdmvs == "421300" {
  9204. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9205. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9206. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9208. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9209. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9210. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  9211. resp, requestErr := http.Get(api)
  9212. if requestErr != nil {
  9213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9214. return
  9215. }
  9216. body, ioErr := ioutil.ReadAll(resp.Body)
  9217. if ioErr != nil {
  9218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9220. return
  9221. }
  9222. var respJSON map[string]interface{}
  9223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9226. return
  9227. }
  9228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9229. result, _ := json.Marshal(respJSON)
  9230. fmt.Println("log")
  9231. fmt.Println(string(result))
  9232. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9233. utils.ErrorLog("解析失败:%v", err)
  9234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9235. return
  9236. }
  9237. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9238. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  9239. if result3101.Infcode == "0" {
  9240. if len(result3101.Output.Result) > 0 {
  9241. var errMsgs []string
  9242. for _, item := range result3101.Output.Result {
  9243. errMsgs = append(errMsgs, item.VolaCont)
  9244. }
  9245. c.ServeSuccessJSON(map[string]interface{}{
  9246. "failed_code": -10,
  9247. "msg": errMsgs,
  9248. })
  9249. return
  9250. } else {
  9251. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9252. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9253. bas := strings.Split(psn_info.CardInfo, "|")
  9254. if his.IdCardType == 1 {
  9255. cert_no = bas[2]
  9256. } else if his.IdCardType == 3 {
  9257. cert_no = his.Certno
  9258. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  9259. } else if his.IdCardType == 4 {
  9260. cert_no = his.Certno
  9261. psn_info.VerifyNumber = psn_info.VerifyNumber
  9262. }
  9263. //江苏地区国家医保医疗类别
  9264. //职工透析:医疗类别选特殊情况门诊9933
  9265. //居民血透门慢: 医疗类别选门诊慢病1402
  9266. //var med_type string
  9267. //if his.Insutype == "310" {
  9268. // if reg_type == 14 {
  9269. // med_type = "9933"
  9270. // } else if reg_type == 11 {
  9271. // med_type = "11"
  9272. //
  9273. // }
  9274. //} else if his.Insutype == "390" {
  9275. // if reg_type == 14 {
  9276. // med_type = "1402"
  9277. // } else if reg_type == 11 {
  9278. // med_type = "11"
  9279. // }
  9280. //}
  9281. var api string
  9282. if miConfig.MdtrtareaAdmvs == "320921" {
  9283. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9284. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9285. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9286. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9287. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9288. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9289. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9290. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9291. } else {
  9292. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9293. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9294. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9295. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9296. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9297. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9298. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9299. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9300. }
  9301. resp, requestErr := http.Get(api)
  9302. if requestErr != nil {
  9303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9304. return
  9305. }
  9306. body, ioErr := ioutil.ReadAll(resp.Body)
  9307. if ioErr != nil {
  9308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9310. return
  9311. }
  9312. var respJSON map[string]interface{}
  9313. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9316. return
  9317. }
  9318. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9319. result, _ := json.Marshal(respJSON)
  9320. fmt.Println("log")
  9321. fmt.Println(string(result))
  9322. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9323. utils.ErrorLog("解析失败:%v", err)
  9324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9325. return
  9326. }
  9327. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9328. res.Output = resSeven10265.Output
  9329. res.ErrMsg = resSeven10265.ErrMsg
  9330. res.Cainfo = resSeven10265.Cainfo
  9331. res.WarnMsg = resSeven10265.WarnMsg
  9332. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9333. res.Infcode = infocode
  9334. }
  9335. }
  9336. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9337. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9338. var cert_no string
  9339. if his.IdCardType == 1 {
  9340. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9341. } else {
  9342. cert_no = psn_info.VerifyNumber
  9343. }
  9344. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9345. var dat map[string]interface{}
  9346. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9347. fmt.Println(dat)
  9348. } else {
  9349. fmt.Println(err)
  9350. }
  9351. saveLog(result2, src_resquest, "2207", "结算")
  9352. userJSONBytes, _ := json.Marshal(dat)
  9353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9354. utils.ErrorLog("解析失败:%v", err)
  9355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9356. return
  9357. }
  9358. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9359. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9360. var cert_no string
  9361. if his.IdCardType == 1 {
  9362. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9363. } else if his.IdCardType == 2 {
  9364. cert_no = his.IdCardNo
  9365. } else {
  9366. cert_no = psn_info.VerifyNumber
  9367. }
  9368. result2, src_resquest := service.Jxyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "")
  9369. var dat map[string]interface{}
  9370. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9371. fmt.Println(dat)
  9372. } else {
  9373. fmt.Println(err)
  9374. }
  9375. saveLog(result2, src_resquest, "2207", "结算")
  9376. userJSONBytes, _ := json.Marshal(dat)
  9377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9378. utils.ErrorLog("解析失败:%v", err)
  9379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9380. return
  9381. }
  9382. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9383. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9384. var cert_no string
  9385. if his.IdCardType == 1 {
  9386. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9387. } else if his.IdCardType == 2 {
  9388. cert_no = his.IdCardNo
  9389. } else {
  9390. cert_no = psn_info.VerifyNumber
  9391. }
  9392. result2, src_resquest := service.Hnyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "")
  9393. var dat map[string]interface{}
  9394. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9395. fmt.Println(dat)
  9396. } else {
  9397. fmt.Println(err)
  9398. }
  9399. saveLog(result2, src_resquest, "2207", "结算")
  9400. userJSONBytes, _ := json.Marshal(dat)
  9401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9402. utils.ErrorLog("解析失败:%v", err)
  9403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9404. return
  9405. }
  9406. } else {
  9407. var src_resquest string
  9408. if miConfig.Code == "H15049901371" {
  9409. //赤峰地区国家医保医疗类别
  9410. //职工透析:医疗类别选特殊情况门诊990502
  9411. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9412. var med_type string
  9413. if his.Insutype == "390" {
  9414. if reg_type == 14 {
  9415. med_type = "9933"
  9416. } else if reg_type == 11 {
  9417. med_type = "11"
  9418. }
  9419. } else if his.Insutype == "310" {
  9420. if reg_type == 14 {
  9421. med_type = "990502"
  9422. } else if reg_type == 11 {
  9423. med_type = "11"
  9424. }
  9425. }
  9426. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "")
  9427. } else {
  9428. if his.IdCardType == 4 {
  9429. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9430. token := psn_info.VerifyNumber
  9431. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token)
  9432. } else {
  9433. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "")
  9434. }
  9435. }
  9436. var dat map[string]interface{}
  9437. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9438. fmt.Println(dat)
  9439. } else {
  9440. fmt.Println(err)
  9441. }
  9442. saveLog(result2, src_resquest, "2207", "结算")
  9443. userJSONBytes, _ := json.Marshal(dat)
  9444. if miConfig.Code == "H15049901371" {
  9445. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9446. utils.ErrorLog("解析失败:%v", err)
  9447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9448. return
  9449. }
  9450. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9451. res.Output = resSeven10265.Output
  9452. res.ErrMsg = resSeven10265.ErrMsg
  9453. res.Cainfo = resSeven10265.Cainfo
  9454. res.WarnMsg = resSeven10265.WarnMsg
  9455. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9456. res.Infcode = infocode
  9457. } else {
  9458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9459. utils.ErrorLog("解析失败:%v", err)
  9460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9461. return
  9462. }
  9463. }
  9464. }
  9465. if res.Infcode != 0 {
  9466. errlog := &models.HisOrderError{
  9467. UserOrgId: adminUser.CurrentOrgId,
  9468. Ctime: time.Now().Unix(),
  9469. Mtime: time.Now().Unix(),
  9470. Number: chrg_bchno,
  9471. ErrMsg: res.ErrMsg,
  9472. Status: 1,
  9473. PatientId: id,
  9474. RecordTime: recordDateTime,
  9475. Stage: 6,
  9476. }
  9477. service.CreateErrMsgLog(errlog)
  9478. c.ServeSuccessJSON(map[string]interface{}{
  9479. "failed_code": -10,
  9480. "msg": res.ErrMsg,
  9481. })
  9482. return
  9483. } else {
  9484. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9485. order.OrderStatus = 2
  9486. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9487. order.SetlId = res.Output.Setlinfo.SetlID
  9488. order.PsnNo = res.Output.Setlinfo.PsnNo
  9489. order.PsnName = res.Output.Setlinfo.PsnName
  9490. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9491. order.Certno = res.Output.Setlinfo.Certno
  9492. order.Gend = res.Output.Setlinfo.Gend
  9493. order.Naty = res.Output.Setlinfo.Naty
  9494. order.Age = res.Output.Setlinfo.Age
  9495. order.Insutype = res.Output.Setlinfo.Insutype
  9496. order.PsnType = res.Output.Setlinfo.PsnType
  9497. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9498. order.SetlTime = res.Output.Setlinfo.SetlTime
  9499. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9500. order.PayWays = pay_ways
  9501. order.AcctUsedFlag = acct_used_flag
  9502. order.WechatPay = wechat_pay
  9503. order.AliPay = ali_pay
  9504. order.JifenPay = jifen_pay
  9505. order.BandCardPay = band_card_pay
  9506. order.CashPay = cash_pay
  9507. order.OthDesc = oth_desc
  9508. //order.MedType = res.Output.Setlinfo.MedType
  9509. if reg_type == 1112 {
  9510. order.MedType = "1112"
  9511. }
  9512. if reg_type == 1111 {
  9513. order.MedType = "1111"
  9514. }
  9515. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9516. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9517. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9518. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9519. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9520. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9521. order.HifpPay = res.Output.Setlinfo.HifpPay
  9522. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9523. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9524. order.HifesPay = res.Output.Setlinfo.HifesPay
  9525. order.HifobPay = res.Output.Setlinfo.HifobPay
  9526. order.MafPay = res.Output.Setlinfo.MafPay
  9527. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9528. order.OthPay = res.Output.Setlinfo.OthPay
  9529. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9530. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9531. order.AcctPay = res.Output.Setlinfo.AcctPay
  9532. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9533. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9534. order.Balc = res.Output.Setlinfo.Balc
  9535. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9536. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9537. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9538. order.ClrWay = res.Output.Setlinfo.ClrWay
  9539. order.Creator = order.Creator
  9540. order.Modify = roles.AdminUserId
  9541. order.RequestLog = src_resquest
  9542. order.Diagnosis = diagnosis_id
  9543. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9544. detailStr := string(setlDetail)
  9545. order.SetlDetail = detailStr
  9546. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9547. err = service.UpDateOrder(order)
  9548. if err == nil {
  9549. //判断是否使用了押金
  9550. if dec_way == "true" {
  9551. tmpstring := strconv.FormatInt(order.ID, 10)
  9552. //扣押金
  9553. order.Decimal = decimal
  9554. service.UpDateOrder(order)
  9555. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9556. if errmsg != nil {
  9557. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9558. return
  9559. }
  9560. }
  9561. c.ServeSuccessJSON(map[string]interface{}{
  9562. "msg": "结算成功",
  9563. })
  9564. } else {
  9565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9566. return
  9567. }
  9568. }
  9569. }
  9570. }
  9571. }
  9572. //func (c *HisApiController) GetPreUploadInfo() {
  9573. // id, _ := c.GetInt64("id")
  9574. // record_time := c.GetString("record_time")
  9575. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9576. // admin_user_id, _ := c.GetInt64("admin_user_id")
  9577. //
  9578. // timeLayout := "2006-01-02"
  9579. // loc, _ := time.LoadLocation("Local")
  9580. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9581. // if err != nil {
  9582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9583. // return
  9584. // }
  9585. // recordDateTime := theTime.Unix()
  9586. // adminUser := c.GetAdminUserInfo()
  9587. //
  9588. // var prescriptions []*models.HisPrescription
  9589. //
  9590. // var start_time int64
  9591. // var end_time int64
  9592. //
  9593. // data := make(map[string]interface{})
  9594. // if settle_accounts_type == 1 { //日结
  9595. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  9596. // data["pre"] = prescriptions
  9597. //
  9598. // } else { //月结
  9599. // start_time_str := c.GetString("start_time")
  9600. // end_time_str := c.GetString("end_time")
  9601. // timeLayout := "2006-01-02"
  9602. // loc, _ := time.LoadLocation("Local")
  9603. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9604. // if err != nil {
  9605. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9606. // return
  9607. // }
  9608. // recordStartTime := theStartTime.Unix()
  9609. // start_time = recordStartTime
  9610. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9611. // if err != nil {
  9612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9613. // return
  9614. // }
  9615. // recordEndTime := theEndTime.Unix()
  9616. // end_time = recordEndTime
  9617. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  9618. // data["pre"] = prescriptions
  9619. //
  9620. // }
  9621. //
  9622. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9623. //
  9624. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9625. // timestamp := time.Now().Unix()
  9626. // tempTime := time.Unix(timestamp, 0)
  9627. // timeFormat := tempTime.Format("20060102150405")
  9628. // chrgBchno := rand.Intn(100000) + 10000
  9629. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9630. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9631. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9632. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9633. // strconv.FormatInt(his.PatientId, 10)
  9634. // client := &http.Client{}
  9635. // data["psn_no"] = his.PsnNo
  9636. // data["mdtrt_id"] = his.Number
  9637. // data["chrg_bchno"] = chrg_bchno
  9638. // data["org_name"] = miConfig.OrgName
  9639. // data["doctor"] = roles.UserName
  9640. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  9641. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9642. // data["fixmedins_code"] = miConfig.Code
  9643. // data["dept_code"] = department.Number
  9644. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9645. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9646. // data["secret_key"] = miConfig.SecretKey
  9647. // var ids []int64
  9648. //
  9649. // for _, item := range prescriptions {
  9650. // ids = append(ids, item.ID)
  9651. // }
  9652. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9653. // if config.IsOpen == 1 { //对接了医保,走医保流程
  9654. // bytesData, _ := json.Marshal(data)
  9655. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  9656. // resp, _ := client.Do(req)
  9657. // defer resp.Body.Close()
  9658. // body, ioErr := ioutil.ReadAll(resp.Body)
  9659. // if ioErr != nil {
  9660. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9662. // return
  9663. // }
  9664. // var respJSON map[string]interface{}
  9665. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9666. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9668. // return
  9669. // }
  9670. //
  9671. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9672. // userJSONBytes, _ := json.Marshal(respJSON)
  9673. // var res ResultFour
  9674. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9675. // utils.ErrorLog("解析失败:%v", err)
  9676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9677. // return
  9678. // }
  9679. //
  9680. // if res.Infcode == 0 {
  9681. // order := &models.HisOrder{
  9682. // UserOrgId: adminUser.CurrentOrgId,
  9683. // HisPatientId: his.ID,
  9684. // PatientId: his.PatientId,
  9685. // SettleAccountsDate: recordDateTime,
  9686. // Ctime: time.Now().Unix(),
  9687. // Mtime: time.Now().Unix(),
  9688. // Status: 1,
  9689. // Number: chrg_bchno,
  9690. // Infcode: res.Infcode,
  9691. // WarnMsg: res.WarnMsg,
  9692. // Cainfo: res.Cainfo,
  9693. // ErrMsg: res.ErrMsg,
  9694. // RespondTime: res.RefmsgTime,
  9695. // InfRefmsgid: res.InfRefmsgid,
  9696. // OrderStatus: 1,
  9697. // IsMedicineInsurance: 1,
  9698. // SettleType: settle_accounts_type,
  9699. // SettleStartTime: start_time,
  9700. // SettleEndTime: end_time,
  9701. // Creator: roles.ID,
  9702. // Modify: roles.ID,
  9703. // PType: 2,
  9704. // }
  9705. // err = service.CreateOrder(order)
  9706. // if err != nil {
  9707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9708. // return
  9709. // }
  9710. //
  9711. // for _, item := range res.Output.Result {
  9712. // temp := strings.Split(item.FeedetlSn, "-")
  9713. // var advice_id int64 = 0
  9714. // var project_id int64 = 0
  9715. // var types int64 = 0
  9716. //
  9717. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  9718. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  9719. //
  9720. // if temp[1] == "1" {
  9721. // advice_id = id
  9722. // project_id = 0
  9723. // } else if temp[1] == "2" {
  9724. // advice_id = 0
  9725. // project_id = id
  9726. // }
  9727. //
  9728. // info := &models.HisOrderInfo{
  9729. // OrderNumber: order.Number,
  9730. // FeedetlSn: item.FeedetlSn,
  9731. // UploadDate: time.Now().Unix(),
  9732. // AdviceId: advice_id,
  9733. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  9734. // Cnt: item.Cnt,
  9735. // Pric: float64(item.Pric),
  9736. // PatientId: his.PatientId,
  9737. // PricUplmtAmt: item.PricUplmtAmt,
  9738. // SelfpayProp: item.SelfpayProp,
  9739. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9740. // OverlmtAmt: item.OverlmtAmt,
  9741. // PreselfpayAmt: item.PreselfpayAmt,
  9742. // BasMednFlag: item.BasMednFlag,
  9743. // MedChrgitmType: item.MedChrgitmType,
  9744. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  9745. // Status: 1,
  9746. // Memo: item.Memo,
  9747. // Mtime: time.Now().Unix(),
  9748. // InscpScpAmt: item.InscpScpAmt,
  9749. // DrtReimFlag: item.DrtReimFlag,
  9750. // Ctime: time.Now().Unix(),
  9751. // ListSpItemFlag: item.ListSpItemFlag,
  9752. // ChldMedcFlag: item.ChldMedcFlag,
  9753. // LmtUsedFlag: item.LmtUsedFlag,
  9754. // ChrgitmLv: item.ChrgitmLv,
  9755. // UserOrgId: adminUser.CurrentOrgId,
  9756. // HisPatientId: his.ID,
  9757. // OrderId: order.ID,
  9758. // ProjectId: project_id,
  9759. // Type: types,
  9760. // }
  9761. // service.CreateOrderInfo(info)
  9762. //
  9763. // }
  9764. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9765. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  9766. //
  9767. // var total float64
  9768. // for _, item := range prescriptions {
  9769. // if item.Type == 1 { //药品
  9770. // for _, subItem := range item.HisDoctorAdviceInfo {
  9771. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9772. // }
  9773. // }
  9774. // if item.Type == 2 { //项目
  9775. // for _, subItem := range item.HisPrescriptionProject {
  9776. // total = total + (subItem.Price * float64(subItem.Count))
  9777. // }
  9778. // }
  9779. // }
  9780. //
  9781. // for _, item := range prescriptions {
  9782. // for _, subItem := range item.HisAdditionalCharge {
  9783. // total = total + (subItem.Price * float64(subItem.Count))
  9784. // }
  9785. // }
  9786. //
  9787. // allTotal := fmt.Sprintf("%.2f", total)
  9788. // if res.Infcode == 0 {
  9789. // var rf []*ResultFive
  9790. // json.Unmarshal([]byte(his.Iinfo), &rf)
  9791. // psn_no := his.PsnNo
  9792. // mdtrt_id := his.Number
  9793. // chrg_bchno := chrg_bchno
  9794. // cert_no := his.Certno
  9795. // insutype := rf[0].Insutype
  9796. //
  9797. // if his.IdCardType == 1 {
  9798. // cert_no = his.MedicalInsuranceNumber
  9799. //
  9800. // } else {
  9801. //
  9802. // cert_no = his.Certno
  9803. //
  9804. // }
  9805. //
  9806. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  9807. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  9808. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  9809. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  9810. // resp, requestErr := http.Get(api)
  9811. // if requestErr != nil {
  9812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9813. // return
  9814. // }
  9815. // defer resp.Body.Close()
  9816. // body, ioErr := ioutil.ReadAll(resp.Body)
  9817. // if ioErr != nil {
  9818. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9820. // return
  9821. // }
  9822. // var respJSON map[string]interface{}
  9823. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9824. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9826. // return
  9827. // }
  9828. // fmt.Println(respJSON)
  9829. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9830. // userJSONBytes, _ := json.Marshal(respJSON)
  9831. // var res ResultSeven
  9832. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9833. // utils.ErrorLog("解析失败:%v", err)
  9834. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9835. // return
  9836. // }
  9837. // if res.Infcode != 0 {
  9838. // errlog := &models.HisOrderError{
  9839. // UserOrgId: adminUser.CurrentOrgId,
  9840. // Ctime: time.Now().Unix(),
  9841. // Mtime: time.Now().Unix(),
  9842. // Number: chrg_bchno,
  9843. // ErrMsg: res.ErrMsg,
  9844. // Status: 1,
  9845. // PatientId: id,
  9846. // RecordTime: recordDateTime,
  9847. // Stage: 7,
  9848. // }
  9849. // service.CreateErrMsgLog(errlog)
  9850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9851. // return
  9852. // } else {
  9853. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9854. // order.OrderStatus = 1
  9855. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9856. // order.SetlId = res.Output.Setlinfo.SetlID
  9857. // order.PsnNo = res.Output.Setlinfo.PsnNo
  9858. // order.PsnName = res.Output.Setlinfo.PsnName
  9859. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9860. // order.Certno = res.Output.Setlinfo.Certno
  9861. // order.Gend = res.Output.Setlinfo.Gend
  9862. // order.Naty = res.Output.Setlinfo.Naty
  9863. // order.Age = res.Output.Setlinfo.Age
  9864. // order.Insutype = res.Output.Setlinfo.Insutype
  9865. // order.PsnType = res.Output.Setlinfo.PsnType
  9866. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9867. // order.SetlTime = res.Output.Setlinfo.SetlTime
  9868. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9869. // order.MedType = res.Output.Setlinfo.MedType
  9870. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9871. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9872. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9873. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9874. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9875. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9876. // order.HifpPay = res.Output.Setlinfo.HifpPay
  9877. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9878. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9879. // order.HifesPay = res.Output.Setlinfo.HifesPay
  9880. // order.HifobPay = res.Output.Setlinfo.HifobPay
  9881. // order.MafPay = res.Output.Setlinfo.MafPay
  9882. // order.OthPay = res.Output.Setlinfo.OthPay
  9883. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9884. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9885. // order.AcctPay = res.Output.Setlinfo.AcctPay
  9886. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9887. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9888. // order.Balc = res.Output.Setlinfo.Balc
  9889. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9890. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9891. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9892. // order.ClrWay = res.Output.Setlinfo.ClrWay
  9893. // order.Creator = order.Creator
  9894. // order.Modify = roles.ID
  9895. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9896. // detailStr := string(setlDetail)
  9897. // order.SetlDetail = detailStr
  9898. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9899. // err = service.UpDateOrder(order)
  9900. // if err == nil {
  9901. // c.ServeSuccessJSON(map[string]interface{}{
  9902. // "msg": "预结算成功",
  9903. // })
  9904. // } else {
  9905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9906. // return
  9907. // }
  9908. // }
  9909. // } else {
  9910. // adminUser := c.GetAdminUserInfo()
  9911. // errlog := &models.HisOrderError{
  9912. // UserOrgId: adminUser.CurrentOrgId,
  9913. // Ctime: time.Now().Unix(),
  9914. // Mtime: time.Now().Unix(),
  9915. // ErrMsg: res.ErrMsg,
  9916. // Status: 1,
  9917. // PatientId: id,
  9918. // RecordTime: recordDateTime,
  9919. // Stage: 4,
  9920. // }
  9921. // service.CreateErrMsgLog(errlog)
  9922. //
  9923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9924. // return
  9925. // }
  9926. // } else {
  9927. // adminUser := c.GetAdminUserInfo()
  9928. // errlog := &models.HisOrderError{
  9929. // UserOrgId: adminUser.CurrentOrgId,
  9930. // Ctime: time.Now().Unix(),
  9931. // Mtime: time.Now().Unix(),
  9932. // ErrMsg: res.ErrMsg,
  9933. // Status: 1,
  9934. // PatientId: id,
  9935. // RecordTime: recordDateTime,
  9936. // Stage: 4,
  9937. // }
  9938. // service.CreateErrMsgLog(errlog)
  9939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9940. // return
  9941. // }
  9942. //
  9943. // } else {
  9944. // var total float64
  9945. // for _, item := range prescriptions {
  9946. // if item.Type == 1 { //药品
  9947. // for _, subItem := range item.HisDoctorAdviceInfo {
  9948. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9949. // }
  9950. // }
  9951. // if item.Type == 2 { //项目
  9952. // for _, subItem := range item.HisPrescriptionProject {
  9953. // total = total + (subItem.Price * float64(subItem.Count))
  9954. // }
  9955. // }
  9956. //
  9957. // for _, subItem := range item.HisAdditionalCharge {
  9958. // total = total + (subItem.Price * float64(subItem.Count))
  9959. // }
  9960. // }
  9961. //
  9962. // allTotal := fmt.Sprintf("%.2f", total)
  9963. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9964. // order := &models.HisOrder{
  9965. // UserOrgId: adminUser.CurrentOrgId,
  9966. // HisPatientId: his.ID,
  9967. // PatientId: id,
  9968. // SettleAccountsDate: recordDateTime,
  9969. // Ctime: time.Now().Unix(),
  9970. // Mtime: time.Now().Unix(),
  9971. // Status: 1,
  9972. // OrderStatus: 2,
  9973. // Number: chrg_bchno,
  9974. // MedfeeSumamt: totals,
  9975. // }
  9976. // err = service.CreateOrder(order)
  9977. // if err != nil {
  9978. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9979. // return
  9980. // }
  9981. //
  9982. // var customs []*Custom
  9983. // for _, item := range prescriptions {
  9984. //
  9985. // if item.Type == 1 { //药品
  9986. // for _, subItem := range item.HisDoctorAdviceInfo {
  9987. // cus := &Custom{
  9988. // AdviceId: subItem.ID,
  9989. // ProjectId: 0,
  9990. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9991. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9992. // FeedetlSn: subItem.FeedetlSn,
  9993. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9994. // MedListCodg: subItem.MedListCodg,
  9995. // Type: 1,
  9996. // }
  9997. // customs = append(customs, cus)
  9998. // }
  9999. // }
  10000. //
  10001. // if item.Type == 2 { //项目
  10002. // for _, subItem := range item.HisPrescriptionProject {
  10003. //
  10004. // cus := &Custom{
  10005. // AdviceId: 0,
  10006. // ProjectId: subItem.ID,
  10007. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  10008. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  10009. // FeedetlSn: subItem.FeedetlSn,
  10010. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  10011. // MedListCodg: subItem.MedListCodg,
  10012. // Type: 2,
  10013. // }
  10014. //
  10015. // customs = append(customs, cus)
  10016. // }
  10017. // }
  10018. //
  10019. // for _, item := range item.HisAdditionalCharge {
  10020. // cus := &Custom{
  10021. // ItemId: item.ID,
  10022. // AdviceId: 0,
  10023. // ProjectId: 0,
  10024. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  10025. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  10026. // FeedetlSn: item.FeedetlSn,
  10027. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  10028. // MedListCodg: item.XtHisAddtionConfig.Code,
  10029. // Type: 3,
  10030. // }
  10031. //
  10032. // customs = append(customs, cus)
  10033. // }
  10034. //
  10035. // }
  10036. //
  10037. // for _, item := range customs {
  10038. // var advice_id int64 = 0
  10039. // var project_id int64 = 0
  10040. // var item_id int64 = 0
  10041. //
  10042. // var types int64 = 0
  10043. //
  10044. // if item.Type == 1 {
  10045. // advice_id = item.AdviceId
  10046. // project_id = 0
  10047. // item_id = 0
  10048. // } else if item.Type == 2 {
  10049. // advice_id = 0
  10050. // item_id = 0
  10051. //
  10052. // project_id = item.ProjectId
  10053. // } else if item.Type == 3 {
  10054. // advice_id = 0
  10055. // item_id = item.ItemId
  10056. // project_id = 0
  10057. // }
  10058. //
  10059. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  10060. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  10061. // pric, _ := strconv.ParseFloat(item.Price, 32)
  10062. //
  10063. // info := &models.HisOrderInfo{
  10064. // OrderNumber: order.Number,
  10065. // UploadDate: time.Now().Unix(),
  10066. // AdviceId: advice_id,
  10067. // DetItemFeeSumamt: detItemFeeSumamt,
  10068. // Cnt: cut,
  10069. // Pric: pric,
  10070. // PatientId: id,
  10071. // Status: 1,
  10072. // Mtime: time.Now().Unix(),
  10073. // Ctime: time.Now().Unix(),
  10074. // UserOrgId: adminUser.CurrentOrgId,
  10075. // HisPatientId: his.ID,
  10076. // OrderId: order.ID,
  10077. // ProjectId: project_id,
  10078. // Type: types,
  10079. // ItemId: item_id,
  10080. // }
  10081. // service.CreateOrderInfo(info)
  10082. // }
  10083. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10084. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10085. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  10086. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10087. // if err == nil {
  10088. // c.ServeSuccessJSON(map[string]interface{}{
  10089. // "msg": "结算成功",
  10090. // })
  10091. // } else {
  10092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10093. // return
  10094. // }
  10095. // }
  10096. //}
  10097. // 上传明细-预结算-
  10098. func (c *HisApiController) GetPreUploadInfo() {
  10099. id, _ := c.GetInt64("id")
  10100. record_time := c.GetString("record_time")
  10101. his_patient_id, _ := c.GetInt64("his_patient_id")
  10102. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10103. admin_user_id, _ := c.GetInt64("admin_user_id")
  10104. diagnosis_id := c.GetString("diagnosis")
  10105. sick_type, _ := c.GetInt64("sick_type")
  10106. reg_type, _ := c.GetInt64("p_type")
  10107. begin_time := c.GetString("begin_time")
  10108. acct_used_flag := c.GetString("acct_used_flag")
  10109. id_str := c.GetString("ids")
  10110. ids_arr := strings.Split(id_str, ",")
  10111. timeLayout := "2006-01-02"
  10112. loc, _ := time.LoadLocation("Local")
  10113. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10114. if err != nil {
  10115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10116. return
  10117. }
  10118. recordDateTime := theTime.Unix()
  10119. adminUser := c.GetAdminUserInfo()
  10120. diagnosis_ids := strings.Split(diagnosis_id, ",")
  10121. var config []*models.HisXtDiagnoseConfig
  10122. for _, item := range diagnosis_ids {
  10123. id, _ := strconv.ParseInt(item, 10, 64)
  10124. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10125. config = append(config, &diagnosisConfig)
  10126. }
  10127. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10128. sickConfig, _ := service.FindSickById(sick_type)
  10129. var prescriptions []*models.HisPrescription
  10130. var start_time int64
  10131. var end_time int64
  10132. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10133. fmt.Println(his_patient_id)
  10134. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10135. timestamp := time.Now().Unix()
  10136. tempTime := time.Unix(timestamp, 0)
  10137. timeFormat := tempTime.Format("20060102150405")
  10138. chrgBchno := rand.Intn(100000) + 10000
  10139. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10140. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10141. var patientPrescription models.HisPrescriptionInfo
  10142. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10143. if patientPrescription.ID == 0 {
  10144. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10145. }
  10146. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10147. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10148. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10149. strconv.FormatInt(his.PatientId, 10)
  10150. var res2 ResultSix
  10151. var resSix10265 ResultSix10265
  10152. //var time_stamp string
  10153. if miConfig.MdtrtareaAdmvs == "421300" {
  10154. data := make(map[string]interface{})
  10155. client := &http.Client{}
  10156. data["psn_no"] = his.PsnNo
  10157. data["mdtrt_id"] = his.Number
  10158. data["department"] = department.Name
  10159. data["org_name"] = miConfig.OrgName
  10160. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10161. data["doctor_id"] = doctor_info.DoctorNumber
  10162. data["doctor_name"] = roles.UserName
  10163. data["fixmedins_code"] = miConfig.Code
  10164. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10165. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10166. data["secret_key"] = miConfig.SecretKey
  10167. data["sick_code"] = sickConfig.CountryCode
  10168. data["sick_name"] = sickConfig.ClassName
  10169. data["begin_time"] = begin_time
  10170. data["dept"] = strconv.FormatInt(department.ID, 10)
  10171. data["config"] = config
  10172. data["opter"] = roles.UserName
  10173. fmt.Println(data)
  10174. bytesData, _ := json.Marshal(data)
  10175. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  10176. resp, _ := client.Do(req)
  10177. defer resp.Body.Close()
  10178. body, ioErr := ioutil.ReadAll(resp.Body)
  10179. if ioErr != nil {
  10180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10182. return
  10183. }
  10184. var respJSON map[string]interface{}
  10185. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10188. return
  10189. }
  10190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10191. userJSONBytes, _ := json.Marshal(respJSON)
  10192. fmt.Println("log")
  10193. fmt.Println(string(userJSONBytes))
  10194. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10195. utils.ErrorLog("解析失败:%v", err)
  10196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10197. return
  10198. }
  10199. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10200. data := make(map[string]interface{})
  10201. client := &http.Client{}
  10202. data["psn_no"] = his.PsnNo
  10203. data["mdtrt_id"] = his.Number
  10204. data["doctor"] = roles.UserName
  10205. data["department"] = department.Name
  10206. data["org_name"] = miConfig.OrgName
  10207. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10208. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  10209. data["fixmedins_code"] = miConfig.Code
  10210. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10211. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10212. data["secret_key"] = miConfig.SecretKey
  10213. data["sick_code"] = sickConfig.CountryCode
  10214. data["sick_name"] = sickConfig.ClassName
  10215. data["begin_time"] = begin_time
  10216. data["dept"] = strconv.FormatInt(department.ID, 10)
  10217. data["config"] = config
  10218. data["url"] = miConfig.Url
  10219. data["ak"] = miConfig.AccessKey
  10220. data["cainfo"] = miConfig.Cainfo
  10221. bytesData, _ := json.Marshal(data)
  10222. var req *http.Request
  10223. if miConfig.MdtrtareaAdmvs == "320921" {
  10224. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10225. } else {
  10226. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10227. }
  10228. resp, _ := client.Do(req)
  10229. defer resp.Body.Close()
  10230. body, ioErr := ioutil.ReadAll(resp.Body)
  10231. if ioErr != nil {
  10232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10234. return
  10235. }
  10236. var respJSON map[string]interface{}
  10237. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10240. return
  10241. }
  10242. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  10243. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  10244. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  10245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10246. userJSONBytes, _ := json.Marshal(respJSON)
  10247. fmt.Println("log")
  10248. fmt.Println(string(userJSONBytes))
  10249. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10250. utils.ErrorLog("解析失败:%v", err)
  10251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10252. return
  10253. }
  10254. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10255. res2.Output = resSix10265.Output
  10256. res2.ErrMsg = resSix10265.ErrMsg
  10257. res2.Cainfo = resSix10265.Cainfo
  10258. res2.WarnMsg = resSix10265.WarnMsg
  10259. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10260. res2.Infcode = infocode
  10261. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10262. result, requestLog, _ := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10263. saveLog(result, requestLog, "2203", "上传就诊信息")
  10264. var respJSON2 map[string]interface{}
  10265. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10268. return
  10269. }
  10270. userJSONBytes2, _ := json.Marshal(respJSON2)
  10271. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10272. utils.ErrorLog("解析失败:%v", err)
  10273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10274. return
  10275. }
  10276. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10277. var result string
  10278. var requestLog string
  10279. result, requestLog = service.Jxyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "")
  10280. saveLog(result, requestLog, "2203", "上传就诊信息")
  10281. var respJSON2 map[string]interface{}
  10282. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10285. return
  10286. }
  10287. userJSONBytes2, _ := json.Marshal(respJSON2)
  10288. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10289. utils.ErrorLog("解析失败:%v", err)
  10290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10291. return
  10292. }
  10293. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10294. var result string
  10295. var requestLog string
  10296. result, requestLog = service.Hnyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "")
  10297. saveLog(result, requestLog, "2203", "上传就诊信息")
  10298. var respJSON2 map[string]interface{}
  10299. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10302. return
  10303. }
  10304. userJSONBytes2, _ := json.Marshal(respJSON2)
  10305. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10306. utils.ErrorLog("解析失败:%v", err)
  10307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10308. return
  10309. }
  10310. } else {
  10311. var result string
  10312. var requestLog string
  10313. if miConfig.MdtrtareaAdmvs == "440781" { //
  10314. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  10315. } else {
  10316. if miConfig.Code == "H15049901371" {
  10317. //赤峰地区国家医保医疗类别
  10318. //职工透析:医疗类别选特殊情况门诊990502
  10319. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10320. var med_type string
  10321. if his.Insutype == "390" {
  10322. if reg_type == 14 {
  10323. med_type = "9933"
  10324. } else if reg_type == 11 {
  10325. med_type = "11"
  10326. }
  10327. } else if his.Insutype == "310" {
  10328. if reg_type == 14 {
  10329. med_type = "990502"
  10330. } else if reg_type == 11 {
  10331. med_type = "11"
  10332. }
  10333. }
  10334. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  10335. } else {
  10336. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  10337. }
  10338. saveLog(result, requestLog, "2203", "上传就诊信息")
  10339. var respJSON2 map[string]interface{}
  10340. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10343. return
  10344. }
  10345. userJSONBytes2, _ := json.Marshal(respJSON2)
  10346. if miConfig.Code == "H15049901371" {
  10347. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  10348. utils.ErrorLog("解析失败:%v", err)
  10349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10350. return
  10351. }
  10352. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10353. res2.Output = resSix10265.Output
  10354. res2.ErrMsg = resSix10265.ErrMsg
  10355. res2.Cainfo = resSix10265.Cainfo
  10356. res2.WarnMsg = resSix10265.WarnMsg
  10357. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10358. res2.Infcode = infocode
  10359. } else {
  10360. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10361. utils.ErrorLog("解析失败:%v", err)
  10362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10363. return
  10364. }
  10365. }
  10366. }
  10367. }
  10368. if res2.Infcode != 0 {
  10369. adminUser := c.GetAdminUserInfo()
  10370. errlog := &models.HisOrderError{
  10371. UserOrgId: adminUser.CurrentOrgId,
  10372. Ctime: time.Now().Unix(),
  10373. Mtime: time.Now().Unix(),
  10374. ErrMsg: res2.ErrMsg,
  10375. Status: 1,
  10376. PatientId: id,
  10377. RecordTime: recordDateTime,
  10378. Stage: 3,
  10379. }
  10380. service.CreateErrMsgLog(errlog)
  10381. c.ServeSuccessJSON(map[string]interface{}{
  10382. "failed_code": -10,
  10383. "msg": res2.ErrMsg,
  10384. })
  10385. return
  10386. } else {
  10387. his.Diagnosis = diagnosis_id
  10388. his.SickType = sickConfig.ID
  10389. his.PType = fmt.Sprintf("%d", reg_type)
  10390. service.UpdateHisPatientThree(&his)
  10391. data := make(map[string]interface{})
  10392. if settle_accounts_type == 1 { //日结
  10393. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  10394. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  10395. } else {
  10396. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  10397. }
  10398. data["pre"] = prescriptions
  10399. } else { //月结
  10400. start_time_str := c.GetString("start_time")
  10401. end_time_str := c.GetString("end_time")
  10402. timeLayout := "2006-01-02"
  10403. loc, _ := time.LoadLocation("Local")
  10404. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10405. if err != nil {
  10406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10407. return
  10408. }
  10409. recordStartTime := theStartTime.Unix()
  10410. start_time = recordStartTime
  10411. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10412. if err != nil {
  10413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10414. return
  10415. }
  10416. recordEndTime := theEndTime.Unix()
  10417. end_time = recordEndTime
  10418. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  10419. data["pre"] = prescriptions
  10420. }
  10421. client := &http.Client{}
  10422. data["psn_no"] = his.PsnNo
  10423. data["mdtrt_id"] = his.Number
  10424. data["chrg_bchno"] = chrg_bchno
  10425. data["org_name"] = miConfig.OrgName
  10426. data["doctor"] = doctor_info.UserName
  10427. data["doctor_id"] = doctor_info.DoctorNumber
  10428. data["dept"] = department.Name
  10429. data["fixmedins_code"] = miConfig.Code
  10430. data["opter"] = roles.UserName
  10431. data["dept_code"] = department.Number
  10432. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10433. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10434. data["secret_key"] = miConfig.SecretKey
  10435. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  10436. data["url"] = miConfig.Url
  10437. data["ak"] = miConfig.AccessKey
  10438. data["new_doctor_name"] = patientPrescription.Doctor
  10439. data["diag_code"] = sickConfig.CountryCode
  10440. data["cainfo"] = miConfig.Cainfo
  10441. data["opter"] = roles.UserName
  10442. var ids []int64
  10443. for _, item := range prescriptions {
  10444. ids = append(ids, item.ID)
  10445. }
  10446. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10447. if config.IsOpen == 1 { //对接了医保,走医保流程
  10448. var res ResultFour
  10449. var resFour10265 ResultFour10265
  10450. if miConfig.MdtrtareaAdmvs == "421300" {
  10451. bytesData, _ := json.Marshal(data)
  10452. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  10453. resp, _ := client.Do(req)
  10454. defer resp.Body.Close()
  10455. body, ioErr := ioutil.ReadAll(resp.Body)
  10456. if ioErr != nil {
  10457. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10459. return
  10460. }
  10461. var respJSON map[string]interface{}
  10462. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10463. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10465. return
  10466. }
  10467. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10468. userJSONBytes, _ := json.Marshal(respJSON)
  10469. fmt.Println("log")
  10470. fmt.Println(string(userJSONBytes))
  10471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10472. utils.ErrorLog("解析失败:%v", err)
  10473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10474. return
  10475. }
  10476. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10477. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  10478. if result3101.Infcode == "0" {
  10479. if len(result3101.Output.Result) > 0 {
  10480. var errMsgs []string
  10481. for _, item := range result3101.Output.Result {
  10482. errMsgs = append(errMsgs, item.VolaCont)
  10483. }
  10484. c.ServeSuccessJSON(map[string]interface{}{
  10485. "failed_code": -10,
  10486. "msg": errMsgs,
  10487. })
  10488. return
  10489. } else {
  10490. if miConfig.MdtrtareaAdmvs == "320921" {
  10491. data["doctor_id"] = "D320923012139"
  10492. } else {
  10493. data["doctor_id"] = "D371621008686"
  10494. }
  10495. bytesData, _ := json.Marshal(data)
  10496. var req *http.Request
  10497. if miConfig.MdtrtareaAdmvs == "320921" {
  10498. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10499. } else {
  10500. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10501. }
  10502. resp, _ := client.Do(req)
  10503. defer resp.Body.Close()
  10504. body, ioErr := ioutil.ReadAll(resp.Body)
  10505. if ioErr != nil {
  10506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10508. return
  10509. }
  10510. var respJSON map[string]interface{}
  10511. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10514. return
  10515. }
  10516. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10517. userJSONBytes, _ := json.Marshal(respJSON)
  10518. fmt.Println("log")
  10519. fmt.Println(string(userJSONBytes))
  10520. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10521. utils.ErrorLog("解析失败:%v", err)
  10522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10523. return
  10524. }
  10525. res.InfRefmsgid = resFour10265.InfRefmsgid
  10526. res.Output = resFour10265.Output
  10527. res.ErrMsg = resFour10265.ErrMsg
  10528. res.Cainfo = resFour10265.Cainfo
  10529. res.WarnMsg = resFour10265.WarnMsg
  10530. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10531. res.Infcode = infocode
  10532. }
  10533. }
  10534. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10535. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  10536. var dat map[string]interface{}
  10537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10538. fmt.Println(dat)
  10539. } else {
  10540. fmt.Println(err)
  10541. }
  10542. saveLog(result, request_log, "2204", "上传费用明细")
  10543. userJSONBytes, _ := json.Marshal(dat)
  10544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10545. utils.ErrorLog("解析失败:%v", err)
  10546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10547. return
  10548. }
  10549. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10550. result, request_log := service.Jxyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  10551. var dat map[string]interface{}
  10552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10553. fmt.Println(dat)
  10554. } else {
  10555. fmt.Println(err)
  10556. }
  10557. saveLog(result, request_log, "2204", "上传费用明细")
  10558. userJSONBytes, _ := json.Marshal(dat)
  10559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10560. utils.ErrorLog("解析失败:%v", err)
  10561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10562. return
  10563. }
  10564. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10565. result, request_log := service.Hnyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  10566. var dat map[string]interface{}
  10567. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10568. fmt.Println(dat)
  10569. } else {
  10570. fmt.Println(err)
  10571. }
  10572. saveLog(result, request_log, "2204", "上传费用明细")
  10573. userJSONBytes, _ := json.Marshal(dat)
  10574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10575. utils.ErrorLog("解析失败:%v", err)
  10576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10577. return
  10578. }
  10579. } else {
  10580. if miConfig.Code == "H15049901371" {
  10581. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  10582. var dat map[string]interface{}
  10583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10584. fmt.Println(dat)
  10585. } else {
  10586. fmt.Println(err)
  10587. }
  10588. saveLog(result, request_log, "2204", "上传费用明细")
  10589. userJSONBytes, _ := json.Marshal(dat)
  10590. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10591. utils.ErrorLog("解析失败:%v", err)
  10592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10593. return
  10594. }
  10595. res.InfRefmsgid = resFour10265.InfRefmsgid
  10596. res.Output = resFour10265.Output
  10597. res.ErrMsg = resFour10265.ErrMsg
  10598. res.Cainfo = resFour10265.Cainfo
  10599. res.WarnMsg = resFour10265.WarnMsg
  10600. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10601. res.Infcode = infocode
  10602. } else {
  10603. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  10604. var dat map[string]interface{}
  10605. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10606. fmt.Println(dat)
  10607. } else {
  10608. fmt.Println(err)
  10609. }
  10610. saveLog(result, request_log, "2204", "上传费用明细")
  10611. userJSONBytes, _ := json.Marshal(dat)
  10612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10613. utils.ErrorLog("解析失败:%v", err)
  10614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10615. return
  10616. }
  10617. }
  10618. }
  10619. var total_two float64
  10620. if res.Infcode == 0 {
  10621. order := &models.HisOrder{
  10622. UserOrgId: adminUser.CurrentOrgId,
  10623. HisPatientId: his.ID,
  10624. PatientId: his.PatientId,
  10625. SettleAccountsDate: recordDateTime,
  10626. Ctime: time.Now().Unix(),
  10627. Mtime: time.Now().Unix(),
  10628. MdtrtId: his.Number,
  10629. PsnNo: his.PsnNo,
  10630. MedType: strconv.FormatInt(reg_type, 10),
  10631. Status: 1,
  10632. Number: chrg_bchno,
  10633. Infcode: res.Infcode,
  10634. WarnMsg: res.WarnMsg,
  10635. Cainfo: res.Cainfo,
  10636. ErrMsg: res.ErrMsg,
  10637. RespondTime: res.RefmsgTime,
  10638. InfRefmsgid: res.InfRefmsgid,
  10639. OrderStatus: 1,
  10640. IsMedicineInsurance: 1,
  10641. SettleType: settle_accounts_type,
  10642. SettleStartTime: start_time,
  10643. SettleEndTime: end_time,
  10644. Creator: roles.AdminUserId,
  10645. Modify: roles.AdminUserId,
  10646. PType: 2,
  10647. Diagnosis: diagnosis_id,
  10648. }
  10649. err = service.CreateOrder(order)
  10650. if err != nil {
  10651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10652. return
  10653. }
  10654. for _, item := range res.Output.Result {
  10655. temp := strings.Split(item.FeedetlSn, "-")
  10656. var advice_id int64 = 0
  10657. var project_id int64 = 0
  10658. var types int64 = 0
  10659. id, _ := strconv.ParseInt(temp[2], 10, 64)
  10660. types, _ = strconv.ParseInt(temp[1], 10, 64)
  10661. if temp[1] == "1" {
  10662. advice_id = id
  10663. project_id = 0
  10664. } else if temp[1] == "2" {
  10665. advice_id = 0
  10666. project_id = id
  10667. }
  10668. total_two = total_two + item.DetItemFeeSumamt
  10669. info := &models.HisOrderInfo{
  10670. OrderNumber: order.Number,
  10671. FeedetlSn: item.FeedetlSn,
  10672. UploadDate: time.Now().Unix(),
  10673. AdviceId: advice_id,
  10674. DetItemFeeSumamt: item.DetItemFeeSumamt,
  10675. Cnt: item.Cnt,
  10676. Pric: float64(item.Pric),
  10677. PatientId: his.PatientId,
  10678. PricUplmtAmt: item.PricUplmtAmt,
  10679. SelfpayProp: item.SelfpayProp,
  10680. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10681. OverlmtAmt: item.OverlmtAmt,
  10682. PreselfpayAmt: item.PreselfpayAmt,
  10683. BasMednFlag: item.BasMednFlag,
  10684. MedChrgitmType: item.MedChrgitmType,
  10685. HiNegoDrugFlag: item.HiNegoDrugFlag,
  10686. Status: 1,
  10687. Memo: item.Memo,
  10688. Mtime: time.Now().Unix(),
  10689. InscpScpAmt: item.InscpScpAmt,
  10690. DrtReimFlag: item.DrtReimFlag,
  10691. Ctime: time.Now().Unix(),
  10692. ListSpItemFlag: item.ListSpItemFlag,
  10693. ChldMedcFlag: item.ChldMedcFlag,
  10694. LmtUsedFlag: item.LmtUsedFlag,
  10695. ChrgitmLv: item.ChrgitmLv,
  10696. UserOrgId: adminUser.CurrentOrgId,
  10697. HisPatientId: his.ID,
  10698. OrderId: order.ID,
  10699. ProjectId: project_id,
  10700. Type: types,
  10701. }
  10702. service.CreateOrderInfo(info)
  10703. }
  10704. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10705. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  10706. var total float64
  10707. for _, item := range prescriptions {
  10708. if item.Type == 1 { //药品
  10709. for _, subItem := range item.HisDoctorAdviceInfo {
  10710. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10711. total_one := price * subItem.PrescribingNumber
  10712. fmt.Println("subItem")
  10713. fmt.Println(subItem.Price)
  10714. fmt.Println("price")
  10715. fmt.Println(price)
  10716. fmt.Println("total_one")
  10717. fmt.Println(total_one)
  10718. total = total + total_one
  10719. fmt.Println(total)
  10720. }
  10721. }
  10722. if item.Type == 2 { //项目
  10723. for _, subItem := range item.HisPrescriptionProject {
  10724. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10725. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10726. total_one := price * cnt
  10727. total = total + total_one
  10728. }
  10729. }
  10730. }
  10731. allTotal := fmt.Sprintf("%2f", total)
  10732. if res.Infcode == 0 {
  10733. var rf []*ResultFive
  10734. json.Unmarshal([]byte(his.Iinfo), &rf)
  10735. chrg_bchno := chrg_bchno
  10736. cert_no := his.Certno
  10737. var insutypes []string
  10738. var insutype string
  10739. var is390 int = 0
  10740. var is310 int = 0
  10741. for _, item := range rf {
  10742. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10743. insutypes = append(insutypes, item.Insutype)
  10744. }
  10745. }
  10746. if len(insutypes) == 1 {
  10747. insutype = insutypes[0]
  10748. } else {
  10749. for _, i := range insutypes {
  10750. if i == "390" {
  10751. is390 = 1
  10752. }
  10753. if i == "310" {
  10754. is310 = 1
  10755. }
  10756. }
  10757. }
  10758. if is390 == 1 {
  10759. insutype = "390"
  10760. }
  10761. if is310 == 1 {
  10762. insutype = "310"
  10763. }
  10764. if len(insutypes) == 0 {
  10765. insutype = "390"
  10766. }
  10767. if len(insutypes) == 2 {
  10768. insutype = strconv.FormatInt(his.SocialType, 10)
  10769. }
  10770. //insutype = "390"
  10771. if his.IdCardType == 1 {
  10772. cert_no = his.MedicalInsuranceNumber
  10773. } else {
  10774. cert_no = his.Certno
  10775. }
  10776. var res ResultSeven
  10777. var resSeven10265 ResultSeven10265
  10778. if miConfig.MdtrtareaAdmvs == "421300" {
  10779. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10780. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10781. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10782. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10783. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10784. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10785. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  10786. resp, requestErr := http.Get(api)
  10787. if requestErr != nil {
  10788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10789. return
  10790. }
  10791. body, ioErr := ioutil.ReadAll(resp.Body)
  10792. if ioErr != nil {
  10793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10795. return
  10796. }
  10797. var respJSON map[string]interface{}
  10798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10801. return
  10802. }
  10803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10804. result, _ := json.Marshal(respJSON)
  10805. fmt.Println("log")
  10806. fmt.Println(string(result))
  10807. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10808. utils.ErrorLog("解析失败:%v", err)
  10809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10810. return
  10811. }
  10812. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10813. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  10814. if result3101.Infcode == "0" {
  10815. if len(result3101.Output.Result) > 0 {
  10816. var errMsgs []string
  10817. for _, item := range result3101.Output.Result {
  10818. errMsgs = append(errMsgs, item.VolaCont)
  10819. }
  10820. c.ServeSuccessJSON(map[string]interface{}{
  10821. "failed_code": -10,
  10822. "msg": errMsgs,
  10823. })
  10824. return
  10825. } else {
  10826. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10827. if his.IdCardType != 4 {
  10828. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10829. bas := strings.Split(psn_info.CardInfo, "|")
  10830. if his.IdCardType == 1 {
  10831. cert_no = bas[2]
  10832. } else {
  10833. cert_no = bas[1]
  10834. }
  10835. } else {
  10836. cert_no = his.Certno
  10837. }
  10838. //江苏地区国家医保医疗类别
  10839. //职工透析:医疗类别选特殊情况门诊9933
  10840. //居民血透门慢: 医疗类别选门诊慢病1402
  10841. //var med_type string
  10842. //if his.Insutype == "310" {
  10843. // if reg_type == 14 {
  10844. // med_type = "9933"
  10845. // } else if reg_type == 11 {
  10846. // med_type = "11"
  10847. //
  10848. // }
  10849. //} else if his.Insutype == "390" {
  10850. // if reg_type == 14 {
  10851. // med_type = "1402"
  10852. // } else if reg_type == 11 {
  10853. // med_type = "11"
  10854. // }
  10855. //}
  10856. var api string
  10857. if miConfig.MdtrtareaAdmvs == "320921" {
  10858. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10859. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10860. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10861. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10862. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10863. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10864. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  10865. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10866. } else {
  10867. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10868. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10869. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10870. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10871. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10872. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10873. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10874. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  10875. }
  10876. resp, requestErr := http.Get(api)
  10877. if requestErr != nil {
  10878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10879. return
  10880. }
  10881. body, ioErr := ioutil.ReadAll(resp.Body)
  10882. if ioErr != nil {
  10883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10885. return
  10886. }
  10887. var respJSON map[string]interface{}
  10888. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10891. return
  10892. }
  10893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10894. result, _ := json.Marshal(respJSON)
  10895. fmt.Println("log")
  10896. fmt.Println(string(result))
  10897. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10898. utils.ErrorLog("解析失败:%v", err)
  10899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10900. return
  10901. }
  10902. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10903. res.Output = resSeven10265.Output
  10904. res.ErrMsg = resSeven10265.ErrMsg
  10905. res.Cainfo = resSeven10265.Cainfo
  10906. res.WarnMsg = resSeven10265.WarnMsg
  10907. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10908. res.Infcode = infocode
  10909. }
  10910. }
  10911. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10912. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  10913. var result string
  10914. var request_log string
  10915. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10916. result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10917. } else {
  10918. result, request_log, _ = service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10919. }
  10920. var dat map[string]interface{}
  10921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10922. fmt.Println(dat)
  10923. } else {
  10924. fmt.Println(err)
  10925. }
  10926. saveLog(result, request_log, "2206", "预结算")
  10927. userJSONBytes, _ := json.Marshal(dat)
  10928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10929. utils.ErrorLog("解析失败:%v", err)
  10930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10931. return
  10932. }
  10933. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10934. var result string
  10935. var request_log string
  10936. if his.IdCardType == 2 {
  10937. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "")
  10938. } else if his.IdCardType == 1 {
  10939. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10940. bas := strings.Split(psn_info.CardInfo, "|")
  10941. basNumber := bas[2]
  10942. card_sn := bas[3]
  10943. result, request_log = service.Jxyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  10944. } else {
  10945. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10946. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "")
  10947. }
  10948. var dat map[string]interface{}
  10949. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10950. fmt.Println(dat)
  10951. } else {
  10952. fmt.Println(err)
  10953. }
  10954. saveLog(result, request_log, "2206", "预结算")
  10955. userJSONBytes, _ := json.Marshal(dat)
  10956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10957. utils.ErrorLog("解析失败:%v", err)
  10958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10959. return
  10960. }
  10961. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10962. var result string
  10963. var request_log string
  10964. if his.IdCardType == 2 {
  10965. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "", acct_used_flag)
  10966. } else if his.IdCardType == 1 {
  10967. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10968. bas := strings.Split(psn_info.CardInfo, "|")
  10969. basNumber := bas[2]
  10970. card_sn := bas[3]
  10971. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, acct_used_flag)
  10972. } else {
  10973. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10974. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", acct_used_flag)
  10975. }
  10976. var dat map[string]interface{}
  10977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10978. fmt.Println(dat)
  10979. } else {
  10980. fmt.Println(err)
  10981. }
  10982. saveLog(result, request_log, "2206", "预结算")
  10983. userJSONBytes, _ := json.Marshal(dat)
  10984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10985. utils.ErrorLog("解析失败:%v", err)
  10986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10987. return
  10988. }
  10989. } else {
  10990. var result string
  10991. var request_log string
  10992. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10993. allTotal = fmt.Sprintf("%2f", total_two)
  10994. if his.IdCardType == 4 {
  10995. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  10996. } else {
  10997. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  10998. }
  10999. var dat map[string]interface{}
  11000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11001. fmt.Println(dat)
  11002. } else {
  11003. fmt.Println(err)
  11004. }
  11005. saveLog(result, request_log, "2206", "预结算")
  11006. //userJSONBytes, _ := json.Marshal(dat)
  11007. //
  11008. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11009. // utils.ErrorLog("解析失败:%v", err)
  11010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11011. // return
  11012. //}
  11013. userJSONBytes, _ := json.Marshal(dat)
  11014. if miConfig.Code == "H15049901371" {
  11015. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11016. utils.ErrorLog("解析失败:%v", err)
  11017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11018. return
  11019. }
  11020. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11021. res.Output = resSeven10265.Output
  11022. res.ErrMsg = resSeven10265.ErrMsg
  11023. res.Cainfo = resSeven10265.Cainfo
  11024. res.WarnMsg = resSeven10265.WarnMsg
  11025. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11026. res.Infcode = infocode
  11027. } else {
  11028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11029. utils.ErrorLog("解析失败:%v", err)
  11030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11031. return
  11032. }
  11033. }
  11034. }
  11035. if res.Infcode != 0 {
  11036. errlog := &models.HisOrderError{
  11037. UserOrgId: adminUser.CurrentOrgId,
  11038. Ctime: time.Now().Unix(),
  11039. Mtime: time.Now().Unix(),
  11040. Number: chrg_bchno,
  11041. ErrMsg: res.ErrMsg,
  11042. Status: 1,
  11043. PatientId: id,
  11044. RecordTime: recordDateTime,
  11045. Stage: 20,
  11046. }
  11047. service.CreateErrMsgLog(errlog)
  11048. c.ServeSuccessJSON(map[string]interface{}{
  11049. "failed_code": -10,
  11050. "msg": res.ErrMsg,
  11051. })
  11052. return
  11053. } else {
  11054. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11055. order.OrderStatus = 1
  11056. order.IsPre = 1
  11057. order.Status = 1
  11058. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11059. order.SetlId = res.Output.Setlinfo.SetlID
  11060. order.PsnNo = res.Output.Setlinfo.PsnNo
  11061. order.PsnName = res.Output.Setlinfo.PsnName
  11062. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11063. order.Certno = res.Output.Setlinfo.Certno
  11064. order.Gend = res.Output.Setlinfo.Gend
  11065. order.Naty = res.Output.Setlinfo.Naty
  11066. order.Age = res.Output.Setlinfo.Age
  11067. order.Insutype = res.Output.Setlinfo.Insutype
  11068. order.PsnType = res.Output.Setlinfo.PsnType
  11069. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11070. order.SetlTime = res.Output.Setlinfo.SetlTime
  11071. order.AcctUsedFlag = acct_used_flag
  11072. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11073. if res.Output.Setlinfo.MedType == "140101" {
  11074. order.MedType = "14"
  11075. } else {
  11076. order.MedType = res.Output.Setlinfo.MedType
  11077. }
  11078. if reg_type == 1112 {
  11079. order.MedType = "1112"
  11080. }
  11081. if reg_type == 1111 {
  11082. order.MedType = "1111"
  11083. }
  11084. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11085. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11086. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11087. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11088. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11089. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11090. order.HifpPay = res.Output.Setlinfo.HifpPay
  11091. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11092. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11093. order.HifesPay = res.Output.Setlinfo.HifesPay
  11094. order.HifobPay = res.Output.Setlinfo.HifobPay
  11095. order.MafPay = res.Output.Setlinfo.MafPay
  11096. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  11097. order.OthPay = res.Output.Setlinfo.OthPay
  11098. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11099. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11100. order.AcctPay = res.Output.Setlinfo.AcctPay
  11101. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11102. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11103. order.Balc = res.Output.Setlinfo.Balc
  11104. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11105. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11106. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11107. order.ClrWay = res.Output.Setlinfo.ClrWay
  11108. order.Creator = order.Creator
  11109. order.Modify = roles.AdminUserId
  11110. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11111. detailStr := string(setlDetail)
  11112. order.SetlDetail = detailStr
  11113. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11114. err = service.UpDateOrder(order)
  11115. if err == nil {
  11116. c.ServeSuccessJSON(map[string]interface{}{
  11117. "msg": "预结算成功",
  11118. })
  11119. } else {
  11120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11121. return
  11122. }
  11123. }
  11124. } else {
  11125. adminUser := c.GetAdminUserInfo()
  11126. errlog := &models.HisOrderError{
  11127. UserOrgId: adminUser.CurrentOrgId,
  11128. Ctime: time.Now().Unix(),
  11129. Mtime: time.Now().Unix(),
  11130. ErrMsg: res.ErrMsg,
  11131. Status: 1,
  11132. PatientId: id,
  11133. RecordTime: recordDateTime,
  11134. Stage: 4,
  11135. }
  11136. service.CreateErrMsgLog(errlog)
  11137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11138. return
  11139. }
  11140. } else {
  11141. adminUser := c.GetAdminUserInfo()
  11142. errlog := &models.HisOrderError{
  11143. UserOrgId: adminUser.CurrentOrgId,
  11144. Ctime: time.Now().Unix(),
  11145. Mtime: time.Now().Unix(),
  11146. ErrMsg: res.ErrMsg,
  11147. Status: 1,
  11148. PatientId: id,
  11149. RecordTime: recordDateTime,
  11150. Stage: 4,
  11151. }
  11152. service.CreateErrMsgLog(errlog)
  11153. c.ServeSuccessJSON(map[string]interface{}{
  11154. "failed_code": -10,
  11155. "msg": res.ErrMsg,
  11156. })
  11157. return
  11158. }
  11159. }
  11160. }
  11161. }
  11162. // 退款
  11163. func (c *HisApiController) Refund() {
  11164. order_id, _ := c.GetInt64("order_id")
  11165. admin_user_id, _ := c.GetInt64("admin_user_id")
  11166. adminUser := c.GetAdminUserInfo()
  11167. var order models.HisOrder
  11168. order, _ = service.GetHisOrderByID(order_id)
  11169. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11170. if order.ID == 0 {
  11171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11172. return
  11173. }
  11174. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11176. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11177. if config.IsOpen == 1 { //对接了医保,走医保流程
  11178. var res ResultSixteen
  11179. var resSixteen10265 ResultSixteen10265
  11180. var src_resquest string
  11181. var result string
  11182. if miConfig.MdtrtareaAdmvs == "421300" {
  11183. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  11184. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11185. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11186. resp3, requestErr3 := http.Get(api3)
  11187. if requestErr3 != nil {
  11188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11189. return
  11190. }
  11191. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11192. if ioErr3 != nil {
  11193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11195. return
  11196. }
  11197. var respJSON3 map[string]interface{}
  11198. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11201. return
  11202. }
  11203. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11204. userJSONBytes3, _ := json.Marshal(respJSON3)
  11205. fmt.Println("log")
  11206. fmt.Println(string(userJSONBytes3))
  11207. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  11208. utils.ErrorLog("解析失败:%v", err)
  11209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11210. return
  11211. }
  11212. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11213. var api3 string
  11214. if miConfig.MdtrtareaAdmvs == "320921" {
  11215. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11216. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11217. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11218. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11219. } else {
  11220. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11221. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11222. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11223. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11224. }
  11225. resp3, requestErr3 := http.Get(api3)
  11226. if requestErr3 != nil {
  11227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11228. return
  11229. }
  11230. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11231. if ioErr3 != nil {
  11232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11234. return
  11235. }
  11236. var respJSON3 map[string]interface{}
  11237. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11240. return
  11241. }
  11242. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11243. userJSONBytes3, _ := json.Marshal(respJSON3)
  11244. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  11245. utils.ErrorLog("解析失败:%v", err)
  11246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11247. return
  11248. }
  11249. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11250. res.Output = resSixteen10265.Output
  11251. res.ErrMsg = resSixteen10265.ErrMsg
  11252. res.Cainfo = resSixteen10265.Cainfo
  11253. res.WarnMsg = resSixteen10265.WarnMsg
  11254. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11255. res.Infcode = infocode
  11256. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11257. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11258. var dat map[string]interface{}
  11259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11260. fmt.Println(dat)
  11261. } else {
  11262. fmt.Println(err)
  11263. }
  11264. saveLog(result, src_resquest, "2208", "退费")
  11265. userJSONBytes, _ := json.Marshal(dat)
  11266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11267. utils.ErrorLog("解析失败:%v", err)
  11268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11269. return
  11270. }
  11271. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11272. result, src_resquest = service.Jxyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  11273. var dat map[string]interface{}
  11274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11275. fmt.Println(dat)
  11276. } else {
  11277. fmt.Println(err)
  11278. }
  11279. saveLog(result, src_resquest, "2208", "退费")
  11280. userJSONBytes, _ := json.Marshal(dat)
  11281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11282. utils.ErrorLog("解析失败:%v", err)
  11283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11284. return
  11285. }
  11286. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11287. result, src_resquest = service.Hnyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  11288. var dat map[string]interface{}
  11289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11290. fmt.Println(dat)
  11291. } else {
  11292. fmt.Println(err)
  11293. }
  11294. saveLog(result, src_resquest, "2208", "退费")
  11295. userJSONBytes, _ := json.Marshal(dat)
  11296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11297. utils.ErrorLog("解析失败:%v", err)
  11298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11299. return
  11300. }
  11301. } else {
  11302. if miConfig.Code == "H15049901371" {
  11303. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11304. var dat map[string]interface{}
  11305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11306. fmt.Println(dat)
  11307. } else {
  11308. fmt.Println(err)
  11309. }
  11310. saveLog(result, src_resquest, "2208", "退费")
  11311. userJSONBytes, _ := json.Marshal(dat)
  11312. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  11313. utils.ErrorLog("解析失败:%v", err)
  11314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11315. return
  11316. }
  11317. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11318. res.Output = resSixteen10265.Output
  11319. res.ErrMsg = resSixteen10265.ErrMsg
  11320. res.Cainfo = resSixteen10265.Cainfo
  11321. res.WarnMsg = resSixteen10265.WarnMsg
  11322. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11323. res.Infcode = infocode
  11324. } else {
  11325. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11326. var dat map[string]interface{}
  11327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11328. fmt.Println(dat)
  11329. } else {
  11330. fmt.Println(err)
  11331. }
  11332. saveLog(result, src_resquest, "2208", "退费")
  11333. userJSONBytes, _ := json.Marshal(dat)
  11334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11335. utils.ErrorLog("解析失败:%v", err)
  11336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11337. return
  11338. }
  11339. }
  11340. }
  11341. if res.Infcode == 0 {
  11342. var res2 ResultSix
  11343. var resSix10265 ResultSix10265
  11344. if miConfig.MdtrtareaAdmvs == "421300" {
  11345. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11346. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11347. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11348. resp3, requestErr3 := http.Get(api3)
  11349. if requestErr3 != nil {
  11350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11351. return
  11352. }
  11353. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11354. if ioErr3 != nil {
  11355. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11357. return
  11358. }
  11359. var respJSON3 map[string]interface{}
  11360. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11363. return
  11364. }
  11365. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11366. userJSONBytes3, _ := json.Marshal(respJSON3)
  11367. fmt.Println("log")
  11368. fmt.Println(string(userJSONBytes3))
  11369. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11370. utils.ErrorLog("解析失败:%v", err)
  11371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11372. return
  11373. }
  11374. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11375. var api3 string
  11376. if miConfig.MdtrtareaAdmvs == "320921" {
  11377. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11378. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11379. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11380. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11381. } else {
  11382. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11383. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11384. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11385. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11386. }
  11387. resp3, requestErr3 := http.Get(api3)
  11388. if requestErr3 != nil {
  11389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11390. return
  11391. }
  11392. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11393. if ioErr3 != nil {
  11394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11396. return
  11397. }
  11398. var respJSON3 map[string]interface{}
  11399. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11402. return
  11403. }
  11404. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11405. userJSONBytes3, _ := json.Marshal(respJSON3)
  11406. fmt.Println("log")
  11407. fmt.Println(string(userJSONBytes3))
  11408. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11409. utils.ErrorLog("解析失败:%v", err)
  11410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11411. return
  11412. }
  11413. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11414. res2.Output = resSix10265.Output
  11415. res2.ErrMsg = resSix10265.ErrMsg
  11416. res2.Cainfo = resSix10265.Cainfo
  11417. res2.WarnMsg = resSix10265.WarnMsg
  11418. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11419. res2.Infcode = infocode
  11420. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11421. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11422. var dat map[string]interface{}
  11423. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11424. fmt.Println(dat)
  11425. } else {
  11426. fmt.Println(err)
  11427. }
  11428. saveLog(result2, src_request, "2205", "撤销明细")
  11429. userJSONBytes, _ := json.Marshal(dat)
  11430. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11431. utils.ErrorLog("解析失败:%v", err)
  11432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11433. return
  11434. }
  11435. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11436. result2, src_request := service.Jxyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11437. var dat map[string]interface{}
  11438. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11439. fmt.Println(dat)
  11440. } else {
  11441. fmt.Println(err)
  11442. }
  11443. saveLog(result2, src_request, "2205", "撤销明细")
  11444. userJSONBytes, _ := json.Marshal(dat)
  11445. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11446. utils.ErrorLog("解析失败:%v", err)
  11447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11448. return
  11449. }
  11450. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11451. result2, src_request := service.Hnyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11452. var dat map[string]interface{}
  11453. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11454. fmt.Println(dat)
  11455. } else {
  11456. fmt.Println(err)
  11457. }
  11458. saveLog(result2, src_request, "2205", "撤销明细")
  11459. userJSONBytes, _ := json.Marshal(dat)
  11460. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11461. utils.ErrorLog("解析失败:%v", err)
  11462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11463. return
  11464. }
  11465. } else {
  11466. if miConfig.Code == "H15049901371" {
  11467. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11468. var dat map[string]interface{}
  11469. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11470. fmt.Println(dat)
  11471. } else {
  11472. fmt.Println(err)
  11473. }
  11474. saveLog(result2, src_request, "2205", "撤销明细")
  11475. userJSONBytes, _ := json.Marshal(dat)
  11476. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11477. utils.ErrorLog("解析失败:%v", err)
  11478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11479. return
  11480. }
  11481. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11482. res2.Output = resSix10265.Output
  11483. res2.ErrMsg = resSix10265.ErrMsg
  11484. res2.Cainfo = resSix10265.Cainfo
  11485. res2.WarnMsg = resSix10265.WarnMsg
  11486. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11487. res2.Infcode = infocode
  11488. } else {
  11489. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11490. var dat map[string]interface{}
  11491. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11492. fmt.Println(dat)
  11493. } else {
  11494. fmt.Println(err)
  11495. }
  11496. saveLog(result2, src_request, "2205", "撤销明细")
  11497. userJSONBytes, _ := json.Marshal(dat)
  11498. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11499. utils.ErrorLog("解析失败:%v", err)
  11500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11501. return
  11502. }
  11503. }
  11504. }
  11505. if res2.Infcode == 0 {
  11506. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  11507. if err == nil {
  11508. //当押金不为零时产生退费记录
  11509. if order.Decimal != 0 {
  11510. tmp := strconv.FormatInt(order.ID, 10)
  11511. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  11512. if err != nil {
  11513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11514. return
  11515. }
  11516. }
  11517. c.ServeSuccessJSON(map[string]interface{}{
  11518. "msg": "退费成功",
  11519. })
  11520. } else {
  11521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11522. return
  11523. }
  11524. } else {
  11525. c.ServeSuccessJSON(map[string]interface{}{
  11526. "code": -10,
  11527. "msg": res2.ErrMsg,
  11528. })
  11529. }
  11530. } else {
  11531. c.ServeSuccessJSON(map[string]interface{}{
  11532. "code": -10,
  11533. "msg": res.ErrMsg,
  11534. })
  11535. }
  11536. }
  11537. }
  11538. func (c *HisApiController) RefundNumber() {
  11539. record_time := c.GetString("record_time")
  11540. //patient_id, _ := c.GetInt64("patient_id")
  11541. admin_user_id, _ := c.GetInt64("admin_user_id")
  11542. his_patient_id, _ := c.GetInt64("id")
  11543. timeLayout := "2006-01-02"
  11544. loc, _ := time.LoadLocation("Local")
  11545. adminUser := c.GetAdminUserInfo()
  11546. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11547. fmt.Println(err)
  11548. if err != nil {
  11549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11550. return
  11551. }
  11552. recordDateTime := theTime.Unix()
  11553. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11554. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  11555. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11556. //order, _ := service.GetHisOrderByID(order_id)
  11557. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11558. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11559. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11560. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  11561. if count > 0 {
  11562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  11563. return
  11564. }
  11565. if config.IsOpen == 1 { //对接了医保,走医保流程
  11566. var res2 ResultSix
  11567. var resSix10265 ResultSix10265
  11568. if miConfig.MdtrtareaAdmvs == "421300" {
  11569. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  11570. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11572. resp3, requestErr3 := http.Get(api3)
  11573. if requestErr3 != nil {
  11574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11575. return
  11576. }
  11577. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11578. if ioErr3 != nil {
  11579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11581. return
  11582. }
  11583. var respJSON3 map[string]interface{}
  11584. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11587. return
  11588. }
  11589. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11590. userJSONBytes3, _ := json.Marshal(respJSON3)
  11591. fmt.Println("log")
  11592. fmt.Println(string(userJSONBytes3))
  11593. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11594. utils.ErrorLog("解析失败:%v", err)
  11595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11596. return
  11597. }
  11598. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11599. var api3 string
  11600. if miConfig.MdtrtareaAdmvs == "320921" {
  11601. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  11602. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11603. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11604. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11605. } else {
  11606. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11607. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  11608. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11609. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11610. }
  11611. resp3, requestErr3 := http.Get(api3)
  11612. if requestErr3 != nil {
  11613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11614. return
  11615. }
  11616. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11617. if ioErr3 != nil {
  11618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11620. return
  11621. }
  11622. var respJSON3 map[string]interface{}
  11623. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11626. return
  11627. }
  11628. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11629. userJSONBytes3, _ := json.Marshal(respJSON3)
  11630. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11631. utils.ErrorLog("解析失败:%v", err)
  11632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11633. return
  11634. }
  11635. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11636. res2.Output = resSix10265.Output
  11637. res2.ErrMsg = resSix10265.ErrMsg
  11638. res2.Cainfo = resSix10265.Cainfo
  11639. res2.WarnMsg = resSix10265.WarnMsg
  11640. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11641. res2.Infcode = infocode
  11642. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11643. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11644. var dat map[string]interface{}
  11645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11646. fmt.Println(dat)
  11647. } else {
  11648. fmt.Println(err)
  11649. }
  11650. saveLog(result, request, "2202", "退号")
  11651. userJSONBytes, _ := json.Marshal(dat)
  11652. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11653. utils.ErrorLog("解析失败:%v", err)
  11654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11655. return
  11656. }
  11657. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11658. result, request := service.Jxyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11659. var dat map[string]interface{}
  11660. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11661. fmt.Println(dat)
  11662. } else {
  11663. fmt.Println(err)
  11664. }
  11665. saveLog(result, request, "2202", "退号")
  11666. userJSONBytes, _ := json.Marshal(dat)
  11667. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11668. utils.ErrorLog("解析失败:%v", err)
  11669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11670. return
  11671. }
  11672. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11673. result, request := service.Hnyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11674. var dat map[string]interface{}
  11675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11676. fmt.Println(dat)
  11677. } else {
  11678. fmt.Println(err)
  11679. }
  11680. saveLog(result, request, "2202", "退号")
  11681. userJSONBytes, _ := json.Marshal(dat)
  11682. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11683. utils.ErrorLog("解析失败:%v", err)
  11684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11685. return
  11686. }
  11687. } else {
  11688. var api3 string
  11689. if miConfig.Code == "H15049901371" {
  11690. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11691. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11692. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11693. } else {
  11694. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11695. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11697. }
  11698. resp3, requestErr3 := http.Get(api3)
  11699. if requestErr3 != nil {
  11700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11701. return
  11702. }
  11703. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11704. if ioErr3 != nil {
  11705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11707. return
  11708. }
  11709. var respJSON3 map[string]interface{}
  11710. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11713. return
  11714. }
  11715. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11716. userJSONBytes3, _ := json.Marshal(respJSON3)
  11717. if miConfig.Code == "H15049901371" {
  11718. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11719. utils.ErrorLog("解析失败:%v", err)
  11720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11721. return
  11722. }
  11723. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11724. res2.Output = resSix10265.Output
  11725. res2.ErrMsg = resSix10265.ErrMsg
  11726. res2.Cainfo = resSix10265.Cainfo
  11727. res2.WarnMsg = resSix10265.WarnMsg
  11728. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11729. res2.Infcode = infocode
  11730. } else {
  11731. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11732. utils.ErrorLog("解析失败:%v", err)
  11733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11734. return
  11735. }
  11736. }
  11737. }
  11738. if res2.Infcode == 0 {
  11739. if err == nil {
  11740. c.ServeSuccessJSON(map[string]interface{}{
  11741. "msg": "退号成功",
  11742. })
  11743. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  11744. } else {
  11745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11746. return
  11747. }
  11748. } else {
  11749. c.ServeSuccessJSON(map[string]interface{}{
  11750. "code": -10,
  11751. "msg": res2.ErrMsg,
  11752. })
  11753. }
  11754. } else {
  11755. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  11756. //if err == nil {
  11757. // c.ServeSuccessJSON(map[string]interface{}{
  11758. // "msg": "退费成功",
  11759. // })
  11760. //} else {
  11761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11762. // return
  11763. //}
  11764. }
  11765. }
  11766. func (c *HisApiController) RefundDetail() {
  11767. order_id, _ := c.GetInt64("order_id")
  11768. admin_user_id, _ := c.GetInt64("admin_user_id")
  11769. //his_patient_id, _ := c.GetInt64("his_patient_id")
  11770. number := c.GetString("number")
  11771. record_time := c.GetString("record_time")
  11772. patient_id, _ := c.GetInt64("patient_id")
  11773. //med_type, _ := c.GetInt64("med_type")
  11774. timeLayout := "2006-01-02"
  11775. loc, _ := time.LoadLocation("Local")
  11776. adminUser := c.GetAdminUserInfo()
  11777. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11778. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11779. fmt.Println(err)
  11780. if err != nil {
  11781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11782. return
  11783. }
  11784. recordDateTime := theTime.Unix()
  11785. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11786. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11787. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11788. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11789. var order models.HisOrder
  11790. order, _ = service.GetHisOrderByID(order_id)
  11791. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11792. if config.IsOpen == 1 { //对接了医保,走医保流程
  11793. var res2 ResultSix
  11794. if miConfig.MdtrtareaAdmvs == "421300" {
  11795. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11796. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11798. resp3, requestErr3 := http.Get(api3)
  11799. if requestErr3 != nil {
  11800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11801. return
  11802. }
  11803. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11804. if ioErr3 != nil {
  11805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11807. return
  11808. }
  11809. var respJSON3 map[string]interface{}
  11810. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11813. return
  11814. }
  11815. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11816. userJSONBytes3, _ := json.Marshal(respJSON3)
  11817. fmt.Println("log")
  11818. fmt.Println(string(userJSONBytes3))
  11819. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11820. utils.ErrorLog("解析失败:%v", err)
  11821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11822. return
  11823. }
  11824. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11825. if err == nil {
  11826. c.ServeSuccessJSON(map[string]interface{}{
  11827. "msg": "撤销明细成功",
  11828. })
  11829. return
  11830. } else {
  11831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11832. return
  11833. }
  11834. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11835. var resSix10265 ResultSix10265
  11836. var api3 string
  11837. if miConfig.MdtrtareaAdmvs == "320921" {
  11838. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11839. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11840. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11841. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11842. } else {
  11843. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11844. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11845. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11847. }
  11848. resp3, requestErr3 := http.Get(api3)
  11849. if requestErr3 != nil {
  11850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11851. return
  11852. }
  11853. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11854. if ioErr3 != nil {
  11855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11857. return
  11858. }
  11859. var respJSON3 map[string]interface{}
  11860. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11863. return
  11864. }
  11865. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11866. userJSONBytes3, _ := json.Marshal(respJSON3)
  11867. fmt.Println("log")
  11868. fmt.Println(string(userJSONBytes3))
  11869. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11870. utils.ErrorLog("解析失败:%v", err)
  11871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11872. return
  11873. }
  11874. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11875. res2.Output = resSix10265.Output
  11876. res2.ErrMsg = resSix10265.ErrMsg
  11877. res2.Cainfo = resSix10265.Cainfo
  11878. res2.WarnMsg = resSix10265.WarnMsg
  11879. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11880. res2.Infcode = infocode
  11881. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11882. if err == nil {
  11883. c.ServeSuccessJSON(map[string]interface{}{
  11884. "msg": "撤销明细成功",
  11885. })
  11886. return
  11887. } else {
  11888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11889. return
  11890. }
  11891. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11892. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11893. var dat map[string]interface{}
  11894. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11895. fmt.Println(dat)
  11896. } else {
  11897. fmt.Println(err)
  11898. }
  11899. saveLog(result2, src_request, "2205", "撤销明细")
  11900. userJSONBytes, _ := json.Marshal(dat)
  11901. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11902. utils.ErrorLog("解析失败:%v", err)
  11903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11904. return
  11905. }
  11906. if res2.Infcode == 0 {
  11907. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11908. if err == nil {
  11909. c.ServeSuccessJSON(map[string]interface{}{
  11910. "msg": "撤销明细成功",
  11911. })
  11912. return
  11913. } else {
  11914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11915. return
  11916. }
  11917. } else {
  11918. c.ServeSuccessJSON(map[string]interface{}{
  11919. "code": -10,
  11920. "msg": res2.ErrMsg,
  11921. })
  11922. }
  11923. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11924. result2, src_request := service.Jxyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11925. var dat map[string]interface{}
  11926. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11927. fmt.Println(dat)
  11928. } else {
  11929. fmt.Println(err)
  11930. }
  11931. saveLog(result2, src_request, "2205", "撤销明细")
  11932. userJSONBytes, _ := json.Marshal(dat)
  11933. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11934. utils.ErrorLog("解析失败:%v", err)
  11935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11936. return
  11937. }
  11938. if res2.Infcode == 0 {
  11939. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11940. if err == nil {
  11941. c.ServeSuccessJSON(map[string]interface{}{
  11942. "msg": "撤销明细成功",
  11943. })
  11944. return
  11945. } else {
  11946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11947. return
  11948. }
  11949. } else {
  11950. c.ServeSuccessJSON(map[string]interface{}{
  11951. "code": -10,
  11952. "msg": res2.ErrMsg,
  11953. })
  11954. }
  11955. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11956. result2, src_request := service.Hnyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11957. var dat map[string]interface{}
  11958. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11959. fmt.Println(dat)
  11960. } else {
  11961. fmt.Println(err)
  11962. }
  11963. saveLog(result2, src_request, "2205", "撤销明细")
  11964. userJSONBytes, _ := json.Marshal(dat)
  11965. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11966. utils.ErrorLog("解析失败:%v", err)
  11967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11968. return
  11969. }
  11970. if res2.Infcode == 0 {
  11971. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11972. if err == nil {
  11973. c.ServeSuccessJSON(map[string]interface{}{
  11974. "msg": "撤销明细成功",
  11975. })
  11976. return
  11977. } else {
  11978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11979. return
  11980. }
  11981. } else {
  11982. c.ServeSuccessJSON(map[string]interface{}{
  11983. "code": -10,
  11984. "msg": res2.ErrMsg,
  11985. })
  11986. }
  11987. } else {
  11988. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11989. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11991. resp2, requestErr2 := http.Get(api2)
  11992. if requestErr2 != nil {
  11993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11994. return
  11995. }
  11996. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11997. if ioErr2 != nil {
  11998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12000. return
  12001. }
  12002. var respJSON2 map[string]interface{}
  12003. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12006. return
  12007. }
  12008. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12009. if err == nil {
  12010. c.ServeSuccessJSON(map[string]interface{}{
  12011. "msg": "撤销明细成功",
  12012. })
  12013. return
  12014. } else {
  12015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12016. return
  12017. }
  12018. }
  12019. } else {
  12020. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12021. if err == nil {
  12022. c.ServeSuccessJSON(map[string]interface{}{
  12023. "msg": "退费成功",
  12024. })
  12025. } else {
  12026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12027. return
  12028. }
  12029. }
  12030. }
  12031. // 对账
  12032. func (c *HisApiController) GetCheckAccount() {
  12033. start_time := c.GetString("start_time")
  12034. end_time := c.GetString("end_time")
  12035. insutype := c.GetString("insutype")
  12036. clr_type := c.GetString("clr_type")
  12037. clr_org := c.GetString("clr_optins")
  12038. admin_user_id, _ := c.GetInt64("admin_user_id")
  12039. adminUser := c.GetAdminUserInfo()
  12040. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12041. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12042. if len(clr_org) == 0 {
  12043. clr_org = miConfig.MdtrtareaAdmvs
  12044. }
  12045. timeLayout := "2006-01-02"
  12046. loc, _ := time.LoadLocation("Local")
  12047. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12048. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12049. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12050. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12051. fixmedins_setl_cnt := int64(len(orders))
  12052. var medfee_sumamt float64
  12053. var acct_pay float64
  12054. var fund_pay_sumamt float64
  12055. for _, item := range orders {
  12056. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12057. acct_pay = acct_pay + item.AcctPay
  12058. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12059. }
  12060. var user_name string
  12061. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12062. if role.ID == 0 {
  12063. user_name = "xxx"
  12064. } else {
  12065. user_name = role.UserName
  12066. }
  12067. var res ResultEight
  12068. var res10188 ResultEightFor10188
  12069. if config.IsOpen == 1 {
  12070. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12071. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  12072. "insutype=" + insutype +
  12073. "&clr_type=" + clr_type +
  12074. "&setl_optins=" + clr_org +
  12075. "&stmt_begndate=" + start_time +
  12076. "&stm_enddate=" + end_time +
  12077. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12078. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12079. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12080. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  12081. "&fixmedins_code=" + miConfig.Code +
  12082. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12083. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12084. "&secret_key=" + miConfig.SecretKey +
  12085. "&org_name=" + miConfig.OrgName +
  12086. "&doctor=" + user_name +
  12087. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12088. fmt.Println(api)
  12089. resp, requestErr := http.Get(api)
  12090. if requestErr != nil {
  12091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12092. return
  12093. }
  12094. body, ioErr := ioutil.ReadAll(resp.Body)
  12095. fmt.Println(body)
  12096. if ioErr != nil {
  12097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12099. return
  12100. }
  12101. var respJSON map[string]interface{}
  12102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12105. return
  12106. }
  12107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12108. userJSONBytes, _ := json.Marshal(respJSON)
  12109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12110. utils.ErrorLog("解析失败:%v", err)
  12111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12112. return
  12113. }
  12114. res.InfRefmsgid = res10188.InfRefmsgid
  12115. res.Output = res10188.Output
  12116. res.ErrMsg = res10188.ErrMsg
  12117. res.Cainfo = res10188.Cainfo
  12118. res.WarnMsg = res10188.WarnMsg
  12119. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12120. res.Infcode = infocode
  12121. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12122. if clr_type == "11" {
  12123. fixmedins_setl_cnt = 2
  12124. }
  12125. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  12126. "insutype=" + insutype +
  12127. "&clr_type=" + clr_type +
  12128. "&setl_optins=" + clr_org +
  12129. "&stmt_begndate=" + start_time +
  12130. "&stm_enddate=" + end_time +
  12131. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12132. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12133. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12134. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  12135. "&fixmedins_code=" + miConfig.Code +
  12136. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12137. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12138. "&secret_key=" + miConfig.SecretKey +
  12139. "&org_name=" + miConfig.OrgName +
  12140. "&doctor=" + user_name
  12141. resp, requestErr := http.Get(api)
  12142. if requestErr != nil {
  12143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12144. return
  12145. }
  12146. body, ioErr := ioutil.ReadAll(resp.Body)
  12147. if ioErr != nil {
  12148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12150. return
  12151. }
  12152. var respJSON map[string]interface{}
  12153. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12156. return
  12157. }
  12158. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12159. result, _ := json.Marshal(respJSON)
  12160. fmt.Println("log")
  12161. fmt.Println(string(result))
  12162. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  12163. utils.ErrorLog("解析失败:%v", err)
  12164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12165. return
  12166. }
  12167. res.InfRefmsgid = res10188.InfRefmsgid
  12168. res.Output = res10188.Output
  12169. res.ErrMsg = res10188.ErrMsg
  12170. res.Cainfo = res10188.Cainfo
  12171. res.WarnMsg = res10188.WarnMsg
  12172. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12173. res.Infcode = infocode
  12174. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12175. var baseParams models.BaseParams
  12176. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12177. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12178. baseParams.SecretKey = miConfig.SecretKey
  12179. baseParams.OrgName = miConfig.OrgName
  12180. baseParams.FixmedinsCode = miConfig.Code
  12181. baseParams.EncKey = miConfig.EncKey
  12182. baseParams.AppSecret = miConfig.AppSecret
  12183. baseParams.SignKey = miConfig.SignKey
  12184. baseParams.AppID = miConfig.Code
  12185. baseParams.Doctor = role.UserName
  12186. baseParams.RequestUrl = miConfig.Url
  12187. businessParams := models.BusinessParams{
  12188. Insutype: insutype,
  12189. ClrType: clr_type,
  12190. SetlOptins: clr_org,
  12191. StmtBegndate: start_time,
  12192. StmtEnddate: end_time,
  12193. MedfeeSumamt: medfee_sumamt,
  12194. FundPaySumamt: fund_pay_sumamt,
  12195. AcctPay: acct_pay,
  12196. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12197. }
  12198. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12199. fmt.Println(requestLog)
  12200. fmt.Println(result)
  12201. fmt.Println(err_msg)
  12202. var dat map[string]interface{}
  12203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12204. fmt.Println(dat)
  12205. } else {
  12206. fmt.Println(err)
  12207. }
  12208. userJSONBytes, _ := json.Marshal(dat)
  12209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12210. utils.ErrorLog("解析失败:%v", err)
  12211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12212. return
  12213. }
  12214. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12215. var baseParams models.BaseParams
  12216. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12217. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12218. baseParams.SecretKey = miConfig.SecretKey
  12219. baseParams.OrgName = miConfig.OrgName
  12220. baseParams.FixmedinsCode = miConfig.Code
  12221. baseParams.EncKey = miConfig.EncKey
  12222. baseParams.AppSecret = miConfig.AppSecret
  12223. baseParams.SignKey = miConfig.SignKey
  12224. baseParams.AppID = miConfig.Code
  12225. baseParams.Doctor = role.UserName
  12226. baseParams.RequestUrl = miConfig.Url
  12227. baseParams.AccessKey = miConfig.AccessKey
  12228. businessParams := models.BusinessParams{
  12229. Insutype: insutype,
  12230. ClrType: clr_type,
  12231. SetlOptins: "430822",
  12232. StmtBegndate: start_time,
  12233. StmtEnddate: end_time,
  12234. MedfeeSumamt: medfee_sumamt,
  12235. FundPaySumamt: fund_pay_sumamt,
  12236. AcctPay: acct_pay,
  12237. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12238. }
  12239. result, requestLog := service.Hnyb3201(businessParams.FixmedinsSetlCnt, businessParams.AcctPay, businessParams.FundPaySumamt, businessParams.MedfeeSumamt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.SetlOptins, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, baseParams.Cainfo)
  12240. fmt.Println(requestLog)
  12241. fmt.Println(result)
  12242. var dat map[string]interface{}
  12243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12244. fmt.Println(dat)
  12245. } else {
  12246. fmt.Println(err)
  12247. }
  12248. userJSONBytes, _ := json.Marshal(dat)
  12249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12250. utils.ErrorLog("解析失败:%v", err)
  12251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12252. return
  12253. }
  12254. } else if miConfig.MdtrtareaAdmvs == "" {
  12255. var baseParams models.BaseParams
  12256. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12257. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12258. baseParams.SecretKey = miConfig.SecretKey
  12259. baseParams.OrgName = miConfig.OrgName
  12260. baseParams.FixmedinsCode = miConfig.Code
  12261. baseParams.EncKey = miConfig.EncKey
  12262. baseParams.AppSecret = miConfig.AppSecret
  12263. baseParams.SignKey = miConfig.SignKey
  12264. baseParams.AppID = miConfig.Code
  12265. baseParams.Doctor = role.UserName
  12266. baseParams.RequestUrl = miConfig.Url
  12267. businessParams := models.BusinessParams{
  12268. Insutype: insutype,
  12269. ClrType: clr_type,
  12270. SetlOptins: clr_org,
  12271. StmtBegndate: start_time,
  12272. StmtEnddate: end_time,
  12273. MedfeeSumamt: medfee_sumamt,
  12274. FundPaySumamt: fund_pay_sumamt,
  12275. AcctPay: acct_pay,
  12276. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12277. }
  12278. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12279. fmt.Println(requestLog)
  12280. fmt.Println(result)
  12281. fmt.Println(err_msg)
  12282. var dat map[string]interface{}
  12283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12284. fmt.Println(dat)
  12285. } else {
  12286. fmt.Println(err)
  12287. }
  12288. userJSONBytes, _ := json.Marshal(dat)
  12289. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12290. utils.ErrorLog("解析失败:%v", err)
  12291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12292. return
  12293. }
  12294. } else {
  12295. if len(clr_type) == 0 {
  12296. clr_type = "11"
  12297. }
  12298. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12299. "insutype=" + insutype +
  12300. "&clr_type=" + clr_type +
  12301. "&setl_optins=" + clr_org +
  12302. "&stmt_begndate=" + start_time +
  12303. "&stm_enddate=" + end_time +
  12304. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12305. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12306. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12307. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  12308. "&fixmedins_code=" + miConfig.Code +
  12309. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12310. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12311. "&secret_key=" + miConfig.SecretKey +
  12312. "&org_name=" + miConfig.OrgName +
  12313. "&doctor=" + user_name
  12314. fmt.Println(api)
  12315. resp, requestErr := http.Get(api)
  12316. if requestErr != nil {
  12317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12318. return
  12319. }
  12320. body, ioErr := ioutil.ReadAll(resp.Body)
  12321. fmt.Println(body)
  12322. if ioErr != nil {
  12323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12325. return
  12326. }
  12327. var respJSON map[string]interface{}
  12328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12331. return
  12332. }
  12333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12334. userJSONBytes, _ := json.Marshal(respJSON)
  12335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12336. utils.ErrorLog("解析失败:%v", err)
  12337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12338. return
  12339. }
  12340. }
  12341. if res.Infcode == 0 {
  12342. if res.Output.Stmtinfo.StmtRslt == "0" {
  12343. micc := &models.MedicalInsuranceCostCompare{
  12344. StartTime: startime.Unix(),
  12345. EndTime: endtime.Unix(),
  12346. Insutype: insutype,
  12347. CheckType: 1,
  12348. Num: fixmedins_setl_cnt,
  12349. Mtime: time.Now().Unix(),
  12350. Status: 1,
  12351. UserOrgId: adminUser.CurrentOrgId,
  12352. CostTotal: medfee_sumamt,
  12353. FuncTotal: fund_pay_sumamt,
  12354. PsnPay: acct_pay,
  12355. Creator: admin_user_id,
  12356. Ctime: time.Now().Unix(),
  12357. ClrType: clr_type,
  12358. }
  12359. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  12360. if err == nil {
  12361. c.ServeSuccessJSON(map[string]interface{}{
  12362. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12363. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12364. })
  12365. } else {
  12366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12367. }
  12368. } else {
  12369. c.ServeSuccessJSON(map[string]interface{}{
  12370. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12371. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12372. })
  12373. }
  12374. } else {
  12375. c.ServeSuccessJSON(map[string]interface{}{
  12376. "code": -10,
  12377. "msg": res.ErrMsg,
  12378. })
  12379. }
  12380. }
  12381. }
  12382. func (c *HisApiController) Check310() {
  12383. adminUser := c.GetAdminUserInfo()
  12384. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12385. var user_name string
  12386. user_name = "高慧裕"
  12387. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12388. "insutype=" + "310" +
  12389. "&clr_type=" + "" +
  12390. "&setl_optins=" + "441202" +
  12391. "&stmt_begndate=" + "2022-03-01" +
  12392. "&stm_enddate=" + "2022-03-31" +
  12393. "&medfee_sumamt=" + "194930.12" +
  12394. "&fund_pay_sumamt=" + "188741.46" +
  12395. "&acct_pay=" + "0" +
  12396. "&fixmedins_setl_cnt=" + "452" +
  12397. "&fixmedins_code=" + miConfig.Code +
  12398. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12399. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12400. "&secret_key=" + miConfig.SecretKey +
  12401. "&org_name=" + miConfig.OrgName +
  12402. "&doctor=" + user_name
  12403. fmt.Println(api)
  12404. resp, requestErr := http.Get(api)
  12405. if requestErr != nil {
  12406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12407. return
  12408. }
  12409. body, ioErr := ioutil.ReadAll(resp.Body)
  12410. fmt.Println(body)
  12411. if ioErr != nil {
  12412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12414. return
  12415. }
  12416. var respJSON map[string]interface{}
  12417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12420. return
  12421. }
  12422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12423. userJSONBytes, _ := json.Marshal(respJSON)
  12424. var res ResultEight
  12425. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12426. utils.ErrorLog("解析失败:%v", err)
  12427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12428. return
  12429. }
  12430. }
  12431. func (c *HisApiController) Check390() {
  12432. adminUser := c.GetAdminUserInfo()
  12433. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12434. var user_name string
  12435. user_name = "高慧裕"
  12436. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12437. "insutype=" + "390" +
  12438. "&clr_type=" + "" +
  12439. "&setl_optins=" + "441202" +
  12440. "&stmt_begndate=" + "2022-03-01" +
  12441. "&stm_enddate=" + "2022-03-31" +
  12442. "&medfee_sumamt=" + "1068448.89" +
  12443. "&fund_pay_sumamt=" + "1014677.62" +
  12444. "&acct_pay=" + "0" +
  12445. "&fixmedins_setl_cnt=" + "1950" +
  12446. "&fixmedins_code=" + miConfig.Code +
  12447. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12448. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12449. "&secret_key=" + miConfig.SecretKey +
  12450. "&org_name=" + miConfig.OrgName +
  12451. "&doctor=" + user_name
  12452. fmt.Println(api)
  12453. resp, requestErr := http.Get(api)
  12454. if requestErr != nil {
  12455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12456. return
  12457. }
  12458. body, ioErr := ioutil.ReadAll(resp.Body)
  12459. fmt.Println(body)
  12460. if ioErr != nil {
  12461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12463. return
  12464. }
  12465. var respJSON map[string]interface{}
  12466. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12469. return
  12470. }
  12471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12472. userJSONBytes, _ := json.Marshal(respJSON)
  12473. var res ResultEight
  12474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12475. utils.ErrorLog("解析失败:%v", err)
  12476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12477. return
  12478. }
  12479. }
  12480. // 对账明细
  12481. func (c *HisApiController) GetCheckDetailAccount() {
  12482. start_time := c.GetString("start_time")
  12483. end_time := c.GetString("end_time")
  12484. admin_user_id, _ := c.GetInt64("admin_user_id")
  12485. adminUser := c.GetAdminUserInfo()
  12486. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12487. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12488. timeLayout := "2006-01-02"
  12489. loc, _ := time.LoadLocation("Local")
  12490. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12491. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12492. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  12493. rand.Seed(time.Now().UnixNano())
  12494. num := rand.Intn(30000)
  12495. Mkdir(miConfig.OrgName)
  12496. file := strconv.FormatInt(int64(num), 10)
  12497. file_name := file + ".txt"
  12498. zip_name := file + ".zip"
  12499. zip_path := miConfig.OrgName + "/" + zip_name
  12500. file_path := miConfig.OrgName + "/" + file_name
  12501. decimal.DivisionPrecision = 2
  12502. var medfee_sumamt float64
  12503. var psn_cash_pay float64
  12504. var fund_pay_sumamt float64
  12505. fixmedins_setl_cnt := int64(len(orders))
  12506. for _, item := range orders {
  12507. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12508. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  12509. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12510. }
  12511. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  12512. defer f.Close()
  12513. if err != nil {
  12514. fmt.Println(err.Error())
  12515. } else {
  12516. for _, item := range orders {
  12517. var refd_setl_flag string
  12518. if item.OrderStatus == 2 {
  12519. refd_setl_flag = "0"
  12520. var str string
  12521. str = item.SetlId + " " +
  12522. item.MdtrtId + " " +
  12523. item.PsnNo + " " +
  12524. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12525. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12526. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  12527. _, err = f.Write([]byte(str))
  12528. }
  12529. if item.OrderStatus == 3 {
  12530. var str string
  12531. str = item.SetlId + " " +
  12532. item.MdtrtId + " " +
  12533. item.PsnNo + " " +
  12534. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12535. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12536. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  12537. _, err = f.Write([]byte(str))
  12538. var str2 string
  12539. str2 = item.SetlId + " " +
  12540. item.MdtrtId + " " +
  12541. item.PsnNo + " " +
  12542. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  12543. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  12544. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  12545. _, err = f.Write([]byte(str2))
  12546. }
  12547. }
  12548. }
  12549. Zip(file_path, zip_path)
  12550. fmt.Println(ReadFile(zip_path))
  12551. fmt.Println(string(ReadFile(zip_path)))
  12552. if config.IsOpen == 1 {
  12553. var user_name string
  12554. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12555. if role.ID == 0 {
  12556. user_name = "管理员"
  12557. } else {
  12558. user_name = role.UserName
  12559. }
  12560. baseParams := models.BaseParams{
  12561. SecretKey: miConfig.SecretKey,
  12562. FixmedinsCode: miConfig.Code,
  12563. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12564. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12565. OrgName: miConfig.OrgName,
  12566. Doctor: user_name,
  12567. }
  12568. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  12569. var dat map[string]interface{}
  12570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12571. fmt.Println(dat)
  12572. } else {
  12573. fmt.Println(err)
  12574. }
  12575. userJSONBytes, _ := json.Marshal(dat)
  12576. var res ResultNine
  12577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12578. utils.ErrorLog("解析失败:%v", err)
  12579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12580. return
  12581. }
  12582. if res.Infcode == 0 {
  12583. fileNo := res.Output.FileQuryNo
  12584. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  12585. "file_qury_no=" + fileNo +
  12586. "&setl_optins=" + "定点医保中心" +
  12587. "&stmt_begndate=" + start_time +
  12588. "&stm_enddate=" + end_time +
  12589. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12590. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12591. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  12592. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  12593. "&fixmedins_code=" + miConfig.Code +
  12594. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12595. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12596. "&secret_key=" + miConfig.SecretKey +
  12597. "&org_name=" + miConfig.OrgName +
  12598. "&doctor=" + user_name
  12599. resp, requestErr := http.Get(api)
  12600. if requestErr != nil {
  12601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12602. return
  12603. }
  12604. body, ioErr := ioutil.ReadAll(resp.Body)
  12605. if ioErr != nil {
  12606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12608. return
  12609. }
  12610. var respJSON map[string]interface{}
  12611. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12614. return
  12615. }
  12616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12617. userJSONBytes, _ := json.Marshal(respJSON)
  12618. var res ResultTen
  12619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12620. utils.ErrorLog("解析失败:%v", err)
  12621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12622. return
  12623. }
  12624. if res.Infcode == 0 {
  12625. service.Gdyb9102(baseParams, zip_name, fileNo)
  12626. micc := &models.MedicalInsuranceCostCompare{
  12627. StartTime: startime.Unix(),
  12628. EndTime: endtime.Unix(),
  12629. Insutype: "0",
  12630. CheckType: 2,
  12631. Num: fixmedins_setl_cnt,
  12632. Mtime: time.Now().Unix(),
  12633. Status: 1,
  12634. UserOrgId: adminUser.CurrentOrgId,
  12635. CostTotal: medfee_sumamt,
  12636. FuncTotal: fund_pay_sumamt,
  12637. PsnPay: psn_cash_pay,
  12638. Creator: admin_user_id,
  12639. Ctime: time.Now().Unix(),
  12640. }
  12641. service.CreateMedicalInsuranceCostCompareRecord(micc)
  12642. c.ServeSuccessJSON(map[string]interface{}{
  12643. "msg": "明细对账成功",
  12644. })
  12645. }
  12646. } else {
  12647. }
  12648. }
  12649. }
  12650. type CustomOrderInfo struct {
  12651. Name string
  12652. Spec string
  12653. Unit string
  12654. Count float64
  12655. Price float64
  12656. Total float64
  12657. }
  12658. func (c *HisApiController) GetSettleAccounts() {
  12659. //id, _ := c.GetInt64("id")
  12660. //record_time := c.GetString("record_time")
  12661. order_id, _ := c.GetInt64("order_id")
  12662. admin_user_id, _ := c.GetInt64("admin_user_id")
  12663. //timeLayout := "2006-01-02"
  12664. //loc, _ := time.LoadLocation("Local")
  12665. //
  12666. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12667. //if err != nil {
  12668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12669. // return
  12670. //}
  12671. //recordDateTime := theTime.Unix()
  12672. adminUser := c.GetAdminUserInfo()
  12673. order, _ := service.GetHisOrderByID(order_id)
  12674. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12675. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  12676. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  12677. orderInfos = append(orderInfos, orderInfos_two...)
  12678. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  12679. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  12680. var diagnosis_ids []string
  12681. if his.ID > 0 {
  12682. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  12683. } else {
  12684. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  12685. }
  12686. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  12687. var dia_config []*models.HisXtDiagnoseConfig
  12688. var name string
  12689. for _, item := range diagnosis_ids {
  12690. id, _ := strconv.ParseInt(item, 10, 64)
  12691. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12692. dia_config = append(dia_config, &diagnosisConfig)
  12693. if len(name) == 0 {
  12694. name = diagnosisConfig.ClassName
  12695. } else {
  12696. name = name + "," + diagnosisConfig.ClassName
  12697. }
  12698. }
  12699. var bedCostTotal float64 = 0 //床位总费
  12700. var bedCostSelfTotal float64 = 0 //床位自费
  12701. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12702. var bedSelfTotal float64 = 0 //床位部分项目自费
  12703. var bedInscpTotal float64 = 0 //床位部分项目自费
  12704. var operationCostTotal float64 = 0 //手术费
  12705. var operationCostSelfTotal float64 = 0 //手术费
  12706. var operationCostPartSelfTotal float64 = 0 //手术费
  12707. var operationSelfTotal float64 = 0 //床位部分项目自费
  12708. var operationInscpTotal float64 = 0 //床位部分项目自费
  12709. var otherCostTotal float64 = 0 //其他费用
  12710. var otherCostSelfTotal float64 = 0 //其他费用
  12711. var otherCostPartSelfTotal float64 = 0 //其他费用
  12712. var otherSelfTotal float64 = 0 //床位部分项目自费
  12713. var otherInscpTotal float64 = 0 //床位部分项目自费
  12714. var materialCostTotal float64 = 0 //材料费
  12715. var materialCostSelfTotal float64 = 0 //材料费
  12716. var materialCostPartSelfTotal float64 = 0 //材料费
  12717. var materialSelfTotal float64 = 0 //床位部分项目自费
  12718. var materialInscpTotal float64 = 0 //床位部分项目自费
  12719. var westernMedicineCostTotal float64 = 0 //西药费
  12720. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12721. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12722. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  12723. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  12724. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12725. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12726. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12727. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  12728. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  12729. var checkCostTotal float64 = 0 //检查费
  12730. var checkCostSelfTotal float64 = 0 //检查费
  12731. var checkCostPartSelfTotal float64 = 0 //检查费
  12732. var checkSelfTotal float64 = 0 //床位部分项目自费
  12733. var checkInscpTotal float64 = 0 //床位部分项目自费
  12734. var laboratoryCostTotal float64 = 0 //化验费
  12735. var laboratoryCostSelfTotal float64 = 0 //化验费
  12736. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12737. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  12738. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  12739. var treatCostTotal float64 = 0 //治疗费用
  12740. var treatCostSelfTotal float64 = 0 //治疗费用
  12741. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12742. var treatSelfTotal float64 = 0 //床位部分项目自费
  12743. var treatInscpTotal float64 = 0 //床位部分项目自费
  12744. decimal.DivisionPrecision = 2
  12745. for _, item := range orderInfos {
  12746. if item.MedChrgitmType == "01" { //床位费
  12747. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12748. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12749. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12750. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12751. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12752. }
  12753. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  12754. if item.MedChrgitmType == "03" { //检查费
  12755. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12756. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12757. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12758. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12759. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12760. }
  12761. } else {
  12762. if item.MedChrgitmType == "03" { //检查费
  12763. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12764. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12765. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12766. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12767. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12768. }
  12769. }
  12770. if item.MedChrgitmType == "04" { //化验费
  12771. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12772. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12773. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12774. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12775. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12776. }
  12777. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  12778. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12779. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12780. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12781. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12782. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12783. }
  12784. if item.MedChrgitmType == "06" { //手术费
  12785. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12786. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12787. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12788. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12789. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12790. }
  12791. if item.MedChrgitmType == "08" { //材料费
  12792. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12793. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12794. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12795. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12796. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12797. }
  12798. if item.MedChrgitmType == "09" { //西药费
  12799. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12800. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12801. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12802. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12803. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12804. }
  12805. if item.MedChrgitmType == "11" { //中成费
  12806. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12807. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12808. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12809. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12810. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12811. }
  12812. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  12813. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12814. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12815. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12816. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12817. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12818. }
  12819. }
  12820. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12821. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12822. var user_name string
  12823. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12824. if role.ID == 0 {
  12825. user_name = "管理员"
  12826. } else {
  12827. user_name = role.UserName
  12828. }
  12829. baseParams := models.BaseParams{
  12830. SecretKey: miConfig.SecretKey,
  12831. FixmedinsCode: miConfig.Code,
  12832. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12833. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12834. OrgName: miConfig.OrgName,
  12835. Doctor: user_name,
  12836. RequestUrl: miConfig.Url,
  12837. AccessKey: miConfig.AccessKey,
  12838. }
  12839. businessParams := models.BusinessParams{
  12840. PsnNo: order.PsnNo,
  12841. MdtrtId: order.MdtrtId,
  12842. SetlId: order.SetlId,
  12843. }
  12844. var res ResultEleven
  12845. var resEleven10265 ResultEleven10265
  12846. if config.IsOpen == 1 {
  12847. if miConfig.MdtrtareaAdmvs == "421300" {
  12848. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12849. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12850. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12851. resp, requestErr := http.Get(api)
  12852. if requestErr != nil {
  12853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12854. return
  12855. }
  12856. body, ioErr := ioutil.ReadAll(resp.Body)
  12857. if ioErr != nil {
  12858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12860. return
  12861. }
  12862. var respJSON map[string]interface{}
  12863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12866. return
  12867. }
  12868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12869. result, _ := json.Marshal(respJSON)
  12870. fmt.Println("log")
  12871. fmt.Println(string(result))
  12872. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12873. utils.ErrorLog("解析失败:%v", err)
  12874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12875. return
  12876. }
  12877. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12878. var api string
  12879. if miConfig.MdtrtareaAdmvs == "320921" {
  12880. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12881. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12882. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12883. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12884. } else {
  12885. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12886. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12887. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12888. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12889. }
  12890. resp, requestErr := http.Get(api)
  12891. if requestErr != nil {
  12892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12893. return
  12894. }
  12895. body, ioErr := ioutil.ReadAll(resp.Body)
  12896. if ioErr != nil {
  12897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12899. return
  12900. }
  12901. var respJSON map[string]interface{}
  12902. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12905. return
  12906. }
  12907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12908. result, _ := json.Marshal(respJSON)
  12909. fmt.Println("log")
  12910. fmt.Println(string(result))
  12911. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12912. utils.ErrorLog("解析失败:%v", err)
  12913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12914. return
  12915. }
  12916. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12917. res.Output = resEleven10265.Output
  12918. res.ErrMsg = resEleven10265.ErrMsg
  12919. res.Cainfo = resEleven10265.Cainfo
  12920. res.WarnMsg = resEleven10265.WarnMsg
  12921. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12922. res.Infcode = infocode
  12923. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12924. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12925. saveLog(result, requestLog, "5203", "结算单")
  12926. var dat map[string]interface{}
  12927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12928. fmt.Println(dat)
  12929. } else {
  12930. fmt.Println(err)
  12931. }
  12932. userJSONBytes, _ := json.Marshal(dat)
  12933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12934. utils.ErrorLog("解析失败:%v", err)
  12935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12936. return
  12937. }
  12938. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12939. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12940. saveLog(result, requestLog, "5203", "结算单")
  12941. var dat map[string]interface{}
  12942. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12943. fmt.Println(dat)
  12944. } else {
  12945. fmt.Println(err)
  12946. }
  12947. userJSONBytes, _ := json.Marshal(dat)
  12948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12949. utils.ErrorLog("解析失败:%v", err)
  12950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12951. return
  12952. }
  12953. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12954. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12955. saveLog(result, requestLog, "5203", "结算单")
  12956. var dat map[string]interface{}
  12957. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12958. fmt.Println(dat)
  12959. } else {
  12960. fmt.Println(err)
  12961. }
  12962. userJSONBytes, _ := json.Marshal(dat)
  12963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12964. utils.ErrorLog("解析失败:%v", err)
  12965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12966. return
  12967. }
  12968. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12969. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12970. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12971. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12972. resp, requestErr := http.Get(api)
  12973. if requestErr != nil {
  12974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12975. return
  12976. }
  12977. body, ioErr := ioutil.ReadAll(resp.Body)
  12978. if ioErr != nil {
  12979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12981. return
  12982. }
  12983. var respJSON map[string]interface{}
  12984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12987. return
  12988. }
  12989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12990. result, _ := json.Marshal(respJSON)
  12991. fmt.Println("log")
  12992. fmt.Println(string(result))
  12993. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12994. utils.ErrorLog("解析失败:%v", err)
  12995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12996. return
  12997. }
  12998. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12999. res.Output = resEleven10265.Output
  13000. res.ErrMsg = resEleven10265.ErrMsg
  13001. res.Cainfo = resEleven10265.Cainfo
  13002. res.WarnMsg = resEleven10265.WarnMsg
  13003. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  13004. res.Infcode = infocode
  13005. } else {
  13006. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  13007. result := service.Gdyb5203(baseParams, businessParams)
  13008. //service.Gdyb5204(baseParams, businessParams)
  13009. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  13010. var dat map[string]interface{}
  13011. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13012. fmt.Println(dat)
  13013. } else {
  13014. fmt.Println(err)
  13015. }
  13016. userJSONBytes, _ := json.Marshal(dat)
  13017. if miConfig.Code == "H15049901371" {
  13018. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  13019. utils.ErrorLog("解析失败:%v", err)
  13020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13021. return
  13022. }
  13023. res.InfRefmsgid = resEleven10265.InfRefmsgid
  13024. res.Output = resEleven10265.Output
  13025. res.ErrMsg = resEleven10265.ErrMsg
  13026. res.Cainfo = resEleven10265.Cainfo
  13027. res.WarnMsg = resEleven10265.WarnMsg
  13028. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  13029. res.Infcode = infocode
  13030. } else {
  13031. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13032. utils.ErrorLog("解析失败:%v", err)
  13033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13034. return
  13035. }
  13036. }
  13037. }
  13038. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13039. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  13040. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  13041. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13042. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  13043. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13044. var doctor_name string
  13045. if roles.ID == 0 {
  13046. doctor_name = "管理员"
  13047. } else {
  13048. doctor_name = roles.UserName
  13049. }
  13050. yiliao_leibie := ""
  13051. switch order.MedType {
  13052. case "11":
  13053. yiliao_leibie = "普通门诊"
  13054. break
  13055. case "12":
  13056. yiliao_leibie = "门诊挂号"
  13057. break
  13058. case "13":
  13059. yiliao_leibie = "急诊"
  13060. break
  13061. case "14":
  13062. yiliao_leibie = "门诊特殊病"
  13063. break
  13064. case "15":
  13065. yiliao_leibie = "门诊统筹"
  13066. break
  13067. case "16":
  13068. yiliao_leibie = "门诊慢性病"
  13069. break
  13070. case "21":
  13071. yiliao_leibie = "普通住院"
  13072. break
  13073. }
  13074. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13075. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  13076. if res.Infcode == 0 {
  13077. c.ServeSuccessJSON(map[string]interface{}{
  13078. "diagnosis": name,
  13079. "order_infos": orderInfos,
  13080. "number": order.MdtrtId,
  13081. "date": order.SettleAccountsDate,
  13082. "charge_admin": charge_admin,
  13083. "printor_admin": printor_admin,
  13084. "info": res.Output.Setlinfo,
  13085. "order": order,
  13086. "bedCostTotal": bedCostTotal,
  13087. "bedCostSelfTotal": bedCostSelfTotal,
  13088. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  13089. "bedSelfTotal": bedSelfTotal,
  13090. "bedInscpTotal": bedInscpTotal,
  13091. "operationCostTotal": operationCostTotal,
  13092. "operationCostSelfTotal": operationCostSelfTotal,
  13093. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  13094. "operationSelfTotal": operationSelfTotal,
  13095. "operationInscpTotal": operationInscpTotal,
  13096. "otherCostTotal": otherCostTotal,
  13097. "otherCostSelfTotal": otherCostSelfTotal,
  13098. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  13099. "otherSelfTotal": otherSelfTotal,
  13100. "otherInscpTotal": otherInscpTotal,
  13101. "materialCostTotal": materialCostTotal,
  13102. "materialCostSelfTotal": materialCostSelfTotal,
  13103. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  13104. "materialSelfTotal": materialSelfTotal,
  13105. "materialInscpTotal": materialInscpTotal,
  13106. "westernMedicineCostTotal": westernMedicineCostTotal,
  13107. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  13108. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  13109. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  13110. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  13111. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  13112. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  13113. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  13114. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  13115. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  13116. "checkCostTotal": checkCostTotal,
  13117. "checkCostSelfTotal": checkCostSelfTotal,
  13118. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  13119. "checkSelfTotal": checkSelfTotal,
  13120. "checkInscpTotal": checkInscpTotal,
  13121. "laboratoryCostTotal": laboratoryCostTotal,
  13122. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  13123. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  13124. "laboratorySelfTotal": laboratorySelfTotal,
  13125. "laboratoryInscpTotal": laboratoryInscpTotal,
  13126. "treatCostTotal": treatCostTotal,
  13127. "treatCostSelfTotal": treatCostSelfTotal,
  13128. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  13129. "treatSelfTotal": treatSelfTotal,
  13130. "treatInscpTotal": treatInscpTotal,
  13131. "doctor_info": doctor_info,
  13132. "doctor_code": adminRole_two.DoctorCode,
  13133. "doctor_name": doctor_name,
  13134. "health_card_no": order.PsnNo,
  13135. "department": departments.Name,
  13136. "yiliao_leibie": yiliao_leibie,
  13137. "after_money": order.AccountPrice,
  13138. "patient": patient,
  13139. "org_name": miConfig.OrgName,
  13140. "org_code": miConfig.Code,
  13141. "order_number": order.Number,
  13142. "his_hospital": his_hospital,
  13143. "his": his,
  13144. "dia_config": dia_config,
  13145. //"check_order_info": cus_slice,
  13146. })
  13147. }
  13148. }
  13149. }
  13150. func (c *HisApiController) CheckTreatment() {
  13151. patient_id, _ := c.GetInt64("patient_id")
  13152. id_card_no := c.GetString("id_card_no")
  13153. insutype := c.GetString("insutype")
  13154. med_type := c.GetString("med_type")
  13155. admin_user_id, _ := c.GetInt64("admin_user_id")
  13156. adminUser := c.GetAdminUserInfo()
  13157. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13158. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13159. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13160. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13161. if miConfig.MdtrtareaAdmvs == "421300" {
  13162. var res ResultTwo
  13163. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13164. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13165. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(2, 10)
  13166. resp, requestErr := http.Get(api)
  13167. if requestErr != nil {
  13168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13169. return
  13170. }
  13171. body, ioErr := ioutil.ReadAll(resp.Body)
  13172. if ioErr != nil {
  13173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13175. return
  13176. }
  13177. var respJSON map[string]interface{}
  13178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13181. return
  13182. }
  13183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13184. result, _ := json.Marshal(respJSON)
  13185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13186. utils.ErrorLog("解析失败:%v", err)
  13187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13188. return
  13189. }
  13190. if res.Infcode == 0 {
  13191. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  13192. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13193. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  13194. resp, requestErr := http.Get(api)
  13195. if requestErr != nil {
  13196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13197. return
  13198. }
  13199. body, ioErr := ioutil.ReadAll(resp.Body)
  13200. if ioErr != nil {
  13201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13203. return
  13204. }
  13205. var respJSON map[string]interface{}
  13206. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13209. return
  13210. }
  13211. var res Result2001
  13212. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13213. result2, _ := json.Marshal(respJSON)
  13214. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  13215. utils.ErrorLog("解析失败:%v", err)
  13216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13217. return
  13218. }
  13219. if res.Infcode == 0 {
  13220. c.ServeSuccessJSON(map[string]interface{}{
  13221. "msg": res.Output.Trtinfo,
  13222. })
  13223. }
  13224. } else {
  13225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13226. return
  13227. }
  13228. } else {
  13229. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13230. var dat map[string]interface{}
  13231. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13232. fmt.Println(dat)
  13233. } else {
  13234. fmt.Println(err)
  13235. }
  13236. userJSONBytes, _ := json.Marshal(dat)
  13237. var res ResultTwo
  13238. var res10265 ResultTwo10265
  13239. if miConfig.Code == "H15049901371" {
  13240. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13241. utils.ErrorLog("解析失败:%v", err)
  13242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13243. return
  13244. }
  13245. res.ErrMsg = res10265.ErrMsg
  13246. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13247. res.Infcode = infocode
  13248. res.Output = res10265.Output
  13249. res.InfRefmsgid = res10265.InfRefmsgid
  13250. } else {
  13251. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13252. utils.ErrorLog("解析失败:%v", err)
  13253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13254. return
  13255. }
  13256. }
  13257. var user_name string
  13258. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  13259. if role.ID == 0 {
  13260. user_name = "xxx"
  13261. } else {
  13262. user_name = role.UserName
  13263. }
  13264. baseParams := models.BaseParams{
  13265. SecretKey: miConfig.SecretKey,
  13266. FixmedinsCode: miConfig.Code,
  13267. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13268. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13269. OrgName: miConfig.OrgName,
  13270. Doctor: user_name,
  13271. }
  13272. if config.IsOpen == 1 {
  13273. if miConfig.Code == "H15049901371" {
  13274. if med_type == "14" {
  13275. if insutype == "390" {
  13276. med_type = "9933"
  13277. } else if insutype == "310" {
  13278. med_type = "990502"
  13279. }
  13280. } else if med_type == "11" {
  13281. med_type = "11"
  13282. }
  13283. }
  13284. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  13285. var dat map[string]interface{}
  13286. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13287. fmt.Println(dat)
  13288. } else {
  13289. fmt.Println(err)
  13290. }
  13291. var res Result2001
  13292. var res10265 Result2001Org10265
  13293. if miConfig.Code == "H15049901371" {
  13294. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13295. utils.ErrorLog("解析失败:%v", err)
  13296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13297. return
  13298. }
  13299. res.ErrMsg = res10265.ErrMsg
  13300. res.Output = res10265.Output
  13301. res.InfRefmsgid = res10265.InfRefmsgid
  13302. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13303. res.Infcode = infocode
  13304. } else {
  13305. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13306. utils.ErrorLog("解析失败:%v", err)
  13307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13308. return
  13309. }
  13310. }
  13311. if res.Infcode == 0 {
  13312. c.ServeSuccessJSON(map[string]interface{}{
  13313. "msg": res.Output.Trtinfo,
  13314. })
  13315. }
  13316. }
  13317. }
  13318. }
  13319. //func (c *HisApiController) PutRecord() {
  13320. // id, _ := c.GetInt64("id")
  13321. // record_time := c.GetString("record_time")
  13322. // timeLayout := "2006-01-02"
  13323. // loc, _ := time.LoadLocation("Local")
  13324. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13325. // if err != nil {
  13326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13327. // return
  13328. // }
  13329. // recordDateTime := theTime.Unix()
  13330. //
  13331. // adminInfo := c.GetAdminUserInfo()
  13332. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  13333. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13334. //
  13335. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13336. //
  13337. // fmt.Println(miConfig.SecretKey)
  13338. //
  13339. // if patient == nil {
  13340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13341. // return
  13342. // }
  13343. // if len(patient.IdCardNo) == 0 {
  13344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  13345. // return
  13346. // }
  13347. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  13348. // if config.IsOpen == 1 {
  13349. // api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13350. // resp, requestErr := http.Get(api)
  13351. // if requestErr != nil {
  13352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13353. // return
  13354. // }
  13355. // defer resp.Body.Close()
  13356. // body, ioErr := ioutil.ReadAll(resp.Body)
  13357. // if ioErr != nil {
  13358. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13360. // return
  13361. // }
  13362. // var respJSON map[string]interface{}
  13363. //
  13364. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13365. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13367. // return
  13368. // }
  13369. //
  13370. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13371. // userJSONBytes, _ := json.Marshal(userJSON)
  13372. // var res ResultTwo
  13373. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13374. // utils.ErrorLog("解析失败:%v", err)
  13375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13376. // return
  13377. // }
  13378. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13379. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13380. // infoStr := string(Iinfos)
  13381. // idetinfoStr := string(Idetinfos)
  13382. //
  13383. // if res.Infcode == 0 {
  13384. // his := models.VMHisPatient{
  13385. // Status: 1,
  13386. // Ctime: time.Now().Unix(),
  13387. // Mtime: time.Now().Unix(),
  13388. // PsnNo: res.Output.Baseinfo.PsnNo,
  13389. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  13390. // Certno: res.Output.Baseinfo.Certno,
  13391. // PsnName: res.Output.Baseinfo.PsnName,
  13392. // Gend: res.Output.Baseinfo.Gend,
  13393. // Naty: res.Output.Baseinfo.Naty,
  13394. // Brdy: res.Output.Baseinfo.Brdy,
  13395. // Age: res.Output.Baseinfo.Age,
  13396. // Iinfo: infoStr,
  13397. // Idetinfo: idetinfoStr,
  13398. // PatientId: patient.ID,
  13399. // RecordDate: theTime.Unix(),
  13400. // UserOrgId: adminInfo.CurrentOrgId,
  13401. // AdminUserId: adminInfo.AdminUser.Id,
  13402. // IsReturn: 1,
  13403. // }
  13404. //
  13405. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  13406. // //result := service.Gdyb2503(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  13407. // //result2 := service.Gdyb5301(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  13408. //
  13409. // //var dat map[string]interface{}
  13410. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13411. // // fmt.Println(dat)
  13412. // //} else {
  13413. // // fmt.Println(err)
  13414. // //}
  13415. //
  13416. // var dat2 map[string]interface{}
  13417. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13418. // fmt.Println(dat2)
  13419. // } else {
  13420. // fmt.Println(err)
  13421. // }
  13422. //
  13423. // } else {
  13424. // adminUser := c.GetAdminUserInfo()
  13425. // errlog := &models.HisOrderError{
  13426. // UserOrgId: adminUser.CurrentOrgId,
  13427. // Ctime: time.Now().Unix(),
  13428. // Mtime: time.Now().Unix(),
  13429. // ErrMsg: res.ErrMsg,
  13430. // Status: 1,
  13431. // PatientId: id,
  13432. // RecordTime: recordDateTime,
  13433. // Stage: 1,
  13434. // }
  13435. // service.CreateErrMsgLog(errlog)
  13436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  13437. // return
  13438. // }
  13439. // }
  13440. //
  13441. //}
  13442. //func (c *HisApiController) GetUploadDiag() {
  13443. // id, _ := c.GetInt64("id")
  13444. // record_time := c.GetString("record_time")
  13445. //
  13446. // diagnosis_id, _ := c.GetInt64("diagnosis")
  13447. // sick_type, _ := c.GetInt64("sick_type")
  13448. // reg_type, _ := c.GetInt64("reg_type")
  13449. //
  13450. // timeLayout := "2006-01-02"
  13451. // loc, _ := time.LoadLocation("Local")
  13452. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13453. // if err != nil {
  13454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13455. // return
  13456. // }
  13457. //
  13458. // var patientPrescription models.HisPrescriptionInfo
  13459. // recordDateTime := theTime.Unix()
  13460. // adminInfo := c.GetAdminUserInfo()
  13461. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13462. //
  13463. // if patientPrescription.ID == 0 {
  13464. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13465. // }
  13466. //
  13467. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13468. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  13469. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13470. // sickConfig, _ := service.FindSickById(sick_type)
  13471. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13472. //
  13473. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  13474. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  13475. // "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
  13476. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  13477. // resp2, requestErr2 := http.Get(api2)
  13478. // if requestErr2 != nil {
  13479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13480. // return
  13481. // }
  13482. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  13483. // if ioErr2 != nil {
  13484. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  13485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13486. // return
  13487. // }
  13488. // var respJSON2 map[string]interface{}
  13489. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  13490. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13492. // return
  13493. // }
  13494. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13495. // userJSONBytes2, _ := json.Marshal(respJSON2)
  13496. //
  13497. // var res2 ResultSix
  13498. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13499. // utils.ErrorLog("解析失败:%v", err)
  13500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13501. // return
  13502. // }
  13503. // if res2.Infcode != 0 {
  13504. // adminUser := c.GetAdminUserInfo()
  13505. // errlog := &models.HisOrderError{
  13506. // UserOrgId: adminUser.CurrentOrgId,
  13507. // Ctime: time.Now().Unix(),
  13508. // Mtime: time.Now().Unix(),
  13509. // ErrMsg: res2.ErrMsg,
  13510. // Status: 1,
  13511. // PatientId: id,
  13512. // RecordTime: recordDateTime,
  13513. // Stage: 3,
  13514. // }
  13515. // service.CreateErrMsgLog(errlog)
  13516. //
  13517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  13518. // return
  13519. // }
  13520. //
  13521. // c.ServeSuccessJSON(map[string]interface{}{
  13522. // "msg": "上传成功",
  13523. // })
  13524. //
  13525. //}
  13526. type QueryResult struct {
  13527. ID int64
  13528. Name string
  13529. Code string
  13530. List_type_code string
  13531. }
  13532. func (c *HisApiController) GetCheckCode() {
  13533. ids_str := c.GetString("ids")
  13534. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  13535. ids_arr := strings.Split(ids_str, ",")
  13536. var queryResult []QueryResult
  13537. ids := make([]int64, 0)
  13538. for _, item := range ids_arr {
  13539. id, _ := strconv.ParseInt(item, 10, 64)
  13540. ids = append(ids, id)
  13541. }
  13542. if record_type == 1 {
  13543. drugs, _ := service.GetBatchDrugList(ids)
  13544. for _, item := range drugs {
  13545. result := QueryResult{
  13546. ID: item.ID,
  13547. Name: item.DrugName,
  13548. Code: item.MedicalInsuranceNumber,
  13549. List_type_code: "101",
  13550. }
  13551. queryResult = append(queryResult, result)
  13552. }
  13553. } else if record_type == 2 {
  13554. goods, _ := service.GetBatchGoodInformationList(ids)
  13555. for _, item := range goods {
  13556. result := QueryResult{
  13557. ID: item.ID,
  13558. Name: item.GoodName,
  13559. Code: item.MedicalInsuranceNumber,
  13560. List_type_code: "301",
  13561. }
  13562. queryResult = append(queryResult, result)
  13563. }
  13564. } else if record_type == 3 {
  13565. projects, _ := service.GetBathchMyPorjecgList(ids)
  13566. for _, item := range projects {
  13567. result := QueryResult{
  13568. ID: item.ID,
  13569. Name: item.ProjectName,
  13570. Code: item.MedicalCode,
  13571. List_type_code: "201",
  13572. }
  13573. queryResult = append(queryResult, result)
  13574. }
  13575. }
  13576. admin_user_id, _ := c.GetInt64("admin_user_id")
  13577. adminUser := c.GetAdminUserInfo()
  13578. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13579. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13580. var user_name string
  13581. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13582. if role.ID == 0 {
  13583. user_name = "xxx"
  13584. } else {
  13585. user_name = role.UserName
  13586. }
  13587. baseParams := &models.BaseParams{
  13588. SecretKey: miConfig.SecretKey,
  13589. FixmedinsCode: miConfig.Code,
  13590. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13591. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13592. OrgName: miConfig.OrgName,
  13593. Doctor: user_name,
  13594. }
  13595. if config.IsOpen == 1 {
  13596. for _, item := range queryResult {
  13597. var result string
  13598. if record_type == 1 {
  13599. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13600. } else if record_type == 2 {
  13601. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13602. } else if record_type == 3 {
  13603. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13604. }
  13605. var dat map[string]interface{}
  13606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13607. fmt.Println(dat)
  13608. } else {
  13609. fmt.Println(err)
  13610. }
  13611. userJSONBytes, _ := json.Marshal(dat)
  13612. var res ResultSix
  13613. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13614. utils.ErrorLog("解析失败:%v", err)
  13615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13616. return
  13617. }
  13618. if res.Infcode == 0 {
  13619. if record_type == 1 {
  13620. service.UpdateBaseDrugById(item.ID)
  13621. } else if record_type == 2 {
  13622. service.UpdateGoodInformaitonByDetail(item.ID)
  13623. } else if record_type == 3 {
  13624. service.UpdateProjectById(item.ID)
  13625. }
  13626. c.ServeSuccessJSON(map[string]interface{}{
  13627. "failed_code": 0,
  13628. "msg": "目录对照成功",
  13629. })
  13630. } else {
  13631. c.ServeSuccessJSON(map[string]interface{}{
  13632. "failed_code": -10,
  13633. "msg": res.ErrMsg,
  13634. })
  13635. }
  13636. }
  13637. }
  13638. }
  13639. func (c *HisApiController) UnCheckCode() {
  13640. ids_str := c.GetString("ids")
  13641. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  13642. admin_user_id, _ := c.GetInt64("admin_user_id")
  13643. ids_arr := strings.Split(ids_str, ",")
  13644. var queryResult []QueryResult
  13645. ids := make([]int64, 0)
  13646. for _, item := range ids_arr {
  13647. id, _ := strconv.ParseInt(item, 10, 64)
  13648. ids = append(ids, id)
  13649. }
  13650. if record_type == 1 {
  13651. drugs, _ := service.GetBatchDrugList(ids)
  13652. for _, item := range drugs {
  13653. result := QueryResult{
  13654. ID: item.ID,
  13655. Name: item.DrugName,
  13656. Code: item.MedicalInsuranceNumber,
  13657. List_type_code: "101",
  13658. }
  13659. queryResult = append(queryResult, result)
  13660. }
  13661. } else if record_type == 2 {
  13662. goods, _ := service.GetBatchGoodInformationList(ids)
  13663. for _, item := range goods {
  13664. result := QueryResult{
  13665. ID: item.ID,
  13666. Name: item.GoodName,
  13667. Code: item.MedicalInsuranceNumber,
  13668. List_type_code: "301",
  13669. }
  13670. queryResult = append(queryResult, result)
  13671. }
  13672. } else if record_type == 3 {
  13673. projects, _ := service.GetBathchMyPorjecgList(ids)
  13674. for _, item := range projects {
  13675. result := QueryResult{
  13676. ID: item.ID,
  13677. Name: item.ProjectName,
  13678. Code: item.MedicalCode,
  13679. List_type_code: "201",
  13680. }
  13681. queryResult = append(queryResult, result)
  13682. }
  13683. }
  13684. adminUser := c.GetAdminUserInfo()
  13685. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13686. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13687. var user_name string
  13688. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13689. if role.ID == 0 {
  13690. user_name = "xxx"
  13691. } else {
  13692. user_name = role.UserName
  13693. }
  13694. baseParams := &models.BaseParams{
  13695. SecretKey: miConfig.SecretKey,
  13696. FixmedinsCode: miConfig.Code,
  13697. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13698. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13699. OrgName: miConfig.OrgName,
  13700. Doctor: user_name,
  13701. }
  13702. if config.IsOpen == 1 {
  13703. for _, item := range queryResult {
  13704. var result string
  13705. if record_type == 1 {
  13706. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13707. } else if record_type == 2 {
  13708. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13709. } else if record_type == 3 {
  13710. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13711. }
  13712. var dat2 map[string]interface{}
  13713. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  13714. fmt.Println(dat2)
  13715. } else {
  13716. fmt.Println(err)
  13717. }
  13718. userJSONBytes, _ := json.Marshal(dat2)
  13719. var res ResultSix
  13720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13721. utils.ErrorLog("解析失败:%v", err)
  13722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13723. return
  13724. }
  13725. if res.Infcode == 0 {
  13726. if record_type == 1 {
  13727. service.UpdateDrugByIdDetail(item.ID)
  13728. } else if record_type == 2 {
  13729. service.UpdateGoodInfoById(item.ID)
  13730. } else if record_type == 3 {
  13731. service.UpdateMyProjectById(item.ID)
  13732. }
  13733. c.ServeSuccessJSON(map[string]interface{}{
  13734. "failed_code": 0,
  13735. "msg": "撤销目录对照成功",
  13736. })
  13737. } else {
  13738. c.ServeSuccessJSON(map[string]interface{}{
  13739. "failed_code": -10,
  13740. "msg": res.ErrMsg,
  13741. })
  13742. }
  13743. }
  13744. }
  13745. }
  13746. func (c *HisApiController) GetPatientInfo() {
  13747. id_card_no := c.GetString("id_card_no")
  13748. admin_user_id, _ := c.GetInt64("admin_user_id")
  13749. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13750. if patient.ID == 0 {
  13751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13752. return
  13753. }
  13754. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13755. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13756. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  13757. if config.IsOpen == 1 {
  13758. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13759. var dat map[string]interface{}
  13760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13761. fmt.Println(dat)
  13762. } else {
  13763. fmt.Println(err)
  13764. }
  13765. userJSONBytes, _ := json.Marshal(dat)
  13766. var res ResultTwo
  13767. var res10265 ResultTwo10265
  13768. if miConfig.Code == "H15049901371" {
  13769. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13770. utils.ErrorLog("解析失败:%v", err)
  13771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13772. return
  13773. }
  13774. res.ErrMsg = res10265.ErrMsg
  13775. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13776. res.Infcode = infocode
  13777. res.Output = res10265.Output
  13778. res.InfRefmsgid = res10265.InfRefmsgid
  13779. } else {
  13780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13781. utils.ErrorLog("解析失败:%v", err)
  13782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13783. return
  13784. }
  13785. }
  13786. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13787. // utils.ErrorLog("解析失败:%v", err)
  13788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13789. // return
  13790. //}
  13791. if res.Infcode != 0 {
  13792. c.ServeSuccessJSON(map[string]interface{}{
  13793. "failed_code": -10,
  13794. "msg": res.ErrMsg,
  13795. })
  13796. } else {
  13797. c.ServeSuccessJSON(map[string]interface{}{
  13798. "failed_code": 0,
  13799. "info": res,
  13800. })
  13801. }
  13802. }
  13803. }
  13804. func (c *HisApiController) PsnPutOnRecord() {
  13805. record_type, _ := c.GetInt64("type")
  13806. patient_id, _ := c.GetInt64("patient_id")
  13807. admin_user_id, _ := c.GetInt64("admin_user_id")
  13808. start_time := c.GetString("start_time")
  13809. end_time := c.GetString("end_time")
  13810. adminUser := c.GetAdminUserInfo()
  13811. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13812. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13813. var patients []*models.Patients
  13814. if record_type == 1 { //全部备案
  13815. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  13816. patients = append(patients, patient...)
  13817. } else { //单个备案
  13818. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13819. patients = append(patients, patient)
  13820. }
  13821. var user_name string
  13822. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13823. if role.ID == 0 {
  13824. user_name = "xxx"
  13825. } else {
  13826. user_name = role.UserName
  13827. }
  13828. if config.IsOpen == 1 {
  13829. for _, item := range patients {
  13830. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + item.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + user_name + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13831. resp, requestErr := http.Get(api)
  13832. if requestErr != nil {
  13833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13834. return
  13835. }
  13836. defer resp.Body.Close()
  13837. body, ioErr := ioutil.ReadAll(resp.Body)
  13838. if ioErr != nil {
  13839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13841. return
  13842. }
  13843. var respJSON map[string]interface{}
  13844. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13847. return
  13848. }
  13849. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13850. userJSONBytes, _ := json.Marshal(userJSON)
  13851. var res ResultTwo
  13852. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13853. utils.ErrorLog("解析失败:%v", err)
  13854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13855. return
  13856. }
  13857. if res.Infcode == 0 {
  13858. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  13859. var dat map[string]interface{}
  13860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13861. fmt.Println(dat)
  13862. } else {
  13863. fmt.Println(err)
  13864. }
  13865. userJSONBytes, _ := json.Marshal(dat)
  13866. var res2 ResultThirteen
  13867. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13868. utils.ErrorLog("解析失败:%v", err)
  13869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13870. return
  13871. }
  13872. if res2.Infcode == 0 {
  13873. psnResult := &models.GdybPsnRecord{
  13874. UserOrgId: adminUser.CurrentOrgId,
  13875. PatientId: item.ID,
  13876. PsnNo: res.Output.Baseinfo.PsnNo,
  13877. Ctime: time.Now().Unix(),
  13878. Mtime: time.Now().Unix(),
  13879. Status: 1,
  13880. IsCancel: 1,
  13881. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13882. }
  13883. service.CreatePsnRecord(psnResult)
  13884. } else {
  13885. c.ServeSuccessJSON(map[string]interface{}{
  13886. "failed_code": -10,
  13887. "msg": res2.ErrMsg,
  13888. })
  13889. return
  13890. }
  13891. }
  13892. }
  13893. }
  13894. }
  13895. func (c *HisApiController) PsnUnPutOnRecord() {
  13896. id, _ := c.GetInt64("id")
  13897. //record_type, _ := c.GetInt64("type")
  13898. admin_user_id, _ := c.GetInt64("admin_user_id")
  13899. adminUser := c.GetAdminUserInfo()
  13900. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13901. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13902. var user_name string
  13903. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13904. if role.ID == 0 {
  13905. user_name = "xxx"
  13906. } else {
  13907. user_name = role.UserName
  13908. }
  13909. psn_record, _ := service.GetPsnRecordById(id)
  13910. if psn_record.ID == 0 {
  13911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13912. return
  13913. }
  13914. if config.IsOpen == 1 {
  13915. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13916. var dat map[string]interface{}
  13917. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13918. fmt.Println(dat)
  13919. } else {
  13920. fmt.Println(err)
  13921. }
  13922. userJSONBytes, _ := json.Marshal(dat)
  13923. var res ResultFourteen
  13924. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13925. utils.ErrorLog("解析失败:%v", err)
  13926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13927. return
  13928. }
  13929. if res.Infcode == 0 {
  13930. psn_record.IsCancel = 2
  13931. service.CreatePsnRecord(&psn_record)
  13932. } else {
  13933. c.ServeSuccessJSON(map[string]interface{}{
  13934. "failed_code": -10,
  13935. "msg": res.ErrMsg,
  13936. })
  13937. return
  13938. }
  13939. }
  13940. }
  13941. func (c *HisApiController) PsnPutNCDSOnRecord() {
  13942. patient_id, _ := c.GetInt64("patient_id")
  13943. insutype_two := c.GetString("insutype")
  13944. psn_no := c.GetString("psn_no")
  13945. doctor_id, _ := c.GetInt64("doctor_id")
  13946. sick_id, _ := c.GetInt64("sick_id")
  13947. department_id, _ := c.GetInt64("department_id")
  13948. start_time := c.GetString("start_time")
  13949. end_time := c.GetString("end_time")
  13950. check_time := c.GetString("check_time")
  13951. hospital_code := c.GetString("hospital_code")
  13952. hospital_name := c.GetString("hospital_name")
  13953. adminUser := c.GetAdminUserInfo()
  13954. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13955. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13956. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13957. sick, _ := service.FindSickById(sick_id)
  13958. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13959. if len(hospital_code) == 0 {
  13960. hospital_code = miConfig.Code
  13961. }
  13962. if len(hospital_name) == 0 {
  13963. hospital_name = miConfig.OrgName
  13964. }
  13965. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13966. var res ResultTwo
  13967. var res10265 ResultTwo10265
  13968. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13969. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13970. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13971. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13972. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  13973. resp, requestErr := http.Get(api)
  13974. if requestErr != nil {
  13975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13976. return
  13977. }
  13978. body, ioErr := ioutil.ReadAll(resp.Body)
  13979. if ioErr != nil {
  13980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13982. return
  13983. }
  13984. var respJSON map[string]interface{}
  13985. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13988. return
  13989. }
  13990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13991. result, _ := json.Marshal(respJSON)
  13992. fmt.Println("log")
  13993. fmt.Println(string(result))
  13994. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13995. utils.ErrorLog("解析失败:%v", err)
  13996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13997. return
  13998. }
  13999. res.ErrMsg = res10265.ErrMsg
  14000. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14001. res.Infcode = infocode
  14002. res.Output = res10265.Output
  14003. res.InfRefmsgid = res10265.InfRefmsgid
  14004. } else {
  14005. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  14006. if miConfig.Code == "H15049901371" {
  14007. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14008. utils.ErrorLog("解析失败:%v", err)
  14009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14010. return
  14011. }
  14012. res.ErrMsg = res10265.ErrMsg
  14013. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14014. res.Infcode = infocode
  14015. res.Output = res10265.Output
  14016. res.InfRefmsgid = res10265.InfRefmsgid
  14017. } else {
  14018. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14019. utils.ErrorLog("解析失败:%v", err)
  14020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14021. return
  14022. }
  14023. }
  14024. }
  14025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14026. infoStr := string(Iinfos)
  14027. var rf []*ResultFive
  14028. json.Unmarshal([]byte(infoStr), &rf)
  14029. var insuplc_admdvs string
  14030. var insutype string
  14031. var is390 int = 0
  14032. var is310 int = 0
  14033. var insutypes []*ResultFive
  14034. for _, item := range rf {
  14035. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14036. insutypes = append(insutypes, item)
  14037. }
  14038. }
  14039. if len(insutypes) == 1 {
  14040. insutype = insutypes[0].Insutype
  14041. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14042. } else {
  14043. for _, i := range insutypes {
  14044. if i.Insutype == "390" {
  14045. is390 = 1
  14046. }
  14047. if i.Insutype == "310" {
  14048. is310 = 1
  14049. }
  14050. }
  14051. }
  14052. if is390 == 1 {
  14053. insutype = "390"
  14054. }
  14055. if is310 == 1 {
  14056. insutype = "310"
  14057. }
  14058. if len(insutypes) == 2 {
  14059. insutype = insutype_two
  14060. }
  14061. if len(insutypes) == 0 {
  14062. insutype = "310"
  14063. }
  14064. insutype = insutype_two
  14065. fmt.Println(insutype)
  14066. for _, item := range rf {
  14067. fmt.Println(item.Insutype)
  14068. fmt.Println(insutype)
  14069. if item.Insutype == insutype {
  14070. fmt.Println(item.Insutype)
  14071. fmt.Println(insutype)
  14072. insuplc_admdvs = item.InsuplcAdmdvs
  14073. }
  14074. }
  14075. fmt.Println(insuplc_admdvs)
  14076. var res2 ResultThirteen
  14077. var res10265_2 ResultThirteen10265
  14078. if config.IsOpen == 1 {
  14079. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14080. } else {
  14081. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  14082. var dat map[string]interface{}
  14083. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14084. fmt.Println(dat)
  14085. } else {
  14086. fmt.Println(err)
  14087. }
  14088. userJSONBytes, _ := json.Marshal(dat)
  14089. if miConfig.Code == "H15049901371" {
  14090. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  14091. utils.ErrorLog("解析失败:%v", err)
  14092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14093. return
  14094. }
  14095. res2.ErrMsg = res10265_2.ErrMsg
  14096. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  14097. res2.Infcode = infocode
  14098. res2.Output = res10265_2.Output
  14099. res2.InfRefmsgid = res10265_2.InfRefmsgid
  14100. } else {
  14101. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14102. utils.ErrorLog("解析失败:%v", err)
  14103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14104. return
  14105. }
  14106. }
  14107. }
  14108. if res2.Infcode == 0 {
  14109. psnResult := &models.GdybPsnNcdsRecord{
  14110. UserOrgId: adminUser.CurrentOrgId,
  14111. PatientId: patient.ID,
  14112. PsnNo: psn_no,
  14113. DoctorId: doctor.AdminUserId,
  14114. DepartmentId: department_id,
  14115. SickType: sick_id,
  14116. Insutype: insutype,
  14117. Ctime: time.Now().Unix(),
  14118. Mtime: time.Now().Unix(),
  14119. Status: 1,
  14120. IsCancel: 1,
  14121. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  14122. }
  14123. service.CreatePsnNCDSRecord(psnResult)
  14124. c.ServeSuccessJSON(map[string]interface{}{
  14125. "failed_code": 0,
  14126. "msg": "备案成功",
  14127. "result": psnResult,
  14128. })
  14129. } else {
  14130. c.ServeSuccessJSON(map[string]interface{}{
  14131. "failed_code": -10,
  14132. "msg": res2.ErrMsg,
  14133. })
  14134. return
  14135. }
  14136. }
  14137. }
  14138. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  14139. id, _ := c.GetInt64("id")
  14140. admin_user_id, _ := c.GetInt64("admin_user_id")
  14141. adminUser := c.GetAdminUserInfo()
  14142. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14143. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14144. //config, _ := service.Ge(adminUser.CurrentOrgId)
  14145. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  14146. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14147. //var user_name string
  14148. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14149. //if role.ID == 0 {
  14150. // user_name = "xxx"
  14151. //} else {
  14152. // user_name = role.UserName
  14153. //}
  14154. psn_record, _ := service.GetPsnNCDSRecordById(id)
  14155. if psn_record.ID == 0 {
  14156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  14157. return
  14158. }
  14159. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  14160. var res ResultTwo
  14161. var res10265 ResultTwo10265
  14162. if miConfig.Code == "H15049901371" {
  14163. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14164. utils.ErrorLog("解析失败:%v", err)
  14165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14166. return
  14167. }
  14168. res.ErrMsg = res10265.ErrMsg
  14169. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14170. res.Infcode = infocode
  14171. res.Output = res10265.Output
  14172. res.InfRefmsgid = res10265.InfRefmsgid
  14173. } else {
  14174. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14175. utils.ErrorLog("解析失败:%v", err)
  14176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14177. return
  14178. }
  14179. }
  14180. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14181. infoStr := string(Iinfos)
  14182. var rf []*ResultFive
  14183. json.Unmarshal([]byte(infoStr), &rf)
  14184. var insuplc_admdvs string
  14185. var insutype string
  14186. var is390 int = 0
  14187. var is310 int = 0
  14188. var insutypes []*ResultFive
  14189. for _, item := range rf {
  14190. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14191. insutypes = append(insutypes, item)
  14192. }
  14193. }
  14194. if len(insutypes) == 1 {
  14195. insutype = insutypes[0].Insutype
  14196. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14197. } else {
  14198. for _, i := range insutypes {
  14199. if i.Insutype == "390" {
  14200. is390 = 1
  14201. }
  14202. if i.Insutype == "310" {
  14203. is310 = 1
  14204. }
  14205. }
  14206. }
  14207. if is390 == 1 {
  14208. insutype = "390"
  14209. }
  14210. if is310 == 1 {
  14211. insutype = "310"
  14212. }
  14213. if len(insutypes) == 0 {
  14214. insutype = "310"
  14215. }
  14216. insutype = psn_record.Insutype
  14217. for _, item := range rf {
  14218. if item.Insutype == insutype {
  14219. insuplc_admdvs = item.InsuplcAdmdvs
  14220. }
  14221. }
  14222. if config.IsOpen == 1 {
  14223. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  14224. var dat map[string]interface{}
  14225. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14226. fmt.Println(dat)
  14227. } else {
  14228. fmt.Println(err)
  14229. }
  14230. userJSONBytes, _ := json.Marshal(dat)
  14231. var res ResultFourteen
  14232. var res10265 ResultFourteen10265
  14233. if miConfig.Code == "H15049901371" {
  14234. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14235. utils.ErrorLog("解析失败:%v", err)
  14236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14237. return
  14238. }
  14239. res.ErrMsg = res10265.ErrMsg
  14240. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14241. res.Infcode = infocode
  14242. res.Output = res10265.Output
  14243. res.InfRefmsgid = res10265.InfRefmsgid
  14244. } else {
  14245. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14246. utils.ErrorLog("解析失败:%v", err)
  14247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14248. return
  14249. }
  14250. }
  14251. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14252. // utils.ErrorLog("解析失败:%v", err)
  14253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14254. // return
  14255. //}
  14256. if res.Infcode == 0 {
  14257. psn_record.IsCancel = 2
  14258. service.CreatePsnNCDSRecord(&psn_record)
  14259. c.ServeSuccessJSON(map[string]interface{}{
  14260. "failed_code": 0,
  14261. "msg": "撤销备案成功",
  14262. })
  14263. } else {
  14264. c.ServeSuccessJSON(map[string]interface{}{
  14265. "failed_code": -10,
  14266. "msg": res.ErrMsg,
  14267. })
  14268. return
  14269. }
  14270. }
  14271. }
  14272. func (c *HisApiController) TestTest() {
  14273. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  14274. fmt.Println(patient.Iinfo)
  14275. }
  14276. type CustomData struct {
  14277. MsgId string
  14278. PsnNo string
  14279. Info string
  14280. }
  14281. func (c *HisApiController) ReversalData() {
  14282. var customData []*CustomData
  14283. custom := &CustomData{
  14284. MsgId: "H44022900158202103301714472004",
  14285. PsnNo: "44020000001101329945",
  14286. Info: "2207",
  14287. }
  14288. customData = append(customData, custom)
  14289. custom1 := &CustomData{
  14290. MsgId: "H4402290015820210330172057803",
  14291. PsnNo: "44020000001101161813",
  14292. Info: "2207",
  14293. }
  14294. customData = append(customData, custom1)
  14295. custom2 := &CustomData{
  14296. MsgId: "H44022900158202103301705198813",
  14297. PsnNo: "44190000133097375417",
  14298. Info: "2207",
  14299. }
  14300. customData = append(customData, custom2)
  14301. custom3 := &CustomData{
  14302. MsgId: "H44022900158202103301715524756",
  14303. PsnNo: "44020000001100187221",
  14304. Info: "2207",
  14305. }
  14306. customData = append(customData, custom3)
  14307. custom4 := &CustomData{
  14308. MsgId: "H44022900158202103301730376224",
  14309. PsnNo: "44020000001101959155",
  14310. Info: "2207",
  14311. }
  14312. customData = append(customData, custom4)
  14313. custom5 := &CustomData{
  14314. MsgId: "H44022900158202103301748008725",
  14315. PsnNo: "44020000001104246641",
  14316. Info: "2207",
  14317. }
  14318. customData = append(customData, custom5)
  14319. custom6 := &CustomData{
  14320. MsgId: "H44022900158202103301718096755",
  14321. PsnNo: "44020000001102211860",
  14322. Info: "2207",
  14323. }
  14324. customData = append(customData, custom6)
  14325. custom7 := &CustomData{
  14326. MsgId: "H44022900158202103301736551640",
  14327. PsnNo: "44020000001102687718",
  14328. Info: "2207",
  14329. }
  14330. customData = append(customData, custom7)
  14331. custom8 := &CustomData{
  14332. MsgId: "H44022900158202103301743097676",
  14333. PsnNo: "44020000001102127785",
  14334. Info: "2207",
  14335. }
  14336. customData = append(customData, custom8)
  14337. custom9 := &CustomData{
  14338. MsgId: "H44022900158202103301712304203",
  14339. PsnNo: "44020000001101518097",
  14340. Info: "2207",
  14341. }
  14342. customData = append(customData, custom9)
  14343. custom10 := &CustomData{
  14344. MsgId: "H44022900158202103301738448785",
  14345. PsnNo: "44020000001100500813",
  14346. Info: "2207",
  14347. }
  14348. customData = append(customData, custom10)
  14349. custom11 := &CustomData{
  14350. MsgId: "H44022900158202103301732455843",
  14351. PsnNo: "44020000001102690557",
  14352. Info: "2207",
  14353. }
  14354. customData = append(customData, custom11)
  14355. custom12 := &CustomData{
  14356. MsgId: "H44022900158202103301745421708",
  14357. PsnNo: "44020000001102211928",
  14358. Info: "2207",
  14359. }
  14360. customData = append(customData, custom12)
  14361. custom1212 := &CustomData{
  14362. MsgId: "H440229001582021033017351627",
  14363. PsnNo: "44020000001102481733",
  14364. Info: "2207",
  14365. }
  14366. customData = append(customData, custom1212)
  14367. custom13 := &CustomData{
  14368. MsgId: "H44022900158202103301740327951",
  14369. PsnNo: "44020000001103174866",
  14370. Info: "2207",
  14371. }
  14372. customData = append(customData, custom13)
  14373. custom14 := &CustomData{
  14374. MsgId: "H4402290015820210330174922668",
  14375. PsnNo: "44020000001102927272",
  14376. Info: "2207",
  14377. }
  14378. customData = append(customData, custom14)
  14379. custom15 := &CustomData{
  14380. MsgId: "H44022900158202103301752362273",
  14381. PsnNo: "44020000001102942890",
  14382. Info: "2207",
  14383. }
  14384. customData = append(customData, custom15)
  14385. custom16 := &CustomData{
  14386. MsgId: "H44022900158202103301751082917",
  14387. PsnNo: "44020000001101662162",
  14388. Info: "2207",
  14389. }
  14390. customData = append(customData, custom16)
  14391. custom17 := &CustomData{
  14392. MsgId: "H44022900158202103301754147728",
  14393. PsnNo: "44020000000229014511",
  14394. Info: "2207",
  14395. }
  14396. customData = append(customData, custom17)
  14397. adminUser := c.GetAdminUserInfo()
  14398. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14399. for _, item := range customData {
  14400. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14401. fmt.Println(result)
  14402. }
  14403. }
  14404. func (c *HisApiController) GetAllopatry() {
  14405. year := c.GetString("year")
  14406. month := c.GetString("month")
  14407. admin_user_id, _ := c.GetInt64("admin_user_id")
  14408. adminUser := c.GetAdminUserInfo()
  14409. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14410. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14411. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  14412. var dat map[string]interface{}
  14413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14414. fmt.Println(dat)
  14415. } else {
  14416. fmt.Println(err)
  14417. }
  14418. userJSONBytes, _ := json.Marshal(dat)
  14419. var res models.Result9001
  14420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14421. utils.ErrorLog("解析失败:%v", err)
  14422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14423. return
  14424. }
  14425. fmt.Println(res.Output.Signinoutb)
  14426. fmt.Println(res.Output.Signinoutb.SignNo)
  14427. fmt.Println(string(userJSONBytes))
  14428. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14429. var dat2 map[string]interface{}
  14430. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14431. fmt.Println(dat)
  14432. } else {
  14433. fmt.Println(err)
  14434. }
  14435. userJSONBytes2, _ := json.Marshal(dat2)
  14436. var res2 models.Result3260
  14437. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14438. utils.ErrorLog("解析失败:%v", err)
  14439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14440. return
  14441. }
  14442. if res2.Infcode == 0 {
  14443. result3, _, _ := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  14444. var dat2 map[string]interface{}
  14445. if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  14446. fmt.Println(dat)
  14447. } else {
  14448. fmt.Println(err)
  14449. }
  14450. c.ServeSuccessJSON(map[string]interface{}{
  14451. "list": res2.Output.Data,
  14452. })
  14453. return
  14454. } else {
  14455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14456. return
  14457. }
  14458. }
  14459. func (c *HisApiController) ComfirmAllopatry() {
  14460. year := c.GetString("year")
  14461. month := c.GetString("month")
  14462. admin_user_id, _ := c.GetInt64("admin_user_id")
  14463. adminUser := c.GetAdminUserInfo()
  14464. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14465. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14466. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  14467. var dat map[string]interface{}
  14468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14469. fmt.Println(dat)
  14470. } else {
  14471. fmt.Println(err)
  14472. }
  14473. userJSONBytes, _ := json.Marshal(dat)
  14474. var res models.Result9001
  14475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14476. utils.ErrorLog("解析失败:%v", err)
  14477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14478. return
  14479. }
  14480. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14481. var dat2 map[string]interface{}
  14482. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14483. fmt.Println(dat)
  14484. } else {
  14485. fmt.Println(err)
  14486. }
  14487. userJSONBytes2, _ := json.Marshal(dat2)
  14488. var res2 models.Result3260
  14489. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14490. utils.ErrorLog("解析失败:%v", err)
  14491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14492. return
  14493. }
  14494. if res2.Infcode == 0 {
  14495. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  14496. var dat map[string]interface{}
  14497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14498. fmt.Println(dat)
  14499. } else {
  14500. fmt.Println(err)
  14501. }
  14502. userJSONBytes, _ := json.Marshal(dat)
  14503. var res3 models.Result3261
  14504. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  14505. utils.ErrorLog("解析失败:%v", err)
  14506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14507. return
  14508. }
  14509. if res3.Infcode == 0 {
  14510. record := &models.HisYidiClearRecord{
  14511. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14512. Ctime: time.Now().Unix(),
  14513. Mtime: time.Now().Unix(),
  14514. Status: 1,
  14515. MsgId: msgId,
  14516. }
  14517. service.SaveClearRecord(record)
  14518. c.ServeSuccessJSON(map[string]interface{}{
  14519. "msg": "提取成功",
  14520. })
  14521. }
  14522. }
  14523. }
  14524. func (c *HisApiController) RefundAllopatry() {
  14525. year := c.GetString("year")
  14526. month := c.GetString("month")
  14527. id, _ := c.GetInt64("id")
  14528. admin_user_id, _ := c.GetInt64("admin_user_id")
  14529. adminUser := c.GetAdminUserInfo()
  14530. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14531. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14532. record, _ := service.GetClearRecordById(id)
  14533. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  14534. var dat map[string]interface{}
  14535. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14536. fmt.Println(dat)
  14537. } else {
  14538. fmt.Println(err)
  14539. }
  14540. userJSONBytes, _ := json.Marshal(dat)
  14541. var empty ResultFourteen
  14542. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  14543. utils.ErrorLog("解析失败:%v", err)
  14544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14545. return
  14546. }
  14547. if empty.Infcode == 0 {
  14548. c.ServeSuccessJSON(map[string]interface{}{
  14549. "msg": "撤销成功",
  14550. })
  14551. return
  14552. }
  14553. }
  14554. func (c *HisApiController) ReversalOtherData() {
  14555. var customData []*CustomData
  14556. custom := &CustomData{
  14557. MsgId: "H44022900158202103301714472004",
  14558. PsnNo: "44020000001101329945",
  14559. Info: "2208",
  14560. }
  14561. customData = append(customData, custom)
  14562. custom1 := &CustomData{
  14563. MsgId: "H4402290015820210330172057803",
  14564. PsnNo: "44020000001101161813",
  14565. Info: "2208",
  14566. }
  14567. customData = append(customData, custom1)
  14568. custom2 := &CustomData{
  14569. MsgId: "H44022900158202103301705198813",
  14570. PsnNo: "44190000133097375417",
  14571. Info: "2208",
  14572. }
  14573. customData = append(customData, custom2)
  14574. custom3 := &CustomData{
  14575. MsgId: "H44022900158202103301715524756",
  14576. PsnNo: "44020000001100187221",
  14577. Info: "2208",
  14578. }
  14579. customData = append(customData, custom3)
  14580. custom4 := &CustomData{
  14581. MsgId: "H44022900158202103301730376224",
  14582. PsnNo: "44020000001101959155",
  14583. Info: "2208",
  14584. }
  14585. customData = append(customData, custom4)
  14586. custom5 := &CustomData{
  14587. MsgId: "H44022900158202103301748008725",
  14588. PsnNo: "44020000001104246641",
  14589. Info: "2208",
  14590. }
  14591. customData = append(customData, custom5)
  14592. custom6 := &CustomData{
  14593. MsgId: "H44022900158202103301718096755",
  14594. PsnNo: "44020000001102211860",
  14595. Info: "2208",
  14596. }
  14597. customData = append(customData, custom6)
  14598. custom7 := &CustomData{
  14599. MsgId: "H44022900158202103301736551640",
  14600. PsnNo: "44020000001102687718",
  14601. Info: "2208",
  14602. }
  14603. customData = append(customData, custom7)
  14604. custom8 := &CustomData{
  14605. MsgId: "H44022900158202103301743097676",
  14606. PsnNo: "44020000001102127785",
  14607. Info: "2208",
  14608. }
  14609. customData = append(customData, custom8)
  14610. custom9 := &CustomData{
  14611. MsgId: "H44022900158202103301712304203",
  14612. PsnNo: "44020000001101518097",
  14613. Info: "2208",
  14614. }
  14615. customData = append(customData, custom9)
  14616. custom10 := &CustomData{
  14617. MsgId: "H44022900158202103301738448785",
  14618. PsnNo: "44020000001100500813",
  14619. Info: "2208",
  14620. }
  14621. customData = append(customData, custom10)
  14622. custom11 := &CustomData{
  14623. MsgId: "H44022900158202103301732455843",
  14624. PsnNo: "44020000001102690557",
  14625. Info: "2208",
  14626. }
  14627. customData = append(customData, custom11)
  14628. custom12 := &CustomData{
  14629. MsgId: "H44022900158202103301745421708",
  14630. PsnNo: "44020000001102211928",
  14631. Info: "2208",
  14632. }
  14633. customData = append(customData, custom12)
  14634. custom1212 := &CustomData{
  14635. MsgId: "H440229001582021033017351627",
  14636. PsnNo: "44020000001102481733",
  14637. Info: "2208",
  14638. }
  14639. customData = append(customData, custom1212)
  14640. custom13 := &CustomData{
  14641. MsgId: "H44022900158202103301740327951",
  14642. PsnNo: "44020000001103174866",
  14643. Info: "2208",
  14644. }
  14645. customData = append(customData, custom13)
  14646. custom14 := &CustomData{
  14647. MsgId: "H4402290015820210330174922668",
  14648. PsnNo: "44020000001102927272",
  14649. Info: "2208",
  14650. }
  14651. customData = append(customData, custom14)
  14652. custom15 := &CustomData{
  14653. MsgId: "H44022900158202103301752362273",
  14654. PsnNo: "44020000001102942890",
  14655. Info: "2208",
  14656. }
  14657. customData = append(customData, custom15)
  14658. custom16 := &CustomData{
  14659. MsgId: "H44022900158202103301751082917",
  14660. PsnNo: "44020000001101662162",
  14661. Info: "2208",
  14662. }
  14663. customData = append(customData, custom16)
  14664. custom17 := &CustomData{
  14665. MsgId: "H44022900158202103301754147728",
  14666. PsnNo: "44020000000229014511",
  14667. Info: "2208",
  14668. }
  14669. customData = append(customData, custom17)
  14670. adminUser := c.GetAdminUserInfo()
  14671. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14672. for _, item := range customData {
  14673. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14674. fmt.Println(result)
  14675. }
  14676. }
  14677. func PathExists(path string) (bool, error) {
  14678. _, err := os.Stat(path)
  14679. if err == nil {
  14680. return true, nil
  14681. }
  14682. if os.IsNotExist(err) {
  14683. return false, nil
  14684. }
  14685. return false, err
  14686. }
  14687. // 创建文件夹
  14688. func Mkdir(dir string) {
  14689. // 创建文件夹
  14690. exist, err := PathExists(dir)
  14691. if err != nil {
  14692. fmt.Println(err.Error())
  14693. } else {
  14694. if exist {
  14695. fmt.Println(dir + "文件夹已存在!")
  14696. } else {
  14697. // 文件夹名称,权限
  14698. err := os.Mkdir(dir, os.ModePerm)
  14699. if err != nil {
  14700. fmt.Println(dir+"文件夹创建失败:", err.Error())
  14701. } else {
  14702. fmt.Println(dir + "文件夹创建成功!")
  14703. }
  14704. }
  14705. }
  14706. }
  14707. // 压缩文件
  14708. func Zip(srcFile string, destZip string) error {
  14709. zipfile, err := os.Create(destZip)
  14710. if err != nil {
  14711. return err
  14712. }
  14713. defer zipfile.Close()
  14714. archive := zip.NewWriter(zipfile)
  14715. defer archive.Close()
  14716. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  14717. if err != nil {
  14718. return err
  14719. }
  14720. header, err := zip.FileInfoHeader(info)
  14721. if err != nil {
  14722. return err
  14723. }
  14724. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  14725. // header.Name = path
  14726. if info.IsDir() {
  14727. header.Name += "/"
  14728. } else {
  14729. header.Method = zip.Deflate
  14730. }
  14731. writer, err := archive.CreateHeader(header)
  14732. if err != nil {
  14733. return err
  14734. }
  14735. if !info.IsDir() {
  14736. file, err := os.Open(path)
  14737. if err != nil {
  14738. return err
  14739. }
  14740. defer file.Close()
  14741. _, err = io.Copy(writer, file)
  14742. }
  14743. return err
  14744. })
  14745. return err
  14746. }
  14747. func ReadFile(filePath string) []byte {
  14748. f, err := os.Open(filePath)
  14749. if err != nil {
  14750. fmt.Println("read file fail", err)
  14751. return nil
  14752. }
  14753. defer f.Close()
  14754. fd, err := ioutil.ReadAll(f)
  14755. if err != nil {
  14756. fmt.Println("read to fd fail", err)
  14757. return nil
  14758. }
  14759. return fd
  14760. }
  14761. func saveLog(result string, request string, infno string, desc string) {
  14762. org_id, _ := beego.AppConfig.Int64("org_id")
  14763. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14764. dir := miConfig.OrgName + "日志"
  14765. utils.Mkdir(dir)
  14766. month := time.Unix(1557042972, 0).Format("1")
  14767. year := time.Now().Format("2006")
  14768. month = time.Now().Format("01")
  14769. day := time.Now().Format("02")
  14770. hour := time.Now().Format("15")
  14771. min := time.Now().Format("04")
  14772. sec := time.Now().Format("05")
  14773. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  14774. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  14775. file_name := file + ".txt"
  14776. file_path := miConfig.OrgName + "日志" + "/" + file_name
  14777. exist, _ := utils.PathExists(file_path)
  14778. if exist { //存在
  14779. fmt.Println("存在")
  14780. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  14781. if err != nil {
  14782. fmt.Println("read fail")
  14783. }
  14784. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  14785. n, _ := f.Seek(0, 2)
  14786. _, err = f.WriteAt([]byte(content), n)
  14787. } else { //不存在
  14788. fmt.Println("文件不存在,创建文件")
  14789. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  14790. defer f.Close()
  14791. if err != nil {
  14792. } else {
  14793. _, err = f.Write([]byte("记录日志"))
  14794. }
  14795. }
  14796. }
  14797. type Charset string
  14798. const (
  14799. UTF8 = Charset("UTF-8")
  14800. GB18030 = Charset("GB18030")
  14801. )
  14802. func ConvertToString(src string, srcCode string, tagCode string) string {
  14803. srcCoder := mahonia.NewDecoder(srcCode)
  14804. srcResult := srcCoder.ConvertString(src)
  14805. tagCoder := mahonia.NewDecoder(tagCode)
  14806. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  14807. result := string(cdata)
  14808. return result
  14809. }
  14810. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  14811. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  14812. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14813. var token string
  14814. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14815. var api string
  14816. if miConfig.MdtrtareaAdmvs == "320921" {
  14817. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14818. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  14819. fmt.Println(api)
  14820. } else {
  14821. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14822. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  14823. }
  14824. resp, requestErr := http.Get(api)
  14825. if requestErr != nil {
  14826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14827. return ""
  14828. }
  14829. body, ioErr := ioutil.ReadAll(resp.Body)
  14830. if ioErr != nil {
  14831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14833. return ""
  14834. }
  14835. var respJSON map[string]interface{}
  14836. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14839. return ""
  14840. }
  14841. var status string
  14842. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14843. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14844. var res ResultTwo //1101结果
  14845. var res10265 ResultTwo10265 //1101结果
  14846. if status == "0" { //读卡成功
  14847. var card_info string //卡信息
  14848. var busi_card_info string
  14849. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14850. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14851. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14852. fmt.Println(card_info)
  14853. fmt.Println(busi_card_info)
  14854. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14855. result, _ := json.Marshal(respJSON)
  14856. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14857. utils.ErrorLog("解析失败:%v", err)
  14858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14859. return ""
  14860. }
  14861. res.ErrMsg = res10265.ErrMsg
  14862. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14863. res.Infcode = infocode
  14864. res.Output = res10265.Output
  14865. res.InfRefmsgid = res10265.InfRefmsgid
  14866. if res.Infcode == 0 {
  14867. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14868. if err == gorm.ErrRecordNotFound {
  14869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14870. return ""
  14871. } else if err != nil {
  14872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14873. return ""
  14874. } else {
  14875. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14876. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14877. infoStr := string(Iinfos)
  14878. idetinfoStr := string(Idetinfos)
  14879. psn := &models.HisPsn{
  14880. PsnNo: res.Output.Baseinfo.PsnNo,
  14881. Age: res.Output.Baseinfo.Age,
  14882. PatientId: patient.ID,
  14883. Certno: res.Output.Baseinfo.Certno,
  14884. Brdy: res.Output.Baseinfo.Brdy,
  14885. Gend: res.Output.Baseinfo.Gend,
  14886. Naty: res.Output.Baseinfo.Naty,
  14887. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14888. PsnName: res.Output.Baseinfo.PsnName,
  14889. Idetinfo: idetinfoStr,
  14890. Insuinfo: infoStr,
  14891. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14892. CardInfo: card_info,
  14893. VerifyNumber: token,
  14894. }
  14895. service.CreateHisPsn(psn)
  14896. return token
  14897. }
  14898. }
  14899. } else {
  14900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14901. return ""
  14902. }
  14903. } else { //读卡失败
  14904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14905. return ""
  14906. }
  14907. return token
  14908. }
  14909. func DeleteExtraSpaceTwo(s string) string {
  14910. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14911. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14912. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14913. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14914. s2 := make([]byte, len(s1)) //定义字符数组切片
  14915. copy(s2, s1) //将字符串复制到切片
  14916. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14917. for len(spc_index) > 0 { //找到适配项
  14918. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14919. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14920. }
  14921. return string(s2)
  14922. }
  14923. func Remove0000(s string) string {
  14924. str := make([]rune, 0, len(s))
  14925. for _, v := range []rune(s) {
  14926. if v == 0 {
  14927. continue
  14928. }
  14929. str = append(str, v)
  14930. }
  14931. return string(str)
  14932. }
  14933. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  14934. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  14935. readCard := DllDef.MustFindProc("EcQuery")
  14936. pCardInfo := make([]byte, 8192)
  14937. pBusiCardInfo := make([]byte, 8192)
  14938. data := make(map[string]interface{})
  14939. //pData := make(map[string]interface{})
  14940. inputData := make(map[string]interface{})
  14941. inputData["orgId"] = code
  14942. inputData["businessType"] = "01101"
  14943. inputData["operatorId"] = operator_id
  14944. inputData["operatorName"] = operator_name
  14945. inputData["officeId"] = "001"
  14946. inputData["officeName"] = "血透室"
  14947. //
  14948. data["data"] = inputData
  14949. data["transType"] = "ec.query"
  14950. data["orgId"] = code
  14951. bytesData, _ := json.Marshal(data)
  14952. pCardInfo = bytesData
  14953. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14954. fmt.Println(ret2)
  14955. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  14956. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14957. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  14958. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14959. if ret2 != 0 {
  14960. return "", ""
  14961. }
  14962. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  14963. }
  14964. func DeleteExtraSpace(s string) string {
  14965. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14966. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14967. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14968. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14969. s2 := make([]byte, len(s1)) //定义字符数组切片
  14970. copy(s2, s1) //将字符串复制到切片
  14971. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14972. for len(spc_index) > 0 { //找到适配项
  14973. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14974. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14975. }
  14976. return string(s2)
  14977. }
  14978. // 对账
  14979. func (c *HisApiController) Post3202() {
  14980. start_time := c.GetString("start_time")
  14981. end_time := c.GetString("end_time")
  14982. //insutype := c.GetString("insutype")
  14983. clr_type := c.GetString("clr_type")
  14984. clr_org := c.GetString("clr_optins")
  14985. admin_user_id, _ := c.GetInt64("admin_user_id")
  14986. adminUser := c.GetAdminUserInfo()
  14987. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14988. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14989. if len(clr_org) == 0 {
  14990. clr_org = miConfig.MdtrtareaAdmvs
  14991. }
  14992. timeLayout := "2006-01-02"
  14993. loc, _ := time.LoadLocation("Local")
  14994. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14995. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14996. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14997. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14998. //fixmedins_setl_cnt := int64(len(orders))
  14999. var medfee_sumamt float64
  15000. var acct_pay float64
  15001. var fund_pay_sumamt float64
  15002. for _, item := range orders {
  15003. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  15004. acct_pay = acct_pay + item.AcctPay
  15005. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  15006. }
  15007. //var medfee_sumamt_two float64
  15008. //var acct_pay_two float64
  15009. //var fund_pay_sumamt_two float64
  15010. //for _, item := range orders_two {
  15011. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  15012. // acct_pay_two = acct_pay_two + item.AcctPay
  15013. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  15014. //}
  15015. //var user_name string
  15016. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15017. //if role.ID == 0 {
  15018. // user_name = "xxx"
  15019. //} else {
  15020. // user_name = role.UserName
  15021. //}
  15022. var res ResultSix
  15023. if config.IsOpen == 1 {
  15024. var bps []*models.BusinessParamsTwo
  15025. var bp models.BusinessParamsTwo
  15026. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  15027. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  15028. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  15029. bp.MedfeeSumamt = medfee_sumamt_str
  15030. bp.AcctPay = acct_pay_str
  15031. bp.FundPaySumamt = fund_pay_sumamt_str
  15032. bp.Insutype = "390"
  15033. bp.StmtBegndate = start_time
  15034. bp.ClrType = clr_type
  15035. bp.SetlOptins = clr_org
  15036. bp.StmtEnddate = end_time
  15037. bps = append(bps, &bp)
  15038. data := make(map[string]interface{})
  15039. data["bps"] = bps
  15040. data["org_name"] = miConfig.OrgName
  15041. data["doctor"] = role.UserName
  15042. data["fixmedins_code"] = miConfig.Code
  15043. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15044. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15045. if miConfig.MdtrtareaAdmvs == "421300" {
  15046. client := &http.Client{}
  15047. bytesData, _ := json.Marshal(data)
  15048. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  15049. resp, _ := client.Do(req)
  15050. defer resp.Body.Close()
  15051. body, ioErr := ioutil.ReadAll(resp.Body)
  15052. if ioErr != nil {
  15053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15055. return
  15056. }
  15057. var respJSON map[string]interface{}
  15058. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15061. return
  15062. }
  15063. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15064. userJSONBytes, _ := json.Marshal(respJSON)
  15065. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15066. utils.ErrorLog("解析失败:%v", err)
  15067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15068. return
  15069. }
  15070. }
  15071. if res.Infcode == 0 {
  15072. c.ServeSuccessJSON(map[string]interface{}{
  15073. "msg": "发起成功",
  15074. })
  15075. } else {
  15076. c.ServeSuccessJSON(map[string]interface{}{
  15077. "code": -10,
  15078. "msg": res.ErrMsg,
  15079. })
  15080. }
  15081. }
  15082. }
  15083. func (c *HisApiController) Post3501() {
  15084. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15085. data := make(map[string]interface{})
  15086. var struct3501s []models.Struct3501
  15087. var struct3501 models.Struct3501
  15088. struct3501.OrgName = miConfig.OrgName
  15089. struct3501.AccessKey = miConfig.AccessKey
  15090. struct3501.RequestUrl = miConfig.Url
  15091. struct3501.SecretKey = miConfig.SecretKey
  15092. struct3501.ManuDate = "2022-08-17"
  15093. struct3501.FixmedinsBchno = ""
  15094. struct3501.ManuLotnum = ""
  15095. struct3501.RxFlag = "0"
  15096. struct3501.ExpyEnd = "2022-08-17"
  15097. struct3501.Invdate = "2022-08-17"
  15098. struct3501.InvCnt = "20.25"
  15099. struct3501.Memo = ""
  15100. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15101. struct3501.FixmedinsHilistId = miConfig.Code
  15102. struct3501.FixmedinsHilistName = miConfig.OrgName
  15103. struct3501s = append(struct3501s, struct3501)
  15104. data["struct_3501s"] = struct3501s
  15105. client := &http.Client{}
  15106. bytesData, _ := json.Marshal(data)
  15107. var req *http.Request
  15108. if miConfig.MdtrtareaAdmvs == "320921" {
  15109. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15110. } else {
  15111. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15112. }
  15113. resp, _ := client.Do(req)
  15114. defer resp.Body.Close()
  15115. body, ioErr := ioutil.ReadAll(resp.Body)
  15116. if ioErr != nil {
  15117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15119. return
  15120. }
  15121. var respJSON map[string]interface{}
  15122. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15125. return
  15126. }
  15127. var res ResultSix
  15128. var resSix10265 ResultSix10265 //1101结果
  15129. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15130. result, _ := json.Marshal(respJSON)
  15131. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15132. utils.ErrorLog("解析失败:%v", err)
  15133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15134. return
  15135. }
  15136. res.InfRefmsgid = resSix10265.InfRefmsgid
  15137. res.Output = resSix10265.Output
  15138. res.ErrMsg = resSix10265.ErrMsg
  15139. res.Cainfo = resSix10265.Cainfo
  15140. res.WarnMsg = resSix10265.WarnMsg
  15141. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15142. res.Infcode = infocode
  15143. if infocode == 0 {
  15144. c.ServeSuccessJSON(map[string]interface{}{
  15145. "msg": "上传成功",
  15146. })
  15147. return
  15148. } else {
  15149. c.ServeSuccessJSON(map[string]interface{}{
  15150. "failed_code": -10,
  15151. "msg": res.ErrMsg,
  15152. })
  15153. return
  15154. }
  15155. }
  15156. func (c *HisApiController) Post3502() {
  15157. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15158. data := make(map[string]interface{})
  15159. var struct3502s []models.Struct3502
  15160. var struct3502 models.Struct3502
  15161. struct3502.OrgName = miConfig.OrgName
  15162. struct3502.AccessKey = miConfig.AccessKey
  15163. struct3502.RequestUrl = miConfig.Url
  15164. struct3502.SecretKey = miConfig.SecretKey
  15165. struct3502.ManuDate = "2022-08-15"
  15166. struct3502.FixmedinsBchno = ""
  15167. struct3502.ManuLotnum = ""
  15168. struct3502.RxFlag = "0"
  15169. struct3502.ExpyEnd = "2022-08-15"
  15170. struct3502.Invdate = "2022-08-15"
  15171. struct3502.InvCnt = "20.25"
  15172. struct3502.Memo = ""
  15173. struct3502.MedListCodg = "XB01ABD056B002020200517"
  15174. struct3502.FixmedinsHilistId = miConfig.Code
  15175. struct3502.FixmedinsHilistName = miConfig.OrgName
  15176. struct3502s = append(struct3502s, struct3502)
  15177. data["struct_3502s"] = struct3502s
  15178. client := &http.Client{}
  15179. bytesData, _ := json.Marshal(data)
  15180. var req *http.Request
  15181. if miConfig.MdtrtareaAdmvs == "320921" {
  15182. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15183. } else {
  15184. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15185. }
  15186. resp, _ := client.Do(req)
  15187. defer resp.Body.Close()
  15188. body, ioErr := ioutil.ReadAll(resp.Body)
  15189. if ioErr != nil {
  15190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15192. return
  15193. }
  15194. var respJSON map[string]interface{}
  15195. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15198. return
  15199. }
  15200. var res ResultSix
  15201. var resSix10265 ResultSix10265 //1101结果
  15202. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15203. result, _ := json.Marshal(respJSON)
  15204. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15205. utils.ErrorLog("解析失败:%v", err)
  15206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15207. return
  15208. }
  15209. res.InfRefmsgid = resSix10265.InfRefmsgid
  15210. res.Output = resSix10265.Output
  15211. res.ErrMsg = resSix10265.ErrMsg
  15212. res.Cainfo = resSix10265.Cainfo
  15213. res.WarnMsg = resSix10265.WarnMsg
  15214. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15215. res.Infcode = infocode
  15216. if infocode == 0 {
  15217. c.ServeSuccessJSON(map[string]interface{}{
  15218. "msg": "上传成功",
  15219. })
  15220. return
  15221. } else {
  15222. c.ServeSuccessJSON(map[string]interface{}{
  15223. "failed_code": -10,
  15224. "msg": res.ErrMsg,
  15225. })
  15226. return
  15227. }
  15228. }
  15229. func (c *HisApiController) Post3503() {
  15230. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15231. data := make(map[string]interface{})
  15232. var struct3501s []models.Struct3501
  15233. var struct3501 models.Struct3501
  15234. struct3501.OrgName = miConfig.OrgName
  15235. struct3501.AccessKey = miConfig.AccessKey
  15236. struct3501.RequestUrl = miConfig.Url
  15237. struct3501.SecretKey = miConfig.SecretKey
  15238. struct3501.ManuDate = "2022-08-15"
  15239. struct3501.FixmedinsBchno = ""
  15240. struct3501.ManuLotnum = ""
  15241. struct3501.RxFlag = "0"
  15242. struct3501.ExpyEnd = "2022-08-15"
  15243. struct3501.Invdate = "2022-08-15"
  15244. struct3501.InvCnt = "20.25"
  15245. struct3501.Memo = ""
  15246. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15247. struct3501.FixmedinsHilistId = miConfig.Code
  15248. struct3501.FixmedinsHilistName = miConfig.OrgName
  15249. struct3501s = append(struct3501s, struct3501)
  15250. data["struct_3501s"] = struct3501s
  15251. client := &http.Client{}
  15252. bytesData, _ := json.Marshal(data)
  15253. var req *http.Request
  15254. if miConfig.MdtrtareaAdmvs == "320921" {
  15255. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15256. } else {
  15257. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15258. }
  15259. resp, _ := client.Do(req)
  15260. defer resp.Body.Close()
  15261. body, ioErr := ioutil.ReadAll(resp.Body)
  15262. if ioErr != nil {
  15263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15265. return
  15266. }
  15267. var respJSON map[string]interface{}
  15268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15271. return
  15272. }
  15273. var res ResultSix
  15274. var resSix10265 ResultSix10265 //1101结果
  15275. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15276. result, _ := json.Marshal(respJSON)
  15277. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15278. utils.ErrorLog("解析失败:%v", err)
  15279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15280. return
  15281. }
  15282. res.InfRefmsgid = resSix10265.InfRefmsgid
  15283. res.Output = resSix10265.Output
  15284. res.ErrMsg = resSix10265.ErrMsg
  15285. res.Cainfo = resSix10265.Cainfo
  15286. res.WarnMsg = resSix10265.WarnMsg
  15287. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15288. res.Infcode = infocode
  15289. if infocode == 0 {
  15290. c.ServeSuccessJSON(map[string]interface{}{
  15291. "msg": "上传成功",
  15292. })
  15293. return
  15294. } else {
  15295. c.ServeSuccessJSON(map[string]interface{}{
  15296. "failed_code": -10,
  15297. "msg": res.ErrMsg,
  15298. })
  15299. return
  15300. }
  15301. }
  15302. func (c *HisApiController) Post3504() {
  15303. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15304. data := make(map[string]interface{})
  15305. var struct3501s []models.Struct3501
  15306. var struct3501 models.Struct3501
  15307. struct3501.OrgName = miConfig.OrgName
  15308. struct3501.AccessKey = miConfig.AccessKey
  15309. struct3501.RequestUrl = miConfig.Url
  15310. struct3501.SecretKey = miConfig.SecretKey
  15311. struct3501.ManuDate = "2022-08-15"
  15312. struct3501.FixmedinsBchno = ""
  15313. struct3501.ManuLotnum = ""
  15314. struct3501.RxFlag = "0"
  15315. struct3501.ExpyEnd = "2022-08-15"
  15316. struct3501.Invdate = "2022-08-15"
  15317. struct3501.InvCnt = "20.25"
  15318. struct3501.Memo = ""
  15319. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15320. struct3501.FixmedinsHilistId = miConfig.Code
  15321. struct3501.FixmedinsHilistName = miConfig.OrgName
  15322. struct3501s = append(struct3501s, struct3501)
  15323. data["struct_3501s"] = struct3501s
  15324. client := &http.Client{}
  15325. bytesData, _ := json.Marshal(data)
  15326. var req *http.Request
  15327. if miConfig.MdtrtareaAdmvs == "320921" {
  15328. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15329. } else {
  15330. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15331. }
  15332. resp, _ := client.Do(req)
  15333. defer resp.Body.Close()
  15334. body, ioErr := ioutil.ReadAll(resp.Body)
  15335. if ioErr != nil {
  15336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15338. return
  15339. }
  15340. var respJSON map[string]interface{}
  15341. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15344. return
  15345. }
  15346. var res ResultSix
  15347. var resSix10265 ResultSix10265 //1101结果
  15348. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15349. result, _ := json.Marshal(respJSON)
  15350. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15351. utils.ErrorLog("解析失败:%v", err)
  15352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15353. return
  15354. }
  15355. res.InfRefmsgid = resSix10265.InfRefmsgid
  15356. res.Output = resSix10265.Output
  15357. res.ErrMsg = resSix10265.ErrMsg
  15358. res.Cainfo = resSix10265.Cainfo
  15359. res.WarnMsg = resSix10265.WarnMsg
  15360. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15361. res.Infcode = infocode
  15362. if infocode == 0 {
  15363. c.ServeSuccessJSON(map[string]interface{}{
  15364. "msg": "上传成功",
  15365. })
  15366. return
  15367. } else {
  15368. c.ServeSuccessJSON(map[string]interface{}{
  15369. "failed_code": -10,
  15370. "msg": res.ErrMsg,
  15371. })
  15372. return
  15373. }
  15374. }
  15375. func (c *HisApiController) Post3505() {
  15376. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15377. data := make(map[string]interface{})
  15378. var struct3501s []models.Struct3501
  15379. var struct3501 models.Struct3501
  15380. struct3501.OrgName = miConfig.OrgName
  15381. struct3501.AccessKey = miConfig.AccessKey
  15382. struct3501.RequestUrl = miConfig.Url
  15383. struct3501.SecretKey = miConfig.SecretKey
  15384. struct3501.ManuDate = "2022-08-15"
  15385. struct3501.FixmedinsBchno = ""
  15386. struct3501.ManuLotnum = ""
  15387. struct3501.RxFlag = "0"
  15388. struct3501.ExpyEnd = "2022-08-15"
  15389. struct3501.Invdate = "2022-08-15"
  15390. struct3501.InvCnt = "20.25"
  15391. struct3501.Memo = ""
  15392. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15393. struct3501.FixmedinsHilistId = miConfig.Code
  15394. struct3501.FixmedinsHilistName = miConfig.OrgName
  15395. struct3501s = append(struct3501s, struct3501)
  15396. data["struct_3501s"] = struct3501s
  15397. client := &http.Client{}
  15398. bytesData, _ := json.Marshal(data)
  15399. var req *http.Request
  15400. if miConfig.MdtrtareaAdmvs == "320921" {
  15401. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15402. } else {
  15403. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15404. }
  15405. resp, _ := client.Do(req)
  15406. defer resp.Body.Close()
  15407. body, ioErr := ioutil.ReadAll(resp.Body)
  15408. if ioErr != nil {
  15409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15411. return
  15412. }
  15413. var respJSON map[string]interface{}
  15414. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15417. return
  15418. }
  15419. var res ResultSix
  15420. var resSix10265 ResultSix10265 //1101结果
  15421. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15422. result, _ := json.Marshal(respJSON)
  15423. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15424. utils.ErrorLog("解析失败:%v", err)
  15425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15426. return
  15427. }
  15428. res.InfRefmsgid = resSix10265.InfRefmsgid
  15429. res.Output = resSix10265.Output
  15430. res.ErrMsg = resSix10265.ErrMsg
  15431. res.Cainfo = resSix10265.Cainfo
  15432. res.WarnMsg = resSix10265.WarnMsg
  15433. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15434. res.Infcode = infocode
  15435. if infocode == 0 {
  15436. c.ServeSuccessJSON(map[string]interface{}{
  15437. "msg": "上传成功",
  15438. })
  15439. return
  15440. } else {
  15441. c.ServeSuccessJSON(map[string]interface{}{
  15442. "failed_code": -10,
  15443. "msg": res.ErrMsg,
  15444. })
  15445. return
  15446. }
  15447. }
  15448. func (c *HisApiController) Post3506() {
  15449. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15450. data := make(map[string]interface{})
  15451. var struct3501s []models.Struct3501
  15452. var struct3501 models.Struct3501
  15453. struct3501.OrgName = miConfig.OrgName
  15454. struct3501.AccessKey = miConfig.AccessKey
  15455. struct3501.RequestUrl = miConfig.Url
  15456. struct3501.SecretKey = miConfig.SecretKey
  15457. struct3501.ManuDate = "2022-08-15"
  15458. struct3501.FixmedinsBchno = ""
  15459. struct3501.ManuLotnum = ""
  15460. struct3501.RxFlag = "0"
  15461. struct3501.ExpyEnd = "2022-08-15"
  15462. struct3501.Invdate = "2022-08-15"
  15463. struct3501.InvCnt = "20.25"
  15464. struct3501.Memo = ""
  15465. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15466. struct3501.FixmedinsHilistId = miConfig.Code
  15467. struct3501.FixmedinsHilistName = miConfig.OrgName
  15468. struct3501s = append(struct3501s, struct3501)
  15469. data["struct_3501s"] = struct3501s
  15470. client := &http.Client{}
  15471. bytesData, _ := json.Marshal(data)
  15472. var req *http.Request
  15473. if miConfig.MdtrtareaAdmvs == "320921" {
  15474. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15475. } else {
  15476. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15477. }
  15478. resp, _ := client.Do(req)
  15479. defer resp.Body.Close()
  15480. body, ioErr := ioutil.ReadAll(resp.Body)
  15481. if ioErr != nil {
  15482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15484. return
  15485. }
  15486. var respJSON map[string]interface{}
  15487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15490. return
  15491. }
  15492. var res ResultSix
  15493. var resSix10265 ResultSix10265 //1101结果
  15494. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15495. result, _ := json.Marshal(respJSON)
  15496. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15497. utils.ErrorLog("解析失败:%v", err)
  15498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15499. return
  15500. }
  15501. res.InfRefmsgid = resSix10265.InfRefmsgid
  15502. res.Output = resSix10265.Output
  15503. res.ErrMsg = resSix10265.ErrMsg
  15504. res.Cainfo = resSix10265.Cainfo
  15505. res.WarnMsg = resSix10265.WarnMsg
  15506. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15507. res.Infcode = infocode
  15508. if infocode == 0 {
  15509. c.ServeSuccessJSON(map[string]interface{}{
  15510. "msg": "上传成功",
  15511. })
  15512. return
  15513. } else {
  15514. c.ServeSuccessJSON(map[string]interface{}{
  15515. "failed_code": -10,
  15516. "msg": res.ErrMsg,
  15517. })
  15518. return
  15519. }
  15520. }
  15521. func (c *HisApiController) Post3507() {
  15522. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15523. data := make(map[string]interface{})
  15524. var struct3501s []models.Struct3501
  15525. var struct3501 models.Struct3501
  15526. struct3501.OrgName = miConfig.OrgName
  15527. struct3501.AccessKey = miConfig.AccessKey
  15528. struct3501.RequestUrl = miConfig.Url
  15529. struct3501.SecretKey = miConfig.SecretKey
  15530. struct3501.ManuDate = "2022-08-15"
  15531. struct3501.FixmedinsBchno = ""
  15532. struct3501.ManuLotnum = ""
  15533. struct3501.RxFlag = "0"
  15534. struct3501.ExpyEnd = "2022-08-15"
  15535. struct3501.Invdate = "2022-08-15"
  15536. struct3501.InvCnt = "20.25"
  15537. struct3501.Memo = ""
  15538. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15539. struct3501.FixmedinsHilistId = miConfig.Code
  15540. struct3501.FixmedinsHilistName = miConfig.OrgName
  15541. struct3501s = append(struct3501s, struct3501)
  15542. data["struct_3501s"] = struct3501s
  15543. client := &http.Client{}
  15544. bytesData, _ := json.Marshal(data)
  15545. var req *http.Request
  15546. if miConfig.MdtrtareaAdmvs == "320921" {
  15547. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15548. } else {
  15549. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15550. }
  15551. resp, _ := client.Do(req)
  15552. defer resp.Body.Close()
  15553. body, ioErr := ioutil.ReadAll(resp.Body)
  15554. if ioErr != nil {
  15555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15557. return
  15558. }
  15559. var respJSON map[string]interface{}
  15560. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15563. return
  15564. }
  15565. var res ResultSix
  15566. var resSix10265 ResultSix10265 //1101结果
  15567. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15568. result, _ := json.Marshal(respJSON)
  15569. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15570. utils.ErrorLog("解析失败:%v", err)
  15571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15572. return
  15573. }
  15574. res.InfRefmsgid = resSix10265.InfRefmsgid
  15575. res.Output = resSix10265.Output
  15576. res.ErrMsg = resSix10265.ErrMsg
  15577. res.Cainfo = resSix10265.Cainfo
  15578. res.WarnMsg = resSix10265.WarnMsg
  15579. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15580. res.Infcode = infocode
  15581. if infocode == 0 {
  15582. c.ServeSuccessJSON(map[string]interface{}{
  15583. "msg": "上传成功",
  15584. })
  15585. return
  15586. } else {
  15587. c.ServeSuccessJSON(map[string]interface{}{
  15588. "failed_code": -10,
  15589. "msg": res.ErrMsg,
  15590. })
  15591. return
  15592. }
  15593. }