his_api_controller.go 601KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614
  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. //
  90. }
  91. func (c *HisApiController) Get2505() {
  92. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  93. 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")
  94. }
  95. func (c *HisApiController) Get4201A() {
  96. order_id, _ := c.GetInt64("order_id")
  97. order_id = 172977
  98. admin_user_id, _ := c.GetInt64("admin_user_id")
  99. admin_user_id = 3432
  100. order, _ := service.GetHisOrderByIDTwo(order_id)
  101. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  102. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  103. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  104. //order_info = append(order_info, order_info_two...)
  105. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  106. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  107. department, _ := service.GetDepartMentDetail(his.Departments)
  108. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  109. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  110. if order.ID == 0 {
  111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  112. return
  113. }
  114. var struct4201A models.Struct4201A
  115. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  116. for _, items := range order_info {
  117. memo := make(map[string]interface{})
  118. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  119. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  120. fsiOPFLD.MedType = "14"
  121. fsiOPFLD.BkkpSn = items.OrderNumber
  122. fsiOPFLD.FixmedinsCode = miConfig.Code
  123. fsiOPFLD.FixmedinsName = miConfig.OrgName
  124. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  125. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  126. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  127. if items.AdviceId > 0 && items.ProjectId == 0 {
  128. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  129. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  130. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  131. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  132. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  133. fsiOPFLD.BilgDeptName = department.Name
  134. fsiOPFLD.BilgDeptCodg = department.Number
  135. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  136. fsiOPFLD.BilgDrName = doctor.UserName
  137. fsiOPFLD.MedChrgitmType = "09"
  138. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  139. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  140. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  141. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  142. fsiOPFLD.BilgDeptName = department.Name
  143. fsiOPFLD.BilgDeptCodg = department.Number
  144. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  145. fsiOPFLD.BilgDrName = doctor.UserName
  146. if items.HisPrescriptionProject.Type == 2 {
  147. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  148. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  149. switch items.HisPrescriptionProject.HisProject.CostClassify {
  150. case 0:
  151. break
  152. case 1:
  153. fsiOPFLD.MedChrgitmType = "14"
  154. break
  155. case 2:
  156. fsiOPFLD.MedChrgitmType = "05"
  157. break
  158. case 3:
  159. fsiOPFLD.MedChrgitmType = "03"
  160. break
  161. case 4:
  162. fsiOPFLD.MedChrgitmType = "03"
  163. break
  164. case 5:
  165. fsiOPFLD.MedChrgitmType = "08"
  166. break
  167. case 6:
  168. fsiOPFLD.MedChrgitmType = "14"
  169. break
  170. case 7:
  171. fsiOPFLD.MedChrgitmType = "14"
  172. break
  173. case 8:
  174. fsiOPFLD.MedChrgitmType = "03"
  175. break
  176. case 9:
  177. fsiOPFLD.MedChrgitmType = "14"
  178. break
  179. case 10:
  180. fsiOPFLD.MedChrgitmType = "14"
  181. break
  182. case 11:
  183. fsiOPFLD.MedChrgitmType = "06"
  184. break
  185. case 12:
  186. fsiOPFLD.MedChrgitmType = "12"
  187. break
  188. case 13:
  189. fsiOPFLD.MedChrgitmType = "01"
  190. break
  191. case 14:
  192. fsiOPFLD.MedChrgitmType = "04"
  193. break
  194. case 15:
  195. fsiOPFLD.MedChrgitmType = "14"
  196. break
  197. }
  198. } else if items.HisPrescriptionProject.Type == 3 {
  199. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  200. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  201. fsiOPFLD.MedChrgitmType = "08"
  202. }
  203. }
  204. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.AdviceName
  205. fsiOPFLD.BilgDeptCodg = department.Number
  206. fsiOPFLD.BilgDeptName = department.Name
  207. memo["hosp_appr_flag"] = "1"
  208. memo["invoice_no"] = order.MdtrtId
  209. memo["memo"] = "自费"
  210. bytesData, _ := json.Marshal(memo)
  211. fsiOPFLD.Memo = string(bytesData)
  212. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  213. }
  214. for _, items := range order_info_two {
  215. memo := make(map[string]interface{})
  216. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  217. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  218. fsiOPFLD.MedType = "14"
  219. fsiOPFLD.BkkpSn = items.OrderNumber
  220. fsiOPFLD.FixmedinsCode = miConfig.Code
  221. fsiOPFLD.FixmedinsName = miConfig.OrgName
  222. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  223. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  224. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  225. if items.AdviceId > 0 && items.ProjectId == 0 {
  226. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  227. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  228. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  229. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  230. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  231. fsiOPFLD.BilgDeptName = department.Name
  232. fsiOPFLD.BilgDeptCodg = department.Number
  233. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  234. fsiOPFLD.BilgDrName = doctor.UserName
  235. fsiOPFLD.MedChrgitmType = "09"
  236. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  237. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  238. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  239. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  240. fsiOPFLD.BilgDeptName = department.Name
  241. fsiOPFLD.BilgDeptCodg = department.Number
  242. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  243. fsiOPFLD.BilgDrName = doctor.UserName
  244. if items.HisPrescriptionProject.Type == 2 {
  245. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  246. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  247. switch items.HisPrescriptionProject.HisProject.CostClassify {
  248. case 0:
  249. break
  250. case 1:
  251. fsiOPFLD.MedChrgitmType = "14"
  252. break
  253. case 2:
  254. fsiOPFLD.MedChrgitmType = "05"
  255. break
  256. case 3:
  257. fsiOPFLD.MedChrgitmType = "03"
  258. break
  259. case 4:
  260. fsiOPFLD.MedChrgitmType = "03"
  261. break
  262. case 5:
  263. fsiOPFLD.MedChrgitmType = "08"
  264. break
  265. case 6:
  266. fsiOPFLD.MedChrgitmType = "14"
  267. break
  268. case 7:
  269. fsiOPFLD.MedChrgitmType = "14"
  270. break
  271. case 8:
  272. fsiOPFLD.MedChrgitmType = "03"
  273. break
  274. case 9:
  275. fsiOPFLD.MedChrgitmType = "14"
  276. break
  277. case 10:
  278. fsiOPFLD.MedChrgitmType = "14"
  279. break
  280. case 11:
  281. fsiOPFLD.MedChrgitmType = "06"
  282. break
  283. case 12:
  284. fsiOPFLD.MedChrgitmType = "12"
  285. break
  286. case 13:
  287. fsiOPFLD.MedChrgitmType = "01"
  288. break
  289. case 14:
  290. fsiOPFLD.MedChrgitmType = "04"
  291. break
  292. case 15:
  293. fsiOPFLD.MedChrgitmType = "14"
  294. break
  295. }
  296. } else if items.HisPrescriptionProject.Type == 3 {
  297. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  298. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  299. fsiOPFLD.MedChrgitmType = "08"
  300. }
  301. }
  302. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.AdviceName
  303. fsiOPFLD.BilgDeptCodg = department.Number
  304. fsiOPFLD.BilgDeptName = department.Name
  305. memo["hosp_appr_flag"] = "1"
  306. memo["invoice_no"] = order.MdtrtId
  307. memo["memo"] = "自费"
  308. bytesData, _ := json.Marshal(memo)
  309. fsiOPFLD.Memo = string(bytesData)
  310. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  311. }
  312. fmt.Println(fsiOPFLDs)
  313. struct4201A.Fopfd = fsiOPFLDs
  314. fmt.Println(struct4201A.Fopfd)
  315. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  316. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  317. var res2 ResultSix
  318. var respJSON2 map[string]interface{}
  319. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  322. return
  323. }
  324. userJSONBytes2, _ := json.Marshal(respJSON2)
  325. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  326. utils.ErrorLog("解析失败:%v", err)
  327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  328. return
  329. }
  330. if res2.Infcode != 0 {
  331. c.ServeSuccessJSON(map[string]interface{}{
  332. "failed_code": -10,
  333. "msg": res2.ErrMsg,
  334. })
  335. return
  336. } else {
  337. c.ServeSuccessJSON(map[string]interface{}{
  338. "msg": "上传成功",
  339. })
  340. }
  341. }
  342. func (c *HisApiController) Get4202() {
  343. order_id, _ := c.GetInt64("order_id")
  344. order_id = 220548
  345. admin_user_id, _ := c.GetInt64("admin_user_id")
  346. admin_user_id = 3432
  347. order, _ := service.GetHisOrderByIDTwo(order_id)
  348. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  349. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  351. if order.ID == 0 {
  352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  353. return
  354. }
  355. var struct4202 models.Struct4202
  356. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  357. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  358. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  359. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  360. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  361. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  362. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  363. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  364. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  365. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  366. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  367. var config []*models.HisXtDiagnoseConfig
  368. for _, item := range diagnosis_ids {
  369. id, _ := strconv.ParseInt(item, 10, 64)
  370. diagnosisConfig, _ := service.FindDiagnoseById(id)
  371. config = append(config, &diagnosisConfig)
  372. }
  373. var tempDiaginfos []models.OwnPayPatnDiagListD
  374. for index, item := range config {
  375. if index == 0 {
  376. var tempDiaginfo models.OwnPayPatnDiagListD
  377. tempDiaginfo.InoutDiagType = "1"
  378. tempDiaginfo.DiagCode = item.CountryCode
  379. tempDiaginfo.DiagName = item.CountryContentName
  380. tempDiaginfo.DiagType = "1"
  381. tempDiaginfo.DiagSrtNo = "1"
  382. tempDiaginfo.MaindiagFlag = "1"
  383. tempDiaginfo.ValiFlag = "1"
  384. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  385. } else {
  386. var tempDiaginfo models.OwnPayPatnDiagListD
  387. tempDiaginfo.DiagCode = item.CountryCode
  388. tempDiaginfo.DiagName = item.CountryContentName
  389. tempDiaginfo.DiagType = "2"
  390. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  391. tempDiaginfo.MaindiagFlag = "0"
  392. tempDiaginfo.ValiFlag = "1"
  393. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  394. }
  395. }
  396. struct4202.ODiagListD = tempDiaginfos
  397. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  398. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  399. var res2 ResultSix
  400. var respJSON2 map[string]interface{}
  401. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  404. return
  405. }
  406. userJSONBytes2, _ := json.Marshal(respJSON2)
  407. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  408. utils.ErrorLog("解析失败:%v", err)
  409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  410. return
  411. }
  412. if res2.Infcode != 0 {
  413. c.ServeSuccessJSON(map[string]interface{}{
  414. "failed_code": -10,
  415. "msg": res2.ErrMsg,
  416. })
  417. return
  418. } else {
  419. c.ServeSuccessJSON(map[string]interface{}{
  420. "msg": "上传成功",
  421. })
  422. }
  423. }
  424. func (c *HisApiController) Get4203() {
  425. admin_user_id, _ := c.GetInt64("admin_user_id")
  426. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  427. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  428. order_id, _ := c.GetInt64("order_id")
  429. order_id = 220548
  430. admin_user_id = 3432
  431. order, _ := service.GetHisOrderByIDTwo(order_id)
  432. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  433. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, his.Number)
  434. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  435. var res2 ResultSix
  436. var respJSON2 map[string]interface{}
  437. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  440. return
  441. }
  442. userJSONBytes2, _ := json.Marshal(respJSON2)
  443. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  444. utils.ErrorLog("解析失败:%v", err)
  445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  446. return
  447. }
  448. if res2.Infcode != 0 {
  449. c.ServeSuccessJSON(map[string]interface{}{
  450. "failed_code": -10,
  451. "msg": res2.ErrMsg,
  452. })
  453. return
  454. } else {
  455. c.ServeSuccessJSON(map[string]interface{}{
  456. "msg": "上传成功",
  457. })
  458. }
  459. }
  460. //func (c *HisApiController) Get4205(){
  461. //
  462. //
  463. //}
  464. //func (c *HisApiController) Get4207(){
  465. //
  466. //
  467. //}
  468. //func (c *HisApiController) Get4208(){
  469. //
  470. //
  471. //}
  472. //func (c *HisApiController) Get4209(){
  473. //
  474. //
  475. //}
  476. type Result3101 struct {
  477. Infcode string `json:"infcode"`
  478. InfRefmsgid string `json:"inf_refmsgid"`
  479. RefmsgTime string `json:"refmsg_time"`
  480. RespondTime string `json:"respond_time"`
  481. Enctype string `json:"enctype"`
  482. Signtype string `json:"signtype"`
  483. ErrMsg string `json:"err_msg"`
  484. Output struct {
  485. Result []struct {
  486. JudgeResultDetailDtos []struct {
  487. VolaItemType string `json:"vola_item_type"`
  488. MdtrtID string `json:"mdtrt_id"`
  489. JrdID string `json:"jrd_id"`
  490. PatnID string `json:"patn_id"`
  491. RxID string `json:"rx_id"`
  492. VolaAmt interface{} `json:"vola_amt"`
  493. } `json:"judge_result_detail_dtos"`
  494. RuleID string `json:"rule_id"`
  495. VolaEvid string `json:"vola_evid"`
  496. MdtrtID string `json:"mdtrt_id"`
  497. RuleName string `json:"rule_name"`
  498. VolaAmtStas string `json:"vola_amt_stas"`
  499. JrID string `json:"jr_id"`
  500. PatnID string `json:"patn_id"`
  501. SevDeg string `json:"sev_deg"`
  502. VolaAmt float64 `json:"vola_amt"`
  503. VolaBhvrType string `json:"vola_bhvr_type"`
  504. VolaCont string `json:"vola_cont"`
  505. } `json:"result"`
  506. } `json:"output"`
  507. }
  508. func (c *HisApiController) ReadEleToken() {
  509. admin_user_id, _ := c.GetInt64("admin_user_id")
  510. his_patient_id, _ := c.GetInt64("his_patient_id")
  511. adminUser := c.GetAdminUserInfo()
  512. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  513. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  514. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  515. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  516. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  517. if len(tokens) > 0 {
  518. c.ServeSuccessJSON(map[string]interface{}{
  519. "msg": "读取成功",
  520. })
  521. } else {
  522. c.ServeSuccessJSON(map[string]interface{}{
  523. "failed_code": -10,
  524. "msg": "读取失败",
  525. })
  526. }
  527. } else if miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "441202" {
  528. if initFlag == 0 {
  529. c.TestGetBasBaseInit()
  530. }
  531. token := c.GetEleBaseInfo()
  532. token = Remove0000(token)
  533. if len(token) > 0 {
  534. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  535. saveLog(result2, requestLog2, "1101", "获取人员信息")
  536. var res ResultTwo
  537. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  538. utils.ErrorLog("解析失败:%v", err)
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  540. return
  541. }
  542. if res.Infcode == 0 {
  543. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  544. if err == gorm.ErrRecordNotFound {
  545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  546. return
  547. } else if err != nil {
  548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  549. return
  550. } else {
  551. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  552. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  553. infoStr := string(Iinfos)
  554. idetinfoStr := string(Idetinfos)
  555. psn := &models.HisPsn{
  556. PsnNo: res.Output.Baseinfo.PsnNo,
  557. Age: res.Output.Baseinfo.Age,
  558. PatientId: patient.ID,
  559. Certno: res.Output.Baseinfo.Certno,
  560. Brdy: res.Output.Baseinfo.Brdy,
  561. Gend: res.Output.Baseinfo.Gend,
  562. Naty: res.Output.Baseinfo.Naty,
  563. PsnCertType: res.Output.Baseinfo.PsnCertType,
  564. PsnName: res.Output.Baseinfo.PsnName,
  565. Idetinfo: idetinfoStr,
  566. Insuinfo: infoStr,
  567. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  568. CardInfo: "",
  569. VerifyNumber: token,
  570. }
  571. service.CreateHisPsn(psn)
  572. c.ServeSuccessJSON(map[string]interface{}{
  573. "msg": "读取成功",
  574. })
  575. }
  576. } else {
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  578. return
  579. }
  580. } else {
  581. c.ServeSuccessJSON(map[string]interface{}{
  582. "failed_code": -10,
  583. "msg": "读取失败",
  584. })
  585. }
  586. } else if miConfig.MdtrtareaAdmvs == "350500" {
  587. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  588. if len(errMsg) == 0 {
  589. type ELeData struct {
  590. Data struct {
  591. IdNo string `json:"idNo"`
  592. IdType string `json:"idType"`
  593. UserName string `json:"userName"`
  594. EcToken string `json:"ecToken"`
  595. InsuOrg string `json:"insuOrg"`
  596. Gender string `json:"gender"`
  597. Birthday string `json:"birthday"`
  598. Nationality string `json:"nationality"`
  599. Email string `json:"email"`
  600. Extra string `json:"extra"`
  601. } `json:"data"`
  602. Code int `json:"code"`
  603. Message string `json:"message"`
  604. }
  605. var ele ELeData
  606. err := json.Unmarshal([]byte(outPutInfo), &ele)
  607. if err != nil {
  608. utils.ErrorLog("解析失败:%v", err)
  609. }
  610. token := ele.Data.EcToken
  611. if len(token) > 0 {
  612. psn := &models.HisPsn{
  613. PsnNo: his.PsnNo,
  614. Age: 0,
  615. PatientId: his.PatientId,
  616. Certno: his.Certno,
  617. Brdy: his.Brdy,
  618. Gend: his.Gend,
  619. Naty: his.Naty,
  620. PsnCertType: his.PsnCertType,
  621. PsnName: his.PsnName,
  622. Idetinfo: his.Idetinfo,
  623. Insuinfo: his.Iinfo,
  624. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  625. CardInfo: outPutInfo,
  626. VerifyNumber: token,
  627. }
  628. service.CreateHisPsn(psn)
  629. }
  630. if len(token) > 0 {
  631. c.ServeSuccessJSON(map[string]interface{}{
  632. "msg": "读取成功",
  633. })
  634. } else {
  635. c.ServeSuccessJSON(map[string]interface{}{
  636. "failed_code": -10,
  637. "msg": "读取失败",
  638. })
  639. }
  640. }
  641. } else if miConfig.MdtrtareaAdmvs == "360399" {
  642. if initFlag == 0 {
  643. c.TestGetJiangXiBasBaseInit()
  644. }
  645. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  646. type ELeData struct {
  647. Data struct {
  648. IdNo string `json:"idNo"`
  649. IdType string `json:"idType"`
  650. UserName string `json:"userName"`
  651. EcToken string `json:"ecToken"`
  652. InsuOrg string `json:"insuOrg"`
  653. Gender string `json:"gender"`
  654. Birthday string `json:"birthday"`
  655. Nationality string `json:"nationality"`
  656. Email string `json:"email"`
  657. Extra string `json:"extra"`
  658. } `json:"data"`
  659. Code int `json:"code"`
  660. Message string `json:"message"`
  661. }
  662. var ele ELeData
  663. err := json.Unmarshal([]byte(json_result), &ele)
  664. if err != nil {
  665. utils.ErrorLog("解析失败:%v", err)
  666. }
  667. token := ele.Data.EcToken
  668. token = Remove0000(token)
  669. fmt.Println(ele.Data.UserName)
  670. 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)
  671. saveLog(result2, requestLog2, "1101", "获取人员信息")
  672. var res ResultTwo
  673. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  674. utils.ErrorLog("解析失败:%v", err)
  675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  676. return
  677. }
  678. if res.Infcode == 0 {
  679. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  680. if err == gorm.ErrRecordNotFound {
  681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  682. return
  683. } else if err != nil {
  684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  685. return
  686. } else {
  687. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  688. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  689. infoStr := string(Iinfos)
  690. idetinfoStr := string(Idetinfos)
  691. psn := &models.HisPsn{
  692. PsnNo: res.Output.Baseinfo.PsnNo,
  693. Age: res.Output.Baseinfo.Age,
  694. PatientId: patient.ID,
  695. Certno: res.Output.Baseinfo.Certno,
  696. Brdy: res.Output.Baseinfo.Brdy,
  697. Gend: res.Output.Baseinfo.Gend,
  698. Naty: res.Output.Baseinfo.Naty,
  699. PsnCertType: res.Output.Baseinfo.PsnCertType,
  700. PsnName: res.Output.Baseinfo.PsnName,
  701. Idetinfo: idetinfoStr,
  702. Insuinfo: infoStr,
  703. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  704. CardInfo: "",
  705. VerifyNumber: token,
  706. }
  707. service.CreateHisPsn(psn)
  708. c.ServeSuccessJSON(map[string]interface{}{
  709. "patient": patient,
  710. "number": token,
  711. })
  712. }
  713. } else {
  714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  715. return
  716. }
  717. } else if miConfig.MdtrtareaAdmvs == "430800" {
  718. if initFlag == 0 {
  719. c.TestGetJiangXiBasBaseInit()
  720. }
  721. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  722. type ELeData struct {
  723. Data struct {
  724. IdNo string `json:"idNo"`
  725. IdType string `json:"idType"`
  726. UserName string `json:"userName"`
  727. EcToken string `json:"ecToken"`
  728. InsuOrg string `json:"insuOrg"`
  729. Gender string `json:"gender"`
  730. Birthday string `json:"birthday"`
  731. Nationality string `json:"nationality"`
  732. Email string `json:"email"`
  733. Extra string `json:"extra"`
  734. } `json:"data"`
  735. Code int `json:"code"`
  736. Message string `json:"message"`
  737. }
  738. var ele ELeData
  739. err := json.Unmarshal([]byte(json_result), &ele)
  740. if err != nil {
  741. utils.ErrorLog("解析失败:%v", err)
  742. }
  743. token := ele.Data.EcToken
  744. token = Remove0000(token)
  745. fmt.Println(ele.Data.UserName)
  746. 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)
  747. saveLog(result2, requestLog2, "1101", "获取人员信息")
  748. var res ResultTwo
  749. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  750. utils.ErrorLog("解析失败:%v", err)
  751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  752. return
  753. }
  754. if res.Infcode == 0 {
  755. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  756. if err == gorm.ErrRecordNotFound {
  757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  758. return
  759. } else if err != nil {
  760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  761. return
  762. } else {
  763. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  764. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  765. infoStr := string(Iinfos)
  766. idetinfoStr := string(Idetinfos)
  767. psn := &models.HisPsn{
  768. PsnNo: res.Output.Baseinfo.PsnNo,
  769. Age: res.Output.Baseinfo.Age,
  770. PatientId: patient.ID,
  771. Certno: res.Output.Baseinfo.Certno,
  772. Brdy: res.Output.Baseinfo.Brdy,
  773. Gend: res.Output.Baseinfo.Gend,
  774. Naty: res.Output.Baseinfo.Naty,
  775. PsnCertType: res.Output.Baseinfo.PsnCertType,
  776. PsnName: res.Output.Baseinfo.PsnName,
  777. Idetinfo: idetinfoStr,
  778. Insuinfo: infoStr,
  779. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  780. CardInfo: "",
  781. VerifyNumber: token,
  782. }
  783. service.CreateHisPsn(psn)
  784. c.ServeSuccessJSON(map[string]interface{}{
  785. "patient": patient,
  786. "number": token,
  787. })
  788. }
  789. } else {
  790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  791. return
  792. }
  793. }
  794. }
  795. func (c *HisApiController) Get9001() {
  796. adminUser := c.GetAdminUserInfo()
  797. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  798. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  799. if miConfig.MdtrtareaAdmvs == "350500" {
  800. service.GetFjAuthorizationInfo(miConfig.Code)
  801. } else if miConfig.MdtrtareaAdmvs == "131023" {
  802. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  803. var dat map[string]interface{}
  804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  805. fmt.Println(dat)
  806. } else {
  807. fmt.Println(err)
  808. }
  809. userJSONBytes, _ := json.Marshal(dat)
  810. var res models.Result9001
  811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  812. utils.ErrorLog("解析失败:%v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. } else {
  817. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  818. var dat map[string]interface{}
  819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  820. fmt.Println(dat)
  821. } else {
  822. fmt.Println(err)
  823. }
  824. userJSONBytes, _ := json.Marshal(dat)
  825. var res models.Result9001
  826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  827. utils.ErrorLog("解析失败:%v", err)
  828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  829. return
  830. }
  831. }
  832. }
  833. 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) {
  834. var res Result3101
  835. adminUser := c.GetAdminUserInfo()
  836. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  837. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  838. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  839. //record_time := c.GetString("record_time")
  840. //trig_scen := c.GetString("trig_scen")
  841. timeLayout := "2006-01-02"
  842. loc, _ := time.LoadLocation("Local")
  843. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  844. if err != nil {
  845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  846. return res
  847. }
  848. recordDateTime := theTime.Unix()
  849. var patientPrescription models.HisPrescriptionInfo
  850. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  851. //if patientPrescription.ID == 0 {
  852. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  853. //}
  854. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  855. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  856. //
  857. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  858. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  859. var pp models.PublicParams
  860. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  861. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  862. pp.FixmedinsName = miConfig.OrgName
  863. pp.FixmedinsCode = miConfig.Code
  864. pp.RequestUrl = miConfig.Url
  865. pp.Cainfo = miConfig.Cainfo
  866. pp.SecretKey = miConfig.SecretKey
  867. pp.AccessKey = miConfig.AccessKey
  868. pp.OpterName = roles.UserName
  869. var config []*models.HisXtDiagnoseConfig
  870. for _, item := range diagnosis_ids {
  871. id, _ := strconv.ParseInt(item, 10, 64)
  872. diagnosisConfig, _ := service.FindDiagnoseById(id)
  873. config = append(config, &diagnosisConfig)
  874. }
  875. var pd models.PatientDtos
  876. pd.PatnID = his.PsnNo
  877. pd.PatnName = his.Name
  878. pd.Gend = his.Gend
  879. pd.Brdy = his.Brdy
  880. pd.Poolarea = miConfig.MdtrtareaAdmvs
  881. pd.CurrMdtrtID = his.Number
  882. var fed models.FsiEncounterDtos
  883. fed.MdtrtID = his.Number
  884. fed.MedinsID = miConfig.Code
  885. fed.MedinsName = miConfig.OrgName
  886. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  887. fed.MedMdtrtType = "1"
  888. fed.MedinsType = "1"
  889. fed.MedinsLv = "11"
  890. tm := time.Unix(his.RecordDate, 0)
  891. s_tm := tm.Format("2006-01-02 15:04:05")
  892. fed.AdmDate = s_tm
  893. fed.DscgDate = s_tm
  894. fed.DscgMainDiseCodg = config[0].CountryCode
  895. fed.DscgMainDiseName = config[0].CountryContentName
  896. //诊断信息
  897. var fdds []*models.FsiDiagnoseDtos
  898. for index, item := range config {
  899. if index == 0 {
  900. var fdd models.FsiDiagnoseDtos
  901. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  902. fdd.InoutDiseType = "1"
  903. fdd.MaindiseFlag = "1"
  904. fdd.DiseDate = s_tm
  905. fdd.DiasSrtNo = "1"
  906. fdd.DiseName = item.CountryContentName
  907. fdd.DiseCodg = item.CountryCode
  908. fdds = append(fdds, &fdd)
  909. } else {
  910. var fdd models.FsiDiagnoseDtos
  911. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  912. fdd.InoutDiseType = "1"
  913. fdd.MaindiseFlag = "1"
  914. fdd.DiseDate = s_tm
  915. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  916. fdd.DiseName = item.CountryContentName
  917. fdd.DiseCodg = item.CountryCode
  918. fdds = append(fdds, &fdd)
  919. }
  920. }
  921. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  922. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  923. fed.AdmDeptName = department.Name
  924. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  925. fed.DscgDeptName = department.Name
  926. fed.MedMdtrtType = "1"
  927. fed.MedType = "11"
  928. //if his.Insutype == "390" {
  929. // fed.MedType = "1402"
  930. //} else {
  931. // fed.MedType = "9933"
  932. //}
  933. var orders []*models.FsiOrderDtos
  934. if trig_scen == "2" {
  935. //处方医嘱信息
  936. for _, item := range prescriptions {
  937. for _, subItem := range item.HisDoctorAdviceInfo {
  938. var order models.FsiOrderDtos
  939. order.RxID = strconv.FormatInt(item.ID, 10)
  940. order.Rxno = strconv.FormatInt(item.ID, 10)
  941. order.LongDrordFlag = "0"
  942. order.HilistType = "1"
  943. order.ChrgType = "1"
  944. order.DrordBhvr = "-"
  945. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  946. order.HosplistName = subItem.BaseDrugLib.DrugName
  947. order.HilistLv = "1"
  948. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  949. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  950. order.HosplistName = subItem.BaseDrugLib.DrugName
  951. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  952. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  953. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  954. order.OwnpayAmt = ""
  955. order.SelfpayAmt = ""
  956. order.Spec = ""
  957. order.SpecUnt = ""
  958. order.DrordBegnDate = s_tm
  959. order.DrordStopDate = ""
  960. order.DrordDrCodg = "1"
  961. order.DrordDeptName = department.Name
  962. order.DrordDrCodg = "1"
  963. order.DrordDrName = doctor_info.UserName
  964. order.DrordDrProfttl = ""
  965. order.CurrDrordFlag = "1"
  966. orders = append(orders, &order)
  967. }
  968. for _, subItem := range item.HisPrescriptionProject {
  969. if subItem.Type == 2 {
  970. var order models.FsiOrderDtos
  971. order.RxID = strconv.FormatInt(item.ID, 10)
  972. order.Rxno = strconv.FormatInt(item.ID, 10)
  973. order.LongDrordFlag = "0"
  974. order.HilistType = "1"
  975. order.ChrgType = "1"
  976. order.DrordBhvr = "-"
  977. order.HilistCode = subItem.HisProject.MedicalCode
  978. order.HosplistName = subItem.HisProject.ProjectName
  979. order.HilistLv = "1"
  980. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  981. order.HosplistCode = subItem.HisProject.MedicalCode
  982. order.HosplistName = subItem.HisProject.ProjectName
  983. order.Cnt = subItem.Count
  984. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  985. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  986. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  987. order.OwnpayAmt = ""
  988. order.SelfpayAmt = ""
  989. order.Spec = ""
  990. order.SpecUnt = ""
  991. order.DrordBegnDate = s_tm
  992. order.DrordStopDate = ""
  993. order.DrordDrCodg = "1"
  994. order.DrordDeptName = department.Name
  995. order.DrordDrCodg = "1"
  996. order.DrordDrName = doctor_info.UserName
  997. order.DrordDrProfttl = ""
  998. order.CurrDrordFlag = "1"
  999. orders = append(orders, &order)
  1000. }
  1001. if subItem.Type == 3 {
  1002. var order models.FsiOrderDtos
  1003. order.RxID = strconv.FormatInt(item.ID, 10)
  1004. order.Rxno = strconv.FormatInt(item.ID, 10)
  1005. order.LongDrordFlag = "0"
  1006. order.HilistType = "1"
  1007. order.ChrgType = "1"
  1008. order.DrordBhvr = "-"
  1009. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1010. order.HosplistName = subItem.GoodInfo.GoodName
  1011. order.HilistLv = "1"
  1012. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1013. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1014. order.HosplistName = subItem.GoodInfo.GoodName
  1015. order.Cnt = subItem.Count
  1016. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1017. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1018. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1019. order.OwnpayAmt = ""
  1020. order.SelfpayAmt = ""
  1021. order.Spec = ""
  1022. order.SpecUnt = ""
  1023. order.DrordBegnDate = s_tm
  1024. order.DrordStopDate = ""
  1025. order.DrordDrCodg = "1"
  1026. order.DrordDeptName = department.Name
  1027. order.DrordDrCodg = "1"
  1028. order.DrordDrName = doctor_info.UserName
  1029. order.DrordDrProfttl = ""
  1030. order.CurrDrordFlag = "1"
  1031. orders = append(orders, &order)
  1032. }
  1033. }
  1034. }
  1035. //处方医嘱信息
  1036. }
  1037. fed.MatnStas = "0"
  1038. fed.MedfeeSumamt = "0"
  1039. fed.OwnpayAmt = "0"
  1040. fed.SelfpayAmt = "0"
  1041. fed.AcctPayamt = "0"
  1042. fed.MaAmt = "0"
  1043. fed.HifpPayamt = "0"
  1044. fed.SetlTotlnum = "1"
  1045. fed.Insutype = his.Insutype
  1046. fed.ReimFlag = "0"
  1047. fed.OutSetlFlag = "0"
  1048. var fopd []*models.FsiOperationDtosData
  1049. data := make(map[string]interface{})
  1050. data["fed"] = fed
  1051. data["fdd"] = fdds
  1052. data["fod"] = orders
  1053. data["pd"] = pd
  1054. data["pp"] = pp
  1055. data["fopd"] = fopd
  1056. data["trig_scen"] = trig_scen
  1057. fmt.Println(data)
  1058. fmt.Println(fed)
  1059. fmt.Println(fdds)
  1060. fmt.Println(orders)
  1061. fmt.Println(pd)
  1062. fmt.Println(pp)
  1063. fmt.Println(fopd)
  1064. client := &http.Client{}
  1065. bytesData, _ := json.Marshal(data)
  1066. var req *http.Request
  1067. if miConfig.MdtrtareaAdmvs == "320921" {
  1068. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1069. } else {
  1070. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1071. }
  1072. resp, _ := client.Do(req)
  1073. defer resp.Body.Close()
  1074. body, ioErr := ioutil.ReadAll(resp.Body)
  1075. if ioErr != nil {
  1076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1078. return res
  1079. }
  1080. var respJSON map[string]interface{}
  1081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1084. return res
  1085. }
  1086. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1087. fmt.Println(respJSON)
  1088. result, _ := json.Marshal(respJSON)
  1089. fmt.Println(result)
  1090. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1091. utils.ErrorLog("解析失败:%v", err)
  1092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1093. return res
  1094. }
  1095. return res
  1096. }
  1097. 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) {
  1098. adminUser := c.GetAdminUserInfo()
  1099. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1100. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1101. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1102. //record_time := c.GetString("record_time")
  1103. //trig_scen := c.GetString("trig_scen")
  1104. timeLayout := "2006-01-02"
  1105. loc, _ := time.LoadLocation("Local")
  1106. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1107. if err != nil {
  1108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1109. return res
  1110. }
  1111. recordDateTime := theTime.Unix()
  1112. var patientPrescription models.HisPrescriptionInfo
  1113. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1114. if patientPrescription.ID == 0 {
  1115. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1116. }
  1117. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1118. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1119. //
  1120. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1121. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1122. var pp models.PublicParams
  1123. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1124. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1125. pp.FixmedinsName = miConfig.OrgName
  1126. pp.FixmedinsCode = miConfig.Code
  1127. pp.RequestUrl = miConfig.Url
  1128. pp.Cainfo = miConfig.Cainfo
  1129. pp.SecretKey = miConfig.SecretKey
  1130. pp.AccessKey = miConfig.AccessKey
  1131. pp.OpterName = roles.UserName
  1132. var config []*models.HisXtDiagnoseConfig
  1133. for _, item := range diagnosis_ids {
  1134. id, _ := strconv.ParseInt(item, 10, 64)
  1135. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1136. config = append(config, &diagnosisConfig)
  1137. }
  1138. var pd models.PatientDtos
  1139. pd.PatnID = his.PsnNo
  1140. pd.PatnName = his.Name
  1141. pd.Gend = his.Gend
  1142. pd.Brdy = his.Brdy
  1143. pd.Poolarea = his.InsuplcAdmdvs
  1144. pd.CurrMdtrtID = his.Number
  1145. var fed models.FsiEncounterDtos
  1146. fed.MdtrtID = his.Number
  1147. fed.MedinsID = miConfig.Code
  1148. fed.MedinsName = miConfig.OrgName
  1149. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1150. fed.MedMdtrtType = "1"
  1151. fed.MedinsType = "1"
  1152. fed.MedinsLv = "11"
  1153. tm := time.Unix(his.RecordDate, 0)
  1154. s_tm := tm.Format("2006-01-02 15:04:05")
  1155. fed.AdmDate = s_tm
  1156. fed.DscgDate = s_tm
  1157. fed.DscgMainDiseCodg = config[0].CountryCode
  1158. fed.DscgMainDiseName = config[0].CountryContentName
  1159. //诊断信息
  1160. var fdds []*models.FsiDiagnoseDtos
  1161. for index, item := range config {
  1162. if index == 0 {
  1163. var fdd models.FsiDiagnoseDtos
  1164. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1165. fdd.InoutDiseType = "1"
  1166. fdd.MaindiseFlag = "1"
  1167. fdd.DiseDate = s_tm
  1168. fdd.DiasSrtNo = "1"
  1169. fdd.DiseName = item.CountryContentName
  1170. fdd.DiseCodg = item.CountryCode
  1171. fdds = append(fdds, &fdd)
  1172. } else {
  1173. var fdd models.FsiDiagnoseDtos
  1174. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1175. fdd.InoutDiseType = "1"
  1176. fdd.MaindiseFlag = "1"
  1177. fdd.DiseDate = s_tm
  1178. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1179. fdd.DiseName = item.CountryContentName
  1180. fdd.DiseCodg = item.CountryCode
  1181. fdds = append(fdds, &fdd)
  1182. }
  1183. }
  1184. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1185. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1186. fed.AdmDeptName = department.Name
  1187. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1188. fed.DscgDeptName = department.Name
  1189. fed.MedMdtrtType = "1"
  1190. fed.MedType = "11"
  1191. //if his.Insutype == "390" {
  1192. // fed.MedType = "1402"
  1193. //} else {
  1194. // fed.MedType = "9933"
  1195. //}
  1196. var orders []*models.FsiOrderDtos
  1197. if trig_scen == "2" {
  1198. //处方医嘱信息
  1199. for _, item := range prescriptions {
  1200. for _, subItem := range item.HisDoctorAdviceInfo {
  1201. var order models.FsiOrderDtos
  1202. order.RxID = strconv.FormatInt(item.ID, 10)
  1203. order.Rxno = strconv.FormatInt(item.ID, 10)
  1204. order.LongDrordFlag = "0"
  1205. order.HilistType = "1"
  1206. order.ChrgType = "1"
  1207. order.DrordBhvr = "-"
  1208. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1209. order.HosplistName = subItem.BaseDrugLib.DrugName
  1210. order.HilistLv = "1"
  1211. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1212. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1213. order.HosplistName = subItem.BaseDrugLib.DrugName
  1214. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1215. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1216. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1217. order.OwnpayAmt = ""
  1218. order.SelfpayAmt = ""
  1219. order.Spec = ""
  1220. order.SpecUnt = ""
  1221. order.DrordBegnDate = s_tm
  1222. order.DrordStopDate = ""
  1223. order.DrordDrCodg = "1"
  1224. order.DrordDeptName = department.Name
  1225. order.DrordDrCodg = "1"
  1226. order.DrordDrName = doctor_info.UserName
  1227. order.DrordDrProfttl = ""
  1228. order.CurrDrordFlag = "1"
  1229. orders = append(orders, &order)
  1230. }
  1231. for _, subItem := range item.HisPrescriptionProject {
  1232. if subItem.Type == 2 {
  1233. var order models.FsiOrderDtos
  1234. order.RxID = strconv.FormatInt(item.ID, 10)
  1235. order.Rxno = strconv.FormatInt(item.ID, 10)
  1236. order.LongDrordFlag = "0"
  1237. order.HilistType = "1"
  1238. order.ChrgType = "1"
  1239. order.DrordBhvr = "-"
  1240. order.HilistCode = subItem.HisProject.MedicalCode
  1241. order.HosplistName = subItem.HisProject.ProjectName
  1242. order.HilistLv = "1"
  1243. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1244. order.HosplistCode = subItem.HisProject.MedicalCode
  1245. order.HosplistName = subItem.HisProject.ProjectName
  1246. order.Cnt = subItem.Count
  1247. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1248. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1249. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1250. order.OwnpayAmt = ""
  1251. order.SelfpayAmt = ""
  1252. order.Spec = ""
  1253. order.SpecUnt = ""
  1254. order.DrordBegnDate = s_tm
  1255. order.DrordStopDate = ""
  1256. order.DrordDrCodg = "1"
  1257. order.DrordDeptName = department.Name
  1258. order.DrordDrCodg = "1"
  1259. order.DrordDrName = doctor_info.UserName
  1260. order.DrordDrProfttl = ""
  1261. order.CurrDrordFlag = "1"
  1262. orders = append(orders, &order)
  1263. }
  1264. if subItem.Type == 3 {
  1265. var order models.FsiOrderDtos
  1266. order.RxID = strconv.FormatInt(item.ID, 10)
  1267. order.Rxno = strconv.FormatInt(item.ID, 10)
  1268. order.LongDrordFlag = "0"
  1269. order.HilistType = "1"
  1270. order.ChrgType = "1"
  1271. order.DrordBhvr = "-"
  1272. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1273. order.HosplistName = subItem.GoodInfo.GoodName
  1274. order.HilistLv = "1"
  1275. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1276. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1277. order.HosplistName = subItem.GoodInfo.GoodName
  1278. order.Cnt = subItem.Count
  1279. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1280. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1281. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1282. order.OwnpayAmt = ""
  1283. order.SelfpayAmt = ""
  1284. order.Spec = ""
  1285. order.SpecUnt = ""
  1286. order.DrordBegnDate = s_tm
  1287. order.DrordStopDate = ""
  1288. order.DrordDrCodg = "1"
  1289. order.DrordDeptName = department.Name
  1290. order.DrordDrCodg = "1"
  1291. order.DrordDrName = doctor_info.UserName
  1292. order.DrordDrProfttl = ""
  1293. order.CurrDrordFlag = "1"
  1294. orders = append(orders, &order)
  1295. }
  1296. }
  1297. }
  1298. //处方医嘱信息
  1299. }
  1300. fed.MatnStas = "0"
  1301. fed.MedfeeSumamt = "0"
  1302. fed.OwnpayAmt = "0"
  1303. fed.SelfpayAmt = "0"
  1304. fed.AcctPayamt = "0"
  1305. fed.MaAmt = "0"
  1306. fed.HifpPayamt = "0"
  1307. fed.SetlTotlnum = "1"
  1308. fed.Insutype = his.Insutype
  1309. fed.ReimFlag = "0"
  1310. fed.OutSetlFlag = "0"
  1311. var fopd []*models.FsiOperationDtosData
  1312. data := make(map[string]interface{})
  1313. data["fed"] = fed
  1314. data["fdd"] = fdds
  1315. data["fod"] = orders
  1316. data["pd"] = pd
  1317. data["pp"] = pp
  1318. data["fopd"] = fopd
  1319. data["trig_scen"] = trig_scen
  1320. fmt.Println(data)
  1321. fmt.Println(fed)
  1322. fmt.Println(fdds)
  1323. fmt.Println(orders)
  1324. fmt.Println(pd)
  1325. fmt.Println(pp)
  1326. fmt.Println(fopd)
  1327. client := &http.Client{}
  1328. bytesData, _ := json.Marshal(data)
  1329. var req *http.Request
  1330. if miConfig.MdtrtareaAdmvs == "320921" {
  1331. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1332. } else {
  1333. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1334. }
  1335. resp, _ := client.Do(req)
  1336. defer resp.Body.Close()
  1337. body, ioErr := ioutil.ReadAll(resp.Body)
  1338. if ioErr != nil {
  1339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. return res
  1342. }
  1343. var respJSON map[string]interface{}
  1344. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1347. return res
  1348. }
  1349. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1350. result, _ := json.Marshal(respJSON)
  1351. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1352. utils.ErrorLog("解析失败:%v", err)
  1353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1354. return res
  1355. }
  1356. return res
  1357. }
  1358. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1359. ////patient_id, _ := c.GetInt64("patient_id")
  1360. //order_id, _ := c.GetInt64("order_id")
  1361. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1362. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1363. //trig_scen := c.GetString("trig_scen")
  1364. adminUser := c.GetAdminUserInfo()
  1365. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1366. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1367. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1368. record_time := c.GetString("record_time")
  1369. order, _ := service.GetHisOrderByID(order_id)
  1370. timeLayout := "2006-01-02"
  1371. loc, _ := time.LoadLocation("Local")
  1372. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1373. if err != nil {
  1374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1375. return
  1376. }
  1377. recordDateTime := theTime.Unix()
  1378. var patientPrescription models.HisPrescriptionInfo
  1379. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1380. if patientPrescription.ID == 0 {
  1381. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1382. }
  1383. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1384. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1385. //
  1386. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1387. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1388. var pp models.PublicParams
  1389. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1390. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1391. pp.FixmedinsName = miConfig.OrgName
  1392. pp.FixmedinsCode = miConfig.Code
  1393. pp.RequestUrl = miConfig.Url
  1394. pp.Cainfo = miConfig.Cainfo
  1395. pp.SecretKey = miConfig.SecretKey
  1396. pp.AccessKey = miConfig.AccessKey
  1397. pp.OpterName = roles.UserName
  1398. var config []*models.HisXtDiagnoseConfig
  1399. for _, item := range diagnosis_ids {
  1400. id, _ := strconv.ParseInt(item, 10, 64)
  1401. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1402. config = append(config, &diagnosisConfig)
  1403. }
  1404. var pd models.PatientDtos
  1405. pd.PatnID = his.PsnNo
  1406. pd.PatnName = his.Name
  1407. pd.Gend = his.Gend
  1408. pd.Brdy = his.Brdy
  1409. pd.Poolarea = his.InsuplcAdmdvs
  1410. pd.CurrMdtrtID = his.Number
  1411. var fed models.FsiEncounterDtos
  1412. fed.MdtrtID = his.Number
  1413. fed.MedinsID = miConfig.Code
  1414. fed.MedinsName = miConfig.OrgName
  1415. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1416. fed.MedMdtrtType = "1"
  1417. fed.MedinsType = "1"
  1418. fed.MedinsLv = "11"
  1419. tm := time.Unix(his.RecordDate, 0)
  1420. s_tm := tm.Format("2006-01-02 15:04:05")
  1421. fed.AdmDate = s_tm
  1422. fed.DscgDate = s_tm
  1423. fed.DscgMainDiseCodg = config[0].CountryCode
  1424. fed.DscgMainDiseName = config[0].CountryContentName
  1425. //诊断信息
  1426. var fdds []*models.FsiDiagnoseDtos
  1427. for index, item := range config {
  1428. if index == 0 {
  1429. var fdd models.FsiDiagnoseDtos
  1430. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1431. fdd.InoutDiseType = "1"
  1432. fdd.MaindiseFlag = "1"
  1433. fdd.DiseDate = s_tm
  1434. fdd.DiasSrtNo = "1"
  1435. fdd.DiseName = item.CountryContentName
  1436. fdd.DiseCodg = item.CountryCode
  1437. fdds = append(fdds, &fdd)
  1438. } else {
  1439. var fdd models.FsiDiagnoseDtos
  1440. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1441. fdd.InoutDiseType = "1"
  1442. fdd.MaindiseFlag = "1"
  1443. fdd.DiseDate = s_tm
  1444. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1445. fdd.DiseName = item.CountryContentName
  1446. fdd.DiseCodg = item.CountryCode
  1447. fdds = append(fdds, &fdd)
  1448. }
  1449. }
  1450. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1451. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1452. fed.AdmDeptName = department.Name
  1453. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1454. fed.DscgDeptName = department.Name
  1455. fed.MedType = order.MedType
  1456. //处方医嘱信息
  1457. var orders []*models.FsiOrderDtos
  1458. //for _, item := range prescriptions {
  1459. // for _, subItem := range item.HisDoctorAdviceInfo {
  1460. // var order models.FsiOrderDtos
  1461. // order.RxID = strconv.FormatInt(item.ID, 10)
  1462. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1463. // order.LongDrordFlag = "0"
  1464. // order.HilistType = "1"
  1465. // order.ChrgType = "1"
  1466. // order.DrordBhvr = "-"
  1467. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1468. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1469. // order.HilistLv = "1"
  1470. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1471. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1472. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1473. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1474. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1475. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1476. // order.OwnpayAmt = ""
  1477. // order.SelfpayAmt = ""
  1478. // order.Spec = ""
  1479. // order.SpecUnt = ""
  1480. // order.DrordBegnDate = s_tm
  1481. // order.DrordStopDate = ""
  1482. // order.DrordDrCodg = "1"
  1483. // order.DrordDeptName = department.Name
  1484. // order.DrordDrCodg = "1"
  1485. // order.DrordDrName = doctor_info.UserName
  1486. // order.DrordDrProfttl = ""
  1487. // order.CurrDrordFlag = "1"
  1488. // orders = append(orders, &order)
  1489. // }
  1490. // for _, subItem := range item.HisPrescriptionProject {
  1491. // if subItem.Type == 2 {
  1492. // var order models.FsiOrderDtos
  1493. // order.RxID = strconv.FormatInt(item.ID, 10)
  1494. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1495. // order.LongDrordFlag = "0"
  1496. // order.HilistType = "1"
  1497. // order.ChrgType = "1"
  1498. // order.DrordBhvr = "-"
  1499. // order.HilistCode = subItem.HisProject.MedicalCode
  1500. // order.HosplistName = subItem.HisProject.ProjectName
  1501. // order.HilistLv = "1"
  1502. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1503. // order.HosplistCode = subItem.HisProject.MedicalCode
  1504. // order.HosplistName = subItem.HisProject.ProjectName
  1505. // order.Cnt = subItem.Count
  1506. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1507. //
  1508. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1509. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1510. // order.OwnpayAmt = ""
  1511. // order.SelfpayAmt = ""
  1512. // order.Spec = ""
  1513. // order.SpecUnt = ""
  1514. // order.DrordBegnDate = s_tm
  1515. // order.DrordStopDate = ""
  1516. // order.DrordDrCodg = "1"
  1517. // order.DrordDeptName = department.Name
  1518. // order.DrordDrCodg = "1"
  1519. // order.DrordDrName = doctor_info.UserName
  1520. // order.DrordDrProfttl = ""
  1521. // order.CurrDrordFlag = "1"
  1522. // orders = append(orders, &order)
  1523. //
  1524. // }
  1525. // if subItem.Type == 3 {
  1526. //
  1527. // var order models.FsiOrderDtos
  1528. // order.RxID = strconv.FormatInt(item.ID, 10)
  1529. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1530. // order.LongDrordFlag = "0"
  1531. // order.HilistType = "1"
  1532. // order.ChrgType = "1"
  1533. // order.DrordBhvr = "-"
  1534. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1535. // order.HosplistName = subItem.GoodInfo.GoodName
  1536. // order.HilistLv = "1"
  1537. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1538. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1539. // order.HosplistName = subItem.GoodInfo.GoodName
  1540. // order.Cnt = subItem.Count
  1541. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1542. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1543. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1544. // order.OwnpayAmt = ""
  1545. // order.SelfpayAmt = ""
  1546. // order.Spec = ""
  1547. // order.SpecUnt = ""
  1548. // order.DrordBegnDate = s_tm
  1549. // order.DrordStopDate = ""
  1550. // order.DrordDrCodg = "1"
  1551. // order.DrordDeptName = department.Name
  1552. // order.DrordDrCodg = "1"
  1553. // order.DrordDrName = doctor_info.UserName
  1554. // order.DrordDrProfttl = ""
  1555. // order.CurrDrordFlag = "1"
  1556. // orders = append(orders, &order)
  1557. //
  1558. // }
  1559. // }
  1560. //}
  1561. for _, item := range prescriptions {
  1562. for _, subItem := range item.HisDoctorAdviceInfo {
  1563. var order models.FsiOrderDtos
  1564. order.RxID = strconv.FormatInt(item.ID, 10)
  1565. order.Rxno = strconv.FormatInt(item.ID, 10)
  1566. order.LongDrordFlag = "0"
  1567. order.HilistType = "1"
  1568. order.ChrgType = "1"
  1569. order.DrordBhvr = "-"
  1570. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1571. order.HosplistName = subItem.BaseDrugLib.DrugName
  1572. order.HilistLv = "1"
  1573. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1574. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1575. order.HosplistName = subItem.BaseDrugLib.DrugName
  1576. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1577. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1578. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1579. order.OwnpayAmt = ""
  1580. order.SelfpayAmt = ""
  1581. order.Spec = ""
  1582. order.SpecUnt = ""
  1583. order.DrordBegnDate = s_tm
  1584. order.DrordStopDate = ""
  1585. order.DrordDrCodg = "1"
  1586. order.DrordDeptName = department.Name
  1587. order.DrordDrCodg = "1"
  1588. order.DrordDrName = doctor_info.UserName
  1589. order.DrordDrProfttl = ""
  1590. order.CurrDrordFlag = "1"
  1591. orders = append(orders, &order)
  1592. }
  1593. for _, subItem := range item.HisPrescriptionProject {
  1594. if subItem.Type == 2 {
  1595. var order models.FsiOrderDtos
  1596. order.RxID = strconv.FormatInt(item.ID, 10)
  1597. order.Rxno = strconv.FormatInt(item.ID, 10)
  1598. order.LongDrordFlag = "0"
  1599. order.HilistType = "1"
  1600. order.ChrgType = "1"
  1601. order.DrordBhvr = "-"
  1602. order.HilistCode = subItem.HisProject.MedicalCode
  1603. order.HosplistName = subItem.HisProject.ProjectName
  1604. order.HilistLv = "1"
  1605. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1606. order.HosplistCode = subItem.HisProject.MedicalCode
  1607. order.HosplistName = subItem.HisProject.ProjectName
  1608. order.Cnt = subItem.Count
  1609. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1610. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1611. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1612. order.OwnpayAmt = ""
  1613. order.SelfpayAmt = ""
  1614. order.Spec = ""
  1615. order.SpecUnt = ""
  1616. order.DrordBegnDate = s_tm
  1617. order.DrordStopDate = ""
  1618. order.DrordDrCodg = "1"
  1619. order.DrordDeptName = department.Name
  1620. order.DrordDrCodg = "1"
  1621. order.DrordDrName = doctor_info.UserName
  1622. order.DrordDrProfttl = ""
  1623. order.CurrDrordFlag = "1"
  1624. orders = append(orders, &order)
  1625. }
  1626. if subItem.Type == 3 {
  1627. var order models.FsiOrderDtos
  1628. order.RxID = strconv.FormatInt(item.ID, 10)
  1629. order.Rxno = strconv.FormatInt(item.ID, 10)
  1630. order.LongDrordFlag = "0"
  1631. order.HilistType = "1"
  1632. order.ChrgType = "1"
  1633. order.DrordBhvr = "-"
  1634. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1635. order.HosplistName = subItem.GoodInfo.GoodName
  1636. order.HilistLv = "1"
  1637. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1638. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1639. order.HosplistName = subItem.GoodInfo.GoodName
  1640. order.Cnt = subItem.Count
  1641. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1642. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1643. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1644. order.OwnpayAmt = ""
  1645. order.SelfpayAmt = ""
  1646. order.Spec = ""
  1647. order.SpecUnt = ""
  1648. order.DrordBegnDate = s_tm
  1649. order.DrordStopDate = ""
  1650. order.DrordDrCodg = "1"
  1651. order.DrordDeptName = department.Name
  1652. order.DrordDrCodg = "1"
  1653. order.DrordDrName = doctor_info.UserName
  1654. order.DrordDrProfttl = ""
  1655. order.CurrDrordFlag = "1"
  1656. orders = append(orders, &order)
  1657. }
  1658. }
  1659. }
  1660. //处方医嘱信息
  1661. fed.MatnStas = "0"
  1662. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1663. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1664. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1665. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1666. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1667. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1668. fed.SetlTotlnum = "1"
  1669. fed.Insutype = his.Insutype
  1670. fed.ReimFlag = "0"
  1671. fed.OutSetlFlag = "0"
  1672. var fopd []*models.FsiOperationDtosData
  1673. data := make(map[string]interface{})
  1674. data["fed"] = fed
  1675. data["fdd"] = fdds
  1676. data["fod"] = orders
  1677. data["pd"] = pd
  1678. data["pp"] = pp
  1679. data["fopd"] = fopd
  1680. data["trig_scen"] = trig_scen
  1681. client := &http.Client{}
  1682. bytesData, _ := json.Marshal(data)
  1683. var req *http.Request
  1684. if miConfig.MdtrtareaAdmvs == "320921" {
  1685. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1686. } else {
  1687. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1688. }
  1689. resp, _ := client.Do(req)
  1690. defer resp.Body.Close()
  1691. body, ioErr := ioutil.ReadAll(resp.Body)
  1692. if ioErr != nil {
  1693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1695. return res
  1696. }
  1697. var respJSON map[string]interface{}
  1698. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1701. return res
  1702. }
  1703. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1704. result, _ := json.Marshal(respJSON)
  1705. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1706. utils.ErrorLog("解析失败:%v", err)
  1707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1708. return res
  1709. }
  1710. return res
  1711. //手术操作集合
  1712. //手术操作集合
  1713. }
  1714. func (c *HisApiController) Check() {
  1715. psn_no := c.GetString("psn_no")
  1716. in := c.GetString("in")
  1717. mt := c.GetString("mt")
  1718. baseParams := models.BaseParams{
  1719. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1720. FixmedinsCode: "H15049901371",
  1721. InsuplcAdmdvs: "150499",
  1722. MdtrtareaAdmvs: "150499",
  1723. OrgName: "赤峰费森血液透析中心",
  1724. Doctor: "1111",
  1725. }
  1726. service.Gdyb2001(baseParams, psn_no, in, mt)
  1727. }
  1728. func (c *HisApiController) GetPsnNcdsInfo() {
  1729. admin_user_id, _ := c.GetInt64("admin_user_id")
  1730. patient_id, _ := c.GetInt64("patient_id")
  1731. id, _ := c.GetInt64("id")
  1732. adminUser := c.GetAdminUserInfo()
  1733. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1734. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1735. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1736. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1737. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1738. //
  1739. //if psn_record.ID == 0 {
  1740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1741. // return
  1742. //}
  1743. var res Result5301
  1744. var res10265 Result5301For10265
  1745. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1746. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1747. var api string
  1748. if miConfig.MdtrtareaAdmvs == "320921" {
  1749. 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 +
  1750. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1751. } else {
  1752. 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 +
  1753. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1754. }
  1755. resp, requestErr := http.Get(api)
  1756. if requestErr != nil {
  1757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1758. return
  1759. }
  1760. body, ioErr := ioutil.ReadAll(resp.Body)
  1761. if ioErr != nil {
  1762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1764. return
  1765. }
  1766. var respJSON map[string]interface{}
  1767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1773. result, _ := json.Marshal(respJSON)
  1774. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1775. utils.ErrorLog("解析失败:%v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. return
  1778. }
  1779. res.ErrMsg = res10265.ErrMsg
  1780. res.Output = res10265.Output
  1781. res.InfRefmsgid = res10265.InfRefmsgid
  1782. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1783. res.Infcode = infocode
  1784. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1785. p, _ := service.GetHisPatientById(patient_id)
  1786. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1787. var dat map[string]interface{}
  1788. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1789. fmt.Println(dat)
  1790. } else {
  1791. fmt.Println(err)
  1792. }
  1793. userJSONBytes, _ := json.Marshal(dat)
  1794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1795. utils.ErrorLog("解析失败:%v", err)
  1796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1797. return
  1798. }
  1799. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1800. p, _ := service.GetHisPatientById(patient_id)
  1801. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1802. var dat map[string]interface{}
  1803. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1804. fmt.Println(dat)
  1805. } else {
  1806. fmt.Println(err)
  1807. }
  1808. userJSONBytes, _ := json.Marshal(dat)
  1809. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1810. utils.ErrorLog("解析失败:%v", err)
  1811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1812. return
  1813. }
  1814. } else {
  1815. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1816. var dat map[string]interface{}
  1817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1818. fmt.Println(dat)
  1819. } else {
  1820. fmt.Println(err)
  1821. }
  1822. userJSONBytes, _ := json.Marshal(dat)
  1823. if miConfig.Code == "H15049901371" {
  1824. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1825. utils.ErrorLog("解析失败:%v", err)
  1826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1827. return
  1828. }
  1829. res.InfRefmsgid = res10265.InfRefmsgid
  1830. res.Output = res10265.Output
  1831. res.ErrMsg = res10265.ErrMsg
  1832. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1833. res.Infcode = infocode
  1834. } else {
  1835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1836. utils.ErrorLog("解析失败:%v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. }
  1841. }
  1842. if res.Infcode == 0 {
  1843. c.ServeSuccessJSON(map[string]interface{}{
  1844. "result": res.Output.Result,
  1845. })
  1846. }
  1847. }
  1848. func (c *HisApiController) CheckInsutype() {
  1849. his_patient_id, _ := c.GetInt64("his_patient_id")
  1850. admin_user_id, _ := c.GetInt64("admin_user_id")
  1851. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1852. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1854. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1855. var dat map[string]interface{}
  1856. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1857. fmt.Println(dat)
  1858. } else {
  1859. fmt.Println(err)
  1860. }
  1861. userJSONBytes, _ := json.Marshal(dat)
  1862. var res Result90100
  1863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1864. utils.ErrorLog("解析失败:%v", err)
  1865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1866. return
  1867. }
  1868. if res.Infcode != 0 {
  1869. c.ServeSuccessJSON(map[string]interface{}{
  1870. "failed_code": -10,
  1871. "msg": res.ErrMsg,
  1872. })
  1873. return
  1874. } else {
  1875. fmt.Println(res)
  1876. }
  1877. }
  1878. func (c *HisApiController) CheckCardPWD() {
  1879. card_pwd := c.GetString("card_pwd")
  1880. his_patient_id, _ := c.GetInt64("his_patient_id")
  1881. admin_user_id, _ := c.GetInt64("admin_user_id")
  1882. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1883. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1884. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1885. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1886. bas := strings.Split(psn.CardInfo, "|")
  1887. basNumber := bas[2]
  1888. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1889. var dat map[string]interface{}
  1890. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1891. fmt.Println(dat)
  1892. } else {
  1893. fmt.Println(err)
  1894. }
  1895. userJSONBytes, _ := json.Marshal(dat)
  1896. var res Result90991
  1897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1898. utils.ErrorLog("解析失败:%v", err)
  1899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1900. return
  1901. }
  1902. if res.Infcode != 0 {
  1903. c.ServeSuccessJSON(map[string]interface{}{
  1904. "failed_code": -10,
  1905. "msg": res.ErrMsg,
  1906. })
  1907. return
  1908. } else {
  1909. if res.Output.Result.SscnoCheckStat == "0" {
  1910. var msg string
  1911. switch res.Output.Result.CardStat {
  1912. case "00":
  1913. msg = "未激活"
  1914. break
  1915. case "10":
  1916. msg = "激活"
  1917. break
  1918. case "20":
  1919. msg = "窗口挂失"
  1920. break
  1921. case "21":
  1922. msg = "电话挂失"
  1923. break
  1924. case "22":
  1925. msg = "单位网上申报挂失"
  1926. break
  1927. case "23":
  1928. msg = "保健办挂失"
  1929. break
  1930. case "24":
  1931. msg = "个人网上挂失"
  1932. break
  1933. case "25":
  1934. msg = "网上服务大厅挂失"
  1935. break
  1936. case "30":
  1937. msg = "注销"
  1938. break
  1939. case "40":
  1940. msg = "回收"
  1941. break
  1942. case "99":
  1943. msg = "制卡中(无效卡)"
  1944. break
  1945. }
  1946. c.ServeSuccessJSON(map[string]interface{}{
  1947. "failed_code": -10,
  1948. "msg": msg,
  1949. })
  1950. return
  1951. } else {
  1952. c.ServeSuccessJSON(map[string]interface{}{
  1953. "msg": "校验成功",
  1954. })
  1955. return
  1956. }
  1957. }
  1958. }
  1959. func (c *HisApiController) CheckCardPWDTwo() {
  1960. //card_pwd := c.GetString("card_pwd")
  1961. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1962. admin_user_id, _ := c.GetInt64("admin_user_id")
  1963. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1964. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1965. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1966. var dat map[string]interface{}
  1967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1968. fmt.Println(dat)
  1969. } else {
  1970. fmt.Println(err)
  1971. }
  1972. userJSONBytes, _ := json.Marshal(dat)
  1973. var res Result90991
  1974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1975. utils.ErrorLog("解析失败:%v", err)
  1976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1977. return
  1978. }
  1979. if res.Infcode != 0 {
  1980. c.ServeSuccessJSON(map[string]interface{}{
  1981. "failed_code": -10,
  1982. "msg": res.ErrMsg,
  1983. })
  1984. return
  1985. } else {
  1986. if res.Output.Result.SscnoCheckStat == "0" {
  1987. var msg string
  1988. switch res.Output.Result.CardStat {
  1989. case "00":
  1990. msg = "未激活"
  1991. break
  1992. case "10":
  1993. msg = "激活"
  1994. break
  1995. case "20":
  1996. msg = "窗口挂失"
  1997. break
  1998. case "21":
  1999. msg = "电话挂失"
  2000. break
  2001. case "22":
  2002. msg = "单位网上申报挂失"
  2003. break
  2004. case "23":
  2005. msg = "保健办挂失"
  2006. break
  2007. case "24":
  2008. msg = "个人网上挂失"
  2009. break
  2010. case "25":
  2011. msg = "网上服务大厅挂失"
  2012. break
  2013. case "30":
  2014. msg = "注销"
  2015. break
  2016. case "40":
  2017. msg = "回收"
  2018. break
  2019. case "99":
  2020. msg = "制卡中(无效卡)"
  2021. break
  2022. }
  2023. c.ServeSuccessJSON(map[string]interface{}{
  2024. "failed_code": -10,
  2025. "msg": msg,
  2026. })
  2027. return
  2028. } else {
  2029. c.ServeSuccessJSON(map[string]interface{}{
  2030. "msg": "校验成功",
  2031. })
  2032. return
  2033. }
  2034. }
  2035. }
  2036. type ELeCertData struct {
  2037. Data struct {
  2038. Extra string `json:"extra"`
  2039. IDNo string `json:"idNo"`
  2040. IDType string `json:"idType"`
  2041. EcToken string `json:"ecToken"`
  2042. InsuOrg string `json:"insuOrg"`
  2043. UserName string `json:"userName"`
  2044. EcIndexNo string `json:"ecIndexNo"`
  2045. Gender string `json:"gender"`
  2046. Birthday string `json:"birthday"`
  2047. Nationality string `json:"nationality"`
  2048. Email string `json:"email"`
  2049. } `json:"OutData"`
  2050. }
  2051. func (c *HisApiController) ReadCard() {
  2052. id_card_type, _ := c.GetInt64("id_card_type")
  2053. admin_user_id, _ := c.GetInt64("admin_user_id")
  2054. certificates, _ := c.GetInt64("certificates")
  2055. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2057. switch id_card_type {
  2058. case 1:
  2059. if miConfig.MdtrtareaAdmvs == "421300" {
  2060. var res ResultTwo
  2061. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  2062. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2063. "&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)
  2064. resp, requestErr := http.Get(api)
  2065. if requestErr != nil {
  2066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2067. return
  2068. }
  2069. body, ioErr := ioutil.ReadAll(resp.Body)
  2070. if ioErr != nil {
  2071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. return
  2074. }
  2075. var respJSON map[string]interface{}
  2076. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2079. return
  2080. }
  2081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2082. result, _ := json.Marshal(respJSON)
  2083. fmt.Println("log")
  2084. fmt.Println(string(result))
  2085. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2086. utils.ErrorLog("解析失败:%v", err)
  2087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2088. return
  2089. }
  2090. if res.Infcode == 0 {
  2091. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2092. if err == gorm.ErrRecordNotFound {
  2093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2094. return
  2095. } else if err != nil {
  2096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2097. return
  2098. } else {
  2099. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2100. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2101. infoStr := string(Iinfos)
  2102. idetinfoStr := string(Idetinfos)
  2103. psn := &models.HisPsn{
  2104. PsnNo: res.Output.Baseinfo.PsnNo,
  2105. Age: res.Output.Baseinfo.Age,
  2106. PatientId: patient.ID,
  2107. Certno: res.Output.Baseinfo.Certno,
  2108. Brdy: res.Output.Baseinfo.Brdy,
  2109. Gend: res.Output.Baseinfo.Gend,
  2110. Naty: res.Output.Baseinfo.Naty,
  2111. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2112. PsnName: res.Output.Baseinfo.PsnName,
  2113. Idetinfo: idetinfoStr,
  2114. Insuinfo: infoStr,
  2115. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2116. }
  2117. service.CreateHisPsn(psn)
  2118. c.ServeSuccessJSON(map[string]interface{}{
  2119. "patient": patient,
  2120. "number": res.Output.Baseinfo.Certno,
  2121. })
  2122. }
  2123. } else {
  2124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2125. return
  2126. }
  2127. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2128. var api string
  2129. if miConfig.MdtrtareaAdmvs == "320921" {
  2130. 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 +
  2131. "&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
  2132. fmt.Println(api)
  2133. } else {
  2134. 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 +
  2135. "&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)
  2136. }
  2137. resp, requestErr := http.Get(api)
  2138. if requestErr != nil {
  2139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2140. return
  2141. }
  2142. body, ioErr := ioutil.ReadAll(resp.Body)
  2143. if ioErr != nil {
  2144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2146. return
  2147. }
  2148. var respJSON map[string]interface{}
  2149. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2152. return
  2153. }
  2154. var status string
  2155. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2156. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2157. //console.log()
  2158. fmt.Println("type===")
  2159. fmt.Println(card_type)
  2160. var token string
  2161. var res ResultTwo //1101结果
  2162. var res10265 ResultTwo10265 //1101结果
  2163. var card_info string //卡信息
  2164. var busi_card_info string
  2165. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2166. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2167. if status == "0" { //读卡成功
  2168. if card_type == "1" {
  2169. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2170. result, _ := json.Marshal(respJSON)
  2171. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2172. utils.ErrorLog("解析失败:%v", err)
  2173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2174. return
  2175. }
  2176. res.ErrMsg = res10265.ErrMsg
  2177. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2178. res.Infcode = infocode
  2179. res.Output = res10265.Output
  2180. res.InfRefmsgid = res10265.InfRefmsgid
  2181. } else {
  2182. //var card_info string //卡信息
  2183. //var busi_card_info string
  2184. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2185. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2186. //fmt.Println(card_info)
  2187. //fmt.Println(busi_card_info)
  2188. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2189. result, _ := json.Marshal(respJSON)
  2190. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2191. utils.ErrorLog("解析失败:%v", err)
  2192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2193. return
  2194. }
  2195. res.ErrMsg = res10265.ErrMsg
  2196. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2197. res.Infcode = infocode
  2198. res.Output = res10265.Output
  2199. res.InfRefmsgid = res10265.InfRefmsgid
  2200. }
  2201. if res.Infcode == 0 {
  2202. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2203. if err == gorm.ErrRecordNotFound {
  2204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2205. return
  2206. } else if err != nil {
  2207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2208. return
  2209. } else {
  2210. if card_type == "1" {
  2211. bas := strings.Split(card_info, "|")
  2212. basNumber := bas[2]
  2213. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2214. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2215. infoStr := string(Iinfos)
  2216. idetinfoStr := string(Idetinfos)
  2217. psn := &models.HisPsn{
  2218. PsnNo: res.Output.Baseinfo.PsnNo,
  2219. Age: res.Output.Baseinfo.Age,
  2220. PatientId: patient.ID,
  2221. Certno: res.Output.Baseinfo.Certno,
  2222. Brdy: res.Output.Baseinfo.Brdy,
  2223. Gend: res.Output.Baseinfo.Gend,
  2224. Naty: res.Output.Baseinfo.Naty,
  2225. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2226. PsnName: res.Output.Baseinfo.PsnName,
  2227. Idetinfo: idetinfoStr,
  2228. Insuinfo: infoStr,
  2229. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2230. CardInfo: card_info,
  2231. VerifyNumber: busi_card_info,
  2232. }
  2233. service.CreateHisPsn(psn)
  2234. var rf []*ResultFive
  2235. json.Unmarshal([]byte(infoStr), &rf)
  2236. var insutypes []*ResultFive
  2237. var insutype string
  2238. var is390 int = 0
  2239. var is310 int = 0
  2240. for _, item := range rf {
  2241. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2242. insutypes = append(insutypes, item)
  2243. }
  2244. }
  2245. if len(insutypes) == 1 {
  2246. insutype = insutypes[0].Insutype
  2247. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2248. } else {
  2249. for _, i := range insutypes {
  2250. if i.Insutype == "390" {
  2251. is390 = 1
  2252. }
  2253. if i.Insutype == "310" {
  2254. is310 = 1
  2255. }
  2256. }
  2257. }
  2258. if is390 == 1 {
  2259. insutype = "390"
  2260. }
  2261. if is310 == 1 {
  2262. insutype = "310"
  2263. }
  2264. if len(insutypes) == 0 {
  2265. insutype = "310"
  2266. }
  2267. c.ServeSuccessJSON(map[string]interface{}{
  2268. "patient": patient,
  2269. "number": basNumber,
  2270. "insutype": insutype,
  2271. })
  2272. } else {
  2273. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2274. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2275. infoStr := string(Iinfos)
  2276. idetinfoStr := string(Idetinfos)
  2277. psn := &models.HisPsn{
  2278. PsnNo: res.Output.Baseinfo.PsnNo,
  2279. Age: res.Output.Baseinfo.Age,
  2280. PatientId: patient.ID,
  2281. Certno: res.Output.Baseinfo.Certno,
  2282. Brdy: res.Output.Baseinfo.Brdy,
  2283. Gend: res.Output.Baseinfo.Gend,
  2284. Naty: res.Output.Baseinfo.Naty,
  2285. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2286. PsnName: res.Output.Baseinfo.PsnName,
  2287. Idetinfo: idetinfoStr,
  2288. Insuinfo: infoStr,
  2289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2290. CardInfo: card_info,
  2291. VerifyNumber: token,
  2292. }
  2293. service.CreateHisPsn(psn)
  2294. c.ServeSuccessJSON(map[string]interface{}{
  2295. "patient": patient,
  2296. "number": token,
  2297. })
  2298. }
  2299. }
  2300. } else {
  2301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2302. return
  2303. }
  2304. } else { //读卡失败
  2305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2306. return
  2307. }
  2308. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2309. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2310. cardnum = DeleteExtraSpaceTwo(cardnum)
  2311. cardCode = DeleteExtraSpaceTwo(cardCode)
  2312. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2313. name = DeleteExtraSpaceTwo(name)
  2314. errmsg = DeleteExtraSpaceTwo(errmsg)
  2315. cardnum = Remove0000(cardnum)
  2316. cardCode = Remove0000(cardCode)
  2317. id_card_no = Remove0000(id_card_no)
  2318. name = Remove0000(name)
  2319. errmsg = Remove0000(errmsg)
  2320. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2321. 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)
  2322. saveLog(result, requestLog, "1101", "获取人员信息")
  2323. fmt.Println(errMsgLog)
  2324. if len(errMsgLog) > 0 {
  2325. } else {
  2326. var dat map[string]interface{}
  2327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2328. fmt.Println(dat)
  2329. } else {
  2330. fmt.Println(err)
  2331. }
  2332. userJSONBytes, _ := json.Marshal(dat)
  2333. var res ResultTwo
  2334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2335. utils.ErrorLog("解析失败:%v", err)
  2336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2337. return
  2338. }
  2339. res.ErrMsg = errMsgLog
  2340. if res.Infcode == 0 {
  2341. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2342. if err == gorm.ErrRecordNotFound {
  2343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2344. return
  2345. } else if err != nil {
  2346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2347. return
  2348. } else {
  2349. fmt.Println(res)
  2350. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2351. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2352. infoStr := string(Iinfos)
  2353. idetinfoStr := string(Idetinfos)
  2354. psn := &models.HisPsn{
  2355. PsnNo: res.Output.Baseinfo.PsnNo,
  2356. Age: res.Output.Baseinfo.Age,
  2357. PatientId: patient.ID,
  2358. Certno: res.Output.Baseinfo.Certno,
  2359. Brdy: res.Output.Baseinfo.Brdy,
  2360. Gend: res.Output.Baseinfo.Gend,
  2361. Naty: res.Output.Baseinfo.Naty,
  2362. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2363. PsnName: res.Output.Baseinfo.PsnName,
  2364. Idetinfo: idetinfoStr,
  2365. Insuinfo: infoStr,
  2366. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2367. CardInfo: basStr,
  2368. VerifyNumber: "",
  2369. }
  2370. service.CreateHisPsn(psn)
  2371. var rf []*ResultFive
  2372. json.Unmarshal([]byte(infoStr), &rf)
  2373. var insutypes []*ResultFive
  2374. var insutype string
  2375. var is390 int = 0
  2376. var is310 int = 0
  2377. for _, item := range rf {
  2378. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2379. insutypes = append(insutypes, item)
  2380. }
  2381. }
  2382. if len(insutypes) == 1 {
  2383. insutype = insutypes[0].Insutype
  2384. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2385. } else {
  2386. for _, i := range insutypes {
  2387. if i.Insutype == "390" {
  2388. is390 = 1
  2389. }
  2390. if i.Insutype == "310" {
  2391. is310 = 1
  2392. }
  2393. }
  2394. }
  2395. if is390 == 1 {
  2396. insutype = "390"
  2397. }
  2398. if is310 == 1 {
  2399. insutype = "310"
  2400. }
  2401. if len(insutypes) == 0 {
  2402. insutype = "390"
  2403. }
  2404. c.ServeSuccessJSON(map[string]interface{}{
  2405. "patient": patient,
  2406. "number": cardnum,
  2407. "insutype": insutype,
  2408. })
  2409. }
  2410. } else {
  2411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2412. return
  2413. }
  2414. }
  2415. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2416. fmt.Println(initFlag)
  2417. fmt.Println("initFlag")
  2418. if initFlag == 0 {
  2419. c.TestGetJiangXiBasBaseInit()
  2420. }
  2421. basStr := c.GetBasBaseInfo()
  2422. if len(basStr) == 0 {
  2423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2424. return
  2425. }
  2426. fmt.Println(basStr)
  2427. bas := strings.Split(basStr, "|")
  2428. basNumber := bas[1]
  2429. fmt.Println(basNumber)
  2430. card_sn := bas[3]
  2431. fmt.Println(card_sn)
  2432. 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, "")
  2433. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2434. var dat map[string]interface{}
  2435. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2436. fmt.Println(dat)
  2437. } else {
  2438. fmt.Println(err)
  2439. }
  2440. userJSONBytes, _ := json.Marshal(dat)
  2441. var res ResultTwo
  2442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2443. utils.ErrorLog("解析失败:%v", err)
  2444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2445. return
  2446. }
  2447. if res.Infcode == 0 {
  2448. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2449. if err == gorm.ErrRecordNotFound {
  2450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2451. return
  2452. } else if err != nil {
  2453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2454. return
  2455. } else {
  2456. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2457. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2458. infoStr := string(Iinfos)
  2459. idetinfoStr := string(Idetinfos)
  2460. psn := &models.HisPsn{
  2461. PsnNo: res.Output.Baseinfo.PsnNo,
  2462. Age: res.Output.Baseinfo.Age,
  2463. PatientId: patient.ID,
  2464. Certno: res.Output.Baseinfo.Certno,
  2465. Brdy: res.Output.Baseinfo.Brdy,
  2466. Gend: res.Output.Baseinfo.Gend,
  2467. Naty: res.Output.Baseinfo.Naty,
  2468. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2469. PsnName: res.Output.Baseinfo.PsnName,
  2470. Idetinfo: idetinfoStr,
  2471. Insuinfo: infoStr,
  2472. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2473. CardInfo: basStr,
  2474. VerifyNumber: "",
  2475. }
  2476. service.CreateHisPsn(psn)
  2477. var rf []*ResultFive
  2478. json.Unmarshal([]byte(infoStr), &rf)
  2479. var insutypes []*ResultFive
  2480. var insutype string
  2481. var is390 int = 0
  2482. var is310 int = 0
  2483. for _, item := range rf {
  2484. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2485. insutypes = append(insutypes, item)
  2486. }
  2487. }
  2488. if len(insutypes) == 1 {
  2489. insutype = insutypes[0].Insutype
  2490. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2491. } else {
  2492. for _, i := range insutypes {
  2493. if i.Insutype == "390" {
  2494. is390 = 1
  2495. }
  2496. if i.Insutype == "310" {
  2497. is310 = 1
  2498. }
  2499. }
  2500. }
  2501. if is390 == 1 {
  2502. insutype = "390"
  2503. }
  2504. if is310 == 1 {
  2505. insutype = "310"
  2506. }
  2507. if len(insutypes) == 0 {
  2508. insutype = "310"
  2509. }
  2510. c.ServeSuccessJSON(map[string]interface{}{
  2511. "patient": patient,
  2512. "number": basNumber,
  2513. "insutype": insutype,
  2514. })
  2515. }
  2516. } else {
  2517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2518. return
  2519. }
  2520. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2521. fmt.Println(initFlag)
  2522. fmt.Println("initFlag")
  2523. if initFlag == 0 {
  2524. c.TestGetHnBasBaseInit()
  2525. }
  2526. basStr := c.GetBasBaseInfo()
  2527. if len(basStr) == 0 {
  2528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2529. return
  2530. }
  2531. fmt.Println(basStr)
  2532. bas := strings.Split(basStr, "|")
  2533. basNumber := bas[1]
  2534. fmt.Println(basNumber)
  2535. card_sn := bas[3]
  2536. card_no := bas[2]
  2537. fmt.Println(card_sn)
  2538. name := bas[4]
  2539. name = ConvertToString(name, "gbk", "utf-8")
  2540. 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)
  2541. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2542. var dat map[string]interface{}
  2543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2544. fmt.Println(dat)
  2545. } else {
  2546. fmt.Println(err)
  2547. }
  2548. userJSONBytes, _ := json.Marshal(dat)
  2549. var res ResultTwo
  2550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2551. utils.ErrorLog("解析失败:%v", err)
  2552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2553. return
  2554. }
  2555. if res.Infcode == 0 {
  2556. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2557. if err == gorm.ErrRecordNotFound {
  2558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2559. return
  2560. } else if err != nil {
  2561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2562. return
  2563. } else {
  2564. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2565. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2566. infoStr := string(Iinfos)
  2567. idetinfoStr := string(Idetinfos)
  2568. psn := &models.HisPsn{
  2569. PsnNo: res.Output.Baseinfo.PsnNo,
  2570. Age: res.Output.Baseinfo.Age,
  2571. PatientId: patient.ID,
  2572. Certno: res.Output.Baseinfo.Certno,
  2573. Brdy: res.Output.Baseinfo.Brdy,
  2574. Gend: res.Output.Baseinfo.Gend,
  2575. Naty: res.Output.Baseinfo.Naty,
  2576. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2577. PsnName: res.Output.Baseinfo.PsnName,
  2578. Idetinfo: idetinfoStr,
  2579. Insuinfo: infoStr,
  2580. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2581. CardInfo: basStr,
  2582. VerifyNumber: "",
  2583. }
  2584. service.CreateHisPsn(psn)
  2585. var rf []*ResultFive
  2586. json.Unmarshal([]byte(infoStr), &rf)
  2587. var insutypes []*ResultFive
  2588. var insutype string
  2589. var is390 int = 0
  2590. var is310 int = 0
  2591. for _, item := range rf {
  2592. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2593. insutypes = append(insutypes, item)
  2594. }
  2595. }
  2596. if len(insutypes) == 1 {
  2597. insutype = insutypes[0].Insutype
  2598. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2599. } else {
  2600. for _, i := range insutypes {
  2601. if i.Insutype == "390" {
  2602. is390 = 1
  2603. }
  2604. if i.Insutype == "310" {
  2605. is310 = 1
  2606. }
  2607. }
  2608. }
  2609. if is390 == 1 {
  2610. insutype = "390"
  2611. }
  2612. if is310 == 1 {
  2613. insutype = "310"
  2614. }
  2615. if len(insutypes) == 0 {
  2616. insutype = "310"
  2617. }
  2618. c.ServeSuccessJSON(map[string]interface{}{
  2619. "patient": patient,
  2620. "number": basNumber,
  2621. "insutype": insutype,
  2622. })
  2623. }
  2624. } else {
  2625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2626. return
  2627. }
  2628. } else {
  2629. if initFlag == 0 {
  2630. c.TestGetBasBaseInit()
  2631. }
  2632. basStr := c.GetBasBaseInfo()
  2633. if len(basStr) == 0 {
  2634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2635. return
  2636. }
  2637. fmt.Println(basStr)
  2638. bas := strings.Split(basStr, "|")
  2639. basNumber := bas[1]
  2640. fmt.Println(basNumber)
  2641. card_sn := bas[3]
  2642. fmt.Println(card_sn)
  2643. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2644. var dat map[string]interface{}
  2645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2646. fmt.Println(dat)
  2647. } else {
  2648. fmt.Println(err)
  2649. }
  2650. userJSONBytes, _ := json.Marshal(dat)
  2651. var res ResultTwo
  2652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2653. utils.ErrorLog("解析失败:%v", err)
  2654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2655. return
  2656. }
  2657. if res.Infcode == 0 {
  2658. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2659. if err == gorm.ErrRecordNotFound {
  2660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2661. return
  2662. } else if err != nil {
  2663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2664. return
  2665. } else {
  2666. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2667. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2668. infoStr := string(Iinfos)
  2669. idetinfoStr := string(Idetinfos)
  2670. psn := &models.HisPsn{
  2671. PsnNo: res.Output.Baseinfo.PsnNo,
  2672. Age: res.Output.Baseinfo.Age,
  2673. PatientId: patient.ID,
  2674. Certno: res.Output.Baseinfo.Certno,
  2675. Brdy: res.Output.Baseinfo.Brdy,
  2676. Gend: res.Output.Baseinfo.Gend,
  2677. Naty: res.Output.Baseinfo.Naty,
  2678. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2679. PsnName: res.Output.Baseinfo.PsnName,
  2680. Idetinfo: idetinfoStr,
  2681. Insuinfo: infoStr,
  2682. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2683. CardInfo: basStr,
  2684. VerifyNumber: "",
  2685. }
  2686. service.CreateHisPsn(psn)
  2687. c.ServeSuccessJSON(map[string]interface{}{
  2688. "patient": patient,
  2689. "number": basNumber,
  2690. })
  2691. }
  2692. } else {
  2693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2694. return
  2695. }
  2696. break
  2697. }
  2698. case 2:
  2699. if miConfig.MdtrtareaAdmvs == "430800" {
  2700. if initFlag == 0 {
  2701. c.TestGetHnBasBaseInit()
  2702. }
  2703. SFZStr := c.GetSFZBaseInfo()
  2704. if len(SFZStr) == 0 {
  2705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2706. return
  2707. }
  2708. fmt.Println(SFZStr)
  2709. id_card_str := strings.Split(SFZStr, "^")
  2710. card_no := id_card_str[0]
  2711. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2712. //name := id_card_str[1]
  2713. //name = ConvertToString(name, "gbk", "utf-8")
  2714. 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)
  2715. var dat map[string]interface{}
  2716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2717. fmt.Println(dat)
  2718. } else {
  2719. fmt.Println(err)
  2720. }
  2721. userJSONBytes, _ := json.Marshal(dat)
  2722. var res ResultTwo
  2723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2724. utils.ErrorLog("解析失败:%v", err)
  2725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2726. return
  2727. }
  2728. if res.Infcode == 0 {
  2729. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2730. if err == gorm.ErrRecordNotFound {
  2731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2732. return
  2733. } else if err != nil {
  2734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2735. return
  2736. } else {
  2737. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2738. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2739. infoStr := string(Iinfos)
  2740. idetinfoStr := string(Idetinfos)
  2741. psn := &models.HisPsn{
  2742. PsnNo: res.Output.Baseinfo.PsnNo,
  2743. Age: res.Output.Baseinfo.Age,
  2744. PatientId: patient.ID,
  2745. Certno: res.Output.Baseinfo.Certno,
  2746. Brdy: res.Output.Baseinfo.Brdy,
  2747. Gend: res.Output.Baseinfo.Gend,
  2748. Naty: res.Output.Baseinfo.Naty,
  2749. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2750. PsnName: res.Output.Baseinfo.PsnName,
  2751. Idetinfo: idetinfoStr,
  2752. Insuinfo: infoStr,
  2753. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2754. CardInfo: SFZStr,
  2755. VerifyNumber: "",
  2756. }
  2757. service.CreateHisPsn(psn)
  2758. var rf []*ResultFive
  2759. json.Unmarshal([]byte(infoStr), &rf)
  2760. var insutypes []*ResultFive
  2761. var insutype string
  2762. var is390 int = 0
  2763. var is310 int = 0
  2764. for _, item := range rf {
  2765. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2766. insutypes = append(insutypes, item)
  2767. }
  2768. }
  2769. if len(insutypes) == 1 {
  2770. insutype = insutypes[0].Insutype
  2771. } else {
  2772. for _, i := range insutypes {
  2773. if i.Insutype == "390" {
  2774. is390 = 1
  2775. }
  2776. if i.Insutype == "310" {
  2777. is310 = 1
  2778. }
  2779. }
  2780. }
  2781. if is390 == 1 {
  2782. insutype = "390"
  2783. }
  2784. if is310 == 1 {
  2785. insutype = "310"
  2786. }
  2787. if len(insutypes) == 0 {
  2788. insutype = "310"
  2789. }
  2790. c.ServeSuccessJSON(map[string]interface{}{
  2791. "patient": patient,
  2792. "number": card_no,
  2793. "insutype": insutype,
  2794. })
  2795. }
  2796. } else {
  2797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2798. return
  2799. }
  2800. } else {
  2801. SFZStr := c.GetSFZBaseInfo()
  2802. id_card_str := strings.Split(SFZStr, "^")
  2803. id_card_number := id_card_str[0]
  2804. card_sn := ""
  2805. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2806. var dat map[string]interface{}
  2807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2808. fmt.Println(dat)
  2809. } else {
  2810. fmt.Println(err)
  2811. }
  2812. userJSONBytes, _ := json.Marshal(dat)
  2813. var res ResultTwo
  2814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2815. utils.ErrorLog("解析失败:%v", err)
  2816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2817. return
  2818. }
  2819. if res.Infcode == 0 {
  2820. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2821. if err == gorm.ErrRecordNotFound {
  2822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2823. return
  2824. } else if err != nil {
  2825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2826. return
  2827. } else {
  2828. c.ServeSuccessJSON(map[string]interface{}{
  2829. "patient": patient,
  2830. "number": id_card_number,
  2831. })
  2832. }
  2833. } else {
  2834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2835. return
  2836. }
  2837. }
  2838. break
  2839. case 3:
  2840. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2841. var api string
  2842. if miConfig.MdtrtareaAdmvs == "320921" {
  2843. 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 +
  2844. "&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
  2845. fmt.Println(api)
  2846. } else {
  2847. 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 +
  2848. "&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)
  2849. }
  2850. resp, requestErr := http.Get(api)
  2851. if requestErr != nil {
  2852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2853. return
  2854. }
  2855. body, ioErr := ioutil.ReadAll(resp.Body)
  2856. if ioErr != nil {
  2857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2859. return
  2860. }
  2861. var respJSON map[string]interface{}
  2862. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2865. return
  2866. }
  2867. var status string
  2868. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2869. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2870. var token string
  2871. var res ResultTwo //1101结果
  2872. var res10265 ResultTwo10265 //1101结果
  2873. var card_info string //卡信息
  2874. var busi_card_info string
  2875. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2876. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2877. if status == "0" { //读卡成功
  2878. if card_type == "1" {
  2879. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2880. result, _ := json.Marshal(respJSON)
  2881. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2882. utils.ErrorLog("解析失败:%v", err)
  2883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2884. return
  2885. }
  2886. res.ErrMsg = res10265.ErrMsg
  2887. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2888. res.Infcode = infocode
  2889. res.Output = res10265.Output
  2890. res.InfRefmsgid = res10265.InfRefmsgid
  2891. } else {
  2892. //var card_info string //卡信息
  2893. //var busi_card_info string
  2894. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2895. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2896. //fmt.Println(card_info)
  2897. //fmt.Println(busi_card_info)
  2898. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2899. result, _ := json.Marshal(respJSON)
  2900. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2901. utils.ErrorLog("解析失败:%v", err)
  2902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2903. return
  2904. }
  2905. res.ErrMsg = res10265.ErrMsg
  2906. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2907. res.Infcode = infocode
  2908. res.Output = res10265.Output
  2909. res.InfRefmsgid = res10265.InfRefmsgid
  2910. }
  2911. if res.Infcode == 0 {
  2912. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2913. if err == gorm.ErrRecordNotFound {
  2914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2915. return
  2916. } else if err != nil {
  2917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2918. return
  2919. } else {
  2920. if card_type == "1" {
  2921. bas := strings.Split(card_info, "|")
  2922. basNumber := bas[2]
  2923. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2924. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2925. infoStr := string(Iinfos)
  2926. idetinfoStr := string(Idetinfos)
  2927. psn := &models.HisPsn{
  2928. PsnNo: res.Output.Baseinfo.PsnNo,
  2929. Age: res.Output.Baseinfo.Age,
  2930. PatientId: patient.ID,
  2931. Certno: res.Output.Baseinfo.Certno,
  2932. Brdy: res.Output.Baseinfo.Brdy,
  2933. Gend: res.Output.Baseinfo.Gend,
  2934. Naty: res.Output.Baseinfo.Naty,
  2935. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2936. PsnName: res.Output.Baseinfo.PsnName,
  2937. Idetinfo: idetinfoStr,
  2938. Insuinfo: infoStr,
  2939. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2940. CardInfo: card_info,
  2941. VerifyNumber: busi_card_info,
  2942. }
  2943. service.CreateHisPsn(psn)
  2944. c.ServeSuccessJSON(map[string]interface{}{
  2945. "patient": patient,
  2946. "number": basNumber,
  2947. })
  2948. } else {
  2949. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2950. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2951. infoStr := string(Iinfos)
  2952. idetinfoStr := string(Idetinfos)
  2953. psn := &models.HisPsn{
  2954. PsnNo: res.Output.Baseinfo.PsnNo,
  2955. Age: res.Output.Baseinfo.Age,
  2956. PatientId: patient.ID,
  2957. Certno: res.Output.Baseinfo.Certno,
  2958. Brdy: res.Output.Baseinfo.Brdy,
  2959. Gend: res.Output.Baseinfo.Gend,
  2960. Naty: res.Output.Baseinfo.Naty,
  2961. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2962. PsnName: res.Output.Baseinfo.PsnName,
  2963. Idetinfo: idetinfoStr,
  2964. Insuinfo: infoStr,
  2965. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2966. CardInfo: card_info,
  2967. VerifyNumber: token,
  2968. }
  2969. service.CreateHisPsn(psn)
  2970. var rf []*ResultFive
  2971. json.Unmarshal([]byte(infoStr), &rf)
  2972. var insutypes []*ResultFive
  2973. var insutype string
  2974. var is390 int = 0
  2975. var is310 int = 0
  2976. for _, item := range rf {
  2977. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2978. insutypes = append(insutypes, item)
  2979. }
  2980. }
  2981. if len(insutypes) == 1 {
  2982. insutype = insutypes[0].Insutype
  2983. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2984. } else {
  2985. for _, i := range insutypes {
  2986. if i.Insutype == "390" {
  2987. is390 = 1
  2988. }
  2989. if i.Insutype == "310" {
  2990. is310 = 1
  2991. }
  2992. }
  2993. }
  2994. if is390 == 1 {
  2995. insutype = "390"
  2996. }
  2997. if is310 == 1 {
  2998. insutype = "310"
  2999. }
  3000. if len(insutypes) == 0 {
  3001. insutype = "310"
  3002. }
  3003. c.ServeSuccessJSON(map[string]interface{}{
  3004. "patient": patient,
  3005. "number": token,
  3006. "insutype": insutype,
  3007. })
  3008. }
  3009. }
  3010. } else {
  3011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3012. return
  3013. }
  3014. } else { //读卡失败
  3015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3016. return
  3017. }
  3018. }
  3019. break
  3020. case 4:
  3021. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3022. var api string
  3023. if miConfig.MdtrtareaAdmvs == "320921" {
  3024. 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 +
  3025. "&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
  3026. fmt.Println(api)
  3027. } else {
  3028. 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 +
  3029. "&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)
  3030. }
  3031. resp, requestErr := http.Get(api)
  3032. if requestErr != nil {
  3033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3034. return
  3035. }
  3036. body, ioErr := ioutil.ReadAll(resp.Body)
  3037. if ioErr != nil {
  3038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3040. return
  3041. }
  3042. var respJSON map[string]interface{}
  3043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3046. return
  3047. }
  3048. var status string
  3049. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3050. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3051. var token string
  3052. var res ResultTwo //1101结果
  3053. var res10265 ResultTwo10265 //1101结果
  3054. if status == "0" { //读卡成功
  3055. var card_info string //卡信息
  3056. var busi_card_info string
  3057. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3058. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3059. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3060. fmt.Println(card_info)
  3061. fmt.Println(busi_card_info)
  3062. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3063. result, _ := json.Marshal(respJSON)
  3064. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3065. utils.ErrorLog("解析失败:%v", err)
  3066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3067. return
  3068. }
  3069. res.ErrMsg = res10265.ErrMsg
  3070. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3071. res.Infcode = infocode
  3072. res.Output = res10265.Output
  3073. res.InfRefmsgid = res10265.InfRefmsgid
  3074. if res.Infcode == 0 {
  3075. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3076. if err == gorm.ErrRecordNotFound {
  3077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3078. return
  3079. } else if err != nil {
  3080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3081. return
  3082. } else {
  3083. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3084. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3085. infoStr := string(Iinfos)
  3086. idetinfoStr := string(Idetinfos)
  3087. psn := &models.HisPsn{
  3088. PsnNo: res.Output.Baseinfo.PsnNo,
  3089. Age: res.Output.Baseinfo.Age,
  3090. PatientId: patient.ID,
  3091. Certno: res.Output.Baseinfo.Certno,
  3092. Brdy: res.Output.Baseinfo.Brdy,
  3093. Gend: res.Output.Baseinfo.Gend,
  3094. Naty: res.Output.Baseinfo.Naty,
  3095. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3096. PsnName: res.Output.Baseinfo.PsnName,
  3097. Idetinfo: idetinfoStr,
  3098. Insuinfo: infoStr,
  3099. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3100. CardInfo: card_info,
  3101. VerifyNumber: token,
  3102. }
  3103. var rf []*ResultFive
  3104. json.Unmarshal([]byte(infoStr), &rf)
  3105. var insutypes []*ResultFive
  3106. var insutype string
  3107. var is390 int = 0
  3108. var is310 int = 0
  3109. for _, item := range rf {
  3110. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3111. insutypes = append(insutypes, item)
  3112. }
  3113. }
  3114. if len(insutypes) == 1 {
  3115. insutype = insutypes[0].Insutype
  3116. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3117. } else {
  3118. for _, i := range insutypes {
  3119. if i.Insutype == "390" {
  3120. is390 = 1
  3121. }
  3122. if i.Insutype == "310" {
  3123. is310 = 1
  3124. }
  3125. }
  3126. }
  3127. if is390 == 1 {
  3128. insutype = "390"
  3129. }
  3130. if is310 == 1 {
  3131. insutype = "310"
  3132. }
  3133. if len(insutypes) == 0 {
  3134. insutype = "310"
  3135. }
  3136. service.CreateHisPsn(psn)
  3137. c.ServeSuccessJSON(map[string]interface{}{
  3138. "patient": patient,
  3139. "number": token,
  3140. "insutype": insutype,
  3141. })
  3142. }
  3143. } else {
  3144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3145. return
  3146. }
  3147. } else { //读卡失败
  3148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3149. return
  3150. }
  3151. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  3152. if initFlag == 0 {
  3153. c.TestGetBasBaseInit()
  3154. }
  3155. token := c.GetEleBaseInfo()
  3156. token = Remove0000(token)
  3157. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  3158. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3159. //
  3160. var res ResultTwo
  3161. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3162. utils.ErrorLog("解析失败:%v", err)
  3163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3164. return
  3165. }
  3166. if res.Infcode == 0 {
  3167. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3168. if err == gorm.ErrRecordNotFound {
  3169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3170. return
  3171. } else if err != nil {
  3172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3173. return
  3174. } else {
  3175. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3176. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3177. infoStr := string(Iinfos)
  3178. idetinfoStr := string(Idetinfos)
  3179. psn := &models.HisPsn{
  3180. PsnNo: res.Output.Baseinfo.PsnNo,
  3181. Age: res.Output.Baseinfo.Age,
  3182. PatientId: patient.ID,
  3183. Certno: res.Output.Baseinfo.Certno,
  3184. Brdy: res.Output.Baseinfo.Brdy,
  3185. Gend: res.Output.Baseinfo.Gend,
  3186. Naty: res.Output.Baseinfo.Naty,
  3187. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3188. PsnName: res.Output.Baseinfo.PsnName,
  3189. Idetinfo: idetinfoStr,
  3190. Insuinfo: infoStr,
  3191. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3192. CardInfo: "",
  3193. VerifyNumber: token,
  3194. }
  3195. service.CreateHisPsn(psn)
  3196. c.ServeSuccessJSON(map[string]interface{}{
  3197. "patient": patient,
  3198. "number": token,
  3199. })
  3200. }
  3201. } else {
  3202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3203. return
  3204. }
  3205. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3206. if initFlag == 0 {
  3207. c.TestGetBasBaseInit()
  3208. }
  3209. token := c.GetEleBaseInfo()
  3210. token = Remove0000(token)
  3211. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  3212. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3213. //
  3214. var res ResultTwo
  3215. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3216. utils.ErrorLog("解析失败:%v", err)
  3217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3218. return
  3219. }
  3220. if res.Infcode == 0 {
  3221. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3222. if err == gorm.ErrRecordNotFound {
  3223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3224. return
  3225. } else if err != nil {
  3226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3227. return
  3228. } else {
  3229. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3230. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3231. infoStr := string(Iinfos)
  3232. idetinfoStr := string(Idetinfos)
  3233. psn := &models.HisPsn{
  3234. PsnNo: res.Output.Baseinfo.PsnNo,
  3235. Age: res.Output.Baseinfo.Age,
  3236. PatientId: patient.ID,
  3237. Certno: res.Output.Baseinfo.Certno,
  3238. Brdy: res.Output.Baseinfo.Brdy,
  3239. Gend: res.Output.Baseinfo.Gend,
  3240. Naty: res.Output.Baseinfo.Naty,
  3241. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3242. PsnName: res.Output.Baseinfo.PsnName,
  3243. Idetinfo: idetinfoStr,
  3244. Insuinfo: infoStr,
  3245. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3246. CardInfo: "",
  3247. VerifyNumber: token,
  3248. }
  3249. service.CreateHisPsn(psn)
  3250. c.ServeSuccessJSON(map[string]interface{}{
  3251. "patient": patient,
  3252. "number": token,
  3253. })
  3254. }
  3255. } else {
  3256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3257. return
  3258. }
  3259. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3260. //if initFlag == 0 {
  3261. c.TestGetJiangXiBasBaseInit()
  3262. //}
  3263. //if initEleFlag == 0 {
  3264. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3265. //}
  3266. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3267. type ELeData struct {
  3268. Data struct {
  3269. IdNo string `json:"idNo"`
  3270. IdType string `json:"idType"`
  3271. UserName string `json:"userName"`
  3272. EcToken string `json:"ecToken"`
  3273. InsuOrg string `json:"insuOrg"`
  3274. Gender string `json:"gender"`
  3275. Birthday string `json:"birthday"`
  3276. Nationality string `json:"nationality"`
  3277. Email string `json:"email"`
  3278. Extra string `json:"extra"`
  3279. } `json:"data"`
  3280. Code int `json:"code"`
  3281. Message string `json:"message"`
  3282. }
  3283. var ele ELeData
  3284. err := json.Unmarshal([]byte(json_result), &ele)
  3285. if err != nil {
  3286. utils.ErrorLog("解析失败:%v", err)
  3287. }
  3288. token := ele.Data.EcToken
  3289. token = Remove0000(token)
  3290. 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)
  3291. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3292. var res ResultTwo
  3293. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3294. utils.ErrorLog("解析失败:%v", err)
  3295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3296. return
  3297. }
  3298. if res.Infcode == 0 {
  3299. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3300. if err == gorm.ErrRecordNotFound {
  3301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3302. return
  3303. } else if err != nil {
  3304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3305. return
  3306. } else {
  3307. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3308. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3309. infoStr := string(Iinfos)
  3310. idetinfoStr := string(Idetinfos)
  3311. psn := &models.HisPsn{
  3312. PsnNo: res.Output.Baseinfo.PsnNo,
  3313. Age: res.Output.Baseinfo.Age,
  3314. PatientId: patient.ID,
  3315. Certno: res.Output.Baseinfo.Certno,
  3316. Brdy: res.Output.Baseinfo.Brdy,
  3317. Gend: res.Output.Baseinfo.Gend,
  3318. Naty: res.Output.Baseinfo.Naty,
  3319. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3320. PsnName: res.Output.Baseinfo.PsnName,
  3321. Idetinfo: idetinfoStr,
  3322. Insuinfo: infoStr,
  3323. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3324. CardInfo: "",
  3325. VerifyNumber: token,
  3326. }
  3327. service.CreateHisPsn(psn)
  3328. var rf []*ResultFive
  3329. json.Unmarshal([]byte(infoStr), &rf)
  3330. var insutypes []*ResultFive
  3331. var insutype string
  3332. var is390 int = 0
  3333. var is310 int = 0
  3334. for _, item := range rf {
  3335. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3336. insutypes = append(insutypes, item)
  3337. }
  3338. }
  3339. if len(insutypes) == 1 {
  3340. insutype = insutypes[0].Insutype
  3341. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3342. } else {
  3343. for _, i := range insutypes {
  3344. if i.Insutype == "390" {
  3345. is390 = 1
  3346. }
  3347. if i.Insutype == "310" {
  3348. is310 = 1
  3349. }
  3350. }
  3351. }
  3352. if is390 == 1 {
  3353. insutype = "390"
  3354. }
  3355. if is310 == 1 {
  3356. insutype = "310"
  3357. }
  3358. if len(insutypes) == 0 {
  3359. insutype = "310"
  3360. }
  3361. c.ServeSuccessJSON(map[string]interface{}{
  3362. "patient": patient,
  3363. "number": token,
  3364. "insutype": insutype,
  3365. })
  3366. }
  3367. } else {
  3368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3369. return
  3370. }
  3371. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3372. //if initFlag == 0 {
  3373. c.TestGetJiangXiBasBaseInit()
  3374. //}
  3375. //if initEleFlag == 0 {
  3376. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3377. //}
  3378. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3379. type ELeData struct {
  3380. Data struct {
  3381. IdNo string `json:"idNo"`
  3382. IdType string `json:"idType"`
  3383. UserName string `json:"userName"`
  3384. EcToken string `json:"ecToken"`
  3385. InsuOrg string `json:"insuOrg"`
  3386. Gender string `json:"gender"`
  3387. Birthday string `json:"birthday"`
  3388. Nationality string `json:"nationality"`
  3389. Email string `json:"email"`
  3390. Extra string `json:"extra"`
  3391. } `json:"data"`
  3392. Code int `json:"code"`
  3393. Message string `json:"message"`
  3394. }
  3395. var ele ELeData
  3396. err := json.Unmarshal([]byte(json_result), &ele)
  3397. if err != nil {
  3398. utils.ErrorLog("解析失败:%v", err)
  3399. }
  3400. token := ele.Data.EcToken
  3401. token = Remove0000(token)
  3402. 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)
  3403. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3404. var res ResultTwo
  3405. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3406. utils.ErrorLog("解析失败:%v", err)
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3408. return
  3409. }
  3410. if res.Infcode == 0 {
  3411. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3412. if err == gorm.ErrRecordNotFound {
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3414. return
  3415. } else if err != nil {
  3416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3417. return
  3418. } else {
  3419. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3420. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3421. infoStr := string(Iinfos)
  3422. idetinfoStr := string(Idetinfos)
  3423. psn := &models.HisPsn{
  3424. PsnNo: res.Output.Baseinfo.PsnNo,
  3425. Age: res.Output.Baseinfo.Age,
  3426. PatientId: patient.ID,
  3427. Certno: res.Output.Baseinfo.Certno,
  3428. Brdy: res.Output.Baseinfo.Brdy,
  3429. Gend: res.Output.Baseinfo.Gend,
  3430. Naty: res.Output.Baseinfo.Naty,
  3431. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3432. PsnName: res.Output.Baseinfo.PsnName,
  3433. Idetinfo: idetinfoStr,
  3434. Insuinfo: infoStr,
  3435. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3436. CardInfo: "",
  3437. VerifyNumber: token,
  3438. }
  3439. service.CreateHisPsn(psn)
  3440. var rf []*ResultFive
  3441. json.Unmarshal([]byte(infoStr), &rf)
  3442. var insutypes []*ResultFive
  3443. var insutype string
  3444. var is390 int = 0
  3445. var is310 int = 0
  3446. for _, item := range rf {
  3447. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3448. insutypes = append(insutypes, item)
  3449. }
  3450. }
  3451. if len(insutypes) == 1 {
  3452. insutype = insutypes[0].Insutype
  3453. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3454. } else {
  3455. for _, i := range insutypes {
  3456. if i.Insutype == "390" {
  3457. is390 = 1
  3458. }
  3459. if i.Insutype == "310" {
  3460. is310 = 1
  3461. }
  3462. }
  3463. }
  3464. if is390 == 1 {
  3465. insutype = "390"
  3466. }
  3467. if is310 == 1 {
  3468. insutype = "310"
  3469. }
  3470. if len(insutypes) == 0 {
  3471. insutype = "310"
  3472. }
  3473. c.ServeSuccessJSON(map[string]interface{}{
  3474. "patient": patient,
  3475. "number": token,
  3476. "insutype": insutype,
  3477. })
  3478. }
  3479. } else {
  3480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3481. return
  3482. }
  3483. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3484. type ELeData struct {
  3485. Code string `json:"code"`
  3486. Data struct {
  3487. Aac002 string `json:"aac002"`
  3488. Aaz500 string `json:"aaz500"`
  3489. ActCardNo string `json:"actCardNo"`
  3490. Bab520 string `json:"bab520"`
  3491. Bkz543 string `json:"bkz543"`
  3492. BusinessType string `json:"businessType"`
  3493. CertfCodg string `json:"certfCodg"`
  3494. EcIndexNo string `json:"ecIndexNo"`
  3495. EcToken string `json:"ecToken"`
  3496. ID0000 string `json:"id0000"`
  3497. IDNo string `json:"idNo"`
  3498. IDType string `json:"idType"`
  3499. Idcode string `json:"idcode"`
  3500. IdentityToken string `json:"identity_token"`
  3501. InsuOrg string `json:"insuOrg"`
  3502. OfficeID string `json:"officeId"`
  3503. OfficeName string `json:"officeName"`
  3504. OperatorID string `json:"operatorId"`
  3505. OperatorName string `json:"operatorName"`
  3506. OrgID string `json:"orgId"`
  3507. UserName string `json:"userName"`
  3508. } `json:"data"`
  3509. Infno interface{} `json:"infno"`
  3510. Message string `json:"message"`
  3511. OrgID string `json:"orgId"`
  3512. TransType string `json:"transType"`
  3513. }
  3514. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3515. outPutInfo = Remove0000(outPutInfo)
  3516. if len(outPutInfo) > 0 {
  3517. var ele ELeData
  3518. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3519. if err != nil {
  3520. utils.ErrorLog("解析失败:%v", err)
  3521. }
  3522. token := ele.Data.EcToken
  3523. fmt.Println(inputInfo)
  3524. fmt.Println(outPutInfo)
  3525. 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)
  3526. saveLog(result, requestLog, "1101", "获取人员信息")
  3527. var dat map[string]interface{}
  3528. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3529. fmt.Println(dat)
  3530. } else {
  3531. fmt.Println(err)
  3532. }
  3533. userJSONBytes, _ := json.Marshal(dat)
  3534. var res ResultTwo
  3535. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3536. utils.ErrorLog("解析失败:%v", err)
  3537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3538. return
  3539. }
  3540. res.ErrMsg = errMsgLog
  3541. if res.Infcode == 0 {
  3542. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  3543. if err == gorm.ErrRecordNotFound {
  3544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3545. return
  3546. } else if err != nil {
  3547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3548. return
  3549. } else {
  3550. fmt.Println(res)
  3551. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3552. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3553. infoStr := string(Iinfos)
  3554. idetinfoStr := string(Idetinfos)
  3555. psn := &models.HisPsn{
  3556. PsnNo: res.Output.Baseinfo.PsnNo,
  3557. Age: res.Output.Baseinfo.Age,
  3558. PatientId: patient.ID,
  3559. Certno: res.Output.Baseinfo.Certno,
  3560. Brdy: res.Output.Baseinfo.Brdy,
  3561. Gend: res.Output.Baseinfo.Gend,
  3562. Naty: res.Output.Baseinfo.Naty,
  3563. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3564. PsnName: res.Output.Baseinfo.PsnName,
  3565. Idetinfo: idetinfoStr,
  3566. Insuinfo: infoStr,
  3567. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3568. CardInfo: outPutInfo,
  3569. VerifyNumber: token,
  3570. InsuplcAdmdvs: ele.Data.InsuOrg,
  3571. }
  3572. service.CreateHisPsn(psn)
  3573. var rf []*ResultFive
  3574. json.Unmarshal([]byte(infoStr), &rf)
  3575. var insutypes []*ResultFive
  3576. var insutype string
  3577. var is390 int = 0
  3578. var is310 int = 0
  3579. for _, item := range rf {
  3580. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3581. insutypes = append(insutypes, item)
  3582. }
  3583. }
  3584. if len(insutypes) == 1 {
  3585. insutype = insutypes[0].Insutype
  3586. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3587. } else {
  3588. for _, i := range insutypes {
  3589. if i.Insutype == "390" {
  3590. is390 = 1
  3591. }
  3592. if i.Insutype == "310" {
  3593. is310 = 1
  3594. }
  3595. }
  3596. }
  3597. if is390 == 1 {
  3598. insutype = "390"
  3599. }
  3600. if is310 == 1 {
  3601. insutype = "310"
  3602. }
  3603. if len(insutypes) == 0 {
  3604. insutype = "310"
  3605. }
  3606. c.ServeSuccessJSON(map[string]interface{}{
  3607. "patient": patient,
  3608. "number": token,
  3609. "insutype": insutype,
  3610. })
  3611. }
  3612. } else {
  3613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3614. return
  3615. }
  3616. }
  3617. }
  3618. break
  3619. }
  3620. }
  3621. var initFlag int64 = 0
  3622. var initEleFlag int64 = 0
  3623. func (c *HisApiController) TestGetBasBaseInit() {
  3624. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3625. Iinit := DllDef.MustFindProc("Init")
  3626. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3627. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3628. if ret != 0 {
  3629. fmt.Println("SSCard的报错原因:", err)
  3630. fmt.Println("SSCard的运算结果为:", ret)
  3631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3632. return
  3633. }
  3634. result := int(ret)
  3635. fmt.Println("SSCard的运算结果为1:", result)
  3636. initFlag = 1
  3637. return
  3638. }
  3639. func (c *HisApiController) HandleJiangXiReadCard() {
  3640. fmt.Println("~~~~~~")
  3641. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3642. admin_user_id, _ := c.GetInt64("admin_user_id")
  3643. id_card_type, _ := c.GetInt64("id_card_type")
  3644. //certificates, _ := c.GetInt64("certificates")
  3645. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3646. if initFlag == 0 {
  3647. c.TestGetJiangXiBasBaseInit()
  3648. }
  3649. basStr := c.GetBasBaseInfo()
  3650. if len(basStr) == 0 {
  3651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3652. return
  3653. }
  3654. fmt.Println(basStr)
  3655. bas := strings.Split(basStr, "|")
  3656. basNumber := bas[1]
  3657. fmt.Println(basNumber)
  3658. card_sn := bas[3]
  3659. fmt.Println(card_sn)
  3660. 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, "")
  3661. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3662. var dat map[string]interface{}
  3663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3664. fmt.Println(dat)
  3665. } else {
  3666. fmt.Println(err)
  3667. }
  3668. userJSONBytes, _ := json.Marshal(dat)
  3669. var res ResultTwo
  3670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3671. utils.ErrorLog("解析失败:%v", err)
  3672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3673. return
  3674. }
  3675. if res.Infcode == 0 {
  3676. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3677. if err == gorm.ErrRecordNotFound {
  3678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3679. return
  3680. } else if err != nil {
  3681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3682. return
  3683. } else {
  3684. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3685. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3686. infoStr := string(Iinfos)
  3687. idetinfoStr := string(Idetinfos)
  3688. psn := &models.HisPsn{
  3689. PsnNo: res.Output.Baseinfo.PsnNo,
  3690. Age: res.Output.Baseinfo.Age,
  3691. PatientId: patient.ID,
  3692. Certno: res.Output.Baseinfo.Certno,
  3693. Brdy: res.Output.Baseinfo.Brdy,
  3694. Gend: res.Output.Baseinfo.Gend,
  3695. Naty: res.Output.Baseinfo.Naty,
  3696. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3697. PsnName: res.Output.Baseinfo.PsnName,
  3698. Idetinfo: idetinfoStr,
  3699. Insuinfo: infoStr,
  3700. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3701. CardInfo: basStr,
  3702. VerifyNumber: "",
  3703. }
  3704. service.CreateHisPsn(psn)
  3705. c.ServeSuccessJSON(map[string]interface{}{
  3706. "patient": patient,
  3707. "number": basNumber,
  3708. })
  3709. }
  3710. } else {
  3711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3712. return
  3713. }
  3714. }
  3715. func (c *HisApiController) TestGetHnBasBaseInit() {
  3716. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3717. Iinit := DllDef.MustFindProc("Init")
  3718. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3719. //http://10.77.211.236/CSB/hsa-fsi-1303
  3720. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  3721. if ret != 0 {
  3722. fmt.Println("SSCard的报错原因:", err)
  3723. fmt.Println("SSCard的运算结果为:", ret)
  3724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3725. return
  3726. }
  3727. result := int(ret)
  3728. fmt.Println("SSCard的运算结果为1:", result)
  3729. initFlag = 1
  3730. return
  3731. }
  3732. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3733. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3734. Iinit := DllDef.MustFindProc("Init")
  3735. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3736. //http://10.77.211.236/CSB/hsa-fsi-1303
  3737. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3738. if ret != 0 {
  3739. fmt.Println("SSCard的报错原因:", err)
  3740. fmt.Println("SSCard的运算结果为:", ret)
  3741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3742. return
  3743. }
  3744. result := int(ret)
  3745. fmt.Println("SSCard的运算结果为1:", result)
  3746. initFlag = 1
  3747. return
  3748. }
  3749. func (c *HisApiController) GetSFZBaseInfo() string {
  3750. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3751. readCard := DllDef.MustFindProc("ReadSFZ")
  3752. if readCard == nil {
  3753. fmt.Println("readcard is nil")
  3754. readCard = DllDef.MustFindProc("ReadSFZ")
  3755. }
  3756. str := make([]byte, 8096)
  3757. str1 := make([]byte, 8096)
  3758. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  3759. fmt.Println(r)
  3760. return Remove0000(string(str))
  3761. }
  3762. func (c *HisApiController) GetEleBaseInfo() string {
  3763. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3764. readCard := DllDef.MustFindProc("GetQRBase")
  3765. fmt.Println(readCard)
  3766. if readCard == nil {
  3767. fmt.Println("readcard is nil")
  3768. readCard = DllDef.MustFindProc("GetQRBase")
  3769. }
  3770. str := make([]byte, 1024)
  3771. str1 := make([]byte, 1024)
  3772. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3773. fmt.Println(ret2)
  3774. fmt.Println(string(str1))
  3775. fmt.Println(string(str))
  3776. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3777. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3778. if ret2 != 0 {
  3779. return ""
  3780. }
  3781. return string(str)
  3782. }
  3783. func GetJxEleBaseInfo(org_id int64) string {
  3784. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3785. readCard := DllDef.MustFindProc("NationEcTrans")
  3786. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3787. if readCard == nil {
  3788. fmt.Println("readcard is nil")
  3789. readCard = DllDef.MustFindProc("NationEcTrans")
  3790. }
  3791. str1 := make([]byte, 1024)
  3792. data := make(map[string]interface{})
  3793. inputData := make(map[string]interface{})
  3794. inputData["orgId"] = miConfig.Code
  3795. inputData["businessType"] = "01101"
  3796. inputData["operatorId"] = "test001"
  3797. inputData["operatorName"] = "cn"
  3798. inputData["officeId"] = "32760"
  3799. inputData["officeName"] = "waike"
  3800. inputData["deviceType"] = ""
  3801. data["data"] = inputData
  3802. data["transType"] = "ec.query"
  3803. data["extra "] = ""
  3804. data["orgId"] = miConfig.Code
  3805. bytesData, _ := json.Marshal(data)
  3806. //bytesData, _ := json.Marshal(data)
  3807. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3808. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3809. fmt.Println(ret2)
  3810. fmt.Println(string(str1))
  3811. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3812. if ret2 != 0 {
  3813. return ""
  3814. }
  3815. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3816. }
  3817. func GetJxEleBaseInitInfo(org_id int64) string {
  3818. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3819. readCard := DllDef.MustFindProc("NationEcTrans")
  3820. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3821. if readCard == nil {
  3822. fmt.Println("readcard is nil")
  3823. readCard = DllDef.MustFindProc("NationEcTrans")
  3824. }
  3825. str1 := make([]byte, 2048)
  3826. data := make(map[string]interface{})
  3827. inputData := make(map[string]interface{})
  3828. inputData["orgId"] = miConfig.Code
  3829. inputData["businessType"] = "01101"
  3830. inputData["operatorId"] = "1"
  3831. inputData["operatorName"] = "huangchuang"
  3832. inputData["officeId"] = "101"
  3833. inputData["officeName"] = "xuetou"
  3834. inputData["deviceType"] = ""
  3835. data["data"] = inputData
  3836. data["transType"] = "ec.query"
  3837. data["orgId"] = miConfig.Code
  3838. bytesData, _ := json.Marshal(data)
  3839. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3840. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3841. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3842. fmt.Println(ret2)
  3843. fmt.Println(string(str1))
  3844. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3845. if ret2 != 0 {
  3846. return ""
  3847. }
  3848. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3849. initEleFlag = 1
  3850. }
  3851. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3852. }
  3853. func (c *HisApiController) GetBasBaseInfo() string {
  3854. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3855. readCard := DllDef.MustFindProc("ReadCardBas")
  3856. if readCard == nil {
  3857. fmt.Println("readcard is nil")
  3858. readCard = DllDef.MustFindProc("ReadCardBas")
  3859. }
  3860. str := make([]byte, 1024)
  3861. str1 := make([]byte, 1024)
  3862. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3863. fmt.Println(string(str1))
  3864. fmt.Println(string(str))
  3865. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3866. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3867. if ret2 != 0 {
  3868. return ""
  3869. }
  3870. return string(str)
  3871. }
  3872. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3873. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3874. readCard := DllDef.MustFindProc("read_cardinfo")
  3875. if readCard == nil {
  3876. fmt.Println("readcard is nil")
  3877. readCard = DllDef.MustFindProc("read_cardinfo")
  3878. }
  3879. str := make([]byte, 1024) //卡号
  3880. str1 := make([]byte, 1024) //卡识别码
  3881. str2 := make([]byte, 1024) //身份证号
  3882. str3 := make([]byte, 1024) //姓名
  3883. str4 := make([]byte, 1024) //错误信息
  3884. 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])))
  3885. fmt.Println(string(str1))
  3886. fmt.Println(string(str))
  3887. fmt.Println(string(str2))
  3888. fmt.Println(string(str3))
  3889. fmt.Println(string(str4))
  3890. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3891. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3892. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3893. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3894. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3895. if ret2 != 0 {
  3896. return "", "", "", "", ""
  3897. }
  3898. return string(str), string(str1), string(str2), string(str3), string(str4)
  3899. }
  3900. type CustomFundPay struct {
  3901. FundPayType string `json:"fund_pay_type"`
  3902. FundPayamt float64 `json:"fund_payamt"`
  3903. }
  3904. func (c *HisApiController) GetSettleList() {
  3905. order_id, _ := c.GetInt64("order_id")
  3906. admin_user_id, _ := c.GetInt64("admin_user_id")
  3907. order, _ := service.GetHisOrderByIDTwo(order_id)
  3908. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3909. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3910. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3911. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3912. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3913. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3914. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3915. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3916. if order.ID == 0 {
  3917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3918. return
  3919. }
  3920. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3921. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3922. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3923. //fmt.Println(count)
  3924. //var zero string
  3925. //number := count + 1
  3926. //if number >= 1000 {
  3927. // zero = "0000" + strconv.FormatInt(number, 10)
  3928. //} else if number >= 10000 {
  3929. // zero = "000" + strconv.FormatInt(number, 10)
  3930. //} else if number >= 100000 {
  3931. // zero = "00" + strconv.FormatInt(number, 10)
  3932. //} else if number >= 1000000 {
  3933. // zero = "0" + strconv.FormatInt(number, 10)
  3934. //} else {
  3935. // zero = strconv.FormatInt(number, 10)
  3936. //}
  3937. //fmt.Println(zero)
  3938. struct4101 := service.Struct4101{
  3939. PsnNo: order.PsnNo,
  3940. MdtrtId: order.MdtrtId,
  3941. SetlId: order.SetlId,
  3942. PsnName: order.PsnName,
  3943. Gend: order.Gend,
  3944. Brdy: his.Brdy,
  3945. Age: his.Age,
  3946. Naty: order.Naty,
  3947. PatnCertType: "01",
  3948. Certno: order.Certno,
  3949. Prfs: "90",
  3950. ConerName: roles[0].UserName,
  3951. PatnRlts: "99",
  3952. ConerAddr: miConfig.OrgName,
  3953. ConerTel: admin.Mobile,
  3954. HiType: order.Insutype,
  3955. Insuplc: miConfig.InsuplcAdmdvs,
  3956. MaindiagFlag: "1",
  3957. BillCode: order.SetlId,
  3958. BillNo: order.SetlId,
  3959. BizSn: order.Number,
  3960. PsnSelfPay: order.PsnPartAmt,
  3961. PsnOwnPay: order.PsnPartAmt,
  3962. AcctPay: order.AcctPay,
  3963. PsnCashpay: order.PsnCashPay,
  3964. HiPaymtd: "1",
  3965. Hsorg: miConfig.InsuplcAdmdvs,
  3966. HsorgOpter: miConfig.InsuplcAdmdvs,
  3967. MedinsFillPsn: curRoles.UserName,
  3968. MedinsFillDept: depart.Name,
  3969. IptMedType: "2",
  3970. }
  3971. struct4101.SetlBegnDate = order.SetlTime
  3972. struct4101.SetlEndDate = order.SetlTime
  3973. time_arr := strings.Split(order.SetlTime, " ")
  3974. struct4101.AdmTime = time_arr[0]
  3975. struct4101.AdmEndTime = time_arr[0]
  3976. var rf []CustomFundPay
  3977. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3978. var tempFunPays []service.CustomStruct
  3979. for _, item := range rf {
  3980. var tempFunPay service.CustomStruct
  3981. tempFunPay.FundPayamt = item.FundPayamt
  3982. tempFunPay.FundPayType = item.FundPayType
  3983. tempFunPays = append(tempFunPays, tempFunPay)
  3984. }
  3985. struct4101.CustomStruct = tempFunPays
  3986. var tempDiaginfos []service.DiaginfoStructTwo
  3987. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3988. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3989. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3990. var config []*models.HisXtDiagnoseConfig
  3991. for _, item := range diagnosis_ids {
  3992. id, _ := strconv.ParseInt(item, 10, 64)
  3993. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3994. config = append(config, &diagnosisConfig)
  3995. }
  3996. for index, item := range config {
  3997. if index == 0 {
  3998. var tempDiaginfo service.DiaginfoStructTwo
  3999. tempDiaginfo.DiagCode = item.CountryCode
  4000. tempDiaginfo.DiagName = item.CountryContentName
  4001. tempDiaginfo.DiagType = "1"
  4002. tempDiaginfo.MaindiagFlag = "1"
  4003. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4004. } else {
  4005. var tempDiaginfo service.DiaginfoStructTwo
  4006. tempDiaginfo.DiagCode = item.CountryCode
  4007. tempDiaginfo.DiagName = item.CountryContentName
  4008. tempDiaginfo.DiagType = "2"
  4009. tempDiaginfo.MaindiagFlag = "0"
  4010. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4011. }
  4012. }
  4013. struct4101.Diseinfo = tempDiaginfos
  4014. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4015. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4016. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4017. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  4018. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  4019. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4020. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4021. var iteminfo service.IteminfoStruct
  4022. var bedCostTotal float64 = 0 //床位总费
  4023. var bedCostSelfTotal float64 = 0 //床位自费
  4024. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4025. var operationCostTotal float64 = 0 //手术费
  4026. var operationCostSelfTotal float64 = 0 //手术费
  4027. var operationCostPartSelfTotal float64 = 0 //手术费
  4028. var otherCostTotal float64 = 0 //其他费用
  4029. var otherCostSelfTotal float64 = 0 //其他费用
  4030. var otherCostPartSelfTotal float64 = 0 //其他费用
  4031. var materialCostTotal float64 = 0 //材料费
  4032. var materialCostSelfTotal float64 = 0 //材料费
  4033. var materialCostPartSelfTotal float64 = 0 //材料费
  4034. var westernMedicineCostTotal float64 = 0 //西药费
  4035. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4036. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4037. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4038. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4039. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4040. var checkCostTotal float64 = 0 //检查费
  4041. var checkCostSelfTotal float64 = 0 //检查费
  4042. var checkCostPartSelfTotal float64 = 0 //检查费
  4043. var laboratoryCostTotal float64 = 0 //化验费
  4044. var laboratoryCostSelfTotal float64 = 0 //化验费
  4045. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4046. var treatCostTotal float64 = 0 //治疗费用
  4047. var treatCostSelfTotal float64 = 0 //治疗费用
  4048. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4049. decimal.DivisionPrecision = 2
  4050. var bed_fulamt_ownpay_amt float64 = 0
  4051. var operation_fulamt_ownpay_amt float64 = 0
  4052. var other_fulamt_ownpay_amt float64 = 0
  4053. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4054. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4055. var check_fulamt_ownpay_amt float64 = 0
  4056. var material_fulamt_ownpay_amt float64 = 0
  4057. var laboratory_fulamt_ownpay_amt float64 = 0
  4058. var treat_fulamt_ownpay_amt float64 = 0
  4059. var bed_claa_sunmfee float64 = 0
  4060. var bed_clab_amt float64 = 0
  4061. var bed_other_amt float64 = 0
  4062. var operation_claa_sunmfee float64 = 0
  4063. var operation_clab_amt float64 = 0
  4064. var operation_other_amt float64 = 0
  4065. var other_claa_sunmfee float64 = 0
  4066. var other_clab_amt float64 = 0
  4067. var other_other_amt float64 = 0
  4068. var westernMedicine_claa_sunmfee float64 = 0
  4069. var westernMedicine_clab_amt float64 = 0
  4070. var westernMedicine_other_amt float64 = 0
  4071. var chineseTraditional_claa_sunmfee float64 = 0
  4072. var chineseTraditional_clab_amt float64 = 0
  4073. var chineseTraditional_other_amt float64 = 0
  4074. var check_claa_sunmfee float64 = 0
  4075. var check_clab_amt float64 = 0
  4076. var check_other_amt float64 = 0
  4077. var material_claa_sunmfee float64 = 0
  4078. var material_clab_amt float64 = 0
  4079. var material_other_amt float64 = 0
  4080. var laboratory_claa_sunmfee float64 = 0
  4081. var laboratory_clab_amt float64 = 0
  4082. var laboratory_other_amt float64 = 0
  4083. var treat_claa_sunmfee float64 = 0
  4084. var treat_clab_amt float64 = 0
  4085. var treat_other_amt float64 = 0
  4086. for _, item := range order.HisOrderInfo {
  4087. if item.MedChrgitmType == "01" { //床位费
  4088. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4089. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4090. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4091. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4092. if item.ChrgitmLv == "1" {
  4093. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4094. }
  4095. if item.ChrgitmLv == "2" {
  4096. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4097. }
  4098. if item.ChrgitmLv == "3" {
  4099. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4100. }
  4101. }
  4102. if item.MedChrgitmType == "03" { //检查费
  4103. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4104. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4105. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4106. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4107. if item.ChrgitmLv == "1" {
  4108. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4109. }
  4110. if item.ChrgitmLv == "2" {
  4111. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4112. }
  4113. if item.ChrgitmLv == "3" {
  4114. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4115. }
  4116. }
  4117. if item.MedChrgitmType == "04" { //化验费
  4118. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4119. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4120. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4121. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4122. if item.ChrgitmLv == "1" {
  4123. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4124. }
  4125. if item.ChrgitmLv == "2" {
  4126. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4127. }
  4128. if item.ChrgitmLv == "3" {
  4129. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4130. }
  4131. }
  4132. if item.MedChrgitmType == "05" { //治疗费
  4133. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4134. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4135. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4136. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4137. if item.ChrgitmLv == "1" {
  4138. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4139. }
  4140. if item.ChrgitmLv == "2" {
  4141. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4142. }
  4143. if item.ChrgitmLv == "3" {
  4144. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4145. }
  4146. }
  4147. if item.MedChrgitmType == "06" { //手术费
  4148. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4149. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4150. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4151. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4152. if item.ChrgitmLv == "1" {
  4153. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4154. }
  4155. if item.ChrgitmLv == "2" {
  4156. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4157. }
  4158. if item.ChrgitmLv == "3" {
  4159. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4160. }
  4161. }
  4162. if item.MedChrgitmType == "08" { //材料费
  4163. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4164. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4165. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4166. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4167. if item.ChrgitmLv == "1" {
  4168. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4169. }
  4170. if item.ChrgitmLv == "2" {
  4171. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4172. }
  4173. if item.ChrgitmLv == "3" {
  4174. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4175. }
  4176. }
  4177. if item.MedChrgitmType == "09" { //西药费
  4178. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4179. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4180. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4181. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4182. if item.ChrgitmLv == "1" {
  4183. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4184. }
  4185. if item.ChrgitmLv == "2" {
  4186. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4187. }
  4188. if item.ChrgitmLv == "3" {
  4189. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4190. }
  4191. }
  4192. if item.MedChrgitmType == "11" { //中成费
  4193. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4194. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4195. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4196. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4197. if item.ChrgitmLv == "1" {
  4198. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4199. }
  4200. if item.ChrgitmLv == "2" {
  4201. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4202. }
  4203. if item.ChrgitmLv == "3" {
  4204. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4205. }
  4206. }
  4207. if item.MedChrgitmType == "14" { //其他费
  4208. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4209. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4210. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4211. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4212. if item.ChrgitmLv == "1" {
  4213. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4214. }
  4215. if item.ChrgitmLv == "2" {
  4216. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4217. }
  4218. if item.ChrgitmLv == "3" {
  4219. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4220. }
  4221. }
  4222. }
  4223. var iteminfoStructs []service.IteminfoStruct
  4224. if bedCostTotal != 0 {
  4225. iteminfo.MedChrgitm = "01"
  4226. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4227. iteminfo.Amt = bedCostTotal
  4228. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4229. iteminfo.ClabAmt = bed_clab_amt
  4230. iteminfo.OthAmt = bed_other_amt
  4231. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4232. }
  4233. if checkCostTotal != 0 {
  4234. iteminfo.MedChrgitm = "03"
  4235. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4236. iteminfo.Amt = checkCostTotal
  4237. iteminfo.ClaaSumfee = check_claa_sunmfee
  4238. iteminfo.ClabAmt = check_clab_amt
  4239. iteminfo.OthAmt = check_other_amt
  4240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4241. }
  4242. if laboratoryCostTotal != 0 {
  4243. iteminfo.MedChrgitm = "04"
  4244. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4245. iteminfo.Amt = laboratoryCostTotal
  4246. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4247. iteminfo.ClabAmt = laboratory_clab_amt
  4248. iteminfo.OthAmt = laboratory_other_amt
  4249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4250. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4251. }
  4252. if treatCostTotal != 0 {
  4253. iteminfo.MedChrgitm = "05"
  4254. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4255. iteminfo.Amt = treatCostTotal
  4256. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4257. iteminfo.ClabAmt = treat_clab_amt
  4258. iteminfo.OthAmt = treat_other_amt
  4259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4260. //(struct4101.IteminfoStruct, iteminfo)
  4261. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4262. }
  4263. if operationCostTotal != 0 {
  4264. iteminfo.MedChrgitm = "06"
  4265. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4266. iteminfo.Amt = operationCostTotal
  4267. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4268. iteminfo.ClabAmt = operation_clab_amt
  4269. iteminfo.OthAmt = operation_other_amt
  4270. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4271. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4272. }
  4273. if materialCostTotal != 0 {
  4274. iteminfo.MedChrgitm = "08"
  4275. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4276. iteminfo.Amt = materialCostTotal
  4277. iteminfo.ClaaSumfee = material_claa_sunmfee
  4278. iteminfo.ClabAmt = material_clab_amt
  4279. iteminfo.OthAmt = material_other_amt
  4280. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4281. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4282. }
  4283. if westernMedicineCostTotal != 0 {
  4284. iteminfo.MedChrgitm = "09"
  4285. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4286. iteminfo.Amt = westernMedicineCostTotal
  4287. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4288. iteminfo.ClabAmt = westernMedicine_clab_amt
  4289. iteminfo.OthAmt = westernMedicine_other_amt
  4290. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4291. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4292. }
  4293. if chineseTraditionalMedicineCostTotal != 0 {
  4294. iteminfo.MedChrgitm = "11"
  4295. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4296. iteminfo.Amt = westernMedicineCostTotal
  4297. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4298. iteminfo.ClabAmt = westernMedicine_clab_amt
  4299. iteminfo.OthAmt = westernMedicine_other_amt
  4300. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4301. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4302. }
  4303. if otherCostTotal != 0 {
  4304. iteminfo.MedChrgitm = "14"
  4305. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4306. iteminfo.Amt = otherCostTotal
  4307. iteminfo.ClaaSumfee = other_claa_sunmfee
  4308. iteminfo.ClabAmt = other_clab_amt
  4309. iteminfo.OthAmt = other_other_amt
  4310. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4311. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4312. }
  4313. struct4101.IteminfoStruct = iteminfoStructs
  4314. struct4101.Ntly = "中国"
  4315. struct4101.AdmCaty = "A03.06"
  4316. struct4101.DoctorName = doctor.UserName
  4317. struct4101.DoctorCode = doctor.DoctorNumber
  4318. var res ResultSeventeen
  4319. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4320. struct4101.BillCode = order.Number
  4321. struct4101.BillNo = order.SetlId
  4322. var resOther ResultSeventeenOther
  4323. var pp models.PublicParams
  4324. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4325. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4326. pp.FixmedinsName = miConfig.OrgName
  4327. pp.FixmedinsCode = miConfig.Code
  4328. pp.RequestUrl = miConfig.Url
  4329. pp.Cainfo = miConfig.Cainfo
  4330. pp.SecretKey = miConfig.SecretKey
  4331. pp.AccessKey = miConfig.AccessKey
  4332. pp.OpterName = curRoles.UserName
  4333. client := &http.Client{}
  4334. var req *http.Request
  4335. data := make(map[string]interface{})
  4336. data["struct4101"] = struct4101
  4337. data["pp"] = pp
  4338. bytesData, _ := json.Marshal(data)
  4339. if miConfig.MdtrtareaAdmvs == "320921" {
  4340. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4341. } else {
  4342. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4343. }
  4344. resp, _ := client.Do(req)
  4345. defer resp.Body.Close()
  4346. body, ioErr := ioutil.ReadAll(resp.Body)
  4347. if ioErr != nil {
  4348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. var respJSON map[string]interface{}
  4353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4356. return
  4357. }
  4358. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4359. userJSONBytes, _ := json.Marshal(respJSON)
  4360. fmt.Println("log")
  4361. fmt.Println(string(userJSONBytes))
  4362. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4363. utils.ErrorLog("解析失败:%v", err)
  4364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4365. return
  4366. }
  4367. res.InfRefmsgid = resOther.InfRefmsgid
  4368. res.Output = resOther.Output
  4369. res.ErrMsg = resOther.ErrMsg
  4370. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4371. res.Infcode = infocode
  4372. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4373. var pp models.PublicParams
  4374. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4375. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4376. pp.FixmedinsName = miConfig.OrgName
  4377. pp.FixmedinsCode = miConfig.Code
  4378. pp.RequestUrl = miConfig.Url
  4379. pp.Cainfo = miConfig.Cainfo
  4380. pp.SecretKey = miConfig.SecretKey
  4381. pp.AccessKey = miConfig.AccessKey
  4382. pp.OpterName = curRoles.UserName
  4383. result, _ := service.Jxyb4101(struct4101, pp)
  4384. var dat map[string]interface{}
  4385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4386. fmt.Println(dat)
  4387. } else {
  4388. fmt.Println(err)
  4389. }
  4390. userJSONBytes, _ := json.Marshal(dat)
  4391. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4392. utils.ErrorLog("解析失败:%v", err)
  4393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. return
  4395. }
  4396. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4397. var pp models.PublicParams
  4398. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4399. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4400. pp.FixmedinsName = miConfig.OrgName
  4401. pp.FixmedinsCode = miConfig.Code
  4402. pp.RequestUrl = miConfig.Url
  4403. pp.Cainfo = miConfig.Cainfo
  4404. pp.SecretKey = miConfig.SecretKey
  4405. pp.AccessKey = miConfig.AccessKey
  4406. pp.OpterName = curRoles.UserName
  4407. result, _ := service.Hnyb4101(struct4101, pp)
  4408. var dat map[string]interface{}
  4409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4410. fmt.Println(dat)
  4411. } else {
  4412. fmt.Println(err)
  4413. }
  4414. userJSONBytes, _ := json.Marshal(dat)
  4415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4416. utils.ErrorLog("解析失败:%v", err)
  4417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4418. return
  4419. }
  4420. } else {
  4421. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4422. var dat map[string]interface{}
  4423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4424. fmt.Println(dat)
  4425. } else {
  4426. fmt.Println(err)
  4427. }
  4428. userJSONBytes, _ := json.Marshal(dat)
  4429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4430. utils.ErrorLog("解析失败:%v", err)
  4431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4432. return
  4433. }
  4434. }
  4435. if res.Infcode != 0 {
  4436. c.ServeSuccessJSON(map[string]interface{}{
  4437. "failed_code": -10,
  4438. "msg": res.ErrMsg,
  4439. })
  4440. return
  4441. } else {
  4442. //order.FaPiaoNumber = zero
  4443. //order.FaPiaoCode = last_order.FaPiaoCode
  4444. //service.UpdateOrder(order)
  4445. hisFundSettleListResult := &models.HisFundSettleListResult{
  4446. Number: res.Output.SetlListId,
  4447. Status: 1,
  4448. Ctime: time.Now().Unix(),
  4449. Mtime: time.Now().Unix(),
  4450. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4451. IsUpload: 1,
  4452. OrderId: order_id,
  4453. }
  4454. service.CreateUploadRecord(hisFundSettleListResult)
  4455. c.ServeSuccessJSON(map[string]interface{}{
  4456. "msg": "上传成功",
  4457. "result": hisFundSettleListResult,
  4458. })
  4459. return
  4460. }
  4461. }
  4462. func (c *HisApiController) GetSettleListHospital() {
  4463. order_id, _ := c.GetInt64("order_id")
  4464. admin_user_id, _ := c.GetInt64("admin_user_id")
  4465. order, _ := service.GetHisOrderByIDTwo(order_id)
  4466. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4467. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4468. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4469. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4470. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4471. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4472. if order.ID == 0 {
  4473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4474. return
  4475. }
  4476. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4477. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4478. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4479. fmt.Println(count)
  4480. var zero string
  4481. number := count + 1
  4482. if number >= 1000 {
  4483. zero = "0000" + strconv.FormatInt(number, 10)
  4484. } else if number >= 10000 {
  4485. zero = "000" + strconv.FormatInt(number, 10)
  4486. } else if number >= 100000 {
  4487. zero = "00" + strconv.FormatInt(number, 10)
  4488. } else if number >= 1000000 {
  4489. zero = "0" + strconv.FormatInt(number, 10)
  4490. } else {
  4491. zero = strconv.FormatInt(number, 10)
  4492. }
  4493. fmt.Println(zero)
  4494. struct4101 := service.Struct4101{
  4495. PsnNo: order.PsnNo,
  4496. MdtrtId: order.MdtrtId,
  4497. SetlId: order.SetlId,
  4498. PsnName: order.PsnName,
  4499. Gend: order.Gend,
  4500. Brdy: his.Brdy,
  4501. Age: int64(order.Age),
  4502. Naty: order.Naty,
  4503. PatnCertType: "01",
  4504. Certno: order.Certno,
  4505. Prfs: "90",
  4506. ConerName: roles[0].UserName,
  4507. PatnRlts: "99",
  4508. ConerAddr: miConfig.OrgName,
  4509. ConerTel: admin.Mobile,
  4510. HiType: order.Insutype,
  4511. Insuplc: miConfig.InsuplcAdmdvs,
  4512. MaindiagFlag: "1",
  4513. BillCode: order.SetlId,
  4514. BillNo: order.SetlId,
  4515. BizSn: order.Number,
  4516. PsnSelfPay: order.PsnPartAmt,
  4517. PsnOwnPay: order.PsnPartAmt,
  4518. AcctPay: order.AcctPay,
  4519. PsnCashpay: order.PsnCashPay,
  4520. HiPaymtd: "1",
  4521. Hsorg: miConfig.InsuplcAdmdvs,
  4522. HsorgOpter: miConfig.InsuplcAdmdvs,
  4523. MedinsFillPsn: curRoles.UserName,
  4524. MedinsFillDept: depart.Name,
  4525. IptMedType: "2",
  4526. AdmTime: his.InHosptialTime,
  4527. AdmEndTime: his.OutHosptialTime,
  4528. }
  4529. struct4101.SetlBegnDate = order.SetlTime
  4530. struct4101.SetlEndDate = order.SetlTime
  4531. var rf []CustomFundPay
  4532. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4533. var tempFunPays []service.CustomStruct
  4534. for _, item := range rf {
  4535. var tempFunPay service.CustomStruct
  4536. tempFunPay.FundPayamt = item.FundPayamt
  4537. tempFunPay.FundPayType = item.FundPayType
  4538. tempFunPays = append(tempFunPays, tempFunPay)
  4539. }
  4540. struct4101.CustomStruct = tempFunPays
  4541. var tempDiaginfos []service.DiaginfoStructTwo
  4542. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4543. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4544. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4545. var config []*models.HisXtDiagnoseConfig
  4546. for _, item := range diagnosis_ids {
  4547. id, _ := strconv.ParseInt(item, 10, 64)
  4548. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4549. config = append(config, &diagnosisConfig)
  4550. }
  4551. for index, item := range config {
  4552. if index == 0 {
  4553. var tempDiaginfo service.DiaginfoStructTwo
  4554. tempDiaginfo.DiagCode = item.CountryCode
  4555. tempDiaginfo.DiagName = item.CountryContentName
  4556. tempDiaginfo.DiagType = "1"
  4557. tempDiaginfo.MaindiagFlag = "1"
  4558. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4559. } else {
  4560. var tempDiaginfo service.DiaginfoStructTwo
  4561. tempDiaginfo.DiagCode = item.CountryCode
  4562. tempDiaginfo.DiagName = item.CountryContentName
  4563. tempDiaginfo.DiagType = "2"
  4564. tempDiaginfo.MaindiagFlag = "0"
  4565. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4566. }
  4567. }
  4568. struct4101.Diseinfo = tempDiaginfos
  4569. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4570. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4571. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4572. tempOpspdiseinfo2.OprnOprtCode = ""
  4573. tempOpspdiseinfo2.OprnOprtName = ""
  4574. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4575. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4576. var iteminfo service.IteminfoStruct
  4577. var bedCostTotal float64 = 0 //床位总费
  4578. var bedCostSelfTotal float64 = 0 //床位自费
  4579. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4580. var operationCostTotal float64 = 0 //手术费
  4581. var operationCostSelfTotal float64 = 0 //手术费
  4582. var operationCostPartSelfTotal float64 = 0 //手术费
  4583. var otherCostTotal float64 = 0 //其他费用
  4584. var otherCostSelfTotal float64 = 0 //其他费用
  4585. var otherCostPartSelfTotal float64 = 0 //其他费用
  4586. var materialCostTotal float64 = 0 //材料费
  4587. var materialCostSelfTotal float64 = 0 //材料费
  4588. var materialCostPartSelfTotal float64 = 0 //材料费
  4589. var westernMedicineCostTotal float64 = 0 //西药费
  4590. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4591. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4592. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4593. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4594. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4595. var checkCostTotal float64 = 0 //检查费
  4596. var checkCostSelfTotal float64 = 0 //检查费
  4597. var checkCostPartSelfTotal float64 = 0 //检查费
  4598. var laboratoryCostTotal float64 = 0 //化验费
  4599. var laboratoryCostSelfTotal float64 = 0 //化验费
  4600. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4601. var treatCostTotal float64 = 0 //治疗费用
  4602. var treatCostSelfTotal float64 = 0 //治疗费用
  4603. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4604. decimal.DivisionPrecision = 2
  4605. var bed_fulamt_ownpay_amt float64 = 0
  4606. var operation_fulamt_ownpay_amt float64 = 0
  4607. var other_fulamt_ownpay_amt float64 = 0
  4608. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4609. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4610. var check_fulamt_ownpay_amt float64 = 0
  4611. var material_fulamt_ownpay_amt float64 = 0
  4612. var laboratory_fulamt_ownpay_amt float64 = 0
  4613. var treat_fulamt_ownpay_amt float64 = 0
  4614. var bed_claa_sunmfee float64 = 0
  4615. var bed_clab_amt float64 = 0
  4616. var bed_other_amt float64 = 0
  4617. var operation_claa_sunmfee float64 = 0
  4618. var operation_clab_amt float64 = 0
  4619. var operation_other_amt float64 = 0
  4620. var other_claa_sunmfee float64 = 0
  4621. var other_clab_amt float64 = 0
  4622. var other_other_amt float64 = 0
  4623. var westernMedicine_claa_sunmfee float64 = 0
  4624. var westernMedicine_clab_amt float64 = 0
  4625. var westernMedicine_other_amt float64 = 0
  4626. var chineseTraditional_claa_sunmfee float64 = 0
  4627. var chineseTraditional_clab_amt float64 = 0
  4628. var chineseTraditional_other_amt float64 = 0
  4629. var check_claa_sunmfee float64 = 0
  4630. var check_clab_amt float64 = 0
  4631. var check_other_amt float64 = 0
  4632. var material_claa_sunmfee float64 = 0
  4633. var material_clab_amt float64 = 0
  4634. var material_other_amt float64 = 0
  4635. var laboratory_claa_sunmfee float64 = 0
  4636. var laboratory_clab_amt float64 = 0
  4637. var laboratory_other_amt float64 = 0
  4638. var treat_claa_sunmfee float64 = 0
  4639. var treat_clab_amt float64 = 0
  4640. var treat_other_amt float64 = 0
  4641. for _, item := range order.HisOrderInfo {
  4642. if item.MedChrgitmType == "01" { //床位费
  4643. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4644. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4645. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4646. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4647. if item.ChrgitmLv == "1" {
  4648. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4649. }
  4650. if item.ChrgitmLv == "2" {
  4651. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4652. }
  4653. if item.ChrgitmLv == "3" {
  4654. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4655. }
  4656. }
  4657. if item.MedChrgitmType == "03" { //检查费
  4658. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4659. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4660. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4661. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4662. if item.ChrgitmLv == "1" {
  4663. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4664. }
  4665. if item.ChrgitmLv == "2" {
  4666. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4667. }
  4668. if item.ChrgitmLv == "3" {
  4669. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4670. }
  4671. }
  4672. if item.MedChrgitmType == "04" { //化验费
  4673. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4674. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4675. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4676. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4677. if item.ChrgitmLv == "1" {
  4678. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4679. }
  4680. if item.ChrgitmLv == "2" {
  4681. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4682. }
  4683. if item.ChrgitmLv == "3" {
  4684. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4685. }
  4686. }
  4687. if item.MedChrgitmType == "05" { //治疗费
  4688. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4689. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4690. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4691. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4692. if item.ChrgitmLv == "1" {
  4693. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4694. }
  4695. if item.ChrgitmLv == "2" {
  4696. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4697. }
  4698. if item.ChrgitmLv == "3" {
  4699. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4700. }
  4701. }
  4702. if item.MedChrgitmType == "06" { //手术费
  4703. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4704. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4705. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4706. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4707. if item.ChrgitmLv == "1" {
  4708. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4709. }
  4710. if item.ChrgitmLv == "2" {
  4711. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4712. }
  4713. if item.ChrgitmLv == "3" {
  4714. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4715. }
  4716. }
  4717. if item.MedChrgitmType == "08" { //材料费
  4718. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4719. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4720. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4721. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4722. if item.ChrgitmLv == "1" {
  4723. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4724. }
  4725. if item.ChrgitmLv == "2" {
  4726. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4727. }
  4728. if item.ChrgitmLv == "3" {
  4729. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4730. }
  4731. }
  4732. if item.MedChrgitmType == "09" { //西药费
  4733. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4734. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4735. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4736. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4737. if item.ChrgitmLv == "1" {
  4738. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4739. }
  4740. if item.ChrgitmLv == "2" {
  4741. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4742. }
  4743. if item.ChrgitmLv == "3" {
  4744. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4745. }
  4746. }
  4747. if item.MedChrgitmType == "11" { //中成费
  4748. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4749. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4750. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4751. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4752. if item.ChrgitmLv == "1" {
  4753. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4754. }
  4755. if item.ChrgitmLv == "2" {
  4756. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4757. }
  4758. if item.ChrgitmLv == "3" {
  4759. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4760. }
  4761. }
  4762. if item.MedChrgitmType == "14" { //其他费
  4763. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4764. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4765. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4766. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4767. if item.ChrgitmLv == "1" {
  4768. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4769. }
  4770. if item.ChrgitmLv == "2" {
  4771. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4772. }
  4773. if item.ChrgitmLv == "3" {
  4774. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4775. }
  4776. }
  4777. }
  4778. var iteminfoStructs []service.IteminfoStruct
  4779. if bedCostTotal != 0 {
  4780. iteminfo.MedChrgitm = "01"
  4781. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4782. iteminfo.Amt = bedCostTotal
  4783. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4784. iteminfo.ClabAmt = bed_clab_amt
  4785. iteminfo.OthAmt = bed_other_amt
  4786. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4787. }
  4788. if checkCostTotal != 0 {
  4789. iteminfo.MedChrgitm = "03"
  4790. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4791. iteminfo.Amt = checkCostTotal
  4792. iteminfo.ClaaSumfee = check_claa_sunmfee
  4793. iteminfo.ClabAmt = check_clab_amt
  4794. iteminfo.OthAmt = check_other_amt
  4795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4796. }
  4797. if laboratoryCostTotal != 0 {
  4798. iteminfo.MedChrgitm = "04"
  4799. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4800. iteminfo.Amt = laboratoryCostTotal
  4801. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4802. iteminfo.ClabAmt = laboratory_clab_amt
  4803. iteminfo.OthAmt = laboratory_other_amt
  4804. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4805. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4806. }
  4807. if treatCostTotal != 0 {
  4808. iteminfo.MedChrgitm = "05"
  4809. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4810. iteminfo.Amt = treatCostTotal
  4811. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4812. iteminfo.ClabAmt = treat_clab_amt
  4813. iteminfo.OthAmt = treat_other_amt
  4814. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4815. //(struct4101.IteminfoStruct, iteminfo)
  4816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4817. }
  4818. if operationCostTotal != 0 {
  4819. iteminfo.MedChrgitm = "06"
  4820. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4821. iteminfo.Amt = operationCostTotal
  4822. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4823. iteminfo.ClabAmt = operation_clab_amt
  4824. iteminfo.OthAmt = operation_other_amt
  4825. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4826. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4827. }
  4828. if materialCostTotal != 0 {
  4829. iteminfo.MedChrgitm = "08"
  4830. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4831. iteminfo.Amt = materialCostTotal
  4832. iteminfo.ClaaSumfee = material_claa_sunmfee
  4833. iteminfo.ClabAmt = material_clab_amt
  4834. iteminfo.OthAmt = material_other_amt
  4835. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4836. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4837. }
  4838. if westernMedicineCostTotal != 0 {
  4839. iteminfo.MedChrgitm = "09"
  4840. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4841. iteminfo.Amt = westernMedicineCostTotal
  4842. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4843. iteminfo.ClabAmt = westernMedicine_clab_amt
  4844. iteminfo.OthAmt = westernMedicine_other_amt
  4845. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4847. }
  4848. if chineseTraditionalMedicineCostTotal != 0 {
  4849. iteminfo.MedChrgitm = "11"
  4850. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4851. iteminfo.Amt = westernMedicineCostTotal
  4852. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4853. iteminfo.ClabAmt = westernMedicine_clab_amt
  4854. iteminfo.OthAmt = westernMedicine_other_amt
  4855. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4856. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4857. }
  4858. if otherCostTotal != 0 {
  4859. iteminfo.MedChrgitm = "14"
  4860. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4861. iteminfo.Amt = otherCostTotal
  4862. iteminfo.ClaaSumfee = other_claa_sunmfee
  4863. iteminfo.ClabAmt = other_clab_amt
  4864. iteminfo.OthAmt = other_other_amt
  4865. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4866. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4867. }
  4868. struct4101.IteminfoStruct = iteminfoStructs
  4869. struct4101.Ntly = "中国"
  4870. struct4101.AdmCaty = "A03.06"
  4871. var resOther ResultSeventeenOther
  4872. var res ResultSeventeen
  4873. if miConfig.MdtrtareaAdmvs == "150499" {
  4874. var pp models.PublicParams
  4875. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4876. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4877. pp.FixmedinsName = miConfig.OrgName
  4878. pp.FixmedinsCode = miConfig.Code
  4879. pp.RequestUrl = miConfig.Url
  4880. pp.Cainfo = miConfig.Cainfo
  4881. pp.SecretKey = miConfig.SecretKey
  4882. pp.AccessKey = miConfig.AccessKey
  4883. pp.OpterName = curRoles.UserName
  4884. client := &http.Client{}
  4885. var req *http.Request
  4886. data := make(map[string]interface{})
  4887. data["struct4101"] = struct4101
  4888. data["pp"] = pp
  4889. bytesData, _ := json.Marshal(data)
  4890. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4891. resp, _ := client.Do(req)
  4892. defer resp.Body.Close()
  4893. body, ioErr := ioutil.ReadAll(resp.Body)
  4894. if ioErr != nil {
  4895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4897. return
  4898. }
  4899. var respJSON map[string]interface{}
  4900. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4903. return
  4904. }
  4905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4906. userJSONBytes, _ := json.Marshal(respJSON)
  4907. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4908. utils.ErrorLog("解析失败:%v", err)
  4909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4910. return
  4911. }
  4912. res.InfRefmsgid = resOther.InfRefmsgid
  4913. res.Output = resOther.Output
  4914. res.ErrMsg = resOther.ErrMsg
  4915. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4916. res.Infcode = infocode
  4917. } else {
  4918. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4919. var dat map[string]interface{}
  4920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4921. fmt.Println(dat)
  4922. } else {
  4923. fmt.Println(err)
  4924. }
  4925. userJSONBytes, _ := json.Marshal(dat)
  4926. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4927. utils.ErrorLog("解析失败:%v", err)
  4928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4929. return
  4930. }
  4931. }
  4932. if res.Infcode != 0 {
  4933. c.ServeSuccessJSON(map[string]interface{}{
  4934. "failed_code": -10,
  4935. "msg": res.ErrMsg,
  4936. })
  4937. return
  4938. } else {
  4939. if miConfig.MdtrtareaAdmvs != "150499" {
  4940. order.FaPiaoNumber = zero
  4941. order.FaPiaoCode = last_order.FaPiaoCode
  4942. service.UpdateOrder(order)
  4943. }
  4944. hisFundSettleListResult := &models.HisFundSettleListResult{
  4945. Number: res.Output.SetlListId,
  4946. Status: 1,
  4947. Ctime: time.Now().Unix(),
  4948. Mtime: time.Now().Unix(),
  4949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4950. IsUpload: 1,
  4951. OrderId: order_id,
  4952. }
  4953. service.CreateUploadRecord(hisFundSettleListResult)
  4954. c.ServeSuccessJSON(map[string]interface{}{
  4955. "msg": "上传成功",
  4956. "result": hisFundSettleListResult,
  4957. })
  4958. return
  4959. }
  4960. }
  4961. func (c *HisApiController) GetBatchSettleList() {
  4962. orders, _ := service.GetAllHisOrder(10106)
  4963. for _, item := range orders {
  4964. order_id := item.ID
  4965. order, _ := service.GetHisOrderByIDTwo(order_id)
  4966. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4967. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4968. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4969. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  4970. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4971. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4972. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4973. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4974. if order.ID == 0 {
  4975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4976. return
  4977. }
  4978. if his.BalanceAccountsType == 2 {
  4979. continue
  4980. }
  4981. struct4101 := service.Struct4101{
  4982. PsnNo: order.PsnNo,
  4983. MdtrtId: order.MdtrtId,
  4984. SetlId: order.SetlId,
  4985. PsnName: order.PsnName,
  4986. Gend: order.Gend,
  4987. Brdy: his.Brdy,
  4988. Age: his.Age,
  4989. Naty: order.Naty,
  4990. PatnCertType: "01",
  4991. Certno: order.Certno,
  4992. Prfs: "90",
  4993. ConerName: roles[0].UserName,
  4994. PatnRlts: "99",
  4995. ConerAddr: miConfig.OrgName,
  4996. ConerTel: admin.Mobile,
  4997. HiType: order.Insutype,
  4998. Insuplc: his.InsuplcAdmdvs,
  4999. MaindiagFlag: "1",
  5000. BillCode: order.SetlId,
  5001. BillNo: order.SetlId,
  5002. BizSn: order.Number,
  5003. PsnSelfPay: order.PsnPartAmt,
  5004. PsnOwnPay: order.PsnPartAmt,
  5005. AcctPay: order.AcctPay,
  5006. PsnCashpay: order.PsnCashPay,
  5007. HiPaymtd: "1",
  5008. Hsorg: his.InsuplcAdmdvs,
  5009. HsorgOpter: his.InsuplcAdmdvs,
  5010. MedinsFillPsn: curRoles.UserName,
  5011. MedinsFillDept: depart.Name,
  5012. IptMedType: "2",
  5013. }
  5014. struct4101.SetlBegnDate = order.SetlTime
  5015. struct4101.SetlEndDate = order.SetlTime
  5016. //if order.SettleType == 1 {
  5017. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  5018. // dateStr := t.Format("2006-01-02")
  5019. // struct4101.SetlBegnDate = dateStr
  5020. // struct4101.SetlEndDate = dateStr
  5021. //} else {
  5022. // t := time.Unix(int64(order.SettleStartTime), 0)
  5023. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  5024. // dateStartStr := t.Format("2006-01-02")
  5025. // dateEndStr := t2.Format("2006-01-02")
  5026. // struct4101.SetlBegnDate = dateStartStr
  5027. // struct4101.SetlEndDate = dateEndStr
  5028. //}
  5029. var rf []CustomFundPay
  5030. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5031. var tempFunPays []service.CustomStruct
  5032. var tempFunPay610100 service.CustomStruct
  5033. for _, item := range rf {
  5034. if item.FundPayType == "610100" {
  5035. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  5036. tempFunPay610100.FundPayType = item.FundPayType
  5037. } else {
  5038. var tempFunPay service.CustomStruct
  5039. tempFunPay.FundPayamt = item.FundPayamt
  5040. tempFunPay.FundPayType = item.FundPayType
  5041. tempFunPays = append(tempFunPays, tempFunPay)
  5042. }
  5043. }
  5044. tempFunPays = append(tempFunPays, tempFunPay610100)
  5045. struct4101.CustomStruct = tempFunPays
  5046. var tempDiaginfos []service.DiaginfoStructTwo
  5047. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5048. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5049. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5050. var config []*models.HisXtDiagnoseConfig
  5051. for _, item := range diagnosis_ids {
  5052. id, _ := strconv.ParseInt(item, 10, 64)
  5053. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5054. config = append(config, &diagnosisConfig)
  5055. }
  5056. for index, item := range config {
  5057. if index == 0 {
  5058. var tempDiaginfo service.DiaginfoStructTwo
  5059. tempDiaginfo.DiagCode = item.CountryCode
  5060. tempDiaginfo.DiagName = item.CountryContentName
  5061. tempDiaginfo.DiagType = "1"
  5062. tempDiaginfo.MaindiagFlag = "1"
  5063. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5064. } else {
  5065. var tempDiaginfo service.DiaginfoStructTwo
  5066. tempDiaginfo.DiagCode = item.CountryCode
  5067. tempDiaginfo.DiagName = item.CountryContentName
  5068. tempDiaginfo.DiagType = "2"
  5069. tempDiaginfo.MaindiagFlag = "0"
  5070. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5071. }
  5072. }
  5073. struct4101.Diseinfo = tempDiaginfos
  5074. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5075. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5076. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5077. tempOpspdiseinfo2.OprnOprtCode = ""
  5078. tempOpspdiseinfo2.OprnOprtName = ""
  5079. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5080. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5081. var iteminfo service.IteminfoStruct
  5082. var bedCostTotal float64 = 0 //床位总费
  5083. var bedCostSelfTotal float64 = 0 //床位自费
  5084. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5085. var examineCostTotal float64 = 0 //诊查总费
  5086. var examineCostSelfTotal float64 = 0 //诊查自费
  5087. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  5088. var nursingCostTotal float64 = 0 //护理总费
  5089. var nursingCostSelfTotal float64 = 0 //护理自费
  5090. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  5091. var chineseMedicineCostTotal float64 = 0 //中成药
  5092. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  5093. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  5094. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  5095. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  5096. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  5097. var registerCostTotal float64 = 0 //一般诊疗费
  5098. var registerCostSelfTotal float64 = 0 //一般诊疗费
  5099. var registerPartSelfTotal float64 = 0 //一般诊疗费
  5100. var operationCostTotal float64 = 0 //手术费
  5101. var operationCostSelfTotal float64 = 0 //手术费
  5102. var operationCostPartSelfTotal float64 = 0 //手术费
  5103. var otherCostTotal float64 = 0 //其他费用
  5104. var otherCostSelfTotal float64 = 0 //其他费用
  5105. var otherCostPartSelfTotal float64 = 0 //其他费用
  5106. var materialCostTotal float64 = 0 //材料费
  5107. var materialCostSelfTotal float64 = 0 //材料费
  5108. var materialCostPartSelfTotal float64 = 0 //材料费
  5109. var westernMedicineCostTotal float64 = 0 //西药费
  5110. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5111. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5112. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5113. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5114. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5115. var checkCostTotal float64 = 0 //检查费
  5116. var checkCostSelfTotal float64 = 0 //检查费
  5117. var checkCostPartSelfTotal float64 = 0 //检查费
  5118. var laboratoryCostTotal float64 = 0 //化验费
  5119. var laboratoryCostSelfTotal float64 = 0 //化验费
  5120. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5121. var treatCostTotal float64 = 0 //治疗费用
  5122. var treatCostSelfTotal float64 = 0 //治疗费用
  5123. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5124. decimal.DivisionPrecision = 2
  5125. var bed_fulamt_ownpay_amt float64 = 0
  5126. var examine_fulamt_ownpay_amt float64 = 0
  5127. var nursing_fulamt_ownpay_amt float64 = 0
  5128. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  5129. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  5130. var register_fulamt_ownpay_amt float64 = 0
  5131. var operation_fulamt_ownpay_amt float64 = 0
  5132. var other_fulamt_ownpay_amt float64 = 0
  5133. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5134. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5135. var check_fulamt_ownpay_amt float64 = 0
  5136. var material_fulamt_ownpay_amt float64 = 0
  5137. var laboratory_fulamt_ownpay_amt float64 = 0
  5138. var treat_fulamt_ownpay_amt float64 = 0
  5139. var bed_claa_sunmfee float64 = 0
  5140. var bed_clab_amt float64 = 0
  5141. var bed_other_amt float64 = 0
  5142. var examine_claa_sunmfee float64 = 0
  5143. var examine_clab_amt float64 = 0
  5144. var examine_other_amt float64 = 0
  5145. var nursing_claa_sunmfee float64 = 0
  5146. var nursing_clab_amt float64 = 0
  5147. var nursing_other_amt float64 = 0
  5148. var chinese_medicine_claa_sunmfee float64 = 0
  5149. var chinese_medicine_clab_amt float64 = 0
  5150. var chinese_medicine_other_amt float64 = 0
  5151. var commonly_treatment_claa_sunmfee float64 = 0
  5152. var commonly_treatment_clab_amt float64 = 0
  5153. var commonly_treatment_other_amt float64 = 0
  5154. var operation_claa_sunmfee float64 = 0
  5155. var operation_clab_amt float64 = 0
  5156. var operation_other_amt float64 = 0
  5157. var other_claa_sunmfee float64 = 0
  5158. var other_clab_amt float64 = 0
  5159. var other_other_amt float64 = 0
  5160. var westernMedicine_claa_sunmfee float64 = 0
  5161. var westernMedicine_clab_amt float64 = 0
  5162. var westernMedicine_other_amt float64 = 0
  5163. var chineseTraditional_claa_sunmfee float64 = 0
  5164. var chineseTraditional_clab_amt float64 = 0
  5165. var chineseTraditional_other_amt float64 = 0
  5166. var check_claa_sunmfee float64 = 0
  5167. var check_clab_amt float64 = 0
  5168. var check_other_amt float64 = 0
  5169. var material_claa_sunmfee float64 = 0
  5170. var material_clab_amt float64 = 0
  5171. var material_other_amt float64 = 0
  5172. var laboratory_claa_sunmfee float64 = 0
  5173. var laboratory_clab_amt float64 = 0
  5174. var laboratory_other_amt float64 = 0
  5175. var treat_claa_sunmfee float64 = 0
  5176. var treat_clab_amt float64 = 0
  5177. var treat_other_amt float64 = 0
  5178. var register_claa_sunmfee float64 = 0
  5179. var register_clab_amt float64 = 0
  5180. var register_other_amt float64 = 0
  5181. for _, item := range order.HisOrderInfo {
  5182. if item.MedChrgitmType == "01" { //床位费
  5183. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5184. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5185. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5186. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5187. if item.ChrgitmLv == "1" {
  5188. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5189. }
  5190. if item.ChrgitmLv == "2" {
  5191. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5192. }
  5193. if item.ChrgitmLv == "3" {
  5194. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5195. }
  5196. }
  5197. if item.MedChrgitmType == "02" { //诊查
  5198. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5199. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5200. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5201. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5202. if item.ChrgitmLv == "1" {
  5203. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5204. }
  5205. if item.ChrgitmLv == "2" {
  5206. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5207. }
  5208. if item.ChrgitmLv == "3" {
  5209. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5210. }
  5211. }
  5212. if item.MedChrgitmType == "03" { //检查费
  5213. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5214. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5215. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5216. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5217. if item.ChrgitmLv == "1" {
  5218. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5219. }
  5220. if item.ChrgitmLv == "2" {
  5221. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5222. }
  5223. if item.ChrgitmLv == "3" {
  5224. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5225. }
  5226. }
  5227. if item.MedChrgitmType == "04" { //化验费
  5228. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5229. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5230. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5231. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5232. if item.ChrgitmLv == "1" {
  5233. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5234. }
  5235. if item.ChrgitmLv == "2" {
  5236. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5237. }
  5238. if item.ChrgitmLv == "3" {
  5239. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5240. }
  5241. }
  5242. if item.MedChrgitmType == "05" { //治疗费
  5243. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5244. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5245. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5246. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5247. if item.ChrgitmLv == "1" {
  5248. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5249. }
  5250. if item.ChrgitmLv == "2" {
  5251. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5252. }
  5253. if item.ChrgitmLv == "3" {
  5254. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5255. }
  5256. }
  5257. if item.MedChrgitmType == "06" { //手术费
  5258. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5259. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5260. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5261. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5262. if item.ChrgitmLv == "1" {
  5263. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5264. }
  5265. if item.ChrgitmLv == "2" {
  5266. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5267. }
  5268. if item.ChrgitmLv == "3" {
  5269. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5270. }
  5271. }
  5272. if item.MedChrgitmType == "07" { //手术费
  5273. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5274. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5275. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5276. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5277. if item.ChrgitmLv == "1" {
  5278. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5279. }
  5280. if item.ChrgitmLv == "2" {
  5281. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5282. }
  5283. if item.ChrgitmLv == "3" {
  5284. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5285. }
  5286. }
  5287. if item.MedChrgitmType == "08" { //材料费
  5288. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5289. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5290. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5291. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5292. if item.ChrgitmLv == "1" {
  5293. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5294. }
  5295. if item.ChrgitmLv == "2" {
  5296. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5297. }
  5298. if item.ChrgitmLv == "3" {
  5299. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5300. }
  5301. }
  5302. if item.MedChrgitmType == "09" { //西药费
  5303. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5304. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5305. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5306. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5307. if item.ChrgitmLv == "1" {
  5308. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5309. }
  5310. if item.ChrgitmLv == "2" {
  5311. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5312. }
  5313. if item.ChrgitmLv == "3" {
  5314. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5315. }
  5316. }
  5317. if item.MedChrgitmType == "10" { //中药饮片
  5318. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5319. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5320. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5321. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5322. if item.ChrgitmLv == "1" {
  5323. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5324. }
  5325. if item.ChrgitmLv == "2" {
  5326. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5327. }
  5328. if item.ChrgitmLv == "3" {
  5329. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5330. }
  5331. }
  5332. if item.MedChrgitmType == "11" { //中成费
  5333. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5334. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5335. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5336. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5337. if item.ChrgitmLv == "1" {
  5338. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5339. }
  5340. if item.ChrgitmLv == "2" {
  5341. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5342. }
  5343. if item.ChrgitmLv == "3" {
  5344. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5345. }
  5346. }
  5347. if item.MedChrgitmType == "12" { //中成费
  5348. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5349. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5350. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5351. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5352. if item.ChrgitmLv == "1" {
  5353. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5354. }
  5355. if item.ChrgitmLv == "2" {
  5356. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5357. }
  5358. if item.ChrgitmLv == "3" {
  5359. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5360. }
  5361. }
  5362. if item.MedChrgitmType == "13" { //中成费
  5363. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5364. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5365. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5366. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5367. if item.ChrgitmLv == "1" {
  5368. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5369. }
  5370. if item.ChrgitmLv == "2" {
  5371. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5372. }
  5373. if item.ChrgitmLv == "3" {
  5374. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5375. }
  5376. }
  5377. if item.MedChrgitmType == "14" { //其他费
  5378. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5379. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5380. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5381. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5382. if item.ChrgitmLv == "1" {
  5383. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5384. }
  5385. if item.ChrgitmLv == "2" {
  5386. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5387. }
  5388. if item.ChrgitmLv == "3" {
  5389. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5390. }
  5391. }
  5392. }
  5393. var iteminfoStructs []service.IteminfoStruct
  5394. if bedCostTotal != 0 {
  5395. iteminfo.MedChrgitm = "01"
  5396. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5397. iteminfo.Amt = bedCostTotal
  5398. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5399. iteminfo.ClabAmt = bed_clab_amt
  5400. iteminfo.OthAmt = bed_other_amt
  5401. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5402. }
  5403. if examineCostTotal != 0 {
  5404. iteminfo.MedChrgitm = "02"
  5405. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5406. iteminfo.Amt = examineCostTotal
  5407. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5408. iteminfo.ClabAmt = examine_clab_amt
  5409. iteminfo.OthAmt = examine_other_amt
  5410. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5411. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5412. }
  5413. if checkCostTotal != 0 {
  5414. iteminfo.MedChrgitm = "03"
  5415. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5416. iteminfo.Amt = checkCostTotal
  5417. iteminfo.ClaaSumfee = check_claa_sunmfee
  5418. iteminfo.ClabAmt = check_clab_amt
  5419. iteminfo.OthAmt = check_other_amt
  5420. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5421. }
  5422. if laboratoryCostTotal != 0 {
  5423. iteminfo.MedChrgitm = "04"
  5424. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5425. iteminfo.Amt = laboratoryCostTotal
  5426. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5427. iteminfo.ClabAmt = laboratory_clab_amt
  5428. iteminfo.OthAmt = laboratory_other_amt
  5429. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5430. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5431. }
  5432. if treatCostTotal != 0 {
  5433. iteminfo.MedChrgitm = "05"
  5434. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5435. iteminfo.Amt = treatCostTotal
  5436. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5437. iteminfo.ClabAmt = treat_clab_amt
  5438. iteminfo.OthAmt = treat_other_amt
  5439. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5440. //(struct4101.IteminfoStruct, iteminfo)
  5441. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5442. }
  5443. if operationCostTotal != 0 {
  5444. iteminfo.MedChrgitm = "06"
  5445. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5446. iteminfo.Amt = operationCostTotal
  5447. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5448. iteminfo.ClabAmt = operation_clab_amt
  5449. iteminfo.OthAmt = operation_other_amt
  5450. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5451. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5452. }
  5453. if nursingCostTotal != 0 {
  5454. iteminfo.MedChrgitm = "07"
  5455. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5456. iteminfo.Amt = nursingCostTotal
  5457. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5458. iteminfo.ClabAmt = nursing_clab_amt
  5459. iteminfo.OthAmt = nursing_other_amt
  5460. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5461. }
  5462. if materialCostTotal != 0 {
  5463. iteminfo.MedChrgitm = "08"
  5464. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5465. iteminfo.Amt = materialCostTotal
  5466. iteminfo.ClaaSumfee = material_claa_sunmfee
  5467. iteminfo.ClabAmt = material_clab_amt
  5468. iteminfo.OthAmt = material_other_amt
  5469. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5470. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5471. }
  5472. if westernMedicineCostTotal != 0 {
  5473. iteminfo.MedChrgitm = "09"
  5474. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5475. iteminfo.Amt = westernMedicineCostTotal
  5476. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5477. iteminfo.ClabAmt = westernMedicine_clab_amt
  5478. iteminfo.OthAmt = westernMedicine_other_amt
  5479. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5480. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5481. }
  5482. if chineseMedicineCostTotal != 0 {
  5483. iteminfo.MedChrgitm = "10"
  5484. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5485. iteminfo.Amt = chineseMedicineCostTotal
  5486. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  5487. iteminfo.ClabAmt = chinese_medicine_clab_amt
  5488. iteminfo.OthAmt = chinese_medicine_other_amt
  5489. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5490. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5491. }
  5492. if chineseTraditionalMedicineCostTotal != 0 {
  5493. iteminfo.MedChrgitm = "11"
  5494. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5495. iteminfo.Amt = westernMedicineCostTotal
  5496. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5497. iteminfo.ClabAmt = westernMedicine_clab_amt
  5498. iteminfo.OthAmt = westernMedicine_other_amt
  5499. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5500. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5501. }
  5502. if commonlyTreatmentCostTotal != 0 {
  5503. iteminfo.MedChrgitm = "12"
  5504. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  5505. iteminfo.Amt = commonlyTreatmentCostTotal
  5506. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  5507. iteminfo.ClabAmt = commonly_treatment_clab_amt
  5508. iteminfo.OthAmt = commonly_treatment_other_amt
  5509. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5510. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5511. }
  5512. if registerCostTotal != 0 {
  5513. iteminfo.MedChrgitm = "13"
  5514. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  5515. iteminfo.Amt = registerCostTotal
  5516. iteminfo.ClaaSumfee = register_claa_sunmfee
  5517. iteminfo.ClabAmt = register_clab_amt
  5518. iteminfo.OthAmt = register_other_amt
  5519. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5520. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5521. }
  5522. if otherCostTotal != 0 {
  5523. iteminfo.MedChrgitm = "14"
  5524. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5525. iteminfo.Amt = otherCostTotal
  5526. iteminfo.ClaaSumfee = other_claa_sunmfee
  5527. iteminfo.ClabAmt = other_clab_amt
  5528. iteminfo.OthAmt = other_other_amt
  5529. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5530. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5531. }
  5532. struct4101.IteminfoStruct = iteminfoStructs
  5533. time_arr := strings.Split(order.SetlTime, " ")
  5534. struct4101.AdmTime = time_arr[0]
  5535. struct4101.AdmEndTime = time_arr[0]
  5536. struct4101.DoctorName = doctor.UserName
  5537. struct4101.DoctorCode = doctor.DoctorNumber
  5538. struct4101.Ntly = "中国"
  5539. struct4101.AdmCaty = "A03.06"
  5540. var res ResultSeventeen
  5541. if miConfig.MdtrtareaAdmvs == "421300" {
  5542. data := make(map[string]interface{})
  5543. data["struct4101"] = struct4101
  5544. data["secret_key"] = miConfig.SecretKey
  5545. data["org_name"] = miConfig.OrgName
  5546. data["opera"] = curRoles.UserName
  5547. data["code"] = miConfig.Code
  5548. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5549. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5550. client := &http.Client{}
  5551. bytesData, _ := json.Marshal(data)
  5552. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  5553. resp, _ := client.Do(req)
  5554. defer resp.Body.Close()
  5555. body, ioErr := ioutil.ReadAll(resp.Body)
  5556. if ioErr != nil {
  5557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5559. return
  5560. }
  5561. var respJSON map[string]interface{}
  5562. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5565. return
  5566. }
  5567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5568. userJSONBytes, _ := json.Marshal(respJSON)
  5569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5570. utils.ErrorLog("解析失败:%v", err)
  5571. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5572. adminUser := c.GetAdminUserInfo()
  5573. errlog := &models.HisOrderError{
  5574. UserOrgId: adminUser.CurrentOrgId,
  5575. Ctime: time.Now().Unix(),
  5576. Mtime: time.Now().Unix(),
  5577. ErrMsg: res.ErrMsg + "解析失败",
  5578. Status: 1,
  5579. PatientId: order_id,
  5580. Stage: 10088,
  5581. }
  5582. service.CreateErrMsgLog(errlog)
  5583. continue
  5584. }
  5585. } else {
  5586. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  5587. fmt.Println(result)
  5588. var dat map[string]interface{}
  5589. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5590. fmt.Println(dat)
  5591. } else {
  5592. fmt.Println(err)
  5593. }
  5594. userJSONBytes, _ := json.Marshal(dat)
  5595. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5596. utils.ErrorLog("解析失败:%v", err)
  5597. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5598. adminUser := c.GetAdminUserInfo()
  5599. errlog := &models.HisOrderError{
  5600. UserOrgId: adminUser.CurrentOrgId,
  5601. Ctime: time.Now().Unix(),
  5602. Mtime: time.Now().Unix(),
  5603. ErrMsg: res.ErrMsg + "解析失败",
  5604. Status: 1,
  5605. PatientId: order_id,
  5606. Stage: 10106,
  5607. }
  5608. service.CreateErrMsgLog(errlog)
  5609. continue
  5610. }
  5611. }
  5612. if res.Infcode != 0 {
  5613. adminUser := c.GetAdminUserInfo()
  5614. errlog := &models.HisOrderError{
  5615. UserOrgId: adminUser.CurrentOrgId,
  5616. Ctime: time.Now().Unix(),
  5617. Mtime: time.Now().Unix(),
  5618. ErrMsg: res.ErrMsg,
  5619. Status: 1,
  5620. PatientId: order_id,
  5621. Stage: 10106,
  5622. }
  5623. service.CreateErrMsgLog(errlog)
  5624. continue
  5625. } else {
  5626. hisFundSettleListResult := &models.HisFundSettleListResult{
  5627. Number: res.Output.SetlListId,
  5628. Status: 1,
  5629. Ctime: time.Now().Unix(),
  5630. Mtime: time.Now().Unix(),
  5631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5632. IsUpload: 1,
  5633. OrderId: order_id,
  5634. }
  5635. service.CreateUploadRecord(hisFundSettleListResult)
  5636. continue
  5637. }
  5638. }
  5639. }
  5640. func (c *HisApiController) GetOrgInfo() {
  5641. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5642. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5643. }
  5644. func (c *HisApiController) GetHisPatientInfo() {
  5645. medical_insurance_card := c.GetString("medical_insurance_card")
  5646. id_card_type, _ := c.GetInt64("id_card_type")
  5647. id_card := c.GetString("id_card")
  5648. adminInfo := c.GetAdminUserInfo()
  5649. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5650. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5651. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5652. IdCardNo := ""
  5653. if id_card_type == 1 {
  5654. IdCardNo = medical_insurance_card
  5655. } else if id_card_type == 2 {
  5656. IdCardNo = id_card
  5657. }
  5658. if config.IsOpen == 1 {
  5659. 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
  5660. resp, requestErr := http.Get(api)
  5661. if requestErr != nil {
  5662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5663. return
  5664. }
  5665. defer resp.Body.Close()
  5666. body, ioErr := ioutil.ReadAll(resp.Body)
  5667. if ioErr != nil {
  5668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5670. return
  5671. }
  5672. var respJSON map[string]interface{}
  5673. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5676. return
  5677. }
  5678. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5679. userJSONBytes, _ := json.Marshal(userJSON)
  5680. var res ResultTwo
  5681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5682. utils.ErrorLog("解析失败:%v", err)
  5683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5684. return
  5685. }
  5686. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5687. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5688. infoStr := string(Iinfos)
  5689. idetinfoStr := string(Idetinfos)
  5690. if res.Infcode == 0 {
  5691. his := models.VMHisPatient{
  5692. Status: 1,
  5693. Ctime: time.Now().Unix(),
  5694. Mtime: time.Now().Unix(),
  5695. PsnNo: res.Output.Baseinfo.PsnNo,
  5696. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5697. Certno: res.Output.Baseinfo.Certno,
  5698. PsnName: res.Output.Baseinfo.PsnName,
  5699. Gend: res.Output.Baseinfo.Gend,
  5700. Naty: res.Output.Baseinfo.Naty,
  5701. Brdy: res.Output.Baseinfo.Brdy,
  5702. Age: res.Output.Baseinfo.Age,
  5703. Iinfo: infoStr,
  5704. Idetinfo: idetinfoStr,
  5705. UserOrgId: adminInfo.CurrentOrgId,
  5706. IsReturn: 1,
  5707. IdCardType: id_card_type,
  5708. }
  5709. c.ServeSuccessJSON(map[string]interface{}{
  5710. "info": his,
  5711. })
  5712. } else {
  5713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5714. return
  5715. }
  5716. }
  5717. }
  5718. //func GetBasBaseInfo() (jsonStr string, err error) {
  5719. //
  5720. // handle := syscall.NewLazyDLL("SSCard.dll")
  5721. // add := handle.NewProc("ReadCardBas")
  5722. // str := make([]byte, 1024)
  5723. // str1 := make([]byte, 1024)
  5724. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5725. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5726. //
  5727. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5728. //
  5729. // fmt.Println("> Add(4,5)的结果为:", ret)
  5730. // handle.Release()
  5731. //
  5732. // return "", nil
  5733. //
  5734. //}
  5735. //func GetQRBaseInfo() (jsonStr string, err error) {
  5736. // handle := syscall.LoadDLL("SSCard.dll")
  5737. // ReadCardBas := handle.FindProc("GetQRBase")
  5738. //
  5739. // str := make([]byte, 256)
  5740. // str1 := make([]byte, 256)
  5741. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5742. //
  5743. // fmt.Println(string(str))
  5744. // fmt.Println(r)
  5745. // return string(str), nil
  5746. //}
  5747. //func CardInit() int {
  5748. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5749. // add := DllTestDef.MustFindProc("Init")
  5750. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5751. // if err != nil {
  5752. // fmt.Println("SSCard的运算结果为:", ret)
  5753. // }
  5754. // result := int(ret)
  5755. // return result
  5756. //}
  5757. //func CardInit() int {
  5758. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5759. // if err != nil {
  5760. // fmt.Println("SSCard的运算结果为:", ret)
  5761. // }
  5762. // fmt.Println(err)
  5763. // result := int(ret)
  5764. // return result
  5765. //}
  5766. func IntPtr(n int) uintptr {
  5767. return uintptr(n)
  5768. }
  5769. func StrPtr(s string) uintptr {
  5770. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5771. }
  5772. type Result2001 struct {
  5773. Cainfo interface{} `json:"cainfo"`
  5774. ErrMsg string `json:"err_msg"`
  5775. InfRefmsgid string `json:"inf_refmsgid"`
  5776. Infcode int64 `json:"infcode"`
  5777. Output struct {
  5778. Trtinfo struct {
  5779. PsnNo string `json:"psn_no"`
  5780. TrtChkType string `json:"trt_chk_type"`
  5781. FundPayType string `json:"fund_pay_type"`
  5782. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5783. Begndate string `json:"begndate"`
  5784. Enddate string `json:"enddate"`
  5785. TrtChkRslt string `json:"trt_chk_rslt"`
  5786. } `json:"trtinfo"`
  5787. } `json:"output"`
  5788. RefmsgTime string `json:"refmsg_time"`
  5789. RespondTime string `json:"respond_time"`
  5790. Signtype interface{} `json:"signtype"`
  5791. WarnMsg interface{} `json:"warn_msg"`
  5792. }
  5793. type Result2001Org10265 struct {
  5794. Cainfo interface{} `json:"cainfo"`
  5795. ErrMsg string `json:"err_msg"`
  5796. InfRefmsgid string `json:"inf_refmsgid"`
  5797. Infcode string `json:"infcode"`
  5798. Output struct {
  5799. Trtinfo struct {
  5800. PsnNo string `json:"psn_no"`
  5801. TrtChkType string `json:"trt_chk_type"`
  5802. FundPayType string `json:"fund_pay_type"`
  5803. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5804. Begndate string `json:"begndate"`
  5805. Enddate string `json:"enddate"`
  5806. TrtChkRslt string `json:"trt_chk_rslt"`
  5807. } `json:"trtinfo"`
  5808. } `json:"output"`
  5809. RefmsgTime string `json:"refmsg_time"`
  5810. RespondTime string `json:"respond_time"`
  5811. Signtype interface{} `json:"signtype"`
  5812. WarnMsg interface{} `json:"warn_msg"`
  5813. }
  5814. type ResultTwo struct {
  5815. ErrMsg string `json:"err_msg"`
  5816. InfRefmsgid string `json:"inf_refmsgid"`
  5817. Infcode int64 `json:"infcode"`
  5818. Output struct {
  5819. Baseinfo struct {
  5820. Age float64 `json:"age"`
  5821. Brdy string `json:"brdy"`
  5822. Certno string `json:"certno"`
  5823. Gend string `json:"gend"`
  5824. Naty string `json:"naty"`
  5825. PsnCertType string `json:"psn_cert_type"`
  5826. PsnName string `json:"psn_name"`
  5827. PsnNo string `json:"psn_no"`
  5828. } `json:"baseinfo"`
  5829. Idetinfo []interface{} `json:"idetinfo"`
  5830. Iinfo []struct {
  5831. Balc float64 `json:"balc"`
  5832. CvlservFlag string `json:"cvlserv_flag"`
  5833. EmpName string `json:"emp_name"`
  5834. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5835. Insutype string `json:"insutype"`
  5836. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5837. PausInsuDate string `json:"paus_insu_date"`
  5838. PsnInsuDate string `json:"psn_insu_date"`
  5839. PsnInsuStas string `json:"psn_insu_stas"`
  5840. PsnType string `json:"psn_type"`
  5841. } `json:"insuinfo"`
  5842. } `json:"output"`
  5843. RefmsgTime string `json:"refmsg_time"`
  5844. RespondTime string `json:"respond_time"`
  5845. Signtype interface{} `json:"signtype"`
  5846. WarnInfo interface{} `json:"warn_info"`
  5847. }
  5848. type ResultTwo10265 struct {
  5849. ErrMsg string `json:"err_msg"`
  5850. InfRefmsgid string `json:"inf_refmsgid"`
  5851. Infcode string `json:"infcode"`
  5852. Output struct {
  5853. Baseinfo struct {
  5854. Age float64 `json:"age"`
  5855. Brdy string `json:"brdy"`
  5856. Certno string `json:"certno"`
  5857. Gend string `json:"gend"`
  5858. Naty string `json:"naty"`
  5859. PsnCertType string `json:"psn_cert_type"`
  5860. PsnName string `json:"psn_name"`
  5861. PsnNo string `json:"psn_no"`
  5862. } `json:"baseinfo"`
  5863. Idetinfo []interface{} `json:"idetinfo"`
  5864. Iinfo []struct {
  5865. Balc float64 `json:"balc"`
  5866. CvlservFlag string `json:"cvlserv_flag"`
  5867. EmpName string `json:"emp_name"`
  5868. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5869. Insutype string `json:"insutype"`
  5870. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5871. PausInsuDate string `json:"paus_insu_date"`
  5872. PsnInsuDate string `json:"psn_insu_date"`
  5873. PsnInsuStas string `json:"psn_insu_stas"`
  5874. PsnType string `json:"psn_type"`
  5875. } `json:"insuinfo"`
  5876. } `json:"output"`
  5877. RefmsgTime string `json:"refmsg_time"`
  5878. RespondTime string `json:"respond_time"`
  5879. Signtype interface{} `json:"signtype"`
  5880. WarnInfo interface{} `json:"warn_info"`
  5881. }
  5882. type ResultThree struct {
  5883. Cainfo interface{} `json:"cainfo"`
  5884. ErrMsg string `json:"err_msg"`
  5885. InfRefmsgid string `json:"inf_refmsgid"`
  5886. Infcode int64 `json:"infcode"`
  5887. Output struct {
  5888. Data struct {
  5889. IptOtpNo string `json:"ipt_otp_no"`
  5890. MdtrtID string `json:"mdtrt_id"`
  5891. PsnNo string `json:"psn_no"`
  5892. } `json:"data"`
  5893. } `json:"output"`
  5894. RefmsgTime string `json:"refmsg_time"`
  5895. RespondTime string `json:"respond_time"`
  5896. Signtype interface{} `json:"signtype"`
  5897. WarnMsg interface{} `json:"warn_msg"`
  5898. }
  5899. type ResultThree10265 struct {
  5900. Cainfo interface{} `json:"cainfo"`
  5901. ErrMsg string `json:"err_msg"`
  5902. InfRefmsgid string `json:"inf_refmsgid"`
  5903. Infcode string `json:"infcode"`
  5904. Output struct {
  5905. Data struct {
  5906. IptOtpNo string `json:"ipt_otp_no"`
  5907. MdtrtID string `json:"mdtrt_id"`
  5908. PsnNo string `json:"psn_no"`
  5909. } `json:"data"`
  5910. } `json:"output"`
  5911. RefmsgTime string `json:"refmsg_time"`
  5912. RespondTime string `json:"respond_time"`
  5913. Signtype interface{} `json:"signtype"`
  5914. WarnMsg interface{} `json:"warn_msg"`
  5915. }
  5916. type ResultFour struct {
  5917. Cainfo string `json:"cainfo"`
  5918. ErrMsg string `json:"err_msg"`
  5919. InfRefmsgid string `json:"inf_refmsgid"`
  5920. Infcode int64 `json:"infcode"`
  5921. Output struct {
  5922. Result []struct {
  5923. BasMednFlag string `json:"bas_medn_flag"`
  5924. ChldMedcFlag string `json:"chld_medc_flag"`
  5925. ChrgitmLv string `json:"chrgitm_lv"`
  5926. Cnt float64 `json:"cnt"`
  5927. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5928. DrtReimFlag string `json:"drt_reim_flag"`
  5929. FeedetlSn string `json:"feedetl_sn"`
  5930. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5931. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5932. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5933. ListSpItemFlag string `json:"list_sp_item_flag"`
  5934. LmtUsedFlag string `json:"lmt_used_flag"`
  5935. MedChrgitmType string `json:"med_chrgitm_type"`
  5936. Memo string `json:"memo"`
  5937. OverlmtAmt float64 `json:"overlmt_amt"`
  5938. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5939. Pric float64 `json:"pric"`
  5940. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5941. SelfpayProp float64 `json:"selfpay_prop"`
  5942. } `json:"result"`
  5943. } `json:"output"`
  5944. RefmsgTime string `json:"refmsg_time"`
  5945. RespondTime string `json:"respond_time"`
  5946. Signtype string `json:"signtype"`
  5947. WarnMsg string `json:"warn_msg"`
  5948. }
  5949. type ResultFour10265 struct {
  5950. Cainfo string `json:"cainfo"`
  5951. ErrMsg string `json:"err_msg"`
  5952. InfRefmsgid string `json:"inf_refmsgid"`
  5953. Infcode string `json:"infcode"`
  5954. Output struct {
  5955. Result []struct {
  5956. BasMednFlag string `json:"bas_medn_flag"`
  5957. ChldMedcFlag string `json:"chld_medc_flag"`
  5958. ChrgitmLv string `json:"chrgitm_lv"`
  5959. Cnt float64 `json:"cnt"`
  5960. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5961. DrtReimFlag string `json:"drt_reim_flag"`
  5962. FeedetlSn string `json:"feedetl_sn"`
  5963. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5964. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5965. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5966. ListSpItemFlag string `json:"list_sp_item_flag"`
  5967. LmtUsedFlag string `json:"lmt_used_flag"`
  5968. MedChrgitmType string `json:"med_chrgitm_type"`
  5969. Memo string `json:"memo"`
  5970. OverlmtAmt float64 `json:"overlmt_amt"`
  5971. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5972. Pric float64 `json:"pric"`
  5973. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5974. SelfpayProp float64 `json:"selfpay_prop"`
  5975. } `json:"result"`
  5976. } `json:"output"`
  5977. RefmsgTime string `json:"refmsg_time"`
  5978. RespondTime string `json:"respond_time"`
  5979. Signtype string `json:"signtype"`
  5980. WarnMsg string `json:"warn_msg"`
  5981. }
  5982. type ResultMemo struct {
  5983. InsuAdmdvs string `json:"insuAdmdvs"`
  5984. }
  5985. //[{"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}]
  5986. type ResultIDInfo struct {
  5987. Begntime string `json:"begntime"`
  5988. Endtime string `json:"endtime"`
  5989. Memo string `json:"memo"`
  5990. }
  5991. type ResultFive struct {
  5992. Balc float64 `json:"balc"`
  5993. CvlservFlag string `json:"cvlserv_flag"`
  5994. EmpName string `json:"emp_name"`
  5995. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5996. Insutype string `json:"insutype"`
  5997. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5998. PausInsuDate string `json:"paus_insu_date"`
  5999. PsnInsuDate string `json:"psn_insu_date"`
  6000. PsnInsuStas string `json:"psn_insu_stas"`
  6001. PsnType string `json:"psn_type"`
  6002. }
  6003. type ResultSix struct {
  6004. Cainfo interface{} `json:"cainfo"`
  6005. ErrMsg string `json:"err_msg"`
  6006. InfRefmsgid string `json:"inf_refmsgid"`
  6007. Infcode int64 `json:"infcode"`
  6008. Output struct {
  6009. } `json:"output"`
  6010. RefmsgTime string `json:"refmsg_time"`
  6011. RespondTime string `json:"respond_time"`
  6012. Signtype interface{} `json:"signtype"`
  6013. WarnMsg interface{} `json:"warn_msg"`
  6014. }
  6015. type ResultSix10265 struct {
  6016. Cainfo interface{} `json:"cainfo"`
  6017. ErrMsg string `json:"err_msg"`
  6018. InfRefmsgid string `json:"inf_refmsgid"`
  6019. Infcode string `json:"infcode"`
  6020. Output struct {
  6021. } `json:"output"`
  6022. RefmsgTime string `json:"refmsg_time"`
  6023. RespondTime string `json:"respond_time"`
  6024. Signtype interface{} `json:"signtype"`
  6025. WarnMsg interface{} `json:"warn_msg"`
  6026. }
  6027. type ResultSeven struct {
  6028. Cainfo string `json:"cainfo"`
  6029. ErrMsg string `json:"err_msg"`
  6030. InfRefmsgid string `json:"inf_refmsgid"`
  6031. Infcode int64 `json:"infcode"`
  6032. Output struct {
  6033. Setldetail []interface{} `json:"setldetail"`
  6034. Setlinfo struct {
  6035. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6036. AcctPay float64 `json:"acct_pay"`
  6037. ActPayDedc float64 `json:"act_pay_dedc"`
  6038. Age float64 `json:"age"`
  6039. Balc float64 `json:"balc"`
  6040. Brdy string `json:"brdy"`
  6041. Certno string `json:"certno"`
  6042. ClrOptins string `json:"clr_optins"`
  6043. ClrType string `json:"clr_type"`
  6044. ClrWay string `json:"clr_way"`
  6045. CvlservFlag string `json:"cvlserv_flag"`
  6046. CvlservPay float64 `json:"cvlserv_pay"`
  6047. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6048. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6049. Gend string `json:"gend"`
  6050. HifesPay float64 `json:"hifes_pay"`
  6051. HifmiPay float64 `json:"hifmi_pay"`
  6052. HifpPay float64 `json:"hifp_pay"`
  6053. HospPartAmt float64 `json:"hosp_part_amt"`
  6054. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6055. Insutype string `json:"insutype"`
  6056. MafPay float64 `json:"maf_pay"`
  6057. MdtrtCertType string `json:"mdtrt_cert_type"`
  6058. HifobPay float64 `json:"hifob_pay"`
  6059. MdtrtID string `json:"mdtrt_id"`
  6060. MedType string `json:"med_type"`
  6061. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6062. MedinsSetlID string `json:"medins_setl_id"`
  6063. Naty string `json:"naty"`
  6064. OthPay float64 `json:"oth_pay"`
  6065. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6066. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6067. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6068. PsnCashPay float64 `json:"psn_cash_pay"`
  6069. PsnCertType string `json:"psn_cert_type"`
  6070. PsnName string `json:"psn_name"`
  6071. PsnNo string `json:"psn_no"`
  6072. PsnPartAmt float64 `json:"psn_part_amt"`
  6073. PsnType string `json:"psn_type"`
  6074. SetlID string `json:"setl_id"`
  6075. SetlTime string `json:"setl_time"`
  6076. } `json:"setlinfo"`
  6077. } `json:"output"`
  6078. RefmsgTime string `json:"refmsg_time"`
  6079. RespondTime string `json:"respond_time"`
  6080. Signtype interface{} `json:"signtype"`
  6081. WarnMsg interface{} `json:"warn_msg"`
  6082. }
  6083. type ResultSeven10265 struct {
  6084. Cainfo string `json:"cainfo"`
  6085. ErrMsg string `json:"err_msg"`
  6086. InfRefmsgid string `json:"inf_refmsgid"`
  6087. Infcode string `json:"infcode"`
  6088. Output struct {
  6089. Setldetail []interface{} `json:"setldetail"`
  6090. Setlinfo struct {
  6091. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6092. AcctPay float64 `json:"acct_pay"`
  6093. ActPayDedc float64 `json:"act_pay_dedc"`
  6094. Age float64 `json:"age"`
  6095. Balc float64 `json:"balc"`
  6096. Brdy string `json:"brdy"`
  6097. Certno string `json:"certno"`
  6098. ClrOptins string `json:"clr_optins"`
  6099. ClrType string `json:"clr_type"`
  6100. ClrWay string `json:"clr_way"`
  6101. CvlservFlag string `json:"cvlserv_flag"`
  6102. CvlservPay float64 `json:"cvlserv_pay"`
  6103. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6104. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6105. Gend string `json:"gend"`
  6106. HifesPay float64 `json:"hifes_pay"`
  6107. HifmiPay float64 `json:"hifmi_pay"`
  6108. HifpPay float64 `json:"hifp_pay"`
  6109. HospPartAmt float64 `json:"hosp_part_amt"`
  6110. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6111. Insutype string `json:"insutype"`
  6112. MafPay float64 `json:"maf_pay"`
  6113. MdtrtCertType string `json:"mdtrt_cert_type"`
  6114. HifobPay float64 `json:"hifob_pay"`
  6115. MdtrtID string `json:"mdtrt_id"`
  6116. MedType string `json:"med_type"`
  6117. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6118. MedinsSetlID string `json:"medins_setl_id"`
  6119. Naty string `json:"naty"`
  6120. OthPay float64 `json:"oth_pay"`
  6121. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6122. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6123. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6124. PsnCashPay float64 `json:"psn_cash_pay"`
  6125. PsnCertType string `json:"psn_cert_type"`
  6126. PsnName string `json:"psn_name"`
  6127. PsnNo string `json:"psn_no"`
  6128. PsnPartAmt float64 `json:"psn_part_amt"`
  6129. PsnType string `json:"psn_type"`
  6130. SetlID string `json:"setl_id"`
  6131. SetlTime string `json:"setl_time"`
  6132. } `json:"setlinfo"`
  6133. } `json:"output"`
  6134. RefmsgTime string `json:"refmsg_time"`
  6135. RespondTime string `json:"respond_time"`
  6136. Signtype interface{} `json:"signtype"`
  6137. WarnMsg interface{} `json:"warn_msg"`
  6138. }
  6139. type ResultEight struct {
  6140. Cainfo string `json:"cainfo"`
  6141. ErrMsg string `json:"err_msg"`
  6142. InfRefmsgid string `json:"inf_refmsgid"`
  6143. Infcode int64 `json:"infcode"`
  6144. Output struct {
  6145. Stmtinfo struct {
  6146. SetlOptins string `json:"setl_optins"`
  6147. StmtRslt string `json:"stmt_rslt"`
  6148. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6149. } `json:"stmtinfo"`
  6150. } `json:"output"`
  6151. RefmsgTime string `json:"refmsg_time"`
  6152. RespondTime string `json:"respond_time"`
  6153. Signtype interface{} `json:"signtype"`
  6154. WarnMsg interface{} `json:"warn_msg"`
  6155. }
  6156. type ResultEightFor10188 struct {
  6157. Cainfo string `json:"cainfo"`
  6158. ErrMsg string `json:"err_msg"`
  6159. InfRefmsgid string `json:"inf_refmsgid"`
  6160. Infcode string `json:"infcode"`
  6161. Output struct {
  6162. Stmtinfo struct {
  6163. SetlOptins string `json:"setl_optins"`
  6164. StmtRslt string `json:"stmt_rslt"`
  6165. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6166. } `json:"stmtinfo"`
  6167. } `json:"output"`
  6168. RefmsgTime string `json:"refmsg_time"`
  6169. RespondTime string `json:"respond_time"`
  6170. Signtype interface{} `json:"signtype"`
  6171. WarnMsg interface{} `json:"warn_msg"`
  6172. }
  6173. type ResultNine struct {
  6174. Cainfo string `json:"cainfo"`
  6175. ErrMsg string `json:"err_msg"`
  6176. InfRefmsgid string `json:"inf_refmsgid"`
  6177. Infcode int64 `json:"infcode"`
  6178. Output struct {
  6179. FileQuryNo string `json:"file_qury_no"`
  6180. } `json:"output"`
  6181. RefmsgTime string `json:"refmsg_time"`
  6182. RespondTime string `json:"respond_time"`
  6183. Signtype interface{} `json:"signtype"`
  6184. WarnMsg interface{} `json:"warn_msg"`
  6185. }
  6186. type ResultTen struct {
  6187. Cainfo string `json:"cainfo"`
  6188. ErrMsg string `json:"err_msg"`
  6189. InfRefmsgid string `json:"inf_refmsgid"`
  6190. Infcode int64 `json:"infcode"`
  6191. Output struct {
  6192. DldEndtime string `json:"dld_endtime"`
  6193. FileQuryNo string `json:"file_qury_no"`
  6194. Filename string `json:"filename"`
  6195. } `json:"output"`
  6196. RefmsgTime string `json:"refmsg_time"`
  6197. RespondTime string `json:"respond_time"`
  6198. Signtype interface{} `json:"signtype"`
  6199. WarnMsg interface{} `json:"warn_msg"`
  6200. }
  6201. //type Autogenerated struct {
  6202. // Output struct {
  6203. // Setlinfo struct {
  6204. // SetlTime string `json:"setl_time"`
  6205. // CvlservPay float64 `json:"cvlserv_pay"`
  6206. // Year string `json:"year"`
  6207. // MedType string `json:"med_type"`
  6208. // PsnPay float64 `json:"psn_pay"`
  6209. // OpterID string `json:"opter_id"`
  6210. // Begndate string `json:"begndate"`
  6211. // FlxempeFlag string `json:"flxempe_flag"`
  6212. // HifmiPay float64 `json:"hifmi_pay"`
  6213. // PsnNo string `json:"psn_no"`
  6214. // ActPayDedc float64 `json:"act_pay_dedc"`
  6215. // MedinsSetlID interface{} `json:"medins_setl_id"`
  6216. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6217. // ClrWay string `json:"clr_way"`
  6218. // OthPay float64 `json:"oth_pay"`
  6219. // Gend string `json:"gend"`
  6220. // MdtrtID string `json:"mdtrt_id"`
  6221. // AcctPay float64 `json:"acct_pay"`
  6222. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  6223. // Insutype string `json:"insutype"`
  6224. // Invono interface{} `json:"invono"`
  6225. // Enddate string `json:"enddate"`
  6226. // CashPayamt float64 `json:"cash_payamt"`
  6227. // PsnType string `json:"psn_type"`
  6228. // FixmedinsName string `json:"fixmedins_name"`
  6229. // HifpPay float64 `json:"hifp_pay"`
  6230. // NewFlag interface{} `json:"new_flag"`
  6231. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6232. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  6233. // PayLoc string `json:"pay_loc"`
  6234. // ClrType string `json:"clr_type"`
  6235. // RefdSetlFlag string `json:"refd_setl_flag"`
  6236. // CvlservFlag string `json:"cvlserv_flag"`
  6237. // EmpName string `json:"emp_name"`
  6238. // Brdy string `json:"brdy"`
  6239. // Naty string `json:"naty"`
  6240. // Certno string `json:"certno"`
  6241. // DiseCode string `json:"dise_code"`
  6242. // FixmedinsCode string `json:"fixmedins_code"`
  6243. // DedcHospLv string `json:"dedc_hosp_lv"`
  6244. // OpterName string `json:"opter_name"`
  6245. // Balc float64 `json:"balc"`
  6246. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6247. // PsnCertType string `json:"psn_cert_type"`
  6248. // HifobPay float64 `json:"hifob_pay"`
  6249. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  6250. // HifesPay float64 `json:"hifes_pay"`
  6251. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6252. // OptTime string `json:"opt_time"`
  6253. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6254. // SetlID string `json:"setl_id"`
  6255. // MafPay float64 `json:"maf_pay"`
  6256. // PsnName string `json:"psn_name"`
  6257. // InsuOptins interface{} `json:"insu_optins"`
  6258. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6259. // ClrOptins string `json:"clr_optins"`
  6260. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6261. // DiseName string `json:"dise_name"`
  6262. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6263. // Age float64 `json:"age"`
  6264. // DtrtCertType string `json:"dtrt_cert_type"`
  6265. // HospLv string `json:"hosp_lv"`
  6266. // } `json:"setlinfo"`
  6267. // Setldetail []struct {
  6268. // FundPayType string `json:"fund_pay_type"`
  6269. // FundPayamt float64 `json:"fund_payamt"`
  6270. // SetlProcInfo interface{} `json:"setl_proc_info"`
  6271. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  6272. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  6273. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  6274. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6275. // } `json:"setldetail"`
  6276. // } `json:"output"`
  6277. // Infcode int `json:"infcode"`
  6278. // WarnMsg interface{} `json:"warn_msg"`
  6279. // Cainfo interface{} `json:"cainfo"`
  6280. // ErrMsg interface{} `json:"err_msg"`
  6281. // RefmsgTime string `json:"refmsg_time"`
  6282. // Signtype interface{} `json:"signtype"`
  6283. // RespondTime string `json:"respond_time"`
  6284. // InfRefmsgid string `json:"inf_refmsgid"`
  6285. //}
  6286. type ResultEleven struct {
  6287. Cainfo string `json:"cainfo"`
  6288. ErrMsg string `json:"err_msg"`
  6289. InfRefmsgid string `json:"inf_refmsgid"`
  6290. Infcode int64 `json:"infcode"`
  6291. Output struct {
  6292. Setlinfo struct {
  6293. SetlTime string `json:"setl_time"`
  6294. CvlservPay float64 `json:"cvlserv_pay"`
  6295. Year string `json:"year"`
  6296. MedType string `json:"med_type"`
  6297. PsnPay float64 `json:"psn_pay"`
  6298. OpterID string `json:"opter_id"`
  6299. Begndate string `json:"begndate"`
  6300. FlxempeFlag string `json:"flxempe_flag"`
  6301. HifmiPay float64 `json:"hifmi_pay"`
  6302. PsnNo string `json:"psn_no"`
  6303. ActPayDedc float64 `json:"act_pay_dedc"`
  6304. MedinsSetlID interface{} `json:"medins_setl_id"`
  6305. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6306. ClrWay string `json:"clr_way"`
  6307. OthPay float64 `json:"oth_pay"`
  6308. Gend string `json:"gend"`
  6309. MdtrtID string `json:"mdtrt_id"`
  6310. AcctPay float64 `json:"acct_pay"`
  6311. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6312. Insutype string `json:"insutype"`
  6313. Invono interface{} `json:"invono"`
  6314. Enddate string `json:"enddate"`
  6315. CashPayamt float64 `json:"cash_payamt"`
  6316. PsnType string `json:"psn_type"`
  6317. FixmedinsName string `json:"fixmedins_name"`
  6318. HifpPay float64 `json:"hifp_pay"`
  6319. NewFlag interface{} `json:"new_flag"`
  6320. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6321. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6322. PayLoc string `json:"pay_loc"`
  6323. ClrType string `json:"clr_type"`
  6324. RefdSetlFlag string `json:"refd_setl_flag"`
  6325. CvlservFlag string `json:"cvlserv_flag"`
  6326. EmpName string `json:"emp_name"`
  6327. Brdy string `json:"brdy"`
  6328. Naty string `json:"naty"`
  6329. Certno string `json:"certno"`
  6330. DiseCode string `json:"dise_code"`
  6331. FixmedinsCode string `json:"fixmedins_code"`
  6332. DedcHospLv string `json:"dedc_hosp_lv"`
  6333. OpterName string `json:"opter_name"`
  6334. Balc float64 `json:"balc"`
  6335. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6336. PsnCertType string `json:"psn_cert_type"`
  6337. HifobPay float64 `json:"hifob_pay"`
  6338. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6339. HifesPay float64 `json:"hifes_pay"`
  6340. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6341. OptTime string `json:"opt_time"`
  6342. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6343. SetlID string `json:"setl_id"`
  6344. MafPay float64 `json:"maf_pay"`
  6345. PsnName string `json:"psn_name"`
  6346. InsuOptins interface{} `json:"insu_optins"`
  6347. PrefFundPay interface{} `json:"pref_fund_pay"`
  6348. ClrOptins string `json:"clr_optins"`
  6349. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6350. DiseName string `json:"dise_name"`
  6351. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6352. Age float64 `json:"age"`
  6353. DtrtCertType string `json:"dtrt_cert_type"`
  6354. HospLv string `json:"hosp_lv"`
  6355. PsnCashPay float64
  6356. } `json:"setlinfo"`
  6357. } `json:"output"`
  6358. RefmsgTime string `json:"refmsg_time"`
  6359. RespondTime string `json:"respond_time"`
  6360. Signtype interface{} `json:"signtype"`
  6361. WarnMsg interface{} `json:"warn_msg"`
  6362. }
  6363. type ResultEleven10265 struct {
  6364. Cainfo string `json:"cainfo"`
  6365. ErrMsg string `json:"err_msg"`
  6366. InfRefmsgid string `json:"inf_refmsgid"`
  6367. Infcode string `json:"infcode"`
  6368. Output struct {
  6369. Setlinfo struct {
  6370. SetlTime string `json:"setl_time"`
  6371. CvlservPay float64 `json:"cvlserv_pay"`
  6372. Year string `json:"year"`
  6373. MedType string `json:"med_type"`
  6374. PsnPay float64 `json:"psn_pay"`
  6375. OpterID string `json:"opter_id"`
  6376. Begndate string `json:"begndate"`
  6377. FlxempeFlag string `json:"flxempe_flag"`
  6378. HifmiPay float64 `json:"hifmi_pay"`
  6379. PsnNo string `json:"psn_no"`
  6380. ActPayDedc float64 `json:"act_pay_dedc"`
  6381. MedinsSetlID interface{} `json:"medins_setl_id"`
  6382. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6383. ClrWay string `json:"clr_way"`
  6384. OthPay float64 `json:"oth_pay"`
  6385. Gend string `json:"gend"`
  6386. MdtrtID string `json:"mdtrt_id"`
  6387. AcctPay float64 `json:"acct_pay"`
  6388. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6389. Insutype string `json:"insutype"`
  6390. Invono interface{} `json:"invono"`
  6391. Enddate string `json:"enddate"`
  6392. CashPayamt float64 `json:"cash_payamt"`
  6393. PsnType string `json:"psn_type"`
  6394. FixmedinsName string `json:"fixmedins_name"`
  6395. HifpPay float64 `json:"hifp_pay"`
  6396. NewFlag interface{} `json:"new_flag"`
  6397. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6398. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6399. PayLoc string `json:"pay_loc"`
  6400. ClrType string `json:"clr_type"`
  6401. RefdSetlFlag string `json:"refd_setl_flag"`
  6402. CvlservFlag string `json:"cvlserv_flag"`
  6403. EmpName string `json:"emp_name"`
  6404. Brdy string `json:"brdy"`
  6405. Naty string `json:"naty"`
  6406. Certno string `json:"certno"`
  6407. DiseCode string `json:"dise_code"`
  6408. FixmedinsCode string `json:"fixmedins_code"`
  6409. DedcHospLv string `json:"dedc_hosp_lv"`
  6410. OpterName string `json:"opter_name"`
  6411. Balc float64 `json:"balc"`
  6412. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6413. PsnCertType string `json:"psn_cert_type"`
  6414. HifobPay float64 `json:"hifob_pay"`
  6415. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6416. HifesPay float64 `json:"hifes_pay"`
  6417. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6418. OptTime string `json:"opt_time"`
  6419. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6420. SetlID string `json:"setl_id"`
  6421. MafPay float64 `json:"maf_pay"`
  6422. PsnName string `json:"psn_name"`
  6423. InsuOptins interface{} `json:"insu_optins"`
  6424. PrefFundPay interface{} `json:"pref_fund_pay"`
  6425. ClrOptins string `json:"clr_optins"`
  6426. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6427. DiseName string `json:"dise_name"`
  6428. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6429. Age float64 `json:"age"`
  6430. DtrtCertType string `json:"dtrt_cert_type"`
  6431. HospLv string `json:"hosp_lv"`
  6432. PsnCashPay float64
  6433. } `json:"setlinfo"`
  6434. } `json:"output"`
  6435. RefmsgTime string `json:"refmsg_time"`
  6436. RespondTime string `json:"respond_time"`
  6437. Signtype interface{} `json:"signtype"`
  6438. WarnMsg interface{} `json:"warn_msg"`
  6439. }
  6440. type ResultTwelve struct {
  6441. Cainfo string `json:"cainfo"`
  6442. ErrMsg string `json:"err_msg"`
  6443. InfRefmsgid string `json:"inf_refmsgid"`
  6444. Infcode int64 `json:"infcode"`
  6445. Output struct {
  6446. MdtrtId string `json:"mdtrt_id"`
  6447. ChrgBchno string `json:"chrg_bchno"`
  6448. PsnNo string `json:"psn_no"`
  6449. } `json:"output"`
  6450. RefmsgTime string `json:"refmsg_time"`
  6451. RespondTime string `json:"respond_time"`
  6452. Signtype interface{} `json:"signtype"`
  6453. WarnMsg interface{} `json:"warn_msg"`
  6454. }
  6455. type ResultThirteen struct {
  6456. ErrMsg string `json:"err_msg"`
  6457. InfRefmsgid string `json:"inf_refmsgid"`
  6458. Infcode int64 `json:"infcode"`
  6459. Output struct {
  6460. Result struct {
  6461. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6462. } `json:"result"`
  6463. } `json:"output"`
  6464. RefmsgTime string `json:"refmsg_time"`
  6465. RespondTime string `json:"respond_time"`
  6466. Signtype interface{} `json:"signtype"`
  6467. WarnInfo interface{} `json:"warn_info"`
  6468. }
  6469. type ResultThirteen10265 struct {
  6470. ErrMsg string `json:"err_msg"`
  6471. InfRefmsgid string `json:"inf_refmsgid"`
  6472. Infcode string `json:"infcode"`
  6473. Output struct {
  6474. Result struct {
  6475. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6476. } `json:"result"`
  6477. } `json:"output"`
  6478. RefmsgTime string `json:"refmsg_time"`
  6479. RespondTime string `json:"respond_time"`
  6480. Signtype interface{} `json:"signtype"`
  6481. WarnInfo interface{} `json:"warn_info"`
  6482. }
  6483. type ResultFourteen struct {
  6484. ErrMsg string `json:"err_msg"`
  6485. InfRefmsgid string `json:"inf_refmsgid"`
  6486. Infcode int64 `json:"infcode"`
  6487. Output struct {
  6488. } `json:"output"`
  6489. RefmsgTime string `json:"refmsg_time"`
  6490. RespondTime string `json:"respond_time"`
  6491. Signtype interface{} `json:"signtype"`
  6492. WarnInfo interface{} `json:"warn_info"`
  6493. }
  6494. type ResultFourteen10265 struct {
  6495. ErrMsg string `json:"err_msg"`
  6496. InfRefmsgid string `json:"inf_refmsgid"`
  6497. Infcode string `json:"infcode"`
  6498. Output struct {
  6499. } `json:"output"`
  6500. RefmsgTime string `json:"refmsg_time"`
  6501. RespondTime string `json:"respond_time"`
  6502. Signtype interface{} `json:"signtype"`
  6503. WarnInfo interface{} `json:"warn_info"`
  6504. }
  6505. type ResultSixteen struct {
  6506. Cainfo string `json:"cainfo"`
  6507. ErrMsg string `json:"err_msg"`
  6508. InfRefmsgid string `json:"inf_refmsgid"`
  6509. Infcode int64 `json:"infcode"`
  6510. Output struct {
  6511. Setldetail []interface{} `json:"setldetail"`
  6512. Setlinfo struct {
  6513. MdtrtID string `json:"mdtrt_id"`
  6514. SetlID string `json:"setl_id"`
  6515. ClrOptins string `json:"clr_optins"`
  6516. SetlTime string `json:"setl_time"`
  6517. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6518. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6519. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6520. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6521. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6522. ActPayDedc float64 `json:"act_pay_dedc"`
  6523. HifpPay float64 `json:"hifp_pay"`
  6524. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6525. Lfpay float64 `json:"selfpay"`
  6526. CvlservPay float64 `json:"cvlserv_pay"`
  6527. HifesPay float64 `json:"hifes_pay"`
  6528. HifmiPay float64 `json:"hifmi_pay"`
  6529. HifobPay float64 `json:"hifob_pay"`
  6530. MafPay float64 `json:"maf_pay"`
  6531. OthPay float64 `json:"oth_pay"`
  6532. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6533. PsnPartAmt float64 `json:"psn_part_amt"`
  6534. AcctPay float64 `json:"acct_pay"`
  6535. Balc float64 `json:"balc"`
  6536. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6537. HospPartAmt float64 `json:"hosp_part_amt"`
  6538. MedinsSetlID string `json:"medins_setl_id"`
  6539. PdnCashPay string `json:"pdn_cash_pay"`
  6540. } `json:"setlinfo"`
  6541. } `json:"output"`
  6542. RefmsgTime string `json:"refmsg_time"`
  6543. RespondTime string `json:"respond_time"`
  6544. Signtype interface{} `json:"signtype"`
  6545. WarnMsg interface{} `json:"warn_msg"`
  6546. }
  6547. type ResultSixteen10265 struct {
  6548. Cainfo string `json:"cainfo"`
  6549. ErrMsg string `json:"err_msg"`
  6550. InfRefmsgid string `json:"inf_refmsgid"`
  6551. Infcode string `json:"infcode"`
  6552. Output struct {
  6553. Setldetail []interface{} `json:"setldetail"`
  6554. Setlinfo struct {
  6555. MdtrtID string `json:"mdtrt_id"`
  6556. SetlID string `json:"setl_id"`
  6557. ClrOptins string `json:"clr_optins"`
  6558. SetlTime string `json:"setl_time"`
  6559. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6560. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6561. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6562. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6563. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6564. ActPayDedc float64 `json:"act_pay_dedc"`
  6565. HifpPay float64 `json:"hifp_pay"`
  6566. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6567. Lfpay float64 `json:"selfpay"`
  6568. CvlservPay float64 `json:"cvlserv_pay"`
  6569. HifesPay float64 `json:"hifes_pay"`
  6570. HifmiPay float64 `json:"hifmi_pay"`
  6571. HifobPay float64 `json:"hifob_pay"`
  6572. MafPay float64 `json:"maf_pay"`
  6573. OthPay float64 `json:"oth_pay"`
  6574. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6575. PsnPartAmt float64 `json:"psn_part_amt"`
  6576. AcctPay float64 `json:"acct_pay"`
  6577. Balc float64 `json:"balc"`
  6578. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6579. HospPartAmt float64 `json:"hosp_part_amt"`
  6580. MedinsSetlID string `json:"medins_setl_id"`
  6581. PdnCashPay string `json:"pdn_cash_pay"`
  6582. } `json:"setlinfo"`
  6583. } `json:"output"`
  6584. RefmsgTime string `json:"refmsg_time"`
  6585. RespondTime string `json:"respond_time"`
  6586. Signtype interface{} `json:"signtype"`
  6587. WarnMsg interface{} `json:"warn_msg"`
  6588. }
  6589. type ResultSeventeen struct {
  6590. ErrMsg string `json:"err_msg"`
  6591. InfRefmsgid string `json:"inf_refmsgid"`
  6592. Infcode int64 `json:"infcode"`
  6593. Output struct {
  6594. SetlListId string `json:"setl_list_id"`
  6595. } `json:"output"`
  6596. RefmsgTime string `json:"refmsg_time"`
  6597. RespondTime string `json:"respond_time"`
  6598. Signtype string `json:"signtype"`
  6599. WarnInfo string `json:"warn_info"`
  6600. }
  6601. type ResultSeventeenOther struct {
  6602. ErrMsg string `json:"err_msg"`
  6603. InfRefmsgid string `json:"inf_refmsgid"`
  6604. Infcode string `json:"infcode"`
  6605. Output struct {
  6606. SetlListId string `json:"setl_list_id"`
  6607. } `json:"output"`
  6608. RefmsgTime string `json:"refmsg_time"`
  6609. RespondTime string `json:"respond_time"`
  6610. Signtype string `json:"signtype"`
  6611. WarnInfo string `json:"warn_info"`
  6612. }
  6613. type Result90991 struct {
  6614. ErrMsg string `json:"err_msg"`
  6615. InfRefmsgid string `json:"inf_refmsgid"`
  6616. Infcode int64 `json:"infcode"`
  6617. Output struct {
  6618. Result struct {
  6619. PsnNo string `json:"psn_no"`
  6620. CardStat string `json:"card_stat"`
  6621. Certno string `json:"certno"`
  6622. PsnName string `json:"psn_name"`
  6623. CheckStat string `json:"check_stat"`
  6624. SscnoCheckStat string `json:"sscno_check_stat"`
  6625. } `json:"result"`
  6626. } `json:"output"`
  6627. RefmsgTime string `json:"refmsg_time"`
  6628. RespondTime string `json:"respond_time"`
  6629. Signtype interface{} `json:"signtype"`
  6630. WarnInfo interface{} `json:"warn_info"`
  6631. }
  6632. type Result90100 struct {
  6633. ErrMsg string `json:"err_msg"`
  6634. InfRefmsgid string `json:"inf_refmsgid"`
  6635. Infcode int64 `json:"infcode"`
  6636. Output struct {
  6637. PoolareaNo string `json:"poolarea_no"`
  6638. PoolareaNoName string `json:"poolarea_no_name"`
  6639. Insutype string `json:"insutype"`
  6640. InsutypeName string `json:"insutype_name"`
  6641. ClctType string `json:"clct_type"`
  6642. ClctTypeName string `json:"clct_type_name"`
  6643. ClctFlag string `json:"clct_flag"`
  6644. ClctFlagName string `json:"clct_flag_name"`
  6645. AccrymBegn string `json:"accrym_begn"`
  6646. AccrymEnd string `json:"accrym_end"`
  6647. ClctTime string `json:"clct_time"`
  6648. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6649. } `json:"output"`
  6650. RefmsgTime string `json:"refmsg_time"`
  6651. RespondTime string `json:"respond_time"`
  6652. Signtype interface{} `json:"signtype"`
  6653. WarnInfo interface{} `json:"warn_info"`
  6654. }
  6655. type Custom struct {
  6656. DetItemFeeSumamt string
  6657. Cut string
  6658. FeedetlSn string
  6659. Price string
  6660. MedListCodg string
  6661. Type int64
  6662. AdviceId int64
  6663. ProjectId int64
  6664. ItemId int64
  6665. }
  6666. type Result5301 struct {
  6667. ErrMsg string `json:"err_msg"`
  6668. InfRefmsgid string `json:"inf_refmsgid"`
  6669. Infcode int64 `json:"infcode"`
  6670. Output struct {
  6671. Result []struct {
  6672. OpspDiseCode string `json:"opsp_dise_code"`
  6673. OpspDiseName string `json:"opsp_dise_name"`
  6674. Begndate string `json:"begndate"`
  6675. Enddate string `json:"enddate"`
  6676. } `json:"feedetail"`
  6677. } `json:"output"`
  6678. RefmsgTime string `json:"refmsg_time"`
  6679. RespondTime string `json:"respond_time"`
  6680. Signtype interface{} `json:"signtype"`
  6681. WarnInfo interface{} `json:"warn_info"`
  6682. }
  6683. type Result5301For10265 struct {
  6684. ErrMsg string `json:"err_msg"`
  6685. InfRefmsgid string `json:"inf_refmsgid"`
  6686. Infcode string `json:"infcode"`
  6687. Output struct {
  6688. Result []struct {
  6689. OpspDiseCode string `json:"opsp_dise_code"`
  6690. OpspDiseName string `json:"opsp_dise_name"`
  6691. Begndate string `json:"begndate"`
  6692. Enddate string `json:"enddate"`
  6693. } `json:"feedetail"`
  6694. } `json:"output"`
  6695. RefmsgTime string `json:"refmsg_time"`
  6696. RespondTime string `json:"respond_time"`
  6697. Signtype interface{} `json:"signtype"`
  6698. WarnInfo interface{} `json:"warn_info"`
  6699. }
  6700. //获取个人信息----挂号-----上传就诊信息
  6701. func (c *HisApiController) GetRegisterInfo() {
  6702. id, _ := c.GetInt64("id")
  6703. record_time := c.GetString("record_time")
  6704. settlementValue, _ := c.GetInt64("settlement_value")
  6705. medical_insurance_card := c.GetString("medical_insurance_card")
  6706. name := c.GetString("name")
  6707. id_card_type, _ := c.GetInt64("id_card_type")
  6708. certificates, _ := c.GetInt64("certificates")
  6709. medical_care, _ := c.GetInt64("medical_care")
  6710. birthday := c.GetString("birthday")
  6711. id_card := c.GetString("id_card")
  6712. register_type, _ := c.GetInt64("register")
  6713. doctor, _ := c.GetInt64("doctor")
  6714. department, _ := c.GetInt64("department")
  6715. gender, _ := c.GetInt64("sex")
  6716. registration_fee, _ := c.GetFloat("registration_fee")
  6717. medical_expenses, _ := c.GetFloat("medical_expenses")
  6718. social_type, _ := c.GetInt64("social_type")
  6719. med_type := c.GetString("social_type")
  6720. admin_user_id, _ := c.GetInt64("admin_user_id")
  6721. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6722. timeLayout := "2006-01-02"
  6723. loc, _ := time.LoadLocation("Local")
  6724. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6725. birthUnix := birthdays.Unix()
  6726. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6727. if err != nil {
  6728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6729. return
  6730. }
  6731. recordDateTime := theTime.Unix()
  6732. adminInfo := c.GetAdminUserInfo()
  6733. var patient service.Patients
  6734. if id == 0 {
  6735. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6736. } else {
  6737. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6738. }
  6739. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6740. if patientPrescription.ID == 0 {
  6741. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6742. }
  6743. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6744. if patient.ID == 0 {
  6745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6746. return
  6747. }
  6748. if len(patient.IdCardNo) == 0 {
  6749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6750. return
  6751. }
  6752. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6753. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6754. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6755. //就诊结算未完成,不能进行二次挂号
  6756. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6757. if len(his) >= 1 {
  6758. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6759. if len(his) >= 1 && order.ID == 0 {
  6760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6761. return
  6762. }
  6763. }
  6764. //var register_log string
  6765. if config.IsOpen == 1 {
  6766. var res ResultTwo
  6767. var res10265 ResultTwo10265
  6768. var PsnNo string
  6769. var PsnCertType string
  6770. var Certno string
  6771. var PsnName string
  6772. var Gend string
  6773. var Naty string
  6774. var Brdy string
  6775. var Age float64
  6776. var infoStr string
  6777. var idetinfoStr string
  6778. var infocode int64
  6779. var verify_number string
  6780. fmt.Println(verify_number)
  6781. if miConfig.MdtrtareaAdmvs == "421300" {
  6782. psn_info, _ := service.GetPsnByPatientId(id)
  6783. PsnNo = psn_info.PsnNo
  6784. PsnCertType = psn_info.PsnCertType
  6785. Certno = psn_info.Certno
  6786. PsnName = psn_info.PsnName
  6787. Gend = psn_info.Gend
  6788. Naty = psn_info.Naty
  6789. Brdy = psn_info.Brdy
  6790. Age = psn_info.Age
  6791. infoStr = psn_info.Insuinfo
  6792. idetinfoStr = psn_info.Idetinfo
  6793. infocode = 0
  6794. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6795. psn_info, _ := service.GetPsnByPatientId(id)
  6796. PsnNo = psn_info.PsnNo
  6797. PsnCertType = psn_info.PsnCertType
  6798. Certno = psn_info.Certno
  6799. PsnName = psn_info.PsnName
  6800. Gend = psn_info.Gend
  6801. Naty = psn_info.Naty
  6802. Brdy = psn_info.Brdy
  6803. Age = psn_info.Age
  6804. infoStr = psn_info.Insuinfo
  6805. idetinfoStr = psn_info.Idetinfo
  6806. infocode = 0
  6807. verify_number = psn_info.VerifyNumber
  6808. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6809. if id_card_type == 1 {
  6810. psn_info, _ := service.GetPsnByPatientId(id)
  6811. PsnNo = psn_info.PsnNo
  6812. PsnCertType = psn_info.PsnCertType
  6813. Certno = psn_info.Certno
  6814. PsnName = psn_info.PsnName
  6815. Gend = psn_info.Gend
  6816. Naty = psn_info.Naty
  6817. Brdy = psn_info.Brdy
  6818. Age = psn_info.Age
  6819. infoStr = psn_info.Insuinfo
  6820. idetinfoStr = psn_info.Idetinfo
  6821. infocode = 0
  6822. verify_number = psn_info.VerifyNumber
  6823. } else if id_card_type == 2 {
  6824. 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)
  6825. fmt.Println(errMsgLog)
  6826. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6827. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6828. utils.ErrorLog("解析失败:%v", err)
  6829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6830. return
  6831. }
  6832. PsnNo = res.Output.Baseinfo.PsnNo
  6833. PsnCertType = res.Output.Baseinfo.PsnCertType
  6834. Certno = res.Output.Baseinfo.Certno
  6835. PsnName = res.Output.Baseinfo.PsnName
  6836. Gend = res.Output.Baseinfo.Gend
  6837. Naty = res.Output.Baseinfo.Naty
  6838. Brdy = res.Output.Baseinfo.Brdy
  6839. Age = res.Output.Baseinfo.Age
  6840. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6841. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6842. infoStr = string(Iinfos)
  6843. idetinfoStr = string(Idetinfos)
  6844. infocode = res.Infcode
  6845. }
  6846. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6847. if id_card_type == 1 {
  6848. psn_info, _ := service.GetPsnByPatientId(id)
  6849. PsnNo = psn_info.PsnNo
  6850. PsnCertType = psn_info.PsnCertType
  6851. Certno = psn_info.Certno
  6852. PsnName = psn_info.PsnName
  6853. Gend = psn_info.Gend
  6854. Naty = psn_info.Naty
  6855. Brdy = psn_info.Brdy
  6856. Age = psn_info.Age
  6857. infoStr = psn_info.Insuinfo
  6858. idetinfoStr = psn_info.Idetinfo
  6859. infocode = 0
  6860. verify_number = psn_info.VerifyNumber
  6861. } else if id_card_type == 2 {
  6862. 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, "")
  6863. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6864. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6865. utils.ErrorLog("解析失败:%v", err)
  6866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6867. return
  6868. }
  6869. PsnNo = res.Output.Baseinfo.PsnNo
  6870. PsnCertType = res.Output.Baseinfo.PsnCertType
  6871. Certno = res.Output.Baseinfo.Certno
  6872. PsnName = res.Output.Baseinfo.PsnName
  6873. Gend = res.Output.Baseinfo.Gend
  6874. Naty = res.Output.Baseinfo.Naty
  6875. Brdy = res.Output.Baseinfo.Brdy
  6876. Age = res.Output.Baseinfo.Age
  6877. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6878. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6879. infoStr = string(Iinfos)
  6880. idetinfoStr = string(Idetinfos)
  6881. infocode = res.Infcode
  6882. }
  6883. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6884. if id_card_type == 1 {
  6885. psn_info, _ := service.GetPsnByPatientId(id)
  6886. PsnNo = psn_info.PsnNo
  6887. PsnCertType = psn_info.PsnCertType
  6888. Certno = psn_info.Certno
  6889. PsnName = psn_info.PsnName
  6890. Gend = psn_info.Gend
  6891. Naty = psn_info.Naty
  6892. Brdy = psn_info.Brdy
  6893. Age = psn_info.Age
  6894. infoStr = psn_info.Insuinfo
  6895. idetinfoStr = psn_info.Idetinfo
  6896. infocode = 0
  6897. verify_number = psn_info.VerifyNumber
  6898. } else if id_card_type == 2 {
  6899. 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)
  6900. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6901. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6902. utils.ErrorLog("解析失败:%v", err)
  6903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6904. return
  6905. }
  6906. PsnNo = res.Output.Baseinfo.PsnNo
  6907. PsnCertType = res.Output.Baseinfo.PsnCertType
  6908. Certno = res.Output.Baseinfo.Certno
  6909. PsnName = res.Output.Baseinfo.PsnName
  6910. Gend = res.Output.Baseinfo.Gend
  6911. Naty = res.Output.Baseinfo.Naty
  6912. Brdy = res.Output.Baseinfo.Brdy
  6913. Age = res.Output.Baseinfo.Age
  6914. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6915. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6916. infoStr = string(Iinfos)
  6917. idetinfoStr = string(Idetinfos)
  6918. infocode = res.Infcode
  6919. }
  6920. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6921. var result string
  6922. var requestLog string
  6923. 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), "")
  6924. if id_card_type == 4 {
  6925. psn_info, _ := service.GetPsnByPatientId(id)
  6926. PsnNo = psn_info.PsnNo
  6927. PsnCertType = psn_info.PsnCertType
  6928. Certno = psn_info.Certno
  6929. PsnName = psn_info.PsnName
  6930. Gend = psn_info.Gend
  6931. Naty = psn_info.Naty
  6932. Brdy = psn_info.Brdy
  6933. Age = psn_info.Age
  6934. infoStr = psn_info.Insuinfo
  6935. idetinfoStr = psn_info.Idetinfo
  6936. infocode = 0
  6937. verify_number = psn_info.VerifyNumber
  6938. } else {
  6939. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6940. if miConfig.Code == "H15049901371" {
  6941. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6942. utils.ErrorLog("解析失败:%v", err)
  6943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6944. return
  6945. }
  6946. res.ErrMsg = res10265.ErrMsg
  6947. res.Output = res10265.Output
  6948. res.InfRefmsgid = res10265.InfRefmsgid
  6949. } else {
  6950. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6951. utils.ErrorLog("解析失败:%v", err)
  6952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6953. return
  6954. }
  6955. }
  6956. PsnNo = res.Output.Baseinfo.PsnNo
  6957. PsnCertType = res.Output.Baseinfo.PsnCertType
  6958. Certno = res.Output.Baseinfo.Certno
  6959. PsnName = res.Output.Baseinfo.PsnName
  6960. Gend = res.Output.Baseinfo.Gend
  6961. Naty = res.Output.Baseinfo.Naty
  6962. Brdy = res.Output.Baseinfo.Brdy
  6963. Age = res.Output.Baseinfo.Age
  6964. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6965. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6966. infoStr = string(Iinfos)
  6967. idetinfoStr = string(Idetinfos)
  6968. if miConfig.Code == "H15049901371" {
  6969. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6970. } else {
  6971. infocode = res.Infcode
  6972. }
  6973. }
  6974. } else {
  6975. var result string
  6976. var requestLog string
  6977. if miConfig.UserOrgId == 10138 {
  6978. if id_card_type != 4 {
  6979. //psn_info, _ := service.GetPsnByPatientId(id)
  6980. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6981. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  6982. }
  6983. } else {
  6984. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  6985. }
  6986. if id_card_type == 4 {
  6987. psn_info, _ := service.GetPsnByPatientId(id)
  6988. PsnNo = psn_info.PsnNo
  6989. PsnCertType = psn_info.PsnCertType
  6990. Certno = psn_info.Certno
  6991. PsnName = psn_info.PsnName
  6992. Gend = psn_info.Gend
  6993. Naty = psn_info.Naty
  6994. Brdy = psn_info.Brdy
  6995. Age = psn_info.Age
  6996. infoStr = psn_info.Insuinfo
  6997. idetinfoStr = psn_info.Idetinfo
  6998. infocode = 0
  6999. verify_number = psn_info.VerifyNumber
  7000. } else {
  7001. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7002. if miConfig.Code == "H15049901371" {
  7003. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7004. utils.ErrorLog("解析失败:%v", err)
  7005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7006. return
  7007. }
  7008. res.ErrMsg = res10265.ErrMsg
  7009. res.Output = res10265.Output
  7010. res.InfRefmsgid = res10265.InfRefmsgid
  7011. } else {
  7012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7013. utils.ErrorLog("解析失败:%v", err)
  7014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7015. return
  7016. }
  7017. }
  7018. PsnNo = res.Output.Baseinfo.PsnNo
  7019. PsnCertType = res.Output.Baseinfo.PsnCertType
  7020. Certno = res.Output.Baseinfo.Certno
  7021. PsnName = res.Output.Baseinfo.PsnName
  7022. Gend = res.Output.Baseinfo.Gend
  7023. Naty = res.Output.Baseinfo.Naty
  7024. Brdy = res.Output.Baseinfo.Brdy
  7025. Age = res.Output.Baseinfo.Age
  7026. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7027. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7028. infoStr = string(Iinfos)
  7029. idetinfoStr = string(Idetinfos)
  7030. if miConfig.Code == "H15049901371" {
  7031. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7032. } else {
  7033. infocode = res.Infcode
  7034. }
  7035. }
  7036. }
  7037. if infocode == 0 {
  7038. his := models.VMHisPatient{
  7039. Name: name,
  7040. Gender: gender,
  7041. Birthday: birthUnix,
  7042. MedicalTreatmentType: medical_care,
  7043. IdType: certificates,
  7044. IdCardNo: id_card,
  7045. BalanceAccountsType: settlementValue,
  7046. SocialType: social_type,
  7047. MedicalInsuranceNumber: medical_insurance_card,
  7048. RegisterType: register_type,
  7049. RegisterCost: registration_fee,
  7050. TreatmentCost: medical_expenses,
  7051. Status: 1,
  7052. Ctime: time.Now().Unix(),
  7053. Mtime: time.Now().Unix(),
  7054. PsnNo: PsnNo,
  7055. PsnCertType: PsnCertType,
  7056. Certno: Certno,
  7057. PsnName: PsnName,
  7058. Gend: Gend,
  7059. Naty: Naty,
  7060. Brdy: Brdy,
  7061. Age: Age,
  7062. Iinfo: infoStr,
  7063. Idetinfo: idetinfoStr,
  7064. PatientId: patient.ID,
  7065. RecordDate: theTime.Unix(),
  7066. UserOrgId: adminInfo.CurrentOrgId,
  7067. AdminUserId: admin_user_id,
  7068. IsReturn: 1,
  7069. IdCardType: id_card_type,
  7070. Doctor: doctor,
  7071. Departments: department,
  7072. }
  7073. timestamp := time.Now().Unix()
  7074. tempTime := time.Unix(timestamp, 0)
  7075. timeFormat := tempTime.Format("20060102150405")
  7076. chrgBchno := rand.Intn(100000) + 10000
  7077. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7078. his.Number = ipt_otp_no
  7079. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  7080. department, _ := service.GetDepartMentDetail(department)
  7081. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  7082. IdCardNo := ""
  7083. if id_card_type == 1 {
  7084. // IdCardNo = medical_insurance_card
  7085. IdCardNo = patient.IdCardNo
  7086. } else {
  7087. IdCardNo = patient.IdCardNo
  7088. }
  7089. var rf []*ResultFive
  7090. json.Unmarshal([]byte(his.Iinfo), &rf)
  7091. var insutypes []*ResultFive
  7092. var insutype string
  7093. var insuplc_admdvs_temp string
  7094. var is390 int = 0
  7095. var is310 int = 0
  7096. for _, item := range rf {
  7097. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7098. insutypes = append(insutypes, item)
  7099. }
  7100. }
  7101. if len(insutypes) == 1 {
  7102. insutype = insutypes[0].Insutype
  7103. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7104. } else {
  7105. for _, i := range insutypes {
  7106. if i.Insutype == "390" {
  7107. is390 = 1
  7108. }
  7109. if i.Insutype == "310" {
  7110. is310 = 1
  7111. }
  7112. }
  7113. }
  7114. if is390 == 1 {
  7115. insutype = "390"
  7116. }
  7117. if is310 == 1 {
  7118. insutype = "310"
  7119. }
  7120. if len(insutypes) == 0 {
  7121. insutype = "310"
  7122. }
  7123. if len(insutypes) == 2 {
  7124. insutype = med_type
  7125. }
  7126. if len(med_type) > 0 {
  7127. insutype = med_type
  7128. }
  7129. var infocode int64
  7130. var resThree ResultThree
  7131. var resThree10265 ResultThree10265
  7132. if len(insuplc_admdvs) == 0 {
  7133. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  7134. } else {
  7135. insuplc_admdvs_temp = insuplc_admdvs
  7136. }
  7137. if miConfig.MdtrtareaAdmvs == "350500" {
  7138. var rf []*ResultIDInfo
  7139. json.Unmarshal([]byte(idetinfoStr), &rf)
  7140. if len(rf) > 0 {
  7141. if len(rf[0].Memo) > 0 {
  7142. fmt.Println("122222222222222")
  7143. content := rf[0].Memo[1:len(rf[0].Memo)]
  7144. content2 := content[:len(content)-1]
  7145. fmt.Println(content2)
  7146. //var rf2 ResultMemo
  7147. //json.Unmarshal([]byte(content2), &rf2)
  7148. //fmt.Println(rf2)
  7149. //fmt.Println(rf2.InsuAdmdvs)
  7150. arr := strings.Split(content2, ",")
  7151. var tarstring string
  7152. for _, item := range arr {
  7153. if find := strings.Contains(item, "insuAdmdvs"); find {
  7154. tarstring = item
  7155. }
  7156. }
  7157. fmt.Println(tarstring)
  7158. if len(tarstring) > 0 {
  7159. arr := strings.Split(tarstring, ":")
  7160. insuplc_admdvs_temp = strings.Replace(arr[1], "\"", "", -1)
  7161. //insuplc_admdvs_temp = arr[1]
  7162. }
  7163. }
  7164. }
  7165. }
  7166. if miConfig.MdtrtareaAdmvs == "421300" {
  7167. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  7168. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  7169. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7170. "&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
  7171. resp, requestErr := http.Get(api)
  7172. if requestErr != nil {
  7173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7174. return
  7175. }
  7176. body, ioErr := ioutil.ReadAll(resp.Body)
  7177. if ioErr != nil {
  7178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7180. return
  7181. }
  7182. var respJSON map[string]interface{}
  7183. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7186. return
  7187. }
  7188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7189. result, _ := json.Marshal(respJSON)
  7190. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7191. utils.ErrorLog("解析失败:%v", err)
  7192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7193. return
  7194. }
  7195. infocode = resThree.Infcode
  7196. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7197. psn_info, _ := service.GetPsnByPatientId(id)
  7198. his.PsnNo = psn_info.PsnNo
  7199. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7200. var cert_no string
  7201. if id_card_type == 3 {
  7202. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  7203. cert_no = IdCardNo
  7204. } else if id_card_type == 4 {
  7205. cert_no = IdCardNo
  7206. psn_info.VerifyNumber = psn_info.VerifyNumber
  7207. } else {
  7208. bas := strings.Split(psn_info.CardInfo, "|")
  7209. cert_no = bas[2]
  7210. }
  7211. var hisPrescription []*models.HisPrescription
  7212. for _, item := range rf {
  7213. if item.Insutype == insutype {
  7214. //insuplc_admdvs = item.InsuplcAdmdvs
  7215. his.InsuplcAdmdvs = insuplc_admdvs
  7216. }
  7217. }
  7218. his.Insutype = insutype
  7219. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  7220. fmt.Println(res3101)
  7221. fmt.Println(res3101.Infcode)
  7222. if res3101.Infcode == "0" {
  7223. fmt.Println("33333333")
  7224. if len(res3101.Output.Result) > 0 {
  7225. fmt.Println("222222")
  7226. for _, item := range res3101.Output.Result {
  7227. if len(res3101.ErrMsg) == 0 {
  7228. res3101.ErrMsg = item.VolaCont
  7229. } else {
  7230. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  7231. }
  7232. }
  7233. c.ServeSuccessJSON(map[string]interface{}{
  7234. "failed_code": -10,
  7235. "msg": res3101.ErrMsg,
  7236. })
  7237. return
  7238. } else {
  7239. fmt.Println("11111")
  7240. var api string
  7241. if miConfig.MdtrtareaAdmvs == "320921" {
  7242. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7243. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7244. "&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
  7245. } else {
  7246. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7247. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7248. "&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
  7249. }
  7250. resp, requestErr := http.Get(api)
  7251. if requestErr != nil {
  7252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7253. return
  7254. }
  7255. body, ioErr := ioutil.ReadAll(resp.Body)
  7256. if ioErr != nil {
  7257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. return
  7260. }
  7261. var respJSON map[string]interface{}
  7262. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7265. return
  7266. }
  7267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7268. result, _ := json.Marshal(respJSON)
  7269. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7270. utils.ErrorLog("解析失败:%v", err)
  7271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7272. return
  7273. }
  7274. resThree.ErrMsg = resThree10265.ErrMsg
  7275. resThree.Output = resThree10265.Output
  7276. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7277. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7278. }
  7279. } else if res3101.Infcode != "0" {
  7280. c.ServeSuccessJSON(map[string]interface{}{
  7281. "failed_code": -10,
  7282. "msg": res3101.ErrMsg,
  7283. })
  7284. return
  7285. }
  7286. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7287. psn_info, _ := service.GetPsnByPatientId(id)
  7288. var cert_no string
  7289. if id_card_type == 1 {
  7290. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7291. } else if id_card_type == 4 {
  7292. cert_no = psn_info.VerifyNumber
  7293. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7294. } else {
  7295. cert_no = psn_info.VerifyNumber
  7296. }
  7297. 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)
  7298. saveLog(result, requestLog, "2201", "挂号")
  7299. if miConfig.Code == "H15049901371" {
  7300. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7301. utils.ErrorLog("解析失败:%v", err)
  7302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7303. return
  7304. }
  7305. resThree.ErrMsg = resThree10265.ErrMsg
  7306. resThree.Output = resThree10265.Output
  7307. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7308. } else {
  7309. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7310. utils.ErrorLog("解析失败:%v", err)
  7311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7312. return
  7313. }
  7314. }
  7315. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7316. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7317. psn_info, _ := service.GetPsnByPatientId(id)
  7318. var result string
  7319. var requestLog string
  7320. if id_card_type == 1 {
  7321. bas := strings.Split(psn_info.CardInfo, "|")
  7322. basNumber := bas[2]
  7323. card_sn := bas[3]
  7324. 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)
  7325. saveLog(result, requestLog, "2201A", "挂号")
  7326. } else if id_card_type == 2 {
  7327. 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, "", "")
  7328. saveLog(result, requestLog, "2201A", "挂号")
  7329. } else {
  7330. 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, "", "")
  7331. saveLog(result, requestLog, "2201A", "挂号")
  7332. }
  7333. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7334. utils.ErrorLog("解析失败:%v", err)
  7335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7336. return
  7337. }
  7338. infocode = resThree.Infcode
  7339. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7340. psn_info, _ := service.GetPsnByPatientId(id)
  7341. var result string
  7342. var requestLog string
  7343. if id_card_type == 1 {
  7344. bas := strings.Split(psn_info.CardInfo, "|")
  7345. basNumber := bas[2]
  7346. card_sn := bas[3]
  7347. 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)
  7348. saveLog(result, requestLog, "2201A", "挂号")
  7349. } else if id_card_type == 2 {
  7350. 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, "", "")
  7351. saveLog(result, requestLog, "2201A", "挂号")
  7352. } else {
  7353. 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, "", "")
  7354. saveLog(result, requestLog, "2201A", "挂号")
  7355. }
  7356. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7357. utils.ErrorLog("解析失败:%v", err)
  7358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7359. return
  7360. }
  7361. infocode = resThree.Infcode
  7362. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7363. psn_info, _ := service.GetPsnByPatientId(id)
  7364. 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)
  7365. saveLog(result, requestLog, "2201A", "挂号")
  7366. if miConfig.Code == "H15049901371" {
  7367. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7368. utils.ErrorLog("解析失败:%v", err)
  7369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. return
  7371. }
  7372. resThree.ErrMsg = resThree10265.ErrMsg
  7373. resThree.Output = resThree10265.Output
  7374. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7375. } else {
  7376. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7377. utils.ErrorLog("解析失败:%v", err)
  7378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7379. return
  7380. }
  7381. }
  7382. if miConfig.Code == "H15049901371" {
  7383. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7384. } else {
  7385. infocode = resThree.Infcode
  7386. }
  7387. } else {
  7388. psn_info, _ := service.GetPsnByPatientId(id)
  7389. 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)
  7390. saveLog(result, requestLog, "2201A", "挂号")
  7391. if miConfig.Code == "H15049901371" {
  7392. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7393. utils.ErrorLog("解析失败:%v", err)
  7394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7395. return
  7396. }
  7397. resThree.ErrMsg = resThree10265.ErrMsg
  7398. resThree.Output = resThree10265.Output
  7399. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7400. } else {
  7401. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7402. utils.ErrorLog("解析失败:%v", err)
  7403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7404. return
  7405. }
  7406. }
  7407. if miConfig.Code == "H15049901371" {
  7408. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7409. } else {
  7410. infocode = resThree.Infcode
  7411. }
  7412. }
  7413. if infocode != 0 {
  7414. adminUser := c.GetAdminUserInfo()
  7415. errlog := &models.HisOrderError{
  7416. UserOrgId: adminUser.CurrentOrgId,
  7417. Ctime: time.Now().Unix(),
  7418. Mtime: time.Now().Unix(),
  7419. ErrMsg: resThree.ErrMsg,
  7420. Status: 1,
  7421. PatientId: id,
  7422. RecordTime: recordDateTime,
  7423. Stage: 2,
  7424. }
  7425. service.CreateErrMsgLog(errlog)
  7426. c.ServeSuccessJSON(map[string]interface{}{
  7427. "failed_code": -10,
  7428. "msg": resThree.ErrMsg,
  7429. })
  7430. return
  7431. }
  7432. his.Number = resThree.Output.Data.MdtrtID
  7433. his.PsnNo = resThree.Output.Data.PsnNo
  7434. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7435. his.IdCardNo = patient.IdCardNo
  7436. his.PhoneNumber = patient.Phone
  7437. his.UserOrgId = adminInfo.CurrentOrgId
  7438. his.Insutype = insutype
  7439. his.Ctime = time.Now().Unix()
  7440. his.Mtime = time.Now().Unix()
  7441. his.InsuplcAdmdvs = insuplc_admdvs_temp
  7442. his.Status = 1
  7443. service.UpdateHisPatientStatus(&his)
  7444. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  7445. c.ServeSuccessJSON(map[string]interface{}{
  7446. "his_info": his,
  7447. })
  7448. } else {
  7449. adminUser := c.GetAdminUserInfo()
  7450. errlog := &models.HisOrderError{
  7451. UserOrgId: adminUser.CurrentOrgId,
  7452. Ctime: time.Now().Unix(),
  7453. Mtime: time.Now().Unix(),
  7454. ErrMsg: res.ErrMsg,
  7455. Status: 1,
  7456. PatientId: id,
  7457. RecordTime: recordDateTime,
  7458. Stage: 1,
  7459. }
  7460. service.CreateErrMsgLog(errlog)
  7461. c.ServeSuccessJSON(map[string]interface{}{
  7462. "failed_code": -10,
  7463. "msg": res.ErrMsg,
  7464. })
  7465. return
  7466. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7467. }
  7468. }
  7469. }
  7470. //上传明细----预结算----确认订单
  7471. func (c *HisApiController) GetUploadInfo() {
  7472. id, _ := c.GetInt64("id")
  7473. record_time := c.GetString("record_time")
  7474. his_patient_id, _ := c.GetInt64("his_patient_id")
  7475. order_id, _ := c.GetInt64("order_id")
  7476. pay_way, _ := c.GetInt64("pay_way")
  7477. pay_price, _ := c.GetFloat("pay_price")
  7478. pay_card_no := c.GetString("pay_card_no")
  7479. discount_price, _ := c.GetFloat("discount_price")
  7480. preferential_price, _ := c.GetFloat("preferential_price")
  7481. reality_price, _ := c.GetFloat("reality_price")
  7482. found_price, _ := c.GetFloat("found_price")
  7483. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7484. private_price, _ := c.GetFloat("private_price")
  7485. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7486. admin_user_id, _ := c.GetInt64("admin_user_id")
  7487. fapiao_code := c.GetString("fapiao_code")
  7488. fapiao_number := c.GetString("fapiao_number")
  7489. diagnosis_id := c.GetString("diagnosis")
  7490. sick_type, _ := c.GetInt64("sick_type")
  7491. reg_type, _ := c.GetInt64("p_type")
  7492. begin_time := c.GetString("begin_time")
  7493. id_str := c.GetString("ids")
  7494. ids_arr := strings.Split(id_str, ",")
  7495. timeLayout := "2006-01-02"
  7496. loc, _ := time.LoadLocation("Local")
  7497. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7498. if err != nil {
  7499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7500. return
  7501. }
  7502. recordDateTime := theTime.Unix()
  7503. adminUser := c.GetAdminUserInfo()
  7504. var tempOrder models.HisOrder
  7505. tempOrder, _ = service.GetHisOrderByID(order_id)
  7506. var prescriptions []*models.HisPrescription
  7507. var start_time int64
  7508. var end_time int64
  7509. //押金模块
  7510. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  7511. tmp_decimal := c.GetString("tmp_decimal")
  7512. var decimal float64 //本次使用的押金
  7513. var errmsg error
  7514. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  7515. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  7516. return
  7517. }
  7518. if len(tmp_decimal) > 0 {
  7519. if tmp_decimal[0] == 45 {
  7520. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  7521. return
  7522. }
  7523. }
  7524. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  7525. fmt.Println(errs)
  7526. decimal = tt
  7527. //if adminUser.CurrentOrgId == 10106{
  7528. // if len(fapiao_code) == 0{
  7529. // fapiao_code = "144072080589"
  7530. // }
  7531. // if len(fapiao_number) == 0{
  7532. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  7533. // if order.ID == 0{
  7534. // fapiao_number = "00001520"
  7535. // }else{
  7536. // //fapiao_code = "00001520"
  7537. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  7538. // var zero string
  7539. // if fpNumber >= 1000{
  7540. // zero = "0000" + strconv.Itoa(fpNumber)
  7541. // }else if fpNumber >= 10000{
  7542. // zero = "000" + strconv.Itoa(fpNumber)
  7543. // } else if fpNumber >= 100000{
  7544. // zero = "00" + strconv.Itoa(fpNumber)
  7545. // } else if fpNumber >= 1000000{
  7546. // zero = "0" + strconv.Itoa(fpNumber)
  7547. // }else {
  7548. // zero = strconv.Itoa(fpNumber)
  7549. // }
  7550. // fapiao_number = zero
  7551. // }
  7552. // }
  7553. //}
  7554. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7555. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7556. var patientPrescription models.HisPrescriptionInfo
  7557. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7558. if patientPrescription.ID == 0 {
  7559. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7560. }
  7561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7562. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7563. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7564. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7565. var config []*models.HisXtDiagnoseConfig
  7566. for _, item := range diagnosis_ids {
  7567. id, _ := strconv.ParseInt(item, 10, 64)
  7568. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7569. config = append(config, &diagnosisConfig)
  7570. }
  7571. sickConfig, _ := service.FindSickById(sick_type)
  7572. //if tempOrder.ID == 0 {
  7573. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  7574. //}
  7575. if tempOrder.ID == 0 {
  7576. var result string
  7577. var requestLog string
  7578. var res2 ResultSix
  7579. var ressix10265 ResultSix10265
  7580. if miConfig.MdtrtareaAdmvs == "421300" {
  7581. data := make(map[string]interface{})
  7582. client := &http.Client{}
  7583. data["psn_no"] = his.PsnNo
  7584. data["mdtrt_id"] = his.Number
  7585. data["opter"] = roles.UserName
  7586. data["org_name"] = miConfig.OrgName
  7587. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7588. data["doctor_id"] = doctor_info.DoctorNumber
  7589. data["doctor_name"] = doctor_info.UserName
  7590. data["department"] = department.Name
  7591. data["fixmedins_code"] = miConfig.Code
  7592. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7593. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7594. data["secret_key"] = miConfig.SecretKey
  7595. data["sick_code"] = sickConfig.CountryCode
  7596. data["sick_name"] = sickConfig.ClassName
  7597. data["dept"] = strconv.FormatInt(department.ID, 10)
  7598. data["config"] = config
  7599. data["begin_time"] = begin_time
  7600. bytesData, _ := json.Marshal(data)
  7601. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7602. resp, _ := client.Do(req)
  7603. defer resp.Body.Close()
  7604. body, ioErr := ioutil.ReadAll(resp.Body)
  7605. if ioErr != nil {
  7606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7608. return
  7609. }
  7610. var respJSON map[string]interface{}
  7611. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7614. return
  7615. }
  7616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7617. userJSONBytes, _ := json.Marshal(respJSON)
  7618. fmt.Println("log")
  7619. fmt.Println(string(userJSONBytes))
  7620. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7621. utils.ErrorLog("解析失败:%v", err)
  7622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7623. return
  7624. }
  7625. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7626. data := make(map[string]interface{})
  7627. client := &http.Client{}
  7628. data["psn_no"] = his.PsnNo
  7629. data["mdtrt_id"] = his.Number
  7630. data["doctor"] = roles.UserName
  7631. data["department"] = department.Name
  7632. data["org_name"] = miConfig.OrgName
  7633. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7634. data["doctor_id"] = doctor_info.DoctorNumber
  7635. data["new_doctor_name"] = doctor_info.UserName
  7636. data["fixmedins_code"] = miConfig.Code
  7637. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7638. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7639. data["secret_key"] = miConfig.SecretKey
  7640. data["sick_code"] = sickConfig.CountryCode
  7641. data["sick_name"] = sickConfig.ClassName
  7642. data["url"] = miConfig.Url
  7643. data["ak"] = miConfig.AccessKey
  7644. data["begin_time"] = begin_time
  7645. data["cainfo"] = miConfig.Cainfo
  7646. data["dept"] = strconv.FormatInt(department.ID, 10)
  7647. data["config"] = config
  7648. bytesData, _ := json.Marshal(data)
  7649. var req *http.Request
  7650. if miConfig.MdtrtareaAdmvs == "320921" {
  7651. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7652. //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 +
  7653. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7654. } else {
  7655. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7656. }
  7657. resp, _ := client.Do(req)
  7658. defer resp.Body.Close()
  7659. body, ioErr := ioutil.ReadAll(resp.Body)
  7660. if ioErr != nil {
  7661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7663. return
  7664. }
  7665. var respJSON map[string]interface{}
  7666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7669. return
  7670. }
  7671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7672. userJSONBytes, _ := json.Marshal(respJSON)
  7673. fmt.Println("log")
  7674. fmt.Println(string(userJSONBytes))
  7675. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  7676. utils.ErrorLog("解析失败:%v", err)
  7677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7678. return
  7679. }
  7680. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7681. res2.Output = ressix10265.Output
  7682. res2.ErrMsg = ressix10265.ErrMsg
  7683. res2.Cainfo = ressix10265.Cainfo
  7684. res2.WarnMsg = ressix10265.WarnMsg
  7685. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7686. res2.Infcode = infocode
  7687. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7688. 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)
  7689. saveLog(result, requestLog, "2203", "上传就诊信息")
  7690. var respJSON2 map[string]interface{}
  7691. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7694. return
  7695. }
  7696. userJSONBytes2, _ := json.Marshal(respJSON2)
  7697. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7698. utils.ErrorLog("解析失败:%v", err)
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7700. return
  7701. }
  7702. } else {
  7703. if miConfig.MdtrtareaAdmvs == "440781" { //
  7704. 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)
  7705. } else {
  7706. if miConfig.Code == "H15049901371" {
  7707. //赤峰地区国家医保医疗类别
  7708. //职工透析:医疗类别选特殊情况门诊990502
  7709. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7710. var med_type string
  7711. if his.Insutype == "390" {
  7712. if reg_type == 14 {
  7713. med_type = "9933"
  7714. } else if reg_type == 11 {
  7715. med_type = "11"
  7716. }
  7717. } else if his.Insutype == "310" {
  7718. if reg_type == 14 {
  7719. med_type = "990502"
  7720. } else if reg_type == 11 {
  7721. med_type = "11"
  7722. }
  7723. }
  7724. 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)
  7725. } else {
  7726. 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)
  7727. }
  7728. }
  7729. saveLog(result, requestLog, "2203", "上传就诊信息")
  7730. var respJSON2 map[string]interface{}
  7731. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7734. return
  7735. }
  7736. userJSONBytes2, _ := json.Marshal(respJSON2)
  7737. if miConfig.Code == "H15049901371" {
  7738. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7739. utils.ErrorLog("解析失败:%v", err)
  7740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7741. return
  7742. }
  7743. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7744. res2.Output = ressix10265.Output
  7745. res2.ErrMsg = ressix10265.ErrMsg
  7746. res2.Cainfo = ressix10265.Cainfo
  7747. res2.WarnMsg = ressix10265.WarnMsg
  7748. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7749. res2.Infcode = infocode
  7750. } else {
  7751. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7752. utils.ErrorLog("解析失败:%v", err)
  7753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7754. return
  7755. }
  7756. }
  7757. }
  7758. if res2.Infcode != 0 {
  7759. adminUser := c.GetAdminUserInfo()
  7760. errlog := &models.HisOrderError{
  7761. UserOrgId: adminUser.CurrentOrgId,
  7762. Ctime: time.Now().Unix(),
  7763. Mtime: time.Now().Unix(),
  7764. ErrMsg: res2.ErrMsg,
  7765. Status: 1,
  7766. PatientId: id,
  7767. RecordTime: recordDateTime,
  7768. Stage: 3,
  7769. }
  7770. service.CreateErrMsgLog(errlog)
  7771. c.ServeSuccessJSON(map[string]interface{}{
  7772. "failed_code": -10,
  7773. "msg": res2.ErrMsg,
  7774. })
  7775. return
  7776. } else {
  7777. his.Diagnosis = diagnosis_id
  7778. his.SickType = sickConfig.ID
  7779. //var p_type int64
  7780. //if reg_type == 1111 || reg_type == 1112 {
  7781. // p_type = 11
  7782. //
  7783. //}
  7784. his.PType = fmt.Sprintf("%d", reg_type)
  7785. service.UpdateHisPatientThree(&his)
  7786. data := make(map[string]interface{})
  7787. if settle_accounts_type == 1 { //日结
  7788. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7789. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7790. } else {
  7791. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7792. }
  7793. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7794. data["pre"] = prescriptions
  7795. } else { //月结
  7796. start_time_str := c.GetString("start_time")
  7797. end_time_str := c.GetString("end_time")
  7798. timeLayout := "2006-01-02"
  7799. loc, _ := time.LoadLocation("Local")
  7800. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7801. if err != nil {
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7803. return
  7804. }
  7805. recordStartTime := theStartTime.Unix()
  7806. start_time = recordStartTime
  7807. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7808. if err != nil {
  7809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7810. return
  7811. }
  7812. recordEndTime := theEndTime.Unix()
  7813. end_time = recordEndTime
  7814. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7815. data["pre"] = prescriptions
  7816. }
  7817. timestamp := time.Now().Unix()
  7818. tempTime := time.Unix(timestamp, 0)
  7819. timeFormat := tempTime.Format("20060102150405")
  7820. chrgBchno := rand.Intn(100000) + 10000
  7821. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7822. strconv.FormatInt(his.PatientId, 10)
  7823. client := &http.Client{}
  7824. data["psn_no"] = his.PsnNo
  7825. data["mdtrt_id"] = his.Number
  7826. data["chrg_bchno"] = chrg_bchno
  7827. data["org_name"] = miConfig.OrgName
  7828. data["doctor"] = doctor_info.UserName
  7829. data["doctor_id"] = doctor_info.DoctorNumber
  7830. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7831. data["fixmedins_code"] = miConfig.Code
  7832. data["opter"] = roles.UserName
  7833. data["dept_code"] = department.Number
  7834. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7835. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7836. data["secret_key"] = miConfig.SecretKey
  7837. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7838. data["url"] = miConfig.Url
  7839. data["ak"] = miConfig.AccessKey
  7840. data["new_doctor_name"] = patientPrescription.Doctor
  7841. data["diag_code"] = sickConfig.CountryCode
  7842. data["cainfo"] = miConfig.Cainfo
  7843. data["opter"] = roles.UserName
  7844. var ids []int64
  7845. for _, item := range prescriptions {
  7846. ids = append(ids, item.ID)
  7847. }
  7848. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7849. if config.IsOpen == 1 { //对接了医保,走医保流程
  7850. var res ResultFour
  7851. var resFour10265 ResultFour10265
  7852. if miConfig.MdtrtareaAdmvs == "421300" {
  7853. bytesData, _ := json.Marshal(data)
  7854. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7855. resp, _ := client.Do(req)
  7856. defer resp.Body.Close()
  7857. body, ioErr := ioutil.ReadAll(resp.Body)
  7858. if ioErr != nil {
  7859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7861. return
  7862. }
  7863. var respJSON map[string]interface{}
  7864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7867. return
  7868. }
  7869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7870. userJSONBytes, _ := json.Marshal(respJSON)
  7871. fmt.Println("log")
  7872. fmt.Println(string(userJSONBytes))
  7873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7874. utils.ErrorLog("解析失败:%v", err)
  7875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7876. return
  7877. }
  7878. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7879. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7880. if result3101.Infcode == "0" {
  7881. if len(result3101.Output.Result) > 0 {
  7882. var errMsgs []string
  7883. for _, item := range result3101.Output.Result {
  7884. errMsgs = append(errMsgs, item.VolaCont)
  7885. }
  7886. c.ServeSuccessJSON(map[string]interface{}{
  7887. "failed_code": -10,
  7888. "msg": errMsgs,
  7889. })
  7890. return
  7891. }
  7892. }
  7893. if miConfig.MdtrtareaAdmvs == "320921" {
  7894. data["doctor_id"] = "D320923012139"
  7895. } else {
  7896. data["doctor_id"] = "D371621008686"
  7897. }
  7898. bytesData, _ := json.Marshal(data)
  7899. var req *http.Request
  7900. if miConfig.MdtrtareaAdmvs == "320921" {
  7901. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7902. } else {
  7903. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7904. }
  7905. resp, _ := client.Do(req)
  7906. defer resp.Body.Close()
  7907. body, ioErr := ioutil.ReadAll(resp.Body)
  7908. if ioErr != nil {
  7909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7911. return
  7912. }
  7913. var respJSON map[string]interface{}
  7914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7917. return
  7918. }
  7919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7920. userJSONBytes, _ := json.Marshal(respJSON)
  7921. fmt.Println("log")
  7922. fmt.Println(string(userJSONBytes))
  7923. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7924. utils.ErrorLog("解析失败:%v", err)
  7925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7926. return
  7927. }
  7928. res.InfRefmsgid = resFour10265.InfRefmsgid
  7929. res.Output = resFour10265.Output
  7930. res.ErrMsg = resFour10265.ErrMsg
  7931. res.Cainfo = resFour10265.Cainfo
  7932. res.WarnMsg = resFour10265.WarnMsg
  7933. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7934. res.Infcode = infocode
  7935. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7936. 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)
  7937. var dat map[string]interface{}
  7938. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7939. fmt.Println(dat)
  7940. } else {
  7941. fmt.Println(err)
  7942. }
  7943. saveLog(result, request_log, "2204", "上传费用明细")
  7944. userJSONBytes, _ := json.Marshal(dat)
  7945. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7946. utils.ErrorLog("解析失败:%v", err)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. res.InfRefmsgid = resFour10265.InfRefmsgid
  7951. res.Output = resFour10265.Output
  7952. res.ErrMsg = resFour10265.ErrMsg
  7953. res.Cainfo = resFour10265.Cainfo
  7954. res.WarnMsg = resFour10265.WarnMsg
  7955. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7956. res.Infcode = infocode
  7957. } else {
  7958. if miConfig.Code == "H15049901371" {
  7959. 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)
  7960. var dat map[string]interface{}
  7961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7962. fmt.Println(dat)
  7963. } else {
  7964. fmt.Println(err)
  7965. }
  7966. saveLog(result, request_log, "2204", "上传费用明细")
  7967. userJSONBytes, _ := json.Marshal(dat)
  7968. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7969. utils.ErrorLog("解析失败:%v", err)
  7970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7971. return
  7972. }
  7973. res.InfRefmsgid = resFour10265.InfRefmsgid
  7974. res.Output = resFour10265.Output
  7975. res.ErrMsg = resFour10265.ErrMsg
  7976. res.Cainfo = resFour10265.Cainfo
  7977. res.WarnMsg = resFour10265.WarnMsg
  7978. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7979. res.Infcode = infocode
  7980. } else {
  7981. 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)
  7982. var dat map[string]interface{}
  7983. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7984. fmt.Println(dat)
  7985. } else {
  7986. fmt.Println(err)
  7987. }
  7988. saveLog(result, request_log, "2204", "上传费用明细")
  7989. userJSONBytes, _ := json.Marshal(dat)
  7990. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7991. utils.ErrorLog("解析失败:%v", err)
  7992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7993. return
  7994. }
  7995. }
  7996. }
  7997. if res.Infcode == 0 {
  7998. order := &models.HisOrder{
  7999. UserOrgId: adminUser.CurrentOrgId,
  8000. HisPatientId: his.ID,
  8001. PatientId: his.PatientId,
  8002. SettleAccountsDate: recordDateTime,
  8003. MdtrtId: his.Number,
  8004. PsnNo: his.PsnNo,
  8005. MedType: strconv.FormatInt(reg_type, 10),
  8006. Ctime: time.Now().Unix(),
  8007. Mtime: time.Now().Unix(),
  8008. Status: 1,
  8009. Number: chrg_bchno,
  8010. Infcode: res.Infcode,
  8011. WarnMsg: res.WarnMsg,
  8012. Cainfo: res.Cainfo,
  8013. ErrMsg: res.ErrMsg,
  8014. RespondTime: res.RefmsgTime,
  8015. InfRefmsgid: res.InfRefmsgid,
  8016. OrderStatus: 1,
  8017. PayWay: pay_way,
  8018. PayPrice: pay_price,
  8019. PayCardNo: pay_card_no,
  8020. DiscountPrice: discount_price,
  8021. PreferentialPrice: preferential_price,
  8022. RealityPrice: reality_price,
  8023. FoundPrice: found_price,
  8024. MedicalInsurancePrice: medical_insurance_price,
  8025. PrivatePrice: private_price,
  8026. IsMedicineInsurance: 1,
  8027. SettleType: settle_accounts_type,
  8028. SettleStartTime: start_time,
  8029. SettleEndTime: end_time,
  8030. Creator: roles.AdminUserId,
  8031. Modify: roles.AdminUserId,
  8032. FaPiaoNumber: fapiao_number,
  8033. FaPiaoCode: fapiao_code,
  8034. PType: 2,
  8035. Diagnosis: diagnosis_id,
  8036. }
  8037. err = service.CreateOrder(order)
  8038. if err != nil {
  8039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8040. return
  8041. }
  8042. for _, item := range res.Output.Result {
  8043. temp := strings.Split(item.FeedetlSn, "-")
  8044. var advice_id int64 = 0
  8045. var project_id int64 = 0
  8046. var types int64 = 0
  8047. id, _ := strconv.ParseInt(temp[2], 10, 64)
  8048. types, _ = strconv.ParseInt(temp[1], 10, 64)
  8049. if temp[1] == "1" {
  8050. advice_id = id
  8051. project_id = 0
  8052. } else if temp[1] == "2" {
  8053. advice_id = 0
  8054. project_id = id
  8055. }
  8056. if item.MedChrgitmType == "9" {
  8057. item.MedChrgitmType = "09"
  8058. }
  8059. info := &models.HisOrderInfo{
  8060. OrderNumber: order.Number,
  8061. FeedetlSn: item.FeedetlSn,
  8062. UploadDate: time.Now().Unix(),
  8063. AdviceId: advice_id,
  8064. DetItemFeeSumamt: item.DetItemFeeSumamt,
  8065. Cnt: item.Cnt,
  8066. Pric: float64(item.Pric),
  8067. PatientId: his.PatientId,
  8068. PricUplmtAmt: item.PricUplmtAmt,
  8069. SelfpayProp: item.SelfpayProp,
  8070. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8071. OverlmtAmt: item.OverlmtAmt,
  8072. PreselfpayAmt: item.PreselfpayAmt,
  8073. BasMednFlag: item.BasMednFlag,
  8074. MedChrgitmType: item.MedChrgitmType,
  8075. HiNegoDrugFlag: item.HiNegoDrugFlag,
  8076. Status: 1,
  8077. Memo: item.Memo,
  8078. Mtime: time.Now().Unix(),
  8079. InscpScpAmt: item.InscpScpAmt,
  8080. DrtReimFlag: item.DrtReimFlag,
  8081. Ctime: time.Now().Unix(),
  8082. ListSpItemFlag: item.ListSpItemFlag,
  8083. ChldMedcFlag: item.ChldMedcFlag,
  8084. LmtUsedFlag: item.LmtUsedFlag,
  8085. ChrgitmLv: item.ChrgitmLv,
  8086. UserOrgId: adminUser.CurrentOrgId,
  8087. HisPatientId: his.ID,
  8088. OrderId: order.ID,
  8089. ProjectId: project_id,
  8090. Type: types,
  8091. }
  8092. service.CreateOrderInfo(info)
  8093. }
  8094. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8095. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  8096. var total float64
  8097. for _, item := range prescriptions {
  8098. if item.Type == 1 { //药品
  8099. for _, subItem := range item.HisDoctorAdviceInfo {
  8100. total = total + (subItem.Price * subItem.PrescribingNumber)
  8101. }
  8102. }
  8103. if item.Type == 2 { //项目
  8104. for _, subItem := range item.HisPrescriptionProject {
  8105. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8106. total = total + (subItem.Price * cnt)
  8107. }
  8108. }
  8109. }
  8110. for _, item := range prescriptions {
  8111. for _, subItem := range item.HisAdditionalCharge {
  8112. total = total + (subItem.Price * float64(subItem.Count))
  8113. }
  8114. }
  8115. var allTotal string
  8116. if adminUser.CurrentOrgId == 9919 {
  8117. allTotal = fmt.Sprintf("%.4f", total)
  8118. } else {
  8119. allTotal = fmt.Sprintf("%.4f", total)
  8120. }
  8121. if res.Infcode == 0 {
  8122. var rf []*ResultFive
  8123. json.Unmarshal([]byte(his.Iinfo), &rf)
  8124. chrg_bchno := chrg_bchno
  8125. cert_no := his.Certno
  8126. var insutypes []string
  8127. var insutype string
  8128. var is390 int = 0
  8129. var is310 int = 0
  8130. for _, item := range rf {
  8131. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8132. insutypes = append(insutypes, item.Insutype)
  8133. }
  8134. }
  8135. if len(insutypes) == 1 {
  8136. insutype = insutypes[0]
  8137. } else {
  8138. for _, i := range insutypes {
  8139. if i == "390" {
  8140. is390 = 1
  8141. }
  8142. if i == "310" {
  8143. is310 = 1
  8144. }
  8145. }
  8146. }
  8147. if is390 == 1 {
  8148. insutype = "390"
  8149. }
  8150. if is310 == 1 {
  8151. insutype = "310"
  8152. }
  8153. if len(insutypes) == 0 {
  8154. insutype = "310"
  8155. }
  8156. if len(insutypes) == 2 {
  8157. insutype = strconv.FormatInt(his.SocialType, 10)
  8158. }
  8159. insutype = strconv.FormatInt(his.SocialType, 10)
  8160. //insutype = "390"
  8161. if his.IdCardType == 1 {
  8162. // cert_no = his.MedicalInsuranceNumber
  8163. cert_no = his.Certno
  8164. } else {
  8165. cert_no = his.Certno
  8166. }
  8167. var res ResultSeven
  8168. var resSeven10265 ResultSeven10265
  8169. var src_resquest string
  8170. var result2 string
  8171. var acct_used_flag string
  8172. fmt.Println("pay_way")
  8173. fmt.Println(pay_way)
  8174. fmt.Println("pay_way")
  8175. if pay_way == 4 {
  8176. acct_used_flag = "1"
  8177. } else {
  8178. acct_used_flag = "0"
  8179. }
  8180. if miConfig.MdtrtareaAdmvs == "421300" {
  8181. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8182. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8183. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8184. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8185. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8186. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8187. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8188. resp, requestErr := http.Get(api)
  8189. if requestErr != nil {
  8190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8191. return
  8192. }
  8193. body, ioErr := ioutil.ReadAll(resp.Body)
  8194. if ioErr != nil {
  8195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. return
  8198. }
  8199. var respJSON map[string]interface{}
  8200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8203. return
  8204. }
  8205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8206. result, _ := json.Marshal(respJSON)
  8207. if miConfig.Code == "H15049901371" {
  8208. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8209. utils.ErrorLog("解析失败:%v", err)
  8210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8211. return
  8212. }
  8213. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8214. res.Output = resSeven10265.Output
  8215. res.ErrMsg = resSeven10265.ErrMsg
  8216. res.Cainfo = resSeven10265.Cainfo
  8217. res.WarnMsg = resSeven10265.WarnMsg
  8218. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8219. res.Infcode = infocode
  8220. } else {
  8221. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8222. utils.ErrorLog("解析失败:%v", err)
  8223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8224. return
  8225. }
  8226. }
  8227. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8228. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  8229. if result3101.Infcode == "0" {
  8230. if len(result3101.Output.Result) > 0 {
  8231. var errMsgs []string
  8232. for _, item := range result3101.Output.Result {
  8233. errMsgs = append(errMsgs, item.VolaCont)
  8234. }
  8235. c.ServeSuccessJSON(map[string]interface{}{
  8236. "failed_code": -10,
  8237. "msg": errMsgs,
  8238. })
  8239. return
  8240. } else {
  8241. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8242. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8243. bas := strings.Split(psn_info.CardInfo, "|")
  8244. if his.IdCardType == 1 {
  8245. cert_no = bas[2]
  8246. } else if his.IdCardType == 3 {
  8247. cert_no = his.Certno
  8248. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8249. } else if his.IdCardType == 4 {
  8250. cert_no = his.Certno
  8251. psn_info.VerifyNumber = psn_info.VerifyNumber
  8252. }
  8253. var api string
  8254. if miConfig.MdtrtareaAdmvs == "320921" {
  8255. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8256. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8257. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8258. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8259. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8260. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8261. "&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
  8262. } else {
  8263. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8264. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8265. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8266. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8267. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8268. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8269. "&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
  8270. }
  8271. resp, requestErr := http.Get(api)
  8272. if requestErr != nil {
  8273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8274. return
  8275. }
  8276. body, ioErr := ioutil.ReadAll(resp.Body)
  8277. if ioErr != nil {
  8278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8280. return
  8281. }
  8282. var respJSON map[string]interface{}
  8283. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8289. result, _ := json.Marshal(respJSON)
  8290. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8291. utils.ErrorLog("解析失败:%v", err)
  8292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8293. return
  8294. }
  8295. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8296. res.Output = resSeven10265.Output
  8297. res.ErrMsg = resSeven10265.ErrMsg
  8298. res.Cainfo = resSeven10265.Cainfo
  8299. res.WarnMsg = resSeven10265.WarnMsg
  8300. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8301. res.Infcode = infocode
  8302. }
  8303. }
  8304. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8305. var cert_no string
  8306. if his.IdCardType == 4 {
  8307. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8308. cert_no = psn_info.VerifyNumber
  8309. 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)
  8310. } else if his.IdCardType == 1 {
  8311. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8312. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8313. 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)
  8314. }
  8315. //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)
  8316. var dat map[string]interface{}
  8317. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8318. fmt.Println(dat)
  8319. } else {
  8320. fmt.Println(err)
  8321. }
  8322. saveLog(result2, src_resquest, "2207", "结算")
  8323. userJSONBytes, _ := json.Marshal(dat)
  8324. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8325. utils.ErrorLog("解析失败:%v", err)
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8327. return
  8328. }
  8329. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8330. res.Output = resSeven10265.Output
  8331. res.ErrMsg = resSeven10265.ErrMsg
  8332. res.Cainfo = resSeven10265.Cainfo
  8333. res.WarnMsg = resSeven10265.WarnMsg
  8334. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8335. res.Infcode = infocode
  8336. } else {
  8337. if miConfig.Code == "H15049901371" {
  8338. //赤峰地区国家医保医疗类别
  8339. //职工透析:医疗类别选特殊情况门诊990502
  8340. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8341. var med_type string
  8342. if his.Insutype == "390" {
  8343. if reg_type == 14 {
  8344. med_type = "9933"
  8345. } else if reg_type == 11 {
  8346. med_type = "11"
  8347. }
  8348. } else if his.Insutype == "310" {
  8349. if reg_type == 14 {
  8350. med_type = "990502"
  8351. } else if reg_type == 11 {
  8352. med_type = "11"
  8353. }
  8354. }
  8355. 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, "")
  8356. } else {
  8357. if his.IdCardType == 4 {
  8358. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8359. var token string
  8360. token = psn_info.VerifyNumber
  8361. 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)
  8362. } else {
  8363. 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, "")
  8364. }
  8365. }
  8366. //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)
  8367. var dat map[string]interface{}
  8368. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8369. fmt.Println(dat)
  8370. } else {
  8371. fmt.Println(err)
  8372. }
  8373. saveLog(result2, src_resquest, "2207", "结算")
  8374. userJSONBytes, _ := json.Marshal(dat)
  8375. if miConfig.Code == "H15049901371" {
  8376. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8377. utils.ErrorLog("解析失败:%v", err)
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8379. return
  8380. }
  8381. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8382. res.Output = resSeven10265.Output
  8383. res.ErrMsg = resSeven10265.ErrMsg
  8384. res.Cainfo = resSeven10265.Cainfo
  8385. res.WarnMsg = resSeven10265.WarnMsg
  8386. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8387. res.Infcode = infocode
  8388. } else {
  8389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8390. utils.ErrorLog("解析失败:%v", err)
  8391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8392. return
  8393. }
  8394. }
  8395. }
  8396. if res.Infcode != 0 {
  8397. errlog := &models.HisOrderError{
  8398. UserOrgId: adminUser.CurrentOrgId,
  8399. Ctime: time.Now().Unix(),
  8400. Mtime: time.Now().Unix(),
  8401. Number: chrg_bchno,
  8402. ErrMsg: res.ErrMsg,
  8403. Status: 1,
  8404. PatientId: id,
  8405. RecordTime: recordDateTime,
  8406. Stage: 6,
  8407. }
  8408. service.CreateErrMsgLog(errlog)
  8409. c.ServeSuccessJSON(map[string]interface{}{
  8410. "failed_code": -10,
  8411. "msg": res.ErrMsg,
  8412. })
  8413. return
  8414. } else {
  8415. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8416. order.OrderStatus = 2
  8417. order.Status = 1
  8418. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8419. order.SetlId = res.Output.Setlinfo.SetlID
  8420. order.PsnNo = res.Output.Setlinfo.PsnNo
  8421. order.PsnName = res.Output.Setlinfo.PsnName
  8422. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8423. order.Certno = res.Output.Setlinfo.Certno
  8424. order.Gend = res.Output.Setlinfo.Gend
  8425. order.Naty = res.Output.Setlinfo.Naty
  8426. order.Age = res.Output.Setlinfo.Age
  8427. order.Insutype = res.Output.Setlinfo.Insutype
  8428. order.PsnType = res.Output.Setlinfo.PsnType
  8429. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8430. order.SetlTime = res.Output.Setlinfo.SetlTime
  8431. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8432. if res.Output.Setlinfo.MedType == "140101" {
  8433. order.MedType = "14"
  8434. } else {
  8435. order.MedType = res.Output.Setlinfo.MedType
  8436. }
  8437. if reg_type == 1112 {
  8438. order.MedType = "1112"
  8439. }
  8440. if reg_type == 1111 {
  8441. order.MedType = "1111"
  8442. }
  8443. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8444. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8445. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8446. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8447. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8448. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8449. order.HifpPay = res.Output.Setlinfo.HifpPay
  8450. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8451. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8452. order.HifesPay = res.Output.Setlinfo.HifesPay
  8453. order.HifobPay = res.Output.Setlinfo.HifobPay
  8454. order.MafPay = res.Output.Setlinfo.MafPay
  8455. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8456. order.OthPay = res.Output.Setlinfo.OthPay
  8457. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8458. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8459. order.AcctPay = res.Output.Setlinfo.AcctPay
  8460. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8461. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8462. order.Balc = res.Output.Setlinfo.Balc
  8463. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8464. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8465. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8466. order.ClrType = res.Output.Setlinfo.ClrType
  8467. order.ClrWay = res.Output.Setlinfo.ClrWay
  8468. order.Creator = order.Creator
  8469. order.Modify = roles.AdminUserId
  8470. order.RequestLog = src_resquest
  8471. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8472. detailStr := string(setlDetail)
  8473. order.SetlDetail = detailStr
  8474. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8475. err = service.UpDateOrder(order)
  8476. if err == nil {
  8477. //判断是否使用了押金
  8478. if dec_way == "true" {
  8479. tmpstring := strconv.FormatInt(order.ID, 10)
  8480. order.Decimal = decimal
  8481. service.UpDateOrder(order)
  8482. //扣押金
  8483. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8484. if errmsg != nil {
  8485. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8486. return
  8487. }
  8488. }
  8489. c.ServeSuccessJSON(map[string]interface{}{
  8490. "msg": "结算成功",
  8491. })
  8492. } else {
  8493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8494. return
  8495. }
  8496. }
  8497. } else {
  8498. adminUser := c.GetAdminUserInfo()
  8499. errlog := &models.HisOrderError{
  8500. UserOrgId: adminUser.CurrentOrgId,
  8501. Ctime: time.Now().Unix(),
  8502. Mtime: time.Now().Unix(),
  8503. ErrMsg: res.ErrMsg,
  8504. Status: 1,
  8505. PatientId: id,
  8506. RecordTime: recordDateTime,
  8507. Stage: 4,
  8508. }
  8509. service.CreateErrMsgLog(errlog)
  8510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8511. return
  8512. }
  8513. } else {
  8514. adminUser := c.GetAdminUserInfo()
  8515. errlog := &models.HisOrderError{
  8516. UserOrgId: adminUser.CurrentOrgId,
  8517. Ctime: time.Now().Unix(),
  8518. Mtime: time.Now().Unix(),
  8519. ErrMsg: res.ErrMsg,
  8520. Status: 1,
  8521. PatientId: id,
  8522. RecordTime: recordDateTime,
  8523. Stage: 4,
  8524. }
  8525. service.CreateErrMsgLog(errlog)
  8526. c.ServeSuccessJSON(map[string]interface{}{
  8527. "failed_code": -10,
  8528. "msg": res.ErrMsg,
  8529. })
  8530. return
  8531. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8532. //return
  8533. }
  8534. }
  8535. }
  8536. } else if tempOrder.ID > 0 {
  8537. if tempOrder.IsPre == 1 {
  8538. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  8539. var rf []*ResultFive
  8540. json.Unmarshal([]byte(his.Iinfo), &rf)
  8541. chrg_bchno := tempOrder.Number
  8542. cert_no := his.Certno
  8543. var insutypes []string
  8544. var insutype string
  8545. var is390 int = 0
  8546. var is310 int = 0
  8547. for _, item := range rf {
  8548. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8549. insutypes = append(insutypes, item.Insutype)
  8550. }
  8551. }
  8552. if len(insutypes) == 1 {
  8553. insutype = insutypes[0]
  8554. } else {
  8555. for _, i := range insutypes {
  8556. if i == "390" {
  8557. is390 = 1
  8558. }
  8559. if i == "310" {
  8560. is310 = 1
  8561. }
  8562. }
  8563. }
  8564. if is390 == 1 {
  8565. insutype = "390"
  8566. }
  8567. if is310 == 1 {
  8568. insutype = "310"
  8569. }
  8570. if len(insutypes) == 0 {
  8571. insutype = "310"
  8572. }
  8573. if len(insutypes) == 2 {
  8574. insutype = strconv.FormatInt(his.SocialType, 64)
  8575. }
  8576. //insutype = "390"
  8577. if his.IdCardType == 1 {
  8578. // cert_no = his.MedicalInsuranceNumber
  8579. cert_no = his.Certno
  8580. } else {
  8581. cert_no = his.Certno
  8582. }
  8583. var res ResultSeven
  8584. var resSeven10265 ResultSeven10265
  8585. var src_resquest string
  8586. var result2 string
  8587. var acct_used_flag string
  8588. fmt.Println("pay_way")
  8589. fmt.Println(pay_way)
  8590. fmt.Println("pay_way")
  8591. if pay_way == 4 {
  8592. acct_used_flag = "1"
  8593. } else {
  8594. acct_used_flag = "0"
  8595. }
  8596. if miConfig.MdtrtareaAdmvs == "421300" {
  8597. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8598. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8599. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8600. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8601. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8602. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8603. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8604. resp, requestErr := http.Get(api)
  8605. if requestErr != nil {
  8606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8607. return
  8608. }
  8609. body, ioErr := ioutil.ReadAll(resp.Body)
  8610. if ioErr != nil {
  8611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8613. return
  8614. }
  8615. var respJSON map[string]interface{}
  8616. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8619. return
  8620. }
  8621. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8622. result, _ := json.Marshal(respJSON)
  8623. fmt.Println("log")
  8624. fmt.Println(string(result))
  8625. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8626. utils.ErrorLog("解析失败:%v", err)
  8627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8628. return
  8629. }
  8630. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8631. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  8632. if result3101.Infcode == "0" {
  8633. if len(result3101.Output.Result) > 0 {
  8634. var errMsgs []string
  8635. for _, item := range result3101.Output.Result {
  8636. errMsgs = append(errMsgs, item.VolaCont)
  8637. }
  8638. c.ServeSuccessJSON(map[string]interface{}{
  8639. "failed_code": -10,
  8640. "msg": errMsgs,
  8641. })
  8642. return
  8643. } else {
  8644. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8645. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8646. bas := strings.Split(psn_info.CardInfo, "|")
  8647. if his.IdCardType == 1 {
  8648. cert_no = bas[2]
  8649. } else if his.IdCardType == 3 {
  8650. cert_no = his.Certno
  8651. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8652. } else if his.IdCardType == 4 {
  8653. cert_no = his.Certno
  8654. psn_info.VerifyNumber = psn_info.VerifyNumber
  8655. }
  8656. //江苏地区国家医保医疗类别
  8657. //职工透析:医疗类别选特殊情况门诊9933
  8658. //居民血透门慢: 医疗类别选门诊慢病1402
  8659. //var med_type string
  8660. //if his.Insutype == "310" {
  8661. // if reg_type == 14 {
  8662. // med_type = "9933"
  8663. // } else if reg_type == 11 {
  8664. // med_type = "11"
  8665. //
  8666. // }
  8667. //} else if his.Insutype == "390" {
  8668. // if reg_type == 14 {
  8669. // med_type = "1402"
  8670. // } else if reg_type == 11 {
  8671. // med_type = "11"
  8672. // }
  8673. //}
  8674. var api string
  8675. if miConfig.MdtrtareaAdmvs == "320921" {
  8676. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8677. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8678. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8679. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8680. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8681. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8682. "&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
  8683. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8684. } else {
  8685. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8686. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8687. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8688. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8689. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8690. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8691. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8692. "&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
  8693. }
  8694. resp, requestErr := http.Get(api)
  8695. if requestErr != nil {
  8696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8697. return
  8698. }
  8699. body, ioErr := ioutil.ReadAll(resp.Body)
  8700. if ioErr != nil {
  8701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8703. return
  8704. }
  8705. var respJSON map[string]interface{}
  8706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8709. return
  8710. }
  8711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8712. result, _ := json.Marshal(respJSON)
  8713. fmt.Println("log")
  8714. fmt.Println(string(result))
  8715. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8716. utils.ErrorLog("解析失败:%v", err)
  8717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8718. return
  8719. }
  8720. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8721. res.Output = resSeven10265.Output
  8722. res.ErrMsg = resSeven10265.ErrMsg
  8723. res.Cainfo = resSeven10265.Cainfo
  8724. res.WarnMsg = resSeven10265.WarnMsg
  8725. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8726. res.Infcode = infocode
  8727. }
  8728. }
  8729. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8730. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8731. var cert_no string
  8732. if his.IdCardType == 1 {
  8733. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8734. } else {
  8735. cert_no = psn_info.VerifyNumber
  8736. }
  8737. 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)
  8738. var dat map[string]interface{}
  8739. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8740. fmt.Println(dat)
  8741. } else {
  8742. fmt.Println(err)
  8743. }
  8744. saveLog(result2, src_resquest, "2207", "结算")
  8745. userJSONBytes, _ := json.Marshal(dat)
  8746. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8747. utils.ErrorLog("解析失败:%v", err)
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8749. return
  8750. }
  8751. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8752. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8753. var cert_no string
  8754. if his.IdCardType == 1 {
  8755. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8756. } else if his.IdCardType == 2 {
  8757. cert_no = his.IdCardNo
  8758. } else {
  8759. cert_no = psn_info.VerifyNumber
  8760. }
  8761. 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, "")
  8762. var dat map[string]interface{}
  8763. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8764. fmt.Println(dat)
  8765. } else {
  8766. fmt.Println(err)
  8767. }
  8768. saveLog(result2, src_resquest, "2207", "结算")
  8769. userJSONBytes, _ := json.Marshal(dat)
  8770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8771. utils.ErrorLog("解析失败:%v", err)
  8772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8773. return
  8774. }
  8775. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8776. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8777. var cert_no string
  8778. if his.IdCardType == 1 {
  8779. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8780. } else if his.IdCardType == 2 {
  8781. cert_no = his.IdCardNo
  8782. } else {
  8783. cert_no = psn_info.VerifyNumber
  8784. }
  8785. 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, "")
  8786. var dat map[string]interface{}
  8787. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8788. fmt.Println(dat)
  8789. } else {
  8790. fmt.Println(err)
  8791. }
  8792. saveLog(result2, src_resquest, "2207", "结算")
  8793. userJSONBytes, _ := json.Marshal(dat)
  8794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8795. utils.ErrorLog("解析失败:%v", err)
  8796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8797. return
  8798. }
  8799. } else {
  8800. var src_resquest string
  8801. if miConfig.Code == "H15049901371" {
  8802. //赤峰地区国家医保医疗类别
  8803. //职工透析:医疗类别选特殊情况门诊990502
  8804. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8805. var med_type string
  8806. if his.Insutype == "390" {
  8807. if reg_type == 14 {
  8808. med_type = "9933"
  8809. } else if reg_type == 11 {
  8810. med_type = "11"
  8811. }
  8812. } else if his.Insutype == "310" {
  8813. if reg_type == 14 {
  8814. med_type = "990502"
  8815. } else if reg_type == 11 {
  8816. med_type = "11"
  8817. }
  8818. }
  8819. 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, "")
  8820. } else {
  8821. if his.IdCardType == 4 {
  8822. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8823. token := psn_info.VerifyNumber
  8824. 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)
  8825. } else {
  8826. 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, "")
  8827. }
  8828. }
  8829. var dat map[string]interface{}
  8830. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8831. fmt.Println(dat)
  8832. } else {
  8833. fmt.Println(err)
  8834. }
  8835. saveLog(result2, src_resquest, "2207", "结算")
  8836. userJSONBytes, _ := json.Marshal(dat)
  8837. if miConfig.Code == "H15049901371" {
  8838. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8839. utils.ErrorLog("解析失败:%v", err)
  8840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8841. return
  8842. }
  8843. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8844. res.Output = resSeven10265.Output
  8845. res.ErrMsg = resSeven10265.ErrMsg
  8846. res.Cainfo = resSeven10265.Cainfo
  8847. res.WarnMsg = resSeven10265.WarnMsg
  8848. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8849. res.Infcode = infocode
  8850. } else {
  8851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8852. utils.ErrorLog("解析失败:%v", err)
  8853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8854. return
  8855. }
  8856. }
  8857. }
  8858. if res.Infcode != 0 {
  8859. errlog := &models.HisOrderError{
  8860. UserOrgId: adminUser.CurrentOrgId,
  8861. Ctime: time.Now().Unix(),
  8862. Mtime: time.Now().Unix(),
  8863. Number: chrg_bchno,
  8864. ErrMsg: res.ErrMsg,
  8865. Status: 1,
  8866. PatientId: id,
  8867. RecordTime: recordDateTime,
  8868. Stage: 6,
  8869. }
  8870. service.CreateErrMsgLog(errlog)
  8871. c.ServeSuccessJSON(map[string]interface{}{
  8872. "failed_code": -10,
  8873. "msg": res.ErrMsg,
  8874. })
  8875. return
  8876. } else {
  8877. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8878. order.OrderStatus = 2
  8879. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8880. order.SetlId = res.Output.Setlinfo.SetlID
  8881. order.PsnNo = res.Output.Setlinfo.PsnNo
  8882. order.PsnName = res.Output.Setlinfo.PsnName
  8883. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8884. order.Certno = res.Output.Setlinfo.Certno
  8885. order.Gend = res.Output.Setlinfo.Gend
  8886. order.Naty = res.Output.Setlinfo.Naty
  8887. order.Age = res.Output.Setlinfo.Age
  8888. order.Insutype = res.Output.Setlinfo.Insutype
  8889. order.PsnType = res.Output.Setlinfo.PsnType
  8890. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8891. order.SetlTime = res.Output.Setlinfo.SetlTime
  8892. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8893. //order.MedType = res.Output.Setlinfo.MedType
  8894. if reg_type == 1112 {
  8895. order.MedType = "1112"
  8896. }
  8897. if reg_type == 1111 {
  8898. order.MedType = "1111"
  8899. }
  8900. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8901. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8902. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8903. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8904. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8905. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8906. order.HifpPay = res.Output.Setlinfo.HifpPay
  8907. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8908. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8909. order.HifesPay = res.Output.Setlinfo.HifesPay
  8910. order.HifobPay = res.Output.Setlinfo.HifobPay
  8911. order.MafPay = res.Output.Setlinfo.MafPay
  8912. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8913. order.OthPay = res.Output.Setlinfo.OthPay
  8914. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8915. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8916. order.AcctPay = res.Output.Setlinfo.AcctPay
  8917. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8918. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8919. order.Balc = res.Output.Setlinfo.Balc
  8920. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8921. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8922. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8923. order.ClrWay = res.Output.Setlinfo.ClrWay
  8924. order.Creator = order.Creator
  8925. order.Modify = roles.AdminUserId
  8926. order.RequestLog = src_resquest
  8927. order.Diagnosis = diagnosis_id
  8928. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8929. detailStr := string(setlDetail)
  8930. order.SetlDetail = detailStr
  8931. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8932. err = service.UpDateOrder(order)
  8933. if err == nil {
  8934. //判断是否使用了押金
  8935. if dec_way == "true" {
  8936. tmpstring := strconv.FormatInt(order.ID, 10)
  8937. //扣押金
  8938. order.Decimal = decimal
  8939. service.UpDateOrder(order)
  8940. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8941. if errmsg != nil {
  8942. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8943. return
  8944. }
  8945. }
  8946. c.ServeSuccessJSON(map[string]interface{}{
  8947. "msg": "结算成功",
  8948. })
  8949. } else {
  8950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8951. return
  8952. }
  8953. }
  8954. }
  8955. }
  8956. }
  8957. //func (c *HisApiController) GetPreUploadInfo() {
  8958. // id, _ := c.GetInt64("id")
  8959. // record_time := c.GetString("record_time")
  8960. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8961. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8962. //
  8963. // timeLayout := "2006-01-02"
  8964. // loc, _ := time.LoadLocation("Local")
  8965. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8966. // if err != nil {
  8967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8968. // return
  8969. // }
  8970. // recordDateTime := theTime.Unix()
  8971. // adminUser := c.GetAdminUserInfo()
  8972. //
  8973. // var prescriptions []*models.HisPrescription
  8974. //
  8975. // var start_time int64
  8976. // var end_time int64
  8977. //
  8978. // data := make(map[string]interface{})
  8979. // if settle_accounts_type == 1 { //日结
  8980. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8981. // data["pre"] = prescriptions
  8982. //
  8983. // } else { //月结
  8984. // start_time_str := c.GetString("start_time")
  8985. // end_time_str := c.GetString("end_time")
  8986. // timeLayout := "2006-01-02"
  8987. // loc, _ := time.LoadLocation("Local")
  8988. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8989. // if err != nil {
  8990. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8991. // return
  8992. // }
  8993. // recordStartTime := theStartTime.Unix()
  8994. // start_time = recordStartTime
  8995. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8996. // if err != nil {
  8997. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8998. // return
  8999. // }
  9000. // recordEndTime := theEndTime.Unix()
  9001. // end_time = recordEndTime
  9002. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  9003. // data["pre"] = prescriptions
  9004. //
  9005. // }
  9006. //
  9007. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9008. //
  9009. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9010. // timestamp := time.Now().Unix()
  9011. // tempTime := time.Unix(timestamp, 0)
  9012. // timeFormat := tempTime.Format("20060102150405")
  9013. // chrgBchno := rand.Intn(100000) + 10000
  9014. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9015. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9016. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9017. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9018. // strconv.FormatInt(his.PatientId, 10)
  9019. // client := &http.Client{}
  9020. // data["psn_no"] = his.PsnNo
  9021. // data["mdtrt_id"] = his.Number
  9022. // data["chrg_bchno"] = chrg_bchno
  9023. // data["org_name"] = miConfig.OrgName
  9024. // data["doctor"] = roles.UserName
  9025. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  9026. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9027. // data["fixmedins_code"] = miConfig.Code
  9028. // data["dept_code"] = department.Number
  9029. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9030. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9031. // data["secret_key"] = miConfig.SecretKey
  9032. // var ids []int64
  9033. //
  9034. // for _, item := range prescriptions {
  9035. // ids = append(ids, item.ID)
  9036. // }
  9037. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9038. // if config.IsOpen == 1 { //对接了医保,走医保流程
  9039. // bytesData, _ := json.Marshal(data)
  9040. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  9041. // resp, _ := client.Do(req)
  9042. // defer resp.Body.Close()
  9043. // body, ioErr := ioutil.ReadAll(resp.Body)
  9044. // if ioErr != nil {
  9045. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9047. // return
  9048. // }
  9049. // var respJSON map[string]interface{}
  9050. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9051. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9053. // return
  9054. // }
  9055. //
  9056. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9057. // userJSONBytes, _ := json.Marshal(respJSON)
  9058. // var res ResultFour
  9059. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9060. // utils.ErrorLog("解析失败:%v", err)
  9061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9062. // return
  9063. // }
  9064. //
  9065. // if res.Infcode == 0 {
  9066. // order := &models.HisOrder{
  9067. // UserOrgId: adminUser.CurrentOrgId,
  9068. // HisPatientId: his.ID,
  9069. // PatientId: his.PatientId,
  9070. // SettleAccountsDate: recordDateTime,
  9071. // Ctime: time.Now().Unix(),
  9072. // Mtime: time.Now().Unix(),
  9073. // Status: 1,
  9074. // Number: chrg_bchno,
  9075. // Infcode: res.Infcode,
  9076. // WarnMsg: res.WarnMsg,
  9077. // Cainfo: res.Cainfo,
  9078. // ErrMsg: res.ErrMsg,
  9079. // RespondTime: res.RefmsgTime,
  9080. // InfRefmsgid: res.InfRefmsgid,
  9081. // OrderStatus: 1,
  9082. // IsMedicineInsurance: 1,
  9083. // SettleType: settle_accounts_type,
  9084. // SettleStartTime: start_time,
  9085. // SettleEndTime: end_time,
  9086. // Creator: roles.ID,
  9087. // Modify: roles.ID,
  9088. // PType: 2,
  9089. // }
  9090. // err = service.CreateOrder(order)
  9091. // if err != nil {
  9092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9093. // return
  9094. // }
  9095. //
  9096. // for _, item := range res.Output.Result {
  9097. // temp := strings.Split(item.FeedetlSn, "-")
  9098. // var advice_id int64 = 0
  9099. // var project_id int64 = 0
  9100. // var types int64 = 0
  9101. //
  9102. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  9103. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  9104. //
  9105. // if temp[1] == "1" {
  9106. // advice_id = id
  9107. // project_id = 0
  9108. // } else if temp[1] == "2" {
  9109. // advice_id = 0
  9110. // project_id = id
  9111. // }
  9112. //
  9113. // info := &models.HisOrderInfo{
  9114. // OrderNumber: order.Number,
  9115. // FeedetlSn: item.FeedetlSn,
  9116. // UploadDate: time.Now().Unix(),
  9117. // AdviceId: advice_id,
  9118. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  9119. // Cnt: item.Cnt,
  9120. // Pric: float64(item.Pric),
  9121. // PatientId: his.PatientId,
  9122. // PricUplmtAmt: item.PricUplmtAmt,
  9123. // SelfpayProp: item.SelfpayProp,
  9124. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9125. // OverlmtAmt: item.OverlmtAmt,
  9126. // PreselfpayAmt: item.PreselfpayAmt,
  9127. // BasMednFlag: item.BasMednFlag,
  9128. // MedChrgitmType: item.MedChrgitmType,
  9129. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  9130. // Status: 1,
  9131. // Memo: item.Memo,
  9132. // Mtime: time.Now().Unix(),
  9133. // InscpScpAmt: item.InscpScpAmt,
  9134. // DrtReimFlag: item.DrtReimFlag,
  9135. // Ctime: time.Now().Unix(),
  9136. // ListSpItemFlag: item.ListSpItemFlag,
  9137. // ChldMedcFlag: item.ChldMedcFlag,
  9138. // LmtUsedFlag: item.LmtUsedFlag,
  9139. // ChrgitmLv: item.ChrgitmLv,
  9140. // UserOrgId: adminUser.CurrentOrgId,
  9141. // HisPatientId: his.ID,
  9142. // OrderId: order.ID,
  9143. // ProjectId: project_id,
  9144. // Type: types,
  9145. // }
  9146. // service.CreateOrderInfo(info)
  9147. //
  9148. // }
  9149. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9150. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  9151. //
  9152. // var total float64
  9153. // for _, item := range prescriptions {
  9154. // if item.Type == 1 { //药品
  9155. // for _, subItem := range item.HisDoctorAdviceInfo {
  9156. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9157. // }
  9158. // }
  9159. // if item.Type == 2 { //项目
  9160. // for _, subItem := range item.HisPrescriptionProject {
  9161. // total = total + (subItem.Price * float64(subItem.Count))
  9162. // }
  9163. // }
  9164. // }
  9165. //
  9166. // for _, item := range prescriptions {
  9167. // for _, subItem := range item.HisAdditionalCharge {
  9168. // total = total + (subItem.Price * float64(subItem.Count))
  9169. // }
  9170. // }
  9171. //
  9172. // allTotal := fmt.Sprintf("%.2f", total)
  9173. // if res.Infcode == 0 {
  9174. // var rf []*ResultFive
  9175. // json.Unmarshal([]byte(his.Iinfo), &rf)
  9176. // psn_no := his.PsnNo
  9177. // mdtrt_id := his.Number
  9178. // chrg_bchno := chrg_bchno
  9179. // cert_no := his.Certno
  9180. // insutype := rf[0].Insutype
  9181. //
  9182. // if his.IdCardType == 1 {
  9183. // cert_no = his.MedicalInsuranceNumber
  9184. //
  9185. // } else {
  9186. //
  9187. // cert_no = his.Certno
  9188. //
  9189. // }
  9190. //
  9191. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  9192. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  9193. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  9194. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  9195. // resp, requestErr := http.Get(api)
  9196. // if requestErr != nil {
  9197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9198. // return
  9199. // }
  9200. // defer resp.Body.Close()
  9201. // body, ioErr := ioutil.ReadAll(resp.Body)
  9202. // if ioErr != nil {
  9203. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9205. // return
  9206. // }
  9207. // var respJSON map[string]interface{}
  9208. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9209. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9211. // return
  9212. // }
  9213. // fmt.Println(respJSON)
  9214. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9215. // userJSONBytes, _ := json.Marshal(respJSON)
  9216. // var res ResultSeven
  9217. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9218. // utils.ErrorLog("解析失败:%v", err)
  9219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9220. // return
  9221. // }
  9222. // if res.Infcode != 0 {
  9223. // errlog := &models.HisOrderError{
  9224. // UserOrgId: adminUser.CurrentOrgId,
  9225. // Ctime: time.Now().Unix(),
  9226. // Mtime: time.Now().Unix(),
  9227. // Number: chrg_bchno,
  9228. // ErrMsg: res.ErrMsg,
  9229. // Status: 1,
  9230. // PatientId: id,
  9231. // RecordTime: recordDateTime,
  9232. // Stage: 7,
  9233. // }
  9234. // service.CreateErrMsgLog(errlog)
  9235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9236. // return
  9237. // } else {
  9238. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9239. // order.OrderStatus = 1
  9240. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9241. // order.SetlId = res.Output.Setlinfo.SetlID
  9242. // order.PsnNo = res.Output.Setlinfo.PsnNo
  9243. // order.PsnName = res.Output.Setlinfo.PsnName
  9244. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9245. // order.Certno = res.Output.Setlinfo.Certno
  9246. // order.Gend = res.Output.Setlinfo.Gend
  9247. // order.Naty = res.Output.Setlinfo.Naty
  9248. // order.Age = res.Output.Setlinfo.Age
  9249. // order.Insutype = res.Output.Setlinfo.Insutype
  9250. // order.PsnType = res.Output.Setlinfo.PsnType
  9251. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9252. // order.SetlTime = res.Output.Setlinfo.SetlTime
  9253. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9254. // order.MedType = res.Output.Setlinfo.MedType
  9255. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9256. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9257. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9258. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9259. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9260. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9261. // order.HifpPay = res.Output.Setlinfo.HifpPay
  9262. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9263. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9264. // order.HifesPay = res.Output.Setlinfo.HifesPay
  9265. // order.HifobPay = res.Output.Setlinfo.HifobPay
  9266. // order.MafPay = res.Output.Setlinfo.MafPay
  9267. // order.OthPay = res.Output.Setlinfo.OthPay
  9268. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9269. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9270. // order.AcctPay = res.Output.Setlinfo.AcctPay
  9271. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9272. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9273. // order.Balc = res.Output.Setlinfo.Balc
  9274. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9275. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9276. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9277. // order.ClrWay = res.Output.Setlinfo.ClrWay
  9278. // order.Creator = order.Creator
  9279. // order.Modify = roles.ID
  9280. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9281. // detailStr := string(setlDetail)
  9282. // order.SetlDetail = detailStr
  9283. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9284. // err = service.UpDateOrder(order)
  9285. // if err == nil {
  9286. // c.ServeSuccessJSON(map[string]interface{}{
  9287. // "msg": "预结算成功",
  9288. // })
  9289. // } else {
  9290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9291. // return
  9292. // }
  9293. // }
  9294. // } else {
  9295. // adminUser := c.GetAdminUserInfo()
  9296. // errlog := &models.HisOrderError{
  9297. // UserOrgId: adminUser.CurrentOrgId,
  9298. // Ctime: time.Now().Unix(),
  9299. // Mtime: time.Now().Unix(),
  9300. // ErrMsg: res.ErrMsg,
  9301. // Status: 1,
  9302. // PatientId: id,
  9303. // RecordTime: recordDateTime,
  9304. // Stage: 4,
  9305. // }
  9306. // service.CreateErrMsgLog(errlog)
  9307. //
  9308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9309. // return
  9310. // }
  9311. // } else {
  9312. // adminUser := c.GetAdminUserInfo()
  9313. // errlog := &models.HisOrderError{
  9314. // UserOrgId: adminUser.CurrentOrgId,
  9315. // Ctime: time.Now().Unix(),
  9316. // Mtime: time.Now().Unix(),
  9317. // ErrMsg: res.ErrMsg,
  9318. // Status: 1,
  9319. // PatientId: id,
  9320. // RecordTime: recordDateTime,
  9321. // Stage: 4,
  9322. // }
  9323. // service.CreateErrMsgLog(errlog)
  9324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9325. // return
  9326. // }
  9327. //
  9328. // } else {
  9329. // var total float64
  9330. // for _, item := range prescriptions {
  9331. // if item.Type == 1 { //药品
  9332. // for _, subItem := range item.HisDoctorAdviceInfo {
  9333. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9334. // }
  9335. // }
  9336. // if item.Type == 2 { //项目
  9337. // for _, subItem := range item.HisPrescriptionProject {
  9338. // total = total + (subItem.Price * float64(subItem.Count))
  9339. // }
  9340. // }
  9341. //
  9342. // for _, subItem := range item.HisAdditionalCharge {
  9343. // total = total + (subItem.Price * float64(subItem.Count))
  9344. // }
  9345. // }
  9346. //
  9347. // allTotal := fmt.Sprintf("%.2f", total)
  9348. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9349. // order := &models.HisOrder{
  9350. // UserOrgId: adminUser.CurrentOrgId,
  9351. // HisPatientId: his.ID,
  9352. // PatientId: id,
  9353. // SettleAccountsDate: recordDateTime,
  9354. // Ctime: time.Now().Unix(),
  9355. // Mtime: time.Now().Unix(),
  9356. // Status: 1,
  9357. // OrderStatus: 2,
  9358. // Number: chrg_bchno,
  9359. // MedfeeSumamt: totals,
  9360. // }
  9361. // err = service.CreateOrder(order)
  9362. // if err != nil {
  9363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9364. // return
  9365. // }
  9366. //
  9367. // var customs []*Custom
  9368. // for _, item := range prescriptions {
  9369. //
  9370. // if item.Type == 1 { //药品
  9371. // for _, subItem := range item.HisDoctorAdviceInfo {
  9372. // cus := &Custom{
  9373. // AdviceId: subItem.ID,
  9374. // ProjectId: 0,
  9375. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9376. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9377. // FeedetlSn: subItem.FeedetlSn,
  9378. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9379. // MedListCodg: subItem.MedListCodg,
  9380. // Type: 1,
  9381. // }
  9382. // customs = append(customs, cus)
  9383. // }
  9384. // }
  9385. //
  9386. // if item.Type == 2 { //项目
  9387. // for _, subItem := range item.HisPrescriptionProject {
  9388. //
  9389. // cus := &Custom{
  9390. // AdviceId: 0,
  9391. // ProjectId: subItem.ID,
  9392. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  9393. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  9394. // FeedetlSn: subItem.FeedetlSn,
  9395. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  9396. // MedListCodg: subItem.MedListCodg,
  9397. // Type: 2,
  9398. // }
  9399. //
  9400. // customs = append(customs, cus)
  9401. // }
  9402. // }
  9403. //
  9404. // for _, item := range item.HisAdditionalCharge {
  9405. // cus := &Custom{
  9406. // ItemId: item.ID,
  9407. // AdviceId: 0,
  9408. // ProjectId: 0,
  9409. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  9410. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  9411. // FeedetlSn: item.FeedetlSn,
  9412. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  9413. // MedListCodg: item.XtHisAddtionConfig.Code,
  9414. // Type: 3,
  9415. // }
  9416. //
  9417. // customs = append(customs, cus)
  9418. // }
  9419. //
  9420. // }
  9421. //
  9422. // for _, item := range customs {
  9423. // var advice_id int64 = 0
  9424. // var project_id int64 = 0
  9425. // var item_id int64 = 0
  9426. //
  9427. // var types int64 = 0
  9428. //
  9429. // if item.Type == 1 {
  9430. // advice_id = item.AdviceId
  9431. // project_id = 0
  9432. // item_id = 0
  9433. // } else if item.Type == 2 {
  9434. // advice_id = 0
  9435. // item_id = 0
  9436. //
  9437. // project_id = item.ProjectId
  9438. // } else if item.Type == 3 {
  9439. // advice_id = 0
  9440. // item_id = item.ItemId
  9441. // project_id = 0
  9442. // }
  9443. //
  9444. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  9445. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  9446. // pric, _ := strconv.ParseFloat(item.Price, 32)
  9447. //
  9448. // info := &models.HisOrderInfo{
  9449. // OrderNumber: order.Number,
  9450. // UploadDate: time.Now().Unix(),
  9451. // AdviceId: advice_id,
  9452. // DetItemFeeSumamt: detItemFeeSumamt,
  9453. // Cnt: cut,
  9454. // Pric: pric,
  9455. // PatientId: id,
  9456. // Status: 1,
  9457. // Mtime: time.Now().Unix(),
  9458. // Ctime: time.Now().Unix(),
  9459. // UserOrgId: adminUser.CurrentOrgId,
  9460. // HisPatientId: his.ID,
  9461. // OrderId: order.ID,
  9462. // ProjectId: project_id,
  9463. // Type: types,
  9464. // ItemId: item_id,
  9465. // }
  9466. // service.CreateOrderInfo(info)
  9467. // }
  9468. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9469. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9470. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  9471. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9472. // if err == nil {
  9473. // c.ServeSuccessJSON(map[string]interface{}{
  9474. // "msg": "结算成功",
  9475. // })
  9476. // } else {
  9477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9478. // return
  9479. // }
  9480. // }
  9481. //}
  9482. //上传明细-预结算-
  9483. func (c *HisApiController) GetPreUploadInfo() {
  9484. id, _ := c.GetInt64("id")
  9485. record_time := c.GetString("record_time")
  9486. his_patient_id, _ := c.GetInt64("his_patient_id")
  9487. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9488. admin_user_id, _ := c.GetInt64("admin_user_id")
  9489. diagnosis_id := c.GetString("diagnosis")
  9490. sick_type, _ := c.GetInt64("sick_type")
  9491. reg_type, _ := c.GetInt64("p_type")
  9492. begin_time := c.GetString("begin_time")
  9493. id_str := c.GetString("ids")
  9494. ids_arr := strings.Split(id_str, ",")
  9495. timeLayout := "2006-01-02"
  9496. loc, _ := time.LoadLocation("Local")
  9497. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9498. if err != nil {
  9499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9500. return
  9501. }
  9502. recordDateTime := theTime.Unix()
  9503. adminUser := c.GetAdminUserInfo()
  9504. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9505. var config []*models.HisXtDiagnoseConfig
  9506. for _, item := range diagnosis_ids {
  9507. id, _ := strconv.ParseInt(item, 10, 64)
  9508. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9509. config = append(config, &diagnosisConfig)
  9510. }
  9511. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9512. sickConfig, _ := service.FindSickById(sick_type)
  9513. var prescriptions []*models.HisPrescription
  9514. var start_time int64
  9515. var end_time int64
  9516. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9517. fmt.Println(his_patient_id)
  9518. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9519. timestamp := time.Now().Unix()
  9520. tempTime := time.Unix(timestamp, 0)
  9521. timeFormat := tempTime.Format("20060102150405")
  9522. chrgBchno := rand.Intn(100000) + 10000
  9523. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9524. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9525. var patientPrescription models.HisPrescriptionInfo
  9526. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9527. if patientPrescription.ID == 0 {
  9528. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9529. }
  9530. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9531. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9532. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9533. strconv.FormatInt(his.PatientId, 10)
  9534. var res2 ResultSix
  9535. var resSix10265 ResultSix10265
  9536. //var time_stamp string
  9537. if miConfig.MdtrtareaAdmvs == "421300" {
  9538. data := make(map[string]interface{})
  9539. client := &http.Client{}
  9540. data["psn_no"] = his.PsnNo
  9541. data["mdtrt_id"] = his.Number
  9542. data["department"] = department.Name
  9543. data["org_name"] = miConfig.OrgName
  9544. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9545. data["doctor_id"] = doctor_info.DoctorNumber
  9546. data["doctor_name"] = roles.UserName
  9547. data["fixmedins_code"] = miConfig.Code
  9548. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9549. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9550. data["secret_key"] = miConfig.SecretKey
  9551. data["sick_code"] = sickConfig.CountryCode
  9552. data["sick_name"] = sickConfig.ClassName
  9553. data["begin_time"] = begin_time
  9554. data["dept"] = strconv.FormatInt(department.ID, 10)
  9555. data["config"] = config
  9556. data["opter"] = roles.UserName
  9557. fmt.Println(data)
  9558. bytesData, _ := json.Marshal(data)
  9559. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9560. resp, _ := client.Do(req)
  9561. defer resp.Body.Close()
  9562. body, ioErr := ioutil.ReadAll(resp.Body)
  9563. if ioErr != nil {
  9564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9566. return
  9567. }
  9568. var respJSON map[string]interface{}
  9569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9572. return
  9573. }
  9574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9575. userJSONBytes, _ := json.Marshal(respJSON)
  9576. fmt.Println("log")
  9577. fmt.Println(string(userJSONBytes))
  9578. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9579. utils.ErrorLog("解析失败:%v", err)
  9580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9581. return
  9582. }
  9583. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9584. data := make(map[string]interface{})
  9585. client := &http.Client{}
  9586. data["psn_no"] = his.PsnNo
  9587. data["mdtrt_id"] = his.Number
  9588. data["doctor"] = roles.UserName
  9589. data["department"] = department.Name
  9590. data["org_name"] = miConfig.OrgName
  9591. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9592. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  9593. data["fixmedins_code"] = miConfig.Code
  9594. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9595. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9596. data["secret_key"] = miConfig.SecretKey
  9597. data["sick_code"] = sickConfig.CountryCode
  9598. data["sick_name"] = sickConfig.ClassName
  9599. data["begin_time"] = begin_time
  9600. data["dept"] = strconv.FormatInt(department.ID, 10)
  9601. data["config"] = config
  9602. data["url"] = miConfig.Url
  9603. data["ak"] = miConfig.AccessKey
  9604. data["cainfo"] = miConfig.Cainfo
  9605. bytesData, _ := json.Marshal(data)
  9606. var req *http.Request
  9607. if miConfig.MdtrtareaAdmvs == "320921" {
  9608. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9609. } else {
  9610. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9611. }
  9612. resp, _ := client.Do(req)
  9613. defer resp.Body.Close()
  9614. body, ioErr := ioutil.ReadAll(resp.Body)
  9615. if ioErr != nil {
  9616. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9618. return
  9619. }
  9620. var respJSON map[string]interface{}
  9621. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9624. return
  9625. }
  9626. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  9627. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  9628. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  9629. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9630. userJSONBytes, _ := json.Marshal(respJSON)
  9631. fmt.Println("log")
  9632. fmt.Println(string(userJSONBytes))
  9633. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  9634. utils.ErrorLog("解析失败:%v", err)
  9635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9636. return
  9637. }
  9638. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9639. res2.Output = resSix10265.Output
  9640. res2.ErrMsg = resSix10265.ErrMsg
  9641. res2.Cainfo = resSix10265.Cainfo
  9642. res2.WarnMsg = resSix10265.WarnMsg
  9643. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9644. res2.Infcode = infocode
  9645. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9646. 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)
  9647. saveLog(result, requestLog, "2203", "上传就诊信息")
  9648. var respJSON2 map[string]interface{}
  9649. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9652. return
  9653. }
  9654. userJSONBytes2, _ := json.Marshal(respJSON2)
  9655. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9656. utils.ErrorLog("解析失败:%v", err)
  9657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9658. return
  9659. }
  9660. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9661. var result string
  9662. var requestLog string
  9663. 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, "")
  9664. saveLog(result, requestLog, "2203", "上传就诊信息")
  9665. var respJSON2 map[string]interface{}
  9666. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9669. return
  9670. }
  9671. userJSONBytes2, _ := json.Marshal(respJSON2)
  9672. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9673. utils.ErrorLog("解析失败:%v", err)
  9674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9675. return
  9676. }
  9677. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9678. var result string
  9679. var requestLog string
  9680. 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, "")
  9681. saveLog(result, requestLog, "2203", "上传就诊信息")
  9682. var respJSON2 map[string]interface{}
  9683. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9686. return
  9687. }
  9688. userJSONBytes2, _ := json.Marshal(respJSON2)
  9689. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9690. utils.ErrorLog("解析失败:%v", err)
  9691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9692. return
  9693. }
  9694. } else {
  9695. var result string
  9696. var requestLog string
  9697. if miConfig.MdtrtareaAdmvs == "440781" { //
  9698. 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)
  9699. } else {
  9700. if miConfig.Code == "H15049901371" {
  9701. //赤峰地区国家医保医疗类别
  9702. //职工透析:医疗类别选特殊情况门诊990502
  9703. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9704. var med_type string
  9705. if his.Insutype == "390" {
  9706. if reg_type == 14 {
  9707. med_type = "9933"
  9708. } else if reg_type == 11 {
  9709. med_type = "11"
  9710. }
  9711. } else if his.Insutype == "310" {
  9712. if reg_type == 14 {
  9713. med_type = "990502"
  9714. } else if reg_type == 11 {
  9715. med_type = "11"
  9716. }
  9717. }
  9718. 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)
  9719. } else {
  9720. 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)
  9721. }
  9722. saveLog(result, requestLog, "2203", "上传就诊信息")
  9723. var respJSON2 map[string]interface{}
  9724. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9727. return
  9728. }
  9729. userJSONBytes2, _ := json.Marshal(respJSON2)
  9730. if miConfig.Code == "H15049901371" {
  9731. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9732. utils.ErrorLog("解析失败:%v", err)
  9733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9734. return
  9735. }
  9736. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9737. res2.Output = resSix10265.Output
  9738. res2.ErrMsg = resSix10265.ErrMsg
  9739. res2.Cainfo = resSix10265.Cainfo
  9740. res2.WarnMsg = resSix10265.WarnMsg
  9741. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9742. res2.Infcode = infocode
  9743. } else {
  9744. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9745. utils.ErrorLog("解析失败:%v", err)
  9746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9747. return
  9748. }
  9749. }
  9750. }
  9751. }
  9752. if res2.Infcode != 0 {
  9753. adminUser := c.GetAdminUserInfo()
  9754. errlog := &models.HisOrderError{
  9755. UserOrgId: adminUser.CurrentOrgId,
  9756. Ctime: time.Now().Unix(),
  9757. Mtime: time.Now().Unix(),
  9758. ErrMsg: res2.ErrMsg,
  9759. Status: 1,
  9760. PatientId: id,
  9761. RecordTime: recordDateTime,
  9762. Stage: 3,
  9763. }
  9764. service.CreateErrMsgLog(errlog)
  9765. c.ServeSuccessJSON(map[string]interface{}{
  9766. "failed_code": -10,
  9767. "msg": res2.ErrMsg,
  9768. })
  9769. return
  9770. } else {
  9771. his.Diagnosis = diagnosis_id
  9772. his.SickType = sickConfig.ID
  9773. his.PType = fmt.Sprintf("%d", reg_type)
  9774. service.UpdateHisPatientThree(&his)
  9775. data := make(map[string]interface{})
  9776. if settle_accounts_type == 1 { //日结
  9777. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9778. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9779. } else {
  9780. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9781. }
  9782. data["pre"] = prescriptions
  9783. } else { //月结
  9784. start_time_str := c.GetString("start_time")
  9785. end_time_str := c.GetString("end_time")
  9786. timeLayout := "2006-01-02"
  9787. loc, _ := time.LoadLocation("Local")
  9788. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9789. if err != nil {
  9790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9791. return
  9792. }
  9793. recordStartTime := theStartTime.Unix()
  9794. start_time = recordStartTime
  9795. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9796. if err != nil {
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9798. return
  9799. }
  9800. recordEndTime := theEndTime.Unix()
  9801. end_time = recordEndTime
  9802. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9803. data["pre"] = prescriptions
  9804. }
  9805. client := &http.Client{}
  9806. data["psn_no"] = his.PsnNo
  9807. data["mdtrt_id"] = his.Number
  9808. data["chrg_bchno"] = chrg_bchno
  9809. data["org_name"] = miConfig.OrgName
  9810. data["doctor"] = doctor_info.UserName
  9811. data["doctor_id"] = doctor_info.DoctorNumber
  9812. data["dept"] = department.Name
  9813. data["fixmedins_code"] = miConfig.Code
  9814. data["opter"] = roles.UserName
  9815. data["dept_code"] = department.Number
  9816. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9817. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9818. data["secret_key"] = miConfig.SecretKey
  9819. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9820. data["url"] = miConfig.Url
  9821. data["ak"] = miConfig.AccessKey
  9822. data["new_doctor_name"] = patientPrescription.Doctor
  9823. data["diag_code"] = sickConfig.CountryCode
  9824. data["cainfo"] = miConfig.Cainfo
  9825. data["opter"] = roles.UserName
  9826. var ids []int64
  9827. for _, item := range prescriptions {
  9828. ids = append(ids, item.ID)
  9829. }
  9830. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9831. if config.IsOpen == 1 { //对接了医保,走医保流程
  9832. var res ResultFour
  9833. var resFour10265 ResultFour10265
  9834. if miConfig.MdtrtareaAdmvs == "421300" {
  9835. bytesData, _ := json.Marshal(data)
  9836. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9837. resp, _ := client.Do(req)
  9838. defer resp.Body.Close()
  9839. body, ioErr := ioutil.ReadAll(resp.Body)
  9840. if ioErr != nil {
  9841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9843. return
  9844. }
  9845. var respJSON map[string]interface{}
  9846. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9849. return
  9850. }
  9851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9852. userJSONBytes, _ := json.Marshal(respJSON)
  9853. fmt.Println("log")
  9854. fmt.Println(string(userJSONBytes))
  9855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9856. utils.ErrorLog("解析失败:%v", err)
  9857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9858. return
  9859. }
  9860. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9861. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9862. if result3101.Infcode == "0" {
  9863. if len(result3101.Output.Result) > 0 {
  9864. var errMsgs []string
  9865. for _, item := range result3101.Output.Result {
  9866. errMsgs = append(errMsgs, item.VolaCont)
  9867. }
  9868. c.ServeSuccessJSON(map[string]interface{}{
  9869. "failed_code": -10,
  9870. "msg": errMsgs,
  9871. })
  9872. return
  9873. } else {
  9874. if miConfig.MdtrtareaAdmvs == "320921" {
  9875. data["doctor_id"] = "D320923012139"
  9876. } else {
  9877. data["doctor_id"] = "D371621008686"
  9878. }
  9879. bytesData, _ := json.Marshal(data)
  9880. var req *http.Request
  9881. if miConfig.MdtrtareaAdmvs == "320921" {
  9882. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9883. } else {
  9884. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9885. }
  9886. resp, _ := client.Do(req)
  9887. defer resp.Body.Close()
  9888. body, ioErr := ioutil.ReadAll(resp.Body)
  9889. if ioErr != nil {
  9890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9892. return
  9893. }
  9894. var respJSON map[string]interface{}
  9895. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9898. return
  9899. }
  9900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9901. userJSONBytes, _ := json.Marshal(respJSON)
  9902. fmt.Println("log")
  9903. fmt.Println(string(userJSONBytes))
  9904. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9905. utils.ErrorLog("解析失败:%v", err)
  9906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9907. return
  9908. }
  9909. res.InfRefmsgid = resFour10265.InfRefmsgid
  9910. res.Output = resFour10265.Output
  9911. res.ErrMsg = resFour10265.ErrMsg
  9912. res.Cainfo = resFour10265.Cainfo
  9913. res.WarnMsg = resFour10265.WarnMsg
  9914. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9915. res.Infcode = infocode
  9916. }
  9917. }
  9918. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9919. 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)
  9920. var dat map[string]interface{}
  9921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9922. fmt.Println(dat)
  9923. } else {
  9924. fmt.Println(err)
  9925. }
  9926. saveLog(result, request_log, "2204", "上传费用明细")
  9927. userJSONBytes, _ := json.Marshal(dat)
  9928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9929. utils.ErrorLog("解析失败:%v", err)
  9930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9931. return
  9932. }
  9933. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9934. 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, "", "")
  9935. var dat map[string]interface{}
  9936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9937. fmt.Println(dat)
  9938. } else {
  9939. fmt.Println(err)
  9940. }
  9941. saveLog(result, request_log, "2204", "上传费用明细")
  9942. userJSONBytes, _ := json.Marshal(dat)
  9943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9944. utils.ErrorLog("解析失败:%v", err)
  9945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9946. return
  9947. }
  9948. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9949. 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, "", "")
  9950. var dat map[string]interface{}
  9951. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9952. fmt.Println(dat)
  9953. } else {
  9954. fmt.Println(err)
  9955. }
  9956. saveLog(result, request_log, "2204", "上传费用明细")
  9957. userJSONBytes, _ := json.Marshal(dat)
  9958. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9959. utils.ErrorLog("解析失败:%v", err)
  9960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9961. return
  9962. }
  9963. } else {
  9964. if miConfig.Code == "H15049901371" {
  9965. 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)
  9966. var dat map[string]interface{}
  9967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9968. fmt.Println(dat)
  9969. } else {
  9970. fmt.Println(err)
  9971. }
  9972. saveLog(result, request_log, "2204", "上传费用明细")
  9973. userJSONBytes, _ := json.Marshal(dat)
  9974. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9975. utils.ErrorLog("解析失败:%v", err)
  9976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9977. return
  9978. }
  9979. res.InfRefmsgid = resFour10265.InfRefmsgid
  9980. res.Output = resFour10265.Output
  9981. res.ErrMsg = resFour10265.ErrMsg
  9982. res.Cainfo = resFour10265.Cainfo
  9983. res.WarnMsg = resFour10265.WarnMsg
  9984. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9985. res.Infcode = infocode
  9986. } else {
  9987. 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), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  9988. var dat map[string]interface{}
  9989. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9990. fmt.Println(dat)
  9991. } else {
  9992. fmt.Println(err)
  9993. }
  9994. saveLog(result, request_log, "2204", "上传费用明细")
  9995. userJSONBytes, _ := json.Marshal(dat)
  9996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9997. utils.ErrorLog("解析失败:%v", err)
  9998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9999. return
  10000. }
  10001. }
  10002. }
  10003. if res.Infcode == 0 {
  10004. order := &models.HisOrder{
  10005. UserOrgId: adminUser.CurrentOrgId,
  10006. HisPatientId: his.ID,
  10007. PatientId: his.PatientId,
  10008. SettleAccountsDate: recordDateTime,
  10009. Ctime: time.Now().Unix(),
  10010. Mtime: time.Now().Unix(),
  10011. MdtrtId: his.Number,
  10012. PsnNo: his.PsnNo,
  10013. MedType: strconv.FormatInt(reg_type, 10),
  10014. Status: 1,
  10015. Number: chrg_bchno,
  10016. Infcode: res.Infcode,
  10017. WarnMsg: res.WarnMsg,
  10018. Cainfo: res.Cainfo,
  10019. ErrMsg: res.ErrMsg,
  10020. RespondTime: res.RefmsgTime,
  10021. InfRefmsgid: res.InfRefmsgid,
  10022. OrderStatus: 1,
  10023. IsMedicineInsurance: 1,
  10024. SettleType: settle_accounts_type,
  10025. SettleStartTime: start_time,
  10026. SettleEndTime: end_time,
  10027. Creator: roles.AdminUserId,
  10028. Modify: roles.AdminUserId,
  10029. PType: 2,
  10030. Diagnosis: diagnosis_id,
  10031. }
  10032. err = service.CreateOrder(order)
  10033. if err != nil {
  10034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10035. return
  10036. }
  10037. for _, item := range res.Output.Result {
  10038. temp := strings.Split(item.FeedetlSn, "-")
  10039. var advice_id int64 = 0
  10040. var project_id int64 = 0
  10041. var types int64 = 0
  10042. id, _ := strconv.ParseInt(temp[2], 10, 64)
  10043. types, _ = strconv.ParseInt(temp[1], 10, 64)
  10044. if temp[1] == "1" {
  10045. advice_id = id
  10046. project_id = 0
  10047. } else if temp[1] == "2" {
  10048. advice_id = 0
  10049. project_id = id
  10050. }
  10051. info := &models.HisOrderInfo{
  10052. OrderNumber: order.Number,
  10053. FeedetlSn: item.FeedetlSn,
  10054. UploadDate: time.Now().Unix(),
  10055. AdviceId: advice_id,
  10056. DetItemFeeSumamt: item.DetItemFeeSumamt,
  10057. Cnt: item.Cnt,
  10058. Pric: float64(item.Pric),
  10059. PatientId: his.PatientId,
  10060. PricUplmtAmt: item.PricUplmtAmt,
  10061. SelfpayProp: item.SelfpayProp,
  10062. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10063. OverlmtAmt: item.OverlmtAmt,
  10064. PreselfpayAmt: item.PreselfpayAmt,
  10065. BasMednFlag: item.BasMednFlag,
  10066. MedChrgitmType: item.MedChrgitmType,
  10067. HiNegoDrugFlag: item.HiNegoDrugFlag,
  10068. Status: 1,
  10069. Memo: item.Memo,
  10070. Mtime: time.Now().Unix(),
  10071. InscpScpAmt: item.InscpScpAmt,
  10072. DrtReimFlag: item.DrtReimFlag,
  10073. Ctime: time.Now().Unix(),
  10074. ListSpItemFlag: item.ListSpItemFlag,
  10075. ChldMedcFlag: item.ChldMedcFlag,
  10076. LmtUsedFlag: item.LmtUsedFlag,
  10077. ChrgitmLv: item.ChrgitmLv,
  10078. UserOrgId: adminUser.CurrentOrgId,
  10079. HisPatientId: his.ID,
  10080. OrderId: order.ID,
  10081. ProjectId: project_id,
  10082. Type: types,
  10083. }
  10084. service.CreateOrderInfo(info)
  10085. }
  10086. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10087. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  10088. var total float64
  10089. for _, item := range prescriptions {
  10090. if item.Type == 1 { //药品
  10091. for _, subItem := range item.HisDoctorAdviceInfo {
  10092. total = total + (subItem.Price * subItem.PrescribingNumber)
  10093. }
  10094. }
  10095. if item.Type == 2 { //项目
  10096. for _, subItem := range item.HisPrescriptionProject {
  10097. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10098. total = total + (subItem.Price * cnt)
  10099. }
  10100. }
  10101. }
  10102. for _, item := range prescriptions {
  10103. for _, subItem := range item.HisAdditionalCharge {
  10104. total = total + (subItem.Price * float64(subItem.Count))
  10105. }
  10106. }
  10107. allTotal := fmt.Sprintf("%.4f", total)
  10108. if res.Infcode == 0 {
  10109. var rf []*ResultFive
  10110. json.Unmarshal([]byte(his.Iinfo), &rf)
  10111. chrg_bchno := chrg_bchno
  10112. cert_no := his.Certno
  10113. var insutypes []string
  10114. var insutype string
  10115. var is390 int = 0
  10116. var is310 int = 0
  10117. for _, item := range rf {
  10118. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10119. insutypes = append(insutypes, item.Insutype)
  10120. }
  10121. }
  10122. if len(insutypes) == 1 {
  10123. insutype = insutypes[0]
  10124. } else {
  10125. for _, i := range insutypes {
  10126. if i == "390" {
  10127. is390 = 1
  10128. }
  10129. if i == "310" {
  10130. is310 = 1
  10131. }
  10132. }
  10133. }
  10134. if is390 == 1 {
  10135. insutype = "390"
  10136. }
  10137. if is310 == 1 {
  10138. insutype = "310"
  10139. }
  10140. if len(insutypes) == 0 {
  10141. insutype = "310"
  10142. }
  10143. if len(insutypes) == 2 {
  10144. insutype = strconv.FormatInt(his.SocialType, 64)
  10145. }
  10146. //insutype = "390"
  10147. if his.IdCardType == 1 {
  10148. cert_no = his.MedicalInsuranceNumber
  10149. } else {
  10150. cert_no = his.Certno
  10151. }
  10152. var res ResultSeven
  10153. var resSeven10265 ResultSeven10265
  10154. if miConfig.MdtrtareaAdmvs == "421300" {
  10155. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10156. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10157. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10159. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10160. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10161. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  10162. resp, requestErr := http.Get(api)
  10163. if requestErr != nil {
  10164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10165. return
  10166. }
  10167. body, ioErr := ioutil.ReadAll(resp.Body)
  10168. if ioErr != nil {
  10169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10171. return
  10172. }
  10173. var respJSON map[string]interface{}
  10174. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10177. return
  10178. }
  10179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10180. result, _ := json.Marshal(respJSON)
  10181. fmt.Println("log")
  10182. fmt.Println(string(result))
  10183. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10184. utils.ErrorLog("解析失败:%v", err)
  10185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10186. return
  10187. }
  10188. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10189. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  10190. if result3101.Infcode == "0" {
  10191. if len(result3101.Output.Result) > 0 {
  10192. var errMsgs []string
  10193. for _, item := range result3101.Output.Result {
  10194. errMsgs = append(errMsgs, item.VolaCont)
  10195. }
  10196. c.ServeSuccessJSON(map[string]interface{}{
  10197. "failed_code": -10,
  10198. "msg": errMsgs,
  10199. })
  10200. return
  10201. } else {
  10202. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10203. if his.IdCardType != 4 {
  10204. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10205. bas := strings.Split(psn_info.CardInfo, "|")
  10206. if his.IdCardType == 1 {
  10207. cert_no = bas[2]
  10208. } else {
  10209. cert_no = bas[1]
  10210. }
  10211. } else {
  10212. cert_no = his.Certno
  10213. }
  10214. //江苏地区国家医保医疗类别
  10215. //职工透析:医疗类别选特殊情况门诊9933
  10216. //居民血透门慢: 医疗类别选门诊慢病1402
  10217. //var med_type string
  10218. //if his.Insutype == "310" {
  10219. // if reg_type == 14 {
  10220. // med_type = "9933"
  10221. // } else if reg_type == 11 {
  10222. // med_type = "11"
  10223. //
  10224. // }
  10225. //} else if his.Insutype == "390" {
  10226. // if reg_type == 14 {
  10227. // med_type = "1402"
  10228. // } else if reg_type == 11 {
  10229. // med_type = "11"
  10230. // }
  10231. //}
  10232. var api string
  10233. if miConfig.MdtrtareaAdmvs == "320921" {
  10234. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10235. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10236. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10237. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10238. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10239. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10240. "&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
  10241. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10242. } else {
  10243. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10244. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10245. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10246. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10247. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10248. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10249. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10250. "&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
  10251. }
  10252. resp, requestErr := http.Get(api)
  10253. if requestErr != nil {
  10254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10255. return
  10256. }
  10257. body, ioErr := ioutil.ReadAll(resp.Body)
  10258. if ioErr != nil {
  10259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10261. return
  10262. }
  10263. var respJSON map[string]interface{}
  10264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10267. return
  10268. }
  10269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10270. result, _ := json.Marshal(respJSON)
  10271. fmt.Println("log")
  10272. fmt.Println(string(result))
  10273. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10274. utils.ErrorLog("解析失败:%v", err)
  10275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10276. return
  10277. }
  10278. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10279. res.Output = resSeven10265.Output
  10280. res.ErrMsg = resSeven10265.ErrMsg
  10281. res.Cainfo = resSeven10265.Cainfo
  10282. res.WarnMsg = resSeven10265.WarnMsg
  10283. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10284. res.Infcode = infocode
  10285. }
  10286. }
  10287. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10288. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  10289. var result string
  10290. var request_log string
  10291. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10292. 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)
  10293. } else {
  10294. 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)
  10295. }
  10296. var dat map[string]interface{}
  10297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10298. fmt.Println(dat)
  10299. } else {
  10300. fmt.Println(err)
  10301. }
  10302. saveLog(result, request_log, "2206", "预结算")
  10303. userJSONBytes, _ := json.Marshal(dat)
  10304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10305. utils.ErrorLog("解析失败:%v", err)
  10306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10307. return
  10308. }
  10309. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10310. var result string
  10311. var request_log string
  10312. if his.IdCardType == 2 {
  10313. 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, "")
  10314. } else if his.IdCardType == 1 {
  10315. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10316. bas := strings.Split(psn_info.CardInfo, "|")
  10317. basNumber := bas[2]
  10318. card_sn := bas[3]
  10319. 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)
  10320. } else {
  10321. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10322. 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, "")
  10323. }
  10324. var dat map[string]interface{}
  10325. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10326. fmt.Println(dat)
  10327. } else {
  10328. fmt.Println(err)
  10329. }
  10330. saveLog(result, request_log, "2206", "预结算")
  10331. userJSONBytes, _ := json.Marshal(dat)
  10332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10333. utils.ErrorLog("解析失败:%v", err)
  10334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10335. return
  10336. }
  10337. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10338. var result string
  10339. var request_log string
  10340. if his.IdCardType == 2 {
  10341. 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, "")
  10342. } else if his.IdCardType == 1 {
  10343. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10344. bas := strings.Split(psn_info.CardInfo, "|")
  10345. basNumber := bas[2]
  10346. card_sn := bas[3]
  10347. 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)
  10348. } else {
  10349. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10350. 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, "")
  10351. }
  10352. var dat map[string]interface{}
  10353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10354. fmt.Println(dat)
  10355. } else {
  10356. fmt.Println(err)
  10357. }
  10358. saveLog(result, request_log, "2206", "预结算")
  10359. userJSONBytes, _ := json.Marshal(dat)
  10360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10361. utils.ErrorLog("解析失败:%v", err)
  10362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10363. return
  10364. }
  10365. } else {
  10366. var result string
  10367. var request_log string
  10368. if miConfig.Code == "H15049901371" {
  10369. //赤峰地区国家医保医疗类别
  10370. //职工透析:医疗类别选特殊情况门诊990502
  10371. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10372. var med_type string
  10373. if his.Insutype == "390" {
  10374. if reg_type == 14 {
  10375. med_type = "9933"
  10376. } else if reg_type == 11 {
  10377. med_type = "11"
  10378. }
  10379. } else if his.Insutype == "310" {
  10380. if reg_type == 14 {
  10381. med_type = "990502"
  10382. } else if reg_type == 11 {
  10383. med_type = "11"
  10384. }
  10385. }
  10386. 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, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  10387. } else {
  10388. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10389. if his.IdCardType == 4 {
  10390. 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)
  10391. } else {
  10392. 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)
  10393. }
  10394. }
  10395. var dat map[string]interface{}
  10396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10397. fmt.Println(dat)
  10398. } else {
  10399. fmt.Println(err)
  10400. }
  10401. saveLog(result, request_log, "2206", "预结算")
  10402. //userJSONBytes, _ := json.Marshal(dat)
  10403. //
  10404. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10405. // utils.ErrorLog("解析失败:%v", err)
  10406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10407. // return
  10408. //}
  10409. userJSONBytes, _ := json.Marshal(dat)
  10410. if miConfig.Code == "H15049901371" {
  10411. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10412. utils.ErrorLog("解析失败:%v", err)
  10413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10414. return
  10415. }
  10416. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10417. res.Output = resSeven10265.Output
  10418. res.ErrMsg = resSeven10265.ErrMsg
  10419. res.Cainfo = resSeven10265.Cainfo
  10420. res.WarnMsg = resSeven10265.WarnMsg
  10421. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10422. res.Infcode = infocode
  10423. } else {
  10424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10425. utils.ErrorLog("解析失败:%v", err)
  10426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10427. return
  10428. }
  10429. }
  10430. }
  10431. if res.Infcode != 0 {
  10432. errlog := &models.HisOrderError{
  10433. UserOrgId: adminUser.CurrentOrgId,
  10434. Ctime: time.Now().Unix(),
  10435. Mtime: time.Now().Unix(),
  10436. Number: chrg_bchno,
  10437. ErrMsg: res.ErrMsg,
  10438. Status: 1,
  10439. PatientId: id,
  10440. RecordTime: recordDateTime,
  10441. Stage: 20,
  10442. }
  10443. service.CreateErrMsgLog(errlog)
  10444. c.ServeSuccessJSON(map[string]interface{}{
  10445. "failed_code": -10,
  10446. "msg": res.ErrMsg,
  10447. })
  10448. return
  10449. } else {
  10450. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10451. order.OrderStatus = 1
  10452. order.IsPre = 1
  10453. order.Status = 1
  10454. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10455. order.SetlId = res.Output.Setlinfo.SetlID
  10456. order.PsnNo = res.Output.Setlinfo.PsnNo
  10457. order.PsnName = res.Output.Setlinfo.PsnName
  10458. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10459. order.Certno = res.Output.Setlinfo.Certno
  10460. order.Gend = res.Output.Setlinfo.Gend
  10461. order.Naty = res.Output.Setlinfo.Naty
  10462. order.Age = res.Output.Setlinfo.Age
  10463. order.Insutype = res.Output.Setlinfo.Insutype
  10464. order.PsnType = res.Output.Setlinfo.PsnType
  10465. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10466. order.SetlTime = res.Output.Setlinfo.SetlTime
  10467. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10468. if res.Output.Setlinfo.MedType == "140101" {
  10469. order.MedType = "14"
  10470. } else {
  10471. order.MedType = res.Output.Setlinfo.MedType
  10472. }
  10473. if reg_type == 1112 {
  10474. order.MedType = "1112"
  10475. }
  10476. if reg_type == 1111 {
  10477. order.MedType = "1111"
  10478. }
  10479. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10480. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10481. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10482. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10483. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10484. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10485. order.HifpPay = res.Output.Setlinfo.HifpPay
  10486. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10487. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10488. order.HifesPay = res.Output.Setlinfo.HifesPay
  10489. order.HifobPay = res.Output.Setlinfo.HifobPay
  10490. order.MafPay = res.Output.Setlinfo.MafPay
  10491. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10492. order.OthPay = res.Output.Setlinfo.OthPay
  10493. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10494. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10495. order.AcctPay = res.Output.Setlinfo.AcctPay
  10496. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10497. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10498. order.Balc = res.Output.Setlinfo.Balc
  10499. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10500. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10501. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10502. order.ClrWay = res.Output.Setlinfo.ClrWay
  10503. order.Creator = order.Creator
  10504. order.Modify = roles.AdminUserId
  10505. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10506. detailStr := string(setlDetail)
  10507. order.SetlDetail = detailStr
  10508. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10509. err = service.UpDateOrder(order)
  10510. if err == nil {
  10511. c.ServeSuccessJSON(map[string]interface{}{
  10512. "msg": "预结算成功",
  10513. })
  10514. } else {
  10515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10516. return
  10517. }
  10518. }
  10519. } else {
  10520. adminUser := c.GetAdminUserInfo()
  10521. errlog := &models.HisOrderError{
  10522. UserOrgId: adminUser.CurrentOrgId,
  10523. Ctime: time.Now().Unix(),
  10524. Mtime: time.Now().Unix(),
  10525. ErrMsg: res.ErrMsg,
  10526. Status: 1,
  10527. PatientId: id,
  10528. RecordTime: recordDateTime,
  10529. Stage: 4,
  10530. }
  10531. service.CreateErrMsgLog(errlog)
  10532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10533. return
  10534. }
  10535. } else {
  10536. adminUser := c.GetAdminUserInfo()
  10537. errlog := &models.HisOrderError{
  10538. UserOrgId: adminUser.CurrentOrgId,
  10539. Ctime: time.Now().Unix(),
  10540. Mtime: time.Now().Unix(),
  10541. ErrMsg: res.ErrMsg,
  10542. Status: 1,
  10543. PatientId: id,
  10544. RecordTime: recordDateTime,
  10545. Stage: 4,
  10546. }
  10547. service.CreateErrMsgLog(errlog)
  10548. c.ServeSuccessJSON(map[string]interface{}{
  10549. "failed_code": -10,
  10550. "msg": res.ErrMsg,
  10551. })
  10552. return
  10553. }
  10554. }
  10555. }
  10556. }
  10557. //退款
  10558. func (c *HisApiController) Refund() {
  10559. order_id, _ := c.GetInt64("order_id")
  10560. admin_user_id, _ := c.GetInt64("admin_user_id")
  10561. adminUser := c.GetAdminUserInfo()
  10562. var order models.HisOrder
  10563. order, _ = service.GetHisOrderByID(order_id)
  10564. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10565. if order.ID == 0 {
  10566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10567. return
  10568. }
  10569. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10570. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10571. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10572. if config.IsOpen == 1 { //对接了医保,走医保流程
  10573. var res ResultSixteen
  10574. var resSixteen10265 ResultSixteen10265
  10575. var src_resquest string
  10576. var result string
  10577. if miConfig.MdtrtareaAdmvs == "421300" {
  10578. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  10579. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10580. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10581. resp3, requestErr3 := http.Get(api3)
  10582. if requestErr3 != nil {
  10583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10584. return
  10585. }
  10586. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10587. if ioErr3 != nil {
  10588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10590. return
  10591. }
  10592. var respJSON3 map[string]interface{}
  10593. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10596. return
  10597. }
  10598. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10599. userJSONBytes3, _ := json.Marshal(respJSON3)
  10600. fmt.Println("log")
  10601. fmt.Println(string(userJSONBytes3))
  10602. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  10603. utils.ErrorLog("解析失败:%v", err)
  10604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10605. return
  10606. }
  10607. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10608. var api3 string
  10609. if miConfig.MdtrtareaAdmvs == "320921" {
  10610. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10611. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10612. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10613. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10614. } else {
  10615. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10616. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10617. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10618. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10619. }
  10620. resp3, requestErr3 := http.Get(api3)
  10621. if requestErr3 != nil {
  10622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10623. return
  10624. }
  10625. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10626. if ioErr3 != nil {
  10627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10629. return
  10630. }
  10631. var respJSON3 map[string]interface{}
  10632. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10635. return
  10636. }
  10637. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10638. userJSONBytes3, _ := json.Marshal(respJSON3)
  10639. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  10640. utils.ErrorLog("解析失败:%v", err)
  10641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10642. return
  10643. }
  10644. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10645. res.Output = resSixteen10265.Output
  10646. res.ErrMsg = resSixteen10265.ErrMsg
  10647. res.Cainfo = resSixteen10265.Cainfo
  10648. res.WarnMsg = resSixteen10265.WarnMsg
  10649. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10650. res.Infcode = infocode
  10651. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10652. 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)
  10653. var dat map[string]interface{}
  10654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10655. fmt.Println(dat)
  10656. } else {
  10657. fmt.Println(err)
  10658. }
  10659. saveLog(result, src_resquest, "2208", "退费")
  10660. userJSONBytes, _ := json.Marshal(dat)
  10661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10662. utils.ErrorLog("解析失败:%v", err)
  10663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10664. return
  10665. }
  10666. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10667. 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, "")
  10668. var dat map[string]interface{}
  10669. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10670. fmt.Println(dat)
  10671. } else {
  10672. fmt.Println(err)
  10673. }
  10674. saveLog(result, src_resquest, "2208", "退费")
  10675. userJSONBytes, _ := json.Marshal(dat)
  10676. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10677. utils.ErrorLog("解析失败:%v", err)
  10678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10679. return
  10680. }
  10681. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10682. 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, "")
  10683. var dat map[string]interface{}
  10684. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10685. fmt.Println(dat)
  10686. } else {
  10687. fmt.Println(err)
  10688. }
  10689. saveLog(result, src_resquest, "2208", "退费")
  10690. userJSONBytes, _ := json.Marshal(dat)
  10691. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10692. utils.ErrorLog("解析失败:%v", err)
  10693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10694. return
  10695. }
  10696. } else {
  10697. if miConfig.Code == "H15049901371" {
  10698. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10699. var dat map[string]interface{}
  10700. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10701. fmt.Println(dat)
  10702. } else {
  10703. fmt.Println(err)
  10704. }
  10705. saveLog(result, src_resquest, "2208", "退费")
  10706. userJSONBytes, _ := json.Marshal(dat)
  10707. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10708. utils.ErrorLog("解析失败:%v", err)
  10709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10710. return
  10711. }
  10712. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10713. res.Output = resSixteen10265.Output
  10714. res.ErrMsg = resSixteen10265.ErrMsg
  10715. res.Cainfo = resSixteen10265.Cainfo
  10716. res.WarnMsg = resSixteen10265.WarnMsg
  10717. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10718. res.Infcode = infocode
  10719. } else {
  10720. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10721. var dat map[string]interface{}
  10722. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10723. fmt.Println(dat)
  10724. } else {
  10725. fmt.Println(err)
  10726. }
  10727. saveLog(result, src_resquest, "2208", "退费")
  10728. userJSONBytes, _ := json.Marshal(dat)
  10729. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10730. utils.ErrorLog("解析失败:%v", err)
  10731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10732. return
  10733. }
  10734. }
  10735. }
  10736. if res.Infcode == 0 {
  10737. var res2 ResultSix
  10738. var resSix10265 ResultSix10265
  10739. if miConfig.MdtrtareaAdmvs == "421300" {
  10740. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10741. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10742. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10743. resp3, requestErr3 := http.Get(api3)
  10744. if requestErr3 != nil {
  10745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10746. return
  10747. }
  10748. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10749. if ioErr3 != nil {
  10750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10752. return
  10753. }
  10754. var respJSON3 map[string]interface{}
  10755. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10758. return
  10759. }
  10760. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10761. userJSONBytes3, _ := json.Marshal(respJSON3)
  10762. fmt.Println("log")
  10763. fmt.Println(string(userJSONBytes3))
  10764. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10765. utils.ErrorLog("解析失败:%v", err)
  10766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10767. return
  10768. }
  10769. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10770. var api3 string
  10771. if miConfig.MdtrtareaAdmvs == "320921" {
  10772. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10773. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10774. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10775. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10776. } else {
  10777. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10778. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10779. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10780. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10781. }
  10782. resp3, requestErr3 := http.Get(api3)
  10783. if requestErr3 != nil {
  10784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10785. return
  10786. }
  10787. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10788. if ioErr3 != nil {
  10789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10791. return
  10792. }
  10793. var respJSON3 map[string]interface{}
  10794. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10797. return
  10798. }
  10799. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10800. userJSONBytes3, _ := json.Marshal(respJSON3)
  10801. fmt.Println("log")
  10802. fmt.Println(string(userJSONBytes3))
  10803. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10804. utils.ErrorLog("解析失败:%v", err)
  10805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10806. return
  10807. }
  10808. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10809. res2.Output = resSix10265.Output
  10810. res2.ErrMsg = resSix10265.ErrMsg
  10811. res2.Cainfo = resSix10265.Cainfo
  10812. res2.WarnMsg = resSix10265.WarnMsg
  10813. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10814. res2.Infcode = infocode
  10815. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10816. 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)
  10817. var dat map[string]interface{}
  10818. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10819. fmt.Println(dat)
  10820. } else {
  10821. fmt.Println(err)
  10822. }
  10823. saveLog(result2, src_request, "2205", "撤销明细")
  10824. userJSONBytes, _ := json.Marshal(dat)
  10825. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10826. utils.ErrorLog("解析失败:%v", err)
  10827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10828. return
  10829. }
  10830. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10831. 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, "")
  10832. var dat map[string]interface{}
  10833. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10834. fmt.Println(dat)
  10835. } else {
  10836. fmt.Println(err)
  10837. }
  10838. saveLog(result2, src_request, "2205", "撤销明细")
  10839. userJSONBytes, _ := json.Marshal(dat)
  10840. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10841. utils.ErrorLog("解析失败:%v", err)
  10842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10843. return
  10844. }
  10845. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10846. 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, "")
  10847. var dat map[string]interface{}
  10848. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10849. fmt.Println(dat)
  10850. } else {
  10851. fmt.Println(err)
  10852. }
  10853. saveLog(result2, src_request, "2205", "撤销明细")
  10854. userJSONBytes, _ := json.Marshal(dat)
  10855. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10856. utils.ErrorLog("解析失败:%v", err)
  10857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10858. return
  10859. }
  10860. } else {
  10861. if miConfig.Code == "H15049901371" {
  10862. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10863. var dat map[string]interface{}
  10864. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10865. fmt.Println(dat)
  10866. } else {
  10867. fmt.Println(err)
  10868. }
  10869. saveLog(result2, src_request, "2205", "撤销明细")
  10870. userJSONBytes, _ := json.Marshal(dat)
  10871. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10872. utils.ErrorLog("解析失败:%v", err)
  10873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10874. return
  10875. }
  10876. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10877. res2.Output = resSix10265.Output
  10878. res2.ErrMsg = resSix10265.ErrMsg
  10879. res2.Cainfo = resSix10265.Cainfo
  10880. res2.WarnMsg = resSix10265.WarnMsg
  10881. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10882. res2.Infcode = infocode
  10883. } else {
  10884. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10885. var dat map[string]interface{}
  10886. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10887. fmt.Println(dat)
  10888. } else {
  10889. fmt.Println(err)
  10890. }
  10891. saveLog(result2, src_request, "2205", "撤销明细")
  10892. userJSONBytes, _ := json.Marshal(dat)
  10893. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10894. utils.ErrorLog("解析失败:%v", err)
  10895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10896. return
  10897. }
  10898. }
  10899. }
  10900. if res2.Infcode == 0 {
  10901. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10902. if err == nil {
  10903. //当押金不为零时产生退费记录
  10904. if order.Decimal != 0 {
  10905. tmp := strconv.FormatInt(order.ID, 10)
  10906. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10907. if err != nil {
  10908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10909. return
  10910. }
  10911. }
  10912. c.ServeSuccessJSON(map[string]interface{}{
  10913. "msg": "退费成功",
  10914. })
  10915. } else {
  10916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10917. return
  10918. }
  10919. } else {
  10920. c.ServeSuccessJSON(map[string]interface{}{
  10921. "code": -10,
  10922. "msg": res2.ErrMsg,
  10923. })
  10924. }
  10925. } else {
  10926. c.ServeSuccessJSON(map[string]interface{}{
  10927. "code": -10,
  10928. "msg": res.ErrMsg,
  10929. })
  10930. }
  10931. }
  10932. }
  10933. func (c *HisApiController) RefundNumber() {
  10934. record_time := c.GetString("record_time")
  10935. //patient_id, _ := c.GetInt64("patient_id")
  10936. admin_user_id, _ := c.GetInt64("admin_user_id")
  10937. his_patient_id, _ := c.GetInt64("id")
  10938. timeLayout := "2006-01-02"
  10939. loc, _ := time.LoadLocation("Local")
  10940. adminUser := c.GetAdminUserInfo()
  10941. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10942. fmt.Println(err)
  10943. if err != nil {
  10944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10945. return
  10946. }
  10947. recordDateTime := theTime.Unix()
  10948. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10949. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10950. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10951. //order, _ := service.GetHisOrderByID(order_id)
  10952. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10953. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10954. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10955. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10956. if count > 0 {
  10957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10958. return
  10959. }
  10960. if config.IsOpen == 1 { //对接了医保,走医保流程
  10961. var res2 ResultSix
  10962. var resSix10265 ResultSix10265
  10963. if miConfig.MdtrtareaAdmvs == "421300" {
  10964. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10965. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10966. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10967. resp3, requestErr3 := http.Get(api3)
  10968. if requestErr3 != nil {
  10969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10970. return
  10971. }
  10972. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10973. if ioErr3 != nil {
  10974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10976. return
  10977. }
  10978. var respJSON3 map[string]interface{}
  10979. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10982. return
  10983. }
  10984. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10985. userJSONBytes3, _ := json.Marshal(respJSON3)
  10986. fmt.Println("log")
  10987. fmt.Println(string(userJSONBytes3))
  10988. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10989. utils.ErrorLog("解析失败:%v", err)
  10990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10991. return
  10992. }
  10993. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10994. var api3 string
  10995. if miConfig.MdtrtareaAdmvs == "320921" {
  10996. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10997. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10998. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10999. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11000. } else {
  11001. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11002. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  11003. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11004. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11005. }
  11006. resp3, requestErr3 := http.Get(api3)
  11007. if requestErr3 != nil {
  11008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11009. return
  11010. }
  11011. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11012. if ioErr3 != nil {
  11013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11015. return
  11016. }
  11017. var respJSON3 map[string]interface{}
  11018. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11021. return
  11022. }
  11023. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11024. userJSONBytes3, _ := json.Marshal(respJSON3)
  11025. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11026. utils.ErrorLog("解析失败:%v", err)
  11027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11028. return
  11029. }
  11030. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11031. res2.Output = resSix10265.Output
  11032. res2.ErrMsg = resSix10265.ErrMsg
  11033. res2.Cainfo = resSix10265.Cainfo
  11034. res2.WarnMsg = resSix10265.WarnMsg
  11035. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11036. res2.Infcode = infocode
  11037. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11038. 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)
  11039. var dat map[string]interface{}
  11040. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11041. fmt.Println(dat)
  11042. } else {
  11043. fmt.Println(err)
  11044. }
  11045. saveLog(result, request, "2202", "退号")
  11046. userJSONBytes, _ := json.Marshal(dat)
  11047. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11048. utils.ErrorLog("解析失败:%v", err)
  11049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11050. return
  11051. }
  11052. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11053. 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, "")
  11054. var dat map[string]interface{}
  11055. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11056. fmt.Println(dat)
  11057. } else {
  11058. fmt.Println(err)
  11059. }
  11060. saveLog(result, request, "2202", "退号")
  11061. userJSONBytes, _ := json.Marshal(dat)
  11062. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11063. utils.ErrorLog("解析失败:%v", err)
  11064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11065. return
  11066. }
  11067. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11068. 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, "")
  11069. var dat map[string]interface{}
  11070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11071. fmt.Println(dat)
  11072. } else {
  11073. fmt.Println(err)
  11074. }
  11075. saveLog(result, request, "2202", "退号")
  11076. userJSONBytes, _ := json.Marshal(dat)
  11077. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11078. utils.ErrorLog("解析失败:%v", err)
  11079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11080. return
  11081. }
  11082. } else {
  11083. var api3 string
  11084. if miConfig.Code == "H15049901371" {
  11085. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11086. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11087. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11088. } else {
  11089. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11090. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11091. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11092. }
  11093. resp3, requestErr3 := http.Get(api3)
  11094. if requestErr3 != nil {
  11095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11096. return
  11097. }
  11098. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11099. if ioErr3 != nil {
  11100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11102. return
  11103. }
  11104. var respJSON3 map[string]interface{}
  11105. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11108. return
  11109. }
  11110. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11111. userJSONBytes3, _ := json.Marshal(respJSON3)
  11112. if miConfig.Code == "H15049901371" {
  11113. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11114. utils.ErrorLog("解析失败:%v", err)
  11115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11116. return
  11117. }
  11118. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11119. res2.Output = resSix10265.Output
  11120. res2.ErrMsg = resSix10265.ErrMsg
  11121. res2.Cainfo = resSix10265.Cainfo
  11122. res2.WarnMsg = resSix10265.WarnMsg
  11123. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11124. res2.Infcode = infocode
  11125. } else {
  11126. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11127. utils.ErrorLog("解析失败:%v", err)
  11128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11129. return
  11130. }
  11131. }
  11132. }
  11133. if res2.Infcode == 0 {
  11134. if err == nil {
  11135. c.ServeSuccessJSON(map[string]interface{}{
  11136. "msg": "退号成功",
  11137. })
  11138. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  11139. } else {
  11140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11141. return
  11142. }
  11143. } else {
  11144. c.ServeSuccessJSON(map[string]interface{}{
  11145. "code": -10,
  11146. "msg": res2.ErrMsg,
  11147. })
  11148. }
  11149. } else {
  11150. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  11151. //if err == nil {
  11152. // c.ServeSuccessJSON(map[string]interface{}{
  11153. // "msg": "退费成功",
  11154. // })
  11155. //} else {
  11156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11157. // return
  11158. //}
  11159. }
  11160. }
  11161. func (c *HisApiController) RefundDetail() {
  11162. order_id, _ := c.GetInt64("order_id")
  11163. admin_user_id, _ := c.GetInt64("admin_user_id")
  11164. //his_patient_id, _ := c.GetInt64("his_patient_id")
  11165. number := c.GetString("number")
  11166. record_time := c.GetString("record_time")
  11167. patient_id, _ := c.GetInt64("patient_id")
  11168. //med_type, _ := c.GetInt64("med_type")
  11169. timeLayout := "2006-01-02"
  11170. loc, _ := time.LoadLocation("Local")
  11171. adminUser := c.GetAdminUserInfo()
  11172. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11173. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11174. fmt.Println(err)
  11175. if err != nil {
  11176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11177. return
  11178. }
  11179. recordDateTime := theTime.Unix()
  11180. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11181. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11182. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11183. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11184. var order models.HisOrder
  11185. order, _ = service.GetHisOrderByID(order_id)
  11186. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11187. if config.IsOpen == 1 { //对接了医保,走医保流程
  11188. var res2 ResultSix
  11189. if miConfig.MdtrtareaAdmvs == "421300" {
  11190. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11191. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11192. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11193. resp3, requestErr3 := http.Get(api3)
  11194. if requestErr3 != nil {
  11195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11196. return
  11197. }
  11198. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11199. if ioErr3 != nil {
  11200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11202. return
  11203. }
  11204. var respJSON3 map[string]interface{}
  11205. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11208. return
  11209. }
  11210. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11211. userJSONBytes3, _ := json.Marshal(respJSON3)
  11212. fmt.Println("log")
  11213. fmt.Println(string(userJSONBytes3))
  11214. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11215. utils.ErrorLog("解析失败:%v", err)
  11216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11217. return
  11218. }
  11219. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11220. if err == nil {
  11221. c.ServeSuccessJSON(map[string]interface{}{
  11222. "msg": "撤销明细成功",
  11223. })
  11224. return
  11225. } else {
  11226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11227. return
  11228. }
  11229. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11230. var resSix10265 ResultSix10265
  11231. var api3 string
  11232. if miConfig.MdtrtareaAdmvs == "320921" {
  11233. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11234. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11235. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11236. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11237. } else {
  11238. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11239. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11240. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11241. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11242. }
  11243. resp3, requestErr3 := http.Get(api3)
  11244. if requestErr3 != nil {
  11245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11246. return
  11247. }
  11248. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11249. if ioErr3 != nil {
  11250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11252. return
  11253. }
  11254. var respJSON3 map[string]interface{}
  11255. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11258. return
  11259. }
  11260. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11261. userJSONBytes3, _ := json.Marshal(respJSON3)
  11262. fmt.Println("log")
  11263. fmt.Println(string(userJSONBytes3))
  11264. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11265. utils.ErrorLog("解析失败:%v", err)
  11266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11267. return
  11268. }
  11269. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11270. res2.Output = resSix10265.Output
  11271. res2.ErrMsg = resSix10265.ErrMsg
  11272. res2.Cainfo = resSix10265.Cainfo
  11273. res2.WarnMsg = resSix10265.WarnMsg
  11274. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11275. res2.Infcode = infocode
  11276. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11277. if err == nil {
  11278. c.ServeSuccessJSON(map[string]interface{}{
  11279. "msg": "撤销明细成功",
  11280. })
  11281. return
  11282. } else {
  11283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11284. return
  11285. }
  11286. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11287. 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)
  11288. var dat map[string]interface{}
  11289. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11290. fmt.Println(dat)
  11291. } else {
  11292. fmt.Println(err)
  11293. }
  11294. saveLog(result2, src_request, "2205", "撤销明细")
  11295. userJSONBytes, _ := json.Marshal(dat)
  11296. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11297. utils.ErrorLog("解析失败:%v", err)
  11298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11299. return
  11300. }
  11301. if res2.Infcode == 0 {
  11302. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11303. if err == nil {
  11304. c.ServeSuccessJSON(map[string]interface{}{
  11305. "msg": "撤销明细成功",
  11306. })
  11307. return
  11308. } else {
  11309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11310. return
  11311. }
  11312. } else {
  11313. c.ServeSuccessJSON(map[string]interface{}{
  11314. "code": -10,
  11315. "msg": res2.ErrMsg,
  11316. })
  11317. }
  11318. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11319. 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, "")
  11320. var dat map[string]interface{}
  11321. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11322. fmt.Println(dat)
  11323. } else {
  11324. fmt.Println(err)
  11325. }
  11326. saveLog(result2, src_request, "2205", "撤销明细")
  11327. userJSONBytes, _ := json.Marshal(dat)
  11328. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11329. utils.ErrorLog("解析失败:%v", err)
  11330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11331. return
  11332. }
  11333. if res2.Infcode == 0 {
  11334. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11335. if err == nil {
  11336. c.ServeSuccessJSON(map[string]interface{}{
  11337. "msg": "撤销明细成功",
  11338. })
  11339. return
  11340. } else {
  11341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11342. return
  11343. }
  11344. } else {
  11345. c.ServeSuccessJSON(map[string]interface{}{
  11346. "code": -10,
  11347. "msg": res2.ErrMsg,
  11348. })
  11349. }
  11350. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11351. 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, "")
  11352. var dat map[string]interface{}
  11353. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11354. fmt.Println(dat)
  11355. } else {
  11356. fmt.Println(err)
  11357. }
  11358. saveLog(result2, src_request, "2205", "撤销明细")
  11359. userJSONBytes, _ := json.Marshal(dat)
  11360. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11361. utils.ErrorLog("解析失败:%v", err)
  11362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11363. return
  11364. }
  11365. if res2.Infcode == 0 {
  11366. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11367. if err == nil {
  11368. c.ServeSuccessJSON(map[string]interface{}{
  11369. "msg": "撤销明细成功",
  11370. })
  11371. return
  11372. } else {
  11373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11374. return
  11375. }
  11376. } else {
  11377. c.ServeSuccessJSON(map[string]interface{}{
  11378. "code": -10,
  11379. "msg": res2.ErrMsg,
  11380. })
  11381. }
  11382. } else {
  11383. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11384. "&mdtrt_id=" + his.Number + "&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
  11386. resp2, requestErr2 := http.Get(api2)
  11387. if requestErr2 != nil {
  11388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11389. return
  11390. }
  11391. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11392. if ioErr2 != nil {
  11393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11395. return
  11396. }
  11397. var respJSON2 map[string]interface{}
  11398. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  11399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11401. return
  11402. }
  11403. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11404. if err == nil {
  11405. c.ServeSuccessJSON(map[string]interface{}{
  11406. "msg": "撤销明细成功",
  11407. })
  11408. return
  11409. } else {
  11410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11411. return
  11412. }
  11413. }
  11414. } else {
  11415. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11416. if err == nil {
  11417. c.ServeSuccessJSON(map[string]interface{}{
  11418. "msg": "退费成功",
  11419. })
  11420. } else {
  11421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11422. return
  11423. }
  11424. }
  11425. }
  11426. //对账
  11427. func (c *HisApiController) GetCheckAccount() {
  11428. start_time := c.GetString("start_time")
  11429. end_time := c.GetString("end_time")
  11430. insutype := c.GetString("insutype")
  11431. clr_type := c.GetString("clr_type")
  11432. clr_org := c.GetString("clr_optins")
  11433. admin_user_id, _ := c.GetInt64("admin_user_id")
  11434. adminUser := c.GetAdminUserInfo()
  11435. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11436. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11437. if len(clr_org) == 0 {
  11438. clr_org = miConfig.MdtrtareaAdmvs
  11439. }
  11440. timeLayout := "2006-01-02"
  11441. loc, _ := time.LoadLocation("Local")
  11442. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11443. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11444. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  11445. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  11446. fixmedins_setl_cnt := int64(len(orders))
  11447. var medfee_sumamt float64
  11448. var acct_pay float64
  11449. var fund_pay_sumamt float64
  11450. for _, item := range orders {
  11451. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11452. acct_pay = acct_pay + item.AcctPay
  11453. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11454. }
  11455. var user_name string
  11456. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11457. if role.ID == 0 {
  11458. user_name = "xxx"
  11459. } else {
  11460. user_name = role.UserName
  11461. }
  11462. var res ResultEight
  11463. var res10188 ResultEightFor10188
  11464. if config.IsOpen == 1 {
  11465. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11466. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  11467. "insutype=" + insutype +
  11468. "&clr_type=" + clr_type +
  11469. "&setl_optins=" + clr_org +
  11470. "&stmt_begndate=" + start_time +
  11471. "&stm_enddate=" + end_time +
  11472. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11473. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11474. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11475. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11476. "&fixmedins_code=" + miConfig.Code +
  11477. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11478. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11479. "&secret_key=" + miConfig.SecretKey +
  11480. "&org_name=" + miConfig.OrgName +
  11481. "&doctor=" + user_name +
  11482. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11483. fmt.Println(api)
  11484. resp, requestErr := http.Get(api)
  11485. if requestErr != nil {
  11486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11487. return
  11488. }
  11489. body, ioErr := ioutil.ReadAll(resp.Body)
  11490. fmt.Println(body)
  11491. if ioErr != nil {
  11492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11494. return
  11495. }
  11496. var respJSON map[string]interface{}
  11497. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11500. return
  11501. }
  11502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11503. userJSONBytes, _ := json.Marshal(respJSON)
  11504. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11505. utils.ErrorLog("解析失败:%v", err)
  11506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11507. return
  11508. }
  11509. res.InfRefmsgid = res10188.InfRefmsgid
  11510. res.Output = res10188.Output
  11511. res.ErrMsg = res10188.ErrMsg
  11512. res.Cainfo = res10188.Cainfo
  11513. res.WarnMsg = res10188.WarnMsg
  11514. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11515. res.Infcode = infocode
  11516. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11517. if clr_type == "11" {
  11518. fixmedins_setl_cnt = 2
  11519. }
  11520. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  11521. "insutype=" + insutype +
  11522. "&clr_type=" + clr_type +
  11523. "&setl_optins=" + clr_org +
  11524. "&stmt_begndate=" + start_time +
  11525. "&stm_enddate=" + end_time +
  11526. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11527. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11528. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11529. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11530. "&fixmedins_code=" + miConfig.Code +
  11531. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11532. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11533. "&secret_key=" + miConfig.SecretKey +
  11534. "&org_name=" + miConfig.OrgName +
  11535. "&doctor=" + user_name
  11536. resp, requestErr := http.Get(api)
  11537. if requestErr != nil {
  11538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11539. return
  11540. }
  11541. body, ioErr := ioutil.ReadAll(resp.Body)
  11542. if ioErr != nil {
  11543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11545. return
  11546. }
  11547. var respJSON map[string]interface{}
  11548. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11551. return
  11552. }
  11553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11554. result, _ := json.Marshal(respJSON)
  11555. fmt.Println("log")
  11556. fmt.Println(string(result))
  11557. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  11558. utils.ErrorLog("解析失败:%v", err)
  11559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11560. return
  11561. }
  11562. res.InfRefmsgid = res10188.InfRefmsgid
  11563. res.Output = res10188.Output
  11564. res.ErrMsg = res10188.ErrMsg
  11565. res.Cainfo = res10188.Cainfo
  11566. res.WarnMsg = res10188.WarnMsg
  11567. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11568. res.Infcode = infocode
  11569. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11570. var baseParams models.BaseParams
  11571. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11572. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11573. baseParams.SecretKey = miConfig.SecretKey
  11574. baseParams.OrgName = miConfig.OrgName
  11575. baseParams.FixmedinsCode = miConfig.Code
  11576. baseParams.EncKey = miConfig.EncKey
  11577. baseParams.AppSecret = miConfig.AppSecret
  11578. baseParams.SignKey = miConfig.SignKey
  11579. baseParams.AppID = miConfig.Code
  11580. baseParams.Doctor = role.UserName
  11581. baseParams.RequestUrl = miConfig.Url
  11582. businessParams := models.BusinessParams{
  11583. Insutype: insutype,
  11584. ClrType: clr_type,
  11585. SetlOptins: clr_org,
  11586. StmtBegndate: start_time,
  11587. StmtEnddate: end_time,
  11588. MedfeeSumamt: medfee_sumamt,
  11589. FundPaySumamt: fund_pay_sumamt,
  11590. AcctPay: acct_pay,
  11591. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11592. }
  11593. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11594. fmt.Println(requestLog)
  11595. fmt.Println(result)
  11596. fmt.Println(err_msg)
  11597. var dat map[string]interface{}
  11598. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11599. fmt.Println(dat)
  11600. } else {
  11601. fmt.Println(err)
  11602. }
  11603. userJSONBytes, _ := json.Marshal(dat)
  11604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11605. utils.ErrorLog("解析失败:%v", err)
  11606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11607. return
  11608. }
  11609. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11610. var baseParams models.BaseParams
  11611. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11612. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11613. baseParams.SecretKey = miConfig.SecretKey
  11614. baseParams.OrgName = miConfig.OrgName
  11615. baseParams.FixmedinsCode = miConfig.Code
  11616. baseParams.EncKey = miConfig.EncKey
  11617. baseParams.AppSecret = miConfig.AppSecret
  11618. baseParams.SignKey = miConfig.SignKey
  11619. baseParams.AppID = miConfig.Code
  11620. baseParams.Doctor = role.UserName
  11621. baseParams.RequestUrl = miConfig.Url
  11622. baseParams.AccessKey = miConfig.AccessKey
  11623. businessParams := models.BusinessParams{
  11624. Insutype: insutype,
  11625. ClrType: clr_type,
  11626. SetlOptins: "430822",
  11627. StmtBegndate: start_time,
  11628. StmtEnddate: end_time,
  11629. MedfeeSumamt: medfee_sumamt,
  11630. FundPaySumamt: fund_pay_sumamt,
  11631. AcctPay: acct_pay,
  11632. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11633. }
  11634. 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)
  11635. fmt.Println(requestLog)
  11636. fmt.Println(result)
  11637. var dat map[string]interface{}
  11638. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11639. fmt.Println(dat)
  11640. } else {
  11641. fmt.Println(err)
  11642. }
  11643. userJSONBytes, _ := json.Marshal(dat)
  11644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11645. utils.ErrorLog("解析失败:%v", err)
  11646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11647. return
  11648. }
  11649. } else if miConfig.MdtrtareaAdmvs == "" {
  11650. var baseParams models.BaseParams
  11651. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11652. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11653. baseParams.SecretKey = miConfig.SecretKey
  11654. baseParams.OrgName = miConfig.OrgName
  11655. baseParams.FixmedinsCode = miConfig.Code
  11656. baseParams.EncKey = miConfig.EncKey
  11657. baseParams.AppSecret = miConfig.AppSecret
  11658. baseParams.SignKey = miConfig.SignKey
  11659. baseParams.AppID = miConfig.Code
  11660. baseParams.Doctor = role.UserName
  11661. baseParams.RequestUrl = miConfig.Url
  11662. businessParams := models.BusinessParams{
  11663. Insutype: insutype,
  11664. ClrType: clr_type,
  11665. SetlOptins: clr_org,
  11666. StmtBegndate: start_time,
  11667. StmtEnddate: end_time,
  11668. MedfeeSumamt: medfee_sumamt,
  11669. FundPaySumamt: fund_pay_sumamt,
  11670. AcctPay: acct_pay,
  11671. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11672. }
  11673. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11674. fmt.Println(requestLog)
  11675. fmt.Println(result)
  11676. fmt.Println(err_msg)
  11677. var dat map[string]interface{}
  11678. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11679. fmt.Println(dat)
  11680. } else {
  11681. fmt.Println(err)
  11682. }
  11683. userJSONBytes, _ := json.Marshal(dat)
  11684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11685. utils.ErrorLog("解析失败:%v", err)
  11686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11687. return
  11688. }
  11689. } else {
  11690. if len(clr_type) == 0 {
  11691. clr_type = "11"
  11692. }
  11693. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11694. "insutype=" + insutype +
  11695. "&clr_type=" + clr_type +
  11696. "&setl_optins=" + clr_org +
  11697. "&stmt_begndate=" + start_time +
  11698. "&stm_enddate=" + end_time +
  11699. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11700. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11701. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11702. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11703. "&fixmedins_code=" + miConfig.Code +
  11704. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11705. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11706. "&secret_key=" + miConfig.SecretKey +
  11707. "&org_name=" + miConfig.OrgName +
  11708. "&doctor=" + user_name
  11709. fmt.Println(api)
  11710. resp, requestErr := http.Get(api)
  11711. if requestErr != nil {
  11712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11713. return
  11714. }
  11715. body, ioErr := ioutil.ReadAll(resp.Body)
  11716. fmt.Println(body)
  11717. if ioErr != nil {
  11718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11720. return
  11721. }
  11722. var respJSON map[string]interface{}
  11723. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11726. return
  11727. }
  11728. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11729. userJSONBytes, _ := json.Marshal(respJSON)
  11730. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11731. utils.ErrorLog("解析失败:%v", err)
  11732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11733. return
  11734. }
  11735. }
  11736. if res.Infcode == 0 {
  11737. if res.Output.Stmtinfo.StmtRslt == "0" {
  11738. micc := &models.MedicalInsuranceCostCompare{
  11739. StartTime: startime.Unix(),
  11740. EndTime: endtime.Unix(),
  11741. Insutype: insutype,
  11742. CheckType: 1,
  11743. Num: fixmedins_setl_cnt,
  11744. Mtime: time.Now().Unix(),
  11745. Status: 1,
  11746. UserOrgId: adminUser.CurrentOrgId,
  11747. CostTotal: medfee_sumamt,
  11748. FuncTotal: fund_pay_sumamt,
  11749. PsnPay: acct_pay,
  11750. Creator: admin_user_id,
  11751. Ctime: time.Now().Unix(),
  11752. ClrType: clr_type,
  11753. }
  11754. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11755. if err == nil {
  11756. c.ServeSuccessJSON(map[string]interface{}{
  11757. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11758. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11759. })
  11760. } else {
  11761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11762. }
  11763. } else {
  11764. c.ServeSuccessJSON(map[string]interface{}{
  11765. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11766. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11767. })
  11768. }
  11769. } else {
  11770. c.ServeSuccessJSON(map[string]interface{}{
  11771. "code": -10,
  11772. "msg": res.ErrMsg,
  11773. })
  11774. }
  11775. }
  11776. }
  11777. func (c *HisApiController) Check310() {
  11778. adminUser := c.GetAdminUserInfo()
  11779. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11780. var user_name string
  11781. user_name = "高慧裕"
  11782. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11783. "insutype=" + "310" +
  11784. "&clr_type=" + "" +
  11785. "&setl_optins=" + "441202" +
  11786. "&stmt_begndate=" + "2022-03-01" +
  11787. "&stm_enddate=" + "2022-03-31" +
  11788. "&medfee_sumamt=" + "194930.12" +
  11789. "&fund_pay_sumamt=" + "188741.46" +
  11790. "&acct_pay=" + "0" +
  11791. "&fixmedins_setl_cnt=" + "452" +
  11792. "&fixmedins_code=" + miConfig.Code +
  11793. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11794. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11795. "&secret_key=" + miConfig.SecretKey +
  11796. "&org_name=" + miConfig.OrgName +
  11797. "&doctor=" + user_name
  11798. fmt.Println(api)
  11799. resp, requestErr := http.Get(api)
  11800. if requestErr != nil {
  11801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11802. return
  11803. }
  11804. body, ioErr := ioutil.ReadAll(resp.Body)
  11805. fmt.Println(body)
  11806. if ioErr != nil {
  11807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11809. return
  11810. }
  11811. var respJSON map[string]interface{}
  11812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11815. return
  11816. }
  11817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11818. userJSONBytes, _ := json.Marshal(respJSON)
  11819. var res ResultEight
  11820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11821. utils.ErrorLog("解析失败:%v", err)
  11822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11823. return
  11824. }
  11825. }
  11826. func (c *HisApiController) Check390() {
  11827. adminUser := c.GetAdminUserInfo()
  11828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11829. var user_name string
  11830. user_name = "高慧裕"
  11831. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11832. "insutype=" + "390" +
  11833. "&clr_type=" + "" +
  11834. "&setl_optins=" + "441202" +
  11835. "&stmt_begndate=" + "2022-03-01" +
  11836. "&stm_enddate=" + "2022-03-31" +
  11837. "&medfee_sumamt=" + "1068448.89" +
  11838. "&fund_pay_sumamt=" + "1014677.62" +
  11839. "&acct_pay=" + "0" +
  11840. "&fixmedins_setl_cnt=" + "1950" +
  11841. "&fixmedins_code=" + miConfig.Code +
  11842. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11843. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11844. "&secret_key=" + miConfig.SecretKey +
  11845. "&org_name=" + miConfig.OrgName +
  11846. "&doctor=" + user_name
  11847. fmt.Println(api)
  11848. resp, requestErr := http.Get(api)
  11849. if requestErr != nil {
  11850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11851. return
  11852. }
  11853. body, ioErr := ioutil.ReadAll(resp.Body)
  11854. fmt.Println(body)
  11855. if ioErr != nil {
  11856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11858. return
  11859. }
  11860. var respJSON map[string]interface{}
  11861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11864. return
  11865. }
  11866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11867. userJSONBytes, _ := json.Marshal(respJSON)
  11868. var res ResultEight
  11869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11870. utils.ErrorLog("解析失败:%v", err)
  11871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11872. return
  11873. }
  11874. }
  11875. //对账明细
  11876. func (c *HisApiController) GetCheckDetailAccount() {
  11877. start_time := c.GetString("start_time")
  11878. end_time := c.GetString("end_time")
  11879. admin_user_id, _ := c.GetInt64("admin_user_id")
  11880. adminUser := c.GetAdminUserInfo()
  11881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11882. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11883. timeLayout := "2006-01-02"
  11884. loc, _ := time.LoadLocation("Local")
  11885. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11886. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11887. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11888. rand.Seed(time.Now().UnixNano())
  11889. num := rand.Intn(30000)
  11890. Mkdir(miConfig.OrgName)
  11891. file := strconv.FormatInt(int64(num), 10)
  11892. file_name := file + ".txt"
  11893. zip_name := file + ".zip"
  11894. zip_path := miConfig.OrgName + "/" + zip_name
  11895. file_path := miConfig.OrgName + "/" + file_name
  11896. decimal.DivisionPrecision = 2
  11897. var medfee_sumamt float64
  11898. var psn_cash_pay float64
  11899. var fund_pay_sumamt float64
  11900. fixmedins_setl_cnt := int64(len(orders))
  11901. for _, item := range orders {
  11902. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11903. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11904. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11905. }
  11906. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11907. defer f.Close()
  11908. if err != nil {
  11909. fmt.Println(err.Error())
  11910. } else {
  11911. for _, item := range orders {
  11912. var refd_setl_flag string
  11913. if item.OrderStatus == 2 {
  11914. refd_setl_flag = "0"
  11915. var str string
  11916. str = item.SetlId + " " +
  11917. item.MdtrtId + " " +
  11918. item.PsnNo + " " +
  11919. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11920. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11921. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11922. _, err = f.Write([]byte(str))
  11923. }
  11924. if item.OrderStatus == 3 {
  11925. var str string
  11926. str = item.SetlId + " " +
  11927. item.MdtrtId + " " +
  11928. item.PsnNo + " " +
  11929. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11930. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11931. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11932. _, err = f.Write([]byte(str))
  11933. var str2 string
  11934. str2 = item.SetlId + " " +
  11935. item.MdtrtId + " " +
  11936. item.PsnNo + " " +
  11937. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11938. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11939. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11940. _, err = f.Write([]byte(str2))
  11941. }
  11942. }
  11943. }
  11944. Zip(file_path, zip_path)
  11945. fmt.Println(ReadFile(zip_path))
  11946. fmt.Println(string(ReadFile(zip_path)))
  11947. if config.IsOpen == 1 {
  11948. var user_name string
  11949. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11950. if role.ID == 0 {
  11951. user_name = "管理员"
  11952. } else {
  11953. user_name = role.UserName
  11954. }
  11955. baseParams := models.BaseParams{
  11956. SecretKey: miConfig.SecretKey,
  11957. FixmedinsCode: miConfig.Code,
  11958. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11959. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11960. OrgName: miConfig.OrgName,
  11961. Doctor: user_name,
  11962. }
  11963. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11964. var dat map[string]interface{}
  11965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11966. fmt.Println(dat)
  11967. } else {
  11968. fmt.Println(err)
  11969. }
  11970. userJSONBytes, _ := json.Marshal(dat)
  11971. var res ResultNine
  11972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11973. utils.ErrorLog("解析失败:%v", err)
  11974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11975. return
  11976. }
  11977. if res.Infcode == 0 {
  11978. fileNo := res.Output.FileQuryNo
  11979. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11980. "file_qury_no=" + fileNo +
  11981. "&setl_optins=" + "定点医保中心" +
  11982. "&stmt_begndate=" + start_time +
  11983. "&stm_enddate=" + end_time +
  11984. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11985. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11986. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11987. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11988. "&fixmedins_code=" + miConfig.Code +
  11989. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11990. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11991. "&secret_key=" + miConfig.SecretKey +
  11992. "&org_name=" + miConfig.OrgName +
  11993. "&doctor=" + user_name
  11994. resp, requestErr := http.Get(api)
  11995. if requestErr != nil {
  11996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11997. return
  11998. }
  11999. body, ioErr := ioutil.ReadAll(resp.Body)
  12000. if ioErr != nil {
  12001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12003. return
  12004. }
  12005. var respJSON map[string]interface{}
  12006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12009. return
  12010. }
  12011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12012. userJSONBytes, _ := json.Marshal(respJSON)
  12013. var res ResultTen
  12014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12015. utils.ErrorLog("解析失败:%v", err)
  12016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12017. return
  12018. }
  12019. if res.Infcode == 0 {
  12020. service.Gdyb9102(baseParams, zip_name, fileNo)
  12021. micc := &models.MedicalInsuranceCostCompare{
  12022. StartTime: startime.Unix(),
  12023. EndTime: endtime.Unix(),
  12024. Insutype: "0",
  12025. CheckType: 2,
  12026. Num: fixmedins_setl_cnt,
  12027. Mtime: time.Now().Unix(),
  12028. Status: 1,
  12029. UserOrgId: adminUser.CurrentOrgId,
  12030. CostTotal: medfee_sumamt,
  12031. FuncTotal: fund_pay_sumamt,
  12032. PsnPay: psn_cash_pay,
  12033. Creator: admin_user_id,
  12034. Ctime: time.Now().Unix(),
  12035. }
  12036. service.CreateMedicalInsuranceCostCompareRecord(micc)
  12037. c.ServeSuccessJSON(map[string]interface{}{
  12038. "msg": "明细对账成功",
  12039. })
  12040. }
  12041. } else {
  12042. }
  12043. }
  12044. }
  12045. type CustomOrderInfo struct {
  12046. Name string
  12047. Spec string
  12048. Unit string
  12049. Count float64
  12050. Price float64
  12051. Total float64
  12052. }
  12053. func (c *HisApiController) GetSettleAccounts() {
  12054. //id, _ := c.GetInt64("id")
  12055. //record_time := c.GetString("record_time")
  12056. order_id, _ := c.GetInt64("order_id")
  12057. admin_user_id, _ := c.GetInt64("admin_user_id")
  12058. //timeLayout := "2006-01-02"
  12059. //loc, _ := time.LoadLocation("Local")
  12060. //
  12061. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12062. //if err != nil {
  12063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12064. // return
  12065. //}
  12066. //recordDateTime := theTime.Unix()
  12067. adminUser := c.GetAdminUserInfo()
  12068. order, _ := service.GetHisOrderByID(order_id)
  12069. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12070. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  12071. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  12072. orderInfos = append(orderInfos, orderInfos_two...)
  12073. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  12074. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  12075. var diagnosis_ids []string
  12076. if his.ID > 0 {
  12077. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  12078. } else {
  12079. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  12080. }
  12081. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  12082. var dia_config []*models.HisXtDiagnoseConfig
  12083. var name string
  12084. for _, item := range diagnosis_ids {
  12085. id, _ := strconv.ParseInt(item, 10, 64)
  12086. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12087. dia_config = append(dia_config, &diagnosisConfig)
  12088. if len(name) == 0 {
  12089. name = diagnosisConfig.ClassName
  12090. } else {
  12091. name = name + "," + diagnosisConfig.ClassName
  12092. }
  12093. }
  12094. var bedCostTotal float64 = 0 //床位总费
  12095. var bedCostSelfTotal float64 = 0 //床位自费
  12096. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12097. var operationCostTotal float64 = 0 //手术费
  12098. var operationCostSelfTotal float64 = 0 //手术费
  12099. var operationCostPartSelfTotal float64 = 0 //手术费
  12100. var otherCostTotal float64 = 0 //其他费用
  12101. var otherCostSelfTotal float64 = 0 //其他费用
  12102. var otherCostPartSelfTotal float64 = 0 //其他费用
  12103. var materialCostTotal float64 = 0 //材料费
  12104. var materialCostSelfTotal float64 = 0 //材料费
  12105. var materialCostPartSelfTotal float64 = 0 //材料费
  12106. var westernMedicineCostTotal float64 = 0 //西药费
  12107. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12108. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12109. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12110. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12111. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12112. var checkCostTotal float64 = 0 //检查费
  12113. var checkCostSelfTotal float64 = 0 //检查费
  12114. var checkCostPartSelfTotal float64 = 0 //检查费
  12115. var laboratoryCostTotal float64 = 0 //化验费
  12116. var laboratoryCostSelfTotal float64 = 0 //化验费
  12117. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12118. var treatCostTotal float64 = 0 //治疗费用
  12119. var treatCostSelfTotal float64 = 0 //治疗费用
  12120. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12121. decimal.DivisionPrecision = 2
  12122. for _, item := range orderInfos {
  12123. if item.MedChrgitmType == "01" { //床位费
  12124. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12125. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12126. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12127. }
  12128. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  12129. if item.MedChrgitmType == "03" { //检查费
  12130. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12131. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12132. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12133. }
  12134. } else {
  12135. if item.MedChrgitmType == "03" { //检查费
  12136. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12137. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12138. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12139. }
  12140. }
  12141. if item.MedChrgitmType == "04" { //化验费
  12142. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12143. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12144. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12145. }
  12146. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  12147. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12148. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12149. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12150. }
  12151. if item.MedChrgitmType == "06" { //手术费
  12152. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12153. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12154. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12155. }
  12156. if item.MedChrgitmType == "08" { //材料费
  12157. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12158. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12159. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12160. }
  12161. if item.MedChrgitmType == "09" { //西药费
  12162. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12163. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12164. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12165. }
  12166. if item.MedChrgitmType == "11" { //中成费
  12167. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12168. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12169. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12170. }
  12171. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  12172. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12173. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12174. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12175. }
  12176. }
  12177. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12178. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12179. var user_name string
  12180. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12181. if role.ID == 0 {
  12182. user_name = "管理员"
  12183. } else {
  12184. user_name = role.UserName
  12185. }
  12186. baseParams := models.BaseParams{
  12187. SecretKey: miConfig.SecretKey,
  12188. FixmedinsCode: miConfig.Code,
  12189. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12190. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12191. OrgName: miConfig.OrgName,
  12192. Doctor: user_name,
  12193. RequestUrl: miConfig.Url,
  12194. AccessKey: miConfig.AccessKey,
  12195. }
  12196. businessParams := models.BusinessParams{
  12197. PsnNo: order.PsnNo,
  12198. MdtrtId: order.MdtrtId,
  12199. SetlId: order.SetlId,
  12200. }
  12201. var res ResultEleven
  12202. var resEleven10265 ResultEleven10265
  12203. if config.IsOpen == 1 {
  12204. if miConfig.MdtrtareaAdmvs == "421300" {
  12205. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12206. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12207. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12208. resp, requestErr := http.Get(api)
  12209. if requestErr != nil {
  12210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12211. return
  12212. }
  12213. body, ioErr := ioutil.ReadAll(resp.Body)
  12214. if ioErr != nil {
  12215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12217. return
  12218. }
  12219. var respJSON map[string]interface{}
  12220. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12223. return
  12224. }
  12225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12226. result, _ := json.Marshal(respJSON)
  12227. fmt.Println("log")
  12228. fmt.Println(string(result))
  12229. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12230. utils.ErrorLog("解析失败:%v", err)
  12231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12232. return
  12233. }
  12234. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12235. var api string
  12236. if miConfig.MdtrtareaAdmvs == "320921" {
  12237. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12238. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12239. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12240. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12241. } else {
  12242. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12243. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12244. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12245. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12246. }
  12247. resp, requestErr := http.Get(api)
  12248. if requestErr != nil {
  12249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12250. return
  12251. }
  12252. body, ioErr := ioutil.ReadAll(resp.Body)
  12253. if ioErr != nil {
  12254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12256. return
  12257. }
  12258. var respJSON map[string]interface{}
  12259. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12262. return
  12263. }
  12264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12265. result, _ := json.Marshal(respJSON)
  12266. fmt.Println("log")
  12267. fmt.Println(string(result))
  12268. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12269. utils.ErrorLog("解析失败:%v", err)
  12270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12271. return
  12272. }
  12273. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12274. res.Output = resEleven10265.Output
  12275. res.ErrMsg = resEleven10265.ErrMsg
  12276. res.Cainfo = resEleven10265.Cainfo
  12277. res.WarnMsg = resEleven10265.WarnMsg
  12278. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12279. res.Infcode = infocode
  12280. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12281. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12282. saveLog(result, requestLog, "5203", "结算单")
  12283. var dat map[string]interface{}
  12284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12285. fmt.Println(dat)
  12286. } else {
  12287. fmt.Println(err)
  12288. }
  12289. userJSONBytes, _ := json.Marshal(dat)
  12290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12291. utils.ErrorLog("解析失败:%v", err)
  12292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12293. return
  12294. }
  12295. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12296. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12297. saveLog(result, requestLog, "5203", "结算单")
  12298. var dat map[string]interface{}
  12299. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12300. fmt.Println(dat)
  12301. } else {
  12302. fmt.Println(err)
  12303. }
  12304. userJSONBytes, _ := json.Marshal(dat)
  12305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12306. utils.ErrorLog("解析失败:%v", err)
  12307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12308. return
  12309. }
  12310. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12311. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12312. saveLog(result, requestLog, "5203", "结算单")
  12313. var dat map[string]interface{}
  12314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12315. fmt.Println(dat)
  12316. } else {
  12317. fmt.Println(err)
  12318. }
  12319. userJSONBytes, _ := json.Marshal(dat)
  12320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12321. utils.ErrorLog("解析失败:%v", err)
  12322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12323. return
  12324. }
  12325. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12326. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12327. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12328. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12329. resp, requestErr := http.Get(api)
  12330. if requestErr != nil {
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. body, ioErr := ioutil.ReadAll(resp.Body)
  12335. if ioErr != nil {
  12336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12338. return
  12339. }
  12340. var respJSON map[string]interface{}
  12341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12344. return
  12345. }
  12346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12347. result, _ := json.Marshal(respJSON)
  12348. fmt.Println("log")
  12349. fmt.Println(string(result))
  12350. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12351. utils.ErrorLog("解析失败:%v", err)
  12352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12353. return
  12354. }
  12355. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12356. res.Output = resEleven10265.Output
  12357. res.ErrMsg = resEleven10265.ErrMsg
  12358. res.Cainfo = resEleven10265.Cainfo
  12359. res.WarnMsg = resEleven10265.WarnMsg
  12360. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12361. res.Infcode = infocode
  12362. } else {
  12363. result := service.Gdyb5203(baseParams, businessParams)
  12364. //service.Gdyb5204(baseParams, businessParams)
  12365. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  12366. var dat map[string]interface{}
  12367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12368. fmt.Println(dat)
  12369. } else {
  12370. fmt.Println(err)
  12371. }
  12372. userJSONBytes, _ := json.Marshal(dat)
  12373. if miConfig.Code == "H15049901371" {
  12374. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  12375. utils.ErrorLog("解析失败:%v", err)
  12376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12377. return
  12378. }
  12379. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12380. res.Output = resEleven10265.Output
  12381. res.ErrMsg = resEleven10265.ErrMsg
  12382. res.Cainfo = resEleven10265.Cainfo
  12383. res.WarnMsg = resEleven10265.WarnMsg
  12384. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12385. res.Infcode = infocode
  12386. } else {
  12387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12388. utils.ErrorLog("解析失败:%v", err)
  12389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12390. return
  12391. }
  12392. }
  12393. }
  12394. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12395. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  12396. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  12397. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12398. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  12399. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12400. var doctor_name string
  12401. if roles.ID == 0 {
  12402. doctor_name = "管理员"
  12403. } else {
  12404. doctor_name = roles.UserName
  12405. }
  12406. yiliao_leibie := ""
  12407. switch order.MedType {
  12408. case "11":
  12409. yiliao_leibie = "普通门诊"
  12410. break
  12411. case "12":
  12412. yiliao_leibie = "门诊挂号"
  12413. break
  12414. case "13":
  12415. yiliao_leibie = "急诊"
  12416. break
  12417. case "14":
  12418. yiliao_leibie = "门诊特殊病"
  12419. break
  12420. case "15":
  12421. yiliao_leibie = "门诊统筹"
  12422. break
  12423. case "16":
  12424. yiliao_leibie = "门诊慢性病"
  12425. break
  12426. case "21":
  12427. yiliao_leibie = "普通住院"
  12428. break
  12429. }
  12430. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12431. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  12432. if res.Infcode == 0 {
  12433. c.ServeSuccessJSON(map[string]interface{}{
  12434. "diagnosis": name,
  12435. "order_infos": orderInfos,
  12436. "number": order.MdtrtId,
  12437. "date": order.SettleAccountsDate,
  12438. "charge_admin": charge_admin,
  12439. "printor_admin": printor_admin,
  12440. "info": res.Output.Setlinfo,
  12441. "order": order,
  12442. "bedCostTotal": bedCostTotal,
  12443. "bedCostSelfTotal": bedCostSelfTotal,
  12444. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  12445. "operationCostTotal": operationCostTotal,
  12446. "operationCostSelfTotal": operationCostSelfTotal,
  12447. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  12448. "otherCostTotal": otherCostTotal,
  12449. "otherCostSelfTotal": otherCostSelfTotal,
  12450. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  12451. "materialCostTotal": materialCostTotal,
  12452. "materialCostSelfTotal": materialCostSelfTotal,
  12453. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  12454. "westernMedicineCostTotal": westernMedicineCostTotal,
  12455. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  12456. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  12457. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  12458. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  12459. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  12460. "checkCostTotal": checkCostTotal,
  12461. "checkCostSelfTotal": checkCostSelfTotal,
  12462. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  12463. "laboratoryCostTotal": laboratoryCostTotal,
  12464. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  12465. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  12466. "treatCostTotal": treatCostTotal,
  12467. "treatCostSelfTotal": treatCostSelfTotal,
  12468. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  12469. "doctor_info": doctor_info,
  12470. "doctor_code": adminRole_two.DoctorCode,
  12471. "doctor_name": doctor_name,
  12472. "health_card_no": order.PsnNo,
  12473. "department": departments.Name,
  12474. "yiliao_leibie": yiliao_leibie,
  12475. "after_money": order.AccountPrice,
  12476. "patient": patient,
  12477. "org_name": miConfig.OrgName,
  12478. "org_code": miConfig.Code,
  12479. "order_number": order.Number,
  12480. "his_hospital": his_hospital,
  12481. "his": his,
  12482. "dia_config": dia_config,
  12483. //"check_order_info": cus_slice,
  12484. })
  12485. }
  12486. }
  12487. }
  12488. func (c *HisApiController) CheckTreatment() {
  12489. patient_id, _ := c.GetInt64("patient_id")
  12490. id_card_no := c.GetString("id_card_no")
  12491. insutype := c.GetString("insutype")
  12492. med_type := c.GetString("med_type")
  12493. admin_user_id, _ := c.GetInt64("admin_user_id")
  12494. adminUser := c.GetAdminUserInfo()
  12495. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12496. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12497. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12498. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12499. if miConfig.MdtrtareaAdmvs == "421300" {
  12500. var res ResultTwo
  12501. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12502. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12503. "&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)
  12504. resp, requestErr := http.Get(api)
  12505. if requestErr != nil {
  12506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12507. return
  12508. }
  12509. body, ioErr := ioutil.ReadAll(resp.Body)
  12510. if ioErr != nil {
  12511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12513. return
  12514. }
  12515. var respJSON map[string]interface{}
  12516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12519. return
  12520. }
  12521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12522. result, _ := json.Marshal(respJSON)
  12523. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12524. utils.ErrorLog("解析失败:%v", err)
  12525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12526. return
  12527. }
  12528. if res.Infcode == 0 {
  12529. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  12530. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12531. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  12532. resp, requestErr := http.Get(api)
  12533. if requestErr != nil {
  12534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12535. return
  12536. }
  12537. body, ioErr := ioutil.ReadAll(resp.Body)
  12538. if ioErr != nil {
  12539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12541. return
  12542. }
  12543. var respJSON map[string]interface{}
  12544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12547. return
  12548. }
  12549. var res Result2001
  12550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12551. result2, _ := json.Marshal(respJSON)
  12552. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  12553. utils.ErrorLog("解析失败:%v", err)
  12554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12555. return
  12556. }
  12557. if res.Infcode == 0 {
  12558. c.ServeSuccessJSON(map[string]interface{}{
  12559. "msg": res.Output.Trtinfo,
  12560. })
  12561. }
  12562. } else {
  12563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12564. return
  12565. }
  12566. } else {
  12567. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12568. var dat map[string]interface{}
  12569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12570. fmt.Println(dat)
  12571. } else {
  12572. fmt.Println(err)
  12573. }
  12574. userJSONBytes, _ := json.Marshal(dat)
  12575. var res ResultTwo
  12576. var res10265 ResultTwo10265
  12577. if miConfig.Code == "H15049901371" {
  12578. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12579. utils.ErrorLog("解析失败:%v", err)
  12580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12581. return
  12582. }
  12583. res.ErrMsg = res10265.ErrMsg
  12584. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12585. res.Infcode = infocode
  12586. res.Output = res10265.Output
  12587. res.InfRefmsgid = res10265.InfRefmsgid
  12588. } else {
  12589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12590. utils.ErrorLog("解析失败:%v", err)
  12591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12592. return
  12593. }
  12594. }
  12595. var user_name string
  12596. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  12597. if role.ID == 0 {
  12598. user_name = "xxx"
  12599. } else {
  12600. user_name = role.UserName
  12601. }
  12602. baseParams := models.BaseParams{
  12603. SecretKey: miConfig.SecretKey,
  12604. FixmedinsCode: miConfig.Code,
  12605. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12606. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12607. OrgName: miConfig.OrgName,
  12608. Doctor: user_name,
  12609. }
  12610. if config.IsOpen == 1 {
  12611. if miConfig.Code == "H15049901371" {
  12612. if med_type == "14" {
  12613. if insutype == "390" {
  12614. med_type = "9933"
  12615. } else if insutype == "310" {
  12616. med_type = "990502"
  12617. }
  12618. } else if med_type == "11" {
  12619. med_type = "11"
  12620. }
  12621. }
  12622. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  12623. var dat map[string]interface{}
  12624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12625. fmt.Println(dat)
  12626. } else {
  12627. fmt.Println(err)
  12628. }
  12629. var res Result2001
  12630. var res10265 Result2001Org10265
  12631. if miConfig.Code == "H15049901371" {
  12632. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12633. utils.ErrorLog("解析失败:%v", err)
  12634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12635. return
  12636. }
  12637. res.ErrMsg = res10265.ErrMsg
  12638. res.Output = res10265.Output
  12639. res.InfRefmsgid = res10265.InfRefmsgid
  12640. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12641. res.Infcode = infocode
  12642. } else {
  12643. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12644. utils.ErrorLog("解析失败:%v", err)
  12645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12646. return
  12647. }
  12648. }
  12649. if res.Infcode == 0 {
  12650. c.ServeSuccessJSON(map[string]interface{}{
  12651. "msg": res.Output.Trtinfo,
  12652. })
  12653. }
  12654. }
  12655. }
  12656. }
  12657. //func (c *HisApiController) PutRecord() {
  12658. // id, _ := c.GetInt64("id")
  12659. // record_time := c.GetString("record_time")
  12660. // timeLayout := "2006-01-02"
  12661. // loc, _ := time.LoadLocation("Local")
  12662. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12663. // if err != nil {
  12664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12665. // return
  12666. // }
  12667. // recordDateTime := theTime.Unix()
  12668. //
  12669. // adminInfo := c.GetAdminUserInfo()
  12670. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  12671. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12672. //
  12673. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12674. //
  12675. // fmt.Println(miConfig.SecretKey)
  12676. //
  12677. // if patient == nil {
  12678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12679. // return
  12680. // }
  12681. // if len(patient.IdCardNo) == 0 {
  12682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  12683. // return
  12684. // }
  12685. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12686. // if config.IsOpen == 1 {
  12687. // 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
  12688. // resp, requestErr := http.Get(api)
  12689. // if requestErr != nil {
  12690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12691. // return
  12692. // }
  12693. // defer resp.Body.Close()
  12694. // body, ioErr := ioutil.ReadAll(resp.Body)
  12695. // if ioErr != nil {
  12696. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12698. // return
  12699. // }
  12700. // var respJSON map[string]interface{}
  12701. //
  12702. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12703. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12705. // return
  12706. // }
  12707. //
  12708. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12709. // userJSONBytes, _ := json.Marshal(userJSON)
  12710. // var res ResultTwo
  12711. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12712. // utils.ErrorLog("解析失败:%v", err)
  12713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12714. // return
  12715. // }
  12716. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12717. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12718. // infoStr := string(Iinfos)
  12719. // idetinfoStr := string(Idetinfos)
  12720. //
  12721. // if res.Infcode == 0 {
  12722. // his := models.VMHisPatient{
  12723. // Status: 1,
  12724. // Ctime: time.Now().Unix(),
  12725. // Mtime: time.Now().Unix(),
  12726. // PsnNo: res.Output.Baseinfo.PsnNo,
  12727. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  12728. // Certno: res.Output.Baseinfo.Certno,
  12729. // PsnName: res.Output.Baseinfo.PsnName,
  12730. // Gend: res.Output.Baseinfo.Gend,
  12731. // Naty: res.Output.Baseinfo.Naty,
  12732. // Brdy: res.Output.Baseinfo.Brdy,
  12733. // Age: res.Output.Baseinfo.Age,
  12734. // Iinfo: infoStr,
  12735. // Idetinfo: idetinfoStr,
  12736. // PatientId: patient.ID,
  12737. // RecordDate: theTime.Unix(),
  12738. // UserOrgId: adminInfo.CurrentOrgId,
  12739. // AdminUserId: adminInfo.AdminUser.Id,
  12740. // IsReturn: 1,
  12741. // }
  12742. //
  12743. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  12744. // //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")
  12745. // //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")
  12746. //
  12747. // //var dat map[string]interface{}
  12748. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12749. // // fmt.Println(dat)
  12750. // //} else {
  12751. // // fmt.Println(err)
  12752. // //}
  12753. //
  12754. // var dat2 map[string]interface{}
  12755. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12756. // fmt.Println(dat2)
  12757. // } else {
  12758. // fmt.Println(err)
  12759. // }
  12760. //
  12761. // } else {
  12762. // adminUser := c.GetAdminUserInfo()
  12763. // errlog := &models.HisOrderError{
  12764. // UserOrgId: adminUser.CurrentOrgId,
  12765. // Ctime: time.Now().Unix(),
  12766. // Mtime: time.Now().Unix(),
  12767. // ErrMsg: res.ErrMsg,
  12768. // Status: 1,
  12769. // PatientId: id,
  12770. // RecordTime: recordDateTime,
  12771. // Stage: 1,
  12772. // }
  12773. // service.CreateErrMsgLog(errlog)
  12774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12775. // return
  12776. // }
  12777. // }
  12778. //
  12779. //}
  12780. //func (c *HisApiController) GetUploadDiag() {
  12781. // id, _ := c.GetInt64("id")
  12782. // record_time := c.GetString("record_time")
  12783. //
  12784. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12785. // sick_type, _ := c.GetInt64("sick_type")
  12786. // reg_type, _ := c.GetInt64("reg_type")
  12787. //
  12788. // timeLayout := "2006-01-02"
  12789. // loc, _ := time.LoadLocation("Local")
  12790. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12791. // if err != nil {
  12792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12793. // return
  12794. // }
  12795. //
  12796. // var patientPrescription models.HisPrescriptionInfo
  12797. // recordDateTime := theTime.Unix()
  12798. // adminInfo := c.GetAdminUserInfo()
  12799. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12800. //
  12801. // if patientPrescription.ID == 0 {
  12802. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12803. // }
  12804. //
  12805. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12806. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12807. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12808. // sickConfig, _ := service.FindSickById(sick_type)
  12809. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12810. //
  12811. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12812. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12813. // "&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 +
  12814. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12815. // resp2, requestErr2 := http.Get(api2)
  12816. // if requestErr2 != nil {
  12817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12818. // return
  12819. // }
  12820. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12821. // if ioErr2 != nil {
  12822. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12824. // return
  12825. // }
  12826. // var respJSON2 map[string]interface{}
  12827. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12828. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12830. // return
  12831. // }
  12832. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12833. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12834. //
  12835. // var res2 ResultSix
  12836. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12837. // utils.ErrorLog("解析失败:%v", err)
  12838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12839. // return
  12840. // }
  12841. // if res2.Infcode != 0 {
  12842. // adminUser := c.GetAdminUserInfo()
  12843. // errlog := &models.HisOrderError{
  12844. // UserOrgId: adminUser.CurrentOrgId,
  12845. // Ctime: time.Now().Unix(),
  12846. // Mtime: time.Now().Unix(),
  12847. // ErrMsg: res2.ErrMsg,
  12848. // Status: 1,
  12849. // PatientId: id,
  12850. // RecordTime: recordDateTime,
  12851. // Stage: 3,
  12852. // }
  12853. // service.CreateErrMsgLog(errlog)
  12854. //
  12855. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12856. // return
  12857. // }
  12858. //
  12859. // c.ServeSuccessJSON(map[string]interface{}{
  12860. // "msg": "上传成功",
  12861. // })
  12862. //
  12863. //}
  12864. type QueryResult struct {
  12865. ID int64
  12866. Name string
  12867. Code string
  12868. List_type_code string
  12869. }
  12870. func (c *HisApiController) GetCheckCode() {
  12871. ids_str := c.GetString("ids")
  12872. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12873. ids_arr := strings.Split(ids_str, ",")
  12874. var queryResult []QueryResult
  12875. ids := make([]int64, 0)
  12876. for _, item := range ids_arr {
  12877. id, _ := strconv.ParseInt(item, 10, 64)
  12878. ids = append(ids, id)
  12879. }
  12880. if record_type == 1 {
  12881. drugs, _ := service.GetBatchDrugList(ids)
  12882. for _, item := range drugs {
  12883. result := QueryResult{
  12884. ID: item.ID,
  12885. Name: item.DrugName,
  12886. Code: item.MedicalInsuranceNumber,
  12887. List_type_code: "101",
  12888. }
  12889. queryResult = append(queryResult, result)
  12890. }
  12891. } else if record_type == 2 {
  12892. goods, _ := service.GetBatchGoodInformationList(ids)
  12893. for _, item := range goods {
  12894. result := QueryResult{
  12895. ID: item.ID,
  12896. Name: item.GoodName,
  12897. Code: item.MedicalInsuranceNumber,
  12898. List_type_code: "301",
  12899. }
  12900. queryResult = append(queryResult, result)
  12901. }
  12902. } else if record_type == 3 {
  12903. projects, _ := service.GetBathchMyPorjecgList(ids)
  12904. for _, item := range projects {
  12905. result := QueryResult{
  12906. ID: item.ID,
  12907. Name: item.ProjectName,
  12908. Code: item.MedicalCode,
  12909. List_type_code: "201",
  12910. }
  12911. queryResult = append(queryResult, result)
  12912. }
  12913. }
  12914. admin_user_id, _ := c.GetInt64("admin_user_id")
  12915. adminUser := c.GetAdminUserInfo()
  12916. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12917. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12918. var user_name string
  12919. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12920. if role.ID == 0 {
  12921. user_name = "xxx"
  12922. } else {
  12923. user_name = role.UserName
  12924. }
  12925. baseParams := &models.BaseParams{
  12926. SecretKey: miConfig.SecretKey,
  12927. FixmedinsCode: miConfig.Code,
  12928. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12929. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12930. OrgName: miConfig.OrgName,
  12931. Doctor: user_name,
  12932. }
  12933. if config.IsOpen == 1 {
  12934. for _, item := range queryResult {
  12935. var result string
  12936. if record_type == 1 {
  12937. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12938. } else if record_type == 2 {
  12939. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12940. } else if record_type == 3 {
  12941. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12942. }
  12943. var dat map[string]interface{}
  12944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12945. fmt.Println(dat)
  12946. } else {
  12947. fmt.Println(err)
  12948. }
  12949. userJSONBytes, _ := json.Marshal(dat)
  12950. var res ResultSix
  12951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12952. utils.ErrorLog("解析失败:%v", err)
  12953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12954. return
  12955. }
  12956. if res.Infcode == 0 {
  12957. if record_type == 1 {
  12958. service.UpdateBaseDrugById(item.ID)
  12959. } else if record_type == 2 {
  12960. service.UpdateGoodInformaitonByDetail(item.ID)
  12961. } else if record_type == 3 {
  12962. service.UpdateProjectById(item.ID)
  12963. }
  12964. c.ServeSuccessJSON(map[string]interface{}{
  12965. "failed_code": 0,
  12966. "msg": "目录对照成功",
  12967. })
  12968. } else {
  12969. c.ServeSuccessJSON(map[string]interface{}{
  12970. "failed_code": -10,
  12971. "msg": res.ErrMsg,
  12972. })
  12973. }
  12974. }
  12975. }
  12976. }
  12977. func (c *HisApiController) UnCheckCode() {
  12978. ids_str := c.GetString("ids")
  12979. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12980. admin_user_id, _ := c.GetInt64("admin_user_id")
  12981. ids_arr := strings.Split(ids_str, ",")
  12982. var queryResult []QueryResult
  12983. ids := make([]int64, 0)
  12984. for _, item := range ids_arr {
  12985. id, _ := strconv.ParseInt(item, 10, 64)
  12986. ids = append(ids, id)
  12987. }
  12988. if record_type == 1 {
  12989. drugs, _ := service.GetBatchDrugList(ids)
  12990. for _, item := range drugs {
  12991. result := QueryResult{
  12992. ID: item.ID,
  12993. Name: item.DrugName,
  12994. Code: item.MedicalInsuranceNumber,
  12995. List_type_code: "101",
  12996. }
  12997. queryResult = append(queryResult, result)
  12998. }
  12999. } else if record_type == 2 {
  13000. goods, _ := service.GetBatchGoodInformationList(ids)
  13001. for _, item := range goods {
  13002. result := QueryResult{
  13003. ID: item.ID,
  13004. Name: item.GoodName,
  13005. Code: item.MedicalInsuranceNumber,
  13006. List_type_code: "301",
  13007. }
  13008. queryResult = append(queryResult, result)
  13009. }
  13010. } else if record_type == 3 {
  13011. projects, _ := service.GetBathchMyPorjecgList(ids)
  13012. for _, item := range projects {
  13013. result := QueryResult{
  13014. ID: item.ID,
  13015. Name: item.ProjectName,
  13016. Code: item.MedicalCode,
  13017. List_type_code: "201",
  13018. }
  13019. queryResult = append(queryResult, result)
  13020. }
  13021. }
  13022. adminUser := c.GetAdminUserInfo()
  13023. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13024. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13025. var user_name string
  13026. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13027. if role.ID == 0 {
  13028. user_name = "xxx"
  13029. } else {
  13030. user_name = role.UserName
  13031. }
  13032. baseParams := &models.BaseParams{
  13033. SecretKey: miConfig.SecretKey,
  13034. FixmedinsCode: miConfig.Code,
  13035. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13036. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13037. OrgName: miConfig.OrgName,
  13038. Doctor: user_name,
  13039. }
  13040. if config.IsOpen == 1 {
  13041. for _, item := range queryResult {
  13042. var result string
  13043. if record_type == 1 {
  13044. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13045. } else if record_type == 2 {
  13046. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13047. } else if record_type == 3 {
  13048. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13049. }
  13050. var dat2 map[string]interface{}
  13051. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  13052. fmt.Println(dat2)
  13053. } else {
  13054. fmt.Println(err)
  13055. }
  13056. userJSONBytes, _ := json.Marshal(dat2)
  13057. var res ResultSix
  13058. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13059. utils.ErrorLog("解析失败:%v", err)
  13060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13061. return
  13062. }
  13063. if res.Infcode == 0 {
  13064. if record_type == 1 {
  13065. service.UpdateDrugByIdDetail(item.ID)
  13066. } else if record_type == 2 {
  13067. service.UpdateGoodInfoById(item.ID)
  13068. } else if record_type == 3 {
  13069. service.UpdateMyProjectById(item.ID)
  13070. }
  13071. c.ServeSuccessJSON(map[string]interface{}{
  13072. "failed_code": 0,
  13073. "msg": "撤销目录对照成功",
  13074. })
  13075. } else {
  13076. c.ServeSuccessJSON(map[string]interface{}{
  13077. "failed_code": -10,
  13078. "msg": res.ErrMsg,
  13079. })
  13080. }
  13081. }
  13082. }
  13083. }
  13084. func (c *HisApiController) GetPatientInfo() {
  13085. id_card_no := c.GetString("id_card_no")
  13086. admin_user_id, _ := c.GetInt64("admin_user_id")
  13087. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13088. if patient.ID == 0 {
  13089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13090. return
  13091. }
  13092. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13093. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13094. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  13095. if config.IsOpen == 1 {
  13096. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13097. var dat map[string]interface{}
  13098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13099. fmt.Println(dat)
  13100. } else {
  13101. fmt.Println(err)
  13102. }
  13103. userJSONBytes, _ := json.Marshal(dat)
  13104. var res ResultTwo
  13105. var res10265 ResultTwo10265
  13106. if miConfig.Code == "H15049901371" {
  13107. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13108. utils.ErrorLog("解析失败:%v", err)
  13109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13110. return
  13111. }
  13112. res.ErrMsg = res10265.ErrMsg
  13113. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13114. res.Infcode = infocode
  13115. res.Output = res10265.Output
  13116. res.InfRefmsgid = res10265.InfRefmsgid
  13117. } else {
  13118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13119. utils.ErrorLog("解析失败:%v", err)
  13120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13121. return
  13122. }
  13123. }
  13124. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13125. // utils.ErrorLog("解析失败:%v", err)
  13126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13127. // return
  13128. //}
  13129. if res.Infcode != 0 {
  13130. c.ServeSuccessJSON(map[string]interface{}{
  13131. "failed_code": -10,
  13132. "msg": res.ErrMsg,
  13133. })
  13134. } else {
  13135. c.ServeSuccessJSON(map[string]interface{}{
  13136. "failed_code": 0,
  13137. "info": res,
  13138. })
  13139. }
  13140. }
  13141. }
  13142. func (c *HisApiController) PsnPutOnRecord() {
  13143. record_type, _ := c.GetInt64("type")
  13144. patient_id, _ := c.GetInt64("patient_id")
  13145. admin_user_id, _ := c.GetInt64("admin_user_id")
  13146. start_time := c.GetString("start_time")
  13147. end_time := c.GetString("end_time")
  13148. adminUser := c.GetAdminUserInfo()
  13149. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13150. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13151. var patients []*models.Patients
  13152. if record_type == 1 { //全部备案
  13153. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  13154. patients = append(patients, patient...)
  13155. } else { //单个备案
  13156. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13157. patients = append(patients, patient)
  13158. }
  13159. var user_name string
  13160. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13161. if role.ID == 0 {
  13162. user_name = "xxx"
  13163. } else {
  13164. user_name = role.UserName
  13165. }
  13166. if config.IsOpen == 1 {
  13167. for _, item := range patients {
  13168. 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
  13169. resp, requestErr := http.Get(api)
  13170. if requestErr != nil {
  13171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13172. return
  13173. }
  13174. defer resp.Body.Close()
  13175. body, ioErr := ioutil.ReadAll(resp.Body)
  13176. if ioErr != nil {
  13177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13179. return
  13180. }
  13181. var respJSON map[string]interface{}
  13182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13185. return
  13186. }
  13187. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13188. userJSONBytes, _ := json.Marshal(userJSON)
  13189. var res ResultTwo
  13190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13191. utils.ErrorLog("解析失败:%v", err)
  13192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13193. return
  13194. }
  13195. if res.Infcode == 0 {
  13196. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  13197. var dat map[string]interface{}
  13198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13199. fmt.Println(dat)
  13200. } else {
  13201. fmt.Println(err)
  13202. }
  13203. userJSONBytes, _ := json.Marshal(dat)
  13204. var res2 ResultThirteen
  13205. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13206. utils.ErrorLog("解析失败:%v", err)
  13207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13208. return
  13209. }
  13210. if res2.Infcode == 0 {
  13211. psnResult := &models.GdybPsnRecord{
  13212. UserOrgId: adminUser.CurrentOrgId,
  13213. PatientId: item.ID,
  13214. PsnNo: res.Output.Baseinfo.PsnNo,
  13215. Ctime: time.Now().Unix(),
  13216. Mtime: time.Now().Unix(),
  13217. Status: 1,
  13218. IsCancel: 1,
  13219. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13220. }
  13221. service.CreatePsnRecord(psnResult)
  13222. } else {
  13223. c.ServeSuccessJSON(map[string]interface{}{
  13224. "failed_code": -10,
  13225. "msg": res2.ErrMsg,
  13226. })
  13227. return
  13228. }
  13229. }
  13230. }
  13231. }
  13232. }
  13233. func (c *HisApiController) PsnUnPutOnRecord() {
  13234. id, _ := c.GetInt64("id")
  13235. //record_type, _ := c.GetInt64("type")
  13236. admin_user_id, _ := c.GetInt64("admin_user_id")
  13237. adminUser := c.GetAdminUserInfo()
  13238. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13239. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13240. var user_name string
  13241. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13242. if role.ID == 0 {
  13243. user_name = "xxx"
  13244. } else {
  13245. user_name = role.UserName
  13246. }
  13247. psn_record, _ := service.GetPsnRecordById(id)
  13248. if psn_record.ID == 0 {
  13249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13250. return
  13251. }
  13252. if config.IsOpen == 1 {
  13253. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13254. var dat map[string]interface{}
  13255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13256. fmt.Println(dat)
  13257. } else {
  13258. fmt.Println(err)
  13259. }
  13260. userJSONBytes, _ := json.Marshal(dat)
  13261. var res ResultFourteen
  13262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13263. utils.ErrorLog("解析失败:%v", err)
  13264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13265. return
  13266. }
  13267. if res.Infcode == 0 {
  13268. psn_record.IsCancel = 2
  13269. service.CreatePsnRecord(&psn_record)
  13270. } else {
  13271. c.ServeSuccessJSON(map[string]interface{}{
  13272. "failed_code": -10,
  13273. "msg": res.ErrMsg,
  13274. })
  13275. return
  13276. }
  13277. }
  13278. }
  13279. func (c *HisApiController) PsnPutNCDSOnRecord() {
  13280. patient_id, _ := c.GetInt64("patient_id")
  13281. insutype_two := c.GetString("insutype")
  13282. psn_no := c.GetString("psn_no")
  13283. doctor_id, _ := c.GetInt64("doctor_id")
  13284. sick_id, _ := c.GetInt64("sick_id")
  13285. department_id, _ := c.GetInt64("department_id")
  13286. start_time := c.GetString("start_time")
  13287. end_time := c.GetString("end_time")
  13288. check_time := c.GetString("check_time")
  13289. hospital_code := c.GetString("hospital_code")
  13290. hospital_name := c.GetString("hospital_name")
  13291. adminUser := c.GetAdminUserInfo()
  13292. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13293. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13294. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13295. sick, _ := service.FindSickById(sick_id)
  13296. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13297. if len(hospital_code) == 0 {
  13298. hospital_code = miConfig.Code
  13299. }
  13300. if len(hospital_name) == 0 {
  13301. hospital_name = miConfig.OrgName
  13302. }
  13303. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13304. var res ResultTwo
  13305. var res10265 ResultTwo10265
  13306. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13307. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13308. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13309. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13310. "&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
  13311. resp, requestErr := http.Get(api)
  13312. if requestErr != nil {
  13313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13314. return
  13315. }
  13316. body, ioErr := ioutil.ReadAll(resp.Body)
  13317. if ioErr != nil {
  13318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13320. return
  13321. }
  13322. var respJSON map[string]interface{}
  13323. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13326. return
  13327. }
  13328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13329. result, _ := json.Marshal(respJSON)
  13330. fmt.Println("log")
  13331. fmt.Println(string(result))
  13332. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13333. utils.ErrorLog("解析失败:%v", err)
  13334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13335. return
  13336. }
  13337. res.ErrMsg = res10265.ErrMsg
  13338. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13339. res.Infcode = infocode
  13340. res.Output = res10265.Output
  13341. res.InfRefmsgid = res10265.InfRefmsgid
  13342. } else {
  13343. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13344. if miConfig.Code == "H15049901371" {
  13345. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13346. utils.ErrorLog("解析失败:%v", err)
  13347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13348. return
  13349. }
  13350. res.ErrMsg = res10265.ErrMsg
  13351. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13352. res.Infcode = infocode
  13353. res.Output = res10265.Output
  13354. res.InfRefmsgid = res10265.InfRefmsgid
  13355. } else {
  13356. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13357. utils.ErrorLog("解析失败:%v", err)
  13358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13359. return
  13360. }
  13361. }
  13362. }
  13363. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13364. infoStr := string(Iinfos)
  13365. var rf []*ResultFive
  13366. json.Unmarshal([]byte(infoStr), &rf)
  13367. var insuplc_admdvs string
  13368. var insutype string
  13369. var is390 int = 0
  13370. var is310 int = 0
  13371. var insutypes []*ResultFive
  13372. for _, item := range rf {
  13373. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13374. insutypes = append(insutypes, item)
  13375. }
  13376. }
  13377. if len(insutypes) == 1 {
  13378. insutype = insutypes[0].Insutype
  13379. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13380. } else {
  13381. for _, i := range insutypes {
  13382. if i.Insutype == "390" {
  13383. is390 = 1
  13384. }
  13385. if i.Insutype == "310" {
  13386. is310 = 1
  13387. }
  13388. }
  13389. }
  13390. if is390 == 1 {
  13391. insutype = "390"
  13392. }
  13393. if is310 == 1 {
  13394. insutype = "310"
  13395. }
  13396. if len(insutypes) == 2 {
  13397. insutype = insutype_two
  13398. }
  13399. if len(insutypes) == 0 {
  13400. insutype = "310"
  13401. }
  13402. insutype = insutype_two
  13403. fmt.Println(insutype)
  13404. for _, item := range rf {
  13405. fmt.Println(item.Insutype)
  13406. fmt.Println(insutype)
  13407. if item.Insutype == insutype {
  13408. fmt.Println(item.Insutype)
  13409. fmt.Println(insutype)
  13410. insuplc_admdvs = item.InsuplcAdmdvs
  13411. }
  13412. }
  13413. fmt.Println(insuplc_admdvs)
  13414. var res2 ResultThirteen
  13415. var res10265_2 ResultThirteen10265
  13416. if config.IsOpen == 1 {
  13417. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13418. } else {
  13419. 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)
  13420. var dat map[string]interface{}
  13421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13422. fmt.Println(dat)
  13423. } else {
  13424. fmt.Println(err)
  13425. }
  13426. userJSONBytes, _ := json.Marshal(dat)
  13427. if miConfig.Code == "H15049901371" {
  13428. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  13429. utils.ErrorLog("解析失败:%v", err)
  13430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13431. return
  13432. }
  13433. res2.ErrMsg = res10265_2.ErrMsg
  13434. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  13435. res2.Infcode = infocode
  13436. res2.Output = res10265_2.Output
  13437. res2.InfRefmsgid = res10265_2.InfRefmsgid
  13438. } else {
  13439. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13440. utils.ErrorLog("解析失败:%v", err)
  13441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13442. return
  13443. }
  13444. }
  13445. }
  13446. if res2.Infcode == 0 {
  13447. psnResult := &models.GdybPsnNcdsRecord{
  13448. UserOrgId: adminUser.CurrentOrgId,
  13449. PatientId: patient.ID,
  13450. PsnNo: psn_no,
  13451. DoctorId: doctor.AdminUserId,
  13452. DepartmentId: department_id,
  13453. SickType: sick_id,
  13454. Insutype: insutype,
  13455. Ctime: time.Now().Unix(),
  13456. Mtime: time.Now().Unix(),
  13457. Status: 1,
  13458. IsCancel: 1,
  13459. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13460. }
  13461. service.CreatePsnNCDSRecord(psnResult)
  13462. c.ServeSuccessJSON(map[string]interface{}{
  13463. "failed_code": 0,
  13464. "msg": "备案成功",
  13465. "result": psnResult,
  13466. })
  13467. } else {
  13468. c.ServeSuccessJSON(map[string]interface{}{
  13469. "failed_code": -10,
  13470. "msg": res2.ErrMsg,
  13471. })
  13472. return
  13473. }
  13474. }
  13475. }
  13476. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  13477. id, _ := c.GetInt64("id")
  13478. admin_user_id, _ := c.GetInt64("admin_user_id")
  13479. adminUser := c.GetAdminUserInfo()
  13480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13481. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13482. //config, _ := service.Ge(adminUser.CurrentOrgId)
  13483. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13484. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13485. //var user_name string
  13486. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13487. //if role.ID == 0 {
  13488. // user_name = "xxx"
  13489. //} else {
  13490. // user_name = role.UserName
  13491. //}
  13492. psn_record, _ := service.GetPsnNCDSRecordById(id)
  13493. if psn_record.ID == 0 {
  13494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13495. return
  13496. }
  13497. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13498. var res ResultTwo
  13499. var res10265 ResultTwo10265
  13500. if miConfig.Code == "H15049901371" {
  13501. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13502. utils.ErrorLog("解析失败:%v", err)
  13503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13504. return
  13505. }
  13506. res.ErrMsg = res10265.ErrMsg
  13507. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13508. res.Infcode = infocode
  13509. res.Output = res10265.Output
  13510. res.InfRefmsgid = res10265.InfRefmsgid
  13511. } else {
  13512. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13513. utils.ErrorLog("解析失败:%v", err)
  13514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13515. return
  13516. }
  13517. }
  13518. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13519. infoStr := string(Iinfos)
  13520. var rf []*ResultFive
  13521. json.Unmarshal([]byte(infoStr), &rf)
  13522. var insuplc_admdvs string
  13523. var insutype string
  13524. var is390 int = 0
  13525. var is310 int = 0
  13526. var insutypes []*ResultFive
  13527. for _, item := range rf {
  13528. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13529. insutypes = append(insutypes, item)
  13530. }
  13531. }
  13532. if len(insutypes) == 1 {
  13533. insutype = insutypes[0].Insutype
  13534. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13535. } else {
  13536. for _, i := range insutypes {
  13537. if i.Insutype == "390" {
  13538. is390 = 1
  13539. }
  13540. if i.Insutype == "310" {
  13541. is310 = 1
  13542. }
  13543. }
  13544. }
  13545. if is390 == 1 {
  13546. insutype = "390"
  13547. }
  13548. if is310 == 1 {
  13549. insutype = "310"
  13550. }
  13551. if len(insutypes) == 0 {
  13552. insutype = "310"
  13553. }
  13554. insutype = psn_record.Insutype
  13555. for _, item := range rf {
  13556. if item.Insutype == insutype {
  13557. insuplc_admdvs = item.InsuplcAdmdvs
  13558. }
  13559. }
  13560. if config.IsOpen == 1 {
  13561. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13562. var dat map[string]interface{}
  13563. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13564. fmt.Println(dat)
  13565. } else {
  13566. fmt.Println(err)
  13567. }
  13568. userJSONBytes, _ := json.Marshal(dat)
  13569. var res ResultFourteen
  13570. var res10265 ResultFourteen10265
  13571. if miConfig.Code == "H15049901371" {
  13572. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13573. utils.ErrorLog("解析失败:%v", err)
  13574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13575. return
  13576. }
  13577. res.ErrMsg = res10265.ErrMsg
  13578. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13579. res.Infcode = infocode
  13580. res.Output = res10265.Output
  13581. res.InfRefmsgid = res10265.InfRefmsgid
  13582. } else {
  13583. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13584. utils.ErrorLog("解析失败:%v", err)
  13585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13586. return
  13587. }
  13588. }
  13589. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13590. // utils.ErrorLog("解析失败:%v", err)
  13591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13592. // return
  13593. //}
  13594. if res.Infcode == 0 {
  13595. psn_record.IsCancel = 2
  13596. service.CreatePsnNCDSRecord(&psn_record)
  13597. c.ServeSuccessJSON(map[string]interface{}{
  13598. "failed_code": 0,
  13599. "msg": "撤销备案成功",
  13600. })
  13601. } else {
  13602. c.ServeSuccessJSON(map[string]interface{}{
  13603. "failed_code": -10,
  13604. "msg": res.ErrMsg,
  13605. })
  13606. return
  13607. }
  13608. }
  13609. }
  13610. func (c *HisApiController) TestTest() {
  13611. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  13612. fmt.Println(patient.Iinfo)
  13613. }
  13614. type CustomData struct {
  13615. MsgId string
  13616. PsnNo string
  13617. Info string
  13618. }
  13619. func (c *HisApiController) ReversalData() {
  13620. var customData []*CustomData
  13621. custom := &CustomData{
  13622. MsgId: "H44022900158202103301714472004",
  13623. PsnNo: "44020000001101329945",
  13624. Info: "2207",
  13625. }
  13626. customData = append(customData, custom)
  13627. custom1 := &CustomData{
  13628. MsgId: "H4402290015820210330172057803",
  13629. PsnNo: "44020000001101161813",
  13630. Info: "2207",
  13631. }
  13632. customData = append(customData, custom1)
  13633. custom2 := &CustomData{
  13634. MsgId: "H44022900158202103301705198813",
  13635. PsnNo: "44190000133097375417",
  13636. Info: "2207",
  13637. }
  13638. customData = append(customData, custom2)
  13639. custom3 := &CustomData{
  13640. MsgId: "H44022900158202103301715524756",
  13641. PsnNo: "44020000001100187221",
  13642. Info: "2207",
  13643. }
  13644. customData = append(customData, custom3)
  13645. custom4 := &CustomData{
  13646. MsgId: "H44022900158202103301730376224",
  13647. PsnNo: "44020000001101959155",
  13648. Info: "2207",
  13649. }
  13650. customData = append(customData, custom4)
  13651. custom5 := &CustomData{
  13652. MsgId: "H44022900158202103301748008725",
  13653. PsnNo: "44020000001104246641",
  13654. Info: "2207",
  13655. }
  13656. customData = append(customData, custom5)
  13657. custom6 := &CustomData{
  13658. MsgId: "H44022900158202103301718096755",
  13659. PsnNo: "44020000001102211860",
  13660. Info: "2207",
  13661. }
  13662. customData = append(customData, custom6)
  13663. custom7 := &CustomData{
  13664. MsgId: "H44022900158202103301736551640",
  13665. PsnNo: "44020000001102687718",
  13666. Info: "2207",
  13667. }
  13668. customData = append(customData, custom7)
  13669. custom8 := &CustomData{
  13670. MsgId: "H44022900158202103301743097676",
  13671. PsnNo: "44020000001102127785",
  13672. Info: "2207",
  13673. }
  13674. customData = append(customData, custom8)
  13675. custom9 := &CustomData{
  13676. MsgId: "H44022900158202103301712304203",
  13677. PsnNo: "44020000001101518097",
  13678. Info: "2207",
  13679. }
  13680. customData = append(customData, custom9)
  13681. custom10 := &CustomData{
  13682. MsgId: "H44022900158202103301738448785",
  13683. PsnNo: "44020000001100500813",
  13684. Info: "2207",
  13685. }
  13686. customData = append(customData, custom10)
  13687. custom11 := &CustomData{
  13688. MsgId: "H44022900158202103301732455843",
  13689. PsnNo: "44020000001102690557",
  13690. Info: "2207",
  13691. }
  13692. customData = append(customData, custom11)
  13693. custom12 := &CustomData{
  13694. MsgId: "H44022900158202103301745421708",
  13695. PsnNo: "44020000001102211928",
  13696. Info: "2207",
  13697. }
  13698. customData = append(customData, custom12)
  13699. custom1212 := &CustomData{
  13700. MsgId: "H440229001582021033017351627",
  13701. PsnNo: "44020000001102481733",
  13702. Info: "2207",
  13703. }
  13704. customData = append(customData, custom1212)
  13705. custom13 := &CustomData{
  13706. MsgId: "H44022900158202103301740327951",
  13707. PsnNo: "44020000001103174866",
  13708. Info: "2207",
  13709. }
  13710. customData = append(customData, custom13)
  13711. custom14 := &CustomData{
  13712. MsgId: "H4402290015820210330174922668",
  13713. PsnNo: "44020000001102927272",
  13714. Info: "2207",
  13715. }
  13716. customData = append(customData, custom14)
  13717. custom15 := &CustomData{
  13718. MsgId: "H44022900158202103301752362273",
  13719. PsnNo: "44020000001102942890",
  13720. Info: "2207",
  13721. }
  13722. customData = append(customData, custom15)
  13723. custom16 := &CustomData{
  13724. MsgId: "H44022900158202103301751082917",
  13725. PsnNo: "44020000001101662162",
  13726. Info: "2207",
  13727. }
  13728. customData = append(customData, custom16)
  13729. custom17 := &CustomData{
  13730. MsgId: "H44022900158202103301754147728",
  13731. PsnNo: "44020000000229014511",
  13732. Info: "2207",
  13733. }
  13734. customData = append(customData, custom17)
  13735. adminUser := c.GetAdminUserInfo()
  13736. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13737. for _, item := range customData {
  13738. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13739. fmt.Println(result)
  13740. }
  13741. }
  13742. //func (c *HisApiController) GetAllopatry() {
  13743. // year := c.GetString("year")
  13744. // month := c.GetString("month")
  13745. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13746. // adminUser := c.GetAdminUserInfo()
  13747. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13748. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13749. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13750. //
  13751. // var dat map[string]interface{}
  13752. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13753. // fmt.Println(dat)
  13754. // } else {
  13755. // fmt.Println(err)
  13756. // }
  13757. // userJSONBytes, _ := json.Marshal(dat)
  13758. // var res models.Result9001
  13759. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13760. // utils.ErrorLog("解析失败:%v", err)
  13761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13762. // return
  13763. // }
  13764. //
  13765. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13766. // var dat2 map[string]interface{}
  13767. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13768. // fmt.Println(dat)
  13769. // } else {
  13770. // fmt.Println(err)
  13771. // }
  13772. // userJSONBytes2, _ := json.Marshal(dat2)
  13773. // var res2 models.Result3260
  13774. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13775. // utils.ErrorLog("解析失败:%v", err)
  13776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13777. // return
  13778. // }
  13779. // if res2.Infcode == 0 {
  13780. // c.ServeSuccessJSON(map[string]interface{}{
  13781. // "list": res2.Output.Data,
  13782. // })
  13783. // return
  13784. // } else {
  13785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13786. // return
  13787. // }
  13788. //
  13789. //}
  13790. //func (c *HisApiController) ComfirmAllopatry() {
  13791. // year := c.GetString("year")
  13792. // month := c.GetString("month")
  13793. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13794. // adminUser := c.GetAdminUserInfo()
  13795. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13796. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13797. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13798. // var dat map[string]interface{}
  13799. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13800. // fmt.Println(dat)
  13801. // } else {
  13802. // fmt.Println(err)
  13803. // }
  13804. // userJSONBytes, _ := json.Marshal(dat)
  13805. // var res models.Result9001
  13806. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13807. // utils.ErrorLog("解析失败:%v", err)
  13808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13809. // return
  13810. // }
  13811. //
  13812. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13813. // var dat2 map[string]interface{}
  13814. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13815. // fmt.Println(dat)
  13816. // } else {
  13817. // fmt.Println(err)
  13818. // }
  13819. // userJSONBytes2, _ := json.Marshal(dat2)
  13820. // var res2 models.Result3260
  13821. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13822. // utils.ErrorLog("解析失败:%v", err)
  13823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13824. // return
  13825. // }
  13826. //
  13827. // if res2.Infcode == 0 {
  13828. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13829. // var dat map[string]interface{}
  13830. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13831. // fmt.Println(dat)
  13832. // } else {
  13833. // fmt.Println(err)
  13834. // }
  13835. // userJSONBytes, _ := json.Marshal(dat)
  13836. // var res3 models.Result3261
  13837. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13838. // utils.ErrorLog("解析失败:%v", err)
  13839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13840. // return
  13841. // }
  13842. //
  13843. // if res3.Infcode == 0 {
  13844. // record := &models.HisYidiClearRecord{
  13845. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13846. // Ctime: time.Now().Unix(),
  13847. // Mtime: time.Now().Unix(),
  13848. // Status: 1,
  13849. // MsgId: msgId,
  13850. // }
  13851. // service.SaveClearRecord(record)
  13852. // c.ServeSuccessJSON(map[string]interface{}{
  13853. // "msg": "提取成功",
  13854. // })
  13855. // }
  13856. // }
  13857. //}
  13858. func (c *HisApiController) RefundAllopatry() {
  13859. year := c.GetString("year")
  13860. month := c.GetString("month")
  13861. id, _ := c.GetInt64("id")
  13862. admin_user_id, _ := c.GetInt64("admin_user_id")
  13863. adminUser := c.GetAdminUserInfo()
  13864. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13865. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13866. record, _ := service.GetClearRecordById(id)
  13867. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13868. var dat map[string]interface{}
  13869. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13870. fmt.Println(dat)
  13871. } else {
  13872. fmt.Println(err)
  13873. }
  13874. userJSONBytes, _ := json.Marshal(dat)
  13875. var empty ResultFourteen
  13876. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13877. utils.ErrorLog("解析失败:%v", err)
  13878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13879. return
  13880. }
  13881. if empty.Infcode == 0 {
  13882. c.ServeSuccessJSON(map[string]interface{}{
  13883. "msg": "撤销成功",
  13884. })
  13885. return
  13886. }
  13887. }
  13888. func (c *HisApiController) ReversalOtherData() {
  13889. var customData []*CustomData
  13890. custom := &CustomData{
  13891. MsgId: "H44022900158202103301714472004",
  13892. PsnNo: "44020000001101329945",
  13893. Info: "2208",
  13894. }
  13895. customData = append(customData, custom)
  13896. custom1 := &CustomData{
  13897. MsgId: "H4402290015820210330172057803",
  13898. PsnNo: "44020000001101161813",
  13899. Info: "2208",
  13900. }
  13901. customData = append(customData, custom1)
  13902. custom2 := &CustomData{
  13903. MsgId: "H44022900158202103301705198813",
  13904. PsnNo: "44190000133097375417",
  13905. Info: "2208",
  13906. }
  13907. customData = append(customData, custom2)
  13908. custom3 := &CustomData{
  13909. MsgId: "H44022900158202103301715524756",
  13910. PsnNo: "44020000001100187221",
  13911. Info: "2208",
  13912. }
  13913. customData = append(customData, custom3)
  13914. custom4 := &CustomData{
  13915. MsgId: "H44022900158202103301730376224",
  13916. PsnNo: "44020000001101959155",
  13917. Info: "2208",
  13918. }
  13919. customData = append(customData, custom4)
  13920. custom5 := &CustomData{
  13921. MsgId: "H44022900158202103301748008725",
  13922. PsnNo: "44020000001104246641",
  13923. Info: "2208",
  13924. }
  13925. customData = append(customData, custom5)
  13926. custom6 := &CustomData{
  13927. MsgId: "H44022900158202103301718096755",
  13928. PsnNo: "44020000001102211860",
  13929. Info: "2208",
  13930. }
  13931. customData = append(customData, custom6)
  13932. custom7 := &CustomData{
  13933. MsgId: "H44022900158202103301736551640",
  13934. PsnNo: "44020000001102687718",
  13935. Info: "2208",
  13936. }
  13937. customData = append(customData, custom7)
  13938. custom8 := &CustomData{
  13939. MsgId: "H44022900158202103301743097676",
  13940. PsnNo: "44020000001102127785",
  13941. Info: "2208",
  13942. }
  13943. customData = append(customData, custom8)
  13944. custom9 := &CustomData{
  13945. MsgId: "H44022900158202103301712304203",
  13946. PsnNo: "44020000001101518097",
  13947. Info: "2208",
  13948. }
  13949. customData = append(customData, custom9)
  13950. custom10 := &CustomData{
  13951. MsgId: "H44022900158202103301738448785",
  13952. PsnNo: "44020000001100500813",
  13953. Info: "2208",
  13954. }
  13955. customData = append(customData, custom10)
  13956. custom11 := &CustomData{
  13957. MsgId: "H44022900158202103301732455843",
  13958. PsnNo: "44020000001102690557",
  13959. Info: "2208",
  13960. }
  13961. customData = append(customData, custom11)
  13962. custom12 := &CustomData{
  13963. MsgId: "H44022900158202103301745421708",
  13964. PsnNo: "44020000001102211928",
  13965. Info: "2208",
  13966. }
  13967. customData = append(customData, custom12)
  13968. custom1212 := &CustomData{
  13969. MsgId: "H440229001582021033017351627",
  13970. PsnNo: "44020000001102481733",
  13971. Info: "2208",
  13972. }
  13973. customData = append(customData, custom1212)
  13974. custom13 := &CustomData{
  13975. MsgId: "H44022900158202103301740327951",
  13976. PsnNo: "44020000001103174866",
  13977. Info: "2208",
  13978. }
  13979. customData = append(customData, custom13)
  13980. custom14 := &CustomData{
  13981. MsgId: "H4402290015820210330174922668",
  13982. PsnNo: "44020000001102927272",
  13983. Info: "2208",
  13984. }
  13985. customData = append(customData, custom14)
  13986. custom15 := &CustomData{
  13987. MsgId: "H44022900158202103301752362273",
  13988. PsnNo: "44020000001102942890",
  13989. Info: "2208",
  13990. }
  13991. customData = append(customData, custom15)
  13992. custom16 := &CustomData{
  13993. MsgId: "H44022900158202103301751082917",
  13994. PsnNo: "44020000001101662162",
  13995. Info: "2208",
  13996. }
  13997. customData = append(customData, custom16)
  13998. custom17 := &CustomData{
  13999. MsgId: "H44022900158202103301754147728",
  14000. PsnNo: "44020000000229014511",
  14001. Info: "2208",
  14002. }
  14003. customData = append(customData, custom17)
  14004. adminUser := c.GetAdminUserInfo()
  14005. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14006. for _, item := range customData {
  14007. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14008. fmt.Println(result)
  14009. }
  14010. }
  14011. func PathExists(path string) (bool, error) {
  14012. _, err := os.Stat(path)
  14013. if err == nil {
  14014. return true, nil
  14015. }
  14016. if os.IsNotExist(err) {
  14017. return false, nil
  14018. }
  14019. return false, err
  14020. }
  14021. //创建文件夹
  14022. func Mkdir(dir string) {
  14023. // 创建文件夹
  14024. exist, err := PathExists(dir)
  14025. if err != nil {
  14026. fmt.Println(err.Error())
  14027. } else {
  14028. if exist {
  14029. fmt.Println(dir + "文件夹已存在!")
  14030. } else {
  14031. // 文件夹名称,权限
  14032. err := os.Mkdir(dir, os.ModePerm)
  14033. if err != nil {
  14034. fmt.Println(dir+"文件夹创建失败:", err.Error())
  14035. } else {
  14036. fmt.Println(dir + "文件夹创建成功!")
  14037. }
  14038. }
  14039. }
  14040. }
  14041. //压缩文件
  14042. func Zip(srcFile string, destZip string) error {
  14043. zipfile, err := os.Create(destZip)
  14044. if err != nil {
  14045. return err
  14046. }
  14047. defer zipfile.Close()
  14048. archive := zip.NewWriter(zipfile)
  14049. defer archive.Close()
  14050. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  14051. if err != nil {
  14052. return err
  14053. }
  14054. header, err := zip.FileInfoHeader(info)
  14055. if err != nil {
  14056. return err
  14057. }
  14058. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  14059. // header.Name = path
  14060. if info.IsDir() {
  14061. header.Name += "/"
  14062. } else {
  14063. header.Method = zip.Deflate
  14064. }
  14065. writer, err := archive.CreateHeader(header)
  14066. if err != nil {
  14067. return err
  14068. }
  14069. if !info.IsDir() {
  14070. file, err := os.Open(path)
  14071. if err != nil {
  14072. return err
  14073. }
  14074. defer file.Close()
  14075. _, err = io.Copy(writer, file)
  14076. }
  14077. return err
  14078. })
  14079. return err
  14080. }
  14081. func ReadFile(filePath string) []byte {
  14082. f, err := os.Open(filePath)
  14083. if err != nil {
  14084. fmt.Println("read file fail", err)
  14085. return nil
  14086. }
  14087. defer f.Close()
  14088. fd, err := ioutil.ReadAll(f)
  14089. if err != nil {
  14090. fmt.Println("read to fd fail", err)
  14091. return nil
  14092. }
  14093. return fd
  14094. }
  14095. func saveLog(result string, request string, infno string, desc string) {
  14096. org_id, _ := beego.AppConfig.Int64("org_id")
  14097. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14098. dir := miConfig.OrgName + "日志"
  14099. utils.Mkdir(dir)
  14100. month := time.Unix(1557042972, 0).Format("1")
  14101. year := time.Now().Format("2006")
  14102. month = time.Now().Format("01")
  14103. day := time.Now().Format("02")
  14104. hour := time.Now().Format("15")
  14105. min := time.Now().Format("04")
  14106. sec := time.Now().Format("05")
  14107. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  14108. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  14109. file_name := file + ".txt"
  14110. file_path := miConfig.OrgName + "日志" + "/" + file_name
  14111. exist, _ := utils.PathExists(file_path)
  14112. if exist { //存在
  14113. fmt.Println("存在")
  14114. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  14115. if err != nil {
  14116. fmt.Println("read fail")
  14117. }
  14118. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  14119. n, _ := f.Seek(0, 2)
  14120. _, err = f.WriteAt([]byte(content), n)
  14121. } else { //不存在
  14122. fmt.Println("文件不存在,创建文件")
  14123. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  14124. defer f.Close()
  14125. if err != nil {
  14126. } else {
  14127. _, err = f.Write([]byte("记录日志"))
  14128. }
  14129. }
  14130. }
  14131. type Charset string
  14132. const (
  14133. UTF8 = Charset("UTF-8")
  14134. GB18030 = Charset("GB18030")
  14135. )
  14136. func ConvertToString(src string, srcCode string, tagCode string) string {
  14137. srcCoder := mahonia.NewDecoder(srcCode)
  14138. srcResult := srcCoder.ConvertString(src)
  14139. tagCoder := mahonia.NewDecoder(tagCode)
  14140. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  14141. result := string(cdata)
  14142. return result
  14143. }
  14144. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  14145. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  14146. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14147. var token string
  14148. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14149. var api string
  14150. if miConfig.MdtrtareaAdmvs == "320921" {
  14151. 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 +
  14152. "&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
  14153. fmt.Println(api)
  14154. } else {
  14155. 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 +
  14156. "&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
  14157. }
  14158. resp, requestErr := http.Get(api)
  14159. if requestErr != nil {
  14160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14161. return ""
  14162. }
  14163. body, ioErr := ioutil.ReadAll(resp.Body)
  14164. if ioErr != nil {
  14165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14167. return ""
  14168. }
  14169. var respJSON map[string]interface{}
  14170. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14173. return ""
  14174. }
  14175. var status string
  14176. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14177. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14178. var res ResultTwo //1101结果
  14179. var res10265 ResultTwo10265 //1101结果
  14180. if status == "0" { //读卡成功
  14181. var card_info string //卡信息
  14182. var busi_card_info string
  14183. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14184. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14185. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14186. fmt.Println(card_info)
  14187. fmt.Println(busi_card_info)
  14188. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14189. result, _ := json.Marshal(respJSON)
  14190. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14191. utils.ErrorLog("解析失败:%v", err)
  14192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14193. return ""
  14194. }
  14195. res.ErrMsg = res10265.ErrMsg
  14196. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14197. res.Infcode = infocode
  14198. res.Output = res10265.Output
  14199. res.InfRefmsgid = res10265.InfRefmsgid
  14200. if res.Infcode == 0 {
  14201. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14202. if err == gorm.ErrRecordNotFound {
  14203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14204. return ""
  14205. } else if err != nil {
  14206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14207. return ""
  14208. } else {
  14209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14211. infoStr := string(Iinfos)
  14212. idetinfoStr := string(Idetinfos)
  14213. psn := &models.HisPsn{
  14214. PsnNo: res.Output.Baseinfo.PsnNo,
  14215. Age: res.Output.Baseinfo.Age,
  14216. PatientId: patient.ID,
  14217. Certno: res.Output.Baseinfo.Certno,
  14218. Brdy: res.Output.Baseinfo.Brdy,
  14219. Gend: res.Output.Baseinfo.Gend,
  14220. Naty: res.Output.Baseinfo.Naty,
  14221. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14222. PsnName: res.Output.Baseinfo.PsnName,
  14223. Idetinfo: idetinfoStr,
  14224. Insuinfo: infoStr,
  14225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14226. CardInfo: card_info,
  14227. VerifyNumber: token,
  14228. }
  14229. service.CreateHisPsn(psn)
  14230. return token
  14231. }
  14232. }
  14233. } else {
  14234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14235. return ""
  14236. }
  14237. } else { //读卡失败
  14238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14239. return ""
  14240. }
  14241. return token
  14242. }
  14243. func DeleteExtraSpaceTwo(s string) string {
  14244. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14245. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14246. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14247. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14248. s2 := make([]byte, len(s1)) //定义字符数组切片
  14249. copy(s2, s1) //将字符串复制到切片
  14250. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14251. for len(spc_index) > 0 { //找到适配项
  14252. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14253. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14254. }
  14255. return string(s2)
  14256. }
  14257. func Remove0000(s string) string {
  14258. str := make([]rune, 0, len(s))
  14259. for _, v := range []rune(s) {
  14260. if v == 0 {
  14261. continue
  14262. }
  14263. str = append(str, v)
  14264. }
  14265. return string(str)
  14266. }
  14267. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  14268. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  14269. readCard := DllDef.MustFindProc("EcQuery")
  14270. pCardInfo := make([]byte, 8192)
  14271. pBusiCardInfo := make([]byte, 8192)
  14272. data := make(map[string]interface{})
  14273. //pData := make(map[string]interface{})
  14274. inputData := make(map[string]interface{})
  14275. inputData["orgId"] = code
  14276. inputData["businessType"] = "01101"
  14277. inputData["operatorId"] = operator_id
  14278. inputData["operatorName"] = operator_name
  14279. inputData["officeId"] = "001"
  14280. inputData["officeName"] = "血透室"
  14281. //
  14282. data["data"] = inputData
  14283. data["transType"] = "ec.query"
  14284. data["orgId"] = code
  14285. bytesData, _ := json.Marshal(data)
  14286. pCardInfo = bytesData
  14287. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14288. fmt.Println(ret2)
  14289. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  14290. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14291. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  14292. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14293. if ret2 != 0 {
  14294. return "", ""
  14295. }
  14296. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  14297. }
  14298. func DeleteExtraSpace(s string) string {
  14299. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14300. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14301. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14302. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14303. s2 := make([]byte, len(s1)) //定义字符数组切片
  14304. copy(s2, s1) //将字符串复制到切片
  14305. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14306. for len(spc_index) > 0 { //找到适配项
  14307. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14308. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14309. }
  14310. return string(s2)
  14311. }
  14312. //对账
  14313. func (c *HisApiController) Post3202() {
  14314. start_time := c.GetString("start_time")
  14315. end_time := c.GetString("end_time")
  14316. //insutype := c.GetString("insutype")
  14317. clr_type := c.GetString("clr_type")
  14318. clr_org := c.GetString("clr_optins")
  14319. admin_user_id, _ := c.GetInt64("admin_user_id")
  14320. adminUser := c.GetAdminUserInfo()
  14321. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14322. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14323. if len(clr_org) == 0 {
  14324. clr_org = miConfig.MdtrtareaAdmvs
  14325. }
  14326. timeLayout := "2006-01-02"
  14327. loc, _ := time.LoadLocation("Local")
  14328. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14329. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14330. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14331. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14332. //fixmedins_setl_cnt := int64(len(orders))
  14333. var medfee_sumamt float64
  14334. var acct_pay float64
  14335. var fund_pay_sumamt float64
  14336. for _, item := range orders {
  14337. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14338. acct_pay = acct_pay + item.AcctPay
  14339. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14340. }
  14341. //var medfee_sumamt_two float64
  14342. //var acct_pay_two float64
  14343. //var fund_pay_sumamt_two float64
  14344. //for _, item := range orders_two {
  14345. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  14346. // acct_pay_two = acct_pay_two + item.AcctPay
  14347. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  14348. //}
  14349. //var user_name string
  14350. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14351. //if role.ID == 0 {
  14352. // user_name = "xxx"
  14353. //} else {
  14354. // user_name = role.UserName
  14355. //}
  14356. var res ResultSix
  14357. if config.IsOpen == 1 {
  14358. var bps []*models.BusinessParamsTwo
  14359. var bp models.BusinessParamsTwo
  14360. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  14361. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  14362. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  14363. bp.MedfeeSumamt = medfee_sumamt_str
  14364. bp.AcctPay = acct_pay_str
  14365. bp.FundPaySumamt = fund_pay_sumamt_str
  14366. bp.Insutype = "390"
  14367. bp.StmtBegndate = start_time
  14368. bp.ClrType = clr_type
  14369. bp.SetlOptins = clr_org
  14370. bp.StmtEnddate = end_time
  14371. bps = append(bps, &bp)
  14372. data := make(map[string]interface{})
  14373. data["bps"] = bps
  14374. data["org_name"] = miConfig.OrgName
  14375. data["doctor"] = role.UserName
  14376. data["fixmedins_code"] = miConfig.Code
  14377. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14378. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14379. if miConfig.MdtrtareaAdmvs == "421300" {
  14380. client := &http.Client{}
  14381. bytesData, _ := json.Marshal(data)
  14382. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  14383. resp, _ := client.Do(req)
  14384. defer resp.Body.Close()
  14385. body, ioErr := ioutil.ReadAll(resp.Body)
  14386. if ioErr != nil {
  14387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14389. return
  14390. }
  14391. var respJSON map[string]interface{}
  14392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14395. return
  14396. }
  14397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14398. userJSONBytes, _ := json.Marshal(respJSON)
  14399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14400. utils.ErrorLog("解析失败:%v", err)
  14401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14402. return
  14403. }
  14404. }
  14405. if res.Infcode == 0 {
  14406. c.ServeSuccessJSON(map[string]interface{}{
  14407. "msg": "发起成功",
  14408. })
  14409. } else {
  14410. c.ServeSuccessJSON(map[string]interface{}{
  14411. "code": -10,
  14412. "msg": res.ErrMsg,
  14413. })
  14414. }
  14415. }
  14416. }
  14417. func (c *HisApiController) Post3501() {
  14418. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14419. data := make(map[string]interface{})
  14420. var struct3501s []models.Struct3501
  14421. var struct3501 models.Struct3501
  14422. struct3501.OrgName = miConfig.OrgName
  14423. struct3501.AccessKey = miConfig.AccessKey
  14424. struct3501.RequestUrl = miConfig.Url
  14425. struct3501.SecretKey = miConfig.SecretKey
  14426. struct3501.ManuDate = "2022-08-17"
  14427. struct3501.FixmedinsBchno = ""
  14428. struct3501.ManuLotnum = ""
  14429. struct3501.RxFlag = "0"
  14430. struct3501.ExpyEnd = "2022-08-17"
  14431. struct3501.Invdate = "2022-08-17"
  14432. struct3501.InvCnt = "20.25"
  14433. struct3501.Memo = ""
  14434. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14435. struct3501.FixmedinsHilistId = miConfig.Code
  14436. struct3501.FixmedinsHilistName = miConfig.OrgName
  14437. struct3501s = append(struct3501s, struct3501)
  14438. data["struct_3501s"] = struct3501s
  14439. client := &http.Client{}
  14440. bytesData, _ := json.Marshal(data)
  14441. var req *http.Request
  14442. if miConfig.MdtrtareaAdmvs == "320921" {
  14443. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14444. } else {
  14445. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14446. }
  14447. resp, _ := client.Do(req)
  14448. defer resp.Body.Close()
  14449. body, ioErr := ioutil.ReadAll(resp.Body)
  14450. if ioErr != nil {
  14451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14453. return
  14454. }
  14455. var respJSON map[string]interface{}
  14456. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14459. return
  14460. }
  14461. var res ResultSix
  14462. var resSix10265 ResultSix10265 //1101结果
  14463. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14464. result, _ := json.Marshal(respJSON)
  14465. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14466. utils.ErrorLog("解析失败:%v", err)
  14467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14468. return
  14469. }
  14470. res.InfRefmsgid = resSix10265.InfRefmsgid
  14471. res.Output = resSix10265.Output
  14472. res.ErrMsg = resSix10265.ErrMsg
  14473. res.Cainfo = resSix10265.Cainfo
  14474. res.WarnMsg = resSix10265.WarnMsg
  14475. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14476. res.Infcode = infocode
  14477. if infocode == 0 {
  14478. c.ServeSuccessJSON(map[string]interface{}{
  14479. "msg": "上传成功",
  14480. })
  14481. return
  14482. } else {
  14483. c.ServeSuccessJSON(map[string]interface{}{
  14484. "failed_code": -10,
  14485. "msg": res.ErrMsg,
  14486. })
  14487. return
  14488. }
  14489. }
  14490. func (c *HisApiController) Post3502() {
  14491. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14492. data := make(map[string]interface{})
  14493. var struct3502s []models.Struct3502
  14494. var struct3502 models.Struct3502
  14495. struct3502.OrgName = miConfig.OrgName
  14496. struct3502.AccessKey = miConfig.AccessKey
  14497. struct3502.RequestUrl = miConfig.Url
  14498. struct3502.SecretKey = miConfig.SecretKey
  14499. struct3502.ManuDate = "2022-08-15"
  14500. struct3502.FixmedinsBchno = ""
  14501. struct3502.ManuLotnum = ""
  14502. struct3502.RxFlag = "0"
  14503. struct3502.ExpyEnd = "2022-08-15"
  14504. struct3502.Invdate = "2022-08-15"
  14505. struct3502.InvCnt = "20.25"
  14506. struct3502.Memo = ""
  14507. struct3502.MedListCodg = "XB01ABD056B002020200517"
  14508. struct3502.FixmedinsHilistId = miConfig.Code
  14509. struct3502.FixmedinsHilistName = miConfig.OrgName
  14510. struct3502s = append(struct3502s, struct3502)
  14511. data["struct_3502s"] = struct3502s
  14512. client := &http.Client{}
  14513. bytesData, _ := json.Marshal(data)
  14514. var req *http.Request
  14515. if miConfig.MdtrtareaAdmvs == "320921" {
  14516. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14517. } else {
  14518. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14519. }
  14520. resp, _ := client.Do(req)
  14521. defer resp.Body.Close()
  14522. body, ioErr := ioutil.ReadAll(resp.Body)
  14523. if ioErr != nil {
  14524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14526. return
  14527. }
  14528. var respJSON map[string]interface{}
  14529. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14532. return
  14533. }
  14534. var res ResultSix
  14535. var resSix10265 ResultSix10265 //1101结果
  14536. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14537. result, _ := json.Marshal(respJSON)
  14538. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14539. utils.ErrorLog("解析失败:%v", err)
  14540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14541. return
  14542. }
  14543. res.InfRefmsgid = resSix10265.InfRefmsgid
  14544. res.Output = resSix10265.Output
  14545. res.ErrMsg = resSix10265.ErrMsg
  14546. res.Cainfo = resSix10265.Cainfo
  14547. res.WarnMsg = resSix10265.WarnMsg
  14548. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14549. res.Infcode = infocode
  14550. if infocode == 0 {
  14551. c.ServeSuccessJSON(map[string]interface{}{
  14552. "msg": "上传成功",
  14553. })
  14554. return
  14555. } else {
  14556. c.ServeSuccessJSON(map[string]interface{}{
  14557. "failed_code": -10,
  14558. "msg": res.ErrMsg,
  14559. })
  14560. return
  14561. }
  14562. }
  14563. func (c *HisApiController) Post3503() {
  14564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14565. data := make(map[string]interface{})
  14566. var struct3501s []models.Struct3501
  14567. var struct3501 models.Struct3501
  14568. struct3501.OrgName = miConfig.OrgName
  14569. struct3501.AccessKey = miConfig.AccessKey
  14570. struct3501.RequestUrl = miConfig.Url
  14571. struct3501.SecretKey = miConfig.SecretKey
  14572. struct3501.ManuDate = "2022-08-15"
  14573. struct3501.FixmedinsBchno = ""
  14574. struct3501.ManuLotnum = ""
  14575. struct3501.RxFlag = "0"
  14576. struct3501.ExpyEnd = "2022-08-15"
  14577. struct3501.Invdate = "2022-08-15"
  14578. struct3501.InvCnt = "20.25"
  14579. struct3501.Memo = ""
  14580. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14581. struct3501.FixmedinsHilistId = miConfig.Code
  14582. struct3501.FixmedinsHilistName = miConfig.OrgName
  14583. struct3501s = append(struct3501s, struct3501)
  14584. data["struct_3501s"] = struct3501s
  14585. client := &http.Client{}
  14586. bytesData, _ := json.Marshal(data)
  14587. var req *http.Request
  14588. if miConfig.MdtrtareaAdmvs == "320921" {
  14589. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14590. } else {
  14591. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14592. }
  14593. resp, _ := client.Do(req)
  14594. defer resp.Body.Close()
  14595. body, ioErr := ioutil.ReadAll(resp.Body)
  14596. if ioErr != nil {
  14597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14599. return
  14600. }
  14601. var respJSON map[string]interface{}
  14602. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14605. return
  14606. }
  14607. var res ResultSix
  14608. var resSix10265 ResultSix10265 //1101结果
  14609. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14610. result, _ := json.Marshal(respJSON)
  14611. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14612. utils.ErrorLog("解析失败:%v", err)
  14613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14614. return
  14615. }
  14616. res.InfRefmsgid = resSix10265.InfRefmsgid
  14617. res.Output = resSix10265.Output
  14618. res.ErrMsg = resSix10265.ErrMsg
  14619. res.Cainfo = resSix10265.Cainfo
  14620. res.WarnMsg = resSix10265.WarnMsg
  14621. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14622. res.Infcode = infocode
  14623. if infocode == 0 {
  14624. c.ServeSuccessJSON(map[string]interface{}{
  14625. "msg": "上传成功",
  14626. })
  14627. return
  14628. } else {
  14629. c.ServeSuccessJSON(map[string]interface{}{
  14630. "failed_code": -10,
  14631. "msg": res.ErrMsg,
  14632. })
  14633. return
  14634. }
  14635. }
  14636. func (c *HisApiController) Post3504() {
  14637. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14638. data := make(map[string]interface{})
  14639. var struct3501s []models.Struct3501
  14640. var struct3501 models.Struct3501
  14641. struct3501.OrgName = miConfig.OrgName
  14642. struct3501.AccessKey = miConfig.AccessKey
  14643. struct3501.RequestUrl = miConfig.Url
  14644. struct3501.SecretKey = miConfig.SecretKey
  14645. struct3501.ManuDate = "2022-08-15"
  14646. struct3501.FixmedinsBchno = ""
  14647. struct3501.ManuLotnum = ""
  14648. struct3501.RxFlag = "0"
  14649. struct3501.ExpyEnd = "2022-08-15"
  14650. struct3501.Invdate = "2022-08-15"
  14651. struct3501.InvCnt = "20.25"
  14652. struct3501.Memo = ""
  14653. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14654. struct3501.FixmedinsHilistId = miConfig.Code
  14655. struct3501.FixmedinsHilistName = miConfig.OrgName
  14656. struct3501s = append(struct3501s, struct3501)
  14657. data["struct_3501s"] = struct3501s
  14658. client := &http.Client{}
  14659. bytesData, _ := json.Marshal(data)
  14660. var req *http.Request
  14661. if miConfig.MdtrtareaAdmvs == "320921" {
  14662. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14663. } else {
  14664. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14665. }
  14666. resp, _ := client.Do(req)
  14667. defer resp.Body.Close()
  14668. body, ioErr := ioutil.ReadAll(resp.Body)
  14669. if ioErr != nil {
  14670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14672. return
  14673. }
  14674. var respJSON map[string]interface{}
  14675. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14678. return
  14679. }
  14680. var res ResultSix
  14681. var resSix10265 ResultSix10265 //1101结果
  14682. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14683. result, _ := json.Marshal(respJSON)
  14684. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14685. utils.ErrorLog("解析失败:%v", err)
  14686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14687. return
  14688. }
  14689. res.InfRefmsgid = resSix10265.InfRefmsgid
  14690. res.Output = resSix10265.Output
  14691. res.ErrMsg = resSix10265.ErrMsg
  14692. res.Cainfo = resSix10265.Cainfo
  14693. res.WarnMsg = resSix10265.WarnMsg
  14694. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14695. res.Infcode = infocode
  14696. if infocode == 0 {
  14697. c.ServeSuccessJSON(map[string]interface{}{
  14698. "msg": "上传成功",
  14699. })
  14700. return
  14701. } else {
  14702. c.ServeSuccessJSON(map[string]interface{}{
  14703. "failed_code": -10,
  14704. "msg": res.ErrMsg,
  14705. })
  14706. return
  14707. }
  14708. }
  14709. func (c *HisApiController) Post3505() {
  14710. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14711. data := make(map[string]interface{})
  14712. var struct3501s []models.Struct3501
  14713. var struct3501 models.Struct3501
  14714. struct3501.OrgName = miConfig.OrgName
  14715. struct3501.AccessKey = miConfig.AccessKey
  14716. struct3501.RequestUrl = miConfig.Url
  14717. struct3501.SecretKey = miConfig.SecretKey
  14718. struct3501.ManuDate = "2022-08-15"
  14719. struct3501.FixmedinsBchno = ""
  14720. struct3501.ManuLotnum = ""
  14721. struct3501.RxFlag = "0"
  14722. struct3501.ExpyEnd = "2022-08-15"
  14723. struct3501.Invdate = "2022-08-15"
  14724. struct3501.InvCnt = "20.25"
  14725. struct3501.Memo = ""
  14726. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14727. struct3501.FixmedinsHilistId = miConfig.Code
  14728. struct3501.FixmedinsHilistName = miConfig.OrgName
  14729. struct3501s = append(struct3501s, struct3501)
  14730. data["struct_3501s"] = struct3501s
  14731. client := &http.Client{}
  14732. bytesData, _ := json.Marshal(data)
  14733. var req *http.Request
  14734. if miConfig.MdtrtareaAdmvs == "320921" {
  14735. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14736. } else {
  14737. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14738. }
  14739. resp, _ := client.Do(req)
  14740. defer resp.Body.Close()
  14741. body, ioErr := ioutil.ReadAll(resp.Body)
  14742. if ioErr != nil {
  14743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14745. return
  14746. }
  14747. var respJSON map[string]interface{}
  14748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14751. return
  14752. }
  14753. var res ResultSix
  14754. var resSix10265 ResultSix10265 //1101结果
  14755. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14756. result, _ := json.Marshal(respJSON)
  14757. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14758. utils.ErrorLog("解析失败:%v", err)
  14759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14760. return
  14761. }
  14762. res.InfRefmsgid = resSix10265.InfRefmsgid
  14763. res.Output = resSix10265.Output
  14764. res.ErrMsg = resSix10265.ErrMsg
  14765. res.Cainfo = resSix10265.Cainfo
  14766. res.WarnMsg = resSix10265.WarnMsg
  14767. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14768. res.Infcode = infocode
  14769. if infocode == 0 {
  14770. c.ServeSuccessJSON(map[string]interface{}{
  14771. "msg": "上传成功",
  14772. })
  14773. return
  14774. } else {
  14775. c.ServeSuccessJSON(map[string]interface{}{
  14776. "failed_code": -10,
  14777. "msg": res.ErrMsg,
  14778. })
  14779. return
  14780. }
  14781. }
  14782. func (c *HisApiController) Post3506() {
  14783. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14784. data := make(map[string]interface{})
  14785. var struct3501s []models.Struct3501
  14786. var struct3501 models.Struct3501
  14787. struct3501.OrgName = miConfig.OrgName
  14788. struct3501.AccessKey = miConfig.AccessKey
  14789. struct3501.RequestUrl = miConfig.Url
  14790. struct3501.SecretKey = miConfig.SecretKey
  14791. struct3501.ManuDate = "2022-08-15"
  14792. struct3501.FixmedinsBchno = ""
  14793. struct3501.ManuLotnum = ""
  14794. struct3501.RxFlag = "0"
  14795. struct3501.ExpyEnd = "2022-08-15"
  14796. struct3501.Invdate = "2022-08-15"
  14797. struct3501.InvCnt = "20.25"
  14798. struct3501.Memo = ""
  14799. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14800. struct3501.FixmedinsHilistId = miConfig.Code
  14801. struct3501.FixmedinsHilistName = miConfig.OrgName
  14802. struct3501s = append(struct3501s, struct3501)
  14803. data["struct_3501s"] = struct3501s
  14804. client := &http.Client{}
  14805. bytesData, _ := json.Marshal(data)
  14806. var req *http.Request
  14807. if miConfig.MdtrtareaAdmvs == "320921" {
  14808. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14809. } else {
  14810. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14811. }
  14812. resp, _ := client.Do(req)
  14813. defer resp.Body.Close()
  14814. body, ioErr := ioutil.ReadAll(resp.Body)
  14815. if ioErr != nil {
  14816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14818. return
  14819. }
  14820. var respJSON map[string]interface{}
  14821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14824. return
  14825. }
  14826. var res ResultSix
  14827. var resSix10265 ResultSix10265 //1101结果
  14828. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14829. result, _ := json.Marshal(respJSON)
  14830. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14831. utils.ErrorLog("解析失败:%v", err)
  14832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14833. return
  14834. }
  14835. res.InfRefmsgid = resSix10265.InfRefmsgid
  14836. res.Output = resSix10265.Output
  14837. res.ErrMsg = resSix10265.ErrMsg
  14838. res.Cainfo = resSix10265.Cainfo
  14839. res.WarnMsg = resSix10265.WarnMsg
  14840. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14841. res.Infcode = infocode
  14842. if infocode == 0 {
  14843. c.ServeSuccessJSON(map[string]interface{}{
  14844. "msg": "上传成功",
  14845. })
  14846. return
  14847. } else {
  14848. c.ServeSuccessJSON(map[string]interface{}{
  14849. "failed_code": -10,
  14850. "msg": res.ErrMsg,
  14851. })
  14852. return
  14853. }
  14854. }
  14855. func (c *HisApiController) Post3507() {
  14856. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14857. data := make(map[string]interface{})
  14858. var struct3501s []models.Struct3501
  14859. var struct3501 models.Struct3501
  14860. struct3501.OrgName = miConfig.OrgName
  14861. struct3501.AccessKey = miConfig.AccessKey
  14862. struct3501.RequestUrl = miConfig.Url
  14863. struct3501.SecretKey = miConfig.SecretKey
  14864. struct3501.ManuDate = "2022-08-15"
  14865. struct3501.FixmedinsBchno = ""
  14866. struct3501.ManuLotnum = ""
  14867. struct3501.RxFlag = "0"
  14868. struct3501.ExpyEnd = "2022-08-15"
  14869. struct3501.Invdate = "2022-08-15"
  14870. struct3501.InvCnt = "20.25"
  14871. struct3501.Memo = ""
  14872. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14873. struct3501.FixmedinsHilistId = miConfig.Code
  14874. struct3501.FixmedinsHilistName = miConfig.OrgName
  14875. struct3501s = append(struct3501s, struct3501)
  14876. data["struct_3501s"] = struct3501s
  14877. client := &http.Client{}
  14878. bytesData, _ := json.Marshal(data)
  14879. var req *http.Request
  14880. if miConfig.MdtrtareaAdmvs == "320921" {
  14881. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14882. } else {
  14883. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14884. }
  14885. resp, _ := client.Do(req)
  14886. defer resp.Body.Close()
  14887. body, ioErr := ioutil.ReadAll(resp.Body)
  14888. if ioErr != nil {
  14889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14891. return
  14892. }
  14893. var respJSON map[string]interface{}
  14894. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14897. return
  14898. }
  14899. var res ResultSix
  14900. var resSix10265 ResultSix10265 //1101结果
  14901. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14902. result, _ := json.Marshal(respJSON)
  14903. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14904. utils.ErrorLog("解析失败:%v", err)
  14905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14906. return
  14907. }
  14908. res.InfRefmsgid = resSix10265.InfRefmsgid
  14909. res.Output = resSix10265.Output
  14910. res.ErrMsg = resSix10265.ErrMsg
  14911. res.Cainfo = resSix10265.Cainfo
  14912. res.WarnMsg = resSix10265.WarnMsg
  14913. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14914. res.Infcode = infocode
  14915. if infocode == 0 {
  14916. c.ServeSuccessJSON(map[string]interface{}{
  14917. "msg": "上传成功",
  14918. })
  14919. return
  14920. } else {
  14921. c.ServeSuccessJSON(map[string]interface{}{
  14922. "failed_code": -10,
  14923. "msg": res.ErrMsg,
  14924. })
  14925. return
  14926. }
  14927. }