his_api_controller.go 629KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  82. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  83. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  84. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  85. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  86. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  87. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  88. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  89. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  90. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  91. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  92. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  93. }
  94. func (c *HisApiController) Get2505() {
  95. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  96. service.Gdyb2505("44120000000010585742", "高慧裕", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-12-23 09:00:00", "2023-12-31 23:00:00")
  97. }
  98. func (c *HisApiController) Get4201A() {
  99. order_id, _ := c.GetInt64("order_id")
  100. admin_user_id, _ := c.GetInt64("admin_user_id")
  101. order, _ := service.GetHisOrderByIDTwo(order_id)
  102. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  103. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  104. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  105. //order_info = append(order_info, order_info_two...)
  106. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  108. department, _ := service.GetDepartMentDetail(his.Departments)
  109. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  110. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  111. if order.ID == 0 {
  112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  113. return
  114. }
  115. var struct4201A models.Struct4201A
  116. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  117. for _, items := range order_info {
  118. memo := make(map[string]interface{})
  119. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  120. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  121. fsiOPFLD.MedType = "14"
  122. fsiOPFLD.BkkpSn = items.FeedetlSn
  123. fsiOPFLD.FixmedinsCode = miConfig.Code
  124. fsiOPFLD.FixmedinsName = miConfig.OrgName
  125. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  126. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  127. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  128. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  129. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  130. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  131. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  132. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  133. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  134. fsiOPFLD.BilgDeptName = department.Name
  135. fsiOPFLD.BilgDeptCodg = department.Number
  136. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  137. fsiOPFLD.BilgDrName = doctor.UserName
  138. fsiOPFLD.MedChrgitmType = "09"
  139. memo["hosp_appr_flag"] = "1"
  140. memo["invoice_no"] = order.MdtrtId
  141. memo["memo"] = "自费"
  142. bytesData, _ := json.Marshal(memo)
  143. fsiOPFLD.Memo = string(bytesData)
  144. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  145. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  146. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  147. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  148. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  149. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  150. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  151. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  152. fsiOPFLD.BilgDeptName = department.Name
  153. fsiOPFLD.BilgDeptCodg = department.Number
  154. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  155. fsiOPFLD.BilgDrName = doctor.UserName
  156. switch items.HisPrescriptionProject.HisProject.CostClassify {
  157. case 0:
  158. break
  159. case 1:
  160. fsiOPFLD.MedChrgitmType = "14"
  161. break
  162. case 2:
  163. fsiOPFLD.MedChrgitmType = "05"
  164. break
  165. case 3:
  166. fsiOPFLD.MedChrgitmType = "03"
  167. break
  168. case 4:
  169. fsiOPFLD.MedChrgitmType = "03"
  170. break
  171. case 5:
  172. fsiOPFLD.MedChrgitmType = "08"
  173. break
  174. case 6:
  175. fsiOPFLD.MedChrgitmType = "14"
  176. break
  177. case 7:
  178. fsiOPFLD.MedChrgitmType = "14"
  179. break
  180. case 8:
  181. fsiOPFLD.MedChrgitmType = "03"
  182. break
  183. case 9:
  184. fsiOPFLD.MedChrgitmType = "14"
  185. break
  186. case 10:
  187. fsiOPFLD.MedChrgitmType = "14"
  188. break
  189. case 11:
  190. fsiOPFLD.MedChrgitmType = "06"
  191. break
  192. case 12:
  193. fsiOPFLD.MedChrgitmType = "12"
  194. break
  195. case 13:
  196. fsiOPFLD.MedChrgitmType = "01"
  197. break
  198. case 14:
  199. fsiOPFLD.MedChrgitmType = "04"
  200. break
  201. case 15:
  202. fsiOPFLD.MedChrgitmType = "14"
  203. break
  204. }
  205. memo["hosp_appr_flag"] = "1"
  206. memo["invoice_no"] = order.MdtrtId
  207. memo["memo"] = "自费"
  208. bytesData, _ := json.Marshal(memo)
  209. fsiOPFLD.Memo = string(bytesData)
  210. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  211. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  212. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  213. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  214. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  215. fsiOPFLD.BilgDeptName = department.Name
  216. fsiOPFLD.BilgDeptCodg = department.Number
  217. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  218. fsiOPFLD.BilgDrName = doctor.UserName
  219. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  220. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  221. fsiOPFLD.MedChrgitmType = "08"
  222. memo["hosp_appr_flag"] = "1"
  223. memo["invoice_no"] = order.MdtrtId
  224. memo["memo"] = "自费"
  225. bytesData, _ := json.Marshal(memo)
  226. fsiOPFLD.Memo = string(bytesData)
  227. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  228. }
  229. }
  230. }
  231. for _, items := range order_info_two {
  232. memo := make(map[string]interface{})
  233. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  234. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  235. fsiOPFLD.MedType = "14"
  236. fsiOPFLD.BkkpSn = items.FeedetlSn
  237. fsiOPFLD.FixmedinsCode = miConfig.Code
  238. fsiOPFLD.FixmedinsName = miConfig.OrgName
  239. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  240. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  241. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  242. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  243. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  244. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  245. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  246. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  247. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  248. fsiOPFLD.BilgDeptName = department.Name
  249. fsiOPFLD.BilgDeptCodg = department.Number
  250. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  251. fsiOPFLD.BilgDrName = doctor.UserName
  252. fsiOPFLD.MedChrgitmType = "09"
  253. memo["hosp_appr_flag"] = "1"
  254. memo["invoice_no"] = order.MdtrtId
  255. memo["memo"] = "自费"
  256. bytesData, _ := json.Marshal(memo)
  257. fsiOPFLD.Memo = string(bytesData)
  258. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  259. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  260. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  261. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  262. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  263. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  264. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  265. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  266. fsiOPFLD.BilgDeptName = department.Name
  267. fsiOPFLD.BilgDeptCodg = department.Number
  268. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  269. fsiOPFLD.BilgDrName = doctor.UserName
  270. switch items.HisPrescriptionProject.HisProject.CostClassify {
  271. case 0:
  272. break
  273. case 1:
  274. fsiOPFLD.MedChrgitmType = "14"
  275. break
  276. case 2:
  277. fsiOPFLD.MedChrgitmType = "05"
  278. break
  279. case 3:
  280. fsiOPFLD.MedChrgitmType = "03"
  281. break
  282. case 4:
  283. fsiOPFLD.MedChrgitmType = "03"
  284. break
  285. case 5:
  286. fsiOPFLD.MedChrgitmType = "08"
  287. break
  288. case 6:
  289. fsiOPFLD.MedChrgitmType = "14"
  290. break
  291. case 7:
  292. fsiOPFLD.MedChrgitmType = "14"
  293. break
  294. case 8:
  295. fsiOPFLD.MedChrgitmType = "03"
  296. break
  297. case 9:
  298. fsiOPFLD.MedChrgitmType = "14"
  299. break
  300. case 10:
  301. fsiOPFLD.MedChrgitmType = "14"
  302. break
  303. case 11:
  304. fsiOPFLD.MedChrgitmType = "06"
  305. break
  306. case 12:
  307. fsiOPFLD.MedChrgitmType = "12"
  308. break
  309. case 13:
  310. fsiOPFLD.MedChrgitmType = "01"
  311. break
  312. case 14:
  313. fsiOPFLD.MedChrgitmType = "04"
  314. break
  315. case 15:
  316. fsiOPFLD.MedChrgitmType = "14"
  317. break
  318. }
  319. memo["hosp_appr_flag"] = "1"
  320. memo["invoice_no"] = order.MdtrtId
  321. memo["memo"] = "自费"
  322. bytesData, _ := json.Marshal(memo)
  323. fsiOPFLD.Memo = string(bytesData)
  324. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  325. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  326. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  327. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  328. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  329. fsiOPFLD.BilgDeptName = department.Name
  330. fsiOPFLD.BilgDeptCodg = department.Number
  331. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  332. fsiOPFLD.BilgDrName = doctor.UserName
  333. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  334. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  335. fsiOPFLD.MedChrgitmType = "08"
  336. memo["hosp_appr_flag"] = "1"
  337. memo["invoice_no"] = order.MdtrtId
  338. memo["memo"] = "自费"
  339. bytesData, _ := json.Marshal(memo)
  340. fsiOPFLD.Memo = string(bytesData)
  341. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  342. }
  343. }
  344. }
  345. fmt.Println(fsiOPFLDs)
  346. struct4201A.Fopfd = fsiOPFLDs
  347. fmt.Println(struct4201A.Fopfd)
  348. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  349. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  350. var res2 ResultSix
  351. var respJSON2 map[string]interface{}
  352. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  355. return
  356. }
  357. userJSONBytes2, _ := json.Marshal(respJSON2)
  358. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  359. utils.ErrorLog("解析失败:%v", err)
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  361. return
  362. }
  363. if res2.Infcode != 0 {
  364. c.ServeSuccessJSON(map[string]interface{}{
  365. "failed_code": -10,
  366. "msg": res2.ErrMsg,
  367. })
  368. return
  369. } else {
  370. order.IsUploadOrderInfo = 1
  371. service.UpdateOrder(order)
  372. c.ServeSuccessJSON(map[string]interface{}{
  373. "msg": "上传成功",
  374. })
  375. }
  376. }
  377. func (c *HisApiController) Get4202() {
  378. order_id, _ := c.GetInt64("order_id")
  379. admin_user_id, _ := c.GetInt64("admin_user_id")
  380. order, _ := service.GetHisOrderByIDTwo(order_id)
  381. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  382. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  383. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  384. if order.ID == 0 {
  385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  386. return
  387. }
  388. var struct4202 models.Struct4202
  389. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  390. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  391. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  392. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  393. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  394. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  395. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  396. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  397. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  398. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  399. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  400. var config []*models.HisXtDiagnoseConfig
  401. for _, item := range diagnosis_ids {
  402. id, _ := strconv.ParseInt(item, 10, 64)
  403. diagnosisConfig, _ := service.FindDiagnoseById(id)
  404. config = append(config, &diagnosisConfig)
  405. }
  406. var tempDiaginfos []models.OwnPayPatnDiagListD
  407. for index, item := range config {
  408. if index == 0 {
  409. var tempDiaginfo models.OwnPayPatnDiagListD
  410. tempDiaginfo.InoutDiagType = "1"
  411. tempDiaginfo.DiagCode = item.CountryCode
  412. tempDiaginfo.DiagName = item.CountryContentName
  413. tempDiaginfo.DiagType = "1"
  414. tempDiaginfo.DiagSrtNo = "1"
  415. tempDiaginfo.MaindiagFlag = "1"
  416. tempDiaginfo.ValiFlag = "1"
  417. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  418. } else {
  419. var tempDiaginfo models.OwnPayPatnDiagListD
  420. tempDiaginfo.DiagCode = item.CountryCode
  421. tempDiaginfo.DiagName = item.CountryContentName
  422. tempDiaginfo.DiagType = "2"
  423. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  424. tempDiaginfo.MaindiagFlag = "0"
  425. tempDiaginfo.ValiFlag = "1"
  426. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  427. }
  428. }
  429. struct4202.ODiagListD = tempDiaginfos
  430. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  431. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  432. var res2 ResultSix
  433. var respJSON2 map[string]interface{}
  434. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  437. return
  438. }
  439. userJSONBytes2, _ := json.Marshal(respJSON2)
  440. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  441. utils.ErrorLog("解析失败:%v", err)
  442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  443. return
  444. }
  445. if res2.Infcode != 0 {
  446. c.ServeSuccessJSON(map[string]interface{}{
  447. "failed_code": -10,
  448. "msg": res2.ErrMsg,
  449. })
  450. return
  451. } else {
  452. order.IsUploadDiagnose = 1
  453. service.UpdateOrder(order)
  454. c.ServeSuccessJSON(map[string]interface{}{
  455. "msg": "上传成功",
  456. })
  457. }
  458. }
  459. func (c *HisApiController) Get4203() {
  460. admin_user_id, _ := c.GetInt64("admin_user_id")
  461. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  462. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  463. order_id, _ := c.GetInt64("order_id")
  464. order, _ := service.GetHisOrderByIDTwo(order_id)
  465. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  466. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, his.Number)
  467. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  468. var res2 ResultSix
  469. var respJSON2 map[string]interface{}
  470. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  473. return
  474. }
  475. userJSONBytes2, _ := json.Marshal(respJSON2)
  476. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  477. utils.ErrorLog("解析失败:%v", err)
  478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  479. return
  480. }
  481. if res2.Infcode != 0 {
  482. c.ServeSuccessJSON(map[string]interface{}{
  483. "failed_code": -10,
  484. "msg": res2.ErrMsg,
  485. })
  486. return
  487. } else {
  488. order.IsUploadSuccess = 1
  489. service.UpdateOrder(order)
  490. c.ServeSuccessJSON(map[string]interface{}{
  491. "msg": "上传成功",
  492. })
  493. }
  494. }
  495. func (c *HisApiController) Get4205() {
  496. order_id, _ := c.GetInt64("order_id")
  497. admin_user_id, _ := c.GetInt64("admin_user_id")
  498. order, _ := service.GetHisOrderByIDTwo(order_id)
  499. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  500. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  501. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  502. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  503. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  504. //order_info = append(order_info, order_info_two...)
  505. department, _ := service.GetDepartMentDetail(his.Departments)
  506. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  507. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  508. if order.ID == 0 {
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  510. return
  511. }
  512. var struct4201A models.Struct4201A
  513. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  514. for _, items := range order_info {
  515. memo := make(map[string]interface{})
  516. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  517. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  518. fsiOPFLD.MedType = "14"
  519. fsiOPFLD.BkkpSn = items.FeedetlSn
  520. fsiOPFLD.FixmedinsCode = miConfig.Code
  521. fsiOPFLD.FixmedinsName = miConfig.OrgName
  522. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  523. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  524. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  525. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  526. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  527. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  528. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  529. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  530. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  531. fsiOPFLD.BilgDeptName = department.Name
  532. fsiOPFLD.BilgDeptCodg = department.Number
  533. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  534. fsiOPFLD.BilgDrName = doctor.UserName
  535. fsiOPFLD.MedChrgitmType = "09"
  536. memo["hosp_appr_flag"] = "1"
  537. memo["invoice_no"] = order.MdtrtId
  538. memo["memo"] = "自费"
  539. bytesData, _ := json.Marshal(memo)
  540. fsiOPFLD.Memo = string(bytesData)
  541. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  542. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  543. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  544. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  545. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  546. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  547. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  548. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  549. fsiOPFLD.BilgDeptName = department.Name
  550. fsiOPFLD.BilgDeptCodg = department.Number
  551. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  552. fsiOPFLD.BilgDrName = doctor.UserName
  553. switch items.HisPrescriptionProject.HisProject.CostClassify {
  554. case 0:
  555. break
  556. case 1:
  557. fsiOPFLD.MedChrgitmType = "14"
  558. break
  559. case 2:
  560. fsiOPFLD.MedChrgitmType = "05"
  561. break
  562. case 3:
  563. fsiOPFLD.MedChrgitmType = "03"
  564. break
  565. case 4:
  566. fsiOPFLD.MedChrgitmType = "03"
  567. break
  568. case 5:
  569. fsiOPFLD.MedChrgitmType = "08"
  570. break
  571. case 6:
  572. fsiOPFLD.MedChrgitmType = "14"
  573. break
  574. case 7:
  575. fsiOPFLD.MedChrgitmType = "14"
  576. break
  577. case 8:
  578. fsiOPFLD.MedChrgitmType = "03"
  579. break
  580. case 9:
  581. fsiOPFLD.MedChrgitmType = "14"
  582. break
  583. case 10:
  584. fsiOPFLD.MedChrgitmType = "14"
  585. break
  586. case 11:
  587. fsiOPFLD.MedChrgitmType = "06"
  588. break
  589. case 12:
  590. fsiOPFLD.MedChrgitmType = "12"
  591. break
  592. case 13:
  593. fsiOPFLD.MedChrgitmType = "01"
  594. break
  595. case 14:
  596. fsiOPFLD.MedChrgitmType = "04"
  597. break
  598. case 15:
  599. fsiOPFLD.MedChrgitmType = "14"
  600. break
  601. }
  602. memo["hosp_appr_flag"] = "1"
  603. memo["invoice_no"] = order.MdtrtId
  604. memo["memo"] = "自费"
  605. bytesData, _ := json.Marshal(memo)
  606. fsiOPFLD.Memo = string(bytesData)
  607. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  608. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  609. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  610. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  611. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  612. fsiOPFLD.BilgDeptName = department.Name
  613. fsiOPFLD.BilgDeptCodg = department.Number
  614. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  615. fsiOPFLD.BilgDrName = doctor.UserName
  616. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  617. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  618. fsiOPFLD.MedChrgitmType = "08"
  619. memo["hosp_appr_flag"] = "1"
  620. memo["invoice_no"] = order.MdtrtId
  621. memo["memo"] = "自费"
  622. bytesData, _ := json.Marshal(memo)
  623. fsiOPFLD.Memo = string(bytesData)
  624. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  625. }
  626. }
  627. }
  628. for _, items := range order_info_two {
  629. memo := make(map[string]interface{})
  630. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  631. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  632. fsiOPFLD.MedType = "14"
  633. fsiOPFLD.BkkpSn = items.FeedetlSn
  634. fsiOPFLD.FixmedinsCode = miConfig.Code
  635. fsiOPFLD.FixmedinsName = miConfig.OrgName
  636. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  637. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  638. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  639. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  640. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  641. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  642. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  643. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  644. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  645. fsiOPFLD.BilgDeptName = department.Name
  646. fsiOPFLD.BilgDeptCodg = department.Number
  647. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  648. fsiOPFLD.BilgDrName = doctor.UserName
  649. fsiOPFLD.MedChrgitmType = "09"
  650. memo["hosp_appr_flag"] = "1"
  651. memo["invoice_no"] = order.MdtrtId
  652. memo["memo"] = "自费"
  653. bytesData, _ := json.Marshal(memo)
  654. fsiOPFLD.Memo = string(bytesData)
  655. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  656. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  657. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  658. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  659. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  660. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  661. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  662. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  663. fsiOPFLD.BilgDeptName = department.Name
  664. fsiOPFLD.BilgDeptCodg = department.Number
  665. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  666. fsiOPFLD.BilgDrName = doctor.UserName
  667. switch items.HisPrescriptionProject.HisProject.CostClassify {
  668. case 0:
  669. break
  670. case 1:
  671. fsiOPFLD.MedChrgitmType = "14"
  672. break
  673. case 2:
  674. fsiOPFLD.MedChrgitmType = "05"
  675. break
  676. case 3:
  677. fsiOPFLD.MedChrgitmType = "03"
  678. break
  679. case 4:
  680. fsiOPFLD.MedChrgitmType = "03"
  681. break
  682. case 5:
  683. fsiOPFLD.MedChrgitmType = "08"
  684. break
  685. case 6:
  686. fsiOPFLD.MedChrgitmType = "14"
  687. break
  688. case 7:
  689. fsiOPFLD.MedChrgitmType = "14"
  690. break
  691. case 8:
  692. fsiOPFLD.MedChrgitmType = "03"
  693. break
  694. case 9:
  695. fsiOPFLD.MedChrgitmType = "14"
  696. break
  697. case 10:
  698. fsiOPFLD.MedChrgitmType = "14"
  699. break
  700. case 11:
  701. fsiOPFLD.MedChrgitmType = "06"
  702. break
  703. case 12:
  704. fsiOPFLD.MedChrgitmType = "12"
  705. break
  706. case 13:
  707. fsiOPFLD.MedChrgitmType = "01"
  708. break
  709. case 14:
  710. fsiOPFLD.MedChrgitmType = "04"
  711. break
  712. case 15:
  713. fsiOPFLD.MedChrgitmType = "14"
  714. break
  715. }
  716. memo["hosp_appr_flag"] = "1"
  717. memo["invoice_no"] = order.MdtrtId
  718. memo["memo"] = "自费"
  719. bytesData, _ := json.Marshal(memo)
  720. fsiOPFLD.Memo = string(bytesData)
  721. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  722. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  723. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  724. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  725. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  726. fsiOPFLD.BilgDeptName = department.Name
  727. fsiOPFLD.BilgDeptCodg = department.Number
  728. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  729. fsiOPFLD.BilgDrName = doctor.UserName
  730. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  731. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  732. fsiOPFLD.MedChrgitmType = "08"
  733. memo["hosp_appr_flag"] = "1"
  734. memo["invoice_no"] = order.MdtrtId
  735. memo["memo"] = "自费"
  736. bytesData, _ := json.Marshal(memo)
  737. fsiOPFLD.Memo = string(bytesData)
  738. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  739. }
  740. }
  741. }
  742. fmt.Println(fsiOPFLDs)
  743. struct4201A.Fopfd = fsiOPFLDs
  744. fmt.Println(struct4201A.Fopfd)
  745. var struct4202 models.Struct4202
  746. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  747. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  748. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  749. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  750. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  751. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  752. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  753. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  754. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  755. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  756. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  757. var config []*models.HisXtDiagnoseConfig
  758. for _, item := range diagnosis_ids {
  759. id, _ := strconv.ParseInt(item, 10, 64)
  760. diagnosisConfig, _ := service.FindDiagnoseById(id)
  761. config = append(config, &diagnosisConfig)
  762. }
  763. var tempDiaginfos []models.OwnPayPatnDiagListD
  764. for index, item := range config {
  765. if index == 0 {
  766. var tempDiaginfo models.OwnPayPatnDiagListD
  767. tempDiaginfo.InoutDiagType = "1"
  768. tempDiaginfo.DiagCode = item.CountryCode
  769. tempDiaginfo.DiagName = item.CountryContentName
  770. tempDiaginfo.DiagType = "1"
  771. tempDiaginfo.DiagSrtNo = "1"
  772. tempDiaginfo.MaindiagFlag = "1"
  773. tempDiaginfo.ValiFlag = "1"
  774. tempDiaginfo.DiagDrName = doctor.UserName
  775. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  776. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  777. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  778. } else {
  779. var tempDiaginfo models.OwnPayPatnDiagListD
  780. tempDiaginfo.DiagCode = item.CountryCode
  781. tempDiaginfo.DiagName = item.CountryContentName
  782. tempDiaginfo.DiagType = "2"
  783. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  784. tempDiaginfo.MaindiagFlag = "0"
  785. tempDiaginfo.ValiFlag = "1"
  786. tempDiaginfo.DiagDrName = doctor.UserName
  787. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  788. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  789. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  790. }
  791. }
  792. struct4202.ODiagListD = tempDiaginfos
  793. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  794. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  795. var res2 ResultSix
  796. var respJSON2 map[string]interface{}
  797. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  800. return
  801. }
  802. userJSONBytes2, _ := json.Marshal(respJSON2)
  803. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  804. utils.ErrorLog("解析失败:%v", err)
  805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  806. return
  807. }
  808. if res2.Infcode != 0 {
  809. c.ServeSuccessJSON(map[string]interface{}{
  810. "failed_code": -10,
  811. "msg": res2.ErrMsg,
  812. })
  813. return
  814. } else {
  815. order.IsUploadDiagnose = 1
  816. order.IsUploadOrderInfo = 1
  817. service.UpdateOrder(order)
  818. c.ServeSuccessJSON(map[string]interface{}{
  819. "msg": "上传成功",
  820. })
  821. }
  822. }
  823. func (c *HisApiController) Get4207() {
  824. admin_user_id, _ := c.GetInt64("admin_user_id")
  825. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  826. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  827. order_id, _ := c.GetInt64("order_id")
  828. order, _ := service.GetHisOrderByIDTwo(order_id)
  829. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  830. var struct4207 models.Struct4207
  831. struct4207.PageNum = "1"
  832. struct4207.PageSize = "1000"
  833. struct4207.FixmedinsCode = miConfig.Code
  834. struct4207.FixmedinsMdtrtID = order.Number
  835. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  836. saveLog(result, requestLog, "4207", "查询")
  837. var res2 ResultSix
  838. var respJSON2 map[string]interface{}
  839. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  842. return
  843. }
  844. userJSONBytes2, _ := json.Marshal(respJSON2)
  845. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  846. utils.ErrorLog("解析失败:%v", err)
  847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  848. return
  849. }
  850. if res2.Infcode != 0 {
  851. c.ServeSuccessJSON(map[string]interface{}{
  852. "failed_code": -10,
  853. "msg": res2.ErrMsg,
  854. })
  855. return
  856. } else {
  857. c.ServeSuccessJSON(map[string]interface{}{
  858. "msg": "查询成功",
  859. })
  860. }
  861. }
  862. func (c *HisApiController) Get4208() {
  863. admin_user_id, _ := c.GetInt64("admin_user_id")
  864. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  865. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  866. order_id, _ := c.GetInt64("order_id")
  867. order, _ := service.GetHisOrderByIDTwo(order_id)
  868. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  869. var struct4208 models.Struct4208
  870. struct4208.PageNum = "1"
  871. struct4208.PageSize = "1000"
  872. struct4208.PsnCertType = "01"
  873. struct4208.Certno = his.Certno
  874. struct4208.MedType = order.MedType
  875. struct4208.PsnName = his.Name
  876. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  877. saveLog(result, requestLog, "4208", "查询")
  878. var res2 ResultSix
  879. var respJSON2 map[string]interface{}
  880. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  883. return
  884. }
  885. userJSONBytes2, _ := json.Marshal(respJSON2)
  886. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  887. utils.ErrorLog("解析失败:%v", err)
  888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  889. return
  890. }
  891. if res2.Infcode != 0 {
  892. c.ServeSuccessJSON(map[string]interface{}{
  893. "failed_code": -10,
  894. "msg": res2.ErrMsg,
  895. })
  896. return
  897. } else {
  898. c.ServeSuccessJSON(map[string]interface{}{
  899. "msg": "查询成功",
  900. })
  901. }
  902. }
  903. func (c *HisApiController) Get4209() {
  904. admin_user_id, _ := c.GetInt64("admin_user_id")
  905. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  906. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  907. order_id, _ := c.GetInt64("order_id")
  908. order, _ := service.GetHisOrderByIDTwo(order_id)
  909. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  910. var struct4209 models.Struct4209
  911. struct4209.FixmedinsMdtrtID = order.Number
  912. struct4209.FixmedinsCode = miConfig.Code
  913. struct4209.PageSize = "1000"
  914. struct4209.PageNum = "1"
  915. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  916. saveLog(result, requestLog, "4209", "查询")
  917. var res2 ResultSix
  918. var respJSON2 map[string]interface{}
  919. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  922. return
  923. }
  924. userJSONBytes2, _ := json.Marshal(respJSON2)
  925. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  926. utils.ErrorLog("解析失败:%v", err)
  927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  928. return
  929. }
  930. if res2.Infcode != 0 {
  931. c.ServeSuccessJSON(map[string]interface{}{
  932. "failed_code": -10,
  933. "msg": res2.ErrMsg,
  934. })
  935. return
  936. } else {
  937. c.ServeSuccessJSON(map[string]interface{}{
  938. "msg": "查询成功",
  939. })
  940. }
  941. }
  942. type Result3101 struct {
  943. Infcode string `json:"infcode"`
  944. InfRefmsgid string `json:"inf_refmsgid"`
  945. RefmsgTime string `json:"refmsg_time"`
  946. RespondTime string `json:"respond_time"`
  947. Enctype string `json:"enctype"`
  948. Signtype string `json:"signtype"`
  949. ErrMsg string `json:"err_msg"`
  950. Output struct {
  951. Result []struct {
  952. JudgeResultDetailDtos []struct {
  953. VolaItemType string `json:"vola_item_type"`
  954. MdtrtID string `json:"mdtrt_id"`
  955. JrdID string `json:"jrd_id"`
  956. PatnID string `json:"patn_id"`
  957. RxID string `json:"rx_id"`
  958. VolaAmt interface{} `json:"vola_amt"`
  959. } `json:"judge_result_detail_dtos"`
  960. RuleID string `json:"rule_id"`
  961. VolaEvid string `json:"vola_evid"`
  962. MdtrtID string `json:"mdtrt_id"`
  963. RuleName string `json:"rule_name"`
  964. VolaAmtStas string `json:"vola_amt_stas"`
  965. JrID string `json:"jr_id"`
  966. PatnID string `json:"patn_id"`
  967. SevDeg string `json:"sev_deg"`
  968. VolaAmt float64 `json:"vola_amt"`
  969. VolaBhvrType string `json:"vola_bhvr_type"`
  970. VolaCont string `json:"vola_cont"`
  971. } `json:"result"`
  972. } `json:"output"`
  973. }
  974. func (c *HisApiController) ReadEleToken() {
  975. admin_user_id, _ := c.GetInt64("admin_user_id")
  976. his_patient_id, _ := c.GetInt64("his_patient_id")
  977. adminUser := c.GetAdminUserInfo()
  978. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  979. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  980. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  981. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  982. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  983. if len(tokens) > 0 {
  984. c.ServeSuccessJSON(map[string]interface{}{
  985. "msg": "读取成功",
  986. })
  987. } else {
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": "读取失败",
  991. })
  992. }
  993. } else if miConfig.MdtrtareaAdmvs == "350500" {
  994. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  995. if len(errMsg) == 0 {
  996. type ELeData struct {
  997. Data struct {
  998. IdNo string `json:"idNo"`
  999. IdType string `json:"idType"`
  1000. UserName string `json:"userName"`
  1001. EcToken string `json:"ecToken"`
  1002. InsuOrg string `json:"insuOrg"`
  1003. Gender string `json:"gender"`
  1004. Birthday string `json:"birthday"`
  1005. Nationality string `json:"nationality"`
  1006. Email string `json:"email"`
  1007. Extra string `json:"extra"`
  1008. } `json:"data"`
  1009. Code int `json:"code"`
  1010. Message string `json:"message"`
  1011. }
  1012. var ele ELeData
  1013. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1014. if err != nil {
  1015. utils.ErrorLog("解析失败:%v", err)
  1016. }
  1017. token := ele.Data.EcToken
  1018. if len(token) > 0 {
  1019. psn := &models.HisPsn{
  1020. PsnNo: his.PsnNo,
  1021. Age: 0,
  1022. PatientId: his.PatientId,
  1023. Certno: his.Certno,
  1024. Brdy: his.Brdy,
  1025. Gend: his.Gend,
  1026. Naty: his.Naty,
  1027. PsnCertType: his.PsnCertType,
  1028. PsnName: his.PsnName,
  1029. Idetinfo: his.Idetinfo,
  1030. Insuinfo: his.Iinfo,
  1031. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1032. CardInfo: outPutInfo,
  1033. VerifyNumber: token,
  1034. }
  1035. service.CreateHisPsn(psn)
  1036. }
  1037. if len(token) > 0 {
  1038. c.ServeSuccessJSON(map[string]interface{}{
  1039. "msg": "读取成功",
  1040. })
  1041. } else {
  1042. c.ServeSuccessJSON(map[string]interface{}{
  1043. "failed_code": -10,
  1044. "msg": "读取失败",
  1045. })
  1046. }
  1047. }
  1048. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1049. if initFlag == 0 {
  1050. c.TestGetJiangXiBasBaseInit()
  1051. }
  1052. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1053. type ELeData struct {
  1054. Data struct {
  1055. IdNo string `json:"idNo"`
  1056. IdType string `json:"idType"`
  1057. UserName string `json:"userName"`
  1058. EcToken string `json:"ecToken"`
  1059. InsuOrg string `json:"insuOrg"`
  1060. Gender string `json:"gender"`
  1061. Birthday string `json:"birthday"`
  1062. Nationality string `json:"nationality"`
  1063. Email string `json:"email"`
  1064. Extra string `json:"extra"`
  1065. } `json:"data"`
  1066. Code int `json:"code"`
  1067. Message string `json:"message"`
  1068. }
  1069. var ele ELeData
  1070. err := json.Unmarshal([]byte(json_result), &ele)
  1071. if err != nil {
  1072. utils.ErrorLog("解析失败:%v", err)
  1073. }
  1074. token := ele.Data.EcToken
  1075. token = Remove0000(token)
  1076. fmt.Println(ele.Data.UserName)
  1077. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  1078. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1079. var res ResultTwo
  1080. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1081. utils.ErrorLog("解析失败:%v", err)
  1082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1083. return
  1084. }
  1085. if res.Infcode == 0 {
  1086. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1087. if err == gorm.ErrRecordNotFound {
  1088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1089. return
  1090. } else if err != nil {
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1092. return
  1093. } else {
  1094. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1095. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1096. infoStr := string(Iinfos)
  1097. idetinfoStr := string(Idetinfos)
  1098. psn := &models.HisPsn{
  1099. PsnNo: res.Output.Baseinfo.PsnNo,
  1100. Age: res.Output.Baseinfo.Age,
  1101. PatientId: patient.ID,
  1102. Certno: res.Output.Baseinfo.Certno,
  1103. Brdy: res.Output.Baseinfo.Brdy,
  1104. Gend: res.Output.Baseinfo.Gend,
  1105. Naty: res.Output.Baseinfo.Naty,
  1106. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1107. PsnName: res.Output.Baseinfo.PsnName,
  1108. Idetinfo: idetinfoStr,
  1109. Insuinfo: infoStr,
  1110. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1111. CardInfo: "",
  1112. VerifyNumber: token,
  1113. }
  1114. service.CreateHisPsn(psn)
  1115. c.ServeSuccessJSON(map[string]interface{}{
  1116. "patient": patient,
  1117. "number": token,
  1118. })
  1119. }
  1120. } else {
  1121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1122. return
  1123. }
  1124. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1125. if initFlag == 0 {
  1126. c.TestGetJiangXiBasBaseInit()
  1127. }
  1128. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1129. type ELeData struct {
  1130. Data struct {
  1131. IdNo string `json:"idNo"`
  1132. IdType string `json:"idType"`
  1133. UserName string `json:"userName"`
  1134. EcToken string `json:"ecToken"`
  1135. InsuOrg string `json:"insuOrg"`
  1136. Gender string `json:"gender"`
  1137. Birthday string `json:"birthday"`
  1138. Nationality string `json:"nationality"`
  1139. Email string `json:"email"`
  1140. Extra string `json:"extra"`
  1141. } `json:"data"`
  1142. Code int `json:"code"`
  1143. Message string `json:"message"`
  1144. }
  1145. var ele ELeData
  1146. err := json.Unmarshal([]byte(json_result), &ele)
  1147. if err != nil {
  1148. utils.ErrorLog("解析失败:%v", err)
  1149. }
  1150. token := ele.Data.EcToken
  1151. token = Remove0000(token)
  1152. fmt.Println(ele.Data.UserName)
  1153. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  1154. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1155. var res ResultTwo
  1156. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1157. utils.ErrorLog("解析失败:%v", err)
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1159. return
  1160. }
  1161. if res.Infcode == 0 {
  1162. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1163. if err == gorm.ErrRecordNotFound {
  1164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1165. return
  1166. } else if err != nil {
  1167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1168. return
  1169. } else {
  1170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1171. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1172. infoStr := string(Iinfos)
  1173. idetinfoStr := string(Idetinfos)
  1174. psn := &models.HisPsn{
  1175. PsnNo: res.Output.Baseinfo.PsnNo,
  1176. Age: res.Output.Baseinfo.Age,
  1177. PatientId: patient.ID,
  1178. Certno: res.Output.Baseinfo.Certno,
  1179. Brdy: res.Output.Baseinfo.Brdy,
  1180. Gend: res.Output.Baseinfo.Gend,
  1181. Naty: res.Output.Baseinfo.Naty,
  1182. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1183. PsnName: res.Output.Baseinfo.PsnName,
  1184. Idetinfo: idetinfoStr,
  1185. Insuinfo: infoStr,
  1186. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1187. CardInfo: "",
  1188. VerifyNumber: token,
  1189. }
  1190. service.CreateHisPsn(psn)
  1191. c.ServeSuccessJSON(map[string]interface{}{
  1192. "patient": patient,
  1193. "number": token,
  1194. })
  1195. }
  1196. } else {
  1197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1198. return
  1199. }
  1200. } else {
  1201. if initFlag == 0 {
  1202. c.TestGetBasBaseInit()
  1203. }
  1204. token := c.GetEleBaseInfo()
  1205. token = Remove0000(token)
  1206. if len(token) > 0 {
  1207. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  1208. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1209. var res ResultTwo
  1210. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1211. utils.ErrorLog("解析失败:%v", err)
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. if res.Infcode == 0 {
  1216. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1217. if err == gorm.ErrRecordNotFound {
  1218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1219. return
  1220. } else if err != nil {
  1221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1222. return
  1223. } else {
  1224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1226. infoStr := string(Iinfos)
  1227. idetinfoStr := string(Idetinfos)
  1228. psn := &models.HisPsn{
  1229. PsnNo: res.Output.Baseinfo.PsnNo,
  1230. Age: res.Output.Baseinfo.Age,
  1231. PatientId: patient.ID,
  1232. Certno: res.Output.Baseinfo.Certno,
  1233. Brdy: res.Output.Baseinfo.Brdy,
  1234. Gend: res.Output.Baseinfo.Gend,
  1235. Naty: res.Output.Baseinfo.Naty,
  1236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1237. PsnName: res.Output.Baseinfo.PsnName,
  1238. Idetinfo: idetinfoStr,
  1239. Insuinfo: infoStr,
  1240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1241. CardInfo: "",
  1242. VerifyNumber: token,
  1243. }
  1244. service.CreateHisPsn(psn)
  1245. c.ServeSuccessJSON(map[string]interface{}{
  1246. "msg": "读取成功",
  1247. })
  1248. }
  1249. } else {
  1250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1251. return
  1252. }
  1253. } else {
  1254. c.ServeSuccessJSON(map[string]interface{}{
  1255. "failed_code": -10,
  1256. "msg": "读取失败",
  1257. })
  1258. }
  1259. }
  1260. }
  1261. func (c *HisApiController) Get9001() {
  1262. adminUser := c.GetAdminUserInfo()
  1263. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1264. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  1265. if miConfig.MdtrtareaAdmvs == "350500" {
  1266. service.GetFjAuthorizationInfo(miConfig.Code)
  1267. } else if miConfig.MdtrtareaAdmvs == "131023" {
  1268. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1269. var dat map[string]interface{}
  1270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1271. fmt.Println(dat)
  1272. } else {
  1273. fmt.Println(err)
  1274. }
  1275. userJSONBytes, _ := json.Marshal(dat)
  1276. var res models.Result9001
  1277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1278. utils.ErrorLog("解析失败:%v", err)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. return
  1281. }
  1282. } else {
  1283. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1284. var dat map[string]interface{}
  1285. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1286. fmt.Println(dat)
  1287. } else {
  1288. fmt.Println(err)
  1289. }
  1290. userJSONBytes, _ := json.Marshal(dat)
  1291. var res models.Result9001
  1292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1293. utils.ErrorLog("解析失败:%v", err)
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1295. return
  1296. }
  1297. }
  1298. }
  1299. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  1300. var res Result3101
  1301. adminUser := c.GetAdminUserInfo()
  1302. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1303. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1304. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1305. //record_time := c.GetString("record_time")
  1306. //trig_scen := c.GetString("trig_scen")
  1307. timeLayout := "2006-01-02"
  1308. loc, _ := time.LoadLocation("Local")
  1309. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1310. if err != nil {
  1311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1312. return res
  1313. }
  1314. recordDateTime := theTime.Unix()
  1315. var patientPrescription models.HisPrescriptionInfo
  1316. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1317. //if patientPrescription.ID == 0 {
  1318. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1319. //}
  1320. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1321. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1322. //
  1323. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1324. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1325. var pp models.PublicParams
  1326. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1327. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1328. pp.FixmedinsName = miConfig.OrgName
  1329. pp.FixmedinsCode = miConfig.Code
  1330. pp.RequestUrl = miConfig.Url
  1331. pp.Cainfo = miConfig.Cainfo
  1332. pp.SecretKey = miConfig.SecretKey
  1333. pp.AccessKey = miConfig.AccessKey
  1334. pp.OpterName = roles.UserName
  1335. var config []*models.HisXtDiagnoseConfig
  1336. for _, item := range diagnosis_ids {
  1337. id, _ := strconv.ParseInt(item, 10, 64)
  1338. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1339. config = append(config, &diagnosisConfig)
  1340. }
  1341. var pd models.PatientDtos
  1342. pd.PatnID = his.PsnNo
  1343. pd.PatnName = his.Name
  1344. pd.Gend = his.Gend
  1345. pd.Brdy = his.Brdy
  1346. pd.Poolarea = miConfig.MdtrtareaAdmvs
  1347. pd.CurrMdtrtID = his.Number
  1348. var fed models.FsiEncounterDtos
  1349. fed.MdtrtID = his.Number
  1350. fed.MedinsID = miConfig.Code
  1351. fed.MedinsName = miConfig.OrgName
  1352. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1353. fed.MedMdtrtType = "1"
  1354. fed.MedinsType = "1"
  1355. fed.MedinsLv = "11"
  1356. tm := time.Unix(his.RecordDate, 0)
  1357. s_tm := tm.Format("2006-01-02 15:04:05")
  1358. fed.AdmDate = s_tm
  1359. fed.DscgDate = s_tm
  1360. fed.DscgMainDiseCodg = config[0].CountryCode
  1361. fed.DscgMainDiseName = config[0].CountryContentName
  1362. //诊断信息
  1363. var fdds []*models.FsiDiagnoseDtos
  1364. for index, item := range config {
  1365. if index == 0 {
  1366. var fdd models.FsiDiagnoseDtos
  1367. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1368. fdd.InoutDiseType = "1"
  1369. fdd.MaindiseFlag = "1"
  1370. fdd.DiseDate = s_tm
  1371. fdd.DiasSrtNo = "1"
  1372. fdd.DiseName = item.CountryContentName
  1373. fdd.DiseCodg = item.CountryCode
  1374. fdds = append(fdds, &fdd)
  1375. } else {
  1376. var fdd models.FsiDiagnoseDtos
  1377. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1378. fdd.InoutDiseType = "1"
  1379. fdd.MaindiseFlag = "1"
  1380. fdd.DiseDate = s_tm
  1381. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1382. fdd.DiseName = item.CountryContentName
  1383. fdd.DiseCodg = item.CountryCode
  1384. fdds = append(fdds, &fdd)
  1385. }
  1386. }
  1387. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1388. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1389. fed.AdmDeptName = department.Name
  1390. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1391. fed.DscgDeptName = department.Name
  1392. fed.MedMdtrtType = "1"
  1393. fed.MedType = "11"
  1394. //if his.Insutype == "390" {
  1395. // fed.MedType = "1402"
  1396. //} else {
  1397. // fed.MedType = "9933"
  1398. //}
  1399. var orders []*models.FsiOrderDtos
  1400. if trig_scen == "2" {
  1401. //处方医嘱信息
  1402. for _, item := range prescriptions {
  1403. for _, subItem := range item.HisDoctorAdviceInfo {
  1404. var order models.FsiOrderDtos
  1405. order.RxID = strconv.FormatInt(item.ID, 10)
  1406. order.Rxno = strconv.FormatInt(item.ID, 10)
  1407. order.LongDrordFlag = "0"
  1408. order.HilistType = "1"
  1409. order.ChrgType = "1"
  1410. order.DrordBhvr = "-"
  1411. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1412. order.HosplistName = subItem.BaseDrugLib.DrugName
  1413. order.HilistLv = "1"
  1414. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1415. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1416. order.HosplistName = subItem.BaseDrugLib.DrugName
  1417. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1418. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1419. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1420. order.OwnpayAmt = ""
  1421. order.SelfpayAmt = ""
  1422. order.Spec = ""
  1423. order.SpecUnt = ""
  1424. order.DrordBegnDate = s_tm
  1425. order.DrordStopDate = ""
  1426. order.DrordDrCodg = "1"
  1427. order.DrordDeptName = department.Name
  1428. order.DrordDrCodg = "1"
  1429. order.DrordDrName = doctor_info.UserName
  1430. order.DrordDrProfttl = ""
  1431. order.CurrDrordFlag = "1"
  1432. orders = append(orders, &order)
  1433. }
  1434. for _, subItem := range item.HisPrescriptionProject {
  1435. if subItem.Type == 2 {
  1436. var order models.FsiOrderDtos
  1437. order.RxID = strconv.FormatInt(item.ID, 10)
  1438. order.Rxno = strconv.FormatInt(item.ID, 10)
  1439. order.LongDrordFlag = "0"
  1440. order.HilistType = "1"
  1441. order.ChrgType = "1"
  1442. order.DrordBhvr = "-"
  1443. order.HilistCode = subItem.HisProject.MedicalCode
  1444. order.HosplistName = subItem.HisProject.ProjectName
  1445. order.HilistLv = "1"
  1446. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1447. order.HosplistCode = subItem.HisProject.MedicalCode
  1448. order.HosplistName = subItem.HisProject.ProjectName
  1449. order.Cnt = subItem.Count
  1450. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1451. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1452. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1453. order.OwnpayAmt = ""
  1454. order.SelfpayAmt = ""
  1455. order.Spec = ""
  1456. order.SpecUnt = ""
  1457. order.DrordBegnDate = s_tm
  1458. order.DrordStopDate = ""
  1459. order.DrordDrCodg = "1"
  1460. order.DrordDeptName = department.Name
  1461. order.DrordDrCodg = "1"
  1462. order.DrordDrName = doctor_info.UserName
  1463. order.DrordDrProfttl = ""
  1464. order.CurrDrordFlag = "1"
  1465. orders = append(orders, &order)
  1466. }
  1467. if subItem.Type == 3 {
  1468. var order models.FsiOrderDtos
  1469. order.RxID = strconv.FormatInt(item.ID, 10)
  1470. order.Rxno = strconv.FormatInt(item.ID, 10)
  1471. order.LongDrordFlag = "0"
  1472. order.HilistType = "1"
  1473. order.ChrgType = "1"
  1474. order.DrordBhvr = "-"
  1475. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1476. order.HosplistName = subItem.GoodInfo.GoodName
  1477. order.HilistLv = "1"
  1478. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1479. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1480. order.HosplistName = subItem.GoodInfo.GoodName
  1481. order.Cnt = subItem.Count
  1482. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1483. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1484. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1485. order.OwnpayAmt = ""
  1486. order.SelfpayAmt = ""
  1487. order.Spec = ""
  1488. order.SpecUnt = ""
  1489. order.DrordBegnDate = s_tm
  1490. order.DrordStopDate = ""
  1491. order.DrordDrCodg = "1"
  1492. order.DrordDeptName = department.Name
  1493. order.DrordDrCodg = "1"
  1494. order.DrordDrName = doctor_info.UserName
  1495. order.DrordDrProfttl = ""
  1496. order.CurrDrordFlag = "1"
  1497. orders = append(orders, &order)
  1498. }
  1499. }
  1500. }
  1501. //处方医嘱信息
  1502. }
  1503. fed.MatnStas = "0"
  1504. fed.MedfeeSumamt = "0"
  1505. fed.OwnpayAmt = "0"
  1506. fed.SelfpayAmt = "0"
  1507. fed.AcctPayamt = "0"
  1508. fed.MaAmt = "0"
  1509. fed.HifpPayamt = "0"
  1510. fed.SetlTotlnum = "1"
  1511. fed.Insutype = his.Insutype
  1512. fed.ReimFlag = "0"
  1513. fed.OutSetlFlag = "0"
  1514. var fopd []*models.FsiOperationDtosData
  1515. data := make(map[string]interface{})
  1516. data["fed"] = fed
  1517. data["fdd"] = fdds
  1518. data["fod"] = orders
  1519. data["pd"] = pd
  1520. data["pp"] = pp
  1521. data["fopd"] = fopd
  1522. data["trig_scen"] = trig_scen
  1523. fmt.Println(data)
  1524. fmt.Println(fed)
  1525. fmt.Println(fdds)
  1526. fmt.Println(orders)
  1527. fmt.Println(pd)
  1528. fmt.Println(pp)
  1529. fmt.Println(fopd)
  1530. client := &http.Client{}
  1531. bytesData, _ := json.Marshal(data)
  1532. var req *http.Request
  1533. if miConfig.MdtrtareaAdmvs == "320921" {
  1534. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1535. } else {
  1536. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1537. }
  1538. resp, _ := client.Do(req)
  1539. defer resp.Body.Close()
  1540. body, ioErr := ioutil.ReadAll(resp.Body)
  1541. if ioErr != nil {
  1542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1544. return res
  1545. }
  1546. var respJSON map[string]interface{}
  1547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1550. return res
  1551. }
  1552. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1553. fmt.Println(respJSON)
  1554. result, _ := json.Marshal(respJSON)
  1555. fmt.Println(result)
  1556. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1557. utils.ErrorLog("解析失败:%v", err)
  1558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1559. return res
  1560. }
  1561. return res
  1562. }
  1563. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  1564. adminUser := c.GetAdminUserInfo()
  1565. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1566. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1567. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1568. //record_time := c.GetString("record_time")
  1569. //trig_scen := c.GetString("trig_scen")
  1570. timeLayout := "2006-01-02"
  1571. loc, _ := time.LoadLocation("Local")
  1572. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1573. if err != nil {
  1574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1575. return res
  1576. }
  1577. recordDateTime := theTime.Unix()
  1578. var patientPrescription models.HisPrescriptionInfo
  1579. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1580. if patientPrescription.ID == 0 {
  1581. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1582. }
  1583. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1584. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1585. //
  1586. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1587. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1588. var pp models.PublicParams
  1589. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1590. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1591. pp.FixmedinsName = miConfig.OrgName
  1592. pp.FixmedinsCode = miConfig.Code
  1593. pp.RequestUrl = miConfig.Url
  1594. pp.Cainfo = miConfig.Cainfo
  1595. pp.SecretKey = miConfig.SecretKey
  1596. pp.AccessKey = miConfig.AccessKey
  1597. pp.OpterName = roles.UserName
  1598. var config []*models.HisXtDiagnoseConfig
  1599. for _, item := range diagnosis_ids {
  1600. id, _ := strconv.ParseInt(item, 10, 64)
  1601. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1602. config = append(config, &diagnosisConfig)
  1603. }
  1604. var pd models.PatientDtos
  1605. pd.PatnID = his.PsnNo
  1606. pd.PatnName = his.Name
  1607. pd.Gend = his.Gend
  1608. pd.Brdy = his.Brdy
  1609. pd.Poolarea = his.InsuplcAdmdvs
  1610. pd.CurrMdtrtID = his.Number
  1611. var fed models.FsiEncounterDtos
  1612. fed.MdtrtID = his.Number
  1613. fed.MedinsID = miConfig.Code
  1614. fed.MedinsName = miConfig.OrgName
  1615. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1616. fed.MedMdtrtType = "1"
  1617. fed.MedinsType = "1"
  1618. fed.MedinsLv = "11"
  1619. tm := time.Unix(his.RecordDate, 0)
  1620. s_tm := tm.Format("2006-01-02 15:04:05")
  1621. fed.AdmDate = s_tm
  1622. fed.DscgDate = s_tm
  1623. fed.DscgMainDiseCodg = config[0].CountryCode
  1624. fed.DscgMainDiseName = config[0].CountryContentName
  1625. //诊断信息
  1626. var fdds []*models.FsiDiagnoseDtos
  1627. for index, item := range config {
  1628. if index == 0 {
  1629. var fdd models.FsiDiagnoseDtos
  1630. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1631. fdd.InoutDiseType = "1"
  1632. fdd.MaindiseFlag = "1"
  1633. fdd.DiseDate = s_tm
  1634. fdd.DiasSrtNo = "1"
  1635. fdd.DiseName = item.CountryContentName
  1636. fdd.DiseCodg = item.CountryCode
  1637. fdds = append(fdds, &fdd)
  1638. } else {
  1639. var fdd models.FsiDiagnoseDtos
  1640. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1641. fdd.InoutDiseType = "1"
  1642. fdd.MaindiseFlag = "1"
  1643. fdd.DiseDate = s_tm
  1644. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1645. fdd.DiseName = item.CountryContentName
  1646. fdd.DiseCodg = item.CountryCode
  1647. fdds = append(fdds, &fdd)
  1648. }
  1649. }
  1650. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1651. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1652. fed.AdmDeptName = department.Name
  1653. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1654. fed.DscgDeptName = department.Name
  1655. fed.MedMdtrtType = "1"
  1656. fed.MedType = "11"
  1657. //if his.Insutype == "390" {
  1658. // fed.MedType = "1402"
  1659. //} else {
  1660. // fed.MedType = "9933"
  1661. //}
  1662. var orders []*models.FsiOrderDtos
  1663. if trig_scen == "2" {
  1664. //处方医嘱信息
  1665. for _, item := range prescriptions {
  1666. for _, subItem := range item.HisDoctorAdviceInfo {
  1667. var order models.FsiOrderDtos
  1668. order.RxID = strconv.FormatInt(item.ID, 10)
  1669. order.Rxno = strconv.FormatInt(item.ID, 10)
  1670. order.LongDrordFlag = "0"
  1671. order.HilistType = "1"
  1672. order.ChrgType = "1"
  1673. order.DrordBhvr = "-"
  1674. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1675. order.HosplistName = subItem.BaseDrugLib.DrugName
  1676. order.HilistLv = "1"
  1677. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1678. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1679. order.HosplistName = subItem.BaseDrugLib.DrugName
  1680. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1681. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1682. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1683. order.OwnpayAmt = ""
  1684. order.SelfpayAmt = ""
  1685. order.Spec = ""
  1686. order.SpecUnt = ""
  1687. order.DrordBegnDate = s_tm
  1688. order.DrordStopDate = ""
  1689. order.DrordDrCodg = "1"
  1690. order.DrordDeptName = department.Name
  1691. order.DrordDrCodg = "1"
  1692. order.DrordDrName = doctor_info.UserName
  1693. order.DrordDrProfttl = ""
  1694. order.CurrDrordFlag = "1"
  1695. orders = append(orders, &order)
  1696. }
  1697. for _, subItem := range item.HisPrescriptionProject {
  1698. if subItem.Type == 2 {
  1699. var order models.FsiOrderDtos
  1700. order.RxID = strconv.FormatInt(item.ID, 10)
  1701. order.Rxno = strconv.FormatInt(item.ID, 10)
  1702. order.LongDrordFlag = "0"
  1703. order.HilistType = "1"
  1704. order.ChrgType = "1"
  1705. order.DrordBhvr = "-"
  1706. order.HilistCode = subItem.HisProject.MedicalCode
  1707. order.HosplistName = subItem.HisProject.ProjectName
  1708. order.HilistLv = "1"
  1709. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1710. order.HosplistCode = subItem.HisProject.MedicalCode
  1711. order.HosplistName = subItem.HisProject.ProjectName
  1712. order.Cnt = subItem.Count
  1713. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1714. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1715. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1716. order.OwnpayAmt = ""
  1717. order.SelfpayAmt = ""
  1718. order.Spec = ""
  1719. order.SpecUnt = ""
  1720. order.DrordBegnDate = s_tm
  1721. order.DrordStopDate = ""
  1722. order.DrordDrCodg = "1"
  1723. order.DrordDeptName = department.Name
  1724. order.DrordDrCodg = "1"
  1725. order.DrordDrName = doctor_info.UserName
  1726. order.DrordDrProfttl = ""
  1727. order.CurrDrordFlag = "1"
  1728. orders = append(orders, &order)
  1729. }
  1730. if subItem.Type == 3 {
  1731. var order models.FsiOrderDtos
  1732. order.RxID = strconv.FormatInt(item.ID, 10)
  1733. order.Rxno = strconv.FormatInt(item.ID, 10)
  1734. order.LongDrordFlag = "0"
  1735. order.HilistType = "1"
  1736. order.ChrgType = "1"
  1737. order.DrordBhvr = "-"
  1738. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1739. order.HosplistName = subItem.GoodInfo.GoodName
  1740. order.HilistLv = "1"
  1741. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1742. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1743. order.HosplistName = subItem.GoodInfo.GoodName
  1744. order.Cnt = subItem.Count
  1745. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1746. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1747. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1748. order.OwnpayAmt = ""
  1749. order.SelfpayAmt = ""
  1750. order.Spec = ""
  1751. order.SpecUnt = ""
  1752. order.DrordBegnDate = s_tm
  1753. order.DrordStopDate = ""
  1754. order.DrordDrCodg = "1"
  1755. order.DrordDeptName = department.Name
  1756. order.DrordDrCodg = "1"
  1757. order.DrordDrName = doctor_info.UserName
  1758. order.DrordDrProfttl = ""
  1759. order.CurrDrordFlag = "1"
  1760. orders = append(orders, &order)
  1761. }
  1762. }
  1763. }
  1764. //处方医嘱信息
  1765. }
  1766. fed.MatnStas = "0"
  1767. fed.MedfeeSumamt = "0"
  1768. fed.OwnpayAmt = "0"
  1769. fed.SelfpayAmt = "0"
  1770. fed.AcctPayamt = "0"
  1771. fed.MaAmt = "0"
  1772. fed.HifpPayamt = "0"
  1773. fed.SetlTotlnum = "1"
  1774. fed.Insutype = his.Insutype
  1775. fed.ReimFlag = "0"
  1776. fed.OutSetlFlag = "0"
  1777. var fopd []*models.FsiOperationDtosData
  1778. data := make(map[string]interface{})
  1779. data["fed"] = fed
  1780. data["fdd"] = fdds
  1781. data["fod"] = orders
  1782. data["pd"] = pd
  1783. data["pp"] = pp
  1784. data["fopd"] = fopd
  1785. data["trig_scen"] = trig_scen
  1786. fmt.Println(data)
  1787. fmt.Println(fed)
  1788. fmt.Println(fdds)
  1789. fmt.Println(orders)
  1790. fmt.Println(pd)
  1791. fmt.Println(pp)
  1792. fmt.Println(fopd)
  1793. client := &http.Client{}
  1794. bytesData, _ := json.Marshal(data)
  1795. var req *http.Request
  1796. if miConfig.MdtrtareaAdmvs == "320921" {
  1797. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1798. } else {
  1799. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1800. }
  1801. resp, _ := client.Do(req)
  1802. defer resp.Body.Close()
  1803. body, ioErr := ioutil.ReadAll(resp.Body)
  1804. if ioErr != nil {
  1805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1807. return res
  1808. }
  1809. var respJSON map[string]interface{}
  1810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1813. return res
  1814. }
  1815. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1816. result, _ := json.Marshal(respJSON)
  1817. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1818. utils.ErrorLog("解析失败:%v", err)
  1819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1820. return res
  1821. }
  1822. return res
  1823. }
  1824. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1825. ////patient_id, _ := c.GetInt64("patient_id")
  1826. //order_id, _ := c.GetInt64("order_id")
  1827. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1828. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1829. //trig_scen := c.GetString("trig_scen")
  1830. adminUser := c.GetAdminUserInfo()
  1831. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1832. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1833. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1834. record_time := c.GetString("record_time")
  1835. order, _ := service.GetHisOrderByID(order_id)
  1836. timeLayout := "2006-01-02"
  1837. loc, _ := time.LoadLocation("Local")
  1838. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1839. if err != nil {
  1840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1841. return
  1842. }
  1843. recordDateTime := theTime.Unix()
  1844. var patientPrescription models.HisPrescriptionInfo
  1845. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1846. if patientPrescription.ID == 0 {
  1847. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1848. }
  1849. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1850. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1851. //
  1852. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1853. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1854. var pp models.PublicParams
  1855. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1856. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1857. pp.FixmedinsName = miConfig.OrgName
  1858. pp.FixmedinsCode = miConfig.Code
  1859. pp.RequestUrl = miConfig.Url
  1860. pp.Cainfo = miConfig.Cainfo
  1861. pp.SecretKey = miConfig.SecretKey
  1862. pp.AccessKey = miConfig.AccessKey
  1863. pp.OpterName = roles.UserName
  1864. var config []*models.HisXtDiagnoseConfig
  1865. for _, item := range diagnosis_ids {
  1866. id, _ := strconv.ParseInt(item, 10, 64)
  1867. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1868. config = append(config, &diagnosisConfig)
  1869. }
  1870. var pd models.PatientDtos
  1871. pd.PatnID = his.PsnNo
  1872. pd.PatnName = his.Name
  1873. pd.Gend = his.Gend
  1874. pd.Brdy = his.Brdy
  1875. pd.Poolarea = his.InsuplcAdmdvs
  1876. pd.CurrMdtrtID = his.Number
  1877. var fed models.FsiEncounterDtos
  1878. fed.MdtrtID = his.Number
  1879. fed.MedinsID = miConfig.Code
  1880. fed.MedinsName = miConfig.OrgName
  1881. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1882. fed.MedMdtrtType = "1"
  1883. fed.MedinsType = "1"
  1884. fed.MedinsLv = "11"
  1885. tm := time.Unix(his.RecordDate, 0)
  1886. s_tm := tm.Format("2006-01-02 15:04:05")
  1887. fed.AdmDate = s_tm
  1888. fed.DscgDate = s_tm
  1889. fed.DscgMainDiseCodg = config[0].CountryCode
  1890. fed.DscgMainDiseName = config[0].CountryContentName
  1891. //诊断信息
  1892. var fdds []*models.FsiDiagnoseDtos
  1893. for index, item := range config {
  1894. if index == 0 {
  1895. var fdd models.FsiDiagnoseDtos
  1896. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1897. fdd.InoutDiseType = "1"
  1898. fdd.MaindiseFlag = "1"
  1899. fdd.DiseDate = s_tm
  1900. fdd.DiasSrtNo = "1"
  1901. fdd.DiseName = item.CountryContentName
  1902. fdd.DiseCodg = item.CountryCode
  1903. fdds = append(fdds, &fdd)
  1904. } else {
  1905. var fdd models.FsiDiagnoseDtos
  1906. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1907. fdd.InoutDiseType = "1"
  1908. fdd.MaindiseFlag = "1"
  1909. fdd.DiseDate = s_tm
  1910. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1911. fdd.DiseName = item.CountryContentName
  1912. fdd.DiseCodg = item.CountryCode
  1913. fdds = append(fdds, &fdd)
  1914. }
  1915. }
  1916. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1917. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1918. fed.AdmDeptName = department.Name
  1919. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1920. fed.DscgDeptName = department.Name
  1921. fed.MedType = order.MedType
  1922. //处方医嘱信息
  1923. var orders []*models.FsiOrderDtos
  1924. //for _, item := range prescriptions {
  1925. // for _, subItem := range item.HisDoctorAdviceInfo {
  1926. // var order models.FsiOrderDtos
  1927. // order.RxID = strconv.FormatInt(item.ID, 10)
  1928. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1929. // order.LongDrordFlag = "0"
  1930. // order.HilistType = "1"
  1931. // order.ChrgType = "1"
  1932. // order.DrordBhvr = "-"
  1933. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1934. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1935. // order.HilistLv = "1"
  1936. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1937. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1938. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1939. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1940. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1941. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1942. // order.OwnpayAmt = ""
  1943. // order.SelfpayAmt = ""
  1944. // order.Spec = ""
  1945. // order.SpecUnt = ""
  1946. // order.DrordBegnDate = s_tm
  1947. // order.DrordStopDate = ""
  1948. // order.DrordDrCodg = "1"
  1949. // order.DrordDeptName = department.Name
  1950. // order.DrordDrCodg = "1"
  1951. // order.DrordDrName = doctor_info.UserName
  1952. // order.DrordDrProfttl = ""
  1953. // order.CurrDrordFlag = "1"
  1954. // orders = append(orders, &order)
  1955. // }
  1956. // for _, subItem := range item.HisPrescriptionProject {
  1957. // if subItem.Type == 2 {
  1958. // var order models.FsiOrderDtos
  1959. // order.RxID = strconv.FormatInt(item.ID, 10)
  1960. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1961. // order.LongDrordFlag = "0"
  1962. // order.HilistType = "1"
  1963. // order.ChrgType = "1"
  1964. // order.DrordBhvr = "-"
  1965. // order.HilistCode = subItem.HisProject.MedicalCode
  1966. // order.HosplistName = subItem.HisProject.ProjectName
  1967. // order.HilistLv = "1"
  1968. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1969. // order.HosplistCode = subItem.HisProject.MedicalCode
  1970. // order.HosplistName = subItem.HisProject.ProjectName
  1971. // order.Cnt = subItem.Count
  1972. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1973. //
  1974. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1975. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1976. // order.OwnpayAmt = ""
  1977. // order.SelfpayAmt = ""
  1978. // order.Spec = ""
  1979. // order.SpecUnt = ""
  1980. // order.DrordBegnDate = s_tm
  1981. // order.DrordStopDate = ""
  1982. // order.DrordDrCodg = "1"
  1983. // order.DrordDeptName = department.Name
  1984. // order.DrordDrCodg = "1"
  1985. // order.DrordDrName = doctor_info.UserName
  1986. // order.DrordDrProfttl = ""
  1987. // order.CurrDrordFlag = "1"
  1988. // orders = append(orders, &order)
  1989. //
  1990. // }
  1991. // if subItem.Type == 3 {
  1992. //
  1993. // var order models.FsiOrderDtos
  1994. // order.RxID = strconv.FormatInt(item.ID, 10)
  1995. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1996. // order.LongDrordFlag = "0"
  1997. // order.HilistType = "1"
  1998. // order.ChrgType = "1"
  1999. // order.DrordBhvr = "-"
  2000. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2001. // order.HosplistName = subItem.GoodInfo.GoodName
  2002. // order.HilistLv = "1"
  2003. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2004. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2005. // order.HosplistName = subItem.GoodInfo.GoodName
  2006. // order.Cnt = subItem.Count
  2007. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2008. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2009. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2010. // order.OwnpayAmt = ""
  2011. // order.SelfpayAmt = ""
  2012. // order.Spec = ""
  2013. // order.SpecUnt = ""
  2014. // order.DrordBegnDate = s_tm
  2015. // order.DrordStopDate = ""
  2016. // order.DrordDrCodg = "1"
  2017. // order.DrordDeptName = department.Name
  2018. // order.DrordDrCodg = "1"
  2019. // order.DrordDrName = doctor_info.UserName
  2020. // order.DrordDrProfttl = ""
  2021. // order.CurrDrordFlag = "1"
  2022. // orders = append(orders, &order)
  2023. //
  2024. // }
  2025. // }
  2026. //}
  2027. for _, item := range prescriptions {
  2028. for _, subItem := range item.HisDoctorAdviceInfo {
  2029. var order models.FsiOrderDtos
  2030. order.RxID = strconv.FormatInt(item.ID, 10)
  2031. order.Rxno = strconv.FormatInt(item.ID, 10)
  2032. order.LongDrordFlag = "0"
  2033. order.HilistType = "1"
  2034. order.ChrgType = "1"
  2035. order.DrordBhvr = "-"
  2036. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2037. order.HosplistName = subItem.BaseDrugLib.DrugName
  2038. order.HilistLv = "1"
  2039. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2040. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2041. order.HosplistName = subItem.BaseDrugLib.DrugName
  2042. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2043. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2044. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2045. order.OwnpayAmt = ""
  2046. order.SelfpayAmt = ""
  2047. order.Spec = ""
  2048. order.SpecUnt = ""
  2049. order.DrordBegnDate = s_tm
  2050. order.DrordStopDate = ""
  2051. order.DrordDrCodg = "1"
  2052. order.DrordDeptName = department.Name
  2053. order.DrordDrCodg = "1"
  2054. order.DrordDrName = doctor_info.UserName
  2055. order.DrordDrProfttl = ""
  2056. order.CurrDrordFlag = "1"
  2057. orders = append(orders, &order)
  2058. }
  2059. for _, subItem := range item.HisPrescriptionProject {
  2060. if subItem.Type == 2 {
  2061. var order models.FsiOrderDtos
  2062. order.RxID = strconv.FormatInt(item.ID, 10)
  2063. order.Rxno = strconv.FormatInt(item.ID, 10)
  2064. order.LongDrordFlag = "0"
  2065. order.HilistType = "1"
  2066. order.ChrgType = "1"
  2067. order.DrordBhvr = "-"
  2068. order.HilistCode = subItem.HisProject.MedicalCode
  2069. order.HosplistName = subItem.HisProject.ProjectName
  2070. order.HilistLv = "1"
  2071. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2072. order.HosplistCode = subItem.HisProject.MedicalCode
  2073. order.HosplistName = subItem.HisProject.ProjectName
  2074. order.Cnt = subItem.Count
  2075. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2076. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2077. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2078. order.OwnpayAmt = ""
  2079. order.SelfpayAmt = ""
  2080. order.Spec = ""
  2081. order.SpecUnt = ""
  2082. order.DrordBegnDate = s_tm
  2083. order.DrordStopDate = ""
  2084. order.DrordDrCodg = "1"
  2085. order.DrordDeptName = department.Name
  2086. order.DrordDrCodg = "1"
  2087. order.DrordDrName = doctor_info.UserName
  2088. order.DrordDrProfttl = ""
  2089. order.CurrDrordFlag = "1"
  2090. orders = append(orders, &order)
  2091. }
  2092. if subItem.Type == 3 {
  2093. var order models.FsiOrderDtos
  2094. order.RxID = strconv.FormatInt(item.ID, 10)
  2095. order.Rxno = strconv.FormatInt(item.ID, 10)
  2096. order.LongDrordFlag = "0"
  2097. order.HilistType = "1"
  2098. order.ChrgType = "1"
  2099. order.DrordBhvr = "-"
  2100. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2101. order.HosplistName = subItem.GoodInfo.GoodName
  2102. order.HilistLv = "1"
  2103. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2104. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2105. order.HosplistName = subItem.GoodInfo.GoodName
  2106. order.Cnt = subItem.Count
  2107. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2108. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2109. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2110. order.OwnpayAmt = ""
  2111. order.SelfpayAmt = ""
  2112. order.Spec = ""
  2113. order.SpecUnt = ""
  2114. order.DrordBegnDate = s_tm
  2115. order.DrordStopDate = ""
  2116. order.DrordDrCodg = "1"
  2117. order.DrordDeptName = department.Name
  2118. order.DrordDrCodg = "1"
  2119. order.DrordDrName = doctor_info.UserName
  2120. order.DrordDrProfttl = ""
  2121. order.CurrDrordFlag = "1"
  2122. orders = append(orders, &order)
  2123. }
  2124. }
  2125. }
  2126. //处方医嘱信息
  2127. fed.MatnStas = "0"
  2128. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2129. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  2130. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  2131. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  2132. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  2133. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  2134. fed.SetlTotlnum = "1"
  2135. fed.Insutype = his.Insutype
  2136. fed.ReimFlag = "0"
  2137. fed.OutSetlFlag = "0"
  2138. var fopd []*models.FsiOperationDtosData
  2139. data := make(map[string]interface{})
  2140. data["fed"] = fed
  2141. data["fdd"] = fdds
  2142. data["fod"] = orders
  2143. data["pd"] = pd
  2144. data["pp"] = pp
  2145. data["fopd"] = fopd
  2146. data["trig_scen"] = trig_scen
  2147. client := &http.Client{}
  2148. bytesData, _ := json.Marshal(data)
  2149. var req *http.Request
  2150. if miConfig.MdtrtareaAdmvs == "320921" {
  2151. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2152. } else {
  2153. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2154. }
  2155. resp, _ := client.Do(req)
  2156. defer resp.Body.Close()
  2157. body, ioErr := ioutil.ReadAll(resp.Body)
  2158. if ioErr != nil {
  2159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2161. return res
  2162. }
  2163. var respJSON map[string]interface{}
  2164. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2167. return res
  2168. }
  2169. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2170. result, _ := json.Marshal(respJSON)
  2171. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2172. utils.ErrorLog("解析失败:%v", err)
  2173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2174. return res
  2175. }
  2176. return res
  2177. //手术操作集合
  2178. //手术操作集合
  2179. }
  2180. func (c *HisApiController) Check() {
  2181. psn_no := c.GetString("psn_no")
  2182. in := c.GetString("in")
  2183. mt := c.GetString("mt")
  2184. baseParams := models.BaseParams{
  2185. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  2186. FixmedinsCode: "H15049901371",
  2187. InsuplcAdmdvs: "150499",
  2188. MdtrtareaAdmvs: "150499",
  2189. OrgName: "赤峰费森血液透析中心",
  2190. Doctor: "1111",
  2191. }
  2192. service.Gdyb2001(baseParams, psn_no, in, mt)
  2193. }
  2194. func (c *HisApiController) GetPsnNcdsInfo() {
  2195. admin_user_id, _ := c.GetInt64("admin_user_id")
  2196. patient_id, _ := c.GetInt64("patient_id")
  2197. id, _ := c.GetInt64("id")
  2198. adminUser := c.GetAdminUserInfo()
  2199. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2200. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2201. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  2202. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2203. psn_record, _ := service.GetPsnNCDSRecordById(id)
  2204. //
  2205. //if psn_record.ID == 0 {
  2206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  2207. // return
  2208. //}
  2209. var res Result5301
  2210. var res10265 Result5301For10265
  2211. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2212. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2213. var api string
  2214. if miConfig.MdtrtareaAdmvs == "320921" {
  2215. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  2216. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2217. } else {
  2218. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  2219. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2220. }
  2221. resp, requestErr := http.Get(api)
  2222. if requestErr != nil {
  2223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2224. return
  2225. }
  2226. body, ioErr := ioutil.ReadAll(resp.Body)
  2227. if ioErr != nil {
  2228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2230. return
  2231. }
  2232. var respJSON map[string]interface{}
  2233. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2236. return
  2237. }
  2238. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2239. result, _ := json.Marshal(respJSON)
  2240. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2241. utils.ErrorLog("解析失败:%v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. return
  2244. }
  2245. res.ErrMsg = res10265.ErrMsg
  2246. res.Output = res10265.Output
  2247. res.InfRefmsgid = res10265.InfRefmsgid
  2248. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2249. res.Infcode = infocode
  2250. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2251. p, _ := service.GetHisPatientById(patient_id)
  2252. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2253. var dat map[string]interface{}
  2254. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2255. fmt.Println(dat)
  2256. } else {
  2257. fmt.Println(err)
  2258. }
  2259. userJSONBytes, _ := json.Marshal(dat)
  2260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2261. utils.ErrorLog("解析失败:%v", err)
  2262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2263. return
  2264. }
  2265. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2266. p, _ := service.GetHisPatientById(patient_id)
  2267. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2268. var dat map[string]interface{}
  2269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2270. fmt.Println(dat)
  2271. } else {
  2272. fmt.Println(err)
  2273. }
  2274. userJSONBytes, _ := json.Marshal(dat)
  2275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2276. utils.ErrorLog("解析失败:%v", err)
  2277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2278. return
  2279. }
  2280. } else {
  2281. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2282. var dat map[string]interface{}
  2283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2284. fmt.Println(dat)
  2285. } else {
  2286. fmt.Println(err)
  2287. }
  2288. userJSONBytes, _ := json.Marshal(dat)
  2289. if miConfig.Code == "H15049901371" {
  2290. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  2291. utils.ErrorLog("解析失败:%v", err)
  2292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2293. return
  2294. }
  2295. res.InfRefmsgid = res10265.InfRefmsgid
  2296. res.Output = res10265.Output
  2297. res.ErrMsg = res10265.ErrMsg
  2298. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2299. res.Infcode = infocode
  2300. } else {
  2301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2302. utils.ErrorLog("解析失败:%v", err)
  2303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2304. return
  2305. }
  2306. }
  2307. }
  2308. if res.Infcode == 0 {
  2309. c.ServeSuccessJSON(map[string]interface{}{
  2310. "result": res.Output.Result,
  2311. })
  2312. }
  2313. }
  2314. func (c *HisApiController) CheckInsutype() {
  2315. his_patient_id, _ := c.GetInt64("his_patient_id")
  2316. admin_user_id, _ := c.GetInt64("admin_user_id")
  2317. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2318. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2319. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2320. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2321. var dat map[string]interface{}
  2322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2323. fmt.Println(dat)
  2324. } else {
  2325. fmt.Println(err)
  2326. }
  2327. userJSONBytes, _ := json.Marshal(dat)
  2328. var res Result90100
  2329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2330. utils.ErrorLog("解析失败:%v", err)
  2331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2332. return
  2333. }
  2334. if res.Infcode != 0 {
  2335. c.ServeSuccessJSON(map[string]interface{}{
  2336. "failed_code": -10,
  2337. "msg": res.ErrMsg,
  2338. })
  2339. return
  2340. } else {
  2341. fmt.Println(res)
  2342. }
  2343. }
  2344. func (c *HisApiController) CheckCardPWD() {
  2345. card_pwd := c.GetString("card_pwd")
  2346. his_patient_id, _ := c.GetInt64("his_patient_id")
  2347. admin_user_id, _ := c.GetInt64("admin_user_id")
  2348. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2349. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2350. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2351. psn, _ := service.GetPsnByPatientId(his.PatientId)
  2352. bas := strings.Split(psn.CardInfo, "|")
  2353. basNumber := bas[2]
  2354. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  2355. var dat map[string]interface{}
  2356. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2357. fmt.Println(dat)
  2358. } else {
  2359. fmt.Println(err)
  2360. }
  2361. userJSONBytes, _ := json.Marshal(dat)
  2362. var res Result90991
  2363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2364. utils.ErrorLog("解析失败:%v", err)
  2365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2366. return
  2367. }
  2368. if res.Infcode != 0 {
  2369. c.ServeSuccessJSON(map[string]interface{}{
  2370. "failed_code": -10,
  2371. "msg": res.ErrMsg,
  2372. })
  2373. return
  2374. } else {
  2375. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  2376. var msg string
  2377. switch res.Output.Result.CardStat {
  2378. case "00":
  2379. msg = "未激活"
  2380. break
  2381. case "10":
  2382. msg = "激活"
  2383. break
  2384. case "20":
  2385. msg = "窗口挂失"
  2386. break
  2387. case "21":
  2388. msg = "电话挂失"
  2389. break
  2390. case "22":
  2391. msg = "单位网上申报挂失"
  2392. break
  2393. case "23":
  2394. msg = "保健办挂失"
  2395. break
  2396. case "24":
  2397. msg = "个人网上挂失"
  2398. break
  2399. case "25":
  2400. msg = "网上服务大厅挂失"
  2401. break
  2402. case "30":
  2403. msg = "注销"
  2404. break
  2405. case "40":
  2406. msg = "回收"
  2407. break
  2408. case "99":
  2409. msg = "制卡中(无效卡)"
  2410. break
  2411. }
  2412. c.ServeSuccessJSON(map[string]interface{}{
  2413. "failed_code": -10,
  2414. "msg": msg,
  2415. })
  2416. return
  2417. } else {
  2418. c.ServeSuccessJSON(map[string]interface{}{
  2419. "msg": "校验成功",
  2420. })
  2421. return
  2422. }
  2423. }
  2424. }
  2425. func (c *HisApiController) CheckCardPWDTwo() {
  2426. //card_pwd := c.GetString("card_pwd")
  2427. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2428. admin_user_id, _ := c.GetInt64("admin_user_id")
  2429. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2430. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2431. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  2432. var dat map[string]interface{}
  2433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2434. fmt.Println(dat)
  2435. } else {
  2436. fmt.Println(err)
  2437. }
  2438. userJSONBytes, _ := json.Marshal(dat)
  2439. var res Result90991
  2440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2441. utils.ErrorLog("解析失败:%v", err)
  2442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2443. return
  2444. }
  2445. if res.Infcode != 0 {
  2446. c.ServeSuccessJSON(map[string]interface{}{
  2447. "failed_code": -10,
  2448. "msg": res.ErrMsg,
  2449. })
  2450. return
  2451. } else {
  2452. if res.Output.Result.SscnoCheckStat == "0" {
  2453. var msg string
  2454. switch res.Output.Result.CardStat {
  2455. case "00":
  2456. msg = "未激活"
  2457. break
  2458. case "10":
  2459. msg = "激活"
  2460. break
  2461. case "20":
  2462. msg = "窗口挂失"
  2463. break
  2464. case "21":
  2465. msg = "电话挂失"
  2466. break
  2467. case "22":
  2468. msg = "单位网上申报挂失"
  2469. break
  2470. case "23":
  2471. msg = "保健办挂失"
  2472. break
  2473. case "24":
  2474. msg = "个人网上挂失"
  2475. break
  2476. case "25":
  2477. msg = "网上服务大厅挂失"
  2478. break
  2479. case "30":
  2480. msg = "注销"
  2481. break
  2482. case "40":
  2483. msg = "回收"
  2484. break
  2485. case "99":
  2486. msg = "制卡中(无效卡)"
  2487. break
  2488. }
  2489. c.ServeSuccessJSON(map[string]interface{}{
  2490. "failed_code": -10,
  2491. "msg": msg,
  2492. })
  2493. return
  2494. } else {
  2495. c.ServeSuccessJSON(map[string]interface{}{
  2496. "msg": "校验成功",
  2497. })
  2498. return
  2499. }
  2500. }
  2501. }
  2502. type ELeCertData struct {
  2503. Data struct {
  2504. Extra string `json:"extra"`
  2505. IDNo string `json:"idNo"`
  2506. IDType string `json:"idType"`
  2507. EcToken string `json:"ecToken"`
  2508. InsuOrg string `json:"insuOrg"`
  2509. UserName string `json:"userName"`
  2510. EcIndexNo string `json:"ecIndexNo"`
  2511. Gender string `json:"gender"`
  2512. Birthday string `json:"birthday"`
  2513. Nationality string `json:"nationality"`
  2514. Email string `json:"email"`
  2515. } `json:"OutData"`
  2516. }
  2517. func (c *HisApiController) ReadCard() {
  2518. id_card_type, _ := c.GetInt64("id_card_type")
  2519. admin_user_id, _ := c.GetInt64("admin_user_id")
  2520. certificates, _ := c.GetInt64("certificates")
  2521. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2522. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2523. switch id_card_type {
  2524. case 1:
  2525. if miConfig.MdtrtareaAdmvs == "421300" {
  2526. var res ResultTwo
  2527. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  2528. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2529. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  2530. resp, requestErr := http.Get(api)
  2531. if requestErr != nil {
  2532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. return
  2534. }
  2535. body, ioErr := ioutil.ReadAll(resp.Body)
  2536. if ioErr != nil {
  2537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2539. return
  2540. }
  2541. var respJSON map[string]interface{}
  2542. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2545. return
  2546. }
  2547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2548. result, _ := json.Marshal(respJSON)
  2549. fmt.Println("log")
  2550. fmt.Println(string(result))
  2551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2552. utils.ErrorLog("解析失败:%v", err)
  2553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2554. return
  2555. }
  2556. if res.Infcode == 0 {
  2557. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2558. if err == gorm.ErrRecordNotFound {
  2559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2560. return
  2561. } else if err != nil {
  2562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2563. return
  2564. } else {
  2565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2566. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2567. infoStr := string(Iinfos)
  2568. idetinfoStr := string(Idetinfos)
  2569. psn := &models.HisPsn{
  2570. PsnNo: res.Output.Baseinfo.PsnNo,
  2571. Age: res.Output.Baseinfo.Age,
  2572. PatientId: patient.ID,
  2573. Certno: res.Output.Baseinfo.Certno,
  2574. Brdy: res.Output.Baseinfo.Brdy,
  2575. Gend: res.Output.Baseinfo.Gend,
  2576. Naty: res.Output.Baseinfo.Naty,
  2577. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2578. PsnName: res.Output.Baseinfo.PsnName,
  2579. Idetinfo: idetinfoStr,
  2580. Insuinfo: infoStr,
  2581. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2582. }
  2583. service.CreateHisPsn(psn)
  2584. c.ServeSuccessJSON(map[string]interface{}{
  2585. "patient": patient,
  2586. "number": res.Output.Baseinfo.Certno,
  2587. })
  2588. }
  2589. } else {
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2591. return
  2592. }
  2593. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2594. var api string
  2595. if miConfig.MdtrtareaAdmvs == "320921" {
  2596. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2597. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  2598. fmt.Println(api)
  2599. } else {
  2600. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2601. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  2602. }
  2603. resp, requestErr := http.Get(api)
  2604. if requestErr != nil {
  2605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2606. return
  2607. }
  2608. body, ioErr := ioutil.ReadAll(resp.Body)
  2609. if ioErr != nil {
  2610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2612. return
  2613. }
  2614. var respJSON map[string]interface{}
  2615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2618. return
  2619. }
  2620. var status string
  2621. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2622. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2623. //console.log()
  2624. fmt.Println("type===")
  2625. fmt.Println(card_type)
  2626. var token string
  2627. var res ResultTwo //1101结果
  2628. var res10265 ResultTwo10265 //1101结果
  2629. var card_info string //卡信息
  2630. var busi_card_info string
  2631. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2632. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2633. if status == "0" { //读卡成功
  2634. if card_type == "1" {
  2635. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2636. result, _ := json.Marshal(respJSON)
  2637. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2638. utils.ErrorLog("解析失败:%v", err)
  2639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2640. return
  2641. }
  2642. res.ErrMsg = res10265.ErrMsg
  2643. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2644. res.Infcode = infocode
  2645. res.Output = res10265.Output
  2646. res.InfRefmsgid = res10265.InfRefmsgid
  2647. } else {
  2648. //var card_info string //卡信息
  2649. //var busi_card_info string
  2650. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2651. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2652. //fmt.Println(card_info)
  2653. //fmt.Println(busi_card_info)
  2654. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2655. result, _ := json.Marshal(respJSON)
  2656. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2657. utils.ErrorLog("解析失败:%v", err)
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. res.ErrMsg = res10265.ErrMsg
  2662. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2663. res.Infcode = infocode
  2664. res.Output = res10265.Output
  2665. res.InfRefmsgid = res10265.InfRefmsgid
  2666. }
  2667. if res.Infcode == 0 {
  2668. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2669. if err == gorm.ErrRecordNotFound {
  2670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2671. return
  2672. } else if err != nil {
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2674. return
  2675. } else {
  2676. if card_type == "1" {
  2677. bas := strings.Split(card_info, "|")
  2678. basNumber := bas[2]
  2679. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2680. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2681. infoStr := string(Iinfos)
  2682. idetinfoStr := string(Idetinfos)
  2683. psn := &models.HisPsn{
  2684. PsnNo: res.Output.Baseinfo.PsnNo,
  2685. Age: res.Output.Baseinfo.Age,
  2686. PatientId: patient.ID,
  2687. Certno: res.Output.Baseinfo.Certno,
  2688. Brdy: res.Output.Baseinfo.Brdy,
  2689. Gend: res.Output.Baseinfo.Gend,
  2690. Naty: res.Output.Baseinfo.Naty,
  2691. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2692. PsnName: res.Output.Baseinfo.PsnName,
  2693. Idetinfo: idetinfoStr,
  2694. Insuinfo: infoStr,
  2695. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2696. CardInfo: card_info,
  2697. VerifyNumber: busi_card_info,
  2698. }
  2699. service.CreateHisPsn(psn)
  2700. var rf []*ResultFive
  2701. json.Unmarshal([]byte(infoStr), &rf)
  2702. var insutypes []*ResultFive
  2703. var insutype string
  2704. var is390 int = 0
  2705. var is310 int = 0
  2706. for _, item := range rf {
  2707. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2708. insutypes = append(insutypes, item)
  2709. }
  2710. }
  2711. if len(insutypes) == 1 {
  2712. insutype = insutypes[0].Insutype
  2713. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2714. } else {
  2715. for _, i := range insutypes {
  2716. if i.Insutype == "390" {
  2717. is390 = 1
  2718. }
  2719. if i.Insutype == "310" {
  2720. is310 = 1
  2721. }
  2722. }
  2723. }
  2724. if is390 == 1 {
  2725. insutype = "390"
  2726. }
  2727. if is310 == 1 {
  2728. insutype = "310"
  2729. }
  2730. if len(insutypes) == 0 {
  2731. insutype = "310"
  2732. }
  2733. c.ServeSuccessJSON(map[string]interface{}{
  2734. "patient": patient,
  2735. "number": basNumber,
  2736. "insutype": insutype,
  2737. })
  2738. } else {
  2739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2741. infoStr := string(Iinfos)
  2742. idetinfoStr := string(Idetinfos)
  2743. psn := &models.HisPsn{
  2744. PsnNo: res.Output.Baseinfo.PsnNo,
  2745. Age: res.Output.Baseinfo.Age,
  2746. PatientId: patient.ID,
  2747. Certno: res.Output.Baseinfo.Certno,
  2748. Brdy: res.Output.Baseinfo.Brdy,
  2749. Gend: res.Output.Baseinfo.Gend,
  2750. Naty: res.Output.Baseinfo.Naty,
  2751. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2752. PsnName: res.Output.Baseinfo.PsnName,
  2753. Idetinfo: idetinfoStr,
  2754. Insuinfo: infoStr,
  2755. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2756. CardInfo: card_info,
  2757. VerifyNumber: token,
  2758. }
  2759. service.CreateHisPsn(psn)
  2760. c.ServeSuccessJSON(map[string]interface{}{
  2761. "patient": patient,
  2762. "number": token,
  2763. })
  2764. }
  2765. }
  2766. } else {
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2768. return
  2769. }
  2770. } else { //读卡失败
  2771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2772. return
  2773. }
  2774. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2775. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2776. cardnum = DeleteExtraSpaceTwo(cardnum)
  2777. cardCode = DeleteExtraSpaceTwo(cardCode)
  2778. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2779. name = DeleteExtraSpaceTwo(name)
  2780. errmsg = DeleteExtraSpaceTwo(errmsg)
  2781. cardnum = Remove0000(cardnum)
  2782. cardCode = Remove0000(cardCode)
  2783. id_card_no = Remove0000(id_card_no)
  2784. name = Remove0000(name)
  2785. errmsg = Remove0000(errmsg)
  2786. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  2787. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2788. result2, requestLog2, errMsgLog2 := service.FJybidcomfirm(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  2789. fmt.Println(result2)
  2790. fmt.Println(requestLog2)
  2791. fmt.Println(errMsgLog2)
  2792. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  2793. saveLog(result, requestLog, "1101", "获取人员信息")
  2794. fmt.Println(errMsgLog)
  2795. if len(errMsgLog) > 0 {
  2796. } else {
  2797. var dat map[string]interface{}
  2798. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2799. fmt.Println(dat)
  2800. } else {
  2801. fmt.Println(err)
  2802. }
  2803. userJSONBytes, _ := json.Marshal(dat)
  2804. var res ResultTwo
  2805. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2806. utils.ErrorLog("解析失败:%v", err)
  2807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2808. return
  2809. }
  2810. res.ErrMsg = errMsgLog
  2811. if res.Infcode == 0 {
  2812. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2813. if err == gorm.ErrRecordNotFound {
  2814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2815. return
  2816. } else if err != nil {
  2817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2818. return
  2819. } else {
  2820. fmt.Println(res)
  2821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2822. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2823. infoStr := string(Iinfos)
  2824. idetinfoStr := string(Idetinfos)
  2825. psn := &models.HisPsn{
  2826. PsnNo: res.Output.Baseinfo.PsnNo,
  2827. Age: res.Output.Baseinfo.Age,
  2828. PatientId: patient.ID,
  2829. Certno: res.Output.Baseinfo.Certno,
  2830. Brdy: res.Output.Baseinfo.Brdy,
  2831. Gend: res.Output.Baseinfo.Gend,
  2832. Naty: res.Output.Baseinfo.Naty,
  2833. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2834. PsnName: res.Output.Baseinfo.PsnName,
  2835. Idetinfo: idetinfoStr,
  2836. Insuinfo: infoStr,
  2837. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2838. CardInfo: basStr,
  2839. VerifyNumber: "",
  2840. }
  2841. service.CreateHisPsn(psn)
  2842. var rf []*ResultFive
  2843. json.Unmarshal([]byte(infoStr), &rf)
  2844. var insutypes []*ResultFive
  2845. var insutype string
  2846. var is390 int = 0
  2847. var is310 int = 0
  2848. for _, item := range rf {
  2849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2850. insutypes = append(insutypes, item)
  2851. }
  2852. }
  2853. if len(insutypes) == 1 {
  2854. insutype = insutypes[0].Insutype
  2855. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2856. } else {
  2857. for _, i := range insutypes {
  2858. if i.Insutype == "390" {
  2859. is390 = 1
  2860. }
  2861. if i.Insutype == "310" {
  2862. is310 = 1
  2863. }
  2864. }
  2865. }
  2866. if is390 == 1 {
  2867. insutype = "390"
  2868. }
  2869. if is310 == 1 {
  2870. insutype = "310"
  2871. }
  2872. if len(insutypes) == 0 {
  2873. insutype = "390"
  2874. }
  2875. c.ServeSuccessJSON(map[string]interface{}{
  2876. "patient": patient,
  2877. "number": cardnum,
  2878. "insutype": insutype,
  2879. })
  2880. }
  2881. } else {
  2882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2883. return
  2884. }
  2885. }
  2886. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2887. fmt.Println(initFlag)
  2888. fmt.Println("initFlag")
  2889. if initFlag == 0 {
  2890. c.TestGetJiangXiBasBaseInit()
  2891. }
  2892. basStr := c.GetBasBaseInfo()
  2893. if len(basStr) == 0 {
  2894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2895. return
  2896. }
  2897. fmt.Println(basStr)
  2898. bas := strings.Split(basStr, "|")
  2899. basNumber := bas[1]
  2900. fmt.Println(basNumber)
  2901. card_sn := bas[3]
  2902. fmt.Println(card_sn)
  2903. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  2904. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2905. var dat map[string]interface{}
  2906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2907. fmt.Println(dat)
  2908. } else {
  2909. fmt.Println(err)
  2910. }
  2911. userJSONBytes, _ := json.Marshal(dat)
  2912. var res ResultTwo
  2913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2914. utils.ErrorLog("解析失败:%v", err)
  2915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2916. return
  2917. }
  2918. if res.Infcode == 0 {
  2919. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2920. if err == gorm.ErrRecordNotFound {
  2921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2922. return
  2923. } else if err != nil {
  2924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2925. return
  2926. } else {
  2927. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2928. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2929. infoStr := string(Iinfos)
  2930. idetinfoStr := string(Idetinfos)
  2931. psn := &models.HisPsn{
  2932. PsnNo: res.Output.Baseinfo.PsnNo,
  2933. Age: res.Output.Baseinfo.Age,
  2934. PatientId: patient.ID,
  2935. Certno: res.Output.Baseinfo.Certno,
  2936. Brdy: res.Output.Baseinfo.Brdy,
  2937. Gend: res.Output.Baseinfo.Gend,
  2938. Naty: res.Output.Baseinfo.Naty,
  2939. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2940. PsnName: res.Output.Baseinfo.PsnName,
  2941. Idetinfo: idetinfoStr,
  2942. Insuinfo: infoStr,
  2943. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2944. CardInfo: basStr,
  2945. VerifyNumber: "",
  2946. }
  2947. service.CreateHisPsn(psn)
  2948. var rf []*ResultFive
  2949. json.Unmarshal([]byte(infoStr), &rf)
  2950. var insutypes []*ResultFive
  2951. var insutype string
  2952. var is390 int = 0
  2953. var is310 int = 0
  2954. for _, item := range rf {
  2955. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2956. insutypes = append(insutypes, item)
  2957. }
  2958. }
  2959. if len(insutypes) == 1 {
  2960. insutype = insutypes[0].Insutype
  2961. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2962. } else {
  2963. for _, i := range insutypes {
  2964. if i.Insutype == "390" {
  2965. is390 = 1
  2966. }
  2967. if i.Insutype == "310" {
  2968. is310 = 1
  2969. }
  2970. }
  2971. }
  2972. if is390 == 1 {
  2973. insutype = "390"
  2974. }
  2975. if is310 == 1 {
  2976. insutype = "310"
  2977. }
  2978. if len(insutypes) == 0 {
  2979. insutype = "310"
  2980. }
  2981. c.ServeSuccessJSON(map[string]interface{}{
  2982. "patient": patient,
  2983. "number": basNumber,
  2984. "insutype": insutype,
  2985. })
  2986. }
  2987. } else {
  2988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2989. return
  2990. }
  2991. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2992. fmt.Println(initFlag)
  2993. fmt.Println("initFlag")
  2994. if initFlag == 0 {
  2995. c.TestGetHnBasBaseInit()
  2996. }
  2997. basStr := c.GetBasBaseInfo()
  2998. if len(basStr) == 0 {
  2999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3000. return
  3001. }
  3002. fmt.Println(basStr)
  3003. bas := strings.Split(basStr, "|")
  3004. basNumber := bas[1]
  3005. fmt.Println(basNumber)
  3006. card_sn := bas[3]
  3007. card_no := bas[2]
  3008. fmt.Println(card_sn)
  3009. name := bas[4]
  3010. name = ConvertToString(name, "gbk", "utf-8")
  3011. result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
  3012. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3013. var dat map[string]interface{}
  3014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3015. fmt.Println(dat)
  3016. } else {
  3017. fmt.Println(err)
  3018. }
  3019. userJSONBytes, _ := json.Marshal(dat)
  3020. var res ResultTwo
  3021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3022. utils.ErrorLog("解析失败:%v", err)
  3023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3024. return
  3025. }
  3026. if res.Infcode == 0 {
  3027. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3028. if err == gorm.ErrRecordNotFound {
  3029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3030. return
  3031. } else if err != nil {
  3032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3033. return
  3034. } else {
  3035. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3036. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3037. infoStr := string(Iinfos)
  3038. idetinfoStr := string(Idetinfos)
  3039. psn := &models.HisPsn{
  3040. PsnNo: res.Output.Baseinfo.PsnNo,
  3041. Age: res.Output.Baseinfo.Age,
  3042. PatientId: patient.ID,
  3043. Certno: res.Output.Baseinfo.Certno,
  3044. Brdy: res.Output.Baseinfo.Brdy,
  3045. Gend: res.Output.Baseinfo.Gend,
  3046. Naty: res.Output.Baseinfo.Naty,
  3047. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3048. PsnName: res.Output.Baseinfo.PsnName,
  3049. Idetinfo: idetinfoStr,
  3050. Insuinfo: infoStr,
  3051. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3052. CardInfo: basStr,
  3053. VerifyNumber: "",
  3054. }
  3055. service.CreateHisPsn(psn)
  3056. var rf []*ResultFive
  3057. json.Unmarshal([]byte(infoStr), &rf)
  3058. var insutypes []*ResultFive
  3059. var insutype string
  3060. var is390 int = 0
  3061. var is310 int = 0
  3062. for _, item := range rf {
  3063. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3064. insutypes = append(insutypes, item)
  3065. }
  3066. }
  3067. if len(insutypes) == 1 {
  3068. insutype = insutypes[0].Insutype
  3069. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3070. } else {
  3071. for _, i := range insutypes {
  3072. if i.Insutype == "390" {
  3073. is390 = 1
  3074. }
  3075. if i.Insutype == "310" {
  3076. is310 = 1
  3077. }
  3078. }
  3079. }
  3080. if is390 == 1 {
  3081. insutype = "390"
  3082. }
  3083. if is310 == 1 {
  3084. insutype = "310"
  3085. }
  3086. if len(insutypes) == 0 {
  3087. insutype = "310"
  3088. }
  3089. c.ServeSuccessJSON(map[string]interface{}{
  3090. "patient": patient,
  3091. "number": basNumber,
  3092. "insutype": insutype,
  3093. })
  3094. }
  3095. } else {
  3096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3097. return
  3098. }
  3099. } else {
  3100. if initFlag == 0 {
  3101. c.TestGetBasBaseInit()
  3102. }
  3103. basStr := c.GetBasBaseInfo()
  3104. if len(basStr) == 0 {
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3106. return
  3107. }
  3108. fmt.Println(basStr)
  3109. bas := strings.Split(basStr, "|")
  3110. basNumber := bas[1]
  3111. fmt.Println(basNumber)
  3112. card_sn := bas[3]
  3113. fmt.Println(card_sn)
  3114. cardNumber := bas[2]
  3115. fmt.Println(cardNumber)
  3116. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  3117. result := service.Gdyb1101f(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  3118. var dat map[string]interface{}
  3119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3120. fmt.Println(dat)
  3121. } else {
  3122. fmt.Println(err)
  3123. }
  3124. userJSONBytes, _ := json.Marshal(dat)
  3125. var res ResultTwo
  3126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3127. utils.ErrorLog("解析失败:%v", err)
  3128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3129. return
  3130. }
  3131. if res.Infcode == 0 {
  3132. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3133. if err == gorm.ErrRecordNotFound {
  3134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3135. return
  3136. } else if err != nil {
  3137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3138. return
  3139. } else {
  3140. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3141. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3142. infoStr := string(Iinfos)
  3143. idetinfoStr := string(Idetinfos)
  3144. var rf []*ResultFive
  3145. json.Unmarshal([]byte(infoStr), &rf)
  3146. var insutypes []*ResultFive
  3147. var insutype string
  3148. var is390 int = 0
  3149. var is310 int = 0
  3150. var insuplc_admdvs string
  3151. for _, item := range rf {
  3152. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3153. insutypes = append(insutypes, item)
  3154. }
  3155. }
  3156. if len(insutypes) == 1 {
  3157. insutype = insutypes[0].Insutype
  3158. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3159. } else {
  3160. for _, i := range insutypes {
  3161. if i.Insutype == "390" {
  3162. is390 = 1
  3163. }
  3164. if i.Insutype == "310" {
  3165. is310 = 1
  3166. }
  3167. }
  3168. }
  3169. if is390 == 1 {
  3170. insutype = "390"
  3171. }
  3172. if is310 == 1 {
  3173. insutype = "310"
  3174. }
  3175. if len(insutypes) == 0 {
  3176. insutype = "310"
  3177. }
  3178. for _, item := range rf {
  3179. if item.Insutype == insutype {
  3180. insuplc_admdvs = item.InsuplcAdmdvs
  3181. }
  3182. }
  3183. psn := &models.HisPsn{
  3184. PsnNo: res.Output.Baseinfo.PsnNo,
  3185. Age: res.Output.Baseinfo.Age,
  3186. PatientId: patient.ID,
  3187. Certno: res.Output.Baseinfo.Certno,
  3188. Brdy: res.Output.Baseinfo.Brdy,
  3189. Gend: res.Output.Baseinfo.Gend,
  3190. Naty: res.Output.Baseinfo.Naty,
  3191. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3192. PsnName: res.Output.Baseinfo.PsnName,
  3193. Idetinfo: idetinfoStr,
  3194. Insuinfo: infoStr,
  3195. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3196. CardInfo: basStr,
  3197. VerifyNumber: "",
  3198. InsuplcAdmdvs: insuplc_admdvs,
  3199. }
  3200. service.CreateHisPsn(psn)
  3201. c.ServeSuccessJSON(map[string]interface{}{
  3202. "patient": patient,
  3203. "number": basNumber,
  3204. })
  3205. }
  3206. } else {
  3207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3208. return
  3209. }
  3210. break
  3211. }
  3212. case 2:
  3213. if miConfig.MdtrtareaAdmvs == "430800" {
  3214. if initFlag == 0 {
  3215. c.TestGetHnBasBaseInit()
  3216. }
  3217. SFZStr := c.GetSFZBaseInfo()
  3218. if len(SFZStr) == 0 {
  3219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3220. return
  3221. }
  3222. fmt.Println(SFZStr)
  3223. id_card_str := strings.Split(SFZStr, "^")
  3224. card_no := id_card_str[0]
  3225. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3226. //name := id_card_str[1]
  3227. //name = ConvertToString(name, "gbk", "utf-8")
  3228. result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", patient.Name, card_no)
  3229. var dat map[string]interface{}
  3230. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3231. fmt.Println(dat)
  3232. } else {
  3233. fmt.Println(err)
  3234. }
  3235. userJSONBytes, _ := json.Marshal(dat)
  3236. var res ResultTwo
  3237. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3238. utils.ErrorLog("解析失败:%v", err)
  3239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3240. return
  3241. }
  3242. if res.Infcode == 0 {
  3243. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3244. if err == gorm.ErrRecordNotFound {
  3245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3246. return
  3247. } else if err != nil {
  3248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3249. return
  3250. } else {
  3251. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3252. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3253. infoStr := string(Iinfos)
  3254. idetinfoStr := string(Idetinfos)
  3255. psn := &models.HisPsn{
  3256. PsnNo: res.Output.Baseinfo.PsnNo,
  3257. Age: res.Output.Baseinfo.Age,
  3258. PatientId: patient.ID,
  3259. Certno: res.Output.Baseinfo.Certno,
  3260. Brdy: res.Output.Baseinfo.Brdy,
  3261. Gend: res.Output.Baseinfo.Gend,
  3262. Naty: res.Output.Baseinfo.Naty,
  3263. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3264. PsnName: res.Output.Baseinfo.PsnName,
  3265. Idetinfo: idetinfoStr,
  3266. Insuinfo: infoStr,
  3267. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3268. CardInfo: SFZStr,
  3269. VerifyNumber: "",
  3270. }
  3271. service.CreateHisPsn(psn)
  3272. var rf []*ResultFive
  3273. json.Unmarshal([]byte(infoStr), &rf)
  3274. var insutypes []*ResultFive
  3275. var insutype string
  3276. var is390 int = 0
  3277. var is310 int = 0
  3278. for _, item := range rf {
  3279. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3280. insutypes = append(insutypes, item)
  3281. }
  3282. }
  3283. if len(insutypes) == 1 {
  3284. insutype = insutypes[0].Insutype
  3285. } else {
  3286. for _, i := range insutypes {
  3287. if i.Insutype == "390" {
  3288. is390 = 1
  3289. }
  3290. if i.Insutype == "310" {
  3291. is310 = 1
  3292. }
  3293. }
  3294. }
  3295. if is390 == 1 {
  3296. insutype = "390"
  3297. }
  3298. if is310 == 1 {
  3299. insutype = "310"
  3300. }
  3301. if len(insutypes) == 0 {
  3302. insutype = "310"
  3303. }
  3304. c.ServeSuccessJSON(map[string]interface{}{
  3305. "patient": patient,
  3306. "number": card_no,
  3307. "insutype": insutype,
  3308. })
  3309. }
  3310. } else {
  3311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3312. return
  3313. }
  3314. } else {
  3315. SFZStr := c.GetSFZBaseInfo()
  3316. id_card_str := strings.Split(SFZStr, "^")
  3317. id_card_number := id_card_str[0]
  3318. card_sn := ""
  3319. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  3320. var dat map[string]interface{}
  3321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3322. fmt.Println(dat)
  3323. } else {
  3324. fmt.Println(err)
  3325. }
  3326. userJSONBytes, _ := json.Marshal(dat)
  3327. var res ResultTwo
  3328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3329. utils.ErrorLog("解析失败:%v", err)
  3330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3331. return
  3332. }
  3333. if res.Infcode == 0 {
  3334. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  3335. if err == gorm.ErrRecordNotFound {
  3336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3337. return
  3338. } else if err != nil {
  3339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3340. return
  3341. } else {
  3342. c.ServeSuccessJSON(map[string]interface{}{
  3343. "patient": patient,
  3344. "number": id_card_number,
  3345. })
  3346. }
  3347. } else {
  3348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3349. return
  3350. }
  3351. }
  3352. break
  3353. case 3:
  3354. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3355. var api string
  3356. if miConfig.MdtrtareaAdmvs == "320921" {
  3357. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3358. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  3359. fmt.Println(api)
  3360. } else {
  3361. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3362. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  3363. }
  3364. resp, requestErr := http.Get(api)
  3365. if requestErr != nil {
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. body, ioErr := ioutil.ReadAll(resp.Body)
  3370. if ioErr != nil {
  3371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. var respJSON map[string]interface{}
  3376. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3379. return
  3380. }
  3381. var status string
  3382. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3383. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3384. var token string
  3385. var res ResultTwo //1101结果
  3386. var res10265 ResultTwo10265 //1101结果
  3387. var card_info string //卡信息
  3388. var busi_card_info string
  3389. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3390. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3391. if status == "0" { //读卡成功
  3392. if card_type == "1" {
  3393. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3394. result, _ := json.Marshal(respJSON)
  3395. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3396. utils.ErrorLog("解析失败:%v", err)
  3397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3398. return
  3399. }
  3400. res.ErrMsg = res10265.ErrMsg
  3401. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3402. res.Infcode = infocode
  3403. res.Output = res10265.Output
  3404. res.InfRefmsgid = res10265.InfRefmsgid
  3405. } else {
  3406. //var card_info string //卡信息
  3407. //var busi_card_info string
  3408. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3409. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3410. //fmt.Println(card_info)
  3411. //fmt.Println(busi_card_info)
  3412. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3413. result, _ := json.Marshal(respJSON)
  3414. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3415. utils.ErrorLog("解析失败:%v", err)
  3416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3417. return
  3418. }
  3419. res.ErrMsg = res10265.ErrMsg
  3420. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3421. res.Infcode = infocode
  3422. res.Output = res10265.Output
  3423. res.InfRefmsgid = res10265.InfRefmsgid
  3424. }
  3425. if res.Infcode == 0 {
  3426. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3427. if err == gorm.ErrRecordNotFound {
  3428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3429. return
  3430. } else if err != nil {
  3431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3432. return
  3433. } else {
  3434. if card_type == "1" {
  3435. bas := strings.Split(card_info, "|")
  3436. basNumber := bas[2]
  3437. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3438. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3439. infoStr := string(Iinfos)
  3440. idetinfoStr := string(Idetinfos)
  3441. psn := &models.HisPsn{
  3442. PsnNo: res.Output.Baseinfo.PsnNo,
  3443. Age: res.Output.Baseinfo.Age,
  3444. PatientId: patient.ID,
  3445. Certno: res.Output.Baseinfo.Certno,
  3446. Brdy: res.Output.Baseinfo.Brdy,
  3447. Gend: res.Output.Baseinfo.Gend,
  3448. Naty: res.Output.Baseinfo.Naty,
  3449. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3450. PsnName: res.Output.Baseinfo.PsnName,
  3451. Idetinfo: idetinfoStr,
  3452. Insuinfo: infoStr,
  3453. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3454. CardInfo: card_info,
  3455. VerifyNumber: busi_card_info,
  3456. }
  3457. service.CreateHisPsn(psn)
  3458. c.ServeSuccessJSON(map[string]interface{}{
  3459. "patient": patient,
  3460. "number": basNumber,
  3461. })
  3462. } else {
  3463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3465. infoStr := string(Iinfos)
  3466. idetinfoStr := string(Idetinfos)
  3467. psn := &models.HisPsn{
  3468. PsnNo: res.Output.Baseinfo.PsnNo,
  3469. Age: res.Output.Baseinfo.Age,
  3470. PatientId: patient.ID,
  3471. Certno: res.Output.Baseinfo.Certno,
  3472. Brdy: res.Output.Baseinfo.Brdy,
  3473. Gend: res.Output.Baseinfo.Gend,
  3474. Naty: res.Output.Baseinfo.Naty,
  3475. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3476. PsnName: res.Output.Baseinfo.PsnName,
  3477. Idetinfo: idetinfoStr,
  3478. Insuinfo: infoStr,
  3479. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3480. CardInfo: card_info,
  3481. VerifyNumber: token,
  3482. }
  3483. service.CreateHisPsn(psn)
  3484. var rf []*ResultFive
  3485. json.Unmarshal([]byte(infoStr), &rf)
  3486. var insutypes []*ResultFive
  3487. var insutype string
  3488. var is390 int = 0
  3489. var is310 int = 0
  3490. for _, item := range rf {
  3491. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3492. insutypes = append(insutypes, item)
  3493. }
  3494. }
  3495. if len(insutypes) == 1 {
  3496. insutype = insutypes[0].Insutype
  3497. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3498. } else {
  3499. for _, i := range insutypes {
  3500. if i.Insutype == "390" {
  3501. is390 = 1
  3502. }
  3503. if i.Insutype == "310" {
  3504. is310 = 1
  3505. }
  3506. }
  3507. }
  3508. if is390 == 1 {
  3509. insutype = "390"
  3510. }
  3511. if is310 == 1 {
  3512. insutype = "310"
  3513. }
  3514. if len(insutypes) == 0 {
  3515. insutype = "310"
  3516. }
  3517. c.ServeSuccessJSON(map[string]interface{}{
  3518. "patient": patient,
  3519. "number": token,
  3520. "insutype": insutype,
  3521. })
  3522. }
  3523. }
  3524. } else {
  3525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3526. return
  3527. }
  3528. } else { //读卡失败
  3529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3530. return
  3531. }
  3532. }
  3533. break
  3534. case 4:
  3535. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3536. var api string
  3537. if miConfig.MdtrtareaAdmvs == "320921" {
  3538. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3539. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  3540. fmt.Println(api)
  3541. } else {
  3542. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3543. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  3544. }
  3545. resp, requestErr := http.Get(api)
  3546. if requestErr != nil {
  3547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3548. return
  3549. }
  3550. body, ioErr := ioutil.ReadAll(resp.Body)
  3551. if ioErr != nil {
  3552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3554. return
  3555. }
  3556. var respJSON map[string]interface{}
  3557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3560. return
  3561. }
  3562. var status string
  3563. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3564. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3565. var token string
  3566. var res ResultTwo //1101结果
  3567. var res10265 ResultTwo10265 //1101结果
  3568. if status == "0" { //读卡成功
  3569. var card_info string //卡信息
  3570. var busi_card_info string
  3571. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3572. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3573. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3574. fmt.Println(card_info)
  3575. fmt.Println(busi_card_info)
  3576. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3577. result, _ := json.Marshal(respJSON)
  3578. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3579. utils.ErrorLog("解析失败:%v", err)
  3580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3581. return
  3582. }
  3583. res.ErrMsg = res10265.ErrMsg
  3584. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3585. res.Infcode = infocode
  3586. res.Output = res10265.Output
  3587. res.InfRefmsgid = res10265.InfRefmsgid
  3588. if res.Infcode == 0 {
  3589. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3590. if err == gorm.ErrRecordNotFound {
  3591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3592. return
  3593. } else if err != nil {
  3594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3595. return
  3596. } else {
  3597. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3598. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3599. infoStr := string(Iinfos)
  3600. idetinfoStr := string(Idetinfos)
  3601. psn := &models.HisPsn{
  3602. PsnNo: res.Output.Baseinfo.PsnNo,
  3603. Age: res.Output.Baseinfo.Age,
  3604. PatientId: patient.ID,
  3605. Certno: res.Output.Baseinfo.Certno,
  3606. Brdy: res.Output.Baseinfo.Brdy,
  3607. Gend: res.Output.Baseinfo.Gend,
  3608. Naty: res.Output.Baseinfo.Naty,
  3609. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3610. PsnName: res.Output.Baseinfo.PsnName,
  3611. Idetinfo: idetinfoStr,
  3612. Insuinfo: infoStr,
  3613. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3614. CardInfo: card_info,
  3615. VerifyNumber: token,
  3616. }
  3617. var rf []*ResultFive
  3618. json.Unmarshal([]byte(infoStr), &rf)
  3619. var insutypes []*ResultFive
  3620. var insutype string
  3621. var is390 int = 0
  3622. var is310 int = 0
  3623. for _, item := range rf {
  3624. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3625. insutypes = append(insutypes, item)
  3626. }
  3627. }
  3628. if len(insutypes) == 1 {
  3629. insutype = insutypes[0].Insutype
  3630. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3631. } else {
  3632. for _, i := range insutypes {
  3633. if i.Insutype == "390" {
  3634. is390 = 1
  3635. }
  3636. if i.Insutype == "310" {
  3637. is310 = 1
  3638. }
  3639. }
  3640. }
  3641. if is390 == 1 {
  3642. insutype = "390"
  3643. }
  3644. if is310 == 1 {
  3645. insutype = "310"
  3646. }
  3647. if len(insutypes) == 0 {
  3648. insutype = "310"
  3649. }
  3650. service.CreateHisPsn(psn)
  3651. c.ServeSuccessJSON(map[string]interface{}{
  3652. "patient": patient,
  3653. "number": token,
  3654. "insutype": insutype,
  3655. })
  3656. }
  3657. } else {
  3658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3659. return
  3660. }
  3661. } else { //读卡失败
  3662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3663. return
  3664. }
  3665. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3666. if initFlag == 0 {
  3667. c.TestGetBasBaseInit()
  3668. }
  3669. token := c.GetEleBaseInfo()
  3670. token = Remove0000(token)
  3671. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  3672. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3673. //
  3674. var res ResultTwo
  3675. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3676. utils.ErrorLog("解析失败:%v", err)
  3677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3678. return
  3679. }
  3680. if res.Infcode == 0 {
  3681. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3682. if err == gorm.ErrRecordNotFound {
  3683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3684. return
  3685. } else if err != nil {
  3686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3687. return
  3688. } else {
  3689. //month := time.Unix(1557042972, 0).Format("1")
  3690. //year := time.Now().Format("2006")
  3691. //month = time.Now().Format("01")
  3692. //day := time.Now().Format("02")
  3693. //date := year+"-"+month+"-"+day + " "+"00:00:00"
  3694. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3695. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3696. infoStr := string(Iinfos)
  3697. idetinfoStr := string(Idetinfos)
  3698. psn := &models.HisPsn{
  3699. PsnNo: res.Output.Baseinfo.PsnNo,
  3700. Age: res.Output.Baseinfo.Age,
  3701. PatientId: patient.ID,
  3702. Certno: res.Output.Baseinfo.Certno,
  3703. Brdy: res.Output.Baseinfo.Brdy,
  3704. Gend: res.Output.Baseinfo.Gend,
  3705. Naty: res.Output.Baseinfo.Naty,
  3706. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3707. PsnName: res.Output.Baseinfo.PsnName,
  3708. Idetinfo: idetinfoStr,
  3709. Insuinfo: infoStr,
  3710. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3711. CardInfo: "",
  3712. Stage: "1",
  3713. //RecordDate:
  3714. VerifyNumber: token,
  3715. }
  3716. service.CreateHisPsn(psn)
  3717. c.ServeSuccessJSON(map[string]interface{}{
  3718. "patient": patient,
  3719. "number": token,
  3720. })
  3721. }
  3722. } else {
  3723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3724. return
  3725. }
  3726. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3727. //if initFlag == 0 {
  3728. c.TestGetJiangXiBasBaseInit()
  3729. //}
  3730. //if initEleFlag == 0 {
  3731. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3732. //}
  3733. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3734. type ELeData struct {
  3735. Data struct {
  3736. IdNo string `json:"idNo"`
  3737. IdType string `json:"idType"`
  3738. UserName string `json:"userName"`
  3739. EcToken string `json:"ecToken"`
  3740. InsuOrg string `json:"insuOrg"`
  3741. Gender string `json:"gender"`
  3742. Birthday string `json:"birthday"`
  3743. Nationality string `json:"nationality"`
  3744. Email string `json:"email"`
  3745. Extra string `json:"extra"`
  3746. } `json:"data"`
  3747. Code int `json:"code"`
  3748. Message string `json:"message"`
  3749. }
  3750. var ele ELeData
  3751. err := json.Unmarshal([]byte(json_result), &ele)
  3752. if err != nil {
  3753. utils.ErrorLog("解析失败:%v", err)
  3754. }
  3755. token := ele.Data.EcToken
  3756. token = Remove0000(token)
  3757. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  3758. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3759. var res ResultTwo
  3760. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3761. utils.ErrorLog("解析失败:%v", err)
  3762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3763. return
  3764. }
  3765. if res.Infcode == 0 {
  3766. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3767. if err == gorm.ErrRecordNotFound {
  3768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3769. return
  3770. } else if err != nil {
  3771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3772. return
  3773. } else {
  3774. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3775. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3776. infoStr := string(Iinfos)
  3777. idetinfoStr := string(Idetinfos)
  3778. psn := &models.HisPsn{
  3779. PsnNo: res.Output.Baseinfo.PsnNo,
  3780. Age: res.Output.Baseinfo.Age,
  3781. PatientId: patient.ID,
  3782. Certno: res.Output.Baseinfo.Certno,
  3783. Brdy: res.Output.Baseinfo.Brdy,
  3784. Gend: res.Output.Baseinfo.Gend,
  3785. Naty: res.Output.Baseinfo.Naty,
  3786. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3787. PsnName: res.Output.Baseinfo.PsnName,
  3788. Idetinfo: idetinfoStr,
  3789. Insuinfo: infoStr,
  3790. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3791. CardInfo: "",
  3792. //RecordDate:
  3793. VerifyNumber: token,
  3794. }
  3795. service.CreateHisPsn(psn)
  3796. var rf []*ResultFive
  3797. json.Unmarshal([]byte(infoStr), &rf)
  3798. var insutypes []*ResultFive
  3799. var insutype string
  3800. var is390 int = 0
  3801. var is310 int = 0
  3802. for _, item := range rf {
  3803. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3804. insutypes = append(insutypes, item)
  3805. }
  3806. }
  3807. if len(insutypes) == 1 {
  3808. insutype = insutypes[0].Insutype
  3809. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3810. } else {
  3811. for _, i := range insutypes {
  3812. if i.Insutype == "390" {
  3813. is390 = 1
  3814. }
  3815. if i.Insutype == "310" {
  3816. is310 = 1
  3817. }
  3818. }
  3819. }
  3820. if is390 == 1 {
  3821. insutype = "390"
  3822. }
  3823. if is310 == 1 {
  3824. insutype = "310"
  3825. }
  3826. if len(insutypes) == 0 {
  3827. insutype = "310"
  3828. }
  3829. c.ServeSuccessJSON(map[string]interface{}{
  3830. "patient": patient,
  3831. "number": token,
  3832. "insutype": insutype,
  3833. })
  3834. }
  3835. } else {
  3836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3837. return
  3838. }
  3839. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3840. //if initFlag == 0 {
  3841. c.TestGetJiangXiBasBaseInit()
  3842. //}
  3843. //if initEleFlag == 0 {
  3844. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3845. //}
  3846. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3847. type ELeData struct {
  3848. Data struct {
  3849. IdNo string `json:"idNo"`
  3850. IdType string `json:"idType"`
  3851. UserName string `json:"userName"`
  3852. EcToken string `json:"ecToken"`
  3853. InsuOrg string `json:"insuOrg"`
  3854. Gender string `json:"gender"`
  3855. Birthday string `json:"birthday"`
  3856. Nationality string `json:"nationality"`
  3857. Email string `json:"email"`
  3858. Extra string `json:"extra"`
  3859. } `json:"data"`
  3860. Code int `json:"code"`
  3861. Message string `json:"message"`
  3862. }
  3863. var ele ELeData
  3864. err := json.Unmarshal([]byte(json_result), &ele)
  3865. if err != nil {
  3866. utils.ErrorLog("解析失败:%v", err)
  3867. }
  3868. token := ele.Data.EcToken
  3869. token = Remove0000(token)
  3870. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  3871. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3872. var res ResultTwo
  3873. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3874. utils.ErrorLog("解析失败:%v", err)
  3875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3876. return
  3877. }
  3878. if res.Infcode == 0 {
  3879. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3880. if err == gorm.ErrRecordNotFound {
  3881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3882. return
  3883. } else if err != nil {
  3884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3885. return
  3886. } else {
  3887. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3888. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3889. infoStr := string(Iinfos)
  3890. idetinfoStr := string(Idetinfos)
  3891. psn := &models.HisPsn{
  3892. PsnNo: res.Output.Baseinfo.PsnNo,
  3893. Age: res.Output.Baseinfo.Age,
  3894. PatientId: patient.ID,
  3895. Certno: res.Output.Baseinfo.Certno,
  3896. Brdy: res.Output.Baseinfo.Brdy,
  3897. Gend: res.Output.Baseinfo.Gend,
  3898. Naty: res.Output.Baseinfo.Naty,
  3899. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3900. PsnName: res.Output.Baseinfo.PsnName,
  3901. Idetinfo: idetinfoStr,
  3902. Insuinfo: infoStr,
  3903. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3904. CardInfo: "",
  3905. VerifyNumber: token,
  3906. }
  3907. service.CreateHisPsn(psn)
  3908. var rf []*ResultFive
  3909. json.Unmarshal([]byte(infoStr), &rf)
  3910. var insutypes []*ResultFive
  3911. var insutype string
  3912. var is390 int = 0
  3913. var is310 int = 0
  3914. for _, item := range rf {
  3915. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3916. insutypes = append(insutypes, item)
  3917. }
  3918. }
  3919. if len(insutypes) == 1 {
  3920. insutype = insutypes[0].Insutype
  3921. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3922. } else {
  3923. for _, i := range insutypes {
  3924. if i.Insutype == "390" {
  3925. is390 = 1
  3926. }
  3927. if i.Insutype == "310" {
  3928. is310 = 1
  3929. }
  3930. }
  3931. }
  3932. if is390 == 1 {
  3933. insutype = "390"
  3934. }
  3935. if is310 == 1 {
  3936. insutype = "310"
  3937. }
  3938. if len(insutypes) == 0 {
  3939. insutype = "310"
  3940. }
  3941. c.ServeSuccessJSON(map[string]interface{}{
  3942. "patient": patient,
  3943. "number": token,
  3944. "insutype": insutype,
  3945. })
  3946. }
  3947. } else {
  3948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3949. return
  3950. }
  3951. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3952. type ELeData struct {
  3953. Code string `json:"code"`
  3954. Data struct {
  3955. Aac002 string `json:"aac002"`
  3956. Aaz500 string `json:"aaz500"`
  3957. ActCardNo string `json:"actCardNo"`
  3958. Bab520 string `json:"bab520"`
  3959. Bkz543 string `json:"bkz543"`
  3960. BusinessType string `json:"businessType"`
  3961. CertfCodg string `json:"certfCodg"`
  3962. EcIndexNo string `json:"ecIndexNo"`
  3963. EcToken string `json:"ecToken"`
  3964. ID0000 string `json:"id0000"`
  3965. IDNo string `json:"idNo"`
  3966. IDType string `json:"idType"`
  3967. Idcode string `json:"idcode"`
  3968. IdentityToken string `json:"identity_token"`
  3969. InsuOrg string `json:"insuOrg"`
  3970. OfficeID string `json:"officeId"`
  3971. OfficeName string `json:"officeName"`
  3972. OperatorID string `json:"operatorId"`
  3973. OperatorName string `json:"operatorName"`
  3974. OrgID string `json:"orgId"`
  3975. UserName string `json:"userName"`
  3976. } `json:"data"`
  3977. Infno interface{} `json:"infno"`
  3978. Message string `json:"message"`
  3979. OrgID string `json:"orgId"`
  3980. TransType string `json:"transType"`
  3981. }
  3982. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3983. outPutInfo = Remove0000(outPutInfo)
  3984. if len(outPutInfo) > 0 {
  3985. var ele ELeData
  3986. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3987. if err != nil {
  3988. utils.ErrorLog("解析失败:%v", err)
  3989. }
  3990. token := ele.Data.EcToken
  3991. fmt.Println(inputInfo)
  3992. fmt.Println(outPutInfo)
  3993. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  3994. saveLog(result, requestLog, "1101", "获取人员信息")
  3995. var dat map[string]interface{}
  3996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3997. fmt.Println(dat)
  3998. } else {
  3999. fmt.Println(err)
  4000. }
  4001. userJSONBytes, _ := json.Marshal(dat)
  4002. var res ResultTwo
  4003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4004. utils.ErrorLog("解析失败:%v", err)
  4005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4006. return
  4007. }
  4008. res.ErrMsg = errMsgLog
  4009. if res.Infcode == 0 {
  4010. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4011. if err == gorm.ErrRecordNotFound {
  4012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4013. return
  4014. } else if err != nil {
  4015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4016. return
  4017. } else {
  4018. fmt.Println(res)
  4019. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4020. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4021. infoStr := string(Iinfos)
  4022. idetinfoStr := string(Idetinfos)
  4023. psn := &models.HisPsn{
  4024. PsnNo: res.Output.Baseinfo.PsnNo,
  4025. Age: res.Output.Baseinfo.Age,
  4026. PatientId: patient.ID,
  4027. Certno: res.Output.Baseinfo.Certno,
  4028. Brdy: res.Output.Baseinfo.Brdy,
  4029. Gend: res.Output.Baseinfo.Gend,
  4030. Naty: res.Output.Baseinfo.Naty,
  4031. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4032. PsnName: res.Output.Baseinfo.PsnName,
  4033. Idetinfo: idetinfoStr,
  4034. Insuinfo: infoStr,
  4035. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4036. CardInfo: outPutInfo,
  4037. VerifyNumber: token,
  4038. InsuplcAdmdvs: ele.Data.InsuOrg,
  4039. }
  4040. service.CreateHisPsn(psn)
  4041. var rf []*ResultFive
  4042. json.Unmarshal([]byte(infoStr), &rf)
  4043. var insutypes []*ResultFive
  4044. var insutype string
  4045. var is390 int = 0
  4046. var is310 int = 0
  4047. for _, item := range rf {
  4048. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4049. insutypes = append(insutypes, item)
  4050. }
  4051. }
  4052. if len(insutypes) == 1 {
  4053. insutype = insutypes[0].Insutype
  4054. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4055. } else {
  4056. for _, i := range insutypes {
  4057. if i.Insutype == "390" {
  4058. is390 = 1
  4059. }
  4060. if i.Insutype == "310" {
  4061. is310 = 1
  4062. }
  4063. }
  4064. }
  4065. if is390 == 1 {
  4066. insutype = "390"
  4067. }
  4068. if is310 == 1 {
  4069. insutype = "310"
  4070. }
  4071. if len(insutypes) == 0 {
  4072. insutype = "310"
  4073. }
  4074. c.ServeSuccessJSON(map[string]interface{}{
  4075. "patient": patient,
  4076. "number": token,
  4077. "insutype": insutype,
  4078. })
  4079. }
  4080. } else {
  4081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4082. return
  4083. }
  4084. }
  4085. } else {
  4086. if initFlag == 0 {
  4087. c.TestGetBasBaseInit()
  4088. }
  4089. token := c.GetEleBaseInfo()
  4090. token = Remove0000(token)
  4091. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  4092. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4093. //
  4094. var res ResultTwo
  4095. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4096. utils.ErrorLog("解析失败:%v", err)
  4097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4098. return
  4099. }
  4100. if res.Infcode == 0 {
  4101. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4102. if err == gorm.ErrRecordNotFound {
  4103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4104. return
  4105. } else if err != nil {
  4106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4107. return
  4108. } else {
  4109. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4110. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4111. infoStr := string(Iinfos)
  4112. idetinfoStr := string(Idetinfos)
  4113. psn := &models.HisPsn{
  4114. PsnNo: res.Output.Baseinfo.PsnNo,
  4115. Age: res.Output.Baseinfo.Age,
  4116. PatientId: patient.ID,
  4117. Certno: res.Output.Baseinfo.Certno,
  4118. Brdy: res.Output.Baseinfo.Brdy,
  4119. Gend: res.Output.Baseinfo.Gend,
  4120. Naty: res.Output.Baseinfo.Naty,
  4121. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4122. PsnName: res.Output.Baseinfo.PsnName,
  4123. Idetinfo: idetinfoStr,
  4124. Insuinfo: infoStr,
  4125. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4126. CardInfo: "",
  4127. VerifyNumber: token,
  4128. }
  4129. service.CreateHisPsn(psn)
  4130. c.ServeSuccessJSON(map[string]interface{}{
  4131. "patient": patient,
  4132. "number": token,
  4133. })
  4134. }
  4135. } else {
  4136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4137. return
  4138. }
  4139. }
  4140. break
  4141. }
  4142. }
  4143. var initFlag int64 = 0
  4144. var initEleFlag int64 = 0
  4145. func (c *HisApiController) TestGetBasBaseInit() {
  4146. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4147. Iinit := DllDef.MustFindProc("Init")
  4148. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4149. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  4150. if ret != 0 {
  4151. fmt.Println("SSCard的报错原因:", err)
  4152. fmt.Println("SSCard的运算结果为:", ret)
  4153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4154. return
  4155. }
  4156. result := int(ret)
  4157. fmt.Println("SSCard的运算结果为1:", result)
  4158. initFlag = 1
  4159. return
  4160. }
  4161. func (c *HisApiController) HandleJiangXiReadCard() {
  4162. fmt.Println("~~~~~~")
  4163. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4164. admin_user_id, _ := c.GetInt64("admin_user_id")
  4165. id_card_type, _ := c.GetInt64("id_card_type")
  4166. //certificates, _ := c.GetInt64("certificates")
  4167. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4168. if initFlag == 0 {
  4169. c.TestGetJiangXiBasBaseInit()
  4170. }
  4171. basStr := c.GetBasBaseInfo()
  4172. if len(basStr) == 0 {
  4173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4174. return
  4175. }
  4176. fmt.Println(basStr)
  4177. bas := strings.Split(basStr, "|")
  4178. basNumber := bas[1]
  4179. fmt.Println(basNumber)
  4180. card_sn := bas[3]
  4181. fmt.Println(card_sn)
  4182. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  4183. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4184. var dat map[string]interface{}
  4185. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4186. fmt.Println(dat)
  4187. } else {
  4188. fmt.Println(err)
  4189. }
  4190. userJSONBytes, _ := json.Marshal(dat)
  4191. var res ResultTwo
  4192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4193. utils.ErrorLog("解析失败:%v", err)
  4194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4195. return
  4196. }
  4197. if res.Infcode == 0 {
  4198. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4199. if err == gorm.ErrRecordNotFound {
  4200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4201. return
  4202. } else if err != nil {
  4203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4204. return
  4205. } else {
  4206. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4207. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4208. infoStr := string(Iinfos)
  4209. idetinfoStr := string(Idetinfos)
  4210. psn := &models.HisPsn{
  4211. PsnNo: res.Output.Baseinfo.PsnNo,
  4212. Age: res.Output.Baseinfo.Age,
  4213. PatientId: patient.ID,
  4214. Certno: res.Output.Baseinfo.Certno,
  4215. Brdy: res.Output.Baseinfo.Brdy,
  4216. Gend: res.Output.Baseinfo.Gend,
  4217. Naty: res.Output.Baseinfo.Naty,
  4218. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4219. PsnName: res.Output.Baseinfo.PsnName,
  4220. Idetinfo: idetinfoStr,
  4221. Insuinfo: infoStr,
  4222. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4223. CardInfo: basStr,
  4224. VerifyNumber: "",
  4225. }
  4226. service.CreateHisPsn(psn)
  4227. c.ServeSuccessJSON(map[string]interface{}{
  4228. "patient": patient,
  4229. "number": basNumber,
  4230. })
  4231. }
  4232. } else {
  4233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4234. return
  4235. }
  4236. }
  4237. func (c *HisApiController) TestGetHnBasBaseInit() {
  4238. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4239. Iinit := DllDef.MustFindProc("Init")
  4240. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4241. //http://10.77.211.236/CSB/hsa-fsi-1303
  4242. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  4243. if ret != 0 {
  4244. fmt.Println("SSCard的报错原因:", err)
  4245. fmt.Println("SSCard的运算结果为:", ret)
  4246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4247. return
  4248. }
  4249. result := int(ret)
  4250. fmt.Println("SSCard的运算结果为1:", result)
  4251. initFlag = 1
  4252. return
  4253. }
  4254. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  4255. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4256. Iinit := DllDef.MustFindProc("Init")
  4257. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4258. //http://10.77.211.236/CSB/hsa-fsi-1303
  4259. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  4260. if ret != 0 {
  4261. fmt.Println("SSCard的报错原因:", err)
  4262. fmt.Println("SSCard的运算结果为:", ret)
  4263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4264. return
  4265. }
  4266. result := int(ret)
  4267. fmt.Println("SSCard的运算结果为1:", result)
  4268. initFlag = 1
  4269. return
  4270. }
  4271. func (c *HisApiController) GetSFZBaseInfo() string {
  4272. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4273. readCard := DllDef.MustFindProc("ReadSFZ")
  4274. if readCard == nil {
  4275. fmt.Println("readcard is nil")
  4276. readCard = DllDef.MustFindProc("ReadSFZ")
  4277. }
  4278. str := make([]byte, 8096)
  4279. str1 := make([]byte, 8096)
  4280. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  4281. fmt.Println(r)
  4282. return Remove0000(string(str))
  4283. }
  4284. func (c *HisApiController) GetEleBaseInfo() string {
  4285. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4286. readCard := DllDef.MustFindProc("GetQRBase")
  4287. fmt.Println(readCard)
  4288. if readCard == nil {
  4289. fmt.Println("readcard is nil")
  4290. readCard = DllDef.MustFindProc("GetQRBase")
  4291. }
  4292. str := make([]byte, 1024)
  4293. str1 := make([]byte, 1024)
  4294. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4295. fmt.Println(ret2)
  4296. fmt.Println(string(str1))
  4297. fmt.Println(string(str))
  4298. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4299. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4300. if ret2 != 0 {
  4301. return ""
  4302. }
  4303. return string(str)
  4304. }
  4305. func GetJxEleBaseInfo(org_id int64) string {
  4306. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4307. readCard := DllDef.MustFindProc("NationEcTrans")
  4308. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4309. if readCard == nil {
  4310. fmt.Println("readcard is nil")
  4311. readCard = DllDef.MustFindProc("NationEcTrans")
  4312. }
  4313. str1 := make([]byte, 1024)
  4314. data := make(map[string]interface{})
  4315. inputData := make(map[string]interface{})
  4316. inputData["orgId"] = miConfig.Code
  4317. inputData["businessType"] = "01101"
  4318. inputData["operatorId"] = "test001"
  4319. inputData["operatorName"] = "cn"
  4320. inputData["officeId"] = "32760"
  4321. inputData["officeName"] = "waike"
  4322. inputData["deviceType"] = ""
  4323. data["data"] = inputData
  4324. data["transType"] = "ec.query"
  4325. data["extra "] = ""
  4326. data["orgId"] = miConfig.Code
  4327. bytesData, _ := json.Marshal(data)
  4328. //bytesData, _ := json.Marshal(data)
  4329. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4330. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4331. fmt.Println(ret2)
  4332. fmt.Println(string(str1))
  4333. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4334. if ret2 != 0 {
  4335. return ""
  4336. }
  4337. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4338. }
  4339. func GetJxEleBaseInitInfo(org_id int64) string {
  4340. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4341. readCard := DllDef.MustFindProc("NationEcTrans")
  4342. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4343. if readCard == nil {
  4344. fmt.Println("readcard is nil")
  4345. readCard = DllDef.MustFindProc("NationEcTrans")
  4346. }
  4347. str1 := make([]byte, 2048)
  4348. data := make(map[string]interface{})
  4349. inputData := make(map[string]interface{})
  4350. inputData["orgId"] = miConfig.Code
  4351. inputData["businessType"] = "01101"
  4352. inputData["operatorId"] = "1"
  4353. inputData["operatorName"] = "huangchuang"
  4354. inputData["officeId"] = "101"
  4355. inputData["officeName"] = "xuetou"
  4356. inputData["deviceType"] = ""
  4357. data["data"] = inputData
  4358. data["transType"] = "ec.query"
  4359. data["orgId"] = miConfig.Code
  4360. bytesData, _ := json.Marshal(data)
  4361. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4362. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4363. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  4364. fmt.Println(ret2)
  4365. fmt.Println(string(str1))
  4366. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4367. if ret2 != 0 {
  4368. return ""
  4369. }
  4370. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  4371. initEleFlag = 1
  4372. }
  4373. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4374. }
  4375. func (c *HisApiController) GetBasBaseInfo() string {
  4376. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4377. readCard := DllDef.MustFindProc("ReadCardBas")
  4378. if readCard == nil {
  4379. fmt.Println("readcard is nil")
  4380. readCard = DllDef.MustFindProc("ReadCardBas")
  4381. }
  4382. str := make([]byte, 1024)
  4383. str1 := make([]byte, 1024)
  4384. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4385. fmt.Println(string(str1))
  4386. fmt.Println(string(str))
  4387. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4388. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4389. if ret2 != 0 {
  4390. return ""
  4391. }
  4392. return string(str)
  4393. }
  4394. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  4395. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  4396. readCard := DllDef.MustFindProc("read_cardinfo")
  4397. if readCard == nil {
  4398. fmt.Println("readcard is nil")
  4399. readCard = DllDef.MustFindProc("read_cardinfo")
  4400. }
  4401. str := make([]byte, 1024) //卡号
  4402. str1 := make([]byte, 1024) //卡识别码
  4403. str2 := make([]byte, 1024) //身份证号
  4404. str3 := make([]byte, 1024) //姓名
  4405. str4 := make([]byte, 1024) //错误信息
  4406. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  4407. fmt.Println(string(str1))
  4408. fmt.Println(string(str))
  4409. fmt.Println(string(str2))
  4410. fmt.Println(string(str3))
  4411. fmt.Println(string(str4))
  4412. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4413. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4414. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  4415. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  4416. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  4417. if ret2 != 0 {
  4418. return "", "", "", "", ""
  4419. }
  4420. return string(str), string(str1), string(str2), string(str3), string(str4)
  4421. }
  4422. type CustomFundPay struct {
  4423. FundPayType string `json:"fund_pay_type"`
  4424. FundPayamt float64 `json:"fund_payamt"`
  4425. }
  4426. func (c *HisApiController) GetSettleList() {
  4427. order_id, _ := c.GetInt64("order_id")
  4428. admin_user_id, _ := c.GetInt64("admin_user_id")
  4429. order, _ := service.GetHisOrderByIDTwo(order_id)
  4430. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4431. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4432. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4433. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4434. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4435. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4436. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4437. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4438. if order.ID == 0 {
  4439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4440. return
  4441. }
  4442. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4443. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4444. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4445. //fmt.Println(count)
  4446. //var zero string
  4447. //number := count + 1
  4448. //if number >= 1000 {
  4449. // zero = "0000" + strconv.FormatInt(number, 10)
  4450. //} else if number >= 10000 {
  4451. // zero = "000" + strconv.FormatInt(number, 10)
  4452. //} else if number >= 100000 {
  4453. // zero = "00" + strconv.FormatInt(number, 10)
  4454. //} else if number >= 1000000 {
  4455. // zero = "0" + strconv.FormatInt(number, 10)
  4456. //} else {
  4457. // zero = strconv.FormatInt(number, 10)
  4458. //}
  4459. //fmt.Println(zero)
  4460. struct4101 := service.Struct4101{
  4461. PsnNo: order.PsnNo,
  4462. MdtrtId: order.MdtrtId,
  4463. SetlId: order.SetlId,
  4464. PsnName: order.PsnName,
  4465. Gend: order.Gend,
  4466. Brdy: his.Brdy,
  4467. Age: his.Age,
  4468. Naty: order.Naty,
  4469. PatnCertType: "01",
  4470. Certno: order.Certno,
  4471. Prfs: "90",
  4472. ConerName: roles[0].UserName,
  4473. PatnRlts: "99",
  4474. ConerAddr: miConfig.OrgName,
  4475. ConerTel: admin.Mobile,
  4476. HiType: order.Insutype,
  4477. Insuplc: miConfig.InsuplcAdmdvs,
  4478. MaindiagFlag: "1",
  4479. BillCode: order.SetlId,
  4480. BillNo: order.SetlId,
  4481. BizSn: order.Number,
  4482. PsnSelfPay: order.PsnPartAmt,
  4483. PsnOwnPay: order.PsnPartAmt,
  4484. AcctPay: order.AcctPay,
  4485. PsnCashpay: order.PsnCashPay,
  4486. HiPaymtd: "1",
  4487. Hsorg: miConfig.InsuplcAdmdvs,
  4488. HsorgOpter: miConfig.InsuplcAdmdvs,
  4489. MedinsFillPsn: curRoles.UserName,
  4490. MedinsFillDept: depart.Name,
  4491. IptMedType: "2",
  4492. }
  4493. struct4101.SetlBegnDate = order.SetlTime
  4494. struct4101.SetlEndDate = order.SetlTime
  4495. time_arr := strings.Split(order.SetlTime, " ")
  4496. struct4101.AdmTime = time_arr[0]
  4497. struct4101.AdmEndTime = time_arr[0]
  4498. var rf []CustomFundPay
  4499. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4500. var tempFunPays []service.CustomStruct
  4501. for _, item := range rf {
  4502. var tempFunPay service.CustomStruct
  4503. tempFunPay.FundPayamt = item.FundPayamt
  4504. tempFunPay.FundPayType = item.FundPayType
  4505. tempFunPays = append(tempFunPays, tempFunPay)
  4506. }
  4507. struct4101.CustomStruct = tempFunPays
  4508. var tempDiaginfos []service.DiaginfoStructTwo
  4509. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4510. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4511. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4512. var config []*models.HisXtDiagnoseConfig
  4513. for _, item := range diagnosis_ids {
  4514. id, _ := strconv.ParseInt(item, 10, 64)
  4515. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4516. config = append(config, &diagnosisConfig)
  4517. }
  4518. for index, item := range config {
  4519. if index == 0 {
  4520. var tempDiaginfo service.DiaginfoStructTwo
  4521. tempDiaginfo.DiagCode = item.CountryCode
  4522. tempDiaginfo.DiagName = item.CountryContentName
  4523. tempDiaginfo.DiagType = "1"
  4524. tempDiaginfo.MaindiagFlag = "1"
  4525. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4526. } else {
  4527. var tempDiaginfo service.DiaginfoStructTwo
  4528. tempDiaginfo.DiagCode = item.CountryCode
  4529. tempDiaginfo.DiagName = item.CountryContentName
  4530. tempDiaginfo.DiagType = "2"
  4531. tempDiaginfo.MaindiagFlag = "0"
  4532. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4533. }
  4534. }
  4535. struct4101.Diseinfo = tempDiaginfos
  4536. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4537. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4538. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4539. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  4540. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  4541. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4542. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4543. var iteminfo service.IteminfoStruct
  4544. var bedCostTotal float64 = 0 //床位总费
  4545. var bedCostSelfTotal float64 = 0 //床位自费
  4546. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4547. var operationCostTotal float64 = 0 //手术费
  4548. var operationCostSelfTotal float64 = 0 //手术费
  4549. var operationCostPartSelfTotal float64 = 0 //手术费
  4550. var otherCostTotal float64 = 0 //其他费用
  4551. var otherCostSelfTotal float64 = 0 //其他费用
  4552. var otherCostPartSelfTotal float64 = 0 //其他费用
  4553. var materialCostTotal float64 = 0 //材料费
  4554. var materialCostSelfTotal float64 = 0 //材料费
  4555. var materialCostPartSelfTotal float64 = 0 //材料费
  4556. var westernMedicineCostTotal float64 = 0 //西药费
  4557. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4558. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4559. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4560. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4561. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4562. var checkCostTotal float64 = 0 //检查费
  4563. var checkCostSelfTotal float64 = 0 //检查费
  4564. var checkCostPartSelfTotal float64 = 0 //检查费
  4565. var laboratoryCostTotal float64 = 0 //化验费
  4566. var laboratoryCostSelfTotal float64 = 0 //化验费
  4567. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4568. var treatCostTotal float64 = 0 //治疗费用
  4569. var treatCostSelfTotal float64 = 0 //治疗费用
  4570. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4571. decimal.DivisionPrecision = 2
  4572. var bed_fulamt_ownpay_amt float64 = 0
  4573. var operation_fulamt_ownpay_amt float64 = 0
  4574. var other_fulamt_ownpay_amt float64 = 0
  4575. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4576. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4577. var check_fulamt_ownpay_amt float64 = 0
  4578. var material_fulamt_ownpay_amt float64 = 0
  4579. var laboratory_fulamt_ownpay_amt float64 = 0
  4580. var treat_fulamt_ownpay_amt float64 = 0
  4581. var bed_claa_sunmfee float64 = 0
  4582. var bed_clab_amt float64 = 0
  4583. var bed_other_amt float64 = 0
  4584. var operation_claa_sunmfee float64 = 0
  4585. var operation_clab_amt float64 = 0
  4586. var operation_other_amt float64 = 0
  4587. var other_claa_sunmfee float64 = 0
  4588. var other_clab_amt float64 = 0
  4589. var other_other_amt float64 = 0
  4590. var westernMedicine_claa_sunmfee float64 = 0
  4591. var westernMedicine_clab_amt float64 = 0
  4592. var westernMedicine_other_amt float64 = 0
  4593. var chineseTraditional_claa_sunmfee float64 = 0
  4594. var chineseTraditional_clab_amt float64 = 0
  4595. var chineseTraditional_other_amt float64 = 0
  4596. var check_claa_sunmfee float64 = 0
  4597. var check_clab_amt float64 = 0
  4598. var check_other_amt float64 = 0
  4599. var material_claa_sunmfee float64 = 0
  4600. var material_clab_amt float64 = 0
  4601. var material_other_amt float64 = 0
  4602. var laboratory_claa_sunmfee float64 = 0
  4603. var laboratory_clab_amt float64 = 0
  4604. var laboratory_other_amt float64 = 0
  4605. var treat_claa_sunmfee float64 = 0
  4606. var treat_clab_amt float64 = 0
  4607. var treat_other_amt float64 = 0
  4608. for _, item := range order.HisOrderInfo {
  4609. if item.MedChrgitmType == "01" { //床位费
  4610. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4611. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4612. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4613. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4614. if item.ChrgitmLv == "1" {
  4615. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4616. }
  4617. if item.ChrgitmLv == "2" {
  4618. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4619. }
  4620. if item.ChrgitmLv == "3" {
  4621. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4622. }
  4623. }
  4624. if item.MedChrgitmType == "03" { //检查费
  4625. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4626. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4627. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4628. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4629. if item.ChrgitmLv == "1" {
  4630. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4631. }
  4632. if item.ChrgitmLv == "2" {
  4633. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4634. }
  4635. if item.ChrgitmLv == "3" {
  4636. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4637. }
  4638. }
  4639. if item.MedChrgitmType == "04" { //化验费
  4640. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4641. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4642. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4643. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4644. if item.ChrgitmLv == "1" {
  4645. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4646. }
  4647. if item.ChrgitmLv == "2" {
  4648. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4649. }
  4650. if item.ChrgitmLv == "3" {
  4651. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4652. }
  4653. }
  4654. if item.MedChrgitmType == "05" { //治疗费
  4655. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4656. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4657. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4658. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4659. if item.ChrgitmLv == "1" {
  4660. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4661. }
  4662. if item.ChrgitmLv == "2" {
  4663. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4664. }
  4665. if item.ChrgitmLv == "3" {
  4666. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4667. }
  4668. }
  4669. if item.MedChrgitmType == "06" { //手术费
  4670. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4671. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4672. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4673. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4674. if item.ChrgitmLv == "1" {
  4675. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4676. }
  4677. if item.ChrgitmLv == "2" {
  4678. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4679. }
  4680. if item.ChrgitmLv == "3" {
  4681. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4682. }
  4683. }
  4684. if item.MedChrgitmType == "08" { //材料费
  4685. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4686. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4687. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4688. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4689. if item.ChrgitmLv == "1" {
  4690. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4691. }
  4692. if item.ChrgitmLv == "2" {
  4693. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4694. }
  4695. if item.ChrgitmLv == "3" {
  4696. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4697. }
  4698. }
  4699. if item.MedChrgitmType == "09" { //西药费
  4700. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4701. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4702. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4703. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4704. if item.ChrgitmLv == "1" {
  4705. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4706. }
  4707. if item.ChrgitmLv == "2" {
  4708. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4709. }
  4710. if item.ChrgitmLv == "3" {
  4711. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4712. }
  4713. }
  4714. if item.MedChrgitmType == "11" { //中成费
  4715. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4716. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4717. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4718. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4719. if item.ChrgitmLv == "1" {
  4720. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4721. }
  4722. if item.ChrgitmLv == "2" {
  4723. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4724. }
  4725. if item.ChrgitmLv == "3" {
  4726. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4727. }
  4728. }
  4729. if item.MedChrgitmType == "14" { //其他费
  4730. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4731. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4732. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4733. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4734. if item.ChrgitmLv == "1" {
  4735. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4736. }
  4737. if item.ChrgitmLv == "2" {
  4738. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4739. }
  4740. if item.ChrgitmLv == "3" {
  4741. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4742. }
  4743. }
  4744. }
  4745. var iteminfoStructs []service.IteminfoStruct
  4746. if bedCostTotal != 0 {
  4747. iteminfo.MedChrgitm = "01"
  4748. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4749. iteminfo.Amt = bedCostTotal
  4750. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4751. iteminfo.ClabAmt = bed_clab_amt
  4752. iteminfo.OthAmt = bed_other_amt
  4753. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4754. }
  4755. if checkCostTotal != 0 {
  4756. iteminfo.MedChrgitm = "03"
  4757. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4758. iteminfo.Amt = checkCostTotal
  4759. iteminfo.ClaaSumfee = check_claa_sunmfee
  4760. iteminfo.ClabAmt = check_clab_amt
  4761. iteminfo.OthAmt = check_other_amt
  4762. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4763. }
  4764. if laboratoryCostTotal != 0 {
  4765. iteminfo.MedChrgitm = "04"
  4766. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4767. iteminfo.Amt = laboratoryCostTotal
  4768. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4769. iteminfo.ClabAmt = laboratory_clab_amt
  4770. iteminfo.OthAmt = laboratory_other_amt
  4771. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4772. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4773. }
  4774. if treatCostTotal != 0 {
  4775. iteminfo.MedChrgitm = "05"
  4776. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4777. iteminfo.Amt = treatCostTotal
  4778. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4779. iteminfo.ClabAmt = treat_clab_amt
  4780. iteminfo.OthAmt = treat_other_amt
  4781. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4782. //(struct4101.IteminfoStruct, iteminfo)
  4783. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4784. }
  4785. if operationCostTotal != 0 {
  4786. iteminfo.MedChrgitm = "06"
  4787. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4788. iteminfo.Amt = operationCostTotal
  4789. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4790. iteminfo.ClabAmt = operation_clab_amt
  4791. iteminfo.OthAmt = operation_other_amt
  4792. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4793. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4794. }
  4795. if materialCostTotal != 0 {
  4796. iteminfo.MedChrgitm = "08"
  4797. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4798. iteminfo.Amt = materialCostTotal
  4799. iteminfo.ClaaSumfee = material_claa_sunmfee
  4800. iteminfo.ClabAmt = material_clab_amt
  4801. iteminfo.OthAmt = material_other_amt
  4802. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4803. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4804. }
  4805. if westernMedicineCostTotal != 0 {
  4806. iteminfo.MedChrgitm = "09"
  4807. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4808. iteminfo.Amt = westernMedicineCostTotal
  4809. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4810. iteminfo.ClabAmt = westernMedicine_clab_amt
  4811. iteminfo.OthAmt = westernMedicine_other_amt
  4812. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4813. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4814. }
  4815. if chineseTraditionalMedicineCostTotal != 0 {
  4816. iteminfo.MedChrgitm = "11"
  4817. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4818. iteminfo.Amt = westernMedicineCostTotal
  4819. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4820. iteminfo.ClabAmt = westernMedicine_clab_amt
  4821. iteminfo.OthAmt = westernMedicine_other_amt
  4822. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4823. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4824. }
  4825. if otherCostTotal != 0 {
  4826. iteminfo.MedChrgitm = "14"
  4827. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4828. iteminfo.Amt = otherCostTotal
  4829. iteminfo.ClaaSumfee = other_claa_sunmfee
  4830. iteminfo.ClabAmt = other_clab_amt
  4831. iteminfo.OthAmt = other_other_amt
  4832. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4833. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4834. }
  4835. struct4101.IteminfoStruct = iteminfoStructs
  4836. struct4101.Ntly = "中国"
  4837. struct4101.AdmCaty = "A03.06"
  4838. struct4101.DoctorName = doctor.UserName
  4839. struct4101.DoctorCode = doctor.DoctorNumber
  4840. var res ResultSeventeen
  4841. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4842. struct4101.BillCode = order.Number
  4843. struct4101.BillNo = order.SetlId
  4844. var resOther ResultSeventeenOther
  4845. var pp models.PublicParams
  4846. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4847. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4848. pp.FixmedinsName = miConfig.OrgName
  4849. pp.FixmedinsCode = miConfig.Code
  4850. pp.RequestUrl = miConfig.Url
  4851. pp.Cainfo = miConfig.Cainfo
  4852. pp.SecretKey = miConfig.SecretKey
  4853. pp.AccessKey = miConfig.AccessKey
  4854. pp.OpterName = curRoles.UserName
  4855. client := &http.Client{}
  4856. var req *http.Request
  4857. data := make(map[string]interface{})
  4858. data["struct4101"] = struct4101
  4859. data["pp"] = pp
  4860. bytesData, _ := json.Marshal(data)
  4861. if miConfig.MdtrtareaAdmvs == "320921" {
  4862. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4863. } else {
  4864. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4865. }
  4866. resp, _ := client.Do(req)
  4867. defer resp.Body.Close()
  4868. body, ioErr := ioutil.ReadAll(resp.Body)
  4869. if ioErr != nil {
  4870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4872. return
  4873. }
  4874. var respJSON map[string]interface{}
  4875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4878. return
  4879. }
  4880. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4881. userJSONBytes, _ := json.Marshal(respJSON)
  4882. fmt.Println("log")
  4883. fmt.Println(string(userJSONBytes))
  4884. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4885. utils.ErrorLog("解析失败:%v", err)
  4886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4887. return
  4888. }
  4889. res.InfRefmsgid = resOther.InfRefmsgid
  4890. res.Output = resOther.Output
  4891. res.ErrMsg = resOther.ErrMsg
  4892. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4893. res.Infcode = infocode
  4894. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4895. var pp models.PublicParams
  4896. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4897. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4898. pp.FixmedinsName = miConfig.OrgName
  4899. pp.FixmedinsCode = miConfig.Code
  4900. pp.RequestUrl = miConfig.Url
  4901. pp.Cainfo = miConfig.Cainfo
  4902. pp.SecretKey = miConfig.SecretKey
  4903. pp.AccessKey = miConfig.AccessKey
  4904. pp.OpterName = curRoles.UserName
  4905. result, _ := service.Jxyb4101(struct4101, pp)
  4906. var dat map[string]interface{}
  4907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4908. fmt.Println(dat)
  4909. } else {
  4910. fmt.Println(err)
  4911. }
  4912. userJSONBytes, _ := json.Marshal(dat)
  4913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4914. utils.ErrorLog("解析失败:%v", err)
  4915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4916. return
  4917. }
  4918. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4919. var pp models.PublicParams
  4920. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4921. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4922. pp.FixmedinsName = miConfig.OrgName
  4923. pp.FixmedinsCode = miConfig.Code
  4924. pp.RequestUrl = miConfig.Url
  4925. pp.Cainfo = miConfig.Cainfo
  4926. pp.SecretKey = miConfig.SecretKey
  4927. pp.AccessKey = miConfig.AccessKey
  4928. pp.OpterName = curRoles.UserName
  4929. result, _ := service.Hnyb4101(struct4101, pp)
  4930. var dat map[string]interface{}
  4931. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4932. fmt.Println(dat)
  4933. } else {
  4934. fmt.Println(err)
  4935. }
  4936. userJSONBytes, _ := json.Marshal(dat)
  4937. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4938. utils.ErrorLog("解析失败:%v", err)
  4939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4940. return
  4941. }
  4942. } else {
  4943. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4944. var dat map[string]interface{}
  4945. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4946. fmt.Println(dat)
  4947. } else {
  4948. fmt.Println(err)
  4949. }
  4950. userJSONBytes, _ := json.Marshal(dat)
  4951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4952. utils.ErrorLog("解析失败:%v", err)
  4953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4954. return
  4955. }
  4956. }
  4957. if res.Infcode != 0 {
  4958. c.ServeSuccessJSON(map[string]interface{}{
  4959. "failed_code": -10,
  4960. "msg": res.ErrMsg,
  4961. })
  4962. return
  4963. } else {
  4964. //order.FaPiaoNumber = zero
  4965. //order.FaPiaoCode = last_order.FaPiaoCode
  4966. //service.UpdateOrder(order)
  4967. hisFundSettleListResult := &models.HisFundSettleListResult{
  4968. Number: res.Output.SetlListId,
  4969. Status: 1,
  4970. Ctime: time.Now().Unix(),
  4971. Mtime: time.Now().Unix(),
  4972. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4973. IsUpload: 1,
  4974. OrderId: order_id,
  4975. }
  4976. service.CreateUploadRecord(hisFundSettleListResult)
  4977. c.ServeSuccessJSON(map[string]interface{}{
  4978. "msg": "上传成功",
  4979. "result": hisFundSettleListResult,
  4980. })
  4981. return
  4982. }
  4983. }
  4984. func (c *HisApiController) GetSettleListHospital() {
  4985. order_id, _ := c.GetInt64("order_id")
  4986. admin_user_id, _ := c.GetInt64("admin_user_id")
  4987. order, _ := service.GetHisOrderByIDTwo(order_id)
  4988. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4989. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4990. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4991. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4992. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4993. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4994. if order.ID == 0 {
  4995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4996. return
  4997. }
  4998. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4999. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5000. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5001. fmt.Println(count)
  5002. var zero string
  5003. number := count + 1
  5004. if number >= 1000 {
  5005. zero = "0000" + strconv.FormatInt(number, 10)
  5006. } else if number >= 10000 {
  5007. zero = "000" + strconv.FormatInt(number, 10)
  5008. } else if number >= 100000 {
  5009. zero = "00" + strconv.FormatInt(number, 10)
  5010. } else if number >= 1000000 {
  5011. zero = "0" + strconv.FormatInt(number, 10)
  5012. } else {
  5013. zero = strconv.FormatInt(number, 10)
  5014. }
  5015. fmt.Println(zero)
  5016. struct4101 := service.Struct4101{
  5017. PsnNo: order.PsnNo,
  5018. MdtrtId: order.MdtrtId,
  5019. SetlId: order.SetlId,
  5020. PsnName: order.PsnName,
  5021. Gend: order.Gend,
  5022. Brdy: his.Brdy,
  5023. Age: int64(order.Age),
  5024. Naty: order.Naty,
  5025. PatnCertType: "01",
  5026. Certno: order.Certno,
  5027. Prfs: "90",
  5028. ConerName: roles[0].UserName,
  5029. PatnRlts: "99",
  5030. ConerAddr: miConfig.OrgName,
  5031. ConerTel: admin.Mobile,
  5032. HiType: order.Insutype,
  5033. Insuplc: miConfig.InsuplcAdmdvs,
  5034. MaindiagFlag: "1",
  5035. BillCode: order.SetlId,
  5036. BillNo: order.SetlId,
  5037. BizSn: order.Number,
  5038. PsnSelfPay: order.PsnPartAmt,
  5039. PsnOwnPay: order.PsnPartAmt,
  5040. AcctPay: order.AcctPay,
  5041. PsnCashpay: order.PsnCashPay,
  5042. HiPaymtd: "1",
  5043. Hsorg: miConfig.InsuplcAdmdvs,
  5044. HsorgOpter: miConfig.InsuplcAdmdvs,
  5045. MedinsFillPsn: curRoles.UserName,
  5046. MedinsFillDept: depart.Name,
  5047. IptMedType: "2",
  5048. AdmTime: his.InHosptialTime,
  5049. AdmEndTime: his.OutHosptialTime,
  5050. }
  5051. struct4101.SetlBegnDate = order.SetlTime
  5052. struct4101.SetlEndDate = order.SetlTime
  5053. var rf []CustomFundPay
  5054. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5055. var tempFunPays []service.CustomStruct
  5056. for _, item := range rf {
  5057. var tempFunPay service.CustomStruct
  5058. tempFunPay.FundPayamt = item.FundPayamt
  5059. tempFunPay.FundPayType = item.FundPayType
  5060. tempFunPays = append(tempFunPays, tempFunPay)
  5061. }
  5062. struct4101.CustomStruct = tempFunPays
  5063. var tempDiaginfos []service.DiaginfoStructTwo
  5064. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5065. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5066. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5067. var config []*models.HisXtDiagnoseConfig
  5068. for _, item := range diagnosis_ids {
  5069. id, _ := strconv.ParseInt(item, 10, 64)
  5070. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5071. config = append(config, &diagnosisConfig)
  5072. }
  5073. for index, item := range config {
  5074. if index == 0 {
  5075. var tempDiaginfo service.DiaginfoStructTwo
  5076. tempDiaginfo.DiagCode = item.CountryCode
  5077. tempDiaginfo.DiagName = item.CountryContentName
  5078. tempDiaginfo.DiagType = "1"
  5079. tempDiaginfo.MaindiagFlag = "1"
  5080. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5081. } else {
  5082. var tempDiaginfo service.DiaginfoStructTwo
  5083. tempDiaginfo.DiagCode = item.CountryCode
  5084. tempDiaginfo.DiagName = item.CountryContentName
  5085. tempDiaginfo.DiagType = "2"
  5086. tempDiaginfo.MaindiagFlag = "0"
  5087. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5088. }
  5089. }
  5090. struct4101.Diseinfo = tempDiaginfos
  5091. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5092. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5093. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5094. tempOpspdiseinfo2.OprnOprtCode = ""
  5095. tempOpspdiseinfo2.OprnOprtName = ""
  5096. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5097. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5098. var iteminfo service.IteminfoStruct
  5099. var bedCostTotal float64 = 0 //床位总费
  5100. var bedCostSelfTotal float64 = 0 //床位自费
  5101. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5102. var operationCostTotal float64 = 0 //手术费
  5103. var operationCostSelfTotal float64 = 0 //手术费
  5104. var operationCostPartSelfTotal float64 = 0 //手术费
  5105. var otherCostTotal float64 = 0 //其他费用
  5106. var otherCostSelfTotal float64 = 0 //其他费用
  5107. var otherCostPartSelfTotal float64 = 0 //其他费用
  5108. var materialCostTotal float64 = 0 //材料费
  5109. var materialCostSelfTotal float64 = 0 //材料费
  5110. var materialCostPartSelfTotal float64 = 0 //材料费
  5111. var westernMedicineCostTotal float64 = 0 //西药费
  5112. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5113. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5114. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5115. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5116. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5117. var checkCostTotal float64 = 0 //检查费
  5118. var checkCostSelfTotal float64 = 0 //检查费
  5119. var checkCostPartSelfTotal float64 = 0 //检查费
  5120. var laboratoryCostTotal float64 = 0 //化验费
  5121. var laboratoryCostSelfTotal float64 = 0 //化验费
  5122. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5123. var treatCostTotal float64 = 0 //治疗费用
  5124. var treatCostSelfTotal float64 = 0 //治疗费用
  5125. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5126. decimal.DivisionPrecision = 2
  5127. var bed_fulamt_ownpay_amt float64 = 0
  5128. var operation_fulamt_ownpay_amt float64 = 0
  5129. var other_fulamt_ownpay_amt float64 = 0
  5130. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5131. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5132. var check_fulamt_ownpay_amt float64 = 0
  5133. var material_fulamt_ownpay_amt float64 = 0
  5134. var laboratory_fulamt_ownpay_amt float64 = 0
  5135. var treat_fulamt_ownpay_amt float64 = 0
  5136. var bed_claa_sunmfee float64 = 0
  5137. var bed_clab_amt float64 = 0
  5138. var bed_other_amt float64 = 0
  5139. var operation_claa_sunmfee float64 = 0
  5140. var operation_clab_amt float64 = 0
  5141. var operation_other_amt float64 = 0
  5142. var other_claa_sunmfee float64 = 0
  5143. var other_clab_amt float64 = 0
  5144. var other_other_amt float64 = 0
  5145. var westernMedicine_claa_sunmfee float64 = 0
  5146. var westernMedicine_clab_amt float64 = 0
  5147. var westernMedicine_other_amt float64 = 0
  5148. var chineseTraditional_claa_sunmfee float64 = 0
  5149. var chineseTraditional_clab_amt float64 = 0
  5150. var chineseTraditional_other_amt float64 = 0
  5151. var check_claa_sunmfee float64 = 0
  5152. var check_clab_amt float64 = 0
  5153. var check_other_amt float64 = 0
  5154. var material_claa_sunmfee float64 = 0
  5155. var material_clab_amt float64 = 0
  5156. var material_other_amt float64 = 0
  5157. var laboratory_claa_sunmfee float64 = 0
  5158. var laboratory_clab_amt float64 = 0
  5159. var laboratory_other_amt float64 = 0
  5160. var treat_claa_sunmfee float64 = 0
  5161. var treat_clab_amt float64 = 0
  5162. var treat_other_amt float64 = 0
  5163. for _, item := range order.HisOrderInfo {
  5164. if item.MedChrgitmType == "01" { //床位费
  5165. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5166. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5167. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5168. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5169. if item.ChrgitmLv == "1" {
  5170. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5171. }
  5172. if item.ChrgitmLv == "2" {
  5173. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5174. }
  5175. if item.ChrgitmLv == "3" {
  5176. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5177. }
  5178. }
  5179. if item.MedChrgitmType == "03" { //检查费
  5180. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5181. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5182. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5183. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5184. if item.ChrgitmLv == "1" {
  5185. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5186. }
  5187. if item.ChrgitmLv == "2" {
  5188. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5189. }
  5190. if item.ChrgitmLv == "3" {
  5191. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5192. }
  5193. }
  5194. if item.MedChrgitmType == "04" { //化验费
  5195. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5196. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5197. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5198. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5199. if item.ChrgitmLv == "1" {
  5200. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5201. }
  5202. if item.ChrgitmLv == "2" {
  5203. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5204. }
  5205. if item.ChrgitmLv == "3" {
  5206. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5207. }
  5208. }
  5209. if item.MedChrgitmType == "05" { //治疗费
  5210. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5211. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5212. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5213. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5214. if item.ChrgitmLv == "1" {
  5215. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5216. }
  5217. if item.ChrgitmLv == "2" {
  5218. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5219. }
  5220. if item.ChrgitmLv == "3" {
  5221. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5222. }
  5223. }
  5224. if item.MedChrgitmType == "06" { //手术费
  5225. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5226. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5227. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5228. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5229. if item.ChrgitmLv == "1" {
  5230. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5231. }
  5232. if item.ChrgitmLv == "2" {
  5233. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5234. }
  5235. if item.ChrgitmLv == "3" {
  5236. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5237. }
  5238. }
  5239. if item.MedChrgitmType == "08" { //材料费
  5240. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5241. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5242. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5243. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5244. if item.ChrgitmLv == "1" {
  5245. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5246. }
  5247. if item.ChrgitmLv == "2" {
  5248. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5249. }
  5250. if item.ChrgitmLv == "3" {
  5251. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5252. }
  5253. }
  5254. if item.MedChrgitmType == "09" { //西药费
  5255. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5256. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5257. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5258. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5259. if item.ChrgitmLv == "1" {
  5260. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5261. }
  5262. if item.ChrgitmLv == "2" {
  5263. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5264. }
  5265. if item.ChrgitmLv == "3" {
  5266. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5267. }
  5268. }
  5269. if item.MedChrgitmType == "11" { //中成费
  5270. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5271. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5272. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5273. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5274. if item.ChrgitmLv == "1" {
  5275. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5276. }
  5277. if item.ChrgitmLv == "2" {
  5278. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5279. }
  5280. if item.ChrgitmLv == "3" {
  5281. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5282. }
  5283. }
  5284. if item.MedChrgitmType == "14" { //其他费
  5285. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5286. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5287. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5288. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5289. if item.ChrgitmLv == "1" {
  5290. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5291. }
  5292. if item.ChrgitmLv == "2" {
  5293. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5294. }
  5295. if item.ChrgitmLv == "3" {
  5296. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5297. }
  5298. }
  5299. }
  5300. var iteminfoStructs []service.IteminfoStruct
  5301. if bedCostTotal != 0 {
  5302. iteminfo.MedChrgitm = "01"
  5303. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5304. iteminfo.Amt = bedCostTotal
  5305. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5306. iteminfo.ClabAmt = bed_clab_amt
  5307. iteminfo.OthAmt = bed_other_amt
  5308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5309. }
  5310. if checkCostTotal != 0 {
  5311. iteminfo.MedChrgitm = "03"
  5312. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5313. iteminfo.Amt = checkCostTotal
  5314. iteminfo.ClaaSumfee = check_claa_sunmfee
  5315. iteminfo.ClabAmt = check_clab_amt
  5316. iteminfo.OthAmt = check_other_amt
  5317. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5318. }
  5319. if laboratoryCostTotal != 0 {
  5320. iteminfo.MedChrgitm = "04"
  5321. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5322. iteminfo.Amt = laboratoryCostTotal
  5323. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5324. iteminfo.ClabAmt = laboratory_clab_amt
  5325. iteminfo.OthAmt = laboratory_other_amt
  5326. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5327. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5328. }
  5329. if treatCostTotal != 0 {
  5330. iteminfo.MedChrgitm = "05"
  5331. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5332. iteminfo.Amt = treatCostTotal
  5333. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5334. iteminfo.ClabAmt = treat_clab_amt
  5335. iteminfo.OthAmt = treat_other_amt
  5336. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5337. //(struct4101.IteminfoStruct, iteminfo)
  5338. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5339. }
  5340. if operationCostTotal != 0 {
  5341. iteminfo.MedChrgitm = "06"
  5342. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5343. iteminfo.Amt = operationCostTotal
  5344. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5345. iteminfo.ClabAmt = operation_clab_amt
  5346. iteminfo.OthAmt = operation_other_amt
  5347. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5348. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5349. }
  5350. if materialCostTotal != 0 {
  5351. iteminfo.MedChrgitm = "08"
  5352. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5353. iteminfo.Amt = materialCostTotal
  5354. iteminfo.ClaaSumfee = material_claa_sunmfee
  5355. iteminfo.ClabAmt = material_clab_amt
  5356. iteminfo.OthAmt = material_other_amt
  5357. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5358. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5359. }
  5360. if westernMedicineCostTotal != 0 {
  5361. iteminfo.MedChrgitm = "09"
  5362. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5363. iteminfo.Amt = westernMedicineCostTotal
  5364. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5365. iteminfo.ClabAmt = westernMedicine_clab_amt
  5366. iteminfo.OthAmt = westernMedicine_other_amt
  5367. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5368. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5369. }
  5370. if chineseTraditionalMedicineCostTotal != 0 {
  5371. iteminfo.MedChrgitm = "11"
  5372. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5373. iteminfo.Amt = westernMedicineCostTotal
  5374. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5375. iteminfo.ClabAmt = westernMedicine_clab_amt
  5376. iteminfo.OthAmt = westernMedicine_other_amt
  5377. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5378. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5379. }
  5380. if otherCostTotal != 0 {
  5381. iteminfo.MedChrgitm = "14"
  5382. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5383. iteminfo.Amt = otherCostTotal
  5384. iteminfo.ClaaSumfee = other_claa_sunmfee
  5385. iteminfo.ClabAmt = other_clab_amt
  5386. iteminfo.OthAmt = other_other_amt
  5387. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5388. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5389. }
  5390. struct4101.IteminfoStruct = iteminfoStructs
  5391. struct4101.Ntly = "中国"
  5392. struct4101.AdmCaty = "A03.06"
  5393. var resOther ResultSeventeenOther
  5394. var res ResultSeventeen
  5395. if miConfig.MdtrtareaAdmvs == "150499" {
  5396. var pp models.PublicParams
  5397. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5398. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5399. pp.FixmedinsName = miConfig.OrgName
  5400. pp.FixmedinsCode = miConfig.Code
  5401. pp.RequestUrl = miConfig.Url
  5402. pp.Cainfo = miConfig.Cainfo
  5403. pp.SecretKey = miConfig.SecretKey
  5404. pp.AccessKey = miConfig.AccessKey
  5405. pp.OpterName = curRoles.UserName
  5406. client := &http.Client{}
  5407. var req *http.Request
  5408. data := make(map[string]interface{})
  5409. data["struct4101"] = struct4101
  5410. data["pp"] = pp
  5411. bytesData, _ := json.Marshal(data)
  5412. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  5413. resp, _ := client.Do(req)
  5414. defer resp.Body.Close()
  5415. body, ioErr := ioutil.ReadAll(resp.Body)
  5416. if ioErr != nil {
  5417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5419. return
  5420. }
  5421. var respJSON map[string]interface{}
  5422. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5425. return
  5426. }
  5427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5428. userJSONBytes, _ := json.Marshal(respJSON)
  5429. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  5430. utils.ErrorLog("解析失败:%v", err)
  5431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5432. return
  5433. }
  5434. res.InfRefmsgid = resOther.InfRefmsgid
  5435. res.Output = resOther.Output
  5436. res.ErrMsg = resOther.ErrMsg
  5437. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  5438. res.Infcode = infocode
  5439. } else {
  5440. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  5441. var dat map[string]interface{}
  5442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5443. fmt.Println(dat)
  5444. } else {
  5445. fmt.Println(err)
  5446. }
  5447. userJSONBytes, _ := json.Marshal(dat)
  5448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5449. utils.ErrorLog("解析失败:%v", err)
  5450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5451. return
  5452. }
  5453. }
  5454. if res.Infcode != 0 {
  5455. c.ServeSuccessJSON(map[string]interface{}{
  5456. "failed_code": -10,
  5457. "msg": res.ErrMsg,
  5458. })
  5459. return
  5460. } else {
  5461. if miConfig.MdtrtareaAdmvs != "150499" {
  5462. order.FaPiaoNumber = zero
  5463. order.FaPiaoCode = last_order.FaPiaoCode
  5464. service.UpdateOrder(order)
  5465. }
  5466. hisFundSettleListResult := &models.HisFundSettleListResult{
  5467. Number: res.Output.SetlListId,
  5468. Status: 1,
  5469. Ctime: time.Now().Unix(),
  5470. Mtime: time.Now().Unix(),
  5471. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5472. IsUpload: 1,
  5473. OrderId: order_id,
  5474. }
  5475. service.CreateUploadRecord(hisFundSettleListResult)
  5476. c.ServeSuccessJSON(map[string]interface{}{
  5477. "msg": "上传成功",
  5478. "result": hisFundSettleListResult,
  5479. })
  5480. return
  5481. }
  5482. }
  5483. func (c *HisApiController) GetBatchSettleList() {
  5484. orders, _ := service.GetAllHisOrder(10106)
  5485. for _, item := range orders {
  5486. order_id := item.ID
  5487. order, _ := service.GetHisOrderByIDTwo(order_id)
  5488. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5489. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5490. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5491. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  5492. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5493. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5494. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5495. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5496. if order.ID == 0 {
  5497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5498. return
  5499. }
  5500. if his.BalanceAccountsType == 2 {
  5501. continue
  5502. }
  5503. struct4101 := service.Struct4101{
  5504. PsnNo: order.PsnNo,
  5505. MdtrtId: order.MdtrtId,
  5506. SetlId: order.SetlId,
  5507. PsnName: order.PsnName,
  5508. Gend: order.Gend,
  5509. Brdy: his.Brdy,
  5510. Age: his.Age,
  5511. Naty: order.Naty,
  5512. PatnCertType: "01",
  5513. Certno: order.Certno,
  5514. Prfs: "90",
  5515. ConerName: roles[0].UserName,
  5516. PatnRlts: "99",
  5517. ConerAddr: miConfig.OrgName,
  5518. ConerTel: admin.Mobile,
  5519. HiType: order.Insutype,
  5520. Insuplc: his.InsuplcAdmdvs,
  5521. MaindiagFlag: "1",
  5522. BillCode: order.SetlId,
  5523. BillNo: order.SetlId,
  5524. BizSn: order.Number,
  5525. PsnSelfPay: order.PsnPartAmt,
  5526. PsnOwnPay: order.PsnPartAmt,
  5527. AcctPay: order.AcctPay,
  5528. PsnCashpay: order.PsnCashPay,
  5529. HiPaymtd: "1",
  5530. Hsorg: his.InsuplcAdmdvs,
  5531. HsorgOpter: his.InsuplcAdmdvs,
  5532. MedinsFillPsn: curRoles.UserName,
  5533. MedinsFillDept: depart.Name,
  5534. IptMedType: "2",
  5535. }
  5536. struct4101.SetlBegnDate = order.SetlTime
  5537. struct4101.SetlEndDate = order.SetlTime
  5538. //if order.SettleType == 1 {
  5539. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  5540. // dateStr := t.Format("2006-01-02")
  5541. // struct4101.SetlBegnDate = dateStr
  5542. // struct4101.SetlEndDate = dateStr
  5543. //} else {
  5544. // t := time.Unix(int64(order.SettleStartTime), 0)
  5545. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  5546. // dateStartStr := t.Format("2006-01-02")
  5547. // dateEndStr := t2.Format("2006-01-02")
  5548. // struct4101.SetlBegnDate = dateStartStr
  5549. // struct4101.SetlEndDate = dateEndStr
  5550. //}
  5551. var rf []CustomFundPay
  5552. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5553. var tempFunPays []service.CustomStruct
  5554. var tempFunPay610100 service.CustomStruct
  5555. for _, item := range rf {
  5556. if item.FundPayType == "610100" {
  5557. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  5558. tempFunPay610100.FundPayType = item.FundPayType
  5559. } else {
  5560. var tempFunPay service.CustomStruct
  5561. tempFunPay.FundPayamt = item.FundPayamt
  5562. tempFunPay.FundPayType = item.FundPayType
  5563. tempFunPays = append(tempFunPays, tempFunPay)
  5564. }
  5565. }
  5566. tempFunPays = append(tempFunPays, tempFunPay610100)
  5567. struct4101.CustomStruct = tempFunPays
  5568. var tempDiaginfos []service.DiaginfoStructTwo
  5569. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5570. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5571. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5572. var config []*models.HisXtDiagnoseConfig
  5573. for _, item := range diagnosis_ids {
  5574. id, _ := strconv.ParseInt(item, 10, 64)
  5575. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5576. config = append(config, &diagnosisConfig)
  5577. }
  5578. for index, item := range config {
  5579. if index == 0 {
  5580. var tempDiaginfo service.DiaginfoStructTwo
  5581. tempDiaginfo.DiagCode = item.CountryCode
  5582. tempDiaginfo.DiagName = item.CountryContentName
  5583. tempDiaginfo.DiagType = "1"
  5584. tempDiaginfo.MaindiagFlag = "1"
  5585. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5586. } else {
  5587. var tempDiaginfo service.DiaginfoStructTwo
  5588. tempDiaginfo.DiagCode = item.CountryCode
  5589. tempDiaginfo.DiagName = item.CountryContentName
  5590. tempDiaginfo.DiagType = "2"
  5591. tempDiaginfo.MaindiagFlag = "0"
  5592. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5593. }
  5594. }
  5595. struct4101.Diseinfo = tempDiaginfos
  5596. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5597. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5598. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5599. tempOpspdiseinfo2.OprnOprtCode = ""
  5600. tempOpspdiseinfo2.OprnOprtName = ""
  5601. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5602. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5603. var iteminfo service.IteminfoStruct
  5604. var bedCostTotal float64 = 0 //床位总费
  5605. var bedCostSelfTotal float64 = 0 //床位自费
  5606. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5607. var examineCostTotal float64 = 0 //诊查总费
  5608. var examineCostSelfTotal float64 = 0 //诊查自费
  5609. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  5610. var nursingCostTotal float64 = 0 //护理总费
  5611. var nursingCostSelfTotal float64 = 0 //护理自费
  5612. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  5613. var chineseMedicineCostTotal float64 = 0 //中成药
  5614. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  5615. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  5616. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  5617. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  5618. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  5619. var registerCostTotal float64 = 0 //一般诊疗费
  5620. var registerCostSelfTotal float64 = 0 //一般诊疗费
  5621. var registerPartSelfTotal float64 = 0 //一般诊疗费
  5622. var operationCostTotal float64 = 0 //手术费
  5623. var operationCostSelfTotal float64 = 0 //手术费
  5624. var operationCostPartSelfTotal float64 = 0 //手术费
  5625. var otherCostTotal float64 = 0 //其他费用
  5626. var otherCostSelfTotal float64 = 0 //其他费用
  5627. var otherCostPartSelfTotal float64 = 0 //其他费用
  5628. var materialCostTotal float64 = 0 //材料费
  5629. var materialCostSelfTotal float64 = 0 //材料费
  5630. var materialCostPartSelfTotal float64 = 0 //材料费
  5631. var westernMedicineCostTotal float64 = 0 //西药费
  5632. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5633. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5634. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5635. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5636. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5637. var checkCostTotal float64 = 0 //检查费
  5638. var checkCostSelfTotal float64 = 0 //检查费
  5639. var checkCostPartSelfTotal float64 = 0 //检查费
  5640. var laboratoryCostTotal float64 = 0 //化验费
  5641. var laboratoryCostSelfTotal float64 = 0 //化验费
  5642. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5643. var treatCostTotal float64 = 0 //治疗费用
  5644. var treatCostSelfTotal float64 = 0 //治疗费用
  5645. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5646. decimal.DivisionPrecision = 2
  5647. var bed_fulamt_ownpay_amt float64 = 0
  5648. var examine_fulamt_ownpay_amt float64 = 0
  5649. var nursing_fulamt_ownpay_amt float64 = 0
  5650. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  5651. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  5652. var register_fulamt_ownpay_amt float64 = 0
  5653. var operation_fulamt_ownpay_amt float64 = 0
  5654. var other_fulamt_ownpay_amt float64 = 0
  5655. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5656. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5657. var check_fulamt_ownpay_amt float64 = 0
  5658. var material_fulamt_ownpay_amt float64 = 0
  5659. var laboratory_fulamt_ownpay_amt float64 = 0
  5660. var treat_fulamt_ownpay_amt float64 = 0
  5661. var bed_claa_sunmfee float64 = 0
  5662. var bed_clab_amt float64 = 0
  5663. var bed_other_amt float64 = 0
  5664. var examine_claa_sunmfee float64 = 0
  5665. var examine_clab_amt float64 = 0
  5666. var examine_other_amt float64 = 0
  5667. var nursing_claa_sunmfee float64 = 0
  5668. var nursing_clab_amt float64 = 0
  5669. var nursing_other_amt float64 = 0
  5670. var chinese_medicine_claa_sunmfee float64 = 0
  5671. var chinese_medicine_clab_amt float64 = 0
  5672. var chinese_medicine_other_amt float64 = 0
  5673. var commonly_treatment_claa_sunmfee float64 = 0
  5674. var commonly_treatment_clab_amt float64 = 0
  5675. var commonly_treatment_other_amt float64 = 0
  5676. var operation_claa_sunmfee float64 = 0
  5677. var operation_clab_amt float64 = 0
  5678. var operation_other_amt float64 = 0
  5679. var other_claa_sunmfee float64 = 0
  5680. var other_clab_amt float64 = 0
  5681. var other_other_amt float64 = 0
  5682. var westernMedicine_claa_sunmfee float64 = 0
  5683. var westernMedicine_clab_amt float64 = 0
  5684. var westernMedicine_other_amt float64 = 0
  5685. var chineseTraditional_claa_sunmfee float64 = 0
  5686. var chineseTraditional_clab_amt float64 = 0
  5687. var chineseTraditional_other_amt float64 = 0
  5688. var check_claa_sunmfee float64 = 0
  5689. var check_clab_amt float64 = 0
  5690. var check_other_amt float64 = 0
  5691. var material_claa_sunmfee float64 = 0
  5692. var material_clab_amt float64 = 0
  5693. var material_other_amt float64 = 0
  5694. var laboratory_claa_sunmfee float64 = 0
  5695. var laboratory_clab_amt float64 = 0
  5696. var laboratory_other_amt float64 = 0
  5697. var treat_claa_sunmfee float64 = 0
  5698. var treat_clab_amt float64 = 0
  5699. var treat_other_amt float64 = 0
  5700. var register_claa_sunmfee float64 = 0
  5701. var register_clab_amt float64 = 0
  5702. var register_other_amt float64 = 0
  5703. for _, item := range order.HisOrderInfo {
  5704. if item.MedChrgitmType == "01" { //床位费
  5705. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5706. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5707. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5708. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5709. if item.ChrgitmLv == "1" {
  5710. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5711. }
  5712. if item.ChrgitmLv == "2" {
  5713. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5714. }
  5715. if item.ChrgitmLv == "3" {
  5716. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5717. }
  5718. }
  5719. if item.MedChrgitmType == "02" { //诊查
  5720. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5721. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5722. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5723. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5724. if item.ChrgitmLv == "1" {
  5725. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5726. }
  5727. if item.ChrgitmLv == "2" {
  5728. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5729. }
  5730. if item.ChrgitmLv == "3" {
  5731. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5732. }
  5733. }
  5734. if item.MedChrgitmType == "03" { //检查费
  5735. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5736. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5737. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5738. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5739. if item.ChrgitmLv == "1" {
  5740. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5741. }
  5742. if item.ChrgitmLv == "2" {
  5743. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5744. }
  5745. if item.ChrgitmLv == "3" {
  5746. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5747. }
  5748. }
  5749. if item.MedChrgitmType == "04" { //化验费
  5750. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5751. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5752. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5753. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5754. if item.ChrgitmLv == "1" {
  5755. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5756. }
  5757. if item.ChrgitmLv == "2" {
  5758. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5759. }
  5760. if item.ChrgitmLv == "3" {
  5761. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5762. }
  5763. }
  5764. if item.MedChrgitmType == "05" { //治疗费
  5765. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5766. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5767. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5768. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5769. if item.ChrgitmLv == "1" {
  5770. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5771. }
  5772. if item.ChrgitmLv == "2" {
  5773. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5774. }
  5775. if item.ChrgitmLv == "3" {
  5776. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5777. }
  5778. }
  5779. if item.MedChrgitmType == "06" { //手术费
  5780. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5781. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5782. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5783. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5784. if item.ChrgitmLv == "1" {
  5785. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5786. }
  5787. if item.ChrgitmLv == "2" {
  5788. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5789. }
  5790. if item.ChrgitmLv == "3" {
  5791. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5792. }
  5793. }
  5794. if item.MedChrgitmType == "07" { //手术费
  5795. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5796. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5797. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5798. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5799. if item.ChrgitmLv == "1" {
  5800. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5801. }
  5802. if item.ChrgitmLv == "2" {
  5803. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5804. }
  5805. if item.ChrgitmLv == "3" {
  5806. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5807. }
  5808. }
  5809. if item.MedChrgitmType == "08" { //材料费
  5810. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5811. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5812. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5813. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5814. if item.ChrgitmLv == "1" {
  5815. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5816. }
  5817. if item.ChrgitmLv == "2" {
  5818. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5819. }
  5820. if item.ChrgitmLv == "3" {
  5821. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5822. }
  5823. }
  5824. if item.MedChrgitmType == "09" { //西药费
  5825. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5826. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5827. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5828. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5829. if item.ChrgitmLv == "1" {
  5830. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5831. }
  5832. if item.ChrgitmLv == "2" {
  5833. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5834. }
  5835. if item.ChrgitmLv == "3" {
  5836. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5837. }
  5838. }
  5839. if item.MedChrgitmType == "10" { //中药饮片
  5840. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5841. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5842. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5843. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5844. if item.ChrgitmLv == "1" {
  5845. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5846. }
  5847. if item.ChrgitmLv == "2" {
  5848. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5849. }
  5850. if item.ChrgitmLv == "3" {
  5851. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5852. }
  5853. }
  5854. if item.MedChrgitmType == "11" { //中成费
  5855. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5856. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5857. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5858. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5859. if item.ChrgitmLv == "1" {
  5860. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5861. }
  5862. if item.ChrgitmLv == "2" {
  5863. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5864. }
  5865. if item.ChrgitmLv == "3" {
  5866. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5867. }
  5868. }
  5869. if item.MedChrgitmType == "12" { //中成费
  5870. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5871. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5872. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5873. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5874. if item.ChrgitmLv == "1" {
  5875. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5876. }
  5877. if item.ChrgitmLv == "2" {
  5878. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5879. }
  5880. if item.ChrgitmLv == "3" {
  5881. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5882. }
  5883. }
  5884. if item.MedChrgitmType == "13" { //中成费
  5885. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5886. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5887. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5888. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5889. if item.ChrgitmLv == "1" {
  5890. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5891. }
  5892. if item.ChrgitmLv == "2" {
  5893. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5894. }
  5895. if item.ChrgitmLv == "3" {
  5896. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5897. }
  5898. }
  5899. if item.MedChrgitmType == "14" { //其他费
  5900. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5901. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5902. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5903. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5904. if item.ChrgitmLv == "1" {
  5905. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5906. }
  5907. if item.ChrgitmLv == "2" {
  5908. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5909. }
  5910. if item.ChrgitmLv == "3" {
  5911. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5912. }
  5913. }
  5914. }
  5915. var iteminfoStructs []service.IteminfoStruct
  5916. if bedCostTotal != 0 {
  5917. iteminfo.MedChrgitm = "01"
  5918. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5919. iteminfo.Amt = bedCostTotal
  5920. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5921. iteminfo.ClabAmt = bed_clab_amt
  5922. iteminfo.OthAmt = bed_other_amt
  5923. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5924. }
  5925. if examineCostTotal != 0 {
  5926. iteminfo.MedChrgitm = "02"
  5927. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5928. iteminfo.Amt = examineCostTotal
  5929. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5930. iteminfo.ClabAmt = examine_clab_amt
  5931. iteminfo.OthAmt = examine_other_amt
  5932. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5933. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5934. }
  5935. if checkCostTotal != 0 {
  5936. iteminfo.MedChrgitm = "03"
  5937. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5938. iteminfo.Amt = checkCostTotal
  5939. iteminfo.ClaaSumfee = check_claa_sunmfee
  5940. iteminfo.ClabAmt = check_clab_amt
  5941. iteminfo.OthAmt = check_other_amt
  5942. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5943. }
  5944. if laboratoryCostTotal != 0 {
  5945. iteminfo.MedChrgitm = "04"
  5946. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5947. iteminfo.Amt = laboratoryCostTotal
  5948. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5949. iteminfo.ClabAmt = laboratory_clab_amt
  5950. iteminfo.OthAmt = laboratory_other_amt
  5951. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5952. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5953. }
  5954. if treatCostTotal != 0 {
  5955. iteminfo.MedChrgitm = "05"
  5956. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5957. iteminfo.Amt = treatCostTotal
  5958. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5959. iteminfo.ClabAmt = treat_clab_amt
  5960. iteminfo.OthAmt = treat_other_amt
  5961. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5962. //(struct4101.IteminfoStruct, iteminfo)
  5963. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5964. }
  5965. if operationCostTotal != 0 {
  5966. iteminfo.MedChrgitm = "06"
  5967. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5968. iteminfo.Amt = operationCostTotal
  5969. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5970. iteminfo.ClabAmt = operation_clab_amt
  5971. iteminfo.OthAmt = operation_other_amt
  5972. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5973. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5974. }
  5975. if nursingCostTotal != 0 {
  5976. iteminfo.MedChrgitm = "07"
  5977. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5978. iteminfo.Amt = nursingCostTotal
  5979. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5980. iteminfo.ClabAmt = nursing_clab_amt
  5981. iteminfo.OthAmt = nursing_other_amt
  5982. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5983. }
  5984. if materialCostTotal != 0 {
  5985. iteminfo.MedChrgitm = "08"
  5986. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5987. iteminfo.Amt = materialCostTotal
  5988. iteminfo.ClaaSumfee = material_claa_sunmfee
  5989. iteminfo.ClabAmt = material_clab_amt
  5990. iteminfo.OthAmt = material_other_amt
  5991. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5992. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5993. }
  5994. if westernMedicineCostTotal != 0 {
  5995. iteminfo.MedChrgitm = "09"
  5996. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5997. iteminfo.Amt = westernMedicineCostTotal
  5998. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5999. iteminfo.ClabAmt = westernMedicine_clab_amt
  6000. iteminfo.OthAmt = westernMedicine_other_amt
  6001. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6002. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6003. }
  6004. if chineseMedicineCostTotal != 0 {
  6005. iteminfo.MedChrgitm = "10"
  6006. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  6007. iteminfo.Amt = chineseMedicineCostTotal
  6008. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  6009. iteminfo.ClabAmt = chinese_medicine_clab_amt
  6010. iteminfo.OthAmt = chinese_medicine_other_amt
  6011. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6012. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6013. }
  6014. if chineseTraditionalMedicineCostTotal != 0 {
  6015. iteminfo.MedChrgitm = "11"
  6016. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6017. iteminfo.Amt = westernMedicineCostTotal
  6018. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6019. iteminfo.ClabAmt = westernMedicine_clab_amt
  6020. iteminfo.OthAmt = westernMedicine_other_amt
  6021. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6022. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6023. }
  6024. if commonlyTreatmentCostTotal != 0 {
  6025. iteminfo.MedChrgitm = "12"
  6026. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  6027. iteminfo.Amt = commonlyTreatmentCostTotal
  6028. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  6029. iteminfo.ClabAmt = commonly_treatment_clab_amt
  6030. iteminfo.OthAmt = commonly_treatment_other_amt
  6031. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6032. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6033. }
  6034. if registerCostTotal != 0 {
  6035. iteminfo.MedChrgitm = "13"
  6036. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  6037. iteminfo.Amt = registerCostTotal
  6038. iteminfo.ClaaSumfee = register_claa_sunmfee
  6039. iteminfo.ClabAmt = register_clab_amt
  6040. iteminfo.OthAmt = register_other_amt
  6041. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6042. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6043. }
  6044. if otherCostTotal != 0 {
  6045. iteminfo.MedChrgitm = "14"
  6046. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6047. iteminfo.Amt = otherCostTotal
  6048. iteminfo.ClaaSumfee = other_claa_sunmfee
  6049. iteminfo.ClabAmt = other_clab_amt
  6050. iteminfo.OthAmt = other_other_amt
  6051. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6052. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6053. }
  6054. struct4101.IteminfoStruct = iteminfoStructs
  6055. time_arr := strings.Split(order.SetlTime, " ")
  6056. struct4101.AdmTime = time_arr[0]
  6057. struct4101.AdmEndTime = time_arr[0]
  6058. struct4101.DoctorName = doctor.UserName
  6059. struct4101.DoctorCode = doctor.DoctorNumber
  6060. struct4101.Ntly = "中国"
  6061. struct4101.AdmCaty = "A03.06"
  6062. var res ResultSeventeen
  6063. if miConfig.MdtrtareaAdmvs == "421300" {
  6064. data := make(map[string]interface{})
  6065. data["struct4101"] = struct4101
  6066. data["secret_key"] = miConfig.SecretKey
  6067. data["org_name"] = miConfig.OrgName
  6068. data["opera"] = curRoles.UserName
  6069. data["code"] = miConfig.Code
  6070. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6071. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6072. client := &http.Client{}
  6073. bytesData, _ := json.Marshal(data)
  6074. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  6075. resp, _ := client.Do(req)
  6076. defer resp.Body.Close()
  6077. body, ioErr := ioutil.ReadAll(resp.Body)
  6078. if ioErr != nil {
  6079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6081. return
  6082. }
  6083. var respJSON map[string]interface{}
  6084. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6087. return
  6088. }
  6089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6090. userJSONBytes, _ := json.Marshal(respJSON)
  6091. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6092. utils.ErrorLog("解析失败:%v", err)
  6093. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6094. adminUser := c.GetAdminUserInfo()
  6095. errlog := &models.HisOrderError{
  6096. UserOrgId: adminUser.CurrentOrgId,
  6097. Ctime: time.Now().Unix(),
  6098. Mtime: time.Now().Unix(),
  6099. ErrMsg: res.ErrMsg + "解析失败",
  6100. Status: 1,
  6101. PatientId: order_id,
  6102. Stage: 10088,
  6103. }
  6104. service.CreateErrMsgLog(errlog)
  6105. continue
  6106. }
  6107. } else {
  6108. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  6109. fmt.Println(result)
  6110. var dat map[string]interface{}
  6111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6112. fmt.Println(dat)
  6113. } else {
  6114. fmt.Println(err)
  6115. }
  6116. userJSONBytes, _ := json.Marshal(dat)
  6117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6118. utils.ErrorLog("解析失败:%v", err)
  6119. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6120. adminUser := c.GetAdminUserInfo()
  6121. errlog := &models.HisOrderError{
  6122. UserOrgId: adminUser.CurrentOrgId,
  6123. Ctime: time.Now().Unix(),
  6124. Mtime: time.Now().Unix(),
  6125. ErrMsg: res.ErrMsg + "解析失败",
  6126. Status: 1,
  6127. PatientId: order_id,
  6128. Stage: 10106,
  6129. }
  6130. service.CreateErrMsgLog(errlog)
  6131. continue
  6132. }
  6133. }
  6134. if res.Infcode != 0 {
  6135. adminUser := c.GetAdminUserInfo()
  6136. errlog := &models.HisOrderError{
  6137. UserOrgId: adminUser.CurrentOrgId,
  6138. Ctime: time.Now().Unix(),
  6139. Mtime: time.Now().Unix(),
  6140. ErrMsg: res.ErrMsg,
  6141. Status: 1,
  6142. PatientId: order_id,
  6143. Stage: 10106,
  6144. }
  6145. service.CreateErrMsgLog(errlog)
  6146. continue
  6147. } else {
  6148. hisFundSettleListResult := &models.HisFundSettleListResult{
  6149. Number: res.Output.SetlListId,
  6150. Status: 1,
  6151. Ctime: time.Now().Unix(),
  6152. Mtime: time.Now().Unix(),
  6153. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6154. IsUpload: 1,
  6155. OrderId: order_id,
  6156. }
  6157. service.CreateUploadRecord(hisFundSettleListResult)
  6158. continue
  6159. }
  6160. }
  6161. }
  6162. func (c *HisApiController) GetOrgInfo() {
  6163. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  6164. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  6165. }
  6166. func (c *HisApiController) GetHisPatientInfo() {
  6167. medical_insurance_card := c.GetString("medical_insurance_card")
  6168. id_card_type, _ := c.GetInt64("id_card_type")
  6169. id_card := c.GetString("id_card")
  6170. adminInfo := c.GetAdminUserInfo()
  6171. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6172. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6173. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  6174. IdCardNo := ""
  6175. if id_card_type == 1 {
  6176. IdCardNo = medical_insurance_card
  6177. } else if id_card_type == 2 {
  6178. IdCardNo = id_card
  6179. }
  6180. if config.IsOpen == 1 {
  6181. 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
  6182. resp, requestErr := http.Get(api)
  6183. if requestErr != nil {
  6184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6185. return
  6186. }
  6187. defer resp.Body.Close()
  6188. body, ioErr := ioutil.ReadAll(resp.Body)
  6189. if ioErr != nil {
  6190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6192. return
  6193. }
  6194. var respJSON map[string]interface{}
  6195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6198. return
  6199. }
  6200. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6201. userJSONBytes, _ := json.Marshal(userJSON)
  6202. var res ResultTwo
  6203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6204. utils.ErrorLog("解析失败:%v", err)
  6205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6206. return
  6207. }
  6208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6209. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6210. infoStr := string(Iinfos)
  6211. idetinfoStr := string(Idetinfos)
  6212. if res.Infcode == 0 {
  6213. his := models.VMHisPatient{
  6214. Status: 1,
  6215. Ctime: time.Now().Unix(),
  6216. Mtime: time.Now().Unix(),
  6217. PsnNo: res.Output.Baseinfo.PsnNo,
  6218. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6219. Certno: res.Output.Baseinfo.Certno,
  6220. PsnName: res.Output.Baseinfo.PsnName,
  6221. Gend: res.Output.Baseinfo.Gend,
  6222. Naty: res.Output.Baseinfo.Naty,
  6223. Brdy: res.Output.Baseinfo.Brdy,
  6224. Age: res.Output.Baseinfo.Age,
  6225. Iinfo: infoStr,
  6226. Idetinfo: idetinfoStr,
  6227. UserOrgId: adminInfo.CurrentOrgId,
  6228. IsReturn: 1,
  6229. IdCardType: id_card_type,
  6230. }
  6231. c.ServeSuccessJSON(map[string]interface{}{
  6232. "info": his,
  6233. })
  6234. } else {
  6235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6236. return
  6237. }
  6238. }
  6239. }
  6240. //func GetBasBaseInfo() (jsonStr string, err error) {
  6241. //
  6242. // handle := syscall.NewLazyDLL("SSCard.dll")
  6243. // add := handle.NewProc("ReadCardBas")
  6244. // str := make([]byte, 1024)
  6245. // str1 := make([]byte, 1024)
  6246. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6247. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  6248. //
  6249. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  6250. //
  6251. // fmt.Println("> Add(4,5)的结果为:", ret)
  6252. // handle.Release()
  6253. //
  6254. // return "", nil
  6255. //
  6256. //}
  6257. //func GetQRBaseInfo() (jsonStr string, err error) {
  6258. // handle := syscall.LoadDLL("SSCard.dll")
  6259. // ReadCardBas := handle.FindProc("GetQRBase")
  6260. //
  6261. // str := make([]byte, 256)
  6262. // str1 := make([]byte, 256)
  6263. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6264. //
  6265. // fmt.Println(string(str))
  6266. // fmt.Println(r)
  6267. // return string(str), nil
  6268. //}
  6269. //func CardInit() int {
  6270. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  6271. // add := DllTestDef.MustFindProc("Init")
  6272. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6273. // if err != nil {
  6274. // fmt.Println("SSCard的运算结果为:", ret)
  6275. // }
  6276. // result := int(ret)
  6277. // return result
  6278. //}
  6279. //func CardInit() int {
  6280. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6281. // if err != nil {
  6282. // fmt.Println("SSCard的运算结果为:", ret)
  6283. // }
  6284. // fmt.Println(err)
  6285. // result := int(ret)
  6286. // return result
  6287. //}
  6288. func IntPtr(n int) uintptr {
  6289. return uintptr(n)
  6290. }
  6291. func StrPtr(s string) uintptr {
  6292. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  6293. }
  6294. type Result2001 struct {
  6295. Cainfo interface{} `json:"cainfo"`
  6296. ErrMsg string `json:"err_msg"`
  6297. InfRefmsgid string `json:"inf_refmsgid"`
  6298. Infcode int64 `json:"infcode"`
  6299. Output struct {
  6300. Trtinfo struct {
  6301. PsnNo string `json:"psn_no"`
  6302. TrtChkType string `json:"trt_chk_type"`
  6303. FundPayType string `json:"fund_pay_type"`
  6304. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6305. Begndate string `json:"begndate"`
  6306. Enddate string `json:"enddate"`
  6307. TrtChkRslt string `json:"trt_chk_rslt"`
  6308. } `json:"trtinfo"`
  6309. } `json:"output"`
  6310. RefmsgTime string `json:"refmsg_time"`
  6311. RespondTime string `json:"respond_time"`
  6312. Signtype interface{} `json:"signtype"`
  6313. WarnMsg interface{} `json:"warn_msg"`
  6314. }
  6315. type Result2001Org10265 struct {
  6316. Cainfo interface{} `json:"cainfo"`
  6317. ErrMsg string `json:"err_msg"`
  6318. InfRefmsgid string `json:"inf_refmsgid"`
  6319. Infcode string `json:"infcode"`
  6320. Output struct {
  6321. Trtinfo struct {
  6322. PsnNo string `json:"psn_no"`
  6323. TrtChkType string `json:"trt_chk_type"`
  6324. FundPayType string `json:"fund_pay_type"`
  6325. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6326. Begndate string `json:"begndate"`
  6327. Enddate string `json:"enddate"`
  6328. TrtChkRslt string `json:"trt_chk_rslt"`
  6329. } `json:"trtinfo"`
  6330. } `json:"output"`
  6331. RefmsgTime string `json:"refmsg_time"`
  6332. RespondTime string `json:"respond_time"`
  6333. Signtype interface{} `json:"signtype"`
  6334. WarnMsg interface{} `json:"warn_msg"`
  6335. }
  6336. type ResultTwo struct {
  6337. ErrMsg string `json:"err_msg"`
  6338. InfRefmsgid string `json:"inf_refmsgid"`
  6339. Infcode int64 `json:"infcode"`
  6340. Output struct {
  6341. Baseinfo struct {
  6342. Age float64 `json:"age"`
  6343. Brdy string `json:"brdy"`
  6344. Certno string `json:"certno"`
  6345. Gend string `json:"gend"`
  6346. Naty string `json:"naty"`
  6347. PsnCertType string `json:"psn_cert_type"`
  6348. PsnName string `json:"psn_name"`
  6349. PsnNo string `json:"psn_no"`
  6350. } `json:"baseinfo"`
  6351. Idetinfo []interface{} `json:"idetinfo"`
  6352. Iinfo []struct {
  6353. Balc float64 `json:"balc"`
  6354. CvlservFlag string `json:"cvlserv_flag"`
  6355. EmpName string `json:"emp_name"`
  6356. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6357. Insutype string `json:"insutype"`
  6358. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6359. PausInsuDate string `json:"paus_insu_date"`
  6360. PsnInsuDate string `json:"psn_insu_date"`
  6361. PsnInsuStas string `json:"psn_insu_stas"`
  6362. PsnType string `json:"psn_type"`
  6363. } `json:"insuinfo"`
  6364. } `json:"output"`
  6365. RefmsgTime string `json:"refmsg_time"`
  6366. RespondTime string `json:"respond_time"`
  6367. Signtype interface{} `json:"signtype"`
  6368. WarnInfo interface{} `json:"warn_info"`
  6369. }
  6370. type ResultTwo10265 struct {
  6371. ErrMsg string `json:"err_msg"`
  6372. InfRefmsgid string `json:"inf_refmsgid"`
  6373. Infcode string `json:"infcode"`
  6374. Output struct {
  6375. Baseinfo struct {
  6376. Age float64 `json:"age"`
  6377. Brdy string `json:"brdy"`
  6378. Certno string `json:"certno"`
  6379. Gend string `json:"gend"`
  6380. Naty string `json:"naty"`
  6381. PsnCertType string `json:"psn_cert_type"`
  6382. PsnName string `json:"psn_name"`
  6383. PsnNo string `json:"psn_no"`
  6384. } `json:"baseinfo"`
  6385. Idetinfo []interface{} `json:"idetinfo"`
  6386. Iinfo []struct {
  6387. Balc float64 `json:"balc"`
  6388. CvlservFlag string `json:"cvlserv_flag"`
  6389. EmpName string `json:"emp_name"`
  6390. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6391. Insutype string `json:"insutype"`
  6392. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6393. PausInsuDate string `json:"paus_insu_date"`
  6394. PsnInsuDate string `json:"psn_insu_date"`
  6395. PsnInsuStas string `json:"psn_insu_stas"`
  6396. PsnType string `json:"psn_type"`
  6397. } `json:"insuinfo"`
  6398. } `json:"output"`
  6399. RefmsgTime string `json:"refmsg_time"`
  6400. RespondTime string `json:"respond_time"`
  6401. Signtype interface{} `json:"signtype"`
  6402. WarnInfo interface{} `json:"warn_info"`
  6403. }
  6404. type ResultThree struct {
  6405. Cainfo interface{} `json:"cainfo"`
  6406. ErrMsg string `json:"err_msg"`
  6407. InfRefmsgid string `json:"inf_refmsgid"`
  6408. Infcode int64 `json:"infcode"`
  6409. Output struct {
  6410. Data struct {
  6411. IptOtpNo string `json:"ipt_otp_no"`
  6412. MdtrtID string `json:"mdtrt_id"`
  6413. PsnNo string `json:"psn_no"`
  6414. } `json:"data"`
  6415. } `json:"output"`
  6416. RefmsgTime string `json:"refmsg_time"`
  6417. RespondTime string `json:"respond_time"`
  6418. Signtype interface{} `json:"signtype"`
  6419. WarnMsg interface{} `json:"warn_msg"`
  6420. }
  6421. type ResultThree10265 struct {
  6422. Cainfo interface{} `json:"cainfo"`
  6423. ErrMsg string `json:"err_msg"`
  6424. InfRefmsgid string `json:"inf_refmsgid"`
  6425. Infcode string `json:"infcode"`
  6426. Output struct {
  6427. Data struct {
  6428. IptOtpNo string `json:"ipt_otp_no"`
  6429. MdtrtID string `json:"mdtrt_id"`
  6430. PsnNo string `json:"psn_no"`
  6431. } `json:"data"`
  6432. } `json:"output"`
  6433. RefmsgTime string `json:"refmsg_time"`
  6434. RespondTime string `json:"respond_time"`
  6435. Signtype interface{} `json:"signtype"`
  6436. WarnMsg interface{} `json:"warn_msg"`
  6437. }
  6438. type ResultFour struct {
  6439. Cainfo string `json:"cainfo"`
  6440. ErrMsg string `json:"err_msg"`
  6441. InfRefmsgid string `json:"inf_refmsgid"`
  6442. Infcode int64 `json:"infcode"`
  6443. Output struct {
  6444. Result []struct {
  6445. BasMednFlag string `json:"bas_medn_flag"`
  6446. ChldMedcFlag string `json:"chld_medc_flag"`
  6447. ChrgitmLv string `json:"chrgitm_lv"`
  6448. Cnt float64 `json:"cnt"`
  6449. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6450. DrtReimFlag string `json:"drt_reim_flag"`
  6451. FeedetlSn string `json:"feedetl_sn"`
  6452. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6453. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6454. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6455. ListSpItemFlag string `json:"list_sp_item_flag"`
  6456. LmtUsedFlag string `json:"lmt_used_flag"`
  6457. MedChrgitmType string `json:"med_chrgitm_type"`
  6458. Memo string `json:"memo"`
  6459. OverlmtAmt float64 `json:"overlmt_amt"`
  6460. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6461. Pric float64 `json:"pric"`
  6462. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6463. SelfpayProp float64 `json:"selfpay_prop"`
  6464. } `json:"result"`
  6465. } `json:"output"`
  6466. RefmsgTime string `json:"refmsg_time"`
  6467. RespondTime string `json:"respond_time"`
  6468. Signtype string `json:"signtype"`
  6469. WarnMsg string `json:"warn_msg"`
  6470. }
  6471. type ResultFour10265 struct {
  6472. Cainfo string `json:"cainfo"`
  6473. ErrMsg string `json:"err_msg"`
  6474. InfRefmsgid string `json:"inf_refmsgid"`
  6475. Infcode string `json:"infcode"`
  6476. Output struct {
  6477. Result []struct {
  6478. BasMednFlag string `json:"bas_medn_flag"`
  6479. ChldMedcFlag string `json:"chld_medc_flag"`
  6480. ChrgitmLv string `json:"chrgitm_lv"`
  6481. Cnt float64 `json:"cnt"`
  6482. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6483. DrtReimFlag string `json:"drt_reim_flag"`
  6484. FeedetlSn string `json:"feedetl_sn"`
  6485. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6486. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6487. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6488. ListSpItemFlag string `json:"list_sp_item_flag"`
  6489. LmtUsedFlag string `json:"lmt_used_flag"`
  6490. MedChrgitmType string `json:"med_chrgitm_type"`
  6491. Memo string `json:"memo"`
  6492. OverlmtAmt float64 `json:"overlmt_amt"`
  6493. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6494. Pric float64 `json:"pric"`
  6495. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6496. SelfpayProp float64 `json:"selfpay_prop"`
  6497. } `json:"result"`
  6498. } `json:"output"`
  6499. RefmsgTime string `json:"refmsg_time"`
  6500. RespondTime string `json:"respond_time"`
  6501. Signtype string `json:"signtype"`
  6502. WarnMsg string `json:"warn_msg"`
  6503. }
  6504. type ResultMemo struct {
  6505. InsuAdmdvs string `json:"insuAdmdvs"`
  6506. }
  6507. // [{"begntime":"2022-01-01 00:00:00","endtime":"2022-12-31 00:00:00","memo":"{\"matIdetCode\":\"20\",\"insuAdmdvs\":\"350481\"}","psn_idet_type":"23","psn_type_lv":null}]
  6508. type ResultIDInfo struct {
  6509. Begntime string `json:"begntime"`
  6510. Endtime string `json:"endtime"`
  6511. Memo string `json:"memo"`
  6512. }
  6513. type ResultFive struct {
  6514. Balc float64 `json:"balc"`
  6515. CvlservFlag string `json:"cvlserv_flag"`
  6516. EmpName string `json:"emp_name"`
  6517. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6518. Insutype string `json:"insutype"`
  6519. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6520. PausInsuDate string `json:"paus_insu_date"`
  6521. PsnInsuDate string `json:"psn_insu_date"`
  6522. PsnInsuStas string `json:"psn_insu_stas"`
  6523. PsnType string `json:"psn_type"`
  6524. }
  6525. type ResultSix struct {
  6526. Cainfo interface{} `json:"cainfo"`
  6527. ErrMsg string `json:"err_msg"`
  6528. InfRefmsgid string `json:"inf_refmsgid"`
  6529. Infcode int64 `json:"infcode"`
  6530. Output struct {
  6531. } `json:"output"`
  6532. RefmsgTime string `json:"refmsg_time"`
  6533. RespondTime string `json:"respond_time"`
  6534. Signtype interface{} `json:"signtype"`
  6535. WarnMsg interface{} `json:"warn_msg"`
  6536. }
  6537. type ResultSix10265 struct {
  6538. Cainfo interface{} `json:"cainfo"`
  6539. ErrMsg string `json:"err_msg"`
  6540. InfRefmsgid string `json:"inf_refmsgid"`
  6541. Infcode string `json:"infcode"`
  6542. Output struct {
  6543. } `json:"output"`
  6544. RefmsgTime string `json:"refmsg_time"`
  6545. RespondTime string `json:"respond_time"`
  6546. Signtype interface{} `json:"signtype"`
  6547. WarnMsg interface{} `json:"warn_msg"`
  6548. }
  6549. type ResultSeven struct {
  6550. Cainfo string `json:"cainfo"`
  6551. ErrMsg string `json:"err_msg"`
  6552. InfRefmsgid string `json:"inf_refmsgid"`
  6553. Infcode int64 `json:"infcode"`
  6554. Output struct {
  6555. Setldetail []interface{} `json:"setldetail"`
  6556. Setlinfo struct {
  6557. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6558. AcctPay float64 `json:"acct_pay"`
  6559. ActPayDedc float64 `json:"act_pay_dedc"`
  6560. Age float64 `json:"age"`
  6561. Balc float64 `json:"balc"`
  6562. Brdy string `json:"brdy"`
  6563. Certno string `json:"certno"`
  6564. ClrOptins string `json:"clr_optins"`
  6565. ClrType string `json:"clr_type"`
  6566. ClrWay string `json:"clr_way"`
  6567. CvlservFlag string `json:"cvlserv_flag"`
  6568. CvlservPay float64 `json:"cvlserv_pay"`
  6569. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6570. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6571. Gend string `json:"gend"`
  6572. HifesPay float64 `json:"hifes_pay"`
  6573. HifmiPay float64 `json:"hifmi_pay"`
  6574. HifpPay float64 `json:"hifp_pay"`
  6575. HospPartAmt float64 `json:"hosp_part_amt"`
  6576. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6577. Insutype string `json:"insutype"`
  6578. MafPay float64 `json:"maf_pay"`
  6579. MdtrtCertType string `json:"mdtrt_cert_type"`
  6580. HifobPay float64 `json:"hifob_pay"`
  6581. MdtrtID string `json:"mdtrt_id"`
  6582. MedType string `json:"med_type"`
  6583. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6584. MedinsSetlID string `json:"medins_setl_id"`
  6585. Naty string `json:"naty"`
  6586. OthPay float64 `json:"oth_pay"`
  6587. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6588. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6589. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6590. PsnCashPay float64 `json:"psn_cash_pay"`
  6591. PsnCertType string `json:"psn_cert_type"`
  6592. PsnName string `json:"psn_name"`
  6593. PsnNo string `json:"psn_no"`
  6594. PsnPartAmt float64 `json:"psn_part_amt"`
  6595. PsnType string `json:"psn_type"`
  6596. SetlID string `json:"setl_id"`
  6597. SetlTime string `json:"setl_time"`
  6598. } `json:"setlinfo"`
  6599. } `json:"output"`
  6600. RefmsgTime string `json:"refmsg_time"`
  6601. RespondTime string `json:"respond_time"`
  6602. Signtype interface{} `json:"signtype"`
  6603. WarnMsg interface{} `json:"warn_msg"`
  6604. }
  6605. type ResultSeven10265 struct {
  6606. Cainfo string `json:"cainfo"`
  6607. ErrMsg string `json:"err_msg"`
  6608. InfRefmsgid string `json:"inf_refmsgid"`
  6609. Infcode string `json:"infcode"`
  6610. Output struct {
  6611. Setldetail []interface{} `json:"setldetail"`
  6612. Setlinfo struct {
  6613. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6614. AcctPay float64 `json:"acct_pay"`
  6615. ActPayDedc float64 `json:"act_pay_dedc"`
  6616. Age float64 `json:"age"`
  6617. Balc float64 `json:"balc"`
  6618. Brdy string `json:"brdy"`
  6619. Certno string `json:"certno"`
  6620. ClrOptins string `json:"clr_optins"`
  6621. ClrType string `json:"clr_type"`
  6622. ClrWay string `json:"clr_way"`
  6623. CvlservFlag string `json:"cvlserv_flag"`
  6624. CvlservPay float64 `json:"cvlserv_pay"`
  6625. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6626. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6627. Gend string `json:"gend"`
  6628. HifesPay float64 `json:"hifes_pay"`
  6629. HifmiPay float64 `json:"hifmi_pay"`
  6630. HifpPay float64 `json:"hifp_pay"`
  6631. HospPartAmt float64 `json:"hosp_part_amt"`
  6632. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6633. Insutype string `json:"insutype"`
  6634. MafPay float64 `json:"maf_pay"`
  6635. MdtrtCertType string `json:"mdtrt_cert_type"`
  6636. HifobPay float64 `json:"hifob_pay"`
  6637. MdtrtID string `json:"mdtrt_id"`
  6638. MedType string `json:"med_type"`
  6639. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6640. MedinsSetlID string `json:"medins_setl_id"`
  6641. Naty string `json:"naty"`
  6642. OthPay float64 `json:"oth_pay"`
  6643. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6644. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6645. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6646. PsnCashPay float64 `json:"psn_cash_pay"`
  6647. PsnCertType string `json:"psn_cert_type"`
  6648. PsnName string `json:"psn_name"`
  6649. PsnNo string `json:"psn_no"`
  6650. PsnPartAmt float64 `json:"psn_part_amt"`
  6651. PsnType string `json:"psn_type"`
  6652. SetlID string `json:"setl_id"`
  6653. SetlTime string `json:"setl_time"`
  6654. } `json:"setlinfo"`
  6655. } `json:"output"`
  6656. RefmsgTime string `json:"refmsg_time"`
  6657. RespondTime string `json:"respond_time"`
  6658. Signtype interface{} `json:"signtype"`
  6659. WarnMsg interface{} `json:"warn_msg"`
  6660. }
  6661. type ResultEight struct {
  6662. Cainfo string `json:"cainfo"`
  6663. ErrMsg string `json:"err_msg"`
  6664. InfRefmsgid string `json:"inf_refmsgid"`
  6665. Infcode int64 `json:"infcode"`
  6666. Output struct {
  6667. Stmtinfo struct {
  6668. SetlOptins string `json:"setl_optins"`
  6669. StmtRslt string `json:"stmt_rslt"`
  6670. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6671. } `json:"stmtinfo"`
  6672. } `json:"output"`
  6673. RefmsgTime string `json:"refmsg_time"`
  6674. RespondTime string `json:"respond_time"`
  6675. Signtype interface{} `json:"signtype"`
  6676. WarnMsg interface{} `json:"warn_msg"`
  6677. }
  6678. type ResultEightFor10188 struct {
  6679. Cainfo string `json:"cainfo"`
  6680. ErrMsg string `json:"err_msg"`
  6681. InfRefmsgid string `json:"inf_refmsgid"`
  6682. Infcode string `json:"infcode"`
  6683. Output struct {
  6684. Stmtinfo struct {
  6685. SetlOptins string `json:"setl_optins"`
  6686. StmtRslt string `json:"stmt_rslt"`
  6687. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  6688. } `json:"stmtinfo"`
  6689. } `json:"output"`
  6690. RefmsgTime string `json:"refmsg_time"`
  6691. RespondTime string `json:"respond_time"`
  6692. Signtype interface{} `json:"signtype"`
  6693. WarnMsg interface{} `json:"warn_msg"`
  6694. }
  6695. type ResultNine struct {
  6696. Cainfo string `json:"cainfo"`
  6697. ErrMsg string `json:"err_msg"`
  6698. InfRefmsgid string `json:"inf_refmsgid"`
  6699. Infcode int64 `json:"infcode"`
  6700. Output struct {
  6701. FileQuryNo string `json:"file_qury_no"`
  6702. } `json:"output"`
  6703. RefmsgTime string `json:"refmsg_time"`
  6704. RespondTime string `json:"respond_time"`
  6705. Signtype interface{} `json:"signtype"`
  6706. WarnMsg interface{} `json:"warn_msg"`
  6707. }
  6708. type ResultTen struct {
  6709. Cainfo string `json:"cainfo"`
  6710. ErrMsg string `json:"err_msg"`
  6711. InfRefmsgid string `json:"inf_refmsgid"`
  6712. Infcode int64 `json:"infcode"`
  6713. Output struct {
  6714. DldEndtime string `json:"dld_endtime"`
  6715. FileQuryNo string `json:"file_qury_no"`
  6716. Filename string `json:"filename"`
  6717. } `json:"output"`
  6718. RefmsgTime string `json:"refmsg_time"`
  6719. RespondTime string `json:"respond_time"`
  6720. Signtype interface{} `json:"signtype"`
  6721. WarnMsg interface{} `json:"warn_msg"`
  6722. }
  6723. //type Autogenerated struct {
  6724. // Output struct {
  6725. // Setlinfo struct {
  6726. // SetlTime string `json:"setl_time"`
  6727. // CvlservPay float64 `json:"cvlserv_pay"`
  6728. // Year string `json:"year"`
  6729. // MedType string `json:"med_type"`
  6730. // PsnPay float64 `json:"psn_pay"`
  6731. // OpterID string `json:"opter_id"`
  6732. // Begndate string `json:"begndate"`
  6733. // FlxempeFlag string `json:"flxempe_flag"`
  6734. // HifmiPay float64 `json:"hifmi_pay"`
  6735. // PsnNo string `json:"psn_no"`
  6736. // ActPayDedc float64 `json:"act_pay_dedc"`
  6737. // MedinsSetlID interface{} `json:"medins_setl_id"`
  6738. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6739. // ClrWay string `json:"clr_way"`
  6740. // OthPay float64 `json:"oth_pay"`
  6741. // Gend string `json:"gend"`
  6742. // MdtrtID string `json:"mdtrt_id"`
  6743. // AcctPay float64 `json:"acct_pay"`
  6744. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  6745. // Insutype string `json:"insutype"`
  6746. // Invono interface{} `json:"invono"`
  6747. // Enddate string `json:"enddate"`
  6748. // CashPayamt float64 `json:"cash_payamt"`
  6749. // PsnType string `json:"psn_type"`
  6750. // FixmedinsName string `json:"fixmedins_name"`
  6751. // HifpPay float64 `json:"hifp_pay"`
  6752. // NewFlag interface{} `json:"new_flag"`
  6753. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6754. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  6755. // PayLoc string `json:"pay_loc"`
  6756. // ClrType string `json:"clr_type"`
  6757. // RefdSetlFlag string `json:"refd_setl_flag"`
  6758. // CvlservFlag string `json:"cvlserv_flag"`
  6759. // EmpName string `json:"emp_name"`
  6760. // Brdy string `json:"brdy"`
  6761. // Naty string `json:"naty"`
  6762. // Certno string `json:"certno"`
  6763. // DiseCode string `json:"dise_code"`
  6764. // FixmedinsCode string `json:"fixmedins_code"`
  6765. // DedcHospLv string `json:"dedc_hosp_lv"`
  6766. // OpterName string `json:"opter_name"`
  6767. // Balc float64 `json:"balc"`
  6768. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6769. // PsnCertType string `json:"psn_cert_type"`
  6770. // HifobPay float64 `json:"hifob_pay"`
  6771. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  6772. // HifesPay float64 `json:"hifes_pay"`
  6773. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6774. // OptTime string `json:"opt_time"`
  6775. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6776. // SetlID string `json:"setl_id"`
  6777. // MafPay float64 `json:"maf_pay"`
  6778. // PsnName string `json:"psn_name"`
  6779. // InsuOptins interface{} `json:"insu_optins"`
  6780. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6781. // ClrOptins string `json:"clr_optins"`
  6782. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6783. // DiseName string `json:"dise_name"`
  6784. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6785. // Age float64 `json:"age"`
  6786. // DtrtCertType string `json:"dtrt_cert_type"`
  6787. // HospLv string `json:"hosp_lv"`
  6788. // } `json:"setlinfo"`
  6789. // Setldetail []struct {
  6790. // FundPayType string `json:"fund_pay_type"`
  6791. // FundPayamt float64 `json:"fund_payamt"`
  6792. // SetlProcInfo interface{} `json:"setl_proc_info"`
  6793. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  6794. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  6795. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  6796. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6797. // } `json:"setldetail"`
  6798. // } `json:"output"`
  6799. // Infcode int `json:"infcode"`
  6800. // WarnMsg interface{} `json:"warn_msg"`
  6801. // Cainfo interface{} `json:"cainfo"`
  6802. // ErrMsg interface{} `json:"err_msg"`
  6803. // RefmsgTime string `json:"refmsg_time"`
  6804. // Signtype interface{} `json:"signtype"`
  6805. // RespondTime string `json:"respond_time"`
  6806. // InfRefmsgid string `json:"inf_refmsgid"`
  6807. //}
  6808. type ResultEleven struct {
  6809. Cainfo string `json:"cainfo"`
  6810. ErrMsg string `json:"err_msg"`
  6811. InfRefmsgid string `json:"inf_refmsgid"`
  6812. Infcode int64 `json:"infcode"`
  6813. Output struct {
  6814. Setlinfo struct {
  6815. SetlTime string `json:"setl_time"`
  6816. CvlservPay float64 `json:"cvlserv_pay"`
  6817. Year string `json:"year"`
  6818. MedType string `json:"med_type"`
  6819. PsnPay float64 `json:"psn_pay"`
  6820. OpterID string `json:"opter_id"`
  6821. Begndate string `json:"begndate"`
  6822. FlxempeFlag string `json:"flxempe_flag"`
  6823. HifmiPay float64 `json:"hifmi_pay"`
  6824. PsnNo string `json:"psn_no"`
  6825. ActPayDedc float64 `json:"act_pay_dedc"`
  6826. MedinsSetlID interface{} `json:"medins_setl_id"`
  6827. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6828. ClrWay string `json:"clr_way"`
  6829. OthPay float64 `json:"oth_pay"`
  6830. Gend string `json:"gend"`
  6831. MdtrtID string `json:"mdtrt_id"`
  6832. AcctPay float64 `json:"acct_pay"`
  6833. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6834. Insutype string `json:"insutype"`
  6835. Invono interface{} `json:"invono"`
  6836. Enddate string `json:"enddate"`
  6837. CashPayamt float64 `json:"cash_payamt"`
  6838. PsnType string `json:"psn_type"`
  6839. FixmedinsName string `json:"fixmedins_name"`
  6840. HifpPay float64 `json:"hifp_pay"`
  6841. NewFlag interface{} `json:"new_flag"`
  6842. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6843. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6844. PayLoc string `json:"pay_loc"`
  6845. ClrType string `json:"clr_type"`
  6846. RefdSetlFlag string `json:"refd_setl_flag"`
  6847. CvlservFlag string `json:"cvlserv_flag"`
  6848. EmpName string `json:"emp_name"`
  6849. Brdy string `json:"brdy"`
  6850. Naty string `json:"naty"`
  6851. Certno string `json:"certno"`
  6852. DiseCode string `json:"dise_code"`
  6853. FixmedinsCode string `json:"fixmedins_code"`
  6854. DedcHospLv string `json:"dedc_hosp_lv"`
  6855. OpterName string `json:"opter_name"`
  6856. Balc float64 `json:"balc"`
  6857. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6858. PsnCertType string `json:"psn_cert_type"`
  6859. HifobPay float64 `json:"hifob_pay"`
  6860. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6861. HifesPay float64 `json:"hifes_pay"`
  6862. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6863. OptTime string `json:"opt_time"`
  6864. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6865. SetlID string `json:"setl_id"`
  6866. MafPay float64 `json:"maf_pay"`
  6867. PsnName string `json:"psn_name"`
  6868. InsuOptins interface{} `json:"insu_optins"`
  6869. PrefFundPay interface{} `json:"pref_fund_pay"`
  6870. ClrOptins string `json:"clr_optins"`
  6871. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6872. DiseName string `json:"dise_name"`
  6873. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6874. Age float64 `json:"age"`
  6875. DtrtCertType string `json:"dtrt_cert_type"`
  6876. HospLv string `json:"hosp_lv"`
  6877. PsnCashPay float64
  6878. } `json:"setlinfo"`
  6879. } `json:"output"`
  6880. RefmsgTime string `json:"refmsg_time"`
  6881. RespondTime string `json:"respond_time"`
  6882. Signtype interface{} `json:"signtype"`
  6883. WarnMsg interface{} `json:"warn_msg"`
  6884. }
  6885. type ResultEleven10265 struct {
  6886. Cainfo string `json:"cainfo"`
  6887. ErrMsg string `json:"err_msg"`
  6888. InfRefmsgid string `json:"inf_refmsgid"`
  6889. Infcode string `json:"infcode"`
  6890. Output struct {
  6891. Setlinfo struct {
  6892. SetlTime string `json:"setl_time"`
  6893. CvlservPay float64 `json:"cvlserv_pay"`
  6894. Year string `json:"year"`
  6895. MedType string `json:"med_type"`
  6896. PsnPay float64 `json:"psn_pay"`
  6897. OpterID string `json:"opter_id"`
  6898. Begndate string `json:"begndate"`
  6899. FlxempeFlag string `json:"flxempe_flag"`
  6900. HifmiPay float64 `json:"hifmi_pay"`
  6901. PsnNo string `json:"psn_no"`
  6902. ActPayDedc float64 `json:"act_pay_dedc"`
  6903. MedinsSetlID interface{} `json:"medins_setl_id"`
  6904. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6905. ClrWay string `json:"clr_way"`
  6906. OthPay float64 `json:"oth_pay"`
  6907. Gend string `json:"gend"`
  6908. MdtrtID string `json:"mdtrt_id"`
  6909. AcctPay float64 `json:"acct_pay"`
  6910. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6911. Insutype string `json:"insutype"`
  6912. Invono interface{} `json:"invono"`
  6913. Enddate string `json:"enddate"`
  6914. CashPayamt float64 `json:"cash_payamt"`
  6915. PsnType string `json:"psn_type"`
  6916. FixmedinsName string `json:"fixmedins_name"`
  6917. HifpPay float64 `json:"hifp_pay"`
  6918. NewFlag interface{} `json:"new_flag"`
  6919. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6920. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6921. PayLoc string `json:"pay_loc"`
  6922. ClrType string `json:"clr_type"`
  6923. RefdSetlFlag string `json:"refd_setl_flag"`
  6924. CvlservFlag string `json:"cvlserv_flag"`
  6925. EmpName string `json:"emp_name"`
  6926. Brdy string `json:"brdy"`
  6927. Naty string `json:"naty"`
  6928. Certno string `json:"certno"`
  6929. DiseCode string `json:"dise_code"`
  6930. FixmedinsCode string `json:"fixmedins_code"`
  6931. DedcHospLv string `json:"dedc_hosp_lv"`
  6932. OpterName string `json:"opter_name"`
  6933. Balc float64 `json:"balc"`
  6934. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6935. PsnCertType string `json:"psn_cert_type"`
  6936. HifobPay float64 `json:"hifob_pay"`
  6937. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6938. HifesPay float64 `json:"hifes_pay"`
  6939. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6940. OptTime string `json:"opt_time"`
  6941. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6942. SetlID string `json:"setl_id"`
  6943. MafPay float64 `json:"maf_pay"`
  6944. PsnName string `json:"psn_name"`
  6945. InsuOptins interface{} `json:"insu_optins"`
  6946. PrefFundPay interface{} `json:"pref_fund_pay"`
  6947. ClrOptins string `json:"clr_optins"`
  6948. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6949. DiseName string `json:"dise_name"`
  6950. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6951. Age float64 `json:"age"`
  6952. DtrtCertType string `json:"dtrt_cert_type"`
  6953. HospLv string `json:"hosp_lv"`
  6954. PsnCashPay float64
  6955. } `json:"setlinfo"`
  6956. } `json:"output"`
  6957. RefmsgTime string `json:"refmsg_time"`
  6958. RespondTime string `json:"respond_time"`
  6959. Signtype interface{} `json:"signtype"`
  6960. WarnMsg interface{} `json:"warn_msg"`
  6961. }
  6962. type ResultTwelve struct {
  6963. Cainfo string `json:"cainfo"`
  6964. ErrMsg string `json:"err_msg"`
  6965. InfRefmsgid string `json:"inf_refmsgid"`
  6966. Infcode int64 `json:"infcode"`
  6967. Output struct {
  6968. MdtrtId string `json:"mdtrt_id"`
  6969. ChrgBchno string `json:"chrg_bchno"`
  6970. PsnNo string `json:"psn_no"`
  6971. } `json:"output"`
  6972. RefmsgTime string `json:"refmsg_time"`
  6973. RespondTime string `json:"respond_time"`
  6974. Signtype interface{} `json:"signtype"`
  6975. WarnMsg interface{} `json:"warn_msg"`
  6976. }
  6977. type ResultThirteen struct {
  6978. ErrMsg string `json:"err_msg"`
  6979. InfRefmsgid string `json:"inf_refmsgid"`
  6980. Infcode int64 `json:"infcode"`
  6981. Output struct {
  6982. Result struct {
  6983. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6984. } `json:"result"`
  6985. } `json:"output"`
  6986. RefmsgTime string `json:"refmsg_time"`
  6987. RespondTime string `json:"respond_time"`
  6988. Signtype interface{} `json:"signtype"`
  6989. WarnInfo interface{} `json:"warn_info"`
  6990. }
  6991. type ResultThirteen10265 struct {
  6992. ErrMsg string `json:"err_msg"`
  6993. InfRefmsgid string `json:"inf_refmsgid"`
  6994. Infcode string `json:"infcode"`
  6995. Output struct {
  6996. Result struct {
  6997. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6998. } `json:"result"`
  6999. } `json:"output"`
  7000. RefmsgTime string `json:"refmsg_time"`
  7001. RespondTime string `json:"respond_time"`
  7002. Signtype interface{} `json:"signtype"`
  7003. WarnInfo interface{} `json:"warn_info"`
  7004. }
  7005. type ResultFourteen struct {
  7006. ErrMsg string `json:"err_msg"`
  7007. InfRefmsgid string `json:"inf_refmsgid"`
  7008. Infcode int64 `json:"infcode"`
  7009. Output struct {
  7010. } `json:"output"`
  7011. RefmsgTime string `json:"refmsg_time"`
  7012. RespondTime string `json:"respond_time"`
  7013. Signtype interface{} `json:"signtype"`
  7014. WarnInfo interface{} `json:"warn_info"`
  7015. }
  7016. type ResultFourteen10265 struct {
  7017. ErrMsg string `json:"err_msg"`
  7018. InfRefmsgid string `json:"inf_refmsgid"`
  7019. Infcode string `json:"infcode"`
  7020. Output struct {
  7021. } `json:"output"`
  7022. RefmsgTime string `json:"refmsg_time"`
  7023. RespondTime string `json:"respond_time"`
  7024. Signtype interface{} `json:"signtype"`
  7025. WarnInfo interface{} `json:"warn_info"`
  7026. }
  7027. type ResultSixteen struct {
  7028. Cainfo string `json:"cainfo"`
  7029. ErrMsg string `json:"err_msg"`
  7030. InfRefmsgid string `json:"inf_refmsgid"`
  7031. Infcode int64 `json:"infcode"`
  7032. Output struct {
  7033. Setldetail []interface{} `json:"setldetail"`
  7034. Setlinfo struct {
  7035. MdtrtID string `json:"mdtrt_id"`
  7036. SetlID string `json:"setl_id"`
  7037. ClrOptins string `json:"clr_optins"`
  7038. SetlTime string `json:"setl_time"`
  7039. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7040. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7041. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7042. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7043. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7044. ActPayDedc float64 `json:"act_pay_dedc"`
  7045. HifpPay float64 `json:"hifp_pay"`
  7046. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7047. Lfpay float64 `json:"selfpay"`
  7048. CvlservPay float64 `json:"cvlserv_pay"`
  7049. HifesPay float64 `json:"hifes_pay"`
  7050. HifmiPay float64 `json:"hifmi_pay"`
  7051. HifobPay float64 `json:"hifob_pay"`
  7052. MafPay float64 `json:"maf_pay"`
  7053. OthPay float64 `json:"oth_pay"`
  7054. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7055. PsnPartAmt float64 `json:"psn_part_amt"`
  7056. AcctPay float64 `json:"acct_pay"`
  7057. Balc float64 `json:"balc"`
  7058. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7059. HospPartAmt float64 `json:"hosp_part_amt"`
  7060. MedinsSetlID string `json:"medins_setl_id"`
  7061. PdnCashPay string `json:"pdn_cash_pay"`
  7062. } `json:"setlinfo"`
  7063. } `json:"output"`
  7064. RefmsgTime string `json:"refmsg_time"`
  7065. RespondTime string `json:"respond_time"`
  7066. Signtype interface{} `json:"signtype"`
  7067. WarnMsg interface{} `json:"warn_msg"`
  7068. }
  7069. type ResultSixteen10265 struct {
  7070. Cainfo string `json:"cainfo"`
  7071. ErrMsg string `json:"err_msg"`
  7072. InfRefmsgid string `json:"inf_refmsgid"`
  7073. Infcode string `json:"infcode"`
  7074. Output struct {
  7075. Setldetail []interface{} `json:"setldetail"`
  7076. Setlinfo struct {
  7077. MdtrtID string `json:"mdtrt_id"`
  7078. SetlID string `json:"setl_id"`
  7079. ClrOptins string `json:"clr_optins"`
  7080. SetlTime string `json:"setl_time"`
  7081. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7082. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7083. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7084. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7085. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7086. ActPayDedc float64 `json:"act_pay_dedc"`
  7087. HifpPay float64 `json:"hifp_pay"`
  7088. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7089. Lfpay float64 `json:"selfpay"`
  7090. CvlservPay float64 `json:"cvlserv_pay"`
  7091. HifesPay float64 `json:"hifes_pay"`
  7092. HifmiPay float64 `json:"hifmi_pay"`
  7093. HifobPay float64 `json:"hifob_pay"`
  7094. MafPay float64 `json:"maf_pay"`
  7095. OthPay float64 `json:"oth_pay"`
  7096. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7097. PsnPartAmt float64 `json:"psn_part_amt"`
  7098. AcctPay float64 `json:"acct_pay"`
  7099. Balc float64 `json:"balc"`
  7100. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7101. HospPartAmt float64 `json:"hosp_part_amt"`
  7102. MedinsSetlID string `json:"medins_setl_id"`
  7103. PdnCashPay string `json:"pdn_cash_pay"`
  7104. } `json:"setlinfo"`
  7105. } `json:"output"`
  7106. RefmsgTime string `json:"refmsg_time"`
  7107. RespondTime string `json:"respond_time"`
  7108. Signtype interface{} `json:"signtype"`
  7109. WarnMsg interface{} `json:"warn_msg"`
  7110. }
  7111. type ResultSeventeen struct {
  7112. ErrMsg string `json:"err_msg"`
  7113. InfRefmsgid string `json:"inf_refmsgid"`
  7114. Infcode int64 `json:"infcode"`
  7115. Output struct {
  7116. SetlListId string `json:"setl_list_id"`
  7117. } `json:"output"`
  7118. RefmsgTime string `json:"refmsg_time"`
  7119. RespondTime string `json:"respond_time"`
  7120. Signtype string `json:"signtype"`
  7121. WarnInfo string `json:"warn_info"`
  7122. }
  7123. type ResultSeventeenOther struct {
  7124. ErrMsg string `json:"err_msg"`
  7125. InfRefmsgid string `json:"inf_refmsgid"`
  7126. Infcode string `json:"infcode"`
  7127. Output struct {
  7128. SetlListId string `json:"setl_list_id"`
  7129. } `json:"output"`
  7130. RefmsgTime string `json:"refmsg_time"`
  7131. RespondTime string `json:"respond_time"`
  7132. Signtype string `json:"signtype"`
  7133. WarnInfo string `json:"warn_info"`
  7134. }
  7135. type Result90991 struct {
  7136. ErrMsg string `json:"err_msg"`
  7137. InfRefmsgid string `json:"inf_refmsgid"`
  7138. Infcode int64 `json:"infcode"`
  7139. Output struct {
  7140. Result struct {
  7141. PsnNo string `json:"psn_no"`
  7142. CardStat string `json:"card_stat"`
  7143. Certno string `json:"certno"`
  7144. PsnName string `json:"psn_name"`
  7145. CheckStat string `json:"check_stat"`
  7146. SscnoCheckStat string `json:"sscno_check_stat"`
  7147. } `json:"result"`
  7148. } `json:"output"`
  7149. RefmsgTime string `json:"refmsg_time"`
  7150. RespondTime string `json:"respond_time"`
  7151. Signtype interface{} `json:"signtype"`
  7152. WarnInfo interface{} `json:"warn_info"`
  7153. }
  7154. type Result90100 struct {
  7155. ErrMsg string `json:"err_msg"`
  7156. InfRefmsgid string `json:"inf_refmsgid"`
  7157. Infcode int64 `json:"infcode"`
  7158. Output struct {
  7159. PoolareaNo string `json:"poolarea_no"`
  7160. PoolareaNoName string `json:"poolarea_no_name"`
  7161. Insutype string `json:"insutype"`
  7162. InsutypeName string `json:"insutype_name"`
  7163. ClctType string `json:"clct_type"`
  7164. ClctTypeName string `json:"clct_type_name"`
  7165. ClctFlag string `json:"clct_flag"`
  7166. ClctFlagName string `json:"clct_flag_name"`
  7167. AccrymBegn string `json:"accrym_begn"`
  7168. AccrymEnd string `json:"accrym_end"`
  7169. ClctTime string `json:"clct_time"`
  7170. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  7171. } `json:"output"`
  7172. RefmsgTime string `json:"refmsg_time"`
  7173. RespondTime string `json:"respond_time"`
  7174. Signtype interface{} `json:"signtype"`
  7175. WarnInfo interface{} `json:"warn_info"`
  7176. }
  7177. type Custom struct {
  7178. DetItemFeeSumamt string
  7179. Cut string
  7180. FeedetlSn string
  7181. Price string
  7182. MedListCodg string
  7183. Type int64
  7184. AdviceId int64
  7185. ProjectId int64
  7186. ItemId int64
  7187. }
  7188. type Result5301 struct {
  7189. ErrMsg string `json:"err_msg"`
  7190. InfRefmsgid string `json:"inf_refmsgid"`
  7191. Infcode int64 `json:"infcode"`
  7192. Output struct {
  7193. Result []struct {
  7194. OpspDiseCode string `json:"opsp_dise_code"`
  7195. OpspDiseName string `json:"opsp_dise_name"`
  7196. Begndate string `json:"begndate"`
  7197. Enddate string `json:"enddate"`
  7198. } `json:"feedetail"`
  7199. } `json:"output"`
  7200. RefmsgTime string `json:"refmsg_time"`
  7201. RespondTime string `json:"respond_time"`
  7202. Signtype interface{} `json:"signtype"`
  7203. WarnInfo interface{} `json:"warn_info"`
  7204. }
  7205. type Result5301For10265 struct {
  7206. ErrMsg string `json:"err_msg"`
  7207. InfRefmsgid string `json:"inf_refmsgid"`
  7208. Infcode string `json:"infcode"`
  7209. Output struct {
  7210. Result []struct {
  7211. OpspDiseCode string `json:"opsp_dise_code"`
  7212. OpspDiseName string `json:"opsp_dise_name"`
  7213. Begndate string `json:"begndate"`
  7214. Enddate string `json:"enddate"`
  7215. } `json:"feedetail"`
  7216. } `json:"output"`
  7217. RefmsgTime string `json:"refmsg_time"`
  7218. RespondTime string `json:"respond_time"`
  7219. Signtype interface{} `json:"signtype"`
  7220. WarnInfo interface{} `json:"warn_info"`
  7221. }
  7222. //获取个人信息----挂号-----上传就诊信息
  7223. func (c *HisApiController) GetRegisterInfo() {
  7224. id, _ := c.GetInt64("id")
  7225. record_time := c.GetString("record_time")
  7226. settlementValue, _ := c.GetInt64("settlement_value")
  7227. medical_insurance_card := c.GetString("medical_insurance_card")
  7228. name := c.GetString("name")
  7229. id_card_type, _ := c.GetInt64("id_card_type")
  7230. certificates, _ := c.GetInt64("certificates")
  7231. medical_care, _ := c.GetInt64("medical_care")
  7232. birthday := c.GetString("birthday")
  7233. id_card := c.GetString("id_card")
  7234. register_type, _ := c.GetInt64("register")
  7235. doctor, _ := c.GetInt64("doctor")
  7236. department, _ := c.GetInt64("department")
  7237. gender, _ := c.GetInt64("sex")
  7238. registration_fee, _ := c.GetFloat("registration_fee")
  7239. medical_expenses, _ := c.GetFloat("medical_expenses")
  7240. social_type, _ := c.GetInt64("social_type")
  7241. med_type := c.GetString("social_type")
  7242. admin_user_id, _ := c.GetInt64("admin_user_id")
  7243. insuplc_admdvs := c.GetString("insuplc_admdvs")
  7244. mdtrt_type := c.GetString("mdtrt_type")
  7245. timeLayout := "2006-01-02"
  7246. loc, _ := time.LoadLocation("Local")
  7247. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  7248. birthUnix := birthdays.Unix()
  7249. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7250. if err != nil {
  7251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7252. return
  7253. }
  7254. recordDateTime := theTime.Unix()
  7255. adminInfo := c.GetAdminUserInfo()
  7256. var patient service.Patients
  7257. if id == 0 {
  7258. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  7259. } else {
  7260. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  7261. }
  7262. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7263. if patientPrescription.ID == 0 {
  7264. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7265. }
  7266. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7267. if patient.ID == 0 {
  7268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7269. return
  7270. }
  7271. if len(patient.IdCardNo) == 0 {
  7272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7273. return
  7274. }
  7275. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7276. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  7277. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  7278. //就诊结算未完成,不能进行二次挂号
  7279. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  7280. if len(his) >= 1 {
  7281. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  7282. if len(his) >= 1 && order.ID == 0 {
  7283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  7284. return
  7285. }
  7286. }
  7287. //var register_log string
  7288. if config.IsOpen == 1 {
  7289. var res ResultTwo
  7290. var res10265 ResultTwo10265
  7291. var PsnNo string
  7292. var PsnCertType string
  7293. var Certno string
  7294. var PsnName string
  7295. var Gend string
  7296. var Naty string
  7297. var Brdy string
  7298. var Age float64
  7299. var infoStr string
  7300. var idetinfoStr string
  7301. var infocode int64
  7302. var verify_number string
  7303. fmt.Println(verify_number)
  7304. if miConfig.MdtrtareaAdmvs == "421300" {
  7305. psn_info, _ := service.GetPsnByPatientId(id)
  7306. PsnNo = psn_info.PsnNo
  7307. PsnCertType = psn_info.PsnCertType
  7308. Certno = psn_info.Certno
  7309. PsnName = psn_info.PsnName
  7310. Gend = psn_info.Gend
  7311. Naty = psn_info.Naty
  7312. Brdy = psn_info.Brdy
  7313. Age = psn_info.Age
  7314. infoStr = psn_info.Insuinfo
  7315. idetinfoStr = psn_info.Idetinfo
  7316. infocode = 0
  7317. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7318. psn_info, _ := service.GetPsnByPatientId(id)
  7319. PsnNo = psn_info.PsnNo
  7320. PsnCertType = psn_info.PsnCertType
  7321. Certno = psn_info.Certno
  7322. PsnName = psn_info.PsnName
  7323. Gend = psn_info.Gend
  7324. Naty = psn_info.Naty
  7325. Brdy = psn_info.Brdy
  7326. Age = psn_info.Age
  7327. infoStr = psn_info.Insuinfo
  7328. idetinfoStr = psn_info.Idetinfo
  7329. infocode = 0
  7330. verify_number = psn_info.VerifyNumber
  7331. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7332. if id_card_type == 1 {
  7333. psn_info, _ := service.GetPsnByPatientId(id)
  7334. PsnNo = psn_info.PsnNo
  7335. PsnCertType = psn_info.PsnCertType
  7336. Certno = psn_info.Certno
  7337. PsnName = psn_info.PsnName
  7338. Gend = psn_info.Gend
  7339. Naty = psn_info.Naty
  7340. Brdy = psn_info.Brdy
  7341. Age = psn_info.Age
  7342. infoStr = psn_info.Insuinfo
  7343. idetinfoStr = psn_info.Idetinfo
  7344. infocode = 0
  7345. verify_number = psn_info.VerifyNumber
  7346. } else if id_card_type == 2 {
  7347. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, "")
  7348. fmt.Println(errMsgLog)
  7349. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7350. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7351. utils.ErrorLog("解析失败:%v", err)
  7352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7353. return
  7354. }
  7355. PsnNo = res.Output.Baseinfo.PsnNo
  7356. PsnCertType = res.Output.Baseinfo.PsnCertType
  7357. Certno = res.Output.Baseinfo.Certno
  7358. PsnName = res.Output.Baseinfo.PsnName
  7359. Gend = res.Output.Baseinfo.Gend
  7360. Naty = res.Output.Baseinfo.Naty
  7361. Brdy = res.Output.Baseinfo.Brdy
  7362. Age = res.Output.Baseinfo.Age
  7363. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7364. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7365. infoStr = string(Iinfos)
  7366. idetinfoStr = string(Idetinfos)
  7367. infocode = res.Infcode
  7368. }
  7369. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7370. if id_card_type == 1 {
  7371. psn_info, _ := service.GetPsnByPatientId(id)
  7372. PsnNo = psn_info.PsnNo
  7373. PsnCertType = psn_info.PsnCertType
  7374. Certno = psn_info.Certno
  7375. PsnName = psn_info.PsnName
  7376. Gend = psn_info.Gend
  7377. Naty = psn_info.Naty
  7378. Brdy = psn_info.Brdy
  7379. Age = psn_info.Age
  7380. infoStr = psn_info.Insuinfo
  7381. idetinfoStr = psn_info.Idetinfo
  7382. infocode = 0
  7383. verify_number = psn_info.VerifyNumber
  7384. } else if id_card_type == 2 {
  7385. result, requestLog := service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "")
  7386. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7388. utils.ErrorLog("解析失败:%v", err)
  7389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7390. return
  7391. }
  7392. PsnNo = res.Output.Baseinfo.PsnNo
  7393. PsnCertType = res.Output.Baseinfo.PsnCertType
  7394. Certno = res.Output.Baseinfo.Certno
  7395. PsnName = res.Output.Baseinfo.PsnName
  7396. Gend = res.Output.Baseinfo.Gend
  7397. Naty = res.Output.Baseinfo.Naty
  7398. Brdy = res.Output.Baseinfo.Brdy
  7399. Age = res.Output.Baseinfo.Age
  7400. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7401. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7402. infoStr = string(Iinfos)
  7403. idetinfoStr = string(Idetinfos)
  7404. infocode = res.Infcode
  7405. }
  7406. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7407. if id_card_type == 1 {
  7408. psn_info, _ := service.GetPsnByPatientId(id)
  7409. PsnNo = psn_info.PsnNo
  7410. PsnCertType = psn_info.PsnCertType
  7411. Certno = psn_info.Certno
  7412. PsnName = psn_info.PsnName
  7413. Gend = psn_info.Gend
  7414. Naty = psn_info.Naty
  7415. Brdy = psn_info.Brdy
  7416. Age = psn_info.Age
  7417. infoStr = psn_info.Insuinfo
  7418. idetinfoStr = psn_info.Idetinfo
  7419. infocode = 0
  7420. verify_number = psn_info.VerifyNumber
  7421. } else if id_card_type == 2 {
  7422. result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", "", Certno)
  7423. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7425. utils.ErrorLog("解析失败:%v", err)
  7426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7427. return
  7428. }
  7429. PsnNo = res.Output.Baseinfo.PsnNo
  7430. PsnCertType = res.Output.Baseinfo.PsnCertType
  7431. Certno = res.Output.Baseinfo.Certno
  7432. PsnName = res.Output.Baseinfo.PsnName
  7433. Gend = res.Output.Baseinfo.Gend
  7434. Naty = res.Output.Baseinfo.Naty
  7435. Brdy = res.Output.Baseinfo.Brdy
  7436. Age = res.Output.Baseinfo.Age
  7437. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7438. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7439. infoStr = string(Iinfos)
  7440. idetinfoStr = string(Idetinfos)
  7441. infocode = res.Infcode
  7442. }
  7443. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7444. var result string
  7445. var requestLog string
  7446. result, requestLog = service.HeBeiyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), "")
  7447. if id_card_type == 4 {
  7448. psn_info, _ := service.GetPsnByPatientId(id)
  7449. PsnNo = psn_info.PsnNo
  7450. PsnCertType = psn_info.PsnCertType
  7451. Certno = psn_info.Certno
  7452. PsnName = psn_info.PsnName
  7453. Gend = psn_info.Gend
  7454. Naty = psn_info.Naty
  7455. Brdy = psn_info.Brdy
  7456. Age = psn_info.Age
  7457. infoStr = psn_info.Insuinfo
  7458. idetinfoStr = psn_info.Idetinfo
  7459. infocode = 0
  7460. verify_number = psn_info.VerifyNumber
  7461. } else {
  7462. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7463. if miConfig.Code == "H15049901371" {
  7464. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7465. utils.ErrorLog("解析失败:%v", err)
  7466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7467. return
  7468. }
  7469. res.ErrMsg = res10265.ErrMsg
  7470. res.Output = res10265.Output
  7471. res.InfRefmsgid = res10265.InfRefmsgid
  7472. } else {
  7473. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7474. utils.ErrorLog("解析失败:%v", err)
  7475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7476. return
  7477. }
  7478. }
  7479. PsnNo = res.Output.Baseinfo.PsnNo
  7480. PsnCertType = res.Output.Baseinfo.PsnCertType
  7481. Certno = res.Output.Baseinfo.Certno
  7482. PsnName = res.Output.Baseinfo.PsnName
  7483. Gend = res.Output.Baseinfo.Gend
  7484. Naty = res.Output.Baseinfo.Naty
  7485. Brdy = res.Output.Baseinfo.Brdy
  7486. Age = res.Output.Baseinfo.Age
  7487. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7488. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7489. infoStr = string(Iinfos)
  7490. idetinfoStr = string(Idetinfos)
  7491. if miConfig.Code == "H15049901371" {
  7492. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7493. } else {
  7494. infocode = res.Infcode
  7495. }
  7496. }
  7497. } else {
  7498. var result string
  7499. var requestLog string
  7500. if miConfig.UserOrgId == 10138 {
  7501. if id_card_type != 4 || id_card_type != 1 {
  7502. var insa string
  7503. if len(patient.InsuplcAdmdvs) > 0 {
  7504. insa = patient.InsuplcAdmdvs
  7505. } else {
  7506. insa = miConfig.InsuplcAdmdvs
  7507. }
  7508. //psn_info, _ := service.GetPsnByPatientId(id)
  7509. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  7510. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  7511. }
  7512. } else {
  7513. var insa string
  7514. if len(patient.InsuplcAdmdvs) > 0 {
  7515. insa = patient.InsuplcAdmdvs
  7516. } else {
  7517. insa = miConfig.InsuplcAdmdvs
  7518. }
  7519. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  7520. }
  7521. if id_card_type == 4 || id_card_type == 1 {
  7522. psn_info, _ := service.GetPsnByPatientId(id)
  7523. PsnNo = psn_info.PsnNo
  7524. PsnCertType = psn_info.PsnCertType
  7525. Certno = psn_info.Certno
  7526. PsnName = psn_info.PsnName
  7527. Gend = psn_info.Gend
  7528. Naty = psn_info.Naty
  7529. Brdy = psn_info.Brdy
  7530. Age = psn_info.Age
  7531. infoStr = psn_info.Insuinfo
  7532. idetinfoStr = psn_info.Idetinfo
  7533. infocode = 0
  7534. verify_number = psn_info.VerifyNumber
  7535. } else {
  7536. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7537. if miConfig.Code == "H15049901371" {
  7538. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7539. utils.ErrorLog("解析失败:%v", err)
  7540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. return
  7542. }
  7543. res.ErrMsg = res10265.ErrMsg
  7544. res.Output = res10265.Output
  7545. res.InfRefmsgid = res10265.InfRefmsgid
  7546. } else {
  7547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7548. utils.ErrorLog("解析失败:%v", err)
  7549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7550. return
  7551. }
  7552. }
  7553. PsnNo = res.Output.Baseinfo.PsnNo
  7554. PsnCertType = res.Output.Baseinfo.PsnCertType
  7555. Certno = res.Output.Baseinfo.Certno
  7556. PsnName = res.Output.Baseinfo.PsnName
  7557. Gend = res.Output.Baseinfo.Gend
  7558. Naty = res.Output.Baseinfo.Naty
  7559. Brdy = res.Output.Baseinfo.Brdy
  7560. Age = res.Output.Baseinfo.Age
  7561. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7562. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7563. infoStr = string(Iinfos)
  7564. idetinfoStr = string(Idetinfos)
  7565. if miConfig.Code == "H15049901371" {
  7566. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7567. } else {
  7568. infocode = res.Infcode
  7569. }
  7570. }
  7571. }
  7572. if infocode == 0 {
  7573. his := models.VMHisPatient{
  7574. Name: name,
  7575. Gender: gender,
  7576. Birthday: birthUnix,
  7577. MedicalTreatmentType: medical_care,
  7578. IdType: certificates,
  7579. IdCardNo: id_card,
  7580. BalanceAccountsType: settlementValue,
  7581. SocialType: social_type,
  7582. MedicalInsuranceNumber: medical_insurance_card,
  7583. RegisterType: register_type,
  7584. RegisterCost: registration_fee,
  7585. TreatmentCost: medical_expenses,
  7586. Status: 1,
  7587. Ctime: time.Now().Unix(),
  7588. Mtime: time.Now().Unix(),
  7589. PsnNo: PsnNo,
  7590. PsnCertType: PsnCertType,
  7591. Certno: Certno,
  7592. PsnName: PsnName,
  7593. Gend: Gend,
  7594. Naty: Naty,
  7595. Brdy: Brdy,
  7596. Age: Age,
  7597. Iinfo: infoStr,
  7598. Idetinfo: idetinfoStr,
  7599. PatientId: patient.ID,
  7600. RecordDate: theTime.Unix(),
  7601. UserOrgId: adminInfo.CurrentOrgId,
  7602. AdminUserId: admin_user_id,
  7603. IsReturn: 1,
  7604. IdCardType: id_card_type,
  7605. Doctor: doctor,
  7606. Departments: department,
  7607. MdtrtGrpType: mdtrt_type,
  7608. }
  7609. timestamp := time.Now().Unix()
  7610. tempTime := time.Unix(timestamp, 0)
  7611. timeFormat := tempTime.Format("20060102150405")
  7612. chrgBchno := rand.Intn(100000) + 10000
  7613. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7614. his.Number = ipt_otp_no
  7615. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  7616. department, _ := service.GetDepartMentDetail(department)
  7617. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  7618. IdCardNo := ""
  7619. if id_card_type == 1 {
  7620. // IdCardNo = medical_insurance_card
  7621. IdCardNo = patient.IdCardNo
  7622. } else {
  7623. IdCardNo = patient.IdCardNo
  7624. }
  7625. var rf []*ResultFive
  7626. json.Unmarshal([]byte(his.Iinfo), &rf)
  7627. var insutypes []*ResultFive
  7628. var insutype string
  7629. var insuplc_admdvs_temp string
  7630. var is390 int = 0
  7631. var is310 int = 0
  7632. for _, item := range rf {
  7633. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7634. insutypes = append(insutypes, item)
  7635. }
  7636. }
  7637. if len(insutypes) == 1 {
  7638. insutype = insutypes[0].Insutype
  7639. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7640. } else {
  7641. for _, i := range insutypes {
  7642. if i.Insutype == "390" {
  7643. is390 = 1
  7644. }
  7645. if i.Insutype == "310" {
  7646. is310 = 1
  7647. }
  7648. }
  7649. }
  7650. if is390 == 1 {
  7651. insutype = "390"
  7652. }
  7653. if is310 == 1 {
  7654. insutype = "310"
  7655. }
  7656. if len(insutypes) == 0 {
  7657. insutype = "390"
  7658. }
  7659. if len(insutypes) == 2 {
  7660. insutype = med_type
  7661. }
  7662. if len(med_type) > 0 {
  7663. insutype = med_type
  7664. }
  7665. var infocode int64
  7666. var resThree ResultThree
  7667. var resThree10265 ResultThree10265
  7668. if len(insuplc_admdvs) == 0 {
  7669. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  7670. } else {
  7671. insuplc_admdvs_temp = insuplc_admdvs
  7672. }
  7673. if miConfig.MdtrtareaAdmvs == "350500" {
  7674. var rf []*ResultIDInfo
  7675. json.Unmarshal([]byte(idetinfoStr), &rf)
  7676. if len(rf) > 0 {
  7677. if len(rf[0].Memo) > 0 {
  7678. content := rf[0].Memo[1:len(rf[0].Memo)]
  7679. content2 := content[:len(content)-1]
  7680. fmt.Println(content2)
  7681. //var rf2 ResultMemo
  7682. //json.Unmarshal([]byte(content2), &rf2)
  7683. //fmt.Println(rf2)
  7684. //fmt.Println(rf2.InsuAdmdvs)
  7685. arr := strings.Split(content2, ",")
  7686. var tarstring string
  7687. for _, item := range arr {
  7688. if find := strings.Contains(item, "insuAdmdvs"); find {
  7689. tarstring = item
  7690. }
  7691. }
  7692. fmt.Println(tarstring)
  7693. if len(tarstring) > 0 {
  7694. arr := strings.Split(tarstring, ":")
  7695. insuplc_admdvs_temp = strings.Replace(arr[1], "\"", "", -1)
  7696. //insuplc_admdvs_temp = arr[1]
  7697. }
  7698. }
  7699. }
  7700. }
  7701. if miConfig.MdtrtareaAdmvs == "421300" {
  7702. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  7703. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  7704. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7705. "&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
  7706. resp, requestErr := http.Get(api)
  7707. if requestErr != nil {
  7708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7709. return
  7710. }
  7711. body, ioErr := ioutil.ReadAll(resp.Body)
  7712. if ioErr != nil {
  7713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7715. return
  7716. }
  7717. var respJSON map[string]interface{}
  7718. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7721. return
  7722. }
  7723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7724. result, _ := json.Marshal(respJSON)
  7725. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7726. utils.ErrorLog("解析失败:%v", err)
  7727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7728. return
  7729. }
  7730. infocode = resThree.Infcode
  7731. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7732. psn_info, _ := service.GetPsnByPatientId(id)
  7733. his.PsnNo = psn_info.PsnNo
  7734. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7735. var cert_no string
  7736. if id_card_type == 3 {
  7737. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  7738. cert_no = IdCardNo
  7739. } else if id_card_type == 4 {
  7740. cert_no = IdCardNo
  7741. psn_info.VerifyNumber = psn_info.VerifyNumber
  7742. } else {
  7743. bas := strings.Split(psn_info.CardInfo, "|")
  7744. cert_no = bas[2]
  7745. }
  7746. var hisPrescription []*models.HisPrescription
  7747. for _, item := range rf {
  7748. if item.Insutype == insutype {
  7749. //insuplc_admdvs = item.InsuplcAdmdvs
  7750. his.InsuplcAdmdvs = insuplc_admdvs
  7751. }
  7752. }
  7753. his.Insutype = insutype
  7754. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  7755. fmt.Println(res3101)
  7756. fmt.Println(res3101.Infcode)
  7757. if res3101.Infcode == "0" {
  7758. fmt.Println("33333333")
  7759. if len(res3101.Output.Result) > 0 {
  7760. fmt.Println("222222")
  7761. for _, item := range res3101.Output.Result {
  7762. if len(res3101.ErrMsg) == 0 {
  7763. res3101.ErrMsg = item.VolaCont
  7764. } else {
  7765. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  7766. }
  7767. }
  7768. c.ServeSuccessJSON(map[string]interface{}{
  7769. "failed_code": -10,
  7770. "msg": res3101.ErrMsg,
  7771. })
  7772. return
  7773. } else {
  7774. fmt.Println("11111")
  7775. var api string
  7776. if miConfig.MdtrtareaAdmvs == "320921" {
  7777. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7778. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7779. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7780. } else {
  7781. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7782. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7783. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7784. }
  7785. resp, requestErr := http.Get(api)
  7786. if requestErr != nil {
  7787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7788. return
  7789. }
  7790. body, ioErr := ioutil.ReadAll(resp.Body)
  7791. if ioErr != nil {
  7792. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7794. return
  7795. }
  7796. var respJSON map[string]interface{}
  7797. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7800. return
  7801. }
  7802. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7803. result, _ := json.Marshal(respJSON)
  7804. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7805. utils.ErrorLog("解析失败:%v", err)
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7807. return
  7808. }
  7809. resThree.ErrMsg = resThree10265.ErrMsg
  7810. resThree.Output = resThree10265.Output
  7811. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7812. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7813. }
  7814. } else if res3101.Infcode != "0" {
  7815. c.ServeSuccessJSON(map[string]interface{}{
  7816. "failed_code": -10,
  7817. "msg": res3101.ErrMsg,
  7818. })
  7819. return
  7820. }
  7821. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7822. psn_info, _ := service.GetPsnByPatientId(id)
  7823. var cert_no string
  7824. if id_card_type == 1 {
  7825. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7826. } else if id_card_type == 4 {
  7827. cert_no = psn_info.VerifyNumber
  7828. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7829. } else {
  7830. cert_no = psn_info.VerifyNumber
  7831. }
  7832. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no, record_time)
  7833. saveLog(result, requestLog, "2201", "挂号")
  7834. if miConfig.Code == "H15049901371" {
  7835. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7836. utils.ErrorLog("解析失败:%v", err)
  7837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7838. return
  7839. }
  7840. resThree.ErrMsg = resThree10265.ErrMsg
  7841. resThree.Output = resThree10265.Output
  7842. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7843. } else {
  7844. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7845. utils.ErrorLog("解析失败:%v", err)
  7846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7847. return
  7848. }
  7849. }
  7850. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7851. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7852. psn_info, _ := service.GetPsnByPatientId(id)
  7853. var result string
  7854. var requestLog string
  7855. if id_card_type == 1 {
  7856. bas := strings.Split(psn_info.CardInfo, "|")
  7857. basNumber := bas[2]
  7858. card_sn := bas[3]
  7859. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  7860. saveLog(result, requestLog, "2201A", "挂号")
  7861. } else if id_card_type == 2 {
  7862. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  7863. saveLog(result, requestLog, "2201A", "挂号")
  7864. } else {
  7865. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "")
  7866. saveLog(result, requestLog, "2201A", "挂号")
  7867. }
  7868. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7869. utils.ErrorLog("解析失败:%v", err)
  7870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7871. return
  7872. }
  7873. infocode = resThree.Infcode
  7874. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7875. psn_info, _ := service.GetPsnByPatientId(id)
  7876. var result string
  7877. var requestLog string
  7878. if id_card_type == 1 {
  7879. bas := strings.Split(psn_info.CardInfo, "|")
  7880. basNumber := bas[2]
  7881. card_sn := bas[3]
  7882. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  7883. saveLog(result, requestLog, "2201A", "挂号")
  7884. } else if id_card_type == 2 {
  7885. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  7886. saveLog(result, requestLog, "2201A", "挂号")
  7887. } else {
  7888. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "")
  7889. saveLog(result, requestLog, "2201A", "挂号")
  7890. }
  7891. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7892. utils.ErrorLog("解析失败:%v", err)
  7893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7894. return
  7895. }
  7896. infocode = resThree.Infcode
  7897. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7898. psn_info, _ := service.GetPsnByPatientId(id)
  7899. result, requestLog := service.HeBeiyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  7900. saveLog(result, requestLog, "2201A", "挂号")
  7901. if miConfig.Code == "H15049901371" {
  7902. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7903. utils.ErrorLog("解析失败:%v", err)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. resThree.ErrMsg = resThree10265.ErrMsg
  7908. resThree.Output = resThree10265.Output
  7909. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7910. } else {
  7911. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7912. utils.ErrorLog("解析失败:%v", err)
  7913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7914. return
  7915. }
  7916. }
  7917. if miConfig.Code == "H15049901371" {
  7918. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7919. } else {
  7920. infocode = resThree.Infcode
  7921. }
  7922. } else {
  7923. psn_info, _ := service.GetPsnByPatientId(id)
  7924. if id_card_type == 4 || id_card_type == 1 {
  7925. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  7926. }
  7927. var rf []*ResultFive
  7928. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  7929. var insutypes []*ResultFive
  7930. var insutype string
  7931. var is390 int = 0
  7932. var is310 int = 0
  7933. for _, item := range rf {
  7934. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7935. insutypes = append(insutypes, item)
  7936. }
  7937. }
  7938. if len(insutypes) == 1 {
  7939. insutype = insutypes[0].Insutype
  7940. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7941. } else {
  7942. for _, i := range insutypes {
  7943. if i.Insutype == "390" {
  7944. is390 = 1
  7945. }
  7946. if i.Insutype == "310" {
  7947. is310 = 1
  7948. }
  7949. }
  7950. }
  7951. if is390 == 1 {
  7952. insutype = "390"
  7953. }
  7954. if is310 == 1 {
  7955. insutype = "310"
  7956. }
  7957. if len(insutypes) == 0 {
  7958. insutype = "310"
  7959. }
  7960. result, requestLog := service.Gdyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  7961. saveLog(result, requestLog, "2201A", "挂号")
  7962. if miConfig.Code == "H15049901371" {
  7963. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7964. utils.ErrorLog("解析失败:%v", err)
  7965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7966. return
  7967. }
  7968. resThree.ErrMsg = resThree10265.ErrMsg
  7969. resThree.Output = resThree10265.Output
  7970. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7971. } else {
  7972. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7973. utils.ErrorLog("解析失败:%v", err)
  7974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7975. return
  7976. }
  7977. }
  7978. if miConfig.Code == "H15049901371" {
  7979. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7980. } else {
  7981. infocode = resThree.Infcode
  7982. }
  7983. }
  7984. if infocode != 0 {
  7985. adminUser := c.GetAdminUserInfo()
  7986. errlog := &models.HisOrderError{
  7987. UserOrgId: adminUser.CurrentOrgId,
  7988. Ctime: time.Now().Unix(),
  7989. Mtime: time.Now().Unix(),
  7990. ErrMsg: resThree.ErrMsg,
  7991. Status: 1,
  7992. PatientId: id,
  7993. RecordTime: recordDateTime,
  7994. Stage: 2,
  7995. }
  7996. service.CreateErrMsgLog(errlog)
  7997. c.ServeSuccessJSON(map[string]interface{}{
  7998. "failed_code": -10,
  7999. "msg": resThree.ErrMsg,
  8000. })
  8001. return
  8002. }
  8003. his.Number = resThree.Output.Data.MdtrtID
  8004. his.PsnNo = resThree.Output.Data.PsnNo
  8005. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  8006. his.IdCardNo = patient.IdCardNo
  8007. his.PhoneNumber = patient.Phone
  8008. his.UserOrgId = adminInfo.CurrentOrgId
  8009. his.Insutype = insutype
  8010. his.Ctime = time.Now().Unix()
  8011. his.Mtime = time.Now().Unix()
  8012. his.InsuplcAdmdvs = insuplc_admdvs_temp
  8013. his.Status = 1
  8014. his.MdtrtGrpType = mdtrt_type
  8015. service.UpdateHisPatientStatus(&his)
  8016. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  8017. c.ServeSuccessJSON(map[string]interface{}{
  8018. "his_info": his,
  8019. })
  8020. } else {
  8021. adminUser := c.GetAdminUserInfo()
  8022. errlog := &models.HisOrderError{
  8023. UserOrgId: adminUser.CurrentOrgId,
  8024. Ctime: time.Now().Unix(),
  8025. Mtime: time.Now().Unix(),
  8026. ErrMsg: res.ErrMsg,
  8027. Status: 1,
  8028. PatientId: id,
  8029. RecordTime: recordDateTime,
  8030. Stage: 1,
  8031. }
  8032. service.CreateErrMsgLog(errlog)
  8033. c.ServeSuccessJSON(map[string]interface{}{
  8034. "failed_code": -10,
  8035. "msg": res.ErrMsg,
  8036. })
  8037. return
  8038. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8039. }
  8040. }
  8041. }
  8042. func (c *HisApiController) GetUploadInfo() {
  8043. id, _ := c.GetInt64("id")
  8044. record_time := c.GetString("record_time")
  8045. his_patient_id, _ := c.GetInt64("his_patient_id")
  8046. order_id, _ := c.GetInt64("order_id")
  8047. pay_way, _ := c.GetInt64("pay_way")
  8048. pay_ways := c.GetString("pay_ways")
  8049. oth_desc := c.GetString("oth_desc")
  8050. pay_price, _ := c.GetFloat("pay_price")
  8051. pay_card_no := c.GetString("pay_card_no")
  8052. discount_price, _ := c.GetFloat("discount_price")
  8053. preferential_price, _ := c.GetFloat("preferential_price")
  8054. reality_price, _ := c.GetFloat("reality_price")
  8055. found_price, _ := c.GetFloat("found_price")
  8056. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  8057. private_price, _ := c.GetFloat("private_price")
  8058. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8059. admin_user_id, _ := c.GetInt64("admin_user_id")
  8060. fapiao_code := c.GetString("fapiao_code")
  8061. fapiao_number := c.GetString("fapiao_number")
  8062. diagnosis_id := c.GetString("diagnosis")
  8063. sick_type, _ := c.GetInt64("sick_type")
  8064. reg_type, _ := c.GetInt64("p_type")
  8065. begin_time := c.GetString("begin_time")
  8066. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  8067. cash_pay := c.GetString("cash_pay")
  8068. band_card_pay := c.GetString("band_card_pay")
  8069. wechat_pay := c.GetString("wechat_pay")
  8070. ali_pay := c.GetString("ali_pay")
  8071. jifen_pay := c.GetString("jifen_pay")
  8072. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  8073. fmt.Println(acct_used_flag)
  8074. id_str := c.GetString("ids")
  8075. ids_arr := strings.Split(id_str, ",")
  8076. timeLayout := "2006-01-02"
  8077. loc, _ := time.LoadLocation("Local")
  8078. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8079. if err != nil {
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8081. return
  8082. }
  8083. recordDateTime := theTime.Unix()
  8084. adminUser := c.GetAdminUserInfo()
  8085. var tempOrder models.HisOrder
  8086. tempOrder, _ = service.GetHisOrderByID(order_id)
  8087. var prescriptions []*models.HisPrescription
  8088. var start_time int64
  8089. var end_time int64
  8090. //押金模块
  8091. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  8092. tmp_decimal := c.GetString("tmp_decimal")
  8093. var decimal float64 //本次使用的押金
  8094. var errmsg error
  8095. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  8096. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  8097. return
  8098. }
  8099. if len(tmp_decimal) > 0 {
  8100. if tmp_decimal[0] == 45 {
  8101. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  8102. return
  8103. }
  8104. }
  8105. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  8106. fmt.Println(errs)
  8107. decimal = tt
  8108. //if adminUser.CurrentOrgId == 10106{
  8109. // if len(fapiao_code) == 0{
  8110. // fapiao_code = "144072080589"
  8111. // }
  8112. // if len(fapiao_number) == 0{
  8113. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  8114. // if order.ID == 0{
  8115. // fapiao_number = "00001520"
  8116. // }else{
  8117. // //fapiao_code = "00001520"
  8118. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  8119. // var zero string
  8120. // if fpNumber >= 1000{
  8121. // zero = "0000" + strconv.Itoa(fpNumber)
  8122. // }else if fpNumber >= 10000{
  8123. // zero = "000" + strconv.Itoa(fpNumber)
  8124. // } else if fpNumber >= 100000{
  8125. // zero = "00" + strconv.Itoa(fpNumber)
  8126. // } else if fpNumber >= 1000000{
  8127. // zero = "0" + strconv.Itoa(fpNumber)
  8128. // }else {
  8129. // zero = strconv.Itoa(fpNumber)
  8130. // }
  8131. // fapiao_number = zero
  8132. // }
  8133. // }
  8134. //}
  8135. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8136. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8137. var patientPrescription models.HisPrescriptionInfo
  8138. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8139. if patientPrescription.ID == 0 {
  8140. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8141. }
  8142. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8143. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8144. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8145. diagnosis_ids := strings.Split(diagnosis_id, ",")
  8146. var config []*models.HisXtDiagnoseConfig
  8147. for _, item := range diagnosis_ids {
  8148. id, _ := strconv.ParseInt(item, 10, 64)
  8149. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8150. config = append(config, &diagnosisConfig)
  8151. }
  8152. sickConfig, _ := service.FindSickById(sick_type)
  8153. //if tempOrder.ID == 0 {
  8154. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  8155. //}
  8156. if tempOrder.ID == 0 {
  8157. var result string
  8158. var requestLog string
  8159. var res2 ResultSix
  8160. var ressix10265 ResultSix10265
  8161. if miConfig.MdtrtareaAdmvs == "421300" {
  8162. data := make(map[string]interface{})
  8163. client := &http.Client{}
  8164. data["psn_no"] = his.PsnNo
  8165. data["mdtrt_id"] = his.Number
  8166. data["opter"] = roles.UserName
  8167. data["org_name"] = miConfig.OrgName
  8168. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8169. data["doctor_id"] = doctor_info.DoctorNumber
  8170. data["doctor_name"] = doctor_info.UserName
  8171. data["department"] = department.Name
  8172. data["fixmedins_code"] = miConfig.Code
  8173. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8174. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8175. data["secret_key"] = miConfig.SecretKey
  8176. data["sick_code"] = sickConfig.CountryCode
  8177. data["sick_name"] = sickConfig.ClassName
  8178. data["dept"] = strconv.FormatInt(department.ID, 10)
  8179. data["config"] = config
  8180. data["begin_time"] = begin_time
  8181. bytesData, _ := json.Marshal(data)
  8182. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  8183. resp, _ := client.Do(req)
  8184. defer resp.Body.Close()
  8185. body, ioErr := ioutil.ReadAll(resp.Body)
  8186. if ioErr != nil {
  8187. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8189. return
  8190. }
  8191. var respJSON map[string]interface{}
  8192. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8195. return
  8196. }
  8197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8198. userJSONBytes, _ := json.Marshal(respJSON)
  8199. fmt.Println("log")
  8200. fmt.Println(string(userJSONBytes))
  8201. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8202. utils.ErrorLog("解析失败:%v", err)
  8203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8204. return
  8205. }
  8206. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8207. data := make(map[string]interface{})
  8208. client := &http.Client{}
  8209. data["psn_no"] = his.PsnNo
  8210. data["mdtrt_id"] = his.Number
  8211. data["doctor"] = roles.UserName
  8212. data["department"] = department.Name
  8213. data["org_name"] = miConfig.OrgName
  8214. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8215. data["doctor_id"] = doctor_info.DoctorNumber
  8216. data["new_doctor_name"] = doctor_info.UserName
  8217. data["fixmedins_code"] = miConfig.Code
  8218. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8219. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8220. data["secret_key"] = miConfig.SecretKey
  8221. data["sick_code"] = sickConfig.CountryCode
  8222. data["sick_name"] = sickConfig.ClassName
  8223. data["url"] = miConfig.Url
  8224. data["ak"] = miConfig.AccessKey
  8225. data["begin_time"] = begin_time
  8226. data["cainfo"] = miConfig.Cainfo
  8227. data["dept"] = strconv.FormatInt(department.ID, 10)
  8228. data["config"] = config
  8229. bytesData, _ := json.Marshal(data)
  8230. var req *http.Request
  8231. if miConfig.MdtrtareaAdmvs == "320921" {
  8232. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8233. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8234. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  8235. } else {
  8236. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8237. }
  8238. resp, _ := client.Do(req)
  8239. defer resp.Body.Close()
  8240. body, ioErr := ioutil.ReadAll(resp.Body)
  8241. if ioErr != nil {
  8242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8244. return
  8245. }
  8246. var respJSON map[string]interface{}
  8247. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8250. return
  8251. }
  8252. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8253. userJSONBytes, _ := json.Marshal(respJSON)
  8254. fmt.Println("log")
  8255. fmt.Println(string(userJSONBytes))
  8256. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  8257. utils.ErrorLog("解析失败:%v", err)
  8258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8259. return
  8260. }
  8261. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8262. res2.Output = ressix10265.Output
  8263. res2.ErrMsg = ressix10265.ErrMsg
  8264. res2.Cainfo = ressix10265.Cainfo
  8265. res2.WarnMsg = ressix10265.WarnMsg
  8266. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8267. res2.Infcode = infocode
  8268. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8269. result, requestLog, _ = service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8270. saveLog(result, requestLog, "2203", "上传就诊信息")
  8271. var respJSON2 map[string]interface{}
  8272. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8275. return
  8276. }
  8277. userJSONBytes2, _ := json.Marshal(respJSON2)
  8278. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8279. utils.ErrorLog("解析失败:%v", err)
  8280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8281. return
  8282. }
  8283. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8284. fmt.Println(result2)
  8285. fmt.Println(src_request)
  8286. } else {
  8287. if miConfig.MdtrtareaAdmvs == "440781" { //
  8288. 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)
  8289. } else {
  8290. if miConfig.Code == "H15049901371" {
  8291. //赤峰地区国家医保医疗类别
  8292. //职工透析:医疗类别选特殊情况门诊990502
  8293. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8294. var med_type string
  8295. if his.Insutype == "390" {
  8296. if reg_type == 14 {
  8297. med_type = "9933"
  8298. } else if reg_type == 11 {
  8299. med_type = "11"
  8300. }
  8301. } else if his.Insutype == "310" {
  8302. if reg_type == 14 {
  8303. med_type = "990502"
  8304. } else if reg_type == 11 {
  8305. med_type = "11"
  8306. }
  8307. }
  8308. 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)
  8309. } else {
  8310. 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)
  8311. }
  8312. }
  8313. saveLog(result, requestLog, "2203", "上传就诊信息")
  8314. var respJSON2 map[string]interface{}
  8315. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8318. return
  8319. }
  8320. userJSONBytes2, _ := json.Marshal(respJSON2)
  8321. if miConfig.Code == "H15049901371" {
  8322. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  8323. utils.ErrorLog("解析失败:%v", err)
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8325. return
  8326. }
  8327. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8328. res2.Output = ressix10265.Output
  8329. res2.ErrMsg = ressix10265.ErrMsg
  8330. res2.Cainfo = ressix10265.Cainfo
  8331. res2.WarnMsg = ressix10265.WarnMsg
  8332. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8333. res2.Infcode = infocode
  8334. } else {
  8335. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8336. utils.ErrorLog("解析失败:%v", err)
  8337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8338. return
  8339. }
  8340. }
  8341. }
  8342. if res2.Infcode != 0 {
  8343. adminUser := c.GetAdminUserInfo()
  8344. errlog := &models.HisOrderError{
  8345. UserOrgId: adminUser.CurrentOrgId,
  8346. Ctime: time.Now().Unix(),
  8347. Mtime: time.Now().Unix(),
  8348. ErrMsg: res2.ErrMsg,
  8349. Status: 1,
  8350. PatientId: id,
  8351. RecordTime: recordDateTime,
  8352. Stage: 3,
  8353. }
  8354. service.CreateErrMsgLog(errlog)
  8355. c.ServeSuccessJSON(map[string]interface{}{
  8356. "failed_code": -10,
  8357. "msg": res2.ErrMsg,
  8358. })
  8359. return
  8360. } else {
  8361. his.Diagnosis = diagnosis_id
  8362. his.SickType = sickConfig.ID
  8363. //var p_type int64
  8364. //if reg_type == 1111 || reg_type == 1112 {
  8365. // p_type = 11
  8366. //
  8367. //}
  8368. his.PType = fmt.Sprintf("%d", reg_type)
  8369. service.UpdateHisPatientThree(&his)
  8370. data := make(map[string]interface{})
  8371. if settle_accounts_type == 1 { //日结
  8372. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  8373. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  8374. } else {
  8375. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  8376. }
  8377. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  8378. data["pre"] = prescriptions
  8379. } else { //月结
  8380. start_time_str := c.GetString("start_time")
  8381. end_time_str := c.GetString("end_time")
  8382. timeLayout := "2006-01-02"
  8383. loc, _ := time.LoadLocation("Local")
  8384. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8385. if err != nil {
  8386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8387. return
  8388. }
  8389. recordStartTime := theStartTime.Unix()
  8390. start_time = recordStartTime
  8391. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8392. if err != nil {
  8393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8394. return
  8395. }
  8396. recordEndTime := theEndTime.Unix()
  8397. end_time = recordEndTime
  8398. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  8399. data["pre"] = prescriptions
  8400. }
  8401. timestamp := time.Now().Unix()
  8402. tempTime := time.Unix(timestamp, 0)
  8403. timeFormat := tempTime.Format("20060102150405")
  8404. chrgBchno := rand.Intn(100000) + 10000
  8405. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8406. strconv.FormatInt(his.PatientId, 10)
  8407. client := &http.Client{}
  8408. data["psn_no"] = his.PsnNo
  8409. data["mdtrt_id"] = his.Number
  8410. data["chrg_bchno"] = chrg_bchno
  8411. data["org_name"] = miConfig.OrgName
  8412. data["doctor"] = doctor_info.UserName
  8413. data["doctor_id"] = doctor_info.DoctorNumber
  8414. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8415. data["fixmedins_code"] = miConfig.Code
  8416. data["opter"] = roles.UserName
  8417. data["dept_code"] = department.Number
  8418. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8419. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8420. data["secret_key"] = miConfig.SecretKey
  8421. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  8422. data["url"] = miConfig.Url
  8423. data["ak"] = miConfig.AccessKey
  8424. data["new_doctor_name"] = patientPrescription.Doctor
  8425. data["diag_code"] = sickConfig.CountryCode
  8426. data["cainfo"] = miConfig.Cainfo
  8427. data["opter"] = roles.UserName
  8428. var ids []int64
  8429. for _, item := range prescriptions {
  8430. ids = append(ids, item.ID)
  8431. }
  8432. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8433. if config.IsOpen == 1 { //对接了医保,走医保流程
  8434. var res ResultFour
  8435. var resFour10265 ResultFour10265
  8436. if miConfig.MdtrtareaAdmvs == "421300" {
  8437. bytesData, _ := json.Marshal(data)
  8438. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  8439. resp, _ := client.Do(req)
  8440. defer resp.Body.Close()
  8441. body, ioErr := ioutil.ReadAll(resp.Body)
  8442. if ioErr != nil {
  8443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8445. return
  8446. }
  8447. var respJSON map[string]interface{}
  8448. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8451. return
  8452. }
  8453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8454. userJSONBytes, _ := json.Marshal(respJSON)
  8455. fmt.Println("log")
  8456. fmt.Println(string(userJSONBytes))
  8457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8458. utils.ErrorLog("解析失败:%v", err)
  8459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8460. return
  8461. }
  8462. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8463. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  8464. if result3101.Infcode == "0" {
  8465. if len(result3101.Output.Result) > 0 {
  8466. var errMsgs []string
  8467. for _, item := range result3101.Output.Result {
  8468. errMsgs = append(errMsgs, item.VolaCont)
  8469. }
  8470. c.ServeSuccessJSON(map[string]interface{}{
  8471. "failed_code": -10,
  8472. "msg": errMsgs,
  8473. })
  8474. return
  8475. }
  8476. }
  8477. if miConfig.MdtrtareaAdmvs == "320921" {
  8478. data["doctor_id"] = "D320923012139"
  8479. } else {
  8480. data["doctor_id"] = "D371621008686"
  8481. }
  8482. bytesData, _ := json.Marshal(data)
  8483. var req *http.Request
  8484. if miConfig.MdtrtareaAdmvs == "320921" {
  8485. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8486. } else {
  8487. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8488. }
  8489. resp, _ := client.Do(req)
  8490. defer resp.Body.Close()
  8491. body, ioErr := ioutil.ReadAll(resp.Body)
  8492. if ioErr != nil {
  8493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8495. return
  8496. }
  8497. var respJSON map[string]interface{}
  8498. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8501. return
  8502. }
  8503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8504. userJSONBytes, _ := json.Marshal(respJSON)
  8505. fmt.Println("log")
  8506. fmt.Println(string(userJSONBytes))
  8507. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8508. utils.ErrorLog("解析失败:%v", err)
  8509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8510. return
  8511. }
  8512. res.InfRefmsgid = resFour10265.InfRefmsgid
  8513. res.Output = resFour10265.Output
  8514. res.ErrMsg = resFour10265.ErrMsg
  8515. res.Cainfo = resFour10265.Cainfo
  8516. res.WarnMsg = resFour10265.WarnMsg
  8517. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8518. res.Infcode = infocode
  8519. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8520. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  8521. var dat map[string]interface{}
  8522. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8523. fmt.Println(dat)
  8524. } else {
  8525. fmt.Println(err)
  8526. }
  8527. saveLog(result, request_log, "2204", "上传费用明细")
  8528. userJSONBytes, _ := json.Marshal(dat)
  8529. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8530. utils.ErrorLog("解析失败:%v", err)
  8531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8532. return
  8533. }
  8534. res.InfRefmsgid = resFour10265.InfRefmsgid
  8535. res.Output = resFour10265.Output
  8536. res.ErrMsg = resFour10265.ErrMsg
  8537. res.Cainfo = resFour10265.Cainfo
  8538. res.WarnMsg = resFour10265.WarnMsg
  8539. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8540. res.Infcode = infocode
  8541. } else {
  8542. if miConfig.Code == "H15049901371" {
  8543. 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)
  8544. var dat map[string]interface{}
  8545. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8546. fmt.Println(dat)
  8547. } else {
  8548. fmt.Println(err)
  8549. }
  8550. saveLog(result, request_log, "2204", "上传费用明细")
  8551. userJSONBytes, _ := json.Marshal(dat)
  8552. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8553. utils.ErrorLog("解析失败:%v", err)
  8554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8555. return
  8556. }
  8557. res.InfRefmsgid = resFour10265.InfRefmsgid
  8558. res.Output = resFour10265.Output
  8559. res.ErrMsg = resFour10265.ErrMsg
  8560. res.Cainfo = resFour10265.Cainfo
  8561. res.WarnMsg = resFour10265.WarnMsg
  8562. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8563. res.Infcode = infocode
  8564. } else {
  8565. 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)
  8566. var dat map[string]interface{}
  8567. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8568. fmt.Println(dat)
  8569. } else {
  8570. fmt.Println(err)
  8571. }
  8572. saveLog(result, request_log, "2204", "上传费用明细")
  8573. userJSONBytes, _ := json.Marshal(dat)
  8574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8575. utils.ErrorLog("解析失败:%v", err)
  8576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8577. return
  8578. }
  8579. }
  8580. }
  8581. if res.Infcode == 0 {
  8582. order := &models.HisOrder{
  8583. UserOrgId: adminUser.CurrentOrgId,
  8584. HisPatientId: his.ID,
  8585. PatientId: his.PatientId,
  8586. SettleAccountsDate: recordDateTime,
  8587. MdtrtId: his.Number,
  8588. PsnNo: his.PsnNo,
  8589. MedType: strconv.FormatInt(reg_type, 10),
  8590. Ctime: time.Now().Unix(),
  8591. Mtime: time.Now().Unix(),
  8592. Status: 1,
  8593. Number: chrg_bchno,
  8594. Infcode: res.Infcode,
  8595. WarnMsg: res.WarnMsg,
  8596. Cainfo: res.Cainfo,
  8597. ErrMsg: res.ErrMsg,
  8598. RespondTime: res.RefmsgTime,
  8599. InfRefmsgid: res.InfRefmsgid,
  8600. OrderStatus: 1,
  8601. PayWay: pay_way,
  8602. PayWays: pay_ways,
  8603. OthDesc: oth_desc,
  8604. PayPrice: pay_price,
  8605. PayCardNo: pay_card_no,
  8606. DiscountPrice: discount_price,
  8607. PreferentialPrice: preferential_price,
  8608. RealityPrice: reality_price,
  8609. FoundPrice: found_price,
  8610. MedicalInsurancePrice: medical_insurance_price,
  8611. PrivatePrice: private_price,
  8612. IsMedicineInsurance: 1,
  8613. SettleType: settle_accounts_type,
  8614. SettleStartTime: start_time,
  8615. SettleEndTime: end_time,
  8616. Creator: roles.AdminUserId,
  8617. Modify: roles.AdminUserId,
  8618. FaPiaoNumber: fapiao_number,
  8619. FaPiaoCode: fapiao_code,
  8620. PType: 2,
  8621. Diagnosis: diagnosis_id,
  8622. CashPay: cash_pay,
  8623. WechatPay: wechat_pay,
  8624. AliPay: ali_pay,
  8625. JifenPay: jifen_pay,
  8626. BandCardPay: band_card_pay,
  8627. }
  8628. err = service.CreateOrder(order)
  8629. if err != nil {
  8630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8631. return
  8632. }
  8633. for _, item := range res.Output.Result {
  8634. temp := strings.Split(item.FeedetlSn, "-")
  8635. var advice_id int64 = 0
  8636. var project_id int64 = 0
  8637. var types int64 = 0
  8638. id, _ := strconv.ParseInt(temp[2], 10, 64)
  8639. types, _ = strconv.ParseInt(temp[1], 10, 64)
  8640. if temp[1] == "1" {
  8641. advice_id = id
  8642. project_id = 0
  8643. } else if temp[1] == "2" {
  8644. advice_id = 0
  8645. project_id = id
  8646. }
  8647. if item.MedChrgitmType == "9" {
  8648. item.MedChrgitmType = "09"
  8649. }
  8650. info := &models.HisOrderInfo{
  8651. OrderNumber: order.Number,
  8652. FeedetlSn: item.FeedetlSn,
  8653. UploadDate: time.Now().Unix(),
  8654. AdviceId: advice_id,
  8655. DetItemFeeSumamt: item.DetItemFeeSumamt,
  8656. Cnt: item.Cnt,
  8657. Pric: float64(item.Pric),
  8658. PatientId: his.PatientId,
  8659. PricUplmtAmt: item.PricUplmtAmt,
  8660. SelfpayProp: item.SelfpayProp,
  8661. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8662. OverlmtAmt: item.OverlmtAmt,
  8663. PreselfpayAmt: item.PreselfpayAmt,
  8664. BasMednFlag: item.BasMednFlag,
  8665. MedChrgitmType: item.MedChrgitmType,
  8666. HiNegoDrugFlag: item.HiNegoDrugFlag,
  8667. Status: 1,
  8668. Memo: item.Memo,
  8669. Mtime: time.Now().Unix(),
  8670. InscpScpAmt: item.InscpScpAmt,
  8671. DrtReimFlag: item.DrtReimFlag,
  8672. Ctime: time.Now().Unix(),
  8673. ListSpItemFlag: item.ListSpItemFlag,
  8674. ChldMedcFlag: item.ChldMedcFlag,
  8675. LmtUsedFlag: item.LmtUsedFlag,
  8676. ChrgitmLv: item.ChrgitmLv,
  8677. UserOrgId: adminUser.CurrentOrgId,
  8678. HisPatientId: his.ID,
  8679. OrderId: order.ID,
  8680. ProjectId: project_id,
  8681. Type: types,
  8682. }
  8683. service.CreateOrderInfo(info)
  8684. }
  8685. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8686. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  8687. var total float64
  8688. for _, item := range prescriptions {
  8689. if item.Type == 1 { //药品
  8690. for _, subItem := range item.HisDoctorAdviceInfo {
  8691. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  8692. total_one := price * subItem.PrescribingNumber
  8693. total = total + total_one
  8694. }
  8695. }
  8696. if item.Type == 2 { //项目
  8697. for _, subItem := range item.HisPrescriptionProject {
  8698. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8699. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  8700. total_one := price * cnt
  8701. total = total + total_one
  8702. }
  8703. }
  8704. }
  8705. allTotal := fmt.Sprintf("%f", total)
  8706. //if adminUser.CurrentOrgId == 9919 {
  8707. //
  8708. // allTotal = fmt.Sprintf("%.2f", total)
  8709. //
  8710. //} else {
  8711. //
  8712. // allTotal = fmt.Sprintf("%.2f", total)
  8713. //
  8714. //}
  8715. if res.Infcode == 0 {
  8716. var rf []*ResultFive
  8717. json.Unmarshal([]byte(his.Iinfo), &rf)
  8718. chrg_bchno := chrg_bchno
  8719. cert_no := his.Certno
  8720. var insutypes []string
  8721. var insutype string
  8722. var is390 int = 0
  8723. var is310 int = 0
  8724. for _, item := range rf {
  8725. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8726. insutypes = append(insutypes, item.Insutype)
  8727. }
  8728. }
  8729. if len(insutypes) == 1 {
  8730. insutype = insutypes[0]
  8731. } else {
  8732. for _, i := range insutypes {
  8733. if i == "390" {
  8734. is390 = 1
  8735. }
  8736. if i == "310" {
  8737. is310 = 1
  8738. }
  8739. }
  8740. }
  8741. if is390 == 1 {
  8742. insutype = "390"
  8743. }
  8744. if is310 == 1 {
  8745. insutype = "310"
  8746. }
  8747. if len(insutypes) == 0 {
  8748. insutype = "310"
  8749. }
  8750. if len(insutypes) == 2 {
  8751. insutype = strconv.FormatInt(his.SocialType, 10)
  8752. }
  8753. insutype = strconv.FormatInt(his.SocialType, 10)
  8754. //insutype = "390"
  8755. if his.IdCardType == 1 {
  8756. // cert_no = his.MedicalInsuranceNumber
  8757. cert_no = his.Certno
  8758. } else {
  8759. cert_no = his.Certno
  8760. }
  8761. var res ResultSeven
  8762. var resSeven10265 ResultSeven10265
  8763. var src_resquest string
  8764. var result2 string
  8765. if miConfig.MdtrtareaAdmvs == "421300" {
  8766. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8767. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8768. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8769. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8770. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8771. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8772. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8773. resp, requestErr := http.Get(api)
  8774. if requestErr != nil {
  8775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8776. return
  8777. }
  8778. body, ioErr := ioutil.ReadAll(resp.Body)
  8779. if ioErr != nil {
  8780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8782. return
  8783. }
  8784. var respJSON map[string]interface{}
  8785. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8788. return
  8789. }
  8790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8791. result, _ := json.Marshal(respJSON)
  8792. if miConfig.Code == "H15049901371" {
  8793. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8794. utils.ErrorLog("解析失败:%v", err)
  8795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8796. return
  8797. }
  8798. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8799. res.Output = resSeven10265.Output
  8800. res.ErrMsg = resSeven10265.ErrMsg
  8801. res.Cainfo = resSeven10265.Cainfo
  8802. res.WarnMsg = resSeven10265.WarnMsg
  8803. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8804. res.Infcode = infocode
  8805. } else {
  8806. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8807. utils.ErrorLog("解析失败:%v", err)
  8808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8809. return
  8810. }
  8811. }
  8812. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8813. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  8814. if result3101.Infcode == "0" {
  8815. if len(result3101.Output.Result) > 0 {
  8816. var errMsgs []string
  8817. for _, item := range result3101.Output.Result {
  8818. errMsgs = append(errMsgs, item.VolaCont)
  8819. }
  8820. c.ServeSuccessJSON(map[string]interface{}{
  8821. "failed_code": -10,
  8822. "msg": errMsgs,
  8823. })
  8824. return
  8825. } else {
  8826. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8827. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8828. bas := strings.Split(psn_info.CardInfo, "|")
  8829. if his.IdCardType == 1 {
  8830. cert_no = bas[2]
  8831. } else if his.IdCardType == 3 {
  8832. cert_no = his.Certno
  8833. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8834. } else if his.IdCardType == 4 {
  8835. cert_no = his.Certno
  8836. psn_info.VerifyNumber = psn_info.VerifyNumber
  8837. }
  8838. var api string
  8839. if miConfig.MdtrtareaAdmvs == "320921" {
  8840. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8841. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8842. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8843. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8844. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8845. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8846. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  8847. } else {
  8848. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8849. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8850. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8851. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8852. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8853. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8854. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  8855. }
  8856. resp, requestErr := http.Get(api)
  8857. if requestErr != nil {
  8858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8859. return
  8860. }
  8861. body, ioErr := ioutil.ReadAll(resp.Body)
  8862. if ioErr != nil {
  8863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8865. return
  8866. }
  8867. var respJSON map[string]interface{}
  8868. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8871. return
  8872. }
  8873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8874. result, _ := json.Marshal(respJSON)
  8875. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8876. utils.ErrorLog("解析失败:%v", err)
  8877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8878. return
  8879. }
  8880. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8881. res.Output = resSeven10265.Output
  8882. res.ErrMsg = resSeven10265.ErrMsg
  8883. res.Cainfo = resSeven10265.Cainfo
  8884. res.WarnMsg = resSeven10265.WarnMsg
  8885. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8886. res.Infcode = infocode
  8887. }
  8888. }
  8889. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8890. var cert_no string
  8891. if his.IdCardType == 4 {
  8892. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8893. cert_no = psn_info.VerifyNumber
  8894. result2, src_resquest, _ = service.FJyb2207ForToken(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8895. } else if his.IdCardType == 1 {
  8896. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8897. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8898. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8899. }
  8900. //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)
  8901. var dat map[string]interface{}
  8902. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8903. fmt.Println(dat)
  8904. } else {
  8905. fmt.Println(err)
  8906. }
  8907. saveLog(result2, src_resquest, "2207", "结算")
  8908. userJSONBytes, _ := json.Marshal(dat)
  8909. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8910. utils.ErrorLog("解析失败:%v", err)
  8911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8912. return
  8913. }
  8914. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8915. res.Output = resSeven10265.Output
  8916. res.ErrMsg = resSeven10265.ErrMsg
  8917. res.Cainfo = resSeven10265.Cainfo
  8918. res.WarnMsg = resSeven10265.WarnMsg
  8919. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8920. res.Infcode = infocode
  8921. } else {
  8922. if miConfig.Code == "H15049901371" {
  8923. //赤峰地区国家医保医疗类别
  8924. //职工透析:医疗类别选特殊情况门诊990502
  8925. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8926. var med_type string
  8927. if his.Insutype == "390" {
  8928. if reg_type == 14 {
  8929. med_type = "9933"
  8930. } else if reg_type == 11 {
  8931. med_type = "11"
  8932. }
  8933. } else if his.Insutype == "310" {
  8934. if reg_type == 14 {
  8935. med_type = "990502"
  8936. } else if reg_type == 11 {
  8937. med_type = "11"
  8938. }
  8939. }
  8940. 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, "")
  8941. } else {
  8942. if his.IdCardType == 4 {
  8943. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8944. var token string
  8945. token = psn_info.VerifyNumber
  8946. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token)
  8947. } else {
  8948. 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, "")
  8949. }
  8950. }
  8951. //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)
  8952. var dat map[string]interface{}
  8953. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8954. fmt.Println(dat)
  8955. } else {
  8956. fmt.Println(err)
  8957. }
  8958. saveLog(result2, src_resquest, "2207", "结算")
  8959. userJSONBytes, _ := json.Marshal(dat)
  8960. if miConfig.Code == "H15049901371" {
  8961. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8962. utils.ErrorLog("解析失败:%v", err)
  8963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8964. return
  8965. }
  8966. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8967. res.Output = resSeven10265.Output
  8968. res.ErrMsg = resSeven10265.ErrMsg
  8969. res.Cainfo = resSeven10265.Cainfo
  8970. res.WarnMsg = resSeven10265.WarnMsg
  8971. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8972. res.Infcode = infocode
  8973. } else {
  8974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8975. utils.ErrorLog("解析失败:%v", err)
  8976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8977. return
  8978. }
  8979. }
  8980. }
  8981. if res.Infcode != 0 {
  8982. errlog := &models.HisOrderError{
  8983. UserOrgId: adminUser.CurrentOrgId,
  8984. Ctime: time.Now().Unix(),
  8985. Mtime: time.Now().Unix(),
  8986. Number: chrg_bchno,
  8987. ErrMsg: res.ErrMsg,
  8988. Status: 1,
  8989. PatientId: id,
  8990. RecordTime: recordDateTime,
  8991. Stage: 6,
  8992. }
  8993. service.CreateErrMsgLog(errlog)
  8994. c.ServeSuccessJSON(map[string]interface{}{
  8995. "failed_code": -10,
  8996. "msg": res.ErrMsg,
  8997. })
  8998. return
  8999. } else {
  9000. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9001. order.OrderStatus = 2
  9002. order.Status = 1
  9003. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9004. order.SetlId = res.Output.Setlinfo.SetlID
  9005. order.PsnNo = res.Output.Setlinfo.PsnNo
  9006. order.PsnName = res.Output.Setlinfo.PsnName
  9007. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9008. order.Certno = res.Output.Setlinfo.Certno
  9009. order.Gend = res.Output.Setlinfo.Gend
  9010. order.Naty = res.Output.Setlinfo.Naty
  9011. order.Age = res.Output.Setlinfo.Age
  9012. order.Insutype = res.Output.Setlinfo.Insutype
  9013. order.PsnType = res.Output.Setlinfo.PsnType
  9014. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9015. order.SetlTime = res.Output.Setlinfo.SetlTime
  9016. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9017. if res.Output.Setlinfo.MedType == "140101" {
  9018. order.MedType = "14"
  9019. } else {
  9020. order.MedType = res.Output.Setlinfo.MedType
  9021. }
  9022. if reg_type == 1112 {
  9023. order.MedType = "1112"
  9024. }
  9025. if reg_type == 1111 {
  9026. order.MedType = "1111"
  9027. }
  9028. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9029. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9030. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9031. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9032. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9033. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9034. order.HifpPay = res.Output.Setlinfo.HifpPay
  9035. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9036. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9037. order.HifesPay = res.Output.Setlinfo.HifesPay
  9038. order.HifobPay = res.Output.Setlinfo.HifobPay
  9039. order.MafPay = res.Output.Setlinfo.MafPay
  9040. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9041. order.OthPay = res.Output.Setlinfo.OthPay
  9042. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9043. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9044. order.AcctPay = res.Output.Setlinfo.AcctPay
  9045. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9046. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9047. order.Balc = res.Output.Setlinfo.Balc
  9048. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9049. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9050. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9051. order.ClrType = res.Output.Setlinfo.ClrType
  9052. order.ClrWay = res.Output.Setlinfo.ClrWay
  9053. order.Creator = order.Creator
  9054. order.Modify = roles.AdminUserId
  9055. order.RequestLog = src_resquest
  9056. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9057. detailStr := string(setlDetail)
  9058. order.SetlDetail = detailStr
  9059. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9060. err = service.UpDateOrder(order)
  9061. if err == nil {
  9062. //判断是否使用了押金
  9063. if dec_way == "true" {
  9064. tmpstring := strconv.FormatInt(order.ID, 10)
  9065. order.Decimal = decimal
  9066. service.UpDateOrder(order)
  9067. //扣押金
  9068. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9069. if errmsg != nil {
  9070. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9071. return
  9072. }
  9073. }
  9074. c.ServeSuccessJSON(map[string]interface{}{
  9075. "msg": "结算成功",
  9076. })
  9077. } else {
  9078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9079. return
  9080. }
  9081. }
  9082. } else {
  9083. adminUser := c.GetAdminUserInfo()
  9084. errlog := &models.HisOrderError{
  9085. UserOrgId: adminUser.CurrentOrgId,
  9086. Ctime: time.Now().Unix(),
  9087. Mtime: time.Now().Unix(),
  9088. ErrMsg: res.ErrMsg,
  9089. Status: 1,
  9090. PatientId: id,
  9091. RecordTime: recordDateTime,
  9092. Stage: 4,
  9093. }
  9094. service.CreateErrMsgLog(errlog)
  9095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9096. return
  9097. }
  9098. } else {
  9099. adminUser := c.GetAdminUserInfo()
  9100. errlog := &models.HisOrderError{
  9101. UserOrgId: adminUser.CurrentOrgId,
  9102. Ctime: time.Now().Unix(),
  9103. Mtime: time.Now().Unix(),
  9104. ErrMsg: res.ErrMsg,
  9105. Status: 1,
  9106. PatientId: id,
  9107. RecordTime: recordDateTime,
  9108. Stage: 4,
  9109. }
  9110. service.CreateErrMsgLog(errlog)
  9111. c.ServeSuccessJSON(map[string]interface{}{
  9112. "failed_code": -10,
  9113. "msg": res.ErrMsg,
  9114. })
  9115. return
  9116. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9117. //return
  9118. }
  9119. }
  9120. }
  9121. } else if tempOrder.ID > 0 {
  9122. if tempOrder.IsPre == 1 {
  9123. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  9124. var rf []*ResultFive
  9125. json.Unmarshal([]byte(his.Iinfo), &rf)
  9126. chrg_bchno := tempOrder.Number
  9127. cert_no := his.Certno
  9128. var insutypes []string
  9129. var insutype string
  9130. var is390 int = 0
  9131. var is310 int = 0
  9132. for _, item := range rf {
  9133. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9134. insutypes = append(insutypes, item.Insutype)
  9135. }
  9136. }
  9137. if len(insutypes) == 1 {
  9138. insutype = insutypes[0]
  9139. } else {
  9140. for _, i := range insutypes {
  9141. if i == "390" {
  9142. is390 = 1
  9143. }
  9144. if i == "310" {
  9145. is310 = 1
  9146. }
  9147. }
  9148. }
  9149. if is390 == 1 {
  9150. insutype = "390"
  9151. }
  9152. if is310 == 1 {
  9153. insutype = "310"
  9154. }
  9155. if len(insutypes) == 0 {
  9156. insutype = "310"
  9157. }
  9158. if len(insutypes) == 2 {
  9159. insutype = strconv.FormatInt(his.SocialType, 10)
  9160. }
  9161. //insutype = "390"
  9162. if his.IdCardType == 1 {
  9163. // cert_no = his.MedicalInsuranceNumber
  9164. cert_no = his.Certno
  9165. } else {
  9166. cert_no = his.Certno
  9167. }
  9168. var res ResultSeven
  9169. var resSeven10265 ResultSeven10265
  9170. var src_resquest string
  9171. var result2 string
  9172. if miConfig.MdtrtareaAdmvs == "421300" {
  9173. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9174. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9175. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9176. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9177. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9178. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9179. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  9180. resp, requestErr := http.Get(api)
  9181. if requestErr != nil {
  9182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9183. return
  9184. }
  9185. body, ioErr := ioutil.ReadAll(resp.Body)
  9186. if ioErr != nil {
  9187. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9189. return
  9190. }
  9191. var respJSON map[string]interface{}
  9192. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9195. return
  9196. }
  9197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9198. result, _ := json.Marshal(respJSON)
  9199. fmt.Println("log")
  9200. fmt.Println(string(result))
  9201. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9202. utils.ErrorLog("解析失败:%v", err)
  9203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9204. return
  9205. }
  9206. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9207. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  9208. if result3101.Infcode == "0" {
  9209. if len(result3101.Output.Result) > 0 {
  9210. var errMsgs []string
  9211. for _, item := range result3101.Output.Result {
  9212. errMsgs = append(errMsgs, item.VolaCont)
  9213. }
  9214. c.ServeSuccessJSON(map[string]interface{}{
  9215. "failed_code": -10,
  9216. "msg": errMsgs,
  9217. })
  9218. return
  9219. } else {
  9220. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9221. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9222. bas := strings.Split(psn_info.CardInfo, "|")
  9223. if his.IdCardType == 1 {
  9224. cert_no = bas[2]
  9225. } else if his.IdCardType == 3 {
  9226. cert_no = his.Certno
  9227. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  9228. } else if his.IdCardType == 4 {
  9229. cert_no = his.Certno
  9230. psn_info.VerifyNumber = psn_info.VerifyNumber
  9231. }
  9232. //江苏地区国家医保医疗类别
  9233. //职工透析:医疗类别选特殊情况门诊9933
  9234. //居民血透门慢: 医疗类别选门诊慢病1402
  9235. //var med_type string
  9236. //if his.Insutype == "310" {
  9237. // if reg_type == 14 {
  9238. // med_type = "9933"
  9239. // } else if reg_type == 11 {
  9240. // med_type = "11"
  9241. //
  9242. // }
  9243. //} else if his.Insutype == "390" {
  9244. // if reg_type == 14 {
  9245. // med_type = "1402"
  9246. // } else if reg_type == 11 {
  9247. // med_type = "11"
  9248. // }
  9249. //}
  9250. var api string
  9251. if miConfig.MdtrtareaAdmvs == "320921" {
  9252. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9253. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9254. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9255. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9256. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9257. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9258. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9259. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9260. } else {
  9261. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9262. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9263. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9264. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9265. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9266. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9267. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9268. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9269. }
  9270. resp, requestErr := http.Get(api)
  9271. if requestErr != nil {
  9272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9273. return
  9274. }
  9275. body, ioErr := ioutil.ReadAll(resp.Body)
  9276. if ioErr != nil {
  9277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9279. return
  9280. }
  9281. var respJSON map[string]interface{}
  9282. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9285. return
  9286. }
  9287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9288. result, _ := json.Marshal(respJSON)
  9289. fmt.Println("log")
  9290. fmt.Println(string(result))
  9291. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9292. utils.ErrorLog("解析失败:%v", err)
  9293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9294. return
  9295. }
  9296. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9297. res.Output = resSeven10265.Output
  9298. res.ErrMsg = resSeven10265.ErrMsg
  9299. res.Cainfo = resSeven10265.Cainfo
  9300. res.WarnMsg = resSeven10265.WarnMsg
  9301. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9302. res.Infcode = infocode
  9303. }
  9304. }
  9305. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9306. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9307. var cert_no string
  9308. if his.IdCardType == 1 {
  9309. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9310. } else {
  9311. cert_no = psn_info.VerifyNumber
  9312. }
  9313. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9314. var dat map[string]interface{}
  9315. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9316. fmt.Println(dat)
  9317. } else {
  9318. fmt.Println(err)
  9319. }
  9320. saveLog(result2, src_resquest, "2207", "结算")
  9321. userJSONBytes, _ := json.Marshal(dat)
  9322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9323. utils.ErrorLog("解析失败:%v", err)
  9324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9325. return
  9326. }
  9327. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9328. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9329. var cert_no string
  9330. if his.IdCardType == 1 {
  9331. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9332. } else if his.IdCardType == 2 {
  9333. cert_no = his.IdCardNo
  9334. } else {
  9335. cert_no = psn_info.VerifyNumber
  9336. }
  9337. result2, src_resquest := service.Jxyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "")
  9338. var dat map[string]interface{}
  9339. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9340. fmt.Println(dat)
  9341. } else {
  9342. fmt.Println(err)
  9343. }
  9344. saveLog(result2, src_resquest, "2207", "结算")
  9345. userJSONBytes, _ := json.Marshal(dat)
  9346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9347. utils.ErrorLog("解析失败:%v", err)
  9348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9349. return
  9350. }
  9351. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9352. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9353. var cert_no string
  9354. if his.IdCardType == 1 {
  9355. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9356. } else if his.IdCardType == 2 {
  9357. cert_no = his.IdCardNo
  9358. } else {
  9359. cert_no = psn_info.VerifyNumber
  9360. }
  9361. result2, src_resquest := service.Hnyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "")
  9362. var dat map[string]interface{}
  9363. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9364. fmt.Println(dat)
  9365. } else {
  9366. fmt.Println(err)
  9367. }
  9368. saveLog(result2, src_resquest, "2207", "结算")
  9369. userJSONBytes, _ := json.Marshal(dat)
  9370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9371. utils.ErrorLog("解析失败:%v", err)
  9372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9373. return
  9374. }
  9375. } else {
  9376. var src_resquest string
  9377. if miConfig.Code == "H15049901371" {
  9378. //赤峰地区国家医保医疗类别
  9379. //职工透析:医疗类别选特殊情况门诊990502
  9380. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9381. var med_type string
  9382. if his.Insutype == "390" {
  9383. if reg_type == 14 {
  9384. med_type = "9933"
  9385. } else if reg_type == 11 {
  9386. med_type = "11"
  9387. }
  9388. } else if his.Insutype == "310" {
  9389. if reg_type == 14 {
  9390. med_type = "990502"
  9391. } else if reg_type == 11 {
  9392. med_type = "11"
  9393. }
  9394. }
  9395. 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, "")
  9396. } else {
  9397. if his.IdCardType == 4 {
  9398. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9399. token := psn_info.VerifyNumber
  9400. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token)
  9401. } else {
  9402. 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, "")
  9403. }
  9404. }
  9405. var dat map[string]interface{}
  9406. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9407. fmt.Println(dat)
  9408. } else {
  9409. fmt.Println(err)
  9410. }
  9411. saveLog(result2, src_resquest, "2207", "结算")
  9412. userJSONBytes, _ := json.Marshal(dat)
  9413. if miConfig.Code == "H15049901371" {
  9414. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9415. utils.ErrorLog("解析失败:%v", err)
  9416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9417. return
  9418. }
  9419. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9420. res.Output = resSeven10265.Output
  9421. res.ErrMsg = resSeven10265.ErrMsg
  9422. res.Cainfo = resSeven10265.Cainfo
  9423. res.WarnMsg = resSeven10265.WarnMsg
  9424. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9425. res.Infcode = infocode
  9426. } else {
  9427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9428. utils.ErrorLog("解析失败:%v", err)
  9429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9430. return
  9431. }
  9432. }
  9433. }
  9434. if res.Infcode != 0 {
  9435. errlog := &models.HisOrderError{
  9436. UserOrgId: adminUser.CurrentOrgId,
  9437. Ctime: time.Now().Unix(),
  9438. Mtime: time.Now().Unix(),
  9439. Number: chrg_bchno,
  9440. ErrMsg: res.ErrMsg,
  9441. Status: 1,
  9442. PatientId: id,
  9443. RecordTime: recordDateTime,
  9444. Stage: 6,
  9445. }
  9446. service.CreateErrMsgLog(errlog)
  9447. c.ServeSuccessJSON(map[string]interface{}{
  9448. "failed_code": -10,
  9449. "msg": res.ErrMsg,
  9450. })
  9451. return
  9452. } else {
  9453. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9454. order.OrderStatus = 2
  9455. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9456. order.SetlId = res.Output.Setlinfo.SetlID
  9457. order.PsnNo = res.Output.Setlinfo.PsnNo
  9458. order.PsnName = res.Output.Setlinfo.PsnName
  9459. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9460. order.Certno = res.Output.Setlinfo.Certno
  9461. order.Gend = res.Output.Setlinfo.Gend
  9462. order.Naty = res.Output.Setlinfo.Naty
  9463. order.Age = res.Output.Setlinfo.Age
  9464. order.Insutype = res.Output.Setlinfo.Insutype
  9465. order.PsnType = res.Output.Setlinfo.PsnType
  9466. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9467. order.SetlTime = res.Output.Setlinfo.SetlTime
  9468. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9469. order.PayWays = pay_ways
  9470. order.AcctUsedFlag = acct_used_flag
  9471. order.WechatPay = wechat_pay
  9472. order.AliPay = ali_pay
  9473. order.JifenPay = jifen_pay
  9474. order.BandCardPay = band_card_pay
  9475. order.CashPay = cash_pay
  9476. order.OthDesc = oth_desc
  9477. //order.MedType = res.Output.Setlinfo.MedType
  9478. if reg_type == 1112 {
  9479. order.MedType = "1112"
  9480. }
  9481. if reg_type == 1111 {
  9482. order.MedType = "1111"
  9483. }
  9484. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9485. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9486. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9487. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9488. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9489. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9490. order.HifpPay = res.Output.Setlinfo.HifpPay
  9491. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9492. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9493. order.HifesPay = res.Output.Setlinfo.HifesPay
  9494. order.HifobPay = res.Output.Setlinfo.HifobPay
  9495. order.MafPay = res.Output.Setlinfo.MafPay
  9496. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9497. order.OthPay = res.Output.Setlinfo.OthPay
  9498. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9499. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9500. order.AcctPay = res.Output.Setlinfo.AcctPay
  9501. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9502. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9503. order.Balc = res.Output.Setlinfo.Balc
  9504. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9505. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9506. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9507. order.ClrWay = res.Output.Setlinfo.ClrWay
  9508. order.Creator = order.Creator
  9509. order.Modify = roles.AdminUserId
  9510. order.RequestLog = src_resquest
  9511. order.Diagnosis = diagnosis_id
  9512. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9513. detailStr := string(setlDetail)
  9514. order.SetlDetail = detailStr
  9515. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9516. err = service.UpDateOrder(order)
  9517. if err == nil {
  9518. //判断是否使用了押金
  9519. if dec_way == "true" {
  9520. tmpstring := strconv.FormatInt(order.ID, 10)
  9521. //扣押金
  9522. order.Decimal = decimal
  9523. service.UpDateOrder(order)
  9524. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9525. if errmsg != nil {
  9526. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9527. return
  9528. }
  9529. }
  9530. c.ServeSuccessJSON(map[string]interface{}{
  9531. "msg": "结算成功",
  9532. })
  9533. } else {
  9534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9535. return
  9536. }
  9537. }
  9538. }
  9539. }
  9540. }
  9541. //func (c *HisApiController) GetPreUploadInfo() {
  9542. // id, _ := c.GetInt64("id")
  9543. // record_time := c.GetString("record_time")
  9544. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9545. // admin_user_id, _ := c.GetInt64("admin_user_id")
  9546. //
  9547. // timeLayout := "2006-01-02"
  9548. // loc, _ := time.LoadLocation("Local")
  9549. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9550. // if err != nil {
  9551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9552. // return
  9553. // }
  9554. // recordDateTime := theTime.Unix()
  9555. // adminUser := c.GetAdminUserInfo()
  9556. //
  9557. // var prescriptions []*models.HisPrescription
  9558. //
  9559. // var start_time int64
  9560. // var end_time int64
  9561. //
  9562. // data := make(map[string]interface{})
  9563. // if settle_accounts_type == 1 { //日结
  9564. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  9565. // data["pre"] = prescriptions
  9566. //
  9567. // } else { //月结
  9568. // start_time_str := c.GetString("start_time")
  9569. // end_time_str := c.GetString("end_time")
  9570. // timeLayout := "2006-01-02"
  9571. // loc, _ := time.LoadLocation("Local")
  9572. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9573. // if err != nil {
  9574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9575. // return
  9576. // }
  9577. // recordStartTime := theStartTime.Unix()
  9578. // start_time = recordStartTime
  9579. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9580. // if err != nil {
  9581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9582. // return
  9583. // }
  9584. // recordEndTime := theEndTime.Unix()
  9585. // end_time = recordEndTime
  9586. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  9587. // data["pre"] = prescriptions
  9588. //
  9589. // }
  9590. //
  9591. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9592. //
  9593. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9594. // timestamp := time.Now().Unix()
  9595. // tempTime := time.Unix(timestamp, 0)
  9596. // timeFormat := tempTime.Format("20060102150405")
  9597. // chrgBchno := rand.Intn(100000) + 10000
  9598. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9599. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9600. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9601. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9602. // strconv.FormatInt(his.PatientId, 10)
  9603. // client := &http.Client{}
  9604. // data["psn_no"] = his.PsnNo
  9605. // data["mdtrt_id"] = his.Number
  9606. // data["chrg_bchno"] = chrg_bchno
  9607. // data["org_name"] = miConfig.OrgName
  9608. // data["doctor"] = roles.UserName
  9609. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  9610. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9611. // data["fixmedins_code"] = miConfig.Code
  9612. // data["dept_code"] = department.Number
  9613. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9614. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9615. // data["secret_key"] = miConfig.SecretKey
  9616. // var ids []int64
  9617. //
  9618. // for _, item := range prescriptions {
  9619. // ids = append(ids, item.ID)
  9620. // }
  9621. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9622. // if config.IsOpen == 1 { //对接了医保,走医保流程
  9623. // bytesData, _ := json.Marshal(data)
  9624. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  9625. // resp, _ := client.Do(req)
  9626. // defer resp.Body.Close()
  9627. // body, ioErr := ioutil.ReadAll(resp.Body)
  9628. // if ioErr != nil {
  9629. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9631. // return
  9632. // }
  9633. // var respJSON map[string]interface{}
  9634. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9635. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9637. // return
  9638. // }
  9639. //
  9640. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9641. // userJSONBytes, _ := json.Marshal(respJSON)
  9642. // var res ResultFour
  9643. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9644. // utils.ErrorLog("解析失败:%v", err)
  9645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9646. // return
  9647. // }
  9648. //
  9649. // if res.Infcode == 0 {
  9650. // order := &models.HisOrder{
  9651. // UserOrgId: adminUser.CurrentOrgId,
  9652. // HisPatientId: his.ID,
  9653. // PatientId: his.PatientId,
  9654. // SettleAccountsDate: recordDateTime,
  9655. // Ctime: time.Now().Unix(),
  9656. // Mtime: time.Now().Unix(),
  9657. // Status: 1,
  9658. // Number: chrg_bchno,
  9659. // Infcode: res.Infcode,
  9660. // WarnMsg: res.WarnMsg,
  9661. // Cainfo: res.Cainfo,
  9662. // ErrMsg: res.ErrMsg,
  9663. // RespondTime: res.RefmsgTime,
  9664. // InfRefmsgid: res.InfRefmsgid,
  9665. // OrderStatus: 1,
  9666. // IsMedicineInsurance: 1,
  9667. // SettleType: settle_accounts_type,
  9668. // SettleStartTime: start_time,
  9669. // SettleEndTime: end_time,
  9670. // Creator: roles.ID,
  9671. // Modify: roles.ID,
  9672. // PType: 2,
  9673. // }
  9674. // err = service.CreateOrder(order)
  9675. // if err != nil {
  9676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9677. // return
  9678. // }
  9679. //
  9680. // for _, item := range res.Output.Result {
  9681. // temp := strings.Split(item.FeedetlSn, "-")
  9682. // var advice_id int64 = 0
  9683. // var project_id int64 = 0
  9684. // var types int64 = 0
  9685. //
  9686. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  9687. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  9688. //
  9689. // if temp[1] == "1" {
  9690. // advice_id = id
  9691. // project_id = 0
  9692. // } else if temp[1] == "2" {
  9693. // advice_id = 0
  9694. // project_id = id
  9695. // }
  9696. //
  9697. // info := &models.HisOrderInfo{
  9698. // OrderNumber: order.Number,
  9699. // FeedetlSn: item.FeedetlSn,
  9700. // UploadDate: time.Now().Unix(),
  9701. // AdviceId: advice_id,
  9702. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  9703. // Cnt: item.Cnt,
  9704. // Pric: float64(item.Pric),
  9705. // PatientId: his.PatientId,
  9706. // PricUplmtAmt: item.PricUplmtAmt,
  9707. // SelfpayProp: item.SelfpayProp,
  9708. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9709. // OverlmtAmt: item.OverlmtAmt,
  9710. // PreselfpayAmt: item.PreselfpayAmt,
  9711. // BasMednFlag: item.BasMednFlag,
  9712. // MedChrgitmType: item.MedChrgitmType,
  9713. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  9714. // Status: 1,
  9715. // Memo: item.Memo,
  9716. // Mtime: time.Now().Unix(),
  9717. // InscpScpAmt: item.InscpScpAmt,
  9718. // DrtReimFlag: item.DrtReimFlag,
  9719. // Ctime: time.Now().Unix(),
  9720. // ListSpItemFlag: item.ListSpItemFlag,
  9721. // ChldMedcFlag: item.ChldMedcFlag,
  9722. // LmtUsedFlag: item.LmtUsedFlag,
  9723. // ChrgitmLv: item.ChrgitmLv,
  9724. // UserOrgId: adminUser.CurrentOrgId,
  9725. // HisPatientId: his.ID,
  9726. // OrderId: order.ID,
  9727. // ProjectId: project_id,
  9728. // Type: types,
  9729. // }
  9730. // service.CreateOrderInfo(info)
  9731. //
  9732. // }
  9733. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9734. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  9735. //
  9736. // var total float64
  9737. // for _, item := range prescriptions {
  9738. // if item.Type == 1 { //药品
  9739. // for _, subItem := range item.HisDoctorAdviceInfo {
  9740. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9741. // }
  9742. // }
  9743. // if item.Type == 2 { //项目
  9744. // for _, subItem := range item.HisPrescriptionProject {
  9745. // total = total + (subItem.Price * float64(subItem.Count))
  9746. // }
  9747. // }
  9748. // }
  9749. //
  9750. // for _, item := range prescriptions {
  9751. // for _, subItem := range item.HisAdditionalCharge {
  9752. // total = total + (subItem.Price * float64(subItem.Count))
  9753. // }
  9754. // }
  9755. //
  9756. // allTotal := fmt.Sprintf("%.2f", total)
  9757. // if res.Infcode == 0 {
  9758. // var rf []*ResultFive
  9759. // json.Unmarshal([]byte(his.Iinfo), &rf)
  9760. // psn_no := his.PsnNo
  9761. // mdtrt_id := his.Number
  9762. // chrg_bchno := chrg_bchno
  9763. // cert_no := his.Certno
  9764. // insutype := rf[0].Insutype
  9765. //
  9766. // if his.IdCardType == 1 {
  9767. // cert_no = his.MedicalInsuranceNumber
  9768. //
  9769. // } else {
  9770. //
  9771. // cert_no = his.Certno
  9772. //
  9773. // }
  9774. //
  9775. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  9776. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  9777. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  9778. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  9779. // resp, requestErr := http.Get(api)
  9780. // if requestErr != nil {
  9781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9782. // return
  9783. // }
  9784. // defer resp.Body.Close()
  9785. // body, ioErr := ioutil.ReadAll(resp.Body)
  9786. // if ioErr != nil {
  9787. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9789. // return
  9790. // }
  9791. // var respJSON map[string]interface{}
  9792. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9793. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9795. // return
  9796. // }
  9797. // fmt.Println(respJSON)
  9798. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9799. // userJSONBytes, _ := json.Marshal(respJSON)
  9800. // var res ResultSeven
  9801. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9802. // utils.ErrorLog("解析失败:%v", err)
  9803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9804. // return
  9805. // }
  9806. // if res.Infcode != 0 {
  9807. // errlog := &models.HisOrderError{
  9808. // UserOrgId: adminUser.CurrentOrgId,
  9809. // Ctime: time.Now().Unix(),
  9810. // Mtime: time.Now().Unix(),
  9811. // Number: chrg_bchno,
  9812. // ErrMsg: res.ErrMsg,
  9813. // Status: 1,
  9814. // PatientId: id,
  9815. // RecordTime: recordDateTime,
  9816. // Stage: 7,
  9817. // }
  9818. // service.CreateErrMsgLog(errlog)
  9819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9820. // return
  9821. // } else {
  9822. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9823. // order.OrderStatus = 1
  9824. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9825. // order.SetlId = res.Output.Setlinfo.SetlID
  9826. // order.PsnNo = res.Output.Setlinfo.PsnNo
  9827. // order.PsnName = res.Output.Setlinfo.PsnName
  9828. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9829. // order.Certno = res.Output.Setlinfo.Certno
  9830. // order.Gend = res.Output.Setlinfo.Gend
  9831. // order.Naty = res.Output.Setlinfo.Naty
  9832. // order.Age = res.Output.Setlinfo.Age
  9833. // order.Insutype = res.Output.Setlinfo.Insutype
  9834. // order.PsnType = res.Output.Setlinfo.PsnType
  9835. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9836. // order.SetlTime = res.Output.Setlinfo.SetlTime
  9837. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9838. // order.MedType = res.Output.Setlinfo.MedType
  9839. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9840. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9841. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9842. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9843. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9844. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9845. // order.HifpPay = res.Output.Setlinfo.HifpPay
  9846. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9847. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9848. // order.HifesPay = res.Output.Setlinfo.HifesPay
  9849. // order.HifobPay = res.Output.Setlinfo.HifobPay
  9850. // order.MafPay = res.Output.Setlinfo.MafPay
  9851. // order.OthPay = res.Output.Setlinfo.OthPay
  9852. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9853. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9854. // order.AcctPay = res.Output.Setlinfo.AcctPay
  9855. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9856. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9857. // order.Balc = res.Output.Setlinfo.Balc
  9858. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9859. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9860. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9861. // order.ClrWay = res.Output.Setlinfo.ClrWay
  9862. // order.Creator = order.Creator
  9863. // order.Modify = roles.ID
  9864. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9865. // detailStr := string(setlDetail)
  9866. // order.SetlDetail = detailStr
  9867. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9868. // err = service.UpDateOrder(order)
  9869. // if err == nil {
  9870. // c.ServeSuccessJSON(map[string]interface{}{
  9871. // "msg": "预结算成功",
  9872. // })
  9873. // } else {
  9874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9875. // return
  9876. // }
  9877. // }
  9878. // } else {
  9879. // adminUser := c.GetAdminUserInfo()
  9880. // errlog := &models.HisOrderError{
  9881. // UserOrgId: adminUser.CurrentOrgId,
  9882. // Ctime: time.Now().Unix(),
  9883. // Mtime: time.Now().Unix(),
  9884. // ErrMsg: res.ErrMsg,
  9885. // Status: 1,
  9886. // PatientId: id,
  9887. // RecordTime: recordDateTime,
  9888. // Stage: 4,
  9889. // }
  9890. // service.CreateErrMsgLog(errlog)
  9891. //
  9892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9893. // return
  9894. // }
  9895. // } else {
  9896. // adminUser := c.GetAdminUserInfo()
  9897. // errlog := &models.HisOrderError{
  9898. // UserOrgId: adminUser.CurrentOrgId,
  9899. // Ctime: time.Now().Unix(),
  9900. // Mtime: time.Now().Unix(),
  9901. // ErrMsg: res.ErrMsg,
  9902. // Status: 1,
  9903. // PatientId: id,
  9904. // RecordTime: recordDateTime,
  9905. // Stage: 4,
  9906. // }
  9907. // service.CreateErrMsgLog(errlog)
  9908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9909. // return
  9910. // }
  9911. //
  9912. // } else {
  9913. // var total float64
  9914. // for _, item := range prescriptions {
  9915. // if item.Type == 1 { //药品
  9916. // for _, subItem := range item.HisDoctorAdviceInfo {
  9917. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9918. // }
  9919. // }
  9920. // if item.Type == 2 { //项目
  9921. // for _, subItem := range item.HisPrescriptionProject {
  9922. // total = total + (subItem.Price * float64(subItem.Count))
  9923. // }
  9924. // }
  9925. //
  9926. // for _, subItem := range item.HisAdditionalCharge {
  9927. // total = total + (subItem.Price * float64(subItem.Count))
  9928. // }
  9929. // }
  9930. //
  9931. // allTotal := fmt.Sprintf("%.2f", total)
  9932. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9933. // order := &models.HisOrder{
  9934. // UserOrgId: adminUser.CurrentOrgId,
  9935. // HisPatientId: his.ID,
  9936. // PatientId: id,
  9937. // SettleAccountsDate: recordDateTime,
  9938. // Ctime: time.Now().Unix(),
  9939. // Mtime: time.Now().Unix(),
  9940. // Status: 1,
  9941. // OrderStatus: 2,
  9942. // Number: chrg_bchno,
  9943. // MedfeeSumamt: totals,
  9944. // }
  9945. // err = service.CreateOrder(order)
  9946. // if err != nil {
  9947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9948. // return
  9949. // }
  9950. //
  9951. // var customs []*Custom
  9952. // for _, item := range prescriptions {
  9953. //
  9954. // if item.Type == 1 { //药品
  9955. // for _, subItem := range item.HisDoctorAdviceInfo {
  9956. // cus := &Custom{
  9957. // AdviceId: subItem.ID,
  9958. // ProjectId: 0,
  9959. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9960. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9961. // FeedetlSn: subItem.FeedetlSn,
  9962. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9963. // MedListCodg: subItem.MedListCodg,
  9964. // Type: 1,
  9965. // }
  9966. // customs = append(customs, cus)
  9967. // }
  9968. // }
  9969. //
  9970. // if item.Type == 2 { //项目
  9971. // for _, subItem := range item.HisPrescriptionProject {
  9972. //
  9973. // cus := &Custom{
  9974. // AdviceId: 0,
  9975. // ProjectId: subItem.ID,
  9976. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  9977. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  9978. // FeedetlSn: subItem.FeedetlSn,
  9979. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  9980. // MedListCodg: subItem.MedListCodg,
  9981. // Type: 2,
  9982. // }
  9983. //
  9984. // customs = append(customs, cus)
  9985. // }
  9986. // }
  9987. //
  9988. // for _, item := range item.HisAdditionalCharge {
  9989. // cus := &Custom{
  9990. // ItemId: item.ID,
  9991. // AdviceId: 0,
  9992. // ProjectId: 0,
  9993. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  9994. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  9995. // FeedetlSn: item.FeedetlSn,
  9996. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  9997. // MedListCodg: item.XtHisAddtionConfig.Code,
  9998. // Type: 3,
  9999. // }
  10000. //
  10001. // customs = append(customs, cus)
  10002. // }
  10003. //
  10004. // }
  10005. //
  10006. // for _, item := range customs {
  10007. // var advice_id int64 = 0
  10008. // var project_id int64 = 0
  10009. // var item_id int64 = 0
  10010. //
  10011. // var types int64 = 0
  10012. //
  10013. // if item.Type == 1 {
  10014. // advice_id = item.AdviceId
  10015. // project_id = 0
  10016. // item_id = 0
  10017. // } else if item.Type == 2 {
  10018. // advice_id = 0
  10019. // item_id = 0
  10020. //
  10021. // project_id = item.ProjectId
  10022. // } else if item.Type == 3 {
  10023. // advice_id = 0
  10024. // item_id = item.ItemId
  10025. // project_id = 0
  10026. // }
  10027. //
  10028. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  10029. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  10030. // pric, _ := strconv.ParseFloat(item.Price, 32)
  10031. //
  10032. // info := &models.HisOrderInfo{
  10033. // OrderNumber: order.Number,
  10034. // UploadDate: time.Now().Unix(),
  10035. // AdviceId: advice_id,
  10036. // DetItemFeeSumamt: detItemFeeSumamt,
  10037. // Cnt: cut,
  10038. // Pric: pric,
  10039. // PatientId: id,
  10040. // Status: 1,
  10041. // Mtime: time.Now().Unix(),
  10042. // Ctime: time.Now().Unix(),
  10043. // UserOrgId: adminUser.CurrentOrgId,
  10044. // HisPatientId: his.ID,
  10045. // OrderId: order.ID,
  10046. // ProjectId: project_id,
  10047. // Type: types,
  10048. // ItemId: item_id,
  10049. // }
  10050. // service.CreateOrderInfo(info)
  10051. // }
  10052. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10053. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10054. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  10055. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10056. // if err == nil {
  10057. // c.ServeSuccessJSON(map[string]interface{}{
  10058. // "msg": "结算成功",
  10059. // })
  10060. // } else {
  10061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10062. // return
  10063. // }
  10064. // }
  10065. //}
  10066. // 上传明细-预结算-
  10067. func (c *HisApiController) GetPreUploadInfo() {
  10068. id, _ := c.GetInt64("id")
  10069. record_time := c.GetString("record_time")
  10070. his_patient_id, _ := c.GetInt64("his_patient_id")
  10071. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10072. admin_user_id, _ := c.GetInt64("admin_user_id")
  10073. diagnosis_id := c.GetString("diagnosis")
  10074. sick_type, _ := c.GetInt64("sick_type")
  10075. reg_type, _ := c.GetInt64("p_type")
  10076. begin_time := c.GetString("begin_time")
  10077. acct_used_flag := c.GetString("acct_used_flag")
  10078. id_str := c.GetString("ids")
  10079. ids_arr := strings.Split(id_str, ",")
  10080. timeLayout := "2006-01-02"
  10081. loc, _ := time.LoadLocation("Local")
  10082. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10083. if err != nil {
  10084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10085. return
  10086. }
  10087. recordDateTime := theTime.Unix()
  10088. adminUser := c.GetAdminUserInfo()
  10089. diagnosis_ids := strings.Split(diagnosis_id, ",")
  10090. var config []*models.HisXtDiagnoseConfig
  10091. for _, item := range diagnosis_ids {
  10092. id, _ := strconv.ParseInt(item, 10, 64)
  10093. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10094. config = append(config, &diagnosisConfig)
  10095. }
  10096. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10097. sickConfig, _ := service.FindSickById(sick_type)
  10098. var prescriptions []*models.HisPrescription
  10099. var start_time int64
  10100. var end_time int64
  10101. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10102. fmt.Println(his_patient_id)
  10103. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10104. timestamp := time.Now().Unix()
  10105. tempTime := time.Unix(timestamp, 0)
  10106. timeFormat := tempTime.Format("20060102150405")
  10107. chrgBchno := rand.Intn(100000) + 10000
  10108. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10109. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10110. var patientPrescription models.HisPrescriptionInfo
  10111. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10112. if patientPrescription.ID == 0 {
  10113. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10114. }
  10115. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10116. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10117. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10118. strconv.FormatInt(his.PatientId, 10)
  10119. var res2 ResultSix
  10120. var resSix10265 ResultSix10265
  10121. //var time_stamp string
  10122. if miConfig.MdtrtareaAdmvs == "421300" {
  10123. data := make(map[string]interface{})
  10124. client := &http.Client{}
  10125. data["psn_no"] = his.PsnNo
  10126. data["mdtrt_id"] = his.Number
  10127. data["department"] = department.Name
  10128. data["org_name"] = miConfig.OrgName
  10129. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10130. data["doctor_id"] = doctor_info.DoctorNumber
  10131. data["doctor_name"] = roles.UserName
  10132. data["fixmedins_code"] = miConfig.Code
  10133. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10134. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10135. data["secret_key"] = miConfig.SecretKey
  10136. data["sick_code"] = sickConfig.CountryCode
  10137. data["sick_name"] = sickConfig.ClassName
  10138. data["begin_time"] = begin_time
  10139. data["dept"] = strconv.FormatInt(department.ID, 10)
  10140. data["config"] = config
  10141. data["opter"] = roles.UserName
  10142. fmt.Println(data)
  10143. bytesData, _ := json.Marshal(data)
  10144. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  10145. resp, _ := client.Do(req)
  10146. defer resp.Body.Close()
  10147. body, ioErr := ioutil.ReadAll(resp.Body)
  10148. if ioErr != nil {
  10149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10151. return
  10152. }
  10153. var respJSON map[string]interface{}
  10154. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10157. return
  10158. }
  10159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10160. userJSONBytes, _ := json.Marshal(respJSON)
  10161. fmt.Println("log")
  10162. fmt.Println(string(userJSONBytes))
  10163. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10164. utils.ErrorLog("解析失败:%v", err)
  10165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10166. return
  10167. }
  10168. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10169. data := make(map[string]interface{})
  10170. client := &http.Client{}
  10171. data["psn_no"] = his.PsnNo
  10172. data["mdtrt_id"] = his.Number
  10173. data["doctor"] = roles.UserName
  10174. data["department"] = department.Name
  10175. data["org_name"] = miConfig.OrgName
  10176. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10177. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  10178. data["fixmedins_code"] = miConfig.Code
  10179. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10180. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10181. data["secret_key"] = miConfig.SecretKey
  10182. data["sick_code"] = sickConfig.CountryCode
  10183. data["sick_name"] = sickConfig.ClassName
  10184. data["begin_time"] = begin_time
  10185. data["dept"] = strconv.FormatInt(department.ID, 10)
  10186. data["config"] = config
  10187. data["url"] = miConfig.Url
  10188. data["ak"] = miConfig.AccessKey
  10189. data["cainfo"] = miConfig.Cainfo
  10190. bytesData, _ := json.Marshal(data)
  10191. var req *http.Request
  10192. if miConfig.MdtrtareaAdmvs == "320921" {
  10193. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10194. } else {
  10195. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10196. }
  10197. resp, _ := client.Do(req)
  10198. defer resp.Body.Close()
  10199. body, ioErr := ioutil.ReadAll(resp.Body)
  10200. if ioErr != nil {
  10201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10203. return
  10204. }
  10205. var respJSON map[string]interface{}
  10206. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10209. return
  10210. }
  10211. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  10212. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  10213. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  10214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10215. userJSONBytes, _ := json.Marshal(respJSON)
  10216. fmt.Println("log")
  10217. fmt.Println(string(userJSONBytes))
  10218. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10219. utils.ErrorLog("解析失败:%v", err)
  10220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10221. return
  10222. }
  10223. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10224. res2.Output = resSix10265.Output
  10225. res2.ErrMsg = resSix10265.ErrMsg
  10226. res2.Cainfo = resSix10265.Cainfo
  10227. res2.WarnMsg = resSix10265.WarnMsg
  10228. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10229. res2.Infcode = infocode
  10230. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10231. result, requestLog, _ := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10232. saveLog(result, requestLog, "2203", "上传就诊信息")
  10233. var respJSON2 map[string]interface{}
  10234. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10237. return
  10238. }
  10239. userJSONBytes2, _ := json.Marshal(respJSON2)
  10240. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10241. utils.ErrorLog("解析失败:%v", err)
  10242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10243. return
  10244. }
  10245. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10246. var result string
  10247. var requestLog string
  10248. result, requestLog = service.Jxyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "")
  10249. saveLog(result, requestLog, "2203", "上传就诊信息")
  10250. var respJSON2 map[string]interface{}
  10251. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10254. return
  10255. }
  10256. userJSONBytes2, _ := json.Marshal(respJSON2)
  10257. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10258. utils.ErrorLog("解析失败:%v", err)
  10259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10260. return
  10261. }
  10262. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10263. var result string
  10264. var requestLog string
  10265. result, requestLog = service.Hnyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "")
  10266. saveLog(result, requestLog, "2203", "上传就诊信息")
  10267. var respJSON2 map[string]interface{}
  10268. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10271. return
  10272. }
  10273. userJSONBytes2, _ := json.Marshal(respJSON2)
  10274. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10275. utils.ErrorLog("解析失败:%v", err)
  10276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10277. return
  10278. }
  10279. } else {
  10280. var result string
  10281. var requestLog string
  10282. if miConfig.MdtrtareaAdmvs == "440781" { //
  10283. 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)
  10284. } else {
  10285. if miConfig.Code == "H15049901371" {
  10286. //赤峰地区国家医保医疗类别
  10287. //职工透析:医疗类别选特殊情况门诊990502
  10288. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10289. var med_type string
  10290. if his.Insutype == "390" {
  10291. if reg_type == 14 {
  10292. med_type = "9933"
  10293. } else if reg_type == 11 {
  10294. med_type = "11"
  10295. }
  10296. } else if his.Insutype == "310" {
  10297. if reg_type == 14 {
  10298. med_type = "990502"
  10299. } else if reg_type == 11 {
  10300. med_type = "11"
  10301. }
  10302. }
  10303. 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)
  10304. } else {
  10305. 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)
  10306. }
  10307. saveLog(result, requestLog, "2203", "上传就诊信息")
  10308. var respJSON2 map[string]interface{}
  10309. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10312. return
  10313. }
  10314. userJSONBytes2, _ := json.Marshal(respJSON2)
  10315. if miConfig.Code == "H15049901371" {
  10316. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  10317. utils.ErrorLog("解析失败:%v", err)
  10318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10319. return
  10320. }
  10321. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10322. res2.Output = resSix10265.Output
  10323. res2.ErrMsg = resSix10265.ErrMsg
  10324. res2.Cainfo = resSix10265.Cainfo
  10325. res2.WarnMsg = resSix10265.WarnMsg
  10326. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10327. res2.Infcode = infocode
  10328. } else {
  10329. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10330. utils.ErrorLog("解析失败:%v", err)
  10331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10332. return
  10333. }
  10334. }
  10335. }
  10336. }
  10337. if res2.Infcode != 0 {
  10338. adminUser := c.GetAdminUserInfo()
  10339. errlog := &models.HisOrderError{
  10340. UserOrgId: adminUser.CurrentOrgId,
  10341. Ctime: time.Now().Unix(),
  10342. Mtime: time.Now().Unix(),
  10343. ErrMsg: res2.ErrMsg,
  10344. Status: 1,
  10345. PatientId: id,
  10346. RecordTime: recordDateTime,
  10347. Stage: 3,
  10348. }
  10349. service.CreateErrMsgLog(errlog)
  10350. c.ServeSuccessJSON(map[string]interface{}{
  10351. "failed_code": -10,
  10352. "msg": res2.ErrMsg,
  10353. })
  10354. return
  10355. } else {
  10356. his.Diagnosis = diagnosis_id
  10357. his.SickType = sickConfig.ID
  10358. his.PType = fmt.Sprintf("%d", reg_type)
  10359. service.UpdateHisPatientThree(&his)
  10360. data := make(map[string]interface{})
  10361. if settle_accounts_type == 1 { //日结
  10362. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  10363. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  10364. } else {
  10365. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  10366. }
  10367. data["pre"] = prescriptions
  10368. } else { //月结
  10369. start_time_str := c.GetString("start_time")
  10370. end_time_str := c.GetString("end_time")
  10371. timeLayout := "2006-01-02"
  10372. loc, _ := time.LoadLocation("Local")
  10373. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10374. if err != nil {
  10375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10376. return
  10377. }
  10378. recordStartTime := theStartTime.Unix()
  10379. start_time = recordStartTime
  10380. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10381. if err != nil {
  10382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10383. return
  10384. }
  10385. recordEndTime := theEndTime.Unix()
  10386. end_time = recordEndTime
  10387. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  10388. data["pre"] = prescriptions
  10389. }
  10390. client := &http.Client{}
  10391. data["psn_no"] = his.PsnNo
  10392. data["mdtrt_id"] = his.Number
  10393. data["chrg_bchno"] = chrg_bchno
  10394. data["org_name"] = miConfig.OrgName
  10395. data["doctor"] = doctor_info.UserName
  10396. data["doctor_id"] = doctor_info.DoctorNumber
  10397. data["dept"] = department.Name
  10398. data["fixmedins_code"] = miConfig.Code
  10399. data["opter"] = roles.UserName
  10400. data["dept_code"] = department.Number
  10401. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10402. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10403. data["secret_key"] = miConfig.SecretKey
  10404. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  10405. data["url"] = miConfig.Url
  10406. data["ak"] = miConfig.AccessKey
  10407. data["new_doctor_name"] = patientPrescription.Doctor
  10408. data["diag_code"] = sickConfig.CountryCode
  10409. data["cainfo"] = miConfig.Cainfo
  10410. data["opter"] = roles.UserName
  10411. var ids []int64
  10412. for _, item := range prescriptions {
  10413. ids = append(ids, item.ID)
  10414. }
  10415. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10416. if config.IsOpen == 1 { //对接了医保,走医保流程
  10417. var res ResultFour
  10418. var resFour10265 ResultFour10265
  10419. if miConfig.MdtrtareaAdmvs == "421300" {
  10420. bytesData, _ := json.Marshal(data)
  10421. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  10422. resp, _ := client.Do(req)
  10423. defer resp.Body.Close()
  10424. body, ioErr := ioutil.ReadAll(resp.Body)
  10425. if ioErr != nil {
  10426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10428. return
  10429. }
  10430. var respJSON map[string]interface{}
  10431. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10434. return
  10435. }
  10436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10437. userJSONBytes, _ := json.Marshal(respJSON)
  10438. fmt.Println("log")
  10439. fmt.Println(string(userJSONBytes))
  10440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10441. utils.ErrorLog("解析失败:%v", err)
  10442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10443. return
  10444. }
  10445. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10446. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  10447. if result3101.Infcode == "0" {
  10448. if len(result3101.Output.Result) > 0 {
  10449. var errMsgs []string
  10450. for _, item := range result3101.Output.Result {
  10451. errMsgs = append(errMsgs, item.VolaCont)
  10452. }
  10453. c.ServeSuccessJSON(map[string]interface{}{
  10454. "failed_code": -10,
  10455. "msg": errMsgs,
  10456. })
  10457. return
  10458. } else {
  10459. if miConfig.MdtrtareaAdmvs == "320921" {
  10460. data["doctor_id"] = "D320923012139"
  10461. } else {
  10462. data["doctor_id"] = "D371621008686"
  10463. }
  10464. bytesData, _ := json.Marshal(data)
  10465. var req *http.Request
  10466. if miConfig.MdtrtareaAdmvs == "320921" {
  10467. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10468. } else {
  10469. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10470. }
  10471. resp, _ := client.Do(req)
  10472. defer resp.Body.Close()
  10473. body, ioErr := ioutil.ReadAll(resp.Body)
  10474. if ioErr != nil {
  10475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10477. return
  10478. }
  10479. var respJSON map[string]interface{}
  10480. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10483. return
  10484. }
  10485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10486. userJSONBytes, _ := json.Marshal(respJSON)
  10487. fmt.Println("log")
  10488. fmt.Println(string(userJSONBytes))
  10489. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10490. utils.ErrorLog("解析失败:%v", err)
  10491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10492. return
  10493. }
  10494. res.InfRefmsgid = resFour10265.InfRefmsgid
  10495. res.Output = resFour10265.Output
  10496. res.ErrMsg = resFour10265.ErrMsg
  10497. res.Cainfo = resFour10265.Cainfo
  10498. res.WarnMsg = resFour10265.WarnMsg
  10499. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10500. res.Infcode = infocode
  10501. }
  10502. }
  10503. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10504. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  10505. var dat map[string]interface{}
  10506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10507. fmt.Println(dat)
  10508. } else {
  10509. fmt.Println(err)
  10510. }
  10511. saveLog(result, request_log, "2204", "上传费用明细")
  10512. userJSONBytes, _ := json.Marshal(dat)
  10513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10514. utils.ErrorLog("解析失败:%v", err)
  10515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10516. return
  10517. }
  10518. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10519. result, request_log := service.Jxyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  10520. var dat map[string]interface{}
  10521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10522. fmt.Println(dat)
  10523. } else {
  10524. fmt.Println(err)
  10525. }
  10526. saveLog(result, request_log, "2204", "上传费用明细")
  10527. userJSONBytes, _ := json.Marshal(dat)
  10528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10529. utils.ErrorLog("解析失败:%v", err)
  10530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10531. return
  10532. }
  10533. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10534. result, request_log := service.Hnyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  10535. var dat map[string]interface{}
  10536. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10537. fmt.Println(dat)
  10538. } else {
  10539. fmt.Println(err)
  10540. }
  10541. saveLog(result, request_log, "2204", "上传费用明细")
  10542. userJSONBytes, _ := json.Marshal(dat)
  10543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10544. utils.ErrorLog("解析失败:%v", err)
  10545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10546. return
  10547. }
  10548. } else {
  10549. if miConfig.Code == "H15049901371" {
  10550. 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)
  10551. var dat map[string]interface{}
  10552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10553. fmt.Println(dat)
  10554. } else {
  10555. fmt.Println(err)
  10556. }
  10557. saveLog(result, request_log, "2204", "上传费用明细")
  10558. userJSONBytes, _ := json.Marshal(dat)
  10559. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10560. utils.ErrorLog("解析失败:%v", err)
  10561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10562. return
  10563. }
  10564. res.InfRefmsgid = resFour10265.InfRefmsgid
  10565. res.Output = resFour10265.Output
  10566. res.ErrMsg = resFour10265.ErrMsg
  10567. res.Cainfo = resFour10265.Cainfo
  10568. res.WarnMsg = resFour10265.WarnMsg
  10569. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10570. res.Infcode = infocode
  10571. } else {
  10572. 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)
  10573. var dat map[string]interface{}
  10574. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10575. fmt.Println(dat)
  10576. } else {
  10577. fmt.Println(err)
  10578. }
  10579. saveLog(result, request_log, "2204", "上传费用明细")
  10580. userJSONBytes, _ := json.Marshal(dat)
  10581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10582. utils.ErrorLog("解析失败:%v", err)
  10583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10584. return
  10585. }
  10586. }
  10587. }
  10588. var total_two float64
  10589. if res.Infcode == 0 {
  10590. order := &models.HisOrder{
  10591. UserOrgId: adminUser.CurrentOrgId,
  10592. HisPatientId: his.ID,
  10593. PatientId: his.PatientId,
  10594. SettleAccountsDate: recordDateTime,
  10595. Ctime: time.Now().Unix(),
  10596. Mtime: time.Now().Unix(),
  10597. MdtrtId: his.Number,
  10598. PsnNo: his.PsnNo,
  10599. MedType: strconv.FormatInt(reg_type, 10),
  10600. Status: 1,
  10601. Number: chrg_bchno,
  10602. Infcode: res.Infcode,
  10603. WarnMsg: res.WarnMsg,
  10604. Cainfo: res.Cainfo,
  10605. ErrMsg: res.ErrMsg,
  10606. RespondTime: res.RefmsgTime,
  10607. InfRefmsgid: res.InfRefmsgid,
  10608. OrderStatus: 1,
  10609. IsMedicineInsurance: 1,
  10610. SettleType: settle_accounts_type,
  10611. SettleStartTime: start_time,
  10612. SettleEndTime: end_time,
  10613. Creator: roles.AdminUserId,
  10614. Modify: roles.AdminUserId,
  10615. PType: 2,
  10616. Diagnosis: diagnosis_id,
  10617. }
  10618. err = service.CreateOrder(order)
  10619. if err != nil {
  10620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10621. return
  10622. }
  10623. for _, item := range res.Output.Result {
  10624. temp := strings.Split(item.FeedetlSn, "-")
  10625. var advice_id int64 = 0
  10626. var project_id int64 = 0
  10627. var types int64 = 0
  10628. id, _ := strconv.ParseInt(temp[2], 10, 64)
  10629. types, _ = strconv.ParseInt(temp[1], 10, 64)
  10630. if temp[1] == "1" {
  10631. advice_id = id
  10632. project_id = 0
  10633. } else if temp[1] == "2" {
  10634. advice_id = 0
  10635. project_id = id
  10636. }
  10637. total_two = total_two + item.DetItemFeeSumamt
  10638. info := &models.HisOrderInfo{
  10639. OrderNumber: order.Number,
  10640. FeedetlSn: item.FeedetlSn,
  10641. UploadDate: time.Now().Unix(),
  10642. AdviceId: advice_id,
  10643. DetItemFeeSumamt: item.DetItemFeeSumamt,
  10644. Cnt: item.Cnt,
  10645. Pric: float64(item.Pric),
  10646. PatientId: his.PatientId,
  10647. PricUplmtAmt: item.PricUplmtAmt,
  10648. SelfpayProp: item.SelfpayProp,
  10649. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10650. OverlmtAmt: item.OverlmtAmt,
  10651. PreselfpayAmt: item.PreselfpayAmt,
  10652. BasMednFlag: item.BasMednFlag,
  10653. MedChrgitmType: item.MedChrgitmType,
  10654. HiNegoDrugFlag: item.HiNegoDrugFlag,
  10655. Status: 1,
  10656. Memo: item.Memo,
  10657. Mtime: time.Now().Unix(),
  10658. InscpScpAmt: item.InscpScpAmt,
  10659. DrtReimFlag: item.DrtReimFlag,
  10660. Ctime: time.Now().Unix(),
  10661. ListSpItemFlag: item.ListSpItemFlag,
  10662. ChldMedcFlag: item.ChldMedcFlag,
  10663. LmtUsedFlag: item.LmtUsedFlag,
  10664. ChrgitmLv: item.ChrgitmLv,
  10665. UserOrgId: adminUser.CurrentOrgId,
  10666. HisPatientId: his.ID,
  10667. OrderId: order.ID,
  10668. ProjectId: project_id,
  10669. Type: types,
  10670. }
  10671. service.CreateOrderInfo(info)
  10672. }
  10673. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10674. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  10675. var total float64
  10676. for _, item := range prescriptions {
  10677. if item.Type == 1 { //药品
  10678. for _, subItem := range item.HisDoctorAdviceInfo {
  10679. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10680. total_one := price * subItem.PrescribingNumber
  10681. fmt.Println("subItem")
  10682. fmt.Println(subItem.Price)
  10683. fmt.Println("price")
  10684. fmt.Println(price)
  10685. fmt.Println("total_one")
  10686. fmt.Println(total_one)
  10687. total = total + total_one
  10688. fmt.Println(total)
  10689. }
  10690. }
  10691. if item.Type == 2 { //项目
  10692. for _, subItem := range item.HisPrescriptionProject {
  10693. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10694. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10695. total_one := price * cnt
  10696. total = total + total_one
  10697. }
  10698. }
  10699. }
  10700. allTotal := fmt.Sprintf("%2f", total)
  10701. if res.Infcode == 0 {
  10702. var rf []*ResultFive
  10703. json.Unmarshal([]byte(his.Iinfo), &rf)
  10704. chrg_bchno := chrg_bchno
  10705. cert_no := his.Certno
  10706. var insutypes []string
  10707. var insutype string
  10708. var is390 int = 0
  10709. var is310 int = 0
  10710. for _, item := range rf {
  10711. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10712. insutypes = append(insutypes, item.Insutype)
  10713. }
  10714. }
  10715. if len(insutypes) == 1 {
  10716. insutype = insutypes[0]
  10717. } else {
  10718. for _, i := range insutypes {
  10719. if i == "390" {
  10720. is390 = 1
  10721. }
  10722. if i == "310" {
  10723. is310 = 1
  10724. }
  10725. }
  10726. }
  10727. if is390 == 1 {
  10728. insutype = "390"
  10729. }
  10730. if is310 == 1 {
  10731. insutype = "310"
  10732. }
  10733. if len(insutypes) == 0 {
  10734. insutype = "390"
  10735. }
  10736. if len(insutypes) == 2 {
  10737. insutype = strconv.FormatInt(his.SocialType, 10)
  10738. }
  10739. //insutype = "390"
  10740. if his.IdCardType == 1 {
  10741. cert_no = his.MedicalInsuranceNumber
  10742. } else {
  10743. cert_no = his.Certno
  10744. }
  10745. var res ResultSeven
  10746. var resSeven10265 ResultSeven10265
  10747. if miConfig.MdtrtareaAdmvs == "421300" {
  10748. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10749. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10750. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10751. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10752. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10753. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10754. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  10755. resp, requestErr := http.Get(api)
  10756. if requestErr != nil {
  10757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10758. return
  10759. }
  10760. body, ioErr := ioutil.ReadAll(resp.Body)
  10761. if ioErr != nil {
  10762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10764. return
  10765. }
  10766. var respJSON map[string]interface{}
  10767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10770. return
  10771. }
  10772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10773. result, _ := json.Marshal(respJSON)
  10774. fmt.Println("log")
  10775. fmt.Println(string(result))
  10776. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10777. utils.ErrorLog("解析失败:%v", err)
  10778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10779. return
  10780. }
  10781. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10782. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  10783. if result3101.Infcode == "0" {
  10784. if len(result3101.Output.Result) > 0 {
  10785. var errMsgs []string
  10786. for _, item := range result3101.Output.Result {
  10787. errMsgs = append(errMsgs, item.VolaCont)
  10788. }
  10789. c.ServeSuccessJSON(map[string]interface{}{
  10790. "failed_code": -10,
  10791. "msg": errMsgs,
  10792. })
  10793. return
  10794. } else {
  10795. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10796. if his.IdCardType != 4 {
  10797. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10798. bas := strings.Split(psn_info.CardInfo, "|")
  10799. if his.IdCardType == 1 {
  10800. cert_no = bas[2]
  10801. } else {
  10802. cert_no = bas[1]
  10803. }
  10804. } else {
  10805. cert_no = his.Certno
  10806. }
  10807. //江苏地区国家医保医疗类别
  10808. //职工透析:医疗类别选特殊情况门诊9933
  10809. //居民血透门慢: 医疗类别选门诊慢病1402
  10810. //var med_type string
  10811. //if his.Insutype == "310" {
  10812. // if reg_type == 14 {
  10813. // med_type = "9933"
  10814. // } else if reg_type == 11 {
  10815. // med_type = "11"
  10816. //
  10817. // }
  10818. //} else if his.Insutype == "390" {
  10819. // if reg_type == 14 {
  10820. // med_type = "1402"
  10821. // } else if reg_type == 11 {
  10822. // med_type = "11"
  10823. // }
  10824. //}
  10825. var api string
  10826. if miConfig.MdtrtareaAdmvs == "320921" {
  10827. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10828. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10829. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10830. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10831. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10832. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10833. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  10834. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10835. } else {
  10836. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10837. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10838. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10839. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10840. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10841. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10842. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10843. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10863. result, _ := json.Marshal(respJSON)
  10864. fmt.Println("log")
  10865. fmt.Println(string(result))
  10866. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10867. utils.ErrorLog("解析失败:%v", err)
  10868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10869. return
  10870. }
  10871. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10872. res.Output = resSeven10265.Output
  10873. res.ErrMsg = resSeven10265.ErrMsg
  10874. res.Cainfo = resSeven10265.Cainfo
  10875. res.WarnMsg = resSeven10265.WarnMsg
  10876. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10877. res.Infcode = infocode
  10878. }
  10879. }
  10880. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10881. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  10882. var result string
  10883. var request_log string
  10884. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10885. result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10886. } else {
  10887. result, request_log, _ = service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10888. }
  10889. var dat map[string]interface{}
  10890. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10891. fmt.Println(dat)
  10892. } else {
  10893. fmt.Println(err)
  10894. }
  10895. saveLog(result, request_log, "2206", "预结算")
  10896. userJSONBytes, _ := json.Marshal(dat)
  10897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10898. utils.ErrorLog("解析失败:%v", err)
  10899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10900. return
  10901. }
  10902. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10903. var result string
  10904. var request_log string
  10905. if his.IdCardType == 2 {
  10906. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "")
  10907. } else if his.IdCardType == 1 {
  10908. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10909. bas := strings.Split(psn_info.CardInfo, "|")
  10910. basNumber := bas[2]
  10911. card_sn := bas[3]
  10912. result, request_log = service.Jxyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  10913. } else {
  10914. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10915. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "")
  10916. }
  10917. var dat map[string]interface{}
  10918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10919. fmt.Println(dat)
  10920. } else {
  10921. fmt.Println(err)
  10922. }
  10923. saveLog(result, request_log, "2206", "预结算")
  10924. userJSONBytes, _ := json.Marshal(dat)
  10925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10926. utils.ErrorLog("解析失败:%v", err)
  10927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10928. return
  10929. }
  10930. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10931. var result string
  10932. var request_log string
  10933. if his.IdCardType == 2 {
  10934. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "", acct_used_flag)
  10935. } else if his.IdCardType == 1 {
  10936. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10937. bas := strings.Split(psn_info.CardInfo, "|")
  10938. basNumber := bas[2]
  10939. card_sn := bas[3]
  10940. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, acct_used_flag)
  10941. } else {
  10942. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10943. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", acct_used_flag)
  10944. }
  10945. var dat map[string]interface{}
  10946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10947. fmt.Println(dat)
  10948. } else {
  10949. fmt.Println(err)
  10950. }
  10951. saveLog(result, request_log, "2206", "预结算")
  10952. userJSONBytes, _ := json.Marshal(dat)
  10953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10954. utils.ErrorLog("解析失败:%v", err)
  10955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10956. return
  10957. }
  10958. } else {
  10959. var result string
  10960. var request_log string
  10961. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10962. allTotal = fmt.Sprintf("%2f", total_two)
  10963. if his.IdCardType == 4 {
  10964. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  10965. } else {
  10966. 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)
  10967. }
  10968. var dat map[string]interface{}
  10969. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10970. fmt.Println(dat)
  10971. } else {
  10972. fmt.Println(err)
  10973. }
  10974. saveLog(result, request_log, "2206", "预结算")
  10975. //userJSONBytes, _ := json.Marshal(dat)
  10976. //
  10977. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10978. // utils.ErrorLog("解析失败:%v", err)
  10979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10980. // return
  10981. //}
  10982. userJSONBytes, _ := json.Marshal(dat)
  10983. if miConfig.Code == "H15049901371" {
  10984. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10985. utils.ErrorLog("解析失败:%v", err)
  10986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10987. return
  10988. }
  10989. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10990. res.Output = resSeven10265.Output
  10991. res.ErrMsg = resSeven10265.ErrMsg
  10992. res.Cainfo = resSeven10265.Cainfo
  10993. res.WarnMsg = resSeven10265.WarnMsg
  10994. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10995. res.Infcode = infocode
  10996. } else {
  10997. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10998. utils.ErrorLog("解析失败:%v", err)
  10999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11000. return
  11001. }
  11002. }
  11003. }
  11004. if res.Infcode != 0 {
  11005. errlog := &models.HisOrderError{
  11006. UserOrgId: adminUser.CurrentOrgId,
  11007. Ctime: time.Now().Unix(),
  11008. Mtime: time.Now().Unix(),
  11009. Number: chrg_bchno,
  11010. ErrMsg: res.ErrMsg,
  11011. Status: 1,
  11012. PatientId: id,
  11013. RecordTime: recordDateTime,
  11014. Stage: 20,
  11015. }
  11016. service.CreateErrMsgLog(errlog)
  11017. c.ServeSuccessJSON(map[string]interface{}{
  11018. "failed_code": -10,
  11019. "msg": res.ErrMsg,
  11020. })
  11021. return
  11022. } else {
  11023. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11024. order.OrderStatus = 1
  11025. order.IsPre = 1
  11026. order.Status = 1
  11027. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11028. order.SetlId = res.Output.Setlinfo.SetlID
  11029. order.PsnNo = res.Output.Setlinfo.PsnNo
  11030. order.PsnName = res.Output.Setlinfo.PsnName
  11031. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11032. order.Certno = res.Output.Setlinfo.Certno
  11033. order.Gend = res.Output.Setlinfo.Gend
  11034. order.Naty = res.Output.Setlinfo.Naty
  11035. order.Age = res.Output.Setlinfo.Age
  11036. order.Insutype = res.Output.Setlinfo.Insutype
  11037. order.PsnType = res.Output.Setlinfo.PsnType
  11038. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11039. order.SetlTime = res.Output.Setlinfo.SetlTime
  11040. order.AcctUsedFlag = acct_used_flag
  11041. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11042. if res.Output.Setlinfo.MedType == "140101" {
  11043. order.MedType = "14"
  11044. } else {
  11045. order.MedType = res.Output.Setlinfo.MedType
  11046. }
  11047. if reg_type == 1112 {
  11048. order.MedType = "1112"
  11049. }
  11050. if reg_type == 1111 {
  11051. order.MedType = "1111"
  11052. }
  11053. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11054. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11055. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11056. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11057. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11058. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11059. order.HifpPay = res.Output.Setlinfo.HifpPay
  11060. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11061. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11062. order.HifesPay = res.Output.Setlinfo.HifesPay
  11063. order.HifobPay = res.Output.Setlinfo.HifobPay
  11064. order.MafPay = res.Output.Setlinfo.MafPay
  11065. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  11066. order.OthPay = res.Output.Setlinfo.OthPay
  11067. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11068. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11069. order.AcctPay = res.Output.Setlinfo.AcctPay
  11070. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11071. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11072. order.Balc = res.Output.Setlinfo.Balc
  11073. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11074. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11075. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11076. order.ClrWay = res.Output.Setlinfo.ClrWay
  11077. order.Creator = order.Creator
  11078. order.Modify = roles.AdminUserId
  11079. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11080. detailStr := string(setlDetail)
  11081. order.SetlDetail = detailStr
  11082. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11083. err = service.UpDateOrder(order)
  11084. if err == nil {
  11085. c.ServeSuccessJSON(map[string]interface{}{
  11086. "msg": "预结算成功",
  11087. })
  11088. } else {
  11089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11090. return
  11091. }
  11092. }
  11093. } else {
  11094. adminUser := c.GetAdminUserInfo()
  11095. errlog := &models.HisOrderError{
  11096. UserOrgId: adminUser.CurrentOrgId,
  11097. Ctime: time.Now().Unix(),
  11098. Mtime: time.Now().Unix(),
  11099. ErrMsg: res.ErrMsg,
  11100. Status: 1,
  11101. PatientId: id,
  11102. RecordTime: recordDateTime,
  11103. Stage: 4,
  11104. }
  11105. service.CreateErrMsgLog(errlog)
  11106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11107. return
  11108. }
  11109. } else {
  11110. adminUser := c.GetAdminUserInfo()
  11111. errlog := &models.HisOrderError{
  11112. UserOrgId: adminUser.CurrentOrgId,
  11113. Ctime: time.Now().Unix(),
  11114. Mtime: time.Now().Unix(),
  11115. ErrMsg: res.ErrMsg,
  11116. Status: 1,
  11117. PatientId: id,
  11118. RecordTime: recordDateTime,
  11119. Stage: 4,
  11120. }
  11121. service.CreateErrMsgLog(errlog)
  11122. c.ServeSuccessJSON(map[string]interface{}{
  11123. "failed_code": -10,
  11124. "msg": res.ErrMsg,
  11125. })
  11126. return
  11127. }
  11128. }
  11129. }
  11130. }
  11131. // 退款
  11132. func (c *HisApiController) Refund() {
  11133. order_id, _ := c.GetInt64("order_id")
  11134. admin_user_id, _ := c.GetInt64("admin_user_id")
  11135. adminUser := c.GetAdminUserInfo()
  11136. var order models.HisOrder
  11137. order, _ = service.GetHisOrderByID(order_id)
  11138. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11139. if order.ID == 0 {
  11140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11141. return
  11142. }
  11143. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11144. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11145. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11146. if config.IsOpen == 1 { //对接了医保,走医保流程
  11147. var res ResultSixteen
  11148. var resSixteen10265 ResultSixteen10265
  11149. var src_resquest string
  11150. var result string
  11151. if miConfig.MdtrtareaAdmvs == "421300" {
  11152. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  11153. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11155. resp3, requestErr3 := http.Get(api3)
  11156. if requestErr3 != nil {
  11157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11158. return
  11159. }
  11160. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11161. if ioErr3 != nil {
  11162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11164. return
  11165. }
  11166. var respJSON3 map[string]interface{}
  11167. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11170. return
  11171. }
  11172. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11173. userJSONBytes3, _ := json.Marshal(respJSON3)
  11174. fmt.Println("log")
  11175. fmt.Println(string(userJSONBytes3))
  11176. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  11177. utils.ErrorLog("解析失败:%v", err)
  11178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11179. return
  11180. }
  11181. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11182. var api3 string
  11183. if miConfig.MdtrtareaAdmvs == "320921" {
  11184. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11185. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11186. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11187. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11188. } else {
  11189. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11190. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11191. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11192. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11193. }
  11194. resp3, requestErr3 := http.Get(api3)
  11195. if requestErr3 != nil {
  11196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11197. return
  11198. }
  11199. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11200. if ioErr3 != nil {
  11201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11203. return
  11204. }
  11205. var respJSON3 map[string]interface{}
  11206. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11209. return
  11210. }
  11211. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11212. userJSONBytes3, _ := json.Marshal(respJSON3)
  11213. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  11214. utils.ErrorLog("解析失败:%v", err)
  11215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11216. return
  11217. }
  11218. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11219. res.Output = resSixteen10265.Output
  11220. res.ErrMsg = resSixteen10265.ErrMsg
  11221. res.Cainfo = resSixteen10265.Cainfo
  11222. res.WarnMsg = resSixteen10265.WarnMsg
  11223. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11224. res.Infcode = infocode
  11225. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11226. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11227. var dat map[string]interface{}
  11228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11229. fmt.Println(dat)
  11230. } else {
  11231. fmt.Println(err)
  11232. }
  11233. saveLog(result, src_resquest, "2208", "退费")
  11234. userJSONBytes, _ := json.Marshal(dat)
  11235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11236. utils.ErrorLog("解析失败:%v", err)
  11237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11238. return
  11239. }
  11240. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11241. result, src_resquest = service.Jxyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  11242. var dat map[string]interface{}
  11243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11244. fmt.Println(dat)
  11245. } else {
  11246. fmt.Println(err)
  11247. }
  11248. saveLog(result, src_resquest, "2208", "退费")
  11249. userJSONBytes, _ := json.Marshal(dat)
  11250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11251. utils.ErrorLog("解析失败:%v", err)
  11252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11253. return
  11254. }
  11255. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11256. result, src_resquest = service.Hnyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  11257. var dat map[string]interface{}
  11258. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11259. fmt.Println(dat)
  11260. } else {
  11261. fmt.Println(err)
  11262. }
  11263. saveLog(result, src_resquest, "2208", "退费")
  11264. userJSONBytes, _ := json.Marshal(dat)
  11265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11266. utils.ErrorLog("解析失败:%v", err)
  11267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11268. return
  11269. }
  11270. } else {
  11271. if miConfig.Code == "H15049901371" {
  11272. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11273. var dat map[string]interface{}
  11274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11275. fmt.Println(dat)
  11276. } else {
  11277. fmt.Println(err)
  11278. }
  11279. saveLog(result, src_resquest, "2208", "退费")
  11280. userJSONBytes, _ := json.Marshal(dat)
  11281. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  11282. utils.ErrorLog("解析失败:%v", err)
  11283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11284. return
  11285. }
  11286. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11287. res.Output = resSixteen10265.Output
  11288. res.ErrMsg = resSixteen10265.ErrMsg
  11289. res.Cainfo = resSixteen10265.Cainfo
  11290. res.WarnMsg = resSixteen10265.WarnMsg
  11291. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11292. res.Infcode = infocode
  11293. } else {
  11294. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11295. var dat map[string]interface{}
  11296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11297. fmt.Println(dat)
  11298. } else {
  11299. fmt.Println(err)
  11300. }
  11301. saveLog(result, src_resquest, "2208", "退费")
  11302. userJSONBytes, _ := json.Marshal(dat)
  11303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11304. utils.ErrorLog("解析失败:%v", err)
  11305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11306. return
  11307. }
  11308. }
  11309. }
  11310. if res.Infcode == 0 {
  11311. var res2 ResultSix
  11312. var resSix10265 ResultSix10265
  11313. if miConfig.MdtrtareaAdmvs == "421300" {
  11314. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11315. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11316. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11317. resp3, requestErr3 := http.Get(api3)
  11318. if requestErr3 != nil {
  11319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11320. return
  11321. }
  11322. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11323. if ioErr3 != nil {
  11324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11326. return
  11327. }
  11328. var respJSON3 map[string]interface{}
  11329. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11332. return
  11333. }
  11334. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11335. userJSONBytes3, _ := json.Marshal(respJSON3)
  11336. fmt.Println("log")
  11337. fmt.Println(string(userJSONBytes3))
  11338. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11339. utils.ErrorLog("解析失败:%v", err)
  11340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11341. return
  11342. }
  11343. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11344. var api3 string
  11345. if miConfig.MdtrtareaAdmvs == "320921" {
  11346. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11347. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11348. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11349. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11350. } else {
  11351. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11352. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11353. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11354. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11355. }
  11356. resp3, requestErr3 := http.Get(api3)
  11357. if requestErr3 != nil {
  11358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11359. return
  11360. }
  11361. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11362. if ioErr3 != nil {
  11363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11365. return
  11366. }
  11367. var respJSON3 map[string]interface{}
  11368. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11371. return
  11372. }
  11373. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11374. userJSONBytes3, _ := json.Marshal(respJSON3)
  11375. fmt.Println("log")
  11376. fmt.Println(string(userJSONBytes3))
  11377. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11378. utils.ErrorLog("解析失败:%v", err)
  11379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11380. return
  11381. }
  11382. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11383. res2.Output = resSix10265.Output
  11384. res2.ErrMsg = resSix10265.ErrMsg
  11385. res2.Cainfo = resSix10265.Cainfo
  11386. res2.WarnMsg = resSix10265.WarnMsg
  11387. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11388. res2.Infcode = infocode
  11389. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11390. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11391. var dat map[string]interface{}
  11392. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11393. fmt.Println(dat)
  11394. } else {
  11395. fmt.Println(err)
  11396. }
  11397. saveLog(result2, src_request, "2205", "撤销明细")
  11398. userJSONBytes, _ := json.Marshal(dat)
  11399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11400. utils.ErrorLog("解析失败:%v", err)
  11401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11402. return
  11403. }
  11404. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11405. result2, src_request := service.Jxyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11406. var dat map[string]interface{}
  11407. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11408. fmt.Println(dat)
  11409. } else {
  11410. fmt.Println(err)
  11411. }
  11412. saveLog(result2, src_request, "2205", "撤销明细")
  11413. userJSONBytes, _ := json.Marshal(dat)
  11414. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11415. utils.ErrorLog("解析失败:%v", err)
  11416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11417. return
  11418. }
  11419. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11420. result2, src_request := service.Hnyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11421. var dat map[string]interface{}
  11422. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11423. fmt.Println(dat)
  11424. } else {
  11425. fmt.Println(err)
  11426. }
  11427. saveLog(result2, src_request, "2205", "撤销明细")
  11428. userJSONBytes, _ := json.Marshal(dat)
  11429. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11430. utils.ErrorLog("解析失败:%v", err)
  11431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11432. return
  11433. }
  11434. } else {
  11435. if miConfig.Code == "H15049901371" {
  11436. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11437. var dat map[string]interface{}
  11438. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11439. fmt.Println(dat)
  11440. } else {
  11441. fmt.Println(err)
  11442. }
  11443. saveLog(result2, src_request, "2205", "撤销明细")
  11444. userJSONBytes, _ := json.Marshal(dat)
  11445. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11446. utils.ErrorLog("解析失败:%v", err)
  11447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11448. return
  11449. }
  11450. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11451. res2.Output = resSix10265.Output
  11452. res2.ErrMsg = resSix10265.ErrMsg
  11453. res2.Cainfo = resSix10265.Cainfo
  11454. res2.WarnMsg = resSix10265.WarnMsg
  11455. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11456. res2.Infcode = infocode
  11457. } else {
  11458. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11459. var dat map[string]interface{}
  11460. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11461. fmt.Println(dat)
  11462. } else {
  11463. fmt.Println(err)
  11464. }
  11465. saveLog(result2, src_request, "2205", "撤销明细")
  11466. userJSONBytes, _ := json.Marshal(dat)
  11467. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11468. utils.ErrorLog("解析失败:%v", err)
  11469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11470. return
  11471. }
  11472. }
  11473. }
  11474. if res2.Infcode == 0 {
  11475. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  11476. if err == nil {
  11477. //当押金不为零时产生退费记录
  11478. if order.Decimal != 0 {
  11479. tmp := strconv.FormatInt(order.ID, 10)
  11480. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  11481. if err != nil {
  11482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11483. return
  11484. }
  11485. }
  11486. c.ServeSuccessJSON(map[string]interface{}{
  11487. "msg": "退费成功",
  11488. })
  11489. } else {
  11490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11491. return
  11492. }
  11493. } else {
  11494. c.ServeSuccessJSON(map[string]interface{}{
  11495. "code": -10,
  11496. "msg": res2.ErrMsg,
  11497. })
  11498. }
  11499. } else {
  11500. c.ServeSuccessJSON(map[string]interface{}{
  11501. "code": -10,
  11502. "msg": res.ErrMsg,
  11503. })
  11504. }
  11505. }
  11506. }
  11507. func (c *HisApiController) RefundNumber() {
  11508. record_time := c.GetString("record_time")
  11509. //patient_id, _ := c.GetInt64("patient_id")
  11510. admin_user_id, _ := c.GetInt64("admin_user_id")
  11511. his_patient_id, _ := c.GetInt64("id")
  11512. timeLayout := "2006-01-02"
  11513. loc, _ := time.LoadLocation("Local")
  11514. adminUser := c.GetAdminUserInfo()
  11515. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11516. fmt.Println(err)
  11517. if err != nil {
  11518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11519. return
  11520. }
  11521. recordDateTime := theTime.Unix()
  11522. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11523. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  11524. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11525. //order, _ := service.GetHisOrderByID(order_id)
  11526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11527. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11528. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11529. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  11530. if count > 0 {
  11531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  11532. return
  11533. }
  11534. if config.IsOpen == 1 { //对接了医保,走医保流程
  11535. var res2 ResultSix
  11536. var resSix10265 ResultSix10265
  11537. if miConfig.MdtrtareaAdmvs == "421300" {
  11538. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  11539. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11540. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11541. resp3, requestErr3 := http.Get(api3)
  11542. if requestErr3 != nil {
  11543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11544. return
  11545. }
  11546. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11547. if ioErr3 != nil {
  11548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11550. return
  11551. }
  11552. var respJSON3 map[string]interface{}
  11553. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11556. return
  11557. }
  11558. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11559. userJSONBytes3, _ := json.Marshal(respJSON3)
  11560. fmt.Println("log")
  11561. fmt.Println(string(userJSONBytes3))
  11562. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11563. utils.ErrorLog("解析失败:%v", err)
  11564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11565. return
  11566. }
  11567. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11568. var api3 string
  11569. if miConfig.MdtrtareaAdmvs == "320921" {
  11570. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  11571. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11572. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11573. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11574. } else {
  11575. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11576. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  11577. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11578. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11579. }
  11580. resp3, requestErr3 := http.Get(api3)
  11581. if requestErr3 != nil {
  11582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11583. return
  11584. }
  11585. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11586. if ioErr3 != nil {
  11587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11589. return
  11590. }
  11591. var respJSON3 map[string]interface{}
  11592. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11595. return
  11596. }
  11597. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11598. userJSONBytes3, _ := json.Marshal(respJSON3)
  11599. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11600. utils.ErrorLog("解析失败:%v", err)
  11601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11602. return
  11603. }
  11604. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11605. res2.Output = resSix10265.Output
  11606. res2.ErrMsg = resSix10265.ErrMsg
  11607. res2.Cainfo = resSix10265.Cainfo
  11608. res2.WarnMsg = resSix10265.WarnMsg
  11609. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11610. res2.Infcode = infocode
  11611. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11612. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11613. var dat map[string]interface{}
  11614. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11615. fmt.Println(dat)
  11616. } else {
  11617. fmt.Println(err)
  11618. }
  11619. saveLog(result, request, "2202", "退号")
  11620. userJSONBytes, _ := json.Marshal(dat)
  11621. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11622. utils.ErrorLog("解析失败:%v", err)
  11623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11624. return
  11625. }
  11626. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11627. result, request := service.Jxyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11628. var dat map[string]interface{}
  11629. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11630. fmt.Println(dat)
  11631. } else {
  11632. fmt.Println(err)
  11633. }
  11634. saveLog(result, request, "2202", "退号")
  11635. userJSONBytes, _ := json.Marshal(dat)
  11636. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11637. utils.ErrorLog("解析失败:%v", err)
  11638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11639. return
  11640. }
  11641. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11642. result, request := service.Hnyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11643. var dat map[string]interface{}
  11644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11645. fmt.Println(dat)
  11646. } else {
  11647. fmt.Println(err)
  11648. }
  11649. saveLog(result, request, "2202", "退号")
  11650. userJSONBytes, _ := json.Marshal(dat)
  11651. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11652. utils.ErrorLog("解析失败:%v", err)
  11653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11654. return
  11655. }
  11656. } else {
  11657. var api3 string
  11658. if miConfig.Code == "H15049901371" {
  11659. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11660. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11661. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11662. } else {
  11663. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  11664. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11665. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11666. }
  11667. resp3, requestErr3 := http.Get(api3)
  11668. if requestErr3 != nil {
  11669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11670. return
  11671. }
  11672. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11673. if ioErr3 != nil {
  11674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11676. return
  11677. }
  11678. var respJSON3 map[string]interface{}
  11679. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11682. return
  11683. }
  11684. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11685. userJSONBytes3, _ := json.Marshal(respJSON3)
  11686. if miConfig.Code == "H15049901371" {
  11687. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11688. utils.ErrorLog("解析失败:%v", err)
  11689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11690. return
  11691. }
  11692. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11693. res2.Output = resSix10265.Output
  11694. res2.ErrMsg = resSix10265.ErrMsg
  11695. res2.Cainfo = resSix10265.Cainfo
  11696. res2.WarnMsg = resSix10265.WarnMsg
  11697. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11698. res2.Infcode = infocode
  11699. } else {
  11700. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11701. utils.ErrorLog("解析失败:%v", err)
  11702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11703. return
  11704. }
  11705. }
  11706. }
  11707. if res2.Infcode == 0 {
  11708. if err == nil {
  11709. c.ServeSuccessJSON(map[string]interface{}{
  11710. "msg": "退号成功",
  11711. })
  11712. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  11713. } else {
  11714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11715. return
  11716. }
  11717. } else {
  11718. c.ServeSuccessJSON(map[string]interface{}{
  11719. "code": -10,
  11720. "msg": res2.ErrMsg,
  11721. })
  11722. }
  11723. } else {
  11724. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  11725. //if err == nil {
  11726. // c.ServeSuccessJSON(map[string]interface{}{
  11727. // "msg": "退费成功",
  11728. // })
  11729. //} else {
  11730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11731. // return
  11732. //}
  11733. }
  11734. }
  11735. func (c *HisApiController) RefundDetail() {
  11736. order_id, _ := c.GetInt64("order_id")
  11737. admin_user_id, _ := c.GetInt64("admin_user_id")
  11738. //his_patient_id, _ := c.GetInt64("his_patient_id")
  11739. number := c.GetString("number")
  11740. record_time := c.GetString("record_time")
  11741. patient_id, _ := c.GetInt64("patient_id")
  11742. //med_type, _ := c.GetInt64("med_type")
  11743. timeLayout := "2006-01-02"
  11744. loc, _ := time.LoadLocation("Local")
  11745. adminUser := c.GetAdminUserInfo()
  11746. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11747. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11748. fmt.Println(err)
  11749. if err != nil {
  11750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11751. return
  11752. }
  11753. recordDateTime := theTime.Unix()
  11754. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11755. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11756. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11757. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11758. var order models.HisOrder
  11759. order, _ = service.GetHisOrderByID(order_id)
  11760. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11761. if config.IsOpen == 1 { //对接了医保,走医保流程
  11762. var res2 ResultSix
  11763. if miConfig.MdtrtareaAdmvs == "421300" {
  11764. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11765. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11766. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11767. resp3, requestErr3 := http.Get(api3)
  11768. if requestErr3 != nil {
  11769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11770. return
  11771. }
  11772. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11773. if ioErr3 != nil {
  11774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11776. return
  11777. }
  11778. var respJSON3 map[string]interface{}
  11779. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11782. return
  11783. }
  11784. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11785. userJSONBytes3, _ := json.Marshal(respJSON3)
  11786. fmt.Println("log")
  11787. fmt.Println(string(userJSONBytes3))
  11788. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11789. utils.ErrorLog("解析失败:%v", err)
  11790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11791. return
  11792. }
  11793. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11794. if err == nil {
  11795. c.ServeSuccessJSON(map[string]interface{}{
  11796. "msg": "撤销明细成功",
  11797. })
  11798. return
  11799. } else {
  11800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11801. return
  11802. }
  11803. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11804. var resSix10265 ResultSix10265
  11805. var api3 string
  11806. if miConfig.MdtrtareaAdmvs == "320921" {
  11807. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11808. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11809. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11810. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11811. } else {
  11812. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11813. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11814. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11815. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11816. }
  11817. resp3, requestErr3 := http.Get(api3)
  11818. if requestErr3 != nil {
  11819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11820. return
  11821. }
  11822. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11823. if ioErr3 != nil {
  11824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11826. return
  11827. }
  11828. var respJSON3 map[string]interface{}
  11829. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11832. return
  11833. }
  11834. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11835. userJSONBytes3, _ := json.Marshal(respJSON3)
  11836. fmt.Println("log")
  11837. fmt.Println(string(userJSONBytes3))
  11838. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11839. utils.ErrorLog("解析失败:%v", err)
  11840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11841. return
  11842. }
  11843. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11844. res2.Output = resSix10265.Output
  11845. res2.ErrMsg = resSix10265.ErrMsg
  11846. res2.Cainfo = resSix10265.Cainfo
  11847. res2.WarnMsg = resSix10265.WarnMsg
  11848. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11849. res2.Infcode = infocode
  11850. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11851. if err == nil {
  11852. c.ServeSuccessJSON(map[string]interface{}{
  11853. "msg": "撤销明细成功",
  11854. })
  11855. return
  11856. } else {
  11857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11858. return
  11859. }
  11860. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11861. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11862. var dat map[string]interface{}
  11863. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11864. fmt.Println(dat)
  11865. } else {
  11866. fmt.Println(err)
  11867. }
  11868. saveLog(result2, src_request, "2205", "撤销明细")
  11869. userJSONBytes, _ := json.Marshal(dat)
  11870. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11871. utils.ErrorLog("解析失败:%v", err)
  11872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11873. return
  11874. }
  11875. if res2.Infcode == 0 {
  11876. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11877. if err == nil {
  11878. c.ServeSuccessJSON(map[string]interface{}{
  11879. "msg": "撤销明细成功",
  11880. })
  11881. return
  11882. } else {
  11883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11884. return
  11885. }
  11886. } else {
  11887. c.ServeSuccessJSON(map[string]interface{}{
  11888. "code": -10,
  11889. "msg": res2.ErrMsg,
  11890. })
  11891. }
  11892. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11893. result2, src_request := service.Jxyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11894. var dat map[string]interface{}
  11895. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11896. fmt.Println(dat)
  11897. } else {
  11898. fmt.Println(err)
  11899. }
  11900. saveLog(result2, src_request, "2205", "撤销明细")
  11901. userJSONBytes, _ := json.Marshal(dat)
  11902. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11903. utils.ErrorLog("解析失败:%v", err)
  11904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11905. return
  11906. }
  11907. if res2.Infcode == 0 {
  11908. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11909. if err == nil {
  11910. c.ServeSuccessJSON(map[string]interface{}{
  11911. "msg": "撤销明细成功",
  11912. })
  11913. return
  11914. } else {
  11915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11916. return
  11917. }
  11918. } else {
  11919. c.ServeSuccessJSON(map[string]interface{}{
  11920. "code": -10,
  11921. "msg": res2.ErrMsg,
  11922. })
  11923. }
  11924. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11925. result2, src_request := service.Hnyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11926. var dat map[string]interface{}
  11927. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11928. fmt.Println(dat)
  11929. } else {
  11930. fmt.Println(err)
  11931. }
  11932. saveLog(result2, src_request, "2205", "撤销明细")
  11933. userJSONBytes, _ := json.Marshal(dat)
  11934. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11935. utils.ErrorLog("解析失败:%v", err)
  11936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11937. return
  11938. }
  11939. if res2.Infcode == 0 {
  11940. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11941. if err == nil {
  11942. c.ServeSuccessJSON(map[string]interface{}{
  11943. "msg": "撤销明细成功",
  11944. })
  11945. return
  11946. } else {
  11947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11948. return
  11949. }
  11950. } else {
  11951. c.ServeSuccessJSON(map[string]interface{}{
  11952. "code": -10,
  11953. "msg": res2.ErrMsg,
  11954. })
  11955. }
  11956. } else {
  11957. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11958. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11959. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11960. resp2, requestErr2 := http.Get(api2)
  11961. if requestErr2 != nil {
  11962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11963. return
  11964. }
  11965. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11966. if ioErr2 != nil {
  11967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11969. return
  11970. }
  11971. var respJSON2 map[string]interface{}
  11972. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  11973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11975. return
  11976. }
  11977. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11978. if err == nil {
  11979. c.ServeSuccessJSON(map[string]interface{}{
  11980. "msg": "撤销明细成功",
  11981. })
  11982. return
  11983. } else {
  11984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11985. return
  11986. }
  11987. }
  11988. } else {
  11989. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11990. if err == nil {
  11991. c.ServeSuccessJSON(map[string]interface{}{
  11992. "msg": "退费成功",
  11993. })
  11994. } else {
  11995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11996. return
  11997. }
  11998. }
  11999. }
  12000. // 对账
  12001. func (c *HisApiController) GetCheckAccount() {
  12002. start_time := c.GetString("start_time")
  12003. end_time := c.GetString("end_time")
  12004. insutype := c.GetString("insutype")
  12005. clr_type := c.GetString("clr_type")
  12006. clr_org := c.GetString("clr_optins")
  12007. admin_user_id, _ := c.GetInt64("admin_user_id")
  12008. adminUser := c.GetAdminUserInfo()
  12009. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12010. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12011. if len(clr_org) == 0 {
  12012. clr_org = miConfig.MdtrtareaAdmvs
  12013. }
  12014. timeLayout := "2006-01-02"
  12015. loc, _ := time.LoadLocation("Local")
  12016. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12017. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12018. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12019. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12020. fixmedins_setl_cnt := int64(len(orders))
  12021. var medfee_sumamt float64
  12022. var acct_pay float64
  12023. var fund_pay_sumamt float64
  12024. for _, item := range orders {
  12025. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12026. acct_pay = acct_pay + item.AcctPay
  12027. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12028. }
  12029. var user_name string
  12030. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12031. if role.ID == 0 {
  12032. user_name = "xxx"
  12033. } else {
  12034. user_name = role.UserName
  12035. }
  12036. var res ResultEight
  12037. var res10188 ResultEightFor10188
  12038. if config.IsOpen == 1 {
  12039. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12040. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  12041. "insutype=" + insutype +
  12042. "&clr_type=" + clr_type +
  12043. "&setl_optins=" + clr_org +
  12044. "&stmt_begndate=" + start_time +
  12045. "&stm_enddate=" + end_time +
  12046. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12047. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12048. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12049. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  12050. "&fixmedins_code=" + miConfig.Code +
  12051. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12052. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12053. "&secret_key=" + miConfig.SecretKey +
  12054. "&org_name=" + miConfig.OrgName +
  12055. "&doctor=" + user_name +
  12056. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12057. fmt.Println(api)
  12058. resp, requestErr := http.Get(api)
  12059. if requestErr != nil {
  12060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12061. return
  12062. }
  12063. body, ioErr := ioutil.ReadAll(resp.Body)
  12064. fmt.Println(body)
  12065. if ioErr != nil {
  12066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12068. return
  12069. }
  12070. var respJSON map[string]interface{}
  12071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12074. return
  12075. }
  12076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12077. userJSONBytes, _ := json.Marshal(respJSON)
  12078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12079. utils.ErrorLog("解析失败:%v", err)
  12080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12081. return
  12082. }
  12083. res.InfRefmsgid = res10188.InfRefmsgid
  12084. res.Output = res10188.Output
  12085. res.ErrMsg = res10188.ErrMsg
  12086. res.Cainfo = res10188.Cainfo
  12087. res.WarnMsg = res10188.WarnMsg
  12088. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12089. res.Infcode = infocode
  12090. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12091. if clr_type == "11" {
  12092. fixmedins_setl_cnt = 2
  12093. }
  12094. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  12095. "insutype=" + insutype +
  12096. "&clr_type=" + clr_type +
  12097. "&setl_optins=" + clr_org +
  12098. "&stmt_begndate=" + start_time +
  12099. "&stm_enddate=" + end_time +
  12100. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12101. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12102. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12103. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  12104. "&fixmedins_code=" + miConfig.Code +
  12105. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12106. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12107. "&secret_key=" + miConfig.SecretKey +
  12108. "&org_name=" + miConfig.OrgName +
  12109. "&doctor=" + user_name
  12110. resp, requestErr := http.Get(api)
  12111. if requestErr != nil {
  12112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12113. return
  12114. }
  12115. body, ioErr := ioutil.ReadAll(resp.Body)
  12116. if ioErr != nil {
  12117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12119. return
  12120. }
  12121. var respJSON map[string]interface{}
  12122. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12125. return
  12126. }
  12127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12128. result, _ := json.Marshal(respJSON)
  12129. fmt.Println("log")
  12130. fmt.Println(string(result))
  12131. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  12132. utils.ErrorLog("解析失败:%v", err)
  12133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12134. return
  12135. }
  12136. res.InfRefmsgid = res10188.InfRefmsgid
  12137. res.Output = res10188.Output
  12138. res.ErrMsg = res10188.ErrMsg
  12139. res.Cainfo = res10188.Cainfo
  12140. res.WarnMsg = res10188.WarnMsg
  12141. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12142. res.Infcode = infocode
  12143. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12144. var baseParams models.BaseParams
  12145. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12146. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12147. baseParams.SecretKey = miConfig.SecretKey
  12148. baseParams.OrgName = miConfig.OrgName
  12149. baseParams.FixmedinsCode = miConfig.Code
  12150. baseParams.EncKey = miConfig.EncKey
  12151. baseParams.AppSecret = miConfig.AppSecret
  12152. baseParams.SignKey = miConfig.SignKey
  12153. baseParams.AppID = miConfig.Code
  12154. baseParams.Doctor = role.UserName
  12155. baseParams.RequestUrl = miConfig.Url
  12156. businessParams := models.BusinessParams{
  12157. Insutype: insutype,
  12158. ClrType: clr_type,
  12159. SetlOptins: clr_org,
  12160. StmtBegndate: start_time,
  12161. StmtEnddate: end_time,
  12162. MedfeeSumamt: medfee_sumamt,
  12163. FundPaySumamt: fund_pay_sumamt,
  12164. AcctPay: acct_pay,
  12165. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12166. }
  12167. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12168. fmt.Println(requestLog)
  12169. fmt.Println(result)
  12170. fmt.Println(err_msg)
  12171. var dat map[string]interface{}
  12172. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12173. fmt.Println(dat)
  12174. } else {
  12175. fmt.Println(err)
  12176. }
  12177. userJSONBytes, _ := json.Marshal(dat)
  12178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12179. utils.ErrorLog("解析失败:%v", err)
  12180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12181. return
  12182. }
  12183. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12184. var baseParams models.BaseParams
  12185. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12186. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12187. baseParams.SecretKey = miConfig.SecretKey
  12188. baseParams.OrgName = miConfig.OrgName
  12189. baseParams.FixmedinsCode = miConfig.Code
  12190. baseParams.EncKey = miConfig.EncKey
  12191. baseParams.AppSecret = miConfig.AppSecret
  12192. baseParams.SignKey = miConfig.SignKey
  12193. baseParams.AppID = miConfig.Code
  12194. baseParams.Doctor = role.UserName
  12195. baseParams.RequestUrl = miConfig.Url
  12196. baseParams.AccessKey = miConfig.AccessKey
  12197. businessParams := models.BusinessParams{
  12198. Insutype: insutype,
  12199. ClrType: clr_type,
  12200. SetlOptins: "430822",
  12201. StmtBegndate: start_time,
  12202. StmtEnddate: end_time,
  12203. MedfeeSumamt: medfee_sumamt,
  12204. FundPaySumamt: fund_pay_sumamt,
  12205. AcctPay: acct_pay,
  12206. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12207. }
  12208. result, requestLog := service.Hnyb3201(businessParams.FixmedinsSetlCnt, businessParams.AcctPay, businessParams.FundPaySumamt, businessParams.MedfeeSumamt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.SetlOptins, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, baseParams.Cainfo)
  12209. fmt.Println(requestLog)
  12210. fmt.Println(result)
  12211. var dat map[string]interface{}
  12212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12213. fmt.Println(dat)
  12214. } else {
  12215. fmt.Println(err)
  12216. }
  12217. userJSONBytes, _ := json.Marshal(dat)
  12218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12219. utils.ErrorLog("解析失败:%v", err)
  12220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12221. return
  12222. }
  12223. } else if miConfig.MdtrtareaAdmvs == "" {
  12224. var baseParams models.BaseParams
  12225. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12226. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12227. baseParams.SecretKey = miConfig.SecretKey
  12228. baseParams.OrgName = miConfig.OrgName
  12229. baseParams.FixmedinsCode = miConfig.Code
  12230. baseParams.EncKey = miConfig.EncKey
  12231. baseParams.AppSecret = miConfig.AppSecret
  12232. baseParams.SignKey = miConfig.SignKey
  12233. baseParams.AppID = miConfig.Code
  12234. baseParams.Doctor = role.UserName
  12235. baseParams.RequestUrl = miConfig.Url
  12236. businessParams := models.BusinessParams{
  12237. Insutype: insutype,
  12238. ClrType: clr_type,
  12239. SetlOptins: clr_org,
  12240. StmtBegndate: start_time,
  12241. StmtEnddate: end_time,
  12242. MedfeeSumamt: medfee_sumamt,
  12243. FundPaySumamt: fund_pay_sumamt,
  12244. AcctPay: acct_pay,
  12245. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12246. }
  12247. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12248. fmt.Println(requestLog)
  12249. fmt.Println(result)
  12250. fmt.Println(err_msg)
  12251. var dat map[string]interface{}
  12252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12253. fmt.Println(dat)
  12254. } else {
  12255. fmt.Println(err)
  12256. }
  12257. userJSONBytes, _ := json.Marshal(dat)
  12258. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12259. utils.ErrorLog("解析失败:%v", err)
  12260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12261. return
  12262. }
  12263. } else {
  12264. if len(clr_type) == 0 {
  12265. clr_type = "11"
  12266. }
  12267. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12268. "insutype=" + insutype +
  12269. "&clr_type=" + clr_type +
  12270. "&setl_optins=" + clr_org +
  12271. "&stmt_begndate=" + start_time +
  12272. "&stm_enddate=" + end_time +
  12273. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12274. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12275. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12276. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  12277. "&fixmedins_code=" + miConfig.Code +
  12278. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12279. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12280. "&secret_key=" + miConfig.SecretKey +
  12281. "&org_name=" + miConfig.OrgName +
  12282. "&doctor=" + user_name
  12283. fmt.Println(api)
  12284. resp, requestErr := http.Get(api)
  12285. if requestErr != nil {
  12286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12287. return
  12288. }
  12289. body, ioErr := ioutil.ReadAll(resp.Body)
  12290. fmt.Println(body)
  12291. if ioErr != nil {
  12292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12294. return
  12295. }
  12296. var respJSON map[string]interface{}
  12297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12300. return
  12301. }
  12302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12303. userJSONBytes, _ := json.Marshal(respJSON)
  12304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12305. utils.ErrorLog("解析失败:%v", err)
  12306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12307. return
  12308. }
  12309. }
  12310. if res.Infcode == 0 {
  12311. if res.Output.Stmtinfo.StmtRslt == "0" {
  12312. micc := &models.MedicalInsuranceCostCompare{
  12313. StartTime: startime.Unix(),
  12314. EndTime: endtime.Unix(),
  12315. Insutype: insutype,
  12316. CheckType: 1,
  12317. Num: fixmedins_setl_cnt,
  12318. Mtime: time.Now().Unix(),
  12319. Status: 1,
  12320. UserOrgId: adminUser.CurrentOrgId,
  12321. CostTotal: medfee_sumamt,
  12322. FuncTotal: fund_pay_sumamt,
  12323. PsnPay: acct_pay,
  12324. Creator: admin_user_id,
  12325. Ctime: time.Now().Unix(),
  12326. ClrType: clr_type,
  12327. }
  12328. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  12329. if err == nil {
  12330. c.ServeSuccessJSON(map[string]interface{}{
  12331. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12332. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12333. })
  12334. } else {
  12335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12336. }
  12337. } else {
  12338. c.ServeSuccessJSON(map[string]interface{}{
  12339. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12340. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12341. })
  12342. }
  12343. } else {
  12344. c.ServeSuccessJSON(map[string]interface{}{
  12345. "code": -10,
  12346. "msg": res.ErrMsg,
  12347. })
  12348. }
  12349. }
  12350. }
  12351. func (c *HisApiController) Check310() {
  12352. adminUser := c.GetAdminUserInfo()
  12353. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12354. var user_name string
  12355. user_name = "高慧裕"
  12356. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12357. "insutype=" + "310" +
  12358. "&clr_type=" + "" +
  12359. "&setl_optins=" + "441202" +
  12360. "&stmt_begndate=" + "2022-03-01" +
  12361. "&stm_enddate=" + "2022-03-31" +
  12362. "&medfee_sumamt=" + "194930.12" +
  12363. "&fund_pay_sumamt=" + "188741.46" +
  12364. "&acct_pay=" + "0" +
  12365. "&fixmedins_setl_cnt=" + "452" +
  12366. "&fixmedins_code=" + miConfig.Code +
  12367. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12368. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12369. "&secret_key=" + miConfig.SecretKey +
  12370. "&org_name=" + miConfig.OrgName +
  12371. "&doctor=" + user_name
  12372. fmt.Println(api)
  12373. resp, requestErr := http.Get(api)
  12374. if requestErr != nil {
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return
  12377. }
  12378. body, ioErr := ioutil.ReadAll(resp.Body)
  12379. fmt.Println(body)
  12380. if ioErr != nil {
  12381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12383. return
  12384. }
  12385. var respJSON map[string]interface{}
  12386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12389. return
  12390. }
  12391. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12392. userJSONBytes, _ := json.Marshal(respJSON)
  12393. var res ResultEight
  12394. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12395. utils.ErrorLog("解析失败:%v", err)
  12396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12397. return
  12398. }
  12399. }
  12400. func (c *HisApiController) Check390() {
  12401. adminUser := c.GetAdminUserInfo()
  12402. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12403. var user_name string
  12404. user_name = "高慧裕"
  12405. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12406. "insutype=" + "390" +
  12407. "&clr_type=" + "" +
  12408. "&setl_optins=" + "441202" +
  12409. "&stmt_begndate=" + "2022-03-01" +
  12410. "&stm_enddate=" + "2022-03-31" +
  12411. "&medfee_sumamt=" + "1068448.89" +
  12412. "&fund_pay_sumamt=" + "1014677.62" +
  12413. "&acct_pay=" + "0" +
  12414. "&fixmedins_setl_cnt=" + "1950" +
  12415. "&fixmedins_code=" + miConfig.Code +
  12416. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12417. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12418. "&secret_key=" + miConfig.SecretKey +
  12419. "&org_name=" + miConfig.OrgName +
  12420. "&doctor=" + user_name
  12421. fmt.Println(api)
  12422. resp, requestErr := http.Get(api)
  12423. if requestErr != nil {
  12424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12425. return
  12426. }
  12427. body, ioErr := ioutil.ReadAll(resp.Body)
  12428. fmt.Println(body)
  12429. if ioErr != nil {
  12430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12432. return
  12433. }
  12434. var respJSON map[string]interface{}
  12435. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12438. return
  12439. }
  12440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12441. userJSONBytes, _ := json.Marshal(respJSON)
  12442. var res ResultEight
  12443. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12444. utils.ErrorLog("解析失败:%v", err)
  12445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12446. return
  12447. }
  12448. }
  12449. // 对账明细
  12450. func (c *HisApiController) GetCheckDetailAccount() {
  12451. start_time := c.GetString("start_time")
  12452. end_time := c.GetString("end_time")
  12453. admin_user_id, _ := c.GetInt64("admin_user_id")
  12454. adminUser := c.GetAdminUserInfo()
  12455. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12456. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12457. timeLayout := "2006-01-02"
  12458. loc, _ := time.LoadLocation("Local")
  12459. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12460. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12461. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  12462. rand.Seed(time.Now().UnixNano())
  12463. num := rand.Intn(30000)
  12464. Mkdir(miConfig.OrgName)
  12465. file := strconv.FormatInt(int64(num), 10)
  12466. file_name := file + ".txt"
  12467. zip_name := file + ".zip"
  12468. zip_path := miConfig.OrgName + "/" + zip_name
  12469. file_path := miConfig.OrgName + "/" + file_name
  12470. decimal.DivisionPrecision = 2
  12471. var medfee_sumamt float64
  12472. var psn_cash_pay float64
  12473. var fund_pay_sumamt float64
  12474. fixmedins_setl_cnt := int64(len(orders))
  12475. for _, item := range orders {
  12476. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12477. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  12478. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12479. }
  12480. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  12481. defer f.Close()
  12482. if err != nil {
  12483. fmt.Println(err.Error())
  12484. } else {
  12485. for _, item := range orders {
  12486. var refd_setl_flag string
  12487. if item.OrderStatus == 2 {
  12488. refd_setl_flag = "0"
  12489. var str string
  12490. str = item.SetlId + " " +
  12491. item.MdtrtId + " " +
  12492. item.PsnNo + " " +
  12493. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12494. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12495. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  12496. _, err = f.Write([]byte(str))
  12497. }
  12498. if item.OrderStatus == 3 {
  12499. var str string
  12500. str = item.SetlId + " " +
  12501. item.MdtrtId + " " +
  12502. item.PsnNo + " " +
  12503. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12504. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12505. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  12506. _, err = f.Write([]byte(str))
  12507. var str2 string
  12508. str2 = item.SetlId + " " +
  12509. item.MdtrtId + " " +
  12510. item.PsnNo + " " +
  12511. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  12512. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  12513. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  12514. _, err = f.Write([]byte(str2))
  12515. }
  12516. }
  12517. }
  12518. Zip(file_path, zip_path)
  12519. fmt.Println(ReadFile(zip_path))
  12520. fmt.Println(string(ReadFile(zip_path)))
  12521. if config.IsOpen == 1 {
  12522. var user_name string
  12523. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12524. if role.ID == 0 {
  12525. user_name = "管理员"
  12526. } else {
  12527. user_name = role.UserName
  12528. }
  12529. baseParams := models.BaseParams{
  12530. SecretKey: miConfig.SecretKey,
  12531. FixmedinsCode: miConfig.Code,
  12532. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12533. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12534. OrgName: miConfig.OrgName,
  12535. Doctor: user_name,
  12536. }
  12537. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  12538. var dat map[string]interface{}
  12539. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12540. fmt.Println(dat)
  12541. } else {
  12542. fmt.Println(err)
  12543. }
  12544. userJSONBytes, _ := json.Marshal(dat)
  12545. var res ResultNine
  12546. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12547. utils.ErrorLog("解析失败:%v", err)
  12548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12549. return
  12550. }
  12551. if res.Infcode == 0 {
  12552. fileNo := res.Output.FileQuryNo
  12553. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  12554. "file_qury_no=" + fileNo +
  12555. "&setl_optins=" + "定点医保中心" +
  12556. "&stmt_begndate=" + start_time +
  12557. "&stm_enddate=" + end_time +
  12558. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12559. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12560. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  12561. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  12562. "&fixmedins_code=" + miConfig.Code +
  12563. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12564. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12565. "&secret_key=" + miConfig.SecretKey +
  12566. "&org_name=" + miConfig.OrgName +
  12567. "&doctor=" + user_name
  12568. resp, requestErr := http.Get(api)
  12569. if requestErr != nil {
  12570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12571. return
  12572. }
  12573. body, ioErr := ioutil.ReadAll(resp.Body)
  12574. if ioErr != nil {
  12575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12577. return
  12578. }
  12579. var respJSON map[string]interface{}
  12580. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12583. return
  12584. }
  12585. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12586. userJSONBytes, _ := json.Marshal(respJSON)
  12587. var res ResultTen
  12588. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12589. utils.ErrorLog("解析失败:%v", err)
  12590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12591. return
  12592. }
  12593. if res.Infcode == 0 {
  12594. service.Gdyb9102(baseParams, zip_name, fileNo)
  12595. micc := &models.MedicalInsuranceCostCompare{
  12596. StartTime: startime.Unix(),
  12597. EndTime: endtime.Unix(),
  12598. Insutype: "0",
  12599. CheckType: 2,
  12600. Num: fixmedins_setl_cnt,
  12601. Mtime: time.Now().Unix(),
  12602. Status: 1,
  12603. UserOrgId: adminUser.CurrentOrgId,
  12604. CostTotal: medfee_sumamt,
  12605. FuncTotal: fund_pay_sumamt,
  12606. PsnPay: psn_cash_pay,
  12607. Creator: admin_user_id,
  12608. Ctime: time.Now().Unix(),
  12609. }
  12610. service.CreateMedicalInsuranceCostCompareRecord(micc)
  12611. c.ServeSuccessJSON(map[string]interface{}{
  12612. "msg": "明细对账成功",
  12613. })
  12614. }
  12615. } else {
  12616. }
  12617. }
  12618. }
  12619. type CustomOrderInfo struct {
  12620. Name string
  12621. Spec string
  12622. Unit string
  12623. Count float64
  12624. Price float64
  12625. Total float64
  12626. }
  12627. func (c *HisApiController) GetSettleAccounts() {
  12628. //id, _ := c.GetInt64("id")
  12629. //record_time := c.GetString("record_time")
  12630. order_id, _ := c.GetInt64("order_id")
  12631. admin_user_id, _ := c.GetInt64("admin_user_id")
  12632. //timeLayout := "2006-01-02"
  12633. //loc, _ := time.LoadLocation("Local")
  12634. //
  12635. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12636. //if err != nil {
  12637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12638. // return
  12639. //}
  12640. //recordDateTime := theTime.Unix()
  12641. adminUser := c.GetAdminUserInfo()
  12642. order, _ := service.GetHisOrderByID(order_id)
  12643. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12644. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  12645. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  12646. orderInfos = append(orderInfos, orderInfos_two...)
  12647. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  12648. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  12649. var diagnosis_ids []string
  12650. if his.ID > 0 {
  12651. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  12652. } else {
  12653. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  12654. }
  12655. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  12656. var dia_config []*models.HisXtDiagnoseConfig
  12657. var name string
  12658. for _, item := range diagnosis_ids {
  12659. id, _ := strconv.ParseInt(item, 10, 64)
  12660. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12661. dia_config = append(dia_config, &diagnosisConfig)
  12662. if len(name) == 0 {
  12663. name = diagnosisConfig.ClassName
  12664. } else {
  12665. name = name + "," + diagnosisConfig.ClassName
  12666. }
  12667. }
  12668. var bedCostTotal float64 = 0 //床位总费
  12669. var bedCostSelfTotal float64 = 0 //床位自费
  12670. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12671. var bedSelfTotal float64 = 0 //床位部分项目自费
  12672. var bedInscpTotal float64 = 0 //床位部分项目自费
  12673. var operationCostTotal float64 = 0 //手术费
  12674. var operationCostSelfTotal float64 = 0 //手术费
  12675. var operationCostPartSelfTotal float64 = 0 //手术费
  12676. var operationSelfTotal float64 = 0 //床位部分项目自费
  12677. var operationInscpTotal float64 = 0 //床位部分项目自费
  12678. var otherCostTotal float64 = 0 //其他费用
  12679. var otherCostSelfTotal float64 = 0 //其他费用
  12680. var otherCostPartSelfTotal float64 = 0 //其他费用
  12681. var otherSelfTotal float64 = 0 //床位部分项目自费
  12682. var otherInscpTotal float64 = 0 //床位部分项目自费
  12683. var materialCostTotal float64 = 0 //材料费
  12684. var materialCostSelfTotal float64 = 0 //材料费
  12685. var materialCostPartSelfTotal float64 = 0 //材料费
  12686. var materialSelfTotal float64 = 0 //床位部分项目自费
  12687. var materialInscpTotal float64 = 0 //床位部分项目自费
  12688. var westernMedicineCostTotal float64 = 0 //西药费
  12689. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12690. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12691. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  12692. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  12693. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12694. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12695. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12696. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  12697. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  12698. var checkCostTotal float64 = 0 //检查费
  12699. var checkCostSelfTotal float64 = 0 //检查费
  12700. var checkCostPartSelfTotal float64 = 0 //检查费
  12701. var checkSelfTotal float64 = 0 //床位部分项目自费
  12702. var checkInscpTotal float64 = 0 //床位部分项目自费
  12703. var laboratoryCostTotal float64 = 0 //化验费
  12704. var laboratoryCostSelfTotal float64 = 0 //化验费
  12705. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12706. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  12707. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  12708. var treatCostTotal float64 = 0 //治疗费用
  12709. var treatCostSelfTotal float64 = 0 //治疗费用
  12710. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12711. var treatSelfTotal float64 = 0 //床位部分项目自费
  12712. var treatInscpTotal float64 = 0 //床位部分项目自费
  12713. decimal.DivisionPrecision = 2
  12714. for _, item := range orderInfos {
  12715. if item.MedChrgitmType == "01" { //床位费
  12716. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12717. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12718. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12719. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12720. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12721. }
  12722. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  12723. if item.MedChrgitmType == "03" { //检查费
  12724. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12725. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12726. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12727. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12728. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12729. }
  12730. } else {
  12731. if item.MedChrgitmType == "03" { //检查费
  12732. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12733. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12734. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12735. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12736. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12737. }
  12738. }
  12739. if item.MedChrgitmType == "04" { //化验费
  12740. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12741. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12742. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12743. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12744. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12745. }
  12746. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  12747. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12748. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12749. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12750. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12751. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12752. }
  12753. if item.MedChrgitmType == "06" { //手术费
  12754. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12755. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12756. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12757. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12758. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12759. }
  12760. if item.MedChrgitmType == "08" { //材料费
  12761. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12762. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12763. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12764. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12765. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12766. }
  12767. if item.MedChrgitmType == "09" { //西药费
  12768. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12769. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12770. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12771. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12772. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12773. }
  12774. if item.MedChrgitmType == "11" { //中成费
  12775. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12776. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12777. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12778. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12779. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12780. }
  12781. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  12782. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12783. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12784. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12785. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12786. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  12787. }
  12788. }
  12789. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12790. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12791. var user_name string
  12792. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12793. if role.ID == 0 {
  12794. user_name = "管理员"
  12795. } else {
  12796. user_name = role.UserName
  12797. }
  12798. baseParams := models.BaseParams{
  12799. SecretKey: miConfig.SecretKey,
  12800. FixmedinsCode: miConfig.Code,
  12801. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12802. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12803. OrgName: miConfig.OrgName,
  12804. Doctor: user_name,
  12805. RequestUrl: miConfig.Url,
  12806. AccessKey: miConfig.AccessKey,
  12807. }
  12808. businessParams := models.BusinessParams{
  12809. PsnNo: order.PsnNo,
  12810. MdtrtId: order.MdtrtId,
  12811. SetlId: order.SetlId,
  12812. }
  12813. var res ResultEleven
  12814. var resEleven10265 ResultEleven10265
  12815. if config.IsOpen == 1 {
  12816. if miConfig.MdtrtareaAdmvs == "421300" {
  12817. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12818. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12819. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12820. resp, requestErr := http.Get(api)
  12821. if requestErr != nil {
  12822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12823. return
  12824. }
  12825. body, ioErr := ioutil.ReadAll(resp.Body)
  12826. if ioErr != nil {
  12827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12829. return
  12830. }
  12831. var respJSON map[string]interface{}
  12832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12835. return
  12836. }
  12837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12838. result, _ := json.Marshal(respJSON)
  12839. fmt.Println("log")
  12840. fmt.Println(string(result))
  12841. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12842. utils.ErrorLog("解析失败:%v", err)
  12843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12844. return
  12845. }
  12846. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12847. var api string
  12848. if miConfig.MdtrtareaAdmvs == "320921" {
  12849. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12850. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12851. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12852. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12853. } else {
  12854. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12855. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12856. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12857. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12858. }
  12859. resp, requestErr := http.Get(api)
  12860. if requestErr != nil {
  12861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12862. return
  12863. }
  12864. body, ioErr := ioutil.ReadAll(resp.Body)
  12865. if ioErr != nil {
  12866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12868. return
  12869. }
  12870. var respJSON map[string]interface{}
  12871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12874. return
  12875. }
  12876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12877. result, _ := json.Marshal(respJSON)
  12878. fmt.Println("log")
  12879. fmt.Println(string(result))
  12880. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12881. utils.ErrorLog("解析失败:%v", err)
  12882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12883. return
  12884. }
  12885. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12886. res.Output = resEleven10265.Output
  12887. res.ErrMsg = resEleven10265.ErrMsg
  12888. res.Cainfo = resEleven10265.Cainfo
  12889. res.WarnMsg = resEleven10265.WarnMsg
  12890. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12891. res.Infcode = infocode
  12892. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12893. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12894. saveLog(result, requestLog, "5203", "结算单")
  12895. var dat map[string]interface{}
  12896. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12897. fmt.Println(dat)
  12898. } else {
  12899. fmt.Println(err)
  12900. }
  12901. userJSONBytes, _ := json.Marshal(dat)
  12902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12903. utils.ErrorLog("解析失败:%v", err)
  12904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12905. return
  12906. }
  12907. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12908. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12909. saveLog(result, requestLog, "5203", "结算单")
  12910. var dat map[string]interface{}
  12911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12912. fmt.Println(dat)
  12913. } else {
  12914. fmt.Println(err)
  12915. }
  12916. userJSONBytes, _ := json.Marshal(dat)
  12917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12918. utils.ErrorLog("解析失败:%v", err)
  12919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12920. return
  12921. }
  12922. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12923. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12924. saveLog(result, requestLog, "5203", "结算单")
  12925. var dat map[string]interface{}
  12926. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12927. fmt.Println(dat)
  12928. } else {
  12929. fmt.Println(err)
  12930. }
  12931. userJSONBytes, _ := json.Marshal(dat)
  12932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12933. utils.ErrorLog("解析失败:%v", err)
  12934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12935. return
  12936. }
  12937. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12938. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12939. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12940. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12941. resp, requestErr := http.Get(api)
  12942. if requestErr != nil {
  12943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12944. return
  12945. }
  12946. body, ioErr := ioutil.ReadAll(resp.Body)
  12947. if ioErr != nil {
  12948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12950. return
  12951. }
  12952. var respJSON map[string]interface{}
  12953. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12956. return
  12957. }
  12958. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12959. result, _ := json.Marshal(respJSON)
  12960. fmt.Println("log")
  12961. fmt.Println(string(result))
  12962. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12963. utils.ErrorLog("解析失败:%v", err)
  12964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12965. return
  12966. }
  12967. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12968. res.Output = resEleven10265.Output
  12969. res.ErrMsg = resEleven10265.ErrMsg
  12970. res.Cainfo = resEleven10265.Cainfo
  12971. res.WarnMsg = resEleven10265.WarnMsg
  12972. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12973. res.Infcode = infocode
  12974. } else {
  12975. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  12976. result := service.Gdyb5203(baseParams, businessParams)
  12977. //service.Gdyb5204(baseParams, businessParams)
  12978. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  12979. var dat map[string]interface{}
  12980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12981. fmt.Println(dat)
  12982. } else {
  12983. fmt.Println(err)
  12984. }
  12985. userJSONBytes, _ := json.Marshal(dat)
  12986. if miConfig.Code == "H15049901371" {
  12987. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  12988. utils.ErrorLog("解析失败:%v", err)
  12989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12990. return
  12991. }
  12992. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12993. res.Output = resEleven10265.Output
  12994. res.ErrMsg = resEleven10265.ErrMsg
  12995. res.Cainfo = resEleven10265.Cainfo
  12996. res.WarnMsg = resEleven10265.WarnMsg
  12997. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12998. res.Infcode = infocode
  12999. } else {
  13000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13001. utils.ErrorLog("解析失败:%v", err)
  13002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13003. return
  13004. }
  13005. }
  13006. }
  13007. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13008. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  13009. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  13010. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13011. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  13012. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13013. var doctor_name string
  13014. if roles.ID == 0 {
  13015. doctor_name = "管理员"
  13016. } else {
  13017. doctor_name = roles.UserName
  13018. }
  13019. yiliao_leibie := ""
  13020. switch order.MedType {
  13021. case "11":
  13022. yiliao_leibie = "普通门诊"
  13023. break
  13024. case "12":
  13025. yiliao_leibie = "门诊挂号"
  13026. break
  13027. case "13":
  13028. yiliao_leibie = "急诊"
  13029. break
  13030. case "14":
  13031. yiliao_leibie = "门诊特殊病"
  13032. break
  13033. case "15":
  13034. yiliao_leibie = "门诊统筹"
  13035. break
  13036. case "16":
  13037. yiliao_leibie = "门诊慢性病"
  13038. break
  13039. case "21":
  13040. yiliao_leibie = "普通住院"
  13041. break
  13042. }
  13043. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13044. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  13045. if res.Infcode == 0 {
  13046. c.ServeSuccessJSON(map[string]interface{}{
  13047. "diagnosis": name,
  13048. "order_infos": orderInfos,
  13049. "number": order.MdtrtId,
  13050. "date": order.SettleAccountsDate,
  13051. "charge_admin": charge_admin,
  13052. "printor_admin": printor_admin,
  13053. "info": res.Output.Setlinfo,
  13054. "order": order,
  13055. "bedCostTotal": bedCostTotal,
  13056. "bedCostSelfTotal": bedCostSelfTotal,
  13057. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  13058. "bedSelfTotal": bedSelfTotal,
  13059. "bedInscpTotal": bedInscpTotal,
  13060. "operationCostTotal": operationCostTotal,
  13061. "operationCostSelfTotal": operationCostSelfTotal,
  13062. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  13063. "operationSelfTotal": operationSelfTotal,
  13064. "operationInscpTotal": operationInscpTotal,
  13065. "otherCostTotal": otherCostTotal,
  13066. "otherCostSelfTotal": otherCostSelfTotal,
  13067. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  13068. "otherSelfTotal": otherSelfTotal,
  13069. "otherInscpTotal": otherInscpTotal,
  13070. "materialCostTotal": materialCostTotal,
  13071. "materialCostSelfTotal": materialCostSelfTotal,
  13072. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  13073. "materialSelfTotal": materialSelfTotal,
  13074. "materialInscpTotal": materialInscpTotal,
  13075. "westernMedicineCostTotal": westernMedicineCostTotal,
  13076. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  13077. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  13078. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  13079. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  13080. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  13081. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  13082. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  13083. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  13084. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  13085. "checkCostTotal": checkCostTotal,
  13086. "checkCostSelfTotal": checkCostSelfTotal,
  13087. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  13088. "checkSelfTotal": checkSelfTotal,
  13089. "checkInscpTotal": checkInscpTotal,
  13090. "laboratoryCostTotal": laboratoryCostTotal,
  13091. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  13092. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  13093. "laboratorySelfTotal": laboratorySelfTotal,
  13094. "laboratoryInscpTotal": laboratoryInscpTotal,
  13095. "treatCostTotal": treatCostTotal,
  13096. "treatCostSelfTotal": treatCostSelfTotal,
  13097. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  13098. "treatSelfTotal": treatSelfTotal,
  13099. "treatInscpTotal": treatInscpTotal,
  13100. "doctor_info": doctor_info,
  13101. "doctor_code": adminRole_two.DoctorCode,
  13102. "doctor_name": doctor_name,
  13103. "health_card_no": order.PsnNo,
  13104. "department": departments.Name,
  13105. "yiliao_leibie": yiliao_leibie,
  13106. "after_money": order.AccountPrice,
  13107. "patient": patient,
  13108. "org_name": miConfig.OrgName,
  13109. "org_code": miConfig.Code,
  13110. "order_number": order.Number,
  13111. "his_hospital": his_hospital,
  13112. "his": his,
  13113. "dia_config": dia_config,
  13114. //"check_order_info": cus_slice,
  13115. })
  13116. }
  13117. }
  13118. }
  13119. func (c *HisApiController) CheckTreatment() {
  13120. patient_id, _ := c.GetInt64("patient_id")
  13121. id_card_no := c.GetString("id_card_no")
  13122. insutype := c.GetString("insutype")
  13123. med_type := c.GetString("med_type")
  13124. admin_user_id, _ := c.GetInt64("admin_user_id")
  13125. adminUser := c.GetAdminUserInfo()
  13126. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13128. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13129. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13130. if miConfig.MdtrtareaAdmvs == "421300" {
  13131. var res ResultTwo
  13132. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13133. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13134. "&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)
  13135. resp, requestErr := http.Get(api)
  13136. if requestErr != nil {
  13137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13138. return
  13139. }
  13140. body, ioErr := ioutil.ReadAll(resp.Body)
  13141. if ioErr != nil {
  13142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13144. return
  13145. }
  13146. var respJSON map[string]interface{}
  13147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13150. return
  13151. }
  13152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13153. result, _ := json.Marshal(respJSON)
  13154. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13155. utils.ErrorLog("解析失败:%v", err)
  13156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13157. return
  13158. }
  13159. if res.Infcode == 0 {
  13160. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  13161. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13162. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  13163. resp, requestErr := http.Get(api)
  13164. if requestErr != nil {
  13165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13166. return
  13167. }
  13168. body, ioErr := ioutil.ReadAll(resp.Body)
  13169. if ioErr != nil {
  13170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13172. return
  13173. }
  13174. var respJSON map[string]interface{}
  13175. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13178. return
  13179. }
  13180. var res Result2001
  13181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13182. result2, _ := json.Marshal(respJSON)
  13183. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  13184. utils.ErrorLog("解析失败:%v", err)
  13185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13186. return
  13187. }
  13188. if res.Infcode == 0 {
  13189. c.ServeSuccessJSON(map[string]interface{}{
  13190. "msg": res.Output.Trtinfo,
  13191. })
  13192. }
  13193. } else {
  13194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13195. return
  13196. }
  13197. } else {
  13198. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13199. var dat map[string]interface{}
  13200. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13201. fmt.Println(dat)
  13202. } else {
  13203. fmt.Println(err)
  13204. }
  13205. userJSONBytes, _ := json.Marshal(dat)
  13206. var res ResultTwo
  13207. var res10265 ResultTwo10265
  13208. if miConfig.Code == "H15049901371" {
  13209. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13210. utils.ErrorLog("解析失败:%v", err)
  13211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13212. return
  13213. }
  13214. res.ErrMsg = res10265.ErrMsg
  13215. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13216. res.Infcode = infocode
  13217. res.Output = res10265.Output
  13218. res.InfRefmsgid = res10265.InfRefmsgid
  13219. } else {
  13220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13221. utils.ErrorLog("解析失败:%v", err)
  13222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13223. return
  13224. }
  13225. }
  13226. var user_name string
  13227. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  13228. if role.ID == 0 {
  13229. user_name = "xxx"
  13230. } else {
  13231. user_name = role.UserName
  13232. }
  13233. baseParams := models.BaseParams{
  13234. SecretKey: miConfig.SecretKey,
  13235. FixmedinsCode: miConfig.Code,
  13236. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13237. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13238. OrgName: miConfig.OrgName,
  13239. Doctor: user_name,
  13240. }
  13241. if config.IsOpen == 1 {
  13242. if miConfig.Code == "H15049901371" {
  13243. if med_type == "14" {
  13244. if insutype == "390" {
  13245. med_type = "9933"
  13246. } else if insutype == "310" {
  13247. med_type = "990502"
  13248. }
  13249. } else if med_type == "11" {
  13250. med_type = "11"
  13251. }
  13252. }
  13253. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  13254. var dat map[string]interface{}
  13255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13256. fmt.Println(dat)
  13257. } else {
  13258. fmt.Println(err)
  13259. }
  13260. var res Result2001
  13261. var res10265 Result2001Org10265
  13262. if miConfig.Code == "H15049901371" {
  13263. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13264. utils.ErrorLog("解析失败:%v", err)
  13265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13266. return
  13267. }
  13268. res.ErrMsg = res10265.ErrMsg
  13269. res.Output = res10265.Output
  13270. res.InfRefmsgid = res10265.InfRefmsgid
  13271. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13272. res.Infcode = infocode
  13273. } else {
  13274. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13275. utils.ErrorLog("解析失败:%v", err)
  13276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13277. return
  13278. }
  13279. }
  13280. if res.Infcode == 0 {
  13281. c.ServeSuccessJSON(map[string]interface{}{
  13282. "msg": res.Output.Trtinfo,
  13283. })
  13284. }
  13285. }
  13286. }
  13287. }
  13288. //func (c *HisApiController) PutRecord() {
  13289. // id, _ := c.GetInt64("id")
  13290. // record_time := c.GetString("record_time")
  13291. // timeLayout := "2006-01-02"
  13292. // loc, _ := time.LoadLocation("Local")
  13293. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13294. // if err != nil {
  13295. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13296. // return
  13297. // }
  13298. // recordDateTime := theTime.Unix()
  13299. //
  13300. // adminInfo := c.GetAdminUserInfo()
  13301. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  13302. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13303. //
  13304. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13305. //
  13306. // fmt.Println(miConfig.SecretKey)
  13307. //
  13308. // if patient == nil {
  13309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13310. // return
  13311. // }
  13312. // if len(patient.IdCardNo) == 0 {
  13313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  13314. // return
  13315. // }
  13316. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  13317. // if config.IsOpen == 1 {
  13318. // 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
  13319. // resp, requestErr := http.Get(api)
  13320. // if requestErr != nil {
  13321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13322. // return
  13323. // }
  13324. // defer resp.Body.Close()
  13325. // body, ioErr := ioutil.ReadAll(resp.Body)
  13326. // if ioErr != nil {
  13327. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13329. // return
  13330. // }
  13331. // var respJSON map[string]interface{}
  13332. //
  13333. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13334. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13336. // return
  13337. // }
  13338. //
  13339. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13340. // userJSONBytes, _ := json.Marshal(userJSON)
  13341. // var res ResultTwo
  13342. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13343. // utils.ErrorLog("解析失败:%v", err)
  13344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13345. // return
  13346. // }
  13347. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13348. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13349. // infoStr := string(Iinfos)
  13350. // idetinfoStr := string(Idetinfos)
  13351. //
  13352. // if res.Infcode == 0 {
  13353. // his := models.VMHisPatient{
  13354. // Status: 1,
  13355. // Ctime: time.Now().Unix(),
  13356. // Mtime: time.Now().Unix(),
  13357. // PsnNo: res.Output.Baseinfo.PsnNo,
  13358. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  13359. // Certno: res.Output.Baseinfo.Certno,
  13360. // PsnName: res.Output.Baseinfo.PsnName,
  13361. // Gend: res.Output.Baseinfo.Gend,
  13362. // Naty: res.Output.Baseinfo.Naty,
  13363. // Brdy: res.Output.Baseinfo.Brdy,
  13364. // Age: res.Output.Baseinfo.Age,
  13365. // Iinfo: infoStr,
  13366. // Idetinfo: idetinfoStr,
  13367. // PatientId: patient.ID,
  13368. // RecordDate: theTime.Unix(),
  13369. // UserOrgId: adminInfo.CurrentOrgId,
  13370. // AdminUserId: adminInfo.AdminUser.Id,
  13371. // IsReturn: 1,
  13372. // }
  13373. //
  13374. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  13375. // //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")
  13376. // //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")
  13377. //
  13378. // //var dat map[string]interface{}
  13379. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13380. // // fmt.Println(dat)
  13381. // //} else {
  13382. // // fmt.Println(err)
  13383. // //}
  13384. //
  13385. // var dat2 map[string]interface{}
  13386. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13387. // fmt.Println(dat2)
  13388. // } else {
  13389. // fmt.Println(err)
  13390. // }
  13391. //
  13392. // } else {
  13393. // adminUser := c.GetAdminUserInfo()
  13394. // errlog := &models.HisOrderError{
  13395. // UserOrgId: adminUser.CurrentOrgId,
  13396. // Ctime: time.Now().Unix(),
  13397. // Mtime: time.Now().Unix(),
  13398. // ErrMsg: res.ErrMsg,
  13399. // Status: 1,
  13400. // PatientId: id,
  13401. // RecordTime: recordDateTime,
  13402. // Stage: 1,
  13403. // }
  13404. // service.CreateErrMsgLog(errlog)
  13405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  13406. // return
  13407. // }
  13408. // }
  13409. //
  13410. //}
  13411. //func (c *HisApiController) GetUploadDiag() {
  13412. // id, _ := c.GetInt64("id")
  13413. // record_time := c.GetString("record_time")
  13414. //
  13415. // diagnosis_id, _ := c.GetInt64("diagnosis")
  13416. // sick_type, _ := c.GetInt64("sick_type")
  13417. // reg_type, _ := c.GetInt64("reg_type")
  13418. //
  13419. // timeLayout := "2006-01-02"
  13420. // loc, _ := time.LoadLocation("Local")
  13421. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13422. // if err != nil {
  13423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13424. // return
  13425. // }
  13426. //
  13427. // var patientPrescription models.HisPrescriptionInfo
  13428. // recordDateTime := theTime.Unix()
  13429. // adminInfo := c.GetAdminUserInfo()
  13430. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13431. //
  13432. // if patientPrescription.ID == 0 {
  13433. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13434. // }
  13435. //
  13436. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13437. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  13438. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13439. // sickConfig, _ := service.FindSickById(sick_type)
  13440. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13441. //
  13442. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  13443. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  13444. // "&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 +
  13445. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  13446. // resp2, requestErr2 := http.Get(api2)
  13447. // if requestErr2 != nil {
  13448. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13449. // return
  13450. // }
  13451. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  13452. // if ioErr2 != nil {
  13453. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  13454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13455. // return
  13456. // }
  13457. // var respJSON2 map[string]interface{}
  13458. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  13459. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13461. // return
  13462. // }
  13463. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13464. // userJSONBytes2, _ := json.Marshal(respJSON2)
  13465. //
  13466. // var res2 ResultSix
  13467. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13468. // utils.ErrorLog("解析失败:%v", err)
  13469. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13470. // return
  13471. // }
  13472. // if res2.Infcode != 0 {
  13473. // adminUser := c.GetAdminUserInfo()
  13474. // errlog := &models.HisOrderError{
  13475. // UserOrgId: adminUser.CurrentOrgId,
  13476. // Ctime: time.Now().Unix(),
  13477. // Mtime: time.Now().Unix(),
  13478. // ErrMsg: res2.ErrMsg,
  13479. // Status: 1,
  13480. // PatientId: id,
  13481. // RecordTime: recordDateTime,
  13482. // Stage: 3,
  13483. // }
  13484. // service.CreateErrMsgLog(errlog)
  13485. //
  13486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  13487. // return
  13488. // }
  13489. //
  13490. // c.ServeSuccessJSON(map[string]interface{}{
  13491. // "msg": "上传成功",
  13492. // })
  13493. //
  13494. //}
  13495. type QueryResult struct {
  13496. ID int64
  13497. Name string
  13498. Code string
  13499. List_type_code string
  13500. }
  13501. func (c *HisApiController) GetCheckCode() {
  13502. ids_str := c.GetString("ids")
  13503. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  13504. ids_arr := strings.Split(ids_str, ",")
  13505. var queryResult []QueryResult
  13506. ids := make([]int64, 0)
  13507. for _, item := range ids_arr {
  13508. id, _ := strconv.ParseInt(item, 10, 64)
  13509. ids = append(ids, id)
  13510. }
  13511. if record_type == 1 {
  13512. drugs, _ := service.GetBatchDrugList(ids)
  13513. for _, item := range drugs {
  13514. result := QueryResult{
  13515. ID: item.ID,
  13516. Name: item.DrugName,
  13517. Code: item.MedicalInsuranceNumber,
  13518. List_type_code: "101",
  13519. }
  13520. queryResult = append(queryResult, result)
  13521. }
  13522. } else if record_type == 2 {
  13523. goods, _ := service.GetBatchGoodInformationList(ids)
  13524. for _, item := range goods {
  13525. result := QueryResult{
  13526. ID: item.ID,
  13527. Name: item.GoodName,
  13528. Code: item.MedicalInsuranceNumber,
  13529. List_type_code: "301",
  13530. }
  13531. queryResult = append(queryResult, result)
  13532. }
  13533. } else if record_type == 3 {
  13534. projects, _ := service.GetBathchMyPorjecgList(ids)
  13535. for _, item := range projects {
  13536. result := QueryResult{
  13537. ID: item.ID,
  13538. Name: item.ProjectName,
  13539. Code: item.MedicalCode,
  13540. List_type_code: "201",
  13541. }
  13542. queryResult = append(queryResult, result)
  13543. }
  13544. }
  13545. admin_user_id, _ := c.GetInt64("admin_user_id")
  13546. adminUser := c.GetAdminUserInfo()
  13547. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13548. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13549. var user_name string
  13550. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13551. if role.ID == 0 {
  13552. user_name = "xxx"
  13553. } else {
  13554. user_name = role.UserName
  13555. }
  13556. baseParams := &models.BaseParams{
  13557. SecretKey: miConfig.SecretKey,
  13558. FixmedinsCode: miConfig.Code,
  13559. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13560. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13561. OrgName: miConfig.OrgName,
  13562. Doctor: user_name,
  13563. }
  13564. if config.IsOpen == 1 {
  13565. for _, item := range queryResult {
  13566. var result string
  13567. if record_type == 1 {
  13568. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13569. } else if record_type == 2 {
  13570. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13571. } else if record_type == 3 {
  13572. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  13573. }
  13574. var dat map[string]interface{}
  13575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13576. fmt.Println(dat)
  13577. } else {
  13578. fmt.Println(err)
  13579. }
  13580. userJSONBytes, _ := json.Marshal(dat)
  13581. var res ResultSix
  13582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13583. utils.ErrorLog("解析失败:%v", err)
  13584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13585. return
  13586. }
  13587. if res.Infcode == 0 {
  13588. if record_type == 1 {
  13589. service.UpdateBaseDrugById(item.ID)
  13590. } else if record_type == 2 {
  13591. service.UpdateGoodInformaitonByDetail(item.ID)
  13592. } else if record_type == 3 {
  13593. service.UpdateProjectById(item.ID)
  13594. }
  13595. c.ServeSuccessJSON(map[string]interface{}{
  13596. "failed_code": 0,
  13597. "msg": "目录对照成功",
  13598. })
  13599. } else {
  13600. c.ServeSuccessJSON(map[string]interface{}{
  13601. "failed_code": -10,
  13602. "msg": res.ErrMsg,
  13603. })
  13604. }
  13605. }
  13606. }
  13607. }
  13608. func (c *HisApiController) UnCheckCode() {
  13609. ids_str := c.GetString("ids")
  13610. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  13611. admin_user_id, _ := c.GetInt64("admin_user_id")
  13612. ids_arr := strings.Split(ids_str, ",")
  13613. var queryResult []QueryResult
  13614. ids := make([]int64, 0)
  13615. for _, item := range ids_arr {
  13616. id, _ := strconv.ParseInt(item, 10, 64)
  13617. ids = append(ids, id)
  13618. }
  13619. if record_type == 1 {
  13620. drugs, _ := service.GetBatchDrugList(ids)
  13621. for _, item := range drugs {
  13622. result := QueryResult{
  13623. ID: item.ID,
  13624. Name: item.DrugName,
  13625. Code: item.MedicalInsuranceNumber,
  13626. List_type_code: "101",
  13627. }
  13628. queryResult = append(queryResult, result)
  13629. }
  13630. } else if record_type == 2 {
  13631. goods, _ := service.GetBatchGoodInformationList(ids)
  13632. for _, item := range goods {
  13633. result := QueryResult{
  13634. ID: item.ID,
  13635. Name: item.GoodName,
  13636. Code: item.MedicalInsuranceNumber,
  13637. List_type_code: "301",
  13638. }
  13639. queryResult = append(queryResult, result)
  13640. }
  13641. } else if record_type == 3 {
  13642. projects, _ := service.GetBathchMyPorjecgList(ids)
  13643. for _, item := range projects {
  13644. result := QueryResult{
  13645. ID: item.ID,
  13646. Name: item.ProjectName,
  13647. Code: item.MedicalCode,
  13648. List_type_code: "201",
  13649. }
  13650. queryResult = append(queryResult, result)
  13651. }
  13652. }
  13653. adminUser := c.GetAdminUserInfo()
  13654. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13655. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13656. var user_name string
  13657. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13658. if role.ID == 0 {
  13659. user_name = "xxx"
  13660. } else {
  13661. user_name = role.UserName
  13662. }
  13663. baseParams := &models.BaseParams{
  13664. SecretKey: miConfig.SecretKey,
  13665. FixmedinsCode: miConfig.Code,
  13666. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13667. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13668. OrgName: miConfig.OrgName,
  13669. Doctor: user_name,
  13670. }
  13671. if config.IsOpen == 1 {
  13672. for _, item := range queryResult {
  13673. var result string
  13674. if record_type == 1 {
  13675. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13676. } else if record_type == 2 {
  13677. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13678. } else if record_type == 3 {
  13679. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  13680. }
  13681. var dat2 map[string]interface{}
  13682. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  13683. fmt.Println(dat2)
  13684. } else {
  13685. fmt.Println(err)
  13686. }
  13687. userJSONBytes, _ := json.Marshal(dat2)
  13688. var res ResultSix
  13689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13690. utils.ErrorLog("解析失败:%v", err)
  13691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13692. return
  13693. }
  13694. if res.Infcode == 0 {
  13695. if record_type == 1 {
  13696. service.UpdateDrugByIdDetail(item.ID)
  13697. } else if record_type == 2 {
  13698. service.UpdateGoodInfoById(item.ID)
  13699. } else if record_type == 3 {
  13700. service.UpdateMyProjectById(item.ID)
  13701. }
  13702. c.ServeSuccessJSON(map[string]interface{}{
  13703. "failed_code": 0,
  13704. "msg": "撤销目录对照成功",
  13705. })
  13706. } else {
  13707. c.ServeSuccessJSON(map[string]interface{}{
  13708. "failed_code": -10,
  13709. "msg": res.ErrMsg,
  13710. })
  13711. }
  13712. }
  13713. }
  13714. }
  13715. func (c *HisApiController) GetPatientInfo() {
  13716. id_card_no := c.GetString("id_card_no")
  13717. admin_user_id, _ := c.GetInt64("admin_user_id")
  13718. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13719. if patient.ID == 0 {
  13720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13721. return
  13722. }
  13723. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13724. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13725. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  13726. if config.IsOpen == 1 {
  13727. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13728. var dat map[string]interface{}
  13729. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13730. fmt.Println(dat)
  13731. } else {
  13732. fmt.Println(err)
  13733. }
  13734. userJSONBytes, _ := json.Marshal(dat)
  13735. var res ResultTwo
  13736. var res10265 ResultTwo10265
  13737. if miConfig.Code == "H15049901371" {
  13738. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13739. utils.ErrorLog("解析失败:%v", err)
  13740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13741. return
  13742. }
  13743. res.ErrMsg = res10265.ErrMsg
  13744. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13745. res.Infcode = infocode
  13746. res.Output = res10265.Output
  13747. res.InfRefmsgid = res10265.InfRefmsgid
  13748. } else {
  13749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13750. utils.ErrorLog("解析失败:%v", err)
  13751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13752. return
  13753. }
  13754. }
  13755. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13756. // utils.ErrorLog("解析失败:%v", err)
  13757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13758. // return
  13759. //}
  13760. for _, item := range res.Output.Iinfo {
  13761. if item.PsnInsuStas == "2" {
  13762. item.Insutype = "300"
  13763. }
  13764. }
  13765. if res.Infcode != 0 {
  13766. c.ServeSuccessJSON(map[string]interface{}{
  13767. "failed_code": -10,
  13768. "msg": res.ErrMsg,
  13769. })
  13770. } else {
  13771. c.ServeSuccessJSON(map[string]interface{}{
  13772. "failed_code": 0,
  13773. "info": res,
  13774. })
  13775. }
  13776. }
  13777. }
  13778. func (c *HisApiController) PsnPutOnRecord() {
  13779. record_type, _ := c.GetInt64("type")
  13780. patient_id, _ := c.GetInt64("patient_id")
  13781. admin_user_id, _ := c.GetInt64("admin_user_id")
  13782. start_time := c.GetString("start_time")
  13783. end_time := c.GetString("end_time")
  13784. adminUser := c.GetAdminUserInfo()
  13785. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13786. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13787. var patients []*models.Patients
  13788. if record_type == 1 { //全部备案
  13789. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  13790. patients = append(patients, patient...)
  13791. } else { //单个备案
  13792. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13793. patients = append(patients, patient)
  13794. }
  13795. var user_name string
  13796. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13797. if role.ID == 0 {
  13798. user_name = "xxx"
  13799. } else {
  13800. user_name = role.UserName
  13801. }
  13802. if config.IsOpen == 1 {
  13803. for _, item := range patients {
  13804. 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
  13805. resp, requestErr := http.Get(api)
  13806. if requestErr != nil {
  13807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13808. return
  13809. }
  13810. defer resp.Body.Close()
  13811. body, ioErr := ioutil.ReadAll(resp.Body)
  13812. if ioErr != nil {
  13813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13815. return
  13816. }
  13817. var respJSON map[string]interface{}
  13818. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13821. return
  13822. }
  13823. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13824. userJSONBytes, _ := json.Marshal(userJSON)
  13825. var res ResultTwo
  13826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13827. utils.ErrorLog("解析失败:%v", err)
  13828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13829. return
  13830. }
  13831. if res.Infcode == 0 {
  13832. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  13833. var dat map[string]interface{}
  13834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13835. fmt.Println(dat)
  13836. } else {
  13837. fmt.Println(err)
  13838. }
  13839. userJSONBytes, _ := json.Marshal(dat)
  13840. var res2 ResultThirteen
  13841. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13842. utils.ErrorLog("解析失败:%v", err)
  13843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13844. return
  13845. }
  13846. if res2.Infcode == 0 {
  13847. psnResult := &models.GdybPsnRecord{
  13848. UserOrgId: adminUser.CurrentOrgId,
  13849. PatientId: item.ID,
  13850. PsnNo: res.Output.Baseinfo.PsnNo,
  13851. Ctime: time.Now().Unix(),
  13852. Mtime: time.Now().Unix(),
  13853. Status: 1,
  13854. IsCancel: 1,
  13855. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13856. }
  13857. service.CreatePsnRecord(psnResult)
  13858. } else {
  13859. c.ServeSuccessJSON(map[string]interface{}{
  13860. "failed_code": -10,
  13861. "msg": res2.ErrMsg,
  13862. })
  13863. return
  13864. }
  13865. }
  13866. }
  13867. }
  13868. }
  13869. func (c *HisApiController) PsnUnPutOnRecord() {
  13870. id, _ := c.GetInt64("id")
  13871. //record_type, _ := c.GetInt64("type")
  13872. admin_user_id, _ := c.GetInt64("admin_user_id")
  13873. adminUser := c.GetAdminUserInfo()
  13874. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13875. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13876. var user_name string
  13877. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13878. if role.ID == 0 {
  13879. user_name = "xxx"
  13880. } else {
  13881. user_name = role.UserName
  13882. }
  13883. psn_record, _ := service.GetPsnRecordById(id)
  13884. if psn_record.ID == 0 {
  13885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13886. return
  13887. }
  13888. if config.IsOpen == 1 {
  13889. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13890. var dat map[string]interface{}
  13891. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13892. fmt.Println(dat)
  13893. } else {
  13894. fmt.Println(err)
  13895. }
  13896. userJSONBytes, _ := json.Marshal(dat)
  13897. var res ResultFourteen
  13898. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13899. utils.ErrorLog("解析失败:%v", err)
  13900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13901. return
  13902. }
  13903. if res.Infcode == 0 {
  13904. psn_record.IsCancel = 2
  13905. service.CreatePsnRecord(&psn_record)
  13906. } else {
  13907. c.ServeSuccessJSON(map[string]interface{}{
  13908. "failed_code": -10,
  13909. "msg": res.ErrMsg,
  13910. })
  13911. return
  13912. }
  13913. }
  13914. }
  13915. func (c *HisApiController) PsnPutNCDSOnRecord() {
  13916. patient_id, _ := c.GetInt64("patient_id")
  13917. insutype_two := c.GetString("insutype")
  13918. psn_no := c.GetString("psn_no")
  13919. doctor_id, _ := c.GetInt64("doctor_id")
  13920. sick_id, _ := c.GetInt64("sick_id")
  13921. department_id, _ := c.GetInt64("department_id")
  13922. start_time := c.GetString("start_time")
  13923. end_time := c.GetString("end_time")
  13924. check_time := c.GetString("check_time")
  13925. hospital_code := c.GetString("hospital_code")
  13926. hospital_name := c.GetString("hospital_name")
  13927. adminUser := c.GetAdminUserInfo()
  13928. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13929. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13930. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13931. sick, _ := service.FindSickById(sick_id)
  13932. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13933. if len(hospital_code) == 0 {
  13934. hospital_code = miConfig.Code
  13935. }
  13936. if len(hospital_name) == 0 {
  13937. hospital_name = miConfig.OrgName
  13938. }
  13939. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13940. var res ResultTwo
  13941. var res10265 ResultTwo10265
  13942. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13943. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13944. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13945. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13946. "&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
  13947. resp, requestErr := http.Get(api)
  13948. if requestErr != nil {
  13949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13950. return
  13951. }
  13952. body, ioErr := ioutil.ReadAll(resp.Body)
  13953. if ioErr != nil {
  13954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13956. return
  13957. }
  13958. var respJSON map[string]interface{}
  13959. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13962. return
  13963. }
  13964. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13965. result, _ := json.Marshal(respJSON)
  13966. fmt.Println("log")
  13967. fmt.Println(string(result))
  13968. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13969. utils.ErrorLog("解析失败:%v", err)
  13970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13971. return
  13972. }
  13973. res.ErrMsg = res10265.ErrMsg
  13974. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13975. res.Infcode = infocode
  13976. res.Output = res10265.Output
  13977. res.InfRefmsgid = res10265.InfRefmsgid
  13978. } else {
  13979. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13980. if miConfig.Code == "H15049901371" {
  13981. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13982. utils.ErrorLog("解析失败:%v", err)
  13983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13984. return
  13985. }
  13986. res.ErrMsg = res10265.ErrMsg
  13987. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13988. res.Infcode = infocode
  13989. res.Output = res10265.Output
  13990. res.InfRefmsgid = res10265.InfRefmsgid
  13991. } else {
  13992. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13993. utils.ErrorLog("解析失败:%v", err)
  13994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13995. return
  13996. }
  13997. }
  13998. }
  13999. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14000. infoStr := string(Iinfos)
  14001. var rf []*ResultFive
  14002. json.Unmarshal([]byte(infoStr), &rf)
  14003. var insuplc_admdvs string
  14004. var insutype string
  14005. var is390 int = 0
  14006. var is310 int = 0
  14007. var insutypes []*ResultFive
  14008. for _, item := range rf {
  14009. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14010. insutypes = append(insutypes, item)
  14011. }
  14012. }
  14013. if len(insutypes) == 1 {
  14014. insutype = insutypes[0].Insutype
  14015. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14016. } else {
  14017. for _, i := range insutypes {
  14018. if i.Insutype == "390" {
  14019. is390 = 1
  14020. }
  14021. if i.Insutype == "310" {
  14022. is310 = 1
  14023. }
  14024. }
  14025. }
  14026. if is390 == 1 {
  14027. insutype = "390"
  14028. }
  14029. if is310 == 1 {
  14030. insutype = "310"
  14031. }
  14032. if len(insutypes) == 2 {
  14033. insutype = insutype_two
  14034. }
  14035. if len(insutypes) == 0 {
  14036. insutype = "310"
  14037. }
  14038. insutype = insutype_two
  14039. fmt.Println(insutype)
  14040. for _, item := range rf {
  14041. fmt.Println(item.Insutype)
  14042. fmt.Println(insutype)
  14043. if item.Insutype == insutype {
  14044. fmt.Println(item.Insutype)
  14045. fmt.Println(insutype)
  14046. insuplc_admdvs = item.InsuplcAdmdvs
  14047. }
  14048. }
  14049. fmt.Println(insuplc_admdvs)
  14050. var res2 ResultThirteen
  14051. var res10265_2 ResultThirteen10265
  14052. if config.IsOpen == 1 {
  14053. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14054. } else {
  14055. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  14056. var dat map[string]interface{}
  14057. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14058. fmt.Println(dat)
  14059. } else {
  14060. fmt.Println(err)
  14061. }
  14062. userJSONBytes, _ := json.Marshal(dat)
  14063. if miConfig.Code == "H15049901371" {
  14064. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  14065. utils.ErrorLog("解析失败:%v", err)
  14066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14067. return
  14068. }
  14069. res2.ErrMsg = res10265_2.ErrMsg
  14070. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  14071. res2.Infcode = infocode
  14072. res2.Output = res10265_2.Output
  14073. res2.InfRefmsgid = res10265_2.InfRefmsgid
  14074. } else {
  14075. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14076. utils.ErrorLog("解析失败:%v", err)
  14077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14078. return
  14079. }
  14080. }
  14081. }
  14082. if res2.Infcode == 0 {
  14083. psnResult := &models.GdybPsnNcdsRecord{
  14084. UserOrgId: adminUser.CurrentOrgId,
  14085. PatientId: patient.ID,
  14086. PsnNo: psn_no,
  14087. DoctorId: doctor.AdminUserId,
  14088. DepartmentId: department_id,
  14089. SickType: sick_id,
  14090. Insutype: insutype,
  14091. Ctime: time.Now().Unix(),
  14092. Mtime: time.Now().Unix(),
  14093. Status: 1,
  14094. IsCancel: 1,
  14095. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  14096. }
  14097. service.CreatePsnNCDSRecord(psnResult)
  14098. c.ServeSuccessJSON(map[string]interface{}{
  14099. "failed_code": 0,
  14100. "msg": "备案成功",
  14101. "result": psnResult,
  14102. })
  14103. } else {
  14104. c.ServeSuccessJSON(map[string]interface{}{
  14105. "failed_code": -10,
  14106. "msg": res2.ErrMsg,
  14107. })
  14108. return
  14109. }
  14110. }
  14111. }
  14112. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  14113. id, _ := c.GetInt64("id")
  14114. admin_user_id, _ := c.GetInt64("admin_user_id")
  14115. adminUser := c.GetAdminUserInfo()
  14116. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14117. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14118. //config, _ := service.Ge(adminUser.CurrentOrgId)
  14119. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  14120. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14121. //var user_name string
  14122. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14123. //if role.ID == 0 {
  14124. // user_name = "xxx"
  14125. //} else {
  14126. // user_name = role.UserName
  14127. //}
  14128. psn_record, _ := service.GetPsnNCDSRecordById(id)
  14129. if psn_record.ID == 0 {
  14130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  14131. return
  14132. }
  14133. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  14134. var res ResultTwo
  14135. var res10265 ResultTwo10265
  14136. if miConfig.Code == "H15049901371" {
  14137. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14138. utils.ErrorLog("解析失败:%v", err)
  14139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14140. return
  14141. }
  14142. res.ErrMsg = res10265.ErrMsg
  14143. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14144. res.Infcode = infocode
  14145. res.Output = res10265.Output
  14146. res.InfRefmsgid = res10265.InfRefmsgid
  14147. } else {
  14148. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14149. utils.ErrorLog("解析失败:%v", err)
  14150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14151. return
  14152. }
  14153. }
  14154. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14155. infoStr := string(Iinfos)
  14156. var rf []*ResultFive
  14157. json.Unmarshal([]byte(infoStr), &rf)
  14158. var insuplc_admdvs string
  14159. var insutype string
  14160. var is390 int = 0
  14161. var is310 int = 0
  14162. var insutypes []*ResultFive
  14163. for _, item := range rf {
  14164. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14165. insutypes = append(insutypes, item)
  14166. }
  14167. }
  14168. if len(insutypes) == 1 {
  14169. insutype = insutypes[0].Insutype
  14170. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14171. } else {
  14172. for _, i := range insutypes {
  14173. if i.Insutype == "390" {
  14174. is390 = 1
  14175. }
  14176. if i.Insutype == "310" {
  14177. is310 = 1
  14178. }
  14179. }
  14180. }
  14181. if is390 == 1 {
  14182. insutype = "390"
  14183. }
  14184. if is310 == 1 {
  14185. insutype = "310"
  14186. }
  14187. if len(insutypes) == 0 {
  14188. insutype = "310"
  14189. }
  14190. insutype = psn_record.Insutype
  14191. for _, item := range rf {
  14192. if item.Insutype == insutype {
  14193. insuplc_admdvs = item.InsuplcAdmdvs
  14194. }
  14195. }
  14196. if config.IsOpen == 1 {
  14197. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  14198. var dat map[string]interface{}
  14199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14200. fmt.Println(dat)
  14201. } else {
  14202. fmt.Println(err)
  14203. }
  14204. userJSONBytes, _ := json.Marshal(dat)
  14205. var res ResultFourteen
  14206. var res10265 ResultFourteen10265
  14207. if miConfig.Code == "H15049901371" {
  14208. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14209. utils.ErrorLog("解析失败:%v", err)
  14210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14211. return
  14212. }
  14213. res.ErrMsg = res10265.ErrMsg
  14214. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14215. res.Infcode = infocode
  14216. res.Output = res10265.Output
  14217. res.InfRefmsgid = res10265.InfRefmsgid
  14218. } else {
  14219. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14220. utils.ErrorLog("解析失败:%v", err)
  14221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14222. return
  14223. }
  14224. }
  14225. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14226. // utils.ErrorLog("解析失败:%v", err)
  14227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14228. // return
  14229. //}
  14230. if res.Infcode == 0 {
  14231. psn_record.IsCancel = 2
  14232. service.CreatePsnNCDSRecord(&psn_record)
  14233. c.ServeSuccessJSON(map[string]interface{}{
  14234. "failed_code": 0,
  14235. "msg": "撤销备案成功",
  14236. })
  14237. } else {
  14238. c.ServeSuccessJSON(map[string]interface{}{
  14239. "failed_code": -10,
  14240. "msg": res.ErrMsg,
  14241. })
  14242. return
  14243. }
  14244. }
  14245. }
  14246. func (c *HisApiController) TestTest() {
  14247. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  14248. fmt.Println(patient.Iinfo)
  14249. }
  14250. type CustomData struct {
  14251. MsgId string
  14252. PsnNo string
  14253. Info string
  14254. }
  14255. func (c *HisApiController) ReversalData() {
  14256. var customData []*CustomData
  14257. custom := &CustomData{
  14258. MsgId: "H44022900158202103301714472004",
  14259. PsnNo: "44020000001101329945",
  14260. Info: "2207",
  14261. }
  14262. customData = append(customData, custom)
  14263. custom1 := &CustomData{
  14264. MsgId: "H4402290015820210330172057803",
  14265. PsnNo: "44020000001101161813",
  14266. Info: "2207",
  14267. }
  14268. customData = append(customData, custom1)
  14269. custom2 := &CustomData{
  14270. MsgId: "H44022900158202103301705198813",
  14271. PsnNo: "44190000133097375417",
  14272. Info: "2207",
  14273. }
  14274. customData = append(customData, custom2)
  14275. custom3 := &CustomData{
  14276. MsgId: "H44022900158202103301715524756",
  14277. PsnNo: "44020000001100187221",
  14278. Info: "2207",
  14279. }
  14280. customData = append(customData, custom3)
  14281. custom4 := &CustomData{
  14282. MsgId: "H44022900158202103301730376224",
  14283. PsnNo: "44020000001101959155",
  14284. Info: "2207",
  14285. }
  14286. customData = append(customData, custom4)
  14287. custom5 := &CustomData{
  14288. MsgId: "H44022900158202103301748008725",
  14289. PsnNo: "44020000001104246641",
  14290. Info: "2207",
  14291. }
  14292. customData = append(customData, custom5)
  14293. custom6 := &CustomData{
  14294. MsgId: "H44022900158202103301718096755",
  14295. PsnNo: "44020000001102211860",
  14296. Info: "2207",
  14297. }
  14298. customData = append(customData, custom6)
  14299. custom7 := &CustomData{
  14300. MsgId: "H44022900158202103301736551640",
  14301. PsnNo: "44020000001102687718",
  14302. Info: "2207",
  14303. }
  14304. customData = append(customData, custom7)
  14305. custom8 := &CustomData{
  14306. MsgId: "H44022900158202103301743097676",
  14307. PsnNo: "44020000001102127785",
  14308. Info: "2207",
  14309. }
  14310. customData = append(customData, custom8)
  14311. custom9 := &CustomData{
  14312. MsgId: "H44022900158202103301712304203",
  14313. PsnNo: "44020000001101518097",
  14314. Info: "2207",
  14315. }
  14316. customData = append(customData, custom9)
  14317. custom10 := &CustomData{
  14318. MsgId: "H44022900158202103301738448785",
  14319. PsnNo: "44020000001100500813",
  14320. Info: "2207",
  14321. }
  14322. customData = append(customData, custom10)
  14323. custom11 := &CustomData{
  14324. MsgId: "H44022900158202103301732455843",
  14325. PsnNo: "44020000001102690557",
  14326. Info: "2207",
  14327. }
  14328. customData = append(customData, custom11)
  14329. custom12 := &CustomData{
  14330. MsgId: "H44022900158202103301745421708",
  14331. PsnNo: "44020000001102211928",
  14332. Info: "2207",
  14333. }
  14334. customData = append(customData, custom12)
  14335. custom1212 := &CustomData{
  14336. MsgId: "H440229001582021033017351627",
  14337. PsnNo: "44020000001102481733",
  14338. Info: "2207",
  14339. }
  14340. customData = append(customData, custom1212)
  14341. custom13 := &CustomData{
  14342. MsgId: "H44022900158202103301740327951",
  14343. PsnNo: "44020000001103174866",
  14344. Info: "2207",
  14345. }
  14346. customData = append(customData, custom13)
  14347. custom14 := &CustomData{
  14348. MsgId: "H4402290015820210330174922668",
  14349. PsnNo: "44020000001102927272",
  14350. Info: "2207",
  14351. }
  14352. customData = append(customData, custom14)
  14353. custom15 := &CustomData{
  14354. MsgId: "H44022900158202103301752362273",
  14355. PsnNo: "44020000001102942890",
  14356. Info: "2207",
  14357. }
  14358. customData = append(customData, custom15)
  14359. custom16 := &CustomData{
  14360. MsgId: "H44022900158202103301751082917",
  14361. PsnNo: "44020000001101662162",
  14362. Info: "2207",
  14363. }
  14364. customData = append(customData, custom16)
  14365. custom17 := &CustomData{
  14366. MsgId: "H44022900158202103301754147728",
  14367. PsnNo: "44020000000229014511",
  14368. Info: "2207",
  14369. }
  14370. customData = append(customData, custom17)
  14371. adminUser := c.GetAdminUserInfo()
  14372. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14373. for _, item := range customData {
  14374. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14375. fmt.Println(result)
  14376. }
  14377. }
  14378. func (c *HisApiController) GetAllopatry() {
  14379. year := c.GetString("year")
  14380. month := c.GetString("month")
  14381. admin_user_id, _ := c.GetInt64("admin_user_id")
  14382. adminUser := c.GetAdminUserInfo()
  14383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14384. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14385. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  14386. var dat map[string]interface{}
  14387. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14388. fmt.Println(dat)
  14389. } else {
  14390. fmt.Println(err)
  14391. }
  14392. userJSONBytes, _ := json.Marshal(dat)
  14393. var res models.Result9001
  14394. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14395. utils.ErrorLog("解析失败:%v", err)
  14396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14397. return
  14398. }
  14399. fmt.Println(res.Output.Signinoutb)
  14400. fmt.Println(res.Output.Signinoutb.SignNo)
  14401. fmt.Println(string(userJSONBytes))
  14402. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14403. var dat2 map[string]interface{}
  14404. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14405. fmt.Println(dat)
  14406. } else {
  14407. fmt.Println(err)
  14408. }
  14409. userJSONBytes2, _ := json.Marshal(dat2)
  14410. var res2 models.Result3260
  14411. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14412. utils.ErrorLog("解析失败:%v", err)
  14413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14414. return
  14415. }
  14416. if res2.Infcode == 0 {
  14417. result3, _, _ := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  14418. var dat2 map[string]interface{}
  14419. if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  14420. fmt.Println(dat)
  14421. } else {
  14422. fmt.Println(err)
  14423. }
  14424. c.ServeSuccessJSON(map[string]interface{}{
  14425. "list": res2.Output.Data,
  14426. })
  14427. return
  14428. } else {
  14429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14430. return
  14431. }
  14432. }
  14433. func (c *HisApiController) ComfirmAllopatry() {
  14434. year := c.GetString("year")
  14435. month := c.GetString("month")
  14436. admin_user_id, _ := c.GetInt64("admin_user_id")
  14437. adminUser := c.GetAdminUserInfo()
  14438. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14439. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14440. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  14441. var dat map[string]interface{}
  14442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14443. fmt.Println(dat)
  14444. } else {
  14445. fmt.Println(err)
  14446. }
  14447. userJSONBytes, _ := json.Marshal(dat)
  14448. var res models.Result9001
  14449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14450. utils.ErrorLog("解析失败:%v", err)
  14451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14452. return
  14453. }
  14454. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14455. var dat2 map[string]interface{}
  14456. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14457. fmt.Println(dat)
  14458. } else {
  14459. fmt.Println(err)
  14460. }
  14461. userJSONBytes2, _ := json.Marshal(dat2)
  14462. var res2 models.Result3260
  14463. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14464. utils.ErrorLog("解析失败:%v", err)
  14465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14466. return
  14467. }
  14468. if res2.Infcode == 0 {
  14469. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  14470. var dat map[string]interface{}
  14471. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14472. fmt.Println(dat)
  14473. } else {
  14474. fmt.Println(err)
  14475. }
  14476. userJSONBytes, _ := json.Marshal(dat)
  14477. var res3 models.Result3261
  14478. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  14479. utils.ErrorLog("解析失败:%v", err)
  14480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14481. return
  14482. }
  14483. if res3.Infcode == 0 {
  14484. record := &models.HisYidiClearRecord{
  14485. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14486. Ctime: time.Now().Unix(),
  14487. Mtime: time.Now().Unix(),
  14488. Status: 1,
  14489. MsgId: msgId,
  14490. }
  14491. service.SaveClearRecord(record)
  14492. c.ServeSuccessJSON(map[string]interface{}{
  14493. "msg": "提取成功",
  14494. })
  14495. }
  14496. }
  14497. }
  14498. func (c *HisApiController) RefundAllopatry() {
  14499. year := c.GetString("year")
  14500. month := c.GetString("month")
  14501. id, _ := c.GetInt64("id")
  14502. admin_user_id, _ := c.GetInt64("admin_user_id")
  14503. adminUser := c.GetAdminUserInfo()
  14504. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14505. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14506. record, _ := service.GetClearRecordById(id)
  14507. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  14508. var dat map[string]interface{}
  14509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14510. fmt.Println(dat)
  14511. } else {
  14512. fmt.Println(err)
  14513. }
  14514. userJSONBytes, _ := json.Marshal(dat)
  14515. var empty ResultFourteen
  14516. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  14517. utils.ErrorLog("解析失败:%v", err)
  14518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14519. return
  14520. }
  14521. if empty.Infcode == 0 {
  14522. c.ServeSuccessJSON(map[string]interface{}{
  14523. "msg": "撤销成功",
  14524. })
  14525. return
  14526. }
  14527. }
  14528. func (c *HisApiController) ReversalOtherData() {
  14529. var customData []*CustomData
  14530. custom := &CustomData{
  14531. MsgId: "H44022900158202103301714472004",
  14532. PsnNo: "44020000001101329945",
  14533. Info: "2208",
  14534. }
  14535. customData = append(customData, custom)
  14536. custom1 := &CustomData{
  14537. MsgId: "H4402290015820210330172057803",
  14538. PsnNo: "44020000001101161813",
  14539. Info: "2208",
  14540. }
  14541. customData = append(customData, custom1)
  14542. custom2 := &CustomData{
  14543. MsgId: "H44022900158202103301705198813",
  14544. PsnNo: "44190000133097375417",
  14545. Info: "2208",
  14546. }
  14547. customData = append(customData, custom2)
  14548. custom3 := &CustomData{
  14549. MsgId: "H44022900158202103301715524756",
  14550. PsnNo: "44020000001100187221",
  14551. Info: "2208",
  14552. }
  14553. customData = append(customData, custom3)
  14554. custom4 := &CustomData{
  14555. MsgId: "H44022900158202103301730376224",
  14556. PsnNo: "44020000001101959155",
  14557. Info: "2208",
  14558. }
  14559. customData = append(customData, custom4)
  14560. custom5 := &CustomData{
  14561. MsgId: "H44022900158202103301748008725",
  14562. PsnNo: "44020000001104246641",
  14563. Info: "2208",
  14564. }
  14565. customData = append(customData, custom5)
  14566. custom6 := &CustomData{
  14567. MsgId: "H44022900158202103301718096755",
  14568. PsnNo: "44020000001102211860",
  14569. Info: "2208",
  14570. }
  14571. customData = append(customData, custom6)
  14572. custom7 := &CustomData{
  14573. MsgId: "H44022900158202103301736551640",
  14574. PsnNo: "44020000001102687718",
  14575. Info: "2208",
  14576. }
  14577. customData = append(customData, custom7)
  14578. custom8 := &CustomData{
  14579. MsgId: "H44022900158202103301743097676",
  14580. PsnNo: "44020000001102127785",
  14581. Info: "2208",
  14582. }
  14583. customData = append(customData, custom8)
  14584. custom9 := &CustomData{
  14585. MsgId: "H44022900158202103301712304203",
  14586. PsnNo: "44020000001101518097",
  14587. Info: "2208",
  14588. }
  14589. customData = append(customData, custom9)
  14590. custom10 := &CustomData{
  14591. MsgId: "H44022900158202103301738448785",
  14592. PsnNo: "44020000001100500813",
  14593. Info: "2208",
  14594. }
  14595. customData = append(customData, custom10)
  14596. custom11 := &CustomData{
  14597. MsgId: "H44022900158202103301732455843",
  14598. PsnNo: "44020000001102690557",
  14599. Info: "2208",
  14600. }
  14601. customData = append(customData, custom11)
  14602. custom12 := &CustomData{
  14603. MsgId: "H44022900158202103301745421708",
  14604. PsnNo: "44020000001102211928",
  14605. Info: "2208",
  14606. }
  14607. customData = append(customData, custom12)
  14608. custom1212 := &CustomData{
  14609. MsgId: "H440229001582021033017351627",
  14610. PsnNo: "44020000001102481733",
  14611. Info: "2208",
  14612. }
  14613. customData = append(customData, custom1212)
  14614. custom13 := &CustomData{
  14615. MsgId: "H44022900158202103301740327951",
  14616. PsnNo: "44020000001103174866",
  14617. Info: "2208",
  14618. }
  14619. customData = append(customData, custom13)
  14620. custom14 := &CustomData{
  14621. MsgId: "H4402290015820210330174922668",
  14622. PsnNo: "44020000001102927272",
  14623. Info: "2208",
  14624. }
  14625. customData = append(customData, custom14)
  14626. custom15 := &CustomData{
  14627. MsgId: "H44022900158202103301752362273",
  14628. PsnNo: "44020000001102942890",
  14629. Info: "2208",
  14630. }
  14631. customData = append(customData, custom15)
  14632. custom16 := &CustomData{
  14633. MsgId: "H44022900158202103301751082917",
  14634. PsnNo: "44020000001101662162",
  14635. Info: "2208",
  14636. }
  14637. customData = append(customData, custom16)
  14638. custom17 := &CustomData{
  14639. MsgId: "H44022900158202103301754147728",
  14640. PsnNo: "44020000000229014511",
  14641. Info: "2208",
  14642. }
  14643. customData = append(customData, custom17)
  14644. adminUser := c.GetAdminUserInfo()
  14645. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14646. for _, item := range customData {
  14647. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14648. fmt.Println(result)
  14649. }
  14650. }
  14651. func PathExists(path string) (bool, error) {
  14652. _, err := os.Stat(path)
  14653. if err == nil {
  14654. return true, nil
  14655. }
  14656. if os.IsNotExist(err) {
  14657. return false, nil
  14658. }
  14659. return false, err
  14660. }
  14661. // 创建文件夹
  14662. func Mkdir(dir string) {
  14663. // 创建文件夹
  14664. exist, err := PathExists(dir)
  14665. if err != nil {
  14666. fmt.Println(err.Error())
  14667. } else {
  14668. if exist {
  14669. fmt.Println(dir + "文件夹已存在!")
  14670. } else {
  14671. // 文件夹名称,权限
  14672. err := os.Mkdir(dir, os.ModePerm)
  14673. if err != nil {
  14674. fmt.Println(dir+"文件夹创建失败:", err.Error())
  14675. } else {
  14676. fmt.Println(dir + "文件夹创建成功!")
  14677. }
  14678. }
  14679. }
  14680. }
  14681. // 压缩文件
  14682. func Zip(srcFile string, destZip string) error {
  14683. zipfile, err := os.Create(destZip)
  14684. if err != nil {
  14685. return err
  14686. }
  14687. defer zipfile.Close()
  14688. archive := zip.NewWriter(zipfile)
  14689. defer archive.Close()
  14690. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  14691. if err != nil {
  14692. return err
  14693. }
  14694. header, err := zip.FileInfoHeader(info)
  14695. if err != nil {
  14696. return err
  14697. }
  14698. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  14699. // header.Name = path
  14700. if info.IsDir() {
  14701. header.Name += "/"
  14702. } else {
  14703. header.Method = zip.Deflate
  14704. }
  14705. writer, err := archive.CreateHeader(header)
  14706. if err != nil {
  14707. return err
  14708. }
  14709. if !info.IsDir() {
  14710. file, err := os.Open(path)
  14711. if err != nil {
  14712. return err
  14713. }
  14714. defer file.Close()
  14715. _, err = io.Copy(writer, file)
  14716. }
  14717. return err
  14718. })
  14719. return err
  14720. }
  14721. func ReadFile(filePath string) []byte {
  14722. f, err := os.Open(filePath)
  14723. if err != nil {
  14724. fmt.Println("read file fail", err)
  14725. return nil
  14726. }
  14727. defer f.Close()
  14728. fd, err := ioutil.ReadAll(f)
  14729. if err != nil {
  14730. fmt.Println("read to fd fail", err)
  14731. return nil
  14732. }
  14733. return fd
  14734. }
  14735. func saveLog(result string, request string, infno string, desc string) {
  14736. org_id, _ := beego.AppConfig.Int64("org_id")
  14737. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14738. dir := miConfig.OrgName + "日志"
  14739. utils.Mkdir(dir)
  14740. month := time.Unix(1557042972, 0).Format("1")
  14741. year := time.Now().Format("2006")
  14742. month = time.Now().Format("01")
  14743. day := time.Now().Format("02")
  14744. hour := time.Now().Format("15")
  14745. min := time.Now().Format("04")
  14746. sec := time.Now().Format("05")
  14747. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  14748. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  14749. file_name := file + ".txt"
  14750. file_path := miConfig.OrgName + "日志" + "/" + file_name
  14751. exist, _ := utils.PathExists(file_path)
  14752. if exist { //存在
  14753. fmt.Println("存在")
  14754. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  14755. if err != nil {
  14756. fmt.Println("read fail")
  14757. }
  14758. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  14759. n, _ := f.Seek(0, 2)
  14760. _, err = f.WriteAt([]byte(content), n)
  14761. } else { //不存在
  14762. fmt.Println("文件不存在,创建文件")
  14763. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  14764. defer f.Close()
  14765. if err != nil {
  14766. } else {
  14767. _, err = f.Write([]byte("记录日志"))
  14768. }
  14769. }
  14770. }
  14771. type Charset string
  14772. const (
  14773. UTF8 = Charset("UTF-8")
  14774. GB18030 = Charset("GB18030")
  14775. )
  14776. func ConvertToString(src string, srcCode string, tagCode string) string {
  14777. srcCoder := mahonia.NewDecoder(srcCode)
  14778. srcResult := srcCoder.ConvertString(src)
  14779. tagCoder := mahonia.NewDecoder(tagCode)
  14780. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  14781. result := string(cdata)
  14782. return result
  14783. }
  14784. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  14785. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  14786. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  14787. var token string
  14788. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14789. var api string
  14790. if miConfig.MdtrtareaAdmvs == "320921" {
  14791. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14792. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  14793. fmt.Println(api)
  14794. } else {
  14795. 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 +
  14796. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  14797. }
  14798. resp, requestErr := http.Get(api)
  14799. if requestErr != nil {
  14800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14801. return ""
  14802. }
  14803. body, ioErr := ioutil.ReadAll(resp.Body)
  14804. if ioErr != nil {
  14805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14807. return ""
  14808. }
  14809. var respJSON map[string]interface{}
  14810. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14813. return ""
  14814. }
  14815. var status string
  14816. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14817. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14818. var res ResultTwo //1101结果
  14819. var res10265 ResultTwo10265 //1101结果
  14820. if status == "0" { //读卡成功
  14821. var card_info string //卡信息
  14822. var busi_card_info string
  14823. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14824. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14825. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14826. fmt.Println(card_info)
  14827. fmt.Println(busi_card_info)
  14828. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14829. result, _ := json.Marshal(respJSON)
  14830. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14831. utils.ErrorLog("解析失败:%v", err)
  14832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14833. return ""
  14834. }
  14835. res.ErrMsg = res10265.ErrMsg
  14836. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14837. res.Infcode = infocode
  14838. res.Output = res10265.Output
  14839. res.InfRefmsgid = res10265.InfRefmsgid
  14840. if res.Infcode == 0 {
  14841. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14842. if err == gorm.ErrRecordNotFound {
  14843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14844. return ""
  14845. } else if err != nil {
  14846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14847. return ""
  14848. } else {
  14849. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14850. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14851. infoStr := string(Iinfos)
  14852. idetinfoStr := string(Idetinfos)
  14853. psn := &models.HisPsn{
  14854. PsnNo: res.Output.Baseinfo.PsnNo,
  14855. Age: res.Output.Baseinfo.Age,
  14856. PatientId: patient.ID,
  14857. Certno: res.Output.Baseinfo.Certno,
  14858. Brdy: res.Output.Baseinfo.Brdy,
  14859. Gend: res.Output.Baseinfo.Gend,
  14860. Naty: res.Output.Baseinfo.Naty,
  14861. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14862. PsnName: res.Output.Baseinfo.PsnName,
  14863. Idetinfo: idetinfoStr,
  14864. Insuinfo: infoStr,
  14865. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14866. CardInfo: card_info,
  14867. VerifyNumber: token,
  14868. }
  14869. service.CreateHisPsn(psn)
  14870. return token
  14871. }
  14872. }
  14873. } else {
  14874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14875. return ""
  14876. }
  14877. } else { //读卡失败
  14878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14879. return ""
  14880. }
  14881. return token
  14882. }
  14883. func DeleteExtraSpaceTwo(s string) string {
  14884. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14885. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14886. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14887. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14888. s2 := make([]byte, len(s1)) //定义字符数组切片
  14889. copy(s2, s1) //将字符串复制到切片
  14890. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14891. for len(spc_index) > 0 { //找到适配项
  14892. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14893. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14894. }
  14895. return string(s2)
  14896. }
  14897. func Remove0000(s string) string {
  14898. str := make([]rune, 0, len(s))
  14899. for _, v := range []rune(s) {
  14900. if v == 0 {
  14901. continue
  14902. }
  14903. str = append(str, v)
  14904. }
  14905. return string(str)
  14906. }
  14907. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  14908. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  14909. readCard := DllDef.MustFindProc("EcQuery")
  14910. pCardInfo := make([]byte, 8192)
  14911. pBusiCardInfo := make([]byte, 8192)
  14912. data := make(map[string]interface{})
  14913. //pData := make(map[string]interface{})
  14914. inputData := make(map[string]interface{})
  14915. inputData["orgId"] = code
  14916. inputData["businessType"] = "01101"
  14917. inputData["operatorId"] = operator_id
  14918. inputData["operatorName"] = operator_name
  14919. inputData["officeId"] = "001"
  14920. inputData["officeName"] = "血透室"
  14921. //
  14922. data["data"] = inputData
  14923. data["transType"] = "ec.query"
  14924. data["orgId"] = code
  14925. bytesData, _ := json.Marshal(data)
  14926. pCardInfo = bytesData
  14927. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  14928. fmt.Println(ret2)
  14929. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  14930. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  14931. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  14932. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  14933. if ret2 != 0 {
  14934. return "", ""
  14935. }
  14936. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  14937. }
  14938. func DeleteExtraSpace(s string) string {
  14939. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  14940. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  14941. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  14942. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14943. s2 := make([]byte, len(s1)) //定义字符数组切片
  14944. copy(s2, s1) //将字符串复制到切片
  14945. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14946. for len(spc_index) > 0 { //找到适配项
  14947. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14948. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14949. }
  14950. return string(s2)
  14951. }
  14952. // 对账
  14953. func (c *HisApiController) Post3202() {
  14954. start_time := c.GetString("start_time")
  14955. end_time := c.GetString("end_time")
  14956. //insutype := c.GetString("insutype")
  14957. clr_type := c.GetString("clr_type")
  14958. clr_org := c.GetString("clr_optins")
  14959. admin_user_id, _ := c.GetInt64("admin_user_id")
  14960. adminUser := c.GetAdminUserInfo()
  14961. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14962. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14963. if len(clr_org) == 0 {
  14964. clr_org = miConfig.MdtrtareaAdmvs
  14965. }
  14966. timeLayout := "2006-01-02"
  14967. loc, _ := time.LoadLocation("Local")
  14968. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14969. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14970. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14971. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14972. //fixmedins_setl_cnt := int64(len(orders))
  14973. var medfee_sumamt float64
  14974. var acct_pay float64
  14975. var fund_pay_sumamt float64
  14976. for _, item := range orders {
  14977. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14978. acct_pay = acct_pay + item.AcctPay
  14979. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14980. }
  14981. //var medfee_sumamt_two float64
  14982. //var acct_pay_two float64
  14983. //var fund_pay_sumamt_two float64
  14984. //for _, item := range orders_two {
  14985. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  14986. // acct_pay_two = acct_pay_two + item.AcctPay
  14987. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  14988. //}
  14989. //var user_name string
  14990. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14991. //if role.ID == 0 {
  14992. // user_name = "xxx"
  14993. //} else {
  14994. // user_name = role.UserName
  14995. //}
  14996. var res ResultSix
  14997. if config.IsOpen == 1 {
  14998. var bps []*models.BusinessParamsTwo
  14999. var bp models.BusinessParamsTwo
  15000. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  15001. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  15002. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  15003. bp.MedfeeSumamt = medfee_sumamt_str
  15004. bp.AcctPay = acct_pay_str
  15005. bp.FundPaySumamt = fund_pay_sumamt_str
  15006. bp.Insutype = "390"
  15007. bp.StmtBegndate = start_time
  15008. bp.ClrType = clr_type
  15009. bp.SetlOptins = clr_org
  15010. bp.StmtEnddate = end_time
  15011. bps = append(bps, &bp)
  15012. data := make(map[string]interface{})
  15013. data["bps"] = bps
  15014. data["org_name"] = miConfig.OrgName
  15015. data["doctor"] = role.UserName
  15016. data["fixmedins_code"] = miConfig.Code
  15017. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15018. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15019. if miConfig.MdtrtareaAdmvs == "421300" {
  15020. client := &http.Client{}
  15021. bytesData, _ := json.Marshal(data)
  15022. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  15023. resp, _ := client.Do(req)
  15024. defer resp.Body.Close()
  15025. body, ioErr := ioutil.ReadAll(resp.Body)
  15026. if ioErr != nil {
  15027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15029. return
  15030. }
  15031. var respJSON map[string]interface{}
  15032. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15035. return
  15036. }
  15037. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15038. userJSONBytes, _ := json.Marshal(respJSON)
  15039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15040. utils.ErrorLog("解析失败:%v", err)
  15041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15042. return
  15043. }
  15044. }
  15045. if res.Infcode == 0 {
  15046. c.ServeSuccessJSON(map[string]interface{}{
  15047. "msg": "发起成功",
  15048. })
  15049. } else {
  15050. c.ServeSuccessJSON(map[string]interface{}{
  15051. "code": -10,
  15052. "msg": res.ErrMsg,
  15053. })
  15054. }
  15055. }
  15056. }
  15057. func (c *HisApiController) Post3501() {
  15058. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15059. data := make(map[string]interface{})
  15060. var struct3501s []models.Struct3501
  15061. var struct3501 models.Struct3501
  15062. struct3501.OrgName = miConfig.OrgName
  15063. struct3501.AccessKey = miConfig.AccessKey
  15064. struct3501.RequestUrl = miConfig.Url
  15065. struct3501.SecretKey = miConfig.SecretKey
  15066. struct3501.ManuDate = "2022-08-17"
  15067. struct3501.FixmedinsBchno = ""
  15068. struct3501.ManuLotnum = ""
  15069. struct3501.RxFlag = "0"
  15070. struct3501.ExpyEnd = "2022-08-17"
  15071. struct3501.Invdate = "2022-08-17"
  15072. struct3501.InvCnt = "20.25"
  15073. struct3501.Memo = ""
  15074. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15075. struct3501.FixmedinsHilistId = miConfig.Code
  15076. struct3501.FixmedinsHilistName = miConfig.OrgName
  15077. struct3501s = append(struct3501s, struct3501)
  15078. data["struct_3501s"] = struct3501s
  15079. client := &http.Client{}
  15080. bytesData, _ := json.Marshal(data)
  15081. var req *http.Request
  15082. if miConfig.MdtrtareaAdmvs == "320921" {
  15083. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15084. } else {
  15085. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15086. }
  15087. resp, _ := client.Do(req)
  15088. defer resp.Body.Close()
  15089. body, ioErr := ioutil.ReadAll(resp.Body)
  15090. if ioErr != nil {
  15091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15093. return
  15094. }
  15095. var respJSON map[string]interface{}
  15096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15099. return
  15100. }
  15101. var res ResultSix
  15102. var resSix10265 ResultSix10265 //1101结果
  15103. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15104. result, _ := json.Marshal(respJSON)
  15105. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15106. utils.ErrorLog("解析失败:%v", err)
  15107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15108. return
  15109. }
  15110. res.InfRefmsgid = resSix10265.InfRefmsgid
  15111. res.Output = resSix10265.Output
  15112. res.ErrMsg = resSix10265.ErrMsg
  15113. res.Cainfo = resSix10265.Cainfo
  15114. res.WarnMsg = resSix10265.WarnMsg
  15115. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15116. res.Infcode = infocode
  15117. if infocode == 0 {
  15118. c.ServeSuccessJSON(map[string]interface{}{
  15119. "msg": "上传成功",
  15120. })
  15121. return
  15122. } else {
  15123. c.ServeSuccessJSON(map[string]interface{}{
  15124. "failed_code": -10,
  15125. "msg": res.ErrMsg,
  15126. })
  15127. return
  15128. }
  15129. }
  15130. func (c *HisApiController) Post3502() {
  15131. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15132. data := make(map[string]interface{})
  15133. var struct3502s []models.Struct3502
  15134. var struct3502 models.Struct3502
  15135. struct3502.OrgName = miConfig.OrgName
  15136. struct3502.AccessKey = miConfig.AccessKey
  15137. struct3502.RequestUrl = miConfig.Url
  15138. struct3502.SecretKey = miConfig.SecretKey
  15139. struct3502.ManuDate = "2022-08-15"
  15140. struct3502.FixmedinsBchno = ""
  15141. struct3502.ManuLotnum = ""
  15142. struct3502.RxFlag = "0"
  15143. struct3502.ExpyEnd = "2022-08-15"
  15144. struct3502.Invdate = "2022-08-15"
  15145. struct3502.InvCnt = "20.25"
  15146. struct3502.Memo = ""
  15147. struct3502.MedListCodg = "XB01ABD056B002020200517"
  15148. struct3502.FixmedinsHilistId = miConfig.Code
  15149. struct3502.FixmedinsHilistName = miConfig.OrgName
  15150. struct3502s = append(struct3502s, struct3502)
  15151. data["struct_3502s"] = struct3502s
  15152. client := &http.Client{}
  15153. bytesData, _ := json.Marshal(data)
  15154. var req *http.Request
  15155. if miConfig.MdtrtareaAdmvs == "320921" {
  15156. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15157. } else {
  15158. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15159. }
  15160. resp, _ := client.Do(req)
  15161. defer resp.Body.Close()
  15162. body, ioErr := ioutil.ReadAll(resp.Body)
  15163. if ioErr != nil {
  15164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15166. return
  15167. }
  15168. var respJSON map[string]interface{}
  15169. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15172. return
  15173. }
  15174. var res ResultSix
  15175. var resSix10265 ResultSix10265 //1101结果
  15176. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15177. result, _ := json.Marshal(respJSON)
  15178. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15179. utils.ErrorLog("解析失败:%v", err)
  15180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15181. return
  15182. }
  15183. res.InfRefmsgid = resSix10265.InfRefmsgid
  15184. res.Output = resSix10265.Output
  15185. res.ErrMsg = resSix10265.ErrMsg
  15186. res.Cainfo = resSix10265.Cainfo
  15187. res.WarnMsg = resSix10265.WarnMsg
  15188. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15189. res.Infcode = infocode
  15190. if infocode == 0 {
  15191. c.ServeSuccessJSON(map[string]interface{}{
  15192. "msg": "上传成功",
  15193. })
  15194. return
  15195. } else {
  15196. c.ServeSuccessJSON(map[string]interface{}{
  15197. "failed_code": -10,
  15198. "msg": res.ErrMsg,
  15199. })
  15200. return
  15201. }
  15202. }
  15203. func (c *HisApiController) Post3503() {
  15204. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15205. data := make(map[string]interface{})
  15206. var struct3501s []models.Struct3501
  15207. var struct3501 models.Struct3501
  15208. struct3501.OrgName = miConfig.OrgName
  15209. struct3501.AccessKey = miConfig.AccessKey
  15210. struct3501.RequestUrl = miConfig.Url
  15211. struct3501.SecretKey = miConfig.SecretKey
  15212. struct3501.ManuDate = "2022-08-15"
  15213. struct3501.FixmedinsBchno = ""
  15214. struct3501.ManuLotnum = ""
  15215. struct3501.RxFlag = "0"
  15216. struct3501.ExpyEnd = "2022-08-15"
  15217. struct3501.Invdate = "2022-08-15"
  15218. struct3501.InvCnt = "20.25"
  15219. struct3501.Memo = ""
  15220. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15221. struct3501.FixmedinsHilistId = miConfig.Code
  15222. struct3501.FixmedinsHilistName = miConfig.OrgName
  15223. struct3501s = append(struct3501s, struct3501)
  15224. data["struct_3501s"] = struct3501s
  15225. client := &http.Client{}
  15226. bytesData, _ := json.Marshal(data)
  15227. var req *http.Request
  15228. if miConfig.MdtrtareaAdmvs == "320921" {
  15229. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15230. } else {
  15231. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15232. }
  15233. resp, _ := client.Do(req)
  15234. defer resp.Body.Close()
  15235. body, ioErr := ioutil.ReadAll(resp.Body)
  15236. if ioErr != nil {
  15237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15239. return
  15240. }
  15241. var respJSON map[string]interface{}
  15242. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15245. return
  15246. }
  15247. var res ResultSix
  15248. var resSix10265 ResultSix10265 //1101结果
  15249. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15250. result, _ := json.Marshal(respJSON)
  15251. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15252. utils.ErrorLog("解析失败:%v", err)
  15253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15254. return
  15255. }
  15256. res.InfRefmsgid = resSix10265.InfRefmsgid
  15257. res.Output = resSix10265.Output
  15258. res.ErrMsg = resSix10265.ErrMsg
  15259. res.Cainfo = resSix10265.Cainfo
  15260. res.WarnMsg = resSix10265.WarnMsg
  15261. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15262. res.Infcode = infocode
  15263. if infocode == 0 {
  15264. c.ServeSuccessJSON(map[string]interface{}{
  15265. "msg": "上传成功",
  15266. })
  15267. return
  15268. } else {
  15269. c.ServeSuccessJSON(map[string]interface{}{
  15270. "failed_code": -10,
  15271. "msg": res.ErrMsg,
  15272. })
  15273. return
  15274. }
  15275. }
  15276. func (c *HisApiController) Post3504() {
  15277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15278. data := make(map[string]interface{})
  15279. var struct3501s []models.Struct3501
  15280. var struct3501 models.Struct3501
  15281. struct3501.OrgName = miConfig.OrgName
  15282. struct3501.AccessKey = miConfig.AccessKey
  15283. struct3501.RequestUrl = miConfig.Url
  15284. struct3501.SecretKey = miConfig.SecretKey
  15285. struct3501.ManuDate = "2022-08-15"
  15286. struct3501.FixmedinsBchno = ""
  15287. struct3501.ManuLotnum = ""
  15288. struct3501.RxFlag = "0"
  15289. struct3501.ExpyEnd = "2022-08-15"
  15290. struct3501.Invdate = "2022-08-15"
  15291. struct3501.InvCnt = "20.25"
  15292. struct3501.Memo = ""
  15293. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15294. struct3501.FixmedinsHilistId = miConfig.Code
  15295. struct3501.FixmedinsHilistName = miConfig.OrgName
  15296. struct3501s = append(struct3501s, struct3501)
  15297. data["struct_3501s"] = struct3501s
  15298. client := &http.Client{}
  15299. bytesData, _ := json.Marshal(data)
  15300. var req *http.Request
  15301. if miConfig.MdtrtareaAdmvs == "320921" {
  15302. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15303. } else {
  15304. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15305. }
  15306. resp, _ := client.Do(req)
  15307. defer resp.Body.Close()
  15308. body, ioErr := ioutil.ReadAll(resp.Body)
  15309. if ioErr != nil {
  15310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15312. return
  15313. }
  15314. var respJSON map[string]interface{}
  15315. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15318. return
  15319. }
  15320. var res ResultSix
  15321. var resSix10265 ResultSix10265 //1101结果
  15322. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15323. result, _ := json.Marshal(respJSON)
  15324. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15325. utils.ErrorLog("解析失败:%v", err)
  15326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15327. return
  15328. }
  15329. res.InfRefmsgid = resSix10265.InfRefmsgid
  15330. res.Output = resSix10265.Output
  15331. res.ErrMsg = resSix10265.ErrMsg
  15332. res.Cainfo = resSix10265.Cainfo
  15333. res.WarnMsg = resSix10265.WarnMsg
  15334. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15335. res.Infcode = infocode
  15336. if infocode == 0 {
  15337. c.ServeSuccessJSON(map[string]interface{}{
  15338. "msg": "上传成功",
  15339. })
  15340. return
  15341. } else {
  15342. c.ServeSuccessJSON(map[string]interface{}{
  15343. "failed_code": -10,
  15344. "msg": res.ErrMsg,
  15345. })
  15346. return
  15347. }
  15348. }
  15349. func (c *HisApiController) Post3505() {
  15350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15351. data := make(map[string]interface{})
  15352. var struct3501s []models.Struct3501
  15353. var struct3501 models.Struct3501
  15354. struct3501.OrgName = miConfig.OrgName
  15355. struct3501.AccessKey = miConfig.AccessKey
  15356. struct3501.RequestUrl = miConfig.Url
  15357. struct3501.SecretKey = miConfig.SecretKey
  15358. struct3501.ManuDate = "2022-08-15"
  15359. struct3501.FixmedinsBchno = ""
  15360. struct3501.ManuLotnum = ""
  15361. struct3501.RxFlag = "0"
  15362. struct3501.ExpyEnd = "2022-08-15"
  15363. struct3501.Invdate = "2022-08-15"
  15364. struct3501.InvCnt = "20.25"
  15365. struct3501.Memo = ""
  15366. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15367. struct3501.FixmedinsHilistId = miConfig.Code
  15368. struct3501.FixmedinsHilistName = miConfig.OrgName
  15369. struct3501s = append(struct3501s, struct3501)
  15370. data["struct_3501s"] = struct3501s
  15371. client := &http.Client{}
  15372. bytesData, _ := json.Marshal(data)
  15373. var req *http.Request
  15374. if miConfig.MdtrtareaAdmvs == "320921" {
  15375. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15376. } else {
  15377. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15378. }
  15379. resp, _ := client.Do(req)
  15380. defer resp.Body.Close()
  15381. body, ioErr := ioutil.ReadAll(resp.Body)
  15382. if ioErr != nil {
  15383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15385. return
  15386. }
  15387. var respJSON map[string]interface{}
  15388. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15391. return
  15392. }
  15393. var res ResultSix
  15394. var resSix10265 ResultSix10265 //1101结果
  15395. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15396. result, _ := json.Marshal(respJSON)
  15397. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15398. utils.ErrorLog("解析失败:%v", err)
  15399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15400. return
  15401. }
  15402. res.InfRefmsgid = resSix10265.InfRefmsgid
  15403. res.Output = resSix10265.Output
  15404. res.ErrMsg = resSix10265.ErrMsg
  15405. res.Cainfo = resSix10265.Cainfo
  15406. res.WarnMsg = resSix10265.WarnMsg
  15407. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15408. res.Infcode = infocode
  15409. if infocode == 0 {
  15410. c.ServeSuccessJSON(map[string]interface{}{
  15411. "msg": "上传成功",
  15412. })
  15413. return
  15414. } else {
  15415. c.ServeSuccessJSON(map[string]interface{}{
  15416. "failed_code": -10,
  15417. "msg": res.ErrMsg,
  15418. })
  15419. return
  15420. }
  15421. }
  15422. func (c *HisApiController) Post3506() {
  15423. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15424. data := make(map[string]interface{})
  15425. var struct3501s []models.Struct3501
  15426. var struct3501 models.Struct3501
  15427. struct3501.OrgName = miConfig.OrgName
  15428. struct3501.AccessKey = miConfig.AccessKey
  15429. struct3501.RequestUrl = miConfig.Url
  15430. struct3501.SecretKey = miConfig.SecretKey
  15431. struct3501.ManuDate = "2022-08-15"
  15432. struct3501.FixmedinsBchno = ""
  15433. struct3501.ManuLotnum = ""
  15434. struct3501.RxFlag = "0"
  15435. struct3501.ExpyEnd = "2022-08-15"
  15436. struct3501.Invdate = "2022-08-15"
  15437. struct3501.InvCnt = "20.25"
  15438. struct3501.Memo = ""
  15439. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15440. struct3501.FixmedinsHilistId = miConfig.Code
  15441. struct3501.FixmedinsHilistName = miConfig.OrgName
  15442. struct3501s = append(struct3501s, struct3501)
  15443. data["struct_3501s"] = struct3501s
  15444. client := &http.Client{}
  15445. bytesData, _ := json.Marshal(data)
  15446. var req *http.Request
  15447. if miConfig.MdtrtareaAdmvs == "320921" {
  15448. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15449. } else {
  15450. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15451. }
  15452. resp, _ := client.Do(req)
  15453. defer resp.Body.Close()
  15454. body, ioErr := ioutil.ReadAll(resp.Body)
  15455. if ioErr != nil {
  15456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15458. return
  15459. }
  15460. var respJSON map[string]interface{}
  15461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15464. return
  15465. }
  15466. var res ResultSix
  15467. var resSix10265 ResultSix10265 //1101结果
  15468. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15469. result, _ := json.Marshal(respJSON)
  15470. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15471. utils.ErrorLog("解析失败:%v", err)
  15472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15473. return
  15474. }
  15475. res.InfRefmsgid = resSix10265.InfRefmsgid
  15476. res.Output = resSix10265.Output
  15477. res.ErrMsg = resSix10265.ErrMsg
  15478. res.Cainfo = resSix10265.Cainfo
  15479. res.WarnMsg = resSix10265.WarnMsg
  15480. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15481. res.Infcode = infocode
  15482. if infocode == 0 {
  15483. c.ServeSuccessJSON(map[string]interface{}{
  15484. "msg": "上传成功",
  15485. })
  15486. return
  15487. } else {
  15488. c.ServeSuccessJSON(map[string]interface{}{
  15489. "failed_code": -10,
  15490. "msg": res.ErrMsg,
  15491. })
  15492. return
  15493. }
  15494. }
  15495. func (c *HisApiController) Post3507() {
  15496. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15497. data := make(map[string]interface{})
  15498. var struct3501s []models.Struct3501
  15499. var struct3501 models.Struct3501
  15500. struct3501.OrgName = miConfig.OrgName
  15501. struct3501.AccessKey = miConfig.AccessKey
  15502. struct3501.RequestUrl = miConfig.Url
  15503. struct3501.SecretKey = miConfig.SecretKey
  15504. struct3501.ManuDate = "2022-08-15"
  15505. struct3501.FixmedinsBchno = ""
  15506. struct3501.ManuLotnum = ""
  15507. struct3501.RxFlag = "0"
  15508. struct3501.ExpyEnd = "2022-08-15"
  15509. struct3501.Invdate = "2022-08-15"
  15510. struct3501.InvCnt = "20.25"
  15511. struct3501.Memo = ""
  15512. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15513. struct3501.FixmedinsHilistId = miConfig.Code
  15514. struct3501.FixmedinsHilistName = miConfig.OrgName
  15515. struct3501s = append(struct3501s, struct3501)
  15516. data["struct_3501s"] = struct3501s
  15517. client := &http.Client{}
  15518. bytesData, _ := json.Marshal(data)
  15519. var req *http.Request
  15520. if miConfig.MdtrtareaAdmvs == "320921" {
  15521. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15522. } else {
  15523. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15524. }
  15525. resp, _ := client.Do(req)
  15526. defer resp.Body.Close()
  15527. body, ioErr := ioutil.ReadAll(resp.Body)
  15528. if ioErr != nil {
  15529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15531. return
  15532. }
  15533. var respJSON map[string]interface{}
  15534. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15537. return
  15538. }
  15539. var res ResultSix
  15540. var resSix10265 ResultSix10265 //1101结果
  15541. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15542. result, _ := json.Marshal(respJSON)
  15543. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15544. utils.ErrorLog("解析失败:%v", err)
  15545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15546. return
  15547. }
  15548. res.InfRefmsgid = resSix10265.InfRefmsgid
  15549. res.Output = resSix10265.Output
  15550. res.ErrMsg = resSix10265.ErrMsg
  15551. res.Cainfo = resSix10265.Cainfo
  15552. res.WarnMsg = resSix10265.WarnMsg
  15553. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15554. res.Infcode = infocode
  15555. if infocode == 0 {
  15556. c.ServeSuccessJSON(map[string]interface{}{
  15557. "msg": "上传成功",
  15558. })
  15559. return
  15560. } else {
  15561. c.ServeSuccessJSON(map[string]interface{}{
  15562. "failed_code": -10,
  15563. "msg": res.ErrMsg,
  15564. })
  15565. return
  15566. }
  15567. }