his_api_controller.go 442KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142
  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. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. //beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  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. }
  79. func (c *HisApiController) Get9001() {
  80. adminUser := c.GetAdminUserInfo()
  81. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  82. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  83. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  84. var dat map[string]interface{}
  85. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  86. fmt.Println(dat)
  87. } else {
  88. fmt.Println(err)
  89. }
  90. userJSONBytes, _ := json.Marshal(dat)
  91. var res models.Result9001
  92. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  93. utils.ErrorLog("解析失败:%v", err)
  94. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  95. return
  96. }
  97. }
  98. func (c *HisApiController) Check3101() {
  99. patient_id, _ := c.GetInt64("patient_id")
  100. his_patient_id, _ := c.GetInt64("his_patient_id")
  101. admin_user_id, _ := c.GetInt64("admin_user_id")
  102. adminUser := c.GetAdminUserInfo()
  103. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  104. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  105. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  106. record_time := c.GetString("record_time")
  107. trig_scen := c.GetString("trig_scen")
  108. timeLayout := "2006-01-02"
  109. loc, _ := time.LoadLocation("Local")
  110. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  111. if err != nil {
  112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  113. return
  114. }
  115. recordDateTime := theTime.Unix()
  116. var patientPrescription models.HisPrescriptionInfo
  117. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  118. if patientPrescription.ID == 0 {
  119. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  120. }
  121. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  122. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  123. //
  124. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  125. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  126. var pp models.PublicParams
  127. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  128. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  129. pp.FixmedinsName = miConfig.OrgName
  130. pp.FixmedinsCode = miConfig.Code
  131. pp.RequestUrl = miConfig.Url
  132. pp.Cainfo = miConfig.Cainfo
  133. pp.SecretKey = miConfig.SecretKey
  134. pp.AccessKey = miConfig.AccessKey
  135. pp.OpterName = roles.UserName
  136. var config []*models.HisXtDiagnoseConfig
  137. for _, item := range diagnosis_ids {
  138. id, _ := strconv.ParseInt(item, 10, 64)
  139. diagnosisConfig, _ := service.FindDiagnoseById(id)
  140. config = append(config, &diagnosisConfig)
  141. }
  142. var pd models.PatientDtos
  143. pd.PatnID = his.PsnNo
  144. pd.PatnName = his.Name
  145. pd.Gend = his.Gend
  146. pd.Brdy = his.Brdy
  147. pd.Poolarea = his.InsuplcAdmdvs
  148. pd.CurrMdtrtID = his.Number
  149. var fed models.FsiEncounterDtos
  150. fed.MdtrtID = his.Number
  151. fed.MedinsID = miConfig.Code
  152. fed.MedinsName = miConfig.OrgName
  153. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  154. fed.MedMdtrtType = "1"
  155. fed.MedinsType = "1"
  156. fed.MedinsLv = "11"
  157. tm := time.Unix(his.RecordDate, 0)
  158. s_tm := tm.Format("2006-01-02 15:04:05")
  159. fed.AdmDate = s_tm
  160. fed.DscgDate = s_tm
  161. fed.DscgMainDiseCodg = config[0].CountryCode
  162. fed.DscgMainDiseName = config[0].CountryContentName
  163. //诊断信息
  164. var fdds []*models.FsiDiagnoseDtos
  165. for index, item := range config {
  166. if index == 0 {
  167. var fdd models.FsiDiagnoseDtos
  168. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  169. fdd.InoutDiseType = "1"
  170. fdd.MaindiseFlag = "1"
  171. fdd.DiseDate = s_tm
  172. fdd.DiasSrtNo = "1"
  173. fdd.DiseName = item.CountryContentName
  174. fdd.DiseCodg = item.CountryCode
  175. fdds = append(fdds, &fdd)
  176. } else {
  177. var fdd models.FsiDiagnoseDtos
  178. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  179. fdd.InoutDiseType = "1"
  180. fdd.MaindiseFlag = "1"
  181. fdd.DiseDate = s_tm
  182. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  183. fdd.DiseName = item.CountryContentName
  184. fdd.DiseCodg = item.CountryCode
  185. fdds = append(fdds, &fdd)
  186. }
  187. }
  188. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  189. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  190. fed.AdmDeptName = department.Name
  191. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  192. fed.DscgDeptName = department.Name
  193. fed.MedMdtrtType = "1"
  194. fed.MedType = "11"
  195. //if his.Insutype == "390" {
  196. // fed.MedType = "1402"
  197. //} else {
  198. // fed.MedType = "9933"
  199. //}
  200. var orders []*models.FsiOrderDtos
  201. if trig_scen == "2" {
  202. //处方医嘱信息
  203. for _, item := range prescriptions {
  204. for _, subItem := range item.HisDoctorAdviceInfo {
  205. var order models.FsiOrderDtos
  206. order.RxID = strconv.FormatInt(item.ID, 10)
  207. order.Rxno = strconv.FormatInt(item.ID, 10)
  208. order.LongDrordFlag = "0"
  209. order.HilistType = "1"
  210. order.ChrgType = "1"
  211. order.DrordBhvr = "-"
  212. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  213. order.HosplistName = subItem.BaseDrugLib.DrugName
  214. order.HilistLv = "1"
  215. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  216. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  217. order.HosplistName = subItem.BaseDrugLib.DrugName
  218. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  219. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  220. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  221. order.OwnpayAmt = ""
  222. order.SelfpayAmt = ""
  223. order.Spec = ""
  224. order.SpecUnt = ""
  225. order.DrordBegnDate = s_tm
  226. order.DrordStopDate = ""
  227. order.DrordDrCodg = "1"
  228. order.DrordDeptName = department.Name
  229. order.DrordDrCodg = "1"
  230. order.DrordDrName = doctor_info.UserName
  231. order.DrordDrProfttl = ""
  232. order.CurrDrordFlag = "1"
  233. orders = append(orders, &order)
  234. }
  235. for _, subItem := range item.HisPrescriptionProject {
  236. if subItem.Type == 2 {
  237. var order models.FsiOrderDtos
  238. order.RxID = strconv.FormatInt(item.ID, 10)
  239. order.Rxno = strconv.FormatInt(item.ID, 10)
  240. order.LongDrordFlag = "0"
  241. order.HilistType = "1"
  242. order.ChrgType = "1"
  243. order.DrordBhvr = "-"
  244. order.HilistCode = subItem.HisProject.MedicalCode
  245. order.HosplistName = subItem.HisProject.ProjectName
  246. order.HilistLv = "1"
  247. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  248. order.HosplistCode = subItem.HisProject.MedicalCode
  249. order.HosplistName = subItem.HisProject.ProjectName
  250. order.Cnt = subItem.Count
  251. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  252. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  254. order.OwnpayAmt = ""
  255. order.SelfpayAmt = ""
  256. order.Spec = ""
  257. order.SpecUnt = ""
  258. order.DrordBegnDate = s_tm
  259. order.DrordStopDate = ""
  260. order.DrordDrCodg = "1"
  261. order.DrordDeptName = department.Name
  262. order.DrordDrCodg = "1"
  263. order.DrordDrName = doctor_info.UserName
  264. order.DrordDrProfttl = ""
  265. order.CurrDrordFlag = "1"
  266. orders = append(orders, &order)
  267. }
  268. if subItem.Type == 3 {
  269. var order models.FsiOrderDtos
  270. order.RxID = strconv.FormatInt(item.ID, 10)
  271. order.Rxno = strconv.FormatInt(item.ID, 10)
  272. order.LongDrordFlag = "0"
  273. order.HilistType = "1"
  274. order.ChrgType = "1"
  275. order.DrordBhvr = "-"
  276. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  277. order.HosplistName = subItem.GoodInfo.GoodName
  278. order.HilistLv = "1"
  279. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  280. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  281. order.HosplistName = subItem.GoodInfo.GoodName
  282. order.Cnt = subItem.Count
  283. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  284. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  285. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  286. order.OwnpayAmt = ""
  287. order.SelfpayAmt = ""
  288. order.Spec = ""
  289. order.SpecUnt = ""
  290. order.DrordBegnDate = s_tm
  291. order.DrordStopDate = ""
  292. order.DrordDrCodg = "1"
  293. order.DrordDeptName = department.Name
  294. order.DrordDrCodg = "1"
  295. order.DrordDrName = doctor_info.UserName
  296. order.DrordDrProfttl = ""
  297. order.CurrDrordFlag = "1"
  298. orders = append(orders, &order)
  299. }
  300. }
  301. }
  302. //处方医嘱信息
  303. }
  304. fed.MatnStas = "0"
  305. fed.MedfeeSumamt = "0"
  306. fed.OwnpayAmt = "0"
  307. fed.SelfpayAmt = "0"
  308. fed.AcctPayamt = "0"
  309. fed.MaAmt = "0"
  310. fed.HifpPayamt = "0"
  311. fed.SetlTotlnum = "1"
  312. fed.Insutype = his.Insutype
  313. fed.ReimFlag = "0"
  314. fed.OutSetlFlag = "0"
  315. var fopd []*models.FsiOperationDtosData
  316. data := make(map[string]interface{})
  317. data["fed"] = fed
  318. data["fdd"] = fdds
  319. data["fod"] = orders
  320. data["pd"] = pd
  321. data["pp"] = pp
  322. data["fopd"] = fopd
  323. data["trig_scen"] = trig_scen
  324. fmt.Println(data)
  325. fmt.Println(fed)
  326. fmt.Println(fdds)
  327. fmt.Println(orders)
  328. fmt.Println(pd)
  329. fmt.Println(pp)
  330. fmt.Println(fopd)
  331. client := &http.Client{}
  332. bytesData, _ := json.Marshal(data)
  333. var req *http.Request
  334. if miConfig.MdtrtareaAdmvs == "320921" {
  335. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  336. } else {
  337. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  338. }
  339. resp, _ := client.Do(req)
  340. defer resp.Body.Close()
  341. body, ioErr := ioutil.ReadAll(resp.Body)
  342. if ioErr != nil {
  343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  345. return
  346. }
  347. var respJSON map[string]interface{}
  348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  351. return
  352. }
  353. //手术操作集合
  354. //手术操作集合
  355. }
  356. func (c *HisApiController) Check3102() {
  357. patient_id, _ := c.GetInt64("patient_id")
  358. order_id, _ := c.GetInt64("order_id")
  359. his_patient_id, _ := c.GetInt64("his_patient_id")
  360. admin_user_id, _ := c.GetInt64("admin_user_id")
  361. trig_scen := c.GetString("trig_scen")
  362. adminUser := c.GetAdminUserInfo()
  363. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  364. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  366. record_time := c.GetString("record_time")
  367. order, _ := service.GetHisOrderByID(order_id)
  368. timeLayout := "2006-01-02"
  369. loc, _ := time.LoadLocation("Local")
  370. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  371. if err != nil {
  372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  373. return
  374. }
  375. recordDateTime := theTime.Unix()
  376. var patientPrescription models.HisPrescriptionInfo
  377. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  378. if patientPrescription.ID == 0 {
  379. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  380. }
  381. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  382. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  383. //
  384. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  385. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  386. var pp models.PublicParams
  387. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  388. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  389. pp.FixmedinsName = miConfig.OrgName
  390. pp.FixmedinsCode = miConfig.Code
  391. pp.RequestUrl = miConfig.Url
  392. pp.Cainfo = miConfig.Cainfo
  393. pp.SecretKey = miConfig.SecretKey
  394. pp.AccessKey = miConfig.AccessKey
  395. pp.OpterName = roles.UserName
  396. var config []*models.HisXtDiagnoseConfig
  397. for _, item := range diagnosis_ids {
  398. id, _ := strconv.ParseInt(item, 10, 64)
  399. diagnosisConfig, _ := service.FindDiagnoseById(id)
  400. config = append(config, &diagnosisConfig)
  401. }
  402. var pd models.PatientDtos
  403. pd.PatnID = his.PsnNo
  404. pd.PatnName = his.Name
  405. pd.Gend = his.Gend
  406. pd.Brdy = his.Brdy
  407. pd.Poolarea = his.InsuplcAdmdvs
  408. pd.CurrMdtrtID = his.Number
  409. var fed models.FsiEncounterDtos
  410. fed.MdtrtID = his.Number
  411. fed.MedinsID = miConfig.Code
  412. fed.MedinsName = miConfig.OrgName
  413. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  414. fed.MedMdtrtType = "1"
  415. fed.MedinsType = "1"
  416. fed.MedinsLv = "11"
  417. tm := time.Unix(his.RecordDate, 0)
  418. s_tm := tm.Format("2006-01-02 15:04:05")
  419. fed.AdmDate = s_tm
  420. fed.DscgDate = s_tm
  421. fed.DscgMainDiseCodg = config[0].CountryCode
  422. fed.DscgMainDiseName = config[0].CountryContentName
  423. //诊断信息
  424. var fdds []*models.FsiDiagnoseDtos
  425. for index, item := range config {
  426. if index == 0 {
  427. var fdd models.FsiDiagnoseDtos
  428. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  429. fdd.InoutDiseType = "1"
  430. fdd.MaindiseFlag = "1"
  431. fdd.DiseDate = s_tm
  432. fdd.DiasSrtNo = "1"
  433. fdd.DiseName = item.CountryContentName
  434. fdd.DiseCodg = item.CountryCode
  435. fdds = append(fdds, &fdd)
  436. } else {
  437. var fdd models.FsiDiagnoseDtos
  438. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  439. fdd.InoutDiseType = "1"
  440. fdd.MaindiseFlag = "1"
  441. fdd.DiseDate = s_tm
  442. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  443. fdd.DiseName = item.CountryContentName
  444. fdd.DiseCodg = item.CountryCode
  445. fdds = append(fdds, &fdd)
  446. }
  447. }
  448. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  449. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  450. fed.AdmDeptName = department.Name
  451. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  452. fed.DscgDeptName = department.Name
  453. fed.MedType = order.MedType
  454. //处方医嘱信息
  455. var orders []*models.FsiOrderDtos
  456. //for _, item := range prescriptions {
  457. // for _, subItem := range item.HisDoctorAdviceInfo {
  458. // var order models.FsiOrderDtos
  459. // order.RxID = strconv.FormatInt(item.ID, 10)
  460. // order.Rxno = strconv.FormatInt(item.ID, 10)
  461. // order.LongDrordFlag = "0"
  462. // order.HilistType = "1"
  463. // order.ChrgType = "1"
  464. // order.DrordBhvr = "-"
  465. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  466. // order.HosplistName = subItem.BaseDrugLib.DrugName
  467. // order.HilistLv = "1"
  468. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  469. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  470. // order.HosplistName = subItem.BaseDrugLib.DrugName
  471. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  472. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  473. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  474. // order.OwnpayAmt = ""
  475. // order.SelfpayAmt = ""
  476. // order.Spec = ""
  477. // order.SpecUnt = ""
  478. // order.DrordBegnDate = s_tm
  479. // order.DrordStopDate = ""
  480. // order.DrordDrCodg = "1"
  481. // order.DrordDeptName = department.Name
  482. // order.DrordDrCodg = "1"
  483. // order.DrordDrName = doctor_info.UserName
  484. // order.DrordDrProfttl = ""
  485. // order.CurrDrordFlag = "1"
  486. // orders = append(orders, &order)
  487. // }
  488. // for _, subItem := range item.HisPrescriptionProject {
  489. // if subItem.Type == 2 {
  490. // var order models.FsiOrderDtos
  491. // order.RxID = strconv.FormatInt(item.ID, 10)
  492. // order.Rxno = strconv.FormatInt(item.ID, 10)
  493. // order.LongDrordFlag = "0"
  494. // order.HilistType = "1"
  495. // order.ChrgType = "1"
  496. // order.DrordBhvr = "-"
  497. // order.HilistCode = subItem.HisProject.MedicalCode
  498. // order.HosplistName = subItem.HisProject.ProjectName
  499. // order.HilistLv = "1"
  500. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  501. // order.HosplistCode = subItem.HisProject.MedicalCode
  502. // order.HosplistName = subItem.HisProject.ProjectName
  503. // order.Cnt = subItem.Count
  504. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  505. //
  506. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  507. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  508. // order.OwnpayAmt = ""
  509. // order.SelfpayAmt = ""
  510. // order.Spec = ""
  511. // order.SpecUnt = ""
  512. // order.DrordBegnDate = s_tm
  513. // order.DrordStopDate = ""
  514. // order.DrordDrCodg = "1"
  515. // order.DrordDeptName = department.Name
  516. // order.DrordDrCodg = "1"
  517. // order.DrordDrName = doctor_info.UserName
  518. // order.DrordDrProfttl = ""
  519. // order.CurrDrordFlag = "1"
  520. // orders = append(orders, &order)
  521. //
  522. // }
  523. // if subItem.Type == 3 {
  524. //
  525. // var order models.FsiOrderDtos
  526. // order.RxID = strconv.FormatInt(item.ID, 10)
  527. // order.Rxno = strconv.FormatInt(item.ID, 10)
  528. // order.LongDrordFlag = "0"
  529. // order.HilistType = "1"
  530. // order.ChrgType = "1"
  531. // order.DrordBhvr = "-"
  532. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  533. // order.HosplistName = subItem.GoodInfo.GoodName
  534. // order.HilistLv = "1"
  535. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  536. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  537. // order.HosplistName = subItem.GoodInfo.GoodName
  538. // order.Cnt = subItem.Count
  539. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  540. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  541. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  542. // order.OwnpayAmt = ""
  543. // order.SelfpayAmt = ""
  544. // order.Spec = ""
  545. // order.SpecUnt = ""
  546. // order.DrordBegnDate = s_tm
  547. // order.DrordStopDate = ""
  548. // order.DrordDrCodg = "1"
  549. // order.DrordDeptName = department.Name
  550. // order.DrordDrCodg = "1"
  551. // order.DrordDrName = doctor_info.UserName
  552. // order.DrordDrProfttl = ""
  553. // order.CurrDrordFlag = "1"
  554. // orders = append(orders, &order)
  555. //
  556. // }
  557. // }
  558. //}
  559. for _, item := range prescriptions {
  560. for _, subItem := range item.HisDoctorAdviceInfo {
  561. var order models.FsiOrderDtos
  562. order.RxID = strconv.FormatInt(item.ID, 10)
  563. order.Rxno = strconv.FormatInt(item.ID, 10)
  564. order.LongDrordFlag = "0"
  565. order.HilistType = "1"
  566. order.ChrgType = "1"
  567. order.DrordBhvr = "-"
  568. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  569. order.HosplistName = subItem.BaseDrugLib.DrugName
  570. order.HilistLv = "1"
  571. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  572. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  573. order.HosplistName = subItem.BaseDrugLib.DrugName
  574. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  575. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  576. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  577. order.OwnpayAmt = ""
  578. order.SelfpayAmt = ""
  579. order.Spec = ""
  580. order.SpecUnt = ""
  581. order.DrordBegnDate = s_tm
  582. order.DrordStopDate = ""
  583. order.DrordDrCodg = "1"
  584. order.DrordDeptName = department.Name
  585. order.DrordDrCodg = "1"
  586. order.DrordDrName = doctor_info.UserName
  587. order.DrordDrProfttl = ""
  588. order.CurrDrordFlag = "1"
  589. orders = append(orders, &order)
  590. }
  591. for _, subItem := range item.HisPrescriptionProject {
  592. if subItem.Type == 2 {
  593. var order models.FsiOrderDtos
  594. order.RxID = strconv.FormatInt(item.ID, 10)
  595. order.Rxno = strconv.FormatInt(item.ID, 10)
  596. order.LongDrordFlag = "0"
  597. order.HilistType = "1"
  598. order.ChrgType = "1"
  599. order.DrordBhvr = "-"
  600. order.HilistCode = subItem.HisProject.MedicalCode
  601. order.HosplistName = subItem.HisProject.ProjectName
  602. order.HilistLv = "1"
  603. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  604. order.HosplistCode = subItem.HisProject.MedicalCode
  605. order.HosplistName = subItem.HisProject.ProjectName
  606. order.Cnt = subItem.Count
  607. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  608. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  610. order.OwnpayAmt = ""
  611. order.SelfpayAmt = ""
  612. order.Spec = ""
  613. order.SpecUnt = ""
  614. order.DrordBegnDate = s_tm
  615. order.DrordStopDate = ""
  616. order.DrordDrCodg = "1"
  617. order.DrordDeptName = department.Name
  618. order.DrordDrCodg = "1"
  619. order.DrordDrName = doctor_info.UserName
  620. order.DrordDrProfttl = ""
  621. order.CurrDrordFlag = "1"
  622. orders = append(orders, &order)
  623. }
  624. if subItem.Type == 3 {
  625. var order models.FsiOrderDtos
  626. order.RxID = strconv.FormatInt(item.ID, 10)
  627. order.Rxno = strconv.FormatInt(item.ID, 10)
  628. order.LongDrordFlag = "0"
  629. order.HilistType = "1"
  630. order.ChrgType = "1"
  631. order.DrordBhvr = "-"
  632. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  633. order.HosplistName = subItem.GoodInfo.GoodName
  634. order.HilistLv = "1"
  635. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  636. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  637. order.HosplistName = subItem.GoodInfo.GoodName
  638. order.Cnt = subItem.Count
  639. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  640. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  641. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  642. order.OwnpayAmt = ""
  643. order.SelfpayAmt = ""
  644. order.Spec = ""
  645. order.SpecUnt = ""
  646. order.DrordBegnDate = s_tm
  647. order.DrordStopDate = ""
  648. order.DrordDrCodg = "1"
  649. order.DrordDeptName = department.Name
  650. order.DrordDrCodg = "1"
  651. order.DrordDrName = doctor_info.UserName
  652. order.DrordDrProfttl = ""
  653. order.CurrDrordFlag = "1"
  654. orders = append(orders, &order)
  655. }
  656. }
  657. }
  658. //处方医嘱信息
  659. fed.MatnStas = "0"
  660. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  661. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  662. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  663. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  664. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  665. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  666. fed.SetlTotlnum = "1"
  667. fed.Insutype = his.Insutype
  668. fed.ReimFlag = "0"
  669. fed.OutSetlFlag = "0"
  670. var fopd []*models.FsiOperationDtosData
  671. data := make(map[string]interface{})
  672. data["fed"] = fed
  673. data["fdd"] = fdds
  674. data["fod"] = orders
  675. data["pd"] = pd
  676. data["pp"] = pp
  677. data["fopd"] = fopd
  678. data["trig_scen"] = trig_scen
  679. client := &http.Client{}
  680. bytesData, _ := json.Marshal(data)
  681. var req *http.Request
  682. if miConfig.MdtrtareaAdmvs == "320921" {
  683. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  684. } else {
  685. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  686. }
  687. resp, _ := client.Do(req)
  688. defer resp.Body.Close()
  689. body, ioErr := ioutil.ReadAll(resp.Body)
  690. if ioErr != nil {
  691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  693. return
  694. }
  695. var respJSON map[string]interface{}
  696. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. return
  700. }
  701. //手术操作集合
  702. //手术操作集合
  703. }
  704. func (c *HisApiController) Check() {
  705. psn_no := c.GetString("psn_no")
  706. in := c.GetString("in")
  707. mt := c.GetString("mt")
  708. baseParams := models.BaseParams{
  709. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  710. FixmedinsCode: "H15049901371",
  711. InsuplcAdmdvs: "150499",
  712. MdtrtareaAdmvs: "150499",
  713. OrgName: "赤峰费森血液透析中心",
  714. Doctor: "1111",
  715. }
  716. service.Gdyb2001(baseParams, psn_no, in, mt)
  717. }
  718. func (c *HisApiController) GetPsnNcdsInfo() {
  719. admin_user_id, _ := c.GetInt64("admin_user_id")
  720. patient_id, _ := c.GetInt64("patient_id")
  721. id, _ := c.GetInt64("id")
  722. adminUser := c.GetAdminUserInfo()
  723. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  724. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  725. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  726. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  727. psn_record, _ := service.GetPsnNCDSRecordById(id)
  728. //
  729. //if psn_record.ID == 0 {
  730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  731. // return
  732. //}
  733. var res Result5301
  734. var res10265 Result5301For10265
  735. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  736. psn_info, _ := service.GetPsnByPatientId(patient_id)
  737. var api string
  738. if miConfig.MdtrtareaAdmvs == "320921" {
  739. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  740. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  741. } else {
  742. 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 +
  743. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  744. }
  745. resp, requestErr := http.Get(api)
  746. if requestErr != nil {
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. body, ioErr := ioutil.ReadAll(resp.Body)
  751. if ioErr != nil {
  752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  754. return
  755. }
  756. var respJSON map[string]interface{}
  757. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  760. return
  761. }
  762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  763. result, _ := json.Marshal(respJSON)
  764. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  765. utils.ErrorLog("解析失败:%v", err)
  766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  767. return
  768. }
  769. res.ErrMsg = res10265.ErrMsg
  770. res.Output = res10265.Output
  771. res.InfRefmsgid = res10265.InfRefmsgid
  772. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  773. res.Infcode = infocode
  774. } else {
  775. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  776. var dat map[string]interface{}
  777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  778. fmt.Println(dat)
  779. } else {
  780. fmt.Println(err)
  781. }
  782. userJSONBytes, _ := json.Marshal(dat)
  783. if miConfig.Code == "H15049901371" {
  784. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  785. utils.ErrorLog("解析失败:%v", err)
  786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  787. return
  788. }
  789. res.InfRefmsgid = res10265.InfRefmsgid
  790. res.Output = res10265.Output
  791. res.ErrMsg = res10265.ErrMsg
  792. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  793. res.Infcode = infocode
  794. } else {
  795. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  796. utils.ErrorLog("解析失败:%v", err)
  797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  798. return
  799. }
  800. }
  801. }
  802. if res.Infcode == 0 {
  803. c.ServeSuccessJSON(map[string]interface{}{
  804. "result": res.Output.Result,
  805. })
  806. }
  807. }
  808. func (c *HisApiController) CheckInsutype() {
  809. his_patient_id, _ := c.GetInt64("his_patient_id")
  810. admin_user_id, _ := c.GetInt64("admin_user_id")
  811. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  812. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  813. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  814. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  815. var dat map[string]interface{}
  816. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  817. fmt.Println(dat)
  818. } else {
  819. fmt.Println(err)
  820. }
  821. userJSONBytes, _ := json.Marshal(dat)
  822. var res Result90100
  823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  824. utils.ErrorLog("解析失败:%v", err)
  825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  826. return
  827. }
  828. if res.Infcode != 0 {
  829. c.ServeSuccessJSON(map[string]interface{}{
  830. "failed_code": -10,
  831. "msg": res.ErrMsg,
  832. })
  833. return
  834. } else {
  835. fmt.Println(res)
  836. }
  837. }
  838. func (c *HisApiController) CheckCardPWD() {
  839. card_pwd := c.GetString("card_pwd")
  840. his_patient_id, _ := c.GetInt64("his_patient_id")
  841. admin_user_id, _ := c.GetInt64("admin_user_id")
  842. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  843. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  844. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  845. psn, _ := service.GetPsnByPatientId(his.PatientId)
  846. bas := strings.Split(psn.CardInfo, "|")
  847. basNumber := bas[2]
  848. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  849. var dat map[string]interface{}
  850. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  851. fmt.Println(dat)
  852. } else {
  853. fmt.Println(err)
  854. }
  855. userJSONBytes, _ := json.Marshal(dat)
  856. var res Result90991
  857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  858. utils.ErrorLog("解析失败:%v", err)
  859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  860. return
  861. }
  862. if res.Infcode != 0 {
  863. c.ServeSuccessJSON(map[string]interface{}{
  864. "failed_code": -10,
  865. "msg": res.ErrMsg,
  866. })
  867. return
  868. } else {
  869. if res.Output.Result.SscnoCheckStat == "0" {
  870. var msg string
  871. switch res.Output.Result.CardStat {
  872. case "00":
  873. msg = "未激活"
  874. break
  875. case "10":
  876. msg = "激活"
  877. break
  878. case "20":
  879. msg = "窗口挂失"
  880. break
  881. case "21":
  882. msg = "电话挂失"
  883. break
  884. case "22":
  885. msg = "单位网上申报挂失"
  886. break
  887. case "23":
  888. msg = "保健办挂失"
  889. break
  890. case "24":
  891. msg = "个人网上挂失"
  892. break
  893. case "25":
  894. msg = "网上服务大厅挂失"
  895. break
  896. case "30":
  897. msg = "注销"
  898. break
  899. case "40":
  900. msg = "回收"
  901. break
  902. case "99":
  903. msg = "制卡中(无效卡)"
  904. break
  905. }
  906. c.ServeSuccessJSON(map[string]interface{}{
  907. "failed_code": -10,
  908. "msg": msg,
  909. })
  910. return
  911. } else {
  912. c.ServeSuccessJSON(map[string]interface{}{
  913. "msg": "校验成功",
  914. })
  915. return
  916. }
  917. }
  918. }
  919. func (c *HisApiController) CheckCardPWDTwo() {
  920. //card_pwd := c.GetString("card_pwd")
  921. //his_patient_id, _ := c.GetInt64("his_patient_id")
  922. admin_user_id, _ := c.GetInt64("admin_user_id")
  923. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  924. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  925. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  926. var dat map[string]interface{}
  927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  928. fmt.Println(dat)
  929. } else {
  930. fmt.Println(err)
  931. }
  932. userJSONBytes, _ := json.Marshal(dat)
  933. var res Result90991
  934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  935. utils.ErrorLog("解析失败:%v", err)
  936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  937. return
  938. }
  939. if res.Infcode != 0 {
  940. c.ServeSuccessJSON(map[string]interface{}{
  941. "failed_code": -10,
  942. "msg": res.ErrMsg,
  943. })
  944. return
  945. } else {
  946. if res.Output.Result.SscnoCheckStat == "0" {
  947. var msg string
  948. switch res.Output.Result.CardStat {
  949. case "00":
  950. msg = "未激活"
  951. break
  952. case "10":
  953. msg = "激活"
  954. break
  955. case "20":
  956. msg = "窗口挂失"
  957. break
  958. case "21":
  959. msg = "电话挂失"
  960. break
  961. case "22":
  962. msg = "单位网上申报挂失"
  963. break
  964. case "23":
  965. msg = "保健办挂失"
  966. break
  967. case "24":
  968. msg = "个人网上挂失"
  969. break
  970. case "25":
  971. msg = "网上服务大厅挂失"
  972. break
  973. case "30":
  974. msg = "注销"
  975. break
  976. case "40":
  977. msg = "回收"
  978. break
  979. case "99":
  980. msg = "制卡中(无效卡)"
  981. break
  982. }
  983. c.ServeSuccessJSON(map[string]interface{}{
  984. "failed_code": -10,
  985. "msg": msg,
  986. })
  987. return
  988. } else {
  989. c.ServeSuccessJSON(map[string]interface{}{
  990. "msg": "校验成功",
  991. })
  992. return
  993. }
  994. }
  995. }
  996. func (c *HisApiController) ReadCard() {
  997. id_card_type, _ := c.GetInt64("id_card_type")
  998. admin_user_id, _ := c.GetInt64("admin_user_id")
  999. certificates, _ := c.GetInt64("certificates")
  1000. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1001. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1002. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1003. switch id_card_type {
  1004. case 1:
  1005. if miConfig.MdtrtareaAdmvs == "421300" {
  1006. var res ResultTwo
  1007. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1008. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1009. "&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)
  1010. resp, requestErr := http.Get(api)
  1011. if requestErr != nil {
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. return
  1014. }
  1015. body, ioErr := ioutil.ReadAll(resp.Body)
  1016. if ioErr != nil {
  1017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1019. return
  1020. }
  1021. var respJSON map[string]interface{}
  1022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1025. return
  1026. }
  1027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1028. result, _ := json.Marshal(respJSON)
  1029. fmt.Println("log")
  1030. fmt.Println(string(result))
  1031. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1032. utils.ErrorLog("解析失败:%v", err)
  1033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1034. return
  1035. }
  1036. if res.Infcode == 0 {
  1037. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1038. if err == gorm.ErrRecordNotFound {
  1039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1040. return
  1041. } else if err != nil {
  1042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1043. return
  1044. } else {
  1045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1047. infoStr := string(Iinfos)
  1048. idetinfoStr := string(Idetinfos)
  1049. psn := &models.HisPsn{
  1050. PsnNo: res.Output.Baseinfo.PsnNo,
  1051. Age: res.Output.Baseinfo.Age,
  1052. PatientId: patient.ID,
  1053. Certno: res.Output.Baseinfo.Certno,
  1054. Brdy: res.Output.Baseinfo.Brdy,
  1055. Gend: res.Output.Baseinfo.Gend,
  1056. Naty: res.Output.Baseinfo.Naty,
  1057. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1058. PsnName: res.Output.Baseinfo.PsnName,
  1059. Idetinfo: idetinfoStr,
  1060. Insuinfo: infoStr,
  1061. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1062. }
  1063. service.CreateHisPsn(psn)
  1064. c.ServeSuccessJSON(map[string]interface{}{
  1065. "patient": patient,
  1066. "number": res.Output.Baseinfo.Certno,
  1067. })
  1068. }
  1069. } else {
  1070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1071. return
  1072. }
  1073. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1074. var api string
  1075. if miConfig.MdtrtareaAdmvs == "320921" {
  1076. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1077. "&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
  1078. fmt.Println(api)
  1079. } else {
  1080. 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 +
  1081. "&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)
  1082. }
  1083. resp, requestErr := http.Get(api)
  1084. if requestErr != nil {
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. body, ioErr := ioutil.ReadAll(resp.Body)
  1089. if ioErr != nil {
  1090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. var respJSON map[string]interface{}
  1095. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1098. return
  1099. }
  1100. var status string
  1101. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1102. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1103. //console.log()
  1104. fmt.Println("type===")
  1105. fmt.Println(card_type)
  1106. var token string
  1107. var res ResultTwo //1101结果
  1108. var res10265 ResultTwo10265 //1101结果
  1109. var card_info string //卡信息
  1110. var busi_card_info string
  1111. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1112. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1113. if status == "0" { //读卡成功
  1114. if card_type == "1" {
  1115. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1116. result, _ := json.Marshal(respJSON)
  1117. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1118. utils.ErrorLog("解析失败:%v", err)
  1119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1120. return
  1121. }
  1122. res.ErrMsg = res10265.ErrMsg
  1123. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1124. res.Infcode = infocode
  1125. res.Output = res10265.Output
  1126. res.InfRefmsgid = res10265.InfRefmsgid
  1127. } else {
  1128. //var card_info string //卡信息
  1129. //var busi_card_info string
  1130. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1131. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1132. //fmt.Println(card_info)
  1133. //fmt.Println(busi_card_info)
  1134. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1135. result, _ := json.Marshal(respJSON)
  1136. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. res.ErrMsg = res10265.ErrMsg
  1142. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1143. res.Infcode = infocode
  1144. res.Output = res10265.Output
  1145. res.InfRefmsgid = res10265.InfRefmsgid
  1146. }
  1147. if res.Infcode == 0 {
  1148. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1149. if err == gorm.ErrRecordNotFound {
  1150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1151. return
  1152. } else if err != nil {
  1153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1154. return
  1155. } else {
  1156. if card_type == "1" {
  1157. bas := strings.Split(card_info, "|")
  1158. basNumber := bas[2]
  1159. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1160. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1161. infoStr := string(Iinfos)
  1162. idetinfoStr := string(Idetinfos)
  1163. psn := &models.HisPsn{
  1164. PsnNo: res.Output.Baseinfo.PsnNo,
  1165. Age: res.Output.Baseinfo.Age,
  1166. PatientId: patient.ID,
  1167. Certno: res.Output.Baseinfo.Certno,
  1168. Brdy: res.Output.Baseinfo.Brdy,
  1169. Gend: res.Output.Baseinfo.Gend,
  1170. Naty: res.Output.Baseinfo.Naty,
  1171. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1172. PsnName: res.Output.Baseinfo.PsnName,
  1173. Idetinfo: idetinfoStr,
  1174. Insuinfo: infoStr,
  1175. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1176. CardInfo: card_info,
  1177. VerifyNumber: busi_card_info,
  1178. }
  1179. service.CreateHisPsn(psn)
  1180. var rf []*ResultFive
  1181. json.Unmarshal([]byte(infoStr), &rf)
  1182. var insutypes []*ResultFive
  1183. var insutype string
  1184. var is390 int = 0
  1185. var is310 int = 0
  1186. for _, item := range rf {
  1187. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1188. insutypes = append(insutypes, item)
  1189. }
  1190. }
  1191. if len(insutypes) == 1 {
  1192. insutype = insutypes[0].Insutype
  1193. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1194. } else {
  1195. for _, i := range insutypes {
  1196. if i.Insutype == "390" {
  1197. is390 = 1
  1198. }
  1199. if i.Insutype == "310" {
  1200. is310 = 1
  1201. }
  1202. }
  1203. }
  1204. if is390 == 1 {
  1205. insutype = "390"
  1206. }
  1207. if is310 == 1 {
  1208. insutype = "310"
  1209. }
  1210. if len(insutypes) == 0 {
  1211. insutype = "310"
  1212. }
  1213. c.ServeSuccessJSON(map[string]interface{}{
  1214. "patient": patient,
  1215. "number": basNumber,
  1216. "insutype": insutype,
  1217. })
  1218. } else {
  1219. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1220. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1221. infoStr := string(Iinfos)
  1222. idetinfoStr := string(Idetinfos)
  1223. psn := &models.HisPsn{
  1224. PsnNo: res.Output.Baseinfo.PsnNo,
  1225. Age: res.Output.Baseinfo.Age,
  1226. PatientId: patient.ID,
  1227. Certno: res.Output.Baseinfo.Certno,
  1228. Brdy: res.Output.Baseinfo.Brdy,
  1229. Gend: res.Output.Baseinfo.Gend,
  1230. Naty: res.Output.Baseinfo.Naty,
  1231. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1232. PsnName: res.Output.Baseinfo.PsnName,
  1233. Idetinfo: idetinfoStr,
  1234. Insuinfo: infoStr,
  1235. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1236. CardInfo: card_info,
  1237. VerifyNumber: token,
  1238. }
  1239. service.CreateHisPsn(psn)
  1240. c.ServeSuccessJSON(map[string]interface{}{
  1241. "patient": patient,
  1242. "number": token,
  1243. })
  1244. }
  1245. }
  1246. } else {
  1247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1248. return
  1249. }
  1250. } else { //读卡失败
  1251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1252. return
  1253. }
  1254. } else {
  1255. if initFlag == 0 {
  1256. c.TestGetBasBaseInit()
  1257. }
  1258. basStr := c.GetBasBaseInfo()
  1259. if len(basStr) == 0 {
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1261. return
  1262. }
  1263. fmt.Println(basStr)
  1264. bas := strings.Split(basStr, "|")
  1265. basNumber := bas[1]
  1266. fmt.Println(basNumber)
  1267. card_sn := bas[3]
  1268. fmt.Println(card_sn)
  1269. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1270. var dat map[string]interface{}
  1271. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1272. fmt.Println(dat)
  1273. } else {
  1274. fmt.Println(err)
  1275. }
  1276. userJSONBytes, _ := json.Marshal(dat)
  1277. var res ResultTwo
  1278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1279. utils.ErrorLog("解析失败:%v", err)
  1280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1281. return
  1282. }
  1283. if res.Infcode == 0 {
  1284. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1285. if err == gorm.ErrRecordNotFound {
  1286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1287. return
  1288. } else if err != nil {
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1290. return
  1291. } else {
  1292. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1293. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1294. infoStr := string(Iinfos)
  1295. idetinfoStr := string(Idetinfos)
  1296. psn := &models.HisPsn{
  1297. PsnNo: res.Output.Baseinfo.PsnNo,
  1298. Age: res.Output.Baseinfo.Age,
  1299. PatientId: patient.ID,
  1300. Certno: res.Output.Baseinfo.Certno,
  1301. Brdy: res.Output.Baseinfo.Brdy,
  1302. Gend: res.Output.Baseinfo.Gend,
  1303. Naty: res.Output.Baseinfo.Naty,
  1304. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1305. PsnName: res.Output.Baseinfo.PsnName,
  1306. Idetinfo: idetinfoStr,
  1307. Insuinfo: infoStr,
  1308. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1309. CardInfo: basStr,
  1310. VerifyNumber: "",
  1311. }
  1312. service.CreateHisPsn(psn)
  1313. c.ServeSuccessJSON(map[string]interface{}{
  1314. "patient": patient,
  1315. "number": basNumber,
  1316. })
  1317. }
  1318. } else {
  1319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1320. return
  1321. }
  1322. break
  1323. }
  1324. case 2:
  1325. SFZStr := c.GetSFZBaseInfo()
  1326. id_card_str := strings.Split(SFZStr, "^")
  1327. id_card_number := id_card_str[0]
  1328. card_sn := ""
  1329. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1330. var dat map[string]interface{}
  1331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1332. fmt.Println(dat)
  1333. } else {
  1334. fmt.Println(err)
  1335. }
  1336. userJSONBytes, _ := json.Marshal(dat)
  1337. var res ResultTwo
  1338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1339. utils.ErrorLog("解析失败:%v", err)
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. return
  1342. }
  1343. if res.Infcode == 0 {
  1344. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1345. if err == gorm.ErrRecordNotFound {
  1346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1347. return
  1348. } else if err != nil {
  1349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1350. return
  1351. } else {
  1352. c.ServeSuccessJSON(map[string]interface{}{
  1353. "patient": patient,
  1354. "number": id_card_number,
  1355. })
  1356. }
  1357. } else {
  1358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1359. return
  1360. }
  1361. break
  1362. case 3:
  1363. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1364. var api string
  1365. if miConfig.MdtrtareaAdmvs == "320921" {
  1366. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1367. "&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
  1368. fmt.Println(api)
  1369. } else {
  1370. 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 +
  1371. "&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)
  1372. }
  1373. resp, requestErr := http.Get(api)
  1374. if requestErr != nil {
  1375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1376. return
  1377. }
  1378. body, ioErr := ioutil.ReadAll(resp.Body)
  1379. if ioErr != nil {
  1380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1382. return
  1383. }
  1384. var respJSON map[string]interface{}
  1385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1388. return
  1389. }
  1390. var status string
  1391. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1392. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1393. var token string
  1394. var res ResultTwo //1101结果
  1395. var res10265 ResultTwo10265 //1101结果
  1396. var card_info string //卡信息
  1397. var busi_card_info string
  1398. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1399. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1400. if status == "0" { //读卡成功
  1401. if card_type == "1" {
  1402. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1403. result, _ := json.Marshal(respJSON)
  1404. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1405. utils.ErrorLog("解析失败:%v", err)
  1406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1407. return
  1408. }
  1409. res.ErrMsg = res10265.ErrMsg
  1410. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1411. res.Infcode = infocode
  1412. res.Output = res10265.Output
  1413. res.InfRefmsgid = res10265.InfRefmsgid
  1414. } else {
  1415. //var card_info string //卡信息
  1416. //var busi_card_info string
  1417. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1418. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1419. //fmt.Println(card_info)
  1420. //fmt.Println(busi_card_info)
  1421. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1422. result, _ := json.Marshal(respJSON)
  1423. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1424. utils.ErrorLog("解析失败:%v", err)
  1425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1426. return
  1427. }
  1428. res.ErrMsg = res10265.ErrMsg
  1429. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1430. res.Infcode = infocode
  1431. res.Output = res10265.Output
  1432. res.InfRefmsgid = res10265.InfRefmsgid
  1433. }
  1434. if res.Infcode == 0 {
  1435. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1436. if err == gorm.ErrRecordNotFound {
  1437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1438. return
  1439. } else if err != nil {
  1440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1441. return
  1442. } else {
  1443. if card_type == "1" {
  1444. bas := strings.Split(card_info, "|")
  1445. basNumber := bas[2]
  1446. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1447. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1448. infoStr := string(Iinfos)
  1449. idetinfoStr := string(Idetinfos)
  1450. psn := &models.HisPsn{
  1451. PsnNo: res.Output.Baseinfo.PsnNo,
  1452. Age: res.Output.Baseinfo.Age,
  1453. PatientId: patient.ID,
  1454. Certno: res.Output.Baseinfo.Certno,
  1455. Brdy: res.Output.Baseinfo.Brdy,
  1456. Gend: res.Output.Baseinfo.Gend,
  1457. Naty: res.Output.Baseinfo.Naty,
  1458. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1459. PsnName: res.Output.Baseinfo.PsnName,
  1460. Idetinfo: idetinfoStr,
  1461. Insuinfo: infoStr,
  1462. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1463. CardInfo: card_info,
  1464. VerifyNumber: busi_card_info,
  1465. }
  1466. service.CreateHisPsn(psn)
  1467. c.ServeSuccessJSON(map[string]interface{}{
  1468. "patient": patient,
  1469. "number": basNumber,
  1470. })
  1471. } else {
  1472. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1473. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1474. infoStr := string(Iinfos)
  1475. idetinfoStr := string(Idetinfos)
  1476. psn := &models.HisPsn{
  1477. PsnNo: res.Output.Baseinfo.PsnNo,
  1478. Age: res.Output.Baseinfo.Age,
  1479. PatientId: patient.ID,
  1480. Certno: res.Output.Baseinfo.Certno,
  1481. Brdy: res.Output.Baseinfo.Brdy,
  1482. Gend: res.Output.Baseinfo.Gend,
  1483. Naty: res.Output.Baseinfo.Naty,
  1484. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1485. PsnName: res.Output.Baseinfo.PsnName,
  1486. Idetinfo: idetinfoStr,
  1487. Insuinfo: infoStr,
  1488. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1489. CardInfo: card_info,
  1490. VerifyNumber: token,
  1491. }
  1492. service.CreateHisPsn(psn)
  1493. var rf []*ResultFive
  1494. json.Unmarshal([]byte(infoStr), &rf)
  1495. var insutypes []*ResultFive
  1496. var insutype string
  1497. var is390 int = 0
  1498. var is310 int = 0
  1499. for _, item := range rf {
  1500. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1501. insutypes = append(insutypes, item)
  1502. }
  1503. }
  1504. if len(insutypes) == 1 {
  1505. insutype = insutypes[0].Insutype
  1506. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1507. } else {
  1508. for _, i := range insutypes {
  1509. if i.Insutype == "390" {
  1510. is390 = 1
  1511. }
  1512. if i.Insutype == "310" {
  1513. is310 = 1
  1514. }
  1515. }
  1516. }
  1517. if is390 == 1 {
  1518. insutype = "390"
  1519. }
  1520. if is310 == 1 {
  1521. insutype = "310"
  1522. }
  1523. if len(insutypes) == 0 {
  1524. insutype = "310"
  1525. }
  1526. c.ServeSuccessJSON(map[string]interface{}{
  1527. "patient": patient,
  1528. "number": token,
  1529. "insutype": insutype,
  1530. })
  1531. }
  1532. }
  1533. } else {
  1534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1535. return
  1536. }
  1537. } else { //读卡失败
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1539. return
  1540. }
  1541. }
  1542. break
  1543. case 4:
  1544. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1545. var api string
  1546. if miConfig.MdtrtareaAdmvs == "320921" {
  1547. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1548. "&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
  1549. fmt.Println(api)
  1550. } else {
  1551. 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 +
  1552. "&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)
  1553. }
  1554. resp, requestErr := http.Get(api)
  1555. if requestErr != nil {
  1556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1557. return
  1558. }
  1559. body, ioErr := ioutil.ReadAll(resp.Body)
  1560. if ioErr != nil {
  1561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1563. return
  1564. }
  1565. var respJSON map[string]interface{}
  1566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1569. return
  1570. }
  1571. var status string
  1572. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1573. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1574. var token string
  1575. var res ResultTwo //1101结果
  1576. var res10265 ResultTwo10265 //1101结果
  1577. if status == "0" { //读卡成功
  1578. var card_info string //卡信息
  1579. var busi_card_info string
  1580. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1581. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1582. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1583. fmt.Println(card_info)
  1584. fmt.Println(busi_card_info)
  1585. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1586. result, _ := json.Marshal(respJSON)
  1587. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1588. utils.ErrorLog("解析失败:%v", err)
  1589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1590. return
  1591. }
  1592. res.ErrMsg = res10265.ErrMsg
  1593. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1594. res.Infcode = infocode
  1595. res.Output = res10265.Output
  1596. res.InfRefmsgid = res10265.InfRefmsgid
  1597. if res.Infcode == 0 {
  1598. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1599. if err == gorm.ErrRecordNotFound {
  1600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1601. return
  1602. } else if err != nil {
  1603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1604. return
  1605. } else {
  1606. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1607. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1608. infoStr := string(Iinfos)
  1609. idetinfoStr := string(Idetinfos)
  1610. psn := &models.HisPsn{
  1611. PsnNo: res.Output.Baseinfo.PsnNo,
  1612. Age: res.Output.Baseinfo.Age,
  1613. PatientId: patient.ID,
  1614. Certno: res.Output.Baseinfo.Certno,
  1615. Brdy: res.Output.Baseinfo.Brdy,
  1616. Gend: res.Output.Baseinfo.Gend,
  1617. Naty: res.Output.Baseinfo.Naty,
  1618. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1619. PsnName: res.Output.Baseinfo.PsnName,
  1620. Idetinfo: idetinfoStr,
  1621. Insuinfo: infoStr,
  1622. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1623. CardInfo: card_info,
  1624. VerifyNumber: token,
  1625. }
  1626. service.CreateHisPsn(psn)
  1627. c.ServeSuccessJSON(map[string]interface{}{
  1628. "patient": patient,
  1629. "number": token,
  1630. })
  1631. }
  1632. } else {
  1633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1634. return
  1635. }
  1636. } else { //读卡失败
  1637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1638. return
  1639. }
  1640. }
  1641. break
  1642. }
  1643. }
  1644. var initFlag int64 = 0
  1645. func (c *HisApiController) TestGetBasBaseInit() {
  1646. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1647. Iinit := DllDef.MustFindProc("Init")
  1648. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1649. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1650. if ret != 0 {
  1651. fmt.Println("SSCard的报错原因:", err)
  1652. fmt.Println("SSCard的运算结果为:", ret)
  1653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1654. return
  1655. }
  1656. result := int(ret)
  1657. fmt.Println("SSCard的运算结果为1:", result)
  1658. initFlag = 1
  1659. return
  1660. }
  1661. func (c *HisApiController) GetSFZBaseInfo() string {
  1662. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1663. readCard := DllDef.MustFindProc("ReadSFZ")
  1664. if readCard == nil {
  1665. fmt.Println("readcard is nil")
  1666. readCard = DllDef.MustFindProc("ReadSFZ")
  1667. }
  1668. str := make([]byte, 256)
  1669. str1 := make([]byte, 256)
  1670. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1671. fmt.Println(r)
  1672. return string(str)
  1673. }
  1674. func (c *HisApiController) GetBasBaseInfo() string {
  1675. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1676. readCard := DllDef.MustFindProc("ReadCardBas")
  1677. if readCard == nil {
  1678. fmt.Println("readcard is nil")
  1679. readCard = DllDef.MustFindProc("ReadCardBas")
  1680. }
  1681. str := make([]byte, 1024)
  1682. str1 := make([]byte, 1024)
  1683. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1684. fmt.Println(string(str1))
  1685. fmt.Println(string(str))
  1686. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1687. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1688. if ret2 != 0 {
  1689. return ""
  1690. }
  1691. return string(str)
  1692. }
  1693. type CustomFundPay struct {
  1694. FundPayType string `json:"fund_pay_type"`
  1695. FundPayamt float64 `json:"fund_payamt"`
  1696. }
  1697. func (c *HisApiController) GetSettleList() {
  1698. order_id, _ := c.GetInt64("order_id")
  1699. admin_user_id, _ := c.GetInt64("admin_user_id")
  1700. order, _ := service.GetHisOrderByIDTwo(order_id)
  1701. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1702. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1703. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1704. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1705. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1706. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1707. if order.ID == 0 {
  1708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1709. return
  1710. }
  1711. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1712. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1713. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1714. fmt.Println(count)
  1715. var zero string
  1716. number := count + 1
  1717. if number >= 1000 {
  1718. zero = "0000" + strconv.FormatInt(number, 10)
  1719. } else if number >= 10000 {
  1720. zero = "000" + strconv.FormatInt(number, 10)
  1721. } else if number >= 100000 {
  1722. zero = "00" + strconv.FormatInt(number, 10)
  1723. } else if number >= 1000000 {
  1724. zero = "0" + strconv.FormatInt(number, 10)
  1725. } else {
  1726. zero = strconv.FormatInt(number, 10)
  1727. }
  1728. fmt.Println(zero)
  1729. struct4101 := service.Struct4101{
  1730. PsnNo: order.PsnNo,
  1731. MdtrtId: order.MdtrtId,
  1732. SetlId: order.SetlId,
  1733. PsnName: order.PsnName,
  1734. Gend: order.Gend,
  1735. Brdy: his.Brdy,
  1736. Age: his.Age,
  1737. Naty: order.Naty,
  1738. PatnCertType: "01",
  1739. Certno: order.Certno,
  1740. Prfs: "90",
  1741. ConerName: roles[0].UserName,
  1742. PatnRlts: "99",
  1743. ConerAddr: miConfig.OrgName,
  1744. ConerTel: admin.Mobile,
  1745. HiType: order.Insutype,
  1746. Insuplc: miConfig.InsuplcAdmdvs,
  1747. MaindiagFlag: "1",
  1748. BillCode: last_order.FaPiaoCode,
  1749. BillNo: zero,
  1750. BizSn: order.Number,
  1751. PsnSelfPay: order.PsnPartAmt,
  1752. PsnOwnPay: order.PsnPartAmt,
  1753. AcctPay: order.AcctPay,
  1754. PsnCashpay: order.PsnCashPay,
  1755. HiPaymtd: "1",
  1756. Hsorg: miConfig.InsuplcAdmdvs,
  1757. HsorgOpter: miConfig.InsuplcAdmdvs,
  1758. MedinsFillPsn: curRoles.UserName,
  1759. MedinsFillDept: depart.Name,
  1760. IptMedType: "2",
  1761. }
  1762. struct4101.SetlBegnDate = order.SetlTime
  1763. struct4101.SetlEndDate = order.SetlTime
  1764. time_arr := strings.Split(order.SetlTime, " ")
  1765. struct4101.AdmTime = time_arr[0]
  1766. struct4101.AdmEndTime = time_arr[0]
  1767. var rf []CustomFundPay
  1768. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1769. var tempFunPays []service.CustomStruct
  1770. for _, item := range rf {
  1771. var tempFunPay service.CustomStruct
  1772. tempFunPay.FundPayamt = item.FundPayamt
  1773. tempFunPay.FundPayType = item.FundPayType
  1774. tempFunPays = append(tempFunPays, tempFunPay)
  1775. }
  1776. struct4101.CustomStruct = tempFunPays
  1777. var tempDiaginfos []service.DiaginfoStructTwo
  1778. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1779. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1780. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1781. var config []*models.HisXtDiagnoseConfig
  1782. for _, item := range diagnosis_ids {
  1783. id, _ := strconv.ParseInt(item, 10, 64)
  1784. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1785. config = append(config, &diagnosisConfig)
  1786. }
  1787. for index, item := range config {
  1788. if index == 0 {
  1789. var tempDiaginfo service.DiaginfoStructTwo
  1790. tempDiaginfo.DiagCode = item.CountryCode
  1791. tempDiaginfo.DiagName = item.CountryContentName
  1792. tempDiaginfo.DiagType = "1"
  1793. tempDiaginfo.MaindiagFlag = "1"
  1794. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1795. } else {
  1796. var tempDiaginfo service.DiaginfoStructTwo
  1797. tempDiaginfo.DiagCode = item.CountryCode
  1798. tempDiaginfo.DiagName = item.CountryContentName
  1799. tempDiaginfo.DiagType = "2"
  1800. tempDiaginfo.MaindiagFlag = "0"
  1801. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1802. }
  1803. }
  1804. struct4101.Diseinfo = tempDiaginfos
  1805. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1806. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1807. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1808. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1809. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1810. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1811. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1812. var iteminfo service.IteminfoStruct
  1813. var bedCostTotal float64 = 0 //床位总费
  1814. var bedCostSelfTotal float64 = 0 //床位自费
  1815. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1816. var operationCostTotal float64 = 0 //手术费
  1817. var operationCostSelfTotal float64 = 0 //手术费
  1818. var operationCostPartSelfTotal float64 = 0 //手术费
  1819. var otherCostTotal float64 = 0 //其他费用
  1820. var otherCostSelfTotal float64 = 0 //其他费用
  1821. var otherCostPartSelfTotal float64 = 0 //其他费用
  1822. var materialCostTotal float64 = 0 //材料费
  1823. var materialCostSelfTotal float64 = 0 //材料费
  1824. var materialCostPartSelfTotal float64 = 0 //材料费
  1825. var westernMedicineCostTotal float64 = 0 //西药费
  1826. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1827. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1828. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1829. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1830. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1831. var checkCostTotal float64 = 0 //检查费
  1832. var checkCostSelfTotal float64 = 0 //检查费
  1833. var checkCostPartSelfTotal float64 = 0 //检查费
  1834. var laboratoryCostTotal float64 = 0 //化验费
  1835. var laboratoryCostSelfTotal float64 = 0 //化验费
  1836. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1837. var treatCostTotal float64 = 0 //治疗费用
  1838. var treatCostSelfTotal float64 = 0 //治疗费用
  1839. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1840. decimal.DivisionPrecision = 2
  1841. var bed_fulamt_ownpay_amt float64 = 0
  1842. var operation_fulamt_ownpay_amt float64 = 0
  1843. var other_fulamt_ownpay_amt float64 = 0
  1844. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1845. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1846. var check_fulamt_ownpay_amt float64 = 0
  1847. var material_fulamt_ownpay_amt float64 = 0
  1848. var laboratory_fulamt_ownpay_amt float64 = 0
  1849. var treat_fulamt_ownpay_amt float64 = 0
  1850. var bed_claa_sunmfee float64 = 0
  1851. var bed_clab_amt float64 = 0
  1852. var bed_other_amt float64 = 0
  1853. var operation_claa_sunmfee float64 = 0
  1854. var operation_clab_amt float64 = 0
  1855. var operation_other_amt float64 = 0
  1856. var other_claa_sunmfee float64 = 0
  1857. var other_clab_amt float64 = 0
  1858. var other_other_amt float64 = 0
  1859. var westernMedicine_claa_sunmfee float64 = 0
  1860. var westernMedicine_clab_amt float64 = 0
  1861. var westernMedicine_other_amt float64 = 0
  1862. var chineseTraditional_claa_sunmfee float64 = 0
  1863. var chineseTraditional_clab_amt float64 = 0
  1864. var chineseTraditional_other_amt float64 = 0
  1865. var check_claa_sunmfee float64 = 0
  1866. var check_clab_amt float64 = 0
  1867. var check_other_amt float64 = 0
  1868. var material_claa_sunmfee float64 = 0
  1869. var material_clab_amt float64 = 0
  1870. var material_other_amt float64 = 0
  1871. var laboratory_claa_sunmfee float64 = 0
  1872. var laboratory_clab_amt float64 = 0
  1873. var laboratory_other_amt float64 = 0
  1874. var treat_claa_sunmfee float64 = 0
  1875. var treat_clab_amt float64 = 0
  1876. var treat_other_amt float64 = 0
  1877. for _, item := range order.HisOrderInfo {
  1878. if item.MedChrgitmType == "01" { //床位费
  1879. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1880. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1881. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1882. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1883. if item.ChrgitmLv == "1" {
  1884. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1885. }
  1886. if item.ChrgitmLv == "2" {
  1887. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1888. }
  1889. if item.ChrgitmLv == "3" {
  1890. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1891. }
  1892. }
  1893. if item.MedChrgitmType == "03" { //检查费
  1894. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1895. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1896. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1897. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1898. if item.ChrgitmLv == "1" {
  1899. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1900. }
  1901. if item.ChrgitmLv == "2" {
  1902. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1903. }
  1904. if item.ChrgitmLv == "3" {
  1905. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1906. }
  1907. }
  1908. if item.MedChrgitmType == "04" { //化验费
  1909. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1910. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1911. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1912. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1913. if item.ChrgitmLv == "1" {
  1914. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1915. }
  1916. if item.ChrgitmLv == "2" {
  1917. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1918. }
  1919. if item.ChrgitmLv == "3" {
  1920. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1921. }
  1922. }
  1923. if item.MedChrgitmType == "05" { //治疗费
  1924. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1925. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1926. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1927. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1928. if item.ChrgitmLv == "1" {
  1929. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1930. }
  1931. if item.ChrgitmLv == "2" {
  1932. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1933. }
  1934. if item.ChrgitmLv == "3" {
  1935. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1936. }
  1937. }
  1938. if item.MedChrgitmType == "06" { //手术费
  1939. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1940. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1941. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1942. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1943. if item.ChrgitmLv == "1" {
  1944. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1945. }
  1946. if item.ChrgitmLv == "2" {
  1947. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1948. }
  1949. if item.ChrgitmLv == "3" {
  1950. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1951. }
  1952. }
  1953. if item.MedChrgitmType == "08" { //材料费
  1954. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1955. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1956. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1957. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1958. if item.ChrgitmLv == "1" {
  1959. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1960. }
  1961. if item.ChrgitmLv == "2" {
  1962. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1963. }
  1964. if item.ChrgitmLv == "3" {
  1965. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1966. }
  1967. }
  1968. if item.MedChrgitmType == "09" { //西药费
  1969. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1970. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1971. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1972. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1973. if item.ChrgitmLv == "1" {
  1974. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1975. }
  1976. if item.ChrgitmLv == "2" {
  1977. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1978. }
  1979. if item.ChrgitmLv == "3" {
  1980. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1981. }
  1982. }
  1983. if item.MedChrgitmType == "11" { //中成费
  1984. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1985. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1986. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1987. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1988. if item.ChrgitmLv == "1" {
  1989. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1990. }
  1991. if item.ChrgitmLv == "2" {
  1992. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1993. }
  1994. if item.ChrgitmLv == "3" {
  1995. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1996. }
  1997. }
  1998. if item.MedChrgitmType == "14" { //其他费
  1999. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2000. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2001. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2002. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2003. if item.ChrgitmLv == "1" {
  2004. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2005. }
  2006. if item.ChrgitmLv == "2" {
  2007. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2008. }
  2009. if item.ChrgitmLv == "3" {
  2010. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2011. }
  2012. }
  2013. }
  2014. var iteminfoStructs []service.IteminfoStruct
  2015. if bedCostTotal != 0 {
  2016. iteminfo.MedChrgitm = "01"
  2017. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2018. iteminfo.Amt = bedCostTotal
  2019. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2020. iteminfo.ClabAmt = bed_clab_amt
  2021. iteminfo.OthAmt = bed_other_amt
  2022. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2023. }
  2024. if checkCostTotal != 0 {
  2025. iteminfo.MedChrgitm = "03"
  2026. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2027. iteminfo.Amt = checkCostTotal
  2028. iteminfo.ClaaSumfee = check_claa_sunmfee
  2029. iteminfo.ClabAmt = check_clab_amt
  2030. iteminfo.OthAmt = check_other_amt
  2031. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2032. }
  2033. if laboratoryCostTotal != 0 {
  2034. iteminfo.MedChrgitm = "04"
  2035. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2036. iteminfo.Amt = laboratoryCostTotal
  2037. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2038. iteminfo.ClabAmt = laboratory_clab_amt
  2039. iteminfo.OthAmt = laboratory_other_amt
  2040. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2041. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2042. }
  2043. if treatCostTotal != 0 {
  2044. iteminfo.MedChrgitm = "05"
  2045. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2046. iteminfo.Amt = treatCostTotal
  2047. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2048. iteminfo.ClabAmt = treat_clab_amt
  2049. iteminfo.OthAmt = treat_other_amt
  2050. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2051. //(struct4101.IteminfoStruct, iteminfo)
  2052. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2053. }
  2054. if operationCostTotal != 0 {
  2055. iteminfo.MedChrgitm = "06"
  2056. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2057. iteminfo.Amt = operationCostTotal
  2058. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2059. iteminfo.ClabAmt = operation_clab_amt
  2060. iteminfo.OthAmt = operation_other_amt
  2061. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2062. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2063. }
  2064. if materialCostTotal != 0 {
  2065. iteminfo.MedChrgitm = "08"
  2066. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2067. iteminfo.Amt = materialCostTotal
  2068. iteminfo.ClaaSumfee = material_claa_sunmfee
  2069. iteminfo.ClabAmt = material_clab_amt
  2070. iteminfo.OthAmt = material_other_amt
  2071. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2072. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2073. }
  2074. if westernMedicineCostTotal != 0 {
  2075. iteminfo.MedChrgitm = "09"
  2076. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2077. iteminfo.Amt = westernMedicineCostTotal
  2078. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2079. iteminfo.ClabAmt = westernMedicine_clab_amt
  2080. iteminfo.OthAmt = westernMedicine_other_amt
  2081. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2082. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2083. }
  2084. if chineseTraditionalMedicineCostTotal != 0 {
  2085. iteminfo.MedChrgitm = "11"
  2086. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2087. iteminfo.Amt = westernMedicineCostTotal
  2088. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2089. iteminfo.ClabAmt = westernMedicine_clab_amt
  2090. iteminfo.OthAmt = westernMedicine_other_amt
  2091. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2092. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2093. }
  2094. if otherCostTotal != 0 {
  2095. iteminfo.MedChrgitm = "14"
  2096. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2097. iteminfo.Amt = otherCostTotal
  2098. iteminfo.ClaaSumfee = other_claa_sunmfee
  2099. iteminfo.ClabAmt = other_clab_amt
  2100. iteminfo.OthAmt = other_other_amt
  2101. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2102. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2103. }
  2104. struct4101.IteminfoStruct = iteminfoStructs
  2105. struct4101.Ntly = "中国"
  2106. struct4101.AdmCaty = "A03.06"
  2107. var res ResultSeventeen
  2108. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2109. var resOther ResultSeventeenOther
  2110. var pp models.PublicParams
  2111. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2112. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2113. pp.FixmedinsName = miConfig.OrgName
  2114. pp.FixmedinsCode = miConfig.Code
  2115. pp.RequestUrl = miConfig.Url
  2116. pp.Cainfo = miConfig.Cainfo
  2117. pp.SecretKey = miConfig.SecretKey
  2118. pp.AccessKey = miConfig.AccessKey
  2119. pp.OpterName = curRoles.UserName
  2120. client := &http.Client{}
  2121. var req *http.Request
  2122. data := make(map[string]interface{})
  2123. data["struct4101"] = struct4101
  2124. data["pp"] = pp
  2125. bytesData, _ := json.Marshal(data)
  2126. if miConfig.MdtrtareaAdmvs == "320921" {
  2127. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2128. } else {
  2129. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2130. }
  2131. resp, _ := client.Do(req)
  2132. defer resp.Body.Close()
  2133. body, ioErr := ioutil.ReadAll(resp.Body)
  2134. if ioErr != nil {
  2135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2137. return
  2138. }
  2139. var respJSON map[string]interface{}
  2140. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2143. return
  2144. }
  2145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2146. userJSONBytes, _ := json.Marshal(respJSON)
  2147. fmt.Println("log")
  2148. fmt.Println(string(userJSONBytes))
  2149. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2150. utils.ErrorLog("解析失败:%v", err)
  2151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2152. return
  2153. }
  2154. res.InfRefmsgid = resOther.InfRefmsgid
  2155. res.Output = resOther.Output
  2156. res.ErrMsg = resOther.ErrMsg
  2157. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2158. res.Infcode = infocode
  2159. } else {
  2160. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2161. var dat map[string]interface{}
  2162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2163. fmt.Println(dat)
  2164. } else {
  2165. fmt.Println(err)
  2166. }
  2167. userJSONBytes, _ := json.Marshal(dat)
  2168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2169. utils.ErrorLog("解析失败:%v", err)
  2170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2171. return
  2172. }
  2173. }
  2174. if res.Infcode != 0 {
  2175. c.ServeSuccessJSON(map[string]interface{}{
  2176. "failed_code": -10,
  2177. "msg": res.ErrMsg,
  2178. })
  2179. return
  2180. } else {
  2181. order.FaPiaoNumber = zero
  2182. order.FaPiaoCode = last_order.FaPiaoCode
  2183. service.UpdateOrder(order)
  2184. hisFundSettleListResult := &models.HisFundSettleListResult{
  2185. Number: res.Output.SetlListId,
  2186. Status: 1,
  2187. Ctime: time.Now().Unix(),
  2188. Mtime: time.Now().Unix(),
  2189. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2190. IsUpload: 1,
  2191. OrderId: order_id,
  2192. }
  2193. service.CreateUploadRecord(hisFundSettleListResult)
  2194. c.ServeSuccessJSON(map[string]interface{}{
  2195. "msg": "上传成功",
  2196. "result": hisFundSettleListResult,
  2197. })
  2198. return
  2199. }
  2200. }
  2201. func (c *HisApiController) GetSettleListHospital() {
  2202. order_id, _ := c.GetInt64("order_id")
  2203. admin_user_id, _ := c.GetInt64("admin_user_id")
  2204. order, _ := service.GetHisOrderByIDTwo(order_id)
  2205. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2206. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2207. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2208. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2209. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2210. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2211. if order.ID == 0 {
  2212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2213. return
  2214. }
  2215. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2216. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2217. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2218. fmt.Println(count)
  2219. var zero string
  2220. number := count + 1
  2221. if number >= 1000 {
  2222. zero = "0000" + strconv.FormatInt(number, 10)
  2223. } else if number >= 10000 {
  2224. zero = "000" + strconv.FormatInt(number, 10)
  2225. } else if number >= 100000 {
  2226. zero = "00" + strconv.FormatInt(number, 10)
  2227. } else if number >= 1000000 {
  2228. zero = "0" + strconv.FormatInt(number, 10)
  2229. } else {
  2230. zero = strconv.FormatInt(number, 10)
  2231. }
  2232. fmt.Println(zero)
  2233. struct4101 := service.Struct4101{
  2234. PsnNo: order.PsnNo,
  2235. MdtrtId: order.MdtrtId,
  2236. SetlId: order.SetlId,
  2237. PsnName: order.PsnName,
  2238. Gend: order.Gend,
  2239. Brdy: his.Brdy,
  2240. Age: int64(order.Age),
  2241. Naty: order.Naty,
  2242. PatnCertType: "01",
  2243. Certno: order.Certno,
  2244. Prfs: "90",
  2245. ConerName: roles[0].UserName,
  2246. PatnRlts: "99",
  2247. ConerAddr: miConfig.OrgName,
  2248. ConerTel: admin.Mobile,
  2249. HiType: order.Insutype,
  2250. Insuplc: miConfig.InsuplcAdmdvs,
  2251. MaindiagFlag: "1",
  2252. BillCode: last_order.FaPiaoCode,
  2253. BillNo: zero,
  2254. BizSn: order.Number,
  2255. PsnSelfPay: order.PsnPartAmt,
  2256. PsnOwnPay: order.PsnPartAmt,
  2257. AcctPay: order.AcctPay,
  2258. PsnCashpay: order.PsnCashPay,
  2259. HiPaymtd: "1",
  2260. Hsorg: miConfig.InsuplcAdmdvs,
  2261. HsorgOpter: miConfig.InsuplcAdmdvs,
  2262. MedinsFillPsn: curRoles.UserName,
  2263. MedinsFillDept: depart.Name,
  2264. IptMedType: "2",
  2265. AdmTime: his.InHosptialTime,
  2266. AdmEndTime: his.OutHosptialTime,
  2267. }
  2268. struct4101.SetlBegnDate = order.SetlTime
  2269. struct4101.SetlEndDate = order.SetlTime
  2270. var rf []CustomFundPay
  2271. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2272. var tempFunPays []service.CustomStruct
  2273. for _, item := range rf {
  2274. var tempFunPay service.CustomStruct
  2275. tempFunPay.FundPayamt = item.FundPayamt
  2276. tempFunPay.FundPayType = item.FundPayType
  2277. tempFunPays = append(tempFunPays, tempFunPay)
  2278. }
  2279. struct4101.CustomStruct = tempFunPays
  2280. var tempDiaginfos []service.DiaginfoStructTwo
  2281. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2282. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2283. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2284. var config []*models.HisXtDiagnoseConfig
  2285. for _, item := range diagnosis_ids {
  2286. id, _ := strconv.ParseInt(item, 10, 64)
  2287. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2288. config = append(config, &diagnosisConfig)
  2289. }
  2290. for index, item := range config {
  2291. if index == 0 {
  2292. var tempDiaginfo service.DiaginfoStructTwo
  2293. tempDiaginfo.DiagCode = item.CountryCode
  2294. tempDiaginfo.DiagName = item.CountryContentName
  2295. tempDiaginfo.DiagType = "1"
  2296. tempDiaginfo.MaindiagFlag = "1"
  2297. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2298. } else {
  2299. var tempDiaginfo service.DiaginfoStructTwo
  2300. tempDiaginfo.DiagCode = item.CountryCode
  2301. tempDiaginfo.DiagName = item.CountryContentName
  2302. tempDiaginfo.DiagType = "2"
  2303. tempDiaginfo.MaindiagFlag = "0"
  2304. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2305. }
  2306. }
  2307. struct4101.Diseinfo = tempDiaginfos
  2308. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2309. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2310. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2311. tempOpspdiseinfo2.OprnOprtCode = ""
  2312. tempOpspdiseinfo2.OprnOprtName = ""
  2313. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2314. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2315. var iteminfo service.IteminfoStruct
  2316. var bedCostTotal float64 = 0 //床位总费
  2317. var bedCostSelfTotal float64 = 0 //床位自费
  2318. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2319. var operationCostTotal float64 = 0 //手术费
  2320. var operationCostSelfTotal float64 = 0 //手术费
  2321. var operationCostPartSelfTotal float64 = 0 //手术费
  2322. var otherCostTotal float64 = 0 //其他费用
  2323. var otherCostSelfTotal float64 = 0 //其他费用
  2324. var otherCostPartSelfTotal float64 = 0 //其他费用
  2325. var materialCostTotal float64 = 0 //材料费
  2326. var materialCostSelfTotal float64 = 0 //材料费
  2327. var materialCostPartSelfTotal float64 = 0 //材料费
  2328. var westernMedicineCostTotal float64 = 0 //西药费
  2329. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2330. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2331. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2332. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2333. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2334. var checkCostTotal float64 = 0 //检查费
  2335. var checkCostSelfTotal float64 = 0 //检查费
  2336. var checkCostPartSelfTotal float64 = 0 //检查费
  2337. var laboratoryCostTotal float64 = 0 //化验费
  2338. var laboratoryCostSelfTotal float64 = 0 //化验费
  2339. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2340. var treatCostTotal float64 = 0 //治疗费用
  2341. var treatCostSelfTotal float64 = 0 //治疗费用
  2342. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2343. decimal.DivisionPrecision = 2
  2344. var bed_fulamt_ownpay_amt float64 = 0
  2345. var operation_fulamt_ownpay_amt float64 = 0
  2346. var other_fulamt_ownpay_amt float64 = 0
  2347. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2348. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2349. var check_fulamt_ownpay_amt float64 = 0
  2350. var material_fulamt_ownpay_amt float64 = 0
  2351. var laboratory_fulamt_ownpay_amt float64 = 0
  2352. var treat_fulamt_ownpay_amt float64 = 0
  2353. var bed_claa_sunmfee float64 = 0
  2354. var bed_clab_amt float64 = 0
  2355. var bed_other_amt float64 = 0
  2356. var operation_claa_sunmfee float64 = 0
  2357. var operation_clab_amt float64 = 0
  2358. var operation_other_amt float64 = 0
  2359. var other_claa_sunmfee float64 = 0
  2360. var other_clab_amt float64 = 0
  2361. var other_other_amt float64 = 0
  2362. var westernMedicine_claa_sunmfee float64 = 0
  2363. var westernMedicine_clab_amt float64 = 0
  2364. var westernMedicine_other_amt float64 = 0
  2365. var chineseTraditional_claa_sunmfee float64 = 0
  2366. var chineseTraditional_clab_amt float64 = 0
  2367. var chineseTraditional_other_amt float64 = 0
  2368. var check_claa_sunmfee float64 = 0
  2369. var check_clab_amt float64 = 0
  2370. var check_other_amt float64 = 0
  2371. var material_claa_sunmfee float64 = 0
  2372. var material_clab_amt float64 = 0
  2373. var material_other_amt float64 = 0
  2374. var laboratory_claa_sunmfee float64 = 0
  2375. var laboratory_clab_amt float64 = 0
  2376. var laboratory_other_amt float64 = 0
  2377. var treat_claa_sunmfee float64 = 0
  2378. var treat_clab_amt float64 = 0
  2379. var treat_other_amt float64 = 0
  2380. for _, item := range order.HisOrderInfo {
  2381. if item.MedChrgitmType == "01" { //床位费
  2382. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2383. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2384. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2385. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2386. if item.ChrgitmLv == "1" {
  2387. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2388. }
  2389. if item.ChrgitmLv == "2" {
  2390. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2391. }
  2392. if item.ChrgitmLv == "3" {
  2393. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2394. }
  2395. }
  2396. if item.MedChrgitmType == "03" { //检查费
  2397. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2398. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2399. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2400. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2401. if item.ChrgitmLv == "1" {
  2402. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2403. }
  2404. if item.ChrgitmLv == "2" {
  2405. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2406. }
  2407. if item.ChrgitmLv == "3" {
  2408. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2409. }
  2410. }
  2411. if item.MedChrgitmType == "04" { //化验费
  2412. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2413. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2414. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2415. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2416. if item.ChrgitmLv == "1" {
  2417. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2418. }
  2419. if item.ChrgitmLv == "2" {
  2420. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2421. }
  2422. if item.ChrgitmLv == "3" {
  2423. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2424. }
  2425. }
  2426. if item.MedChrgitmType == "05" { //治疗费
  2427. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2428. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2429. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2430. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2431. if item.ChrgitmLv == "1" {
  2432. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2433. }
  2434. if item.ChrgitmLv == "2" {
  2435. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2436. }
  2437. if item.ChrgitmLv == "3" {
  2438. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2439. }
  2440. }
  2441. if item.MedChrgitmType == "06" { //手术费
  2442. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2443. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2444. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2445. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2446. if item.ChrgitmLv == "1" {
  2447. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2448. }
  2449. if item.ChrgitmLv == "2" {
  2450. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2451. }
  2452. if item.ChrgitmLv == "3" {
  2453. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2454. }
  2455. }
  2456. if item.MedChrgitmType == "08" { //材料费
  2457. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2458. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2459. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2460. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2461. if item.ChrgitmLv == "1" {
  2462. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2463. }
  2464. if item.ChrgitmLv == "2" {
  2465. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2466. }
  2467. if item.ChrgitmLv == "3" {
  2468. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2469. }
  2470. }
  2471. if item.MedChrgitmType == "09" { //西药费
  2472. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2473. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2474. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2475. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2476. if item.ChrgitmLv == "1" {
  2477. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2478. }
  2479. if item.ChrgitmLv == "2" {
  2480. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2481. }
  2482. if item.ChrgitmLv == "3" {
  2483. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2484. }
  2485. }
  2486. if item.MedChrgitmType == "11" { //中成费
  2487. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2488. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2489. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2490. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2491. if item.ChrgitmLv == "1" {
  2492. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2493. }
  2494. if item.ChrgitmLv == "2" {
  2495. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2496. }
  2497. if item.ChrgitmLv == "3" {
  2498. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2499. }
  2500. }
  2501. if item.MedChrgitmType == "14" { //其他费
  2502. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2503. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2504. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2505. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2506. if item.ChrgitmLv == "1" {
  2507. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2508. }
  2509. if item.ChrgitmLv == "2" {
  2510. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2511. }
  2512. if item.ChrgitmLv == "3" {
  2513. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2514. }
  2515. }
  2516. }
  2517. var iteminfoStructs []service.IteminfoStruct
  2518. if bedCostTotal != 0 {
  2519. iteminfo.MedChrgitm = "01"
  2520. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2521. iteminfo.Amt = bedCostTotal
  2522. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2523. iteminfo.ClabAmt = bed_clab_amt
  2524. iteminfo.OthAmt = bed_other_amt
  2525. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2526. }
  2527. if checkCostTotal != 0 {
  2528. iteminfo.MedChrgitm = "03"
  2529. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2530. iteminfo.Amt = checkCostTotal
  2531. iteminfo.ClaaSumfee = check_claa_sunmfee
  2532. iteminfo.ClabAmt = check_clab_amt
  2533. iteminfo.OthAmt = check_other_amt
  2534. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2535. }
  2536. if laboratoryCostTotal != 0 {
  2537. iteminfo.MedChrgitm = "04"
  2538. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2539. iteminfo.Amt = laboratoryCostTotal
  2540. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2541. iteminfo.ClabAmt = laboratory_clab_amt
  2542. iteminfo.OthAmt = laboratory_other_amt
  2543. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2544. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2545. }
  2546. if treatCostTotal != 0 {
  2547. iteminfo.MedChrgitm = "05"
  2548. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2549. iteminfo.Amt = treatCostTotal
  2550. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2551. iteminfo.ClabAmt = treat_clab_amt
  2552. iteminfo.OthAmt = treat_other_amt
  2553. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2554. //(struct4101.IteminfoStruct, iteminfo)
  2555. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2556. }
  2557. if operationCostTotal != 0 {
  2558. iteminfo.MedChrgitm = "06"
  2559. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2560. iteminfo.Amt = operationCostTotal
  2561. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2562. iteminfo.ClabAmt = operation_clab_amt
  2563. iteminfo.OthAmt = operation_other_amt
  2564. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2565. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2566. }
  2567. if materialCostTotal != 0 {
  2568. iteminfo.MedChrgitm = "08"
  2569. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2570. iteminfo.Amt = materialCostTotal
  2571. iteminfo.ClaaSumfee = material_claa_sunmfee
  2572. iteminfo.ClabAmt = material_clab_amt
  2573. iteminfo.OthAmt = material_other_amt
  2574. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2575. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2576. }
  2577. if westernMedicineCostTotal != 0 {
  2578. iteminfo.MedChrgitm = "09"
  2579. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2580. iteminfo.Amt = westernMedicineCostTotal
  2581. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2582. iteminfo.ClabAmt = westernMedicine_clab_amt
  2583. iteminfo.OthAmt = westernMedicine_other_amt
  2584. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2585. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2586. }
  2587. if chineseTraditionalMedicineCostTotal != 0 {
  2588. iteminfo.MedChrgitm = "11"
  2589. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2590. iteminfo.Amt = westernMedicineCostTotal
  2591. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2592. iteminfo.ClabAmt = westernMedicine_clab_amt
  2593. iteminfo.OthAmt = westernMedicine_other_amt
  2594. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2595. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2596. }
  2597. if otherCostTotal != 0 {
  2598. iteminfo.MedChrgitm = "14"
  2599. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2600. iteminfo.Amt = otherCostTotal
  2601. iteminfo.ClaaSumfee = other_claa_sunmfee
  2602. iteminfo.ClabAmt = other_clab_amt
  2603. iteminfo.OthAmt = other_other_amt
  2604. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2605. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2606. }
  2607. struct4101.IteminfoStruct = iteminfoStructs
  2608. struct4101.Ntly = "中国"
  2609. struct4101.AdmCaty = "A03.06"
  2610. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2611. fmt.Println(result)
  2612. var dat map[string]interface{}
  2613. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2614. fmt.Println(dat)
  2615. } else {
  2616. fmt.Println(err)
  2617. }
  2618. userJSONBytes, _ := json.Marshal(dat)
  2619. var res ResultSeventeen
  2620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2621. utils.ErrorLog("解析失败:%v", err)
  2622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2623. return
  2624. }
  2625. if res.Infcode != 0 {
  2626. c.ServeSuccessJSON(map[string]interface{}{
  2627. "failed_code": -10,
  2628. "msg": res.ErrMsg,
  2629. })
  2630. return
  2631. } else {
  2632. order.FaPiaoNumber = zero
  2633. order.FaPiaoCode = last_order.FaPiaoCode
  2634. service.UpdateOrder(order)
  2635. hisFundSettleListResult := &models.HisFundSettleListResult{
  2636. Number: res.Output.SetlListId,
  2637. Status: 1,
  2638. Ctime: time.Now().Unix(),
  2639. Mtime: time.Now().Unix(),
  2640. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2641. IsUpload: 1,
  2642. OrderId: order_id,
  2643. }
  2644. service.CreateUploadRecord(hisFundSettleListResult)
  2645. c.ServeSuccessJSON(map[string]interface{}{
  2646. "msg": "上传成功",
  2647. "result": hisFundSettleListResult,
  2648. })
  2649. return
  2650. }
  2651. }
  2652. func (c *HisApiController) GetBatchSettleList() {
  2653. orders, _ := service.GetAllHisOrder(10106)
  2654. for _, item := range orders {
  2655. order_id := item.ID
  2656. order, _ := service.GetHisOrderByIDTwo(order_id)
  2657. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2658. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2659. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2660. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2661. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2663. if order.ID == 0 {
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2665. return
  2666. }
  2667. if his.BalanceAccountsType == 2 {
  2668. continue
  2669. }
  2670. struct4101 := service.Struct4101{
  2671. PsnNo: order.PsnNo,
  2672. MdtrtId: order.MdtrtId,
  2673. SetlId: order.SetlId,
  2674. PsnName: order.PsnName,
  2675. Gend: order.Gend,
  2676. Brdy: his.Brdy,
  2677. Age: his.Age,
  2678. Naty: order.Naty,
  2679. PatnCertType: "01",
  2680. Certno: order.Certno,
  2681. Prfs: "90",
  2682. ConerName: roles[0].UserName,
  2683. PatnRlts: "99",
  2684. ConerAddr: miConfig.OrgName,
  2685. ConerTel: admin.Mobile,
  2686. HiType: order.Insutype,
  2687. Insuplc: his.InsuplcAdmdvs,
  2688. MaindiagFlag: "1",
  2689. BillCode: order.FaPiaoCode,
  2690. BillNo: order.FaPiaoNumber,
  2691. BizSn: order.Number,
  2692. PsnSelfPay: order.PsnPartAmt,
  2693. PsnOwnPay: order.PsnPartAmt,
  2694. AcctPay: order.AcctPay,
  2695. PsnCashpay: order.PsnCashPay,
  2696. HiPaymtd: "1",
  2697. Hsorg: his.InsuplcAdmdvs,
  2698. HsorgOpter: his.InsuplcAdmdvs,
  2699. MedinsFillPsn: curRoles.UserName,
  2700. MedinsFillDept: depart.Name,
  2701. IptMedType: "2",
  2702. }
  2703. struct4101.SetlBegnDate = order.SetlTime
  2704. struct4101.SetlEndDate = order.SetlTime
  2705. //if order.SettleType == 1 {
  2706. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2707. // dateStr := t.Format("2006-01-02")
  2708. // struct4101.SetlBegnDate = dateStr
  2709. // struct4101.SetlEndDate = dateStr
  2710. //} else {
  2711. // t := time.Unix(int64(order.SettleStartTime), 0)
  2712. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2713. // dateStartStr := t.Format("2006-01-02")
  2714. // dateEndStr := t2.Format("2006-01-02")
  2715. // struct4101.SetlBegnDate = dateStartStr
  2716. // struct4101.SetlEndDate = dateEndStr
  2717. //}
  2718. var rf []CustomFundPay
  2719. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2720. var tempFunPays []service.CustomStruct
  2721. var tempFunPay610100 service.CustomStruct
  2722. for _, item := range rf {
  2723. if item.FundPayType == "610100" {
  2724. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2725. tempFunPay610100.FundPayType = item.FundPayType
  2726. } else {
  2727. var tempFunPay service.CustomStruct
  2728. tempFunPay.FundPayamt = item.FundPayamt
  2729. tempFunPay.FundPayType = item.FundPayType
  2730. tempFunPays = append(tempFunPays, tempFunPay)
  2731. }
  2732. }
  2733. tempFunPays = append(tempFunPays, tempFunPay610100)
  2734. struct4101.CustomStruct = tempFunPays
  2735. var tempDiaginfos []service.DiaginfoStructTwo
  2736. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2737. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2738. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2739. var config []*models.HisXtDiagnoseConfig
  2740. for _, item := range diagnosis_ids {
  2741. id, _ := strconv.ParseInt(item, 10, 64)
  2742. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2743. config = append(config, &diagnosisConfig)
  2744. }
  2745. for index, item := range config {
  2746. if index == 0 {
  2747. var tempDiaginfo service.DiaginfoStructTwo
  2748. tempDiaginfo.DiagCode = item.CountryCode
  2749. tempDiaginfo.DiagName = item.CountryContentName
  2750. tempDiaginfo.DiagType = "1"
  2751. tempDiaginfo.MaindiagFlag = "1"
  2752. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2753. } else {
  2754. var tempDiaginfo service.DiaginfoStructTwo
  2755. tempDiaginfo.DiagCode = item.CountryCode
  2756. tempDiaginfo.DiagName = item.CountryContentName
  2757. tempDiaginfo.DiagType = "2"
  2758. tempDiaginfo.MaindiagFlag = "0"
  2759. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2760. }
  2761. }
  2762. struct4101.Diseinfo = tempDiaginfos
  2763. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2764. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2765. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2766. tempOpspdiseinfo2.OprnOprtCode = ""
  2767. tempOpspdiseinfo2.OprnOprtName = ""
  2768. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2769. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2770. var iteminfo service.IteminfoStruct
  2771. var bedCostTotal float64 = 0 //床位总费
  2772. var bedCostSelfTotal float64 = 0 //床位自费
  2773. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2774. var examineCostTotal float64 = 0 //诊查总费
  2775. var examineCostSelfTotal float64 = 0 //诊查自费
  2776. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2777. var nursingCostTotal float64 = 0 //护理总费
  2778. var nursingCostSelfTotal float64 = 0 //护理自费
  2779. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2780. var chineseMedicineCostTotal float64 = 0 //中成药
  2781. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2782. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2783. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2784. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2785. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2786. var registerCostTotal float64 = 0 //一般诊疗费
  2787. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2788. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2789. var operationCostTotal float64 = 0 //手术费
  2790. var operationCostSelfTotal float64 = 0 //手术费
  2791. var operationCostPartSelfTotal float64 = 0 //手术费
  2792. var otherCostTotal float64 = 0 //其他费用
  2793. var otherCostSelfTotal float64 = 0 //其他费用
  2794. var otherCostPartSelfTotal float64 = 0 //其他费用
  2795. var materialCostTotal float64 = 0 //材料费
  2796. var materialCostSelfTotal float64 = 0 //材料费
  2797. var materialCostPartSelfTotal float64 = 0 //材料费
  2798. var westernMedicineCostTotal float64 = 0 //西药费
  2799. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2800. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2801. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2802. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2803. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2804. var checkCostTotal float64 = 0 //检查费
  2805. var checkCostSelfTotal float64 = 0 //检查费
  2806. var checkCostPartSelfTotal float64 = 0 //检查费
  2807. var laboratoryCostTotal float64 = 0 //化验费
  2808. var laboratoryCostSelfTotal float64 = 0 //化验费
  2809. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2810. var treatCostTotal float64 = 0 //治疗费用
  2811. var treatCostSelfTotal float64 = 0 //治疗费用
  2812. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2813. decimal.DivisionPrecision = 2
  2814. var bed_fulamt_ownpay_amt float64 = 0
  2815. var examine_fulamt_ownpay_amt float64 = 0
  2816. var nursing_fulamt_ownpay_amt float64 = 0
  2817. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2818. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2819. var register_fulamt_ownpay_amt float64 = 0
  2820. var operation_fulamt_ownpay_amt float64 = 0
  2821. var other_fulamt_ownpay_amt float64 = 0
  2822. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2823. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2824. var check_fulamt_ownpay_amt float64 = 0
  2825. var material_fulamt_ownpay_amt float64 = 0
  2826. var laboratory_fulamt_ownpay_amt float64 = 0
  2827. var treat_fulamt_ownpay_amt float64 = 0
  2828. var bed_claa_sunmfee float64 = 0
  2829. var bed_clab_amt float64 = 0
  2830. var bed_other_amt float64 = 0
  2831. var examine_claa_sunmfee float64 = 0
  2832. var examine_clab_amt float64 = 0
  2833. var examine_other_amt float64 = 0
  2834. var nursing_claa_sunmfee float64 = 0
  2835. var nursing_clab_amt float64 = 0
  2836. var nursing_other_amt float64 = 0
  2837. var chinese_medicine_claa_sunmfee float64 = 0
  2838. var chinese_medicine_clab_amt float64 = 0
  2839. var chinese_medicine_other_amt float64 = 0
  2840. var commonly_treatment_claa_sunmfee float64 = 0
  2841. var commonly_treatment_clab_amt float64 = 0
  2842. var commonly_treatment_other_amt float64 = 0
  2843. var operation_claa_sunmfee float64 = 0
  2844. var operation_clab_amt float64 = 0
  2845. var operation_other_amt float64 = 0
  2846. var other_claa_sunmfee float64 = 0
  2847. var other_clab_amt float64 = 0
  2848. var other_other_amt float64 = 0
  2849. var westernMedicine_claa_sunmfee float64 = 0
  2850. var westernMedicine_clab_amt float64 = 0
  2851. var westernMedicine_other_amt float64 = 0
  2852. var chineseTraditional_claa_sunmfee float64 = 0
  2853. var chineseTraditional_clab_amt float64 = 0
  2854. var chineseTraditional_other_amt float64 = 0
  2855. var check_claa_sunmfee float64 = 0
  2856. var check_clab_amt float64 = 0
  2857. var check_other_amt float64 = 0
  2858. var material_claa_sunmfee float64 = 0
  2859. var material_clab_amt float64 = 0
  2860. var material_other_amt float64 = 0
  2861. var laboratory_claa_sunmfee float64 = 0
  2862. var laboratory_clab_amt float64 = 0
  2863. var laboratory_other_amt float64 = 0
  2864. var treat_claa_sunmfee float64 = 0
  2865. var treat_clab_amt float64 = 0
  2866. var treat_other_amt float64 = 0
  2867. var register_claa_sunmfee float64 = 0
  2868. var register_clab_amt float64 = 0
  2869. var register_other_amt float64 = 0
  2870. for _, item := range order.HisOrderInfo {
  2871. if item.MedChrgitmType == "01" { //床位费
  2872. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2873. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2874. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2875. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2876. if item.ChrgitmLv == "1" {
  2877. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2878. }
  2879. if item.ChrgitmLv == "2" {
  2880. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2881. }
  2882. if item.ChrgitmLv == "3" {
  2883. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2884. }
  2885. }
  2886. if item.MedChrgitmType == "02" { //诊查
  2887. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2888. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2889. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2890. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2891. if item.ChrgitmLv == "1" {
  2892. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2893. }
  2894. if item.ChrgitmLv == "2" {
  2895. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2896. }
  2897. if item.ChrgitmLv == "3" {
  2898. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2899. }
  2900. }
  2901. if item.MedChrgitmType == "03" { //检查费
  2902. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2903. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2904. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2905. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2906. if item.ChrgitmLv == "1" {
  2907. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2908. }
  2909. if item.ChrgitmLv == "2" {
  2910. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2911. }
  2912. if item.ChrgitmLv == "3" {
  2913. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2914. }
  2915. }
  2916. if item.MedChrgitmType == "04" { //化验费
  2917. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2918. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2919. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2920. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2921. if item.ChrgitmLv == "1" {
  2922. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2923. }
  2924. if item.ChrgitmLv == "2" {
  2925. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2926. }
  2927. if item.ChrgitmLv == "3" {
  2928. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2929. }
  2930. }
  2931. if item.MedChrgitmType == "05" { //治疗费
  2932. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2933. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2934. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2935. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2936. if item.ChrgitmLv == "1" {
  2937. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2938. }
  2939. if item.ChrgitmLv == "2" {
  2940. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2941. }
  2942. if item.ChrgitmLv == "3" {
  2943. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2944. }
  2945. }
  2946. if item.MedChrgitmType == "06" { //手术费
  2947. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2948. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2949. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2950. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2951. if item.ChrgitmLv == "1" {
  2952. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2953. }
  2954. if item.ChrgitmLv == "2" {
  2955. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2956. }
  2957. if item.ChrgitmLv == "3" {
  2958. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2959. }
  2960. }
  2961. if item.MedChrgitmType == "07" { //手术费
  2962. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2963. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2964. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2965. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2966. if item.ChrgitmLv == "1" {
  2967. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2968. }
  2969. if item.ChrgitmLv == "2" {
  2970. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2971. }
  2972. if item.ChrgitmLv == "3" {
  2973. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2974. }
  2975. }
  2976. if item.MedChrgitmType == "08" { //材料费
  2977. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2978. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2979. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2980. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2981. if item.ChrgitmLv == "1" {
  2982. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2983. }
  2984. if item.ChrgitmLv == "2" {
  2985. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2986. }
  2987. if item.ChrgitmLv == "3" {
  2988. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2989. }
  2990. }
  2991. if item.MedChrgitmType == "09" { //西药费
  2992. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2993. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2994. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2995. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2996. if item.ChrgitmLv == "1" {
  2997. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2998. }
  2999. if item.ChrgitmLv == "2" {
  3000. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3001. }
  3002. if item.ChrgitmLv == "3" {
  3003. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3004. }
  3005. }
  3006. if item.MedChrgitmType == "10" { //中药饮片
  3007. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3008. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3009. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3010. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3011. if item.ChrgitmLv == "1" {
  3012. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3013. }
  3014. if item.ChrgitmLv == "2" {
  3015. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3016. }
  3017. if item.ChrgitmLv == "3" {
  3018. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3019. }
  3020. }
  3021. if item.MedChrgitmType == "11" { //中成费
  3022. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3023. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3024. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3025. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3026. if item.ChrgitmLv == "1" {
  3027. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3028. }
  3029. if item.ChrgitmLv == "2" {
  3030. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3031. }
  3032. if item.ChrgitmLv == "3" {
  3033. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3034. }
  3035. }
  3036. if item.MedChrgitmType == "12" { //中成费
  3037. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3038. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3039. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3040. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3041. if item.ChrgitmLv == "1" {
  3042. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3043. }
  3044. if item.ChrgitmLv == "2" {
  3045. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3046. }
  3047. if item.ChrgitmLv == "3" {
  3048. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3049. }
  3050. }
  3051. if item.MedChrgitmType == "13" { //中成费
  3052. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3053. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3054. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3055. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3056. if item.ChrgitmLv == "1" {
  3057. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3058. }
  3059. if item.ChrgitmLv == "2" {
  3060. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3061. }
  3062. if item.ChrgitmLv == "3" {
  3063. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3064. }
  3065. }
  3066. if item.MedChrgitmType == "14" { //其他费
  3067. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3068. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3069. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3070. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3071. if item.ChrgitmLv == "1" {
  3072. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3073. }
  3074. if item.ChrgitmLv == "2" {
  3075. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3076. }
  3077. if item.ChrgitmLv == "3" {
  3078. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3079. }
  3080. }
  3081. }
  3082. var iteminfoStructs []service.IteminfoStruct
  3083. if bedCostTotal != 0 {
  3084. iteminfo.MedChrgitm = "01"
  3085. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3086. iteminfo.Amt = bedCostTotal
  3087. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3088. iteminfo.ClabAmt = bed_clab_amt
  3089. iteminfo.OthAmt = bed_other_amt
  3090. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3091. }
  3092. if examineCostTotal != 0 {
  3093. iteminfo.MedChrgitm = "02"
  3094. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3095. iteminfo.Amt = examineCostTotal
  3096. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3097. iteminfo.ClabAmt = examine_clab_amt
  3098. iteminfo.OthAmt = examine_other_amt
  3099. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3100. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3101. }
  3102. if checkCostTotal != 0 {
  3103. iteminfo.MedChrgitm = "03"
  3104. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3105. iteminfo.Amt = checkCostTotal
  3106. iteminfo.ClaaSumfee = check_claa_sunmfee
  3107. iteminfo.ClabAmt = check_clab_amt
  3108. iteminfo.OthAmt = check_other_amt
  3109. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3110. }
  3111. if laboratoryCostTotal != 0 {
  3112. iteminfo.MedChrgitm = "04"
  3113. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3114. iteminfo.Amt = laboratoryCostTotal
  3115. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3116. iteminfo.ClabAmt = laboratory_clab_amt
  3117. iteminfo.OthAmt = laboratory_other_amt
  3118. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3119. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3120. }
  3121. if treatCostTotal != 0 {
  3122. iteminfo.MedChrgitm = "05"
  3123. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3124. iteminfo.Amt = treatCostTotal
  3125. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3126. iteminfo.ClabAmt = treat_clab_amt
  3127. iteminfo.OthAmt = treat_other_amt
  3128. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3129. //(struct4101.IteminfoStruct, iteminfo)
  3130. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3131. }
  3132. if operationCostTotal != 0 {
  3133. iteminfo.MedChrgitm = "06"
  3134. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3135. iteminfo.Amt = operationCostTotal
  3136. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3137. iteminfo.ClabAmt = operation_clab_amt
  3138. iteminfo.OthAmt = operation_other_amt
  3139. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3140. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3141. }
  3142. if nursingCostTotal != 0 {
  3143. iteminfo.MedChrgitm = "07"
  3144. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3145. iteminfo.Amt = nursingCostTotal
  3146. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3147. iteminfo.ClabAmt = nursing_clab_amt
  3148. iteminfo.OthAmt = nursing_other_amt
  3149. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3150. }
  3151. if materialCostTotal != 0 {
  3152. iteminfo.MedChrgitm = "08"
  3153. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3154. iteminfo.Amt = materialCostTotal
  3155. iteminfo.ClaaSumfee = material_claa_sunmfee
  3156. iteminfo.ClabAmt = material_clab_amt
  3157. iteminfo.OthAmt = material_other_amt
  3158. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3159. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3160. }
  3161. if westernMedicineCostTotal != 0 {
  3162. iteminfo.MedChrgitm = "09"
  3163. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3164. iteminfo.Amt = westernMedicineCostTotal
  3165. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3166. iteminfo.ClabAmt = westernMedicine_clab_amt
  3167. iteminfo.OthAmt = westernMedicine_other_amt
  3168. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3169. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3170. }
  3171. if chineseMedicineCostTotal != 0 {
  3172. iteminfo.MedChrgitm = "10"
  3173. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3174. iteminfo.Amt = chineseMedicineCostTotal
  3175. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3176. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3177. iteminfo.OthAmt = chinese_medicine_other_amt
  3178. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3179. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3180. }
  3181. if chineseTraditionalMedicineCostTotal != 0 {
  3182. iteminfo.MedChrgitm = "11"
  3183. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3184. iteminfo.Amt = westernMedicineCostTotal
  3185. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3186. iteminfo.ClabAmt = westernMedicine_clab_amt
  3187. iteminfo.OthAmt = westernMedicine_other_amt
  3188. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3189. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3190. }
  3191. if commonlyTreatmentCostTotal != 0 {
  3192. iteminfo.MedChrgitm = "12"
  3193. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3194. iteminfo.Amt = commonlyTreatmentCostTotal
  3195. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3196. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3197. iteminfo.OthAmt = commonly_treatment_other_amt
  3198. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3199. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3200. }
  3201. if registerCostTotal != 0 {
  3202. iteminfo.MedChrgitm = "13"
  3203. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3204. iteminfo.Amt = registerCostTotal
  3205. iteminfo.ClaaSumfee = register_claa_sunmfee
  3206. iteminfo.ClabAmt = register_clab_amt
  3207. iteminfo.OthAmt = register_other_amt
  3208. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3209. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3210. }
  3211. if otherCostTotal != 0 {
  3212. iteminfo.MedChrgitm = "14"
  3213. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3214. iteminfo.Amt = otherCostTotal
  3215. iteminfo.ClaaSumfee = other_claa_sunmfee
  3216. iteminfo.ClabAmt = other_clab_amt
  3217. iteminfo.OthAmt = other_other_amt
  3218. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3219. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3220. }
  3221. struct4101.IteminfoStruct = iteminfoStructs
  3222. struct4101.Ntly = "中国"
  3223. struct4101.AdmCaty = "A03.06"
  3224. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3225. fmt.Println(result)
  3226. var dat map[string]interface{}
  3227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3228. fmt.Println(dat)
  3229. } else {
  3230. fmt.Println(err)
  3231. }
  3232. userJSONBytes, _ := json.Marshal(dat)
  3233. var res ResultSeventeen
  3234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3235. utils.ErrorLog("解析失败:%v", err)
  3236. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3237. adminUser := c.GetAdminUserInfo()
  3238. errlog := &models.HisOrderError{
  3239. UserOrgId: adminUser.CurrentOrgId,
  3240. Ctime: time.Now().Unix(),
  3241. Mtime: time.Now().Unix(),
  3242. ErrMsg: res.ErrMsg + "解析失败",
  3243. Status: 1,
  3244. PatientId: order_id,
  3245. Stage: 10106,
  3246. }
  3247. service.CreateErrMsgLog(errlog)
  3248. continue
  3249. }
  3250. if res.Infcode != 0 {
  3251. adminUser := c.GetAdminUserInfo()
  3252. errlog := &models.HisOrderError{
  3253. UserOrgId: adminUser.CurrentOrgId,
  3254. Ctime: time.Now().Unix(),
  3255. Mtime: time.Now().Unix(),
  3256. ErrMsg: res.ErrMsg,
  3257. Status: 1,
  3258. PatientId: order_id,
  3259. Stage: 10106,
  3260. }
  3261. service.CreateErrMsgLog(errlog)
  3262. continue
  3263. } else {
  3264. hisFundSettleListResult := &models.HisFundSettleListResult{
  3265. Number: res.Output.SetlListId,
  3266. Status: 1,
  3267. Ctime: time.Now().Unix(),
  3268. Mtime: time.Now().Unix(),
  3269. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3270. IsUpload: 1,
  3271. OrderId: order_id,
  3272. }
  3273. service.CreateUploadRecord(hisFundSettleListResult)
  3274. continue
  3275. }
  3276. }
  3277. }
  3278. func (c *HisApiController) GetOrgInfo() {
  3279. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3280. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3281. }
  3282. func (c *HisApiController) GetHisPatientInfo() {
  3283. medical_insurance_card := c.GetString("medical_insurance_card")
  3284. id_card_type, _ := c.GetInt64("id_card_type")
  3285. id_card := c.GetString("id_card")
  3286. adminInfo := c.GetAdminUserInfo()
  3287. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3288. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3289. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3290. IdCardNo := ""
  3291. if id_card_type == 1 {
  3292. IdCardNo = medical_insurance_card
  3293. } else if id_card_type == 2 {
  3294. IdCardNo = id_card
  3295. }
  3296. if config.IsOpen == 1 {
  3297. 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
  3298. resp, requestErr := http.Get(api)
  3299. if requestErr != nil {
  3300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3301. return
  3302. }
  3303. defer resp.Body.Close()
  3304. body, ioErr := ioutil.ReadAll(resp.Body)
  3305. if ioErr != nil {
  3306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3308. return
  3309. }
  3310. var respJSON map[string]interface{}
  3311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3314. return
  3315. }
  3316. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3317. userJSONBytes, _ := json.Marshal(userJSON)
  3318. var res ResultTwo
  3319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3320. utils.ErrorLog("解析失败:%v", err)
  3321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3322. return
  3323. }
  3324. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3325. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3326. infoStr := string(Iinfos)
  3327. idetinfoStr := string(Idetinfos)
  3328. if res.Infcode == 0 {
  3329. his := models.VMHisPatient{
  3330. Status: 1,
  3331. Ctime: time.Now().Unix(),
  3332. Mtime: time.Now().Unix(),
  3333. PsnNo: res.Output.Baseinfo.PsnNo,
  3334. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3335. Certno: res.Output.Baseinfo.Certno,
  3336. PsnName: res.Output.Baseinfo.PsnName,
  3337. Gend: res.Output.Baseinfo.Gend,
  3338. Naty: res.Output.Baseinfo.Naty,
  3339. Brdy: res.Output.Baseinfo.Brdy,
  3340. Age: res.Output.Baseinfo.Age,
  3341. Iinfo: infoStr,
  3342. Idetinfo: idetinfoStr,
  3343. UserOrgId: adminInfo.CurrentOrgId,
  3344. IsReturn: 1,
  3345. IdCardType: id_card_type,
  3346. }
  3347. c.ServeSuccessJSON(map[string]interface{}{
  3348. "info": his,
  3349. })
  3350. } else {
  3351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3352. return
  3353. }
  3354. }
  3355. }
  3356. //func GetBasBaseInfo() (jsonStr string, err error) {
  3357. //
  3358. // handle := syscall.NewLazyDLL("SSCard.dll")
  3359. // add := handle.NewProc("ReadCardBas")
  3360. // str := make([]byte, 1024)
  3361. // str1 := make([]byte, 1024)
  3362. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3363. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3364. //
  3365. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3366. //
  3367. // fmt.Println("> Add(4,5)的结果为:", ret)
  3368. // handle.Release()
  3369. //
  3370. // return "", nil
  3371. //
  3372. //}
  3373. //func GetQRBaseInfo() (jsonStr string, err error) {
  3374. // handle := syscall.LoadDLL("SSCard.dll")
  3375. // ReadCardBas := handle.FindProc("GetQRBase")
  3376. //
  3377. // str := make([]byte, 256)
  3378. // str1 := make([]byte, 256)
  3379. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3380. //
  3381. // fmt.Println(string(str))
  3382. // fmt.Println(r)
  3383. // return string(str), nil
  3384. //}
  3385. //func CardInit() int {
  3386. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3387. // add := DllTestDef.MustFindProc("Init")
  3388. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3389. // if err != nil {
  3390. // fmt.Println("SSCard的运算结果为:", ret)
  3391. // }
  3392. // result := int(ret)
  3393. // return result
  3394. //}
  3395. //func CardInit() int {
  3396. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3397. // if err != nil {
  3398. // fmt.Println("SSCard的运算结果为:", ret)
  3399. // }
  3400. // fmt.Println(err)
  3401. // result := int(ret)
  3402. // return result
  3403. //}
  3404. func IntPtr(n int) uintptr {
  3405. return uintptr(n)
  3406. }
  3407. func StrPtr(s string) uintptr {
  3408. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3409. }
  3410. type Result2001 struct {
  3411. Cainfo interface{} `json:"cainfo"`
  3412. ErrMsg string `json:"err_msg"`
  3413. InfRefmsgid string `json:"inf_refmsgid"`
  3414. Infcode int64 `json:"infcode"`
  3415. Output struct {
  3416. Trtinfo struct {
  3417. PsnNo string `json:"psn_no"`
  3418. TrtChkType string `json:"trt_chk_type"`
  3419. FundPayType string `json:"fund_pay_type"`
  3420. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3421. Begndate string `json:"begndate"`
  3422. Enddate string `json:"enddate"`
  3423. TrtChkRslt string `json:"trt_chk_rslt"`
  3424. } `json:"trtinfo"`
  3425. } `json:"output"`
  3426. RefmsgTime string `json:"refmsg_time"`
  3427. RespondTime string `json:"respond_time"`
  3428. Signtype interface{} `json:"signtype"`
  3429. WarnMsg interface{} `json:"warn_msg"`
  3430. }
  3431. type Result2001Org10265 struct {
  3432. Cainfo interface{} `json:"cainfo"`
  3433. ErrMsg string `json:"err_msg"`
  3434. InfRefmsgid string `json:"inf_refmsgid"`
  3435. Infcode string `json:"infcode"`
  3436. Output struct {
  3437. Trtinfo struct {
  3438. PsnNo string `json:"psn_no"`
  3439. TrtChkType string `json:"trt_chk_type"`
  3440. FundPayType string `json:"fund_pay_type"`
  3441. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3442. Begndate string `json:"begndate"`
  3443. Enddate string `json:"enddate"`
  3444. TrtChkRslt string `json:"trt_chk_rslt"`
  3445. } `json:"trtinfo"`
  3446. } `json:"output"`
  3447. RefmsgTime string `json:"refmsg_time"`
  3448. RespondTime string `json:"respond_time"`
  3449. Signtype interface{} `json:"signtype"`
  3450. WarnMsg interface{} `json:"warn_msg"`
  3451. }
  3452. type ResultTwo struct {
  3453. ErrMsg string `json:"err_msg"`
  3454. InfRefmsgid string `json:"inf_refmsgid"`
  3455. Infcode int64 `json:"infcode"`
  3456. Output struct {
  3457. Baseinfo struct {
  3458. Age float64 `json:"age"`
  3459. Brdy string `json:"brdy"`
  3460. Certno string `json:"certno"`
  3461. Gend string `json:"gend"`
  3462. Naty string `json:"naty"`
  3463. PsnCertType string `json:"psn_cert_type"`
  3464. PsnName string `json:"psn_name"`
  3465. PsnNo string `json:"psn_no"`
  3466. } `json:"baseinfo"`
  3467. Idetinfo []interface{} `json:"idetinfo"`
  3468. Iinfo []struct {
  3469. Balc float64 `json:"balc"`
  3470. CvlservFlag string `json:"cvlserv_flag"`
  3471. EmpName string `json:"emp_name"`
  3472. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3473. Insutype string `json:"insutype"`
  3474. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3475. PausInsuDate string `json:"paus_insu_date"`
  3476. PsnInsuDate string `json:"psn_insu_date"`
  3477. PsnInsuStas string `json:"psn_insu_stas"`
  3478. PsnType string `json:"psn_type"`
  3479. } `json:"insuinfo"`
  3480. } `json:"output"`
  3481. RefmsgTime string `json:"refmsg_time"`
  3482. RespondTime string `json:"respond_time"`
  3483. Signtype interface{} `json:"signtype"`
  3484. WarnInfo interface{} `json:"warn_info"`
  3485. }
  3486. type ResultTwo10265 struct {
  3487. ErrMsg string `json:"err_msg"`
  3488. InfRefmsgid string `json:"inf_refmsgid"`
  3489. Infcode string `json:"infcode"`
  3490. Output struct {
  3491. Baseinfo struct {
  3492. Age float64 `json:"age"`
  3493. Brdy string `json:"brdy"`
  3494. Certno string `json:"certno"`
  3495. Gend string `json:"gend"`
  3496. Naty string `json:"naty"`
  3497. PsnCertType string `json:"psn_cert_type"`
  3498. PsnName string `json:"psn_name"`
  3499. PsnNo string `json:"psn_no"`
  3500. } `json:"baseinfo"`
  3501. Idetinfo []interface{} `json:"idetinfo"`
  3502. Iinfo []struct {
  3503. Balc float64 `json:"balc"`
  3504. CvlservFlag string `json:"cvlserv_flag"`
  3505. EmpName string `json:"emp_name"`
  3506. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3507. Insutype string `json:"insutype"`
  3508. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3509. PausInsuDate string `json:"paus_insu_date"`
  3510. PsnInsuDate string `json:"psn_insu_date"`
  3511. PsnInsuStas string `json:"psn_insu_stas"`
  3512. PsnType string `json:"psn_type"`
  3513. } `json:"insuinfo"`
  3514. } `json:"output"`
  3515. RefmsgTime string `json:"refmsg_time"`
  3516. RespondTime string `json:"respond_time"`
  3517. Signtype interface{} `json:"signtype"`
  3518. WarnInfo interface{} `json:"warn_info"`
  3519. }
  3520. type ResultThree struct {
  3521. Cainfo interface{} `json:"cainfo"`
  3522. ErrMsg string `json:"err_msg"`
  3523. InfRefmsgid string `json:"inf_refmsgid"`
  3524. Infcode int64 `json:"infcode"`
  3525. Output struct {
  3526. Data struct {
  3527. IptOtpNo string `json:"ipt_otp_no"`
  3528. MdtrtID string `json:"mdtrt_id"`
  3529. PsnNo string `json:"psn_no"`
  3530. } `json:"data"`
  3531. } `json:"output"`
  3532. RefmsgTime string `json:"refmsg_time"`
  3533. RespondTime string `json:"respond_time"`
  3534. Signtype interface{} `json:"signtype"`
  3535. WarnMsg interface{} `json:"warn_msg"`
  3536. }
  3537. type ResultThree10265 struct {
  3538. Cainfo interface{} `json:"cainfo"`
  3539. ErrMsg string `json:"err_msg"`
  3540. InfRefmsgid string `json:"inf_refmsgid"`
  3541. Infcode string `json:"infcode"`
  3542. Output struct {
  3543. Data struct {
  3544. IptOtpNo string `json:"ipt_otp_no"`
  3545. MdtrtID string `json:"mdtrt_id"`
  3546. PsnNo string `json:"psn_no"`
  3547. } `json:"data"`
  3548. } `json:"output"`
  3549. RefmsgTime string `json:"refmsg_time"`
  3550. RespondTime string `json:"respond_time"`
  3551. Signtype interface{} `json:"signtype"`
  3552. WarnMsg interface{} `json:"warn_msg"`
  3553. }
  3554. type ResultFour struct {
  3555. Cainfo string `json:"cainfo"`
  3556. ErrMsg string `json:"err_msg"`
  3557. InfRefmsgid string `json:"inf_refmsgid"`
  3558. Infcode int64 `json:"infcode"`
  3559. Output struct {
  3560. Result []struct {
  3561. BasMednFlag string `json:"bas_medn_flag"`
  3562. ChldMedcFlag string `json:"chld_medc_flag"`
  3563. ChrgitmLv string `json:"chrgitm_lv"`
  3564. Cnt float64 `json:"cnt"`
  3565. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3566. DrtReimFlag string `json:"drt_reim_flag"`
  3567. FeedetlSn string `json:"feedetl_sn"`
  3568. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3569. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3570. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3571. ListSpItemFlag string `json:"list_sp_item_flag"`
  3572. LmtUsedFlag string `json:"lmt_used_flag"`
  3573. MedChrgitmType string `json:"med_chrgitm_type"`
  3574. Memo string `json:"memo"`
  3575. OverlmtAmt float64 `json:"overlmt_amt"`
  3576. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3577. Pric float64 `json:"pric"`
  3578. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3579. SelfpayProp float64 `json:"selfpay_prop"`
  3580. } `json:"result"`
  3581. } `json:"output"`
  3582. RefmsgTime string `json:"refmsg_time"`
  3583. RespondTime string `json:"respond_time"`
  3584. Signtype string `json:"signtype"`
  3585. WarnMsg string `json:"warn_msg"`
  3586. }
  3587. type ResultFour10265 struct {
  3588. Cainfo string `json:"cainfo"`
  3589. ErrMsg string `json:"err_msg"`
  3590. InfRefmsgid string `json:"inf_refmsgid"`
  3591. Infcode string `json:"infcode"`
  3592. Output struct {
  3593. Result []struct {
  3594. BasMednFlag string `json:"bas_medn_flag"`
  3595. ChldMedcFlag string `json:"chld_medc_flag"`
  3596. ChrgitmLv string `json:"chrgitm_lv"`
  3597. Cnt float64 `json:"cnt"`
  3598. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3599. DrtReimFlag string `json:"drt_reim_flag"`
  3600. FeedetlSn string `json:"feedetl_sn"`
  3601. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3602. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3603. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3604. ListSpItemFlag string `json:"list_sp_item_flag"`
  3605. LmtUsedFlag string `json:"lmt_used_flag"`
  3606. MedChrgitmType string `json:"med_chrgitm_type"`
  3607. Memo string `json:"memo"`
  3608. OverlmtAmt float64 `json:"overlmt_amt"`
  3609. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3610. Pric float64 `json:"pric"`
  3611. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3612. SelfpayProp float64 `json:"selfpay_prop"`
  3613. } `json:"result"`
  3614. } `json:"output"`
  3615. RefmsgTime string `json:"refmsg_time"`
  3616. RespondTime string `json:"respond_time"`
  3617. Signtype string `json:"signtype"`
  3618. WarnMsg string `json:"warn_msg"`
  3619. }
  3620. type ResultFive struct {
  3621. Balc float64 `json:"balc"`
  3622. CvlservFlag string `json:"cvlserv_flag"`
  3623. EmpName string `json:"emp_name"`
  3624. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3625. Insutype string `json:"insutype"`
  3626. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3627. PausInsuDate string `json:"paus_insu_date"`
  3628. PsnInsuDate string `json:"psn_insu_date"`
  3629. PsnInsuStas string `json:"psn_insu_stas"`
  3630. PsnType string `json:"psn_type"`
  3631. }
  3632. type ResultSix struct {
  3633. Cainfo interface{} `json:"cainfo"`
  3634. ErrMsg string `json:"err_msg"`
  3635. InfRefmsgid string `json:"inf_refmsgid"`
  3636. Infcode int64 `json:"infcode"`
  3637. Output struct {
  3638. } `json:"output"`
  3639. RefmsgTime string `json:"refmsg_time"`
  3640. RespondTime string `json:"respond_time"`
  3641. Signtype interface{} `json:"signtype"`
  3642. WarnMsg interface{} `json:"warn_msg"`
  3643. }
  3644. type ResultSix10265 struct {
  3645. Cainfo interface{} `json:"cainfo"`
  3646. ErrMsg string `json:"err_msg"`
  3647. InfRefmsgid string `json:"inf_refmsgid"`
  3648. Infcode string `json:"infcode"`
  3649. Output struct {
  3650. } `json:"output"`
  3651. RefmsgTime string `json:"refmsg_time"`
  3652. RespondTime string `json:"respond_time"`
  3653. Signtype interface{} `json:"signtype"`
  3654. WarnMsg interface{} `json:"warn_msg"`
  3655. }
  3656. type ResultSeven struct {
  3657. Cainfo string `json:"cainfo"`
  3658. ErrMsg string `json:"err_msg"`
  3659. InfRefmsgid string `json:"inf_refmsgid"`
  3660. Infcode int64 `json:"infcode"`
  3661. Output struct {
  3662. Setldetail []interface{} `json:"setldetail"`
  3663. Setlinfo struct {
  3664. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3665. AcctPay float64 `json:"acct_pay"`
  3666. ActPayDedc float64 `json:"act_pay_dedc"`
  3667. Age float64 `json:"age"`
  3668. Balc float64 `json:"balc"`
  3669. Brdy string `json:"brdy"`
  3670. Certno string `json:"certno"`
  3671. ClrOptins string `json:"clr_optins"`
  3672. ClrType string `json:"clr_type"`
  3673. ClrWay string `json:"clr_way"`
  3674. CvlservFlag string `json:"cvlserv_flag"`
  3675. CvlservPay float64 `json:"cvlserv_pay"`
  3676. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3677. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3678. Gend string `json:"gend"`
  3679. HifesPay float64 `json:"hifes_pay"`
  3680. HifmiPay float64 `json:"hifmi_pay"`
  3681. HifpPay float64 `json:"hifp_pay"`
  3682. HospPartAmt float64 `json:"hosp_part_amt"`
  3683. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3684. Insutype string `json:"insutype"`
  3685. MafPay float64 `json:"maf_pay"`
  3686. MdtrtCertType string `json:"mdtrt_cert_type"`
  3687. HifobPay float64 `json:"hifob_pay"`
  3688. MdtrtID string `json:"mdtrt_id"`
  3689. MedType string `json:"med_type"`
  3690. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3691. MedinsSetlID string `json:"medins_setl_id"`
  3692. Naty string `json:"naty"`
  3693. OthPay float64 `json:"oth_pay"`
  3694. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3695. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3696. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3697. PsnCashPay float64 `json:"psn_cash_pay"`
  3698. PsnCertType string `json:"psn_cert_type"`
  3699. PsnName string `json:"psn_name"`
  3700. PsnNo string `json:"psn_no"`
  3701. PsnPartAmt float64 `json:"psn_part_amt"`
  3702. PsnType string `json:"psn_type"`
  3703. SetlID string `json:"setl_id"`
  3704. SetlTime string `json:"setl_time"`
  3705. } `json:"setlinfo"`
  3706. } `json:"output"`
  3707. RefmsgTime string `json:"refmsg_time"`
  3708. RespondTime string `json:"respond_time"`
  3709. Signtype interface{} `json:"signtype"`
  3710. WarnMsg interface{} `json:"warn_msg"`
  3711. }
  3712. type ResultSeven10265 struct {
  3713. Cainfo string `json:"cainfo"`
  3714. ErrMsg string `json:"err_msg"`
  3715. InfRefmsgid string `json:"inf_refmsgid"`
  3716. Infcode string `json:"infcode"`
  3717. Output struct {
  3718. Setldetail []interface{} `json:"setldetail"`
  3719. Setlinfo struct {
  3720. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3721. AcctPay float64 `json:"acct_pay"`
  3722. ActPayDedc float64 `json:"act_pay_dedc"`
  3723. Age float64 `json:"age"`
  3724. Balc float64 `json:"balc"`
  3725. Brdy string `json:"brdy"`
  3726. Certno string `json:"certno"`
  3727. ClrOptins string `json:"clr_optins"`
  3728. ClrType string `json:"clr_type"`
  3729. ClrWay string `json:"clr_way"`
  3730. CvlservFlag string `json:"cvlserv_flag"`
  3731. CvlservPay float64 `json:"cvlserv_pay"`
  3732. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3733. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3734. Gend string `json:"gend"`
  3735. HifesPay float64 `json:"hifes_pay"`
  3736. HifmiPay float64 `json:"hifmi_pay"`
  3737. HifpPay float64 `json:"hifp_pay"`
  3738. HospPartAmt float64 `json:"hosp_part_amt"`
  3739. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3740. Insutype string `json:"insutype"`
  3741. MafPay float64 `json:"maf_pay"`
  3742. MdtrtCertType string `json:"mdtrt_cert_type"`
  3743. HifobPay float64 `json:"hifob_pay"`
  3744. MdtrtID string `json:"mdtrt_id"`
  3745. MedType string `json:"med_type"`
  3746. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3747. MedinsSetlID string `json:"medins_setl_id"`
  3748. Naty string `json:"naty"`
  3749. OthPay float64 `json:"oth_pay"`
  3750. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3751. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3752. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3753. PsnCashPay float64 `json:"psn_cash_pay"`
  3754. PsnCertType string `json:"psn_cert_type"`
  3755. PsnName string `json:"psn_name"`
  3756. PsnNo string `json:"psn_no"`
  3757. PsnPartAmt float64 `json:"psn_part_amt"`
  3758. PsnType string `json:"psn_type"`
  3759. SetlID string `json:"setl_id"`
  3760. SetlTime string `json:"setl_time"`
  3761. } `json:"setlinfo"`
  3762. } `json:"output"`
  3763. RefmsgTime string `json:"refmsg_time"`
  3764. RespondTime string `json:"respond_time"`
  3765. Signtype interface{} `json:"signtype"`
  3766. WarnMsg interface{} `json:"warn_msg"`
  3767. }
  3768. type ResultEight struct {
  3769. Cainfo string `json:"cainfo"`
  3770. ErrMsg string `json:"err_msg"`
  3771. InfRefmsgid string `json:"inf_refmsgid"`
  3772. Infcode int64 `json:"infcode"`
  3773. Output struct {
  3774. Stmtinfo struct {
  3775. SetlOptins string `json:"setl_optins"`
  3776. StmtRslt string `json:"stmt_rslt"`
  3777. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3778. } `json:"stmtinfo"`
  3779. } `json:"output"`
  3780. RefmsgTime string `json:"refmsg_time"`
  3781. RespondTime string `json:"respond_time"`
  3782. Signtype interface{} `json:"signtype"`
  3783. WarnMsg interface{} `json:"warn_msg"`
  3784. }
  3785. type ResultEightFor10188 struct {
  3786. Cainfo string `json:"cainfo"`
  3787. ErrMsg string `json:"err_msg"`
  3788. InfRefmsgid string `json:"inf_refmsgid"`
  3789. Infcode string `json:"infcode"`
  3790. Output struct {
  3791. Stmtinfo struct {
  3792. SetlOptins string `json:"setl_optins"`
  3793. StmtRslt string `json:"stmt_rslt"`
  3794. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3795. } `json:"stmtinfo"`
  3796. } `json:"output"`
  3797. RefmsgTime string `json:"refmsg_time"`
  3798. RespondTime string `json:"respond_time"`
  3799. Signtype interface{} `json:"signtype"`
  3800. WarnMsg interface{} `json:"warn_msg"`
  3801. }
  3802. type ResultNine struct {
  3803. Cainfo string `json:"cainfo"`
  3804. ErrMsg string `json:"err_msg"`
  3805. InfRefmsgid string `json:"inf_refmsgid"`
  3806. Infcode int64 `json:"infcode"`
  3807. Output struct {
  3808. FileQuryNo string `json:"file_qury_no"`
  3809. } `json:"output"`
  3810. RefmsgTime string `json:"refmsg_time"`
  3811. RespondTime string `json:"respond_time"`
  3812. Signtype interface{} `json:"signtype"`
  3813. WarnMsg interface{} `json:"warn_msg"`
  3814. }
  3815. type ResultTen struct {
  3816. Cainfo string `json:"cainfo"`
  3817. ErrMsg string `json:"err_msg"`
  3818. InfRefmsgid string `json:"inf_refmsgid"`
  3819. Infcode int64 `json:"infcode"`
  3820. Output struct {
  3821. DldEndtime string `json:"dld_endtime"`
  3822. FileQuryNo string `json:"file_qury_no"`
  3823. Filename string `json:"filename"`
  3824. } `json:"output"`
  3825. RefmsgTime string `json:"refmsg_time"`
  3826. RespondTime string `json:"respond_time"`
  3827. Signtype interface{} `json:"signtype"`
  3828. WarnMsg interface{} `json:"warn_msg"`
  3829. }
  3830. //type Autogenerated struct {
  3831. // Output struct {
  3832. // Setlinfo struct {
  3833. // SetlTime string `json:"setl_time"`
  3834. // CvlservPay float64 `json:"cvlserv_pay"`
  3835. // Year string `json:"year"`
  3836. // MedType string `json:"med_type"`
  3837. // PsnPay float64 `json:"psn_pay"`
  3838. // OpterID string `json:"opter_id"`
  3839. // Begndate string `json:"begndate"`
  3840. // FlxempeFlag string `json:"flxempe_flag"`
  3841. // HifmiPay float64 `json:"hifmi_pay"`
  3842. // PsnNo string `json:"psn_no"`
  3843. // ActPayDedc float64 `json:"act_pay_dedc"`
  3844. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3845. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3846. // ClrWay string `json:"clr_way"`
  3847. // OthPay float64 `json:"oth_pay"`
  3848. // Gend string `json:"gend"`
  3849. // MdtrtID string `json:"mdtrt_id"`
  3850. // AcctPay float64 `json:"acct_pay"`
  3851. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3852. // Insutype string `json:"insutype"`
  3853. // Invono interface{} `json:"invono"`
  3854. // Enddate string `json:"enddate"`
  3855. // CashPayamt float64 `json:"cash_payamt"`
  3856. // PsnType string `json:"psn_type"`
  3857. // FixmedinsName string `json:"fixmedins_name"`
  3858. // HifpPay float64 `json:"hifp_pay"`
  3859. // NewFlag interface{} `json:"new_flag"`
  3860. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3861. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3862. // PayLoc string `json:"pay_loc"`
  3863. // ClrType string `json:"clr_type"`
  3864. // RefdSetlFlag string `json:"refd_setl_flag"`
  3865. // CvlservFlag string `json:"cvlserv_flag"`
  3866. // EmpName string `json:"emp_name"`
  3867. // Brdy string `json:"brdy"`
  3868. // Naty string `json:"naty"`
  3869. // Certno string `json:"certno"`
  3870. // DiseCode string `json:"dise_code"`
  3871. // FixmedinsCode string `json:"fixmedins_code"`
  3872. // DedcHospLv string `json:"dedc_hosp_lv"`
  3873. // OpterName string `json:"opter_name"`
  3874. // Balc float64 `json:"balc"`
  3875. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3876. // PsnCertType string `json:"psn_cert_type"`
  3877. // HifobPay float64 `json:"hifob_pay"`
  3878. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3879. // HifesPay float64 `json:"hifes_pay"`
  3880. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3881. // OptTime string `json:"opt_time"`
  3882. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3883. // SetlID string `json:"setl_id"`
  3884. // MafPay float64 `json:"maf_pay"`
  3885. // PsnName string `json:"psn_name"`
  3886. // InsuOptins interface{} `json:"insu_optins"`
  3887. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3888. // ClrOptins string `json:"clr_optins"`
  3889. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3890. // DiseName string `json:"dise_name"`
  3891. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3892. // Age float64 `json:"age"`
  3893. // DtrtCertType string `json:"dtrt_cert_type"`
  3894. // HospLv string `json:"hosp_lv"`
  3895. // } `json:"setlinfo"`
  3896. // Setldetail []struct {
  3897. // FundPayType string `json:"fund_pay_type"`
  3898. // FundPayamt float64 `json:"fund_payamt"`
  3899. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3900. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3901. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3902. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3903. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3904. // } `json:"setldetail"`
  3905. // } `json:"output"`
  3906. // Infcode int `json:"infcode"`
  3907. // WarnMsg interface{} `json:"warn_msg"`
  3908. // Cainfo interface{} `json:"cainfo"`
  3909. // ErrMsg interface{} `json:"err_msg"`
  3910. // RefmsgTime string `json:"refmsg_time"`
  3911. // Signtype interface{} `json:"signtype"`
  3912. // RespondTime string `json:"respond_time"`
  3913. // InfRefmsgid string `json:"inf_refmsgid"`
  3914. //}
  3915. type ResultEleven struct {
  3916. Cainfo string `json:"cainfo"`
  3917. ErrMsg string `json:"err_msg"`
  3918. InfRefmsgid string `json:"inf_refmsgid"`
  3919. Infcode int64 `json:"infcode"`
  3920. Output struct {
  3921. Setlinfo struct {
  3922. SetlTime string `json:"setl_time"`
  3923. CvlservPay float64 `json:"cvlserv_pay"`
  3924. Year string `json:"year"`
  3925. MedType string `json:"med_type"`
  3926. PsnPay float64 `json:"psn_pay"`
  3927. OpterID string `json:"opter_id"`
  3928. Begndate string `json:"begndate"`
  3929. FlxempeFlag string `json:"flxempe_flag"`
  3930. HifmiPay float64 `json:"hifmi_pay"`
  3931. PsnNo string `json:"psn_no"`
  3932. ActPayDedc float64 `json:"act_pay_dedc"`
  3933. MedinsSetlID interface{} `json:"medins_setl_id"`
  3934. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3935. ClrWay string `json:"clr_way"`
  3936. OthPay float64 `json:"oth_pay"`
  3937. Gend string `json:"gend"`
  3938. MdtrtID string `json:"mdtrt_id"`
  3939. AcctPay float64 `json:"acct_pay"`
  3940. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3941. Insutype string `json:"insutype"`
  3942. Invono interface{} `json:"invono"`
  3943. Enddate string `json:"enddate"`
  3944. CashPayamt float64 `json:"cash_payamt"`
  3945. PsnType string `json:"psn_type"`
  3946. FixmedinsName string `json:"fixmedins_name"`
  3947. HifpPay float64 `json:"hifp_pay"`
  3948. NewFlag interface{} `json:"new_flag"`
  3949. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3950. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3951. PayLoc string `json:"pay_loc"`
  3952. ClrType string `json:"clr_type"`
  3953. RefdSetlFlag string `json:"refd_setl_flag"`
  3954. CvlservFlag string `json:"cvlserv_flag"`
  3955. EmpName string `json:"emp_name"`
  3956. Brdy string `json:"brdy"`
  3957. Naty string `json:"naty"`
  3958. Certno string `json:"certno"`
  3959. DiseCode string `json:"dise_code"`
  3960. FixmedinsCode string `json:"fixmedins_code"`
  3961. DedcHospLv string `json:"dedc_hosp_lv"`
  3962. OpterName string `json:"opter_name"`
  3963. Balc float64 `json:"balc"`
  3964. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3965. PsnCertType string `json:"psn_cert_type"`
  3966. HifobPay float64 `json:"hifob_pay"`
  3967. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3968. HifesPay float64 `json:"hifes_pay"`
  3969. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3970. OptTime string `json:"opt_time"`
  3971. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3972. SetlID string `json:"setl_id"`
  3973. MafPay float64 `json:"maf_pay"`
  3974. PsnName string `json:"psn_name"`
  3975. InsuOptins interface{} `json:"insu_optins"`
  3976. PrefFundPay interface{} `json:"pref_fund_pay"`
  3977. ClrOptins string `json:"clr_optins"`
  3978. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3979. DiseName string `json:"dise_name"`
  3980. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3981. Age float64 `json:"age"`
  3982. DtrtCertType string `json:"dtrt_cert_type"`
  3983. HospLv string `json:"hosp_lv"`
  3984. } `json:"setlinfo"`
  3985. } `json:"output"`
  3986. RefmsgTime string `json:"refmsg_time"`
  3987. RespondTime string `json:"respond_time"`
  3988. Signtype interface{} `json:"signtype"`
  3989. WarnMsg interface{} `json:"warn_msg"`
  3990. }
  3991. type ResultEleven10265 struct {
  3992. Cainfo string `json:"cainfo"`
  3993. ErrMsg string `json:"err_msg"`
  3994. InfRefmsgid string `json:"inf_refmsgid"`
  3995. Infcode string `json:"infcode"`
  3996. Output struct {
  3997. Setlinfo struct {
  3998. SetlTime string `json:"setl_time"`
  3999. CvlservPay float64 `json:"cvlserv_pay"`
  4000. Year string `json:"year"`
  4001. MedType string `json:"med_type"`
  4002. PsnPay float64 `json:"psn_pay"`
  4003. OpterID string `json:"opter_id"`
  4004. Begndate string `json:"begndate"`
  4005. FlxempeFlag string `json:"flxempe_flag"`
  4006. HifmiPay float64 `json:"hifmi_pay"`
  4007. PsnNo string `json:"psn_no"`
  4008. ActPayDedc float64 `json:"act_pay_dedc"`
  4009. MedinsSetlID interface{} `json:"medins_setl_id"`
  4010. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4011. ClrWay string `json:"clr_way"`
  4012. OthPay float64 `json:"oth_pay"`
  4013. Gend string `json:"gend"`
  4014. MdtrtID string `json:"mdtrt_id"`
  4015. AcctPay float64 `json:"acct_pay"`
  4016. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4017. Insutype string `json:"insutype"`
  4018. Invono interface{} `json:"invono"`
  4019. Enddate string `json:"enddate"`
  4020. CashPayamt float64 `json:"cash_payamt"`
  4021. PsnType string `json:"psn_type"`
  4022. FixmedinsName string `json:"fixmedins_name"`
  4023. HifpPay float64 `json:"hifp_pay"`
  4024. NewFlag interface{} `json:"new_flag"`
  4025. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4026. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4027. PayLoc string `json:"pay_loc"`
  4028. ClrType string `json:"clr_type"`
  4029. RefdSetlFlag string `json:"refd_setl_flag"`
  4030. CvlservFlag string `json:"cvlserv_flag"`
  4031. EmpName string `json:"emp_name"`
  4032. Brdy string `json:"brdy"`
  4033. Naty string `json:"naty"`
  4034. Certno string `json:"certno"`
  4035. DiseCode string `json:"dise_code"`
  4036. FixmedinsCode string `json:"fixmedins_code"`
  4037. DedcHospLv string `json:"dedc_hosp_lv"`
  4038. OpterName string `json:"opter_name"`
  4039. Balc float64 `json:"balc"`
  4040. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4041. PsnCertType string `json:"psn_cert_type"`
  4042. HifobPay float64 `json:"hifob_pay"`
  4043. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4044. HifesPay float64 `json:"hifes_pay"`
  4045. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4046. OptTime string `json:"opt_time"`
  4047. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4048. SetlID string `json:"setl_id"`
  4049. MafPay float64 `json:"maf_pay"`
  4050. PsnName string `json:"psn_name"`
  4051. InsuOptins interface{} `json:"insu_optins"`
  4052. PrefFundPay interface{} `json:"pref_fund_pay"`
  4053. ClrOptins string `json:"clr_optins"`
  4054. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4055. DiseName string `json:"dise_name"`
  4056. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4057. Age float64 `json:"age"`
  4058. DtrtCertType string `json:"dtrt_cert_type"`
  4059. HospLv string `json:"hosp_lv"`
  4060. } `json:"setlinfo"`
  4061. } `json:"output"`
  4062. RefmsgTime string `json:"refmsg_time"`
  4063. RespondTime string `json:"respond_time"`
  4064. Signtype interface{} `json:"signtype"`
  4065. WarnMsg interface{} `json:"warn_msg"`
  4066. }
  4067. type ResultTwelve struct {
  4068. Cainfo string `json:"cainfo"`
  4069. ErrMsg string `json:"err_msg"`
  4070. InfRefmsgid string `json:"inf_refmsgid"`
  4071. Infcode int64 `json:"infcode"`
  4072. Output struct {
  4073. MdtrtId string `json:"mdtrt_id"`
  4074. ChrgBchno string `json:"chrg_bchno"`
  4075. PsnNo string `json:"psn_no"`
  4076. } `json:"output"`
  4077. RefmsgTime string `json:"refmsg_time"`
  4078. RespondTime string `json:"respond_time"`
  4079. Signtype interface{} `json:"signtype"`
  4080. WarnMsg interface{} `json:"warn_msg"`
  4081. }
  4082. type ResultThirteen struct {
  4083. ErrMsg string `json:"err_msg"`
  4084. InfRefmsgid string `json:"inf_refmsgid"`
  4085. Infcode int64 `json:"infcode"`
  4086. Output struct {
  4087. Result struct {
  4088. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4089. } `json:"result"`
  4090. } `json:"output"`
  4091. RefmsgTime string `json:"refmsg_time"`
  4092. RespondTime string `json:"respond_time"`
  4093. Signtype interface{} `json:"signtype"`
  4094. WarnInfo interface{} `json:"warn_info"`
  4095. }
  4096. type ResultThirteen10265 struct {
  4097. ErrMsg string `json:"err_msg"`
  4098. InfRefmsgid string `json:"inf_refmsgid"`
  4099. Infcode string `json:"infcode"`
  4100. Output struct {
  4101. Result struct {
  4102. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4103. } `json:"result"`
  4104. } `json:"output"`
  4105. RefmsgTime string `json:"refmsg_time"`
  4106. RespondTime string `json:"respond_time"`
  4107. Signtype interface{} `json:"signtype"`
  4108. WarnInfo interface{} `json:"warn_info"`
  4109. }
  4110. type ResultFourteen struct {
  4111. ErrMsg string `json:"err_msg"`
  4112. InfRefmsgid string `json:"inf_refmsgid"`
  4113. Infcode int64 `json:"infcode"`
  4114. Output struct {
  4115. } `json:"output"`
  4116. RefmsgTime string `json:"refmsg_time"`
  4117. RespondTime string `json:"respond_time"`
  4118. Signtype interface{} `json:"signtype"`
  4119. WarnInfo interface{} `json:"warn_info"`
  4120. }
  4121. type ResultFourteen10265 struct {
  4122. ErrMsg string `json:"err_msg"`
  4123. InfRefmsgid string `json:"inf_refmsgid"`
  4124. Infcode string `json:"infcode"`
  4125. Output struct {
  4126. } `json:"output"`
  4127. RefmsgTime string `json:"refmsg_time"`
  4128. RespondTime string `json:"respond_time"`
  4129. Signtype interface{} `json:"signtype"`
  4130. WarnInfo interface{} `json:"warn_info"`
  4131. }
  4132. type ResultSixteen struct {
  4133. Cainfo string `json:"cainfo"`
  4134. ErrMsg string `json:"err_msg"`
  4135. InfRefmsgid string `json:"inf_refmsgid"`
  4136. Infcode int64 `json:"infcode"`
  4137. Output struct {
  4138. Setldetail []interface{} `json:"setldetail"`
  4139. Setlinfo struct {
  4140. MdtrtID string `json:"mdtrt_id"`
  4141. SetlID string `json:"setl_id"`
  4142. ClrOptins string `json:"clr_optins"`
  4143. SetlTime string `json:"setl_time"`
  4144. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4145. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4146. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4147. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4148. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4149. ActPayDedc float64 `json:"act_pay_dedc"`
  4150. HifpPay float64 `json:"hifp_pay"`
  4151. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4152. Lfpay float64 `json:"selfpay"`
  4153. CvlservPay float64 `json:"cvlserv_pay"`
  4154. HifesPay float64 `json:"hifes_pay"`
  4155. HifmiPay float64 `json:"hifmi_pay"`
  4156. HifobPay float64 `json:"hifob_pay"`
  4157. MafPay float64 `json:"maf_pay"`
  4158. OthPay float64 `json:"oth_pay"`
  4159. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4160. PsnPartAmt float64 `json:"psn_part_amt"`
  4161. AcctPay float64 `json:"acct_pay"`
  4162. Balc float64 `json:"balc"`
  4163. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4164. HospPartAmt float64 `json:"hosp_part_amt"`
  4165. MedinsSetlID string `json:"medins_setl_id"`
  4166. PdnCashPay string `json:"pdn_cash_pay"`
  4167. } `json:"setlinfo"`
  4168. } `json:"output"`
  4169. RefmsgTime string `json:"refmsg_time"`
  4170. RespondTime string `json:"respond_time"`
  4171. Signtype interface{} `json:"signtype"`
  4172. WarnMsg interface{} `json:"warn_msg"`
  4173. }
  4174. type ResultSixteen10265 struct {
  4175. Cainfo string `json:"cainfo"`
  4176. ErrMsg string `json:"err_msg"`
  4177. InfRefmsgid string `json:"inf_refmsgid"`
  4178. Infcode string `json:"infcode"`
  4179. Output struct {
  4180. Setldetail []interface{} `json:"setldetail"`
  4181. Setlinfo struct {
  4182. MdtrtID string `json:"mdtrt_id"`
  4183. SetlID string `json:"setl_id"`
  4184. ClrOptins string `json:"clr_optins"`
  4185. SetlTime string `json:"setl_time"`
  4186. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4187. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4188. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4189. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4190. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4191. ActPayDedc float64 `json:"act_pay_dedc"`
  4192. HifpPay float64 `json:"hifp_pay"`
  4193. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4194. Lfpay float64 `json:"selfpay"`
  4195. CvlservPay float64 `json:"cvlserv_pay"`
  4196. HifesPay float64 `json:"hifes_pay"`
  4197. HifmiPay float64 `json:"hifmi_pay"`
  4198. HifobPay float64 `json:"hifob_pay"`
  4199. MafPay float64 `json:"maf_pay"`
  4200. OthPay float64 `json:"oth_pay"`
  4201. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4202. PsnPartAmt float64 `json:"psn_part_amt"`
  4203. AcctPay float64 `json:"acct_pay"`
  4204. Balc float64 `json:"balc"`
  4205. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4206. HospPartAmt float64 `json:"hosp_part_amt"`
  4207. MedinsSetlID string `json:"medins_setl_id"`
  4208. PdnCashPay string `json:"pdn_cash_pay"`
  4209. } `json:"setlinfo"`
  4210. } `json:"output"`
  4211. RefmsgTime string `json:"refmsg_time"`
  4212. RespondTime string `json:"respond_time"`
  4213. Signtype interface{} `json:"signtype"`
  4214. WarnMsg interface{} `json:"warn_msg"`
  4215. }
  4216. type ResultSeventeen struct {
  4217. ErrMsg string `json:"err_msg"`
  4218. InfRefmsgid string `json:"inf_refmsgid"`
  4219. Infcode int64 `json:"infcode"`
  4220. Output struct {
  4221. SetlListId string `json:"setl_list_id"`
  4222. } `json:"output"`
  4223. RefmsgTime string `json:"refmsg_time"`
  4224. RespondTime string `json:"respond_time"`
  4225. Signtype string `json:"signtype"`
  4226. WarnInfo string `json:"warn_info"`
  4227. }
  4228. type ResultSeventeenOther struct {
  4229. ErrMsg string `json:"err_msg"`
  4230. InfRefmsgid string `json:"inf_refmsgid"`
  4231. Infcode string `json:"infcode"`
  4232. Output struct {
  4233. SetlListId string `json:"setl_list_id"`
  4234. } `json:"output"`
  4235. RefmsgTime string `json:"refmsg_time"`
  4236. RespondTime string `json:"respond_time"`
  4237. Signtype string `json:"signtype"`
  4238. WarnInfo string `json:"warn_info"`
  4239. }
  4240. type Result90991 struct {
  4241. ErrMsg string `json:"err_msg"`
  4242. InfRefmsgid string `json:"inf_refmsgid"`
  4243. Infcode int64 `json:"infcode"`
  4244. Output struct {
  4245. Result struct {
  4246. PsnNo string `json:"psn_no"`
  4247. CardStat string `json:"card_stat"`
  4248. Certno string `json:"certno"`
  4249. PsnName string `json:"psn_name"`
  4250. CheckStat string `json:"check_stat"`
  4251. SscnoCheckStat string `json:"sscno_check_stat"`
  4252. } `json:"result"`
  4253. } `json:"output"`
  4254. RefmsgTime string `json:"refmsg_time"`
  4255. RespondTime string `json:"respond_time"`
  4256. Signtype interface{} `json:"signtype"`
  4257. WarnInfo interface{} `json:"warn_info"`
  4258. }
  4259. type Result90100 struct {
  4260. ErrMsg string `json:"err_msg"`
  4261. InfRefmsgid string `json:"inf_refmsgid"`
  4262. Infcode int64 `json:"infcode"`
  4263. Output struct {
  4264. PoolareaNo string `json:"poolarea_no"`
  4265. PoolareaNoName string `json:"poolarea_no_name"`
  4266. Insutype string `json:"insutype"`
  4267. InsutypeName string `json:"insutype_name"`
  4268. ClctType string `json:"clct_type"`
  4269. ClctTypeName string `json:"clct_type_name"`
  4270. ClctFlag string `json:"clct_flag"`
  4271. ClctFlagName string `json:"clct_flag_name"`
  4272. AccrymBegn string `json:"accrym_begn"`
  4273. AccrymEnd string `json:"accrym_end"`
  4274. ClctTime string `json:"clct_time"`
  4275. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4276. } `json:"output"`
  4277. RefmsgTime string `json:"refmsg_time"`
  4278. RespondTime string `json:"respond_time"`
  4279. Signtype interface{} `json:"signtype"`
  4280. WarnInfo interface{} `json:"warn_info"`
  4281. }
  4282. type Custom struct {
  4283. DetItemFeeSumamt string
  4284. Cut string
  4285. FeedetlSn string
  4286. Price string
  4287. MedListCodg string
  4288. Type int64
  4289. AdviceId int64
  4290. ProjectId int64
  4291. ItemId int64
  4292. }
  4293. type Result5301 struct {
  4294. ErrMsg string `json:"err_msg"`
  4295. InfRefmsgid string `json:"inf_refmsgid"`
  4296. Infcode int64 `json:"infcode"`
  4297. Output struct {
  4298. Result []struct {
  4299. OpspDiseCode string `json:"opsp_dise_code"`
  4300. OpspDiseName string `json:"opsp_dise_name"`
  4301. Begndate string `json:"begndate"`
  4302. Enddate string `json:"enddate"`
  4303. } `json:"feedetail"`
  4304. } `json:"output"`
  4305. RefmsgTime string `json:"refmsg_time"`
  4306. RespondTime string `json:"respond_time"`
  4307. Signtype interface{} `json:"signtype"`
  4308. WarnInfo interface{} `json:"warn_info"`
  4309. }
  4310. type Result5301For10265 struct {
  4311. ErrMsg string `json:"err_msg"`
  4312. InfRefmsgid string `json:"inf_refmsgid"`
  4313. Infcode string `json:"infcode"`
  4314. Output struct {
  4315. Result []struct {
  4316. OpspDiseCode string `json:"opsp_dise_code"`
  4317. OpspDiseName string `json:"opsp_dise_name"`
  4318. Begndate string `json:"begndate"`
  4319. Enddate string `json:"enddate"`
  4320. } `json:"feedetail"`
  4321. } `json:"output"`
  4322. RefmsgTime string `json:"refmsg_time"`
  4323. RespondTime string `json:"respond_time"`
  4324. Signtype interface{} `json:"signtype"`
  4325. WarnInfo interface{} `json:"warn_info"`
  4326. }
  4327. //获取个人信息----挂号-----上传就诊信息
  4328. func (c *HisApiController) GetRegisterInfo() {
  4329. id, _ := c.GetInt64("id")
  4330. record_time := c.GetString("record_time")
  4331. settlementValue, _ := c.GetInt64("settlement_value")
  4332. medical_insurance_card := c.GetString("medical_insurance_card")
  4333. name := c.GetString("name")
  4334. id_card_type, _ := c.GetInt64("id_card_type")
  4335. certificates, _ := c.GetInt64("certificates")
  4336. medical_care, _ := c.GetInt64("medical_care")
  4337. birthday := c.GetString("birthday")
  4338. id_card := c.GetString("id_card")
  4339. register_type, _ := c.GetInt64("register")
  4340. doctor, _ := c.GetInt64("doctor")
  4341. department, _ := c.GetInt64("department")
  4342. gender, _ := c.GetInt64("sex")
  4343. registration_fee, _ := c.GetFloat("registration_fee")
  4344. medical_expenses, _ := c.GetFloat("medical_expenses")
  4345. social_type, _ := c.GetInt64("social_type")
  4346. med_type := c.GetString("social_type")
  4347. admin_user_id, _ := c.GetInt64("admin_user_id")
  4348. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4349. timeLayout := "2006-01-02"
  4350. loc, _ := time.LoadLocation("Local")
  4351. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4352. birthUnix := birthdays.Unix()
  4353. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4354. if err != nil {
  4355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4356. return
  4357. }
  4358. recordDateTime := theTime.Unix()
  4359. adminInfo := c.GetAdminUserInfo()
  4360. var patient service.Patients
  4361. if id == 0 {
  4362. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4363. } else {
  4364. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4365. }
  4366. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4367. if patientPrescription.ID == 0 {
  4368. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4369. }
  4370. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4371. if patient.ID == 0 {
  4372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4373. return
  4374. }
  4375. if len(patient.IdCardNo) == 0 {
  4376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4377. return
  4378. }
  4379. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4380. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4381. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4382. //就诊结算未完成,不能进行二次挂号
  4383. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4384. if len(his) >= 1 {
  4385. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4386. if len(his) >= 1 && order.ID == 0 {
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4388. return
  4389. }
  4390. }
  4391. //var register_log string
  4392. if config.IsOpen == 1 {
  4393. var res ResultTwo
  4394. var res10265 ResultTwo10265
  4395. var PsnNo string
  4396. var PsnCertType string
  4397. var Certno string
  4398. var PsnName string
  4399. var Gend string
  4400. var Naty string
  4401. var Brdy string
  4402. var Age float64
  4403. var infoStr string
  4404. var idetinfoStr string
  4405. var infocode int64
  4406. var verify_number string
  4407. fmt.Println(verify_number)
  4408. if miConfig.MdtrtareaAdmvs == "421300" {
  4409. psn_info, _ := service.GetPsnByPatientId(id)
  4410. PsnNo = psn_info.PsnNo
  4411. PsnCertType = psn_info.PsnCertType
  4412. Certno = psn_info.Certno
  4413. PsnName = psn_info.PsnName
  4414. Gend = psn_info.Gend
  4415. Naty = psn_info.Naty
  4416. Brdy = psn_info.Brdy
  4417. Age = psn_info.Age
  4418. infoStr = psn_info.Insuinfo
  4419. idetinfoStr = psn_info.Idetinfo
  4420. infocode = 0
  4421. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4422. psn_info, _ := service.GetPsnByPatientId(id)
  4423. PsnNo = psn_info.PsnNo
  4424. PsnCertType = psn_info.PsnCertType
  4425. Certno = psn_info.Certno
  4426. PsnName = psn_info.PsnName
  4427. Gend = psn_info.Gend
  4428. Naty = psn_info.Naty
  4429. Brdy = psn_info.Brdy
  4430. Age = psn_info.Age
  4431. infoStr = psn_info.Insuinfo
  4432. idetinfoStr = psn_info.Idetinfo
  4433. infocode = 0
  4434. verify_number = psn_info.VerifyNumber
  4435. } else {
  4436. var result string
  4437. var requestLog string
  4438. if miConfig.UserOrgId == 10138 {
  4439. 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)
  4440. } else {
  4441. 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)
  4442. }
  4443. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4444. if miConfig.Code == "H15049901371" {
  4445. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4446. utils.ErrorLog("解析失败:%v", err)
  4447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4448. return
  4449. }
  4450. res.ErrMsg = res10265.ErrMsg
  4451. res.Output = res10265.Output
  4452. res.InfRefmsgid = res10265.InfRefmsgid
  4453. } else {
  4454. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4455. utils.ErrorLog("解析失败:%v", err)
  4456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4457. return
  4458. }
  4459. }
  4460. PsnNo = res.Output.Baseinfo.PsnNo
  4461. PsnCertType = res.Output.Baseinfo.PsnCertType
  4462. Certno = res.Output.Baseinfo.Certno
  4463. PsnName = res.Output.Baseinfo.PsnName
  4464. Gend = res.Output.Baseinfo.Gend
  4465. Naty = res.Output.Baseinfo.Naty
  4466. Brdy = res.Output.Baseinfo.Brdy
  4467. Age = res.Output.Baseinfo.Age
  4468. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4469. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4470. infoStr = string(Iinfos)
  4471. idetinfoStr = string(Idetinfos)
  4472. if miConfig.Code == "H15049901371" {
  4473. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4474. } else {
  4475. infocode = res.Infcode
  4476. }
  4477. }
  4478. if infocode == 0 {
  4479. his := models.VMHisPatient{
  4480. Name: name,
  4481. Gender: gender,
  4482. Birthday: birthUnix,
  4483. MedicalTreatmentType: medical_care,
  4484. IdType: certificates,
  4485. IdCardNo: id_card,
  4486. BalanceAccountsType: settlementValue,
  4487. SocialType: social_type,
  4488. MedicalInsuranceNumber: medical_insurance_card,
  4489. RegisterType: register_type,
  4490. RegisterCost: registration_fee,
  4491. TreatmentCost: medical_expenses,
  4492. Status: 1,
  4493. Ctime: time.Now().Unix(),
  4494. Mtime: time.Now().Unix(),
  4495. PsnNo: PsnNo,
  4496. PsnCertType: PsnCertType,
  4497. Certno: Certno,
  4498. PsnName: PsnName,
  4499. Gend: Gend,
  4500. Naty: Naty,
  4501. Brdy: Brdy,
  4502. Age: Age,
  4503. Iinfo: infoStr,
  4504. Idetinfo: idetinfoStr,
  4505. PatientId: patient.ID,
  4506. RecordDate: theTime.Unix(),
  4507. UserOrgId: adminInfo.CurrentOrgId,
  4508. AdminUserId: admin_user_id,
  4509. IsReturn: 1,
  4510. IdCardType: id_card_type,
  4511. Doctor: doctor,
  4512. Departments: department,
  4513. }
  4514. timestamp := time.Now().Unix()
  4515. tempTime := time.Unix(timestamp, 0)
  4516. timeFormat := tempTime.Format("20060102150405")
  4517. chrgBchno := rand.Intn(100000) + 10000
  4518. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4519. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4520. department, _ := service.GetDepartMentDetail(department)
  4521. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4522. IdCardNo := ""
  4523. if id_card_type == 1 {
  4524. // IdCardNo = medical_insurance_card
  4525. IdCardNo = patient.IdCardNo
  4526. } else {
  4527. IdCardNo = patient.IdCardNo
  4528. }
  4529. var rf []*ResultFive
  4530. json.Unmarshal([]byte(his.Iinfo), &rf)
  4531. var insutypes []*ResultFive
  4532. var insutype string
  4533. var insuplc_admdvs_temp string
  4534. var is390 int = 0
  4535. var is310 int = 0
  4536. for _, item := range rf {
  4537. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4538. insutypes = append(insutypes, item)
  4539. }
  4540. }
  4541. if len(insutypes) == 1 {
  4542. insutype = insutypes[0].Insutype
  4543. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4544. } else {
  4545. for _, i := range insutypes {
  4546. if i.Insutype == "390" {
  4547. is390 = 1
  4548. }
  4549. if i.Insutype == "310" {
  4550. is310 = 1
  4551. }
  4552. }
  4553. }
  4554. if is390 == 1 {
  4555. insutype = "390"
  4556. }
  4557. if is310 == 1 {
  4558. insutype = "310"
  4559. }
  4560. if len(insutypes) == 0 {
  4561. insutype = "310"
  4562. }
  4563. if len(insutypes) == 2 {
  4564. insutype = med_type
  4565. }
  4566. if len(med_type) > 0 {
  4567. insutype = med_type
  4568. }
  4569. //for _, item := range rf {
  4570. // if item.Insutype == insutype {
  4571. // insuplc_admdvs = item.InsuplcAdmdvs
  4572. // }
  4573. //}
  4574. var infocode int64
  4575. var resThree ResultThree
  4576. var resThree10265 ResultThree10265
  4577. if len(insuplc_admdvs) == 0 {
  4578. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4579. } else {
  4580. insuplc_admdvs_temp = insuplc_admdvs
  4581. }
  4582. if miConfig.MdtrtareaAdmvs == "421300" {
  4583. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4584. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4585. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4586. "&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
  4587. resp, requestErr := http.Get(api)
  4588. if requestErr != nil {
  4589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4590. return
  4591. }
  4592. body, ioErr := ioutil.ReadAll(resp.Body)
  4593. if ioErr != nil {
  4594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4596. return
  4597. }
  4598. var respJSON map[string]interface{}
  4599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4602. return
  4603. }
  4604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4605. result, _ := json.Marshal(respJSON)
  4606. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4607. utils.ErrorLog("解析失败:%v", err)
  4608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4609. return
  4610. }
  4611. infocode = resThree.Infcode
  4612. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4613. psn_info, _ := service.GetPsnByPatientId(id)
  4614. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4615. var cert_no string
  4616. if id_card_type == 3 {
  4617. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4618. cert_no = IdCardNo
  4619. } else if id_card_type == 4 {
  4620. cert_no = IdCardNo
  4621. psn_info.VerifyNumber = psn_info.VerifyNumber
  4622. } else {
  4623. bas := strings.Split(psn_info.CardInfo, "|")
  4624. cert_no = bas[2]
  4625. }
  4626. var api string
  4627. if miConfig.MdtrtareaAdmvs == "320921" {
  4628. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4629. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4630. "&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_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4631. } else {
  4632. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4633. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4634. "&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_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4635. }
  4636. resp, requestErr := http.Get(api)
  4637. if requestErr != nil {
  4638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4639. return
  4640. }
  4641. body, ioErr := ioutil.ReadAll(resp.Body)
  4642. if ioErr != nil {
  4643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4645. return
  4646. }
  4647. var respJSON map[string]interface{}
  4648. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4651. return
  4652. }
  4653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4654. result, _ := json.Marshal(respJSON)
  4655. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4656. utils.ErrorLog("解析失败:%v", err)
  4657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4658. return
  4659. }
  4660. resThree.ErrMsg = resThree10265.ErrMsg
  4661. resThree.Output = resThree10265.Output
  4662. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4663. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4664. } else {
  4665. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4666. saveLog(result, requestLog, "2201A", "挂号")
  4667. if miConfig.Code == "H15049901371" {
  4668. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4669. utils.ErrorLog("解析失败:%v", err)
  4670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4671. return
  4672. }
  4673. resThree.ErrMsg = resThree10265.ErrMsg
  4674. resThree.Output = resThree10265.Output
  4675. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4676. } else {
  4677. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4678. utils.ErrorLog("解析失败:%v", err)
  4679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4680. return
  4681. }
  4682. }
  4683. if miConfig.Code == "H15049901371" {
  4684. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4685. } else {
  4686. infocode = resThree.Infcode
  4687. }
  4688. }
  4689. if infocode != 0 {
  4690. adminUser := c.GetAdminUserInfo()
  4691. errlog := &models.HisOrderError{
  4692. UserOrgId: adminUser.CurrentOrgId,
  4693. Ctime: time.Now().Unix(),
  4694. Mtime: time.Now().Unix(),
  4695. ErrMsg: resThree.ErrMsg,
  4696. Status: 1,
  4697. PatientId: id,
  4698. RecordTime: recordDateTime,
  4699. Stage: 2,
  4700. }
  4701. service.CreateErrMsgLog(errlog)
  4702. c.ServeSuccessJSON(map[string]interface{}{
  4703. "failed_code": -10,
  4704. "msg": resThree.ErrMsg,
  4705. })
  4706. return
  4707. }
  4708. his.Number = resThree.Output.Data.MdtrtID
  4709. his.PsnNo = resThree.Output.Data.PsnNo
  4710. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4711. his.IdCardNo = patient.IdCardNo
  4712. his.PhoneNumber = patient.Phone
  4713. his.UserOrgId = adminInfo.CurrentOrgId
  4714. his.Insutype = insutype
  4715. his.Ctime = time.Now().Unix()
  4716. his.Mtime = time.Now().Unix()
  4717. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4718. his.Status = 1
  4719. service.UpdateHisPatientStatus(&his)
  4720. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4721. c.ServeSuccessJSON(map[string]interface{}{
  4722. "his_info": his,
  4723. })
  4724. } else {
  4725. adminUser := c.GetAdminUserInfo()
  4726. errlog := &models.HisOrderError{
  4727. UserOrgId: adminUser.CurrentOrgId,
  4728. Ctime: time.Now().Unix(),
  4729. Mtime: time.Now().Unix(),
  4730. ErrMsg: res.ErrMsg,
  4731. Status: 1,
  4732. PatientId: id,
  4733. RecordTime: recordDateTime,
  4734. Stage: 1,
  4735. }
  4736. service.CreateErrMsgLog(errlog)
  4737. c.ServeSuccessJSON(map[string]interface{}{
  4738. "failed_code": -10,
  4739. "msg": res.ErrMsg,
  4740. })
  4741. return
  4742. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4743. }
  4744. }
  4745. }
  4746. //上传明细----预结算----确认订单
  4747. func (c *HisApiController) GetUploadInfo() {
  4748. id, _ := c.GetInt64("id")
  4749. record_time := c.GetString("record_time")
  4750. his_patient_id, _ := c.GetInt64("his_patient_id")
  4751. order_id, _ := c.GetInt64("order_id")
  4752. pay_way, _ := c.GetInt64("pay_way")
  4753. pay_price, _ := c.GetFloat("pay_price")
  4754. pay_card_no := c.GetString("pay_card_no")
  4755. token := c.GetString("token")
  4756. discount_price, _ := c.GetFloat("discount_price")
  4757. preferential_price, _ := c.GetFloat("preferential_price")
  4758. reality_price, _ := c.GetFloat("reality_price")
  4759. found_price, _ := c.GetFloat("found_price")
  4760. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4761. private_price, _ := c.GetFloat("private_price")
  4762. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4763. admin_user_id, _ := c.GetInt64("admin_user_id")
  4764. fapiao_code := c.GetString("fapiao_code")
  4765. fapiao_number := c.GetString("fapiao_number")
  4766. diagnosis_id := c.GetString("diagnosis")
  4767. sick_type, _ := c.GetInt64("sick_type")
  4768. reg_type, _ := c.GetInt64("p_type")
  4769. begin_time := c.GetString("begin_time")
  4770. id_str := c.GetString("ids")
  4771. ids_arr := strings.Split(id_str, ",")
  4772. timeLayout := "2006-01-02"
  4773. loc, _ := time.LoadLocation("Local")
  4774. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4775. if err != nil {
  4776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4777. return
  4778. }
  4779. recordDateTime := theTime.Unix()
  4780. adminUser := c.GetAdminUserInfo()
  4781. var tempOrder models.HisOrder
  4782. tempOrder, _ = service.GetHisOrderByID(order_id)
  4783. var prescriptions []*models.HisPrescription
  4784. var start_time int64
  4785. var end_time int64
  4786. //押金模块
  4787. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4788. tmp_decimal := c.GetString("tmp_decimal")
  4789. var decimal float64 //本次使用的押金
  4790. var errmsg error
  4791. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4792. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4793. return
  4794. }
  4795. if len(tmp_decimal) > 0 {
  4796. if tmp_decimal[0] == 45 {
  4797. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4798. return
  4799. }
  4800. }
  4801. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4802. fmt.Println(errs)
  4803. decimal = tt
  4804. //if adminUser.CurrentOrgId == 10106{
  4805. // if len(fapiao_code) == 0{
  4806. // fapiao_code = "144072080589"
  4807. // }
  4808. // if len(fapiao_number) == 0{
  4809. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4810. // if order.ID == 0{
  4811. // fapiao_number = "00001520"
  4812. // }else{
  4813. // //fapiao_code = "00001520"
  4814. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4815. // var zero string
  4816. // if fpNumber >= 1000{
  4817. // zero = "0000" + strconv.Itoa(fpNumber)
  4818. // }else if fpNumber >= 10000{
  4819. // zero = "000" + strconv.Itoa(fpNumber)
  4820. // } else if fpNumber >= 100000{
  4821. // zero = "00" + strconv.Itoa(fpNumber)
  4822. // } else if fpNumber >= 1000000{
  4823. // zero = "0" + strconv.Itoa(fpNumber)
  4824. // }else {
  4825. // zero = strconv.Itoa(fpNumber)
  4826. // }
  4827. // fapiao_number = zero
  4828. // }
  4829. // }
  4830. //}
  4831. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4832. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4833. var patientPrescription models.HisPrescriptionInfo
  4834. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4835. if patientPrescription.ID == 0 {
  4836. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4837. }
  4838. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4839. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4840. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4841. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4842. var config []*models.HisXtDiagnoseConfig
  4843. for _, item := range diagnosis_ids {
  4844. id, _ := strconv.ParseInt(item, 10, 64)
  4845. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4846. config = append(config, &diagnosisConfig)
  4847. }
  4848. sickConfig, _ := service.FindSickById(sick_type)
  4849. //if tempOrder.ID == 0 {
  4850. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4851. //}
  4852. if tempOrder.ID == 0 {
  4853. var result string
  4854. var requestLog string
  4855. var res2 ResultSix
  4856. var ressix10265 ResultSix10265
  4857. if miConfig.MdtrtareaAdmvs == "421300" {
  4858. data := make(map[string]interface{})
  4859. client := &http.Client{}
  4860. data["psn_no"] = his.PsnNo
  4861. data["mdtrt_id"] = his.Number
  4862. data["opter"] = roles.UserName
  4863. data["org_name"] = miConfig.OrgName
  4864. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4865. data["doctor_id"] = doctor_info.DoctorNumber
  4866. data["doctor_name"] = doctor_info.UserName
  4867. data["department"] = department.Name
  4868. data["fixmedins_code"] = miConfig.Code
  4869. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4870. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4871. data["secret_key"] = miConfig.SecretKey
  4872. data["sick_code"] = sickConfig.CountryCode
  4873. data["sick_name"] = sickConfig.ClassName
  4874. data["dept"] = strconv.FormatInt(department.ID, 10)
  4875. data["config"] = config
  4876. data["begin_time"] = begin_time
  4877. bytesData, _ := json.Marshal(data)
  4878. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4879. resp, _ := client.Do(req)
  4880. defer resp.Body.Close()
  4881. body, ioErr := ioutil.ReadAll(resp.Body)
  4882. if ioErr != nil {
  4883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4885. return
  4886. }
  4887. var respJSON map[string]interface{}
  4888. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4891. return
  4892. }
  4893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4894. userJSONBytes, _ := json.Marshal(respJSON)
  4895. fmt.Println("log")
  4896. fmt.Println(string(userJSONBytes))
  4897. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4898. utils.ErrorLog("解析失败:%v", err)
  4899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4900. return
  4901. }
  4902. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4903. //江苏地区国家医保医疗类别
  4904. //职工透析:医疗类别选特殊情况门诊9933
  4905. //居民血透门慢: 医疗类别选门诊慢病1402
  4906. //var med_type string
  4907. //if his.Insutype == "310" {
  4908. // if reg_type == 14 {
  4909. // med_type = "9933"
  4910. // } else if reg_type == 11 {
  4911. // med_type = "11"
  4912. //
  4913. // }
  4914. //} else if his.Insutype == "390" {
  4915. // if reg_type == 14 {
  4916. // med_type = "1402"
  4917. // } else if reg_type == 11 {
  4918. // med_type = "11"
  4919. // }
  4920. //}
  4921. data := make(map[string]interface{})
  4922. client := &http.Client{}
  4923. data["psn_no"] = his.PsnNo
  4924. data["mdtrt_id"] = his.Number
  4925. data["doctor"] = roles.UserName
  4926. data["department"] = department.Name
  4927. data["org_name"] = miConfig.OrgName
  4928. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4929. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4930. data["fixmedins_code"] = miConfig.Code
  4931. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4932. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4933. data["secret_key"] = miConfig.SecretKey
  4934. data["sick_code"] = sickConfig.CountryCode
  4935. data["sick_name"] = sickConfig.ClassName
  4936. data["url"] = miConfig.Url
  4937. data["ak"] = miConfig.AccessKey
  4938. data["begin_time"] = begin_time
  4939. data["cainfo"] = miConfig.Cainfo
  4940. data["dept"] = strconv.FormatInt(department.ID, 10)
  4941. data["config"] = config
  4942. bytesData, _ := json.Marshal(data)
  4943. var req *http.Request
  4944. if miConfig.MdtrtareaAdmvs == "320921" {
  4945. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4946. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4947. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4948. } else {
  4949. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4950. }
  4951. resp, _ := client.Do(req)
  4952. defer resp.Body.Close()
  4953. body, ioErr := ioutil.ReadAll(resp.Body)
  4954. if ioErr != nil {
  4955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4957. return
  4958. }
  4959. var respJSON map[string]interface{}
  4960. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4963. return
  4964. }
  4965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4966. userJSONBytes, _ := json.Marshal(respJSON)
  4967. fmt.Println("log")
  4968. fmt.Println(string(userJSONBytes))
  4969. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4970. utils.ErrorLog("解析失败:%v", err)
  4971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4972. return
  4973. }
  4974. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4975. res2.Output = ressix10265.Output
  4976. res2.ErrMsg = ressix10265.ErrMsg
  4977. res2.Cainfo = ressix10265.Cainfo
  4978. res2.WarnMsg = ressix10265.WarnMsg
  4979. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4980. res2.Infcode = infocode
  4981. } else {
  4982. if miConfig.MdtrtareaAdmvs == "440781" { //
  4983. 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)
  4984. } else {
  4985. if miConfig.Code == "H15049901371" {
  4986. //赤峰地区国家医保医疗类别
  4987. //职工透析:医疗类别选特殊情况门诊990502
  4988. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4989. var med_type string
  4990. if his.Insutype == "390" {
  4991. if reg_type == 14 {
  4992. med_type = "9933"
  4993. } else if reg_type == 11 {
  4994. med_type = "11"
  4995. }
  4996. } else if his.Insutype == "310" {
  4997. if reg_type == 14 {
  4998. med_type = "990502"
  4999. } else if reg_type == 11 {
  5000. med_type = "11"
  5001. }
  5002. }
  5003. 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)
  5004. } else {
  5005. 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)
  5006. }
  5007. }
  5008. saveLog(result, requestLog, "2203", "上传就诊信息")
  5009. var respJSON2 map[string]interface{}
  5010. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5013. return
  5014. }
  5015. userJSONBytes2, _ := json.Marshal(respJSON2)
  5016. if miConfig.Code == "H15049901371" {
  5017. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5018. utils.ErrorLog("解析失败:%v", err)
  5019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. return
  5021. }
  5022. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5023. res2.Output = ressix10265.Output
  5024. res2.ErrMsg = ressix10265.ErrMsg
  5025. res2.Cainfo = ressix10265.Cainfo
  5026. res2.WarnMsg = ressix10265.WarnMsg
  5027. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5028. res2.Infcode = infocode
  5029. } else {
  5030. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5031. utils.ErrorLog("解析失败:%v", err)
  5032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5033. return
  5034. }
  5035. }
  5036. }
  5037. if res2.Infcode != 0 {
  5038. adminUser := c.GetAdminUserInfo()
  5039. errlog := &models.HisOrderError{
  5040. UserOrgId: adminUser.CurrentOrgId,
  5041. Ctime: time.Now().Unix(),
  5042. Mtime: time.Now().Unix(),
  5043. ErrMsg: res2.ErrMsg,
  5044. Status: 1,
  5045. PatientId: id,
  5046. RecordTime: recordDateTime,
  5047. Stage: 3,
  5048. }
  5049. service.CreateErrMsgLog(errlog)
  5050. c.ServeSuccessJSON(map[string]interface{}{
  5051. "failed_code": -10,
  5052. "msg": res2.ErrMsg,
  5053. })
  5054. return
  5055. } else {
  5056. his.Diagnosis = diagnosis_id
  5057. his.SickType = sickConfig.ID
  5058. //var p_type int64
  5059. //if reg_type == 1111 || reg_type == 1112 {
  5060. // p_type = 11
  5061. //
  5062. //}
  5063. his.PType = fmt.Sprintf("%d", reg_type)
  5064. service.UpdateHisPatientThree(&his)
  5065. data := make(map[string]interface{})
  5066. if settle_accounts_type == 1 { //日结
  5067. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5068. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5069. } else {
  5070. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5071. }
  5072. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5073. data["pre"] = prescriptions
  5074. } else { //月结
  5075. start_time_str := c.GetString("start_time")
  5076. end_time_str := c.GetString("end_time")
  5077. timeLayout := "2006-01-02"
  5078. loc, _ := time.LoadLocation("Local")
  5079. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5080. if err != nil {
  5081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5082. return
  5083. }
  5084. recordStartTime := theStartTime.Unix()
  5085. start_time = recordStartTime
  5086. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5087. if err != nil {
  5088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5089. return
  5090. }
  5091. recordEndTime := theEndTime.Unix()
  5092. end_time = recordEndTime
  5093. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5094. data["pre"] = prescriptions
  5095. }
  5096. timestamp := time.Now().Unix()
  5097. tempTime := time.Unix(timestamp, 0)
  5098. timeFormat := tempTime.Format("20060102150405")
  5099. chrgBchno := rand.Intn(100000) + 10000
  5100. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5101. strconv.FormatInt(his.PatientId, 10)
  5102. client := &http.Client{}
  5103. data["psn_no"] = his.PsnNo
  5104. data["mdtrt_id"] = his.Number
  5105. data["chrg_bchno"] = chrg_bchno
  5106. data["org_name"] = miConfig.OrgName
  5107. data["doctor"] = doctor_info.UserName
  5108. data["doctor_id"] = doctor_info.DoctorNumber
  5109. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5110. data["fixmedins_code"] = miConfig.Code
  5111. data["opter"] = roles.UserName
  5112. data["dept_code"] = department.Number
  5113. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5114. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5115. data["secret_key"] = miConfig.SecretKey
  5116. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5117. data["url"] = miConfig.Url
  5118. data["ak"] = miConfig.AccessKey
  5119. data["new_doctor_name"] = patientPrescription.Doctor
  5120. data["diag_code"] = sickConfig.CountryCode
  5121. data["cainfo"] = miConfig.Cainfo
  5122. var ids []int64
  5123. for _, item := range prescriptions {
  5124. ids = append(ids, item.ID)
  5125. }
  5126. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5127. if config.IsOpen == 1 { //对接了医保,走医保流程
  5128. var res ResultFour
  5129. var resFour10265 ResultFour10265
  5130. if miConfig.MdtrtareaAdmvs == "421300" {
  5131. bytesData, _ := json.Marshal(data)
  5132. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5133. resp, _ := client.Do(req)
  5134. defer resp.Body.Close()
  5135. body, ioErr := ioutil.ReadAll(resp.Body)
  5136. if ioErr != nil {
  5137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5139. return
  5140. }
  5141. var respJSON map[string]interface{}
  5142. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5145. return
  5146. }
  5147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5148. userJSONBytes, _ := json.Marshal(respJSON)
  5149. fmt.Println("log")
  5150. fmt.Println(string(userJSONBytes))
  5151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5152. utils.ErrorLog("解析失败:%v", err)
  5153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5154. return
  5155. }
  5156. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5157. bytesData, _ := json.Marshal(data)
  5158. var req *http.Request
  5159. if miConfig.MdtrtareaAdmvs == "320921" {
  5160. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5161. } else {
  5162. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5163. }
  5164. resp, _ := client.Do(req)
  5165. defer resp.Body.Close()
  5166. body, ioErr := ioutil.ReadAll(resp.Body)
  5167. if ioErr != nil {
  5168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5170. return
  5171. }
  5172. var respJSON map[string]interface{}
  5173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5176. return
  5177. }
  5178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5179. userJSONBytes, _ := json.Marshal(respJSON)
  5180. fmt.Println("log")
  5181. fmt.Println(string(userJSONBytes))
  5182. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5183. utils.ErrorLog("解析失败:%v", err)
  5184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5185. return
  5186. }
  5187. res.InfRefmsgid = resFour10265.InfRefmsgid
  5188. res.Output = resFour10265.Output
  5189. res.ErrMsg = resFour10265.ErrMsg
  5190. res.Cainfo = resFour10265.Cainfo
  5191. res.WarnMsg = resFour10265.WarnMsg
  5192. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5193. res.Infcode = infocode
  5194. } else {
  5195. if miConfig.Code == "H15049901371" {
  5196. 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)
  5197. var dat map[string]interface{}
  5198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5199. fmt.Println(dat)
  5200. } else {
  5201. fmt.Println(err)
  5202. }
  5203. saveLog(result, request_log, "2204", "上传费用明细")
  5204. userJSONBytes, _ := json.Marshal(dat)
  5205. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5206. utils.ErrorLog("解析失败:%v", err)
  5207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5208. return
  5209. }
  5210. res.InfRefmsgid = resFour10265.InfRefmsgid
  5211. res.Output = resFour10265.Output
  5212. res.ErrMsg = resFour10265.ErrMsg
  5213. res.Cainfo = resFour10265.Cainfo
  5214. res.WarnMsg = resFour10265.WarnMsg
  5215. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5216. res.Infcode = infocode
  5217. } else {
  5218. 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)
  5219. var dat map[string]interface{}
  5220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5221. fmt.Println(dat)
  5222. } else {
  5223. fmt.Println(err)
  5224. }
  5225. saveLog(result, request_log, "2204", "上传费用明细")
  5226. userJSONBytes, _ := json.Marshal(dat)
  5227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5228. utils.ErrorLog("解析失败:%v", err)
  5229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5230. return
  5231. }
  5232. }
  5233. }
  5234. if res.Infcode == 0 {
  5235. order := &models.HisOrder{
  5236. UserOrgId: adminUser.CurrentOrgId,
  5237. HisPatientId: his.ID,
  5238. PatientId: his.PatientId,
  5239. SettleAccountsDate: recordDateTime,
  5240. MdtrtId: his.Number,
  5241. PsnNo: his.PsnNo,
  5242. MedType: strconv.FormatInt(reg_type, 10),
  5243. Ctime: time.Now().Unix(),
  5244. Mtime: time.Now().Unix(),
  5245. Status: 1,
  5246. Number: chrg_bchno,
  5247. Infcode: res.Infcode,
  5248. WarnMsg: res.WarnMsg,
  5249. Cainfo: res.Cainfo,
  5250. ErrMsg: res.ErrMsg,
  5251. RespondTime: res.RefmsgTime,
  5252. InfRefmsgid: res.InfRefmsgid,
  5253. OrderStatus: 1,
  5254. PayWay: pay_way,
  5255. PayPrice: pay_price,
  5256. PayCardNo: pay_card_no,
  5257. DiscountPrice: discount_price,
  5258. PreferentialPrice: preferential_price,
  5259. RealityPrice: reality_price,
  5260. FoundPrice: found_price,
  5261. MedicalInsurancePrice: medical_insurance_price,
  5262. PrivatePrice: private_price,
  5263. IsMedicineInsurance: 1,
  5264. SettleType: settle_accounts_type,
  5265. SettleStartTime: start_time,
  5266. SettleEndTime: end_time,
  5267. Creator: roles.AdminUserId,
  5268. Modify: roles.AdminUserId,
  5269. FaPiaoNumber: fapiao_number,
  5270. FaPiaoCode: fapiao_code,
  5271. PType: 2,
  5272. Diagnosis: diagnosis_id,
  5273. }
  5274. err = service.CreateOrder(order)
  5275. if err != nil {
  5276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5277. return
  5278. }
  5279. for _, item := range res.Output.Result {
  5280. temp := strings.Split(item.FeedetlSn, "-")
  5281. var advice_id int64 = 0
  5282. var project_id int64 = 0
  5283. var types int64 = 0
  5284. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5285. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5286. if temp[1] == "1" {
  5287. advice_id = id
  5288. project_id = 0
  5289. } else if temp[1] == "2" {
  5290. advice_id = 0
  5291. project_id = id
  5292. }
  5293. info := &models.HisOrderInfo{
  5294. OrderNumber: order.Number,
  5295. FeedetlSn: item.FeedetlSn,
  5296. UploadDate: time.Now().Unix(),
  5297. AdviceId: advice_id,
  5298. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5299. Cnt: item.Cnt,
  5300. Pric: float64(item.Pric),
  5301. PatientId: his.PatientId,
  5302. PricUplmtAmt: item.PricUplmtAmt,
  5303. SelfpayProp: item.SelfpayProp,
  5304. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5305. OverlmtAmt: item.OverlmtAmt,
  5306. PreselfpayAmt: item.PreselfpayAmt,
  5307. BasMednFlag: item.BasMednFlag,
  5308. MedChrgitmType: item.MedChrgitmType,
  5309. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5310. Status: 1,
  5311. Memo: item.Memo,
  5312. Mtime: time.Now().Unix(),
  5313. InscpScpAmt: item.InscpScpAmt,
  5314. DrtReimFlag: item.DrtReimFlag,
  5315. Ctime: time.Now().Unix(),
  5316. ListSpItemFlag: item.ListSpItemFlag,
  5317. ChldMedcFlag: item.ChldMedcFlag,
  5318. LmtUsedFlag: item.LmtUsedFlag,
  5319. ChrgitmLv: item.ChrgitmLv,
  5320. UserOrgId: adminUser.CurrentOrgId,
  5321. HisPatientId: his.ID,
  5322. OrderId: order.ID,
  5323. ProjectId: project_id,
  5324. Type: types,
  5325. }
  5326. service.CreateOrderInfo(info)
  5327. }
  5328. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5329. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5330. var total float64
  5331. for _, item := range prescriptions {
  5332. if item.Type == 1 { //药品
  5333. for _, subItem := range item.HisDoctorAdviceInfo {
  5334. total = total + (subItem.Price * subItem.PrescribingNumber)
  5335. }
  5336. }
  5337. if item.Type == 2 { //项目
  5338. for _, subItem := range item.HisPrescriptionProject {
  5339. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5340. total = total + (subItem.Price * cnt)
  5341. }
  5342. }
  5343. }
  5344. for _, item := range prescriptions {
  5345. for _, subItem := range item.HisAdditionalCharge {
  5346. total = total + (subItem.Price * float64(subItem.Count))
  5347. }
  5348. }
  5349. var allTotal string
  5350. if adminUser.CurrentOrgId == 9919 {
  5351. allTotal = fmt.Sprintf("%.4f", total)
  5352. } else {
  5353. allTotal = fmt.Sprintf("%.4f", total)
  5354. }
  5355. if res.Infcode == 0 {
  5356. var rf []*ResultFive
  5357. json.Unmarshal([]byte(his.Iinfo), &rf)
  5358. chrg_bchno := chrg_bchno
  5359. cert_no := his.Certno
  5360. var insutypes []string
  5361. var insutype string
  5362. var is390 int = 0
  5363. var is310 int = 0
  5364. for _, item := range rf {
  5365. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5366. insutypes = append(insutypes, item.Insutype)
  5367. }
  5368. }
  5369. if len(insutypes) == 1 {
  5370. insutype = insutypes[0]
  5371. } else {
  5372. for _, i := range insutypes {
  5373. if i == "390" {
  5374. is390 = 1
  5375. }
  5376. if i == "310" {
  5377. is310 = 1
  5378. }
  5379. }
  5380. }
  5381. if is390 == 1 {
  5382. insutype = "390"
  5383. }
  5384. if is310 == 1 {
  5385. insutype = "310"
  5386. }
  5387. if len(insutypes) == 0 {
  5388. insutype = "310"
  5389. }
  5390. if len(insutypes) == 2 {
  5391. insutype = strconv.FormatInt(his.SocialType, 10)
  5392. }
  5393. insutype = strconv.FormatInt(his.SocialType, 10)
  5394. //insutype = "390"
  5395. if his.IdCardType == 1 {
  5396. // cert_no = his.MedicalInsuranceNumber
  5397. cert_no = his.Certno
  5398. } else {
  5399. cert_no = his.Certno
  5400. }
  5401. var res ResultSeven
  5402. var resSeven10265 ResultSeven10265
  5403. var src_resquest string
  5404. var result2 string
  5405. var acct_used_flag string
  5406. fmt.Println("pay_way")
  5407. fmt.Println(pay_way)
  5408. fmt.Println("pay_way")
  5409. if pay_way == 4 {
  5410. acct_used_flag = "1"
  5411. } else {
  5412. acct_used_flag = "0"
  5413. }
  5414. if miConfig.MdtrtareaAdmvs == "421300" {
  5415. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5416. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5417. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5418. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5419. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5420. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5421. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5422. resp, requestErr := http.Get(api)
  5423. if requestErr != nil {
  5424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5425. return
  5426. }
  5427. body, ioErr := ioutil.ReadAll(resp.Body)
  5428. if ioErr != nil {
  5429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5431. return
  5432. }
  5433. var respJSON map[string]interface{}
  5434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5437. return
  5438. }
  5439. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5440. result, _ := json.Marshal(respJSON)
  5441. if miConfig.Code == "H15049901371" {
  5442. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5443. utils.ErrorLog("解析失败:%v", err)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5448. res.Output = resSeven10265.Output
  5449. res.ErrMsg = resSeven10265.ErrMsg
  5450. res.Cainfo = resSeven10265.Cainfo
  5451. res.WarnMsg = resSeven10265.WarnMsg
  5452. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5453. res.Infcode = infocode
  5454. } else {
  5455. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5456. utils.ErrorLog("解析失败:%v", err)
  5457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5458. return
  5459. }
  5460. }
  5461. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5462. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5463. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5464. bas := strings.Split(psn_info.CardInfo, "|")
  5465. if his.IdCardType == 1 {
  5466. cert_no = bas[2]
  5467. } else if his.IdCardType == 3 {
  5468. cert_no = his.Certno
  5469. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5470. } else if his.IdCardType == 4 {
  5471. cert_no = his.Certno
  5472. psn_info.VerifyNumber = token
  5473. }
  5474. var api string
  5475. if miConfig.MdtrtareaAdmvs == "320921" {
  5476. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5477. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5478. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5479. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5480. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5481. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5482. "&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
  5483. } else {
  5484. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5485. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5486. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5487. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5488. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5489. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5490. "&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
  5491. }
  5492. resp, requestErr := http.Get(api)
  5493. if requestErr != nil {
  5494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5495. return
  5496. }
  5497. body, ioErr := ioutil.ReadAll(resp.Body)
  5498. if ioErr != nil {
  5499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5501. return
  5502. }
  5503. var respJSON map[string]interface{}
  5504. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5507. return
  5508. }
  5509. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5510. result, _ := json.Marshal(respJSON)
  5511. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5512. utils.ErrorLog("解析失败:%v", err)
  5513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5514. return
  5515. }
  5516. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5517. res.Output = resSeven10265.Output
  5518. res.ErrMsg = resSeven10265.ErrMsg
  5519. res.Cainfo = resSeven10265.Cainfo
  5520. res.WarnMsg = resSeven10265.WarnMsg
  5521. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5522. res.Infcode = infocode
  5523. } else {
  5524. if miConfig.Code == "H15049901371" {
  5525. //赤峰地区国家医保医疗类别
  5526. //职工透析:医疗类别选特殊情况门诊990502
  5527. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5528. var med_type string
  5529. if his.Insutype == "390" {
  5530. if reg_type == 14 {
  5531. med_type = "9933"
  5532. } else if reg_type == 11 {
  5533. med_type = "11"
  5534. }
  5535. } else if his.Insutype == "310" {
  5536. if reg_type == 14 {
  5537. med_type = "990502"
  5538. } else if reg_type == 11 {
  5539. med_type = "11"
  5540. }
  5541. }
  5542. 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)
  5543. } else {
  5544. 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)
  5545. }
  5546. //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)
  5547. var dat map[string]interface{}
  5548. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5549. fmt.Println(dat)
  5550. } else {
  5551. fmt.Println(err)
  5552. }
  5553. saveLog(result2, src_resquest, "2207", "结算")
  5554. userJSONBytes, _ := json.Marshal(dat)
  5555. if miConfig.Code == "H15049901371" {
  5556. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5557. utils.ErrorLog("解析失败:%v", err)
  5558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5559. return
  5560. }
  5561. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5562. res.Output = resSeven10265.Output
  5563. res.ErrMsg = resSeven10265.ErrMsg
  5564. res.Cainfo = resSeven10265.Cainfo
  5565. res.WarnMsg = resSeven10265.WarnMsg
  5566. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5567. res.Infcode = infocode
  5568. } else {
  5569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5570. utils.ErrorLog("解析失败:%v", err)
  5571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5572. return
  5573. }
  5574. }
  5575. }
  5576. if res.Infcode != 0 {
  5577. errlog := &models.HisOrderError{
  5578. UserOrgId: adminUser.CurrentOrgId,
  5579. Ctime: time.Now().Unix(),
  5580. Mtime: time.Now().Unix(),
  5581. Number: chrg_bchno,
  5582. ErrMsg: res.ErrMsg,
  5583. Status: 1,
  5584. PatientId: id,
  5585. RecordTime: recordDateTime,
  5586. Stage: 6,
  5587. }
  5588. service.CreateErrMsgLog(errlog)
  5589. c.ServeSuccessJSON(map[string]interface{}{
  5590. "failed_code": -10,
  5591. "msg": res.ErrMsg,
  5592. })
  5593. return
  5594. } else {
  5595. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5596. order.OrderStatus = 2
  5597. order.Status = 1
  5598. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5599. order.SetlId = res.Output.Setlinfo.SetlID
  5600. order.PsnNo = res.Output.Setlinfo.PsnNo
  5601. order.PsnName = res.Output.Setlinfo.PsnName
  5602. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5603. order.Certno = res.Output.Setlinfo.Certno
  5604. order.Gend = res.Output.Setlinfo.Gend
  5605. order.Naty = res.Output.Setlinfo.Naty
  5606. order.Age = res.Output.Setlinfo.Age
  5607. order.Insutype = res.Output.Setlinfo.Insutype
  5608. order.PsnType = res.Output.Setlinfo.PsnType
  5609. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5610. order.SetlTime = res.Output.Setlinfo.SetlTime
  5611. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5612. if res.Output.Setlinfo.MedType == "140101" {
  5613. order.MedType = "14"
  5614. } else {
  5615. order.MedType = res.Output.Setlinfo.MedType
  5616. }
  5617. if reg_type == 1112 {
  5618. order.MedType = "1112"
  5619. }
  5620. if reg_type == 1111 {
  5621. order.MedType = "1111"
  5622. }
  5623. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5624. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5625. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5626. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5627. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5628. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5629. order.HifpPay = res.Output.Setlinfo.HifpPay
  5630. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5631. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5632. order.HifesPay = res.Output.Setlinfo.HifesPay
  5633. order.HifobPay = res.Output.Setlinfo.HifobPay
  5634. order.MafPay = res.Output.Setlinfo.MafPay
  5635. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5636. order.OthPay = res.Output.Setlinfo.OthPay
  5637. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5638. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5639. order.AcctPay = res.Output.Setlinfo.AcctPay
  5640. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5641. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5642. order.Balc = res.Output.Setlinfo.Balc
  5643. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5644. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5645. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5646. order.ClrType = res.Output.Setlinfo.ClrType
  5647. order.ClrWay = res.Output.Setlinfo.ClrWay
  5648. order.Creator = order.Creator
  5649. order.Modify = roles.AdminUserId
  5650. order.RequestLog = src_resquest
  5651. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5652. detailStr := string(setlDetail)
  5653. order.SetlDetail = detailStr
  5654. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5655. err = service.UpDateOrder(order)
  5656. if err == nil {
  5657. //判断是否使用了押金
  5658. if dec_way == "true" {
  5659. tmpstring := strconv.FormatInt(order.ID, 10)
  5660. order.Decimal = decimal
  5661. service.UpDateOrder(order)
  5662. //扣押金
  5663. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5664. if errmsg != nil {
  5665. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5666. return
  5667. }
  5668. }
  5669. c.ServeSuccessJSON(map[string]interface{}{
  5670. "msg": "结算成功",
  5671. })
  5672. } else {
  5673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5674. return
  5675. }
  5676. }
  5677. } else {
  5678. adminUser := c.GetAdminUserInfo()
  5679. errlog := &models.HisOrderError{
  5680. UserOrgId: adminUser.CurrentOrgId,
  5681. Ctime: time.Now().Unix(),
  5682. Mtime: time.Now().Unix(),
  5683. ErrMsg: res.ErrMsg,
  5684. Status: 1,
  5685. PatientId: id,
  5686. RecordTime: recordDateTime,
  5687. Stage: 4,
  5688. }
  5689. service.CreateErrMsgLog(errlog)
  5690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5691. return
  5692. }
  5693. } else {
  5694. adminUser := c.GetAdminUserInfo()
  5695. errlog := &models.HisOrderError{
  5696. UserOrgId: adminUser.CurrentOrgId,
  5697. Ctime: time.Now().Unix(),
  5698. Mtime: time.Now().Unix(),
  5699. ErrMsg: res.ErrMsg,
  5700. Status: 1,
  5701. PatientId: id,
  5702. RecordTime: recordDateTime,
  5703. Stage: 4,
  5704. }
  5705. service.CreateErrMsgLog(errlog)
  5706. c.ServeSuccessJSON(map[string]interface{}{
  5707. "failed_code": -10,
  5708. "msg": res.ErrMsg,
  5709. })
  5710. return
  5711. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5712. //return
  5713. }
  5714. }
  5715. }
  5716. } else if tempOrder.ID > 0 {
  5717. if tempOrder.IsPre == 1 {
  5718. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5719. var rf []*ResultFive
  5720. json.Unmarshal([]byte(his.Iinfo), &rf)
  5721. chrg_bchno := tempOrder.Number
  5722. cert_no := his.Certno
  5723. var insutypes []string
  5724. var insutype string
  5725. var is390 int = 0
  5726. var is310 int = 0
  5727. for _, item := range rf {
  5728. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5729. insutypes = append(insutypes, item.Insutype)
  5730. }
  5731. }
  5732. if len(insutypes) == 1 {
  5733. insutype = insutypes[0]
  5734. } else {
  5735. for _, i := range insutypes {
  5736. if i == "390" {
  5737. is390 = 1
  5738. }
  5739. if i == "310" {
  5740. is310 = 1
  5741. }
  5742. }
  5743. }
  5744. if is390 == 1 {
  5745. insutype = "390"
  5746. }
  5747. if is310 == 1 {
  5748. insutype = "310"
  5749. }
  5750. if len(insutypes) == 0 {
  5751. insutype = "310"
  5752. }
  5753. if len(insutypes) == 2 {
  5754. insutype = strconv.FormatInt(his.SocialType, 64)
  5755. }
  5756. //insutype = "390"
  5757. if his.IdCardType == 1 {
  5758. // cert_no = his.MedicalInsuranceNumber
  5759. cert_no = his.Certno
  5760. } else {
  5761. cert_no = his.Certno
  5762. }
  5763. var res ResultSeven
  5764. var resSeven10265 ResultSeven10265
  5765. var src_resquest string
  5766. var result2 string
  5767. var acct_used_flag string
  5768. fmt.Println("pay_way")
  5769. fmt.Println(pay_way)
  5770. fmt.Println("pay_way")
  5771. if pay_way == 4 {
  5772. acct_used_flag = "1"
  5773. } else {
  5774. acct_used_flag = "0"
  5775. }
  5776. if miConfig.MdtrtareaAdmvs == "421300" {
  5777. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5778. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5779. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5780. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5781. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5782. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5783. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5784. resp, requestErr := http.Get(api)
  5785. if requestErr != nil {
  5786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5787. return
  5788. }
  5789. body, ioErr := ioutil.ReadAll(resp.Body)
  5790. if ioErr != nil {
  5791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5793. return
  5794. }
  5795. var respJSON map[string]interface{}
  5796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5799. return
  5800. }
  5801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5802. result, _ := json.Marshal(respJSON)
  5803. fmt.Println("log")
  5804. fmt.Println(string(result))
  5805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5806. utils.ErrorLog("解析失败:%v", err)
  5807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5808. return
  5809. }
  5810. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5811. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5812. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5813. //psn_info, _ := service.GetPsnByPatientId(id)
  5814. bas := strings.Split(psn_info.CardInfo, "|")
  5815. if his.IdCardType == 1 {
  5816. cert_no = bas[2]
  5817. } else {
  5818. cert_no = bas[1]
  5819. }
  5820. //江苏地区国家医保医疗类别
  5821. //职工透析:医疗类别选特殊情况门诊9933
  5822. //居民血透门慢: 医疗类别选门诊慢病1402
  5823. //var med_type string
  5824. //if his.Insutype == "310" {
  5825. // if reg_type == 14 {
  5826. // med_type = "9933"
  5827. // } else if reg_type == 11 {
  5828. // med_type = "11"
  5829. //
  5830. // }
  5831. //} else if his.Insutype == "390" {
  5832. // if reg_type == 14 {
  5833. // med_type = "1402"
  5834. // } else if reg_type == 11 {
  5835. // med_type = "11"
  5836. // }
  5837. //}
  5838. var api string
  5839. if miConfig.MdtrtareaAdmvs == "320921" {
  5840. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5841. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5842. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5843. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5844. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5845. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5846. "&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
  5847. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5848. } else {
  5849. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5850. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5851. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5852. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5854. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5855. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5856. "&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
  5857. }
  5858. resp, requestErr := http.Get(api)
  5859. if requestErr != nil {
  5860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5861. return
  5862. }
  5863. body, ioErr := ioutil.ReadAll(resp.Body)
  5864. if ioErr != nil {
  5865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5867. return
  5868. }
  5869. var respJSON map[string]interface{}
  5870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5873. return
  5874. }
  5875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5876. result, _ := json.Marshal(respJSON)
  5877. fmt.Println("log")
  5878. fmt.Println(string(result))
  5879. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5880. utils.ErrorLog("解析失败:%v", err)
  5881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5882. return
  5883. }
  5884. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5885. res.Output = resSeven10265.Output
  5886. res.ErrMsg = resSeven10265.ErrMsg
  5887. res.Cainfo = resSeven10265.Cainfo
  5888. res.WarnMsg = resSeven10265.WarnMsg
  5889. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5890. res.Infcode = infocode
  5891. } else {
  5892. var src_resquest string
  5893. if miConfig.Code == "H15049901371" {
  5894. //赤峰地区国家医保医疗类别
  5895. //职工透析:医疗类别选特殊情况门诊990502
  5896. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5897. var med_type string
  5898. if his.Insutype == "390" {
  5899. if reg_type == 14 {
  5900. med_type = "9933"
  5901. } else if reg_type == 11 {
  5902. med_type = "11"
  5903. }
  5904. } else if his.Insutype == "310" {
  5905. if reg_type == 14 {
  5906. med_type = "990502"
  5907. } else if reg_type == 11 {
  5908. med_type = "11"
  5909. }
  5910. }
  5911. 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)
  5912. } else {
  5913. 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)
  5914. }
  5915. var dat map[string]interface{}
  5916. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5917. fmt.Println(dat)
  5918. } else {
  5919. fmt.Println(err)
  5920. }
  5921. saveLog(result2, src_resquest, "2207", "结算")
  5922. userJSONBytes, _ := json.Marshal(dat)
  5923. if miConfig.Code == "H15049901371" {
  5924. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5925. utils.ErrorLog("解析失败:%v", err)
  5926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5927. return
  5928. }
  5929. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5930. res.Output = resSeven10265.Output
  5931. res.ErrMsg = resSeven10265.ErrMsg
  5932. res.Cainfo = resSeven10265.Cainfo
  5933. res.WarnMsg = resSeven10265.WarnMsg
  5934. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5935. res.Infcode = infocode
  5936. } else {
  5937. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5938. utils.ErrorLog("解析失败:%v", err)
  5939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5940. return
  5941. }
  5942. }
  5943. }
  5944. if res.Infcode != 0 {
  5945. errlog := &models.HisOrderError{
  5946. UserOrgId: adminUser.CurrentOrgId,
  5947. Ctime: time.Now().Unix(),
  5948. Mtime: time.Now().Unix(),
  5949. Number: chrg_bchno,
  5950. ErrMsg: res.ErrMsg,
  5951. Status: 1,
  5952. PatientId: id,
  5953. RecordTime: recordDateTime,
  5954. Stage: 6,
  5955. }
  5956. service.CreateErrMsgLog(errlog)
  5957. c.ServeSuccessJSON(map[string]interface{}{
  5958. "failed_code": -10,
  5959. "msg": res.ErrMsg,
  5960. })
  5961. return
  5962. } else {
  5963. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5964. order.OrderStatus = 2
  5965. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5966. order.SetlId = res.Output.Setlinfo.SetlID
  5967. order.PsnNo = res.Output.Setlinfo.PsnNo
  5968. order.PsnName = res.Output.Setlinfo.PsnName
  5969. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5970. order.Certno = res.Output.Setlinfo.Certno
  5971. order.Gend = res.Output.Setlinfo.Gend
  5972. order.Naty = res.Output.Setlinfo.Naty
  5973. order.Age = res.Output.Setlinfo.Age
  5974. order.Insutype = res.Output.Setlinfo.Insutype
  5975. order.PsnType = res.Output.Setlinfo.PsnType
  5976. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5977. order.SetlTime = res.Output.Setlinfo.SetlTime
  5978. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5979. //order.MedType = res.Output.Setlinfo.MedType
  5980. if reg_type == 1112 {
  5981. order.MedType = "1112"
  5982. }
  5983. if reg_type == 1111 {
  5984. order.MedType = "1111"
  5985. }
  5986. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5987. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5988. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5989. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5990. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5991. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5992. order.HifpPay = res.Output.Setlinfo.HifpPay
  5993. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5994. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5995. order.HifesPay = res.Output.Setlinfo.HifesPay
  5996. order.HifobPay = res.Output.Setlinfo.HifobPay
  5997. order.MafPay = res.Output.Setlinfo.MafPay
  5998. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5999. order.OthPay = res.Output.Setlinfo.OthPay
  6000. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6001. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6002. order.AcctPay = res.Output.Setlinfo.AcctPay
  6003. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6004. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6005. order.Balc = res.Output.Setlinfo.Balc
  6006. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6007. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6008. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6009. order.ClrWay = res.Output.Setlinfo.ClrWay
  6010. order.Creator = order.Creator
  6011. order.Modify = roles.AdminUserId
  6012. order.RequestLog = src_resquest
  6013. order.Diagnosis = diagnosis_id
  6014. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6015. detailStr := string(setlDetail)
  6016. order.SetlDetail = detailStr
  6017. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6018. err = service.UpDateOrder(order)
  6019. if err == nil {
  6020. //判断是否使用了押金
  6021. if dec_way == "true" {
  6022. tmpstring := strconv.FormatInt(order.ID, 10)
  6023. //扣押金
  6024. order.Decimal = decimal
  6025. service.UpDateOrder(order)
  6026. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6027. if errmsg != nil {
  6028. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6029. return
  6030. }
  6031. }
  6032. c.ServeSuccessJSON(map[string]interface{}{
  6033. "msg": "结算成功",
  6034. })
  6035. } else {
  6036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6037. return
  6038. }
  6039. }
  6040. }
  6041. }
  6042. }
  6043. //func (c *HisApiController) GetPreUploadInfo() {
  6044. // id, _ := c.GetInt64("id")
  6045. // record_time := c.GetString("record_time")
  6046. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6047. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6048. //
  6049. // timeLayout := "2006-01-02"
  6050. // loc, _ := time.LoadLocation("Local")
  6051. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6052. // if err != nil {
  6053. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6054. // return
  6055. // }
  6056. // recordDateTime := theTime.Unix()
  6057. // adminUser := c.GetAdminUserInfo()
  6058. //
  6059. // var prescriptions []*models.HisPrescription
  6060. //
  6061. // var start_time int64
  6062. // var end_time int64
  6063. //
  6064. // data := make(map[string]interface{})
  6065. // if settle_accounts_type == 1 { //日结
  6066. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6067. // data["pre"] = prescriptions
  6068. //
  6069. // } else { //月结
  6070. // start_time_str := c.GetString("start_time")
  6071. // end_time_str := c.GetString("end_time")
  6072. // timeLayout := "2006-01-02"
  6073. // loc, _ := time.LoadLocation("Local")
  6074. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6075. // if err != nil {
  6076. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6077. // return
  6078. // }
  6079. // recordStartTime := theStartTime.Unix()
  6080. // start_time = recordStartTime
  6081. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6082. // if err != nil {
  6083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6084. // return
  6085. // }
  6086. // recordEndTime := theEndTime.Unix()
  6087. // end_time = recordEndTime
  6088. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6089. // data["pre"] = prescriptions
  6090. //
  6091. // }
  6092. //
  6093. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6094. //
  6095. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6096. // timestamp := time.Now().Unix()
  6097. // tempTime := time.Unix(timestamp, 0)
  6098. // timeFormat := tempTime.Format("20060102150405")
  6099. // chrgBchno := rand.Intn(100000) + 10000
  6100. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6101. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6102. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6103. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6104. // strconv.FormatInt(his.PatientId, 10)
  6105. // client := &http.Client{}
  6106. // data["psn_no"] = his.PsnNo
  6107. // data["mdtrt_id"] = his.Number
  6108. // data["chrg_bchno"] = chrg_bchno
  6109. // data["org_name"] = miConfig.OrgName
  6110. // data["doctor"] = roles.UserName
  6111. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6112. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6113. // data["fixmedins_code"] = miConfig.Code
  6114. // data["dept_code"] = department.Number
  6115. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6116. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6117. // data["secret_key"] = miConfig.SecretKey
  6118. // var ids []int64
  6119. //
  6120. // for _, item := range prescriptions {
  6121. // ids = append(ids, item.ID)
  6122. // }
  6123. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6124. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6125. // bytesData, _ := json.Marshal(data)
  6126. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6127. // resp, _ := client.Do(req)
  6128. // defer resp.Body.Close()
  6129. // body, ioErr := ioutil.ReadAll(resp.Body)
  6130. // if ioErr != nil {
  6131. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6133. // return
  6134. // }
  6135. // var respJSON map[string]interface{}
  6136. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6137. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6139. // return
  6140. // }
  6141. //
  6142. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6143. // userJSONBytes, _ := json.Marshal(respJSON)
  6144. // var res ResultFour
  6145. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6146. // utils.ErrorLog("解析失败:%v", err)
  6147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6148. // return
  6149. // }
  6150. //
  6151. // if res.Infcode == 0 {
  6152. // order := &models.HisOrder{
  6153. // UserOrgId: adminUser.CurrentOrgId,
  6154. // HisPatientId: his.ID,
  6155. // PatientId: his.PatientId,
  6156. // SettleAccountsDate: recordDateTime,
  6157. // Ctime: time.Now().Unix(),
  6158. // Mtime: time.Now().Unix(),
  6159. // Status: 1,
  6160. // Number: chrg_bchno,
  6161. // Infcode: res.Infcode,
  6162. // WarnMsg: res.WarnMsg,
  6163. // Cainfo: res.Cainfo,
  6164. // ErrMsg: res.ErrMsg,
  6165. // RespondTime: res.RefmsgTime,
  6166. // InfRefmsgid: res.InfRefmsgid,
  6167. // OrderStatus: 1,
  6168. // IsMedicineInsurance: 1,
  6169. // SettleType: settle_accounts_type,
  6170. // SettleStartTime: start_time,
  6171. // SettleEndTime: end_time,
  6172. // Creator: roles.ID,
  6173. // Modify: roles.ID,
  6174. // PType: 2,
  6175. // }
  6176. // err = service.CreateOrder(order)
  6177. // if err != nil {
  6178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6179. // return
  6180. // }
  6181. //
  6182. // for _, item := range res.Output.Result {
  6183. // temp := strings.Split(item.FeedetlSn, "-")
  6184. // var advice_id int64 = 0
  6185. // var project_id int64 = 0
  6186. // var types int64 = 0
  6187. //
  6188. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6189. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6190. //
  6191. // if temp[1] == "1" {
  6192. // advice_id = id
  6193. // project_id = 0
  6194. // } else if temp[1] == "2" {
  6195. // advice_id = 0
  6196. // project_id = id
  6197. // }
  6198. //
  6199. // info := &models.HisOrderInfo{
  6200. // OrderNumber: order.Number,
  6201. // FeedetlSn: item.FeedetlSn,
  6202. // UploadDate: time.Now().Unix(),
  6203. // AdviceId: advice_id,
  6204. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6205. // Cnt: item.Cnt,
  6206. // Pric: float64(item.Pric),
  6207. // PatientId: his.PatientId,
  6208. // PricUplmtAmt: item.PricUplmtAmt,
  6209. // SelfpayProp: item.SelfpayProp,
  6210. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6211. // OverlmtAmt: item.OverlmtAmt,
  6212. // PreselfpayAmt: item.PreselfpayAmt,
  6213. // BasMednFlag: item.BasMednFlag,
  6214. // MedChrgitmType: item.MedChrgitmType,
  6215. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6216. // Status: 1,
  6217. // Memo: item.Memo,
  6218. // Mtime: time.Now().Unix(),
  6219. // InscpScpAmt: item.InscpScpAmt,
  6220. // DrtReimFlag: item.DrtReimFlag,
  6221. // Ctime: time.Now().Unix(),
  6222. // ListSpItemFlag: item.ListSpItemFlag,
  6223. // ChldMedcFlag: item.ChldMedcFlag,
  6224. // LmtUsedFlag: item.LmtUsedFlag,
  6225. // ChrgitmLv: item.ChrgitmLv,
  6226. // UserOrgId: adminUser.CurrentOrgId,
  6227. // HisPatientId: his.ID,
  6228. // OrderId: order.ID,
  6229. // ProjectId: project_id,
  6230. // Type: types,
  6231. // }
  6232. // service.CreateOrderInfo(info)
  6233. //
  6234. // }
  6235. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6236. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6237. //
  6238. // var total float64
  6239. // for _, item := range prescriptions {
  6240. // if item.Type == 1 { //药品
  6241. // for _, subItem := range item.HisDoctorAdviceInfo {
  6242. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6243. // }
  6244. // }
  6245. // if item.Type == 2 { //项目
  6246. // for _, subItem := range item.HisPrescriptionProject {
  6247. // total = total + (subItem.Price * float64(subItem.Count))
  6248. // }
  6249. // }
  6250. // }
  6251. //
  6252. // for _, item := range prescriptions {
  6253. // for _, subItem := range item.HisAdditionalCharge {
  6254. // total = total + (subItem.Price * float64(subItem.Count))
  6255. // }
  6256. // }
  6257. //
  6258. // allTotal := fmt.Sprintf("%.2f", total)
  6259. // if res.Infcode == 0 {
  6260. // var rf []*ResultFive
  6261. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6262. // psn_no := his.PsnNo
  6263. // mdtrt_id := his.Number
  6264. // chrg_bchno := chrg_bchno
  6265. // cert_no := his.Certno
  6266. // insutype := rf[0].Insutype
  6267. //
  6268. // if his.IdCardType == 1 {
  6269. // cert_no = his.MedicalInsuranceNumber
  6270. //
  6271. // } else {
  6272. //
  6273. // cert_no = his.Certno
  6274. //
  6275. // }
  6276. //
  6277. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6278. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6279. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6280. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6281. // resp, requestErr := http.Get(api)
  6282. // if requestErr != nil {
  6283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6284. // return
  6285. // }
  6286. // defer resp.Body.Close()
  6287. // body, ioErr := ioutil.ReadAll(resp.Body)
  6288. // if ioErr != nil {
  6289. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6291. // return
  6292. // }
  6293. // var respJSON map[string]interface{}
  6294. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6295. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. // return
  6298. // }
  6299. // fmt.Println(respJSON)
  6300. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6301. // userJSONBytes, _ := json.Marshal(respJSON)
  6302. // var res ResultSeven
  6303. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6304. // utils.ErrorLog("解析失败:%v", err)
  6305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6306. // return
  6307. // }
  6308. // if res.Infcode != 0 {
  6309. // errlog := &models.HisOrderError{
  6310. // UserOrgId: adminUser.CurrentOrgId,
  6311. // Ctime: time.Now().Unix(),
  6312. // Mtime: time.Now().Unix(),
  6313. // Number: chrg_bchno,
  6314. // ErrMsg: res.ErrMsg,
  6315. // Status: 1,
  6316. // PatientId: id,
  6317. // RecordTime: recordDateTime,
  6318. // Stage: 7,
  6319. // }
  6320. // service.CreateErrMsgLog(errlog)
  6321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6322. // return
  6323. // } else {
  6324. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6325. // order.OrderStatus = 1
  6326. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6327. // order.SetlId = res.Output.Setlinfo.SetlID
  6328. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6329. // order.PsnName = res.Output.Setlinfo.PsnName
  6330. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6331. // order.Certno = res.Output.Setlinfo.Certno
  6332. // order.Gend = res.Output.Setlinfo.Gend
  6333. // order.Naty = res.Output.Setlinfo.Naty
  6334. // order.Age = res.Output.Setlinfo.Age
  6335. // order.Insutype = res.Output.Setlinfo.Insutype
  6336. // order.PsnType = res.Output.Setlinfo.PsnType
  6337. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6338. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6339. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6340. // order.MedType = res.Output.Setlinfo.MedType
  6341. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6342. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6343. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6344. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6345. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6346. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6347. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6348. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6349. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6350. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6351. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6352. // order.MafPay = res.Output.Setlinfo.MafPay
  6353. // order.OthPay = res.Output.Setlinfo.OthPay
  6354. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6355. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6356. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6357. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6358. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6359. // order.Balc = res.Output.Setlinfo.Balc
  6360. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6361. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6362. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6363. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6364. // order.Creator = order.Creator
  6365. // order.Modify = roles.ID
  6366. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6367. // detailStr := string(setlDetail)
  6368. // order.SetlDetail = detailStr
  6369. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6370. // err = service.UpDateOrder(order)
  6371. // if err == nil {
  6372. // c.ServeSuccessJSON(map[string]interface{}{
  6373. // "msg": "预结算成功",
  6374. // })
  6375. // } else {
  6376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6377. // return
  6378. // }
  6379. // }
  6380. // } else {
  6381. // adminUser := c.GetAdminUserInfo()
  6382. // errlog := &models.HisOrderError{
  6383. // UserOrgId: adminUser.CurrentOrgId,
  6384. // Ctime: time.Now().Unix(),
  6385. // Mtime: time.Now().Unix(),
  6386. // ErrMsg: res.ErrMsg,
  6387. // Status: 1,
  6388. // PatientId: id,
  6389. // RecordTime: recordDateTime,
  6390. // Stage: 4,
  6391. // }
  6392. // service.CreateErrMsgLog(errlog)
  6393. //
  6394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6395. // return
  6396. // }
  6397. // } else {
  6398. // adminUser := c.GetAdminUserInfo()
  6399. // errlog := &models.HisOrderError{
  6400. // UserOrgId: adminUser.CurrentOrgId,
  6401. // Ctime: time.Now().Unix(),
  6402. // Mtime: time.Now().Unix(),
  6403. // ErrMsg: res.ErrMsg,
  6404. // Status: 1,
  6405. // PatientId: id,
  6406. // RecordTime: recordDateTime,
  6407. // Stage: 4,
  6408. // }
  6409. // service.CreateErrMsgLog(errlog)
  6410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6411. // return
  6412. // }
  6413. //
  6414. // } else {
  6415. // var total float64
  6416. // for _, item := range prescriptions {
  6417. // if item.Type == 1 { //药品
  6418. // for _, subItem := range item.HisDoctorAdviceInfo {
  6419. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6420. // }
  6421. // }
  6422. // if item.Type == 2 { //项目
  6423. // for _, subItem := range item.HisPrescriptionProject {
  6424. // total = total + (subItem.Price * float64(subItem.Count))
  6425. // }
  6426. // }
  6427. //
  6428. // for _, subItem := range item.HisAdditionalCharge {
  6429. // total = total + (subItem.Price * float64(subItem.Count))
  6430. // }
  6431. // }
  6432. //
  6433. // allTotal := fmt.Sprintf("%.2f", total)
  6434. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6435. // order := &models.HisOrder{
  6436. // UserOrgId: adminUser.CurrentOrgId,
  6437. // HisPatientId: his.ID,
  6438. // PatientId: id,
  6439. // SettleAccountsDate: recordDateTime,
  6440. // Ctime: time.Now().Unix(),
  6441. // Mtime: time.Now().Unix(),
  6442. // Status: 1,
  6443. // OrderStatus: 2,
  6444. // Number: chrg_bchno,
  6445. // MedfeeSumamt: totals,
  6446. // }
  6447. // err = service.CreateOrder(order)
  6448. // if err != nil {
  6449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6450. // return
  6451. // }
  6452. //
  6453. // var customs []*Custom
  6454. // for _, item := range prescriptions {
  6455. //
  6456. // if item.Type == 1 { //药品
  6457. // for _, subItem := range item.HisDoctorAdviceInfo {
  6458. // cus := &Custom{
  6459. // AdviceId: subItem.ID,
  6460. // ProjectId: 0,
  6461. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6462. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6463. // FeedetlSn: subItem.FeedetlSn,
  6464. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6465. // MedListCodg: subItem.MedListCodg,
  6466. // Type: 1,
  6467. // }
  6468. // customs = append(customs, cus)
  6469. // }
  6470. // }
  6471. //
  6472. // if item.Type == 2 { //项目
  6473. // for _, subItem := range item.HisPrescriptionProject {
  6474. //
  6475. // cus := &Custom{
  6476. // AdviceId: 0,
  6477. // ProjectId: subItem.ID,
  6478. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6479. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6480. // FeedetlSn: subItem.FeedetlSn,
  6481. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6482. // MedListCodg: subItem.MedListCodg,
  6483. // Type: 2,
  6484. // }
  6485. //
  6486. // customs = append(customs, cus)
  6487. // }
  6488. // }
  6489. //
  6490. // for _, item := range item.HisAdditionalCharge {
  6491. // cus := &Custom{
  6492. // ItemId: item.ID,
  6493. // AdviceId: 0,
  6494. // ProjectId: 0,
  6495. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6496. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6497. // FeedetlSn: item.FeedetlSn,
  6498. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6499. // MedListCodg: item.XtHisAddtionConfig.Code,
  6500. // Type: 3,
  6501. // }
  6502. //
  6503. // customs = append(customs, cus)
  6504. // }
  6505. //
  6506. // }
  6507. //
  6508. // for _, item := range customs {
  6509. // var advice_id int64 = 0
  6510. // var project_id int64 = 0
  6511. // var item_id int64 = 0
  6512. //
  6513. // var types int64 = 0
  6514. //
  6515. // if item.Type == 1 {
  6516. // advice_id = item.AdviceId
  6517. // project_id = 0
  6518. // item_id = 0
  6519. // } else if item.Type == 2 {
  6520. // advice_id = 0
  6521. // item_id = 0
  6522. //
  6523. // project_id = item.ProjectId
  6524. // } else if item.Type == 3 {
  6525. // advice_id = 0
  6526. // item_id = item.ItemId
  6527. // project_id = 0
  6528. // }
  6529. //
  6530. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6531. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6532. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6533. //
  6534. // info := &models.HisOrderInfo{
  6535. // OrderNumber: order.Number,
  6536. // UploadDate: time.Now().Unix(),
  6537. // AdviceId: advice_id,
  6538. // DetItemFeeSumamt: detItemFeeSumamt,
  6539. // Cnt: cut,
  6540. // Pric: pric,
  6541. // PatientId: id,
  6542. // Status: 1,
  6543. // Mtime: time.Now().Unix(),
  6544. // Ctime: time.Now().Unix(),
  6545. // UserOrgId: adminUser.CurrentOrgId,
  6546. // HisPatientId: his.ID,
  6547. // OrderId: order.ID,
  6548. // ProjectId: project_id,
  6549. // Type: types,
  6550. // ItemId: item_id,
  6551. // }
  6552. // service.CreateOrderInfo(info)
  6553. // }
  6554. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6555. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6556. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6557. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6558. // if err == nil {
  6559. // c.ServeSuccessJSON(map[string]interface{}{
  6560. // "msg": "结算成功",
  6561. // })
  6562. // } else {
  6563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6564. // return
  6565. // }
  6566. // }
  6567. //}
  6568. //上传明细-预结算-
  6569. func (c *HisApiController) GetPreUploadInfo() {
  6570. id, _ := c.GetInt64("id")
  6571. record_time := c.GetString("record_time")
  6572. his_patient_id, _ := c.GetInt64("his_patient_id")
  6573. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6574. admin_user_id, _ := c.GetInt64("admin_user_id")
  6575. diagnosis_id := c.GetString("diagnosis")
  6576. sick_type, _ := c.GetInt64("sick_type")
  6577. reg_type, _ := c.GetInt64("p_type")
  6578. begin_time := c.GetString("begin_time")
  6579. id_str := c.GetString("ids")
  6580. ids_arr := strings.Split(id_str, ",")
  6581. timeLayout := "2006-01-02"
  6582. loc, _ := time.LoadLocation("Local")
  6583. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6584. if err != nil {
  6585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6586. return
  6587. }
  6588. recordDateTime := theTime.Unix()
  6589. adminUser := c.GetAdminUserInfo()
  6590. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6591. var config []*models.HisXtDiagnoseConfig
  6592. for _, item := range diagnosis_ids {
  6593. id, _ := strconv.ParseInt(item, 10, 64)
  6594. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6595. config = append(config, &diagnosisConfig)
  6596. }
  6597. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6598. sickConfig, _ := service.FindSickById(sick_type)
  6599. var prescriptions []*models.HisPrescription
  6600. var start_time int64
  6601. var end_time int64
  6602. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6603. fmt.Println(his_patient_id)
  6604. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6605. timestamp := time.Now().Unix()
  6606. tempTime := time.Unix(timestamp, 0)
  6607. timeFormat := tempTime.Format("20060102150405")
  6608. chrgBchno := rand.Intn(100000) + 10000
  6609. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6610. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6611. var patientPrescription models.HisPrescriptionInfo
  6612. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6613. if patientPrescription.ID == 0 {
  6614. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6615. }
  6616. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6617. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6618. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6619. strconv.FormatInt(his.PatientId, 10)
  6620. var res2 ResultSix
  6621. var resSix10265 ResultSix10265
  6622. var time_stamp string
  6623. if miConfig.MdtrtareaAdmvs == "421300" {
  6624. data := make(map[string]interface{})
  6625. client := &http.Client{}
  6626. data["psn_no"] = his.PsnNo
  6627. data["mdtrt_id"] = his.Number
  6628. data["department"] = department.Name
  6629. data["org_name"] = miConfig.OrgName
  6630. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6631. data["doctor_id"] = doctor_info.DoctorNumber
  6632. data["doctor_name"] = roles.UserName
  6633. data["fixmedins_code"] = miConfig.Code
  6634. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6635. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6636. data["secret_key"] = miConfig.SecretKey
  6637. data["sick_code"] = sickConfig.CountryCode
  6638. data["sick_name"] = sickConfig.ClassName
  6639. data["begin_time"] = begin_time
  6640. data["dept"] = strconv.FormatInt(department.ID, 10)
  6641. data["config"] = config
  6642. data["opter"] = roles.UserName
  6643. fmt.Println(data)
  6644. bytesData, _ := json.Marshal(data)
  6645. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6646. resp, _ := client.Do(req)
  6647. defer resp.Body.Close()
  6648. body, ioErr := ioutil.ReadAll(resp.Body)
  6649. if ioErr != nil {
  6650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6652. return
  6653. }
  6654. var respJSON map[string]interface{}
  6655. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6658. return
  6659. }
  6660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6661. userJSONBytes, _ := json.Marshal(respJSON)
  6662. fmt.Println("log")
  6663. fmt.Println(string(userJSONBytes))
  6664. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6665. utils.ErrorLog("解析失败:%v", err)
  6666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6667. return
  6668. }
  6669. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6670. //江苏地区国家医保医疗类别
  6671. //职工透析:医疗类别选特殊情况门诊9933
  6672. //居民血透门慢: 医疗类别选门诊慢病1402
  6673. //var med_type string
  6674. //if his.Insutype == "310" {
  6675. // if reg_type == 14 {
  6676. // med_type = "9933"
  6677. // } else if reg_type == 11 {
  6678. // med_type = "11"
  6679. //
  6680. // }
  6681. //} else if his.Insutype == "390" {
  6682. // if reg_type == 14 {
  6683. // med_type = "1402"
  6684. // } else if reg_type == 11 {
  6685. // med_type = "11"
  6686. // }
  6687. //}
  6688. data := make(map[string]interface{})
  6689. client := &http.Client{}
  6690. data["psn_no"] = his.PsnNo
  6691. data["mdtrt_id"] = his.Number
  6692. data["doctor"] = roles.UserName
  6693. data["department"] = department.Name
  6694. data["org_name"] = miConfig.OrgName
  6695. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6696. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6697. data["fixmedins_code"] = miConfig.Code
  6698. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6699. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6700. data["secret_key"] = miConfig.SecretKey
  6701. data["sick_code"] = sickConfig.CountryCode
  6702. data["sick_name"] = sickConfig.ClassName
  6703. data["begin_time"] = begin_time
  6704. data["dept"] = strconv.FormatInt(department.ID, 10)
  6705. data["config"] = config
  6706. data["url"] = miConfig.Url
  6707. data["ak"] = miConfig.AccessKey
  6708. data["cainfo"] = miConfig.Cainfo
  6709. bytesData, _ := json.Marshal(data)
  6710. var req *http.Request
  6711. if miConfig.MdtrtareaAdmvs == "320921" {
  6712. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6713. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6714. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6715. } else {
  6716. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6717. }
  6718. resp, _ := client.Do(req)
  6719. defer resp.Body.Close()
  6720. body, ioErr := ioutil.ReadAll(resp.Body)
  6721. if ioErr != nil {
  6722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. return
  6725. }
  6726. var respJSON map[string]interface{}
  6727. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6730. return
  6731. }
  6732. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6733. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6734. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6736. userJSONBytes, _ := json.Marshal(respJSON)
  6737. fmt.Println("log")
  6738. fmt.Println(string(userJSONBytes))
  6739. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6740. utils.ErrorLog("解析失败:%v", err)
  6741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6742. return
  6743. }
  6744. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6745. res2.Output = resSix10265.Output
  6746. res2.ErrMsg = resSix10265.ErrMsg
  6747. res2.Cainfo = resSix10265.Cainfo
  6748. res2.WarnMsg = resSix10265.WarnMsg
  6749. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6750. res2.Infcode = infocode
  6751. } else {
  6752. var result string
  6753. var requestLog string
  6754. if miConfig.MdtrtareaAdmvs == "440781" { //
  6755. 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)
  6756. } else {
  6757. if miConfig.Code == "H15049901371" {
  6758. //赤峰地区国家医保医疗类别
  6759. //职工透析:医疗类别选特殊情况门诊990502
  6760. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6761. var med_type string
  6762. if his.Insutype == "390" {
  6763. if reg_type == 14 {
  6764. med_type = "9933"
  6765. } else if reg_type == 11 {
  6766. med_type = "11"
  6767. }
  6768. } else if his.Insutype == "310" {
  6769. if reg_type == 14 {
  6770. med_type = "990502"
  6771. } else if reg_type == 11 {
  6772. med_type = "11"
  6773. }
  6774. }
  6775. 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)
  6776. } else {
  6777. 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)
  6778. }
  6779. saveLog(result, requestLog, "2203", "上传就诊信息")
  6780. var respJSON2 map[string]interface{}
  6781. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6784. return
  6785. }
  6786. userJSONBytes2, _ := json.Marshal(respJSON2)
  6787. if miConfig.Code == "H15049901371" {
  6788. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6789. utils.ErrorLog("解析失败:%v", err)
  6790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6791. return
  6792. }
  6793. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6794. res2.Output = resSix10265.Output
  6795. res2.ErrMsg = resSix10265.ErrMsg
  6796. res2.Cainfo = resSix10265.Cainfo
  6797. res2.WarnMsg = resSix10265.WarnMsg
  6798. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6799. res2.Infcode = infocode
  6800. } else {
  6801. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6802. utils.ErrorLog("解析失败:%v", err)
  6803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6804. return
  6805. }
  6806. }
  6807. }
  6808. }
  6809. if res2.Infcode != 0 {
  6810. adminUser := c.GetAdminUserInfo()
  6811. errlog := &models.HisOrderError{
  6812. UserOrgId: adminUser.CurrentOrgId,
  6813. Ctime: time.Now().Unix(),
  6814. Mtime: time.Now().Unix(),
  6815. ErrMsg: res2.ErrMsg,
  6816. Status: 1,
  6817. PatientId: id,
  6818. RecordTime: recordDateTime,
  6819. Stage: 3,
  6820. }
  6821. service.CreateErrMsgLog(errlog)
  6822. c.ServeSuccessJSON(map[string]interface{}{
  6823. "failed_code": -10,
  6824. "msg": res2.ErrMsg,
  6825. })
  6826. return
  6827. } else {
  6828. his.Diagnosis = diagnosis_id
  6829. his.SickType = sickConfig.ID
  6830. his.PType = fmt.Sprintf("%d", reg_type)
  6831. service.UpdateHisPatientThree(&his)
  6832. data := make(map[string]interface{})
  6833. if settle_accounts_type == 1 { //日结
  6834. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6835. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6836. } else {
  6837. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6838. }
  6839. data["pre"] = prescriptions
  6840. } else { //月结
  6841. start_time_str := c.GetString("start_time")
  6842. end_time_str := c.GetString("end_time")
  6843. timeLayout := "2006-01-02"
  6844. loc, _ := time.LoadLocation("Local")
  6845. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6846. if err != nil {
  6847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6848. return
  6849. }
  6850. recordStartTime := theStartTime.Unix()
  6851. start_time = recordStartTime
  6852. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6853. if err != nil {
  6854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6855. return
  6856. }
  6857. recordEndTime := theEndTime.Unix()
  6858. end_time = recordEndTime
  6859. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6860. data["pre"] = prescriptions
  6861. }
  6862. client := &http.Client{}
  6863. data["psn_no"] = his.PsnNo
  6864. data["mdtrt_id"] = his.Number
  6865. data["chrg_bchno"] = chrg_bchno
  6866. data["org_name"] = miConfig.OrgName
  6867. data["doctor"] = roles.UserName
  6868. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6869. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6870. data["fixmedins_code"] = miConfig.Code
  6871. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6872. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6873. data["dept_code"] = "15"
  6874. } else {
  6875. data["dept_code"] = department.Number
  6876. }
  6877. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6878. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6879. data["secret_key"] = miConfig.SecretKey
  6880. data["url"] = miConfig.Url
  6881. data["ak"] = miConfig.AccessKey
  6882. data["new_doctor_name"] = patientPrescription.Doctor
  6883. data["diag_code"] = sickConfig.CountryCode
  6884. data["time_stamp"] = time_stamp
  6885. data["cainfo"] = miConfig.Cainfo
  6886. var ids []int64
  6887. for _, item := range prescriptions {
  6888. ids = append(ids, item.ID)
  6889. }
  6890. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6891. if config.IsOpen == 1 { //对接了医保,走医保流程
  6892. var res ResultFour
  6893. var resFour10265 ResultFour10265
  6894. if miConfig.MdtrtareaAdmvs == "421300" {
  6895. bytesData, _ := json.Marshal(data)
  6896. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6897. resp, _ := client.Do(req)
  6898. defer resp.Body.Close()
  6899. body, ioErr := ioutil.ReadAll(resp.Body)
  6900. if ioErr != nil {
  6901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. return
  6904. }
  6905. var respJSON map[string]interface{}
  6906. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6909. return
  6910. }
  6911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6912. userJSONBytes, _ := json.Marshal(respJSON)
  6913. fmt.Println("log")
  6914. fmt.Println(string(userJSONBytes))
  6915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6916. utils.ErrorLog("解析失败:%v", err)
  6917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6918. return
  6919. }
  6920. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6921. bytesData, _ := json.Marshal(data)
  6922. var req *http.Request
  6923. if miConfig.MdtrtareaAdmvs == "320921" {
  6924. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6925. } else {
  6926. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6927. }
  6928. resp, _ := client.Do(req)
  6929. defer resp.Body.Close()
  6930. body, ioErr := ioutil.ReadAll(resp.Body)
  6931. if ioErr != nil {
  6932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6934. return
  6935. }
  6936. var respJSON map[string]interface{}
  6937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6940. return
  6941. }
  6942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6943. userJSONBytes, _ := json.Marshal(respJSON)
  6944. fmt.Println("log")
  6945. fmt.Println(string(userJSONBytes))
  6946. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6947. utils.ErrorLog("解析失败:%v", err)
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. return
  6950. }
  6951. res.InfRefmsgid = resFour10265.InfRefmsgid
  6952. res.Output = resFour10265.Output
  6953. res.ErrMsg = resFour10265.ErrMsg
  6954. res.Cainfo = resFour10265.Cainfo
  6955. res.WarnMsg = resFour10265.WarnMsg
  6956. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6957. res.Infcode = infocode
  6958. } else {
  6959. if miConfig.Code == "H15049901371" {
  6960. 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)
  6961. var dat map[string]interface{}
  6962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6963. fmt.Println(dat)
  6964. } else {
  6965. fmt.Println(err)
  6966. }
  6967. saveLog(result, request_log, "2204", "上传费用明细")
  6968. userJSONBytes, _ := json.Marshal(dat)
  6969. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6970. utils.ErrorLog("解析失败:%v", err)
  6971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6972. return
  6973. }
  6974. res.InfRefmsgid = resFour10265.InfRefmsgid
  6975. res.Output = resFour10265.Output
  6976. res.ErrMsg = resFour10265.ErrMsg
  6977. res.Cainfo = resFour10265.Cainfo
  6978. res.WarnMsg = resFour10265.WarnMsg
  6979. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6980. res.Infcode = infocode
  6981. } else {
  6982. 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)
  6983. var dat map[string]interface{}
  6984. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6985. fmt.Println(dat)
  6986. } else {
  6987. fmt.Println(err)
  6988. }
  6989. saveLog(result, request_log, "2204", "上传费用明细")
  6990. userJSONBytes, _ := json.Marshal(dat)
  6991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6992. utils.ErrorLog("解析失败:%v", err)
  6993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6994. return
  6995. }
  6996. }
  6997. }
  6998. if res.Infcode == 0 {
  6999. order := &models.HisOrder{
  7000. UserOrgId: adminUser.CurrentOrgId,
  7001. HisPatientId: his.ID,
  7002. PatientId: his.PatientId,
  7003. SettleAccountsDate: recordDateTime,
  7004. Ctime: time.Now().Unix(),
  7005. Mtime: time.Now().Unix(),
  7006. MdtrtId: his.Number,
  7007. PsnNo: his.PsnNo,
  7008. MedType: strconv.FormatInt(reg_type, 10),
  7009. Status: 1,
  7010. Number: chrg_bchno,
  7011. Infcode: res.Infcode,
  7012. WarnMsg: res.WarnMsg,
  7013. Cainfo: res.Cainfo,
  7014. ErrMsg: res.ErrMsg,
  7015. RespondTime: res.RefmsgTime,
  7016. InfRefmsgid: res.InfRefmsgid,
  7017. OrderStatus: 1,
  7018. IsMedicineInsurance: 1,
  7019. SettleType: settle_accounts_type,
  7020. SettleStartTime: start_time,
  7021. SettleEndTime: end_time,
  7022. Creator: roles.AdminUserId,
  7023. Modify: roles.AdminUserId,
  7024. PType: 2,
  7025. Diagnosis: diagnosis_id,
  7026. }
  7027. err = service.CreateOrder(order)
  7028. if err != nil {
  7029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7030. return
  7031. }
  7032. for _, item := range res.Output.Result {
  7033. temp := strings.Split(item.FeedetlSn, "-")
  7034. var advice_id int64 = 0
  7035. var project_id int64 = 0
  7036. var types int64 = 0
  7037. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7038. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7039. if temp[1] == "1" {
  7040. advice_id = id
  7041. project_id = 0
  7042. } else if temp[1] == "2" {
  7043. advice_id = 0
  7044. project_id = id
  7045. }
  7046. info := &models.HisOrderInfo{
  7047. OrderNumber: order.Number,
  7048. FeedetlSn: item.FeedetlSn,
  7049. UploadDate: time.Now().Unix(),
  7050. AdviceId: advice_id,
  7051. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7052. Cnt: item.Cnt,
  7053. Pric: float64(item.Pric),
  7054. PatientId: his.PatientId,
  7055. PricUplmtAmt: item.PricUplmtAmt,
  7056. SelfpayProp: item.SelfpayProp,
  7057. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7058. OverlmtAmt: item.OverlmtAmt,
  7059. PreselfpayAmt: item.PreselfpayAmt,
  7060. BasMednFlag: item.BasMednFlag,
  7061. MedChrgitmType: item.MedChrgitmType,
  7062. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7063. Status: 1,
  7064. Memo: item.Memo,
  7065. Mtime: time.Now().Unix(),
  7066. InscpScpAmt: item.InscpScpAmt,
  7067. DrtReimFlag: item.DrtReimFlag,
  7068. Ctime: time.Now().Unix(),
  7069. ListSpItemFlag: item.ListSpItemFlag,
  7070. ChldMedcFlag: item.ChldMedcFlag,
  7071. LmtUsedFlag: item.LmtUsedFlag,
  7072. ChrgitmLv: item.ChrgitmLv,
  7073. UserOrgId: adminUser.CurrentOrgId,
  7074. HisPatientId: his.ID,
  7075. OrderId: order.ID,
  7076. ProjectId: project_id,
  7077. Type: types,
  7078. }
  7079. service.CreateOrderInfo(info)
  7080. }
  7081. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7082. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7083. var total float64
  7084. for _, item := range prescriptions {
  7085. if item.Type == 1 { //药品
  7086. for _, subItem := range item.HisDoctorAdviceInfo {
  7087. total = total + (subItem.Price * subItem.PrescribingNumber)
  7088. }
  7089. }
  7090. if item.Type == 2 { //项目
  7091. for _, subItem := range item.HisPrescriptionProject {
  7092. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7093. total = total + (subItem.Price * cnt)
  7094. }
  7095. }
  7096. }
  7097. for _, item := range prescriptions {
  7098. for _, subItem := range item.HisAdditionalCharge {
  7099. total = total + (subItem.Price * float64(subItem.Count))
  7100. }
  7101. }
  7102. allTotal := fmt.Sprintf("%.4f", total)
  7103. if res.Infcode == 0 {
  7104. var rf []*ResultFive
  7105. json.Unmarshal([]byte(his.Iinfo), &rf)
  7106. chrg_bchno := chrg_bchno
  7107. cert_no := his.Certno
  7108. var insutypes []string
  7109. var insutype string
  7110. var is390 int = 0
  7111. var is310 int = 0
  7112. for _, item := range rf {
  7113. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7114. insutypes = append(insutypes, item.Insutype)
  7115. }
  7116. }
  7117. if len(insutypes) == 1 {
  7118. insutype = insutypes[0]
  7119. } else {
  7120. for _, i := range insutypes {
  7121. if i == "390" {
  7122. is390 = 1
  7123. }
  7124. if i == "310" {
  7125. is310 = 1
  7126. }
  7127. }
  7128. }
  7129. if is390 == 1 {
  7130. insutype = "390"
  7131. }
  7132. if is310 == 1 {
  7133. insutype = "310"
  7134. }
  7135. if len(insutypes) == 0 {
  7136. insutype = "310"
  7137. }
  7138. if len(insutypes) == 2 {
  7139. insutype = strconv.FormatInt(his.SocialType, 64)
  7140. }
  7141. //insutype = "390"
  7142. if his.IdCardType == 1 {
  7143. cert_no = his.MedicalInsuranceNumber
  7144. } else {
  7145. cert_no = his.Certno
  7146. }
  7147. var res ResultSeven
  7148. var resSeven10265 ResultSeven10265
  7149. if miConfig.MdtrtareaAdmvs == "421300" {
  7150. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7151. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7152. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7153. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7154. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7155. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7156. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7157. resp, requestErr := http.Get(api)
  7158. if requestErr != nil {
  7159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7160. return
  7161. }
  7162. body, ioErr := ioutil.ReadAll(resp.Body)
  7163. if ioErr != nil {
  7164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7166. return
  7167. }
  7168. var respJSON map[string]interface{}
  7169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7172. return
  7173. }
  7174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7175. result, _ := json.Marshal(respJSON)
  7176. fmt.Println("log")
  7177. fmt.Println(string(result))
  7178. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7179. utils.ErrorLog("解析失败:%v", err)
  7180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7181. return
  7182. }
  7183. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7184. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7185. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7186. bas := strings.Split(psn_info.CardInfo, "|")
  7187. if his.IdCardType == 1 {
  7188. cert_no = bas[2]
  7189. } else {
  7190. cert_no = bas[1]
  7191. }
  7192. //江苏地区国家医保医疗类别
  7193. //职工透析:医疗类别选特殊情况门诊9933
  7194. //居民血透门慢: 医疗类别选门诊慢病1402
  7195. //var med_type string
  7196. //if his.Insutype == "310" {
  7197. // if reg_type == 14 {
  7198. // med_type = "9933"
  7199. // } else if reg_type == 11 {
  7200. // med_type = "11"
  7201. //
  7202. // }
  7203. //} else if his.Insutype == "390" {
  7204. // if reg_type == 14 {
  7205. // med_type = "1402"
  7206. // } else if reg_type == 11 {
  7207. // med_type = "11"
  7208. // }
  7209. //}
  7210. var api string
  7211. if miConfig.MdtrtareaAdmvs == "320921" {
  7212. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7213. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7214. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7215. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7216. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7217. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7218. "&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
  7219. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7220. } else {
  7221. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7222. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7223. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7224. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7225. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7226. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7227. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7228. "&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
  7229. }
  7230. resp, requestErr := http.Get(api)
  7231. if requestErr != nil {
  7232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7233. return
  7234. }
  7235. body, ioErr := ioutil.ReadAll(resp.Body)
  7236. if ioErr != nil {
  7237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7239. return
  7240. }
  7241. var respJSON map[string]interface{}
  7242. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7245. return
  7246. }
  7247. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7248. result, _ := json.Marshal(respJSON)
  7249. fmt.Println("log")
  7250. fmt.Println(string(result))
  7251. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7252. utils.ErrorLog("解析失败:%v", err)
  7253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7254. return
  7255. }
  7256. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7257. res.Output = resSeven10265.Output
  7258. res.ErrMsg = resSeven10265.ErrMsg
  7259. res.Cainfo = resSeven10265.Cainfo
  7260. res.WarnMsg = resSeven10265.WarnMsg
  7261. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7262. res.Infcode = infocode
  7263. } else {
  7264. var result string
  7265. var request_log string
  7266. if miConfig.Code == "H15049901371" {
  7267. //赤峰地区国家医保医疗类别
  7268. //职工透析:医疗类别选特殊情况门诊990502
  7269. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7270. var med_type string
  7271. if his.Insutype == "390" {
  7272. if reg_type == 14 {
  7273. med_type = "9933"
  7274. } else if reg_type == 11 {
  7275. med_type = "11"
  7276. }
  7277. } else if his.Insutype == "310" {
  7278. if reg_type == 14 {
  7279. med_type = "990502"
  7280. } else if reg_type == 11 {
  7281. med_type = "11"
  7282. }
  7283. }
  7284. 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)
  7285. } else {
  7286. 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)
  7287. }
  7288. var dat map[string]interface{}
  7289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7290. fmt.Println(dat)
  7291. } else {
  7292. fmt.Println(err)
  7293. }
  7294. saveLog(result, request_log, "2206", "预结算")
  7295. //userJSONBytes, _ := json.Marshal(dat)
  7296. //
  7297. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7298. // utils.ErrorLog("解析失败:%v", err)
  7299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7300. // return
  7301. //}
  7302. userJSONBytes, _ := json.Marshal(dat)
  7303. if miConfig.Code == "H15049901371" {
  7304. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7305. utils.ErrorLog("解析失败:%v", err)
  7306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7307. return
  7308. }
  7309. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7310. res.Output = resSeven10265.Output
  7311. res.ErrMsg = resSeven10265.ErrMsg
  7312. res.Cainfo = resSeven10265.Cainfo
  7313. res.WarnMsg = resSeven10265.WarnMsg
  7314. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7315. res.Infcode = infocode
  7316. } else {
  7317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7318. utils.ErrorLog("解析失败:%v", err)
  7319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7320. return
  7321. }
  7322. }
  7323. }
  7324. if res.Infcode != 0 {
  7325. errlog := &models.HisOrderError{
  7326. UserOrgId: adminUser.CurrentOrgId,
  7327. Ctime: time.Now().Unix(),
  7328. Mtime: time.Now().Unix(),
  7329. Number: chrg_bchno,
  7330. ErrMsg: res.ErrMsg,
  7331. Status: 1,
  7332. PatientId: id,
  7333. RecordTime: recordDateTime,
  7334. Stage: 20,
  7335. }
  7336. service.CreateErrMsgLog(errlog)
  7337. c.ServeSuccessJSON(map[string]interface{}{
  7338. "failed_code": -10,
  7339. "msg": res.ErrMsg,
  7340. })
  7341. return
  7342. } else {
  7343. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7344. order.OrderStatus = 1
  7345. order.IsPre = 1
  7346. order.Status = 1
  7347. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7348. order.SetlId = res.Output.Setlinfo.SetlID
  7349. order.PsnNo = res.Output.Setlinfo.PsnNo
  7350. order.PsnName = res.Output.Setlinfo.PsnName
  7351. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7352. order.Certno = res.Output.Setlinfo.Certno
  7353. order.Gend = res.Output.Setlinfo.Gend
  7354. order.Naty = res.Output.Setlinfo.Naty
  7355. order.Age = res.Output.Setlinfo.Age
  7356. order.Insutype = res.Output.Setlinfo.Insutype
  7357. order.PsnType = res.Output.Setlinfo.PsnType
  7358. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7359. order.SetlTime = res.Output.Setlinfo.SetlTime
  7360. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7361. if res.Output.Setlinfo.MedType == "140101" {
  7362. order.MedType = "14"
  7363. } else {
  7364. order.MedType = res.Output.Setlinfo.MedType
  7365. }
  7366. if reg_type == 1112 {
  7367. order.MedType = "1112"
  7368. }
  7369. if reg_type == 1111 {
  7370. order.MedType = "1111"
  7371. }
  7372. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7373. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7374. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7375. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7376. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7377. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7378. order.HifpPay = res.Output.Setlinfo.HifpPay
  7379. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7380. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7381. order.HifesPay = res.Output.Setlinfo.HifesPay
  7382. order.HifobPay = res.Output.Setlinfo.HifobPay
  7383. order.MafPay = res.Output.Setlinfo.MafPay
  7384. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7385. order.OthPay = res.Output.Setlinfo.OthPay
  7386. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7387. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7388. order.AcctPay = res.Output.Setlinfo.AcctPay
  7389. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7390. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7391. order.Balc = res.Output.Setlinfo.Balc
  7392. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7393. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7394. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7395. order.ClrWay = res.Output.Setlinfo.ClrWay
  7396. order.Creator = order.Creator
  7397. order.Modify = roles.AdminUserId
  7398. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7399. detailStr := string(setlDetail)
  7400. order.SetlDetail = detailStr
  7401. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7402. err = service.UpDateOrder(order)
  7403. if err == nil {
  7404. c.ServeSuccessJSON(map[string]interface{}{
  7405. "msg": "预结算成功",
  7406. })
  7407. } else {
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7409. return
  7410. }
  7411. }
  7412. } else {
  7413. adminUser := c.GetAdminUserInfo()
  7414. errlog := &models.HisOrderError{
  7415. UserOrgId: adminUser.CurrentOrgId,
  7416. Ctime: time.Now().Unix(),
  7417. Mtime: time.Now().Unix(),
  7418. ErrMsg: res.ErrMsg,
  7419. Status: 1,
  7420. PatientId: id,
  7421. RecordTime: recordDateTime,
  7422. Stage: 4,
  7423. }
  7424. service.CreateErrMsgLog(errlog)
  7425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7426. return
  7427. }
  7428. } else {
  7429. adminUser := c.GetAdminUserInfo()
  7430. errlog := &models.HisOrderError{
  7431. UserOrgId: adminUser.CurrentOrgId,
  7432. Ctime: time.Now().Unix(),
  7433. Mtime: time.Now().Unix(),
  7434. ErrMsg: res.ErrMsg,
  7435. Status: 1,
  7436. PatientId: id,
  7437. RecordTime: recordDateTime,
  7438. Stage: 4,
  7439. }
  7440. service.CreateErrMsgLog(errlog)
  7441. c.ServeSuccessJSON(map[string]interface{}{
  7442. "failed_code": -10,
  7443. "msg": res.ErrMsg,
  7444. })
  7445. return
  7446. }
  7447. }
  7448. }
  7449. }
  7450. //func (c *HisApiController) GetSettleInfo() {
  7451. // id, _ := c.GetInt64("id")
  7452. // order_id, _ := c.GetInt64("order_id")
  7453. //
  7454. // record_time := c.GetString("record_time")
  7455. // pay_way, _ := c.GetInt64("pay_way")
  7456. // pay_price, _ := c.GetFloat("pay_price")
  7457. // pay_card_no := c.GetString("pay_card_no")
  7458. // discount_price, _ := c.GetFloat("discount_price")
  7459. // preferential_price, _ := c.GetFloat("preferential_price")
  7460. // reality_price, _ := c.GetFloat("reality_price")
  7461. // found_price, _ := c.GetFloat("found_price")
  7462. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7463. // private_price, _ := c.GetFloat("private_price")
  7464. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7465. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7466. //
  7467. // timeLayout := "2006-01-02"
  7468. // loc, _ := time.LoadLocation("Local")
  7469. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7470. // if err != nil {
  7471. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7472. // return
  7473. // }
  7474. // recordDateTime := theTime.Unix()
  7475. // adminUser := c.GetAdminUserInfo()
  7476. //
  7477. // var prescriptions []*models.HisPrescription
  7478. //
  7479. // data := make(map[string]interface{})
  7480. // if settle_accounts_type == 1 { //日结
  7481. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7482. // data["pre"] = prescriptions
  7483. //
  7484. // } else { //月结
  7485. // start_time_str := c.GetString("start_time")
  7486. // end_time_str := c.GetString("end_time")
  7487. // timeLayout := "2006-01-02"
  7488. // loc, _ := time.LoadLocation("Local")
  7489. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7490. // if err != nil {
  7491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7492. // return
  7493. // }
  7494. // recordStartTime := theStartTime.Unix()
  7495. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7496. // if err != nil {
  7497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7498. // return
  7499. // }
  7500. // recordEndTime := theEndTime.Unix()
  7501. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7502. // data["pre"] = prescriptions
  7503. //
  7504. // }
  7505. //
  7506. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7507. //
  7508. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7509. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7510. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7511. // strconv.FormatInt(his.PatientId, 10)
  7512. //
  7513. // order_src, _ := service.GetHisOrderByID(order_id)
  7514. //
  7515. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7516. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7517. //
  7518. // var total float64
  7519. // for _, item := range prescriptions {
  7520. // if item.Type == 1 { //药品
  7521. // for _, subItem := range item.HisDoctorAdviceInfo {
  7522. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7523. // }
  7524. // }
  7525. // if item.Type == 2 { //项目
  7526. // for _, subItem := range item.HisPrescriptionProject {
  7527. // total = total + (subItem.Price * float64(subItem.Count))
  7528. // }
  7529. // }
  7530. // }
  7531. //
  7532. // for _, item := range prescriptions {
  7533. // for _, subItem := range item.HisAdditionalCharge {
  7534. // total = total + (subItem.Price * float64(subItem.Count))
  7535. // }
  7536. // }
  7537. //
  7538. // allTotal := fmt.Sprintf("%.2f", total)
  7539. // var rf []*ResultFive
  7540. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7541. // psn_no := order_src.PsnNo
  7542. // mdtrt_id := order_src.MdtrtId
  7543. // chrg_bchno := order_src.Number
  7544. // cert_no := order_src.Certno
  7545. // insutype := rf[0].Insutype
  7546. //
  7547. // if his.IdCardType == 1 {
  7548. // cert_no = his.MedicalInsuranceNumber
  7549. // } else {
  7550. // cert_no = his.Certno
  7551. // }
  7552. //
  7553. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  7554. // var dat map[string]interface{}
  7555. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7556. // fmt.Println(dat)
  7557. // } else {
  7558. // fmt.Println(err)
  7559. // }
  7560. //
  7561. // userJSONBytes, _ := json.Marshal(dat)
  7562. //
  7563. //
  7564. //
  7565. // var res ResultSeven
  7566. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7567. // utils.ErrorLog("解析失败:%v", err)
  7568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7569. // return
  7570. // }
  7571. // if res.Infcode == -1 {
  7572. // errlog := &models.HisOrderError{
  7573. // UserOrgId: adminUser.CurrentOrgId,
  7574. // Ctime: time.Now().Unix(),
  7575. // Mtime: time.Now().Unix(),
  7576. // Number: chrg_bchno,
  7577. // ErrMsg: res.ErrMsg,
  7578. // Status: 1,
  7579. // PatientId: id,
  7580. // RecordTime: recordDateTime,
  7581. // Stage: 6,
  7582. // }
  7583. // service.CreateErrMsgLog(errlog)
  7584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7585. // return
  7586. // } else {
  7587. // order_src.OrderStatus = 2
  7588. // order_src.PayWay = pay_way
  7589. // order_src.PayPrice = pay_price
  7590. // order_src.PayCardNo = pay_card_no
  7591. // order_src.DiscountPrice = discount_price
  7592. // order_src.PreferentialPrice = preferential_price
  7593. // order_src.RealityPrice = reality_price
  7594. // order_src.FoundPrice = found_price
  7595. // order_src.MedicalInsurancePrice = medical_insurance_price
  7596. // order_src.PrivatePrice = private_price
  7597. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7598. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7599. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7600. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7601. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7602. // order_src.Certno = res.Output.Setlinfo.Certno
  7603. // order_src.Gend = res.Output.Setlinfo.Gend
  7604. // order_src.Naty = res.Output.Setlinfo.Naty
  7605. // order_src.Age = res.Output.Setlinfo.Age
  7606. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7607. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7608. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7609. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7610. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7611. // order_src.MedType = res.Output.Setlinfo.MedType
  7612. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7613. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7614. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7615. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7616. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7617. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7618. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7619. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7620. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7621. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7622. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7623. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7624. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7625. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7626. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7627. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7628. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7629. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7630. // order_src.Balc = res.Output.Setlinfo.Balc
  7631. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7632. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7633. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7634. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7635. // order_src.Creator = order_src.Creator
  7636. // order_src.Modify = roles.ID
  7637. // order_src.RequestLog = src_resquest
  7638. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7639. // detailStr := string(setlDetail)
  7640. // order_src.SetlDetail = detailStr
  7641. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7642. // err = service.UpDateOrder(order_src)
  7643. //
  7644. // if err == nil {
  7645. // c.ServeSuccessJSON(map[string]interface{}{
  7646. // "msg": "结算成功",
  7647. // })
  7648. // } else {
  7649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7650. // return
  7651. // }
  7652. // }
  7653. // }
  7654. //}
  7655. //退款
  7656. func (c *HisApiController) Refund() {
  7657. order_id, _ := c.GetInt64("order_id")
  7658. admin_user_id, _ := c.GetInt64("admin_user_id")
  7659. adminUser := c.GetAdminUserInfo()
  7660. var order models.HisOrder
  7661. order, _ = service.GetHisOrderByID(order_id)
  7662. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7663. if order.ID == 0 {
  7664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7665. return
  7666. }
  7667. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7668. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7669. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7670. if config.IsOpen == 1 { //对接了医保,走医保流程
  7671. var res ResultSixteen
  7672. var resSixteen10265 ResultSixteen10265
  7673. var src_resquest string
  7674. var result string
  7675. if miConfig.MdtrtareaAdmvs == "421300" {
  7676. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7677. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7678. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7679. resp3, requestErr3 := http.Get(api3)
  7680. if requestErr3 != nil {
  7681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7682. return
  7683. }
  7684. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7685. if ioErr3 != nil {
  7686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7688. return
  7689. }
  7690. var respJSON3 map[string]interface{}
  7691. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7694. return
  7695. }
  7696. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7697. userJSONBytes3, _ := json.Marshal(respJSON3)
  7698. fmt.Println("log")
  7699. fmt.Println(string(userJSONBytes3))
  7700. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7701. utils.ErrorLog("解析失败:%v", err)
  7702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7703. return
  7704. }
  7705. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7706. var api3 string
  7707. if miConfig.MdtrtareaAdmvs == "320921" {
  7708. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7709. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7710. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7711. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7712. } else {
  7713. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7714. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7715. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7716. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7717. }
  7718. resp3, requestErr3 := http.Get(api3)
  7719. if requestErr3 != nil {
  7720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7721. return
  7722. }
  7723. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7724. if ioErr3 != nil {
  7725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7727. return
  7728. }
  7729. var respJSON3 map[string]interface{}
  7730. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7733. return
  7734. }
  7735. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7736. userJSONBytes3, _ := json.Marshal(respJSON3)
  7737. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7738. utils.ErrorLog("解析失败:%v", err)
  7739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7740. return
  7741. }
  7742. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7743. res.Output = resSixteen10265.Output
  7744. res.ErrMsg = resSixteen10265.ErrMsg
  7745. res.Cainfo = resSixteen10265.Cainfo
  7746. res.WarnMsg = resSixteen10265.WarnMsg
  7747. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7748. res.Infcode = infocode
  7749. } else {
  7750. if miConfig.Code == "H15049901371" {
  7751. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7752. var dat map[string]interface{}
  7753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7754. fmt.Println(dat)
  7755. } else {
  7756. fmt.Println(err)
  7757. }
  7758. saveLog(result, src_resquest, "2208", "退费")
  7759. userJSONBytes, _ := json.Marshal(dat)
  7760. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7761. utils.ErrorLog("解析失败:%v", err)
  7762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7763. return
  7764. }
  7765. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7766. res.Output = resSixteen10265.Output
  7767. res.ErrMsg = resSixteen10265.ErrMsg
  7768. res.Cainfo = resSixteen10265.Cainfo
  7769. res.WarnMsg = resSixteen10265.WarnMsg
  7770. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7771. res.Infcode = infocode
  7772. } else {
  7773. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7774. var dat map[string]interface{}
  7775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7776. fmt.Println(dat)
  7777. } else {
  7778. fmt.Println(err)
  7779. }
  7780. saveLog(result, src_resquest, "2208", "退费")
  7781. userJSONBytes, _ := json.Marshal(dat)
  7782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7783. utils.ErrorLog("解析失败:%v", err)
  7784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. return
  7786. }
  7787. }
  7788. }
  7789. if res.Infcode == 0 {
  7790. var res2 ResultSix
  7791. var resSix10265 ResultSix10265
  7792. if miConfig.MdtrtareaAdmvs == "421300" {
  7793. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7794. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7795. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7796. resp3, requestErr3 := http.Get(api3)
  7797. if requestErr3 != nil {
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7802. if ioErr3 != nil {
  7803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7805. return
  7806. }
  7807. var respJSON3 map[string]interface{}
  7808. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7811. return
  7812. }
  7813. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7814. userJSONBytes3, _ := json.Marshal(respJSON3)
  7815. fmt.Println("log")
  7816. fmt.Println(string(userJSONBytes3))
  7817. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7818. utils.ErrorLog("解析失败:%v", err)
  7819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7820. return
  7821. }
  7822. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7823. var api3 string
  7824. if miConfig.MdtrtareaAdmvs == "320921" {
  7825. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7826. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7827. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7828. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7829. } else {
  7830. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7831. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7832. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7833. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7834. }
  7835. resp3, requestErr3 := http.Get(api3)
  7836. if requestErr3 != nil {
  7837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7838. return
  7839. }
  7840. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7841. if ioErr3 != nil {
  7842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7844. return
  7845. }
  7846. var respJSON3 map[string]interface{}
  7847. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7850. return
  7851. }
  7852. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7853. userJSONBytes3, _ := json.Marshal(respJSON3)
  7854. fmt.Println("log")
  7855. fmt.Println(string(userJSONBytes3))
  7856. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7857. utils.ErrorLog("解析失败:%v", err)
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7859. return
  7860. }
  7861. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7862. res2.Output = resSix10265.Output
  7863. res2.ErrMsg = resSix10265.ErrMsg
  7864. res2.Cainfo = resSix10265.Cainfo
  7865. res2.WarnMsg = resSix10265.WarnMsg
  7866. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7867. res2.Infcode = infocode
  7868. } else {
  7869. if miConfig.Code == "H15049901371" {
  7870. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7871. var dat map[string]interface{}
  7872. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7873. fmt.Println(dat)
  7874. } else {
  7875. fmt.Println(err)
  7876. }
  7877. saveLog(result2, src_request, "2205", "撤销明细")
  7878. userJSONBytes, _ := json.Marshal(dat)
  7879. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7880. utils.ErrorLog("解析失败:%v", err)
  7881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7882. return
  7883. }
  7884. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7885. res2.Output = resSix10265.Output
  7886. res2.ErrMsg = resSix10265.ErrMsg
  7887. res2.Cainfo = resSix10265.Cainfo
  7888. res2.WarnMsg = resSix10265.WarnMsg
  7889. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7890. res2.Infcode = infocode
  7891. } else {
  7892. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7893. var dat map[string]interface{}
  7894. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7895. fmt.Println(dat)
  7896. } else {
  7897. fmt.Println(err)
  7898. }
  7899. saveLog(result2, src_request, "2205", "撤销明细")
  7900. userJSONBytes, _ := json.Marshal(dat)
  7901. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7902. utils.ErrorLog("解析失败:%v", err)
  7903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7904. return
  7905. }
  7906. }
  7907. }
  7908. if res2.Infcode == 0 {
  7909. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7910. if err == nil {
  7911. //当押金不为零时产生退费记录
  7912. if order.Decimal != 0 {
  7913. tmp := strconv.FormatInt(order.ID, 10)
  7914. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7915. if err != nil {
  7916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7917. return
  7918. }
  7919. }
  7920. c.ServeSuccessJSON(map[string]interface{}{
  7921. "msg": "退费成功",
  7922. })
  7923. } else {
  7924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7925. return
  7926. }
  7927. } else {
  7928. c.ServeSuccessJSON(map[string]interface{}{
  7929. "code": -10,
  7930. "msg": res2.ErrMsg,
  7931. })
  7932. }
  7933. } else {
  7934. c.ServeSuccessJSON(map[string]interface{}{
  7935. "code": -10,
  7936. "msg": res.ErrMsg,
  7937. })
  7938. }
  7939. }
  7940. }
  7941. func (c *HisApiController) RefundNumber() {
  7942. record_time := c.GetString("record_time")
  7943. //patient_id, _ := c.GetInt64("patient_id")
  7944. admin_user_id, _ := c.GetInt64("admin_user_id")
  7945. his_patient_id, _ := c.GetInt64("id")
  7946. timeLayout := "2006-01-02"
  7947. loc, _ := time.LoadLocation("Local")
  7948. adminUser := c.GetAdminUserInfo()
  7949. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7950. fmt.Println(err)
  7951. if err != nil {
  7952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7953. return
  7954. }
  7955. recordDateTime := theTime.Unix()
  7956. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7957. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7958. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7959. //order, _ := service.GetHisOrderByID(order_id)
  7960. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7961. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7962. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7963. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7964. if count > 0 {
  7965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7966. return
  7967. }
  7968. if config.IsOpen == 1 { //对接了医保,走医保流程
  7969. var res2 ResultSix
  7970. var resSix10265 ResultSix10265
  7971. if miConfig.MdtrtareaAdmvs == "421300" {
  7972. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7973. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7974. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7975. resp3, requestErr3 := http.Get(api3)
  7976. if requestErr3 != nil {
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7981. if ioErr3 != nil {
  7982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7984. return
  7985. }
  7986. var respJSON3 map[string]interface{}
  7987. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7990. return
  7991. }
  7992. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7993. userJSONBytes3, _ := json.Marshal(respJSON3)
  7994. fmt.Println("log")
  7995. fmt.Println(string(userJSONBytes3))
  7996. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7997. utils.ErrorLog("解析失败:%v", err)
  7998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7999. return
  8000. }
  8001. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8002. var api3 string
  8003. if miConfig.MdtrtareaAdmvs == "320921" {
  8004. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8005. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8006. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8007. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8008. } else {
  8009. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8010. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8011. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8012. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8013. }
  8014. resp3, requestErr3 := http.Get(api3)
  8015. if requestErr3 != nil {
  8016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8017. return
  8018. }
  8019. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8020. if ioErr3 != nil {
  8021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8023. return
  8024. }
  8025. var respJSON3 map[string]interface{}
  8026. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8029. return
  8030. }
  8031. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8032. userJSONBytes3, _ := json.Marshal(respJSON3)
  8033. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8034. utils.ErrorLog("解析失败:%v", err)
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8036. return
  8037. }
  8038. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8039. res2.Output = resSix10265.Output
  8040. res2.ErrMsg = resSix10265.ErrMsg
  8041. res2.Cainfo = resSix10265.Cainfo
  8042. res2.WarnMsg = resSix10265.WarnMsg
  8043. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8044. res2.Infcode = infocode
  8045. } else {
  8046. var api3 string
  8047. if miConfig.Code == "H15049901371" {
  8048. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8049. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8050. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8051. } else {
  8052. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8053. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8054. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8055. }
  8056. resp3, requestErr3 := http.Get(api3)
  8057. if requestErr3 != nil {
  8058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8059. return
  8060. }
  8061. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8062. if ioErr3 != nil {
  8063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8065. return
  8066. }
  8067. var respJSON3 map[string]interface{}
  8068. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8071. return
  8072. }
  8073. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8074. userJSONBytes3, _ := json.Marshal(respJSON3)
  8075. if miConfig.Code == "H15049901371" {
  8076. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8077. utils.ErrorLog("解析失败:%v", err)
  8078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8079. return
  8080. }
  8081. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8082. res2.Output = resSix10265.Output
  8083. res2.ErrMsg = resSix10265.ErrMsg
  8084. res2.Cainfo = resSix10265.Cainfo
  8085. res2.WarnMsg = resSix10265.WarnMsg
  8086. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8087. res2.Infcode = infocode
  8088. } else {
  8089. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8090. utils.ErrorLog("解析失败:%v", err)
  8091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8092. return
  8093. }
  8094. }
  8095. }
  8096. if res2.Infcode == 0 {
  8097. if err == nil {
  8098. c.ServeSuccessJSON(map[string]interface{}{
  8099. "msg": "退号成功",
  8100. })
  8101. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8102. } else {
  8103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8104. return
  8105. }
  8106. } else {
  8107. c.ServeSuccessJSON(map[string]interface{}{
  8108. "code": -10,
  8109. "msg": res2.ErrMsg,
  8110. })
  8111. }
  8112. } else {
  8113. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8114. //if err == nil {
  8115. // c.ServeSuccessJSON(map[string]interface{}{
  8116. // "msg": "退费成功",
  8117. // })
  8118. //} else {
  8119. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8120. // return
  8121. //}
  8122. }
  8123. }
  8124. func (c *HisApiController) RefundDetail() {
  8125. order_id, _ := c.GetInt64("order_id")
  8126. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8127. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8128. number := c.GetString("number")
  8129. record_time := c.GetString("record_time")
  8130. patient_id, _ := c.GetInt64("patient_id")
  8131. //med_type, _ := c.GetInt64("med_type")
  8132. timeLayout := "2006-01-02"
  8133. loc, _ := time.LoadLocation("Local")
  8134. adminUser := c.GetAdminUserInfo()
  8135. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8136. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8137. fmt.Println(err)
  8138. if err != nil {
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8140. return
  8141. }
  8142. recordDateTime := theTime.Unix()
  8143. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8144. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8145. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8146. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8147. var order models.HisOrder
  8148. order, _ = service.GetHisOrderByID(order_id)
  8149. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8150. if config.IsOpen == 1 { //对接了医保,走医保流程
  8151. var res2 ResultSix
  8152. if miConfig.MdtrtareaAdmvs == "421300" {
  8153. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8154. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8155. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8156. resp3, requestErr3 := http.Get(api3)
  8157. if requestErr3 != nil {
  8158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8159. return
  8160. }
  8161. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8162. if ioErr3 != nil {
  8163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8165. return
  8166. }
  8167. var respJSON3 map[string]interface{}
  8168. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8171. return
  8172. }
  8173. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8174. userJSONBytes3, _ := json.Marshal(respJSON3)
  8175. fmt.Println("log")
  8176. fmt.Println(string(userJSONBytes3))
  8177. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8178. utils.ErrorLog("解析失败:%v", err)
  8179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8180. return
  8181. }
  8182. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8183. if err == nil {
  8184. c.ServeSuccessJSON(map[string]interface{}{
  8185. "msg": "撤销明细成功",
  8186. })
  8187. return
  8188. } else {
  8189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8190. return
  8191. }
  8192. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8193. var resSix10265 ResultSix10265
  8194. var api3 string
  8195. if miConfig.MdtrtareaAdmvs == "320921" {
  8196. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8197. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8198. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8199. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8200. } else {
  8201. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8202. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8203. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8204. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8205. }
  8206. resp3, requestErr3 := http.Get(api3)
  8207. if requestErr3 != nil {
  8208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8209. return
  8210. }
  8211. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8212. if ioErr3 != nil {
  8213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. var respJSON3 map[string]interface{}
  8218. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8221. return
  8222. }
  8223. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8224. userJSONBytes3, _ := json.Marshal(respJSON3)
  8225. fmt.Println("log")
  8226. fmt.Println(string(userJSONBytes3))
  8227. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8228. utils.ErrorLog("解析失败:%v", err)
  8229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8230. return
  8231. }
  8232. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8233. res2.Output = resSix10265.Output
  8234. res2.ErrMsg = resSix10265.ErrMsg
  8235. res2.Cainfo = resSix10265.Cainfo
  8236. res2.WarnMsg = resSix10265.WarnMsg
  8237. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8238. res2.Infcode = infocode
  8239. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8240. if err == nil {
  8241. c.ServeSuccessJSON(map[string]interface{}{
  8242. "msg": "撤销明细成功",
  8243. })
  8244. return
  8245. } else {
  8246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8247. return
  8248. }
  8249. } else {
  8250. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8251. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8252. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8253. resp2, requestErr2 := http.Get(api2)
  8254. if requestErr2 != nil {
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8256. return
  8257. }
  8258. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8259. if ioErr2 != nil {
  8260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8262. return
  8263. }
  8264. var respJSON2 map[string]interface{}
  8265. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8268. return
  8269. }
  8270. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8271. if err == nil {
  8272. c.ServeSuccessJSON(map[string]interface{}{
  8273. "msg": "撤销明细成功",
  8274. })
  8275. return
  8276. } else {
  8277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8278. return
  8279. }
  8280. }
  8281. } else {
  8282. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8283. if err == nil {
  8284. c.ServeSuccessJSON(map[string]interface{}{
  8285. "msg": "退费成功",
  8286. })
  8287. } else {
  8288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8289. return
  8290. }
  8291. }
  8292. }
  8293. //对账
  8294. func (c *HisApiController) GetCheckAccount() {
  8295. start_time := c.GetString("start_time")
  8296. end_time := c.GetString("end_time")
  8297. insutype := c.GetString("insutype")
  8298. clr_type := c.GetString("clr_type")
  8299. clr_org := c.GetString("clr_optins")
  8300. admin_user_id, _ := c.GetInt64("admin_user_id")
  8301. adminUser := c.GetAdminUserInfo()
  8302. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8303. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8304. if len(clr_org) == 0 {
  8305. clr_org = miConfig.MdtrtareaAdmvs
  8306. }
  8307. timeLayout := "2006-01-02"
  8308. loc, _ := time.LoadLocation("Local")
  8309. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8310. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8311. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8312. fixmedins_setl_cnt := int64(len(orders))
  8313. var medfee_sumamt float64
  8314. var acct_pay float64
  8315. var fund_pay_sumamt float64
  8316. for _, item := range orders {
  8317. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8318. acct_pay = acct_pay + item.AcctPay
  8319. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8320. }
  8321. var user_name string
  8322. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8323. if role.ID == 0 {
  8324. user_name = "xxx"
  8325. } else {
  8326. user_name = role.UserName
  8327. }
  8328. var res ResultEight
  8329. var res10188 ResultEightFor10188
  8330. if config.IsOpen == 1 {
  8331. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8332. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8333. "insutype=" + insutype +
  8334. "&clr_type=" + clr_type +
  8335. "&setl_optins=" + clr_org +
  8336. "&stmt_begndate=" + start_time +
  8337. "&stm_enddate=" + end_time +
  8338. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8339. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8340. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8341. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8342. "&fixmedins_code=" + miConfig.Code +
  8343. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8344. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8345. "&secret_key=" + miConfig.SecretKey +
  8346. "&org_name=" + miConfig.OrgName +
  8347. "&doctor=" + user_name +
  8348. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8349. fmt.Println(api)
  8350. resp, requestErr := http.Get(api)
  8351. if requestErr != nil {
  8352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8353. return
  8354. }
  8355. body, ioErr := ioutil.ReadAll(resp.Body)
  8356. fmt.Println(body)
  8357. if ioErr != nil {
  8358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8360. return
  8361. }
  8362. var respJSON map[string]interface{}
  8363. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8366. return
  8367. }
  8368. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8369. userJSONBytes, _ := json.Marshal(respJSON)
  8370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8371. utils.ErrorLog("解析失败:%v", err)
  8372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8373. return
  8374. }
  8375. res.InfRefmsgid = res10188.InfRefmsgid
  8376. res.Output = res10188.Output
  8377. res.ErrMsg = res10188.ErrMsg
  8378. res.Cainfo = res10188.Cainfo
  8379. res.WarnMsg = res10188.WarnMsg
  8380. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8381. res.Infcode = infocode
  8382. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8383. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8384. "insutype=" + insutype +
  8385. "&clr_type=" + clr_type +
  8386. "&setl_optins=" + clr_org +
  8387. "&stmt_begndate=" + start_time +
  8388. "&stm_enddate=" + end_time +
  8389. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8390. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8391. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8392. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8393. "&fixmedins_code=" + miConfig.Code +
  8394. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8395. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8396. "&secret_key=" + miConfig.SecretKey +
  8397. "&org_name=" + miConfig.OrgName +
  8398. "&doctor=" + user_name
  8399. resp, requestErr := http.Get(api)
  8400. if requestErr != nil {
  8401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8402. return
  8403. }
  8404. body, ioErr := ioutil.ReadAll(resp.Body)
  8405. if ioErr != nil {
  8406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8408. return
  8409. }
  8410. var respJSON map[string]interface{}
  8411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8414. return
  8415. }
  8416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8417. result, _ := json.Marshal(respJSON)
  8418. fmt.Println("log")
  8419. fmt.Println(string(result))
  8420. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8421. utils.ErrorLog("解析失败:%v", err)
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. res.InfRefmsgid = res10188.InfRefmsgid
  8426. res.Output = res10188.Output
  8427. res.ErrMsg = res10188.ErrMsg
  8428. res.Cainfo = res10188.Cainfo
  8429. res.WarnMsg = res10188.WarnMsg
  8430. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8431. res.Infcode = infocode
  8432. } else {
  8433. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8434. "insutype=" + insutype +
  8435. "&clr_type=" + clr_type +
  8436. "&setl_optins=" + clr_org +
  8437. "&stmt_begndate=" + start_time +
  8438. "&stm_enddate=" + end_time +
  8439. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8440. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8441. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8442. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8443. "&fixmedins_code=" + miConfig.Code +
  8444. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8445. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8446. "&secret_key=" + miConfig.SecretKey +
  8447. "&org_name=" + miConfig.OrgName +
  8448. "&doctor=" + user_name
  8449. fmt.Println(api)
  8450. resp, requestErr := http.Get(api)
  8451. if requestErr != nil {
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8453. return
  8454. }
  8455. body, ioErr := ioutil.ReadAll(resp.Body)
  8456. fmt.Println(body)
  8457. if ioErr != nil {
  8458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8460. return
  8461. }
  8462. var respJSON map[string]interface{}
  8463. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8466. return
  8467. }
  8468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8469. userJSONBytes, _ := json.Marshal(respJSON)
  8470. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8471. utils.ErrorLog("解析失败:%v", err)
  8472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8473. return
  8474. }
  8475. }
  8476. if res.Infcode == 0 {
  8477. if res.Output.Stmtinfo.StmtRslt == "0" {
  8478. micc := &models.MedicalInsuranceCostCompare{
  8479. StartTime: startime.Unix(),
  8480. EndTime: endtime.Unix(),
  8481. Insutype: insutype,
  8482. CheckType: 1,
  8483. Num: fixmedins_setl_cnt,
  8484. Mtime: time.Now().Unix(),
  8485. Status: 1,
  8486. UserOrgId: adminUser.CurrentOrgId,
  8487. CostTotal: medfee_sumamt,
  8488. FuncTotal: fund_pay_sumamt,
  8489. PsnPay: acct_pay,
  8490. Creator: admin_user_id,
  8491. Ctime: time.Now().Unix(),
  8492. ClrType: clr_type,
  8493. }
  8494. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8495. if err == nil {
  8496. c.ServeSuccessJSON(map[string]interface{}{
  8497. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8498. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8499. })
  8500. } else {
  8501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8502. }
  8503. } else {
  8504. c.ServeSuccessJSON(map[string]interface{}{
  8505. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8506. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8507. })
  8508. }
  8509. } else {
  8510. c.ServeSuccessJSON(map[string]interface{}{
  8511. "code": -10,
  8512. "msg": res.ErrMsg,
  8513. })
  8514. }
  8515. }
  8516. }
  8517. func (c *HisApiController) Check310() {
  8518. adminUser := c.GetAdminUserInfo()
  8519. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8520. var user_name string
  8521. user_name = "高慧裕"
  8522. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8523. "insutype=" + "310" +
  8524. "&clr_type=" + "" +
  8525. "&setl_optins=" + "441202" +
  8526. "&stmt_begndate=" + "2022-03-01" +
  8527. "&stm_enddate=" + "2022-03-31" +
  8528. "&medfee_sumamt=" + "194930.12" +
  8529. "&fund_pay_sumamt=" + "188741.46" +
  8530. "&acct_pay=" + "0" +
  8531. "&fixmedins_setl_cnt=" + "452" +
  8532. "&fixmedins_code=" + miConfig.Code +
  8533. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8534. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8535. "&secret_key=" + miConfig.SecretKey +
  8536. "&org_name=" + miConfig.OrgName +
  8537. "&doctor=" + user_name
  8538. fmt.Println(api)
  8539. resp, requestErr := http.Get(api)
  8540. if requestErr != nil {
  8541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8542. return
  8543. }
  8544. body, ioErr := ioutil.ReadAll(resp.Body)
  8545. fmt.Println(body)
  8546. if ioErr != nil {
  8547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8549. return
  8550. }
  8551. var respJSON map[string]interface{}
  8552. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8555. return
  8556. }
  8557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8558. userJSONBytes, _ := json.Marshal(respJSON)
  8559. var res ResultEight
  8560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8561. utils.ErrorLog("解析失败:%v", err)
  8562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8563. return
  8564. }
  8565. }
  8566. func (c *HisApiController) Check390() {
  8567. adminUser := c.GetAdminUserInfo()
  8568. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8569. var user_name string
  8570. user_name = "高慧裕"
  8571. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8572. "insutype=" + "390" +
  8573. "&clr_type=" + "" +
  8574. "&setl_optins=" + "441202" +
  8575. "&stmt_begndate=" + "2022-03-01" +
  8576. "&stm_enddate=" + "2022-03-31" +
  8577. "&medfee_sumamt=" + "1068448.89" +
  8578. "&fund_pay_sumamt=" + "1014677.62" +
  8579. "&acct_pay=" + "0" +
  8580. "&fixmedins_setl_cnt=" + "1950" +
  8581. "&fixmedins_code=" + miConfig.Code +
  8582. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8583. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8584. "&secret_key=" + miConfig.SecretKey +
  8585. "&org_name=" + miConfig.OrgName +
  8586. "&doctor=" + user_name
  8587. fmt.Println(api)
  8588. resp, requestErr := http.Get(api)
  8589. if requestErr != nil {
  8590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8591. return
  8592. }
  8593. body, ioErr := ioutil.ReadAll(resp.Body)
  8594. fmt.Println(body)
  8595. if ioErr != nil {
  8596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8598. return
  8599. }
  8600. var respJSON map[string]interface{}
  8601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8604. return
  8605. }
  8606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8607. userJSONBytes, _ := json.Marshal(respJSON)
  8608. var res ResultEight
  8609. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8610. utils.ErrorLog("解析失败:%v", err)
  8611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8612. return
  8613. }
  8614. }
  8615. //对账明细
  8616. func (c *HisApiController) GetCheckDetailAccount() {
  8617. start_time := c.GetString("start_time")
  8618. end_time := c.GetString("end_time")
  8619. admin_user_id, _ := c.GetInt64("admin_user_id")
  8620. adminUser := c.GetAdminUserInfo()
  8621. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8622. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8623. timeLayout := "2006-01-02"
  8624. loc, _ := time.LoadLocation("Local")
  8625. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8626. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8627. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8628. rand.Seed(time.Now().UnixNano())
  8629. num := rand.Intn(30000)
  8630. Mkdir(miConfig.OrgName)
  8631. file := strconv.FormatInt(int64(num), 10)
  8632. file_name := file + ".txt"
  8633. zip_name := file + ".zip"
  8634. zip_path := miConfig.OrgName + "/" + zip_name
  8635. file_path := miConfig.OrgName + "/" + file_name
  8636. decimal.DivisionPrecision = 2
  8637. var medfee_sumamt float64
  8638. var psn_cash_pay float64
  8639. var fund_pay_sumamt float64
  8640. fixmedins_setl_cnt := int64(len(orders))
  8641. for _, item := range orders {
  8642. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8643. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8644. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8645. }
  8646. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8647. defer f.Close()
  8648. if err != nil {
  8649. fmt.Println(err.Error())
  8650. } else {
  8651. for _, item := range orders {
  8652. var refd_setl_flag string
  8653. if item.OrderStatus == 2 {
  8654. refd_setl_flag = "0"
  8655. var str string
  8656. str = item.SetlId + " " +
  8657. item.MdtrtId + " " +
  8658. item.PsnNo + " " +
  8659. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8660. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8661. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8662. _, err = f.Write([]byte(str))
  8663. }
  8664. if item.OrderStatus == 3 {
  8665. var str string
  8666. str = item.SetlId + " " +
  8667. item.MdtrtId + " " +
  8668. item.PsnNo + " " +
  8669. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8670. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8671. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8672. _, err = f.Write([]byte(str))
  8673. var str2 string
  8674. str2 = item.SetlId + " " +
  8675. item.MdtrtId + " " +
  8676. item.PsnNo + " " +
  8677. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8678. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8679. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8680. _, err = f.Write([]byte(str2))
  8681. }
  8682. }
  8683. }
  8684. Zip(file_path, zip_path)
  8685. fmt.Println(ReadFile(zip_path))
  8686. fmt.Println(string(ReadFile(zip_path)))
  8687. if config.IsOpen == 1 {
  8688. var user_name string
  8689. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8690. if role.ID == 0 {
  8691. user_name = "管理员"
  8692. } else {
  8693. user_name = role.UserName
  8694. }
  8695. baseParams := models.BaseParams{
  8696. SecretKey: miConfig.SecretKey,
  8697. FixmedinsCode: miConfig.Code,
  8698. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8699. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8700. OrgName: miConfig.OrgName,
  8701. Doctor: user_name,
  8702. }
  8703. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8704. var dat map[string]interface{}
  8705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8706. fmt.Println(dat)
  8707. } else {
  8708. fmt.Println(err)
  8709. }
  8710. userJSONBytes, _ := json.Marshal(dat)
  8711. var res ResultNine
  8712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8713. utils.ErrorLog("解析失败:%v", err)
  8714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8715. return
  8716. }
  8717. if res.Infcode == 0 {
  8718. fileNo := res.Output.FileQuryNo
  8719. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8720. "file_qury_no=" + fileNo +
  8721. "&setl_optins=" + "定点医保中心" +
  8722. "&stmt_begndate=" + start_time +
  8723. "&stm_enddate=" + end_time +
  8724. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8725. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8726. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8727. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8728. "&fixmedins_code=" + miConfig.Code +
  8729. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8730. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8731. "&secret_key=" + miConfig.SecretKey +
  8732. "&org_name=" + miConfig.OrgName +
  8733. "&doctor=" + user_name
  8734. resp, requestErr := http.Get(api)
  8735. if requestErr != nil {
  8736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8737. return
  8738. }
  8739. body, ioErr := ioutil.ReadAll(resp.Body)
  8740. if ioErr != nil {
  8741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8743. return
  8744. }
  8745. var respJSON map[string]interface{}
  8746. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8749. return
  8750. }
  8751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8752. userJSONBytes, _ := json.Marshal(respJSON)
  8753. var res ResultTen
  8754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8755. utils.ErrorLog("解析失败:%v", err)
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. if res.Infcode == 0 {
  8760. service.Gdyb9102(baseParams, zip_name, fileNo)
  8761. micc := &models.MedicalInsuranceCostCompare{
  8762. StartTime: startime.Unix(),
  8763. EndTime: endtime.Unix(),
  8764. Insutype: "0",
  8765. CheckType: 2,
  8766. Num: fixmedins_setl_cnt,
  8767. Mtime: time.Now().Unix(),
  8768. Status: 1,
  8769. UserOrgId: adminUser.CurrentOrgId,
  8770. CostTotal: medfee_sumamt,
  8771. FuncTotal: fund_pay_sumamt,
  8772. PsnPay: psn_cash_pay,
  8773. Creator: admin_user_id,
  8774. Ctime: time.Now().Unix(),
  8775. }
  8776. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8777. c.ServeSuccessJSON(map[string]interface{}{
  8778. "msg": "明细对账成功",
  8779. })
  8780. }
  8781. } else {
  8782. }
  8783. }
  8784. }
  8785. type CustomOrderInfo struct {
  8786. Name string
  8787. Spec string
  8788. Unit string
  8789. Count float64
  8790. Price float64
  8791. Total float64
  8792. }
  8793. func (c *HisApiController) GetSettleAccounts() {
  8794. //id, _ := c.GetInt64("id")
  8795. //record_time := c.GetString("record_time")
  8796. order_id, _ := c.GetInt64("order_id")
  8797. admin_user_id, _ := c.GetInt64("admin_user_id")
  8798. //timeLayout := "2006-01-02"
  8799. //loc, _ := time.LoadLocation("Local")
  8800. //
  8801. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8802. //if err != nil {
  8803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8804. // return
  8805. //}
  8806. //recordDateTime := theTime.Unix()
  8807. adminUser := c.GetAdminUserInfo()
  8808. order, _ := service.GetHisOrderByID(order_id)
  8809. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8810. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8811. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8812. orderInfos = append(orderInfos, orderInfos_two...)
  8813. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8814. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8815. var diagnosis_ids []string
  8816. if his.ID > 0 {
  8817. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8818. } else {
  8819. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8820. }
  8821. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8822. var dia_config []*models.HisXtDiagnoseConfig
  8823. var name string
  8824. for _, item := range diagnosis_ids {
  8825. id, _ := strconv.ParseInt(item, 10, 64)
  8826. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8827. dia_config = append(dia_config, &diagnosisConfig)
  8828. if len(name) == 0 {
  8829. name = diagnosisConfig.ClassName
  8830. } else {
  8831. name = name + "," + diagnosisConfig.ClassName
  8832. }
  8833. }
  8834. var bedCostTotal float64 = 0 //床位总费
  8835. var bedCostSelfTotal float64 = 0 //床位自费
  8836. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8837. var operationCostTotal float64 = 0 //手术费
  8838. var operationCostSelfTotal float64 = 0 //手术费
  8839. var operationCostPartSelfTotal float64 = 0 //手术费
  8840. var otherCostTotal float64 = 0 //其他费用
  8841. var otherCostSelfTotal float64 = 0 //其他费用
  8842. var otherCostPartSelfTotal float64 = 0 //其他费用
  8843. var materialCostTotal float64 = 0 //材料费
  8844. var materialCostSelfTotal float64 = 0 //材料费
  8845. var materialCostPartSelfTotal float64 = 0 //材料费
  8846. var westernMedicineCostTotal float64 = 0 //西药费
  8847. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8848. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8849. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8850. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8851. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8852. var checkCostTotal float64 = 0 //检查费
  8853. var checkCostSelfTotal float64 = 0 //检查费
  8854. var checkCostPartSelfTotal float64 = 0 //检查费
  8855. var laboratoryCostTotal float64 = 0 //化验费
  8856. var laboratoryCostSelfTotal float64 = 0 //化验费
  8857. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8858. var treatCostTotal float64 = 0 //治疗费用
  8859. var treatCostSelfTotal float64 = 0 //治疗费用
  8860. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8861. decimal.DivisionPrecision = 2
  8862. for _, item := range orderInfos {
  8863. if item.MedChrgitmType == "01" { //床位费
  8864. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8865. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8866. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8867. }
  8868. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8869. if item.MedChrgitmType == "03" { //检查费
  8870. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8871. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8872. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8873. }
  8874. } else {
  8875. if item.MedChrgitmType == "03" { //检查费
  8876. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8877. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8878. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8879. }
  8880. }
  8881. if item.MedChrgitmType == "04" { //化验费
  8882. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8883. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8884. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8885. }
  8886. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8887. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8888. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8889. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8890. }
  8891. if item.MedChrgitmType == "06" { //手术费
  8892. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8893. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8894. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8895. }
  8896. if item.MedChrgitmType == "08" { //材料费
  8897. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8898. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8899. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8900. }
  8901. if item.MedChrgitmType == "09" { //西药费
  8902. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8903. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8904. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8905. }
  8906. if item.MedChrgitmType == "11" { //中成费
  8907. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8908. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8909. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8910. }
  8911. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8912. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8913. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8914. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8915. }
  8916. }
  8917. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8918. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8919. var user_name string
  8920. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8921. if role.ID == 0 {
  8922. user_name = "管理员"
  8923. } else {
  8924. user_name = role.UserName
  8925. }
  8926. baseParams := models.BaseParams{
  8927. SecretKey: miConfig.SecretKey,
  8928. FixmedinsCode: miConfig.Code,
  8929. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8930. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8931. OrgName: miConfig.OrgName,
  8932. Doctor: user_name,
  8933. }
  8934. businessParams := models.BusinessParams{
  8935. PsnNo: order.PsnNo,
  8936. MdtrtId: order.MdtrtId,
  8937. SetlId: order.SetlId,
  8938. }
  8939. var res ResultEleven
  8940. var resEleven10265 ResultEleven10265
  8941. if config.IsOpen == 1 {
  8942. if miConfig.MdtrtareaAdmvs == "421300" {
  8943. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8944. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8945. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8946. resp, requestErr := http.Get(api)
  8947. if requestErr != nil {
  8948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8949. return
  8950. }
  8951. body, ioErr := ioutil.ReadAll(resp.Body)
  8952. if ioErr != nil {
  8953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8955. return
  8956. }
  8957. var respJSON map[string]interface{}
  8958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8961. return
  8962. }
  8963. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8964. result, _ := json.Marshal(respJSON)
  8965. fmt.Println("log")
  8966. fmt.Println(string(result))
  8967. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8968. utils.ErrorLog("解析失败:%v", err)
  8969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8970. return
  8971. }
  8972. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8973. var api string
  8974. if miConfig.MdtrtareaAdmvs == "320921" {
  8975. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8976. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8977. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8978. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8979. } else {
  8980. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8981. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8982. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8983. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8984. }
  8985. resp, requestErr := http.Get(api)
  8986. if requestErr != nil {
  8987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8988. return
  8989. }
  8990. body, ioErr := ioutil.ReadAll(resp.Body)
  8991. if ioErr != nil {
  8992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8994. return
  8995. }
  8996. var respJSON map[string]interface{}
  8997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9000. return
  9001. }
  9002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9003. result, _ := json.Marshal(respJSON)
  9004. fmt.Println("log")
  9005. fmt.Println(string(result))
  9006. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9007. utils.ErrorLog("解析失败:%v", err)
  9008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9009. return
  9010. }
  9011. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9012. res.Output = resEleven10265.Output
  9013. res.ErrMsg = resEleven10265.ErrMsg
  9014. res.Cainfo = resEleven10265.Cainfo
  9015. res.WarnMsg = resEleven10265.WarnMsg
  9016. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9017. res.Infcode = infocode
  9018. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9019. fmt.Println("~~~~~~~")
  9020. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9021. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9022. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9023. resp, requestErr := http.Get(api)
  9024. if requestErr != nil {
  9025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9026. return
  9027. }
  9028. body, ioErr := ioutil.ReadAll(resp.Body)
  9029. if ioErr != nil {
  9030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9032. return
  9033. }
  9034. var respJSON map[string]interface{}
  9035. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9038. return
  9039. }
  9040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9041. result, _ := json.Marshal(respJSON)
  9042. fmt.Println("log")
  9043. fmt.Println(string(result))
  9044. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9045. utils.ErrorLog("解析失败:%v", err)
  9046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9047. return
  9048. }
  9049. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9050. res.Output = resEleven10265.Output
  9051. res.ErrMsg = resEleven10265.ErrMsg
  9052. res.Cainfo = resEleven10265.Cainfo
  9053. res.WarnMsg = resEleven10265.WarnMsg
  9054. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9055. res.Infcode = infocode
  9056. } else {
  9057. result := service.Gdyb5203(baseParams, businessParams)
  9058. //service.Gdyb5204(baseParams, businessParams)
  9059. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9060. var dat map[string]interface{}
  9061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9062. fmt.Println(dat)
  9063. } else {
  9064. fmt.Println(err)
  9065. }
  9066. userJSONBytes, _ := json.Marshal(dat)
  9067. if miConfig.Code == "H15049901371" {
  9068. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9069. utils.ErrorLog("解析失败:%v", err)
  9070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9071. return
  9072. }
  9073. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9074. res.Output = resEleven10265.Output
  9075. res.ErrMsg = resEleven10265.ErrMsg
  9076. res.Cainfo = resEleven10265.Cainfo
  9077. res.WarnMsg = resEleven10265.WarnMsg
  9078. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9079. res.Infcode = infocode
  9080. } else {
  9081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9082. utils.ErrorLog("解析失败:%v", err)
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9084. return
  9085. }
  9086. }
  9087. }
  9088. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9089. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9090. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9091. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9092. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9093. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9094. var doctor_name string
  9095. if roles.ID == 0 {
  9096. doctor_name = "管理员"
  9097. } else {
  9098. doctor_name = roles.UserName
  9099. }
  9100. yiliao_leibie := ""
  9101. switch order.MedType {
  9102. case "11":
  9103. yiliao_leibie = "普通门诊"
  9104. break
  9105. case "12":
  9106. yiliao_leibie = "门诊挂号"
  9107. break
  9108. case "13":
  9109. yiliao_leibie = "急诊"
  9110. break
  9111. case "14":
  9112. yiliao_leibie = "门诊特殊病"
  9113. break
  9114. case "15":
  9115. yiliao_leibie = "门诊统筹"
  9116. break
  9117. case "16":
  9118. yiliao_leibie = "门诊慢性病"
  9119. break
  9120. case "21":
  9121. yiliao_leibie = "普通住院"
  9122. break
  9123. }
  9124. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9125. if res.Infcode == 0 {
  9126. c.ServeSuccessJSON(map[string]interface{}{
  9127. "diagnosis": name,
  9128. "order_infos": orderInfos,
  9129. "number": order.MdtrtId,
  9130. "date": order.SettleAccountsDate,
  9131. "charge_admin": charge_admin,
  9132. "printor_admin": printor_admin,
  9133. "info": res.Output.Setlinfo,
  9134. "order": order,
  9135. "bedCostTotal": bedCostTotal,
  9136. "bedCostSelfTotal": bedCostSelfTotal,
  9137. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9138. "operationCostTotal": operationCostTotal,
  9139. "operationCostSelfTotal": operationCostSelfTotal,
  9140. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9141. "otherCostTotal": otherCostTotal,
  9142. "otherCostSelfTotal": otherCostSelfTotal,
  9143. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9144. "materialCostTotal": materialCostTotal,
  9145. "materialCostSelfTotal": materialCostSelfTotal,
  9146. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9147. "westernMedicineCostTotal": westernMedicineCostTotal,
  9148. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9149. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9150. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9151. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9152. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9153. "checkCostTotal": checkCostTotal,
  9154. "checkCostSelfTotal": checkCostSelfTotal,
  9155. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9156. "laboratoryCostTotal": laboratoryCostTotal,
  9157. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9158. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9159. "treatCostTotal": treatCostTotal,
  9160. "treatCostSelfTotal": treatCostSelfTotal,
  9161. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9162. "doctor_info": doctor_info,
  9163. "doctor_code": adminRole_two.DoctorCode,
  9164. "doctor_name": doctor_name,
  9165. "health_card_no": order.PsnNo,
  9166. "department": departments.Name,
  9167. "yiliao_leibie": yiliao_leibie,
  9168. "after_money": order.AccountPrice,
  9169. "patient": patient,
  9170. "org_name": miConfig.OrgName,
  9171. "org_code": miConfig.Code,
  9172. "order_number": order.Number,
  9173. "his_hospital": his_hospital,
  9174. "his": his,
  9175. "dia_config": dia_config,
  9176. //"check_order_info": cus_slice,
  9177. })
  9178. }
  9179. }
  9180. }
  9181. func (c *HisApiController) CheckTreatment() {
  9182. patient_id, _ := c.GetInt64("patient_id")
  9183. id_card_no := c.GetString("id_card_no")
  9184. insutype := c.GetString("insutype")
  9185. med_type := c.GetString("med_type")
  9186. admin_user_id, _ := c.GetInt64("admin_user_id")
  9187. adminUser := c.GetAdminUserInfo()
  9188. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9189. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9190. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9191. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9192. if miConfig.MdtrtareaAdmvs == "421300" {
  9193. var res ResultTwo
  9194. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9195. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9196. "&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)
  9197. resp, requestErr := http.Get(api)
  9198. if requestErr != nil {
  9199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9200. return
  9201. }
  9202. body, ioErr := ioutil.ReadAll(resp.Body)
  9203. if ioErr != nil {
  9204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9206. return
  9207. }
  9208. var respJSON map[string]interface{}
  9209. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9212. return
  9213. }
  9214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9215. result, _ := json.Marshal(respJSON)
  9216. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9217. utils.ErrorLog("解析失败:%v", err)
  9218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9219. return
  9220. }
  9221. if res.Infcode == 0 {
  9222. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9223. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9224. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9225. resp, requestErr := http.Get(api)
  9226. if requestErr != nil {
  9227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9228. return
  9229. }
  9230. body, ioErr := ioutil.ReadAll(resp.Body)
  9231. if ioErr != nil {
  9232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9234. return
  9235. }
  9236. var respJSON map[string]interface{}
  9237. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9240. return
  9241. }
  9242. var res Result2001
  9243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9244. result2, _ := json.Marshal(respJSON)
  9245. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9246. utils.ErrorLog("解析失败:%v", err)
  9247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9248. return
  9249. }
  9250. if res.Infcode == 0 {
  9251. c.ServeSuccessJSON(map[string]interface{}{
  9252. "msg": res.Output.Trtinfo,
  9253. })
  9254. }
  9255. } else {
  9256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9257. return
  9258. }
  9259. } else {
  9260. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9261. var dat map[string]interface{}
  9262. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9263. fmt.Println(dat)
  9264. } else {
  9265. fmt.Println(err)
  9266. }
  9267. userJSONBytes, _ := json.Marshal(dat)
  9268. var res ResultTwo
  9269. var res10265 ResultTwo10265
  9270. if miConfig.Code == "H15049901371" {
  9271. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9272. utils.ErrorLog("解析失败:%v", err)
  9273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9274. return
  9275. }
  9276. res.ErrMsg = res10265.ErrMsg
  9277. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9278. res.Infcode = infocode
  9279. res.Output = res10265.Output
  9280. res.InfRefmsgid = res10265.InfRefmsgid
  9281. } else {
  9282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9283. utils.ErrorLog("解析失败:%v", err)
  9284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9285. return
  9286. }
  9287. }
  9288. var user_name string
  9289. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9290. if role.ID == 0 {
  9291. user_name = "xxx"
  9292. } else {
  9293. user_name = role.UserName
  9294. }
  9295. baseParams := models.BaseParams{
  9296. SecretKey: miConfig.SecretKey,
  9297. FixmedinsCode: miConfig.Code,
  9298. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9299. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9300. OrgName: miConfig.OrgName,
  9301. Doctor: user_name,
  9302. }
  9303. if config.IsOpen == 1 {
  9304. if miConfig.Code == "H15049901371" {
  9305. if med_type == "14" {
  9306. if insutype == "390" {
  9307. med_type = "9933"
  9308. } else if insutype == "310" {
  9309. med_type = "990502"
  9310. }
  9311. } else if med_type == "11" {
  9312. med_type = "11"
  9313. }
  9314. }
  9315. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9316. var dat map[string]interface{}
  9317. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9318. fmt.Println(dat)
  9319. } else {
  9320. fmt.Println(err)
  9321. }
  9322. var res Result2001
  9323. var res10265 Result2001Org10265
  9324. if miConfig.Code == "H15049901371" {
  9325. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9326. utils.ErrorLog("解析失败:%v", err)
  9327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9328. return
  9329. }
  9330. res.ErrMsg = res10265.ErrMsg
  9331. res.Output = res10265.Output
  9332. res.InfRefmsgid = res10265.InfRefmsgid
  9333. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9334. res.Infcode = infocode
  9335. } else {
  9336. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9337. utils.ErrorLog("解析失败:%v", err)
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9339. return
  9340. }
  9341. }
  9342. if res.Infcode == 0 {
  9343. c.ServeSuccessJSON(map[string]interface{}{
  9344. "msg": res.Output.Trtinfo,
  9345. })
  9346. }
  9347. }
  9348. }
  9349. }
  9350. //func (c *HisApiController) PutRecord() {
  9351. // id, _ := c.GetInt64("id")
  9352. // record_time := c.GetString("record_time")
  9353. // timeLayout := "2006-01-02"
  9354. // loc, _ := time.LoadLocation("Local")
  9355. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9356. // if err != nil {
  9357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9358. // return
  9359. // }
  9360. // recordDateTime := theTime.Unix()
  9361. //
  9362. // adminInfo := c.GetAdminUserInfo()
  9363. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9364. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9365. //
  9366. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9367. //
  9368. // fmt.Println(miConfig.SecretKey)
  9369. //
  9370. // if patient == nil {
  9371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9372. // return
  9373. // }
  9374. // if len(patient.IdCardNo) == 0 {
  9375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9376. // return
  9377. // }
  9378. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9379. // if config.IsOpen == 1 {
  9380. // 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
  9381. // resp, requestErr := http.Get(api)
  9382. // if requestErr != nil {
  9383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9384. // return
  9385. // }
  9386. // defer resp.Body.Close()
  9387. // body, ioErr := ioutil.ReadAll(resp.Body)
  9388. // if ioErr != nil {
  9389. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9390. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9391. // return
  9392. // }
  9393. // var respJSON map[string]interface{}
  9394. //
  9395. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9396. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9398. // return
  9399. // }
  9400. //
  9401. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9402. // userJSONBytes, _ := json.Marshal(userJSON)
  9403. // var res ResultTwo
  9404. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9405. // utils.ErrorLog("解析失败:%v", err)
  9406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9407. // return
  9408. // }
  9409. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9410. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9411. // infoStr := string(Iinfos)
  9412. // idetinfoStr := string(Idetinfos)
  9413. //
  9414. // if res.Infcode == 0 {
  9415. // his := models.VMHisPatient{
  9416. // Status: 1,
  9417. // Ctime: time.Now().Unix(),
  9418. // Mtime: time.Now().Unix(),
  9419. // PsnNo: res.Output.Baseinfo.PsnNo,
  9420. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9421. // Certno: res.Output.Baseinfo.Certno,
  9422. // PsnName: res.Output.Baseinfo.PsnName,
  9423. // Gend: res.Output.Baseinfo.Gend,
  9424. // Naty: res.Output.Baseinfo.Naty,
  9425. // Brdy: res.Output.Baseinfo.Brdy,
  9426. // Age: res.Output.Baseinfo.Age,
  9427. // Iinfo: infoStr,
  9428. // Idetinfo: idetinfoStr,
  9429. // PatientId: patient.ID,
  9430. // RecordDate: theTime.Unix(),
  9431. // UserOrgId: adminInfo.CurrentOrgId,
  9432. // AdminUserId: adminInfo.AdminUser.Id,
  9433. // IsReturn: 1,
  9434. // }
  9435. //
  9436. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9437. // //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")
  9438. // //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")
  9439. //
  9440. // //var dat map[string]interface{}
  9441. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9442. // // fmt.Println(dat)
  9443. // //} else {
  9444. // // fmt.Println(err)
  9445. // //}
  9446. //
  9447. // var dat2 map[string]interface{}
  9448. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9449. // fmt.Println(dat2)
  9450. // } else {
  9451. // fmt.Println(err)
  9452. // }
  9453. //
  9454. // } else {
  9455. // adminUser := c.GetAdminUserInfo()
  9456. // errlog := &models.HisOrderError{
  9457. // UserOrgId: adminUser.CurrentOrgId,
  9458. // Ctime: time.Now().Unix(),
  9459. // Mtime: time.Now().Unix(),
  9460. // ErrMsg: res.ErrMsg,
  9461. // Status: 1,
  9462. // PatientId: id,
  9463. // RecordTime: recordDateTime,
  9464. // Stage: 1,
  9465. // }
  9466. // service.CreateErrMsgLog(errlog)
  9467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9468. // return
  9469. // }
  9470. // }
  9471. //
  9472. //}
  9473. //func (c *HisApiController) GetUploadDiag() {
  9474. // id, _ := c.GetInt64("id")
  9475. // record_time := c.GetString("record_time")
  9476. //
  9477. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9478. // sick_type, _ := c.GetInt64("sick_type")
  9479. // reg_type, _ := c.GetInt64("reg_type")
  9480. //
  9481. // timeLayout := "2006-01-02"
  9482. // loc, _ := time.LoadLocation("Local")
  9483. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9484. // if err != nil {
  9485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9486. // return
  9487. // }
  9488. //
  9489. // var patientPrescription models.HisPrescriptionInfo
  9490. // recordDateTime := theTime.Unix()
  9491. // adminInfo := c.GetAdminUserInfo()
  9492. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9493. //
  9494. // if patientPrescription.ID == 0 {
  9495. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9496. // }
  9497. //
  9498. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9499. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9500. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9501. // sickConfig, _ := service.FindSickById(sick_type)
  9502. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9503. //
  9504. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9505. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9506. // "&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 +
  9507. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9508. // resp2, requestErr2 := http.Get(api2)
  9509. // if requestErr2 != nil {
  9510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9511. // return
  9512. // }
  9513. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9514. // if ioErr2 != nil {
  9515. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9517. // return
  9518. // }
  9519. // var respJSON2 map[string]interface{}
  9520. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9521. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9523. // return
  9524. // }
  9525. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9526. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9527. //
  9528. // var res2 ResultSix
  9529. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9530. // utils.ErrorLog("解析失败:%v", err)
  9531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9532. // return
  9533. // }
  9534. // if res2.Infcode != 0 {
  9535. // adminUser := c.GetAdminUserInfo()
  9536. // errlog := &models.HisOrderError{
  9537. // UserOrgId: adminUser.CurrentOrgId,
  9538. // Ctime: time.Now().Unix(),
  9539. // Mtime: time.Now().Unix(),
  9540. // ErrMsg: res2.ErrMsg,
  9541. // Status: 1,
  9542. // PatientId: id,
  9543. // RecordTime: recordDateTime,
  9544. // Stage: 3,
  9545. // }
  9546. // service.CreateErrMsgLog(errlog)
  9547. //
  9548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9549. // return
  9550. // }
  9551. //
  9552. // c.ServeSuccessJSON(map[string]interface{}{
  9553. // "msg": "上传成功",
  9554. // })
  9555. //
  9556. //}
  9557. type QueryResult struct {
  9558. ID int64
  9559. Name string
  9560. Code string
  9561. List_type_code string
  9562. }
  9563. func (c *HisApiController) GetCheckCode() {
  9564. ids_str := c.GetString("ids")
  9565. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9566. ids_arr := strings.Split(ids_str, ",")
  9567. var queryResult []QueryResult
  9568. ids := make([]int64, 0)
  9569. for _, item := range ids_arr {
  9570. id, _ := strconv.ParseInt(item, 10, 64)
  9571. ids = append(ids, id)
  9572. }
  9573. if record_type == 1 {
  9574. drugs, _ := service.GetBatchDrugList(ids)
  9575. for _, item := range drugs {
  9576. result := QueryResult{
  9577. ID: item.ID,
  9578. Name: item.DrugName,
  9579. Code: item.MedicalInsuranceNumber,
  9580. List_type_code: "101",
  9581. }
  9582. queryResult = append(queryResult, result)
  9583. }
  9584. } else if record_type == 2 {
  9585. goods, _ := service.GetBatchGoodInformationList(ids)
  9586. for _, item := range goods {
  9587. result := QueryResult{
  9588. ID: item.ID,
  9589. Name: item.GoodName,
  9590. Code: item.MedicalInsuranceNumber,
  9591. List_type_code: "301",
  9592. }
  9593. queryResult = append(queryResult, result)
  9594. }
  9595. } else if record_type == 3 {
  9596. projects, _ := service.GetBathchMyPorjecgList(ids)
  9597. for _, item := range projects {
  9598. result := QueryResult{
  9599. ID: item.ID,
  9600. Name: item.ProjectName,
  9601. Code: item.MedicalCode,
  9602. List_type_code: "201",
  9603. }
  9604. queryResult = append(queryResult, result)
  9605. }
  9606. }
  9607. admin_user_id, _ := c.GetInt64("admin_user_id")
  9608. adminUser := c.GetAdminUserInfo()
  9609. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9610. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9611. var user_name string
  9612. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9613. if role.ID == 0 {
  9614. user_name = "xxx"
  9615. } else {
  9616. user_name = role.UserName
  9617. }
  9618. baseParams := &models.BaseParams{
  9619. SecretKey: miConfig.SecretKey,
  9620. FixmedinsCode: miConfig.Code,
  9621. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9622. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9623. OrgName: miConfig.OrgName,
  9624. Doctor: user_name,
  9625. }
  9626. if config.IsOpen == 1 {
  9627. for _, item := range queryResult {
  9628. var result string
  9629. if record_type == 1 {
  9630. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9631. } else if record_type == 2 {
  9632. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9633. } else if record_type == 3 {
  9634. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9635. }
  9636. var dat map[string]interface{}
  9637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9638. fmt.Println(dat)
  9639. } else {
  9640. fmt.Println(err)
  9641. }
  9642. userJSONBytes, _ := json.Marshal(dat)
  9643. var res ResultSix
  9644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9645. utils.ErrorLog("解析失败:%v", err)
  9646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9647. return
  9648. }
  9649. if res.Infcode == 0 {
  9650. if record_type == 1 {
  9651. service.UpdateBaseDrugById(item.ID)
  9652. } else if record_type == 2 {
  9653. service.UpdateGoodInformaitonByDetail(item.ID)
  9654. } else if record_type == 3 {
  9655. service.UpdateProjectById(item.ID)
  9656. }
  9657. c.ServeSuccessJSON(map[string]interface{}{
  9658. "failed_code": 0,
  9659. "msg": "目录对照成功",
  9660. })
  9661. } else {
  9662. c.ServeSuccessJSON(map[string]interface{}{
  9663. "failed_code": -10,
  9664. "msg": res.ErrMsg,
  9665. })
  9666. }
  9667. }
  9668. }
  9669. }
  9670. func (c *HisApiController) UnCheckCode() {
  9671. ids_str := c.GetString("ids")
  9672. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9673. admin_user_id, _ := c.GetInt64("admin_user_id")
  9674. ids_arr := strings.Split(ids_str, ",")
  9675. var queryResult []QueryResult
  9676. ids := make([]int64, 0)
  9677. for _, item := range ids_arr {
  9678. id, _ := strconv.ParseInt(item, 10, 64)
  9679. ids = append(ids, id)
  9680. }
  9681. if record_type == 1 {
  9682. drugs, _ := service.GetBatchDrugList(ids)
  9683. for _, item := range drugs {
  9684. result := QueryResult{
  9685. ID: item.ID,
  9686. Name: item.DrugName,
  9687. Code: item.MedicalInsuranceNumber,
  9688. List_type_code: "101",
  9689. }
  9690. queryResult = append(queryResult, result)
  9691. }
  9692. } else if record_type == 2 {
  9693. goods, _ := service.GetBatchGoodInformationList(ids)
  9694. for _, item := range goods {
  9695. result := QueryResult{
  9696. ID: item.ID,
  9697. Name: item.GoodName,
  9698. Code: item.MedicalInsuranceNumber,
  9699. List_type_code: "301",
  9700. }
  9701. queryResult = append(queryResult, result)
  9702. }
  9703. } else if record_type == 3 {
  9704. projects, _ := service.GetBathchMyPorjecgList(ids)
  9705. for _, item := range projects {
  9706. result := QueryResult{
  9707. ID: item.ID,
  9708. Name: item.ProjectName,
  9709. Code: item.MedicalCode,
  9710. List_type_code: "201",
  9711. }
  9712. queryResult = append(queryResult, result)
  9713. }
  9714. }
  9715. adminUser := c.GetAdminUserInfo()
  9716. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9717. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9718. var user_name string
  9719. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9720. if role.ID == 0 {
  9721. user_name = "xxx"
  9722. } else {
  9723. user_name = role.UserName
  9724. }
  9725. baseParams := &models.BaseParams{
  9726. SecretKey: miConfig.SecretKey,
  9727. FixmedinsCode: miConfig.Code,
  9728. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9729. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9730. OrgName: miConfig.OrgName,
  9731. Doctor: user_name,
  9732. }
  9733. if config.IsOpen == 1 {
  9734. for _, item := range queryResult {
  9735. var result string
  9736. if record_type == 1 {
  9737. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9738. } else if record_type == 2 {
  9739. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9740. } else if record_type == 3 {
  9741. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9742. }
  9743. var dat2 map[string]interface{}
  9744. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9745. fmt.Println(dat2)
  9746. } else {
  9747. fmt.Println(err)
  9748. }
  9749. userJSONBytes, _ := json.Marshal(dat2)
  9750. var res ResultSix
  9751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9752. utils.ErrorLog("解析失败:%v", err)
  9753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9754. return
  9755. }
  9756. if res.Infcode == 0 {
  9757. if record_type == 1 {
  9758. service.UpdateDrugByIdDetail(item.ID)
  9759. } else if record_type == 2 {
  9760. service.UpdateGoodInfoById(item.ID)
  9761. } else if record_type == 3 {
  9762. service.UpdateMyProjectById(item.ID)
  9763. }
  9764. c.ServeSuccessJSON(map[string]interface{}{
  9765. "failed_code": 0,
  9766. "msg": "撤销目录对照成功",
  9767. })
  9768. } else {
  9769. c.ServeSuccessJSON(map[string]interface{}{
  9770. "failed_code": -10,
  9771. "msg": res.ErrMsg,
  9772. })
  9773. }
  9774. }
  9775. }
  9776. }
  9777. func (c *HisApiController) GetPatientInfo() {
  9778. id_card_no := c.GetString("id_card_no")
  9779. admin_user_id, _ := c.GetInt64("admin_user_id")
  9780. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9781. if patient.ID == 0 {
  9782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9783. return
  9784. }
  9785. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9786. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9787. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9788. if config.IsOpen == 1 {
  9789. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9790. var dat map[string]interface{}
  9791. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9792. fmt.Println(dat)
  9793. } else {
  9794. fmt.Println(err)
  9795. }
  9796. userJSONBytes, _ := json.Marshal(dat)
  9797. var res ResultTwo
  9798. var res10265 ResultTwo10265
  9799. if miConfig.Code == "H15049901371" {
  9800. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9801. utils.ErrorLog("解析失败:%v", err)
  9802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9803. return
  9804. }
  9805. res.ErrMsg = res10265.ErrMsg
  9806. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9807. res.Infcode = infocode
  9808. res.Output = res10265.Output
  9809. res.InfRefmsgid = res10265.InfRefmsgid
  9810. } else {
  9811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9812. utils.ErrorLog("解析失败:%v", err)
  9813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9814. return
  9815. }
  9816. }
  9817. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9818. // utils.ErrorLog("解析失败:%v", err)
  9819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9820. // return
  9821. //}
  9822. if res.Infcode != 0 {
  9823. c.ServeSuccessJSON(map[string]interface{}{
  9824. "failed_code": -10,
  9825. "msg": res.ErrMsg,
  9826. })
  9827. } else {
  9828. c.ServeSuccessJSON(map[string]interface{}{
  9829. "failed_code": 0,
  9830. "info": res,
  9831. })
  9832. }
  9833. }
  9834. }
  9835. func (c *HisApiController) PsnPutOnRecord() {
  9836. record_type, _ := c.GetInt64("type")
  9837. patient_id, _ := c.GetInt64("patient_id")
  9838. admin_user_id, _ := c.GetInt64("admin_user_id")
  9839. start_time := c.GetString("start_time")
  9840. end_time := c.GetString("end_time")
  9841. adminUser := c.GetAdminUserInfo()
  9842. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9843. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9844. var patients []*models.Patients
  9845. if record_type == 1 { //全部备案
  9846. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9847. patients = append(patients, patient...)
  9848. } else { //单个备案
  9849. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9850. patients = append(patients, patient)
  9851. }
  9852. var user_name string
  9853. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9854. if role.ID == 0 {
  9855. user_name = "xxx"
  9856. } else {
  9857. user_name = role.UserName
  9858. }
  9859. if config.IsOpen == 1 {
  9860. for _, item := range patients {
  9861. 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
  9862. resp, requestErr := http.Get(api)
  9863. if requestErr != nil {
  9864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9865. return
  9866. }
  9867. defer resp.Body.Close()
  9868. body, ioErr := ioutil.ReadAll(resp.Body)
  9869. if ioErr != nil {
  9870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9872. return
  9873. }
  9874. var respJSON map[string]interface{}
  9875. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9878. return
  9879. }
  9880. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9881. userJSONBytes, _ := json.Marshal(userJSON)
  9882. var res ResultTwo
  9883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9884. utils.ErrorLog("解析失败:%v", err)
  9885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9886. return
  9887. }
  9888. if res.Infcode == 0 {
  9889. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9890. var dat map[string]interface{}
  9891. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9892. fmt.Println(dat)
  9893. } else {
  9894. fmt.Println(err)
  9895. }
  9896. userJSONBytes, _ := json.Marshal(dat)
  9897. var res2 ResultThirteen
  9898. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9899. utils.ErrorLog("解析失败:%v", err)
  9900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9901. return
  9902. }
  9903. if res2.Infcode == 0 {
  9904. psnResult := &models.GdybPsnRecord{
  9905. UserOrgId: adminUser.CurrentOrgId,
  9906. PatientId: item.ID,
  9907. PsnNo: res.Output.Baseinfo.PsnNo,
  9908. Ctime: time.Now().Unix(),
  9909. Mtime: time.Now().Unix(),
  9910. Status: 1,
  9911. IsCancel: 1,
  9912. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9913. }
  9914. service.CreatePsnRecord(psnResult)
  9915. } else {
  9916. c.ServeSuccessJSON(map[string]interface{}{
  9917. "failed_code": -10,
  9918. "msg": res2.ErrMsg,
  9919. })
  9920. return
  9921. }
  9922. }
  9923. }
  9924. }
  9925. }
  9926. func (c *HisApiController) PsnUnPutOnRecord() {
  9927. id, _ := c.GetInt64("id")
  9928. //record_type, _ := c.GetInt64("type")
  9929. admin_user_id, _ := c.GetInt64("admin_user_id")
  9930. adminUser := c.GetAdminUserInfo()
  9931. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9932. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9933. var user_name string
  9934. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9935. if role.ID == 0 {
  9936. user_name = "xxx"
  9937. } else {
  9938. user_name = role.UserName
  9939. }
  9940. psn_record, _ := service.GetPsnRecordById(id)
  9941. if psn_record.ID == 0 {
  9942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9943. return
  9944. }
  9945. if config.IsOpen == 1 {
  9946. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9947. var dat map[string]interface{}
  9948. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9949. fmt.Println(dat)
  9950. } else {
  9951. fmt.Println(err)
  9952. }
  9953. userJSONBytes, _ := json.Marshal(dat)
  9954. var res ResultFourteen
  9955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9956. utils.ErrorLog("解析失败:%v", err)
  9957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9958. return
  9959. }
  9960. if res.Infcode == 0 {
  9961. psn_record.IsCancel = 2
  9962. service.CreatePsnRecord(&psn_record)
  9963. } else {
  9964. c.ServeSuccessJSON(map[string]interface{}{
  9965. "failed_code": -10,
  9966. "msg": res.ErrMsg,
  9967. })
  9968. return
  9969. }
  9970. }
  9971. }
  9972. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9973. patient_id, _ := c.GetInt64("patient_id")
  9974. insutype_two := c.GetString("insutype")
  9975. psn_no := c.GetString("psn_no")
  9976. doctor_id, _ := c.GetInt64("doctor_id")
  9977. sick_id, _ := c.GetInt64("sick_id")
  9978. department_id, _ := c.GetInt64("department_id")
  9979. start_time := c.GetString("start_time")
  9980. end_time := c.GetString("end_time")
  9981. check_time := c.GetString("check_time")
  9982. adminUser := c.GetAdminUserInfo()
  9983. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9984. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9985. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9986. sick, _ := service.FindSickById(sick_id)
  9987. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9988. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9989. var res ResultTwo
  9990. var res10265 ResultTwo10265
  9991. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9992. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9993. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9994. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9995. "&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
  9996. resp, requestErr := http.Get(api)
  9997. if requestErr != nil {
  9998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9999. return
  10000. }
  10001. body, ioErr := ioutil.ReadAll(resp.Body)
  10002. if ioErr != nil {
  10003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10005. return
  10006. }
  10007. var respJSON map[string]interface{}
  10008. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10011. return
  10012. }
  10013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10014. result, _ := json.Marshal(respJSON)
  10015. fmt.Println("log")
  10016. fmt.Println(string(result))
  10017. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10018. utils.ErrorLog("解析失败:%v", err)
  10019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10020. return
  10021. }
  10022. res.ErrMsg = res10265.ErrMsg
  10023. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10024. res.Infcode = infocode
  10025. res.Output = res10265.Output
  10026. res.InfRefmsgid = res10265.InfRefmsgid
  10027. } else {
  10028. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10029. if miConfig.Code == "H15049901371" {
  10030. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10031. utils.ErrorLog("解析失败:%v", err)
  10032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10033. return
  10034. }
  10035. res.ErrMsg = res10265.ErrMsg
  10036. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10037. res.Infcode = infocode
  10038. res.Output = res10265.Output
  10039. res.InfRefmsgid = res10265.InfRefmsgid
  10040. } else {
  10041. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10042. utils.ErrorLog("解析失败:%v", err)
  10043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10044. return
  10045. }
  10046. }
  10047. }
  10048. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10049. infoStr := string(Iinfos)
  10050. var rf []*ResultFive
  10051. json.Unmarshal([]byte(infoStr), &rf)
  10052. var insuplc_admdvs string
  10053. var insutype string
  10054. var is390 int = 0
  10055. var is310 int = 0
  10056. var insutypes []*ResultFive
  10057. for _, item := range rf {
  10058. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10059. insutypes = append(insutypes, item)
  10060. }
  10061. }
  10062. if len(insutypes) == 1 {
  10063. insutype = insutypes[0].Insutype
  10064. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10065. } else {
  10066. for _, i := range insutypes {
  10067. if i.Insutype == "390" {
  10068. is390 = 1
  10069. }
  10070. if i.Insutype == "310" {
  10071. is310 = 1
  10072. }
  10073. }
  10074. }
  10075. if is390 == 1 {
  10076. insutype = "390"
  10077. }
  10078. if is310 == 1 {
  10079. insutype = "310"
  10080. }
  10081. if len(insutypes) == 2 {
  10082. insutype = insutype_two
  10083. }
  10084. if len(insutypes) == 0 {
  10085. insutype = "310"
  10086. }
  10087. insutype = insutype_two
  10088. fmt.Println(insutype)
  10089. for _, item := range rf {
  10090. fmt.Println(item.Insutype)
  10091. fmt.Println(insutype)
  10092. if item.Insutype == insutype {
  10093. fmt.Println(item.Insutype)
  10094. fmt.Println(insutype)
  10095. insuplc_admdvs = item.InsuplcAdmdvs
  10096. }
  10097. }
  10098. fmt.Println(insuplc_admdvs)
  10099. var res2 ResultThirteen
  10100. var res10265_2 ResultThirteen10265
  10101. if config.IsOpen == 1 {
  10102. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10103. } else {
  10104. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  10105. var dat map[string]interface{}
  10106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10107. fmt.Println(dat)
  10108. } else {
  10109. fmt.Println(err)
  10110. }
  10111. userJSONBytes, _ := json.Marshal(dat)
  10112. if miConfig.Code == "H15049901371" {
  10113. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10114. utils.ErrorLog("解析失败:%v", err)
  10115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10116. return
  10117. }
  10118. res2.ErrMsg = res10265_2.ErrMsg
  10119. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10120. res2.Infcode = infocode
  10121. res2.Output = res10265_2.Output
  10122. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10123. } else {
  10124. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10125. utils.ErrorLog("解析失败:%v", err)
  10126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10127. return
  10128. }
  10129. }
  10130. }
  10131. if res2.Infcode == 0 {
  10132. psnResult := &models.GdybPsnNcdsRecord{
  10133. UserOrgId: adminUser.CurrentOrgId,
  10134. PatientId: patient.ID,
  10135. PsnNo: psn_no,
  10136. DoctorId: doctor.AdminUserId,
  10137. DepartmentId: department_id,
  10138. SickType: sick_id,
  10139. Insutype: insutype,
  10140. Ctime: time.Now().Unix(),
  10141. Mtime: time.Now().Unix(),
  10142. Status: 1,
  10143. IsCancel: 1,
  10144. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10145. }
  10146. service.CreatePsnNCDSRecord(psnResult)
  10147. c.ServeSuccessJSON(map[string]interface{}{
  10148. "failed_code": 0,
  10149. "msg": "备案成功",
  10150. "result": psnResult,
  10151. })
  10152. } else {
  10153. c.ServeSuccessJSON(map[string]interface{}{
  10154. "failed_code": -10,
  10155. "msg": res2.ErrMsg,
  10156. })
  10157. return
  10158. }
  10159. }
  10160. }
  10161. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10162. id, _ := c.GetInt64("id")
  10163. admin_user_id, _ := c.GetInt64("admin_user_id")
  10164. adminUser := c.GetAdminUserInfo()
  10165. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10166. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10167. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10168. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10169. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10170. //var user_name string
  10171. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10172. //if role.ID == 0 {
  10173. // user_name = "xxx"
  10174. //} else {
  10175. // user_name = role.UserName
  10176. //}
  10177. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10178. if psn_record.ID == 0 {
  10179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10180. return
  10181. }
  10182. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10183. var res ResultTwo
  10184. var res10265 ResultTwo10265
  10185. if miConfig.Code == "H15049901371" {
  10186. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10187. utils.ErrorLog("解析失败:%v", err)
  10188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10189. return
  10190. }
  10191. res.ErrMsg = res10265.ErrMsg
  10192. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10193. res.Infcode = infocode
  10194. res.Output = res10265.Output
  10195. res.InfRefmsgid = res10265.InfRefmsgid
  10196. } else {
  10197. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10198. utils.ErrorLog("解析失败:%v", err)
  10199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10200. return
  10201. }
  10202. }
  10203. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10204. infoStr := string(Iinfos)
  10205. var rf []*ResultFive
  10206. json.Unmarshal([]byte(infoStr), &rf)
  10207. var insuplc_admdvs string
  10208. var insutype string
  10209. var is390 int = 0
  10210. var is310 int = 0
  10211. var insutypes []*ResultFive
  10212. for _, item := range rf {
  10213. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10214. insutypes = append(insutypes, item)
  10215. }
  10216. }
  10217. if len(insutypes) == 1 {
  10218. insutype = insutypes[0].Insutype
  10219. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10220. } else {
  10221. for _, i := range insutypes {
  10222. if i.Insutype == "390" {
  10223. is390 = 1
  10224. }
  10225. if i.Insutype == "310" {
  10226. is310 = 1
  10227. }
  10228. }
  10229. }
  10230. if is390 == 1 {
  10231. insutype = "390"
  10232. }
  10233. if is310 == 1 {
  10234. insutype = "310"
  10235. }
  10236. if len(insutypes) == 0 {
  10237. insutype = "310"
  10238. }
  10239. insutype = psn_record.Insutype
  10240. for _, item := range rf {
  10241. if item.Insutype == insutype {
  10242. insuplc_admdvs = item.InsuplcAdmdvs
  10243. }
  10244. }
  10245. if config.IsOpen == 1 {
  10246. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10247. var dat map[string]interface{}
  10248. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10249. fmt.Println(dat)
  10250. } else {
  10251. fmt.Println(err)
  10252. }
  10253. userJSONBytes, _ := json.Marshal(dat)
  10254. var res ResultFourteen
  10255. var res10265 ResultFourteen10265
  10256. if miConfig.Code == "H15049901371" {
  10257. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10258. utils.ErrorLog("解析失败:%v", err)
  10259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10260. return
  10261. }
  10262. res.ErrMsg = res10265.ErrMsg
  10263. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10264. res.Infcode = infocode
  10265. res.Output = res10265.Output
  10266. res.InfRefmsgid = res10265.InfRefmsgid
  10267. } else {
  10268. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10269. utils.ErrorLog("解析失败:%v", err)
  10270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10271. return
  10272. }
  10273. }
  10274. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10275. // utils.ErrorLog("解析失败:%v", err)
  10276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10277. // return
  10278. //}
  10279. if res.Infcode == 0 {
  10280. psn_record.IsCancel = 2
  10281. service.CreatePsnNCDSRecord(&psn_record)
  10282. c.ServeSuccessJSON(map[string]interface{}{
  10283. "failed_code": 0,
  10284. "msg": "撤销备案成功",
  10285. })
  10286. } else {
  10287. c.ServeSuccessJSON(map[string]interface{}{
  10288. "failed_code": -10,
  10289. "msg": res.ErrMsg,
  10290. })
  10291. return
  10292. }
  10293. }
  10294. }
  10295. func (c *HisApiController) TestTest() {
  10296. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10297. fmt.Println(patient.Iinfo)
  10298. }
  10299. type CustomData struct {
  10300. MsgId string
  10301. PsnNo string
  10302. Info string
  10303. }
  10304. func (c *HisApiController) ReversalData() {
  10305. var customData []*CustomData
  10306. custom := &CustomData{
  10307. MsgId: "H44022900158202103301714472004",
  10308. PsnNo: "44020000001101329945",
  10309. Info: "2207",
  10310. }
  10311. customData = append(customData, custom)
  10312. custom1 := &CustomData{
  10313. MsgId: "H4402290015820210330172057803",
  10314. PsnNo: "44020000001101161813",
  10315. Info: "2207",
  10316. }
  10317. customData = append(customData, custom1)
  10318. custom2 := &CustomData{
  10319. MsgId: "H44022900158202103301705198813",
  10320. PsnNo: "44190000133097375417",
  10321. Info: "2207",
  10322. }
  10323. customData = append(customData, custom2)
  10324. custom3 := &CustomData{
  10325. MsgId: "H44022900158202103301715524756",
  10326. PsnNo: "44020000001100187221",
  10327. Info: "2207",
  10328. }
  10329. customData = append(customData, custom3)
  10330. custom4 := &CustomData{
  10331. MsgId: "H44022900158202103301730376224",
  10332. PsnNo: "44020000001101959155",
  10333. Info: "2207",
  10334. }
  10335. customData = append(customData, custom4)
  10336. custom5 := &CustomData{
  10337. MsgId: "H44022900158202103301748008725",
  10338. PsnNo: "44020000001104246641",
  10339. Info: "2207",
  10340. }
  10341. customData = append(customData, custom5)
  10342. custom6 := &CustomData{
  10343. MsgId: "H44022900158202103301718096755",
  10344. PsnNo: "44020000001102211860",
  10345. Info: "2207",
  10346. }
  10347. customData = append(customData, custom6)
  10348. custom7 := &CustomData{
  10349. MsgId: "H44022900158202103301736551640",
  10350. PsnNo: "44020000001102687718",
  10351. Info: "2207",
  10352. }
  10353. customData = append(customData, custom7)
  10354. custom8 := &CustomData{
  10355. MsgId: "H44022900158202103301743097676",
  10356. PsnNo: "44020000001102127785",
  10357. Info: "2207",
  10358. }
  10359. customData = append(customData, custom8)
  10360. custom9 := &CustomData{
  10361. MsgId: "H44022900158202103301712304203",
  10362. PsnNo: "44020000001101518097",
  10363. Info: "2207",
  10364. }
  10365. customData = append(customData, custom9)
  10366. custom10 := &CustomData{
  10367. MsgId: "H44022900158202103301738448785",
  10368. PsnNo: "44020000001100500813",
  10369. Info: "2207",
  10370. }
  10371. customData = append(customData, custom10)
  10372. custom11 := &CustomData{
  10373. MsgId: "H44022900158202103301732455843",
  10374. PsnNo: "44020000001102690557",
  10375. Info: "2207",
  10376. }
  10377. customData = append(customData, custom11)
  10378. custom12 := &CustomData{
  10379. MsgId: "H44022900158202103301745421708",
  10380. PsnNo: "44020000001102211928",
  10381. Info: "2207",
  10382. }
  10383. customData = append(customData, custom12)
  10384. custom1212 := &CustomData{
  10385. MsgId: "H440229001582021033017351627",
  10386. PsnNo: "44020000001102481733",
  10387. Info: "2207",
  10388. }
  10389. customData = append(customData, custom1212)
  10390. custom13 := &CustomData{
  10391. MsgId: "H44022900158202103301740327951",
  10392. PsnNo: "44020000001103174866",
  10393. Info: "2207",
  10394. }
  10395. customData = append(customData, custom13)
  10396. custom14 := &CustomData{
  10397. MsgId: "H4402290015820210330174922668",
  10398. PsnNo: "44020000001102927272",
  10399. Info: "2207",
  10400. }
  10401. customData = append(customData, custom14)
  10402. custom15 := &CustomData{
  10403. MsgId: "H44022900158202103301752362273",
  10404. PsnNo: "44020000001102942890",
  10405. Info: "2207",
  10406. }
  10407. customData = append(customData, custom15)
  10408. custom16 := &CustomData{
  10409. MsgId: "H44022900158202103301751082917",
  10410. PsnNo: "44020000001101662162",
  10411. Info: "2207",
  10412. }
  10413. customData = append(customData, custom16)
  10414. custom17 := &CustomData{
  10415. MsgId: "H44022900158202103301754147728",
  10416. PsnNo: "44020000000229014511",
  10417. Info: "2207",
  10418. }
  10419. customData = append(customData, custom17)
  10420. adminUser := c.GetAdminUserInfo()
  10421. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10422. for _, item := range customData {
  10423. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10424. fmt.Println(result)
  10425. }
  10426. }
  10427. //func (c *HisApiController) GetAllopatry() {
  10428. // year := c.GetString("year")
  10429. // month := c.GetString("month")
  10430. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10431. // adminUser := c.GetAdminUserInfo()
  10432. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10433. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10434. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10435. //
  10436. // var dat map[string]interface{}
  10437. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10438. // fmt.Println(dat)
  10439. // } else {
  10440. // fmt.Println(err)
  10441. // }
  10442. // userJSONBytes, _ := json.Marshal(dat)
  10443. // var res models.Result9001
  10444. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10445. // utils.ErrorLog("解析失败:%v", err)
  10446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10447. // return
  10448. // }
  10449. //
  10450. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10451. // var dat2 map[string]interface{}
  10452. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10453. // fmt.Println(dat)
  10454. // } else {
  10455. // fmt.Println(err)
  10456. // }
  10457. // userJSONBytes2, _ := json.Marshal(dat2)
  10458. // var res2 models.Result3260
  10459. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10460. // utils.ErrorLog("解析失败:%v", err)
  10461. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10462. // return
  10463. // }
  10464. // if res2.Infcode == 0 {
  10465. // c.ServeSuccessJSON(map[string]interface{}{
  10466. // "list": res2.Output.Data,
  10467. // })
  10468. // return
  10469. // } else {
  10470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10471. // return
  10472. // }
  10473. //
  10474. //}
  10475. //func (c *HisApiController) ComfirmAllopatry() {
  10476. // year := c.GetString("year")
  10477. // month := c.GetString("month")
  10478. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10479. // adminUser := c.GetAdminUserInfo()
  10480. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10481. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10482. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10483. // var dat map[string]interface{}
  10484. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10485. // fmt.Println(dat)
  10486. // } else {
  10487. // fmt.Println(err)
  10488. // }
  10489. // userJSONBytes, _ := json.Marshal(dat)
  10490. // var res models.Result9001
  10491. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10492. // utils.ErrorLog("解析失败:%v", err)
  10493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10494. // return
  10495. // }
  10496. //
  10497. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10498. // var dat2 map[string]interface{}
  10499. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10500. // fmt.Println(dat)
  10501. // } else {
  10502. // fmt.Println(err)
  10503. // }
  10504. // userJSONBytes2, _ := json.Marshal(dat2)
  10505. // var res2 models.Result3260
  10506. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10507. // utils.ErrorLog("解析失败:%v", err)
  10508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10509. // return
  10510. // }
  10511. //
  10512. // if res2.Infcode == 0 {
  10513. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10514. // var dat map[string]interface{}
  10515. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10516. // fmt.Println(dat)
  10517. // } else {
  10518. // fmt.Println(err)
  10519. // }
  10520. // userJSONBytes, _ := json.Marshal(dat)
  10521. // var res3 models.Result3261
  10522. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10523. // utils.ErrorLog("解析失败:%v", err)
  10524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10525. // return
  10526. // }
  10527. //
  10528. // if res3.Infcode == 0 {
  10529. // record := &models.HisYidiClearRecord{
  10530. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10531. // Ctime: time.Now().Unix(),
  10532. // Mtime: time.Now().Unix(),
  10533. // Status: 1,
  10534. // MsgId: msgId,
  10535. // }
  10536. // service.SaveClearRecord(record)
  10537. // c.ServeSuccessJSON(map[string]interface{}{
  10538. // "msg": "提取成功",
  10539. // })
  10540. // }
  10541. // }
  10542. //}
  10543. func (c *HisApiController) RefundAllopatry() {
  10544. year := c.GetString("year")
  10545. month := c.GetString("month")
  10546. id, _ := c.GetInt64("id")
  10547. admin_user_id, _ := c.GetInt64("admin_user_id")
  10548. adminUser := c.GetAdminUserInfo()
  10549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10550. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10551. record, _ := service.GetClearRecordById(id)
  10552. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10553. var dat map[string]interface{}
  10554. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10555. fmt.Println(dat)
  10556. } else {
  10557. fmt.Println(err)
  10558. }
  10559. userJSONBytes, _ := json.Marshal(dat)
  10560. var empty ResultFourteen
  10561. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10562. utils.ErrorLog("解析失败:%v", err)
  10563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10564. return
  10565. }
  10566. if empty.Infcode == 0 {
  10567. c.ServeSuccessJSON(map[string]interface{}{
  10568. "msg": "撤销成功",
  10569. })
  10570. return
  10571. }
  10572. }
  10573. func (c *HisApiController) ReversalOtherData() {
  10574. var customData []*CustomData
  10575. custom := &CustomData{
  10576. MsgId: "H44022900158202103301714472004",
  10577. PsnNo: "44020000001101329945",
  10578. Info: "2208",
  10579. }
  10580. customData = append(customData, custom)
  10581. custom1 := &CustomData{
  10582. MsgId: "H4402290015820210330172057803",
  10583. PsnNo: "44020000001101161813",
  10584. Info: "2208",
  10585. }
  10586. customData = append(customData, custom1)
  10587. custom2 := &CustomData{
  10588. MsgId: "H44022900158202103301705198813",
  10589. PsnNo: "44190000133097375417",
  10590. Info: "2208",
  10591. }
  10592. customData = append(customData, custom2)
  10593. custom3 := &CustomData{
  10594. MsgId: "H44022900158202103301715524756",
  10595. PsnNo: "44020000001100187221",
  10596. Info: "2208",
  10597. }
  10598. customData = append(customData, custom3)
  10599. custom4 := &CustomData{
  10600. MsgId: "H44022900158202103301730376224",
  10601. PsnNo: "44020000001101959155",
  10602. Info: "2208",
  10603. }
  10604. customData = append(customData, custom4)
  10605. custom5 := &CustomData{
  10606. MsgId: "H44022900158202103301748008725",
  10607. PsnNo: "44020000001104246641",
  10608. Info: "2208",
  10609. }
  10610. customData = append(customData, custom5)
  10611. custom6 := &CustomData{
  10612. MsgId: "H44022900158202103301718096755",
  10613. PsnNo: "44020000001102211860",
  10614. Info: "2208",
  10615. }
  10616. customData = append(customData, custom6)
  10617. custom7 := &CustomData{
  10618. MsgId: "H44022900158202103301736551640",
  10619. PsnNo: "44020000001102687718",
  10620. Info: "2208",
  10621. }
  10622. customData = append(customData, custom7)
  10623. custom8 := &CustomData{
  10624. MsgId: "H44022900158202103301743097676",
  10625. PsnNo: "44020000001102127785",
  10626. Info: "2208",
  10627. }
  10628. customData = append(customData, custom8)
  10629. custom9 := &CustomData{
  10630. MsgId: "H44022900158202103301712304203",
  10631. PsnNo: "44020000001101518097",
  10632. Info: "2208",
  10633. }
  10634. customData = append(customData, custom9)
  10635. custom10 := &CustomData{
  10636. MsgId: "H44022900158202103301738448785",
  10637. PsnNo: "44020000001100500813",
  10638. Info: "2208",
  10639. }
  10640. customData = append(customData, custom10)
  10641. custom11 := &CustomData{
  10642. MsgId: "H44022900158202103301732455843",
  10643. PsnNo: "44020000001102690557",
  10644. Info: "2208",
  10645. }
  10646. customData = append(customData, custom11)
  10647. custom12 := &CustomData{
  10648. MsgId: "H44022900158202103301745421708",
  10649. PsnNo: "44020000001102211928",
  10650. Info: "2208",
  10651. }
  10652. customData = append(customData, custom12)
  10653. custom1212 := &CustomData{
  10654. MsgId: "H440229001582021033017351627",
  10655. PsnNo: "44020000001102481733",
  10656. Info: "2208",
  10657. }
  10658. customData = append(customData, custom1212)
  10659. custom13 := &CustomData{
  10660. MsgId: "H44022900158202103301740327951",
  10661. PsnNo: "44020000001103174866",
  10662. Info: "2208",
  10663. }
  10664. customData = append(customData, custom13)
  10665. custom14 := &CustomData{
  10666. MsgId: "H4402290015820210330174922668",
  10667. PsnNo: "44020000001102927272",
  10668. Info: "2208",
  10669. }
  10670. customData = append(customData, custom14)
  10671. custom15 := &CustomData{
  10672. MsgId: "H44022900158202103301752362273",
  10673. PsnNo: "44020000001102942890",
  10674. Info: "2208",
  10675. }
  10676. customData = append(customData, custom15)
  10677. custom16 := &CustomData{
  10678. MsgId: "H44022900158202103301751082917",
  10679. PsnNo: "44020000001101662162",
  10680. Info: "2208",
  10681. }
  10682. customData = append(customData, custom16)
  10683. custom17 := &CustomData{
  10684. MsgId: "H44022900158202103301754147728",
  10685. PsnNo: "44020000000229014511",
  10686. Info: "2208",
  10687. }
  10688. customData = append(customData, custom17)
  10689. adminUser := c.GetAdminUserInfo()
  10690. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10691. for _, item := range customData {
  10692. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10693. fmt.Println(result)
  10694. }
  10695. }
  10696. func PathExists(path string) (bool, error) {
  10697. _, err := os.Stat(path)
  10698. if err == nil {
  10699. return true, nil
  10700. }
  10701. if os.IsNotExist(err) {
  10702. return false, nil
  10703. }
  10704. return false, err
  10705. }
  10706. //创建文件夹
  10707. func Mkdir(dir string) {
  10708. // 创建文件夹
  10709. exist, err := PathExists(dir)
  10710. if err != nil {
  10711. fmt.Println(err.Error())
  10712. } else {
  10713. if exist {
  10714. fmt.Println(dir + "文件夹已存在!")
  10715. } else {
  10716. // 文件夹名称,权限
  10717. err := os.Mkdir(dir, os.ModePerm)
  10718. if err != nil {
  10719. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10720. } else {
  10721. fmt.Println(dir + "文件夹创建成功!")
  10722. }
  10723. }
  10724. }
  10725. }
  10726. //压缩文件
  10727. func Zip(srcFile string, destZip string) error {
  10728. zipfile, err := os.Create(destZip)
  10729. if err != nil {
  10730. return err
  10731. }
  10732. defer zipfile.Close()
  10733. archive := zip.NewWriter(zipfile)
  10734. defer archive.Close()
  10735. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10736. if err != nil {
  10737. return err
  10738. }
  10739. header, err := zip.FileInfoHeader(info)
  10740. if err != nil {
  10741. return err
  10742. }
  10743. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10744. // header.Name = path
  10745. if info.IsDir() {
  10746. header.Name += "/"
  10747. } else {
  10748. header.Method = zip.Deflate
  10749. }
  10750. writer, err := archive.CreateHeader(header)
  10751. if err != nil {
  10752. return err
  10753. }
  10754. if !info.IsDir() {
  10755. file, err := os.Open(path)
  10756. if err != nil {
  10757. return err
  10758. }
  10759. defer file.Close()
  10760. _, err = io.Copy(writer, file)
  10761. }
  10762. return err
  10763. })
  10764. return err
  10765. }
  10766. func ReadFile(filePath string) []byte {
  10767. f, err := os.Open(filePath)
  10768. if err != nil {
  10769. fmt.Println("read file fail", err)
  10770. return nil
  10771. }
  10772. defer f.Close()
  10773. fd, err := ioutil.ReadAll(f)
  10774. if err != nil {
  10775. fmt.Println("read to fd fail", err)
  10776. return nil
  10777. }
  10778. return fd
  10779. }
  10780. func saveLog(result string, request string, infno string, desc string) {
  10781. org_id, _ := beego.AppConfig.Int64("org_id")
  10782. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10783. dir := miConfig.OrgName + "日志"
  10784. utils.Mkdir(dir)
  10785. month := time.Unix(1557042972, 0).Format("1")
  10786. year := time.Now().Format("2006")
  10787. month = time.Now().Format("01")
  10788. day := time.Now().Format("02")
  10789. hour := time.Now().Format("15")
  10790. min := time.Now().Format("04")
  10791. sec := time.Now().Format("05")
  10792. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10793. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10794. file_name := file + ".txt"
  10795. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10796. exist, _ := utils.PathExists(file_path)
  10797. if exist { //存在
  10798. fmt.Println("存在")
  10799. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10800. if err != nil {
  10801. fmt.Println("read fail")
  10802. }
  10803. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10804. n, _ := f.Seek(0, 2)
  10805. _, err = f.WriteAt([]byte(content), n)
  10806. } else { //不存在
  10807. fmt.Println("文件不存在,创建文件")
  10808. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10809. defer f.Close()
  10810. if err != nil {
  10811. } else {
  10812. _, err = f.Write([]byte("记录日志"))
  10813. }
  10814. }
  10815. }
  10816. type Charset string
  10817. const (
  10818. UTF8 = Charset("UTF-8")
  10819. GB18030 = Charset("GB18030")
  10820. )
  10821. func ConvertToString(src string, srcCode string, tagCode string) string {
  10822. srcCoder := mahonia.NewDecoder(srcCode)
  10823. srcResult := srcCoder.ConvertString(src)
  10824. tagCoder := mahonia.NewDecoder(tagCode)
  10825. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10826. result := string(cdata)
  10827. return result
  10828. }
  10829. func (c *HisApiController) ReadEleCard() {
  10830. id_card_type, _ := c.GetInt64("id_card_type")
  10831. admin_user_id, _ := c.GetInt64("admin_user_id")
  10832. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10833. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10834. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10835. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10836. var api string
  10837. if miConfig.MdtrtareaAdmvs == "320921" {
  10838. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10839. "&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
  10840. fmt.Println(api)
  10841. } else {
  10842. 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 +
  10843. "&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)
  10844. }
  10845. resp, requestErr := http.Get(api)
  10846. if requestErr != nil {
  10847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10848. return
  10849. }
  10850. body, ioErr := ioutil.ReadAll(resp.Body)
  10851. if ioErr != nil {
  10852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10854. return
  10855. }
  10856. var respJSON map[string]interface{}
  10857. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10860. return
  10861. }
  10862. var status string
  10863. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10864. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10865. var token string
  10866. var res ResultTwo //1101结果
  10867. var res10265 ResultTwo10265 //1101结果
  10868. if status == "0" { //读卡成功
  10869. var card_info string //卡信息
  10870. var busi_card_info string
  10871. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10872. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10873. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10874. fmt.Println(card_info)
  10875. fmt.Println(busi_card_info)
  10876. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10877. result, _ := json.Marshal(respJSON)
  10878. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10879. utils.ErrorLog("解析失败:%v", err)
  10880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10881. return
  10882. }
  10883. res.ErrMsg = res10265.ErrMsg
  10884. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10885. res.Infcode = infocode
  10886. res.Output = res10265.Output
  10887. res.InfRefmsgid = res10265.InfRefmsgid
  10888. if res.Infcode == 0 {
  10889. c.ServeSuccessJSON(map[string]interface{}{
  10890. "number": token,
  10891. })
  10892. }
  10893. } else {
  10894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10895. return
  10896. }
  10897. } else { //读卡失败
  10898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10899. return
  10900. }
  10901. }