his_api_controller.go 503KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822
  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. }
  81. type Result3101 struct {
  82. Infcode string `json:"infcode"`
  83. InfRefmsgid string `json:"inf_refmsgid"`
  84. RefmsgTime string `json:"refmsg_time"`
  85. RespondTime string `json:"respond_time"`
  86. Enctype string `json:"enctype"`
  87. Signtype string `json:"signtype"`
  88. ErrMsg string `json:"err_msg"`
  89. Output struct {
  90. Result []struct {
  91. JudgeResultDetailDtos []struct {
  92. VolaItemType string `json:"vola_item_type"`
  93. MdtrtID string `json:"mdtrt_id"`
  94. JrdID string `json:"jrd_id"`
  95. PatnID string `json:"patn_id"`
  96. RxID string `json:"rx_id"`
  97. VolaAmt interface{} `json:"vola_amt"`
  98. } `json:"judge_result_detail_dtos"`
  99. RuleID string `json:"rule_id"`
  100. VolaEvid string `json:"vola_evid"`
  101. MdtrtID string `json:"mdtrt_id"`
  102. RuleName string `json:"rule_name"`
  103. VolaAmtStas string `json:"vola_amt_stas"`
  104. JrID string `json:"jr_id"`
  105. PatnID string `json:"patn_id"`
  106. SevDeg string `json:"sev_deg"`
  107. VolaAmt float64 `json:"vola_amt"`
  108. VolaBhvrType string `json:"vola_bhvr_type"`
  109. VolaCont string `json:"vola_cont"`
  110. } `json:"result"`
  111. } `json:"output"`
  112. }
  113. func (c *HisApiController) Get9001() {
  114. adminUser := c.GetAdminUserInfo()
  115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  116. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  117. if miConfig.MdtrtareaAdmvs == "350500" {
  118. service.GetFjAuthorizationInfo(miConfig.Code)
  119. } else {
  120. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  121. var dat map[string]interface{}
  122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  123. fmt.Println(dat)
  124. } else {
  125. fmt.Println(err)
  126. }
  127. userJSONBytes, _ := json.Marshal(dat)
  128. var res models.Result9001
  129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  130. utils.ErrorLog("解析失败:%v", err)
  131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  132. return
  133. }
  134. }
  135. }
  136. 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) {
  137. var res Result3101
  138. adminUser := c.GetAdminUserInfo()
  139. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  140. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  141. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  142. //record_time := c.GetString("record_time")
  143. //trig_scen := c.GetString("trig_scen")
  144. timeLayout := "2006-01-02"
  145. loc, _ := time.LoadLocation("Local")
  146. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  147. if err != nil {
  148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  149. return res
  150. }
  151. recordDateTime := theTime.Unix()
  152. var patientPrescription models.HisPrescriptionInfo
  153. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  154. //if patientPrescription.ID == 0 {
  155. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  156. //}
  157. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  158. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  159. //
  160. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  161. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  162. var pp models.PublicParams
  163. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  164. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  165. pp.FixmedinsName = miConfig.OrgName
  166. pp.FixmedinsCode = miConfig.Code
  167. pp.RequestUrl = miConfig.Url
  168. pp.Cainfo = miConfig.Cainfo
  169. pp.SecretKey = miConfig.SecretKey
  170. pp.AccessKey = miConfig.AccessKey
  171. pp.OpterName = roles.UserName
  172. var config []*models.HisXtDiagnoseConfig
  173. for _, item := range diagnosis_ids {
  174. id, _ := strconv.ParseInt(item, 10, 64)
  175. diagnosisConfig, _ := service.FindDiagnoseById(id)
  176. config = append(config, &diagnosisConfig)
  177. }
  178. var pd models.PatientDtos
  179. pd.PatnID = his.PsnNo
  180. pd.PatnName = his.Name
  181. pd.Gend = his.Gend
  182. pd.Brdy = his.Brdy
  183. pd.Poolarea = miConfig.MdtrtareaAdmvs
  184. pd.CurrMdtrtID = his.Number
  185. var fed models.FsiEncounterDtos
  186. fed.MdtrtID = his.Number
  187. fed.MedinsID = miConfig.Code
  188. fed.MedinsName = miConfig.OrgName
  189. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  190. fed.MedMdtrtType = "1"
  191. fed.MedinsType = "1"
  192. fed.MedinsLv = "11"
  193. tm := time.Unix(his.RecordDate, 0)
  194. s_tm := tm.Format("2006-01-02 15:04:05")
  195. fed.AdmDate = s_tm
  196. fed.DscgDate = s_tm
  197. fed.DscgMainDiseCodg = config[0].CountryCode
  198. fed.DscgMainDiseName = config[0].CountryContentName
  199. //诊断信息
  200. var fdds []*models.FsiDiagnoseDtos
  201. for index, item := range config {
  202. if index == 0 {
  203. var fdd models.FsiDiagnoseDtos
  204. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  205. fdd.InoutDiseType = "1"
  206. fdd.MaindiseFlag = "1"
  207. fdd.DiseDate = s_tm
  208. fdd.DiasSrtNo = "1"
  209. fdd.DiseName = item.CountryContentName
  210. fdd.DiseCodg = item.CountryCode
  211. fdds = append(fdds, &fdd)
  212. } else {
  213. var fdd models.FsiDiagnoseDtos
  214. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  215. fdd.InoutDiseType = "1"
  216. fdd.MaindiseFlag = "1"
  217. fdd.DiseDate = s_tm
  218. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  219. fdd.DiseName = item.CountryContentName
  220. fdd.DiseCodg = item.CountryCode
  221. fdds = append(fdds, &fdd)
  222. }
  223. }
  224. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  225. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  226. fed.AdmDeptName = department.Name
  227. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  228. fed.DscgDeptName = department.Name
  229. fed.MedMdtrtType = "1"
  230. fed.MedType = "11"
  231. //if his.Insutype == "390" {
  232. // fed.MedType = "1402"
  233. //} else {
  234. // fed.MedType = "9933"
  235. //}
  236. var orders []*models.FsiOrderDtos
  237. if trig_scen == "2" {
  238. //处方医嘱信息
  239. for _, item := range prescriptions {
  240. for _, subItem := range item.HisDoctorAdviceInfo {
  241. var order models.FsiOrderDtos
  242. order.RxID = strconv.FormatInt(item.ID, 10)
  243. order.Rxno = strconv.FormatInt(item.ID, 10)
  244. order.LongDrordFlag = "0"
  245. order.HilistType = "1"
  246. order.ChrgType = "1"
  247. order.DrordBhvr = "-"
  248. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  249. order.HosplistName = subItem.BaseDrugLib.DrugName
  250. order.HilistLv = "1"
  251. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  252. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  253. order.HosplistName = subItem.BaseDrugLib.DrugName
  254. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  255. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  256. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  257. order.OwnpayAmt = ""
  258. order.SelfpayAmt = ""
  259. order.Spec = ""
  260. order.SpecUnt = ""
  261. order.DrordBegnDate = s_tm
  262. order.DrordStopDate = ""
  263. order.DrordDrCodg = "1"
  264. order.DrordDeptName = department.Name
  265. order.DrordDrCodg = "1"
  266. order.DrordDrName = doctor_info.UserName
  267. order.DrordDrProfttl = ""
  268. order.CurrDrordFlag = "1"
  269. orders = append(orders, &order)
  270. }
  271. for _, subItem := range item.HisPrescriptionProject {
  272. if subItem.Type == 2 {
  273. var order models.FsiOrderDtos
  274. order.RxID = strconv.FormatInt(item.ID, 10)
  275. order.Rxno = strconv.FormatInt(item.ID, 10)
  276. order.LongDrordFlag = "0"
  277. order.HilistType = "1"
  278. order.ChrgType = "1"
  279. order.DrordBhvr = "-"
  280. order.HilistCode = subItem.HisProject.MedicalCode
  281. order.HosplistName = subItem.HisProject.ProjectName
  282. order.HilistLv = "1"
  283. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  284. order.HosplistCode = subItem.HisProject.MedicalCode
  285. order.HosplistName = subItem.HisProject.ProjectName
  286. order.Cnt = subItem.Count
  287. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  288. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  289. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  290. order.OwnpayAmt = ""
  291. order.SelfpayAmt = ""
  292. order.Spec = ""
  293. order.SpecUnt = ""
  294. order.DrordBegnDate = s_tm
  295. order.DrordStopDate = ""
  296. order.DrordDrCodg = "1"
  297. order.DrordDeptName = department.Name
  298. order.DrordDrCodg = "1"
  299. order.DrordDrName = doctor_info.UserName
  300. order.DrordDrProfttl = ""
  301. order.CurrDrordFlag = "1"
  302. orders = append(orders, &order)
  303. }
  304. if subItem.Type == 3 {
  305. var order models.FsiOrderDtos
  306. order.RxID = strconv.FormatInt(item.ID, 10)
  307. order.Rxno = strconv.FormatInt(item.ID, 10)
  308. order.LongDrordFlag = "0"
  309. order.HilistType = "1"
  310. order.ChrgType = "1"
  311. order.DrordBhvr = "-"
  312. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  313. order.HosplistName = subItem.GoodInfo.GoodName
  314. order.HilistLv = "1"
  315. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  316. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  317. order.HosplistName = subItem.GoodInfo.GoodName
  318. order.Cnt = subItem.Count
  319. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  320. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  321. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  322. order.OwnpayAmt = ""
  323. order.SelfpayAmt = ""
  324. order.Spec = ""
  325. order.SpecUnt = ""
  326. order.DrordBegnDate = s_tm
  327. order.DrordStopDate = ""
  328. order.DrordDrCodg = "1"
  329. order.DrordDeptName = department.Name
  330. order.DrordDrCodg = "1"
  331. order.DrordDrName = doctor_info.UserName
  332. order.DrordDrProfttl = ""
  333. order.CurrDrordFlag = "1"
  334. orders = append(orders, &order)
  335. }
  336. }
  337. }
  338. //处方医嘱信息
  339. }
  340. fed.MatnStas = "0"
  341. fed.MedfeeSumamt = "0"
  342. fed.OwnpayAmt = "0"
  343. fed.SelfpayAmt = "0"
  344. fed.AcctPayamt = "0"
  345. fed.MaAmt = "0"
  346. fed.HifpPayamt = "0"
  347. fed.SetlTotlnum = "1"
  348. fed.Insutype = his.Insutype
  349. fed.ReimFlag = "0"
  350. fed.OutSetlFlag = "0"
  351. var fopd []*models.FsiOperationDtosData
  352. data := make(map[string]interface{})
  353. data["fed"] = fed
  354. data["fdd"] = fdds
  355. data["fod"] = orders
  356. data["pd"] = pd
  357. data["pp"] = pp
  358. data["fopd"] = fopd
  359. data["trig_scen"] = trig_scen
  360. fmt.Println(data)
  361. fmt.Println(fed)
  362. fmt.Println(fdds)
  363. fmt.Println(orders)
  364. fmt.Println(pd)
  365. fmt.Println(pp)
  366. fmt.Println(fopd)
  367. client := &http.Client{}
  368. bytesData, _ := json.Marshal(data)
  369. var req *http.Request
  370. if miConfig.MdtrtareaAdmvs == "320921" {
  371. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  372. } else {
  373. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  374. }
  375. resp, _ := client.Do(req)
  376. defer resp.Body.Close()
  377. body, ioErr := ioutil.ReadAll(resp.Body)
  378. if ioErr != nil {
  379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  381. return res
  382. }
  383. var respJSON map[string]interface{}
  384. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  387. return res
  388. }
  389. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  390. fmt.Println(respJSON)
  391. result, _ := json.Marshal(respJSON)
  392. fmt.Println(result)
  393. if err := json.Unmarshal([]byte(result), &res); err != nil {
  394. utils.ErrorLog("解析失败:%v", err)
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return res
  397. }
  398. return res
  399. }
  400. 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) {
  401. adminUser := c.GetAdminUserInfo()
  402. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  403. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  404. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  405. //record_time := c.GetString("record_time")
  406. //trig_scen := c.GetString("trig_scen")
  407. timeLayout := "2006-01-02"
  408. loc, _ := time.LoadLocation("Local")
  409. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  410. if err != nil {
  411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  412. return res
  413. }
  414. recordDateTime := theTime.Unix()
  415. var patientPrescription models.HisPrescriptionInfo
  416. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  417. if patientPrescription.ID == 0 {
  418. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  419. }
  420. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  421. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  422. //
  423. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  424. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  425. var pp models.PublicParams
  426. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  427. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  428. pp.FixmedinsName = miConfig.OrgName
  429. pp.FixmedinsCode = miConfig.Code
  430. pp.RequestUrl = miConfig.Url
  431. pp.Cainfo = miConfig.Cainfo
  432. pp.SecretKey = miConfig.SecretKey
  433. pp.AccessKey = miConfig.AccessKey
  434. pp.OpterName = roles.UserName
  435. var config []*models.HisXtDiagnoseConfig
  436. for _, item := range diagnosis_ids {
  437. id, _ := strconv.ParseInt(item, 10, 64)
  438. diagnosisConfig, _ := service.FindDiagnoseById(id)
  439. config = append(config, &diagnosisConfig)
  440. }
  441. var pd models.PatientDtos
  442. pd.PatnID = his.PsnNo
  443. pd.PatnName = his.Name
  444. pd.Gend = his.Gend
  445. pd.Brdy = his.Brdy
  446. pd.Poolarea = his.InsuplcAdmdvs
  447. pd.CurrMdtrtID = his.Number
  448. var fed models.FsiEncounterDtos
  449. fed.MdtrtID = his.Number
  450. fed.MedinsID = miConfig.Code
  451. fed.MedinsName = miConfig.OrgName
  452. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  453. fed.MedMdtrtType = "1"
  454. fed.MedinsType = "1"
  455. fed.MedinsLv = "11"
  456. tm := time.Unix(his.RecordDate, 0)
  457. s_tm := tm.Format("2006-01-02 15:04:05")
  458. fed.AdmDate = s_tm
  459. fed.DscgDate = s_tm
  460. fed.DscgMainDiseCodg = config[0].CountryCode
  461. fed.DscgMainDiseName = config[0].CountryContentName
  462. //诊断信息
  463. var fdds []*models.FsiDiagnoseDtos
  464. for index, item := range config {
  465. if index == 0 {
  466. var fdd models.FsiDiagnoseDtos
  467. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  468. fdd.InoutDiseType = "1"
  469. fdd.MaindiseFlag = "1"
  470. fdd.DiseDate = s_tm
  471. fdd.DiasSrtNo = "1"
  472. fdd.DiseName = item.CountryContentName
  473. fdd.DiseCodg = item.CountryCode
  474. fdds = append(fdds, &fdd)
  475. } else {
  476. var fdd models.FsiDiagnoseDtos
  477. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  478. fdd.InoutDiseType = "1"
  479. fdd.MaindiseFlag = "1"
  480. fdd.DiseDate = s_tm
  481. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  482. fdd.DiseName = item.CountryContentName
  483. fdd.DiseCodg = item.CountryCode
  484. fdds = append(fdds, &fdd)
  485. }
  486. }
  487. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  488. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  489. fed.AdmDeptName = department.Name
  490. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  491. fed.DscgDeptName = department.Name
  492. fed.MedMdtrtType = "1"
  493. fed.MedType = "11"
  494. //if his.Insutype == "390" {
  495. // fed.MedType = "1402"
  496. //} else {
  497. // fed.MedType = "9933"
  498. //}
  499. var orders []*models.FsiOrderDtos
  500. if trig_scen == "2" {
  501. //处方医嘱信息
  502. for _, item := range prescriptions {
  503. for _, subItem := range item.HisDoctorAdviceInfo {
  504. var order models.FsiOrderDtos
  505. order.RxID = strconv.FormatInt(item.ID, 10)
  506. order.Rxno = strconv.FormatInt(item.ID, 10)
  507. order.LongDrordFlag = "0"
  508. order.HilistType = "1"
  509. order.ChrgType = "1"
  510. order.DrordBhvr = "-"
  511. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  512. order.HosplistName = subItem.BaseDrugLib.DrugName
  513. order.HilistLv = "1"
  514. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  515. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  516. order.HosplistName = subItem.BaseDrugLib.DrugName
  517. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  518. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  519. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  520. order.OwnpayAmt = ""
  521. order.SelfpayAmt = ""
  522. order.Spec = ""
  523. order.SpecUnt = ""
  524. order.DrordBegnDate = s_tm
  525. order.DrordStopDate = ""
  526. order.DrordDrCodg = "1"
  527. order.DrordDeptName = department.Name
  528. order.DrordDrCodg = "1"
  529. order.DrordDrName = doctor_info.UserName
  530. order.DrordDrProfttl = ""
  531. order.CurrDrordFlag = "1"
  532. orders = append(orders, &order)
  533. }
  534. for _, subItem := range item.HisPrescriptionProject {
  535. if subItem.Type == 2 {
  536. var order models.FsiOrderDtos
  537. order.RxID = strconv.FormatInt(item.ID, 10)
  538. order.Rxno = strconv.FormatInt(item.ID, 10)
  539. order.LongDrordFlag = "0"
  540. order.HilistType = "1"
  541. order.ChrgType = "1"
  542. order.DrordBhvr = "-"
  543. order.HilistCode = subItem.HisProject.MedicalCode
  544. order.HosplistName = subItem.HisProject.ProjectName
  545. order.HilistLv = "1"
  546. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  547. order.HosplistCode = subItem.HisProject.MedicalCode
  548. order.HosplistName = subItem.HisProject.ProjectName
  549. order.Cnt = subItem.Count
  550. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  551. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  552. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  553. order.OwnpayAmt = ""
  554. order.SelfpayAmt = ""
  555. order.Spec = ""
  556. order.SpecUnt = ""
  557. order.DrordBegnDate = s_tm
  558. order.DrordStopDate = ""
  559. order.DrordDrCodg = "1"
  560. order.DrordDeptName = department.Name
  561. order.DrordDrCodg = "1"
  562. order.DrordDrName = doctor_info.UserName
  563. order.DrordDrProfttl = ""
  564. order.CurrDrordFlag = "1"
  565. orders = append(orders, &order)
  566. }
  567. if subItem.Type == 3 {
  568. var order models.FsiOrderDtos
  569. order.RxID = strconv.FormatInt(item.ID, 10)
  570. order.Rxno = strconv.FormatInt(item.ID, 10)
  571. order.LongDrordFlag = "0"
  572. order.HilistType = "1"
  573. order.ChrgType = "1"
  574. order.DrordBhvr = "-"
  575. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  576. order.HosplistName = subItem.GoodInfo.GoodName
  577. order.HilistLv = "1"
  578. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  579. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  580. order.HosplistName = subItem.GoodInfo.GoodName
  581. order.Cnt = subItem.Count
  582. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  583. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  584. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  585. order.OwnpayAmt = ""
  586. order.SelfpayAmt = ""
  587. order.Spec = ""
  588. order.SpecUnt = ""
  589. order.DrordBegnDate = s_tm
  590. order.DrordStopDate = ""
  591. order.DrordDrCodg = "1"
  592. order.DrordDeptName = department.Name
  593. order.DrordDrCodg = "1"
  594. order.DrordDrName = doctor_info.UserName
  595. order.DrordDrProfttl = ""
  596. order.CurrDrordFlag = "1"
  597. orders = append(orders, &order)
  598. }
  599. }
  600. }
  601. //处方医嘱信息
  602. }
  603. fed.MatnStas = "0"
  604. fed.MedfeeSumamt = "0"
  605. fed.OwnpayAmt = "0"
  606. fed.SelfpayAmt = "0"
  607. fed.AcctPayamt = "0"
  608. fed.MaAmt = "0"
  609. fed.HifpPayamt = "0"
  610. fed.SetlTotlnum = "1"
  611. fed.Insutype = his.Insutype
  612. fed.ReimFlag = "0"
  613. fed.OutSetlFlag = "0"
  614. var fopd []*models.FsiOperationDtosData
  615. data := make(map[string]interface{})
  616. data["fed"] = fed
  617. data["fdd"] = fdds
  618. data["fod"] = orders
  619. data["pd"] = pd
  620. data["pp"] = pp
  621. data["fopd"] = fopd
  622. data["trig_scen"] = trig_scen
  623. fmt.Println(data)
  624. fmt.Println(fed)
  625. fmt.Println(fdds)
  626. fmt.Println(orders)
  627. fmt.Println(pd)
  628. fmt.Println(pp)
  629. fmt.Println(fopd)
  630. client := &http.Client{}
  631. bytesData, _ := json.Marshal(data)
  632. var req *http.Request
  633. if miConfig.MdtrtareaAdmvs == "320921" {
  634. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  635. } else {
  636. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  637. }
  638. resp, _ := client.Do(req)
  639. defer resp.Body.Close()
  640. body, ioErr := ioutil.ReadAll(resp.Body)
  641. if ioErr != nil {
  642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  644. return res
  645. }
  646. var respJSON map[string]interface{}
  647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  650. return res
  651. }
  652. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  653. result, _ := json.Marshal(respJSON)
  654. if err := json.Unmarshal([]byte(result), &res); err != nil {
  655. utils.ErrorLog("解析失败:%v", err)
  656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  657. return res
  658. }
  659. return res
  660. }
  661. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  662. ////patient_id, _ := c.GetInt64("patient_id")
  663. //order_id, _ := c.GetInt64("order_id")
  664. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  665. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  666. //trig_scen := c.GetString("trig_scen")
  667. adminUser := c.GetAdminUserInfo()
  668. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  669. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  670. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  671. record_time := c.GetString("record_time")
  672. order, _ := service.GetHisOrderByID(order_id)
  673. timeLayout := "2006-01-02"
  674. loc, _ := time.LoadLocation("Local")
  675. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  676. if err != nil {
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  678. return
  679. }
  680. recordDateTime := theTime.Unix()
  681. var patientPrescription models.HisPrescriptionInfo
  682. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  683. if patientPrescription.ID == 0 {
  684. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  685. }
  686. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  687. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  688. //
  689. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  690. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  691. var pp models.PublicParams
  692. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  693. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  694. pp.FixmedinsName = miConfig.OrgName
  695. pp.FixmedinsCode = miConfig.Code
  696. pp.RequestUrl = miConfig.Url
  697. pp.Cainfo = miConfig.Cainfo
  698. pp.SecretKey = miConfig.SecretKey
  699. pp.AccessKey = miConfig.AccessKey
  700. pp.OpterName = roles.UserName
  701. var config []*models.HisXtDiagnoseConfig
  702. for _, item := range diagnosis_ids {
  703. id, _ := strconv.ParseInt(item, 10, 64)
  704. diagnosisConfig, _ := service.FindDiagnoseById(id)
  705. config = append(config, &diagnosisConfig)
  706. }
  707. var pd models.PatientDtos
  708. pd.PatnID = his.PsnNo
  709. pd.PatnName = his.Name
  710. pd.Gend = his.Gend
  711. pd.Brdy = his.Brdy
  712. pd.Poolarea = his.InsuplcAdmdvs
  713. pd.CurrMdtrtID = his.Number
  714. var fed models.FsiEncounterDtos
  715. fed.MdtrtID = his.Number
  716. fed.MedinsID = miConfig.Code
  717. fed.MedinsName = miConfig.OrgName
  718. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  719. fed.MedMdtrtType = "1"
  720. fed.MedinsType = "1"
  721. fed.MedinsLv = "11"
  722. tm := time.Unix(his.RecordDate, 0)
  723. s_tm := tm.Format("2006-01-02 15:04:05")
  724. fed.AdmDate = s_tm
  725. fed.DscgDate = s_tm
  726. fed.DscgMainDiseCodg = config[0].CountryCode
  727. fed.DscgMainDiseName = config[0].CountryContentName
  728. //诊断信息
  729. var fdds []*models.FsiDiagnoseDtos
  730. for index, item := range config {
  731. if index == 0 {
  732. var fdd models.FsiDiagnoseDtos
  733. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  734. fdd.InoutDiseType = "1"
  735. fdd.MaindiseFlag = "1"
  736. fdd.DiseDate = s_tm
  737. fdd.DiasSrtNo = "1"
  738. fdd.DiseName = item.CountryContentName
  739. fdd.DiseCodg = item.CountryCode
  740. fdds = append(fdds, &fdd)
  741. } else {
  742. var fdd models.FsiDiagnoseDtos
  743. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  744. fdd.InoutDiseType = "1"
  745. fdd.MaindiseFlag = "1"
  746. fdd.DiseDate = s_tm
  747. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  748. fdd.DiseName = item.CountryContentName
  749. fdd.DiseCodg = item.CountryCode
  750. fdds = append(fdds, &fdd)
  751. }
  752. }
  753. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  754. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  755. fed.AdmDeptName = department.Name
  756. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  757. fed.DscgDeptName = department.Name
  758. fed.MedType = order.MedType
  759. //处方医嘱信息
  760. var orders []*models.FsiOrderDtos
  761. //for _, item := range prescriptions {
  762. // for _, subItem := range item.HisDoctorAdviceInfo {
  763. // var order models.FsiOrderDtos
  764. // order.RxID = strconv.FormatInt(item.ID, 10)
  765. // order.Rxno = strconv.FormatInt(item.ID, 10)
  766. // order.LongDrordFlag = "0"
  767. // order.HilistType = "1"
  768. // order.ChrgType = "1"
  769. // order.DrordBhvr = "-"
  770. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  771. // order.HosplistName = subItem.BaseDrugLib.DrugName
  772. // order.HilistLv = "1"
  773. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  774. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  775. // order.HosplistName = subItem.BaseDrugLib.DrugName
  776. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  777. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  778. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  779. // order.OwnpayAmt = ""
  780. // order.SelfpayAmt = ""
  781. // order.Spec = ""
  782. // order.SpecUnt = ""
  783. // order.DrordBegnDate = s_tm
  784. // order.DrordStopDate = ""
  785. // order.DrordDrCodg = "1"
  786. // order.DrordDeptName = department.Name
  787. // order.DrordDrCodg = "1"
  788. // order.DrordDrName = doctor_info.UserName
  789. // order.DrordDrProfttl = ""
  790. // order.CurrDrordFlag = "1"
  791. // orders = append(orders, &order)
  792. // }
  793. // for _, subItem := range item.HisPrescriptionProject {
  794. // if subItem.Type == 2 {
  795. // var order models.FsiOrderDtos
  796. // order.RxID = strconv.FormatInt(item.ID, 10)
  797. // order.Rxno = strconv.FormatInt(item.ID, 10)
  798. // order.LongDrordFlag = "0"
  799. // order.HilistType = "1"
  800. // order.ChrgType = "1"
  801. // order.DrordBhvr = "-"
  802. // order.HilistCode = subItem.HisProject.MedicalCode
  803. // order.HosplistName = subItem.HisProject.ProjectName
  804. // order.HilistLv = "1"
  805. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  806. // order.HosplistCode = subItem.HisProject.MedicalCode
  807. // order.HosplistName = subItem.HisProject.ProjectName
  808. // order.Cnt = subItem.Count
  809. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  810. //
  811. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  812. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  813. // order.OwnpayAmt = ""
  814. // order.SelfpayAmt = ""
  815. // order.Spec = ""
  816. // order.SpecUnt = ""
  817. // order.DrordBegnDate = s_tm
  818. // order.DrordStopDate = ""
  819. // order.DrordDrCodg = "1"
  820. // order.DrordDeptName = department.Name
  821. // order.DrordDrCodg = "1"
  822. // order.DrordDrName = doctor_info.UserName
  823. // order.DrordDrProfttl = ""
  824. // order.CurrDrordFlag = "1"
  825. // orders = append(orders, &order)
  826. //
  827. // }
  828. // if subItem.Type == 3 {
  829. //
  830. // var order models.FsiOrderDtos
  831. // order.RxID = strconv.FormatInt(item.ID, 10)
  832. // order.Rxno = strconv.FormatInt(item.ID, 10)
  833. // order.LongDrordFlag = "0"
  834. // order.HilistType = "1"
  835. // order.ChrgType = "1"
  836. // order.DrordBhvr = "-"
  837. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  838. // order.HosplistName = subItem.GoodInfo.GoodName
  839. // order.HilistLv = "1"
  840. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  841. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  842. // order.HosplistName = subItem.GoodInfo.GoodName
  843. // order.Cnt = subItem.Count
  844. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  845. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  846. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  847. // order.OwnpayAmt = ""
  848. // order.SelfpayAmt = ""
  849. // order.Spec = ""
  850. // order.SpecUnt = ""
  851. // order.DrordBegnDate = s_tm
  852. // order.DrordStopDate = ""
  853. // order.DrordDrCodg = "1"
  854. // order.DrordDeptName = department.Name
  855. // order.DrordDrCodg = "1"
  856. // order.DrordDrName = doctor_info.UserName
  857. // order.DrordDrProfttl = ""
  858. // order.CurrDrordFlag = "1"
  859. // orders = append(orders, &order)
  860. //
  861. // }
  862. // }
  863. //}
  864. for _, item := range prescriptions {
  865. for _, subItem := range item.HisDoctorAdviceInfo {
  866. var order models.FsiOrderDtos
  867. order.RxID = strconv.FormatInt(item.ID, 10)
  868. order.Rxno = strconv.FormatInt(item.ID, 10)
  869. order.LongDrordFlag = "0"
  870. order.HilistType = "1"
  871. order.ChrgType = "1"
  872. order.DrordBhvr = "-"
  873. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  874. order.HosplistName = subItem.BaseDrugLib.DrugName
  875. order.HilistLv = "1"
  876. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  877. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  878. order.HosplistName = subItem.BaseDrugLib.DrugName
  879. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  880. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  881. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  882. order.OwnpayAmt = ""
  883. order.SelfpayAmt = ""
  884. order.Spec = ""
  885. order.SpecUnt = ""
  886. order.DrordBegnDate = s_tm
  887. order.DrordStopDate = ""
  888. order.DrordDrCodg = "1"
  889. order.DrordDeptName = department.Name
  890. order.DrordDrCodg = "1"
  891. order.DrordDrName = doctor_info.UserName
  892. order.DrordDrProfttl = ""
  893. order.CurrDrordFlag = "1"
  894. orders = append(orders, &order)
  895. }
  896. for _, subItem := range item.HisPrescriptionProject {
  897. if subItem.Type == 2 {
  898. var order models.FsiOrderDtos
  899. order.RxID = strconv.FormatInt(item.ID, 10)
  900. order.Rxno = strconv.FormatInt(item.ID, 10)
  901. order.LongDrordFlag = "0"
  902. order.HilistType = "1"
  903. order.ChrgType = "1"
  904. order.DrordBhvr = "-"
  905. order.HilistCode = subItem.HisProject.MedicalCode
  906. order.HosplistName = subItem.HisProject.ProjectName
  907. order.HilistLv = "1"
  908. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  909. order.HosplistCode = subItem.HisProject.MedicalCode
  910. order.HosplistName = subItem.HisProject.ProjectName
  911. order.Cnt = subItem.Count
  912. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  913. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  914. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  915. order.OwnpayAmt = ""
  916. order.SelfpayAmt = ""
  917. order.Spec = ""
  918. order.SpecUnt = ""
  919. order.DrordBegnDate = s_tm
  920. order.DrordStopDate = ""
  921. order.DrordDrCodg = "1"
  922. order.DrordDeptName = department.Name
  923. order.DrordDrCodg = "1"
  924. order.DrordDrName = doctor_info.UserName
  925. order.DrordDrProfttl = ""
  926. order.CurrDrordFlag = "1"
  927. orders = append(orders, &order)
  928. }
  929. if subItem.Type == 3 {
  930. var order models.FsiOrderDtos
  931. order.RxID = strconv.FormatInt(item.ID, 10)
  932. order.Rxno = strconv.FormatInt(item.ID, 10)
  933. order.LongDrordFlag = "0"
  934. order.HilistType = "1"
  935. order.ChrgType = "1"
  936. order.DrordBhvr = "-"
  937. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  938. order.HosplistName = subItem.GoodInfo.GoodName
  939. order.HilistLv = "1"
  940. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  941. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  942. order.HosplistName = subItem.GoodInfo.GoodName
  943. order.Cnt = subItem.Count
  944. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  945. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  946. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  947. order.OwnpayAmt = ""
  948. order.SelfpayAmt = ""
  949. order.Spec = ""
  950. order.SpecUnt = ""
  951. order.DrordBegnDate = s_tm
  952. order.DrordStopDate = ""
  953. order.DrordDrCodg = "1"
  954. order.DrordDeptName = department.Name
  955. order.DrordDrCodg = "1"
  956. order.DrordDrName = doctor_info.UserName
  957. order.DrordDrProfttl = ""
  958. order.CurrDrordFlag = "1"
  959. orders = append(orders, &order)
  960. }
  961. }
  962. }
  963. //处方医嘱信息
  964. fed.MatnStas = "0"
  965. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  966. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  967. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  968. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  969. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  970. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  971. fed.SetlTotlnum = "1"
  972. fed.Insutype = his.Insutype
  973. fed.ReimFlag = "0"
  974. fed.OutSetlFlag = "0"
  975. var fopd []*models.FsiOperationDtosData
  976. data := make(map[string]interface{})
  977. data["fed"] = fed
  978. data["fdd"] = fdds
  979. data["fod"] = orders
  980. data["pd"] = pd
  981. data["pp"] = pp
  982. data["fopd"] = fopd
  983. data["trig_scen"] = trig_scen
  984. client := &http.Client{}
  985. bytesData, _ := json.Marshal(data)
  986. var req *http.Request
  987. if miConfig.MdtrtareaAdmvs == "320921" {
  988. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  989. } else {
  990. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  991. }
  992. resp, _ := client.Do(req)
  993. defer resp.Body.Close()
  994. body, ioErr := ioutil.ReadAll(resp.Body)
  995. if ioErr != nil {
  996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  998. return res
  999. }
  1000. var respJSON map[string]interface{}
  1001. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1004. return res
  1005. }
  1006. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1007. result, _ := json.Marshal(respJSON)
  1008. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1009. utils.ErrorLog("解析失败:%v", err)
  1010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1011. return res
  1012. }
  1013. return res
  1014. //手术操作集合
  1015. //手术操作集合
  1016. }
  1017. func (c *HisApiController) Check() {
  1018. psn_no := c.GetString("psn_no")
  1019. in := c.GetString("in")
  1020. mt := c.GetString("mt")
  1021. baseParams := models.BaseParams{
  1022. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1023. FixmedinsCode: "H15049901371",
  1024. InsuplcAdmdvs: "150499",
  1025. MdtrtareaAdmvs: "150499",
  1026. OrgName: "赤峰费森血液透析中心",
  1027. Doctor: "1111",
  1028. }
  1029. service.Gdyb2001(baseParams, psn_no, in, mt)
  1030. }
  1031. func (c *HisApiController) GetPsnNcdsInfo() {
  1032. admin_user_id, _ := c.GetInt64("admin_user_id")
  1033. patient_id, _ := c.GetInt64("patient_id")
  1034. id, _ := c.GetInt64("id")
  1035. adminUser := c.GetAdminUserInfo()
  1036. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1037. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1038. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1039. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1040. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1041. //
  1042. //if psn_record.ID == 0 {
  1043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1044. // return
  1045. //}
  1046. var res Result5301
  1047. var res10265 Result5301For10265
  1048. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1049. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1050. var api string
  1051. if miConfig.MdtrtareaAdmvs == "320921" {
  1052. 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 +
  1053. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1054. } else {
  1055. 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 +
  1056. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1057. }
  1058. resp, requestErr := http.Get(api)
  1059. if requestErr != nil {
  1060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1061. return
  1062. }
  1063. body, ioErr := ioutil.ReadAll(resp.Body)
  1064. if ioErr != nil {
  1065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1067. return
  1068. }
  1069. var respJSON map[string]interface{}
  1070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1073. return
  1074. }
  1075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1076. result, _ := json.Marshal(respJSON)
  1077. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1078. utils.ErrorLog("解析失败:%v", err)
  1079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1080. return
  1081. }
  1082. res.ErrMsg = res10265.ErrMsg
  1083. res.Output = res10265.Output
  1084. res.InfRefmsgid = res10265.InfRefmsgid
  1085. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1086. res.Infcode = infocode
  1087. } else {
  1088. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1089. var dat map[string]interface{}
  1090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1091. fmt.Println(dat)
  1092. } else {
  1093. fmt.Println(err)
  1094. }
  1095. userJSONBytes, _ := json.Marshal(dat)
  1096. if miConfig.Code == "H15049901371" {
  1097. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1098. utils.ErrorLog("解析失败:%v", err)
  1099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1100. return
  1101. }
  1102. res.InfRefmsgid = res10265.InfRefmsgid
  1103. res.Output = res10265.Output
  1104. res.ErrMsg = res10265.ErrMsg
  1105. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1106. res.Infcode = infocode
  1107. } else {
  1108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1109. utils.ErrorLog("解析失败:%v", err)
  1110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1111. return
  1112. }
  1113. }
  1114. }
  1115. if res.Infcode == 0 {
  1116. c.ServeSuccessJSON(map[string]interface{}{
  1117. "result": res.Output.Result,
  1118. })
  1119. }
  1120. }
  1121. func (c *HisApiController) CheckInsutype() {
  1122. his_patient_id, _ := c.GetInt64("his_patient_id")
  1123. admin_user_id, _ := c.GetInt64("admin_user_id")
  1124. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1125. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1126. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1127. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1128. var dat map[string]interface{}
  1129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1130. fmt.Println(dat)
  1131. } else {
  1132. fmt.Println(err)
  1133. }
  1134. userJSONBytes, _ := json.Marshal(dat)
  1135. var res Result90100
  1136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. if res.Infcode != 0 {
  1142. c.ServeSuccessJSON(map[string]interface{}{
  1143. "failed_code": -10,
  1144. "msg": res.ErrMsg,
  1145. })
  1146. return
  1147. } else {
  1148. fmt.Println(res)
  1149. }
  1150. }
  1151. func (c *HisApiController) CheckCardPWD() {
  1152. card_pwd := c.GetString("card_pwd")
  1153. his_patient_id, _ := c.GetInt64("his_patient_id")
  1154. admin_user_id, _ := c.GetInt64("admin_user_id")
  1155. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1156. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1157. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1158. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1159. bas := strings.Split(psn.CardInfo, "|")
  1160. basNumber := bas[2]
  1161. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1162. var dat map[string]interface{}
  1163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1164. fmt.Println(dat)
  1165. } else {
  1166. fmt.Println(err)
  1167. }
  1168. userJSONBytes, _ := json.Marshal(dat)
  1169. var res Result90991
  1170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1171. utils.ErrorLog("解析失败:%v", err)
  1172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1173. return
  1174. }
  1175. if res.Infcode != 0 {
  1176. c.ServeSuccessJSON(map[string]interface{}{
  1177. "failed_code": -10,
  1178. "msg": res.ErrMsg,
  1179. })
  1180. return
  1181. } else {
  1182. if res.Output.Result.SscnoCheckStat == "0" {
  1183. var msg string
  1184. switch res.Output.Result.CardStat {
  1185. case "00":
  1186. msg = "未激活"
  1187. break
  1188. case "10":
  1189. msg = "激活"
  1190. break
  1191. case "20":
  1192. msg = "窗口挂失"
  1193. break
  1194. case "21":
  1195. msg = "电话挂失"
  1196. break
  1197. case "22":
  1198. msg = "单位网上申报挂失"
  1199. break
  1200. case "23":
  1201. msg = "保健办挂失"
  1202. break
  1203. case "24":
  1204. msg = "个人网上挂失"
  1205. break
  1206. case "25":
  1207. msg = "网上服务大厅挂失"
  1208. break
  1209. case "30":
  1210. msg = "注销"
  1211. break
  1212. case "40":
  1213. msg = "回收"
  1214. break
  1215. case "99":
  1216. msg = "制卡中(无效卡)"
  1217. break
  1218. }
  1219. c.ServeSuccessJSON(map[string]interface{}{
  1220. "failed_code": -10,
  1221. "msg": msg,
  1222. })
  1223. return
  1224. } else {
  1225. c.ServeSuccessJSON(map[string]interface{}{
  1226. "msg": "校验成功",
  1227. })
  1228. return
  1229. }
  1230. }
  1231. }
  1232. func (c *HisApiController) CheckCardPWDTwo() {
  1233. //card_pwd := c.GetString("card_pwd")
  1234. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1235. admin_user_id, _ := c.GetInt64("admin_user_id")
  1236. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1237. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1238. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1239. var dat map[string]interface{}
  1240. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1241. fmt.Println(dat)
  1242. } else {
  1243. fmt.Println(err)
  1244. }
  1245. userJSONBytes, _ := json.Marshal(dat)
  1246. var res Result90991
  1247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1248. utils.ErrorLog("解析失败:%v", err)
  1249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1250. return
  1251. }
  1252. if res.Infcode != 0 {
  1253. c.ServeSuccessJSON(map[string]interface{}{
  1254. "failed_code": -10,
  1255. "msg": res.ErrMsg,
  1256. })
  1257. return
  1258. } else {
  1259. if res.Output.Result.SscnoCheckStat == "0" {
  1260. var msg string
  1261. switch res.Output.Result.CardStat {
  1262. case "00":
  1263. msg = "未激活"
  1264. break
  1265. case "10":
  1266. msg = "激活"
  1267. break
  1268. case "20":
  1269. msg = "窗口挂失"
  1270. break
  1271. case "21":
  1272. msg = "电话挂失"
  1273. break
  1274. case "22":
  1275. msg = "单位网上申报挂失"
  1276. break
  1277. case "23":
  1278. msg = "保健办挂失"
  1279. break
  1280. case "24":
  1281. msg = "个人网上挂失"
  1282. break
  1283. case "25":
  1284. msg = "网上服务大厅挂失"
  1285. break
  1286. case "30":
  1287. msg = "注销"
  1288. break
  1289. case "40":
  1290. msg = "回收"
  1291. break
  1292. case "99":
  1293. msg = "制卡中(无效卡)"
  1294. break
  1295. }
  1296. c.ServeSuccessJSON(map[string]interface{}{
  1297. "failed_code": -10,
  1298. "msg": msg,
  1299. })
  1300. return
  1301. } else {
  1302. c.ServeSuccessJSON(map[string]interface{}{
  1303. "msg": "校验成功",
  1304. })
  1305. return
  1306. }
  1307. }
  1308. }
  1309. type ELeCertData struct {
  1310. Data struct {
  1311. Extra string `json:"extra"`
  1312. IDNo string `json:"idNo"`
  1313. IDType string `json:"idType"`
  1314. EcToken string `json:"ecToken"`
  1315. InsuOrg string `json:"insuOrg"`
  1316. UserName string `json:"userName"`
  1317. EcIndexNo string `json:"ecIndexNo"`
  1318. Gender string `json:"gender"`
  1319. Birthday string `json:"birthday"`
  1320. Nationality string `json:"nationality"`
  1321. Email string `json:"email"`
  1322. } `json:"OutData"`
  1323. }
  1324. func (c *HisApiController) ReadCard() {
  1325. id_card_type, _ := c.GetInt64("id_card_type")
  1326. admin_user_id, _ := c.GetInt64("admin_user_id")
  1327. certificates, _ := c.GetInt64("certificates")
  1328. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1329. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1330. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1331. switch id_card_type {
  1332. case 1:
  1333. if miConfig.MdtrtareaAdmvs == "421300" {
  1334. var res ResultTwo
  1335. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1336. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1337. "&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)
  1338. resp, requestErr := http.Get(api)
  1339. if requestErr != nil {
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. return
  1342. }
  1343. body, ioErr := ioutil.ReadAll(resp.Body)
  1344. if ioErr != nil {
  1345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1347. return
  1348. }
  1349. var respJSON map[string]interface{}
  1350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1353. return
  1354. }
  1355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1356. result, _ := json.Marshal(respJSON)
  1357. fmt.Println("log")
  1358. fmt.Println(string(result))
  1359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1360. utils.ErrorLog("解析失败:%v", err)
  1361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1362. return
  1363. }
  1364. if res.Infcode == 0 {
  1365. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1366. if err == gorm.ErrRecordNotFound {
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1368. return
  1369. } else if err != nil {
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1371. return
  1372. } else {
  1373. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1374. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1375. infoStr := string(Iinfos)
  1376. idetinfoStr := string(Idetinfos)
  1377. psn := &models.HisPsn{
  1378. PsnNo: res.Output.Baseinfo.PsnNo,
  1379. Age: res.Output.Baseinfo.Age,
  1380. PatientId: patient.ID,
  1381. Certno: res.Output.Baseinfo.Certno,
  1382. Brdy: res.Output.Baseinfo.Brdy,
  1383. Gend: res.Output.Baseinfo.Gend,
  1384. Naty: res.Output.Baseinfo.Naty,
  1385. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1386. PsnName: res.Output.Baseinfo.PsnName,
  1387. Idetinfo: idetinfoStr,
  1388. Insuinfo: infoStr,
  1389. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1390. }
  1391. service.CreateHisPsn(psn)
  1392. c.ServeSuccessJSON(map[string]interface{}{
  1393. "patient": patient,
  1394. "number": res.Output.Baseinfo.Certno,
  1395. })
  1396. }
  1397. } else {
  1398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1399. return
  1400. }
  1401. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1402. var api string
  1403. if miConfig.MdtrtareaAdmvs == "320921" {
  1404. 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 +
  1405. "&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
  1406. fmt.Println(api)
  1407. } else {
  1408. 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 +
  1409. "&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)
  1410. }
  1411. resp, requestErr := http.Get(api)
  1412. if requestErr != nil {
  1413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1414. return
  1415. }
  1416. body, ioErr := ioutil.ReadAll(resp.Body)
  1417. if ioErr != nil {
  1418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1420. return
  1421. }
  1422. var respJSON map[string]interface{}
  1423. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1426. return
  1427. }
  1428. var status string
  1429. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1430. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1431. //console.log()
  1432. fmt.Println("type===")
  1433. fmt.Println(card_type)
  1434. var token string
  1435. var res ResultTwo //1101结果
  1436. var res10265 ResultTwo10265 //1101结果
  1437. var card_info string //卡信息
  1438. var busi_card_info string
  1439. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1440. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1441. if status == "0" { //读卡成功
  1442. if card_type == "1" {
  1443. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1444. result, _ := json.Marshal(respJSON)
  1445. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1446. utils.ErrorLog("解析失败:%v", err)
  1447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1448. return
  1449. }
  1450. res.ErrMsg = res10265.ErrMsg
  1451. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1452. res.Infcode = infocode
  1453. res.Output = res10265.Output
  1454. res.InfRefmsgid = res10265.InfRefmsgid
  1455. } else {
  1456. //var card_info string //卡信息
  1457. //var busi_card_info string
  1458. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1459. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1460. //fmt.Println(card_info)
  1461. //fmt.Println(busi_card_info)
  1462. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1463. result, _ := json.Marshal(respJSON)
  1464. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1465. utils.ErrorLog("解析失败:%v", err)
  1466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1467. return
  1468. }
  1469. res.ErrMsg = res10265.ErrMsg
  1470. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1471. res.Infcode = infocode
  1472. res.Output = res10265.Output
  1473. res.InfRefmsgid = res10265.InfRefmsgid
  1474. }
  1475. if res.Infcode == 0 {
  1476. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1477. if err == gorm.ErrRecordNotFound {
  1478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1479. return
  1480. } else if err != nil {
  1481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1482. return
  1483. } else {
  1484. if card_type == "1" {
  1485. bas := strings.Split(card_info, "|")
  1486. basNumber := bas[2]
  1487. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1488. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1489. infoStr := string(Iinfos)
  1490. idetinfoStr := string(Idetinfos)
  1491. psn := &models.HisPsn{
  1492. PsnNo: res.Output.Baseinfo.PsnNo,
  1493. Age: res.Output.Baseinfo.Age,
  1494. PatientId: patient.ID,
  1495. Certno: res.Output.Baseinfo.Certno,
  1496. Brdy: res.Output.Baseinfo.Brdy,
  1497. Gend: res.Output.Baseinfo.Gend,
  1498. Naty: res.Output.Baseinfo.Naty,
  1499. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1500. PsnName: res.Output.Baseinfo.PsnName,
  1501. Idetinfo: idetinfoStr,
  1502. Insuinfo: infoStr,
  1503. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1504. CardInfo: card_info,
  1505. VerifyNumber: busi_card_info,
  1506. }
  1507. service.CreateHisPsn(psn)
  1508. var rf []*ResultFive
  1509. json.Unmarshal([]byte(infoStr), &rf)
  1510. var insutypes []*ResultFive
  1511. var insutype string
  1512. var is390 int = 0
  1513. var is310 int = 0
  1514. for _, item := range rf {
  1515. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1516. insutypes = append(insutypes, item)
  1517. }
  1518. }
  1519. if len(insutypes) == 1 {
  1520. insutype = insutypes[0].Insutype
  1521. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1522. } else {
  1523. for _, i := range insutypes {
  1524. if i.Insutype == "390" {
  1525. is390 = 1
  1526. }
  1527. if i.Insutype == "310" {
  1528. is310 = 1
  1529. }
  1530. }
  1531. }
  1532. if is390 == 1 {
  1533. insutype = "390"
  1534. }
  1535. if is310 == 1 {
  1536. insutype = "310"
  1537. }
  1538. if len(insutypes) == 0 {
  1539. insutype = "310"
  1540. }
  1541. c.ServeSuccessJSON(map[string]interface{}{
  1542. "patient": patient,
  1543. "number": basNumber,
  1544. "insutype": insutype,
  1545. })
  1546. } else {
  1547. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1548. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1549. infoStr := string(Iinfos)
  1550. idetinfoStr := string(Idetinfos)
  1551. psn := &models.HisPsn{
  1552. PsnNo: res.Output.Baseinfo.PsnNo,
  1553. Age: res.Output.Baseinfo.Age,
  1554. PatientId: patient.ID,
  1555. Certno: res.Output.Baseinfo.Certno,
  1556. Brdy: res.Output.Baseinfo.Brdy,
  1557. Gend: res.Output.Baseinfo.Gend,
  1558. Naty: res.Output.Baseinfo.Naty,
  1559. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1560. PsnName: res.Output.Baseinfo.PsnName,
  1561. Idetinfo: idetinfoStr,
  1562. Insuinfo: infoStr,
  1563. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1564. CardInfo: card_info,
  1565. VerifyNumber: token,
  1566. }
  1567. service.CreateHisPsn(psn)
  1568. c.ServeSuccessJSON(map[string]interface{}{
  1569. "patient": patient,
  1570. "number": token,
  1571. })
  1572. }
  1573. }
  1574. } else {
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1576. return
  1577. }
  1578. } else { //读卡失败
  1579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1580. return
  1581. }
  1582. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1583. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1584. cardnum = DeleteExtraSpaceTwo(cardnum)
  1585. cardCode = DeleteExtraSpaceTwo(cardCode)
  1586. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1587. name = DeleteExtraSpaceTwo(name)
  1588. errmsg = DeleteExtraSpaceTwo(errmsg)
  1589. cardnum = Remove0000(cardnum)
  1590. cardCode = Remove0000(cardCode)
  1591. id_card_no = Remove0000(id_card_no)
  1592. name = Remove0000(name)
  1593. errmsg = Remove0000(errmsg)
  1594. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1595. 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)
  1596. saveLog(result, requestLog, "1101", "获取人员信息")
  1597. fmt.Println(errMsgLog)
  1598. if len(errMsgLog) > 0 {
  1599. } else {
  1600. var dat map[string]interface{}
  1601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1602. fmt.Println(dat)
  1603. } else {
  1604. fmt.Println(err)
  1605. }
  1606. userJSONBytes, _ := json.Marshal(dat)
  1607. var res ResultTwo
  1608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1609. utils.ErrorLog("解析失败:%v", err)
  1610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1611. return
  1612. }
  1613. res.ErrMsg = errMsgLog
  1614. if res.Infcode == 0 {
  1615. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1616. if err == gorm.ErrRecordNotFound {
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1618. return
  1619. } else if err != nil {
  1620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1621. return
  1622. } else {
  1623. fmt.Println(res)
  1624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1626. infoStr := string(Iinfos)
  1627. idetinfoStr := string(Idetinfos)
  1628. psn := &models.HisPsn{
  1629. PsnNo: res.Output.Baseinfo.PsnNo,
  1630. Age: res.Output.Baseinfo.Age,
  1631. PatientId: patient.ID,
  1632. Certno: res.Output.Baseinfo.Certno,
  1633. Brdy: res.Output.Baseinfo.Brdy,
  1634. Gend: res.Output.Baseinfo.Gend,
  1635. Naty: res.Output.Baseinfo.Naty,
  1636. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1637. PsnName: res.Output.Baseinfo.PsnName,
  1638. Idetinfo: idetinfoStr,
  1639. Insuinfo: infoStr,
  1640. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1641. CardInfo: basStr,
  1642. VerifyNumber: "",
  1643. }
  1644. service.CreateHisPsn(psn)
  1645. var rf []*ResultFive
  1646. json.Unmarshal([]byte(infoStr), &rf)
  1647. var insutypes []*ResultFive
  1648. var insutype string
  1649. var is390 int = 0
  1650. var is310 int = 0
  1651. for _, item := range rf {
  1652. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1653. insutypes = append(insutypes, item)
  1654. }
  1655. }
  1656. if len(insutypes) == 1 {
  1657. insutype = insutypes[0].Insutype
  1658. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1659. } else {
  1660. for _, i := range insutypes {
  1661. if i.Insutype == "390" {
  1662. is390 = 1
  1663. }
  1664. if i.Insutype == "310" {
  1665. is310 = 1
  1666. }
  1667. }
  1668. }
  1669. if is390 == 1 {
  1670. insutype = "390"
  1671. }
  1672. if is310 == 1 {
  1673. insutype = "310"
  1674. }
  1675. if len(insutypes) == 0 {
  1676. insutype = "310"
  1677. }
  1678. c.ServeSuccessJSON(map[string]interface{}{
  1679. "patient": patient,
  1680. "number": cardnum,
  1681. "insutype": insutype,
  1682. })
  1683. }
  1684. } else {
  1685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1686. return
  1687. }
  1688. }
  1689. } else {
  1690. if initFlag == 0 {
  1691. c.TestGetBasBaseInit()
  1692. }
  1693. basStr := c.GetBasBaseInfo()
  1694. if len(basStr) == 0 {
  1695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1696. return
  1697. }
  1698. fmt.Println(basStr)
  1699. bas := strings.Split(basStr, "|")
  1700. basNumber := bas[1]
  1701. fmt.Println(basNumber)
  1702. card_sn := bas[3]
  1703. fmt.Println(card_sn)
  1704. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1705. var dat map[string]interface{}
  1706. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1707. fmt.Println(dat)
  1708. } else {
  1709. fmt.Println(err)
  1710. }
  1711. userJSONBytes, _ := json.Marshal(dat)
  1712. var res ResultTwo
  1713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1714. utils.ErrorLog("解析失败:%v", err)
  1715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1716. return
  1717. }
  1718. if res.Infcode == 0 {
  1719. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1720. if err == gorm.ErrRecordNotFound {
  1721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1722. return
  1723. } else if err != nil {
  1724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1725. return
  1726. } else {
  1727. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1728. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1729. infoStr := string(Iinfos)
  1730. idetinfoStr := string(Idetinfos)
  1731. psn := &models.HisPsn{
  1732. PsnNo: res.Output.Baseinfo.PsnNo,
  1733. Age: res.Output.Baseinfo.Age,
  1734. PatientId: patient.ID,
  1735. Certno: res.Output.Baseinfo.Certno,
  1736. Brdy: res.Output.Baseinfo.Brdy,
  1737. Gend: res.Output.Baseinfo.Gend,
  1738. Naty: res.Output.Baseinfo.Naty,
  1739. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1740. PsnName: res.Output.Baseinfo.PsnName,
  1741. Idetinfo: idetinfoStr,
  1742. Insuinfo: infoStr,
  1743. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1744. CardInfo: basStr,
  1745. VerifyNumber: "",
  1746. }
  1747. service.CreateHisPsn(psn)
  1748. c.ServeSuccessJSON(map[string]interface{}{
  1749. "patient": patient,
  1750. "number": basNumber,
  1751. })
  1752. }
  1753. } else {
  1754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1755. return
  1756. }
  1757. break
  1758. }
  1759. case 2:
  1760. SFZStr := c.GetSFZBaseInfo()
  1761. id_card_str := strings.Split(SFZStr, "^")
  1762. id_card_number := id_card_str[0]
  1763. card_sn := ""
  1764. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1765. var dat map[string]interface{}
  1766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1767. fmt.Println(dat)
  1768. } else {
  1769. fmt.Println(err)
  1770. }
  1771. userJSONBytes, _ := json.Marshal(dat)
  1772. var res ResultTwo
  1773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1774. utils.ErrorLog("解析失败:%v", err)
  1775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1776. return
  1777. }
  1778. if res.Infcode == 0 {
  1779. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1780. if err == gorm.ErrRecordNotFound {
  1781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1782. return
  1783. } else if err != nil {
  1784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1785. return
  1786. } else {
  1787. c.ServeSuccessJSON(map[string]interface{}{
  1788. "patient": patient,
  1789. "number": id_card_number,
  1790. })
  1791. }
  1792. } else {
  1793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1794. return
  1795. }
  1796. break
  1797. case 3:
  1798. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1799. var api string
  1800. if miConfig.MdtrtareaAdmvs == "320921" {
  1801. 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 +
  1802. "&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
  1803. fmt.Println(api)
  1804. } else {
  1805. 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 +
  1806. "&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)
  1807. }
  1808. resp, requestErr := http.Get(api)
  1809. if requestErr != nil {
  1810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1811. return
  1812. }
  1813. body, ioErr := ioutil.ReadAll(resp.Body)
  1814. if ioErr != nil {
  1815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1817. return
  1818. }
  1819. var respJSON map[string]interface{}
  1820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. return
  1824. }
  1825. var status string
  1826. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1827. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1828. var token string
  1829. var res ResultTwo //1101结果
  1830. var res10265 ResultTwo10265 //1101结果
  1831. var card_info string //卡信息
  1832. var busi_card_info string
  1833. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1834. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1835. if status == "0" { //读卡成功
  1836. if card_type == "1" {
  1837. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1838. result, _ := json.Marshal(respJSON)
  1839. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1840. utils.ErrorLog("解析失败:%v", err)
  1841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1842. return
  1843. }
  1844. res.ErrMsg = res10265.ErrMsg
  1845. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1846. res.Infcode = infocode
  1847. res.Output = res10265.Output
  1848. res.InfRefmsgid = res10265.InfRefmsgid
  1849. } else {
  1850. //var card_info string //卡信息
  1851. //var busi_card_info string
  1852. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1853. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1854. //fmt.Println(card_info)
  1855. //fmt.Println(busi_card_info)
  1856. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1857. result, _ := json.Marshal(respJSON)
  1858. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1859. utils.ErrorLog("解析失败:%v", err)
  1860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1861. return
  1862. }
  1863. res.ErrMsg = res10265.ErrMsg
  1864. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1865. res.Infcode = infocode
  1866. res.Output = res10265.Output
  1867. res.InfRefmsgid = res10265.InfRefmsgid
  1868. }
  1869. if res.Infcode == 0 {
  1870. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1871. if err == gorm.ErrRecordNotFound {
  1872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1873. return
  1874. } else if err != nil {
  1875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1876. return
  1877. } else {
  1878. if card_type == "1" {
  1879. bas := strings.Split(card_info, "|")
  1880. basNumber := bas[2]
  1881. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1882. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1883. infoStr := string(Iinfos)
  1884. idetinfoStr := string(Idetinfos)
  1885. psn := &models.HisPsn{
  1886. PsnNo: res.Output.Baseinfo.PsnNo,
  1887. Age: res.Output.Baseinfo.Age,
  1888. PatientId: patient.ID,
  1889. Certno: res.Output.Baseinfo.Certno,
  1890. Brdy: res.Output.Baseinfo.Brdy,
  1891. Gend: res.Output.Baseinfo.Gend,
  1892. Naty: res.Output.Baseinfo.Naty,
  1893. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1894. PsnName: res.Output.Baseinfo.PsnName,
  1895. Idetinfo: idetinfoStr,
  1896. Insuinfo: infoStr,
  1897. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1898. CardInfo: card_info,
  1899. VerifyNumber: busi_card_info,
  1900. }
  1901. service.CreateHisPsn(psn)
  1902. c.ServeSuccessJSON(map[string]interface{}{
  1903. "patient": patient,
  1904. "number": basNumber,
  1905. })
  1906. } else {
  1907. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1908. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1909. infoStr := string(Iinfos)
  1910. idetinfoStr := string(Idetinfos)
  1911. psn := &models.HisPsn{
  1912. PsnNo: res.Output.Baseinfo.PsnNo,
  1913. Age: res.Output.Baseinfo.Age,
  1914. PatientId: patient.ID,
  1915. Certno: res.Output.Baseinfo.Certno,
  1916. Brdy: res.Output.Baseinfo.Brdy,
  1917. Gend: res.Output.Baseinfo.Gend,
  1918. Naty: res.Output.Baseinfo.Naty,
  1919. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1920. PsnName: res.Output.Baseinfo.PsnName,
  1921. Idetinfo: idetinfoStr,
  1922. Insuinfo: infoStr,
  1923. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1924. CardInfo: card_info,
  1925. VerifyNumber: token,
  1926. }
  1927. service.CreateHisPsn(psn)
  1928. var rf []*ResultFive
  1929. json.Unmarshal([]byte(infoStr), &rf)
  1930. var insutypes []*ResultFive
  1931. var insutype string
  1932. var is390 int = 0
  1933. var is310 int = 0
  1934. for _, item := range rf {
  1935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1936. insutypes = append(insutypes, item)
  1937. }
  1938. }
  1939. if len(insutypes) == 1 {
  1940. insutype = insutypes[0].Insutype
  1941. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1942. } else {
  1943. for _, i := range insutypes {
  1944. if i.Insutype == "390" {
  1945. is390 = 1
  1946. }
  1947. if i.Insutype == "310" {
  1948. is310 = 1
  1949. }
  1950. }
  1951. }
  1952. if is390 == 1 {
  1953. insutype = "390"
  1954. }
  1955. if is310 == 1 {
  1956. insutype = "310"
  1957. }
  1958. if len(insutypes) == 0 {
  1959. insutype = "310"
  1960. }
  1961. c.ServeSuccessJSON(map[string]interface{}{
  1962. "patient": patient,
  1963. "number": token,
  1964. "insutype": insutype,
  1965. })
  1966. }
  1967. }
  1968. } else {
  1969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1970. return
  1971. }
  1972. } else { //读卡失败
  1973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1974. return
  1975. }
  1976. }
  1977. break
  1978. case 4:
  1979. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1980. var api string
  1981. if miConfig.MdtrtareaAdmvs == "320921" {
  1982. 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 +
  1983. "&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
  1984. fmt.Println(api)
  1985. } else {
  1986. 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 +
  1987. "&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)
  1988. }
  1989. resp, requestErr := http.Get(api)
  1990. if requestErr != nil {
  1991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1992. return
  1993. }
  1994. body, ioErr := ioutil.ReadAll(resp.Body)
  1995. if ioErr != nil {
  1996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1998. return
  1999. }
  2000. var respJSON map[string]interface{}
  2001. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2004. return
  2005. }
  2006. var status string
  2007. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2008. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2009. var token string
  2010. var res ResultTwo //1101结果
  2011. var res10265 ResultTwo10265 //1101结果
  2012. if status == "0" { //读卡成功
  2013. var card_info string //卡信息
  2014. var busi_card_info string
  2015. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2016. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2017. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2018. fmt.Println(card_info)
  2019. fmt.Println(busi_card_info)
  2020. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2021. result, _ := json.Marshal(respJSON)
  2022. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2023. utils.ErrorLog("解析失败:%v", err)
  2024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2025. return
  2026. }
  2027. res.ErrMsg = res10265.ErrMsg
  2028. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2029. res.Infcode = infocode
  2030. res.Output = res10265.Output
  2031. res.InfRefmsgid = res10265.InfRefmsgid
  2032. if res.Infcode == 0 {
  2033. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2034. if err == gorm.ErrRecordNotFound {
  2035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2036. return
  2037. } else if err != nil {
  2038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2039. return
  2040. } else {
  2041. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2042. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2043. infoStr := string(Iinfos)
  2044. idetinfoStr := string(Idetinfos)
  2045. psn := &models.HisPsn{
  2046. PsnNo: res.Output.Baseinfo.PsnNo,
  2047. Age: res.Output.Baseinfo.Age,
  2048. PatientId: patient.ID,
  2049. Certno: res.Output.Baseinfo.Certno,
  2050. Brdy: res.Output.Baseinfo.Brdy,
  2051. Gend: res.Output.Baseinfo.Gend,
  2052. Naty: res.Output.Baseinfo.Naty,
  2053. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2054. PsnName: res.Output.Baseinfo.PsnName,
  2055. Idetinfo: idetinfoStr,
  2056. Insuinfo: infoStr,
  2057. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2058. CardInfo: card_info,
  2059. VerifyNumber: token,
  2060. }
  2061. service.CreateHisPsn(psn)
  2062. c.ServeSuccessJSON(map[string]interface{}{
  2063. "patient": patient,
  2064. "number": token,
  2065. })
  2066. }
  2067. } else {
  2068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2069. return
  2070. }
  2071. } else { //读卡失败
  2072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2073. return
  2074. }
  2075. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2076. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2077. saveLog(result, requestLog, "6101", "电子凭证")
  2078. var ele ELeCertData
  2079. err := json.Unmarshal([]byte(result), &ele)
  2080. if err != nil {
  2081. utils.ErrorLog("解析失败:%v", err)
  2082. }
  2083. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  2084. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2085. var res ResultTwo
  2086. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2087. utils.ErrorLog("解析失败:%v", err)
  2088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2089. return
  2090. }
  2091. if res.Infcode == 0 {
  2092. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2093. if err == gorm.ErrRecordNotFound {
  2094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2095. return
  2096. } else if err != nil {
  2097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2098. return
  2099. } else {
  2100. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2101. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2102. infoStr := string(Iinfos)
  2103. idetinfoStr := string(Idetinfos)
  2104. psn := &models.HisPsn{
  2105. PsnNo: res.Output.Baseinfo.PsnNo,
  2106. Age: res.Output.Baseinfo.Age,
  2107. PatientId: patient.ID,
  2108. Certno: res.Output.Baseinfo.Certno,
  2109. Brdy: res.Output.Baseinfo.Brdy,
  2110. Gend: res.Output.Baseinfo.Gend,
  2111. Naty: res.Output.Baseinfo.Naty,
  2112. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2113. PsnName: res.Output.Baseinfo.PsnName,
  2114. Idetinfo: idetinfoStr,
  2115. Insuinfo: infoStr,
  2116. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2117. CardInfo: "",
  2118. VerifyNumber: ele.Data.EcToken,
  2119. }
  2120. service.CreateHisPsn(psn)
  2121. c.ServeSuccessJSON(map[string]interface{}{
  2122. "patient": patient,
  2123. "number": ele.Data.EcToken,
  2124. })
  2125. }
  2126. } else {
  2127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2128. return
  2129. }
  2130. }
  2131. break
  2132. }
  2133. }
  2134. var initFlag int64 = 0
  2135. func (c *HisApiController) TestGetBasBaseInit() {
  2136. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2137. Iinit := DllDef.MustFindProc("Init")
  2138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2139. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  2140. if ret != 0 {
  2141. fmt.Println("SSCard的报错原因:", err)
  2142. fmt.Println("SSCard的运算结果为:", ret)
  2143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2144. return
  2145. }
  2146. result := int(ret)
  2147. fmt.Println("SSCard的运算结果为1:", result)
  2148. initFlag = 1
  2149. return
  2150. }
  2151. func (c *HisApiController) GetSFZBaseInfo() string {
  2152. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2153. readCard := DllDef.MustFindProc("ReadSFZ")
  2154. if readCard == nil {
  2155. fmt.Println("readcard is nil")
  2156. readCard = DllDef.MustFindProc("ReadSFZ")
  2157. }
  2158. str := make([]byte, 256)
  2159. str1 := make([]byte, 256)
  2160. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2161. fmt.Println(r)
  2162. return string(str)
  2163. }
  2164. func (c *HisApiController) GetBasBaseInfo() string {
  2165. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2166. readCard := DllDef.MustFindProc("ReadCardBas")
  2167. if readCard == nil {
  2168. fmt.Println("readcard is nil")
  2169. readCard = DllDef.MustFindProc("ReadCardBas")
  2170. }
  2171. str := make([]byte, 1024)
  2172. str1 := make([]byte, 1024)
  2173. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2174. fmt.Println(string(str1))
  2175. fmt.Println(string(str))
  2176. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2177. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2178. if ret2 != 0 {
  2179. return ""
  2180. }
  2181. return string(str)
  2182. }
  2183. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  2184. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2185. readCard := DllDef.MustFindProc("read_cardinfo")
  2186. if readCard == nil {
  2187. fmt.Println("readcard is nil")
  2188. readCard = DllDef.MustFindProc("read_cardinfo")
  2189. }
  2190. str := make([]byte, 1024) //卡号
  2191. str1 := make([]byte, 1024) //卡识别码
  2192. str2 := make([]byte, 1024) //身份证号
  2193. str3 := make([]byte, 1024) //姓名
  2194. str4 := make([]byte, 1024) //错误信息
  2195. 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])))
  2196. fmt.Println(string(str1))
  2197. fmt.Println(string(str))
  2198. fmt.Println(string(str2))
  2199. fmt.Println(string(str3))
  2200. fmt.Println(string(str4))
  2201. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2202. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2203. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  2204. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  2205. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  2206. if ret2 != 0 {
  2207. return "", "", "", "", ""
  2208. }
  2209. return string(str), string(str1), string(str2), string(str3), string(str4)
  2210. }
  2211. type CustomFundPay struct {
  2212. FundPayType string `json:"fund_pay_type"`
  2213. FundPayamt float64 `json:"fund_payamt"`
  2214. }
  2215. func (c *HisApiController) GetSettleList() {
  2216. order_id, _ := c.GetInt64("order_id")
  2217. admin_user_id, _ := c.GetInt64("admin_user_id")
  2218. order, _ := service.GetHisOrderByIDTwo(order_id)
  2219. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2220. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2221. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2222. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2223. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2224. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2225. if order.ID == 0 {
  2226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2227. return
  2228. }
  2229. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2230. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2231. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2232. fmt.Println(count)
  2233. var zero string
  2234. number := count + 1
  2235. if number >= 1000 {
  2236. zero = "0000" + strconv.FormatInt(number, 10)
  2237. } else if number >= 10000 {
  2238. zero = "000" + strconv.FormatInt(number, 10)
  2239. } else if number >= 100000 {
  2240. zero = "00" + strconv.FormatInt(number, 10)
  2241. } else if number >= 1000000 {
  2242. zero = "0" + strconv.FormatInt(number, 10)
  2243. } else {
  2244. zero = strconv.FormatInt(number, 10)
  2245. }
  2246. fmt.Println(zero)
  2247. struct4101 := service.Struct4101{
  2248. PsnNo: order.PsnNo,
  2249. MdtrtId: order.MdtrtId,
  2250. SetlId: order.SetlId,
  2251. PsnName: order.PsnName,
  2252. Gend: order.Gend,
  2253. Brdy: his.Brdy,
  2254. Age: his.Age,
  2255. Naty: order.Naty,
  2256. PatnCertType: "01",
  2257. Certno: order.Certno,
  2258. Prfs: "90",
  2259. ConerName: roles[0].UserName,
  2260. PatnRlts: "99",
  2261. ConerAddr: miConfig.OrgName,
  2262. ConerTel: admin.Mobile,
  2263. HiType: order.Insutype,
  2264. Insuplc: miConfig.InsuplcAdmdvs,
  2265. MaindiagFlag: "1",
  2266. BillCode: last_order.FaPiaoCode,
  2267. BillNo: zero,
  2268. BizSn: order.Number,
  2269. PsnSelfPay: order.PsnPartAmt,
  2270. PsnOwnPay: order.PsnPartAmt,
  2271. AcctPay: order.AcctPay,
  2272. PsnCashpay: order.PsnCashPay,
  2273. HiPaymtd: "1",
  2274. Hsorg: miConfig.InsuplcAdmdvs,
  2275. HsorgOpter: miConfig.InsuplcAdmdvs,
  2276. MedinsFillPsn: curRoles.UserName,
  2277. MedinsFillDept: depart.Name,
  2278. IptMedType: "2",
  2279. }
  2280. struct4101.SetlBegnDate = order.SetlTime
  2281. struct4101.SetlEndDate = order.SetlTime
  2282. time_arr := strings.Split(order.SetlTime, " ")
  2283. struct4101.AdmTime = time_arr[0]
  2284. struct4101.AdmEndTime = time_arr[0]
  2285. var rf []CustomFundPay
  2286. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2287. var tempFunPays []service.CustomStruct
  2288. for _, item := range rf {
  2289. var tempFunPay service.CustomStruct
  2290. tempFunPay.FundPayamt = item.FundPayamt
  2291. tempFunPay.FundPayType = item.FundPayType
  2292. tempFunPays = append(tempFunPays, tempFunPay)
  2293. }
  2294. struct4101.CustomStruct = tempFunPays
  2295. var tempDiaginfos []service.DiaginfoStructTwo
  2296. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2297. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2298. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2299. var config []*models.HisXtDiagnoseConfig
  2300. for _, item := range diagnosis_ids {
  2301. id, _ := strconv.ParseInt(item, 10, 64)
  2302. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2303. config = append(config, &diagnosisConfig)
  2304. }
  2305. for index, item := range config {
  2306. if index == 0 {
  2307. var tempDiaginfo service.DiaginfoStructTwo
  2308. tempDiaginfo.DiagCode = item.CountryCode
  2309. tempDiaginfo.DiagName = item.CountryContentName
  2310. tempDiaginfo.DiagType = "1"
  2311. tempDiaginfo.MaindiagFlag = "1"
  2312. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2313. } else {
  2314. var tempDiaginfo service.DiaginfoStructTwo
  2315. tempDiaginfo.DiagCode = item.CountryCode
  2316. tempDiaginfo.DiagName = item.CountryContentName
  2317. tempDiaginfo.DiagType = "2"
  2318. tempDiaginfo.MaindiagFlag = "0"
  2319. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2320. }
  2321. }
  2322. struct4101.Diseinfo = tempDiaginfos
  2323. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2324. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2325. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2326. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2327. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2328. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2329. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2330. var iteminfo service.IteminfoStruct
  2331. var bedCostTotal float64 = 0 //床位总费
  2332. var bedCostSelfTotal float64 = 0 //床位自费
  2333. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2334. var operationCostTotal float64 = 0 //手术费
  2335. var operationCostSelfTotal float64 = 0 //手术费
  2336. var operationCostPartSelfTotal float64 = 0 //手术费
  2337. var otherCostTotal float64 = 0 //其他费用
  2338. var otherCostSelfTotal float64 = 0 //其他费用
  2339. var otherCostPartSelfTotal float64 = 0 //其他费用
  2340. var materialCostTotal float64 = 0 //材料费
  2341. var materialCostSelfTotal float64 = 0 //材料费
  2342. var materialCostPartSelfTotal float64 = 0 //材料费
  2343. var westernMedicineCostTotal float64 = 0 //西药费
  2344. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2345. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2346. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2347. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2348. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2349. var checkCostTotal float64 = 0 //检查费
  2350. var checkCostSelfTotal float64 = 0 //检查费
  2351. var checkCostPartSelfTotal float64 = 0 //检查费
  2352. var laboratoryCostTotal float64 = 0 //化验费
  2353. var laboratoryCostSelfTotal float64 = 0 //化验费
  2354. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2355. var treatCostTotal float64 = 0 //治疗费用
  2356. var treatCostSelfTotal float64 = 0 //治疗费用
  2357. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2358. decimal.DivisionPrecision = 2
  2359. var bed_fulamt_ownpay_amt float64 = 0
  2360. var operation_fulamt_ownpay_amt float64 = 0
  2361. var other_fulamt_ownpay_amt float64 = 0
  2362. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2363. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2364. var check_fulamt_ownpay_amt float64 = 0
  2365. var material_fulamt_ownpay_amt float64 = 0
  2366. var laboratory_fulamt_ownpay_amt float64 = 0
  2367. var treat_fulamt_ownpay_amt float64 = 0
  2368. var bed_claa_sunmfee float64 = 0
  2369. var bed_clab_amt float64 = 0
  2370. var bed_other_amt float64 = 0
  2371. var operation_claa_sunmfee float64 = 0
  2372. var operation_clab_amt float64 = 0
  2373. var operation_other_amt float64 = 0
  2374. var other_claa_sunmfee float64 = 0
  2375. var other_clab_amt float64 = 0
  2376. var other_other_amt float64 = 0
  2377. var westernMedicine_claa_sunmfee float64 = 0
  2378. var westernMedicine_clab_amt float64 = 0
  2379. var westernMedicine_other_amt float64 = 0
  2380. var chineseTraditional_claa_sunmfee float64 = 0
  2381. var chineseTraditional_clab_amt float64 = 0
  2382. var chineseTraditional_other_amt float64 = 0
  2383. var check_claa_sunmfee float64 = 0
  2384. var check_clab_amt float64 = 0
  2385. var check_other_amt float64 = 0
  2386. var material_claa_sunmfee float64 = 0
  2387. var material_clab_amt float64 = 0
  2388. var material_other_amt float64 = 0
  2389. var laboratory_claa_sunmfee float64 = 0
  2390. var laboratory_clab_amt float64 = 0
  2391. var laboratory_other_amt float64 = 0
  2392. var treat_claa_sunmfee float64 = 0
  2393. var treat_clab_amt float64 = 0
  2394. var treat_other_amt float64 = 0
  2395. for _, item := range order.HisOrderInfo {
  2396. if item.MedChrgitmType == "01" { //床位费
  2397. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2398. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2399. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2400. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2401. if item.ChrgitmLv == "1" {
  2402. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2403. }
  2404. if item.ChrgitmLv == "2" {
  2405. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2406. }
  2407. if item.ChrgitmLv == "3" {
  2408. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2409. }
  2410. }
  2411. if item.MedChrgitmType == "03" { //检查费
  2412. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2413. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2414. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2415. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2416. if item.ChrgitmLv == "1" {
  2417. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2418. }
  2419. if item.ChrgitmLv == "2" {
  2420. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2421. }
  2422. if item.ChrgitmLv == "3" {
  2423. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2424. }
  2425. }
  2426. if item.MedChrgitmType == "04" { //化验费
  2427. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2428. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2429. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2430. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2431. if item.ChrgitmLv == "1" {
  2432. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2433. }
  2434. if item.ChrgitmLv == "2" {
  2435. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2436. }
  2437. if item.ChrgitmLv == "3" {
  2438. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2439. }
  2440. }
  2441. if item.MedChrgitmType == "05" { //治疗费
  2442. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2443. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2444. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2445. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2446. if item.ChrgitmLv == "1" {
  2447. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2448. }
  2449. if item.ChrgitmLv == "2" {
  2450. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2451. }
  2452. if item.ChrgitmLv == "3" {
  2453. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2454. }
  2455. }
  2456. if item.MedChrgitmType == "06" { //手术费
  2457. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2458. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2459. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2460. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2461. if item.ChrgitmLv == "1" {
  2462. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2463. }
  2464. if item.ChrgitmLv == "2" {
  2465. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2466. }
  2467. if item.ChrgitmLv == "3" {
  2468. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2469. }
  2470. }
  2471. if item.MedChrgitmType == "08" { //材料费
  2472. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2473. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2474. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2475. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2476. if item.ChrgitmLv == "1" {
  2477. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2478. }
  2479. if item.ChrgitmLv == "2" {
  2480. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2481. }
  2482. if item.ChrgitmLv == "3" {
  2483. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2484. }
  2485. }
  2486. if item.MedChrgitmType == "09" { //西药费
  2487. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2488. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2489. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2490. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2491. if item.ChrgitmLv == "1" {
  2492. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2493. }
  2494. if item.ChrgitmLv == "2" {
  2495. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2496. }
  2497. if item.ChrgitmLv == "3" {
  2498. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2499. }
  2500. }
  2501. if item.MedChrgitmType == "11" { //中成费
  2502. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2503. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2504. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2505. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2506. if item.ChrgitmLv == "1" {
  2507. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2508. }
  2509. if item.ChrgitmLv == "2" {
  2510. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2511. }
  2512. if item.ChrgitmLv == "3" {
  2513. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2514. }
  2515. }
  2516. if item.MedChrgitmType == "14" { //其他费
  2517. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2518. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2519. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2520. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2521. if item.ChrgitmLv == "1" {
  2522. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2523. }
  2524. if item.ChrgitmLv == "2" {
  2525. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2526. }
  2527. if item.ChrgitmLv == "3" {
  2528. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2529. }
  2530. }
  2531. }
  2532. var iteminfoStructs []service.IteminfoStruct
  2533. if bedCostTotal != 0 {
  2534. iteminfo.MedChrgitm = "01"
  2535. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2536. iteminfo.Amt = bedCostTotal
  2537. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2538. iteminfo.ClabAmt = bed_clab_amt
  2539. iteminfo.OthAmt = bed_other_amt
  2540. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2541. }
  2542. if checkCostTotal != 0 {
  2543. iteminfo.MedChrgitm = "03"
  2544. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2545. iteminfo.Amt = checkCostTotal
  2546. iteminfo.ClaaSumfee = check_claa_sunmfee
  2547. iteminfo.ClabAmt = check_clab_amt
  2548. iteminfo.OthAmt = check_other_amt
  2549. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2550. }
  2551. if laboratoryCostTotal != 0 {
  2552. iteminfo.MedChrgitm = "04"
  2553. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2554. iteminfo.Amt = laboratoryCostTotal
  2555. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2556. iteminfo.ClabAmt = laboratory_clab_amt
  2557. iteminfo.OthAmt = laboratory_other_amt
  2558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2559. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2560. }
  2561. if treatCostTotal != 0 {
  2562. iteminfo.MedChrgitm = "05"
  2563. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2564. iteminfo.Amt = treatCostTotal
  2565. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2566. iteminfo.ClabAmt = treat_clab_amt
  2567. iteminfo.OthAmt = treat_other_amt
  2568. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2569. //(struct4101.IteminfoStruct, iteminfo)
  2570. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2571. }
  2572. if operationCostTotal != 0 {
  2573. iteminfo.MedChrgitm = "06"
  2574. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2575. iteminfo.Amt = operationCostTotal
  2576. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2577. iteminfo.ClabAmt = operation_clab_amt
  2578. iteminfo.OthAmt = operation_other_amt
  2579. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2580. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2581. }
  2582. if materialCostTotal != 0 {
  2583. iteminfo.MedChrgitm = "08"
  2584. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2585. iteminfo.Amt = materialCostTotal
  2586. iteminfo.ClaaSumfee = material_claa_sunmfee
  2587. iteminfo.ClabAmt = material_clab_amt
  2588. iteminfo.OthAmt = material_other_amt
  2589. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2590. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2591. }
  2592. if westernMedicineCostTotal != 0 {
  2593. iteminfo.MedChrgitm = "09"
  2594. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2595. iteminfo.Amt = westernMedicineCostTotal
  2596. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2597. iteminfo.ClabAmt = westernMedicine_clab_amt
  2598. iteminfo.OthAmt = westernMedicine_other_amt
  2599. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2600. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2601. }
  2602. if chineseTraditionalMedicineCostTotal != 0 {
  2603. iteminfo.MedChrgitm = "11"
  2604. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2605. iteminfo.Amt = westernMedicineCostTotal
  2606. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2607. iteminfo.ClabAmt = westernMedicine_clab_amt
  2608. iteminfo.OthAmt = westernMedicine_other_amt
  2609. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2610. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2611. }
  2612. if otherCostTotal != 0 {
  2613. iteminfo.MedChrgitm = "14"
  2614. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2615. iteminfo.Amt = otherCostTotal
  2616. iteminfo.ClaaSumfee = other_claa_sunmfee
  2617. iteminfo.ClabAmt = other_clab_amt
  2618. iteminfo.OthAmt = other_other_amt
  2619. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2620. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2621. }
  2622. struct4101.IteminfoStruct = iteminfoStructs
  2623. struct4101.Ntly = "中国"
  2624. struct4101.AdmCaty = "A03.06"
  2625. var res ResultSeventeen
  2626. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2627. struct4101.BillCode = order.Number
  2628. struct4101.BillNo = order.SetlId
  2629. var resOther ResultSeventeenOther
  2630. var pp models.PublicParams
  2631. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2632. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2633. pp.FixmedinsName = miConfig.OrgName
  2634. pp.FixmedinsCode = miConfig.Code
  2635. pp.RequestUrl = miConfig.Url
  2636. pp.Cainfo = miConfig.Cainfo
  2637. pp.SecretKey = miConfig.SecretKey
  2638. pp.AccessKey = miConfig.AccessKey
  2639. pp.OpterName = curRoles.UserName
  2640. client := &http.Client{}
  2641. var req *http.Request
  2642. data := make(map[string]interface{})
  2643. data["struct4101"] = struct4101
  2644. data["pp"] = pp
  2645. bytesData, _ := json.Marshal(data)
  2646. if miConfig.MdtrtareaAdmvs == "320921" {
  2647. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2648. } else {
  2649. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2650. }
  2651. resp, _ := client.Do(req)
  2652. defer resp.Body.Close()
  2653. body, ioErr := ioutil.ReadAll(resp.Body)
  2654. if ioErr != nil {
  2655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2657. return
  2658. }
  2659. var respJSON map[string]interface{}
  2660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2663. return
  2664. }
  2665. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2666. userJSONBytes, _ := json.Marshal(respJSON)
  2667. fmt.Println("log")
  2668. fmt.Println(string(userJSONBytes))
  2669. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2670. utils.ErrorLog("解析失败:%v", err)
  2671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2672. return
  2673. }
  2674. res.InfRefmsgid = resOther.InfRefmsgid
  2675. res.Output = resOther.Output
  2676. res.ErrMsg = resOther.ErrMsg
  2677. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2678. res.Infcode = infocode
  2679. } else {
  2680. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2681. var dat map[string]interface{}
  2682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2683. fmt.Println(dat)
  2684. } else {
  2685. fmt.Println(err)
  2686. }
  2687. userJSONBytes, _ := json.Marshal(dat)
  2688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2689. utils.ErrorLog("解析失败:%v", err)
  2690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2691. return
  2692. }
  2693. }
  2694. if res.Infcode != 0 {
  2695. c.ServeSuccessJSON(map[string]interface{}{
  2696. "failed_code": -10,
  2697. "msg": res.ErrMsg,
  2698. })
  2699. return
  2700. } else {
  2701. order.FaPiaoNumber = zero
  2702. order.FaPiaoCode = last_order.FaPiaoCode
  2703. service.UpdateOrder(order)
  2704. hisFundSettleListResult := &models.HisFundSettleListResult{
  2705. Number: res.Output.SetlListId,
  2706. Status: 1,
  2707. Ctime: time.Now().Unix(),
  2708. Mtime: time.Now().Unix(),
  2709. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2710. IsUpload: 1,
  2711. OrderId: order_id,
  2712. }
  2713. service.CreateUploadRecord(hisFundSettleListResult)
  2714. c.ServeSuccessJSON(map[string]interface{}{
  2715. "msg": "上传成功",
  2716. "result": hisFundSettleListResult,
  2717. })
  2718. return
  2719. }
  2720. }
  2721. func (c *HisApiController) GetSettleListHospital() {
  2722. order_id, _ := c.GetInt64("order_id")
  2723. admin_user_id, _ := c.GetInt64("admin_user_id")
  2724. order, _ := service.GetHisOrderByIDTwo(order_id)
  2725. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2726. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2727. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2728. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2729. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2730. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2731. if order.ID == 0 {
  2732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2733. return
  2734. }
  2735. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2736. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2737. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2738. fmt.Println(count)
  2739. var zero string
  2740. number := count + 1
  2741. if number >= 1000 {
  2742. zero = "0000" + strconv.FormatInt(number, 10)
  2743. } else if number >= 10000 {
  2744. zero = "000" + strconv.FormatInt(number, 10)
  2745. } else if number >= 100000 {
  2746. zero = "00" + strconv.FormatInt(number, 10)
  2747. } else if number >= 1000000 {
  2748. zero = "0" + strconv.FormatInt(number, 10)
  2749. } else {
  2750. zero = strconv.FormatInt(number, 10)
  2751. }
  2752. fmt.Println(zero)
  2753. struct4101 := service.Struct4101{
  2754. PsnNo: order.PsnNo,
  2755. MdtrtId: order.MdtrtId,
  2756. SetlId: order.SetlId,
  2757. PsnName: order.PsnName,
  2758. Gend: order.Gend,
  2759. Brdy: his.Brdy,
  2760. Age: int64(order.Age),
  2761. Naty: order.Naty,
  2762. PatnCertType: "01",
  2763. Certno: order.Certno,
  2764. Prfs: "90",
  2765. ConerName: roles[0].UserName,
  2766. PatnRlts: "99",
  2767. ConerAddr: miConfig.OrgName,
  2768. ConerTel: admin.Mobile,
  2769. HiType: order.Insutype,
  2770. Insuplc: miConfig.InsuplcAdmdvs,
  2771. MaindiagFlag: "1",
  2772. BillCode: order.FaPiaoCode,
  2773. BillNo: order.FaPiaoCode,
  2774. BizSn: order.Number,
  2775. PsnSelfPay: order.PsnPartAmt,
  2776. PsnOwnPay: order.PsnPartAmt,
  2777. AcctPay: order.AcctPay,
  2778. PsnCashpay: order.PsnCashPay,
  2779. HiPaymtd: "1",
  2780. Hsorg: miConfig.InsuplcAdmdvs,
  2781. HsorgOpter: miConfig.InsuplcAdmdvs,
  2782. MedinsFillPsn: curRoles.UserName,
  2783. MedinsFillDept: depart.Name,
  2784. IptMedType: "2",
  2785. AdmTime: his.InHosptialTime,
  2786. AdmEndTime: his.OutHosptialTime,
  2787. }
  2788. struct4101.SetlBegnDate = order.SetlTime
  2789. struct4101.SetlEndDate = order.SetlTime
  2790. var rf []CustomFundPay
  2791. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2792. var tempFunPays []service.CustomStruct
  2793. for _, item := range rf {
  2794. var tempFunPay service.CustomStruct
  2795. tempFunPay.FundPayamt = item.FundPayamt
  2796. tempFunPay.FundPayType = item.FundPayType
  2797. tempFunPays = append(tempFunPays, tempFunPay)
  2798. }
  2799. struct4101.CustomStruct = tempFunPays
  2800. var tempDiaginfos []service.DiaginfoStructTwo
  2801. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2802. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2803. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2804. var config []*models.HisXtDiagnoseConfig
  2805. for _, item := range diagnosis_ids {
  2806. id, _ := strconv.ParseInt(item, 10, 64)
  2807. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2808. config = append(config, &diagnosisConfig)
  2809. }
  2810. for index, item := range config {
  2811. if index == 0 {
  2812. var tempDiaginfo service.DiaginfoStructTwo
  2813. tempDiaginfo.DiagCode = item.CountryCode
  2814. tempDiaginfo.DiagName = item.CountryContentName
  2815. tempDiaginfo.DiagType = "1"
  2816. tempDiaginfo.MaindiagFlag = "1"
  2817. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2818. } else {
  2819. var tempDiaginfo service.DiaginfoStructTwo
  2820. tempDiaginfo.DiagCode = item.CountryCode
  2821. tempDiaginfo.DiagName = item.CountryContentName
  2822. tempDiaginfo.DiagType = "2"
  2823. tempDiaginfo.MaindiagFlag = "0"
  2824. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2825. }
  2826. }
  2827. struct4101.Diseinfo = tempDiaginfos
  2828. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2829. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2830. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2831. tempOpspdiseinfo2.OprnOprtCode = ""
  2832. tempOpspdiseinfo2.OprnOprtName = ""
  2833. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2834. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2835. var iteminfo service.IteminfoStruct
  2836. var bedCostTotal float64 = 0 //床位总费
  2837. var bedCostSelfTotal float64 = 0 //床位自费
  2838. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2839. var operationCostTotal float64 = 0 //手术费
  2840. var operationCostSelfTotal float64 = 0 //手术费
  2841. var operationCostPartSelfTotal float64 = 0 //手术费
  2842. var otherCostTotal float64 = 0 //其他费用
  2843. var otherCostSelfTotal float64 = 0 //其他费用
  2844. var otherCostPartSelfTotal float64 = 0 //其他费用
  2845. var materialCostTotal float64 = 0 //材料费
  2846. var materialCostSelfTotal float64 = 0 //材料费
  2847. var materialCostPartSelfTotal float64 = 0 //材料费
  2848. var westernMedicineCostTotal float64 = 0 //西药费
  2849. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2850. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2851. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2852. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2853. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2854. var checkCostTotal float64 = 0 //检查费
  2855. var checkCostSelfTotal float64 = 0 //检查费
  2856. var checkCostPartSelfTotal float64 = 0 //检查费
  2857. var laboratoryCostTotal float64 = 0 //化验费
  2858. var laboratoryCostSelfTotal float64 = 0 //化验费
  2859. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2860. var treatCostTotal float64 = 0 //治疗费用
  2861. var treatCostSelfTotal float64 = 0 //治疗费用
  2862. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2863. decimal.DivisionPrecision = 2
  2864. var bed_fulamt_ownpay_amt float64 = 0
  2865. var operation_fulamt_ownpay_amt float64 = 0
  2866. var other_fulamt_ownpay_amt float64 = 0
  2867. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2868. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2869. var check_fulamt_ownpay_amt float64 = 0
  2870. var material_fulamt_ownpay_amt float64 = 0
  2871. var laboratory_fulamt_ownpay_amt float64 = 0
  2872. var treat_fulamt_ownpay_amt float64 = 0
  2873. var bed_claa_sunmfee float64 = 0
  2874. var bed_clab_amt float64 = 0
  2875. var bed_other_amt float64 = 0
  2876. var operation_claa_sunmfee float64 = 0
  2877. var operation_clab_amt float64 = 0
  2878. var operation_other_amt float64 = 0
  2879. var other_claa_sunmfee float64 = 0
  2880. var other_clab_amt float64 = 0
  2881. var other_other_amt float64 = 0
  2882. var westernMedicine_claa_sunmfee float64 = 0
  2883. var westernMedicine_clab_amt float64 = 0
  2884. var westernMedicine_other_amt float64 = 0
  2885. var chineseTraditional_claa_sunmfee float64 = 0
  2886. var chineseTraditional_clab_amt float64 = 0
  2887. var chineseTraditional_other_amt float64 = 0
  2888. var check_claa_sunmfee float64 = 0
  2889. var check_clab_amt float64 = 0
  2890. var check_other_amt float64 = 0
  2891. var material_claa_sunmfee float64 = 0
  2892. var material_clab_amt float64 = 0
  2893. var material_other_amt float64 = 0
  2894. var laboratory_claa_sunmfee float64 = 0
  2895. var laboratory_clab_amt float64 = 0
  2896. var laboratory_other_amt float64 = 0
  2897. var treat_claa_sunmfee float64 = 0
  2898. var treat_clab_amt float64 = 0
  2899. var treat_other_amt float64 = 0
  2900. for _, item := range order.HisOrderInfo {
  2901. if item.MedChrgitmType == "01" { //床位费
  2902. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2903. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2904. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2905. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2906. if item.ChrgitmLv == "1" {
  2907. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2908. }
  2909. if item.ChrgitmLv == "2" {
  2910. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2911. }
  2912. if item.ChrgitmLv == "3" {
  2913. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2914. }
  2915. }
  2916. if item.MedChrgitmType == "03" { //检查费
  2917. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2918. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2919. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2920. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2921. if item.ChrgitmLv == "1" {
  2922. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2923. }
  2924. if item.ChrgitmLv == "2" {
  2925. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2926. }
  2927. if item.ChrgitmLv == "3" {
  2928. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2929. }
  2930. }
  2931. if item.MedChrgitmType == "04" { //化验费
  2932. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2933. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2934. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2935. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2936. if item.ChrgitmLv == "1" {
  2937. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2938. }
  2939. if item.ChrgitmLv == "2" {
  2940. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2941. }
  2942. if item.ChrgitmLv == "3" {
  2943. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2944. }
  2945. }
  2946. if item.MedChrgitmType == "05" { //治疗费
  2947. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2948. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2949. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2950. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2951. if item.ChrgitmLv == "1" {
  2952. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2953. }
  2954. if item.ChrgitmLv == "2" {
  2955. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2956. }
  2957. if item.ChrgitmLv == "3" {
  2958. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2959. }
  2960. }
  2961. if item.MedChrgitmType == "06" { //手术费
  2962. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2963. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2964. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2965. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2966. if item.ChrgitmLv == "1" {
  2967. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2968. }
  2969. if item.ChrgitmLv == "2" {
  2970. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2971. }
  2972. if item.ChrgitmLv == "3" {
  2973. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2974. }
  2975. }
  2976. if item.MedChrgitmType == "08" { //材料费
  2977. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2978. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2979. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2980. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2981. if item.ChrgitmLv == "1" {
  2982. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2983. }
  2984. if item.ChrgitmLv == "2" {
  2985. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2986. }
  2987. if item.ChrgitmLv == "3" {
  2988. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2989. }
  2990. }
  2991. if item.MedChrgitmType == "09" { //西药费
  2992. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2993. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2994. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2995. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2996. if item.ChrgitmLv == "1" {
  2997. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2998. }
  2999. if item.ChrgitmLv == "2" {
  3000. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3001. }
  3002. if item.ChrgitmLv == "3" {
  3003. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3004. }
  3005. }
  3006. if item.MedChrgitmType == "11" { //中成费
  3007. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3008. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3009. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3010. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3011. if item.ChrgitmLv == "1" {
  3012. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3013. }
  3014. if item.ChrgitmLv == "2" {
  3015. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3016. }
  3017. if item.ChrgitmLv == "3" {
  3018. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3019. }
  3020. }
  3021. if item.MedChrgitmType == "14" { //其他费
  3022. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3023. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3024. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3025. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3026. if item.ChrgitmLv == "1" {
  3027. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3028. }
  3029. if item.ChrgitmLv == "2" {
  3030. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3031. }
  3032. if item.ChrgitmLv == "3" {
  3033. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3034. }
  3035. }
  3036. }
  3037. var iteminfoStructs []service.IteminfoStruct
  3038. if bedCostTotal != 0 {
  3039. iteminfo.MedChrgitm = "01"
  3040. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3041. iteminfo.Amt = bedCostTotal
  3042. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3043. iteminfo.ClabAmt = bed_clab_amt
  3044. iteminfo.OthAmt = bed_other_amt
  3045. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3046. }
  3047. if checkCostTotal != 0 {
  3048. iteminfo.MedChrgitm = "03"
  3049. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3050. iteminfo.Amt = checkCostTotal
  3051. iteminfo.ClaaSumfee = check_claa_sunmfee
  3052. iteminfo.ClabAmt = check_clab_amt
  3053. iteminfo.OthAmt = check_other_amt
  3054. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3055. }
  3056. if laboratoryCostTotal != 0 {
  3057. iteminfo.MedChrgitm = "04"
  3058. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3059. iteminfo.Amt = laboratoryCostTotal
  3060. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3061. iteminfo.ClabAmt = laboratory_clab_amt
  3062. iteminfo.OthAmt = laboratory_other_amt
  3063. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3064. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3065. }
  3066. if treatCostTotal != 0 {
  3067. iteminfo.MedChrgitm = "05"
  3068. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3069. iteminfo.Amt = treatCostTotal
  3070. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3071. iteminfo.ClabAmt = treat_clab_amt
  3072. iteminfo.OthAmt = treat_other_amt
  3073. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3074. //(struct4101.IteminfoStruct, iteminfo)
  3075. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3076. }
  3077. if operationCostTotal != 0 {
  3078. iteminfo.MedChrgitm = "06"
  3079. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3080. iteminfo.Amt = operationCostTotal
  3081. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3082. iteminfo.ClabAmt = operation_clab_amt
  3083. iteminfo.OthAmt = operation_other_amt
  3084. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3085. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3086. }
  3087. if materialCostTotal != 0 {
  3088. iteminfo.MedChrgitm = "08"
  3089. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3090. iteminfo.Amt = materialCostTotal
  3091. iteminfo.ClaaSumfee = material_claa_sunmfee
  3092. iteminfo.ClabAmt = material_clab_amt
  3093. iteminfo.OthAmt = material_other_amt
  3094. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3095. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3096. }
  3097. if westernMedicineCostTotal != 0 {
  3098. iteminfo.MedChrgitm = "09"
  3099. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3100. iteminfo.Amt = westernMedicineCostTotal
  3101. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3102. iteminfo.ClabAmt = westernMedicine_clab_amt
  3103. iteminfo.OthAmt = westernMedicine_other_amt
  3104. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3105. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3106. }
  3107. if chineseTraditionalMedicineCostTotal != 0 {
  3108. iteminfo.MedChrgitm = "11"
  3109. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3110. iteminfo.Amt = westernMedicineCostTotal
  3111. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3112. iteminfo.ClabAmt = westernMedicine_clab_amt
  3113. iteminfo.OthAmt = westernMedicine_other_amt
  3114. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3115. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3116. }
  3117. if otherCostTotal != 0 {
  3118. iteminfo.MedChrgitm = "14"
  3119. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3120. iteminfo.Amt = otherCostTotal
  3121. iteminfo.ClaaSumfee = other_claa_sunmfee
  3122. iteminfo.ClabAmt = other_clab_amt
  3123. iteminfo.OthAmt = other_other_amt
  3124. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3125. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3126. }
  3127. struct4101.IteminfoStruct = iteminfoStructs
  3128. struct4101.Ntly = "中国"
  3129. struct4101.AdmCaty = "A03.06"
  3130. var resOther ResultSeventeenOther
  3131. var res ResultSeventeen
  3132. if miConfig.MdtrtareaAdmvs == "150499" {
  3133. var pp models.PublicParams
  3134. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3135. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3136. pp.FixmedinsName = miConfig.OrgName
  3137. pp.FixmedinsCode = miConfig.Code
  3138. pp.RequestUrl = miConfig.Url
  3139. pp.Cainfo = miConfig.Cainfo
  3140. pp.SecretKey = miConfig.SecretKey
  3141. pp.AccessKey = miConfig.AccessKey
  3142. pp.OpterName = curRoles.UserName
  3143. client := &http.Client{}
  3144. var req *http.Request
  3145. data := make(map[string]interface{})
  3146. data["struct4101"] = struct4101
  3147. data["pp"] = pp
  3148. bytesData, _ := json.Marshal(data)
  3149. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  3150. resp, _ := client.Do(req)
  3151. defer resp.Body.Close()
  3152. body, ioErr := ioutil.ReadAll(resp.Body)
  3153. if ioErr != nil {
  3154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3156. return
  3157. }
  3158. var respJSON map[string]interface{}
  3159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3162. return
  3163. }
  3164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3165. userJSONBytes, _ := json.Marshal(respJSON)
  3166. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3167. utils.ErrorLog("解析失败:%v", err)
  3168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3169. return
  3170. }
  3171. res.InfRefmsgid = resOther.InfRefmsgid
  3172. res.Output = resOther.Output
  3173. res.ErrMsg = resOther.ErrMsg
  3174. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3175. res.Infcode = infocode
  3176. } else {
  3177. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3178. var dat map[string]interface{}
  3179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3180. fmt.Println(dat)
  3181. } else {
  3182. fmt.Println(err)
  3183. }
  3184. userJSONBytes, _ := json.Marshal(dat)
  3185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3186. utils.ErrorLog("解析失败:%v", err)
  3187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3188. return
  3189. }
  3190. }
  3191. if res.Infcode != 0 {
  3192. c.ServeSuccessJSON(map[string]interface{}{
  3193. "failed_code": -10,
  3194. "msg": res.ErrMsg,
  3195. })
  3196. return
  3197. } else {
  3198. if miConfig.MdtrtareaAdmvs != "150499" {
  3199. order.FaPiaoNumber = zero
  3200. order.FaPiaoCode = last_order.FaPiaoCode
  3201. service.UpdateOrder(order)
  3202. }
  3203. hisFundSettleListResult := &models.HisFundSettleListResult{
  3204. Number: res.Output.SetlListId,
  3205. Status: 1,
  3206. Ctime: time.Now().Unix(),
  3207. Mtime: time.Now().Unix(),
  3208. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3209. IsUpload: 1,
  3210. OrderId: order_id,
  3211. }
  3212. service.CreateUploadRecord(hisFundSettleListResult)
  3213. c.ServeSuccessJSON(map[string]interface{}{
  3214. "msg": "上传成功",
  3215. "result": hisFundSettleListResult,
  3216. })
  3217. return
  3218. }
  3219. }
  3220. func (c *HisApiController) GetBatchSettleList() {
  3221. orders, _ := service.GetAllHisOrder(10106)
  3222. for _, item := range orders {
  3223. order_id := item.ID
  3224. order, _ := service.GetHisOrderByIDTwo(order_id)
  3225. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3226. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3227. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  3229. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3230. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3231. if order.ID == 0 {
  3232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3233. return
  3234. }
  3235. if his.BalanceAccountsType == 2 {
  3236. continue
  3237. }
  3238. struct4101 := service.Struct4101{
  3239. PsnNo: order.PsnNo,
  3240. MdtrtId: order.MdtrtId,
  3241. SetlId: order.SetlId,
  3242. PsnName: order.PsnName,
  3243. Gend: order.Gend,
  3244. Brdy: his.Brdy,
  3245. Age: his.Age,
  3246. Naty: order.Naty,
  3247. PatnCertType: "01",
  3248. Certno: order.Certno,
  3249. Prfs: "90",
  3250. ConerName: roles[0].UserName,
  3251. PatnRlts: "99",
  3252. ConerAddr: miConfig.OrgName,
  3253. ConerTel: admin.Mobile,
  3254. HiType: order.Insutype,
  3255. Insuplc: his.InsuplcAdmdvs,
  3256. MaindiagFlag: "1",
  3257. BillCode: order.FaPiaoCode,
  3258. BillNo: order.FaPiaoNumber,
  3259. BizSn: order.Number,
  3260. PsnSelfPay: order.PsnPartAmt,
  3261. PsnOwnPay: order.PsnPartAmt,
  3262. AcctPay: order.AcctPay,
  3263. PsnCashpay: order.PsnCashPay,
  3264. HiPaymtd: "1",
  3265. Hsorg: his.InsuplcAdmdvs,
  3266. HsorgOpter: his.InsuplcAdmdvs,
  3267. MedinsFillPsn: curRoles.UserName,
  3268. MedinsFillDept: depart.Name,
  3269. IptMedType: "2",
  3270. }
  3271. struct4101.SetlBegnDate = order.SetlTime
  3272. struct4101.SetlEndDate = order.SetlTime
  3273. //if order.SettleType == 1 {
  3274. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  3275. // dateStr := t.Format("2006-01-02")
  3276. // struct4101.SetlBegnDate = dateStr
  3277. // struct4101.SetlEndDate = dateStr
  3278. //} else {
  3279. // t := time.Unix(int64(order.SettleStartTime), 0)
  3280. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  3281. // dateStartStr := t.Format("2006-01-02")
  3282. // dateEndStr := t2.Format("2006-01-02")
  3283. // struct4101.SetlBegnDate = dateStartStr
  3284. // struct4101.SetlEndDate = dateEndStr
  3285. //}
  3286. var rf []CustomFundPay
  3287. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3288. var tempFunPays []service.CustomStruct
  3289. var tempFunPay610100 service.CustomStruct
  3290. for _, item := range rf {
  3291. if item.FundPayType == "610100" {
  3292. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  3293. tempFunPay610100.FundPayType = item.FundPayType
  3294. } else {
  3295. var tempFunPay service.CustomStruct
  3296. tempFunPay.FundPayamt = item.FundPayamt
  3297. tempFunPay.FundPayType = item.FundPayType
  3298. tempFunPays = append(tempFunPays, tempFunPay)
  3299. }
  3300. }
  3301. tempFunPays = append(tempFunPays, tempFunPay610100)
  3302. struct4101.CustomStruct = tempFunPays
  3303. var tempDiaginfos []service.DiaginfoStructTwo
  3304. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3305. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3306. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3307. var config []*models.HisXtDiagnoseConfig
  3308. for _, item := range diagnosis_ids {
  3309. id, _ := strconv.ParseInt(item, 10, 64)
  3310. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3311. config = append(config, &diagnosisConfig)
  3312. }
  3313. for index, item := range config {
  3314. if index == 0 {
  3315. var tempDiaginfo service.DiaginfoStructTwo
  3316. tempDiaginfo.DiagCode = item.CountryCode
  3317. tempDiaginfo.DiagName = item.CountryContentName
  3318. tempDiaginfo.DiagType = "1"
  3319. tempDiaginfo.MaindiagFlag = "1"
  3320. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3321. } else {
  3322. var tempDiaginfo service.DiaginfoStructTwo
  3323. tempDiaginfo.DiagCode = item.CountryCode
  3324. tempDiaginfo.DiagName = item.CountryContentName
  3325. tempDiaginfo.DiagType = "2"
  3326. tempDiaginfo.MaindiagFlag = "0"
  3327. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3328. }
  3329. }
  3330. struct4101.Diseinfo = tempDiaginfos
  3331. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3332. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3333. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3334. tempOpspdiseinfo2.OprnOprtCode = ""
  3335. tempOpspdiseinfo2.OprnOprtName = ""
  3336. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3337. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3338. var iteminfo service.IteminfoStruct
  3339. var bedCostTotal float64 = 0 //床位总费
  3340. var bedCostSelfTotal float64 = 0 //床位自费
  3341. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3342. var examineCostTotal float64 = 0 //诊查总费
  3343. var examineCostSelfTotal float64 = 0 //诊查自费
  3344. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3345. var nursingCostTotal float64 = 0 //护理总费
  3346. var nursingCostSelfTotal float64 = 0 //护理自费
  3347. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3348. var chineseMedicineCostTotal float64 = 0 //中成药
  3349. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3350. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3351. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3352. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3353. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3354. var registerCostTotal float64 = 0 //一般诊疗费
  3355. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3356. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3357. var operationCostTotal float64 = 0 //手术费
  3358. var operationCostSelfTotal float64 = 0 //手术费
  3359. var operationCostPartSelfTotal float64 = 0 //手术费
  3360. var otherCostTotal float64 = 0 //其他费用
  3361. var otherCostSelfTotal float64 = 0 //其他费用
  3362. var otherCostPartSelfTotal float64 = 0 //其他费用
  3363. var materialCostTotal float64 = 0 //材料费
  3364. var materialCostSelfTotal float64 = 0 //材料费
  3365. var materialCostPartSelfTotal float64 = 0 //材料费
  3366. var westernMedicineCostTotal float64 = 0 //西药费
  3367. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3368. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3369. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3370. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3371. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3372. var checkCostTotal float64 = 0 //检查费
  3373. var checkCostSelfTotal float64 = 0 //检查费
  3374. var checkCostPartSelfTotal float64 = 0 //检查费
  3375. var laboratoryCostTotal float64 = 0 //化验费
  3376. var laboratoryCostSelfTotal float64 = 0 //化验费
  3377. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3378. var treatCostTotal float64 = 0 //治疗费用
  3379. var treatCostSelfTotal float64 = 0 //治疗费用
  3380. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3381. decimal.DivisionPrecision = 2
  3382. var bed_fulamt_ownpay_amt float64 = 0
  3383. var examine_fulamt_ownpay_amt float64 = 0
  3384. var nursing_fulamt_ownpay_amt float64 = 0
  3385. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3386. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3387. var register_fulamt_ownpay_amt float64 = 0
  3388. var operation_fulamt_ownpay_amt float64 = 0
  3389. var other_fulamt_ownpay_amt float64 = 0
  3390. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3391. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3392. var check_fulamt_ownpay_amt float64 = 0
  3393. var material_fulamt_ownpay_amt float64 = 0
  3394. var laboratory_fulamt_ownpay_amt float64 = 0
  3395. var treat_fulamt_ownpay_amt float64 = 0
  3396. var bed_claa_sunmfee float64 = 0
  3397. var bed_clab_amt float64 = 0
  3398. var bed_other_amt float64 = 0
  3399. var examine_claa_sunmfee float64 = 0
  3400. var examine_clab_amt float64 = 0
  3401. var examine_other_amt float64 = 0
  3402. var nursing_claa_sunmfee float64 = 0
  3403. var nursing_clab_amt float64 = 0
  3404. var nursing_other_amt float64 = 0
  3405. var chinese_medicine_claa_sunmfee float64 = 0
  3406. var chinese_medicine_clab_amt float64 = 0
  3407. var chinese_medicine_other_amt float64 = 0
  3408. var commonly_treatment_claa_sunmfee float64 = 0
  3409. var commonly_treatment_clab_amt float64 = 0
  3410. var commonly_treatment_other_amt float64 = 0
  3411. var operation_claa_sunmfee float64 = 0
  3412. var operation_clab_amt float64 = 0
  3413. var operation_other_amt float64 = 0
  3414. var other_claa_sunmfee float64 = 0
  3415. var other_clab_amt float64 = 0
  3416. var other_other_amt float64 = 0
  3417. var westernMedicine_claa_sunmfee float64 = 0
  3418. var westernMedicine_clab_amt float64 = 0
  3419. var westernMedicine_other_amt float64 = 0
  3420. var chineseTraditional_claa_sunmfee float64 = 0
  3421. var chineseTraditional_clab_amt float64 = 0
  3422. var chineseTraditional_other_amt float64 = 0
  3423. var check_claa_sunmfee float64 = 0
  3424. var check_clab_amt float64 = 0
  3425. var check_other_amt float64 = 0
  3426. var material_claa_sunmfee float64 = 0
  3427. var material_clab_amt float64 = 0
  3428. var material_other_amt float64 = 0
  3429. var laboratory_claa_sunmfee float64 = 0
  3430. var laboratory_clab_amt float64 = 0
  3431. var laboratory_other_amt float64 = 0
  3432. var treat_claa_sunmfee float64 = 0
  3433. var treat_clab_amt float64 = 0
  3434. var treat_other_amt float64 = 0
  3435. var register_claa_sunmfee float64 = 0
  3436. var register_clab_amt float64 = 0
  3437. var register_other_amt float64 = 0
  3438. for _, item := range order.HisOrderInfo {
  3439. if item.MedChrgitmType == "01" { //床位费
  3440. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3441. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3442. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3443. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3444. if item.ChrgitmLv == "1" {
  3445. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3446. }
  3447. if item.ChrgitmLv == "2" {
  3448. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3449. }
  3450. if item.ChrgitmLv == "3" {
  3451. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3452. }
  3453. }
  3454. if item.MedChrgitmType == "02" { //诊查
  3455. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3456. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3457. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3458. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3459. if item.ChrgitmLv == "1" {
  3460. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3461. }
  3462. if item.ChrgitmLv == "2" {
  3463. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3464. }
  3465. if item.ChrgitmLv == "3" {
  3466. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3467. }
  3468. }
  3469. if item.MedChrgitmType == "03" { //检查费
  3470. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3471. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3472. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3473. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3474. if item.ChrgitmLv == "1" {
  3475. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3476. }
  3477. if item.ChrgitmLv == "2" {
  3478. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3479. }
  3480. if item.ChrgitmLv == "3" {
  3481. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3482. }
  3483. }
  3484. if item.MedChrgitmType == "04" { //化验费
  3485. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3486. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3487. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3488. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3489. if item.ChrgitmLv == "1" {
  3490. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3491. }
  3492. if item.ChrgitmLv == "2" {
  3493. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3494. }
  3495. if item.ChrgitmLv == "3" {
  3496. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3497. }
  3498. }
  3499. if item.MedChrgitmType == "05" { //治疗费
  3500. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3501. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3502. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3503. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3504. if item.ChrgitmLv == "1" {
  3505. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3506. }
  3507. if item.ChrgitmLv == "2" {
  3508. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3509. }
  3510. if item.ChrgitmLv == "3" {
  3511. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3512. }
  3513. }
  3514. if item.MedChrgitmType == "06" { //手术费
  3515. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3516. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3517. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3518. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3519. if item.ChrgitmLv == "1" {
  3520. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3521. }
  3522. if item.ChrgitmLv == "2" {
  3523. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3524. }
  3525. if item.ChrgitmLv == "3" {
  3526. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3527. }
  3528. }
  3529. if item.MedChrgitmType == "07" { //手术费
  3530. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3531. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3532. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3533. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3534. if item.ChrgitmLv == "1" {
  3535. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3536. }
  3537. if item.ChrgitmLv == "2" {
  3538. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3539. }
  3540. if item.ChrgitmLv == "3" {
  3541. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3542. }
  3543. }
  3544. if item.MedChrgitmType == "08" { //材料费
  3545. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3546. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3547. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3548. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3549. if item.ChrgitmLv == "1" {
  3550. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3551. }
  3552. if item.ChrgitmLv == "2" {
  3553. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3554. }
  3555. if item.ChrgitmLv == "3" {
  3556. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3557. }
  3558. }
  3559. if item.MedChrgitmType == "09" { //西药费
  3560. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3561. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3562. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3563. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3564. if item.ChrgitmLv == "1" {
  3565. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3566. }
  3567. if item.ChrgitmLv == "2" {
  3568. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3569. }
  3570. if item.ChrgitmLv == "3" {
  3571. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3572. }
  3573. }
  3574. if item.MedChrgitmType == "10" { //中药饮片
  3575. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3576. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3577. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3578. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3579. if item.ChrgitmLv == "1" {
  3580. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3581. }
  3582. if item.ChrgitmLv == "2" {
  3583. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3584. }
  3585. if item.ChrgitmLv == "3" {
  3586. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3587. }
  3588. }
  3589. if item.MedChrgitmType == "11" { //中成费
  3590. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3591. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3592. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3593. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3594. if item.ChrgitmLv == "1" {
  3595. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3596. }
  3597. if item.ChrgitmLv == "2" {
  3598. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3599. }
  3600. if item.ChrgitmLv == "3" {
  3601. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3602. }
  3603. }
  3604. if item.MedChrgitmType == "12" { //中成费
  3605. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3606. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3607. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3608. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3609. if item.ChrgitmLv == "1" {
  3610. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3611. }
  3612. if item.ChrgitmLv == "2" {
  3613. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3614. }
  3615. if item.ChrgitmLv == "3" {
  3616. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3617. }
  3618. }
  3619. if item.MedChrgitmType == "13" { //中成费
  3620. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3621. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3622. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3623. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3624. if item.ChrgitmLv == "1" {
  3625. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3626. }
  3627. if item.ChrgitmLv == "2" {
  3628. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3629. }
  3630. if item.ChrgitmLv == "3" {
  3631. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3632. }
  3633. }
  3634. if item.MedChrgitmType == "14" { //其他费
  3635. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3636. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3637. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3638. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3639. if item.ChrgitmLv == "1" {
  3640. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3641. }
  3642. if item.ChrgitmLv == "2" {
  3643. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3644. }
  3645. if item.ChrgitmLv == "3" {
  3646. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3647. }
  3648. }
  3649. }
  3650. var iteminfoStructs []service.IteminfoStruct
  3651. if bedCostTotal != 0 {
  3652. iteminfo.MedChrgitm = "01"
  3653. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3654. iteminfo.Amt = bedCostTotal
  3655. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3656. iteminfo.ClabAmt = bed_clab_amt
  3657. iteminfo.OthAmt = bed_other_amt
  3658. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3659. }
  3660. if examineCostTotal != 0 {
  3661. iteminfo.MedChrgitm = "02"
  3662. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3663. iteminfo.Amt = examineCostTotal
  3664. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3665. iteminfo.ClabAmt = examine_clab_amt
  3666. iteminfo.OthAmt = examine_other_amt
  3667. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3668. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3669. }
  3670. if checkCostTotal != 0 {
  3671. iteminfo.MedChrgitm = "03"
  3672. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3673. iteminfo.Amt = checkCostTotal
  3674. iteminfo.ClaaSumfee = check_claa_sunmfee
  3675. iteminfo.ClabAmt = check_clab_amt
  3676. iteminfo.OthAmt = check_other_amt
  3677. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3678. }
  3679. if laboratoryCostTotal != 0 {
  3680. iteminfo.MedChrgitm = "04"
  3681. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3682. iteminfo.Amt = laboratoryCostTotal
  3683. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3684. iteminfo.ClabAmt = laboratory_clab_amt
  3685. iteminfo.OthAmt = laboratory_other_amt
  3686. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3687. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3688. }
  3689. if treatCostTotal != 0 {
  3690. iteminfo.MedChrgitm = "05"
  3691. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3692. iteminfo.Amt = treatCostTotal
  3693. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3694. iteminfo.ClabAmt = treat_clab_amt
  3695. iteminfo.OthAmt = treat_other_amt
  3696. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3697. //(struct4101.IteminfoStruct, iteminfo)
  3698. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3699. }
  3700. if operationCostTotal != 0 {
  3701. iteminfo.MedChrgitm = "06"
  3702. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3703. iteminfo.Amt = operationCostTotal
  3704. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3705. iteminfo.ClabAmt = operation_clab_amt
  3706. iteminfo.OthAmt = operation_other_amt
  3707. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3708. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3709. }
  3710. if nursingCostTotal != 0 {
  3711. iteminfo.MedChrgitm = "07"
  3712. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3713. iteminfo.Amt = nursingCostTotal
  3714. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3715. iteminfo.ClabAmt = nursing_clab_amt
  3716. iteminfo.OthAmt = nursing_other_amt
  3717. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3718. }
  3719. if materialCostTotal != 0 {
  3720. iteminfo.MedChrgitm = "08"
  3721. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3722. iteminfo.Amt = materialCostTotal
  3723. iteminfo.ClaaSumfee = material_claa_sunmfee
  3724. iteminfo.ClabAmt = material_clab_amt
  3725. iteminfo.OthAmt = material_other_amt
  3726. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3727. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3728. }
  3729. if westernMedicineCostTotal != 0 {
  3730. iteminfo.MedChrgitm = "09"
  3731. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3732. iteminfo.Amt = westernMedicineCostTotal
  3733. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3734. iteminfo.ClabAmt = westernMedicine_clab_amt
  3735. iteminfo.OthAmt = westernMedicine_other_amt
  3736. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3737. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3738. }
  3739. if chineseMedicineCostTotal != 0 {
  3740. iteminfo.MedChrgitm = "10"
  3741. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3742. iteminfo.Amt = chineseMedicineCostTotal
  3743. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3744. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3745. iteminfo.OthAmt = chinese_medicine_other_amt
  3746. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3747. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3748. }
  3749. if chineseTraditionalMedicineCostTotal != 0 {
  3750. iteminfo.MedChrgitm = "11"
  3751. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3752. iteminfo.Amt = westernMedicineCostTotal
  3753. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3754. iteminfo.ClabAmt = westernMedicine_clab_amt
  3755. iteminfo.OthAmt = westernMedicine_other_amt
  3756. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3757. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3758. }
  3759. if commonlyTreatmentCostTotal != 0 {
  3760. iteminfo.MedChrgitm = "12"
  3761. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3762. iteminfo.Amt = commonlyTreatmentCostTotal
  3763. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3764. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3765. iteminfo.OthAmt = commonly_treatment_other_amt
  3766. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3767. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3768. }
  3769. if registerCostTotal != 0 {
  3770. iteminfo.MedChrgitm = "13"
  3771. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3772. iteminfo.Amt = registerCostTotal
  3773. iteminfo.ClaaSumfee = register_claa_sunmfee
  3774. iteminfo.ClabAmt = register_clab_amt
  3775. iteminfo.OthAmt = register_other_amt
  3776. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3778. }
  3779. if otherCostTotal != 0 {
  3780. iteminfo.MedChrgitm = "14"
  3781. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3782. iteminfo.Amt = otherCostTotal
  3783. iteminfo.ClaaSumfee = other_claa_sunmfee
  3784. iteminfo.ClabAmt = other_clab_amt
  3785. iteminfo.OthAmt = other_other_amt
  3786. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3787. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3788. }
  3789. struct4101.IteminfoStruct = iteminfoStructs
  3790. struct4101.Ntly = "中国"
  3791. struct4101.AdmCaty = "A03.06"
  3792. var res ResultSeventeen
  3793. if miConfig.MdtrtareaAdmvs == "421300" {
  3794. data := make(map[string]interface{})
  3795. data["struct4101"] = struct4101
  3796. data["secret_key"] = miConfig.SecretKey
  3797. data["org_name"] = miConfig.OrgName
  3798. data["opera"] = curRoles.UserName
  3799. data["code"] = miConfig.Code
  3800. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3801. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3802. client := &http.Client{}
  3803. bytesData, _ := json.Marshal(data)
  3804. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3805. resp, _ := client.Do(req)
  3806. defer resp.Body.Close()
  3807. body, ioErr := ioutil.ReadAll(resp.Body)
  3808. if ioErr != nil {
  3809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. return
  3812. }
  3813. var respJSON map[string]interface{}
  3814. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3817. return
  3818. }
  3819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3820. userJSONBytes, _ := json.Marshal(respJSON)
  3821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3822. utils.ErrorLog("解析失败:%v", err)
  3823. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3824. adminUser := c.GetAdminUserInfo()
  3825. errlog := &models.HisOrderError{
  3826. UserOrgId: adminUser.CurrentOrgId,
  3827. Ctime: time.Now().Unix(),
  3828. Mtime: time.Now().Unix(),
  3829. ErrMsg: res.ErrMsg + "解析失败",
  3830. Status: 1,
  3831. PatientId: order_id,
  3832. Stage: 10088,
  3833. }
  3834. service.CreateErrMsgLog(errlog)
  3835. continue
  3836. }
  3837. } else {
  3838. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3839. fmt.Println(result)
  3840. var dat map[string]interface{}
  3841. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3842. fmt.Println(dat)
  3843. } else {
  3844. fmt.Println(err)
  3845. }
  3846. userJSONBytes, _ := json.Marshal(dat)
  3847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3848. utils.ErrorLog("解析失败:%v", err)
  3849. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. adminUser := c.GetAdminUserInfo()
  3851. errlog := &models.HisOrderError{
  3852. UserOrgId: adminUser.CurrentOrgId,
  3853. Ctime: time.Now().Unix(),
  3854. Mtime: time.Now().Unix(),
  3855. ErrMsg: res.ErrMsg + "解析失败",
  3856. Status: 1,
  3857. PatientId: order_id,
  3858. Stage: 10106,
  3859. }
  3860. service.CreateErrMsgLog(errlog)
  3861. continue
  3862. }
  3863. }
  3864. if res.Infcode != 0 {
  3865. adminUser := c.GetAdminUserInfo()
  3866. errlog := &models.HisOrderError{
  3867. UserOrgId: adminUser.CurrentOrgId,
  3868. Ctime: time.Now().Unix(),
  3869. Mtime: time.Now().Unix(),
  3870. ErrMsg: res.ErrMsg,
  3871. Status: 1,
  3872. PatientId: order_id,
  3873. Stage: 10106,
  3874. }
  3875. service.CreateErrMsgLog(errlog)
  3876. continue
  3877. } else {
  3878. hisFundSettleListResult := &models.HisFundSettleListResult{
  3879. Number: res.Output.SetlListId,
  3880. Status: 1,
  3881. Ctime: time.Now().Unix(),
  3882. Mtime: time.Now().Unix(),
  3883. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3884. IsUpload: 1,
  3885. OrderId: order_id,
  3886. }
  3887. service.CreateUploadRecord(hisFundSettleListResult)
  3888. continue
  3889. }
  3890. }
  3891. }
  3892. func (c *HisApiController) GetOrgInfo() {
  3893. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3894. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3895. }
  3896. func (c *HisApiController) GetHisPatientInfo() {
  3897. medical_insurance_card := c.GetString("medical_insurance_card")
  3898. id_card_type, _ := c.GetInt64("id_card_type")
  3899. id_card := c.GetString("id_card")
  3900. adminInfo := c.GetAdminUserInfo()
  3901. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3902. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3903. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3904. IdCardNo := ""
  3905. if id_card_type == 1 {
  3906. IdCardNo = medical_insurance_card
  3907. } else if id_card_type == 2 {
  3908. IdCardNo = id_card
  3909. }
  3910. if config.IsOpen == 1 {
  3911. 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
  3912. resp, requestErr := http.Get(api)
  3913. if requestErr != nil {
  3914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3915. return
  3916. }
  3917. defer resp.Body.Close()
  3918. body, ioErr := ioutil.ReadAll(resp.Body)
  3919. if ioErr != nil {
  3920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3922. return
  3923. }
  3924. var respJSON map[string]interface{}
  3925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3928. return
  3929. }
  3930. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3931. userJSONBytes, _ := json.Marshal(userJSON)
  3932. var res ResultTwo
  3933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3934. utils.ErrorLog("解析失败:%v", err)
  3935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3936. return
  3937. }
  3938. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3939. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3940. infoStr := string(Iinfos)
  3941. idetinfoStr := string(Idetinfos)
  3942. if res.Infcode == 0 {
  3943. his := models.VMHisPatient{
  3944. Status: 1,
  3945. Ctime: time.Now().Unix(),
  3946. Mtime: time.Now().Unix(),
  3947. PsnNo: res.Output.Baseinfo.PsnNo,
  3948. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3949. Certno: res.Output.Baseinfo.Certno,
  3950. PsnName: res.Output.Baseinfo.PsnName,
  3951. Gend: res.Output.Baseinfo.Gend,
  3952. Naty: res.Output.Baseinfo.Naty,
  3953. Brdy: res.Output.Baseinfo.Brdy,
  3954. Age: res.Output.Baseinfo.Age,
  3955. Iinfo: infoStr,
  3956. Idetinfo: idetinfoStr,
  3957. UserOrgId: adminInfo.CurrentOrgId,
  3958. IsReturn: 1,
  3959. IdCardType: id_card_type,
  3960. }
  3961. c.ServeSuccessJSON(map[string]interface{}{
  3962. "info": his,
  3963. })
  3964. } else {
  3965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3966. return
  3967. }
  3968. }
  3969. }
  3970. //func GetBasBaseInfo() (jsonStr string, err error) {
  3971. //
  3972. // handle := syscall.NewLazyDLL("SSCard.dll")
  3973. // add := handle.NewProc("ReadCardBas")
  3974. // str := make([]byte, 1024)
  3975. // str1 := make([]byte, 1024)
  3976. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3977. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3978. //
  3979. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3980. //
  3981. // fmt.Println("> Add(4,5)的结果为:", ret)
  3982. // handle.Release()
  3983. //
  3984. // return "", nil
  3985. //
  3986. //}
  3987. //func GetQRBaseInfo() (jsonStr string, err error) {
  3988. // handle := syscall.LoadDLL("SSCard.dll")
  3989. // ReadCardBas := handle.FindProc("GetQRBase")
  3990. //
  3991. // str := make([]byte, 256)
  3992. // str1 := make([]byte, 256)
  3993. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3994. //
  3995. // fmt.Println(string(str))
  3996. // fmt.Println(r)
  3997. // return string(str), nil
  3998. //}
  3999. //func CardInit() int {
  4000. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  4001. // add := DllTestDef.MustFindProc("Init")
  4002. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4003. // if err != nil {
  4004. // fmt.Println("SSCard的运算结果为:", ret)
  4005. // }
  4006. // result := int(ret)
  4007. // return result
  4008. //}
  4009. //func CardInit() int {
  4010. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4011. // if err != nil {
  4012. // fmt.Println("SSCard的运算结果为:", ret)
  4013. // }
  4014. // fmt.Println(err)
  4015. // result := int(ret)
  4016. // return result
  4017. //}
  4018. func IntPtr(n int) uintptr {
  4019. return uintptr(n)
  4020. }
  4021. func StrPtr(s string) uintptr {
  4022. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  4023. }
  4024. type Result2001 struct {
  4025. Cainfo interface{} `json:"cainfo"`
  4026. ErrMsg string `json:"err_msg"`
  4027. InfRefmsgid string `json:"inf_refmsgid"`
  4028. Infcode int64 `json:"infcode"`
  4029. Output struct {
  4030. Trtinfo struct {
  4031. PsnNo string `json:"psn_no"`
  4032. TrtChkType string `json:"trt_chk_type"`
  4033. FundPayType string `json:"fund_pay_type"`
  4034. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4035. Begndate string `json:"begndate"`
  4036. Enddate string `json:"enddate"`
  4037. TrtChkRslt string `json:"trt_chk_rslt"`
  4038. } `json:"trtinfo"`
  4039. } `json:"output"`
  4040. RefmsgTime string `json:"refmsg_time"`
  4041. RespondTime string `json:"respond_time"`
  4042. Signtype interface{} `json:"signtype"`
  4043. WarnMsg interface{} `json:"warn_msg"`
  4044. }
  4045. type Result2001Org10265 struct {
  4046. Cainfo interface{} `json:"cainfo"`
  4047. ErrMsg string `json:"err_msg"`
  4048. InfRefmsgid string `json:"inf_refmsgid"`
  4049. Infcode string `json:"infcode"`
  4050. Output struct {
  4051. Trtinfo struct {
  4052. PsnNo string `json:"psn_no"`
  4053. TrtChkType string `json:"trt_chk_type"`
  4054. FundPayType string `json:"fund_pay_type"`
  4055. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4056. Begndate string `json:"begndate"`
  4057. Enddate string `json:"enddate"`
  4058. TrtChkRslt string `json:"trt_chk_rslt"`
  4059. } `json:"trtinfo"`
  4060. } `json:"output"`
  4061. RefmsgTime string `json:"refmsg_time"`
  4062. RespondTime string `json:"respond_time"`
  4063. Signtype interface{} `json:"signtype"`
  4064. WarnMsg interface{} `json:"warn_msg"`
  4065. }
  4066. type ResultTwo struct {
  4067. ErrMsg string `json:"err_msg"`
  4068. InfRefmsgid string `json:"inf_refmsgid"`
  4069. Infcode int64 `json:"infcode"`
  4070. Output struct {
  4071. Baseinfo struct {
  4072. Age float64 `json:"age"`
  4073. Brdy string `json:"brdy"`
  4074. Certno string `json:"certno"`
  4075. Gend string `json:"gend"`
  4076. Naty string `json:"naty"`
  4077. PsnCertType string `json:"psn_cert_type"`
  4078. PsnName string `json:"psn_name"`
  4079. PsnNo string `json:"psn_no"`
  4080. } `json:"baseinfo"`
  4081. Idetinfo []interface{} `json:"idetinfo"`
  4082. Iinfo []struct {
  4083. Balc float64 `json:"balc"`
  4084. CvlservFlag string `json:"cvlserv_flag"`
  4085. EmpName string `json:"emp_name"`
  4086. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4087. Insutype string `json:"insutype"`
  4088. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4089. PausInsuDate string `json:"paus_insu_date"`
  4090. PsnInsuDate string `json:"psn_insu_date"`
  4091. PsnInsuStas string `json:"psn_insu_stas"`
  4092. PsnType string `json:"psn_type"`
  4093. } `json:"insuinfo"`
  4094. } `json:"output"`
  4095. RefmsgTime string `json:"refmsg_time"`
  4096. RespondTime string `json:"respond_time"`
  4097. Signtype interface{} `json:"signtype"`
  4098. WarnInfo interface{} `json:"warn_info"`
  4099. }
  4100. type ResultTwo10265 struct {
  4101. ErrMsg string `json:"err_msg"`
  4102. InfRefmsgid string `json:"inf_refmsgid"`
  4103. Infcode string `json:"infcode"`
  4104. Output struct {
  4105. Baseinfo struct {
  4106. Age float64 `json:"age"`
  4107. Brdy string `json:"brdy"`
  4108. Certno string `json:"certno"`
  4109. Gend string `json:"gend"`
  4110. Naty string `json:"naty"`
  4111. PsnCertType string `json:"psn_cert_type"`
  4112. PsnName string `json:"psn_name"`
  4113. PsnNo string `json:"psn_no"`
  4114. } `json:"baseinfo"`
  4115. Idetinfo []interface{} `json:"idetinfo"`
  4116. Iinfo []struct {
  4117. Balc float64 `json:"balc"`
  4118. CvlservFlag string `json:"cvlserv_flag"`
  4119. EmpName string `json:"emp_name"`
  4120. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4121. Insutype string `json:"insutype"`
  4122. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4123. PausInsuDate string `json:"paus_insu_date"`
  4124. PsnInsuDate string `json:"psn_insu_date"`
  4125. PsnInsuStas string `json:"psn_insu_stas"`
  4126. PsnType string `json:"psn_type"`
  4127. } `json:"insuinfo"`
  4128. } `json:"output"`
  4129. RefmsgTime string `json:"refmsg_time"`
  4130. RespondTime string `json:"respond_time"`
  4131. Signtype interface{} `json:"signtype"`
  4132. WarnInfo interface{} `json:"warn_info"`
  4133. }
  4134. type ResultThree struct {
  4135. Cainfo interface{} `json:"cainfo"`
  4136. ErrMsg string `json:"err_msg"`
  4137. InfRefmsgid string `json:"inf_refmsgid"`
  4138. Infcode int64 `json:"infcode"`
  4139. Output struct {
  4140. Data struct {
  4141. IptOtpNo string `json:"ipt_otp_no"`
  4142. MdtrtID string `json:"mdtrt_id"`
  4143. PsnNo string `json:"psn_no"`
  4144. } `json:"data"`
  4145. } `json:"output"`
  4146. RefmsgTime string `json:"refmsg_time"`
  4147. RespondTime string `json:"respond_time"`
  4148. Signtype interface{} `json:"signtype"`
  4149. WarnMsg interface{} `json:"warn_msg"`
  4150. }
  4151. type ResultThree10265 struct {
  4152. Cainfo interface{} `json:"cainfo"`
  4153. ErrMsg string `json:"err_msg"`
  4154. InfRefmsgid string `json:"inf_refmsgid"`
  4155. Infcode string `json:"infcode"`
  4156. Output struct {
  4157. Data struct {
  4158. IptOtpNo string `json:"ipt_otp_no"`
  4159. MdtrtID string `json:"mdtrt_id"`
  4160. PsnNo string `json:"psn_no"`
  4161. } `json:"data"`
  4162. } `json:"output"`
  4163. RefmsgTime string `json:"refmsg_time"`
  4164. RespondTime string `json:"respond_time"`
  4165. Signtype interface{} `json:"signtype"`
  4166. WarnMsg interface{} `json:"warn_msg"`
  4167. }
  4168. type ResultFour struct {
  4169. Cainfo string `json:"cainfo"`
  4170. ErrMsg string `json:"err_msg"`
  4171. InfRefmsgid string `json:"inf_refmsgid"`
  4172. Infcode int64 `json:"infcode"`
  4173. Output struct {
  4174. Result []struct {
  4175. BasMednFlag string `json:"bas_medn_flag"`
  4176. ChldMedcFlag string `json:"chld_medc_flag"`
  4177. ChrgitmLv string `json:"chrgitm_lv"`
  4178. Cnt float64 `json:"cnt"`
  4179. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4180. DrtReimFlag string `json:"drt_reim_flag"`
  4181. FeedetlSn string `json:"feedetl_sn"`
  4182. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4183. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4184. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4185. ListSpItemFlag string `json:"list_sp_item_flag"`
  4186. LmtUsedFlag string `json:"lmt_used_flag"`
  4187. MedChrgitmType string `json:"med_chrgitm_type"`
  4188. Memo string `json:"memo"`
  4189. OverlmtAmt float64 `json:"overlmt_amt"`
  4190. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4191. Pric float64 `json:"pric"`
  4192. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4193. SelfpayProp float64 `json:"selfpay_prop"`
  4194. } `json:"result"`
  4195. } `json:"output"`
  4196. RefmsgTime string `json:"refmsg_time"`
  4197. RespondTime string `json:"respond_time"`
  4198. Signtype string `json:"signtype"`
  4199. WarnMsg string `json:"warn_msg"`
  4200. }
  4201. type ResultFour10265 struct {
  4202. Cainfo string `json:"cainfo"`
  4203. ErrMsg string `json:"err_msg"`
  4204. InfRefmsgid string `json:"inf_refmsgid"`
  4205. Infcode string `json:"infcode"`
  4206. Output struct {
  4207. Result []struct {
  4208. BasMednFlag string `json:"bas_medn_flag"`
  4209. ChldMedcFlag string `json:"chld_medc_flag"`
  4210. ChrgitmLv string `json:"chrgitm_lv"`
  4211. Cnt float64 `json:"cnt"`
  4212. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4213. DrtReimFlag string `json:"drt_reim_flag"`
  4214. FeedetlSn string `json:"feedetl_sn"`
  4215. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4216. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4217. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4218. ListSpItemFlag string `json:"list_sp_item_flag"`
  4219. LmtUsedFlag string `json:"lmt_used_flag"`
  4220. MedChrgitmType string `json:"med_chrgitm_type"`
  4221. Memo string `json:"memo"`
  4222. OverlmtAmt float64 `json:"overlmt_amt"`
  4223. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4224. Pric float64 `json:"pric"`
  4225. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4226. SelfpayProp float64 `json:"selfpay_prop"`
  4227. } `json:"result"`
  4228. } `json:"output"`
  4229. RefmsgTime string `json:"refmsg_time"`
  4230. RespondTime string `json:"respond_time"`
  4231. Signtype string `json:"signtype"`
  4232. WarnMsg string `json:"warn_msg"`
  4233. }
  4234. type ResultFive struct {
  4235. Balc float64 `json:"balc"`
  4236. CvlservFlag string `json:"cvlserv_flag"`
  4237. EmpName string `json:"emp_name"`
  4238. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4239. Insutype string `json:"insutype"`
  4240. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4241. PausInsuDate string `json:"paus_insu_date"`
  4242. PsnInsuDate string `json:"psn_insu_date"`
  4243. PsnInsuStas string `json:"psn_insu_stas"`
  4244. PsnType string `json:"psn_type"`
  4245. }
  4246. type ResultSix struct {
  4247. Cainfo interface{} `json:"cainfo"`
  4248. ErrMsg string `json:"err_msg"`
  4249. InfRefmsgid string `json:"inf_refmsgid"`
  4250. Infcode int64 `json:"infcode"`
  4251. Output struct {
  4252. } `json:"output"`
  4253. RefmsgTime string `json:"refmsg_time"`
  4254. RespondTime string `json:"respond_time"`
  4255. Signtype interface{} `json:"signtype"`
  4256. WarnMsg interface{} `json:"warn_msg"`
  4257. }
  4258. type ResultSix10265 struct {
  4259. Cainfo interface{} `json:"cainfo"`
  4260. ErrMsg string `json:"err_msg"`
  4261. InfRefmsgid string `json:"inf_refmsgid"`
  4262. Infcode string `json:"infcode"`
  4263. Output struct {
  4264. } `json:"output"`
  4265. RefmsgTime string `json:"refmsg_time"`
  4266. RespondTime string `json:"respond_time"`
  4267. Signtype interface{} `json:"signtype"`
  4268. WarnMsg interface{} `json:"warn_msg"`
  4269. }
  4270. type ResultSeven struct {
  4271. Cainfo string `json:"cainfo"`
  4272. ErrMsg string `json:"err_msg"`
  4273. InfRefmsgid string `json:"inf_refmsgid"`
  4274. Infcode int64 `json:"infcode"`
  4275. Output struct {
  4276. Setldetail []interface{} `json:"setldetail"`
  4277. Setlinfo struct {
  4278. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4279. AcctPay float64 `json:"acct_pay"`
  4280. ActPayDedc float64 `json:"act_pay_dedc"`
  4281. Age float64 `json:"age"`
  4282. Balc float64 `json:"balc"`
  4283. Brdy string `json:"brdy"`
  4284. Certno string `json:"certno"`
  4285. ClrOptins string `json:"clr_optins"`
  4286. ClrType string `json:"clr_type"`
  4287. ClrWay string `json:"clr_way"`
  4288. CvlservFlag string `json:"cvlserv_flag"`
  4289. CvlservPay float64 `json:"cvlserv_pay"`
  4290. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4291. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4292. Gend string `json:"gend"`
  4293. HifesPay float64 `json:"hifes_pay"`
  4294. HifmiPay float64 `json:"hifmi_pay"`
  4295. HifpPay float64 `json:"hifp_pay"`
  4296. HospPartAmt float64 `json:"hosp_part_amt"`
  4297. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4298. Insutype string `json:"insutype"`
  4299. MafPay float64 `json:"maf_pay"`
  4300. MdtrtCertType string `json:"mdtrt_cert_type"`
  4301. HifobPay float64 `json:"hifob_pay"`
  4302. MdtrtID string `json:"mdtrt_id"`
  4303. MedType string `json:"med_type"`
  4304. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4305. MedinsSetlID string `json:"medins_setl_id"`
  4306. Naty string `json:"naty"`
  4307. OthPay float64 `json:"oth_pay"`
  4308. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4309. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4310. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4311. PsnCashPay float64 `json:"psn_cash_pay"`
  4312. PsnCertType string `json:"psn_cert_type"`
  4313. PsnName string `json:"psn_name"`
  4314. PsnNo string `json:"psn_no"`
  4315. PsnPartAmt float64 `json:"psn_part_amt"`
  4316. PsnType string `json:"psn_type"`
  4317. SetlID string `json:"setl_id"`
  4318. SetlTime string `json:"setl_time"`
  4319. } `json:"setlinfo"`
  4320. } `json:"output"`
  4321. RefmsgTime string `json:"refmsg_time"`
  4322. RespondTime string `json:"respond_time"`
  4323. Signtype interface{} `json:"signtype"`
  4324. WarnMsg interface{} `json:"warn_msg"`
  4325. }
  4326. type ResultSeven10265 struct {
  4327. Cainfo string `json:"cainfo"`
  4328. ErrMsg string `json:"err_msg"`
  4329. InfRefmsgid string `json:"inf_refmsgid"`
  4330. Infcode string `json:"infcode"`
  4331. Output struct {
  4332. Setldetail []interface{} `json:"setldetail"`
  4333. Setlinfo struct {
  4334. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4335. AcctPay float64 `json:"acct_pay"`
  4336. ActPayDedc float64 `json:"act_pay_dedc"`
  4337. Age float64 `json:"age"`
  4338. Balc float64 `json:"balc"`
  4339. Brdy string `json:"brdy"`
  4340. Certno string `json:"certno"`
  4341. ClrOptins string `json:"clr_optins"`
  4342. ClrType string `json:"clr_type"`
  4343. ClrWay string `json:"clr_way"`
  4344. CvlservFlag string `json:"cvlserv_flag"`
  4345. CvlservPay float64 `json:"cvlserv_pay"`
  4346. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4347. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4348. Gend string `json:"gend"`
  4349. HifesPay float64 `json:"hifes_pay"`
  4350. HifmiPay float64 `json:"hifmi_pay"`
  4351. HifpPay float64 `json:"hifp_pay"`
  4352. HospPartAmt float64 `json:"hosp_part_amt"`
  4353. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4354. Insutype string `json:"insutype"`
  4355. MafPay float64 `json:"maf_pay"`
  4356. MdtrtCertType string `json:"mdtrt_cert_type"`
  4357. HifobPay float64 `json:"hifob_pay"`
  4358. MdtrtID string `json:"mdtrt_id"`
  4359. MedType string `json:"med_type"`
  4360. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4361. MedinsSetlID string `json:"medins_setl_id"`
  4362. Naty string `json:"naty"`
  4363. OthPay float64 `json:"oth_pay"`
  4364. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4365. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4366. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4367. PsnCashPay float64 `json:"psn_cash_pay"`
  4368. PsnCertType string `json:"psn_cert_type"`
  4369. PsnName string `json:"psn_name"`
  4370. PsnNo string `json:"psn_no"`
  4371. PsnPartAmt float64 `json:"psn_part_amt"`
  4372. PsnType string `json:"psn_type"`
  4373. SetlID string `json:"setl_id"`
  4374. SetlTime string `json:"setl_time"`
  4375. } `json:"setlinfo"`
  4376. } `json:"output"`
  4377. RefmsgTime string `json:"refmsg_time"`
  4378. RespondTime string `json:"respond_time"`
  4379. Signtype interface{} `json:"signtype"`
  4380. WarnMsg interface{} `json:"warn_msg"`
  4381. }
  4382. type ResultEight struct {
  4383. Cainfo string `json:"cainfo"`
  4384. ErrMsg string `json:"err_msg"`
  4385. InfRefmsgid string `json:"inf_refmsgid"`
  4386. Infcode int64 `json:"infcode"`
  4387. Output struct {
  4388. Stmtinfo struct {
  4389. SetlOptins string `json:"setl_optins"`
  4390. StmtRslt string `json:"stmt_rslt"`
  4391. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4392. } `json:"stmtinfo"`
  4393. } `json:"output"`
  4394. RefmsgTime string `json:"refmsg_time"`
  4395. RespondTime string `json:"respond_time"`
  4396. Signtype interface{} `json:"signtype"`
  4397. WarnMsg interface{} `json:"warn_msg"`
  4398. }
  4399. type ResultEightFor10188 struct {
  4400. Cainfo string `json:"cainfo"`
  4401. ErrMsg string `json:"err_msg"`
  4402. InfRefmsgid string `json:"inf_refmsgid"`
  4403. Infcode string `json:"infcode"`
  4404. Output struct {
  4405. Stmtinfo struct {
  4406. SetlOptins string `json:"setl_optins"`
  4407. StmtRslt string `json:"stmt_rslt"`
  4408. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4409. } `json:"stmtinfo"`
  4410. } `json:"output"`
  4411. RefmsgTime string `json:"refmsg_time"`
  4412. RespondTime string `json:"respond_time"`
  4413. Signtype interface{} `json:"signtype"`
  4414. WarnMsg interface{} `json:"warn_msg"`
  4415. }
  4416. type ResultNine struct {
  4417. Cainfo string `json:"cainfo"`
  4418. ErrMsg string `json:"err_msg"`
  4419. InfRefmsgid string `json:"inf_refmsgid"`
  4420. Infcode int64 `json:"infcode"`
  4421. Output struct {
  4422. FileQuryNo string `json:"file_qury_no"`
  4423. } `json:"output"`
  4424. RefmsgTime string `json:"refmsg_time"`
  4425. RespondTime string `json:"respond_time"`
  4426. Signtype interface{} `json:"signtype"`
  4427. WarnMsg interface{} `json:"warn_msg"`
  4428. }
  4429. type ResultTen struct {
  4430. Cainfo string `json:"cainfo"`
  4431. ErrMsg string `json:"err_msg"`
  4432. InfRefmsgid string `json:"inf_refmsgid"`
  4433. Infcode int64 `json:"infcode"`
  4434. Output struct {
  4435. DldEndtime string `json:"dld_endtime"`
  4436. FileQuryNo string `json:"file_qury_no"`
  4437. Filename string `json:"filename"`
  4438. } `json:"output"`
  4439. RefmsgTime string `json:"refmsg_time"`
  4440. RespondTime string `json:"respond_time"`
  4441. Signtype interface{} `json:"signtype"`
  4442. WarnMsg interface{} `json:"warn_msg"`
  4443. }
  4444. //type Autogenerated struct {
  4445. // Output struct {
  4446. // Setlinfo struct {
  4447. // SetlTime string `json:"setl_time"`
  4448. // CvlservPay float64 `json:"cvlserv_pay"`
  4449. // Year string `json:"year"`
  4450. // MedType string `json:"med_type"`
  4451. // PsnPay float64 `json:"psn_pay"`
  4452. // OpterID string `json:"opter_id"`
  4453. // Begndate string `json:"begndate"`
  4454. // FlxempeFlag string `json:"flxempe_flag"`
  4455. // HifmiPay float64 `json:"hifmi_pay"`
  4456. // PsnNo string `json:"psn_no"`
  4457. // ActPayDedc float64 `json:"act_pay_dedc"`
  4458. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4459. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4460. // ClrWay string `json:"clr_way"`
  4461. // OthPay float64 `json:"oth_pay"`
  4462. // Gend string `json:"gend"`
  4463. // MdtrtID string `json:"mdtrt_id"`
  4464. // AcctPay float64 `json:"acct_pay"`
  4465. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4466. // Insutype string `json:"insutype"`
  4467. // Invono interface{} `json:"invono"`
  4468. // Enddate string `json:"enddate"`
  4469. // CashPayamt float64 `json:"cash_payamt"`
  4470. // PsnType string `json:"psn_type"`
  4471. // FixmedinsName string `json:"fixmedins_name"`
  4472. // HifpPay float64 `json:"hifp_pay"`
  4473. // NewFlag interface{} `json:"new_flag"`
  4474. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4475. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4476. // PayLoc string `json:"pay_loc"`
  4477. // ClrType string `json:"clr_type"`
  4478. // RefdSetlFlag string `json:"refd_setl_flag"`
  4479. // CvlservFlag string `json:"cvlserv_flag"`
  4480. // EmpName string `json:"emp_name"`
  4481. // Brdy string `json:"brdy"`
  4482. // Naty string `json:"naty"`
  4483. // Certno string `json:"certno"`
  4484. // DiseCode string `json:"dise_code"`
  4485. // FixmedinsCode string `json:"fixmedins_code"`
  4486. // DedcHospLv string `json:"dedc_hosp_lv"`
  4487. // OpterName string `json:"opter_name"`
  4488. // Balc float64 `json:"balc"`
  4489. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4490. // PsnCertType string `json:"psn_cert_type"`
  4491. // HifobPay float64 `json:"hifob_pay"`
  4492. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4493. // HifesPay float64 `json:"hifes_pay"`
  4494. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4495. // OptTime string `json:"opt_time"`
  4496. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4497. // SetlID string `json:"setl_id"`
  4498. // MafPay float64 `json:"maf_pay"`
  4499. // PsnName string `json:"psn_name"`
  4500. // InsuOptins interface{} `json:"insu_optins"`
  4501. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4502. // ClrOptins string `json:"clr_optins"`
  4503. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4504. // DiseName string `json:"dise_name"`
  4505. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4506. // Age float64 `json:"age"`
  4507. // DtrtCertType string `json:"dtrt_cert_type"`
  4508. // HospLv string `json:"hosp_lv"`
  4509. // } `json:"setlinfo"`
  4510. // Setldetail []struct {
  4511. // FundPayType string `json:"fund_pay_type"`
  4512. // FundPayamt float64 `json:"fund_payamt"`
  4513. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4514. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4515. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4516. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4517. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4518. // } `json:"setldetail"`
  4519. // } `json:"output"`
  4520. // Infcode int `json:"infcode"`
  4521. // WarnMsg interface{} `json:"warn_msg"`
  4522. // Cainfo interface{} `json:"cainfo"`
  4523. // ErrMsg interface{} `json:"err_msg"`
  4524. // RefmsgTime string `json:"refmsg_time"`
  4525. // Signtype interface{} `json:"signtype"`
  4526. // RespondTime string `json:"respond_time"`
  4527. // InfRefmsgid string `json:"inf_refmsgid"`
  4528. //}
  4529. type ResultEleven struct {
  4530. Cainfo string `json:"cainfo"`
  4531. ErrMsg string `json:"err_msg"`
  4532. InfRefmsgid string `json:"inf_refmsgid"`
  4533. Infcode int64 `json:"infcode"`
  4534. Output struct {
  4535. Setlinfo struct {
  4536. SetlTime string `json:"setl_time"`
  4537. CvlservPay float64 `json:"cvlserv_pay"`
  4538. Year string `json:"year"`
  4539. MedType string `json:"med_type"`
  4540. PsnPay float64 `json:"psn_pay"`
  4541. OpterID string `json:"opter_id"`
  4542. Begndate string `json:"begndate"`
  4543. FlxempeFlag string `json:"flxempe_flag"`
  4544. HifmiPay float64 `json:"hifmi_pay"`
  4545. PsnNo string `json:"psn_no"`
  4546. ActPayDedc float64 `json:"act_pay_dedc"`
  4547. MedinsSetlID interface{} `json:"medins_setl_id"`
  4548. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4549. ClrWay string `json:"clr_way"`
  4550. OthPay float64 `json:"oth_pay"`
  4551. Gend string `json:"gend"`
  4552. MdtrtID string `json:"mdtrt_id"`
  4553. AcctPay float64 `json:"acct_pay"`
  4554. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4555. Insutype string `json:"insutype"`
  4556. Invono interface{} `json:"invono"`
  4557. Enddate string `json:"enddate"`
  4558. CashPayamt float64 `json:"cash_payamt"`
  4559. PsnType string `json:"psn_type"`
  4560. FixmedinsName string `json:"fixmedins_name"`
  4561. HifpPay float64 `json:"hifp_pay"`
  4562. NewFlag interface{} `json:"new_flag"`
  4563. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4564. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4565. PayLoc string `json:"pay_loc"`
  4566. ClrType string `json:"clr_type"`
  4567. RefdSetlFlag string `json:"refd_setl_flag"`
  4568. CvlservFlag string `json:"cvlserv_flag"`
  4569. EmpName string `json:"emp_name"`
  4570. Brdy string `json:"brdy"`
  4571. Naty string `json:"naty"`
  4572. Certno string `json:"certno"`
  4573. DiseCode string `json:"dise_code"`
  4574. FixmedinsCode string `json:"fixmedins_code"`
  4575. DedcHospLv string `json:"dedc_hosp_lv"`
  4576. OpterName string `json:"opter_name"`
  4577. Balc float64 `json:"balc"`
  4578. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4579. PsnCertType string `json:"psn_cert_type"`
  4580. HifobPay float64 `json:"hifob_pay"`
  4581. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4582. HifesPay float64 `json:"hifes_pay"`
  4583. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4584. OptTime string `json:"opt_time"`
  4585. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4586. SetlID string `json:"setl_id"`
  4587. MafPay float64 `json:"maf_pay"`
  4588. PsnName string `json:"psn_name"`
  4589. InsuOptins interface{} `json:"insu_optins"`
  4590. PrefFundPay interface{} `json:"pref_fund_pay"`
  4591. ClrOptins string `json:"clr_optins"`
  4592. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4593. DiseName string `json:"dise_name"`
  4594. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4595. Age float64 `json:"age"`
  4596. DtrtCertType string `json:"dtrt_cert_type"`
  4597. HospLv string `json:"hosp_lv"`
  4598. } `json:"setlinfo"`
  4599. } `json:"output"`
  4600. RefmsgTime string `json:"refmsg_time"`
  4601. RespondTime string `json:"respond_time"`
  4602. Signtype interface{} `json:"signtype"`
  4603. WarnMsg interface{} `json:"warn_msg"`
  4604. }
  4605. type ResultEleven10265 struct {
  4606. Cainfo string `json:"cainfo"`
  4607. ErrMsg string `json:"err_msg"`
  4608. InfRefmsgid string `json:"inf_refmsgid"`
  4609. Infcode string `json:"infcode"`
  4610. Output struct {
  4611. Setlinfo struct {
  4612. SetlTime string `json:"setl_time"`
  4613. CvlservPay float64 `json:"cvlserv_pay"`
  4614. Year string `json:"year"`
  4615. MedType string `json:"med_type"`
  4616. PsnPay float64 `json:"psn_pay"`
  4617. OpterID string `json:"opter_id"`
  4618. Begndate string `json:"begndate"`
  4619. FlxempeFlag string `json:"flxempe_flag"`
  4620. HifmiPay float64 `json:"hifmi_pay"`
  4621. PsnNo string `json:"psn_no"`
  4622. ActPayDedc float64 `json:"act_pay_dedc"`
  4623. MedinsSetlID interface{} `json:"medins_setl_id"`
  4624. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4625. ClrWay string `json:"clr_way"`
  4626. OthPay float64 `json:"oth_pay"`
  4627. Gend string `json:"gend"`
  4628. MdtrtID string `json:"mdtrt_id"`
  4629. AcctPay float64 `json:"acct_pay"`
  4630. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4631. Insutype string `json:"insutype"`
  4632. Invono interface{} `json:"invono"`
  4633. Enddate string `json:"enddate"`
  4634. CashPayamt float64 `json:"cash_payamt"`
  4635. PsnType string `json:"psn_type"`
  4636. FixmedinsName string `json:"fixmedins_name"`
  4637. HifpPay float64 `json:"hifp_pay"`
  4638. NewFlag interface{} `json:"new_flag"`
  4639. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4640. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4641. PayLoc string `json:"pay_loc"`
  4642. ClrType string `json:"clr_type"`
  4643. RefdSetlFlag string `json:"refd_setl_flag"`
  4644. CvlservFlag string `json:"cvlserv_flag"`
  4645. EmpName string `json:"emp_name"`
  4646. Brdy string `json:"brdy"`
  4647. Naty string `json:"naty"`
  4648. Certno string `json:"certno"`
  4649. DiseCode string `json:"dise_code"`
  4650. FixmedinsCode string `json:"fixmedins_code"`
  4651. DedcHospLv string `json:"dedc_hosp_lv"`
  4652. OpterName string `json:"opter_name"`
  4653. Balc float64 `json:"balc"`
  4654. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4655. PsnCertType string `json:"psn_cert_type"`
  4656. HifobPay float64 `json:"hifob_pay"`
  4657. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4658. HifesPay float64 `json:"hifes_pay"`
  4659. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4660. OptTime string `json:"opt_time"`
  4661. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4662. SetlID string `json:"setl_id"`
  4663. MafPay float64 `json:"maf_pay"`
  4664. PsnName string `json:"psn_name"`
  4665. InsuOptins interface{} `json:"insu_optins"`
  4666. PrefFundPay interface{} `json:"pref_fund_pay"`
  4667. ClrOptins string `json:"clr_optins"`
  4668. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4669. DiseName string `json:"dise_name"`
  4670. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4671. Age float64 `json:"age"`
  4672. DtrtCertType string `json:"dtrt_cert_type"`
  4673. HospLv string `json:"hosp_lv"`
  4674. } `json:"setlinfo"`
  4675. } `json:"output"`
  4676. RefmsgTime string `json:"refmsg_time"`
  4677. RespondTime string `json:"respond_time"`
  4678. Signtype interface{} `json:"signtype"`
  4679. WarnMsg interface{} `json:"warn_msg"`
  4680. }
  4681. type ResultTwelve struct {
  4682. Cainfo string `json:"cainfo"`
  4683. ErrMsg string `json:"err_msg"`
  4684. InfRefmsgid string `json:"inf_refmsgid"`
  4685. Infcode int64 `json:"infcode"`
  4686. Output struct {
  4687. MdtrtId string `json:"mdtrt_id"`
  4688. ChrgBchno string `json:"chrg_bchno"`
  4689. PsnNo string `json:"psn_no"`
  4690. } `json:"output"`
  4691. RefmsgTime string `json:"refmsg_time"`
  4692. RespondTime string `json:"respond_time"`
  4693. Signtype interface{} `json:"signtype"`
  4694. WarnMsg interface{} `json:"warn_msg"`
  4695. }
  4696. type ResultThirteen struct {
  4697. ErrMsg string `json:"err_msg"`
  4698. InfRefmsgid string `json:"inf_refmsgid"`
  4699. Infcode int64 `json:"infcode"`
  4700. Output struct {
  4701. Result struct {
  4702. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4703. } `json:"result"`
  4704. } `json:"output"`
  4705. RefmsgTime string `json:"refmsg_time"`
  4706. RespondTime string `json:"respond_time"`
  4707. Signtype interface{} `json:"signtype"`
  4708. WarnInfo interface{} `json:"warn_info"`
  4709. }
  4710. type ResultThirteen10265 struct {
  4711. ErrMsg string `json:"err_msg"`
  4712. InfRefmsgid string `json:"inf_refmsgid"`
  4713. Infcode string `json:"infcode"`
  4714. Output struct {
  4715. Result struct {
  4716. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4717. } `json:"result"`
  4718. } `json:"output"`
  4719. RefmsgTime string `json:"refmsg_time"`
  4720. RespondTime string `json:"respond_time"`
  4721. Signtype interface{} `json:"signtype"`
  4722. WarnInfo interface{} `json:"warn_info"`
  4723. }
  4724. type ResultFourteen struct {
  4725. ErrMsg string `json:"err_msg"`
  4726. InfRefmsgid string `json:"inf_refmsgid"`
  4727. Infcode int64 `json:"infcode"`
  4728. Output struct {
  4729. } `json:"output"`
  4730. RefmsgTime string `json:"refmsg_time"`
  4731. RespondTime string `json:"respond_time"`
  4732. Signtype interface{} `json:"signtype"`
  4733. WarnInfo interface{} `json:"warn_info"`
  4734. }
  4735. type ResultFourteen10265 struct {
  4736. ErrMsg string `json:"err_msg"`
  4737. InfRefmsgid string `json:"inf_refmsgid"`
  4738. Infcode string `json:"infcode"`
  4739. Output struct {
  4740. } `json:"output"`
  4741. RefmsgTime string `json:"refmsg_time"`
  4742. RespondTime string `json:"respond_time"`
  4743. Signtype interface{} `json:"signtype"`
  4744. WarnInfo interface{} `json:"warn_info"`
  4745. }
  4746. type ResultSixteen struct {
  4747. Cainfo string `json:"cainfo"`
  4748. ErrMsg string `json:"err_msg"`
  4749. InfRefmsgid string `json:"inf_refmsgid"`
  4750. Infcode int64 `json:"infcode"`
  4751. Output struct {
  4752. Setldetail []interface{} `json:"setldetail"`
  4753. Setlinfo struct {
  4754. MdtrtID string `json:"mdtrt_id"`
  4755. SetlID string `json:"setl_id"`
  4756. ClrOptins string `json:"clr_optins"`
  4757. SetlTime string `json:"setl_time"`
  4758. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4759. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4760. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4761. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4762. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4763. ActPayDedc float64 `json:"act_pay_dedc"`
  4764. HifpPay float64 `json:"hifp_pay"`
  4765. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4766. Lfpay float64 `json:"selfpay"`
  4767. CvlservPay float64 `json:"cvlserv_pay"`
  4768. HifesPay float64 `json:"hifes_pay"`
  4769. HifmiPay float64 `json:"hifmi_pay"`
  4770. HifobPay float64 `json:"hifob_pay"`
  4771. MafPay float64 `json:"maf_pay"`
  4772. OthPay float64 `json:"oth_pay"`
  4773. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4774. PsnPartAmt float64 `json:"psn_part_amt"`
  4775. AcctPay float64 `json:"acct_pay"`
  4776. Balc float64 `json:"balc"`
  4777. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4778. HospPartAmt float64 `json:"hosp_part_amt"`
  4779. MedinsSetlID string `json:"medins_setl_id"`
  4780. PdnCashPay string `json:"pdn_cash_pay"`
  4781. } `json:"setlinfo"`
  4782. } `json:"output"`
  4783. RefmsgTime string `json:"refmsg_time"`
  4784. RespondTime string `json:"respond_time"`
  4785. Signtype interface{} `json:"signtype"`
  4786. WarnMsg interface{} `json:"warn_msg"`
  4787. }
  4788. type ResultSixteen10265 struct {
  4789. Cainfo string `json:"cainfo"`
  4790. ErrMsg string `json:"err_msg"`
  4791. InfRefmsgid string `json:"inf_refmsgid"`
  4792. Infcode string `json:"infcode"`
  4793. Output struct {
  4794. Setldetail []interface{} `json:"setldetail"`
  4795. Setlinfo struct {
  4796. MdtrtID string `json:"mdtrt_id"`
  4797. SetlID string `json:"setl_id"`
  4798. ClrOptins string `json:"clr_optins"`
  4799. SetlTime string `json:"setl_time"`
  4800. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4801. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4802. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4803. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4804. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4805. ActPayDedc float64 `json:"act_pay_dedc"`
  4806. HifpPay float64 `json:"hifp_pay"`
  4807. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4808. Lfpay float64 `json:"selfpay"`
  4809. CvlservPay float64 `json:"cvlserv_pay"`
  4810. HifesPay float64 `json:"hifes_pay"`
  4811. HifmiPay float64 `json:"hifmi_pay"`
  4812. HifobPay float64 `json:"hifob_pay"`
  4813. MafPay float64 `json:"maf_pay"`
  4814. OthPay float64 `json:"oth_pay"`
  4815. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4816. PsnPartAmt float64 `json:"psn_part_amt"`
  4817. AcctPay float64 `json:"acct_pay"`
  4818. Balc float64 `json:"balc"`
  4819. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4820. HospPartAmt float64 `json:"hosp_part_amt"`
  4821. MedinsSetlID string `json:"medins_setl_id"`
  4822. PdnCashPay string `json:"pdn_cash_pay"`
  4823. } `json:"setlinfo"`
  4824. } `json:"output"`
  4825. RefmsgTime string `json:"refmsg_time"`
  4826. RespondTime string `json:"respond_time"`
  4827. Signtype interface{} `json:"signtype"`
  4828. WarnMsg interface{} `json:"warn_msg"`
  4829. }
  4830. type ResultSeventeen struct {
  4831. ErrMsg string `json:"err_msg"`
  4832. InfRefmsgid string `json:"inf_refmsgid"`
  4833. Infcode int64 `json:"infcode"`
  4834. Output struct {
  4835. SetlListId string `json:"setl_list_id"`
  4836. } `json:"output"`
  4837. RefmsgTime string `json:"refmsg_time"`
  4838. RespondTime string `json:"respond_time"`
  4839. Signtype string `json:"signtype"`
  4840. WarnInfo string `json:"warn_info"`
  4841. }
  4842. type ResultSeventeenOther struct {
  4843. ErrMsg string `json:"err_msg"`
  4844. InfRefmsgid string `json:"inf_refmsgid"`
  4845. Infcode string `json:"infcode"`
  4846. Output struct {
  4847. SetlListId string `json:"setl_list_id"`
  4848. } `json:"output"`
  4849. RefmsgTime string `json:"refmsg_time"`
  4850. RespondTime string `json:"respond_time"`
  4851. Signtype string `json:"signtype"`
  4852. WarnInfo string `json:"warn_info"`
  4853. }
  4854. type Result90991 struct {
  4855. ErrMsg string `json:"err_msg"`
  4856. InfRefmsgid string `json:"inf_refmsgid"`
  4857. Infcode int64 `json:"infcode"`
  4858. Output struct {
  4859. Result struct {
  4860. PsnNo string `json:"psn_no"`
  4861. CardStat string `json:"card_stat"`
  4862. Certno string `json:"certno"`
  4863. PsnName string `json:"psn_name"`
  4864. CheckStat string `json:"check_stat"`
  4865. SscnoCheckStat string `json:"sscno_check_stat"`
  4866. } `json:"result"`
  4867. } `json:"output"`
  4868. RefmsgTime string `json:"refmsg_time"`
  4869. RespondTime string `json:"respond_time"`
  4870. Signtype interface{} `json:"signtype"`
  4871. WarnInfo interface{} `json:"warn_info"`
  4872. }
  4873. type Result90100 struct {
  4874. ErrMsg string `json:"err_msg"`
  4875. InfRefmsgid string `json:"inf_refmsgid"`
  4876. Infcode int64 `json:"infcode"`
  4877. Output struct {
  4878. PoolareaNo string `json:"poolarea_no"`
  4879. PoolareaNoName string `json:"poolarea_no_name"`
  4880. Insutype string `json:"insutype"`
  4881. InsutypeName string `json:"insutype_name"`
  4882. ClctType string `json:"clct_type"`
  4883. ClctTypeName string `json:"clct_type_name"`
  4884. ClctFlag string `json:"clct_flag"`
  4885. ClctFlagName string `json:"clct_flag_name"`
  4886. AccrymBegn string `json:"accrym_begn"`
  4887. AccrymEnd string `json:"accrym_end"`
  4888. ClctTime string `json:"clct_time"`
  4889. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4890. } `json:"output"`
  4891. RefmsgTime string `json:"refmsg_time"`
  4892. RespondTime string `json:"respond_time"`
  4893. Signtype interface{} `json:"signtype"`
  4894. WarnInfo interface{} `json:"warn_info"`
  4895. }
  4896. type Custom struct {
  4897. DetItemFeeSumamt string
  4898. Cut string
  4899. FeedetlSn string
  4900. Price string
  4901. MedListCodg string
  4902. Type int64
  4903. AdviceId int64
  4904. ProjectId int64
  4905. ItemId int64
  4906. }
  4907. type Result5301 struct {
  4908. ErrMsg string `json:"err_msg"`
  4909. InfRefmsgid string `json:"inf_refmsgid"`
  4910. Infcode int64 `json:"infcode"`
  4911. Output struct {
  4912. Result []struct {
  4913. OpspDiseCode string `json:"opsp_dise_code"`
  4914. OpspDiseName string `json:"opsp_dise_name"`
  4915. Begndate string `json:"begndate"`
  4916. Enddate string `json:"enddate"`
  4917. } `json:"feedetail"`
  4918. } `json:"output"`
  4919. RefmsgTime string `json:"refmsg_time"`
  4920. RespondTime string `json:"respond_time"`
  4921. Signtype interface{} `json:"signtype"`
  4922. WarnInfo interface{} `json:"warn_info"`
  4923. }
  4924. type Result5301For10265 struct {
  4925. ErrMsg string `json:"err_msg"`
  4926. InfRefmsgid string `json:"inf_refmsgid"`
  4927. Infcode string `json:"infcode"`
  4928. Output struct {
  4929. Result []struct {
  4930. OpspDiseCode string `json:"opsp_dise_code"`
  4931. OpspDiseName string `json:"opsp_dise_name"`
  4932. Begndate string `json:"begndate"`
  4933. Enddate string `json:"enddate"`
  4934. } `json:"feedetail"`
  4935. } `json:"output"`
  4936. RefmsgTime string `json:"refmsg_time"`
  4937. RespondTime string `json:"respond_time"`
  4938. Signtype interface{} `json:"signtype"`
  4939. WarnInfo interface{} `json:"warn_info"`
  4940. }
  4941. //获取个人信息----挂号-----上传就诊信息
  4942. func (c *HisApiController) GetRegisterInfo() {
  4943. id, _ := c.GetInt64("id")
  4944. record_time := c.GetString("record_time")
  4945. settlementValue, _ := c.GetInt64("settlement_value")
  4946. medical_insurance_card := c.GetString("medical_insurance_card")
  4947. name := c.GetString("name")
  4948. id_card_type, _ := c.GetInt64("id_card_type")
  4949. certificates, _ := c.GetInt64("certificates")
  4950. medical_care, _ := c.GetInt64("medical_care")
  4951. birthday := c.GetString("birthday")
  4952. id_card := c.GetString("id_card")
  4953. register_type, _ := c.GetInt64("register")
  4954. doctor, _ := c.GetInt64("doctor")
  4955. department, _ := c.GetInt64("department")
  4956. gender, _ := c.GetInt64("sex")
  4957. registration_fee, _ := c.GetFloat("registration_fee")
  4958. medical_expenses, _ := c.GetFloat("medical_expenses")
  4959. social_type, _ := c.GetInt64("social_type")
  4960. med_type := c.GetString("social_type")
  4961. admin_user_id, _ := c.GetInt64("admin_user_id")
  4962. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4963. timeLayout := "2006-01-02"
  4964. loc, _ := time.LoadLocation("Local")
  4965. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4966. birthUnix := birthdays.Unix()
  4967. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4968. if err != nil {
  4969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4970. return
  4971. }
  4972. recordDateTime := theTime.Unix()
  4973. adminInfo := c.GetAdminUserInfo()
  4974. var patient service.Patients
  4975. if id == 0 {
  4976. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4977. } else {
  4978. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4979. }
  4980. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4981. if patientPrescription.ID == 0 {
  4982. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4983. }
  4984. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4985. if patient.ID == 0 {
  4986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4987. return
  4988. }
  4989. if len(patient.IdCardNo) == 0 {
  4990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4991. return
  4992. }
  4993. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4994. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4995. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4996. //就诊结算未完成,不能进行二次挂号
  4997. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4998. if len(his) >= 1 {
  4999. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  5000. if len(his) >= 1 && order.ID == 0 {
  5001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  5002. return
  5003. }
  5004. }
  5005. //var register_log string
  5006. if config.IsOpen == 1 {
  5007. var res ResultTwo
  5008. var res10265 ResultTwo10265
  5009. var PsnNo string
  5010. var PsnCertType string
  5011. var Certno string
  5012. var PsnName string
  5013. var Gend string
  5014. var Naty string
  5015. var Brdy string
  5016. var Age float64
  5017. var infoStr string
  5018. var idetinfoStr string
  5019. var infocode int64
  5020. var verify_number string
  5021. fmt.Println(verify_number)
  5022. if miConfig.MdtrtareaAdmvs == "421300" {
  5023. psn_info, _ := service.GetPsnByPatientId(id)
  5024. PsnNo = psn_info.PsnNo
  5025. PsnCertType = psn_info.PsnCertType
  5026. Certno = psn_info.Certno
  5027. PsnName = psn_info.PsnName
  5028. Gend = psn_info.Gend
  5029. Naty = psn_info.Naty
  5030. Brdy = psn_info.Brdy
  5031. Age = psn_info.Age
  5032. infoStr = psn_info.Insuinfo
  5033. idetinfoStr = psn_info.Idetinfo
  5034. infocode = 0
  5035. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5036. psn_info, _ := service.GetPsnByPatientId(id)
  5037. PsnNo = psn_info.PsnNo
  5038. PsnCertType = psn_info.PsnCertType
  5039. Certno = psn_info.Certno
  5040. PsnName = psn_info.PsnName
  5041. Gend = psn_info.Gend
  5042. Naty = psn_info.Naty
  5043. Brdy = psn_info.Brdy
  5044. Age = psn_info.Age
  5045. infoStr = psn_info.Insuinfo
  5046. idetinfoStr = psn_info.Idetinfo
  5047. infocode = 0
  5048. verify_number = psn_info.VerifyNumber
  5049. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5050. if id_card_type == 1 {
  5051. psn_info, _ := service.GetPsnByPatientId(id)
  5052. PsnNo = psn_info.PsnNo
  5053. PsnCertType = psn_info.PsnCertType
  5054. Certno = psn_info.Certno
  5055. PsnName = psn_info.PsnName
  5056. Gend = psn_info.Gend
  5057. Naty = psn_info.Naty
  5058. Brdy = psn_info.Brdy
  5059. Age = psn_info.Age
  5060. infoStr = psn_info.Insuinfo
  5061. idetinfoStr = psn_info.Idetinfo
  5062. infocode = 0
  5063. verify_number = psn_info.VerifyNumber
  5064. } else if id_card_type == 2 {
  5065. 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)
  5066. fmt.Println(errMsgLog)
  5067. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5068. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5069. utils.ErrorLog("解析失败:%v", err)
  5070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5071. return
  5072. }
  5073. PsnNo = res.Output.Baseinfo.PsnNo
  5074. PsnCertType = res.Output.Baseinfo.PsnCertType
  5075. Certno = res.Output.Baseinfo.Certno
  5076. PsnName = res.Output.Baseinfo.PsnName
  5077. Gend = res.Output.Baseinfo.Gend
  5078. Naty = res.Output.Baseinfo.Naty
  5079. Brdy = res.Output.Baseinfo.Brdy
  5080. Age = res.Output.Baseinfo.Age
  5081. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5082. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5083. infoStr = string(Iinfos)
  5084. idetinfoStr = string(Idetinfos)
  5085. infocode = res.Infcode
  5086. }
  5087. } else {
  5088. var result string
  5089. var requestLog string
  5090. if miConfig.UserOrgId == 10138 {
  5091. if id_card_type == 4 {
  5092. psn_info, _ := service.GetPsnByPatientId(id)
  5093. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  5094. } else {
  5095. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  5096. }
  5097. } else {
  5098. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  5099. }
  5100. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5101. if miConfig.Code == "H15049901371" {
  5102. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5103. utils.ErrorLog("解析失败:%v", err)
  5104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5105. return
  5106. }
  5107. res.ErrMsg = res10265.ErrMsg
  5108. res.Output = res10265.Output
  5109. res.InfRefmsgid = res10265.InfRefmsgid
  5110. } else {
  5111. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5112. utils.ErrorLog("解析失败:%v", err)
  5113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5114. return
  5115. }
  5116. }
  5117. PsnNo = res.Output.Baseinfo.PsnNo
  5118. PsnCertType = res.Output.Baseinfo.PsnCertType
  5119. Certno = res.Output.Baseinfo.Certno
  5120. PsnName = res.Output.Baseinfo.PsnName
  5121. Gend = res.Output.Baseinfo.Gend
  5122. Naty = res.Output.Baseinfo.Naty
  5123. Brdy = res.Output.Baseinfo.Brdy
  5124. Age = res.Output.Baseinfo.Age
  5125. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5126. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5127. infoStr = string(Iinfos)
  5128. idetinfoStr = string(Idetinfos)
  5129. if miConfig.Code == "H15049901371" {
  5130. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  5131. } else {
  5132. infocode = res.Infcode
  5133. }
  5134. }
  5135. if infocode == 0 {
  5136. his := models.VMHisPatient{
  5137. Name: name,
  5138. Gender: gender,
  5139. Birthday: birthUnix,
  5140. MedicalTreatmentType: medical_care,
  5141. IdType: certificates,
  5142. IdCardNo: id_card,
  5143. BalanceAccountsType: settlementValue,
  5144. SocialType: social_type,
  5145. MedicalInsuranceNumber: medical_insurance_card,
  5146. RegisterType: register_type,
  5147. RegisterCost: registration_fee,
  5148. TreatmentCost: medical_expenses,
  5149. Status: 1,
  5150. Ctime: time.Now().Unix(),
  5151. Mtime: time.Now().Unix(),
  5152. PsnNo: PsnNo,
  5153. PsnCertType: PsnCertType,
  5154. Certno: Certno,
  5155. PsnName: PsnName,
  5156. Gend: Gend,
  5157. Naty: Naty,
  5158. Brdy: Brdy,
  5159. Age: Age,
  5160. Iinfo: infoStr,
  5161. Idetinfo: idetinfoStr,
  5162. PatientId: patient.ID,
  5163. RecordDate: theTime.Unix(),
  5164. UserOrgId: adminInfo.CurrentOrgId,
  5165. AdminUserId: admin_user_id,
  5166. IsReturn: 1,
  5167. IdCardType: id_card_type,
  5168. Doctor: doctor,
  5169. Departments: department,
  5170. }
  5171. timestamp := time.Now().Unix()
  5172. tempTime := time.Unix(timestamp, 0)
  5173. timeFormat := tempTime.Format("20060102150405")
  5174. chrgBchno := rand.Intn(100000) + 10000
  5175. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5176. his.Number = ipt_otp_no
  5177. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  5178. department, _ := service.GetDepartMentDetail(department)
  5179. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  5180. IdCardNo := ""
  5181. if id_card_type == 1 {
  5182. // IdCardNo = medical_insurance_card
  5183. IdCardNo = patient.IdCardNo
  5184. } else {
  5185. IdCardNo = patient.IdCardNo
  5186. }
  5187. var rf []*ResultFive
  5188. json.Unmarshal([]byte(his.Iinfo), &rf)
  5189. var insutypes []*ResultFive
  5190. var insutype string
  5191. var insuplc_admdvs_temp string
  5192. var is390 int = 0
  5193. var is310 int = 0
  5194. for _, item := range rf {
  5195. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5196. insutypes = append(insutypes, item)
  5197. }
  5198. }
  5199. if len(insutypes) == 1 {
  5200. insutype = insutypes[0].Insutype
  5201. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5202. } else {
  5203. for _, i := range insutypes {
  5204. if i.Insutype == "390" {
  5205. is390 = 1
  5206. }
  5207. if i.Insutype == "310" {
  5208. is310 = 1
  5209. }
  5210. }
  5211. }
  5212. if is390 == 1 {
  5213. insutype = "390"
  5214. }
  5215. if is310 == 1 {
  5216. insutype = "310"
  5217. }
  5218. if len(insutypes) == 0 {
  5219. insutype = "310"
  5220. }
  5221. if len(insutypes) == 2 {
  5222. insutype = med_type
  5223. }
  5224. if len(med_type) > 0 {
  5225. insutype = med_type
  5226. }
  5227. var infocode int64
  5228. var resThree ResultThree
  5229. var resThree10265 ResultThree10265
  5230. if len(insuplc_admdvs) == 0 {
  5231. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  5232. } else {
  5233. insuplc_admdvs_temp = insuplc_admdvs
  5234. }
  5235. if miConfig.MdtrtareaAdmvs == "421300" {
  5236. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  5237. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  5238. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5239. "&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
  5240. resp, requestErr := http.Get(api)
  5241. if requestErr != nil {
  5242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5243. return
  5244. }
  5245. body, ioErr := ioutil.ReadAll(resp.Body)
  5246. if ioErr != nil {
  5247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5249. return
  5250. }
  5251. var respJSON map[string]interface{}
  5252. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5255. return
  5256. }
  5257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5258. result, _ := json.Marshal(respJSON)
  5259. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5260. utils.ErrorLog("解析失败:%v", err)
  5261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5262. return
  5263. }
  5264. infocode = resThree.Infcode
  5265. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5266. psn_info, _ := service.GetPsnByPatientId(id)
  5267. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5268. var cert_no string
  5269. if id_card_type == 3 {
  5270. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  5271. cert_no = IdCardNo
  5272. } else if id_card_type == 4 {
  5273. cert_no = IdCardNo
  5274. psn_info.VerifyNumber = psn_info.VerifyNumber
  5275. } else {
  5276. bas := strings.Split(psn_info.CardInfo, "|")
  5277. cert_no = bas[2]
  5278. }
  5279. var hisPrescription []*models.HisPrescription
  5280. for _, item := range rf {
  5281. if item.Insutype == insutype {
  5282. //insuplc_admdvs = item.InsuplcAdmdvs
  5283. his.InsuplcAdmdvs = insuplc_admdvs
  5284. }
  5285. }
  5286. his.Insutype = insutype
  5287. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  5288. fmt.Println(res3101)
  5289. fmt.Println(res3101.Infcode)
  5290. if res3101.Infcode == "0" {
  5291. fmt.Println("33333333")
  5292. if len(res3101.Output.Result) > 0 {
  5293. fmt.Println("222222")
  5294. for _, item := range res3101.Output.Result {
  5295. if len(res3101.ErrMsg) == 0 {
  5296. res3101.ErrMsg = item.VolaCont
  5297. } else {
  5298. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  5299. }
  5300. }
  5301. c.ServeSuccessJSON(map[string]interface{}{
  5302. "failed_code": -10,
  5303. "msg": res3101.ErrMsg,
  5304. })
  5305. return
  5306. } else {
  5307. fmt.Println("11111")
  5308. var api string
  5309. if miConfig.MdtrtareaAdmvs == "320921" {
  5310. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5311. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5312. "&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
  5313. } else {
  5314. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5315. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5316. "&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
  5317. }
  5318. resp, requestErr := http.Get(api)
  5319. if requestErr != nil {
  5320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5321. return
  5322. }
  5323. body, ioErr := ioutil.ReadAll(resp.Body)
  5324. if ioErr != nil {
  5325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5327. return
  5328. }
  5329. var respJSON map[string]interface{}
  5330. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5333. return
  5334. }
  5335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5336. result, _ := json.Marshal(respJSON)
  5337. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5338. utils.ErrorLog("解析失败:%v", err)
  5339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5340. return
  5341. }
  5342. resThree.ErrMsg = resThree10265.ErrMsg
  5343. resThree.Output = resThree10265.Output
  5344. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5345. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5346. }
  5347. } else if res3101.Infcode != "0" {
  5348. c.ServeSuccessJSON(map[string]interface{}{
  5349. "failed_code": -10,
  5350. "msg": res3101.ErrMsg,
  5351. })
  5352. return
  5353. }
  5354. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5355. psn_info, _ := service.GetPsnByPatientId(id)
  5356. var cert_no string
  5357. if id_card_type == 1 {
  5358. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5359. } else {
  5360. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  5361. }
  5362. fmt.Println(cert_no)
  5363. 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)
  5364. saveLog(result, requestLog, "2201", "挂号")
  5365. if miConfig.Code == "H15049901371" {
  5366. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5367. utils.ErrorLog("解析失败:%v", err)
  5368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5369. return
  5370. }
  5371. resThree.ErrMsg = resThree10265.ErrMsg
  5372. resThree.Output = resThree10265.Output
  5373. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5374. } else {
  5375. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5376. utils.ErrorLog("解析失败:%v", err)
  5377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5378. return
  5379. }
  5380. }
  5381. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5382. } else {
  5383. psn_info, _ := service.GetPsnByPatientId(id)
  5384. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.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)
  5385. saveLog(result, requestLog, "2201A", "挂号")
  5386. if miConfig.Code == "H15049901371" {
  5387. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5388. utils.ErrorLog("解析失败:%v", err)
  5389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5390. return
  5391. }
  5392. resThree.ErrMsg = resThree10265.ErrMsg
  5393. resThree.Output = resThree10265.Output
  5394. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5395. } else {
  5396. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5397. utils.ErrorLog("解析失败:%v", err)
  5398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5399. return
  5400. }
  5401. }
  5402. if miConfig.Code == "H15049901371" {
  5403. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5404. } else {
  5405. infocode = resThree.Infcode
  5406. }
  5407. }
  5408. if infocode != 0 {
  5409. adminUser := c.GetAdminUserInfo()
  5410. errlog := &models.HisOrderError{
  5411. UserOrgId: adminUser.CurrentOrgId,
  5412. Ctime: time.Now().Unix(),
  5413. Mtime: time.Now().Unix(),
  5414. ErrMsg: resThree.ErrMsg,
  5415. Status: 1,
  5416. PatientId: id,
  5417. RecordTime: recordDateTime,
  5418. Stage: 2,
  5419. }
  5420. service.CreateErrMsgLog(errlog)
  5421. c.ServeSuccessJSON(map[string]interface{}{
  5422. "failed_code": -10,
  5423. "msg": resThree.ErrMsg,
  5424. })
  5425. return
  5426. }
  5427. his.Number = resThree.Output.Data.MdtrtID
  5428. his.PsnNo = resThree.Output.Data.PsnNo
  5429. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5430. his.IdCardNo = patient.IdCardNo
  5431. his.PhoneNumber = patient.Phone
  5432. his.UserOrgId = adminInfo.CurrentOrgId
  5433. his.Insutype = insutype
  5434. his.Ctime = time.Now().Unix()
  5435. his.Mtime = time.Now().Unix()
  5436. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5437. his.Status = 1
  5438. service.UpdateHisPatientStatus(&his)
  5439. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5440. c.ServeSuccessJSON(map[string]interface{}{
  5441. "his_info": his,
  5442. })
  5443. } else {
  5444. adminUser := c.GetAdminUserInfo()
  5445. errlog := &models.HisOrderError{
  5446. UserOrgId: adminUser.CurrentOrgId,
  5447. Ctime: time.Now().Unix(),
  5448. Mtime: time.Now().Unix(),
  5449. ErrMsg: res.ErrMsg,
  5450. Status: 1,
  5451. PatientId: id,
  5452. RecordTime: recordDateTime,
  5453. Stage: 1,
  5454. }
  5455. service.CreateErrMsgLog(errlog)
  5456. c.ServeSuccessJSON(map[string]interface{}{
  5457. "failed_code": -10,
  5458. "msg": res.ErrMsg,
  5459. })
  5460. return
  5461. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5462. }
  5463. }
  5464. }
  5465. //上传明细----预结算----确认订单
  5466. func (c *HisApiController) GetUploadInfo() {
  5467. id, _ := c.GetInt64("id")
  5468. record_time := c.GetString("record_time")
  5469. his_patient_id, _ := c.GetInt64("his_patient_id")
  5470. order_id, _ := c.GetInt64("order_id")
  5471. pay_way, _ := c.GetInt64("pay_way")
  5472. pay_price, _ := c.GetFloat("pay_price")
  5473. pay_card_no := c.GetString("pay_card_no")
  5474. token := c.GetString("token")
  5475. discount_price, _ := c.GetFloat("discount_price")
  5476. preferential_price, _ := c.GetFloat("preferential_price")
  5477. reality_price, _ := c.GetFloat("reality_price")
  5478. found_price, _ := c.GetFloat("found_price")
  5479. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5480. private_price, _ := c.GetFloat("private_price")
  5481. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5482. admin_user_id, _ := c.GetInt64("admin_user_id")
  5483. fapiao_code := c.GetString("fapiao_code")
  5484. fapiao_number := c.GetString("fapiao_number")
  5485. diagnosis_id := c.GetString("diagnosis")
  5486. sick_type, _ := c.GetInt64("sick_type")
  5487. reg_type, _ := c.GetInt64("p_type")
  5488. begin_time := c.GetString("begin_time")
  5489. id_str := c.GetString("ids")
  5490. ids_arr := strings.Split(id_str, ",")
  5491. timeLayout := "2006-01-02"
  5492. loc, _ := time.LoadLocation("Local")
  5493. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5494. if err != nil {
  5495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5496. return
  5497. }
  5498. recordDateTime := theTime.Unix()
  5499. adminUser := c.GetAdminUserInfo()
  5500. var tempOrder models.HisOrder
  5501. tempOrder, _ = service.GetHisOrderByID(order_id)
  5502. var prescriptions []*models.HisPrescription
  5503. var start_time int64
  5504. var end_time int64
  5505. //押金模块
  5506. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5507. tmp_decimal := c.GetString("tmp_decimal")
  5508. var decimal float64 //本次使用的押金
  5509. var errmsg error
  5510. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5511. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5512. return
  5513. }
  5514. if len(tmp_decimal) > 0 {
  5515. if tmp_decimal[0] == 45 {
  5516. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5517. return
  5518. }
  5519. }
  5520. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5521. fmt.Println(errs)
  5522. decimal = tt
  5523. //if adminUser.CurrentOrgId == 10106{
  5524. // if len(fapiao_code) == 0{
  5525. // fapiao_code = "144072080589"
  5526. // }
  5527. // if len(fapiao_number) == 0{
  5528. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5529. // if order.ID == 0{
  5530. // fapiao_number = "00001520"
  5531. // }else{
  5532. // //fapiao_code = "00001520"
  5533. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5534. // var zero string
  5535. // if fpNumber >= 1000{
  5536. // zero = "0000" + strconv.Itoa(fpNumber)
  5537. // }else if fpNumber >= 10000{
  5538. // zero = "000" + strconv.Itoa(fpNumber)
  5539. // } else if fpNumber >= 100000{
  5540. // zero = "00" + strconv.Itoa(fpNumber)
  5541. // } else if fpNumber >= 1000000{
  5542. // zero = "0" + strconv.Itoa(fpNumber)
  5543. // }else {
  5544. // zero = strconv.Itoa(fpNumber)
  5545. // }
  5546. // fapiao_number = zero
  5547. // }
  5548. // }
  5549. //}
  5550. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5551. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5552. var patientPrescription models.HisPrescriptionInfo
  5553. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5554. if patientPrescription.ID == 0 {
  5555. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5556. }
  5557. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5558. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5559. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5560. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5561. var config []*models.HisXtDiagnoseConfig
  5562. for _, item := range diagnosis_ids {
  5563. id, _ := strconv.ParseInt(item, 10, 64)
  5564. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5565. config = append(config, &diagnosisConfig)
  5566. }
  5567. sickConfig, _ := service.FindSickById(sick_type)
  5568. //if tempOrder.ID == 0 {
  5569. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5570. //}
  5571. if tempOrder.ID == 0 {
  5572. var result string
  5573. var requestLog string
  5574. var res2 ResultSix
  5575. var ressix10265 ResultSix10265
  5576. if miConfig.MdtrtareaAdmvs == "421300" {
  5577. data := make(map[string]interface{})
  5578. client := &http.Client{}
  5579. data["psn_no"] = his.PsnNo
  5580. data["mdtrt_id"] = his.Number
  5581. data["opter"] = roles.UserName
  5582. data["org_name"] = miConfig.OrgName
  5583. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5584. data["doctor_id"] = doctor_info.DoctorNumber
  5585. data["doctor_name"] = doctor_info.UserName
  5586. data["department"] = department.Name
  5587. data["fixmedins_code"] = miConfig.Code
  5588. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5589. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5590. data["secret_key"] = miConfig.SecretKey
  5591. data["sick_code"] = sickConfig.CountryCode
  5592. data["sick_name"] = sickConfig.ClassName
  5593. data["dept"] = strconv.FormatInt(department.ID, 10)
  5594. data["config"] = config
  5595. data["begin_time"] = begin_time
  5596. bytesData, _ := json.Marshal(data)
  5597. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5598. resp, _ := client.Do(req)
  5599. defer resp.Body.Close()
  5600. body, ioErr := ioutil.ReadAll(resp.Body)
  5601. if ioErr != nil {
  5602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5604. return
  5605. }
  5606. var respJSON map[string]interface{}
  5607. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5610. return
  5611. }
  5612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5613. userJSONBytes, _ := json.Marshal(respJSON)
  5614. fmt.Println("log")
  5615. fmt.Println(string(userJSONBytes))
  5616. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5617. utils.ErrorLog("解析失败:%v", err)
  5618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5619. return
  5620. }
  5621. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5622. //江苏地区国家医保医疗类别
  5623. //职工透析:医疗类别选特殊情况门诊9933
  5624. //居民血透门慢: 医疗类别选门诊慢病1402
  5625. //var med_type string
  5626. //if his.Insutype == "310" {
  5627. // if reg_type == 14 {
  5628. // med_type = "9933"
  5629. // } else if reg_type == 11 {
  5630. // med_type = "11"
  5631. //
  5632. // }
  5633. //} else if his.Insutype == "390" {
  5634. // if reg_type == 14 {
  5635. // med_type = "1402"
  5636. // } else if reg_type == 11 {
  5637. // med_type = "11"
  5638. // }
  5639. //}
  5640. data := make(map[string]interface{})
  5641. client := &http.Client{}
  5642. data["psn_no"] = his.PsnNo
  5643. data["mdtrt_id"] = his.Number
  5644. data["doctor"] = roles.UserName
  5645. data["department"] = department.Name
  5646. data["org_name"] = miConfig.OrgName
  5647. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5648. data["doctor_id"] = doctor_info.DoctorNumber
  5649. data["new_doctor_name"] = doctor_info.UserName
  5650. data["fixmedins_code"] = miConfig.Code
  5651. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5652. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5653. data["secret_key"] = miConfig.SecretKey
  5654. data["sick_code"] = sickConfig.CountryCode
  5655. data["sick_name"] = sickConfig.ClassName
  5656. data["url"] = miConfig.Url
  5657. data["ak"] = miConfig.AccessKey
  5658. data["begin_time"] = begin_time
  5659. data["cainfo"] = miConfig.Cainfo
  5660. data["dept"] = strconv.FormatInt(department.ID, 10)
  5661. data["config"] = config
  5662. bytesData, _ := json.Marshal(data)
  5663. var req *http.Request
  5664. if miConfig.MdtrtareaAdmvs == "320921" {
  5665. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5666. //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 +
  5667. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5668. } else {
  5669. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5670. }
  5671. resp, _ := client.Do(req)
  5672. defer resp.Body.Close()
  5673. body, ioErr := ioutil.ReadAll(resp.Body)
  5674. if ioErr != nil {
  5675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5677. return
  5678. }
  5679. var respJSON map[string]interface{}
  5680. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5683. return
  5684. }
  5685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5686. userJSONBytes, _ := json.Marshal(respJSON)
  5687. fmt.Println("log")
  5688. fmt.Println(string(userJSONBytes))
  5689. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5690. utils.ErrorLog("解析失败:%v", err)
  5691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5692. return
  5693. }
  5694. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5695. res2.Output = ressix10265.Output
  5696. res2.ErrMsg = ressix10265.ErrMsg
  5697. res2.Cainfo = ressix10265.Cainfo
  5698. res2.WarnMsg = ressix10265.WarnMsg
  5699. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5700. res2.Infcode = infocode
  5701. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5702. 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)
  5703. saveLog(result, requestLog, "2203", "上传就诊信息")
  5704. var respJSON2 map[string]interface{}
  5705. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5708. return
  5709. }
  5710. userJSONBytes2, _ := json.Marshal(respJSON2)
  5711. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5712. utils.ErrorLog("解析失败:%v", err)
  5713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5714. return
  5715. }
  5716. } else {
  5717. if miConfig.MdtrtareaAdmvs == "440781" { //
  5718. 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)
  5719. } else {
  5720. if miConfig.Code == "H15049901371" {
  5721. //赤峰地区国家医保医疗类别
  5722. //职工透析:医疗类别选特殊情况门诊990502
  5723. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5724. var med_type string
  5725. if his.Insutype == "390" {
  5726. if reg_type == 14 {
  5727. med_type = "9933"
  5728. } else if reg_type == 11 {
  5729. med_type = "11"
  5730. }
  5731. } else if his.Insutype == "310" {
  5732. if reg_type == 14 {
  5733. med_type = "990502"
  5734. } else if reg_type == 11 {
  5735. med_type = "11"
  5736. }
  5737. }
  5738. 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)
  5739. } else {
  5740. 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)
  5741. }
  5742. }
  5743. saveLog(result, requestLog, "2203", "上传就诊信息")
  5744. var respJSON2 map[string]interface{}
  5745. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5748. return
  5749. }
  5750. userJSONBytes2, _ := json.Marshal(respJSON2)
  5751. if miConfig.Code == "H15049901371" {
  5752. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5753. utils.ErrorLog("解析失败:%v", err)
  5754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5755. return
  5756. }
  5757. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5758. res2.Output = ressix10265.Output
  5759. res2.ErrMsg = ressix10265.ErrMsg
  5760. res2.Cainfo = ressix10265.Cainfo
  5761. res2.WarnMsg = ressix10265.WarnMsg
  5762. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5763. res2.Infcode = infocode
  5764. } else {
  5765. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5766. utils.ErrorLog("解析失败:%v", err)
  5767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5768. return
  5769. }
  5770. }
  5771. }
  5772. if res2.Infcode != 0 {
  5773. adminUser := c.GetAdminUserInfo()
  5774. errlog := &models.HisOrderError{
  5775. UserOrgId: adminUser.CurrentOrgId,
  5776. Ctime: time.Now().Unix(),
  5777. Mtime: time.Now().Unix(),
  5778. ErrMsg: res2.ErrMsg,
  5779. Status: 1,
  5780. PatientId: id,
  5781. RecordTime: recordDateTime,
  5782. Stage: 3,
  5783. }
  5784. service.CreateErrMsgLog(errlog)
  5785. c.ServeSuccessJSON(map[string]interface{}{
  5786. "failed_code": -10,
  5787. "msg": res2.ErrMsg,
  5788. })
  5789. return
  5790. } else {
  5791. his.Diagnosis = diagnosis_id
  5792. his.SickType = sickConfig.ID
  5793. //var p_type int64
  5794. //if reg_type == 1111 || reg_type == 1112 {
  5795. // p_type = 11
  5796. //
  5797. //}
  5798. his.PType = fmt.Sprintf("%d", reg_type)
  5799. service.UpdateHisPatientThree(&his)
  5800. data := make(map[string]interface{})
  5801. if settle_accounts_type == 1 { //日结
  5802. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5803. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5804. } else {
  5805. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5806. }
  5807. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5808. data["pre"] = prescriptions
  5809. } else { //月结
  5810. start_time_str := c.GetString("start_time")
  5811. end_time_str := c.GetString("end_time")
  5812. timeLayout := "2006-01-02"
  5813. loc, _ := time.LoadLocation("Local")
  5814. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5815. if err != nil {
  5816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5817. return
  5818. }
  5819. recordStartTime := theStartTime.Unix()
  5820. start_time = recordStartTime
  5821. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5822. if err != nil {
  5823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5824. return
  5825. }
  5826. recordEndTime := theEndTime.Unix()
  5827. end_time = recordEndTime
  5828. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5829. data["pre"] = prescriptions
  5830. }
  5831. timestamp := time.Now().Unix()
  5832. tempTime := time.Unix(timestamp, 0)
  5833. timeFormat := tempTime.Format("20060102150405")
  5834. chrgBchno := rand.Intn(100000) + 10000
  5835. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5836. strconv.FormatInt(his.PatientId, 10)
  5837. client := &http.Client{}
  5838. data["psn_no"] = his.PsnNo
  5839. data["mdtrt_id"] = his.Number
  5840. data["chrg_bchno"] = chrg_bchno
  5841. data["org_name"] = miConfig.OrgName
  5842. data["doctor"] = doctor_info.UserName
  5843. data["doctor_id"] = doctor_info.DoctorNumber
  5844. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5845. data["fixmedins_code"] = miConfig.Code
  5846. data["opter"] = roles.UserName
  5847. data["dept_code"] = department.Number
  5848. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5849. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5850. data["secret_key"] = miConfig.SecretKey
  5851. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5852. data["url"] = miConfig.Url
  5853. data["ak"] = miConfig.AccessKey
  5854. data["new_doctor_name"] = patientPrescription.Doctor
  5855. data["diag_code"] = sickConfig.CountryCode
  5856. data["cainfo"] = miConfig.Cainfo
  5857. var ids []int64
  5858. for _, item := range prescriptions {
  5859. ids = append(ids, item.ID)
  5860. }
  5861. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5862. if config.IsOpen == 1 { //对接了医保,走医保流程
  5863. var res ResultFour
  5864. var resFour10265 ResultFour10265
  5865. if miConfig.MdtrtareaAdmvs == "421300" {
  5866. bytesData, _ := json.Marshal(data)
  5867. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5868. resp, _ := client.Do(req)
  5869. defer resp.Body.Close()
  5870. body, ioErr := ioutil.ReadAll(resp.Body)
  5871. if ioErr != nil {
  5872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5874. return
  5875. }
  5876. var respJSON map[string]interface{}
  5877. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5880. return
  5881. }
  5882. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5883. userJSONBytes, _ := json.Marshal(respJSON)
  5884. fmt.Println("log")
  5885. fmt.Println(string(userJSONBytes))
  5886. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5887. utils.ErrorLog("解析失败:%v", err)
  5888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5889. return
  5890. }
  5891. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5892. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5893. if result3101.Infcode == "0" {
  5894. if len(result3101.Output.Result) > 0 {
  5895. var errMsgs []string
  5896. for _, item := range result3101.Output.Result {
  5897. errMsgs = append(errMsgs, item.VolaCont)
  5898. }
  5899. c.ServeSuccessJSON(map[string]interface{}{
  5900. "failed_code": -10,
  5901. "msg": errMsgs,
  5902. })
  5903. return
  5904. }
  5905. }
  5906. bytesData, _ := json.Marshal(data)
  5907. var req *http.Request
  5908. if miConfig.MdtrtareaAdmvs == "320921" {
  5909. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5910. } else {
  5911. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5912. }
  5913. resp, _ := client.Do(req)
  5914. defer resp.Body.Close()
  5915. body, ioErr := ioutil.ReadAll(resp.Body)
  5916. if ioErr != nil {
  5917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5919. return
  5920. }
  5921. var respJSON map[string]interface{}
  5922. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5925. return
  5926. }
  5927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5928. userJSONBytes, _ := json.Marshal(respJSON)
  5929. fmt.Println("log")
  5930. fmt.Println(string(userJSONBytes))
  5931. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5932. utils.ErrorLog("解析失败:%v", err)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. res.InfRefmsgid = resFour10265.InfRefmsgid
  5937. res.Output = resFour10265.Output
  5938. res.ErrMsg = resFour10265.ErrMsg
  5939. res.Cainfo = resFour10265.Cainfo
  5940. res.WarnMsg = resFour10265.WarnMsg
  5941. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5942. res.Infcode = infocode
  5943. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5944. 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)
  5945. var dat map[string]interface{}
  5946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5947. fmt.Println(dat)
  5948. } else {
  5949. fmt.Println(err)
  5950. }
  5951. saveLog(result, request_log, "2204", "上传费用明细")
  5952. userJSONBytes, _ := json.Marshal(dat)
  5953. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5954. utils.ErrorLog("解析失败:%v", err)
  5955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5956. return
  5957. }
  5958. res.InfRefmsgid = resFour10265.InfRefmsgid
  5959. res.Output = resFour10265.Output
  5960. res.ErrMsg = resFour10265.ErrMsg
  5961. res.Cainfo = resFour10265.Cainfo
  5962. res.WarnMsg = resFour10265.WarnMsg
  5963. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5964. res.Infcode = infocode
  5965. } else {
  5966. if miConfig.Code == "H15049901371" {
  5967. 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)
  5968. var dat map[string]interface{}
  5969. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5970. fmt.Println(dat)
  5971. } else {
  5972. fmt.Println(err)
  5973. }
  5974. saveLog(result, request_log, "2204", "上传费用明细")
  5975. userJSONBytes, _ := json.Marshal(dat)
  5976. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5977. utils.ErrorLog("解析失败:%v", err)
  5978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5979. return
  5980. }
  5981. res.InfRefmsgid = resFour10265.InfRefmsgid
  5982. res.Output = resFour10265.Output
  5983. res.ErrMsg = resFour10265.ErrMsg
  5984. res.Cainfo = resFour10265.Cainfo
  5985. res.WarnMsg = resFour10265.WarnMsg
  5986. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5987. res.Infcode = infocode
  5988. } else {
  5989. 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)
  5990. var dat map[string]interface{}
  5991. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5992. fmt.Println(dat)
  5993. } else {
  5994. fmt.Println(err)
  5995. }
  5996. saveLog(result, request_log, "2204", "上传费用明细")
  5997. userJSONBytes, _ := json.Marshal(dat)
  5998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5999. utils.ErrorLog("解析失败:%v", err)
  6000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6001. return
  6002. }
  6003. }
  6004. }
  6005. if res.Infcode == 0 {
  6006. order := &models.HisOrder{
  6007. UserOrgId: adminUser.CurrentOrgId,
  6008. HisPatientId: his.ID,
  6009. PatientId: his.PatientId,
  6010. SettleAccountsDate: recordDateTime,
  6011. MdtrtId: his.Number,
  6012. PsnNo: his.PsnNo,
  6013. MedType: strconv.FormatInt(reg_type, 10),
  6014. Ctime: time.Now().Unix(),
  6015. Mtime: time.Now().Unix(),
  6016. Status: 1,
  6017. Number: chrg_bchno,
  6018. Infcode: res.Infcode,
  6019. WarnMsg: res.WarnMsg,
  6020. Cainfo: res.Cainfo,
  6021. ErrMsg: res.ErrMsg,
  6022. RespondTime: res.RefmsgTime,
  6023. InfRefmsgid: res.InfRefmsgid,
  6024. OrderStatus: 1,
  6025. PayWay: pay_way,
  6026. PayPrice: pay_price,
  6027. PayCardNo: pay_card_no,
  6028. DiscountPrice: discount_price,
  6029. PreferentialPrice: preferential_price,
  6030. RealityPrice: reality_price,
  6031. FoundPrice: found_price,
  6032. MedicalInsurancePrice: medical_insurance_price,
  6033. PrivatePrice: private_price,
  6034. IsMedicineInsurance: 1,
  6035. SettleType: settle_accounts_type,
  6036. SettleStartTime: start_time,
  6037. SettleEndTime: end_time,
  6038. Creator: roles.AdminUserId,
  6039. Modify: roles.AdminUserId,
  6040. FaPiaoNumber: fapiao_number,
  6041. FaPiaoCode: fapiao_code,
  6042. PType: 2,
  6043. Diagnosis: diagnosis_id,
  6044. }
  6045. err = service.CreateOrder(order)
  6046. if err != nil {
  6047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6048. return
  6049. }
  6050. for _, item := range res.Output.Result {
  6051. temp := strings.Split(item.FeedetlSn, "-")
  6052. var advice_id int64 = 0
  6053. var project_id int64 = 0
  6054. var types int64 = 0
  6055. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6056. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6057. if temp[1] == "1" {
  6058. advice_id = id
  6059. project_id = 0
  6060. } else if temp[1] == "2" {
  6061. advice_id = 0
  6062. project_id = id
  6063. }
  6064. info := &models.HisOrderInfo{
  6065. OrderNumber: order.Number,
  6066. FeedetlSn: item.FeedetlSn,
  6067. UploadDate: time.Now().Unix(),
  6068. AdviceId: advice_id,
  6069. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6070. Cnt: item.Cnt,
  6071. Pric: float64(item.Pric),
  6072. PatientId: his.PatientId,
  6073. PricUplmtAmt: item.PricUplmtAmt,
  6074. SelfpayProp: item.SelfpayProp,
  6075. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6076. OverlmtAmt: item.OverlmtAmt,
  6077. PreselfpayAmt: item.PreselfpayAmt,
  6078. BasMednFlag: item.BasMednFlag,
  6079. MedChrgitmType: item.MedChrgitmType,
  6080. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6081. Status: 1,
  6082. Memo: item.Memo,
  6083. Mtime: time.Now().Unix(),
  6084. InscpScpAmt: item.InscpScpAmt,
  6085. DrtReimFlag: item.DrtReimFlag,
  6086. Ctime: time.Now().Unix(),
  6087. ListSpItemFlag: item.ListSpItemFlag,
  6088. ChldMedcFlag: item.ChldMedcFlag,
  6089. LmtUsedFlag: item.LmtUsedFlag,
  6090. ChrgitmLv: item.ChrgitmLv,
  6091. UserOrgId: adminUser.CurrentOrgId,
  6092. HisPatientId: his.ID,
  6093. OrderId: order.ID,
  6094. ProjectId: project_id,
  6095. Type: types,
  6096. }
  6097. service.CreateOrderInfo(info)
  6098. }
  6099. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6100. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6101. var total float64
  6102. for _, item := range prescriptions {
  6103. if item.Type == 1 { //药品
  6104. for _, subItem := range item.HisDoctorAdviceInfo {
  6105. total = total + (subItem.Price * subItem.PrescribingNumber)
  6106. }
  6107. }
  6108. if item.Type == 2 { //项目
  6109. for _, subItem := range item.HisPrescriptionProject {
  6110. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6111. total = total + (subItem.Price * cnt)
  6112. }
  6113. }
  6114. }
  6115. for _, item := range prescriptions {
  6116. for _, subItem := range item.HisAdditionalCharge {
  6117. total = total + (subItem.Price * float64(subItem.Count))
  6118. }
  6119. }
  6120. var allTotal string
  6121. if adminUser.CurrentOrgId == 9919 {
  6122. allTotal = fmt.Sprintf("%.4f", total)
  6123. } else {
  6124. allTotal = fmt.Sprintf("%.4f", total)
  6125. }
  6126. if res.Infcode == 0 {
  6127. var rf []*ResultFive
  6128. json.Unmarshal([]byte(his.Iinfo), &rf)
  6129. chrg_bchno := chrg_bchno
  6130. cert_no := his.Certno
  6131. var insutypes []string
  6132. var insutype string
  6133. var is390 int = 0
  6134. var is310 int = 0
  6135. for _, item := range rf {
  6136. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6137. insutypes = append(insutypes, item.Insutype)
  6138. }
  6139. }
  6140. if len(insutypes) == 1 {
  6141. insutype = insutypes[0]
  6142. } else {
  6143. for _, i := range insutypes {
  6144. if i == "390" {
  6145. is390 = 1
  6146. }
  6147. if i == "310" {
  6148. is310 = 1
  6149. }
  6150. }
  6151. }
  6152. if is390 == 1 {
  6153. insutype = "390"
  6154. }
  6155. if is310 == 1 {
  6156. insutype = "310"
  6157. }
  6158. if len(insutypes) == 0 {
  6159. insutype = "310"
  6160. }
  6161. if len(insutypes) == 2 {
  6162. insutype = strconv.FormatInt(his.SocialType, 10)
  6163. }
  6164. insutype = strconv.FormatInt(his.SocialType, 10)
  6165. //insutype = "390"
  6166. if his.IdCardType == 1 {
  6167. // cert_no = his.MedicalInsuranceNumber
  6168. cert_no = his.Certno
  6169. } else {
  6170. cert_no = his.Certno
  6171. }
  6172. var res ResultSeven
  6173. var resSeven10265 ResultSeven10265
  6174. var src_resquest string
  6175. var result2 string
  6176. var acct_used_flag string
  6177. fmt.Println("pay_way")
  6178. fmt.Println(pay_way)
  6179. fmt.Println("pay_way")
  6180. if pay_way == 4 {
  6181. acct_used_flag = "1"
  6182. } else {
  6183. acct_used_flag = "0"
  6184. }
  6185. if miConfig.MdtrtareaAdmvs == "421300" {
  6186. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6187. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6188. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6189. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6190. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6191. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6192. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6193. resp, requestErr := http.Get(api)
  6194. if requestErr != nil {
  6195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6196. return
  6197. }
  6198. body, ioErr := ioutil.ReadAll(resp.Body)
  6199. if ioErr != nil {
  6200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6202. return
  6203. }
  6204. var respJSON map[string]interface{}
  6205. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6208. return
  6209. }
  6210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6211. result, _ := json.Marshal(respJSON)
  6212. if miConfig.Code == "H15049901371" {
  6213. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6214. utils.ErrorLog("解析失败:%v", err)
  6215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6216. return
  6217. }
  6218. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6219. res.Output = resSeven10265.Output
  6220. res.ErrMsg = resSeven10265.ErrMsg
  6221. res.Cainfo = resSeven10265.Cainfo
  6222. res.WarnMsg = resSeven10265.WarnMsg
  6223. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6224. res.Infcode = infocode
  6225. } else {
  6226. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6227. utils.ErrorLog("解析失败:%v", err)
  6228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6229. return
  6230. }
  6231. }
  6232. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6233. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  6234. if result3101.Infcode == "0" {
  6235. if len(result3101.Output.Result) > 0 {
  6236. var errMsgs []string
  6237. for _, item := range result3101.Output.Result {
  6238. errMsgs = append(errMsgs, item.VolaCont)
  6239. }
  6240. c.ServeSuccessJSON(map[string]interface{}{
  6241. "failed_code": -10,
  6242. "msg": errMsgs,
  6243. })
  6244. return
  6245. } else {
  6246. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6247. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6248. bas := strings.Split(psn_info.CardInfo, "|")
  6249. if his.IdCardType == 1 {
  6250. cert_no = bas[2]
  6251. } else if his.IdCardType == 3 {
  6252. cert_no = his.Certno
  6253. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6254. } else if his.IdCardType == 4 {
  6255. cert_no = his.Certno
  6256. psn_info.VerifyNumber = token
  6257. }
  6258. var api string
  6259. if miConfig.MdtrtareaAdmvs == "320921" {
  6260. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6261. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6262. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6263. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6264. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6265. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6266. "&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
  6267. } else {
  6268. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6269. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6270. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6271. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6272. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6273. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6274. "&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
  6275. }
  6276. resp, requestErr := http.Get(api)
  6277. if requestErr != nil {
  6278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6279. return
  6280. }
  6281. body, ioErr := ioutil.ReadAll(resp.Body)
  6282. if ioErr != nil {
  6283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6285. return
  6286. }
  6287. var respJSON map[string]interface{}
  6288. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6291. return
  6292. }
  6293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6294. result, _ := json.Marshal(respJSON)
  6295. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6296. utils.ErrorLog("解析失败:%v", err)
  6297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6298. return
  6299. }
  6300. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6301. res.Output = resSeven10265.Output
  6302. res.ErrMsg = resSeven10265.ErrMsg
  6303. res.Cainfo = resSeven10265.Cainfo
  6304. res.WarnMsg = resSeven10265.WarnMsg
  6305. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6306. res.Infcode = infocode
  6307. }
  6308. }
  6309. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6310. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6311. var cert_no string
  6312. if his.IdCardType == 1 {
  6313. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6314. }
  6315. fmt.Println(cert_no)
  6316. 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)
  6317. //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)
  6318. var dat map[string]interface{}
  6319. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6320. fmt.Println(dat)
  6321. } else {
  6322. fmt.Println(err)
  6323. }
  6324. saveLog(result2, src_resquest, "2207", "结算")
  6325. userJSONBytes, _ := json.Marshal(dat)
  6326. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6327. utils.ErrorLog("解析失败:%v", err)
  6328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6329. return
  6330. }
  6331. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6332. res.Output = resSeven10265.Output
  6333. res.ErrMsg = resSeven10265.ErrMsg
  6334. res.Cainfo = resSeven10265.Cainfo
  6335. res.WarnMsg = resSeven10265.WarnMsg
  6336. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6337. res.Infcode = infocode
  6338. } else {
  6339. if miConfig.Code == "H15049901371" {
  6340. //赤峰地区国家医保医疗类别
  6341. //职工透析:医疗类别选特殊情况门诊990502
  6342. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6343. var med_type string
  6344. if his.Insutype == "390" {
  6345. if reg_type == 14 {
  6346. med_type = "9933"
  6347. } else if reg_type == 11 {
  6348. med_type = "11"
  6349. }
  6350. } else if his.Insutype == "310" {
  6351. if reg_type == 14 {
  6352. med_type = "990502"
  6353. } else if reg_type == 11 {
  6354. med_type = "11"
  6355. }
  6356. }
  6357. 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)
  6358. } else {
  6359. 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)
  6360. }
  6361. //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)
  6362. var dat map[string]interface{}
  6363. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6364. fmt.Println(dat)
  6365. } else {
  6366. fmt.Println(err)
  6367. }
  6368. saveLog(result2, src_resquest, "2207", "结算")
  6369. userJSONBytes, _ := json.Marshal(dat)
  6370. if miConfig.Code == "H15049901371" {
  6371. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6372. utils.ErrorLog("解析失败:%v", err)
  6373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6374. return
  6375. }
  6376. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6377. res.Output = resSeven10265.Output
  6378. res.ErrMsg = resSeven10265.ErrMsg
  6379. res.Cainfo = resSeven10265.Cainfo
  6380. res.WarnMsg = resSeven10265.WarnMsg
  6381. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6382. res.Infcode = infocode
  6383. } else {
  6384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6385. utils.ErrorLog("解析失败:%v", err)
  6386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6387. return
  6388. }
  6389. }
  6390. }
  6391. if res.Infcode != 0 {
  6392. errlog := &models.HisOrderError{
  6393. UserOrgId: adminUser.CurrentOrgId,
  6394. Ctime: time.Now().Unix(),
  6395. Mtime: time.Now().Unix(),
  6396. Number: chrg_bchno,
  6397. ErrMsg: res.ErrMsg,
  6398. Status: 1,
  6399. PatientId: id,
  6400. RecordTime: recordDateTime,
  6401. Stage: 6,
  6402. }
  6403. service.CreateErrMsgLog(errlog)
  6404. c.ServeSuccessJSON(map[string]interface{}{
  6405. "failed_code": -10,
  6406. "msg": res.ErrMsg,
  6407. })
  6408. return
  6409. } else {
  6410. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6411. order.OrderStatus = 2
  6412. order.Status = 1
  6413. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6414. order.SetlId = res.Output.Setlinfo.SetlID
  6415. order.PsnNo = res.Output.Setlinfo.PsnNo
  6416. order.PsnName = res.Output.Setlinfo.PsnName
  6417. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6418. order.Certno = res.Output.Setlinfo.Certno
  6419. order.Gend = res.Output.Setlinfo.Gend
  6420. order.Naty = res.Output.Setlinfo.Naty
  6421. order.Age = res.Output.Setlinfo.Age
  6422. order.Insutype = res.Output.Setlinfo.Insutype
  6423. order.PsnType = res.Output.Setlinfo.PsnType
  6424. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6425. order.SetlTime = res.Output.Setlinfo.SetlTime
  6426. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6427. if res.Output.Setlinfo.MedType == "140101" {
  6428. order.MedType = "14"
  6429. } else {
  6430. order.MedType = res.Output.Setlinfo.MedType
  6431. }
  6432. if reg_type == 1112 {
  6433. order.MedType = "1112"
  6434. }
  6435. if reg_type == 1111 {
  6436. order.MedType = "1111"
  6437. }
  6438. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6439. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6440. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6441. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6442. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6443. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6444. order.HifpPay = res.Output.Setlinfo.HifpPay
  6445. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6446. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6447. order.HifesPay = res.Output.Setlinfo.HifesPay
  6448. order.HifobPay = res.Output.Setlinfo.HifobPay
  6449. order.MafPay = res.Output.Setlinfo.MafPay
  6450. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6451. order.OthPay = res.Output.Setlinfo.OthPay
  6452. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6453. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6454. order.AcctPay = res.Output.Setlinfo.AcctPay
  6455. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6456. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6457. order.Balc = res.Output.Setlinfo.Balc
  6458. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6459. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6460. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6461. order.ClrType = res.Output.Setlinfo.ClrType
  6462. order.ClrWay = res.Output.Setlinfo.ClrWay
  6463. order.Creator = order.Creator
  6464. order.Modify = roles.AdminUserId
  6465. order.RequestLog = src_resquest
  6466. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6467. detailStr := string(setlDetail)
  6468. order.SetlDetail = detailStr
  6469. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6470. err = service.UpDateOrder(order)
  6471. if err == nil {
  6472. //判断是否使用了押金
  6473. if dec_way == "true" {
  6474. tmpstring := strconv.FormatInt(order.ID, 10)
  6475. order.Decimal = decimal
  6476. service.UpDateOrder(order)
  6477. //扣押金
  6478. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6479. if errmsg != nil {
  6480. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6481. return
  6482. }
  6483. }
  6484. c.ServeSuccessJSON(map[string]interface{}{
  6485. "msg": "结算成功",
  6486. })
  6487. } else {
  6488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6489. return
  6490. }
  6491. }
  6492. } else {
  6493. adminUser := c.GetAdminUserInfo()
  6494. errlog := &models.HisOrderError{
  6495. UserOrgId: adminUser.CurrentOrgId,
  6496. Ctime: time.Now().Unix(),
  6497. Mtime: time.Now().Unix(),
  6498. ErrMsg: res.ErrMsg,
  6499. Status: 1,
  6500. PatientId: id,
  6501. RecordTime: recordDateTime,
  6502. Stage: 4,
  6503. }
  6504. service.CreateErrMsgLog(errlog)
  6505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6506. return
  6507. }
  6508. } else {
  6509. adminUser := c.GetAdminUserInfo()
  6510. errlog := &models.HisOrderError{
  6511. UserOrgId: adminUser.CurrentOrgId,
  6512. Ctime: time.Now().Unix(),
  6513. Mtime: time.Now().Unix(),
  6514. ErrMsg: res.ErrMsg,
  6515. Status: 1,
  6516. PatientId: id,
  6517. RecordTime: recordDateTime,
  6518. Stage: 4,
  6519. }
  6520. service.CreateErrMsgLog(errlog)
  6521. c.ServeSuccessJSON(map[string]interface{}{
  6522. "failed_code": -10,
  6523. "msg": res.ErrMsg,
  6524. })
  6525. return
  6526. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6527. //return
  6528. }
  6529. }
  6530. }
  6531. } else if tempOrder.ID > 0 {
  6532. if tempOrder.IsPre == 1 {
  6533. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6534. var rf []*ResultFive
  6535. json.Unmarshal([]byte(his.Iinfo), &rf)
  6536. chrg_bchno := tempOrder.Number
  6537. cert_no := his.Certno
  6538. var insutypes []string
  6539. var insutype string
  6540. var is390 int = 0
  6541. var is310 int = 0
  6542. for _, item := range rf {
  6543. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6544. insutypes = append(insutypes, item.Insutype)
  6545. }
  6546. }
  6547. if len(insutypes) == 1 {
  6548. insutype = insutypes[0]
  6549. } else {
  6550. for _, i := range insutypes {
  6551. if i == "390" {
  6552. is390 = 1
  6553. }
  6554. if i == "310" {
  6555. is310 = 1
  6556. }
  6557. }
  6558. }
  6559. if is390 == 1 {
  6560. insutype = "390"
  6561. }
  6562. if is310 == 1 {
  6563. insutype = "310"
  6564. }
  6565. if len(insutypes) == 0 {
  6566. insutype = "310"
  6567. }
  6568. if len(insutypes) == 2 {
  6569. insutype = strconv.FormatInt(his.SocialType, 64)
  6570. }
  6571. //insutype = "390"
  6572. if his.IdCardType == 1 {
  6573. // cert_no = his.MedicalInsuranceNumber
  6574. cert_no = his.Certno
  6575. } else {
  6576. cert_no = his.Certno
  6577. }
  6578. var res ResultSeven
  6579. var resSeven10265 ResultSeven10265
  6580. var src_resquest string
  6581. var result2 string
  6582. var acct_used_flag string
  6583. fmt.Println("pay_way")
  6584. fmt.Println(pay_way)
  6585. fmt.Println("pay_way")
  6586. if pay_way == 4 {
  6587. acct_used_flag = "1"
  6588. } else {
  6589. acct_used_flag = "0"
  6590. }
  6591. if miConfig.MdtrtareaAdmvs == "421300" {
  6592. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6593. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6594. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6595. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6596. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6597. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6598. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6599. resp, requestErr := http.Get(api)
  6600. if requestErr != nil {
  6601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6602. return
  6603. }
  6604. body, ioErr := ioutil.ReadAll(resp.Body)
  6605. if ioErr != nil {
  6606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6608. return
  6609. }
  6610. var respJSON map[string]interface{}
  6611. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6614. return
  6615. }
  6616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6617. result, _ := json.Marshal(respJSON)
  6618. fmt.Println("log")
  6619. fmt.Println(string(result))
  6620. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6621. utils.ErrorLog("解析失败:%v", err)
  6622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6623. return
  6624. }
  6625. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6626. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  6627. if result3101.Infcode == "0" {
  6628. if len(result3101.Output.Result) > 0 {
  6629. var errMsgs []string
  6630. for _, item := range result3101.Output.Result {
  6631. errMsgs = append(errMsgs, item.VolaCont)
  6632. }
  6633. c.ServeSuccessJSON(map[string]interface{}{
  6634. "failed_code": -10,
  6635. "msg": errMsgs,
  6636. })
  6637. return
  6638. } else {
  6639. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6640. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6641. //psn_info, _ := service.GetPsnByPatientId(id)
  6642. bas := strings.Split(psn_info.CardInfo, "|")
  6643. if his.IdCardType == 1 {
  6644. cert_no = bas[2]
  6645. } else {
  6646. cert_no = bas[1]
  6647. }
  6648. //江苏地区国家医保医疗类别
  6649. //职工透析:医疗类别选特殊情况门诊9933
  6650. //居民血透门慢: 医疗类别选门诊慢病1402
  6651. //var med_type string
  6652. //if his.Insutype == "310" {
  6653. // if reg_type == 14 {
  6654. // med_type = "9933"
  6655. // } else if reg_type == 11 {
  6656. // med_type = "11"
  6657. //
  6658. // }
  6659. //} else if his.Insutype == "390" {
  6660. // if reg_type == 14 {
  6661. // med_type = "1402"
  6662. // } else if reg_type == 11 {
  6663. // med_type = "11"
  6664. // }
  6665. //}
  6666. var api string
  6667. if miConfig.MdtrtareaAdmvs == "320921" {
  6668. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6669. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6670. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6671. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6672. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6673. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6674. "&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
  6675. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6676. } else {
  6677. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6678. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6679. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6680. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6681. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6682. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6683. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6684. "&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
  6685. }
  6686. resp, requestErr := http.Get(api)
  6687. if requestErr != nil {
  6688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6689. return
  6690. }
  6691. body, ioErr := ioutil.ReadAll(resp.Body)
  6692. if ioErr != nil {
  6693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6695. return
  6696. }
  6697. var respJSON map[string]interface{}
  6698. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6701. return
  6702. }
  6703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6704. result, _ := json.Marshal(respJSON)
  6705. fmt.Println("log")
  6706. fmt.Println(string(result))
  6707. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6708. utils.ErrorLog("解析失败:%v", err)
  6709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6710. return
  6711. }
  6712. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6713. res.Output = resSeven10265.Output
  6714. res.ErrMsg = resSeven10265.ErrMsg
  6715. res.Cainfo = resSeven10265.Cainfo
  6716. res.WarnMsg = resSeven10265.WarnMsg
  6717. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6718. res.Infcode = infocode
  6719. }
  6720. }
  6721. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6722. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6723. var cert_no string
  6724. if his.IdCardType == 1 {
  6725. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6726. }
  6727. fmt.Println(cert_no)
  6728. 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)
  6729. var dat map[string]interface{}
  6730. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6731. fmt.Println(dat)
  6732. } else {
  6733. fmt.Println(err)
  6734. }
  6735. saveLog(result2, src_resquest, "2207", "结算")
  6736. userJSONBytes, _ := json.Marshal(dat)
  6737. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6738. utils.ErrorLog("解析失败:%v", err)
  6739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6740. return
  6741. }
  6742. } else {
  6743. var src_resquest string
  6744. if miConfig.Code == "H15049901371" {
  6745. //赤峰地区国家医保医疗类别
  6746. //职工透析:医疗类别选特殊情况门诊990502
  6747. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6748. var med_type string
  6749. if his.Insutype == "390" {
  6750. if reg_type == 14 {
  6751. med_type = "9933"
  6752. } else if reg_type == 11 {
  6753. med_type = "11"
  6754. }
  6755. } else if his.Insutype == "310" {
  6756. if reg_type == 14 {
  6757. med_type = "990502"
  6758. } else if reg_type == 11 {
  6759. med_type = "11"
  6760. }
  6761. }
  6762. 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)
  6763. } else {
  6764. 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)
  6765. }
  6766. var dat map[string]interface{}
  6767. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6768. fmt.Println(dat)
  6769. } else {
  6770. fmt.Println(err)
  6771. }
  6772. saveLog(result2, src_resquest, "2207", "结算")
  6773. userJSONBytes, _ := json.Marshal(dat)
  6774. if miConfig.Code == "H15049901371" {
  6775. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6776. utils.ErrorLog("解析失败:%v", err)
  6777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6778. return
  6779. }
  6780. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6781. res.Output = resSeven10265.Output
  6782. res.ErrMsg = resSeven10265.ErrMsg
  6783. res.Cainfo = resSeven10265.Cainfo
  6784. res.WarnMsg = resSeven10265.WarnMsg
  6785. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6786. res.Infcode = infocode
  6787. } else {
  6788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6789. utils.ErrorLog("解析失败:%v", err)
  6790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6791. return
  6792. }
  6793. }
  6794. }
  6795. if res.Infcode != 0 {
  6796. errlog := &models.HisOrderError{
  6797. UserOrgId: adminUser.CurrentOrgId,
  6798. Ctime: time.Now().Unix(),
  6799. Mtime: time.Now().Unix(),
  6800. Number: chrg_bchno,
  6801. ErrMsg: res.ErrMsg,
  6802. Status: 1,
  6803. PatientId: id,
  6804. RecordTime: recordDateTime,
  6805. Stage: 6,
  6806. }
  6807. service.CreateErrMsgLog(errlog)
  6808. c.ServeSuccessJSON(map[string]interface{}{
  6809. "failed_code": -10,
  6810. "msg": res.ErrMsg,
  6811. })
  6812. return
  6813. } else {
  6814. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6815. order.OrderStatus = 2
  6816. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6817. order.SetlId = res.Output.Setlinfo.SetlID
  6818. order.PsnNo = res.Output.Setlinfo.PsnNo
  6819. order.PsnName = res.Output.Setlinfo.PsnName
  6820. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6821. order.Certno = res.Output.Setlinfo.Certno
  6822. order.Gend = res.Output.Setlinfo.Gend
  6823. order.Naty = res.Output.Setlinfo.Naty
  6824. order.Age = res.Output.Setlinfo.Age
  6825. order.Insutype = res.Output.Setlinfo.Insutype
  6826. order.PsnType = res.Output.Setlinfo.PsnType
  6827. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6828. order.SetlTime = res.Output.Setlinfo.SetlTime
  6829. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6830. //order.MedType = res.Output.Setlinfo.MedType
  6831. if reg_type == 1112 {
  6832. order.MedType = "1112"
  6833. }
  6834. if reg_type == 1111 {
  6835. order.MedType = "1111"
  6836. }
  6837. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6838. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6839. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6840. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6841. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6842. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6843. order.HifpPay = res.Output.Setlinfo.HifpPay
  6844. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6845. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6846. order.HifesPay = res.Output.Setlinfo.HifesPay
  6847. order.HifobPay = res.Output.Setlinfo.HifobPay
  6848. order.MafPay = res.Output.Setlinfo.MafPay
  6849. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6850. order.OthPay = res.Output.Setlinfo.OthPay
  6851. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6852. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6853. order.AcctPay = res.Output.Setlinfo.AcctPay
  6854. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6855. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6856. order.Balc = res.Output.Setlinfo.Balc
  6857. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6858. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6859. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6860. order.ClrWay = res.Output.Setlinfo.ClrWay
  6861. order.Creator = order.Creator
  6862. order.Modify = roles.AdminUserId
  6863. order.RequestLog = src_resquest
  6864. order.Diagnosis = diagnosis_id
  6865. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6866. detailStr := string(setlDetail)
  6867. order.SetlDetail = detailStr
  6868. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6869. err = service.UpDateOrder(order)
  6870. if err == nil {
  6871. //判断是否使用了押金
  6872. if dec_way == "true" {
  6873. tmpstring := strconv.FormatInt(order.ID, 10)
  6874. //扣押金
  6875. order.Decimal = decimal
  6876. service.UpDateOrder(order)
  6877. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6878. if errmsg != nil {
  6879. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6880. return
  6881. }
  6882. }
  6883. c.ServeSuccessJSON(map[string]interface{}{
  6884. "msg": "结算成功",
  6885. })
  6886. } else {
  6887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6888. return
  6889. }
  6890. }
  6891. }
  6892. }
  6893. }
  6894. //func (c *HisApiController) GetPreUploadInfo() {
  6895. // id, _ := c.GetInt64("id")
  6896. // record_time := c.GetString("record_time")
  6897. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6898. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6899. //
  6900. // timeLayout := "2006-01-02"
  6901. // loc, _ := time.LoadLocation("Local")
  6902. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6903. // if err != nil {
  6904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6905. // return
  6906. // }
  6907. // recordDateTime := theTime.Unix()
  6908. // adminUser := c.GetAdminUserInfo()
  6909. //
  6910. // var prescriptions []*models.HisPrescription
  6911. //
  6912. // var start_time int64
  6913. // var end_time int64
  6914. //
  6915. // data := make(map[string]interface{})
  6916. // if settle_accounts_type == 1 { //日结
  6917. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6918. // data["pre"] = prescriptions
  6919. //
  6920. // } else { //月结
  6921. // start_time_str := c.GetString("start_time")
  6922. // end_time_str := c.GetString("end_time")
  6923. // timeLayout := "2006-01-02"
  6924. // loc, _ := time.LoadLocation("Local")
  6925. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6926. // if err != nil {
  6927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6928. // return
  6929. // }
  6930. // recordStartTime := theStartTime.Unix()
  6931. // start_time = recordStartTime
  6932. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6933. // if err != nil {
  6934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6935. // return
  6936. // }
  6937. // recordEndTime := theEndTime.Unix()
  6938. // end_time = recordEndTime
  6939. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6940. // data["pre"] = prescriptions
  6941. //
  6942. // }
  6943. //
  6944. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6945. //
  6946. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6947. // timestamp := time.Now().Unix()
  6948. // tempTime := time.Unix(timestamp, 0)
  6949. // timeFormat := tempTime.Format("20060102150405")
  6950. // chrgBchno := rand.Intn(100000) + 10000
  6951. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6952. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6953. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6954. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6955. // strconv.FormatInt(his.PatientId, 10)
  6956. // client := &http.Client{}
  6957. // data["psn_no"] = his.PsnNo
  6958. // data["mdtrt_id"] = his.Number
  6959. // data["chrg_bchno"] = chrg_bchno
  6960. // data["org_name"] = miConfig.OrgName
  6961. // data["doctor"] = roles.UserName
  6962. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6963. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6964. // data["fixmedins_code"] = miConfig.Code
  6965. // data["dept_code"] = department.Number
  6966. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6967. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6968. // data["secret_key"] = miConfig.SecretKey
  6969. // var ids []int64
  6970. //
  6971. // for _, item := range prescriptions {
  6972. // ids = append(ids, item.ID)
  6973. // }
  6974. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6975. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6976. // bytesData, _ := json.Marshal(data)
  6977. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6978. // resp, _ := client.Do(req)
  6979. // defer resp.Body.Close()
  6980. // body, ioErr := ioutil.ReadAll(resp.Body)
  6981. // if ioErr != nil {
  6982. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6983. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6984. // return
  6985. // }
  6986. // var respJSON map[string]interface{}
  6987. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6988. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6989. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6990. // return
  6991. // }
  6992. //
  6993. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6994. // userJSONBytes, _ := json.Marshal(respJSON)
  6995. // var res ResultFour
  6996. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6997. // utils.ErrorLog("解析失败:%v", err)
  6998. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6999. // return
  7000. // }
  7001. //
  7002. // if res.Infcode == 0 {
  7003. // order := &models.HisOrder{
  7004. // UserOrgId: adminUser.CurrentOrgId,
  7005. // HisPatientId: his.ID,
  7006. // PatientId: his.PatientId,
  7007. // SettleAccountsDate: recordDateTime,
  7008. // Ctime: time.Now().Unix(),
  7009. // Mtime: time.Now().Unix(),
  7010. // Status: 1,
  7011. // Number: chrg_bchno,
  7012. // Infcode: res.Infcode,
  7013. // WarnMsg: res.WarnMsg,
  7014. // Cainfo: res.Cainfo,
  7015. // ErrMsg: res.ErrMsg,
  7016. // RespondTime: res.RefmsgTime,
  7017. // InfRefmsgid: res.InfRefmsgid,
  7018. // OrderStatus: 1,
  7019. // IsMedicineInsurance: 1,
  7020. // SettleType: settle_accounts_type,
  7021. // SettleStartTime: start_time,
  7022. // SettleEndTime: end_time,
  7023. // Creator: roles.ID,
  7024. // Modify: roles.ID,
  7025. // PType: 2,
  7026. // }
  7027. // err = service.CreateOrder(order)
  7028. // if err != nil {
  7029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7030. // return
  7031. // }
  7032. //
  7033. // for _, item := range res.Output.Result {
  7034. // temp := strings.Split(item.FeedetlSn, "-")
  7035. // var advice_id int64 = 0
  7036. // var project_id int64 = 0
  7037. // var types int64 = 0
  7038. //
  7039. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  7040. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  7041. //
  7042. // if temp[1] == "1" {
  7043. // advice_id = id
  7044. // project_id = 0
  7045. // } else if temp[1] == "2" {
  7046. // advice_id = 0
  7047. // project_id = id
  7048. // }
  7049. //
  7050. // info := &models.HisOrderInfo{
  7051. // OrderNumber: order.Number,
  7052. // FeedetlSn: item.FeedetlSn,
  7053. // UploadDate: time.Now().Unix(),
  7054. // AdviceId: advice_id,
  7055. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  7056. // Cnt: item.Cnt,
  7057. // Pric: float64(item.Pric),
  7058. // PatientId: his.PatientId,
  7059. // PricUplmtAmt: item.PricUplmtAmt,
  7060. // SelfpayProp: item.SelfpayProp,
  7061. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7062. // OverlmtAmt: item.OverlmtAmt,
  7063. // PreselfpayAmt: item.PreselfpayAmt,
  7064. // BasMednFlag: item.BasMednFlag,
  7065. // MedChrgitmType: item.MedChrgitmType,
  7066. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  7067. // Status: 1,
  7068. // Memo: item.Memo,
  7069. // Mtime: time.Now().Unix(),
  7070. // InscpScpAmt: item.InscpScpAmt,
  7071. // DrtReimFlag: item.DrtReimFlag,
  7072. // Ctime: time.Now().Unix(),
  7073. // ListSpItemFlag: item.ListSpItemFlag,
  7074. // ChldMedcFlag: item.ChldMedcFlag,
  7075. // LmtUsedFlag: item.LmtUsedFlag,
  7076. // ChrgitmLv: item.ChrgitmLv,
  7077. // UserOrgId: adminUser.CurrentOrgId,
  7078. // HisPatientId: his.ID,
  7079. // OrderId: order.ID,
  7080. // ProjectId: project_id,
  7081. // Type: types,
  7082. // }
  7083. // service.CreateOrderInfo(info)
  7084. //
  7085. // }
  7086. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7087. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  7088. //
  7089. // var total float64
  7090. // for _, item := range prescriptions {
  7091. // if item.Type == 1 { //药品
  7092. // for _, subItem := range item.HisDoctorAdviceInfo {
  7093. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7094. // }
  7095. // }
  7096. // if item.Type == 2 { //项目
  7097. // for _, subItem := range item.HisPrescriptionProject {
  7098. // total = total + (subItem.Price * float64(subItem.Count))
  7099. // }
  7100. // }
  7101. // }
  7102. //
  7103. // for _, item := range prescriptions {
  7104. // for _, subItem := range item.HisAdditionalCharge {
  7105. // total = total + (subItem.Price * float64(subItem.Count))
  7106. // }
  7107. // }
  7108. //
  7109. // allTotal := fmt.Sprintf("%.2f", total)
  7110. // if res.Infcode == 0 {
  7111. // var rf []*ResultFive
  7112. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7113. // psn_no := his.PsnNo
  7114. // mdtrt_id := his.Number
  7115. // chrg_bchno := chrg_bchno
  7116. // cert_no := his.Certno
  7117. // insutype := rf[0].Insutype
  7118. //
  7119. // if his.IdCardType == 1 {
  7120. // cert_no = his.MedicalInsuranceNumber
  7121. //
  7122. // } else {
  7123. //
  7124. // cert_no = his.Certno
  7125. //
  7126. // }
  7127. //
  7128. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  7129. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  7130. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  7131. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  7132. // resp, requestErr := http.Get(api)
  7133. // if requestErr != nil {
  7134. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7135. // return
  7136. // }
  7137. // defer resp.Body.Close()
  7138. // body, ioErr := ioutil.ReadAll(resp.Body)
  7139. // if ioErr != nil {
  7140. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7142. // return
  7143. // }
  7144. // var respJSON map[string]interface{}
  7145. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7146. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7148. // return
  7149. // }
  7150. // fmt.Println(respJSON)
  7151. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7152. // userJSONBytes, _ := json.Marshal(respJSON)
  7153. // var res ResultSeven
  7154. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7155. // utils.ErrorLog("解析失败:%v", err)
  7156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7157. // return
  7158. // }
  7159. // if res.Infcode != 0 {
  7160. // errlog := &models.HisOrderError{
  7161. // UserOrgId: adminUser.CurrentOrgId,
  7162. // Ctime: time.Now().Unix(),
  7163. // Mtime: time.Now().Unix(),
  7164. // Number: chrg_bchno,
  7165. // ErrMsg: res.ErrMsg,
  7166. // Status: 1,
  7167. // PatientId: id,
  7168. // RecordTime: recordDateTime,
  7169. // Stage: 7,
  7170. // }
  7171. // service.CreateErrMsgLog(errlog)
  7172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7173. // return
  7174. // } else {
  7175. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7176. // order.OrderStatus = 1
  7177. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7178. // order.SetlId = res.Output.Setlinfo.SetlID
  7179. // order.PsnNo = res.Output.Setlinfo.PsnNo
  7180. // order.PsnName = res.Output.Setlinfo.PsnName
  7181. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7182. // order.Certno = res.Output.Setlinfo.Certno
  7183. // order.Gend = res.Output.Setlinfo.Gend
  7184. // order.Naty = res.Output.Setlinfo.Naty
  7185. // order.Age = res.Output.Setlinfo.Age
  7186. // order.Insutype = res.Output.Setlinfo.Insutype
  7187. // order.PsnType = res.Output.Setlinfo.PsnType
  7188. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7189. // order.SetlTime = res.Output.Setlinfo.SetlTime
  7190. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7191. // order.MedType = res.Output.Setlinfo.MedType
  7192. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7193. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7194. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7195. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7196. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7197. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7198. // order.HifpPay = res.Output.Setlinfo.HifpPay
  7199. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7200. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7201. // order.HifesPay = res.Output.Setlinfo.HifesPay
  7202. // order.HifobPay = res.Output.Setlinfo.HifobPay
  7203. // order.MafPay = res.Output.Setlinfo.MafPay
  7204. // order.OthPay = res.Output.Setlinfo.OthPay
  7205. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7206. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7207. // order.AcctPay = res.Output.Setlinfo.AcctPay
  7208. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7209. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7210. // order.Balc = res.Output.Setlinfo.Balc
  7211. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7212. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7213. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7214. // order.ClrWay = res.Output.Setlinfo.ClrWay
  7215. // order.Creator = order.Creator
  7216. // order.Modify = roles.ID
  7217. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7218. // detailStr := string(setlDetail)
  7219. // order.SetlDetail = detailStr
  7220. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7221. // err = service.UpDateOrder(order)
  7222. // if err == nil {
  7223. // c.ServeSuccessJSON(map[string]interface{}{
  7224. // "msg": "预结算成功",
  7225. // })
  7226. // } else {
  7227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7228. // return
  7229. // }
  7230. // }
  7231. // } else {
  7232. // adminUser := c.GetAdminUserInfo()
  7233. // errlog := &models.HisOrderError{
  7234. // UserOrgId: adminUser.CurrentOrgId,
  7235. // Ctime: time.Now().Unix(),
  7236. // Mtime: time.Now().Unix(),
  7237. // ErrMsg: res.ErrMsg,
  7238. // Status: 1,
  7239. // PatientId: id,
  7240. // RecordTime: recordDateTime,
  7241. // Stage: 4,
  7242. // }
  7243. // service.CreateErrMsgLog(errlog)
  7244. //
  7245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7246. // return
  7247. // }
  7248. // } else {
  7249. // adminUser := c.GetAdminUserInfo()
  7250. // errlog := &models.HisOrderError{
  7251. // UserOrgId: adminUser.CurrentOrgId,
  7252. // Ctime: time.Now().Unix(),
  7253. // Mtime: time.Now().Unix(),
  7254. // ErrMsg: res.ErrMsg,
  7255. // Status: 1,
  7256. // PatientId: id,
  7257. // RecordTime: recordDateTime,
  7258. // Stage: 4,
  7259. // }
  7260. // service.CreateErrMsgLog(errlog)
  7261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7262. // return
  7263. // }
  7264. //
  7265. // } else {
  7266. // var total float64
  7267. // for _, item := range prescriptions {
  7268. // if item.Type == 1 { //药品
  7269. // for _, subItem := range item.HisDoctorAdviceInfo {
  7270. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7271. // }
  7272. // }
  7273. // if item.Type == 2 { //项目
  7274. // for _, subItem := range item.HisPrescriptionProject {
  7275. // total = total + (subItem.Price * float64(subItem.Count))
  7276. // }
  7277. // }
  7278. //
  7279. // for _, subItem := range item.HisAdditionalCharge {
  7280. // total = total + (subItem.Price * float64(subItem.Count))
  7281. // }
  7282. // }
  7283. //
  7284. // allTotal := fmt.Sprintf("%.2f", total)
  7285. // totals, _ := strconv.ParseFloat(allTotal, 64)
  7286. // order := &models.HisOrder{
  7287. // UserOrgId: adminUser.CurrentOrgId,
  7288. // HisPatientId: his.ID,
  7289. // PatientId: id,
  7290. // SettleAccountsDate: recordDateTime,
  7291. // Ctime: time.Now().Unix(),
  7292. // Mtime: time.Now().Unix(),
  7293. // Status: 1,
  7294. // OrderStatus: 2,
  7295. // Number: chrg_bchno,
  7296. // MedfeeSumamt: totals,
  7297. // }
  7298. // err = service.CreateOrder(order)
  7299. // if err != nil {
  7300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7301. // return
  7302. // }
  7303. //
  7304. // var customs []*Custom
  7305. // for _, item := range prescriptions {
  7306. //
  7307. // if item.Type == 1 { //药品
  7308. // for _, subItem := range item.HisDoctorAdviceInfo {
  7309. // cus := &Custom{
  7310. // AdviceId: subItem.ID,
  7311. // ProjectId: 0,
  7312. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7313. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7314. // FeedetlSn: subItem.FeedetlSn,
  7315. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7316. // MedListCodg: subItem.MedListCodg,
  7317. // Type: 1,
  7318. // }
  7319. // customs = append(customs, cus)
  7320. // }
  7321. // }
  7322. //
  7323. // if item.Type == 2 { //项目
  7324. // for _, subItem := range item.HisPrescriptionProject {
  7325. //
  7326. // cus := &Custom{
  7327. // AdviceId: 0,
  7328. // ProjectId: subItem.ID,
  7329. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7330. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7331. // FeedetlSn: subItem.FeedetlSn,
  7332. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7333. // MedListCodg: subItem.MedListCodg,
  7334. // Type: 2,
  7335. // }
  7336. //
  7337. // customs = append(customs, cus)
  7338. // }
  7339. // }
  7340. //
  7341. // for _, item := range item.HisAdditionalCharge {
  7342. // cus := &Custom{
  7343. // ItemId: item.ID,
  7344. // AdviceId: 0,
  7345. // ProjectId: 0,
  7346. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7347. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7348. // FeedetlSn: item.FeedetlSn,
  7349. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7350. // MedListCodg: item.XtHisAddtionConfig.Code,
  7351. // Type: 3,
  7352. // }
  7353. //
  7354. // customs = append(customs, cus)
  7355. // }
  7356. //
  7357. // }
  7358. //
  7359. // for _, item := range customs {
  7360. // var advice_id int64 = 0
  7361. // var project_id int64 = 0
  7362. // var item_id int64 = 0
  7363. //
  7364. // var types int64 = 0
  7365. //
  7366. // if item.Type == 1 {
  7367. // advice_id = item.AdviceId
  7368. // project_id = 0
  7369. // item_id = 0
  7370. // } else if item.Type == 2 {
  7371. // advice_id = 0
  7372. // item_id = 0
  7373. //
  7374. // project_id = item.ProjectId
  7375. // } else if item.Type == 3 {
  7376. // advice_id = 0
  7377. // item_id = item.ItemId
  7378. // project_id = 0
  7379. // }
  7380. //
  7381. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7382. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7383. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7384. //
  7385. // info := &models.HisOrderInfo{
  7386. // OrderNumber: order.Number,
  7387. // UploadDate: time.Now().Unix(),
  7388. // AdviceId: advice_id,
  7389. // DetItemFeeSumamt: detItemFeeSumamt,
  7390. // Cnt: cut,
  7391. // Pric: pric,
  7392. // PatientId: id,
  7393. // Status: 1,
  7394. // Mtime: time.Now().Unix(),
  7395. // Ctime: time.Now().Unix(),
  7396. // UserOrgId: adminUser.CurrentOrgId,
  7397. // HisPatientId: his.ID,
  7398. // OrderId: order.ID,
  7399. // ProjectId: project_id,
  7400. // Type: types,
  7401. // ItemId: item_id,
  7402. // }
  7403. // service.CreateOrderInfo(info)
  7404. // }
  7405. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7406. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7407. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7408. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7409. // if err == nil {
  7410. // c.ServeSuccessJSON(map[string]interface{}{
  7411. // "msg": "结算成功",
  7412. // })
  7413. // } else {
  7414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7415. // return
  7416. // }
  7417. // }
  7418. //}
  7419. //上传明细-预结算-
  7420. func (c *HisApiController) GetPreUploadInfo() {
  7421. id, _ := c.GetInt64("id")
  7422. record_time := c.GetString("record_time")
  7423. his_patient_id, _ := c.GetInt64("his_patient_id")
  7424. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7425. admin_user_id, _ := c.GetInt64("admin_user_id")
  7426. diagnosis_id := c.GetString("diagnosis")
  7427. sick_type, _ := c.GetInt64("sick_type")
  7428. reg_type, _ := c.GetInt64("p_type")
  7429. begin_time := c.GetString("begin_time")
  7430. id_str := c.GetString("ids")
  7431. ids_arr := strings.Split(id_str, ",")
  7432. timeLayout := "2006-01-02"
  7433. loc, _ := time.LoadLocation("Local")
  7434. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7435. if err != nil {
  7436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7437. return
  7438. }
  7439. recordDateTime := theTime.Unix()
  7440. adminUser := c.GetAdminUserInfo()
  7441. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7442. var config []*models.HisXtDiagnoseConfig
  7443. for _, item := range diagnosis_ids {
  7444. id, _ := strconv.ParseInt(item, 10, 64)
  7445. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7446. config = append(config, &diagnosisConfig)
  7447. }
  7448. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7449. sickConfig, _ := service.FindSickById(sick_type)
  7450. var prescriptions []*models.HisPrescription
  7451. var start_time int64
  7452. var end_time int64
  7453. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7454. fmt.Println(his_patient_id)
  7455. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7456. timestamp := time.Now().Unix()
  7457. tempTime := time.Unix(timestamp, 0)
  7458. timeFormat := tempTime.Format("20060102150405")
  7459. chrgBchno := rand.Intn(100000) + 10000
  7460. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7461. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7462. var patientPrescription models.HisPrescriptionInfo
  7463. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7464. if patientPrescription.ID == 0 {
  7465. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7466. }
  7467. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7468. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7469. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7470. strconv.FormatInt(his.PatientId, 10)
  7471. var res2 ResultSix
  7472. var resSix10265 ResultSix10265
  7473. var time_stamp string
  7474. if miConfig.MdtrtareaAdmvs == "421300" {
  7475. data := make(map[string]interface{})
  7476. client := &http.Client{}
  7477. data["psn_no"] = his.PsnNo
  7478. data["mdtrt_id"] = his.Number
  7479. data["department"] = department.Name
  7480. data["org_name"] = miConfig.OrgName
  7481. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7482. data["doctor_id"] = doctor_info.DoctorNumber
  7483. data["doctor_name"] = roles.UserName
  7484. data["fixmedins_code"] = miConfig.Code
  7485. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7486. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7487. data["secret_key"] = miConfig.SecretKey
  7488. data["sick_code"] = sickConfig.CountryCode
  7489. data["sick_name"] = sickConfig.ClassName
  7490. data["begin_time"] = begin_time
  7491. data["dept"] = strconv.FormatInt(department.ID, 10)
  7492. data["config"] = config
  7493. data["opter"] = roles.UserName
  7494. fmt.Println(data)
  7495. bytesData, _ := json.Marshal(data)
  7496. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7497. resp, _ := client.Do(req)
  7498. defer resp.Body.Close()
  7499. body, ioErr := ioutil.ReadAll(resp.Body)
  7500. if ioErr != nil {
  7501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7503. return
  7504. }
  7505. var respJSON map[string]interface{}
  7506. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7509. return
  7510. }
  7511. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7512. userJSONBytes, _ := json.Marshal(respJSON)
  7513. fmt.Println("log")
  7514. fmt.Println(string(userJSONBytes))
  7515. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7516. utils.ErrorLog("解析失败:%v", err)
  7517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7518. return
  7519. }
  7520. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7521. data := make(map[string]interface{})
  7522. client := &http.Client{}
  7523. data["psn_no"] = his.PsnNo
  7524. data["mdtrt_id"] = his.Number
  7525. data["doctor"] = roles.UserName
  7526. data["department"] = department.Name
  7527. data["org_name"] = miConfig.OrgName
  7528. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7529. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7530. data["fixmedins_code"] = miConfig.Code
  7531. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7532. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7533. data["secret_key"] = miConfig.SecretKey
  7534. data["sick_code"] = sickConfig.CountryCode
  7535. data["sick_name"] = sickConfig.ClassName
  7536. data["begin_time"] = begin_time
  7537. data["dept"] = strconv.FormatInt(department.ID, 10)
  7538. data["config"] = config
  7539. data["url"] = miConfig.Url
  7540. data["ak"] = miConfig.AccessKey
  7541. data["cainfo"] = miConfig.Cainfo
  7542. bytesData, _ := json.Marshal(data)
  7543. var req *http.Request
  7544. if miConfig.MdtrtareaAdmvs == "320921" {
  7545. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7546. //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 +
  7547. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7548. } else {
  7549. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7550. }
  7551. resp, _ := client.Do(req)
  7552. defer resp.Body.Close()
  7553. body, ioErr := ioutil.ReadAll(resp.Body)
  7554. if ioErr != nil {
  7555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7557. return
  7558. }
  7559. var respJSON map[string]interface{}
  7560. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7563. return
  7564. }
  7565. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7566. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7567. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7568. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7569. userJSONBytes, _ := json.Marshal(respJSON)
  7570. fmt.Println("log")
  7571. fmt.Println(string(userJSONBytes))
  7572. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7573. utils.ErrorLog("解析失败:%v", err)
  7574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7575. return
  7576. }
  7577. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7578. res2.Output = resSix10265.Output
  7579. res2.ErrMsg = resSix10265.ErrMsg
  7580. res2.Cainfo = resSix10265.Cainfo
  7581. res2.WarnMsg = resSix10265.WarnMsg
  7582. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7583. res2.Infcode = infocode
  7584. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7585. 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)
  7586. saveLog(result, requestLog, "2203", "上传就诊信息")
  7587. var respJSON2 map[string]interface{}
  7588. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7591. return
  7592. }
  7593. userJSONBytes2, _ := json.Marshal(respJSON2)
  7594. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7595. utils.ErrorLog("解析失败:%v", err)
  7596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7597. return
  7598. }
  7599. } else {
  7600. var result string
  7601. var requestLog string
  7602. if miConfig.MdtrtareaAdmvs == "440781" { //
  7603. 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)
  7604. } else {
  7605. if miConfig.Code == "H15049901371" {
  7606. //赤峰地区国家医保医疗类别
  7607. //职工透析:医疗类别选特殊情况门诊990502
  7608. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7609. var med_type string
  7610. if his.Insutype == "390" {
  7611. if reg_type == 14 {
  7612. med_type = "9933"
  7613. } else if reg_type == 11 {
  7614. med_type = "11"
  7615. }
  7616. } else if his.Insutype == "310" {
  7617. if reg_type == 14 {
  7618. med_type = "990502"
  7619. } else if reg_type == 11 {
  7620. med_type = "11"
  7621. }
  7622. }
  7623. 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)
  7624. } else {
  7625. 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)
  7626. }
  7627. saveLog(result, requestLog, "2203", "上传就诊信息")
  7628. var respJSON2 map[string]interface{}
  7629. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7632. return
  7633. }
  7634. userJSONBytes2, _ := json.Marshal(respJSON2)
  7635. if miConfig.Code == "H15049901371" {
  7636. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7637. utils.ErrorLog("解析失败:%v", err)
  7638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7639. return
  7640. }
  7641. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7642. res2.Output = resSix10265.Output
  7643. res2.ErrMsg = resSix10265.ErrMsg
  7644. res2.Cainfo = resSix10265.Cainfo
  7645. res2.WarnMsg = resSix10265.WarnMsg
  7646. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7647. res2.Infcode = infocode
  7648. } else {
  7649. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7650. utils.ErrorLog("解析失败:%v", err)
  7651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7652. return
  7653. }
  7654. }
  7655. }
  7656. }
  7657. if res2.Infcode != 0 {
  7658. adminUser := c.GetAdminUserInfo()
  7659. errlog := &models.HisOrderError{
  7660. UserOrgId: adminUser.CurrentOrgId,
  7661. Ctime: time.Now().Unix(),
  7662. Mtime: time.Now().Unix(),
  7663. ErrMsg: res2.ErrMsg,
  7664. Status: 1,
  7665. PatientId: id,
  7666. RecordTime: recordDateTime,
  7667. Stage: 3,
  7668. }
  7669. service.CreateErrMsgLog(errlog)
  7670. c.ServeSuccessJSON(map[string]interface{}{
  7671. "failed_code": -10,
  7672. "msg": res2.ErrMsg,
  7673. })
  7674. return
  7675. } else {
  7676. his.Diagnosis = diagnosis_id
  7677. his.SickType = sickConfig.ID
  7678. his.PType = fmt.Sprintf("%d", reg_type)
  7679. service.UpdateHisPatientThree(&his)
  7680. data := make(map[string]interface{})
  7681. if settle_accounts_type == 1 { //日结
  7682. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7683. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7684. } else {
  7685. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7686. }
  7687. data["pre"] = prescriptions
  7688. } else { //月结
  7689. start_time_str := c.GetString("start_time")
  7690. end_time_str := c.GetString("end_time")
  7691. timeLayout := "2006-01-02"
  7692. loc, _ := time.LoadLocation("Local")
  7693. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7694. if err != nil {
  7695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7696. return
  7697. }
  7698. recordStartTime := theStartTime.Unix()
  7699. start_time = recordStartTime
  7700. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7701. if err != nil {
  7702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7703. return
  7704. }
  7705. recordEndTime := theEndTime.Unix()
  7706. end_time = recordEndTime
  7707. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7708. data["pre"] = prescriptions
  7709. }
  7710. client := &http.Client{}
  7711. data["psn_no"] = his.PsnNo
  7712. data["mdtrt_id"] = his.Number
  7713. data["chrg_bchno"] = chrg_bchno
  7714. data["org_name"] = miConfig.OrgName
  7715. data["doctor"] = roles.UserName
  7716. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7717. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7718. data["fixmedins_code"] = miConfig.Code
  7719. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7720. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7721. data["dept_code"] = "15"
  7722. } else {
  7723. data["dept_code"] = department.Number
  7724. }
  7725. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7726. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7727. data["secret_key"] = miConfig.SecretKey
  7728. data["url"] = miConfig.Url
  7729. data["ak"] = miConfig.AccessKey
  7730. data["new_doctor_name"] = patientPrescription.Doctor
  7731. data["diag_code"] = sickConfig.CountryCode
  7732. data["time_stamp"] = time_stamp
  7733. data["cainfo"] = miConfig.Cainfo
  7734. var ids []int64
  7735. for _, item := range prescriptions {
  7736. ids = append(ids, item.ID)
  7737. }
  7738. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7739. if config.IsOpen == 1 { //对接了医保,走医保流程
  7740. var res ResultFour
  7741. var resFour10265 ResultFour10265
  7742. if miConfig.MdtrtareaAdmvs == "421300" {
  7743. bytesData, _ := json.Marshal(data)
  7744. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7745. resp, _ := client.Do(req)
  7746. defer resp.Body.Close()
  7747. body, ioErr := ioutil.ReadAll(resp.Body)
  7748. if ioErr != nil {
  7749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7751. return
  7752. }
  7753. var respJSON map[string]interface{}
  7754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7757. return
  7758. }
  7759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7760. userJSONBytes, _ := json.Marshal(respJSON)
  7761. fmt.Println("log")
  7762. fmt.Println(string(userJSONBytes))
  7763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7764. utils.ErrorLog("解析失败:%v", err)
  7765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7766. return
  7767. }
  7768. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7769. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7770. if result3101.Infcode == "0" {
  7771. if len(result3101.Output.Result) > 0 {
  7772. var errMsgs []string
  7773. for _, item := range result3101.Output.Result {
  7774. errMsgs = append(errMsgs, item.VolaCont)
  7775. }
  7776. c.ServeSuccessJSON(map[string]interface{}{
  7777. "failed_code": -10,
  7778. "msg": errMsgs,
  7779. })
  7780. return
  7781. } else {
  7782. bytesData, _ := json.Marshal(data)
  7783. var req *http.Request
  7784. if miConfig.MdtrtareaAdmvs == "320921" {
  7785. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7786. } else {
  7787. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7788. }
  7789. resp, _ := client.Do(req)
  7790. defer resp.Body.Close()
  7791. body, ioErr := ioutil.ReadAll(resp.Body)
  7792. if ioErr != nil {
  7793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7795. return
  7796. }
  7797. var respJSON map[string]interface{}
  7798. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7801. return
  7802. }
  7803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7804. userJSONBytes, _ := json.Marshal(respJSON)
  7805. fmt.Println("log")
  7806. fmt.Println(string(userJSONBytes))
  7807. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7808. utils.ErrorLog("解析失败:%v", err)
  7809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7810. return
  7811. }
  7812. res.InfRefmsgid = resFour10265.InfRefmsgid
  7813. res.Output = resFour10265.Output
  7814. res.ErrMsg = resFour10265.ErrMsg
  7815. res.Cainfo = resFour10265.Cainfo
  7816. res.WarnMsg = resFour10265.WarnMsg
  7817. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7818. res.Infcode = infocode
  7819. }
  7820. }
  7821. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7822. 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)
  7823. var dat map[string]interface{}
  7824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7825. fmt.Println(dat)
  7826. } else {
  7827. fmt.Println(err)
  7828. }
  7829. saveLog(result, request_log, "2204", "上传费用明细")
  7830. userJSONBytes, _ := json.Marshal(dat)
  7831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7832. utils.ErrorLog("解析失败:%v", err)
  7833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7834. return
  7835. }
  7836. } else {
  7837. if miConfig.Code == "H15049901371" {
  7838. 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)
  7839. var dat map[string]interface{}
  7840. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7841. fmt.Println(dat)
  7842. } else {
  7843. fmt.Println(err)
  7844. }
  7845. saveLog(result, request_log, "2204", "上传费用明细")
  7846. userJSONBytes, _ := json.Marshal(dat)
  7847. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7848. utils.ErrorLog("解析失败:%v", err)
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7850. return
  7851. }
  7852. res.InfRefmsgid = resFour10265.InfRefmsgid
  7853. res.Output = resFour10265.Output
  7854. res.ErrMsg = resFour10265.ErrMsg
  7855. res.Cainfo = resFour10265.Cainfo
  7856. res.WarnMsg = resFour10265.WarnMsg
  7857. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7858. res.Infcode = infocode
  7859. } else {
  7860. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  7861. var dat map[string]interface{}
  7862. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7863. fmt.Println(dat)
  7864. } else {
  7865. fmt.Println(err)
  7866. }
  7867. saveLog(result, request_log, "2204", "上传费用明细")
  7868. userJSONBytes, _ := json.Marshal(dat)
  7869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7870. utils.ErrorLog("解析失败:%v", err)
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7872. return
  7873. }
  7874. }
  7875. }
  7876. if res.Infcode == 0 {
  7877. order := &models.HisOrder{
  7878. UserOrgId: adminUser.CurrentOrgId,
  7879. HisPatientId: his.ID,
  7880. PatientId: his.PatientId,
  7881. SettleAccountsDate: recordDateTime,
  7882. Ctime: time.Now().Unix(),
  7883. Mtime: time.Now().Unix(),
  7884. MdtrtId: his.Number,
  7885. PsnNo: his.PsnNo,
  7886. MedType: strconv.FormatInt(reg_type, 10),
  7887. Status: 1,
  7888. Number: chrg_bchno,
  7889. Infcode: res.Infcode,
  7890. WarnMsg: res.WarnMsg,
  7891. Cainfo: res.Cainfo,
  7892. ErrMsg: res.ErrMsg,
  7893. RespondTime: res.RefmsgTime,
  7894. InfRefmsgid: res.InfRefmsgid,
  7895. OrderStatus: 1,
  7896. IsMedicineInsurance: 1,
  7897. SettleType: settle_accounts_type,
  7898. SettleStartTime: start_time,
  7899. SettleEndTime: end_time,
  7900. Creator: roles.AdminUserId,
  7901. Modify: roles.AdminUserId,
  7902. PType: 2,
  7903. Diagnosis: diagnosis_id,
  7904. }
  7905. err = service.CreateOrder(order)
  7906. if err != nil {
  7907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7908. return
  7909. }
  7910. for _, item := range res.Output.Result {
  7911. temp := strings.Split(item.FeedetlSn, "-")
  7912. var advice_id int64 = 0
  7913. var project_id int64 = 0
  7914. var types int64 = 0
  7915. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7916. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7917. if temp[1] == "1" {
  7918. advice_id = id
  7919. project_id = 0
  7920. } else if temp[1] == "2" {
  7921. advice_id = 0
  7922. project_id = id
  7923. }
  7924. info := &models.HisOrderInfo{
  7925. OrderNumber: order.Number,
  7926. FeedetlSn: item.FeedetlSn,
  7927. UploadDate: time.Now().Unix(),
  7928. AdviceId: advice_id,
  7929. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7930. Cnt: item.Cnt,
  7931. Pric: float64(item.Pric),
  7932. PatientId: his.PatientId,
  7933. PricUplmtAmt: item.PricUplmtAmt,
  7934. SelfpayProp: item.SelfpayProp,
  7935. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7936. OverlmtAmt: item.OverlmtAmt,
  7937. PreselfpayAmt: item.PreselfpayAmt,
  7938. BasMednFlag: item.BasMednFlag,
  7939. MedChrgitmType: item.MedChrgitmType,
  7940. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7941. Status: 1,
  7942. Memo: item.Memo,
  7943. Mtime: time.Now().Unix(),
  7944. InscpScpAmt: item.InscpScpAmt,
  7945. DrtReimFlag: item.DrtReimFlag,
  7946. Ctime: time.Now().Unix(),
  7947. ListSpItemFlag: item.ListSpItemFlag,
  7948. ChldMedcFlag: item.ChldMedcFlag,
  7949. LmtUsedFlag: item.LmtUsedFlag,
  7950. ChrgitmLv: item.ChrgitmLv,
  7951. UserOrgId: adminUser.CurrentOrgId,
  7952. HisPatientId: his.ID,
  7953. OrderId: order.ID,
  7954. ProjectId: project_id,
  7955. Type: types,
  7956. }
  7957. service.CreateOrderInfo(info)
  7958. }
  7959. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7960. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7961. var total float64
  7962. for _, item := range prescriptions {
  7963. if item.Type == 1 { //药品
  7964. for _, subItem := range item.HisDoctorAdviceInfo {
  7965. total = total + (subItem.Price * subItem.PrescribingNumber)
  7966. }
  7967. }
  7968. if item.Type == 2 { //项目
  7969. for _, subItem := range item.HisPrescriptionProject {
  7970. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7971. total = total + (subItem.Price * cnt)
  7972. }
  7973. }
  7974. }
  7975. for _, item := range prescriptions {
  7976. for _, subItem := range item.HisAdditionalCharge {
  7977. total = total + (subItem.Price * float64(subItem.Count))
  7978. }
  7979. }
  7980. allTotal := fmt.Sprintf("%.4f", total)
  7981. if res.Infcode == 0 {
  7982. var rf []*ResultFive
  7983. json.Unmarshal([]byte(his.Iinfo), &rf)
  7984. chrg_bchno := chrg_bchno
  7985. cert_no := his.Certno
  7986. var insutypes []string
  7987. var insutype string
  7988. var is390 int = 0
  7989. var is310 int = 0
  7990. for _, item := range rf {
  7991. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7992. insutypes = append(insutypes, item.Insutype)
  7993. }
  7994. }
  7995. if len(insutypes) == 1 {
  7996. insutype = insutypes[0]
  7997. } else {
  7998. for _, i := range insutypes {
  7999. if i == "390" {
  8000. is390 = 1
  8001. }
  8002. if i == "310" {
  8003. is310 = 1
  8004. }
  8005. }
  8006. }
  8007. if is390 == 1 {
  8008. insutype = "390"
  8009. }
  8010. if is310 == 1 {
  8011. insutype = "310"
  8012. }
  8013. if len(insutypes) == 0 {
  8014. insutype = "310"
  8015. }
  8016. if len(insutypes) == 2 {
  8017. insutype = strconv.FormatInt(his.SocialType, 64)
  8018. }
  8019. //insutype = "390"
  8020. if his.IdCardType == 1 {
  8021. cert_no = his.MedicalInsuranceNumber
  8022. } else {
  8023. cert_no = his.Certno
  8024. }
  8025. var res ResultSeven
  8026. var resSeven10265 ResultSeven10265
  8027. if miConfig.MdtrtareaAdmvs == "421300" {
  8028. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8029. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8030. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8031. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8032. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8033. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8034. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  8035. resp, requestErr := http.Get(api)
  8036. if requestErr != nil {
  8037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8038. return
  8039. }
  8040. body, ioErr := ioutil.ReadAll(resp.Body)
  8041. if ioErr != nil {
  8042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8044. return
  8045. }
  8046. var respJSON map[string]interface{}
  8047. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8050. return
  8051. }
  8052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8053. result, _ := json.Marshal(respJSON)
  8054. fmt.Println("log")
  8055. fmt.Println(string(result))
  8056. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8057. utils.ErrorLog("解析失败:%v", err)
  8058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8059. return
  8060. }
  8061. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8062. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  8063. if result3101.Infcode == "0" {
  8064. if len(result3101.Output.Result) > 0 {
  8065. var errMsgs []string
  8066. for _, item := range result3101.Output.Result {
  8067. errMsgs = append(errMsgs, item.VolaCont)
  8068. }
  8069. c.ServeSuccessJSON(map[string]interface{}{
  8070. "failed_code": -10,
  8071. "msg": errMsgs,
  8072. })
  8073. return
  8074. } else {
  8075. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8076. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8077. bas := strings.Split(psn_info.CardInfo, "|")
  8078. if his.IdCardType == 1 {
  8079. cert_no = bas[2]
  8080. } else {
  8081. cert_no = bas[1]
  8082. }
  8083. //江苏地区国家医保医疗类别
  8084. //职工透析:医疗类别选特殊情况门诊9933
  8085. //居民血透门慢: 医疗类别选门诊慢病1402
  8086. //var med_type string
  8087. //if his.Insutype == "310" {
  8088. // if reg_type == 14 {
  8089. // med_type = "9933"
  8090. // } else if reg_type == 11 {
  8091. // med_type = "11"
  8092. //
  8093. // }
  8094. //} else if his.Insutype == "390" {
  8095. // if reg_type == 14 {
  8096. // med_type = "1402"
  8097. // } else if reg_type == 11 {
  8098. // med_type = "11"
  8099. // }
  8100. //}
  8101. var api string
  8102. if miConfig.MdtrtareaAdmvs == "320921" {
  8103. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8104. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8105. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8106. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8107. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8108. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8109. "&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
  8110. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8111. } else {
  8112. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8113. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8114. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8115. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8116. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8117. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8118. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8119. "&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
  8120. }
  8121. resp, requestErr := http.Get(api)
  8122. if requestErr != nil {
  8123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8124. return
  8125. }
  8126. body, ioErr := ioutil.ReadAll(resp.Body)
  8127. if ioErr != nil {
  8128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8130. return
  8131. }
  8132. var respJSON map[string]interface{}
  8133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8136. return
  8137. }
  8138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8139. result, _ := json.Marshal(respJSON)
  8140. fmt.Println("log")
  8141. fmt.Println(string(result))
  8142. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8143. utils.ErrorLog("解析失败:%v", err)
  8144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8145. return
  8146. }
  8147. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8148. res.Output = resSeven10265.Output
  8149. res.ErrMsg = resSeven10265.ErrMsg
  8150. res.Cainfo = resSeven10265.Cainfo
  8151. res.WarnMsg = resSeven10265.WarnMsg
  8152. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8153. res.Infcode = infocode
  8154. }
  8155. }
  8156. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8157. 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)
  8158. var dat map[string]interface{}
  8159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8160. fmt.Println(dat)
  8161. } else {
  8162. fmt.Println(err)
  8163. }
  8164. saveLog(result, request_log, "2206", "预结算")
  8165. userJSONBytes, _ := json.Marshal(dat)
  8166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8167. utils.ErrorLog("解析失败:%v", err)
  8168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8169. return
  8170. }
  8171. } else {
  8172. var result string
  8173. var request_log string
  8174. if miConfig.Code == "H15049901371" {
  8175. //赤峰地区国家医保医疗类别
  8176. //职工透析:医疗类别选特殊情况门诊990502
  8177. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8178. var med_type string
  8179. if his.Insutype == "390" {
  8180. if reg_type == 14 {
  8181. med_type = "9933"
  8182. } else if reg_type == 11 {
  8183. med_type = "11"
  8184. }
  8185. } else if his.Insutype == "310" {
  8186. if reg_type == 14 {
  8187. med_type = "990502"
  8188. } else if reg_type == 11 {
  8189. med_type = "11"
  8190. }
  8191. }
  8192. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  8193. } else {
  8194. 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)
  8195. }
  8196. var dat map[string]interface{}
  8197. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8198. fmt.Println(dat)
  8199. } else {
  8200. fmt.Println(err)
  8201. }
  8202. saveLog(result, request_log, "2206", "预结算")
  8203. //userJSONBytes, _ := json.Marshal(dat)
  8204. //
  8205. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8206. // utils.ErrorLog("解析失败:%v", err)
  8207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. // return
  8209. //}
  8210. userJSONBytes, _ := json.Marshal(dat)
  8211. if miConfig.Code == "H15049901371" {
  8212. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8213. utils.ErrorLog("解析失败:%v", err)
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8218. res.Output = resSeven10265.Output
  8219. res.ErrMsg = resSeven10265.ErrMsg
  8220. res.Cainfo = resSeven10265.Cainfo
  8221. res.WarnMsg = resSeven10265.WarnMsg
  8222. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8223. res.Infcode = infocode
  8224. } else {
  8225. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8226. utils.ErrorLog("解析失败:%v", err)
  8227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8228. return
  8229. }
  8230. }
  8231. }
  8232. if res.Infcode != 0 {
  8233. errlog := &models.HisOrderError{
  8234. UserOrgId: adminUser.CurrentOrgId,
  8235. Ctime: time.Now().Unix(),
  8236. Mtime: time.Now().Unix(),
  8237. Number: chrg_bchno,
  8238. ErrMsg: res.ErrMsg,
  8239. Status: 1,
  8240. PatientId: id,
  8241. RecordTime: recordDateTime,
  8242. Stage: 20,
  8243. }
  8244. service.CreateErrMsgLog(errlog)
  8245. c.ServeSuccessJSON(map[string]interface{}{
  8246. "failed_code": -10,
  8247. "msg": res.ErrMsg,
  8248. })
  8249. return
  8250. } else {
  8251. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8252. order.OrderStatus = 1
  8253. order.IsPre = 1
  8254. order.Status = 1
  8255. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8256. order.SetlId = res.Output.Setlinfo.SetlID
  8257. order.PsnNo = res.Output.Setlinfo.PsnNo
  8258. order.PsnName = res.Output.Setlinfo.PsnName
  8259. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8260. order.Certno = res.Output.Setlinfo.Certno
  8261. order.Gend = res.Output.Setlinfo.Gend
  8262. order.Naty = res.Output.Setlinfo.Naty
  8263. order.Age = res.Output.Setlinfo.Age
  8264. order.Insutype = res.Output.Setlinfo.Insutype
  8265. order.PsnType = res.Output.Setlinfo.PsnType
  8266. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8267. order.SetlTime = res.Output.Setlinfo.SetlTime
  8268. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8269. if res.Output.Setlinfo.MedType == "140101" {
  8270. order.MedType = "14"
  8271. } else {
  8272. order.MedType = res.Output.Setlinfo.MedType
  8273. }
  8274. if reg_type == 1112 {
  8275. order.MedType = "1112"
  8276. }
  8277. if reg_type == 1111 {
  8278. order.MedType = "1111"
  8279. }
  8280. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8281. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8282. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8283. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8284. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8285. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8286. order.HifpPay = res.Output.Setlinfo.HifpPay
  8287. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8288. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8289. order.HifesPay = res.Output.Setlinfo.HifesPay
  8290. order.HifobPay = res.Output.Setlinfo.HifobPay
  8291. order.MafPay = res.Output.Setlinfo.MafPay
  8292. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8293. order.OthPay = res.Output.Setlinfo.OthPay
  8294. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8295. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8296. order.AcctPay = res.Output.Setlinfo.AcctPay
  8297. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8298. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8299. order.Balc = res.Output.Setlinfo.Balc
  8300. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8301. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8302. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8303. order.ClrWay = res.Output.Setlinfo.ClrWay
  8304. order.Creator = order.Creator
  8305. order.Modify = roles.AdminUserId
  8306. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8307. detailStr := string(setlDetail)
  8308. order.SetlDetail = detailStr
  8309. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8310. err = service.UpDateOrder(order)
  8311. if err == nil {
  8312. c.ServeSuccessJSON(map[string]interface{}{
  8313. "msg": "预结算成功",
  8314. })
  8315. } else {
  8316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8317. return
  8318. }
  8319. }
  8320. } else {
  8321. adminUser := c.GetAdminUserInfo()
  8322. errlog := &models.HisOrderError{
  8323. UserOrgId: adminUser.CurrentOrgId,
  8324. Ctime: time.Now().Unix(),
  8325. Mtime: time.Now().Unix(),
  8326. ErrMsg: res.ErrMsg,
  8327. Status: 1,
  8328. PatientId: id,
  8329. RecordTime: recordDateTime,
  8330. Stage: 4,
  8331. }
  8332. service.CreateErrMsgLog(errlog)
  8333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8334. return
  8335. }
  8336. } else {
  8337. adminUser := c.GetAdminUserInfo()
  8338. errlog := &models.HisOrderError{
  8339. UserOrgId: adminUser.CurrentOrgId,
  8340. Ctime: time.Now().Unix(),
  8341. Mtime: time.Now().Unix(),
  8342. ErrMsg: res.ErrMsg,
  8343. Status: 1,
  8344. PatientId: id,
  8345. RecordTime: recordDateTime,
  8346. Stage: 4,
  8347. }
  8348. service.CreateErrMsgLog(errlog)
  8349. c.ServeSuccessJSON(map[string]interface{}{
  8350. "failed_code": -10,
  8351. "msg": res.ErrMsg,
  8352. })
  8353. return
  8354. }
  8355. }
  8356. }
  8357. }
  8358. //退款
  8359. func (c *HisApiController) Refund() {
  8360. order_id, _ := c.GetInt64("order_id")
  8361. admin_user_id, _ := c.GetInt64("admin_user_id")
  8362. adminUser := c.GetAdminUserInfo()
  8363. var order models.HisOrder
  8364. order, _ = service.GetHisOrderByID(order_id)
  8365. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8366. if order.ID == 0 {
  8367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8368. return
  8369. }
  8370. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8371. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8372. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8373. if config.IsOpen == 1 { //对接了医保,走医保流程
  8374. var res ResultSixteen
  8375. var resSixteen10265 ResultSixteen10265
  8376. var src_resquest string
  8377. var result string
  8378. if miConfig.MdtrtareaAdmvs == "421300" {
  8379. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8380. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8381. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8382. resp3, requestErr3 := http.Get(api3)
  8383. if requestErr3 != nil {
  8384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8385. return
  8386. }
  8387. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8388. if ioErr3 != nil {
  8389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8391. return
  8392. }
  8393. var respJSON3 map[string]interface{}
  8394. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8397. return
  8398. }
  8399. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8400. userJSONBytes3, _ := json.Marshal(respJSON3)
  8401. fmt.Println("log")
  8402. fmt.Println(string(userJSONBytes3))
  8403. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8404. utils.ErrorLog("解析失败:%v", err)
  8405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8406. return
  8407. }
  8408. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8409. var api3 string
  8410. if miConfig.MdtrtareaAdmvs == "320921" {
  8411. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8412. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8413. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8414. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8415. } else {
  8416. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8417. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8418. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8419. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8420. }
  8421. resp3, requestErr3 := http.Get(api3)
  8422. if requestErr3 != nil {
  8423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8424. return
  8425. }
  8426. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8427. if ioErr3 != nil {
  8428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8430. return
  8431. }
  8432. var respJSON3 map[string]interface{}
  8433. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8436. return
  8437. }
  8438. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8439. userJSONBytes3, _ := json.Marshal(respJSON3)
  8440. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8441. utils.ErrorLog("解析失败:%v", err)
  8442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8443. return
  8444. }
  8445. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8446. res.Output = resSixteen10265.Output
  8447. res.ErrMsg = resSixteen10265.ErrMsg
  8448. res.Cainfo = resSixteen10265.Cainfo
  8449. res.WarnMsg = resSixteen10265.WarnMsg
  8450. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8451. res.Infcode = infocode
  8452. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8453. 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)
  8454. var dat map[string]interface{}
  8455. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8456. fmt.Println(dat)
  8457. } else {
  8458. fmt.Println(err)
  8459. }
  8460. saveLog(result, src_resquest, "2208", "退费")
  8461. userJSONBytes, _ := json.Marshal(dat)
  8462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8463. utils.ErrorLog("解析失败:%v", err)
  8464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8465. return
  8466. }
  8467. } else {
  8468. if miConfig.Code == "H15049901371" {
  8469. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8470. var dat map[string]interface{}
  8471. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8472. fmt.Println(dat)
  8473. } else {
  8474. fmt.Println(err)
  8475. }
  8476. saveLog(result, src_resquest, "2208", "退费")
  8477. userJSONBytes, _ := json.Marshal(dat)
  8478. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8479. utils.ErrorLog("解析失败:%v", err)
  8480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8481. return
  8482. }
  8483. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8484. res.Output = resSixteen10265.Output
  8485. res.ErrMsg = resSixteen10265.ErrMsg
  8486. res.Cainfo = resSixteen10265.Cainfo
  8487. res.WarnMsg = resSixteen10265.WarnMsg
  8488. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8489. res.Infcode = infocode
  8490. } else {
  8491. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8492. var dat map[string]interface{}
  8493. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8494. fmt.Println(dat)
  8495. } else {
  8496. fmt.Println(err)
  8497. }
  8498. saveLog(result, src_resquest, "2208", "退费")
  8499. userJSONBytes, _ := json.Marshal(dat)
  8500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8501. utils.ErrorLog("解析失败:%v", err)
  8502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8503. return
  8504. }
  8505. }
  8506. }
  8507. if res.Infcode == 0 {
  8508. var res2 ResultSix
  8509. var resSix10265 ResultSix10265
  8510. if miConfig.MdtrtareaAdmvs == "421300" {
  8511. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8512. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8514. resp3, requestErr3 := http.Get(api3)
  8515. if requestErr3 != nil {
  8516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8517. return
  8518. }
  8519. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8520. if ioErr3 != nil {
  8521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8523. return
  8524. }
  8525. var respJSON3 map[string]interface{}
  8526. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8529. return
  8530. }
  8531. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8532. userJSONBytes3, _ := json.Marshal(respJSON3)
  8533. fmt.Println("log")
  8534. fmt.Println(string(userJSONBytes3))
  8535. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8536. utils.ErrorLog("解析失败:%v", err)
  8537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8538. return
  8539. }
  8540. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8541. var api3 string
  8542. if miConfig.MdtrtareaAdmvs == "320921" {
  8543. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8544. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8545. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8546. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8547. } else {
  8548. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8549. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8550. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8551. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8552. }
  8553. resp3, requestErr3 := http.Get(api3)
  8554. if requestErr3 != nil {
  8555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8556. return
  8557. }
  8558. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8559. if ioErr3 != nil {
  8560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8562. return
  8563. }
  8564. var respJSON3 map[string]interface{}
  8565. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8568. return
  8569. }
  8570. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8571. userJSONBytes3, _ := json.Marshal(respJSON3)
  8572. fmt.Println("log")
  8573. fmt.Println(string(userJSONBytes3))
  8574. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8575. utils.ErrorLog("解析失败:%v", err)
  8576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8577. return
  8578. }
  8579. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8580. res2.Output = resSix10265.Output
  8581. res2.ErrMsg = resSix10265.ErrMsg
  8582. res2.Cainfo = resSix10265.Cainfo
  8583. res2.WarnMsg = resSix10265.WarnMsg
  8584. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8585. res2.Infcode = infocode
  8586. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8587. 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)
  8588. var dat map[string]interface{}
  8589. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8590. fmt.Println(dat)
  8591. } else {
  8592. fmt.Println(err)
  8593. }
  8594. saveLog(result2, src_request, "2205", "撤销明细")
  8595. userJSONBytes, _ := json.Marshal(dat)
  8596. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8597. utils.ErrorLog("解析失败:%v", err)
  8598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8599. return
  8600. }
  8601. } else {
  8602. if miConfig.Code == "H15049901371" {
  8603. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8604. var dat map[string]interface{}
  8605. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8606. fmt.Println(dat)
  8607. } else {
  8608. fmt.Println(err)
  8609. }
  8610. saveLog(result2, src_request, "2205", "撤销明细")
  8611. userJSONBytes, _ := json.Marshal(dat)
  8612. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8613. utils.ErrorLog("解析失败:%v", err)
  8614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8615. return
  8616. }
  8617. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8618. res2.Output = resSix10265.Output
  8619. res2.ErrMsg = resSix10265.ErrMsg
  8620. res2.Cainfo = resSix10265.Cainfo
  8621. res2.WarnMsg = resSix10265.WarnMsg
  8622. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8623. res2.Infcode = infocode
  8624. } else {
  8625. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8626. var dat map[string]interface{}
  8627. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8628. fmt.Println(dat)
  8629. } else {
  8630. fmt.Println(err)
  8631. }
  8632. saveLog(result2, src_request, "2205", "撤销明细")
  8633. userJSONBytes, _ := json.Marshal(dat)
  8634. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8635. utils.ErrorLog("解析失败:%v", err)
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8637. return
  8638. }
  8639. }
  8640. }
  8641. if res2.Infcode == 0 {
  8642. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8643. if err == nil {
  8644. //当押金不为零时产生退费记录
  8645. if order.Decimal != 0 {
  8646. tmp := strconv.FormatInt(order.ID, 10)
  8647. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8648. if err != nil {
  8649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8650. return
  8651. }
  8652. }
  8653. c.ServeSuccessJSON(map[string]interface{}{
  8654. "msg": "退费成功",
  8655. })
  8656. } else {
  8657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8658. return
  8659. }
  8660. } else {
  8661. c.ServeSuccessJSON(map[string]interface{}{
  8662. "code": -10,
  8663. "msg": res2.ErrMsg,
  8664. })
  8665. }
  8666. } else {
  8667. c.ServeSuccessJSON(map[string]interface{}{
  8668. "code": -10,
  8669. "msg": res.ErrMsg,
  8670. })
  8671. }
  8672. }
  8673. }
  8674. func (c *HisApiController) RefundNumber() {
  8675. record_time := c.GetString("record_time")
  8676. //patient_id, _ := c.GetInt64("patient_id")
  8677. admin_user_id, _ := c.GetInt64("admin_user_id")
  8678. his_patient_id, _ := c.GetInt64("id")
  8679. timeLayout := "2006-01-02"
  8680. loc, _ := time.LoadLocation("Local")
  8681. adminUser := c.GetAdminUserInfo()
  8682. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8683. fmt.Println(err)
  8684. if err != nil {
  8685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8686. return
  8687. }
  8688. recordDateTime := theTime.Unix()
  8689. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8690. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8691. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8692. //order, _ := service.GetHisOrderByID(order_id)
  8693. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8694. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8695. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8696. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8697. if count > 0 {
  8698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8699. return
  8700. }
  8701. if config.IsOpen == 1 { //对接了医保,走医保流程
  8702. var res2 ResultSix
  8703. var resSix10265 ResultSix10265
  8704. if miConfig.MdtrtareaAdmvs == "421300" {
  8705. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8706. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8707. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8708. resp3, requestErr3 := http.Get(api3)
  8709. if requestErr3 != nil {
  8710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8711. return
  8712. }
  8713. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8714. if ioErr3 != nil {
  8715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8717. return
  8718. }
  8719. var respJSON3 map[string]interface{}
  8720. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8723. return
  8724. }
  8725. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8726. userJSONBytes3, _ := json.Marshal(respJSON3)
  8727. fmt.Println("log")
  8728. fmt.Println(string(userJSONBytes3))
  8729. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8730. utils.ErrorLog("解析失败:%v", err)
  8731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8732. return
  8733. }
  8734. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8735. var api3 string
  8736. if miConfig.MdtrtareaAdmvs == "320921" {
  8737. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8738. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8739. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8740. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8741. } else {
  8742. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8743. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8744. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8745. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8746. }
  8747. resp3, requestErr3 := http.Get(api3)
  8748. if requestErr3 != nil {
  8749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8750. return
  8751. }
  8752. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8753. if ioErr3 != nil {
  8754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8756. return
  8757. }
  8758. var respJSON3 map[string]interface{}
  8759. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8762. return
  8763. }
  8764. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8765. userJSONBytes3, _ := json.Marshal(respJSON3)
  8766. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8767. utils.ErrorLog("解析失败:%v", err)
  8768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8769. return
  8770. }
  8771. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8772. res2.Output = resSix10265.Output
  8773. res2.ErrMsg = resSix10265.ErrMsg
  8774. res2.Cainfo = resSix10265.Cainfo
  8775. res2.WarnMsg = resSix10265.WarnMsg
  8776. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8777. res2.Infcode = infocode
  8778. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8779. 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)
  8780. var dat map[string]interface{}
  8781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8782. fmt.Println(dat)
  8783. } else {
  8784. fmt.Println(err)
  8785. }
  8786. saveLog(result, request, "2202", "退号")
  8787. userJSONBytes, _ := json.Marshal(dat)
  8788. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8789. utils.ErrorLog("解析失败:%v", err)
  8790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8791. return
  8792. }
  8793. } else {
  8794. var api3 string
  8795. if miConfig.Code == "H15049901371" {
  8796. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8797. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8798. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8799. } else {
  8800. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8801. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8802. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8803. }
  8804. resp3, requestErr3 := http.Get(api3)
  8805. if requestErr3 != nil {
  8806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8807. return
  8808. }
  8809. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8810. if ioErr3 != nil {
  8811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8813. return
  8814. }
  8815. var respJSON3 map[string]interface{}
  8816. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8819. return
  8820. }
  8821. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8822. userJSONBytes3, _ := json.Marshal(respJSON3)
  8823. if miConfig.Code == "H15049901371" {
  8824. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8825. utils.ErrorLog("解析失败:%v", err)
  8826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8827. return
  8828. }
  8829. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8830. res2.Output = resSix10265.Output
  8831. res2.ErrMsg = resSix10265.ErrMsg
  8832. res2.Cainfo = resSix10265.Cainfo
  8833. res2.WarnMsg = resSix10265.WarnMsg
  8834. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8835. res2.Infcode = infocode
  8836. } else {
  8837. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8838. utils.ErrorLog("解析失败:%v", err)
  8839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8840. return
  8841. }
  8842. }
  8843. }
  8844. if res2.Infcode == 0 {
  8845. if err == nil {
  8846. c.ServeSuccessJSON(map[string]interface{}{
  8847. "msg": "退号成功",
  8848. })
  8849. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8850. } else {
  8851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8852. return
  8853. }
  8854. } else {
  8855. c.ServeSuccessJSON(map[string]interface{}{
  8856. "code": -10,
  8857. "msg": res2.ErrMsg,
  8858. })
  8859. }
  8860. } else {
  8861. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8862. //if err == nil {
  8863. // c.ServeSuccessJSON(map[string]interface{}{
  8864. // "msg": "退费成功",
  8865. // })
  8866. //} else {
  8867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8868. // return
  8869. //}
  8870. }
  8871. }
  8872. func (c *HisApiController) RefundDetail() {
  8873. order_id, _ := c.GetInt64("order_id")
  8874. admin_user_id, _ := c.GetInt64("admin_user_id")
  8875. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8876. number := c.GetString("number")
  8877. record_time := c.GetString("record_time")
  8878. patient_id, _ := c.GetInt64("patient_id")
  8879. //med_type, _ := c.GetInt64("med_type")
  8880. timeLayout := "2006-01-02"
  8881. loc, _ := time.LoadLocation("Local")
  8882. adminUser := c.GetAdminUserInfo()
  8883. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8884. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8885. fmt.Println(err)
  8886. if err != nil {
  8887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8888. return
  8889. }
  8890. recordDateTime := theTime.Unix()
  8891. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8892. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8893. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8894. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8895. var order models.HisOrder
  8896. order, _ = service.GetHisOrderByID(order_id)
  8897. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8898. if config.IsOpen == 1 { //对接了医保,走医保流程
  8899. var res2 ResultSix
  8900. if miConfig.MdtrtareaAdmvs == "421300" {
  8901. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8902. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8903. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8904. resp3, requestErr3 := http.Get(api3)
  8905. if requestErr3 != nil {
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8910. if ioErr3 != nil {
  8911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. return
  8914. }
  8915. var respJSON3 map[string]interface{}
  8916. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8919. return
  8920. }
  8921. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8922. userJSONBytes3, _ := json.Marshal(respJSON3)
  8923. fmt.Println("log")
  8924. fmt.Println(string(userJSONBytes3))
  8925. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8926. utils.ErrorLog("解析失败:%v", err)
  8927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8928. return
  8929. }
  8930. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8931. if err == nil {
  8932. c.ServeSuccessJSON(map[string]interface{}{
  8933. "msg": "撤销明细成功",
  8934. })
  8935. return
  8936. } else {
  8937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8938. return
  8939. }
  8940. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8941. var resSix10265 ResultSix10265
  8942. var api3 string
  8943. if miConfig.MdtrtareaAdmvs == "320921" {
  8944. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8945. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8946. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8947. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8948. } else {
  8949. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8950. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8951. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8952. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8953. }
  8954. resp3, requestErr3 := http.Get(api3)
  8955. if requestErr3 != nil {
  8956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8957. return
  8958. }
  8959. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8960. if ioErr3 != nil {
  8961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8963. return
  8964. }
  8965. var respJSON3 map[string]interface{}
  8966. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8969. return
  8970. }
  8971. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8972. userJSONBytes3, _ := json.Marshal(respJSON3)
  8973. fmt.Println("log")
  8974. fmt.Println(string(userJSONBytes3))
  8975. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8976. utils.ErrorLog("解析失败:%v", err)
  8977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8978. return
  8979. }
  8980. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8981. res2.Output = resSix10265.Output
  8982. res2.ErrMsg = resSix10265.ErrMsg
  8983. res2.Cainfo = resSix10265.Cainfo
  8984. res2.WarnMsg = resSix10265.WarnMsg
  8985. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8986. res2.Infcode = infocode
  8987. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8988. if err == nil {
  8989. c.ServeSuccessJSON(map[string]interface{}{
  8990. "msg": "撤销明细成功",
  8991. })
  8992. return
  8993. } else {
  8994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8995. return
  8996. }
  8997. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8998. 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)
  8999. var dat map[string]interface{}
  9000. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9001. fmt.Println(dat)
  9002. } else {
  9003. fmt.Println(err)
  9004. }
  9005. saveLog(result2, src_request, "2205", "撤销明细")
  9006. userJSONBytes, _ := json.Marshal(dat)
  9007. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9008. utils.ErrorLog("解析失败:%v", err)
  9009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9010. return
  9011. }
  9012. if res2.Infcode == 0 {
  9013. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9014. if err == nil {
  9015. c.ServeSuccessJSON(map[string]interface{}{
  9016. "msg": "撤销明细成功",
  9017. })
  9018. return
  9019. } else {
  9020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9021. return
  9022. }
  9023. } else {
  9024. c.ServeSuccessJSON(map[string]interface{}{
  9025. "code": -10,
  9026. "msg": res2.ErrMsg,
  9027. })
  9028. }
  9029. } else {
  9030. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  9031. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9033. resp2, requestErr2 := http.Get(api2)
  9034. if requestErr2 != nil {
  9035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9036. return
  9037. }
  9038. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9039. if ioErr2 != nil {
  9040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9042. return
  9043. }
  9044. var respJSON2 map[string]interface{}
  9045. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9048. return
  9049. }
  9050. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9051. if err == nil {
  9052. c.ServeSuccessJSON(map[string]interface{}{
  9053. "msg": "撤销明细成功",
  9054. })
  9055. return
  9056. } else {
  9057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9058. return
  9059. }
  9060. }
  9061. } else {
  9062. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9063. if err == nil {
  9064. c.ServeSuccessJSON(map[string]interface{}{
  9065. "msg": "退费成功",
  9066. })
  9067. } else {
  9068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9069. return
  9070. }
  9071. }
  9072. }
  9073. //对账
  9074. func (c *HisApiController) GetCheckAccount() {
  9075. start_time := c.GetString("start_time")
  9076. end_time := c.GetString("end_time")
  9077. insutype := c.GetString("insutype")
  9078. clr_type := c.GetString("clr_type")
  9079. clr_org := c.GetString("clr_optins")
  9080. admin_user_id, _ := c.GetInt64("admin_user_id")
  9081. adminUser := c.GetAdminUserInfo()
  9082. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9083. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9084. if len(clr_org) == 0 {
  9085. clr_org = miConfig.MdtrtareaAdmvs
  9086. }
  9087. timeLayout := "2006-01-02"
  9088. loc, _ := time.LoadLocation("Local")
  9089. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9090. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9091. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9092. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9093. fixmedins_setl_cnt := int64(len(orders))
  9094. var medfee_sumamt float64
  9095. var acct_pay float64
  9096. var fund_pay_sumamt float64
  9097. for _, item := range orders {
  9098. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9099. acct_pay = acct_pay + item.AcctPay
  9100. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9101. }
  9102. var user_name string
  9103. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9104. if role.ID == 0 {
  9105. user_name = "xxx"
  9106. } else {
  9107. user_name = role.UserName
  9108. }
  9109. var res ResultEight
  9110. var res10188 ResultEightFor10188
  9111. if config.IsOpen == 1 {
  9112. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9113. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  9114. "insutype=" + insutype +
  9115. "&clr_type=" + clr_type +
  9116. "&setl_optins=" + clr_org +
  9117. "&stmt_begndate=" + start_time +
  9118. "&stm_enddate=" + end_time +
  9119. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9120. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9121. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9122. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9123. "&fixmedins_code=" + miConfig.Code +
  9124. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9125. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9126. "&secret_key=" + miConfig.SecretKey +
  9127. "&org_name=" + miConfig.OrgName +
  9128. "&doctor=" + user_name +
  9129. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9130. fmt.Println(api)
  9131. resp, requestErr := http.Get(api)
  9132. if requestErr != nil {
  9133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9134. return
  9135. }
  9136. body, ioErr := ioutil.ReadAll(resp.Body)
  9137. fmt.Println(body)
  9138. if ioErr != nil {
  9139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9141. return
  9142. }
  9143. var respJSON map[string]interface{}
  9144. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9147. return
  9148. }
  9149. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9150. userJSONBytes, _ := json.Marshal(respJSON)
  9151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9152. utils.ErrorLog("解析失败:%v", err)
  9153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9154. return
  9155. }
  9156. res.InfRefmsgid = res10188.InfRefmsgid
  9157. res.Output = res10188.Output
  9158. res.ErrMsg = res10188.ErrMsg
  9159. res.Cainfo = res10188.Cainfo
  9160. res.WarnMsg = res10188.WarnMsg
  9161. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9162. res.Infcode = infocode
  9163. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9164. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  9165. "insutype=" + insutype +
  9166. "&clr_type=" + "21" +
  9167. "&setl_optins=" + clr_org +
  9168. "&stmt_begndate=" + start_time +
  9169. "&stm_enddate=" + end_time +
  9170. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9171. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9172. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9173. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9174. "&fixmedins_code=" + miConfig.Code +
  9175. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9176. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9177. "&secret_key=" + miConfig.SecretKey +
  9178. "&org_name=" + miConfig.OrgName +
  9179. "&doctor=" + user_name
  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), &res10188); err != nil {
  9202. utils.ErrorLog("解析失败:%v", err)
  9203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9204. return
  9205. }
  9206. res.InfRefmsgid = res10188.InfRefmsgid
  9207. res.Output = res10188.Output
  9208. res.ErrMsg = res10188.ErrMsg
  9209. res.Cainfo = res10188.Cainfo
  9210. res.WarnMsg = res10188.WarnMsg
  9211. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9212. res.Infcode = infocode
  9213. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9214. var baseParams models.BaseParams
  9215. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9216. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9217. baseParams.SecretKey = miConfig.SecretKey
  9218. baseParams.OrgName = miConfig.OrgName
  9219. baseParams.FixmedinsCode = miConfig.Code
  9220. baseParams.EncKey = miConfig.EncKey
  9221. baseParams.AppSecret = miConfig.AppSecret
  9222. baseParams.SignKey = miConfig.SignKey
  9223. baseParams.AppID = miConfig.Code
  9224. baseParams.Doctor = role.UserName
  9225. baseParams.RequestUrl = miConfig.Url
  9226. businessParams := models.BusinessParams{
  9227. Insutype: insutype,
  9228. ClrType: clr_type,
  9229. SetlOptins: clr_org,
  9230. StmtBegndate: start_time,
  9231. StmtEnddate: end_time,
  9232. MedfeeSumamt: medfee_sumamt,
  9233. FundPaySumamt: fund_pay_sumamt,
  9234. AcctPay: acct_pay,
  9235. FixmedinsSetlCnt: fixmedins_setl_cnt + int64(len(orders_two)*2),
  9236. }
  9237. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams)
  9238. fmt.Println(requestLog)
  9239. fmt.Println(result)
  9240. fmt.Println(err_msg)
  9241. } else {
  9242. if len(clr_type) == 0 {
  9243. clr_type = "11"
  9244. }
  9245. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9246. "insutype=" + insutype +
  9247. "&clr_type=" + clr_type +
  9248. "&setl_optins=" + clr_org +
  9249. "&stmt_begndate=" + start_time +
  9250. "&stm_enddate=" + end_time +
  9251. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9252. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9253. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9254. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9255. "&fixmedins_code=" + miConfig.Code +
  9256. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9257. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9258. "&secret_key=" + miConfig.SecretKey +
  9259. "&org_name=" + miConfig.OrgName +
  9260. "&doctor=" + user_name
  9261. fmt.Println(api)
  9262. resp, requestErr := http.Get(api)
  9263. if requestErr != nil {
  9264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9265. return
  9266. }
  9267. body, ioErr := ioutil.ReadAll(resp.Body)
  9268. fmt.Println(body)
  9269. if ioErr != nil {
  9270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9272. return
  9273. }
  9274. var respJSON map[string]interface{}
  9275. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9278. return
  9279. }
  9280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9281. userJSONBytes, _ := json.Marshal(respJSON)
  9282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9283. utils.ErrorLog("解析失败:%v", err)
  9284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9285. return
  9286. }
  9287. }
  9288. if res.Infcode == 0 {
  9289. if res.Output.Stmtinfo.StmtRslt == "0" {
  9290. micc := &models.MedicalInsuranceCostCompare{
  9291. StartTime: startime.Unix(),
  9292. EndTime: endtime.Unix(),
  9293. Insutype: insutype,
  9294. CheckType: 1,
  9295. Num: fixmedins_setl_cnt,
  9296. Mtime: time.Now().Unix(),
  9297. Status: 1,
  9298. UserOrgId: adminUser.CurrentOrgId,
  9299. CostTotal: medfee_sumamt,
  9300. FuncTotal: fund_pay_sumamt,
  9301. PsnPay: acct_pay,
  9302. Creator: admin_user_id,
  9303. Ctime: time.Now().Unix(),
  9304. ClrType: clr_type,
  9305. }
  9306. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  9307. if err == nil {
  9308. c.ServeSuccessJSON(map[string]interface{}{
  9309. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9310. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9311. })
  9312. } else {
  9313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9314. }
  9315. } else {
  9316. c.ServeSuccessJSON(map[string]interface{}{
  9317. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9318. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9319. })
  9320. }
  9321. } else {
  9322. c.ServeSuccessJSON(map[string]interface{}{
  9323. "code": -10,
  9324. "msg": res.ErrMsg,
  9325. })
  9326. }
  9327. }
  9328. }
  9329. func (c *HisApiController) Check310() {
  9330. adminUser := c.GetAdminUserInfo()
  9331. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9332. var user_name string
  9333. user_name = "高慧裕"
  9334. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9335. "insutype=" + "310" +
  9336. "&clr_type=" + "" +
  9337. "&setl_optins=" + "441202" +
  9338. "&stmt_begndate=" + "2022-03-01" +
  9339. "&stm_enddate=" + "2022-03-31" +
  9340. "&medfee_sumamt=" + "194930.12" +
  9341. "&fund_pay_sumamt=" + "188741.46" +
  9342. "&acct_pay=" + "0" +
  9343. "&fixmedins_setl_cnt=" + "452" +
  9344. "&fixmedins_code=" + miConfig.Code +
  9345. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9346. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9347. "&secret_key=" + miConfig.SecretKey +
  9348. "&org_name=" + miConfig.OrgName +
  9349. "&doctor=" + user_name
  9350. fmt.Println(api)
  9351. resp, requestErr := http.Get(api)
  9352. if requestErr != nil {
  9353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9354. return
  9355. }
  9356. body, ioErr := ioutil.ReadAll(resp.Body)
  9357. fmt.Println(body)
  9358. if ioErr != nil {
  9359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9361. return
  9362. }
  9363. var respJSON map[string]interface{}
  9364. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9367. return
  9368. }
  9369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9370. userJSONBytes, _ := json.Marshal(respJSON)
  9371. var res ResultEight
  9372. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9373. utils.ErrorLog("解析失败:%v", err)
  9374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9375. return
  9376. }
  9377. }
  9378. func (c *HisApiController) Check390() {
  9379. adminUser := c.GetAdminUserInfo()
  9380. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9381. var user_name string
  9382. user_name = "高慧裕"
  9383. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9384. "insutype=" + "390" +
  9385. "&clr_type=" + "" +
  9386. "&setl_optins=" + "441202" +
  9387. "&stmt_begndate=" + "2022-03-01" +
  9388. "&stm_enddate=" + "2022-03-31" +
  9389. "&medfee_sumamt=" + "1068448.89" +
  9390. "&fund_pay_sumamt=" + "1014677.62" +
  9391. "&acct_pay=" + "0" +
  9392. "&fixmedins_setl_cnt=" + "1950" +
  9393. "&fixmedins_code=" + miConfig.Code +
  9394. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9395. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9396. "&secret_key=" + miConfig.SecretKey +
  9397. "&org_name=" + miConfig.OrgName +
  9398. "&doctor=" + user_name
  9399. fmt.Println(api)
  9400. resp, requestErr := http.Get(api)
  9401. if requestErr != nil {
  9402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9403. return
  9404. }
  9405. body, ioErr := ioutil.ReadAll(resp.Body)
  9406. fmt.Println(body)
  9407. if ioErr != nil {
  9408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9410. return
  9411. }
  9412. var respJSON map[string]interface{}
  9413. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9416. return
  9417. }
  9418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9419. userJSONBytes, _ := json.Marshal(respJSON)
  9420. var res ResultEight
  9421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9422. utils.ErrorLog("解析失败:%v", err)
  9423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9424. return
  9425. }
  9426. }
  9427. //对账明细
  9428. func (c *HisApiController) GetCheckDetailAccount() {
  9429. start_time := c.GetString("start_time")
  9430. end_time := c.GetString("end_time")
  9431. admin_user_id, _ := c.GetInt64("admin_user_id")
  9432. adminUser := c.GetAdminUserInfo()
  9433. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9434. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9435. timeLayout := "2006-01-02"
  9436. loc, _ := time.LoadLocation("Local")
  9437. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9438. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9439. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9440. rand.Seed(time.Now().UnixNano())
  9441. num := rand.Intn(30000)
  9442. Mkdir(miConfig.OrgName)
  9443. file := strconv.FormatInt(int64(num), 10)
  9444. file_name := file + ".txt"
  9445. zip_name := file + ".zip"
  9446. zip_path := miConfig.OrgName + "/" + zip_name
  9447. file_path := miConfig.OrgName + "/" + file_name
  9448. decimal.DivisionPrecision = 2
  9449. var medfee_sumamt float64
  9450. var psn_cash_pay float64
  9451. var fund_pay_sumamt float64
  9452. fixmedins_setl_cnt := int64(len(orders))
  9453. for _, item := range orders {
  9454. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9455. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9456. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9457. }
  9458. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9459. defer f.Close()
  9460. if err != nil {
  9461. fmt.Println(err.Error())
  9462. } else {
  9463. for _, item := range orders {
  9464. var refd_setl_flag string
  9465. if item.OrderStatus == 2 {
  9466. refd_setl_flag = "0"
  9467. var str string
  9468. str = item.SetlId + " " +
  9469. item.MdtrtId + " " +
  9470. item.PsnNo + " " +
  9471. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9472. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9473. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9474. _, err = f.Write([]byte(str))
  9475. }
  9476. if item.OrderStatus == 3 {
  9477. var str string
  9478. str = item.SetlId + " " +
  9479. item.MdtrtId + " " +
  9480. item.PsnNo + " " +
  9481. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9482. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9483. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9484. _, err = f.Write([]byte(str))
  9485. var str2 string
  9486. str2 = item.SetlId + " " +
  9487. item.MdtrtId + " " +
  9488. item.PsnNo + " " +
  9489. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9490. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9491. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9492. _, err = f.Write([]byte(str2))
  9493. }
  9494. }
  9495. }
  9496. Zip(file_path, zip_path)
  9497. fmt.Println(ReadFile(zip_path))
  9498. fmt.Println(string(ReadFile(zip_path)))
  9499. if config.IsOpen == 1 {
  9500. var user_name string
  9501. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9502. if role.ID == 0 {
  9503. user_name = "管理员"
  9504. } else {
  9505. user_name = role.UserName
  9506. }
  9507. baseParams := models.BaseParams{
  9508. SecretKey: miConfig.SecretKey,
  9509. FixmedinsCode: miConfig.Code,
  9510. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9511. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9512. OrgName: miConfig.OrgName,
  9513. Doctor: user_name,
  9514. }
  9515. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9516. var dat map[string]interface{}
  9517. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9518. fmt.Println(dat)
  9519. } else {
  9520. fmt.Println(err)
  9521. }
  9522. userJSONBytes, _ := json.Marshal(dat)
  9523. var res ResultNine
  9524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9525. utils.ErrorLog("解析失败:%v", err)
  9526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9527. return
  9528. }
  9529. if res.Infcode == 0 {
  9530. fileNo := res.Output.FileQuryNo
  9531. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9532. "file_qury_no=" + fileNo +
  9533. "&setl_optins=" + "定点医保中心" +
  9534. "&stmt_begndate=" + start_time +
  9535. "&stm_enddate=" + end_time +
  9536. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9537. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9538. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9539. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9540. "&fixmedins_code=" + miConfig.Code +
  9541. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9542. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9543. "&secret_key=" + miConfig.SecretKey +
  9544. "&org_name=" + miConfig.OrgName +
  9545. "&doctor=" + user_name
  9546. resp, requestErr := http.Get(api)
  9547. if requestErr != nil {
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9549. return
  9550. }
  9551. body, ioErr := ioutil.ReadAll(resp.Body)
  9552. if ioErr != nil {
  9553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9555. return
  9556. }
  9557. var respJSON map[string]interface{}
  9558. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9561. return
  9562. }
  9563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9564. userJSONBytes, _ := json.Marshal(respJSON)
  9565. var res ResultTen
  9566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9567. utils.ErrorLog("解析失败:%v", err)
  9568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9569. return
  9570. }
  9571. if res.Infcode == 0 {
  9572. service.Gdyb9102(baseParams, zip_name, fileNo)
  9573. micc := &models.MedicalInsuranceCostCompare{
  9574. StartTime: startime.Unix(),
  9575. EndTime: endtime.Unix(),
  9576. Insutype: "0",
  9577. CheckType: 2,
  9578. Num: fixmedins_setl_cnt,
  9579. Mtime: time.Now().Unix(),
  9580. Status: 1,
  9581. UserOrgId: adminUser.CurrentOrgId,
  9582. CostTotal: medfee_sumamt,
  9583. FuncTotal: fund_pay_sumamt,
  9584. PsnPay: psn_cash_pay,
  9585. Creator: admin_user_id,
  9586. Ctime: time.Now().Unix(),
  9587. }
  9588. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9589. c.ServeSuccessJSON(map[string]interface{}{
  9590. "msg": "明细对账成功",
  9591. })
  9592. }
  9593. } else {
  9594. }
  9595. }
  9596. }
  9597. type CustomOrderInfo struct {
  9598. Name string
  9599. Spec string
  9600. Unit string
  9601. Count float64
  9602. Price float64
  9603. Total float64
  9604. }
  9605. func (c *HisApiController) GetSettleAccounts() {
  9606. //id, _ := c.GetInt64("id")
  9607. //record_time := c.GetString("record_time")
  9608. order_id, _ := c.GetInt64("order_id")
  9609. admin_user_id, _ := c.GetInt64("admin_user_id")
  9610. //timeLayout := "2006-01-02"
  9611. //loc, _ := time.LoadLocation("Local")
  9612. //
  9613. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9614. //if err != nil {
  9615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9616. // return
  9617. //}
  9618. //recordDateTime := theTime.Unix()
  9619. adminUser := c.GetAdminUserInfo()
  9620. order, _ := service.GetHisOrderByID(order_id)
  9621. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9622. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9623. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9624. orderInfos = append(orderInfos, orderInfos_two...)
  9625. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9626. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9627. var diagnosis_ids []string
  9628. if his.ID > 0 {
  9629. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9630. } else {
  9631. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9632. }
  9633. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9634. var dia_config []*models.HisXtDiagnoseConfig
  9635. var name string
  9636. for _, item := range diagnosis_ids {
  9637. id, _ := strconv.ParseInt(item, 10, 64)
  9638. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9639. dia_config = append(dia_config, &diagnosisConfig)
  9640. if len(name) == 0 {
  9641. name = diagnosisConfig.ClassName
  9642. } else {
  9643. name = name + "," + diagnosisConfig.ClassName
  9644. }
  9645. }
  9646. var bedCostTotal float64 = 0 //床位总费
  9647. var bedCostSelfTotal float64 = 0 //床位自费
  9648. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9649. var operationCostTotal float64 = 0 //手术费
  9650. var operationCostSelfTotal float64 = 0 //手术费
  9651. var operationCostPartSelfTotal float64 = 0 //手术费
  9652. var otherCostTotal float64 = 0 //其他费用
  9653. var otherCostSelfTotal float64 = 0 //其他费用
  9654. var otherCostPartSelfTotal float64 = 0 //其他费用
  9655. var materialCostTotal float64 = 0 //材料费
  9656. var materialCostSelfTotal float64 = 0 //材料费
  9657. var materialCostPartSelfTotal float64 = 0 //材料费
  9658. var westernMedicineCostTotal float64 = 0 //西药费
  9659. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9660. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9661. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9662. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9663. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9664. var checkCostTotal float64 = 0 //检查费
  9665. var checkCostSelfTotal float64 = 0 //检查费
  9666. var checkCostPartSelfTotal float64 = 0 //检查费
  9667. var laboratoryCostTotal float64 = 0 //化验费
  9668. var laboratoryCostSelfTotal float64 = 0 //化验费
  9669. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9670. var treatCostTotal float64 = 0 //治疗费用
  9671. var treatCostSelfTotal float64 = 0 //治疗费用
  9672. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9673. decimal.DivisionPrecision = 2
  9674. for _, item := range orderInfos {
  9675. if item.MedChrgitmType == "01" { //床位费
  9676. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9677. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9678. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9679. }
  9680. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9681. if item.MedChrgitmType == "03" { //检查费
  9682. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9683. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9684. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9685. }
  9686. } else {
  9687. if item.MedChrgitmType == "03" { //检查费
  9688. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9689. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9690. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9691. }
  9692. }
  9693. if item.MedChrgitmType == "04" { //化验费
  9694. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9695. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9696. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9697. }
  9698. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9699. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9700. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9701. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9702. }
  9703. if item.MedChrgitmType == "06" { //手术费
  9704. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9705. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9706. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9707. }
  9708. if item.MedChrgitmType == "08" { //材料费
  9709. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9710. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9711. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9712. }
  9713. if item.MedChrgitmType == "09" { //西药费
  9714. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9715. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9716. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9717. }
  9718. if item.MedChrgitmType == "11" { //中成费
  9719. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9720. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9721. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9722. }
  9723. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9724. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9725. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9726. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9727. }
  9728. }
  9729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9730. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9731. var user_name string
  9732. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9733. if role.ID == 0 {
  9734. user_name = "管理员"
  9735. } else {
  9736. user_name = role.UserName
  9737. }
  9738. baseParams := models.BaseParams{
  9739. SecretKey: miConfig.SecretKey,
  9740. FixmedinsCode: miConfig.Code,
  9741. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9742. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9743. OrgName: miConfig.OrgName,
  9744. Doctor: user_name,
  9745. }
  9746. businessParams := models.BusinessParams{
  9747. PsnNo: order.PsnNo,
  9748. MdtrtId: order.MdtrtId,
  9749. SetlId: order.SetlId,
  9750. }
  9751. var res ResultEleven
  9752. var resEleven10265 ResultEleven10265
  9753. if config.IsOpen == 1 {
  9754. if miConfig.MdtrtareaAdmvs == "421300" {
  9755. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9756. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9757. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9758. resp, requestErr := http.Get(api)
  9759. if requestErr != nil {
  9760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9761. return
  9762. }
  9763. body, ioErr := ioutil.ReadAll(resp.Body)
  9764. if ioErr != nil {
  9765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9767. return
  9768. }
  9769. var respJSON map[string]interface{}
  9770. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9773. return
  9774. }
  9775. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9776. result, _ := json.Marshal(respJSON)
  9777. fmt.Println("log")
  9778. fmt.Println(string(result))
  9779. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9780. utils.ErrorLog("解析失败:%v", err)
  9781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9782. return
  9783. }
  9784. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9785. var api string
  9786. if miConfig.MdtrtareaAdmvs == "320921" {
  9787. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9788. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9789. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9790. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9791. } else {
  9792. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9793. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9794. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9795. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9796. }
  9797. resp, requestErr := http.Get(api)
  9798. if requestErr != nil {
  9799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9800. return
  9801. }
  9802. body, ioErr := ioutil.ReadAll(resp.Body)
  9803. if ioErr != nil {
  9804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9806. return
  9807. }
  9808. var respJSON map[string]interface{}
  9809. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9812. return
  9813. }
  9814. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9815. result, _ := json.Marshal(respJSON)
  9816. fmt.Println("log")
  9817. fmt.Println(string(result))
  9818. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9819. utils.ErrorLog("解析失败:%v", err)
  9820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9821. return
  9822. }
  9823. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9824. res.Output = resEleven10265.Output
  9825. res.ErrMsg = resEleven10265.ErrMsg
  9826. res.Cainfo = resEleven10265.Cainfo
  9827. res.WarnMsg = resEleven10265.WarnMsg
  9828. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9829. res.Infcode = infocode
  9830. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9831. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9832. saveLog(result, requestLog, "5203", "结算单")
  9833. var dat map[string]interface{}
  9834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9835. fmt.Println(dat)
  9836. } else {
  9837. fmt.Println(err)
  9838. }
  9839. userJSONBytes, _ := json.Marshal(dat)
  9840. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9841. utils.ErrorLog("解析失败:%v", err)
  9842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9843. return
  9844. }
  9845. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9846. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9847. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9848. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9849. resp, requestErr := http.Get(api)
  9850. if requestErr != nil {
  9851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9852. return
  9853. }
  9854. body, ioErr := ioutil.ReadAll(resp.Body)
  9855. if ioErr != nil {
  9856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9858. return
  9859. }
  9860. var respJSON map[string]interface{}
  9861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9864. return
  9865. }
  9866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9867. result, _ := json.Marshal(respJSON)
  9868. fmt.Println("log")
  9869. fmt.Println(string(result))
  9870. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9871. utils.ErrorLog("解析失败:%v", err)
  9872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9873. return
  9874. }
  9875. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9876. res.Output = resEleven10265.Output
  9877. res.ErrMsg = resEleven10265.ErrMsg
  9878. res.Cainfo = resEleven10265.Cainfo
  9879. res.WarnMsg = resEleven10265.WarnMsg
  9880. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9881. res.Infcode = infocode
  9882. } else {
  9883. result := service.Gdyb5203(baseParams, businessParams)
  9884. //service.Gdyb5204(baseParams, businessParams)
  9885. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9886. var dat map[string]interface{}
  9887. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9888. fmt.Println(dat)
  9889. } else {
  9890. fmt.Println(err)
  9891. }
  9892. userJSONBytes, _ := json.Marshal(dat)
  9893. if miConfig.Code == "H15049901371" {
  9894. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9895. utils.ErrorLog("解析失败:%v", err)
  9896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9897. return
  9898. }
  9899. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9900. res.Output = resEleven10265.Output
  9901. res.ErrMsg = resEleven10265.ErrMsg
  9902. res.Cainfo = resEleven10265.Cainfo
  9903. res.WarnMsg = resEleven10265.WarnMsg
  9904. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9905. res.Infcode = infocode
  9906. } else {
  9907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9908. utils.ErrorLog("解析失败:%v", err)
  9909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9910. return
  9911. }
  9912. }
  9913. }
  9914. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9915. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9916. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9917. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9918. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9919. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9920. var doctor_name string
  9921. if roles.ID == 0 {
  9922. doctor_name = "管理员"
  9923. } else {
  9924. doctor_name = roles.UserName
  9925. }
  9926. yiliao_leibie := ""
  9927. switch order.MedType {
  9928. case "11":
  9929. yiliao_leibie = "普通门诊"
  9930. break
  9931. case "12":
  9932. yiliao_leibie = "门诊挂号"
  9933. break
  9934. case "13":
  9935. yiliao_leibie = "急诊"
  9936. break
  9937. case "14":
  9938. yiliao_leibie = "门诊特殊病"
  9939. break
  9940. case "15":
  9941. yiliao_leibie = "门诊统筹"
  9942. break
  9943. case "16":
  9944. yiliao_leibie = "门诊慢性病"
  9945. break
  9946. case "21":
  9947. yiliao_leibie = "普通住院"
  9948. break
  9949. }
  9950. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9951. if res.Infcode == 0 {
  9952. c.ServeSuccessJSON(map[string]interface{}{
  9953. "diagnosis": name,
  9954. "order_infos": orderInfos,
  9955. "number": order.MdtrtId,
  9956. "date": order.SettleAccountsDate,
  9957. "charge_admin": charge_admin,
  9958. "printor_admin": printor_admin,
  9959. "info": res.Output.Setlinfo,
  9960. "order": order,
  9961. "bedCostTotal": bedCostTotal,
  9962. "bedCostSelfTotal": bedCostSelfTotal,
  9963. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9964. "operationCostTotal": operationCostTotal,
  9965. "operationCostSelfTotal": operationCostSelfTotal,
  9966. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9967. "otherCostTotal": otherCostTotal,
  9968. "otherCostSelfTotal": otherCostSelfTotal,
  9969. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9970. "materialCostTotal": materialCostTotal,
  9971. "materialCostSelfTotal": materialCostSelfTotal,
  9972. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9973. "westernMedicineCostTotal": westernMedicineCostTotal,
  9974. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9975. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9976. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9977. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9978. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9979. "checkCostTotal": checkCostTotal,
  9980. "checkCostSelfTotal": checkCostSelfTotal,
  9981. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9982. "laboratoryCostTotal": laboratoryCostTotal,
  9983. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9984. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9985. "treatCostTotal": treatCostTotal,
  9986. "treatCostSelfTotal": treatCostSelfTotal,
  9987. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9988. "doctor_info": doctor_info,
  9989. "doctor_code": adminRole_two.DoctorCode,
  9990. "doctor_name": doctor_name,
  9991. "health_card_no": order.PsnNo,
  9992. "department": departments.Name,
  9993. "yiliao_leibie": yiliao_leibie,
  9994. "after_money": order.AccountPrice,
  9995. "patient": patient,
  9996. "org_name": miConfig.OrgName,
  9997. "org_code": miConfig.Code,
  9998. "order_number": order.Number,
  9999. "his_hospital": his_hospital,
  10000. "his": his,
  10001. "dia_config": dia_config,
  10002. //"check_order_info": cus_slice,
  10003. })
  10004. }
  10005. }
  10006. }
  10007. func (c *HisApiController) CheckTreatment() {
  10008. patient_id, _ := c.GetInt64("patient_id")
  10009. id_card_no := c.GetString("id_card_no")
  10010. insutype := c.GetString("insutype")
  10011. med_type := c.GetString("med_type")
  10012. admin_user_id, _ := c.GetInt64("admin_user_id")
  10013. adminUser := c.GetAdminUserInfo()
  10014. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10015. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10016. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10017. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10018. if miConfig.MdtrtareaAdmvs == "421300" {
  10019. var res ResultTwo
  10020. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  10021. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10022. "&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)
  10023. resp, requestErr := http.Get(api)
  10024. if requestErr != nil {
  10025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10026. return
  10027. }
  10028. body, ioErr := ioutil.ReadAll(resp.Body)
  10029. if ioErr != nil {
  10030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10032. return
  10033. }
  10034. var respJSON map[string]interface{}
  10035. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10038. return
  10039. }
  10040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10041. result, _ := json.Marshal(respJSON)
  10042. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10043. utils.ErrorLog("解析失败:%v", err)
  10044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10045. return
  10046. }
  10047. if res.Infcode == 0 {
  10048. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  10049. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10050. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  10051. resp, requestErr := http.Get(api)
  10052. if requestErr != nil {
  10053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10054. return
  10055. }
  10056. body, ioErr := ioutil.ReadAll(resp.Body)
  10057. if ioErr != nil {
  10058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10060. return
  10061. }
  10062. var respJSON map[string]interface{}
  10063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10066. return
  10067. }
  10068. var res Result2001
  10069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10070. result2, _ := json.Marshal(respJSON)
  10071. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10072. utils.ErrorLog("解析失败:%v", err)
  10073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10074. return
  10075. }
  10076. if res.Infcode == 0 {
  10077. c.ServeSuccessJSON(map[string]interface{}{
  10078. "msg": res.Output.Trtinfo,
  10079. })
  10080. }
  10081. } else {
  10082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10083. return
  10084. }
  10085. } else {
  10086. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10087. var dat map[string]interface{}
  10088. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10089. fmt.Println(dat)
  10090. } else {
  10091. fmt.Println(err)
  10092. }
  10093. userJSONBytes, _ := json.Marshal(dat)
  10094. var res ResultTwo
  10095. var res10265 ResultTwo10265
  10096. if miConfig.Code == "H15049901371" {
  10097. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10098. utils.ErrorLog("解析失败:%v", err)
  10099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10100. return
  10101. }
  10102. res.ErrMsg = res10265.ErrMsg
  10103. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10104. res.Infcode = infocode
  10105. res.Output = res10265.Output
  10106. res.InfRefmsgid = res10265.InfRefmsgid
  10107. } else {
  10108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10109. utils.ErrorLog("解析失败:%v", err)
  10110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10111. return
  10112. }
  10113. }
  10114. var user_name string
  10115. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  10116. if role.ID == 0 {
  10117. user_name = "xxx"
  10118. } else {
  10119. user_name = role.UserName
  10120. }
  10121. baseParams := models.BaseParams{
  10122. SecretKey: miConfig.SecretKey,
  10123. FixmedinsCode: miConfig.Code,
  10124. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10125. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10126. OrgName: miConfig.OrgName,
  10127. Doctor: user_name,
  10128. }
  10129. if config.IsOpen == 1 {
  10130. if miConfig.Code == "H15049901371" {
  10131. if med_type == "14" {
  10132. if insutype == "390" {
  10133. med_type = "9933"
  10134. } else if insutype == "310" {
  10135. med_type = "990502"
  10136. }
  10137. } else if med_type == "11" {
  10138. med_type = "11"
  10139. }
  10140. }
  10141. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  10142. var dat map[string]interface{}
  10143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10144. fmt.Println(dat)
  10145. } else {
  10146. fmt.Println(err)
  10147. }
  10148. var res Result2001
  10149. var res10265 Result2001Org10265
  10150. if miConfig.Code == "H15049901371" {
  10151. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10152. utils.ErrorLog("解析失败:%v", err)
  10153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10154. return
  10155. }
  10156. res.ErrMsg = res10265.ErrMsg
  10157. res.Output = res10265.Output
  10158. res.InfRefmsgid = res10265.InfRefmsgid
  10159. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10160. res.Infcode = infocode
  10161. } else {
  10162. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10163. utils.ErrorLog("解析失败:%v", err)
  10164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10165. return
  10166. }
  10167. }
  10168. if res.Infcode == 0 {
  10169. c.ServeSuccessJSON(map[string]interface{}{
  10170. "msg": res.Output.Trtinfo,
  10171. })
  10172. }
  10173. }
  10174. }
  10175. }
  10176. //func (c *HisApiController) PutRecord() {
  10177. // id, _ := c.GetInt64("id")
  10178. // record_time := c.GetString("record_time")
  10179. // timeLayout := "2006-01-02"
  10180. // loc, _ := time.LoadLocation("Local")
  10181. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10182. // if err != nil {
  10183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10184. // return
  10185. // }
  10186. // recordDateTime := theTime.Unix()
  10187. //
  10188. // adminInfo := c.GetAdminUserInfo()
  10189. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  10190. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10191. //
  10192. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10193. //
  10194. // fmt.Println(miConfig.SecretKey)
  10195. //
  10196. // if patient == nil {
  10197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10198. // return
  10199. // }
  10200. // if len(patient.IdCardNo) == 0 {
  10201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10202. // return
  10203. // }
  10204. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10205. // if config.IsOpen == 1 {
  10206. // 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
  10207. // resp, requestErr := http.Get(api)
  10208. // if requestErr != nil {
  10209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10210. // return
  10211. // }
  10212. // defer resp.Body.Close()
  10213. // body, ioErr := ioutil.ReadAll(resp.Body)
  10214. // if ioErr != nil {
  10215. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10217. // return
  10218. // }
  10219. // var respJSON map[string]interface{}
  10220. //
  10221. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10222. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10223. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10224. // return
  10225. // }
  10226. //
  10227. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10228. // userJSONBytes, _ := json.Marshal(userJSON)
  10229. // var res ResultTwo
  10230. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10231. // utils.ErrorLog("解析失败:%v", err)
  10232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10233. // return
  10234. // }
  10235. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10236. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10237. // infoStr := string(Iinfos)
  10238. // idetinfoStr := string(Idetinfos)
  10239. //
  10240. // if res.Infcode == 0 {
  10241. // his := models.VMHisPatient{
  10242. // Status: 1,
  10243. // Ctime: time.Now().Unix(),
  10244. // Mtime: time.Now().Unix(),
  10245. // PsnNo: res.Output.Baseinfo.PsnNo,
  10246. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10247. // Certno: res.Output.Baseinfo.Certno,
  10248. // PsnName: res.Output.Baseinfo.PsnName,
  10249. // Gend: res.Output.Baseinfo.Gend,
  10250. // Naty: res.Output.Baseinfo.Naty,
  10251. // Brdy: res.Output.Baseinfo.Brdy,
  10252. // Age: res.Output.Baseinfo.Age,
  10253. // Iinfo: infoStr,
  10254. // Idetinfo: idetinfoStr,
  10255. // PatientId: patient.ID,
  10256. // RecordDate: theTime.Unix(),
  10257. // UserOrgId: adminInfo.CurrentOrgId,
  10258. // AdminUserId: adminInfo.AdminUser.Id,
  10259. // IsReturn: 1,
  10260. // }
  10261. //
  10262. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  10263. // //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")
  10264. // //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")
  10265. //
  10266. // //var dat map[string]interface{}
  10267. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10268. // // fmt.Println(dat)
  10269. // //} else {
  10270. // // fmt.Println(err)
  10271. // //}
  10272. //
  10273. // var dat2 map[string]interface{}
  10274. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10275. // fmt.Println(dat2)
  10276. // } else {
  10277. // fmt.Println(err)
  10278. // }
  10279. //
  10280. // } else {
  10281. // adminUser := c.GetAdminUserInfo()
  10282. // errlog := &models.HisOrderError{
  10283. // UserOrgId: adminUser.CurrentOrgId,
  10284. // Ctime: time.Now().Unix(),
  10285. // Mtime: time.Now().Unix(),
  10286. // ErrMsg: res.ErrMsg,
  10287. // Status: 1,
  10288. // PatientId: id,
  10289. // RecordTime: recordDateTime,
  10290. // Stage: 1,
  10291. // }
  10292. // service.CreateErrMsgLog(errlog)
  10293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10294. // return
  10295. // }
  10296. // }
  10297. //
  10298. //}
  10299. //func (c *HisApiController) GetUploadDiag() {
  10300. // id, _ := c.GetInt64("id")
  10301. // record_time := c.GetString("record_time")
  10302. //
  10303. // diagnosis_id, _ := c.GetInt64("diagnosis")
  10304. // sick_type, _ := c.GetInt64("sick_type")
  10305. // reg_type, _ := c.GetInt64("reg_type")
  10306. //
  10307. // timeLayout := "2006-01-02"
  10308. // loc, _ := time.LoadLocation("Local")
  10309. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10310. // if err != nil {
  10311. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10312. // return
  10313. // }
  10314. //
  10315. // var patientPrescription models.HisPrescriptionInfo
  10316. // recordDateTime := theTime.Unix()
  10317. // adminInfo := c.GetAdminUserInfo()
  10318. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10319. //
  10320. // if patientPrescription.ID == 0 {
  10321. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10322. // }
  10323. //
  10324. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10325. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10326. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10327. // sickConfig, _ := service.FindSickById(sick_type)
  10328. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10329. //
  10330. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  10331. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  10332. // "&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 +
  10333. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  10334. // resp2, requestErr2 := http.Get(api2)
  10335. // if requestErr2 != nil {
  10336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10337. // return
  10338. // }
  10339. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10340. // if ioErr2 != nil {
  10341. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10343. // return
  10344. // }
  10345. // var respJSON2 map[string]interface{}
  10346. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10347. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10349. // return
  10350. // }
  10351. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10352. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10353. //
  10354. // var res2 ResultSix
  10355. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10356. // utils.ErrorLog("解析失败:%v", err)
  10357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10358. // return
  10359. // }
  10360. // if res2.Infcode != 0 {
  10361. // adminUser := c.GetAdminUserInfo()
  10362. // errlog := &models.HisOrderError{
  10363. // UserOrgId: adminUser.CurrentOrgId,
  10364. // Ctime: time.Now().Unix(),
  10365. // Mtime: time.Now().Unix(),
  10366. // ErrMsg: res2.ErrMsg,
  10367. // Status: 1,
  10368. // PatientId: id,
  10369. // RecordTime: recordDateTime,
  10370. // Stage: 3,
  10371. // }
  10372. // service.CreateErrMsgLog(errlog)
  10373. //
  10374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10375. // return
  10376. // }
  10377. //
  10378. // c.ServeSuccessJSON(map[string]interface{}{
  10379. // "msg": "上传成功",
  10380. // })
  10381. //
  10382. //}
  10383. type QueryResult struct {
  10384. ID int64
  10385. Name string
  10386. Code string
  10387. List_type_code string
  10388. }
  10389. func (c *HisApiController) GetCheckCode() {
  10390. ids_str := c.GetString("ids")
  10391. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10392. ids_arr := strings.Split(ids_str, ",")
  10393. var queryResult []QueryResult
  10394. ids := make([]int64, 0)
  10395. for _, item := range ids_arr {
  10396. id, _ := strconv.ParseInt(item, 10, 64)
  10397. ids = append(ids, id)
  10398. }
  10399. if record_type == 1 {
  10400. drugs, _ := service.GetBatchDrugList(ids)
  10401. for _, item := range drugs {
  10402. result := QueryResult{
  10403. ID: item.ID,
  10404. Name: item.DrugName,
  10405. Code: item.MedicalInsuranceNumber,
  10406. List_type_code: "101",
  10407. }
  10408. queryResult = append(queryResult, result)
  10409. }
  10410. } else if record_type == 2 {
  10411. goods, _ := service.GetBatchGoodInformationList(ids)
  10412. for _, item := range goods {
  10413. result := QueryResult{
  10414. ID: item.ID,
  10415. Name: item.GoodName,
  10416. Code: item.MedicalInsuranceNumber,
  10417. List_type_code: "301",
  10418. }
  10419. queryResult = append(queryResult, result)
  10420. }
  10421. } else if record_type == 3 {
  10422. projects, _ := service.GetBathchMyPorjecgList(ids)
  10423. for _, item := range projects {
  10424. result := QueryResult{
  10425. ID: item.ID,
  10426. Name: item.ProjectName,
  10427. Code: item.MedicalCode,
  10428. List_type_code: "201",
  10429. }
  10430. queryResult = append(queryResult, result)
  10431. }
  10432. }
  10433. admin_user_id, _ := c.GetInt64("admin_user_id")
  10434. adminUser := c.GetAdminUserInfo()
  10435. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10436. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10437. var user_name string
  10438. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10439. if role.ID == 0 {
  10440. user_name = "xxx"
  10441. } else {
  10442. user_name = role.UserName
  10443. }
  10444. baseParams := &models.BaseParams{
  10445. SecretKey: miConfig.SecretKey,
  10446. FixmedinsCode: miConfig.Code,
  10447. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10448. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10449. OrgName: miConfig.OrgName,
  10450. Doctor: user_name,
  10451. }
  10452. if config.IsOpen == 1 {
  10453. for _, item := range queryResult {
  10454. var result string
  10455. if record_type == 1 {
  10456. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10457. } else if record_type == 2 {
  10458. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10459. } else if record_type == 3 {
  10460. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10461. }
  10462. var dat map[string]interface{}
  10463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10464. fmt.Println(dat)
  10465. } else {
  10466. fmt.Println(err)
  10467. }
  10468. userJSONBytes, _ := json.Marshal(dat)
  10469. var res ResultSix
  10470. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10471. utils.ErrorLog("解析失败:%v", err)
  10472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10473. return
  10474. }
  10475. if res.Infcode == 0 {
  10476. if record_type == 1 {
  10477. service.UpdateBaseDrugById(item.ID)
  10478. } else if record_type == 2 {
  10479. service.UpdateGoodInformaitonByDetail(item.ID)
  10480. } else if record_type == 3 {
  10481. service.UpdateProjectById(item.ID)
  10482. }
  10483. c.ServeSuccessJSON(map[string]interface{}{
  10484. "failed_code": 0,
  10485. "msg": "目录对照成功",
  10486. })
  10487. } else {
  10488. c.ServeSuccessJSON(map[string]interface{}{
  10489. "failed_code": -10,
  10490. "msg": res.ErrMsg,
  10491. })
  10492. }
  10493. }
  10494. }
  10495. }
  10496. func (c *HisApiController) UnCheckCode() {
  10497. ids_str := c.GetString("ids")
  10498. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10499. admin_user_id, _ := c.GetInt64("admin_user_id")
  10500. ids_arr := strings.Split(ids_str, ",")
  10501. var queryResult []QueryResult
  10502. ids := make([]int64, 0)
  10503. for _, item := range ids_arr {
  10504. id, _ := strconv.ParseInt(item, 10, 64)
  10505. ids = append(ids, id)
  10506. }
  10507. if record_type == 1 {
  10508. drugs, _ := service.GetBatchDrugList(ids)
  10509. for _, item := range drugs {
  10510. result := QueryResult{
  10511. ID: item.ID,
  10512. Name: item.DrugName,
  10513. Code: item.MedicalInsuranceNumber,
  10514. List_type_code: "101",
  10515. }
  10516. queryResult = append(queryResult, result)
  10517. }
  10518. } else if record_type == 2 {
  10519. goods, _ := service.GetBatchGoodInformationList(ids)
  10520. for _, item := range goods {
  10521. result := QueryResult{
  10522. ID: item.ID,
  10523. Name: item.GoodName,
  10524. Code: item.MedicalInsuranceNumber,
  10525. List_type_code: "301",
  10526. }
  10527. queryResult = append(queryResult, result)
  10528. }
  10529. } else if record_type == 3 {
  10530. projects, _ := service.GetBathchMyPorjecgList(ids)
  10531. for _, item := range projects {
  10532. result := QueryResult{
  10533. ID: item.ID,
  10534. Name: item.ProjectName,
  10535. Code: item.MedicalCode,
  10536. List_type_code: "201",
  10537. }
  10538. queryResult = append(queryResult, result)
  10539. }
  10540. }
  10541. adminUser := c.GetAdminUserInfo()
  10542. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10543. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10544. var user_name string
  10545. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10546. if role.ID == 0 {
  10547. user_name = "xxx"
  10548. } else {
  10549. user_name = role.UserName
  10550. }
  10551. baseParams := &models.BaseParams{
  10552. SecretKey: miConfig.SecretKey,
  10553. FixmedinsCode: miConfig.Code,
  10554. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10555. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10556. OrgName: miConfig.OrgName,
  10557. Doctor: user_name,
  10558. }
  10559. if config.IsOpen == 1 {
  10560. for _, item := range queryResult {
  10561. var result string
  10562. if record_type == 1 {
  10563. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10564. } else if record_type == 2 {
  10565. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10566. } else if record_type == 3 {
  10567. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10568. }
  10569. var dat2 map[string]interface{}
  10570. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10571. fmt.Println(dat2)
  10572. } else {
  10573. fmt.Println(err)
  10574. }
  10575. userJSONBytes, _ := json.Marshal(dat2)
  10576. var res ResultSix
  10577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10578. utils.ErrorLog("解析失败:%v", err)
  10579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10580. return
  10581. }
  10582. if res.Infcode == 0 {
  10583. if record_type == 1 {
  10584. service.UpdateDrugByIdDetail(item.ID)
  10585. } else if record_type == 2 {
  10586. service.UpdateGoodInfoById(item.ID)
  10587. } else if record_type == 3 {
  10588. service.UpdateMyProjectById(item.ID)
  10589. }
  10590. c.ServeSuccessJSON(map[string]interface{}{
  10591. "failed_code": 0,
  10592. "msg": "撤销目录对照成功",
  10593. })
  10594. } else {
  10595. c.ServeSuccessJSON(map[string]interface{}{
  10596. "failed_code": -10,
  10597. "msg": res.ErrMsg,
  10598. })
  10599. }
  10600. }
  10601. }
  10602. }
  10603. func (c *HisApiController) GetPatientInfo() {
  10604. id_card_no := c.GetString("id_card_no")
  10605. admin_user_id, _ := c.GetInt64("admin_user_id")
  10606. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10607. if patient.ID == 0 {
  10608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10609. return
  10610. }
  10611. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10612. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10613. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10614. if config.IsOpen == 1 {
  10615. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10616. var dat map[string]interface{}
  10617. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10618. fmt.Println(dat)
  10619. } else {
  10620. fmt.Println(err)
  10621. }
  10622. userJSONBytes, _ := json.Marshal(dat)
  10623. var res ResultTwo
  10624. var res10265 ResultTwo10265
  10625. if miConfig.Code == "H15049901371" {
  10626. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10627. utils.ErrorLog("解析失败:%v", err)
  10628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10629. return
  10630. }
  10631. res.ErrMsg = res10265.ErrMsg
  10632. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10633. res.Infcode = infocode
  10634. res.Output = res10265.Output
  10635. res.InfRefmsgid = res10265.InfRefmsgid
  10636. } else {
  10637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10638. utils.ErrorLog("解析失败:%v", err)
  10639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10640. return
  10641. }
  10642. }
  10643. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10644. // utils.ErrorLog("解析失败:%v", err)
  10645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10646. // return
  10647. //}
  10648. if res.Infcode != 0 {
  10649. c.ServeSuccessJSON(map[string]interface{}{
  10650. "failed_code": -10,
  10651. "msg": res.ErrMsg,
  10652. })
  10653. } else {
  10654. c.ServeSuccessJSON(map[string]interface{}{
  10655. "failed_code": 0,
  10656. "info": res,
  10657. })
  10658. }
  10659. }
  10660. }
  10661. func (c *HisApiController) PsnPutOnRecord() {
  10662. record_type, _ := c.GetInt64("type")
  10663. patient_id, _ := c.GetInt64("patient_id")
  10664. admin_user_id, _ := c.GetInt64("admin_user_id")
  10665. start_time := c.GetString("start_time")
  10666. end_time := c.GetString("end_time")
  10667. adminUser := c.GetAdminUserInfo()
  10668. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10669. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10670. var patients []*models.Patients
  10671. if record_type == 1 { //全部备案
  10672. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10673. patients = append(patients, patient...)
  10674. } else { //单个备案
  10675. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10676. patients = append(patients, patient)
  10677. }
  10678. var user_name string
  10679. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10680. if role.ID == 0 {
  10681. user_name = "xxx"
  10682. } else {
  10683. user_name = role.UserName
  10684. }
  10685. if config.IsOpen == 1 {
  10686. for _, item := range patients {
  10687. 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
  10688. resp, requestErr := http.Get(api)
  10689. if requestErr != nil {
  10690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10691. return
  10692. }
  10693. defer resp.Body.Close()
  10694. body, ioErr := ioutil.ReadAll(resp.Body)
  10695. if ioErr != nil {
  10696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10698. return
  10699. }
  10700. var respJSON map[string]interface{}
  10701. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10704. return
  10705. }
  10706. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10707. userJSONBytes, _ := json.Marshal(userJSON)
  10708. var res ResultTwo
  10709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10710. utils.ErrorLog("解析失败:%v", err)
  10711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10712. return
  10713. }
  10714. if res.Infcode == 0 {
  10715. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10716. var dat map[string]interface{}
  10717. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10718. fmt.Println(dat)
  10719. } else {
  10720. fmt.Println(err)
  10721. }
  10722. userJSONBytes, _ := json.Marshal(dat)
  10723. var res2 ResultThirteen
  10724. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10725. utils.ErrorLog("解析失败:%v", err)
  10726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10727. return
  10728. }
  10729. if res2.Infcode == 0 {
  10730. psnResult := &models.GdybPsnRecord{
  10731. UserOrgId: adminUser.CurrentOrgId,
  10732. PatientId: item.ID,
  10733. PsnNo: res.Output.Baseinfo.PsnNo,
  10734. Ctime: time.Now().Unix(),
  10735. Mtime: time.Now().Unix(),
  10736. Status: 1,
  10737. IsCancel: 1,
  10738. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10739. }
  10740. service.CreatePsnRecord(psnResult)
  10741. } else {
  10742. c.ServeSuccessJSON(map[string]interface{}{
  10743. "failed_code": -10,
  10744. "msg": res2.ErrMsg,
  10745. })
  10746. return
  10747. }
  10748. }
  10749. }
  10750. }
  10751. }
  10752. func (c *HisApiController) PsnUnPutOnRecord() {
  10753. id, _ := c.GetInt64("id")
  10754. //record_type, _ := c.GetInt64("type")
  10755. admin_user_id, _ := c.GetInt64("admin_user_id")
  10756. adminUser := c.GetAdminUserInfo()
  10757. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10758. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10759. var user_name string
  10760. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10761. if role.ID == 0 {
  10762. user_name = "xxx"
  10763. } else {
  10764. user_name = role.UserName
  10765. }
  10766. psn_record, _ := service.GetPsnRecordById(id)
  10767. if psn_record.ID == 0 {
  10768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10769. return
  10770. }
  10771. if config.IsOpen == 1 {
  10772. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10773. var dat map[string]interface{}
  10774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10775. fmt.Println(dat)
  10776. } else {
  10777. fmt.Println(err)
  10778. }
  10779. userJSONBytes, _ := json.Marshal(dat)
  10780. var res ResultFourteen
  10781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10782. utils.ErrorLog("解析失败:%v", err)
  10783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10784. return
  10785. }
  10786. if res.Infcode == 0 {
  10787. psn_record.IsCancel = 2
  10788. service.CreatePsnRecord(&psn_record)
  10789. } else {
  10790. c.ServeSuccessJSON(map[string]interface{}{
  10791. "failed_code": -10,
  10792. "msg": res.ErrMsg,
  10793. })
  10794. return
  10795. }
  10796. }
  10797. }
  10798. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10799. patient_id, _ := c.GetInt64("patient_id")
  10800. insutype_two := c.GetString("insutype")
  10801. psn_no := c.GetString("psn_no")
  10802. doctor_id, _ := c.GetInt64("doctor_id")
  10803. sick_id, _ := c.GetInt64("sick_id")
  10804. department_id, _ := c.GetInt64("department_id")
  10805. start_time := c.GetString("start_time")
  10806. end_time := c.GetString("end_time")
  10807. check_time := c.GetString("check_time")
  10808. adminUser := c.GetAdminUserInfo()
  10809. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10810. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10811. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10812. sick, _ := service.FindSickById(sick_id)
  10813. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10814. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10815. var res ResultTwo
  10816. var res10265 ResultTwo10265
  10817. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10818. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10819. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10820. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10821. "&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
  10822. resp, requestErr := http.Get(api)
  10823. if requestErr != nil {
  10824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10825. return
  10826. }
  10827. body, ioErr := ioutil.ReadAll(resp.Body)
  10828. if ioErr != nil {
  10829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10831. return
  10832. }
  10833. var respJSON map[string]interface{}
  10834. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10837. return
  10838. }
  10839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10840. result, _ := json.Marshal(respJSON)
  10841. fmt.Println("log")
  10842. fmt.Println(string(result))
  10843. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10844. utils.ErrorLog("解析失败:%v", err)
  10845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10846. return
  10847. }
  10848. res.ErrMsg = res10265.ErrMsg
  10849. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10850. res.Infcode = infocode
  10851. res.Output = res10265.Output
  10852. res.InfRefmsgid = res10265.InfRefmsgid
  10853. } else {
  10854. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10855. if miConfig.Code == "H15049901371" {
  10856. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10857. utils.ErrorLog("解析失败:%v", err)
  10858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10859. return
  10860. }
  10861. res.ErrMsg = res10265.ErrMsg
  10862. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10863. res.Infcode = infocode
  10864. res.Output = res10265.Output
  10865. res.InfRefmsgid = res10265.InfRefmsgid
  10866. } else {
  10867. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10868. utils.ErrorLog("解析失败:%v", err)
  10869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10870. return
  10871. }
  10872. }
  10873. }
  10874. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10875. infoStr := string(Iinfos)
  10876. var rf []*ResultFive
  10877. json.Unmarshal([]byte(infoStr), &rf)
  10878. var insuplc_admdvs string
  10879. var insutype string
  10880. var is390 int = 0
  10881. var is310 int = 0
  10882. var insutypes []*ResultFive
  10883. for _, item := range rf {
  10884. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10885. insutypes = append(insutypes, item)
  10886. }
  10887. }
  10888. if len(insutypes) == 1 {
  10889. insutype = insutypes[0].Insutype
  10890. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10891. } else {
  10892. for _, i := range insutypes {
  10893. if i.Insutype == "390" {
  10894. is390 = 1
  10895. }
  10896. if i.Insutype == "310" {
  10897. is310 = 1
  10898. }
  10899. }
  10900. }
  10901. if is390 == 1 {
  10902. insutype = "390"
  10903. }
  10904. if is310 == 1 {
  10905. insutype = "310"
  10906. }
  10907. if len(insutypes) == 2 {
  10908. insutype = insutype_two
  10909. }
  10910. if len(insutypes) == 0 {
  10911. insutype = "310"
  10912. }
  10913. insutype = insutype_two
  10914. fmt.Println(insutype)
  10915. for _, item := range rf {
  10916. fmt.Println(item.Insutype)
  10917. fmt.Println(insutype)
  10918. if item.Insutype == insutype {
  10919. fmt.Println(item.Insutype)
  10920. fmt.Println(insutype)
  10921. insuplc_admdvs = item.InsuplcAdmdvs
  10922. }
  10923. }
  10924. fmt.Println(insuplc_admdvs)
  10925. var res2 ResultThirteen
  10926. var res10265_2 ResultThirteen10265
  10927. if config.IsOpen == 1 {
  10928. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10929. } else {
  10930. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  10931. var dat map[string]interface{}
  10932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10933. fmt.Println(dat)
  10934. } else {
  10935. fmt.Println(err)
  10936. }
  10937. userJSONBytes, _ := json.Marshal(dat)
  10938. if miConfig.Code == "H15049901371" {
  10939. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10940. utils.ErrorLog("解析失败:%v", err)
  10941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10942. return
  10943. }
  10944. res2.ErrMsg = res10265_2.ErrMsg
  10945. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10946. res2.Infcode = infocode
  10947. res2.Output = res10265_2.Output
  10948. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10949. } else {
  10950. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10951. utils.ErrorLog("解析失败:%v", err)
  10952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10953. return
  10954. }
  10955. }
  10956. }
  10957. if res2.Infcode == 0 {
  10958. psnResult := &models.GdybPsnNcdsRecord{
  10959. UserOrgId: adminUser.CurrentOrgId,
  10960. PatientId: patient.ID,
  10961. PsnNo: psn_no,
  10962. DoctorId: doctor.AdminUserId,
  10963. DepartmentId: department_id,
  10964. SickType: sick_id,
  10965. Insutype: insutype,
  10966. Ctime: time.Now().Unix(),
  10967. Mtime: time.Now().Unix(),
  10968. Status: 1,
  10969. IsCancel: 1,
  10970. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10971. }
  10972. service.CreatePsnNCDSRecord(psnResult)
  10973. c.ServeSuccessJSON(map[string]interface{}{
  10974. "failed_code": 0,
  10975. "msg": "备案成功",
  10976. "result": psnResult,
  10977. })
  10978. } else {
  10979. c.ServeSuccessJSON(map[string]interface{}{
  10980. "failed_code": -10,
  10981. "msg": res2.ErrMsg,
  10982. })
  10983. return
  10984. }
  10985. }
  10986. }
  10987. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10988. id, _ := c.GetInt64("id")
  10989. admin_user_id, _ := c.GetInt64("admin_user_id")
  10990. adminUser := c.GetAdminUserInfo()
  10991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10992. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10993. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10994. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10995. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10996. //var user_name string
  10997. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10998. //if role.ID == 0 {
  10999. // user_name = "xxx"
  11000. //} else {
  11001. // user_name = role.UserName
  11002. //}
  11003. psn_record, _ := service.GetPsnNCDSRecordById(id)
  11004. if psn_record.ID == 0 {
  11005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11006. return
  11007. }
  11008. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  11009. var res ResultTwo
  11010. var res10265 ResultTwo10265
  11011. if miConfig.Code == "H15049901371" {
  11012. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11013. utils.ErrorLog("解析失败:%v", err)
  11014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11015. return
  11016. }
  11017. res.ErrMsg = res10265.ErrMsg
  11018. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11019. res.Infcode = infocode
  11020. res.Output = res10265.Output
  11021. res.InfRefmsgid = res10265.InfRefmsgid
  11022. } else {
  11023. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11024. utils.ErrorLog("解析失败:%v", err)
  11025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11026. return
  11027. }
  11028. }
  11029. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11030. infoStr := string(Iinfos)
  11031. var rf []*ResultFive
  11032. json.Unmarshal([]byte(infoStr), &rf)
  11033. var insuplc_admdvs string
  11034. var insutype string
  11035. var is390 int = 0
  11036. var is310 int = 0
  11037. var insutypes []*ResultFive
  11038. for _, item := range rf {
  11039. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11040. insutypes = append(insutypes, item)
  11041. }
  11042. }
  11043. if len(insutypes) == 1 {
  11044. insutype = insutypes[0].Insutype
  11045. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11046. } else {
  11047. for _, i := range insutypes {
  11048. if i.Insutype == "390" {
  11049. is390 = 1
  11050. }
  11051. if i.Insutype == "310" {
  11052. is310 = 1
  11053. }
  11054. }
  11055. }
  11056. if is390 == 1 {
  11057. insutype = "390"
  11058. }
  11059. if is310 == 1 {
  11060. insutype = "310"
  11061. }
  11062. if len(insutypes) == 0 {
  11063. insutype = "310"
  11064. }
  11065. insutype = psn_record.Insutype
  11066. for _, item := range rf {
  11067. if item.Insutype == insutype {
  11068. insuplc_admdvs = item.InsuplcAdmdvs
  11069. }
  11070. }
  11071. if config.IsOpen == 1 {
  11072. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  11073. var dat map[string]interface{}
  11074. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11075. fmt.Println(dat)
  11076. } else {
  11077. fmt.Println(err)
  11078. }
  11079. userJSONBytes, _ := json.Marshal(dat)
  11080. var res ResultFourteen
  11081. var res10265 ResultFourteen10265
  11082. if miConfig.Code == "H15049901371" {
  11083. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11084. utils.ErrorLog("解析失败:%v", err)
  11085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11086. return
  11087. }
  11088. res.ErrMsg = res10265.ErrMsg
  11089. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11090. res.Infcode = infocode
  11091. res.Output = res10265.Output
  11092. res.InfRefmsgid = res10265.InfRefmsgid
  11093. } else {
  11094. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11095. utils.ErrorLog("解析失败:%v", err)
  11096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11097. return
  11098. }
  11099. }
  11100. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11101. // utils.ErrorLog("解析失败:%v", err)
  11102. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11103. // return
  11104. //}
  11105. if res.Infcode == 0 {
  11106. psn_record.IsCancel = 2
  11107. service.CreatePsnNCDSRecord(&psn_record)
  11108. c.ServeSuccessJSON(map[string]interface{}{
  11109. "failed_code": 0,
  11110. "msg": "撤销备案成功",
  11111. })
  11112. } else {
  11113. c.ServeSuccessJSON(map[string]interface{}{
  11114. "failed_code": -10,
  11115. "msg": res.ErrMsg,
  11116. })
  11117. return
  11118. }
  11119. }
  11120. }
  11121. func (c *HisApiController) TestTest() {
  11122. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  11123. fmt.Println(patient.Iinfo)
  11124. }
  11125. type CustomData struct {
  11126. MsgId string
  11127. PsnNo string
  11128. Info string
  11129. }
  11130. func (c *HisApiController) ReversalData() {
  11131. var customData []*CustomData
  11132. custom := &CustomData{
  11133. MsgId: "H44022900158202103301714472004",
  11134. PsnNo: "44020000001101329945",
  11135. Info: "2207",
  11136. }
  11137. customData = append(customData, custom)
  11138. custom1 := &CustomData{
  11139. MsgId: "H4402290015820210330172057803",
  11140. PsnNo: "44020000001101161813",
  11141. Info: "2207",
  11142. }
  11143. customData = append(customData, custom1)
  11144. custom2 := &CustomData{
  11145. MsgId: "H44022900158202103301705198813",
  11146. PsnNo: "44190000133097375417",
  11147. Info: "2207",
  11148. }
  11149. customData = append(customData, custom2)
  11150. custom3 := &CustomData{
  11151. MsgId: "H44022900158202103301715524756",
  11152. PsnNo: "44020000001100187221",
  11153. Info: "2207",
  11154. }
  11155. customData = append(customData, custom3)
  11156. custom4 := &CustomData{
  11157. MsgId: "H44022900158202103301730376224",
  11158. PsnNo: "44020000001101959155",
  11159. Info: "2207",
  11160. }
  11161. customData = append(customData, custom4)
  11162. custom5 := &CustomData{
  11163. MsgId: "H44022900158202103301748008725",
  11164. PsnNo: "44020000001104246641",
  11165. Info: "2207",
  11166. }
  11167. customData = append(customData, custom5)
  11168. custom6 := &CustomData{
  11169. MsgId: "H44022900158202103301718096755",
  11170. PsnNo: "44020000001102211860",
  11171. Info: "2207",
  11172. }
  11173. customData = append(customData, custom6)
  11174. custom7 := &CustomData{
  11175. MsgId: "H44022900158202103301736551640",
  11176. PsnNo: "44020000001102687718",
  11177. Info: "2207",
  11178. }
  11179. customData = append(customData, custom7)
  11180. custom8 := &CustomData{
  11181. MsgId: "H44022900158202103301743097676",
  11182. PsnNo: "44020000001102127785",
  11183. Info: "2207",
  11184. }
  11185. customData = append(customData, custom8)
  11186. custom9 := &CustomData{
  11187. MsgId: "H44022900158202103301712304203",
  11188. PsnNo: "44020000001101518097",
  11189. Info: "2207",
  11190. }
  11191. customData = append(customData, custom9)
  11192. custom10 := &CustomData{
  11193. MsgId: "H44022900158202103301738448785",
  11194. PsnNo: "44020000001100500813",
  11195. Info: "2207",
  11196. }
  11197. customData = append(customData, custom10)
  11198. custom11 := &CustomData{
  11199. MsgId: "H44022900158202103301732455843",
  11200. PsnNo: "44020000001102690557",
  11201. Info: "2207",
  11202. }
  11203. customData = append(customData, custom11)
  11204. custom12 := &CustomData{
  11205. MsgId: "H44022900158202103301745421708",
  11206. PsnNo: "44020000001102211928",
  11207. Info: "2207",
  11208. }
  11209. customData = append(customData, custom12)
  11210. custom1212 := &CustomData{
  11211. MsgId: "H440229001582021033017351627",
  11212. PsnNo: "44020000001102481733",
  11213. Info: "2207",
  11214. }
  11215. customData = append(customData, custom1212)
  11216. custom13 := &CustomData{
  11217. MsgId: "H44022900158202103301740327951",
  11218. PsnNo: "44020000001103174866",
  11219. Info: "2207",
  11220. }
  11221. customData = append(customData, custom13)
  11222. custom14 := &CustomData{
  11223. MsgId: "H4402290015820210330174922668",
  11224. PsnNo: "44020000001102927272",
  11225. Info: "2207",
  11226. }
  11227. customData = append(customData, custom14)
  11228. custom15 := &CustomData{
  11229. MsgId: "H44022900158202103301752362273",
  11230. PsnNo: "44020000001102942890",
  11231. Info: "2207",
  11232. }
  11233. customData = append(customData, custom15)
  11234. custom16 := &CustomData{
  11235. MsgId: "H44022900158202103301751082917",
  11236. PsnNo: "44020000001101662162",
  11237. Info: "2207",
  11238. }
  11239. customData = append(customData, custom16)
  11240. custom17 := &CustomData{
  11241. MsgId: "H44022900158202103301754147728",
  11242. PsnNo: "44020000000229014511",
  11243. Info: "2207",
  11244. }
  11245. customData = append(customData, custom17)
  11246. adminUser := c.GetAdminUserInfo()
  11247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11248. for _, item := range customData {
  11249. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11250. fmt.Println(result)
  11251. }
  11252. }
  11253. //func (c *HisApiController) GetAllopatry() {
  11254. // year := c.GetString("year")
  11255. // month := c.GetString("month")
  11256. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11257. // adminUser := c.GetAdminUserInfo()
  11258. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11259. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11260. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11261. //
  11262. // var dat map[string]interface{}
  11263. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11264. // fmt.Println(dat)
  11265. // } else {
  11266. // fmt.Println(err)
  11267. // }
  11268. // userJSONBytes, _ := json.Marshal(dat)
  11269. // var res models.Result9001
  11270. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11271. // utils.ErrorLog("解析失败:%v", err)
  11272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11273. // return
  11274. // }
  11275. //
  11276. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11277. // var dat2 map[string]interface{}
  11278. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11279. // fmt.Println(dat)
  11280. // } else {
  11281. // fmt.Println(err)
  11282. // }
  11283. // userJSONBytes2, _ := json.Marshal(dat2)
  11284. // var res2 models.Result3260
  11285. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11286. // utils.ErrorLog("解析失败:%v", err)
  11287. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11288. // return
  11289. // }
  11290. // if res2.Infcode == 0 {
  11291. // c.ServeSuccessJSON(map[string]interface{}{
  11292. // "list": res2.Output.Data,
  11293. // })
  11294. // return
  11295. // } else {
  11296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11297. // return
  11298. // }
  11299. //
  11300. //}
  11301. //func (c *HisApiController) ComfirmAllopatry() {
  11302. // year := c.GetString("year")
  11303. // month := c.GetString("month")
  11304. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11305. // adminUser := c.GetAdminUserInfo()
  11306. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11307. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11308. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11309. // var dat map[string]interface{}
  11310. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11311. // fmt.Println(dat)
  11312. // } else {
  11313. // fmt.Println(err)
  11314. // }
  11315. // userJSONBytes, _ := json.Marshal(dat)
  11316. // var res models.Result9001
  11317. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11318. // utils.ErrorLog("解析失败:%v", err)
  11319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11320. // return
  11321. // }
  11322. //
  11323. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11324. // var dat2 map[string]interface{}
  11325. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11326. // fmt.Println(dat)
  11327. // } else {
  11328. // fmt.Println(err)
  11329. // }
  11330. // userJSONBytes2, _ := json.Marshal(dat2)
  11331. // var res2 models.Result3260
  11332. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11333. // utils.ErrorLog("解析失败:%v", err)
  11334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11335. // return
  11336. // }
  11337. //
  11338. // if res2.Infcode == 0 {
  11339. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  11340. // var dat map[string]interface{}
  11341. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11342. // fmt.Println(dat)
  11343. // } else {
  11344. // fmt.Println(err)
  11345. // }
  11346. // userJSONBytes, _ := json.Marshal(dat)
  11347. // var res3 models.Result3261
  11348. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11349. // utils.ErrorLog("解析失败:%v", err)
  11350. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11351. // return
  11352. // }
  11353. //
  11354. // if res3.Infcode == 0 {
  11355. // record := &models.HisYidiClearRecord{
  11356. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11357. // Ctime: time.Now().Unix(),
  11358. // Mtime: time.Now().Unix(),
  11359. // Status: 1,
  11360. // MsgId: msgId,
  11361. // }
  11362. // service.SaveClearRecord(record)
  11363. // c.ServeSuccessJSON(map[string]interface{}{
  11364. // "msg": "提取成功",
  11365. // })
  11366. // }
  11367. // }
  11368. //}
  11369. func (c *HisApiController) RefundAllopatry() {
  11370. year := c.GetString("year")
  11371. month := c.GetString("month")
  11372. id, _ := c.GetInt64("id")
  11373. admin_user_id, _ := c.GetInt64("admin_user_id")
  11374. adminUser := c.GetAdminUserInfo()
  11375. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11376. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11377. record, _ := service.GetClearRecordById(id)
  11378. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11379. var dat map[string]interface{}
  11380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11381. fmt.Println(dat)
  11382. } else {
  11383. fmt.Println(err)
  11384. }
  11385. userJSONBytes, _ := json.Marshal(dat)
  11386. var empty ResultFourteen
  11387. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11388. utils.ErrorLog("解析失败:%v", err)
  11389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11390. return
  11391. }
  11392. if empty.Infcode == 0 {
  11393. c.ServeSuccessJSON(map[string]interface{}{
  11394. "msg": "撤销成功",
  11395. })
  11396. return
  11397. }
  11398. }
  11399. func (c *HisApiController) ReversalOtherData() {
  11400. var customData []*CustomData
  11401. custom := &CustomData{
  11402. MsgId: "H44022900158202103301714472004",
  11403. PsnNo: "44020000001101329945",
  11404. Info: "2208",
  11405. }
  11406. customData = append(customData, custom)
  11407. custom1 := &CustomData{
  11408. MsgId: "H4402290015820210330172057803",
  11409. PsnNo: "44020000001101161813",
  11410. Info: "2208",
  11411. }
  11412. customData = append(customData, custom1)
  11413. custom2 := &CustomData{
  11414. MsgId: "H44022900158202103301705198813",
  11415. PsnNo: "44190000133097375417",
  11416. Info: "2208",
  11417. }
  11418. customData = append(customData, custom2)
  11419. custom3 := &CustomData{
  11420. MsgId: "H44022900158202103301715524756",
  11421. PsnNo: "44020000001100187221",
  11422. Info: "2208",
  11423. }
  11424. customData = append(customData, custom3)
  11425. custom4 := &CustomData{
  11426. MsgId: "H44022900158202103301730376224",
  11427. PsnNo: "44020000001101959155",
  11428. Info: "2208",
  11429. }
  11430. customData = append(customData, custom4)
  11431. custom5 := &CustomData{
  11432. MsgId: "H44022900158202103301748008725",
  11433. PsnNo: "44020000001104246641",
  11434. Info: "2208",
  11435. }
  11436. customData = append(customData, custom5)
  11437. custom6 := &CustomData{
  11438. MsgId: "H44022900158202103301718096755",
  11439. PsnNo: "44020000001102211860",
  11440. Info: "2208",
  11441. }
  11442. customData = append(customData, custom6)
  11443. custom7 := &CustomData{
  11444. MsgId: "H44022900158202103301736551640",
  11445. PsnNo: "44020000001102687718",
  11446. Info: "2208",
  11447. }
  11448. customData = append(customData, custom7)
  11449. custom8 := &CustomData{
  11450. MsgId: "H44022900158202103301743097676",
  11451. PsnNo: "44020000001102127785",
  11452. Info: "2208",
  11453. }
  11454. customData = append(customData, custom8)
  11455. custom9 := &CustomData{
  11456. MsgId: "H44022900158202103301712304203",
  11457. PsnNo: "44020000001101518097",
  11458. Info: "2208",
  11459. }
  11460. customData = append(customData, custom9)
  11461. custom10 := &CustomData{
  11462. MsgId: "H44022900158202103301738448785",
  11463. PsnNo: "44020000001100500813",
  11464. Info: "2208",
  11465. }
  11466. customData = append(customData, custom10)
  11467. custom11 := &CustomData{
  11468. MsgId: "H44022900158202103301732455843",
  11469. PsnNo: "44020000001102690557",
  11470. Info: "2208",
  11471. }
  11472. customData = append(customData, custom11)
  11473. custom12 := &CustomData{
  11474. MsgId: "H44022900158202103301745421708",
  11475. PsnNo: "44020000001102211928",
  11476. Info: "2208",
  11477. }
  11478. customData = append(customData, custom12)
  11479. custom1212 := &CustomData{
  11480. MsgId: "H440229001582021033017351627",
  11481. PsnNo: "44020000001102481733",
  11482. Info: "2208",
  11483. }
  11484. customData = append(customData, custom1212)
  11485. custom13 := &CustomData{
  11486. MsgId: "H44022900158202103301740327951",
  11487. PsnNo: "44020000001103174866",
  11488. Info: "2208",
  11489. }
  11490. customData = append(customData, custom13)
  11491. custom14 := &CustomData{
  11492. MsgId: "H4402290015820210330174922668",
  11493. PsnNo: "44020000001102927272",
  11494. Info: "2208",
  11495. }
  11496. customData = append(customData, custom14)
  11497. custom15 := &CustomData{
  11498. MsgId: "H44022900158202103301752362273",
  11499. PsnNo: "44020000001102942890",
  11500. Info: "2208",
  11501. }
  11502. customData = append(customData, custom15)
  11503. custom16 := &CustomData{
  11504. MsgId: "H44022900158202103301751082917",
  11505. PsnNo: "44020000001101662162",
  11506. Info: "2208",
  11507. }
  11508. customData = append(customData, custom16)
  11509. custom17 := &CustomData{
  11510. MsgId: "H44022900158202103301754147728",
  11511. PsnNo: "44020000000229014511",
  11512. Info: "2208",
  11513. }
  11514. customData = append(customData, custom17)
  11515. adminUser := c.GetAdminUserInfo()
  11516. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11517. for _, item := range customData {
  11518. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11519. fmt.Println(result)
  11520. }
  11521. }
  11522. func PathExists(path string) (bool, error) {
  11523. _, err := os.Stat(path)
  11524. if err == nil {
  11525. return true, nil
  11526. }
  11527. if os.IsNotExist(err) {
  11528. return false, nil
  11529. }
  11530. return false, err
  11531. }
  11532. //创建文件夹
  11533. func Mkdir(dir string) {
  11534. // 创建文件夹
  11535. exist, err := PathExists(dir)
  11536. if err != nil {
  11537. fmt.Println(err.Error())
  11538. } else {
  11539. if exist {
  11540. fmt.Println(dir + "文件夹已存在!")
  11541. } else {
  11542. // 文件夹名称,权限
  11543. err := os.Mkdir(dir, os.ModePerm)
  11544. if err != nil {
  11545. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11546. } else {
  11547. fmt.Println(dir + "文件夹创建成功!")
  11548. }
  11549. }
  11550. }
  11551. }
  11552. //压缩文件
  11553. func Zip(srcFile string, destZip string) error {
  11554. zipfile, err := os.Create(destZip)
  11555. if err != nil {
  11556. return err
  11557. }
  11558. defer zipfile.Close()
  11559. archive := zip.NewWriter(zipfile)
  11560. defer archive.Close()
  11561. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11562. if err != nil {
  11563. return err
  11564. }
  11565. header, err := zip.FileInfoHeader(info)
  11566. if err != nil {
  11567. return err
  11568. }
  11569. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11570. // header.Name = path
  11571. if info.IsDir() {
  11572. header.Name += "/"
  11573. } else {
  11574. header.Method = zip.Deflate
  11575. }
  11576. writer, err := archive.CreateHeader(header)
  11577. if err != nil {
  11578. return err
  11579. }
  11580. if !info.IsDir() {
  11581. file, err := os.Open(path)
  11582. if err != nil {
  11583. return err
  11584. }
  11585. defer file.Close()
  11586. _, err = io.Copy(writer, file)
  11587. }
  11588. return err
  11589. })
  11590. return err
  11591. }
  11592. func ReadFile(filePath string) []byte {
  11593. f, err := os.Open(filePath)
  11594. if err != nil {
  11595. fmt.Println("read file fail", err)
  11596. return nil
  11597. }
  11598. defer f.Close()
  11599. fd, err := ioutil.ReadAll(f)
  11600. if err != nil {
  11601. fmt.Println("read to fd fail", err)
  11602. return nil
  11603. }
  11604. return fd
  11605. }
  11606. func saveLog(result string, request string, infno string, desc string) {
  11607. org_id, _ := beego.AppConfig.Int64("org_id")
  11608. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11609. dir := miConfig.OrgName + "日志"
  11610. utils.Mkdir(dir)
  11611. month := time.Unix(1557042972, 0).Format("1")
  11612. year := time.Now().Format("2006")
  11613. month = time.Now().Format("01")
  11614. day := time.Now().Format("02")
  11615. hour := time.Now().Format("15")
  11616. min := time.Now().Format("04")
  11617. sec := time.Now().Format("05")
  11618. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11619. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11620. file_name := file + ".txt"
  11621. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11622. exist, _ := utils.PathExists(file_path)
  11623. if exist { //存在
  11624. fmt.Println("存在")
  11625. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11626. if err != nil {
  11627. fmt.Println("read fail")
  11628. }
  11629. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11630. n, _ := f.Seek(0, 2)
  11631. _, err = f.WriteAt([]byte(content), n)
  11632. } else { //不存在
  11633. fmt.Println("文件不存在,创建文件")
  11634. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11635. defer f.Close()
  11636. if err != nil {
  11637. } else {
  11638. _, err = f.Write([]byte("记录日志"))
  11639. }
  11640. }
  11641. }
  11642. type Charset string
  11643. const (
  11644. UTF8 = Charset("UTF-8")
  11645. GB18030 = Charset("GB18030")
  11646. )
  11647. func ConvertToString(src string, srcCode string, tagCode string) string {
  11648. srcCoder := mahonia.NewDecoder(srcCode)
  11649. srcResult := srcCoder.ConvertString(src)
  11650. tagCoder := mahonia.NewDecoder(tagCode)
  11651. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11652. result := string(cdata)
  11653. return result
  11654. }
  11655. func (c *HisApiController) ReadEleCard() {
  11656. id_card_type, _ := c.GetInt64("id_card_type")
  11657. admin_user_id, _ := c.GetInt64("admin_user_id")
  11658. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11659. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11660. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11661. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11662. var api string
  11663. if miConfig.MdtrtareaAdmvs == "320921" {
  11664. 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 +
  11665. "&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
  11666. fmt.Println(api)
  11667. } else {
  11668. 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 +
  11669. "&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
  11670. }
  11671. resp, requestErr := http.Get(api)
  11672. if requestErr != nil {
  11673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11674. return
  11675. }
  11676. body, ioErr := ioutil.ReadAll(resp.Body)
  11677. if ioErr != nil {
  11678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11680. return
  11681. }
  11682. var respJSON map[string]interface{}
  11683. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11686. return
  11687. }
  11688. var status string
  11689. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11690. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11691. var token string
  11692. var res ResultTwo //1101结果
  11693. var res10265 ResultTwo10265 //1101结果
  11694. if status == "0" { //读卡成功
  11695. var card_info string //卡信息
  11696. var busi_card_info string
  11697. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11698. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11699. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11700. fmt.Println(card_info)
  11701. fmt.Println(busi_card_info)
  11702. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11703. result, _ := json.Marshal(respJSON)
  11704. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11705. utils.ErrorLog("解析失败:%v", err)
  11706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11707. return
  11708. }
  11709. res.ErrMsg = res10265.ErrMsg
  11710. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11711. res.Infcode = infocode
  11712. res.Output = res10265.Output
  11713. res.InfRefmsgid = res10265.InfRefmsgid
  11714. if res.Infcode == 0 {
  11715. c.ServeSuccessJSON(map[string]interface{}{
  11716. "number": token,
  11717. })
  11718. }
  11719. } else {
  11720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11721. return
  11722. }
  11723. } else { //读卡失败
  11724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11725. return
  11726. }
  11727. }
  11728. func DeleteExtraSpaceTwo(s string) string {
  11729. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11730. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11731. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11732. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11733. s2 := make([]byte, len(s1)) //定义字符数组切片
  11734. copy(s2, s1) //将字符串复制到切片
  11735. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11736. for len(spc_index) > 0 { //找到适配项
  11737. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11738. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11739. }
  11740. return string(s2)
  11741. }
  11742. func Remove0000(s string) string {
  11743. str := make([]rune, 0, len(s))
  11744. for _, v := range []rune(s) {
  11745. if v == 0 {
  11746. continue
  11747. }
  11748. str = append(str, v)
  11749. }
  11750. return string(str)
  11751. }
  11752. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11753. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11754. readCard := DllDef.MustFindProc("EcQuery")
  11755. pCardInfo := make([]byte, 8192)
  11756. pBusiCardInfo := make([]byte, 8192)
  11757. data := make(map[string]interface{})
  11758. //pData := make(map[string]interface{})
  11759. inputData := make(map[string]interface{})
  11760. inputData["orgId"] = code
  11761. inputData["businessType"] = "01101"
  11762. inputData["operatorId"] = operator_id
  11763. inputData["operatorName"] = operator_name
  11764. inputData["officeId"] = "001"
  11765. inputData["officeName"] = "血透室"
  11766. //
  11767. data["data"] = inputData
  11768. data["transType"] = "ec.query"
  11769. data["orgId"] = code
  11770. bytesData, _ := json.Marshal(data)
  11771. pCardInfo = bytesData
  11772. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11773. fmt.Println(ret2)
  11774. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11775. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11776. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11777. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11778. if ret2 != 0 {
  11779. return "", ""
  11780. }
  11781. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11782. }
  11783. func DeleteExtraSpace(s string) string {
  11784. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11785. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11786. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11787. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11788. s2 := make([]byte, len(s1)) //定义字符数组切片
  11789. copy(s2, s1) //将字符串复制到切片
  11790. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11791. for len(spc_index) > 0 { //找到适配项
  11792. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11793. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11794. }
  11795. return string(s2)
  11796. }
  11797. //对账
  11798. func (c *HisApiController) Post3202() {
  11799. start_time := c.GetString("start_time")
  11800. end_time := c.GetString("end_time")
  11801. //insutype := c.GetString("insutype")
  11802. clr_type := c.GetString("clr_type")
  11803. clr_org := c.GetString("clr_optins")
  11804. admin_user_id, _ := c.GetInt64("admin_user_id")
  11805. adminUser := c.GetAdminUserInfo()
  11806. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11807. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11808. if len(clr_org) == 0 {
  11809. clr_org = miConfig.MdtrtareaAdmvs
  11810. }
  11811. timeLayout := "2006-01-02"
  11812. loc, _ := time.LoadLocation("Local")
  11813. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11814. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11815. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "390", "", clr_type)
  11816. orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  11817. //fixmedins_setl_cnt := int64(len(orders))
  11818. var medfee_sumamt float64
  11819. var acct_pay float64
  11820. var fund_pay_sumamt float64
  11821. for _, item := range orders {
  11822. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11823. acct_pay = acct_pay + item.AcctPay
  11824. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11825. }
  11826. var medfee_sumamt_two float64
  11827. var acct_pay_two float64
  11828. var fund_pay_sumamt_two float64
  11829. for _, item := range orders_two {
  11830. medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  11831. acct_pay_two = acct_pay_two + item.AcctPay
  11832. fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  11833. }
  11834. //var user_name string
  11835. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11836. //if role.ID == 0 {
  11837. // user_name = "xxx"
  11838. //} else {
  11839. // user_name = role.UserName
  11840. //}
  11841. var res ResultSix
  11842. if config.IsOpen == 1 {
  11843. var bps []*models.BusinessParamsTwo
  11844. var bp models.BusinessParamsTwo
  11845. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  11846. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  11847. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  11848. bp.MedfeeSumamt = medfee_sumamt_str
  11849. bp.AcctPay = acct_pay_str
  11850. bp.FundPaySumamt = fund_pay_sumamt_str
  11851. bp.Insutype = "390"
  11852. bp.StmtBegndate = start_time
  11853. bp.ClrType = clr_type
  11854. bp.SetlOptins = clr_org
  11855. bp.StmtEnddate = end_time
  11856. bps = append(bps, &bp)
  11857. medfee_sumamt_two_str := fmt.Sprintf("%.2f", medfee_sumamt_two)
  11858. acct_pay_two_str := fmt.Sprintf("%.2f", acct_pay_two)
  11859. fund_pay_sumamt_two_str := fmt.Sprintf("%.2f", fund_pay_sumamt_two)
  11860. var bp2 models.BusinessParamsTwo
  11861. bp2.MedfeeSumamt = medfee_sumamt_two_str
  11862. bp2.AcctPay = acct_pay_two_str
  11863. bp2.FundPaySumamt = fund_pay_sumamt_two_str
  11864. bp2.Insutype = "310"
  11865. bp2.StmtBegndate = start_time
  11866. bp2.StmtEnddate = end_time
  11867. bp2.ClrType = clr_type
  11868. bp2.SetlOptins = clr_org
  11869. bps = append(bps, &bp2)
  11870. fmt.Println(bps)
  11871. data := make(map[string]interface{})
  11872. data["bps"] = bps
  11873. data["org_name"] = miConfig.OrgName
  11874. data["doctor"] = role.UserName
  11875. data["fixmedins_code"] = miConfig.Code
  11876. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11877. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11878. if miConfig.MdtrtareaAdmvs == "421300" {
  11879. client := &http.Client{}
  11880. bytesData, _ := json.Marshal(data)
  11881. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  11882. resp, _ := client.Do(req)
  11883. defer resp.Body.Close()
  11884. body, ioErr := ioutil.ReadAll(resp.Body)
  11885. if ioErr != nil {
  11886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11888. return
  11889. }
  11890. var respJSON map[string]interface{}
  11891. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11894. return
  11895. }
  11896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11897. userJSONBytes, _ := json.Marshal(respJSON)
  11898. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11899. utils.ErrorLog("解析失败:%v", err)
  11900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11901. return
  11902. }
  11903. }
  11904. if res.Infcode == 0 {
  11905. c.ServeSuccessJSON(map[string]interface{}{
  11906. "msg": "发起成功",
  11907. })
  11908. } else {
  11909. c.ServeSuccessJSON(map[string]interface{}{
  11910. "code": -10,
  11911. "msg": res.ErrMsg,
  11912. })
  11913. }
  11914. }
  11915. }
  11916. func (c *HisApiController) Post3501() {
  11917. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11918. data := make(map[string]interface{})
  11919. var struct3501s []models.Struct3501
  11920. var struct3501 models.Struct3501
  11921. struct3501.OrgName = miConfig.OrgName
  11922. struct3501.AccessKey = miConfig.AccessKey
  11923. struct3501.RequestUrl = miConfig.Url
  11924. struct3501.SecretKey = miConfig.SecretKey
  11925. struct3501.ManuDate = "2022-08-17"
  11926. struct3501.FixmedinsBchno = ""
  11927. struct3501.ManuLotnum = ""
  11928. struct3501.RxFlag = "0"
  11929. struct3501.ExpyEnd = "2022-08-17"
  11930. struct3501.Invdate = "2022-08-17"
  11931. struct3501.InvCnt = "20.25"
  11932. struct3501.Memo = ""
  11933. struct3501.MedListCodg = "XB01ABD056B002020200517"
  11934. struct3501.FixmedinsHilistId = miConfig.Code
  11935. struct3501.FixmedinsHilistName = miConfig.OrgName
  11936. struct3501s = append(struct3501s, struct3501)
  11937. data["struct_3501s"] = struct3501s
  11938. client := &http.Client{}
  11939. bytesData, _ := json.Marshal(data)
  11940. var req *http.Request
  11941. if miConfig.MdtrtareaAdmvs == "320921" {
  11942. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  11943. } else {
  11944. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  11945. }
  11946. resp, _ := client.Do(req)
  11947. defer resp.Body.Close()
  11948. body, ioErr := ioutil.ReadAll(resp.Body)
  11949. if ioErr != nil {
  11950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11952. return
  11953. }
  11954. var respJSON map[string]interface{}
  11955. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11958. return
  11959. }
  11960. var res ResultSix
  11961. var resSix10265 ResultSix10265 //1101结果
  11962. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11963. result, _ := json.Marshal(respJSON)
  11964. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  11965. utils.ErrorLog("解析失败:%v", err)
  11966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11967. return
  11968. }
  11969. res.InfRefmsgid = resSix10265.InfRefmsgid
  11970. res.Output = resSix10265.Output
  11971. res.ErrMsg = resSix10265.ErrMsg
  11972. res.Cainfo = resSix10265.Cainfo
  11973. res.WarnMsg = resSix10265.WarnMsg
  11974. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11975. res.Infcode = infocode
  11976. if infocode == 0 {
  11977. c.ServeSuccessJSON(map[string]interface{}{
  11978. "msg": "上传成功",
  11979. })
  11980. return
  11981. } else {
  11982. c.ServeSuccessJSON(map[string]interface{}{
  11983. "failed_code": -10,
  11984. "msg": res.ErrMsg,
  11985. })
  11986. return
  11987. }
  11988. }
  11989. func (c *HisApiController) Post3502() {
  11990. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11991. data := make(map[string]interface{})
  11992. var struct3502s []models.Struct3502
  11993. var struct3502 models.Struct3502
  11994. struct3502.OrgName = miConfig.OrgName
  11995. struct3502.AccessKey = miConfig.AccessKey
  11996. struct3502.RequestUrl = miConfig.Url
  11997. struct3502.SecretKey = miConfig.SecretKey
  11998. struct3502.ManuDate = "2022-08-15"
  11999. struct3502.FixmedinsBchno = ""
  12000. struct3502.ManuLotnum = ""
  12001. struct3502.RxFlag = "0"
  12002. struct3502.ExpyEnd = "2022-08-15"
  12003. struct3502.Invdate = "2022-08-15"
  12004. struct3502.InvCnt = "20.25"
  12005. struct3502.Memo = ""
  12006. struct3502.MedListCodg = "XB01ABD056B002020200517"
  12007. struct3502.FixmedinsHilistId = miConfig.Code
  12008. struct3502.FixmedinsHilistName = miConfig.OrgName
  12009. struct3502s = append(struct3502s, struct3502)
  12010. data["struct_3502s"] = struct3502s
  12011. client := &http.Client{}
  12012. bytesData, _ := json.Marshal(data)
  12013. var req *http.Request
  12014. if miConfig.MdtrtareaAdmvs == "320921" {
  12015. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12016. } else {
  12017. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12018. }
  12019. resp, _ := client.Do(req)
  12020. defer resp.Body.Close()
  12021. body, ioErr := ioutil.ReadAll(resp.Body)
  12022. if ioErr != nil {
  12023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12025. return
  12026. }
  12027. var respJSON map[string]interface{}
  12028. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12031. return
  12032. }
  12033. var res ResultSix
  12034. var resSix10265 ResultSix10265 //1101结果
  12035. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12036. result, _ := json.Marshal(respJSON)
  12037. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12038. utils.ErrorLog("解析失败:%v", err)
  12039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12040. return
  12041. }
  12042. res.InfRefmsgid = resSix10265.InfRefmsgid
  12043. res.Output = resSix10265.Output
  12044. res.ErrMsg = resSix10265.ErrMsg
  12045. res.Cainfo = resSix10265.Cainfo
  12046. res.WarnMsg = resSix10265.WarnMsg
  12047. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12048. res.Infcode = infocode
  12049. if infocode == 0 {
  12050. c.ServeSuccessJSON(map[string]interface{}{
  12051. "msg": "上传成功",
  12052. })
  12053. return
  12054. } else {
  12055. c.ServeSuccessJSON(map[string]interface{}{
  12056. "failed_code": -10,
  12057. "msg": res.ErrMsg,
  12058. })
  12059. return
  12060. }
  12061. }
  12062. func (c *HisApiController) Post3503() {
  12063. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12064. data := make(map[string]interface{})
  12065. var struct3501s []models.Struct3501
  12066. var struct3501 models.Struct3501
  12067. struct3501.OrgName = miConfig.OrgName
  12068. struct3501.AccessKey = miConfig.AccessKey
  12069. struct3501.RequestUrl = miConfig.Url
  12070. struct3501.SecretKey = miConfig.SecretKey
  12071. struct3501.ManuDate = "2022-08-15"
  12072. struct3501.FixmedinsBchno = ""
  12073. struct3501.ManuLotnum = ""
  12074. struct3501.RxFlag = "0"
  12075. struct3501.ExpyEnd = "2022-08-15"
  12076. struct3501.Invdate = "2022-08-15"
  12077. struct3501.InvCnt = "20.25"
  12078. struct3501.Memo = ""
  12079. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12080. struct3501.FixmedinsHilistId = miConfig.Code
  12081. struct3501.FixmedinsHilistName = miConfig.OrgName
  12082. struct3501s = append(struct3501s, struct3501)
  12083. data["struct_3501s"] = struct3501s
  12084. client := &http.Client{}
  12085. bytesData, _ := json.Marshal(data)
  12086. var req *http.Request
  12087. if miConfig.MdtrtareaAdmvs == "320921" {
  12088. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12089. } else {
  12090. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12091. }
  12092. resp, _ := client.Do(req)
  12093. defer resp.Body.Close()
  12094. body, ioErr := ioutil.ReadAll(resp.Body)
  12095. if ioErr != nil {
  12096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12098. return
  12099. }
  12100. var respJSON map[string]interface{}
  12101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12104. return
  12105. }
  12106. var res ResultSix
  12107. var resSix10265 ResultSix10265 //1101结果
  12108. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12109. result, _ := json.Marshal(respJSON)
  12110. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12111. utils.ErrorLog("解析失败:%v", err)
  12112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12113. return
  12114. }
  12115. res.InfRefmsgid = resSix10265.InfRefmsgid
  12116. res.Output = resSix10265.Output
  12117. res.ErrMsg = resSix10265.ErrMsg
  12118. res.Cainfo = resSix10265.Cainfo
  12119. res.WarnMsg = resSix10265.WarnMsg
  12120. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12121. res.Infcode = infocode
  12122. if infocode == 0 {
  12123. c.ServeSuccessJSON(map[string]interface{}{
  12124. "msg": "上传成功",
  12125. })
  12126. return
  12127. } else {
  12128. c.ServeSuccessJSON(map[string]interface{}{
  12129. "failed_code": -10,
  12130. "msg": res.ErrMsg,
  12131. })
  12132. return
  12133. }
  12134. }
  12135. func (c *HisApiController) Post3504() {
  12136. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12137. data := make(map[string]interface{})
  12138. var struct3501s []models.Struct3501
  12139. var struct3501 models.Struct3501
  12140. struct3501.OrgName = miConfig.OrgName
  12141. struct3501.AccessKey = miConfig.AccessKey
  12142. struct3501.RequestUrl = miConfig.Url
  12143. struct3501.SecretKey = miConfig.SecretKey
  12144. struct3501.ManuDate = "2022-08-15"
  12145. struct3501.FixmedinsBchno = ""
  12146. struct3501.ManuLotnum = ""
  12147. struct3501.RxFlag = "0"
  12148. struct3501.ExpyEnd = "2022-08-15"
  12149. struct3501.Invdate = "2022-08-15"
  12150. struct3501.InvCnt = "20.25"
  12151. struct3501.Memo = ""
  12152. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12153. struct3501.FixmedinsHilistId = miConfig.Code
  12154. struct3501.FixmedinsHilistName = miConfig.OrgName
  12155. struct3501s = append(struct3501s, struct3501)
  12156. data["struct_3501s"] = struct3501s
  12157. client := &http.Client{}
  12158. bytesData, _ := json.Marshal(data)
  12159. var req *http.Request
  12160. if miConfig.MdtrtareaAdmvs == "320921" {
  12161. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12162. } else {
  12163. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12164. }
  12165. resp, _ := client.Do(req)
  12166. defer resp.Body.Close()
  12167. body, ioErr := ioutil.ReadAll(resp.Body)
  12168. if ioErr != nil {
  12169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12171. return
  12172. }
  12173. var respJSON map[string]interface{}
  12174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12177. return
  12178. }
  12179. var res ResultSix
  12180. var resSix10265 ResultSix10265 //1101结果
  12181. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12182. result, _ := json.Marshal(respJSON)
  12183. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12184. utils.ErrorLog("解析失败:%v", err)
  12185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12186. return
  12187. }
  12188. res.InfRefmsgid = resSix10265.InfRefmsgid
  12189. res.Output = resSix10265.Output
  12190. res.ErrMsg = resSix10265.ErrMsg
  12191. res.Cainfo = resSix10265.Cainfo
  12192. res.WarnMsg = resSix10265.WarnMsg
  12193. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12194. res.Infcode = infocode
  12195. if infocode == 0 {
  12196. c.ServeSuccessJSON(map[string]interface{}{
  12197. "msg": "上传成功",
  12198. })
  12199. return
  12200. } else {
  12201. c.ServeSuccessJSON(map[string]interface{}{
  12202. "failed_code": -10,
  12203. "msg": res.ErrMsg,
  12204. })
  12205. return
  12206. }
  12207. }
  12208. func (c *HisApiController) Post3505() {
  12209. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12210. data := make(map[string]interface{})
  12211. var struct3501s []models.Struct3501
  12212. var struct3501 models.Struct3501
  12213. struct3501.OrgName = miConfig.OrgName
  12214. struct3501.AccessKey = miConfig.AccessKey
  12215. struct3501.RequestUrl = miConfig.Url
  12216. struct3501.SecretKey = miConfig.SecretKey
  12217. struct3501.ManuDate = "2022-08-15"
  12218. struct3501.FixmedinsBchno = ""
  12219. struct3501.ManuLotnum = ""
  12220. struct3501.RxFlag = "0"
  12221. struct3501.ExpyEnd = "2022-08-15"
  12222. struct3501.Invdate = "2022-08-15"
  12223. struct3501.InvCnt = "20.25"
  12224. struct3501.Memo = ""
  12225. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12226. struct3501.FixmedinsHilistId = miConfig.Code
  12227. struct3501.FixmedinsHilistName = miConfig.OrgName
  12228. struct3501s = append(struct3501s, struct3501)
  12229. data["struct_3501s"] = struct3501s
  12230. client := &http.Client{}
  12231. bytesData, _ := json.Marshal(data)
  12232. var req *http.Request
  12233. if miConfig.MdtrtareaAdmvs == "320921" {
  12234. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12235. } else {
  12236. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12237. }
  12238. resp, _ := client.Do(req)
  12239. defer resp.Body.Close()
  12240. body, ioErr := ioutil.ReadAll(resp.Body)
  12241. if ioErr != nil {
  12242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12244. return
  12245. }
  12246. var respJSON map[string]interface{}
  12247. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12250. return
  12251. }
  12252. var res ResultSix
  12253. var resSix10265 ResultSix10265 //1101结果
  12254. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12255. result, _ := json.Marshal(respJSON)
  12256. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12257. utils.ErrorLog("解析失败:%v", err)
  12258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12259. return
  12260. }
  12261. res.InfRefmsgid = resSix10265.InfRefmsgid
  12262. res.Output = resSix10265.Output
  12263. res.ErrMsg = resSix10265.ErrMsg
  12264. res.Cainfo = resSix10265.Cainfo
  12265. res.WarnMsg = resSix10265.WarnMsg
  12266. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12267. res.Infcode = infocode
  12268. if infocode == 0 {
  12269. c.ServeSuccessJSON(map[string]interface{}{
  12270. "msg": "上传成功",
  12271. })
  12272. return
  12273. } else {
  12274. c.ServeSuccessJSON(map[string]interface{}{
  12275. "failed_code": -10,
  12276. "msg": res.ErrMsg,
  12277. })
  12278. return
  12279. }
  12280. }
  12281. func (c *HisApiController) Post3506() {
  12282. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12283. data := make(map[string]interface{})
  12284. var struct3501s []models.Struct3501
  12285. var struct3501 models.Struct3501
  12286. struct3501.OrgName = miConfig.OrgName
  12287. struct3501.AccessKey = miConfig.AccessKey
  12288. struct3501.RequestUrl = miConfig.Url
  12289. struct3501.SecretKey = miConfig.SecretKey
  12290. struct3501.ManuDate = "2022-08-15"
  12291. struct3501.FixmedinsBchno = ""
  12292. struct3501.ManuLotnum = ""
  12293. struct3501.RxFlag = "0"
  12294. struct3501.ExpyEnd = "2022-08-15"
  12295. struct3501.Invdate = "2022-08-15"
  12296. struct3501.InvCnt = "20.25"
  12297. struct3501.Memo = ""
  12298. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12299. struct3501.FixmedinsHilistId = miConfig.Code
  12300. struct3501.FixmedinsHilistName = miConfig.OrgName
  12301. struct3501s = append(struct3501s, struct3501)
  12302. data["struct_3501s"] = struct3501s
  12303. client := &http.Client{}
  12304. bytesData, _ := json.Marshal(data)
  12305. var req *http.Request
  12306. if miConfig.MdtrtareaAdmvs == "320921" {
  12307. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12308. } else {
  12309. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12310. }
  12311. resp, _ := client.Do(req)
  12312. defer resp.Body.Close()
  12313. body, ioErr := ioutil.ReadAll(resp.Body)
  12314. if ioErr != nil {
  12315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12317. return
  12318. }
  12319. var respJSON map[string]interface{}
  12320. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12323. return
  12324. }
  12325. var res ResultSix
  12326. var resSix10265 ResultSix10265 //1101结果
  12327. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12328. result, _ := json.Marshal(respJSON)
  12329. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12330. utils.ErrorLog("解析失败:%v", err)
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. res.InfRefmsgid = resSix10265.InfRefmsgid
  12335. res.Output = resSix10265.Output
  12336. res.ErrMsg = resSix10265.ErrMsg
  12337. res.Cainfo = resSix10265.Cainfo
  12338. res.WarnMsg = resSix10265.WarnMsg
  12339. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12340. res.Infcode = infocode
  12341. if infocode == 0 {
  12342. c.ServeSuccessJSON(map[string]interface{}{
  12343. "msg": "上传成功",
  12344. })
  12345. return
  12346. } else {
  12347. c.ServeSuccessJSON(map[string]interface{}{
  12348. "failed_code": -10,
  12349. "msg": res.ErrMsg,
  12350. })
  12351. return
  12352. }
  12353. }
  12354. func (c *HisApiController) Post3507() {
  12355. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12356. data := make(map[string]interface{})
  12357. var struct3501s []models.Struct3501
  12358. var struct3501 models.Struct3501
  12359. struct3501.OrgName = miConfig.OrgName
  12360. struct3501.AccessKey = miConfig.AccessKey
  12361. struct3501.RequestUrl = miConfig.Url
  12362. struct3501.SecretKey = miConfig.SecretKey
  12363. struct3501.ManuDate = "2022-08-15"
  12364. struct3501.FixmedinsBchno = ""
  12365. struct3501.ManuLotnum = ""
  12366. struct3501.RxFlag = "0"
  12367. struct3501.ExpyEnd = "2022-08-15"
  12368. struct3501.Invdate = "2022-08-15"
  12369. struct3501.InvCnt = "20.25"
  12370. struct3501.Memo = ""
  12371. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12372. struct3501.FixmedinsHilistId = miConfig.Code
  12373. struct3501.FixmedinsHilistName = miConfig.OrgName
  12374. struct3501s = append(struct3501s, struct3501)
  12375. data["struct_3501s"] = struct3501s
  12376. client := &http.Client{}
  12377. bytesData, _ := json.Marshal(data)
  12378. var req *http.Request
  12379. if miConfig.MdtrtareaAdmvs == "320921" {
  12380. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12381. } else {
  12382. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12383. }
  12384. resp, _ := client.Do(req)
  12385. defer resp.Body.Close()
  12386. body, ioErr := ioutil.ReadAll(resp.Body)
  12387. if ioErr != nil {
  12388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12390. return
  12391. }
  12392. var respJSON map[string]interface{}
  12393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12396. return
  12397. }
  12398. var res ResultSix
  12399. var resSix10265 ResultSix10265 //1101结果
  12400. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12401. result, _ := json.Marshal(respJSON)
  12402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12403. utils.ErrorLog("解析失败:%v", err)
  12404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12405. return
  12406. }
  12407. res.InfRefmsgid = resSix10265.InfRefmsgid
  12408. res.Output = resSix10265.Output
  12409. res.ErrMsg = resSix10265.ErrMsg
  12410. res.Cainfo = resSix10265.Cainfo
  12411. res.WarnMsg = resSix10265.WarnMsg
  12412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12413. res.Infcode = infocode
  12414. if infocode == 0 {
  12415. c.ServeSuccessJSON(map[string]interface{}{
  12416. "msg": "上传成功",
  12417. })
  12418. return
  12419. } else {
  12420. c.ServeSuccessJSON(map[string]interface{}{
  12421. "failed_code": -10,
  12422. "msg": res.ErrMsg,
  12423. })
  12424. return
  12425. }
  12426. }