his_api_controller.go 406KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. }
  74. func (c *HisApiController) Check() {
  75. psn_no := c.GetString("psn_no")
  76. in := c.GetString("in")
  77. mt := c.GetString("mt")
  78. baseParams := models.BaseParams{
  79. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  80. FixmedinsCode: "H15049901371",
  81. InsuplcAdmdvs: "150499",
  82. MdtrtareaAdmvs: "150499",
  83. OrgName: "赤峰费森血液透析中心",
  84. Doctor: "1111",
  85. }
  86. service.Gdyb2001(baseParams, psn_no, in, mt)
  87. }
  88. func (c *HisApiController) GetPsnNcdsInfo() {
  89. admin_user_id, _ := c.GetInt64("admin_user_id")
  90. patient_id, _ := c.GetInt64("patient_id")
  91. id, _ := c.GetInt64("id")
  92. adminUser := c.GetAdminUserInfo()
  93. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  94. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  95. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  96. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  97. psn_record, _ := service.GetPsnNCDSRecordById(id)
  98. //
  99. //if psn_record.ID == 0 {
  100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  101. // return
  102. //}
  103. var res Result5301
  104. var res10265 Result5301For10265
  105. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  106. psn_info, _ := service.GetPsnByPatientId(patient_id)
  107. var api string
  108. if miConfig.MdtrtareaAdmvs == "320921" {
  109. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  111. } else {
  112. 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 +
  113. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  114. }
  115. resp, requestErr := http.Get(api)
  116. if requestErr != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  118. return
  119. }
  120. body, ioErr := ioutil.ReadAll(resp.Body)
  121. if ioErr != nil {
  122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  124. return
  125. }
  126. var respJSON map[string]interface{}
  127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  130. return
  131. }
  132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  133. result, _ := json.Marshal(respJSON)
  134. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  135. utils.ErrorLog("解析失败:%v", err)
  136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  137. return
  138. }
  139. res.ErrMsg = res10265.ErrMsg
  140. res.Output = res10265.Output
  141. res.InfRefmsgid = res10265.InfRefmsgid
  142. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  143. res.Infcode = infocode
  144. } else {
  145. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  146. var dat map[string]interface{}
  147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  148. fmt.Println(dat)
  149. } else {
  150. fmt.Println(err)
  151. }
  152. userJSONBytes, _ := json.Marshal(dat)
  153. if miConfig.Code == "H15049901371" {
  154. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  155. utils.ErrorLog("解析失败:%v", err)
  156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  157. return
  158. }
  159. res.InfRefmsgid = res10265.InfRefmsgid
  160. res.Output = res10265.Output
  161. res.ErrMsg = res10265.ErrMsg
  162. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  163. res.Infcode = infocode
  164. } else {
  165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  166. utils.ErrorLog("解析失败:%v", err)
  167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  168. return
  169. }
  170. }
  171. }
  172. if res.Infcode == 0 {
  173. c.ServeSuccessJSON(map[string]interface{}{
  174. "result": res.Output.Result,
  175. })
  176. }
  177. }
  178. func (c *HisApiController) CheckInsutype() {
  179. his_patient_id, _ := c.GetInt64("his_patient_id")
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  182. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  183. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  184. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  185. var dat map[string]interface{}
  186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  187. fmt.Println(dat)
  188. } else {
  189. fmt.Println(err)
  190. }
  191. userJSONBytes, _ := json.Marshal(dat)
  192. var res Result90100
  193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  194. utils.ErrorLog("解析失败:%v", err)
  195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  196. return
  197. }
  198. if res.Infcode != 0 {
  199. c.ServeSuccessJSON(map[string]interface{}{
  200. "failed_code": -10,
  201. "msg": res.ErrMsg,
  202. })
  203. return
  204. } else {
  205. fmt.Println(res)
  206. }
  207. }
  208. func (c *HisApiController) CheckCardPWD() {
  209. card_pwd := c.GetString("card_pwd")
  210. his_patient_id, _ := c.GetInt64("his_patient_id")
  211. admin_user_id, _ := c.GetInt64("admin_user_id")
  212. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  214. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  215. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  216. var dat map[string]interface{}
  217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  218. fmt.Println(dat)
  219. } else {
  220. fmt.Println(err)
  221. }
  222. userJSONBytes, _ := json.Marshal(dat)
  223. var res Result90991
  224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode != 0 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. return
  235. } else {
  236. if res.Output.Result.CheckStat == "0" {
  237. var msg string
  238. switch res.Output.Result.CardStat {
  239. case "00":
  240. msg = "未激活"
  241. break
  242. case "10":
  243. msg = "激活"
  244. break
  245. case "20":
  246. msg = "窗口挂失"
  247. break
  248. case "21":
  249. msg = "电话挂失"
  250. break
  251. case "22":
  252. msg = "单位网上申报挂失"
  253. break
  254. case "23":
  255. msg = "保健办挂失"
  256. break
  257. case "24":
  258. msg = "个人网上挂失"
  259. break
  260. case "25":
  261. msg = "网上服务大厅挂失"
  262. break
  263. case "30":
  264. msg = "注销"
  265. break
  266. case "40":
  267. msg = "回收"
  268. break
  269. case "99":
  270. msg = "制卡中(无效卡)"
  271. break
  272. }
  273. c.ServeSuccessJSON(map[string]interface{}{
  274. "failed_code": -10,
  275. "msg": msg,
  276. })
  277. return
  278. } else {
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "msg": "校验成功",
  281. })
  282. return
  283. }
  284. }
  285. }
  286. func (c *HisApiController) ReadCard() {
  287. id_card_type, _ := c.GetInt64("id_card_type")
  288. admin_user_id, _ := c.GetInt64("admin_user_id")
  289. certificates, _ := c.GetInt64("certificates")
  290. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  291. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  292. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  293. switch id_card_type {
  294. case 1:
  295. if miConfig.MdtrtareaAdmvs == "421300" {
  296. var res ResultTwo
  297. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  298. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  299. "&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)
  300. resp, requestErr := http.Get(api)
  301. if requestErr != nil {
  302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  303. return
  304. }
  305. body, ioErr := ioutil.ReadAll(resp.Body)
  306. if ioErr != nil {
  307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. var respJSON map[string]interface{}
  312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  315. return
  316. }
  317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  318. result, _ := json.Marshal(respJSON)
  319. fmt.Println("log")
  320. fmt.Println(string(result))
  321. if err := json.Unmarshal([]byte(result), &res); err != nil {
  322. utils.ErrorLog("解析失败:%v", err)
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  324. return
  325. }
  326. if res.Infcode == 0 {
  327. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  328. if err == gorm.ErrRecordNotFound {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  330. return
  331. } else if err != nil {
  332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  333. return
  334. } else {
  335. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  336. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  337. infoStr := string(Iinfos)
  338. idetinfoStr := string(Idetinfos)
  339. psn := &models.HisPsn{
  340. PsnNo: res.Output.Baseinfo.PsnNo,
  341. Age: res.Output.Baseinfo.Age,
  342. PatientId: patient.ID,
  343. Certno: res.Output.Baseinfo.Certno,
  344. Brdy: res.Output.Baseinfo.Brdy,
  345. Gend: res.Output.Baseinfo.Gend,
  346. Naty: res.Output.Baseinfo.Naty,
  347. PsnCertType: res.Output.Baseinfo.PsnCertType,
  348. PsnName: res.Output.Baseinfo.PsnName,
  349. Idetinfo: idetinfoStr,
  350. Insuinfo: infoStr,
  351. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  352. }
  353. service.CreateHisPsn(psn)
  354. c.ServeSuccessJSON(map[string]interface{}{
  355. "patient": patient,
  356. "number": res.Output.Baseinfo.Certno,
  357. })
  358. }
  359. } else {
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  361. return
  362. }
  363. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  364. var api string
  365. if miConfig.MdtrtareaAdmvs == "320921" {
  366. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  367. "&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
  368. fmt.Println(api)
  369. } else {
  370. 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 +
  371. "&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)
  372. }
  373. resp, requestErr := http.Get(api)
  374. if requestErr != nil {
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  376. return
  377. }
  378. body, ioErr := ioutil.ReadAll(resp.Body)
  379. if ioErr != nil {
  380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  382. return
  383. }
  384. var respJSON map[string]interface{}
  385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  388. return
  389. }
  390. var status string
  391. status = respJSON["data"].(map[string]interface{})["status"].(string)
  392. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  393. //console.log()
  394. fmt.Println("type===")
  395. fmt.Println(card_type)
  396. var token string
  397. var res ResultTwo //1101结果
  398. var res10265 ResultTwo10265 //1101结果
  399. var card_info string //卡信息
  400. var busi_card_info string
  401. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  402. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  403. if status == "0" { //读卡成功
  404. if card_type == "1" {
  405. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  406. result, _ := json.Marshal(respJSON)
  407. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  408. utils.ErrorLog("解析失败:%v", err)
  409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  410. return
  411. }
  412. res.ErrMsg = res10265.ErrMsg
  413. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  414. res.Infcode = infocode
  415. res.Output = res10265.Output
  416. res.InfRefmsgid = res10265.InfRefmsgid
  417. } else {
  418. //var card_info string //卡信息
  419. //var busi_card_info string
  420. token = respJSON["data"].(map[string]interface{})["token"].(string)
  421. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  422. //fmt.Println(card_info)
  423. //fmt.Println(busi_card_info)
  424. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  425. result, _ := json.Marshal(respJSON)
  426. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  427. utils.ErrorLog("解析失败:%v", err)
  428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  429. return
  430. }
  431. res.ErrMsg = res10265.ErrMsg
  432. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  433. res.Infcode = infocode
  434. res.Output = res10265.Output
  435. res.InfRefmsgid = res10265.InfRefmsgid
  436. }
  437. if res.Infcode == 0 {
  438. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  439. if err == gorm.ErrRecordNotFound {
  440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  441. return
  442. } else if err != nil {
  443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  444. return
  445. } else {
  446. if card_type == "1" {
  447. bas := strings.Split(card_info, "|")
  448. basNumber := bas[2]
  449. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  450. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  451. infoStr := string(Iinfos)
  452. idetinfoStr := string(Idetinfos)
  453. psn := &models.HisPsn{
  454. PsnNo: res.Output.Baseinfo.PsnNo,
  455. Age: res.Output.Baseinfo.Age,
  456. PatientId: patient.ID,
  457. Certno: res.Output.Baseinfo.Certno,
  458. Brdy: res.Output.Baseinfo.Brdy,
  459. Gend: res.Output.Baseinfo.Gend,
  460. Naty: res.Output.Baseinfo.Naty,
  461. PsnCertType: res.Output.Baseinfo.PsnCertType,
  462. PsnName: res.Output.Baseinfo.PsnName,
  463. Idetinfo: idetinfoStr,
  464. Insuinfo: infoStr,
  465. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  466. CardInfo: card_info,
  467. VerifyNumber: busi_card_info,
  468. }
  469. service.CreateHisPsn(psn)
  470. c.ServeSuccessJSON(map[string]interface{}{
  471. "patient": patient,
  472. "number": basNumber,
  473. })
  474. } else {
  475. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  476. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  477. infoStr := string(Iinfos)
  478. idetinfoStr := string(Idetinfos)
  479. psn := &models.HisPsn{
  480. PsnNo: res.Output.Baseinfo.PsnNo,
  481. Age: res.Output.Baseinfo.Age,
  482. PatientId: patient.ID,
  483. Certno: res.Output.Baseinfo.Certno,
  484. Brdy: res.Output.Baseinfo.Brdy,
  485. Gend: res.Output.Baseinfo.Gend,
  486. Naty: res.Output.Baseinfo.Naty,
  487. PsnCertType: res.Output.Baseinfo.PsnCertType,
  488. PsnName: res.Output.Baseinfo.PsnName,
  489. Idetinfo: idetinfoStr,
  490. Insuinfo: infoStr,
  491. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  492. CardInfo: card_info,
  493. VerifyNumber: token,
  494. }
  495. service.CreateHisPsn(psn)
  496. c.ServeSuccessJSON(map[string]interface{}{
  497. "patient": patient,
  498. "number": token,
  499. })
  500. }
  501. }
  502. } else {
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  504. return
  505. }
  506. } else { //读卡失败
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  508. return
  509. }
  510. } else {
  511. if initFlag == 0 {
  512. c.TestGetBasBaseInit()
  513. }
  514. basStr := c.GetBasBaseInfo()
  515. if len(basStr) == 0 {
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  517. return
  518. }
  519. fmt.Println(basStr)
  520. bas := strings.Split(basStr, "|")
  521. basNumber := bas[1]
  522. fmt.Println(basNumber)
  523. card_sn := bas[3]
  524. fmt.Println(card_sn)
  525. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  526. var dat map[string]interface{}
  527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  528. fmt.Println(dat)
  529. } else {
  530. fmt.Println(err)
  531. }
  532. userJSONBytes, _ := json.Marshal(dat)
  533. var res ResultTwo
  534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  535. utils.ErrorLog("解析失败:%v", err)
  536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  537. return
  538. }
  539. if res.Infcode == 0 {
  540. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  541. if err == gorm.ErrRecordNotFound {
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  543. return
  544. } else if err != nil {
  545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  546. return
  547. } else {
  548. c.ServeSuccessJSON(map[string]interface{}{
  549. "patient": patient,
  550. "number": basNumber,
  551. })
  552. }
  553. } else {
  554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  555. return
  556. }
  557. break
  558. }
  559. case 2:
  560. SFZStr := c.GetSFZBaseInfo()
  561. id_card_str := strings.Split(SFZStr, "^")
  562. id_card_number := id_card_str[0]
  563. card_sn := ""
  564. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  565. var dat map[string]interface{}
  566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  567. fmt.Println(dat)
  568. } else {
  569. fmt.Println(err)
  570. }
  571. userJSONBytes, _ := json.Marshal(dat)
  572. var res ResultTwo
  573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  574. utils.ErrorLog("解析失败:%v", err)
  575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  576. return
  577. }
  578. if res.Infcode == 0 {
  579. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  580. if err == gorm.ErrRecordNotFound {
  581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  582. return
  583. } else if err != nil {
  584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  585. return
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "patient": patient,
  589. "number": id_card_number,
  590. })
  591. }
  592. } else {
  593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  594. return
  595. }
  596. break
  597. case 3:
  598. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  599. var api string
  600. if miConfig.MdtrtareaAdmvs == "320921" {
  601. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  602. "&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
  603. fmt.Println(api)
  604. } else {
  605. 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 +
  606. "&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)
  607. }
  608. resp, requestErr := http.Get(api)
  609. if requestErr != nil {
  610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  611. return
  612. }
  613. body, ioErr := ioutil.ReadAll(resp.Body)
  614. if ioErr != nil {
  615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  617. return
  618. }
  619. var respJSON map[string]interface{}
  620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  623. return
  624. }
  625. var status string
  626. status = respJSON["data"].(map[string]interface{})["status"].(string)
  627. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  628. var token string
  629. var res ResultTwo //1101结果
  630. var res10265 ResultTwo10265 //1101结果
  631. var card_info string //卡信息
  632. var busi_card_info string
  633. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  634. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  635. if status == "0" { //读卡成功
  636. if card_type == "1" {
  637. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  638. result, _ := json.Marshal(respJSON)
  639. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  640. utils.ErrorLog("解析失败:%v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. res.ErrMsg = res10265.ErrMsg
  645. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  646. res.Infcode = infocode
  647. res.Output = res10265.Output
  648. res.InfRefmsgid = res10265.InfRefmsgid
  649. } else {
  650. //var card_info string //卡信息
  651. //var busi_card_info string
  652. token = respJSON["data"].(map[string]interface{})["token"].(string)
  653. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  654. //fmt.Println(card_info)
  655. //fmt.Println(busi_card_info)
  656. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  657. result, _ := json.Marshal(respJSON)
  658. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  659. utils.ErrorLog("解析失败:%v", err)
  660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  661. return
  662. }
  663. res.ErrMsg = res10265.ErrMsg
  664. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  665. res.Infcode = infocode
  666. res.Output = res10265.Output
  667. res.InfRefmsgid = res10265.InfRefmsgid
  668. }
  669. if res.Infcode == 0 {
  670. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  671. if err == gorm.ErrRecordNotFound {
  672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  673. return
  674. } else if err != nil {
  675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  676. return
  677. } else {
  678. if card_type == "1" {
  679. bas := strings.Split(card_info, "|")
  680. basNumber := bas[2]
  681. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  682. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  683. infoStr := string(Iinfos)
  684. idetinfoStr := string(Idetinfos)
  685. psn := &models.HisPsn{
  686. PsnNo: res.Output.Baseinfo.PsnNo,
  687. Age: res.Output.Baseinfo.Age,
  688. PatientId: patient.ID,
  689. Certno: res.Output.Baseinfo.Certno,
  690. Brdy: res.Output.Baseinfo.Brdy,
  691. Gend: res.Output.Baseinfo.Gend,
  692. Naty: res.Output.Baseinfo.Naty,
  693. PsnCertType: res.Output.Baseinfo.PsnCertType,
  694. PsnName: res.Output.Baseinfo.PsnName,
  695. Idetinfo: idetinfoStr,
  696. Insuinfo: infoStr,
  697. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  698. CardInfo: card_info,
  699. VerifyNumber: busi_card_info,
  700. }
  701. service.CreateHisPsn(psn)
  702. c.ServeSuccessJSON(map[string]interface{}{
  703. "patient": patient,
  704. "number": basNumber,
  705. })
  706. } else {
  707. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  708. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  709. infoStr := string(Iinfos)
  710. idetinfoStr := string(Idetinfos)
  711. psn := &models.HisPsn{
  712. PsnNo: res.Output.Baseinfo.PsnNo,
  713. Age: res.Output.Baseinfo.Age,
  714. PatientId: patient.ID,
  715. Certno: res.Output.Baseinfo.Certno,
  716. Brdy: res.Output.Baseinfo.Brdy,
  717. Gend: res.Output.Baseinfo.Gend,
  718. Naty: res.Output.Baseinfo.Naty,
  719. PsnCertType: res.Output.Baseinfo.PsnCertType,
  720. PsnName: res.Output.Baseinfo.PsnName,
  721. Idetinfo: idetinfoStr,
  722. Insuinfo: infoStr,
  723. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  724. CardInfo: card_info,
  725. VerifyNumber: token,
  726. }
  727. service.CreateHisPsn(psn)
  728. c.ServeSuccessJSON(map[string]interface{}{
  729. "patient": patient,
  730. "number": token,
  731. })
  732. }
  733. }
  734. } else {
  735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  736. return
  737. }
  738. } else { //读卡失败
  739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  740. return
  741. }
  742. }
  743. break
  744. case 4:
  745. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  746. var api string
  747. if miConfig.MdtrtareaAdmvs == "320921" {
  748. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  749. "&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
  750. fmt.Println(api)
  751. } else {
  752. 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 +
  753. "&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)
  754. }
  755. resp, requestErr := http.Get(api)
  756. if requestErr != nil {
  757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  758. return
  759. }
  760. body, ioErr := ioutil.ReadAll(resp.Body)
  761. if ioErr != nil {
  762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. var respJSON map[string]interface{}
  767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. var status string
  773. status = respJSON["data"].(map[string]interface{})["status"].(string)
  774. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  775. var token string
  776. var res ResultTwo //1101结果
  777. var res10265 ResultTwo10265 //1101结果
  778. var card_info string //卡信息
  779. var busi_card_info string
  780. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  781. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  782. if status == "0" { //读卡成功
  783. if card_type == "1" {
  784. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  785. result, _ := json.Marshal(respJSON)
  786. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  787. utils.ErrorLog("解析失败:%v", err)
  788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  789. return
  790. }
  791. res.ErrMsg = res10265.ErrMsg
  792. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  793. res.Infcode = infocode
  794. res.Output = res10265.Output
  795. res.InfRefmsgid = res10265.InfRefmsgid
  796. } else {
  797. var card_info string //卡信息
  798. var busi_card_info string
  799. token = respJSON["data"].(map[string]interface{})["token"].(string)
  800. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  801. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  802. fmt.Println(card_info)
  803. fmt.Println(busi_card_info)
  804. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  805. result, _ := json.Marshal(respJSON)
  806. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  807. utils.ErrorLog("解析失败:%v", err)
  808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  809. return
  810. }
  811. res.ErrMsg = res10265.ErrMsg
  812. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  813. res.Infcode = infocode
  814. res.Output = res10265.Output
  815. res.InfRefmsgid = res10265.InfRefmsgid
  816. }
  817. if res.Infcode == 0 {
  818. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  819. if err == gorm.ErrRecordNotFound {
  820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  821. return
  822. } else if err != nil {
  823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  824. return
  825. } else {
  826. if card_type == "1" {
  827. bas := strings.Split(card_info, "|")
  828. basNumber := bas[2]
  829. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  830. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  831. infoStr := string(Iinfos)
  832. idetinfoStr := string(Idetinfos)
  833. psn := &models.HisPsn{
  834. PsnNo: res.Output.Baseinfo.PsnNo,
  835. Age: res.Output.Baseinfo.Age,
  836. PatientId: patient.ID,
  837. Certno: res.Output.Baseinfo.Certno,
  838. Brdy: res.Output.Baseinfo.Brdy,
  839. Gend: res.Output.Baseinfo.Gend,
  840. Naty: res.Output.Baseinfo.Naty,
  841. PsnCertType: res.Output.Baseinfo.PsnCertType,
  842. PsnName: res.Output.Baseinfo.PsnName,
  843. Idetinfo: idetinfoStr,
  844. Insuinfo: infoStr,
  845. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  846. CardInfo: card_info,
  847. VerifyNumber: busi_card_info,
  848. }
  849. service.CreateHisPsn(psn)
  850. c.ServeSuccessJSON(map[string]interface{}{
  851. "patient": patient,
  852. "number": basNumber,
  853. })
  854. } else if card_type == "4" {
  855. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  856. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  857. infoStr := string(Iinfos)
  858. idetinfoStr := string(Idetinfos)
  859. psn := &models.HisPsn{
  860. PsnNo: res.Output.Baseinfo.PsnNo,
  861. Age: res.Output.Baseinfo.Age,
  862. PatientId: patient.ID,
  863. Certno: res.Output.Baseinfo.Certno,
  864. Brdy: res.Output.Baseinfo.Brdy,
  865. Gend: res.Output.Baseinfo.Gend,
  866. Naty: res.Output.Baseinfo.Naty,
  867. PsnCertType: res.Output.Baseinfo.PsnCertType,
  868. PsnName: res.Output.Baseinfo.PsnName,
  869. Idetinfo: idetinfoStr,
  870. Insuinfo: infoStr,
  871. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  872. CardInfo: card_info,
  873. VerifyNumber: token,
  874. }
  875. service.CreateHisPsn(psn)
  876. c.ServeSuccessJSON(map[string]interface{}{
  877. "patient": patient,
  878. "number": token,
  879. })
  880. } else {
  881. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  882. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  883. infoStr := string(Iinfos)
  884. idetinfoStr := string(Idetinfos)
  885. psn := &models.HisPsn{
  886. PsnNo: res.Output.Baseinfo.PsnNo,
  887. Age: res.Output.Baseinfo.Age,
  888. PatientId: patient.ID,
  889. Certno: res.Output.Baseinfo.Certno,
  890. Brdy: res.Output.Baseinfo.Brdy,
  891. Gend: res.Output.Baseinfo.Gend,
  892. Naty: res.Output.Baseinfo.Naty,
  893. PsnCertType: res.Output.Baseinfo.PsnCertType,
  894. PsnName: res.Output.Baseinfo.PsnName,
  895. Idetinfo: idetinfoStr,
  896. Insuinfo: infoStr,
  897. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  898. CardInfo: card_info,
  899. VerifyNumber: token,
  900. }
  901. service.CreateHisPsn(psn)
  902. c.ServeSuccessJSON(map[string]interface{}{
  903. "patient": patient,
  904. "number": token,
  905. })
  906. }
  907. }
  908. } else {
  909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  910. return
  911. }
  912. } else { //读卡失败
  913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  914. return
  915. }
  916. }
  917. break
  918. }
  919. }
  920. var initFlag int64 = 0
  921. func (c *HisApiController) TestGetBasBaseInit() {
  922. DllDef := syscall.MustLoadDLL("SSCard.dll")
  923. Iinit := DllDef.MustFindProc("Init")
  924. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  925. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  926. if ret != 0 {
  927. fmt.Println("SSCard的报错原因:", err)
  928. fmt.Println("SSCard的运算结果为:", ret)
  929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  930. return
  931. }
  932. result := int(ret)
  933. fmt.Println("SSCard的运算结果为1:", result)
  934. initFlag = 1
  935. return
  936. }
  937. func (c *HisApiController) GetSFZBaseInfo() string {
  938. DllDef := syscall.MustLoadDLL("SSCard.dll")
  939. readCard := DllDef.MustFindProc("ReadSFZ")
  940. if readCard == nil {
  941. fmt.Println("readcard is nil")
  942. readCard = DllDef.MustFindProc("ReadSFZ")
  943. }
  944. str := make([]byte, 256)
  945. str1 := make([]byte, 256)
  946. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  947. fmt.Println(r)
  948. return string(str)
  949. }
  950. func (c *HisApiController) GetBasBaseInfo() string {
  951. DllDef := syscall.MustLoadDLL("SSCard.dll")
  952. readCard := DllDef.MustFindProc("ReadCardBas")
  953. if readCard == nil {
  954. fmt.Println("readcard is nil")
  955. readCard = DllDef.MustFindProc("ReadCardBas")
  956. }
  957. str := make([]byte, 1024)
  958. str1 := make([]byte, 1024)
  959. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  960. fmt.Println(string(str1))
  961. fmt.Println(string(str))
  962. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  963. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  964. if ret2 != 0 {
  965. return ""
  966. }
  967. return string(str)
  968. }
  969. type CustomFundPay struct {
  970. FundPayType string `json:"fund_pay_type"`
  971. FundPayamt float64 `json:"fund_payamt"`
  972. }
  973. func (c *HisApiController) GetSettleList() {
  974. order_id, _ := c.GetInt64("order_id")
  975. admin_user_id, _ := c.GetInt64("admin_user_id")
  976. order, _ := service.GetHisOrderByIDTwo(order_id)
  977. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  978. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  979. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  980. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  981. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  983. if order.ID == 0 {
  984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  985. return
  986. }
  987. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  988. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  989. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  990. fmt.Println(count)
  991. var zero string
  992. number := count + 1
  993. if number >= 1000 {
  994. zero = "0000" + strconv.FormatInt(number, 10)
  995. } else if number >= 10000 {
  996. zero = "000" + strconv.FormatInt(number, 10)
  997. } else if number >= 100000 {
  998. zero = "00" + strconv.FormatInt(number, 10)
  999. } else if number >= 1000000 {
  1000. zero = "0" + strconv.FormatInt(number, 10)
  1001. } else {
  1002. zero = strconv.FormatInt(number, 10)
  1003. }
  1004. fmt.Println(zero)
  1005. struct4101 := service.Struct4101{
  1006. PsnNo: order.PsnNo,
  1007. MdtrtId: order.MdtrtId,
  1008. SetlId: order.SetlId,
  1009. PsnName: order.PsnName,
  1010. Gend: order.Gend,
  1011. Brdy: his.Brdy,
  1012. Age: his.Age,
  1013. Naty: order.Naty,
  1014. PatnCertType: "01",
  1015. Certno: order.Certno,
  1016. Prfs: "90",
  1017. ConerName: roles[0].UserName,
  1018. PatnRlts: "99",
  1019. ConerAddr: miConfig.OrgName,
  1020. ConerTel: admin.Mobile,
  1021. HiType: order.Insutype,
  1022. Insuplc: miConfig.InsuplcAdmdvs,
  1023. MaindiagFlag: "1",
  1024. BillCode: last_order.FaPiaoCode,
  1025. BillNo: zero,
  1026. BizSn: order.Number,
  1027. PsnSelfPay: order.PsnPartAmt,
  1028. PsnOwnPay: order.PsnPartAmt,
  1029. AcctPay: order.AcctPay,
  1030. PsnCashpay: order.PsnCashPay,
  1031. HiPaymtd: "1",
  1032. Hsorg: miConfig.InsuplcAdmdvs,
  1033. HsorgOpter: miConfig.InsuplcAdmdvs,
  1034. MedinsFillPsn: curRoles.UserName,
  1035. MedinsFillDept: depart.Name,
  1036. IptMedType: "2",
  1037. }
  1038. struct4101.SetlBegnDate = order.SetlTime
  1039. struct4101.SetlEndDate = order.SetlTime
  1040. time_arr := strings.Split(order.SetlTime, " ")
  1041. struct4101.AdmTime = time_arr[0]
  1042. struct4101.AdmEndTime = time_arr[0]
  1043. var rf []CustomFundPay
  1044. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1045. var tempFunPays []service.CustomStruct
  1046. for _, item := range rf {
  1047. var tempFunPay service.CustomStruct
  1048. tempFunPay.FundPayamt = item.FundPayamt
  1049. tempFunPay.FundPayType = item.FundPayType
  1050. tempFunPays = append(tempFunPays, tempFunPay)
  1051. }
  1052. struct4101.CustomStruct = tempFunPays
  1053. var tempDiaginfos []service.DiaginfoStructTwo
  1054. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1055. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1056. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1057. var config []*models.HisXtDiagnoseConfig
  1058. for _, item := range diagnosis_ids {
  1059. id, _ := strconv.ParseInt(item, 10, 64)
  1060. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1061. config = append(config, &diagnosisConfig)
  1062. }
  1063. for index, item := range config {
  1064. if index == 0 {
  1065. var tempDiaginfo service.DiaginfoStructTwo
  1066. tempDiaginfo.DiagCode = item.CountryCode
  1067. tempDiaginfo.DiagName = item.CountryContentName
  1068. tempDiaginfo.DiagType = "1"
  1069. tempDiaginfo.MaindiagFlag = "1"
  1070. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1071. } else {
  1072. var tempDiaginfo service.DiaginfoStructTwo
  1073. tempDiaginfo.DiagCode = item.CountryCode
  1074. tempDiaginfo.DiagName = item.CountryContentName
  1075. tempDiaginfo.DiagType = "2"
  1076. tempDiaginfo.MaindiagFlag = "0"
  1077. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1078. }
  1079. }
  1080. struct4101.Diseinfo = tempDiaginfos
  1081. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1082. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1083. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1084. tempOpspdiseinfo2.OprnOprtCode = ""
  1085. tempOpspdiseinfo2.OprnOprtName = ""
  1086. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1087. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1088. var iteminfo service.IteminfoStruct
  1089. var bedCostTotal float64 = 0 //床位总费
  1090. var bedCostSelfTotal float64 = 0 //床位自费
  1091. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1092. var operationCostTotal float64 = 0 //手术费
  1093. var operationCostSelfTotal float64 = 0 //手术费
  1094. var operationCostPartSelfTotal float64 = 0 //手术费
  1095. var otherCostTotal float64 = 0 //其他费用
  1096. var otherCostSelfTotal float64 = 0 //其他费用
  1097. var otherCostPartSelfTotal float64 = 0 //其他费用
  1098. var materialCostTotal float64 = 0 //材料费
  1099. var materialCostSelfTotal float64 = 0 //材料费
  1100. var materialCostPartSelfTotal float64 = 0 //材料费
  1101. var westernMedicineCostTotal float64 = 0 //西药费
  1102. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1103. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1104. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1105. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1106. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1107. var checkCostTotal float64 = 0 //检查费
  1108. var checkCostSelfTotal float64 = 0 //检查费
  1109. var checkCostPartSelfTotal float64 = 0 //检查费
  1110. var laboratoryCostTotal float64 = 0 //化验费
  1111. var laboratoryCostSelfTotal float64 = 0 //化验费
  1112. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1113. var treatCostTotal float64 = 0 //治疗费用
  1114. var treatCostSelfTotal float64 = 0 //治疗费用
  1115. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1116. decimal.DivisionPrecision = 2
  1117. var bed_fulamt_ownpay_amt float64 = 0
  1118. var operation_fulamt_ownpay_amt float64 = 0
  1119. var other_fulamt_ownpay_amt float64 = 0
  1120. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1121. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1122. var check_fulamt_ownpay_amt float64 = 0
  1123. var material_fulamt_ownpay_amt float64 = 0
  1124. var laboratory_fulamt_ownpay_amt float64 = 0
  1125. var treat_fulamt_ownpay_amt float64 = 0
  1126. var bed_claa_sunmfee float64 = 0
  1127. var bed_clab_amt float64 = 0
  1128. var bed_other_amt float64 = 0
  1129. var operation_claa_sunmfee float64 = 0
  1130. var operation_clab_amt float64 = 0
  1131. var operation_other_amt float64 = 0
  1132. var other_claa_sunmfee float64 = 0
  1133. var other_clab_amt float64 = 0
  1134. var other_other_amt float64 = 0
  1135. var westernMedicine_claa_sunmfee float64 = 0
  1136. var westernMedicine_clab_amt float64 = 0
  1137. var westernMedicine_other_amt float64 = 0
  1138. var chineseTraditional_claa_sunmfee float64 = 0
  1139. var chineseTraditional_clab_amt float64 = 0
  1140. var chineseTraditional_other_amt float64 = 0
  1141. var check_claa_sunmfee float64 = 0
  1142. var check_clab_amt float64 = 0
  1143. var check_other_amt float64 = 0
  1144. var material_claa_sunmfee float64 = 0
  1145. var material_clab_amt float64 = 0
  1146. var material_other_amt float64 = 0
  1147. var laboratory_claa_sunmfee float64 = 0
  1148. var laboratory_clab_amt float64 = 0
  1149. var laboratory_other_amt float64 = 0
  1150. var treat_claa_sunmfee float64 = 0
  1151. var treat_clab_amt float64 = 0
  1152. var treat_other_amt float64 = 0
  1153. for _, item := range order.HisOrderInfo {
  1154. if item.MedChrgitmType == "01" { //床位费
  1155. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1156. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1157. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1158. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1159. if item.ChrgitmLv == "1" {
  1160. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1161. }
  1162. if item.ChrgitmLv == "2" {
  1163. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1164. }
  1165. if item.ChrgitmLv == "3" {
  1166. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1167. }
  1168. }
  1169. if item.MedChrgitmType == "03" { //检查费
  1170. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1171. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1172. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1173. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1174. if item.ChrgitmLv == "1" {
  1175. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1176. }
  1177. if item.ChrgitmLv == "2" {
  1178. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1179. }
  1180. if item.ChrgitmLv == "3" {
  1181. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1182. }
  1183. }
  1184. if item.MedChrgitmType == "04" { //化验费
  1185. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1186. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1187. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1188. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1189. if item.ChrgitmLv == "1" {
  1190. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1191. }
  1192. if item.ChrgitmLv == "2" {
  1193. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1194. }
  1195. if item.ChrgitmLv == "3" {
  1196. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1197. }
  1198. }
  1199. if item.MedChrgitmType == "05" { //治疗费
  1200. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1201. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1202. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1203. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1204. if item.ChrgitmLv == "1" {
  1205. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1206. }
  1207. if item.ChrgitmLv == "2" {
  1208. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1209. }
  1210. if item.ChrgitmLv == "3" {
  1211. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1212. }
  1213. }
  1214. if item.MedChrgitmType == "06" { //手术费
  1215. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1216. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1217. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1218. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1219. if item.ChrgitmLv == "1" {
  1220. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1221. }
  1222. if item.ChrgitmLv == "2" {
  1223. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1224. }
  1225. if item.ChrgitmLv == "3" {
  1226. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1227. }
  1228. }
  1229. if item.MedChrgitmType == "08" { //材料费
  1230. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1231. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1232. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1233. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1234. if item.ChrgitmLv == "1" {
  1235. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1236. }
  1237. if item.ChrgitmLv == "2" {
  1238. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1239. }
  1240. if item.ChrgitmLv == "3" {
  1241. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1242. }
  1243. }
  1244. if item.MedChrgitmType == "09" { //西药费
  1245. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1246. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1247. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1248. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1249. if item.ChrgitmLv == "1" {
  1250. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1251. }
  1252. if item.ChrgitmLv == "2" {
  1253. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1254. }
  1255. if item.ChrgitmLv == "3" {
  1256. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1257. }
  1258. }
  1259. if item.MedChrgitmType == "11" { //中成费
  1260. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1261. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1262. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1263. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1264. if item.ChrgitmLv == "1" {
  1265. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1266. }
  1267. if item.ChrgitmLv == "2" {
  1268. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1269. }
  1270. if item.ChrgitmLv == "3" {
  1271. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1272. }
  1273. }
  1274. if item.MedChrgitmType == "14" { //其他费
  1275. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1276. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1277. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1278. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1279. if item.ChrgitmLv == "1" {
  1280. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1281. }
  1282. if item.ChrgitmLv == "2" {
  1283. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1284. }
  1285. if item.ChrgitmLv == "3" {
  1286. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1287. }
  1288. }
  1289. }
  1290. var iteminfoStructs []service.IteminfoStruct
  1291. if bedCostTotal != 0 {
  1292. iteminfo.MedChrgitm = "01"
  1293. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1294. iteminfo.Amt = bedCostTotal
  1295. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1296. iteminfo.ClabAmt = bed_clab_amt
  1297. iteminfo.OthAmt = bed_other_amt
  1298. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1299. }
  1300. if checkCostTotal != 0 {
  1301. iteminfo.MedChrgitm = "03"
  1302. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1303. iteminfo.Amt = checkCostTotal
  1304. iteminfo.ClaaSumfee = check_claa_sunmfee
  1305. iteminfo.ClabAmt = check_clab_amt
  1306. iteminfo.OthAmt = check_other_amt
  1307. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1308. }
  1309. if laboratoryCostTotal != 0 {
  1310. iteminfo.MedChrgitm = "04"
  1311. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1312. iteminfo.Amt = laboratoryCostTotal
  1313. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1314. iteminfo.ClabAmt = laboratory_clab_amt
  1315. iteminfo.OthAmt = laboratory_other_amt
  1316. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1317. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1318. }
  1319. if treatCostTotal != 0 {
  1320. iteminfo.MedChrgitm = "05"
  1321. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1322. iteminfo.Amt = treatCostTotal
  1323. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1324. iteminfo.ClabAmt = treat_clab_amt
  1325. iteminfo.OthAmt = treat_other_amt
  1326. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1327. //(struct4101.IteminfoStruct, iteminfo)
  1328. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1329. }
  1330. if operationCostTotal != 0 {
  1331. iteminfo.MedChrgitm = "06"
  1332. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1333. iteminfo.Amt = operationCostTotal
  1334. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1335. iteminfo.ClabAmt = operation_clab_amt
  1336. iteminfo.OthAmt = operation_other_amt
  1337. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1338. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1339. }
  1340. if materialCostTotal != 0 {
  1341. iteminfo.MedChrgitm = "08"
  1342. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1343. iteminfo.Amt = materialCostTotal
  1344. iteminfo.ClaaSumfee = material_claa_sunmfee
  1345. iteminfo.ClabAmt = material_clab_amt
  1346. iteminfo.OthAmt = material_other_amt
  1347. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1348. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1349. }
  1350. if westernMedicineCostTotal != 0 {
  1351. iteminfo.MedChrgitm = "09"
  1352. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1353. iteminfo.Amt = westernMedicineCostTotal
  1354. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1355. iteminfo.ClabAmt = westernMedicine_clab_amt
  1356. iteminfo.OthAmt = westernMedicine_other_amt
  1357. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1358. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1359. }
  1360. if chineseTraditionalMedicineCostTotal != 0 {
  1361. iteminfo.MedChrgitm = "11"
  1362. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1363. iteminfo.Amt = westernMedicineCostTotal
  1364. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1365. iteminfo.ClabAmt = westernMedicine_clab_amt
  1366. iteminfo.OthAmt = westernMedicine_other_amt
  1367. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1368. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1369. }
  1370. if otherCostTotal != 0 {
  1371. iteminfo.MedChrgitm = "14"
  1372. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1373. iteminfo.Amt = otherCostTotal
  1374. iteminfo.ClaaSumfee = other_claa_sunmfee
  1375. iteminfo.ClabAmt = other_clab_amt
  1376. iteminfo.OthAmt = other_other_amt
  1377. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1378. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1379. }
  1380. struct4101.IteminfoStruct = iteminfoStructs
  1381. struct4101.Ntly = "中国"
  1382. struct4101.AdmCaty = "A03.06"
  1383. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1384. fmt.Println(result)
  1385. var dat map[string]interface{}
  1386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1387. fmt.Println(dat)
  1388. } else {
  1389. fmt.Println(err)
  1390. }
  1391. userJSONBytes, _ := json.Marshal(dat)
  1392. var res ResultSeventeen
  1393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1394. utils.ErrorLog("解析失败:%v", err)
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1396. return
  1397. }
  1398. if res.Infcode != 0 {
  1399. c.ServeSuccessJSON(map[string]interface{}{
  1400. "failed_code": -10,
  1401. "msg": res.ErrMsg,
  1402. })
  1403. return
  1404. } else {
  1405. order.FaPiaoNumber = zero
  1406. order.FaPiaoCode = last_order.FaPiaoCode
  1407. service.UpdateOrder(order)
  1408. hisFundSettleListResult := &models.HisFundSettleListResult{
  1409. Number: res.Output.SetlListId,
  1410. Status: 1,
  1411. Ctime: time.Now().Unix(),
  1412. Mtime: time.Now().Unix(),
  1413. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1414. IsUpload: 1,
  1415. OrderId: order_id,
  1416. }
  1417. service.CreateUploadRecord(hisFundSettleListResult)
  1418. c.ServeSuccessJSON(map[string]interface{}{
  1419. "msg": "上传成功",
  1420. "result": hisFundSettleListResult,
  1421. })
  1422. return
  1423. }
  1424. }
  1425. func (c *HisApiController) GetSettleListHospital() {
  1426. order_id, _ := c.GetInt64("order_id")
  1427. admin_user_id, _ := c.GetInt64("admin_user_id")
  1428. order, _ := service.GetHisOrderByIDTwo(order_id)
  1429. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1430. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1431. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1432. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1433. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1434. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1435. if order.ID == 0 {
  1436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1437. return
  1438. }
  1439. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1440. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1441. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1442. fmt.Println(count)
  1443. var zero string
  1444. number := count + 1
  1445. if number >= 1000 {
  1446. zero = "0000" + strconv.FormatInt(number, 10)
  1447. } else if number >= 10000 {
  1448. zero = "000" + strconv.FormatInt(number, 10)
  1449. } else if number >= 100000 {
  1450. zero = "00" + strconv.FormatInt(number, 10)
  1451. } else if number >= 1000000 {
  1452. zero = "0" + strconv.FormatInt(number, 10)
  1453. } else {
  1454. zero = strconv.FormatInt(number, 10)
  1455. }
  1456. fmt.Println(zero)
  1457. struct4101 := service.Struct4101{
  1458. PsnNo: order.PsnNo,
  1459. MdtrtId: order.MdtrtId,
  1460. SetlId: order.SetlId,
  1461. PsnName: order.PsnName,
  1462. Gend: order.Gend,
  1463. Brdy: his.Brdy,
  1464. Age: int64(order.Age),
  1465. Naty: order.Naty,
  1466. PatnCertType: "01",
  1467. Certno: order.Certno,
  1468. Prfs: "90",
  1469. ConerName: roles[0].UserName,
  1470. PatnRlts: "99",
  1471. ConerAddr: miConfig.OrgName,
  1472. ConerTel: admin.Mobile,
  1473. HiType: order.Insutype,
  1474. Insuplc: miConfig.InsuplcAdmdvs,
  1475. MaindiagFlag: "1",
  1476. BillCode: last_order.FaPiaoCode,
  1477. BillNo: zero,
  1478. BizSn: order.Number,
  1479. PsnSelfPay: order.PsnPartAmt,
  1480. PsnOwnPay: order.PsnPartAmt,
  1481. AcctPay: order.AcctPay,
  1482. PsnCashpay: order.PsnCashPay,
  1483. HiPaymtd: "1",
  1484. Hsorg: miConfig.InsuplcAdmdvs,
  1485. HsorgOpter: miConfig.InsuplcAdmdvs,
  1486. MedinsFillPsn: curRoles.UserName,
  1487. MedinsFillDept: depart.Name,
  1488. IptMedType: "2",
  1489. AdmTime: his.InHosptialTime,
  1490. AdmEndTime: his.OutHosptialTime,
  1491. }
  1492. struct4101.SetlBegnDate = order.SetlTime
  1493. struct4101.SetlEndDate = order.SetlTime
  1494. var rf []CustomFundPay
  1495. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1496. var tempFunPays []service.CustomStruct
  1497. for _, item := range rf {
  1498. var tempFunPay service.CustomStruct
  1499. tempFunPay.FundPayamt = item.FundPayamt
  1500. tempFunPay.FundPayType = item.FundPayType
  1501. tempFunPays = append(tempFunPays, tempFunPay)
  1502. }
  1503. struct4101.CustomStruct = tempFunPays
  1504. var tempDiaginfos []service.DiaginfoStructTwo
  1505. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1506. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1507. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1508. var config []*models.HisXtDiagnoseConfig
  1509. for _, item := range diagnosis_ids {
  1510. id, _ := strconv.ParseInt(item, 10, 64)
  1511. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1512. config = append(config, &diagnosisConfig)
  1513. }
  1514. for index, item := range config {
  1515. if index == 0 {
  1516. var tempDiaginfo service.DiaginfoStructTwo
  1517. tempDiaginfo.DiagCode = item.CountryCode
  1518. tempDiaginfo.DiagName = item.CountryContentName
  1519. tempDiaginfo.DiagType = "1"
  1520. tempDiaginfo.MaindiagFlag = "1"
  1521. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1522. } else {
  1523. var tempDiaginfo service.DiaginfoStructTwo
  1524. tempDiaginfo.DiagCode = item.CountryCode
  1525. tempDiaginfo.DiagName = item.CountryContentName
  1526. tempDiaginfo.DiagType = "2"
  1527. tempDiaginfo.MaindiagFlag = "0"
  1528. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1529. }
  1530. }
  1531. struct4101.Diseinfo = tempDiaginfos
  1532. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1533. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1534. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1535. tempOpspdiseinfo2.OprnOprtCode = ""
  1536. tempOpspdiseinfo2.OprnOprtName = ""
  1537. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1538. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1539. var iteminfo service.IteminfoStruct
  1540. var bedCostTotal float64 = 0 //床位总费
  1541. var bedCostSelfTotal float64 = 0 //床位自费
  1542. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1543. var operationCostTotal float64 = 0 //手术费
  1544. var operationCostSelfTotal float64 = 0 //手术费
  1545. var operationCostPartSelfTotal float64 = 0 //手术费
  1546. var otherCostTotal float64 = 0 //其他费用
  1547. var otherCostSelfTotal float64 = 0 //其他费用
  1548. var otherCostPartSelfTotal float64 = 0 //其他费用
  1549. var materialCostTotal float64 = 0 //材料费
  1550. var materialCostSelfTotal float64 = 0 //材料费
  1551. var materialCostPartSelfTotal float64 = 0 //材料费
  1552. var westernMedicineCostTotal float64 = 0 //西药费
  1553. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1554. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1555. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1556. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1557. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1558. var checkCostTotal float64 = 0 //检查费
  1559. var checkCostSelfTotal float64 = 0 //检查费
  1560. var checkCostPartSelfTotal float64 = 0 //检查费
  1561. var laboratoryCostTotal float64 = 0 //化验费
  1562. var laboratoryCostSelfTotal float64 = 0 //化验费
  1563. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1564. var treatCostTotal float64 = 0 //治疗费用
  1565. var treatCostSelfTotal float64 = 0 //治疗费用
  1566. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1567. decimal.DivisionPrecision = 2
  1568. var bed_fulamt_ownpay_amt float64 = 0
  1569. var operation_fulamt_ownpay_amt float64 = 0
  1570. var other_fulamt_ownpay_amt float64 = 0
  1571. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1572. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1573. var check_fulamt_ownpay_amt float64 = 0
  1574. var material_fulamt_ownpay_amt float64 = 0
  1575. var laboratory_fulamt_ownpay_amt float64 = 0
  1576. var treat_fulamt_ownpay_amt float64 = 0
  1577. var bed_claa_sunmfee float64 = 0
  1578. var bed_clab_amt float64 = 0
  1579. var bed_other_amt float64 = 0
  1580. var operation_claa_sunmfee float64 = 0
  1581. var operation_clab_amt float64 = 0
  1582. var operation_other_amt float64 = 0
  1583. var other_claa_sunmfee float64 = 0
  1584. var other_clab_amt float64 = 0
  1585. var other_other_amt float64 = 0
  1586. var westernMedicine_claa_sunmfee float64 = 0
  1587. var westernMedicine_clab_amt float64 = 0
  1588. var westernMedicine_other_amt float64 = 0
  1589. var chineseTraditional_claa_sunmfee float64 = 0
  1590. var chineseTraditional_clab_amt float64 = 0
  1591. var chineseTraditional_other_amt float64 = 0
  1592. var check_claa_sunmfee float64 = 0
  1593. var check_clab_amt float64 = 0
  1594. var check_other_amt float64 = 0
  1595. var material_claa_sunmfee float64 = 0
  1596. var material_clab_amt float64 = 0
  1597. var material_other_amt float64 = 0
  1598. var laboratory_claa_sunmfee float64 = 0
  1599. var laboratory_clab_amt float64 = 0
  1600. var laboratory_other_amt float64 = 0
  1601. var treat_claa_sunmfee float64 = 0
  1602. var treat_clab_amt float64 = 0
  1603. var treat_other_amt float64 = 0
  1604. for _, item := range order.HisOrderInfo {
  1605. if item.MedChrgitmType == "01" { //床位费
  1606. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1607. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1608. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1609. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1610. if item.ChrgitmLv == "1" {
  1611. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1612. }
  1613. if item.ChrgitmLv == "2" {
  1614. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1615. }
  1616. if item.ChrgitmLv == "3" {
  1617. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1618. }
  1619. }
  1620. if item.MedChrgitmType == "03" { //检查费
  1621. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1622. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1623. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1624. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1625. if item.ChrgitmLv == "1" {
  1626. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1627. }
  1628. if item.ChrgitmLv == "2" {
  1629. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1630. }
  1631. if item.ChrgitmLv == "3" {
  1632. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1633. }
  1634. }
  1635. if item.MedChrgitmType == "04" { //化验费
  1636. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1637. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1638. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1639. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1640. if item.ChrgitmLv == "1" {
  1641. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1642. }
  1643. if item.ChrgitmLv == "2" {
  1644. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1645. }
  1646. if item.ChrgitmLv == "3" {
  1647. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1648. }
  1649. }
  1650. if item.MedChrgitmType == "05" { //治疗费
  1651. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1652. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1653. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1654. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1655. if item.ChrgitmLv == "1" {
  1656. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1657. }
  1658. if item.ChrgitmLv == "2" {
  1659. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1660. }
  1661. if item.ChrgitmLv == "3" {
  1662. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1663. }
  1664. }
  1665. if item.MedChrgitmType == "06" { //手术费
  1666. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1667. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1668. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1669. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1670. if item.ChrgitmLv == "1" {
  1671. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1672. }
  1673. if item.ChrgitmLv == "2" {
  1674. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1675. }
  1676. if item.ChrgitmLv == "3" {
  1677. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1678. }
  1679. }
  1680. if item.MedChrgitmType == "08" { //材料费
  1681. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1682. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1683. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1684. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1685. if item.ChrgitmLv == "1" {
  1686. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1687. }
  1688. if item.ChrgitmLv == "2" {
  1689. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1690. }
  1691. if item.ChrgitmLv == "3" {
  1692. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1693. }
  1694. }
  1695. if item.MedChrgitmType == "09" { //西药费
  1696. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1697. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1698. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1699. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1700. if item.ChrgitmLv == "1" {
  1701. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1702. }
  1703. if item.ChrgitmLv == "2" {
  1704. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1705. }
  1706. if item.ChrgitmLv == "3" {
  1707. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1708. }
  1709. }
  1710. if item.MedChrgitmType == "11" { //中成费
  1711. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1712. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1713. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1714. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1715. if item.ChrgitmLv == "1" {
  1716. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1717. }
  1718. if item.ChrgitmLv == "2" {
  1719. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1720. }
  1721. if item.ChrgitmLv == "3" {
  1722. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1723. }
  1724. }
  1725. if item.MedChrgitmType == "14" { //其他费
  1726. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1727. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1728. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1729. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1730. if item.ChrgitmLv == "1" {
  1731. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1732. }
  1733. if item.ChrgitmLv == "2" {
  1734. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1735. }
  1736. if item.ChrgitmLv == "3" {
  1737. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1738. }
  1739. }
  1740. }
  1741. var iteminfoStructs []service.IteminfoStruct
  1742. if bedCostTotal != 0 {
  1743. iteminfo.MedChrgitm = "01"
  1744. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1745. iteminfo.Amt = bedCostTotal
  1746. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1747. iteminfo.ClabAmt = bed_clab_amt
  1748. iteminfo.OthAmt = bed_other_amt
  1749. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1750. }
  1751. if checkCostTotal != 0 {
  1752. iteminfo.MedChrgitm = "03"
  1753. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1754. iteminfo.Amt = checkCostTotal
  1755. iteminfo.ClaaSumfee = check_claa_sunmfee
  1756. iteminfo.ClabAmt = check_clab_amt
  1757. iteminfo.OthAmt = check_other_amt
  1758. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1759. }
  1760. if laboratoryCostTotal != 0 {
  1761. iteminfo.MedChrgitm = "04"
  1762. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1763. iteminfo.Amt = laboratoryCostTotal
  1764. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1765. iteminfo.ClabAmt = laboratory_clab_amt
  1766. iteminfo.OthAmt = laboratory_other_amt
  1767. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1768. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1769. }
  1770. if treatCostTotal != 0 {
  1771. iteminfo.MedChrgitm = "05"
  1772. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1773. iteminfo.Amt = treatCostTotal
  1774. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1775. iteminfo.ClabAmt = treat_clab_amt
  1776. iteminfo.OthAmt = treat_other_amt
  1777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1778. //(struct4101.IteminfoStruct, iteminfo)
  1779. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1780. }
  1781. if operationCostTotal != 0 {
  1782. iteminfo.MedChrgitm = "06"
  1783. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1784. iteminfo.Amt = operationCostTotal
  1785. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1786. iteminfo.ClabAmt = operation_clab_amt
  1787. iteminfo.OthAmt = operation_other_amt
  1788. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1789. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1790. }
  1791. if materialCostTotal != 0 {
  1792. iteminfo.MedChrgitm = "08"
  1793. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1794. iteminfo.Amt = materialCostTotal
  1795. iteminfo.ClaaSumfee = material_claa_sunmfee
  1796. iteminfo.ClabAmt = material_clab_amt
  1797. iteminfo.OthAmt = material_other_amt
  1798. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1799. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1800. }
  1801. if westernMedicineCostTotal != 0 {
  1802. iteminfo.MedChrgitm = "09"
  1803. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1804. iteminfo.Amt = westernMedicineCostTotal
  1805. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1806. iteminfo.ClabAmt = westernMedicine_clab_amt
  1807. iteminfo.OthAmt = westernMedicine_other_amt
  1808. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1809. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1810. }
  1811. if chineseTraditionalMedicineCostTotal != 0 {
  1812. iteminfo.MedChrgitm = "11"
  1813. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1814. iteminfo.Amt = westernMedicineCostTotal
  1815. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1816. iteminfo.ClabAmt = westernMedicine_clab_amt
  1817. iteminfo.OthAmt = westernMedicine_other_amt
  1818. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1819. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1820. }
  1821. if otherCostTotal != 0 {
  1822. iteminfo.MedChrgitm = "14"
  1823. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1824. iteminfo.Amt = otherCostTotal
  1825. iteminfo.ClaaSumfee = other_claa_sunmfee
  1826. iteminfo.ClabAmt = other_clab_amt
  1827. iteminfo.OthAmt = other_other_amt
  1828. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1829. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1830. }
  1831. struct4101.IteminfoStruct = iteminfoStructs
  1832. struct4101.Ntly = "中国"
  1833. struct4101.AdmCaty = "A03.06"
  1834. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1835. fmt.Println(result)
  1836. var dat map[string]interface{}
  1837. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1838. fmt.Println(dat)
  1839. } else {
  1840. fmt.Println(err)
  1841. }
  1842. userJSONBytes, _ := json.Marshal(dat)
  1843. var res ResultSeventeen
  1844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1845. utils.ErrorLog("解析失败:%v", err)
  1846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1847. return
  1848. }
  1849. if res.Infcode != 0 {
  1850. c.ServeSuccessJSON(map[string]interface{}{
  1851. "failed_code": -10,
  1852. "msg": res.ErrMsg,
  1853. })
  1854. return
  1855. } else {
  1856. order.FaPiaoNumber = zero
  1857. order.FaPiaoCode = last_order.FaPiaoCode
  1858. service.UpdateOrder(order)
  1859. hisFundSettleListResult := &models.HisFundSettleListResult{
  1860. Number: res.Output.SetlListId,
  1861. Status: 1,
  1862. Ctime: time.Now().Unix(),
  1863. Mtime: time.Now().Unix(),
  1864. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1865. IsUpload: 1,
  1866. OrderId: order_id,
  1867. }
  1868. service.CreateUploadRecord(hisFundSettleListResult)
  1869. c.ServeSuccessJSON(map[string]interface{}{
  1870. "msg": "上传成功",
  1871. "result": hisFundSettleListResult,
  1872. })
  1873. return
  1874. }
  1875. }
  1876. func (c *HisApiController) GetBatchSettleList() {
  1877. orders, _ := service.GetAllHisOrder(10106)
  1878. for _, item := range orders {
  1879. order_id := item.ID
  1880. order, _ := service.GetHisOrderByIDTwo(order_id)
  1881. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1882. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1883. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1884. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1885. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1886. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1887. if order.ID == 0 {
  1888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1889. return
  1890. }
  1891. if his.BalanceAccountsType == 2 {
  1892. continue
  1893. }
  1894. struct4101 := service.Struct4101{
  1895. PsnNo: order.PsnNo,
  1896. MdtrtId: order.MdtrtId,
  1897. SetlId: order.SetlId,
  1898. PsnName: order.PsnName,
  1899. Gend: order.Gend,
  1900. Brdy: his.Brdy,
  1901. Age: his.Age,
  1902. Naty: order.Naty,
  1903. PatnCertType: "01",
  1904. Certno: order.Certno,
  1905. Prfs: "90",
  1906. ConerName: roles[0].UserName,
  1907. PatnRlts: "99",
  1908. ConerAddr: miConfig.OrgName,
  1909. ConerTel: admin.Mobile,
  1910. HiType: order.Insutype,
  1911. Insuplc: his.InsuplcAdmdvs,
  1912. MaindiagFlag: "1",
  1913. BillCode: order.FaPiaoCode,
  1914. BillNo: order.FaPiaoNumber,
  1915. BizSn: order.Number,
  1916. PsnSelfPay: order.PsnPartAmt,
  1917. PsnOwnPay: order.PsnPartAmt,
  1918. AcctPay: order.AcctPay,
  1919. PsnCashpay: order.PsnCashPay,
  1920. HiPaymtd: "1",
  1921. Hsorg: his.InsuplcAdmdvs,
  1922. HsorgOpter: his.InsuplcAdmdvs,
  1923. MedinsFillPsn: curRoles.UserName,
  1924. MedinsFillDept: depart.Name,
  1925. IptMedType: "2",
  1926. }
  1927. struct4101.SetlBegnDate = order.SetlTime
  1928. struct4101.SetlEndDate = order.SetlTime
  1929. //if order.SettleType == 1 {
  1930. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1931. // dateStr := t.Format("2006-01-02")
  1932. // struct4101.SetlBegnDate = dateStr
  1933. // struct4101.SetlEndDate = dateStr
  1934. //} else {
  1935. // t := time.Unix(int64(order.SettleStartTime), 0)
  1936. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1937. // dateStartStr := t.Format("2006-01-02")
  1938. // dateEndStr := t2.Format("2006-01-02")
  1939. // struct4101.SetlBegnDate = dateStartStr
  1940. // struct4101.SetlEndDate = dateEndStr
  1941. //}
  1942. var rf []CustomFundPay
  1943. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1944. var tempFunPays []service.CustomStruct
  1945. var tempFunPay610100 service.CustomStruct
  1946. for _, item := range rf {
  1947. if item.FundPayType == "610100" {
  1948. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1949. tempFunPay610100.FundPayType = item.FundPayType
  1950. } else {
  1951. var tempFunPay service.CustomStruct
  1952. tempFunPay.FundPayamt = item.FundPayamt
  1953. tempFunPay.FundPayType = item.FundPayType
  1954. tempFunPays = append(tempFunPays, tempFunPay)
  1955. }
  1956. }
  1957. tempFunPays = append(tempFunPays, tempFunPay610100)
  1958. struct4101.CustomStruct = tempFunPays
  1959. var tempDiaginfos []service.DiaginfoStructTwo
  1960. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1961. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1962. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1963. var config []*models.HisXtDiagnoseConfig
  1964. for _, item := range diagnosis_ids {
  1965. id, _ := strconv.ParseInt(item, 10, 64)
  1966. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1967. config = append(config, &diagnosisConfig)
  1968. }
  1969. for index, item := range config {
  1970. if index == 0 {
  1971. var tempDiaginfo service.DiaginfoStructTwo
  1972. tempDiaginfo.DiagCode = item.CountryCode
  1973. tempDiaginfo.DiagName = item.CountryContentName
  1974. tempDiaginfo.DiagType = "1"
  1975. tempDiaginfo.MaindiagFlag = "1"
  1976. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1977. } else {
  1978. var tempDiaginfo service.DiaginfoStructTwo
  1979. tempDiaginfo.DiagCode = item.CountryCode
  1980. tempDiaginfo.DiagName = item.CountryContentName
  1981. tempDiaginfo.DiagType = "2"
  1982. tempDiaginfo.MaindiagFlag = "0"
  1983. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1984. }
  1985. }
  1986. struct4101.Diseinfo = tempDiaginfos
  1987. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1988. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1989. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1990. tempOpspdiseinfo2.OprnOprtCode = ""
  1991. tempOpspdiseinfo2.OprnOprtName = ""
  1992. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1993. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1994. var iteminfo service.IteminfoStruct
  1995. var bedCostTotal float64 = 0 //床位总费
  1996. var bedCostSelfTotal float64 = 0 //床位自费
  1997. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1998. var examineCostTotal float64 = 0 //诊查总费
  1999. var examineCostSelfTotal float64 = 0 //诊查自费
  2000. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2001. var nursingCostTotal float64 = 0 //护理总费
  2002. var nursingCostSelfTotal float64 = 0 //护理自费
  2003. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2004. var chineseMedicineCostTotal float64 = 0 //中成药
  2005. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2006. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2007. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2008. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2009. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2010. var registerCostTotal float64 = 0 //一般诊疗费
  2011. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2012. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2013. var operationCostTotal float64 = 0 //手术费
  2014. var operationCostSelfTotal float64 = 0 //手术费
  2015. var operationCostPartSelfTotal float64 = 0 //手术费
  2016. var otherCostTotal float64 = 0 //其他费用
  2017. var otherCostSelfTotal float64 = 0 //其他费用
  2018. var otherCostPartSelfTotal float64 = 0 //其他费用
  2019. var materialCostTotal float64 = 0 //材料费
  2020. var materialCostSelfTotal float64 = 0 //材料费
  2021. var materialCostPartSelfTotal float64 = 0 //材料费
  2022. var westernMedicineCostTotal float64 = 0 //西药费
  2023. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2024. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2025. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2026. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2027. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2028. var checkCostTotal float64 = 0 //检查费
  2029. var checkCostSelfTotal float64 = 0 //检查费
  2030. var checkCostPartSelfTotal float64 = 0 //检查费
  2031. var laboratoryCostTotal float64 = 0 //化验费
  2032. var laboratoryCostSelfTotal float64 = 0 //化验费
  2033. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2034. var treatCostTotal float64 = 0 //治疗费用
  2035. var treatCostSelfTotal float64 = 0 //治疗费用
  2036. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2037. decimal.DivisionPrecision = 2
  2038. var bed_fulamt_ownpay_amt float64 = 0
  2039. var examine_fulamt_ownpay_amt float64 = 0
  2040. var nursing_fulamt_ownpay_amt float64 = 0
  2041. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2042. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2043. var register_fulamt_ownpay_amt float64 = 0
  2044. var operation_fulamt_ownpay_amt float64 = 0
  2045. var other_fulamt_ownpay_amt float64 = 0
  2046. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2047. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2048. var check_fulamt_ownpay_amt float64 = 0
  2049. var material_fulamt_ownpay_amt float64 = 0
  2050. var laboratory_fulamt_ownpay_amt float64 = 0
  2051. var treat_fulamt_ownpay_amt float64 = 0
  2052. var bed_claa_sunmfee float64 = 0
  2053. var bed_clab_amt float64 = 0
  2054. var bed_other_amt float64 = 0
  2055. var examine_claa_sunmfee float64 = 0
  2056. var examine_clab_amt float64 = 0
  2057. var examine_other_amt float64 = 0
  2058. var nursing_claa_sunmfee float64 = 0
  2059. var nursing_clab_amt float64 = 0
  2060. var nursing_other_amt float64 = 0
  2061. var chinese_medicine_claa_sunmfee float64 = 0
  2062. var chinese_medicine_clab_amt float64 = 0
  2063. var chinese_medicine_other_amt float64 = 0
  2064. var commonly_treatment_claa_sunmfee float64 = 0
  2065. var commonly_treatment_clab_amt float64 = 0
  2066. var commonly_treatment_other_amt float64 = 0
  2067. var operation_claa_sunmfee float64 = 0
  2068. var operation_clab_amt float64 = 0
  2069. var operation_other_amt float64 = 0
  2070. var other_claa_sunmfee float64 = 0
  2071. var other_clab_amt float64 = 0
  2072. var other_other_amt float64 = 0
  2073. var westernMedicine_claa_sunmfee float64 = 0
  2074. var westernMedicine_clab_amt float64 = 0
  2075. var westernMedicine_other_amt float64 = 0
  2076. var chineseTraditional_claa_sunmfee float64 = 0
  2077. var chineseTraditional_clab_amt float64 = 0
  2078. var chineseTraditional_other_amt float64 = 0
  2079. var check_claa_sunmfee float64 = 0
  2080. var check_clab_amt float64 = 0
  2081. var check_other_amt float64 = 0
  2082. var material_claa_sunmfee float64 = 0
  2083. var material_clab_amt float64 = 0
  2084. var material_other_amt float64 = 0
  2085. var laboratory_claa_sunmfee float64 = 0
  2086. var laboratory_clab_amt float64 = 0
  2087. var laboratory_other_amt float64 = 0
  2088. var treat_claa_sunmfee float64 = 0
  2089. var treat_clab_amt float64 = 0
  2090. var treat_other_amt float64 = 0
  2091. var register_claa_sunmfee float64 = 0
  2092. var register_clab_amt float64 = 0
  2093. var register_other_amt float64 = 0
  2094. for _, item := range order.HisOrderInfo {
  2095. if item.MedChrgitmType == "01" { //床位费
  2096. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2097. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2098. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2099. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2100. if item.ChrgitmLv == "1" {
  2101. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2102. }
  2103. if item.ChrgitmLv == "2" {
  2104. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2105. }
  2106. if item.ChrgitmLv == "3" {
  2107. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2108. }
  2109. }
  2110. if item.MedChrgitmType == "02" { //诊查
  2111. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2112. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2113. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2114. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2115. if item.ChrgitmLv == "1" {
  2116. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2117. }
  2118. if item.ChrgitmLv == "2" {
  2119. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2120. }
  2121. if item.ChrgitmLv == "3" {
  2122. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2123. }
  2124. }
  2125. if item.MedChrgitmType == "03" { //检查费
  2126. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2127. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2128. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2129. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2130. if item.ChrgitmLv == "1" {
  2131. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2132. }
  2133. if item.ChrgitmLv == "2" {
  2134. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2135. }
  2136. if item.ChrgitmLv == "3" {
  2137. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2138. }
  2139. }
  2140. if item.MedChrgitmType == "04" { //化验费
  2141. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2142. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2143. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2144. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2145. if item.ChrgitmLv == "1" {
  2146. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2147. }
  2148. if item.ChrgitmLv == "2" {
  2149. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2150. }
  2151. if item.ChrgitmLv == "3" {
  2152. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2153. }
  2154. }
  2155. if item.MedChrgitmType == "05" { //治疗费
  2156. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2157. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2158. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2159. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2160. if item.ChrgitmLv == "1" {
  2161. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2162. }
  2163. if item.ChrgitmLv == "2" {
  2164. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2165. }
  2166. if item.ChrgitmLv == "3" {
  2167. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2168. }
  2169. }
  2170. if item.MedChrgitmType == "06" { //手术费
  2171. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2172. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2173. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2174. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2175. if item.ChrgitmLv == "1" {
  2176. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2177. }
  2178. if item.ChrgitmLv == "2" {
  2179. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2180. }
  2181. if item.ChrgitmLv == "3" {
  2182. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2183. }
  2184. }
  2185. if item.MedChrgitmType == "07" { //手术费
  2186. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2187. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2188. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2189. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2190. if item.ChrgitmLv == "1" {
  2191. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2192. }
  2193. if item.ChrgitmLv == "2" {
  2194. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2195. }
  2196. if item.ChrgitmLv == "3" {
  2197. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2198. }
  2199. }
  2200. if item.MedChrgitmType == "08" { //材料费
  2201. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2202. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2203. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2204. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2205. if item.ChrgitmLv == "1" {
  2206. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2207. }
  2208. if item.ChrgitmLv == "2" {
  2209. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2210. }
  2211. if item.ChrgitmLv == "3" {
  2212. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2213. }
  2214. }
  2215. if item.MedChrgitmType == "09" { //西药费
  2216. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2217. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2218. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2219. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2220. if item.ChrgitmLv == "1" {
  2221. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2222. }
  2223. if item.ChrgitmLv == "2" {
  2224. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2225. }
  2226. if item.ChrgitmLv == "3" {
  2227. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2228. }
  2229. }
  2230. if item.MedChrgitmType == "10" { //中药饮片
  2231. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2232. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2233. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2234. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2235. if item.ChrgitmLv == "1" {
  2236. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2237. }
  2238. if item.ChrgitmLv == "2" {
  2239. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2240. }
  2241. if item.ChrgitmLv == "3" {
  2242. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2243. }
  2244. }
  2245. if item.MedChrgitmType == "11" { //中成费
  2246. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2247. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2248. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2249. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2250. if item.ChrgitmLv == "1" {
  2251. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2252. }
  2253. if item.ChrgitmLv == "2" {
  2254. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2255. }
  2256. if item.ChrgitmLv == "3" {
  2257. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2258. }
  2259. }
  2260. if item.MedChrgitmType == "12" { //中成费
  2261. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2262. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2263. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2264. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2265. if item.ChrgitmLv == "1" {
  2266. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2267. }
  2268. if item.ChrgitmLv == "2" {
  2269. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2270. }
  2271. if item.ChrgitmLv == "3" {
  2272. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2273. }
  2274. }
  2275. if item.MedChrgitmType == "13" { //中成费
  2276. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2277. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2278. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2279. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2280. if item.ChrgitmLv == "1" {
  2281. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2282. }
  2283. if item.ChrgitmLv == "2" {
  2284. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2285. }
  2286. if item.ChrgitmLv == "3" {
  2287. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2288. }
  2289. }
  2290. if item.MedChrgitmType == "14" { //其他费
  2291. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2292. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2293. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2294. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2295. if item.ChrgitmLv == "1" {
  2296. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2297. }
  2298. if item.ChrgitmLv == "2" {
  2299. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2300. }
  2301. if item.ChrgitmLv == "3" {
  2302. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2303. }
  2304. }
  2305. }
  2306. var iteminfoStructs []service.IteminfoStruct
  2307. if bedCostTotal != 0 {
  2308. iteminfo.MedChrgitm = "01"
  2309. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2310. iteminfo.Amt = bedCostTotal
  2311. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2312. iteminfo.ClabAmt = bed_clab_amt
  2313. iteminfo.OthAmt = bed_other_amt
  2314. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2315. }
  2316. if examineCostTotal != 0 {
  2317. iteminfo.MedChrgitm = "02"
  2318. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2319. iteminfo.Amt = examineCostTotal
  2320. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2321. iteminfo.ClabAmt = examine_clab_amt
  2322. iteminfo.OthAmt = examine_other_amt
  2323. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2324. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2325. }
  2326. if checkCostTotal != 0 {
  2327. iteminfo.MedChrgitm = "03"
  2328. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2329. iteminfo.Amt = checkCostTotal
  2330. iteminfo.ClaaSumfee = check_claa_sunmfee
  2331. iteminfo.ClabAmt = check_clab_amt
  2332. iteminfo.OthAmt = check_other_amt
  2333. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2334. }
  2335. if laboratoryCostTotal != 0 {
  2336. iteminfo.MedChrgitm = "04"
  2337. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2338. iteminfo.Amt = laboratoryCostTotal
  2339. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2340. iteminfo.ClabAmt = laboratory_clab_amt
  2341. iteminfo.OthAmt = laboratory_other_amt
  2342. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2343. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2344. }
  2345. if treatCostTotal != 0 {
  2346. iteminfo.MedChrgitm = "05"
  2347. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2348. iteminfo.Amt = treatCostTotal
  2349. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2350. iteminfo.ClabAmt = treat_clab_amt
  2351. iteminfo.OthAmt = treat_other_amt
  2352. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2353. //(struct4101.IteminfoStruct, iteminfo)
  2354. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2355. }
  2356. if operationCostTotal != 0 {
  2357. iteminfo.MedChrgitm = "06"
  2358. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2359. iteminfo.Amt = operationCostTotal
  2360. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2361. iteminfo.ClabAmt = operation_clab_amt
  2362. iteminfo.OthAmt = operation_other_amt
  2363. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2364. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2365. }
  2366. if nursingCostTotal != 0 {
  2367. iteminfo.MedChrgitm = "07"
  2368. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2369. iteminfo.Amt = nursingCostTotal
  2370. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2371. iteminfo.ClabAmt = nursing_clab_amt
  2372. iteminfo.OthAmt = nursing_other_amt
  2373. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2374. }
  2375. if materialCostTotal != 0 {
  2376. iteminfo.MedChrgitm = "08"
  2377. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2378. iteminfo.Amt = materialCostTotal
  2379. iteminfo.ClaaSumfee = material_claa_sunmfee
  2380. iteminfo.ClabAmt = material_clab_amt
  2381. iteminfo.OthAmt = material_other_amt
  2382. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2383. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2384. }
  2385. if westernMedicineCostTotal != 0 {
  2386. iteminfo.MedChrgitm = "09"
  2387. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2388. iteminfo.Amt = westernMedicineCostTotal
  2389. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2390. iteminfo.ClabAmt = westernMedicine_clab_amt
  2391. iteminfo.OthAmt = westernMedicine_other_amt
  2392. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2393. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2394. }
  2395. if chineseMedicineCostTotal != 0 {
  2396. iteminfo.MedChrgitm = "10"
  2397. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2398. iteminfo.Amt = chineseMedicineCostTotal
  2399. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2400. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2401. iteminfo.OthAmt = chinese_medicine_other_amt
  2402. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2403. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2404. }
  2405. if chineseTraditionalMedicineCostTotal != 0 {
  2406. iteminfo.MedChrgitm = "11"
  2407. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2408. iteminfo.Amt = westernMedicineCostTotal
  2409. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2410. iteminfo.ClabAmt = westernMedicine_clab_amt
  2411. iteminfo.OthAmt = westernMedicine_other_amt
  2412. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2413. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2414. }
  2415. if commonlyTreatmentCostTotal != 0 {
  2416. iteminfo.MedChrgitm = "12"
  2417. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2418. iteminfo.Amt = commonlyTreatmentCostTotal
  2419. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2420. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2421. iteminfo.OthAmt = commonly_treatment_other_amt
  2422. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2423. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2424. }
  2425. if registerCostTotal != 0 {
  2426. iteminfo.MedChrgitm = "13"
  2427. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2428. iteminfo.Amt = registerCostTotal
  2429. iteminfo.ClaaSumfee = register_claa_sunmfee
  2430. iteminfo.ClabAmt = register_clab_amt
  2431. iteminfo.OthAmt = register_other_amt
  2432. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2433. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2434. }
  2435. if otherCostTotal != 0 {
  2436. iteminfo.MedChrgitm = "14"
  2437. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2438. iteminfo.Amt = otherCostTotal
  2439. iteminfo.ClaaSumfee = other_claa_sunmfee
  2440. iteminfo.ClabAmt = other_clab_amt
  2441. iteminfo.OthAmt = other_other_amt
  2442. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2443. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2444. }
  2445. struct4101.IteminfoStruct = iteminfoStructs
  2446. struct4101.Ntly = "中国"
  2447. struct4101.AdmCaty = "A03.06"
  2448. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2449. fmt.Println(result)
  2450. var dat map[string]interface{}
  2451. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2452. fmt.Println(dat)
  2453. } else {
  2454. fmt.Println(err)
  2455. }
  2456. userJSONBytes, _ := json.Marshal(dat)
  2457. var res ResultSeventeen
  2458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2459. utils.ErrorLog("解析失败:%v", err)
  2460. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2461. adminUser := c.GetAdminUserInfo()
  2462. errlog := &models.HisOrderError{
  2463. UserOrgId: adminUser.CurrentOrgId,
  2464. Ctime: time.Now().Unix(),
  2465. Mtime: time.Now().Unix(),
  2466. ErrMsg: res.ErrMsg + "解析失败",
  2467. Status: 1,
  2468. PatientId: order_id,
  2469. Stage: 10106,
  2470. }
  2471. service.CreateErrMsgLog(errlog)
  2472. continue
  2473. }
  2474. if res.Infcode != 0 {
  2475. adminUser := c.GetAdminUserInfo()
  2476. errlog := &models.HisOrderError{
  2477. UserOrgId: adminUser.CurrentOrgId,
  2478. Ctime: time.Now().Unix(),
  2479. Mtime: time.Now().Unix(),
  2480. ErrMsg: res.ErrMsg,
  2481. Status: 1,
  2482. PatientId: order_id,
  2483. Stage: 10106,
  2484. }
  2485. service.CreateErrMsgLog(errlog)
  2486. continue
  2487. } else {
  2488. hisFundSettleListResult := &models.HisFundSettleListResult{
  2489. Number: res.Output.SetlListId,
  2490. Status: 1,
  2491. Ctime: time.Now().Unix(),
  2492. Mtime: time.Now().Unix(),
  2493. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2494. IsUpload: 1,
  2495. OrderId: order_id,
  2496. }
  2497. service.CreateUploadRecord(hisFundSettleListResult)
  2498. continue
  2499. }
  2500. }
  2501. }
  2502. func (c *HisApiController) GetOrgInfo() {
  2503. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2504. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2505. }
  2506. func (c *HisApiController) GetHisPatientInfo() {
  2507. medical_insurance_card := c.GetString("medical_insurance_card")
  2508. id_card_type, _ := c.GetInt64("id_card_type")
  2509. id_card := c.GetString("id_card")
  2510. adminInfo := c.GetAdminUserInfo()
  2511. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2512. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2513. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2514. IdCardNo := ""
  2515. if id_card_type == 1 {
  2516. IdCardNo = medical_insurance_card
  2517. } else if id_card_type == 2 {
  2518. IdCardNo = id_card
  2519. }
  2520. if config.IsOpen == 1 {
  2521. 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
  2522. resp, requestErr := http.Get(api)
  2523. if requestErr != nil {
  2524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2525. return
  2526. }
  2527. defer resp.Body.Close()
  2528. body, ioErr := ioutil.ReadAll(resp.Body)
  2529. if ioErr != nil {
  2530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2532. return
  2533. }
  2534. var respJSON map[string]interface{}
  2535. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2538. return
  2539. }
  2540. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2541. userJSONBytes, _ := json.Marshal(userJSON)
  2542. var res ResultTwo
  2543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2544. utils.ErrorLog("解析失败:%v", err)
  2545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2546. return
  2547. }
  2548. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2549. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2550. infoStr := string(Iinfos)
  2551. idetinfoStr := string(Idetinfos)
  2552. if res.Infcode == 0 {
  2553. his := models.VMHisPatient{
  2554. Status: 1,
  2555. Ctime: time.Now().Unix(),
  2556. Mtime: time.Now().Unix(),
  2557. PsnNo: res.Output.Baseinfo.PsnNo,
  2558. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2559. Certno: res.Output.Baseinfo.Certno,
  2560. PsnName: res.Output.Baseinfo.PsnName,
  2561. Gend: res.Output.Baseinfo.Gend,
  2562. Naty: res.Output.Baseinfo.Naty,
  2563. Brdy: res.Output.Baseinfo.Brdy,
  2564. Age: res.Output.Baseinfo.Age,
  2565. Iinfo: infoStr,
  2566. Idetinfo: idetinfoStr,
  2567. UserOrgId: adminInfo.CurrentOrgId,
  2568. IsReturn: 1,
  2569. IdCardType: id_card_type,
  2570. }
  2571. c.ServeSuccessJSON(map[string]interface{}{
  2572. "info": his,
  2573. })
  2574. } else {
  2575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2576. return
  2577. }
  2578. }
  2579. }
  2580. //func GetBasBaseInfo() (jsonStr string, err error) {
  2581. //
  2582. // handle := syscall.NewLazyDLL("SSCard.dll")
  2583. // add := handle.NewProc("ReadCardBas")
  2584. // str := make([]byte, 1024)
  2585. // str1 := make([]byte, 1024)
  2586. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2587. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2588. //
  2589. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2590. //
  2591. // fmt.Println("> Add(4,5)的结果为:", ret)
  2592. // handle.Release()
  2593. //
  2594. // return "", nil
  2595. //
  2596. //}
  2597. //func GetQRBaseInfo() (jsonStr string, err error) {
  2598. // handle := syscall.LoadDLL("SSCard.dll")
  2599. // ReadCardBas := handle.FindProc("GetQRBase")
  2600. //
  2601. // str := make([]byte, 256)
  2602. // str1 := make([]byte, 256)
  2603. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2604. //
  2605. // fmt.Println(string(str))
  2606. // fmt.Println(r)
  2607. // return string(str), nil
  2608. //}
  2609. //func CardInit() int {
  2610. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2611. // add := DllTestDef.MustFindProc("Init")
  2612. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2613. // if err != nil {
  2614. // fmt.Println("SSCard的运算结果为:", ret)
  2615. // }
  2616. // result := int(ret)
  2617. // return result
  2618. //}
  2619. //func CardInit() int {
  2620. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2621. // if err != nil {
  2622. // fmt.Println("SSCard的运算结果为:", ret)
  2623. // }
  2624. // fmt.Println(err)
  2625. // result := int(ret)
  2626. // return result
  2627. //}
  2628. func IntPtr(n int) uintptr {
  2629. return uintptr(n)
  2630. }
  2631. func StrPtr(s string) uintptr {
  2632. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2633. }
  2634. type Result2001 struct {
  2635. Cainfo interface{} `json:"cainfo"`
  2636. ErrMsg string `json:"err_msg"`
  2637. InfRefmsgid string `json:"inf_refmsgid"`
  2638. Infcode int64 `json:"infcode"`
  2639. Output struct {
  2640. Trtinfo struct {
  2641. PsnNo string `json:"psn_no"`
  2642. TrtChkType string `json:"trt_chk_type"`
  2643. FundPayType string `json:"fund_pay_type"`
  2644. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2645. Begndate string `json:"begndate"`
  2646. Enddate string `json:"enddate"`
  2647. TrtChkRslt string `json:"trt_chk_rslt"`
  2648. } `json:"trtinfo"`
  2649. } `json:"output"`
  2650. RefmsgTime string `json:"refmsg_time"`
  2651. RespondTime string `json:"respond_time"`
  2652. Signtype interface{} `json:"signtype"`
  2653. WarnMsg interface{} `json:"warn_msg"`
  2654. }
  2655. type Result2001Org10265 struct {
  2656. Cainfo interface{} `json:"cainfo"`
  2657. ErrMsg string `json:"err_msg"`
  2658. InfRefmsgid string `json:"inf_refmsgid"`
  2659. Infcode string `json:"infcode"`
  2660. Output struct {
  2661. Trtinfo struct {
  2662. PsnNo string `json:"psn_no"`
  2663. TrtChkType string `json:"trt_chk_type"`
  2664. FundPayType string `json:"fund_pay_type"`
  2665. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2666. Begndate string `json:"begndate"`
  2667. Enddate string `json:"enddate"`
  2668. TrtChkRslt string `json:"trt_chk_rslt"`
  2669. } `json:"trtinfo"`
  2670. } `json:"output"`
  2671. RefmsgTime string `json:"refmsg_time"`
  2672. RespondTime string `json:"respond_time"`
  2673. Signtype interface{} `json:"signtype"`
  2674. WarnMsg interface{} `json:"warn_msg"`
  2675. }
  2676. type ResultTwo struct {
  2677. ErrMsg string `json:"err_msg"`
  2678. InfRefmsgid string `json:"inf_refmsgid"`
  2679. Infcode int64 `json:"infcode"`
  2680. Output struct {
  2681. Baseinfo struct {
  2682. Age float64 `json:"age"`
  2683. Brdy string `json:"brdy"`
  2684. Certno string `json:"certno"`
  2685. Gend string `json:"gend"`
  2686. Naty string `json:"naty"`
  2687. PsnCertType string `json:"psn_cert_type"`
  2688. PsnName string `json:"psn_name"`
  2689. PsnNo string `json:"psn_no"`
  2690. } `json:"baseinfo"`
  2691. Idetinfo []interface{} `json:"idetinfo"`
  2692. Iinfo []struct {
  2693. Balc float64 `json:"balc"`
  2694. CvlservFlag string `json:"cvlserv_flag"`
  2695. EmpName string `json:"emp_name"`
  2696. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2697. Insutype string `json:"insutype"`
  2698. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2699. PausInsuDate string `json:"paus_insu_date"`
  2700. PsnInsuDate string `json:"psn_insu_date"`
  2701. PsnInsuStas string `json:"psn_insu_stas"`
  2702. PsnType string `json:"psn_type"`
  2703. } `json:"insuinfo"`
  2704. } `json:"output"`
  2705. RefmsgTime string `json:"refmsg_time"`
  2706. RespondTime string `json:"respond_time"`
  2707. Signtype interface{} `json:"signtype"`
  2708. WarnInfo interface{} `json:"warn_info"`
  2709. }
  2710. type ResultTwo10265 struct {
  2711. ErrMsg string `json:"err_msg"`
  2712. InfRefmsgid string `json:"inf_refmsgid"`
  2713. Infcode string `json:"infcode"`
  2714. Output struct {
  2715. Baseinfo struct {
  2716. Age float64 `json:"age"`
  2717. Brdy string `json:"brdy"`
  2718. Certno string `json:"certno"`
  2719. Gend string `json:"gend"`
  2720. Naty string `json:"naty"`
  2721. PsnCertType string `json:"psn_cert_type"`
  2722. PsnName string `json:"psn_name"`
  2723. PsnNo string `json:"psn_no"`
  2724. } `json:"baseinfo"`
  2725. Idetinfo []interface{} `json:"idetinfo"`
  2726. Iinfo []struct {
  2727. Balc float64 `json:"balc"`
  2728. CvlservFlag string `json:"cvlserv_flag"`
  2729. EmpName string `json:"emp_name"`
  2730. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2731. Insutype string `json:"insutype"`
  2732. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2733. PausInsuDate string `json:"paus_insu_date"`
  2734. PsnInsuDate string `json:"psn_insu_date"`
  2735. PsnInsuStas string `json:"psn_insu_stas"`
  2736. PsnType string `json:"psn_type"`
  2737. } `json:"insuinfo"`
  2738. } `json:"output"`
  2739. RefmsgTime string `json:"refmsg_time"`
  2740. RespondTime string `json:"respond_time"`
  2741. Signtype interface{} `json:"signtype"`
  2742. WarnInfo interface{} `json:"warn_info"`
  2743. }
  2744. type ResultThree struct {
  2745. Cainfo interface{} `json:"cainfo"`
  2746. ErrMsg string `json:"err_msg"`
  2747. InfRefmsgid string `json:"inf_refmsgid"`
  2748. Infcode int64 `json:"infcode"`
  2749. Output struct {
  2750. Data struct {
  2751. IptOtpNo string `json:"ipt_otp_no"`
  2752. MdtrtID string `json:"mdtrt_id"`
  2753. PsnNo string `json:"psn_no"`
  2754. } `json:"data"`
  2755. } `json:"output"`
  2756. RefmsgTime string `json:"refmsg_time"`
  2757. RespondTime string `json:"respond_time"`
  2758. Signtype interface{} `json:"signtype"`
  2759. WarnMsg interface{} `json:"warn_msg"`
  2760. }
  2761. type ResultThree10265 struct {
  2762. Cainfo interface{} `json:"cainfo"`
  2763. ErrMsg string `json:"err_msg"`
  2764. InfRefmsgid string `json:"inf_refmsgid"`
  2765. Infcode string `json:"infcode"`
  2766. Output struct {
  2767. Data struct {
  2768. IptOtpNo string `json:"ipt_otp_no"`
  2769. MdtrtID string `json:"mdtrt_id"`
  2770. PsnNo string `json:"psn_no"`
  2771. } `json:"data"`
  2772. } `json:"output"`
  2773. RefmsgTime string `json:"refmsg_time"`
  2774. RespondTime string `json:"respond_time"`
  2775. Signtype interface{} `json:"signtype"`
  2776. WarnMsg interface{} `json:"warn_msg"`
  2777. }
  2778. type ResultFour struct {
  2779. Cainfo string `json:"cainfo"`
  2780. ErrMsg string `json:"err_msg"`
  2781. InfRefmsgid string `json:"inf_refmsgid"`
  2782. Infcode int64 `json:"infcode"`
  2783. Output struct {
  2784. Result []struct {
  2785. BasMednFlag string `json:"bas_medn_flag"`
  2786. ChldMedcFlag string `json:"chld_medc_flag"`
  2787. ChrgitmLv string `json:"chrgitm_lv"`
  2788. Cnt float64 `json:"cnt"`
  2789. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2790. DrtReimFlag string `json:"drt_reim_flag"`
  2791. FeedetlSn string `json:"feedetl_sn"`
  2792. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2793. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2794. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2795. ListSpItemFlag string `json:"list_sp_item_flag"`
  2796. LmtUsedFlag string `json:"lmt_used_flag"`
  2797. MedChrgitmType string `json:"med_chrgitm_type"`
  2798. Memo string `json:"memo"`
  2799. OverlmtAmt float64 `json:"overlmt_amt"`
  2800. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2801. Pric float64 `json:"pric"`
  2802. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2803. SelfpayProp float64 `json:"selfpay_prop"`
  2804. } `json:"result"`
  2805. } `json:"output"`
  2806. RefmsgTime string `json:"refmsg_time"`
  2807. RespondTime string `json:"respond_time"`
  2808. Signtype string `json:"signtype"`
  2809. WarnMsg string `json:"warn_msg"`
  2810. }
  2811. type ResultFour10265 struct {
  2812. Cainfo string `json:"cainfo"`
  2813. ErrMsg string `json:"err_msg"`
  2814. InfRefmsgid string `json:"inf_refmsgid"`
  2815. Infcode string `json:"infcode"`
  2816. Output struct {
  2817. Result []struct {
  2818. BasMednFlag string `json:"bas_medn_flag"`
  2819. ChldMedcFlag string `json:"chld_medc_flag"`
  2820. ChrgitmLv string `json:"chrgitm_lv"`
  2821. Cnt float64 `json:"cnt"`
  2822. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2823. DrtReimFlag string `json:"drt_reim_flag"`
  2824. FeedetlSn string `json:"feedetl_sn"`
  2825. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2826. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2827. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2828. ListSpItemFlag string `json:"list_sp_item_flag"`
  2829. LmtUsedFlag string `json:"lmt_used_flag"`
  2830. MedChrgitmType string `json:"med_chrgitm_type"`
  2831. Memo string `json:"memo"`
  2832. OverlmtAmt float64 `json:"overlmt_amt"`
  2833. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2834. Pric float64 `json:"pric"`
  2835. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2836. SelfpayProp float64 `json:"selfpay_prop"`
  2837. } `json:"result"`
  2838. } `json:"output"`
  2839. RefmsgTime string `json:"refmsg_time"`
  2840. RespondTime string `json:"respond_time"`
  2841. Signtype string `json:"signtype"`
  2842. WarnMsg string `json:"warn_msg"`
  2843. }
  2844. type ResultFive struct {
  2845. Balc float64 `json:"balc"`
  2846. CvlservFlag string `json:"cvlserv_flag"`
  2847. EmpName string `json:"emp_name"`
  2848. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2849. Insutype string `json:"insutype"`
  2850. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2851. PausInsuDate string `json:"paus_insu_date"`
  2852. PsnInsuDate string `json:"psn_insu_date"`
  2853. PsnInsuStas string `json:"psn_insu_stas"`
  2854. PsnType string `json:"psn_type"`
  2855. }
  2856. type ResultSix struct {
  2857. Cainfo interface{} `json:"cainfo"`
  2858. ErrMsg string `json:"err_msg"`
  2859. InfRefmsgid string `json:"inf_refmsgid"`
  2860. Infcode int64 `json:"infcode"`
  2861. Output struct {
  2862. } `json:"output"`
  2863. RefmsgTime string `json:"refmsg_time"`
  2864. RespondTime string `json:"respond_time"`
  2865. Signtype interface{} `json:"signtype"`
  2866. WarnMsg interface{} `json:"warn_msg"`
  2867. }
  2868. type ResultSix10265 struct {
  2869. Cainfo interface{} `json:"cainfo"`
  2870. ErrMsg string `json:"err_msg"`
  2871. InfRefmsgid string `json:"inf_refmsgid"`
  2872. Infcode string `json:"infcode"`
  2873. Output struct {
  2874. } `json:"output"`
  2875. RefmsgTime string `json:"refmsg_time"`
  2876. RespondTime string `json:"respond_time"`
  2877. Signtype interface{} `json:"signtype"`
  2878. WarnMsg interface{} `json:"warn_msg"`
  2879. }
  2880. type ResultSeven struct {
  2881. Cainfo string `json:"cainfo"`
  2882. ErrMsg string `json:"err_msg"`
  2883. InfRefmsgid string `json:"inf_refmsgid"`
  2884. Infcode int64 `json:"infcode"`
  2885. Output struct {
  2886. Setldetail []interface{} `json:"setldetail"`
  2887. Setlinfo struct {
  2888. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2889. AcctPay float64 `json:"acct_pay"`
  2890. ActPayDedc float64 `json:"act_pay_dedc"`
  2891. Age float64 `json:"age"`
  2892. Balc float64 `json:"balc"`
  2893. Brdy string `json:"brdy"`
  2894. Certno string `json:"certno"`
  2895. ClrOptins string `json:"clr_optins"`
  2896. ClrType string `json:"clr_type"`
  2897. ClrWay string `json:"clr_way"`
  2898. CvlservFlag string `json:"cvlserv_flag"`
  2899. CvlservPay float64 `json:"cvlserv_pay"`
  2900. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2901. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2902. Gend string `json:"gend"`
  2903. HifesPay float64 `json:"hifes_pay"`
  2904. HifmiPay float64 `json:"hifmi_pay"`
  2905. HifpPay float64 `json:"hifp_pay"`
  2906. HospPartAmt float64 `json:"hosp_part_amt"`
  2907. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2908. Insutype string `json:"insutype"`
  2909. MafPay float64 `json:"maf_pay"`
  2910. MdtrtCertType string `json:"mdtrt_cert_type"`
  2911. HifobPay float64 `json:"hifob_pay"`
  2912. MdtrtID string `json:"mdtrt_id"`
  2913. MedType string `json:"med_type"`
  2914. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2915. MedinsSetlID string `json:"medins_setl_id"`
  2916. Naty string `json:"naty"`
  2917. OthPay float64 `json:"oth_pay"`
  2918. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2919. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2920. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2921. PsnCashPay float64 `json:"psn_cash_pay"`
  2922. PsnCertType string `json:"psn_cert_type"`
  2923. PsnName string `json:"psn_name"`
  2924. PsnNo string `json:"psn_no"`
  2925. PsnPartAmt float64 `json:"psn_part_amt"`
  2926. PsnType string `json:"psn_type"`
  2927. SetlID string `json:"setl_id"`
  2928. SetlTime string `json:"setl_time"`
  2929. } `json:"setlinfo"`
  2930. } `json:"output"`
  2931. RefmsgTime string `json:"refmsg_time"`
  2932. RespondTime string `json:"respond_time"`
  2933. Signtype interface{} `json:"signtype"`
  2934. WarnMsg interface{} `json:"warn_msg"`
  2935. }
  2936. type ResultSeven10265 struct {
  2937. Cainfo string `json:"cainfo"`
  2938. ErrMsg string `json:"err_msg"`
  2939. InfRefmsgid string `json:"inf_refmsgid"`
  2940. Infcode string `json:"infcode"`
  2941. Output struct {
  2942. Setldetail []interface{} `json:"setldetail"`
  2943. Setlinfo struct {
  2944. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2945. AcctPay float64 `json:"acct_pay"`
  2946. ActPayDedc float64 `json:"act_pay_dedc"`
  2947. Age float64 `json:"age"`
  2948. Balc float64 `json:"balc"`
  2949. Brdy string `json:"brdy"`
  2950. Certno string `json:"certno"`
  2951. ClrOptins string `json:"clr_optins"`
  2952. ClrType string `json:"clr_type"`
  2953. ClrWay string `json:"clr_way"`
  2954. CvlservFlag string `json:"cvlserv_flag"`
  2955. CvlservPay float64 `json:"cvlserv_pay"`
  2956. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2957. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2958. Gend string `json:"gend"`
  2959. HifesPay float64 `json:"hifes_pay"`
  2960. HifmiPay float64 `json:"hifmi_pay"`
  2961. HifpPay float64 `json:"hifp_pay"`
  2962. HospPartAmt float64 `json:"hosp_part_amt"`
  2963. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2964. Insutype string `json:"insutype"`
  2965. MafPay float64 `json:"maf_pay"`
  2966. MdtrtCertType string `json:"mdtrt_cert_type"`
  2967. HifobPay float64 `json:"hifob_pay"`
  2968. MdtrtID string `json:"mdtrt_id"`
  2969. MedType string `json:"med_type"`
  2970. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2971. MedinsSetlID string `json:"medins_setl_id"`
  2972. Naty string `json:"naty"`
  2973. OthPay float64 `json:"oth_pay"`
  2974. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2975. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2976. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2977. PsnCashPay float64 `json:"psn_cash_pay"`
  2978. PsnCertType string `json:"psn_cert_type"`
  2979. PsnName string `json:"psn_name"`
  2980. PsnNo string `json:"psn_no"`
  2981. PsnPartAmt float64 `json:"psn_part_amt"`
  2982. PsnType string `json:"psn_type"`
  2983. SetlID string `json:"setl_id"`
  2984. SetlTime string `json:"setl_time"`
  2985. } `json:"setlinfo"`
  2986. } `json:"output"`
  2987. RefmsgTime string `json:"refmsg_time"`
  2988. RespondTime string `json:"respond_time"`
  2989. Signtype interface{} `json:"signtype"`
  2990. WarnMsg interface{} `json:"warn_msg"`
  2991. }
  2992. type ResultEight struct {
  2993. Cainfo string `json:"cainfo"`
  2994. ErrMsg string `json:"err_msg"`
  2995. InfRefmsgid string `json:"inf_refmsgid"`
  2996. Infcode int64 `json:"infcode"`
  2997. Output struct {
  2998. Stmtinfo struct {
  2999. SetlOptins string `json:"setl_optins"`
  3000. StmtRslt string `json:"stmt_rslt"`
  3001. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3002. } `json:"stmtinfo"`
  3003. } `json:"output"`
  3004. RefmsgTime string `json:"refmsg_time"`
  3005. RespondTime string `json:"respond_time"`
  3006. Signtype interface{} `json:"signtype"`
  3007. WarnMsg interface{} `json:"warn_msg"`
  3008. }
  3009. type ResultEightFor10188 struct {
  3010. Cainfo string `json:"cainfo"`
  3011. ErrMsg string `json:"err_msg"`
  3012. InfRefmsgid string `json:"inf_refmsgid"`
  3013. Infcode string `json:"infcode"`
  3014. Output struct {
  3015. Stmtinfo struct {
  3016. SetlOptins string `json:"setl_optins"`
  3017. StmtRslt string `json:"stmt_rslt"`
  3018. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3019. } `json:"stmtinfo"`
  3020. } `json:"output"`
  3021. RefmsgTime string `json:"refmsg_time"`
  3022. RespondTime string `json:"respond_time"`
  3023. Signtype interface{} `json:"signtype"`
  3024. WarnMsg interface{} `json:"warn_msg"`
  3025. }
  3026. type ResultNine struct {
  3027. Cainfo string `json:"cainfo"`
  3028. ErrMsg string `json:"err_msg"`
  3029. InfRefmsgid string `json:"inf_refmsgid"`
  3030. Infcode int64 `json:"infcode"`
  3031. Output struct {
  3032. FileQuryNo string `json:"file_qury_no"`
  3033. } `json:"output"`
  3034. RefmsgTime string `json:"refmsg_time"`
  3035. RespondTime string `json:"respond_time"`
  3036. Signtype interface{} `json:"signtype"`
  3037. WarnMsg interface{} `json:"warn_msg"`
  3038. }
  3039. type ResultTen struct {
  3040. Cainfo string `json:"cainfo"`
  3041. ErrMsg string `json:"err_msg"`
  3042. InfRefmsgid string `json:"inf_refmsgid"`
  3043. Infcode int64 `json:"infcode"`
  3044. Output struct {
  3045. DldEndtime string `json:"dld_endtime"`
  3046. FileQuryNo string `json:"file_qury_no"`
  3047. Filename string `json:"filename"`
  3048. } `json:"output"`
  3049. RefmsgTime string `json:"refmsg_time"`
  3050. RespondTime string `json:"respond_time"`
  3051. Signtype interface{} `json:"signtype"`
  3052. WarnMsg interface{} `json:"warn_msg"`
  3053. }
  3054. //type Autogenerated struct {
  3055. // Output struct {
  3056. // Setlinfo struct {
  3057. // SetlTime string `json:"setl_time"`
  3058. // CvlservPay float64 `json:"cvlserv_pay"`
  3059. // Year string `json:"year"`
  3060. // MedType string `json:"med_type"`
  3061. // PsnPay float64 `json:"psn_pay"`
  3062. // OpterID string `json:"opter_id"`
  3063. // Begndate string `json:"begndate"`
  3064. // FlxempeFlag string `json:"flxempe_flag"`
  3065. // HifmiPay float64 `json:"hifmi_pay"`
  3066. // PsnNo string `json:"psn_no"`
  3067. // ActPayDedc float64 `json:"act_pay_dedc"`
  3068. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3069. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3070. // ClrWay string `json:"clr_way"`
  3071. // OthPay float64 `json:"oth_pay"`
  3072. // Gend string `json:"gend"`
  3073. // MdtrtID string `json:"mdtrt_id"`
  3074. // AcctPay float64 `json:"acct_pay"`
  3075. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3076. // Insutype string `json:"insutype"`
  3077. // Invono interface{} `json:"invono"`
  3078. // Enddate string `json:"enddate"`
  3079. // CashPayamt float64 `json:"cash_payamt"`
  3080. // PsnType string `json:"psn_type"`
  3081. // FixmedinsName string `json:"fixmedins_name"`
  3082. // HifpPay float64 `json:"hifp_pay"`
  3083. // NewFlag interface{} `json:"new_flag"`
  3084. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3085. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3086. // PayLoc string `json:"pay_loc"`
  3087. // ClrType string `json:"clr_type"`
  3088. // RefdSetlFlag string `json:"refd_setl_flag"`
  3089. // CvlservFlag string `json:"cvlserv_flag"`
  3090. // EmpName string `json:"emp_name"`
  3091. // Brdy string `json:"brdy"`
  3092. // Naty string `json:"naty"`
  3093. // Certno string `json:"certno"`
  3094. // DiseCode string `json:"dise_code"`
  3095. // FixmedinsCode string `json:"fixmedins_code"`
  3096. // DedcHospLv string `json:"dedc_hosp_lv"`
  3097. // OpterName string `json:"opter_name"`
  3098. // Balc float64 `json:"balc"`
  3099. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3100. // PsnCertType string `json:"psn_cert_type"`
  3101. // HifobPay float64 `json:"hifob_pay"`
  3102. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3103. // HifesPay float64 `json:"hifes_pay"`
  3104. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3105. // OptTime string `json:"opt_time"`
  3106. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3107. // SetlID string `json:"setl_id"`
  3108. // MafPay float64 `json:"maf_pay"`
  3109. // PsnName string `json:"psn_name"`
  3110. // InsuOptins interface{} `json:"insu_optins"`
  3111. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3112. // ClrOptins string `json:"clr_optins"`
  3113. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3114. // DiseName string `json:"dise_name"`
  3115. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3116. // Age float64 `json:"age"`
  3117. // DtrtCertType string `json:"dtrt_cert_type"`
  3118. // HospLv string `json:"hosp_lv"`
  3119. // } `json:"setlinfo"`
  3120. // Setldetail []struct {
  3121. // FundPayType string `json:"fund_pay_type"`
  3122. // FundPayamt float64 `json:"fund_payamt"`
  3123. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3124. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3125. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3126. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3127. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3128. // } `json:"setldetail"`
  3129. // } `json:"output"`
  3130. // Infcode int `json:"infcode"`
  3131. // WarnMsg interface{} `json:"warn_msg"`
  3132. // Cainfo interface{} `json:"cainfo"`
  3133. // ErrMsg interface{} `json:"err_msg"`
  3134. // RefmsgTime string `json:"refmsg_time"`
  3135. // Signtype interface{} `json:"signtype"`
  3136. // RespondTime string `json:"respond_time"`
  3137. // InfRefmsgid string `json:"inf_refmsgid"`
  3138. //}
  3139. type ResultEleven struct {
  3140. Cainfo string `json:"cainfo"`
  3141. ErrMsg string `json:"err_msg"`
  3142. InfRefmsgid string `json:"inf_refmsgid"`
  3143. Infcode int64 `json:"infcode"`
  3144. Output struct {
  3145. Setlinfo struct {
  3146. SetlTime string `json:"setl_time"`
  3147. CvlservPay float64 `json:"cvlserv_pay"`
  3148. Year string `json:"year"`
  3149. MedType string `json:"med_type"`
  3150. PsnPay float64 `json:"psn_pay"`
  3151. OpterID string `json:"opter_id"`
  3152. Begndate string `json:"begndate"`
  3153. FlxempeFlag string `json:"flxempe_flag"`
  3154. HifmiPay float64 `json:"hifmi_pay"`
  3155. PsnNo string `json:"psn_no"`
  3156. ActPayDedc float64 `json:"act_pay_dedc"`
  3157. MedinsSetlID interface{} `json:"medins_setl_id"`
  3158. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3159. ClrWay string `json:"clr_way"`
  3160. OthPay float64 `json:"oth_pay"`
  3161. Gend string `json:"gend"`
  3162. MdtrtID string `json:"mdtrt_id"`
  3163. AcctPay float64 `json:"acct_pay"`
  3164. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3165. Insutype string `json:"insutype"`
  3166. Invono interface{} `json:"invono"`
  3167. Enddate string `json:"enddate"`
  3168. CashPayamt float64 `json:"cash_payamt"`
  3169. PsnType string `json:"psn_type"`
  3170. FixmedinsName string `json:"fixmedins_name"`
  3171. HifpPay float64 `json:"hifp_pay"`
  3172. NewFlag interface{} `json:"new_flag"`
  3173. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3174. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3175. PayLoc string `json:"pay_loc"`
  3176. ClrType string `json:"clr_type"`
  3177. RefdSetlFlag string `json:"refd_setl_flag"`
  3178. CvlservFlag string `json:"cvlserv_flag"`
  3179. EmpName string `json:"emp_name"`
  3180. Brdy string `json:"brdy"`
  3181. Naty string `json:"naty"`
  3182. Certno string `json:"certno"`
  3183. DiseCode string `json:"dise_code"`
  3184. FixmedinsCode string `json:"fixmedins_code"`
  3185. DedcHospLv string `json:"dedc_hosp_lv"`
  3186. OpterName string `json:"opter_name"`
  3187. Balc float64 `json:"balc"`
  3188. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3189. PsnCertType string `json:"psn_cert_type"`
  3190. HifobPay float64 `json:"hifob_pay"`
  3191. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3192. HifesPay float64 `json:"hifes_pay"`
  3193. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3194. OptTime string `json:"opt_time"`
  3195. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3196. SetlID string `json:"setl_id"`
  3197. MafPay float64 `json:"maf_pay"`
  3198. PsnName string `json:"psn_name"`
  3199. InsuOptins interface{} `json:"insu_optins"`
  3200. PrefFundPay interface{} `json:"pref_fund_pay"`
  3201. ClrOptins string `json:"clr_optins"`
  3202. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3203. DiseName string `json:"dise_name"`
  3204. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3205. Age float64 `json:"age"`
  3206. DtrtCertType string `json:"dtrt_cert_type"`
  3207. HospLv string `json:"hosp_lv"`
  3208. } `json:"setlinfo"`
  3209. } `json:"output"`
  3210. RefmsgTime string `json:"refmsg_time"`
  3211. RespondTime string `json:"respond_time"`
  3212. Signtype interface{} `json:"signtype"`
  3213. WarnMsg interface{} `json:"warn_msg"`
  3214. }
  3215. type ResultEleven10265 struct {
  3216. Cainfo string `json:"cainfo"`
  3217. ErrMsg string `json:"err_msg"`
  3218. InfRefmsgid string `json:"inf_refmsgid"`
  3219. Infcode string `json:"infcode"`
  3220. Output struct {
  3221. Setlinfo struct {
  3222. SetlTime string `json:"setl_time"`
  3223. CvlservPay float64 `json:"cvlserv_pay"`
  3224. Year string `json:"year"`
  3225. MedType string `json:"med_type"`
  3226. PsnPay float64 `json:"psn_pay"`
  3227. OpterID string `json:"opter_id"`
  3228. Begndate string `json:"begndate"`
  3229. FlxempeFlag string `json:"flxempe_flag"`
  3230. HifmiPay float64 `json:"hifmi_pay"`
  3231. PsnNo string `json:"psn_no"`
  3232. ActPayDedc float64 `json:"act_pay_dedc"`
  3233. MedinsSetlID interface{} `json:"medins_setl_id"`
  3234. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3235. ClrWay string `json:"clr_way"`
  3236. OthPay float64 `json:"oth_pay"`
  3237. Gend string `json:"gend"`
  3238. MdtrtID string `json:"mdtrt_id"`
  3239. AcctPay float64 `json:"acct_pay"`
  3240. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3241. Insutype string `json:"insutype"`
  3242. Invono interface{} `json:"invono"`
  3243. Enddate string `json:"enddate"`
  3244. CashPayamt float64 `json:"cash_payamt"`
  3245. PsnType string `json:"psn_type"`
  3246. FixmedinsName string `json:"fixmedins_name"`
  3247. HifpPay float64 `json:"hifp_pay"`
  3248. NewFlag interface{} `json:"new_flag"`
  3249. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3250. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3251. PayLoc string `json:"pay_loc"`
  3252. ClrType string `json:"clr_type"`
  3253. RefdSetlFlag string `json:"refd_setl_flag"`
  3254. CvlservFlag string `json:"cvlserv_flag"`
  3255. EmpName string `json:"emp_name"`
  3256. Brdy string `json:"brdy"`
  3257. Naty string `json:"naty"`
  3258. Certno string `json:"certno"`
  3259. DiseCode string `json:"dise_code"`
  3260. FixmedinsCode string `json:"fixmedins_code"`
  3261. DedcHospLv string `json:"dedc_hosp_lv"`
  3262. OpterName string `json:"opter_name"`
  3263. Balc float64 `json:"balc"`
  3264. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3265. PsnCertType string `json:"psn_cert_type"`
  3266. HifobPay float64 `json:"hifob_pay"`
  3267. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3268. HifesPay float64 `json:"hifes_pay"`
  3269. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3270. OptTime string `json:"opt_time"`
  3271. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3272. SetlID string `json:"setl_id"`
  3273. MafPay float64 `json:"maf_pay"`
  3274. PsnName string `json:"psn_name"`
  3275. InsuOptins interface{} `json:"insu_optins"`
  3276. PrefFundPay interface{} `json:"pref_fund_pay"`
  3277. ClrOptins string `json:"clr_optins"`
  3278. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3279. DiseName string `json:"dise_name"`
  3280. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3281. Age float64 `json:"age"`
  3282. DtrtCertType string `json:"dtrt_cert_type"`
  3283. HospLv string `json:"hosp_lv"`
  3284. } `json:"setlinfo"`
  3285. } `json:"output"`
  3286. RefmsgTime string `json:"refmsg_time"`
  3287. RespondTime string `json:"respond_time"`
  3288. Signtype interface{} `json:"signtype"`
  3289. WarnMsg interface{} `json:"warn_msg"`
  3290. }
  3291. type ResultTwelve struct {
  3292. Cainfo string `json:"cainfo"`
  3293. ErrMsg string `json:"err_msg"`
  3294. InfRefmsgid string `json:"inf_refmsgid"`
  3295. Infcode int64 `json:"infcode"`
  3296. Output struct {
  3297. MdtrtId string `json:"mdtrt_id"`
  3298. ChrgBchno string `json:"chrg_bchno"`
  3299. PsnNo string `json:"psn_no"`
  3300. } `json:"output"`
  3301. RefmsgTime string `json:"refmsg_time"`
  3302. RespondTime string `json:"respond_time"`
  3303. Signtype interface{} `json:"signtype"`
  3304. WarnMsg interface{} `json:"warn_msg"`
  3305. }
  3306. type ResultThirteen struct {
  3307. ErrMsg string `json:"err_msg"`
  3308. InfRefmsgid string `json:"inf_refmsgid"`
  3309. Infcode int64 `json:"infcode"`
  3310. Output struct {
  3311. Result struct {
  3312. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3313. } `json:"result"`
  3314. } `json:"output"`
  3315. RefmsgTime string `json:"refmsg_time"`
  3316. RespondTime string `json:"respond_time"`
  3317. Signtype interface{} `json:"signtype"`
  3318. WarnInfo interface{} `json:"warn_info"`
  3319. }
  3320. type ResultThirteen10265 struct {
  3321. ErrMsg string `json:"err_msg"`
  3322. InfRefmsgid string `json:"inf_refmsgid"`
  3323. Infcode string `json:"infcode"`
  3324. Output struct {
  3325. Result struct {
  3326. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3327. } `json:"result"`
  3328. } `json:"output"`
  3329. RefmsgTime string `json:"refmsg_time"`
  3330. RespondTime string `json:"respond_time"`
  3331. Signtype interface{} `json:"signtype"`
  3332. WarnInfo interface{} `json:"warn_info"`
  3333. }
  3334. type ResultFourteen struct {
  3335. ErrMsg string `json:"err_msg"`
  3336. InfRefmsgid string `json:"inf_refmsgid"`
  3337. Infcode int64 `json:"infcode"`
  3338. Output struct {
  3339. } `json:"output"`
  3340. RefmsgTime string `json:"refmsg_time"`
  3341. RespondTime string `json:"respond_time"`
  3342. Signtype interface{} `json:"signtype"`
  3343. WarnInfo interface{} `json:"warn_info"`
  3344. }
  3345. type ResultFourteen10265 struct {
  3346. ErrMsg string `json:"err_msg"`
  3347. InfRefmsgid string `json:"inf_refmsgid"`
  3348. Infcode string `json:"infcode"`
  3349. Output struct {
  3350. } `json:"output"`
  3351. RefmsgTime string `json:"refmsg_time"`
  3352. RespondTime string `json:"respond_time"`
  3353. Signtype interface{} `json:"signtype"`
  3354. WarnInfo interface{} `json:"warn_info"`
  3355. }
  3356. type ResultSixteen struct {
  3357. Cainfo string `json:"cainfo"`
  3358. ErrMsg string `json:"err_msg"`
  3359. InfRefmsgid string `json:"inf_refmsgid"`
  3360. Infcode int64 `json:"infcode"`
  3361. Output struct {
  3362. Setldetail []interface{} `json:"setldetail"`
  3363. Setlinfo struct {
  3364. MdtrtID string `json:"mdtrt_id"`
  3365. SetlID string `json:"setl_id"`
  3366. ClrOptins string `json:"clr_optins"`
  3367. SetlTime string `json:"setl_time"`
  3368. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3369. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3370. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3371. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3372. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3373. ActPayDedc float64 `json:"act_pay_dedc"`
  3374. HifpPay float64 `json:"hifp_pay"`
  3375. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3376. Lfpay float64 `json:"selfpay"`
  3377. CvlservPay float64 `json:"cvlserv_pay"`
  3378. HifesPay float64 `json:"hifes_pay"`
  3379. HifmiPay float64 `json:"hifmi_pay"`
  3380. HifobPay float64 `json:"hifob_pay"`
  3381. MafPay float64 `json:"maf_pay"`
  3382. OthPay float64 `json:"oth_pay"`
  3383. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3384. PsnPartAmt float64 `json:"psn_part_amt"`
  3385. AcctPay float64 `json:"acct_pay"`
  3386. Balc float64 `json:"balc"`
  3387. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3388. HospPartAmt float64 `json:"hosp_part_amt"`
  3389. MedinsSetlID string `json:"medins_setl_id"`
  3390. PdnCashPay string `json:"pdn_cash_pay"`
  3391. } `json:"setlinfo"`
  3392. } `json:"output"`
  3393. RefmsgTime string `json:"refmsg_time"`
  3394. RespondTime string `json:"respond_time"`
  3395. Signtype interface{} `json:"signtype"`
  3396. WarnMsg interface{} `json:"warn_msg"`
  3397. }
  3398. type ResultSixteen10265 struct {
  3399. Cainfo string `json:"cainfo"`
  3400. ErrMsg string `json:"err_msg"`
  3401. InfRefmsgid string `json:"inf_refmsgid"`
  3402. Infcode string `json:"infcode"`
  3403. Output struct {
  3404. Setldetail []interface{} `json:"setldetail"`
  3405. Setlinfo struct {
  3406. MdtrtID string `json:"mdtrt_id"`
  3407. SetlID string `json:"setl_id"`
  3408. ClrOptins string `json:"clr_optins"`
  3409. SetlTime string `json:"setl_time"`
  3410. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3411. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3412. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3413. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3414. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3415. ActPayDedc float64 `json:"act_pay_dedc"`
  3416. HifpPay float64 `json:"hifp_pay"`
  3417. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3418. Lfpay float64 `json:"selfpay"`
  3419. CvlservPay float64 `json:"cvlserv_pay"`
  3420. HifesPay float64 `json:"hifes_pay"`
  3421. HifmiPay float64 `json:"hifmi_pay"`
  3422. HifobPay float64 `json:"hifob_pay"`
  3423. MafPay float64 `json:"maf_pay"`
  3424. OthPay float64 `json:"oth_pay"`
  3425. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3426. PsnPartAmt float64 `json:"psn_part_amt"`
  3427. AcctPay float64 `json:"acct_pay"`
  3428. Balc float64 `json:"balc"`
  3429. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3430. HospPartAmt float64 `json:"hosp_part_amt"`
  3431. MedinsSetlID string `json:"medins_setl_id"`
  3432. PdnCashPay string `json:"pdn_cash_pay"`
  3433. } `json:"setlinfo"`
  3434. } `json:"output"`
  3435. RefmsgTime string `json:"refmsg_time"`
  3436. RespondTime string `json:"respond_time"`
  3437. Signtype interface{} `json:"signtype"`
  3438. WarnMsg interface{} `json:"warn_msg"`
  3439. }
  3440. type ResultSeventeen struct {
  3441. ErrMsg string `json:"err_msg"`
  3442. InfRefmsgid string `json:"inf_refmsgid"`
  3443. Infcode int64 `json:"infcode"`
  3444. Output struct {
  3445. SetlListId string `json:"setl_list_id"`
  3446. } `json:"output"`
  3447. RefmsgTime string `json:"refmsg_time"`
  3448. RespondTime string `json:"respond_time"`
  3449. Signtype string `json:"signtype"`
  3450. WarnInfo string `json:"warn_info"`
  3451. }
  3452. type Result90991 struct {
  3453. ErrMsg string `json:"err_msg"`
  3454. InfRefmsgid string `json:"inf_refmsgid"`
  3455. Infcode int64 `json:"infcode"`
  3456. Output struct {
  3457. Result struct {
  3458. PsnNo string `json:"psn_no"`
  3459. CardStat string `json:"card_stat"`
  3460. Certno string `json:"certno"`
  3461. PsnName string `json:"psn_name"`
  3462. CheckStat string `json:"check_stat"`
  3463. } `json:"result"`
  3464. } `json:"output"`
  3465. RefmsgTime string `json:"refmsg_time"`
  3466. RespondTime string `json:"respond_time"`
  3467. Signtype interface{} `json:"signtype"`
  3468. WarnInfo interface{} `json:"warn_info"`
  3469. }
  3470. type Result90100 struct {
  3471. ErrMsg string `json:"err_msg"`
  3472. InfRefmsgid string `json:"inf_refmsgid"`
  3473. Infcode int64 `json:"infcode"`
  3474. Output struct {
  3475. PoolareaNo string `json:"poolarea_no"`
  3476. PoolareaNoName string `json:"poolarea_no_name"`
  3477. Insutype string `json:"insutype"`
  3478. InsutypeName string `json:"insutype_name"`
  3479. ClctType string `json:"clct_type"`
  3480. ClctTypeName string `json:"clct_type_name"`
  3481. ClctFlag string `json:"clct_flag"`
  3482. ClctFlagName string `json:"clct_flag_name"`
  3483. AccrymBegn string `json:"accrym_begn"`
  3484. AccrymEnd string `json:"accrym_end"`
  3485. ClctTime string `json:"clct_time"`
  3486. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3487. } `json:"output"`
  3488. RefmsgTime string `json:"refmsg_time"`
  3489. RespondTime string `json:"respond_time"`
  3490. Signtype interface{} `json:"signtype"`
  3491. WarnInfo interface{} `json:"warn_info"`
  3492. }
  3493. type Custom struct {
  3494. DetItemFeeSumamt string
  3495. Cut string
  3496. FeedetlSn string
  3497. Price string
  3498. MedListCodg string
  3499. Type int64
  3500. AdviceId int64
  3501. ProjectId int64
  3502. ItemId int64
  3503. }
  3504. type Result5301 struct {
  3505. ErrMsg string `json:"err_msg"`
  3506. InfRefmsgid string `json:"inf_refmsgid"`
  3507. Infcode int64 `json:"infcode"`
  3508. Output struct {
  3509. Result []struct {
  3510. OpspDiseCode string `json:"opsp_dise_code"`
  3511. OpspDiseName string `json:"opsp_dise_name"`
  3512. Begndate string `json:"begndate"`
  3513. Enddate string `json:"enddate"`
  3514. } `json:"feedetail"`
  3515. } `json:"output"`
  3516. RefmsgTime string `json:"refmsg_time"`
  3517. RespondTime string `json:"respond_time"`
  3518. Signtype interface{} `json:"signtype"`
  3519. WarnInfo interface{} `json:"warn_info"`
  3520. }
  3521. type Result5301For10265 struct {
  3522. ErrMsg string `json:"err_msg"`
  3523. InfRefmsgid string `json:"inf_refmsgid"`
  3524. Infcode string `json:"infcode"`
  3525. Output struct {
  3526. Result []struct {
  3527. OpspDiseCode string `json:"opsp_dise_code"`
  3528. OpspDiseName string `json:"opsp_dise_name"`
  3529. Begndate string `json:"begndate"`
  3530. Enddate string `json:"enddate"`
  3531. } `json:"feedetail"`
  3532. } `json:"output"`
  3533. RefmsgTime string `json:"refmsg_time"`
  3534. RespondTime string `json:"respond_time"`
  3535. Signtype interface{} `json:"signtype"`
  3536. WarnInfo interface{} `json:"warn_info"`
  3537. }
  3538. //获取个人信息----挂号-----上传就诊信息
  3539. func (c *HisApiController) GetRegisterInfo() {
  3540. id, _ := c.GetInt64("id")
  3541. record_time := c.GetString("record_time")
  3542. settlementValue, _ := c.GetInt64("settlement_value")
  3543. medical_insurance_card := c.GetString("medical_insurance_card")
  3544. name := c.GetString("name")
  3545. id_card_type, _ := c.GetInt64("id_card_type")
  3546. certificates, _ := c.GetInt64("certificates")
  3547. medical_care, _ := c.GetInt64("medical_care")
  3548. birthday := c.GetString("birthday")
  3549. id_card := c.GetString("id_card")
  3550. register_type, _ := c.GetInt64("register")
  3551. doctor, _ := c.GetInt64("doctor")
  3552. department, _ := c.GetInt64("department")
  3553. gender, _ := c.GetInt64("sex")
  3554. registration_fee, _ := c.GetFloat("registration_fee")
  3555. medical_expenses, _ := c.GetFloat("medical_expenses")
  3556. social_type, _ := c.GetInt64("social_type")
  3557. med_type := c.GetString("social_type")
  3558. admin_user_id, _ := c.GetInt64("admin_user_id")
  3559. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3560. timeLayout := "2006-01-02"
  3561. loc, _ := time.LoadLocation("Local")
  3562. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3563. birthUnix := birthdays.Unix()
  3564. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3565. if err != nil {
  3566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3567. return
  3568. }
  3569. recordDateTime := theTime.Unix()
  3570. adminInfo := c.GetAdminUserInfo()
  3571. var patient service.Patients
  3572. if id == 0 {
  3573. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3574. } else {
  3575. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3576. }
  3577. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3578. if patientPrescription.ID == 0 {
  3579. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3580. }
  3581. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3582. if patient.ID == 0 {
  3583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3584. return
  3585. }
  3586. if len(patient.IdCardNo) == 0 {
  3587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3588. return
  3589. }
  3590. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3591. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3592. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3593. //就诊结算未完成,不能进行二次挂号
  3594. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3595. if len(his) >= 1 {
  3596. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3597. if len(his) >= 1 && order.ID == 0 {
  3598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3599. return
  3600. }
  3601. }
  3602. //var register_log string
  3603. if config.IsOpen == 1 {
  3604. var res ResultTwo
  3605. var res10265 ResultTwo10265
  3606. var PsnNo string
  3607. var PsnCertType string
  3608. var Certno string
  3609. var PsnName string
  3610. var Gend string
  3611. var Naty string
  3612. var Brdy string
  3613. var Age float64
  3614. var infoStr string
  3615. var idetinfoStr string
  3616. var infocode int64
  3617. var verify_number string
  3618. fmt.Println(verify_number)
  3619. if miConfig.MdtrtareaAdmvs == "421300" {
  3620. psn_info, _ := service.GetPsnByPatientId(id)
  3621. PsnNo = psn_info.PsnNo
  3622. PsnCertType = psn_info.PsnCertType
  3623. Certno = psn_info.Certno
  3624. PsnName = psn_info.PsnName
  3625. Gend = psn_info.Gend
  3626. Naty = psn_info.Naty
  3627. Brdy = psn_info.Brdy
  3628. Age = psn_info.Age
  3629. infoStr = psn_info.Insuinfo
  3630. idetinfoStr = psn_info.Idetinfo
  3631. infocode = 0
  3632. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3633. psn_info, _ := service.GetPsnByPatientId(id)
  3634. PsnNo = psn_info.PsnNo
  3635. PsnCertType = psn_info.PsnCertType
  3636. Certno = psn_info.Certno
  3637. PsnName = psn_info.PsnName
  3638. Gend = psn_info.Gend
  3639. Naty = psn_info.Naty
  3640. Brdy = psn_info.Brdy
  3641. Age = psn_info.Age
  3642. infoStr = psn_info.Insuinfo
  3643. idetinfoStr = psn_info.Idetinfo
  3644. infocode = 0
  3645. verify_number = psn_info.VerifyNumber
  3646. } else {
  3647. var result string
  3648. var requestLog string
  3649. if miConfig.UserOrgId == 10138 {
  3650. 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)
  3651. } else {
  3652. 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)
  3653. }
  3654. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3655. if miConfig.Code == "H15049901371" {
  3656. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3657. utils.ErrorLog("解析失败:%v", err)
  3658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3659. return
  3660. }
  3661. res.ErrMsg = res10265.ErrMsg
  3662. res.Output = res10265.Output
  3663. res.InfRefmsgid = res10265.InfRefmsgid
  3664. } else {
  3665. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3666. utils.ErrorLog("解析失败:%v", err)
  3667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3668. return
  3669. }
  3670. }
  3671. PsnNo = res.Output.Baseinfo.PsnNo
  3672. PsnCertType = res.Output.Baseinfo.PsnCertType
  3673. Certno = res.Output.Baseinfo.Certno
  3674. PsnName = res.Output.Baseinfo.PsnName
  3675. Gend = res.Output.Baseinfo.Gend
  3676. Naty = res.Output.Baseinfo.Naty
  3677. Brdy = res.Output.Baseinfo.Brdy
  3678. Age = res.Output.Baseinfo.Age
  3679. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3680. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3681. infoStr = string(Iinfos)
  3682. idetinfoStr = string(Idetinfos)
  3683. if miConfig.Code == "H15049901371" {
  3684. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3685. } else {
  3686. infocode = res.Infcode
  3687. }
  3688. }
  3689. if infocode == 0 {
  3690. his := models.VMHisPatient{
  3691. Name: name,
  3692. Gender: gender,
  3693. Birthday: birthUnix,
  3694. MedicalTreatmentType: medical_care,
  3695. IdType: certificates,
  3696. IdCardNo: id_card,
  3697. BalanceAccountsType: settlementValue,
  3698. SocialType: social_type,
  3699. MedicalInsuranceNumber: medical_insurance_card,
  3700. RegisterType: register_type,
  3701. RegisterCost: registration_fee,
  3702. TreatmentCost: medical_expenses,
  3703. Status: 1,
  3704. Ctime: time.Now().Unix(),
  3705. Mtime: time.Now().Unix(),
  3706. PsnNo: PsnNo,
  3707. PsnCertType: PsnCertType,
  3708. Certno: Certno,
  3709. PsnName: PsnName,
  3710. Gend: Gend,
  3711. Naty: Naty,
  3712. Brdy: Brdy,
  3713. Age: Age,
  3714. Iinfo: infoStr,
  3715. Idetinfo: idetinfoStr,
  3716. PatientId: patient.ID,
  3717. RecordDate: theTime.Unix(),
  3718. UserOrgId: adminInfo.CurrentOrgId,
  3719. AdminUserId: admin_user_id,
  3720. IsReturn: 1,
  3721. IdCardType: id_card_type,
  3722. Doctor: doctor,
  3723. Departments: department,
  3724. }
  3725. timestamp := time.Now().Unix()
  3726. tempTime := time.Unix(timestamp, 0)
  3727. timeFormat := tempTime.Format("20060102150405")
  3728. chrgBchno := rand.Intn(100000) + 10000
  3729. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3730. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3731. department, _ := service.GetDepartMentDetail(department)
  3732. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3733. IdCardNo := ""
  3734. if id_card_type == 1 {
  3735. // IdCardNo = medical_insurance_card
  3736. IdCardNo = patient.IdCardNo
  3737. } else {
  3738. IdCardNo = patient.IdCardNo
  3739. }
  3740. var rf []*ResultFive
  3741. json.Unmarshal([]byte(his.Iinfo), &rf)
  3742. var insutypes []*ResultFive
  3743. var insutype string
  3744. var insuplc_admdvs_temp string
  3745. var is390 int = 0
  3746. var is310 int = 0
  3747. for _, item := range rf {
  3748. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3749. insutypes = append(insutypes, item)
  3750. }
  3751. }
  3752. if len(insutypes) == 1 {
  3753. insutype = insutypes[0].Insutype
  3754. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3755. } else {
  3756. for _, i := range insutypes {
  3757. if i.Insutype == "390" {
  3758. is390 = 1
  3759. }
  3760. if i.Insutype == "310" {
  3761. is310 = 1
  3762. }
  3763. }
  3764. }
  3765. if is390 == 1 {
  3766. insutype = "390"
  3767. }
  3768. if is310 == 1 {
  3769. insutype = "310"
  3770. }
  3771. if len(insutypes) == 0 {
  3772. insutype = "310"
  3773. }
  3774. if len(insutypes) == 2 {
  3775. insutype = med_type
  3776. }
  3777. if len(med_type) > 0 {
  3778. insutype = med_type
  3779. }
  3780. //for _, item := range rf {
  3781. // if item.Insutype == insutype {
  3782. // insuplc_admdvs = item.InsuplcAdmdvs
  3783. // }
  3784. //}
  3785. var infocode int64
  3786. var resThree ResultThree
  3787. var resThree10265 ResultThree10265
  3788. if len(insuplc_admdvs) == 0 {
  3789. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3790. } else {
  3791. insuplc_admdvs_temp = insuplc_admdvs
  3792. }
  3793. if miConfig.MdtrtareaAdmvs == "421300" {
  3794. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3795. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3796. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  3797. resp, requestErr := http.Get(api)
  3798. if requestErr != nil {
  3799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3800. return
  3801. }
  3802. body, ioErr := ioutil.ReadAll(resp.Body)
  3803. if ioErr != nil {
  3804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3806. return
  3807. }
  3808. var respJSON map[string]interface{}
  3809. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3812. return
  3813. }
  3814. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3815. result, _ := json.Marshal(respJSON)
  3816. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3817. utils.ErrorLog("解析失败:%v", err)
  3818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3819. return
  3820. }
  3821. infocode = resThree.Infcode
  3822. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3823. psn_info, _ := service.GetPsnByPatientId(id)
  3824. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3825. var cert_no string
  3826. if id_card_type == 3 {
  3827. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  3828. cert_no = IdCardNo
  3829. } else {
  3830. bas := strings.Split(psn_info.CardInfo, "|")
  3831. cert_no = bas[2]
  3832. }
  3833. var api string
  3834. if miConfig.MdtrtareaAdmvs == "320921" {
  3835. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3836. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3837. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3838. } else {
  3839. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3840. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3841. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3842. }
  3843. resp, requestErr := http.Get(api)
  3844. if requestErr != nil {
  3845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3846. return
  3847. }
  3848. body, ioErr := ioutil.ReadAll(resp.Body)
  3849. if ioErr != nil {
  3850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3852. return
  3853. }
  3854. var respJSON map[string]interface{}
  3855. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3858. return
  3859. }
  3860. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3861. result, _ := json.Marshal(respJSON)
  3862. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3863. utils.ErrorLog("解析失败:%v", err)
  3864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3865. return
  3866. }
  3867. resThree.ErrMsg = resThree10265.ErrMsg
  3868. resThree.Output = resThree10265.Output
  3869. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3870. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3871. } else {
  3872. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3873. saveLog(result, requestLog, "2201", "挂号")
  3874. if miConfig.Code == "H15049901371" {
  3875. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3876. utils.ErrorLog("解析失败:%v", err)
  3877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3878. return
  3879. }
  3880. resThree.ErrMsg = resThree10265.ErrMsg
  3881. resThree.Output = resThree10265.Output
  3882. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3883. } else {
  3884. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3885. utils.ErrorLog("解析失败:%v", err)
  3886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3887. return
  3888. }
  3889. }
  3890. if miConfig.Code == "H15049901371" {
  3891. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3892. } else {
  3893. infocode = resThree.Infcode
  3894. }
  3895. }
  3896. if infocode != 0 {
  3897. adminUser := c.GetAdminUserInfo()
  3898. errlog := &models.HisOrderError{
  3899. UserOrgId: adminUser.CurrentOrgId,
  3900. Ctime: time.Now().Unix(),
  3901. Mtime: time.Now().Unix(),
  3902. ErrMsg: resThree.ErrMsg,
  3903. Status: 1,
  3904. PatientId: id,
  3905. RecordTime: recordDateTime,
  3906. Stage: 2,
  3907. }
  3908. service.CreateErrMsgLog(errlog)
  3909. c.ServeSuccessJSON(map[string]interface{}{
  3910. "failed_code": -10,
  3911. "msg": resThree.ErrMsg,
  3912. })
  3913. return
  3914. }
  3915. his.Number = resThree.Output.Data.MdtrtID
  3916. his.PsnNo = resThree.Output.Data.PsnNo
  3917. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3918. his.IdCardNo = patient.IdCardNo
  3919. his.PhoneNumber = patient.Phone
  3920. his.UserOrgId = adminInfo.CurrentOrgId
  3921. his.Insutype = insutype
  3922. his.Ctime = time.Now().Unix()
  3923. his.Mtime = time.Now().Unix()
  3924. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3925. his.Status = 1
  3926. service.UpdateHisPatientStatus(&his)
  3927. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3928. c.ServeSuccessJSON(map[string]interface{}{
  3929. "his_info": his,
  3930. })
  3931. } else {
  3932. adminUser := c.GetAdminUserInfo()
  3933. errlog := &models.HisOrderError{
  3934. UserOrgId: adminUser.CurrentOrgId,
  3935. Ctime: time.Now().Unix(),
  3936. Mtime: time.Now().Unix(),
  3937. ErrMsg: res.ErrMsg,
  3938. Status: 1,
  3939. PatientId: id,
  3940. RecordTime: recordDateTime,
  3941. Stage: 1,
  3942. }
  3943. service.CreateErrMsgLog(errlog)
  3944. c.ServeSuccessJSON(map[string]interface{}{
  3945. "failed_code": -10,
  3946. "msg": res.ErrMsg,
  3947. })
  3948. return
  3949. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3950. }
  3951. }
  3952. }
  3953. //上传明细----预结算----确认订单
  3954. func (c *HisApiController) GetUploadInfo() {
  3955. id, _ := c.GetInt64("id")
  3956. record_time := c.GetString("record_time")
  3957. his_patient_id, _ := c.GetInt64("his_patient_id")
  3958. order_id, _ := c.GetInt64("order_id")
  3959. pay_way, _ := c.GetInt64("pay_way")
  3960. pay_price, _ := c.GetFloat("pay_price")
  3961. pay_card_no := c.GetString("pay_card_no")
  3962. discount_price, _ := c.GetFloat("discount_price")
  3963. preferential_price, _ := c.GetFloat("preferential_price")
  3964. reality_price, _ := c.GetFloat("reality_price")
  3965. found_price, _ := c.GetFloat("found_price")
  3966. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3967. private_price, _ := c.GetFloat("private_price")
  3968. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3969. admin_user_id, _ := c.GetInt64("admin_user_id")
  3970. fapiao_code := c.GetString("fapiao_code")
  3971. fapiao_number := c.GetString("fapiao_number")
  3972. diagnosis_id := c.GetString("diagnosis")
  3973. sick_type, _ := c.GetInt64("sick_type")
  3974. reg_type, _ := c.GetInt64("p_type")
  3975. begin_time := c.GetString("begin_time")
  3976. id_str := c.GetString("ids")
  3977. ids_arr := strings.Split(id_str, ",")
  3978. timeLayout := "2006-01-02"
  3979. loc, _ := time.LoadLocation("Local")
  3980. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3981. if err != nil {
  3982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3983. return
  3984. }
  3985. recordDateTime := theTime.Unix()
  3986. adminUser := c.GetAdminUserInfo()
  3987. var tempOrder models.HisOrder
  3988. tempOrder, _ = service.GetHisOrderByID(order_id)
  3989. var prescriptions []*models.HisPrescription
  3990. var start_time int64
  3991. var end_time int64
  3992. //if adminUser.CurrentOrgId == 10106{
  3993. // if len(fapiao_code) == 0{
  3994. // fapiao_code = "144072080589"
  3995. // }
  3996. // if len(fapiao_number) == 0{
  3997. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3998. // if order.ID == 0{
  3999. // fapiao_number = "00001520"
  4000. // }else{
  4001. // //fapiao_code = "00001520"
  4002. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4003. // var zero string
  4004. // if fpNumber >= 1000{
  4005. // zero = "0000" + strconv.Itoa(fpNumber)
  4006. // }else if fpNumber >= 10000{
  4007. // zero = "000" + strconv.Itoa(fpNumber)
  4008. // } else if fpNumber >= 100000{
  4009. // zero = "00" + strconv.Itoa(fpNumber)
  4010. // } else if fpNumber >= 1000000{
  4011. // zero = "0" + strconv.Itoa(fpNumber)
  4012. // }else {
  4013. // zero = strconv.Itoa(fpNumber)
  4014. // }
  4015. // fapiao_number = zero
  4016. // }
  4017. // }
  4018. //}
  4019. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4020. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4021. var patientPrescription models.HisPrescriptionInfo
  4022. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4023. if patientPrescription.ID == 0 {
  4024. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4025. }
  4026. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4027. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4028. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4029. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4030. var config []*models.HisXtDiagnoseConfig
  4031. for _, item := range diagnosis_ids {
  4032. id, _ := strconv.ParseInt(item, 10, 64)
  4033. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4034. config = append(config, &diagnosisConfig)
  4035. }
  4036. sickConfig, _ := service.FindSickById(sick_type)
  4037. //if tempOrder.ID == 0 {
  4038. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4039. //}
  4040. if tempOrder.ID == 0 {
  4041. var result string
  4042. var requestLog string
  4043. var res2 ResultSix
  4044. var ressix10265 ResultSix10265
  4045. if miConfig.MdtrtareaAdmvs == "421300" {
  4046. data := make(map[string]interface{})
  4047. client := &http.Client{}
  4048. data["psn_no"] = his.PsnNo
  4049. data["mdtrt_id"] = his.Number
  4050. data["doctor"] = roles.UserName
  4051. data["department"] = department.Name
  4052. data["org_name"] = miConfig.OrgName
  4053. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4054. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4055. data["fixmedins_code"] = miConfig.Code
  4056. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4057. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4058. data["secret_key"] = miConfig.SecretKey
  4059. data["sick_code"] = sickConfig.CountryCode
  4060. data["sick_name"] = sickConfig.ClassName
  4061. data["dept"] = strconv.FormatInt(department.ID, 10)
  4062. data["config"] = config
  4063. data["begin_time"] = begin_time
  4064. bytesData, _ := json.Marshal(data)
  4065. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4066. resp, _ := client.Do(req)
  4067. defer resp.Body.Close()
  4068. body, ioErr := ioutil.ReadAll(resp.Body)
  4069. if ioErr != nil {
  4070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4072. return
  4073. }
  4074. var respJSON map[string]interface{}
  4075. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4078. return
  4079. }
  4080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4081. userJSONBytes, _ := json.Marshal(respJSON)
  4082. fmt.Println("log")
  4083. fmt.Println(string(userJSONBytes))
  4084. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4085. utils.ErrorLog("解析失败:%v", err)
  4086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4087. return
  4088. }
  4089. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4090. //江苏地区国家医保医疗类别
  4091. //职工透析:医疗类别选特殊情况门诊9933
  4092. //居民血透门慢: 医疗类别选门诊慢病1402
  4093. //var med_type string
  4094. //if his.Insutype == "310" {
  4095. // if reg_type == 14 {
  4096. // med_type = "9933"
  4097. // } else if reg_type == 11 {
  4098. // med_type = "11"
  4099. //
  4100. // }
  4101. //} else if his.Insutype == "390" {
  4102. // if reg_type == 14 {
  4103. // med_type = "1402"
  4104. // } else if reg_type == 11 {
  4105. // med_type = "11"
  4106. // }
  4107. //}
  4108. data := make(map[string]interface{})
  4109. client := &http.Client{}
  4110. data["psn_no"] = his.PsnNo
  4111. data["mdtrt_id"] = his.Number
  4112. data["doctor"] = roles.UserName
  4113. data["department"] = department.Name
  4114. data["org_name"] = miConfig.OrgName
  4115. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4116. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4117. data["fixmedins_code"] = miConfig.Code
  4118. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4119. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4120. data["secret_key"] = miConfig.SecretKey
  4121. data["sick_code"] = sickConfig.CountryCode
  4122. data["sick_name"] = sickConfig.ClassName
  4123. data["url"] = miConfig.Url
  4124. data["ak"] = miConfig.AccessKey
  4125. data["begin_time"] = begin_time
  4126. data["cainfo"] = miConfig.Cainfo
  4127. data["dept"] = strconv.FormatInt(department.ID, 10)
  4128. data["config"] = config
  4129. bytesData, _ := json.Marshal(data)
  4130. var req *http.Request
  4131. if miConfig.MdtrtareaAdmvs == "320921" {
  4132. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4133. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4134. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4135. } else {
  4136. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4137. }
  4138. resp, _ := client.Do(req)
  4139. defer resp.Body.Close()
  4140. body, ioErr := ioutil.ReadAll(resp.Body)
  4141. if ioErr != nil {
  4142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4144. return
  4145. }
  4146. var respJSON map[string]interface{}
  4147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4150. return
  4151. }
  4152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4153. userJSONBytes, _ := json.Marshal(respJSON)
  4154. fmt.Println("log")
  4155. fmt.Println(string(userJSONBytes))
  4156. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4157. utils.ErrorLog("解析失败:%v", err)
  4158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4159. return
  4160. }
  4161. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4162. res2.Output = ressix10265.Output
  4163. res2.ErrMsg = ressix10265.ErrMsg
  4164. res2.Cainfo = ressix10265.Cainfo
  4165. res2.WarnMsg = ressix10265.WarnMsg
  4166. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4167. res2.Infcode = infocode
  4168. } else {
  4169. if miConfig.MdtrtareaAdmvs == "440781" { //
  4170. 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)
  4171. } else {
  4172. if miConfig.Code == "H15049901371" {
  4173. //赤峰地区国家医保医疗类别
  4174. //职工透析:医疗类别选特殊情况门诊990502
  4175. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4176. var med_type string
  4177. if his.Insutype == "390" {
  4178. if reg_type == 14 {
  4179. med_type = "9933"
  4180. } else if reg_type == 11 {
  4181. med_type = "11"
  4182. }
  4183. } else if his.Insutype == "310" {
  4184. if reg_type == 14 {
  4185. med_type = "990502"
  4186. } else if reg_type == 11 {
  4187. med_type = "11"
  4188. }
  4189. }
  4190. 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)
  4191. } else {
  4192. 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)
  4193. }
  4194. }
  4195. saveLog(result, requestLog, "2203", "上传就诊信息")
  4196. var respJSON2 map[string]interface{}
  4197. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. userJSONBytes2, _ := json.Marshal(respJSON2)
  4203. if miConfig.Code == "H15049901371" {
  4204. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4205. utils.ErrorLog("解析失败:%v", err)
  4206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4207. return
  4208. }
  4209. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4210. res2.Output = ressix10265.Output
  4211. res2.ErrMsg = ressix10265.ErrMsg
  4212. res2.Cainfo = ressix10265.Cainfo
  4213. res2.WarnMsg = ressix10265.WarnMsg
  4214. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4215. res2.Infcode = infocode
  4216. } else {
  4217. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4218. utils.ErrorLog("解析失败:%v", err)
  4219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4220. return
  4221. }
  4222. }
  4223. }
  4224. if res2.Infcode != 0 {
  4225. adminUser := c.GetAdminUserInfo()
  4226. errlog := &models.HisOrderError{
  4227. UserOrgId: adminUser.CurrentOrgId,
  4228. Ctime: time.Now().Unix(),
  4229. Mtime: time.Now().Unix(),
  4230. ErrMsg: res2.ErrMsg,
  4231. Status: 1,
  4232. PatientId: id,
  4233. RecordTime: recordDateTime,
  4234. Stage: 3,
  4235. }
  4236. service.CreateErrMsgLog(errlog)
  4237. c.ServeSuccessJSON(map[string]interface{}{
  4238. "failed_code": -10,
  4239. "msg": res2.ErrMsg,
  4240. })
  4241. return
  4242. } else {
  4243. his.Diagnosis = diagnosis_id
  4244. his.SickType = sickConfig.ID
  4245. //var p_type int64
  4246. //if reg_type == 1111 || reg_type == 1112 {
  4247. // p_type = 11
  4248. //
  4249. //}
  4250. his.PType = fmt.Sprintf("%d", reg_type)
  4251. service.UpdateHisPatientThree(&his)
  4252. data := make(map[string]interface{})
  4253. if settle_accounts_type == 1 { //日结
  4254. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4255. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4256. } else {
  4257. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4258. }
  4259. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4260. data["pre"] = prescriptions
  4261. } else { //月结
  4262. start_time_str := c.GetString("start_time")
  4263. end_time_str := c.GetString("end_time")
  4264. timeLayout := "2006-01-02"
  4265. loc, _ := time.LoadLocation("Local")
  4266. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4267. if err != nil {
  4268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4269. return
  4270. }
  4271. recordStartTime := theStartTime.Unix()
  4272. start_time = recordStartTime
  4273. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4274. if err != nil {
  4275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4276. return
  4277. }
  4278. recordEndTime := theEndTime.Unix()
  4279. end_time = recordEndTime
  4280. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4281. data["pre"] = prescriptions
  4282. }
  4283. timestamp := time.Now().Unix()
  4284. tempTime := time.Unix(timestamp, 0)
  4285. timeFormat := tempTime.Format("20060102150405")
  4286. chrgBchno := rand.Intn(100000) + 10000
  4287. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4288. strconv.FormatInt(his.PatientId, 10)
  4289. client := &http.Client{}
  4290. data["psn_no"] = his.PsnNo
  4291. data["mdtrt_id"] = his.Number
  4292. data["chrg_bchno"] = chrg_bchno
  4293. data["org_name"] = miConfig.OrgName
  4294. data["doctor"] = roles.UserName
  4295. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4296. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4297. data["fixmedins_code"] = miConfig.Code
  4298. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4299. // data["dept_code"] = "15"
  4300. //} else {
  4301. data["dept_code"] = department.Number
  4302. //}
  4303. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4304. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4305. data["secret_key"] = miConfig.SecretKey
  4306. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4307. data["url"] = miConfig.Url
  4308. data["ak"] = miConfig.AccessKey
  4309. data["new_doctor_name"] = patientPrescription.Doctor
  4310. data["diag_code"] = sickConfig.CountryCode
  4311. data["cainfo"] = miConfig.Cainfo
  4312. var ids []int64
  4313. for _, item := range prescriptions {
  4314. ids = append(ids, item.ID)
  4315. }
  4316. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4317. if config.IsOpen == 1 { //对接了医保,走医保流程
  4318. var res ResultFour
  4319. var resFour10265 ResultFour10265
  4320. if miConfig.MdtrtareaAdmvs == "421300" {
  4321. bytesData, _ := json.Marshal(data)
  4322. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4323. resp, _ := client.Do(req)
  4324. defer resp.Body.Close()
  4325. body, ioErr := ioutil.ReadAll(resp.Body)
  4326. if ioErr != nil {
  4327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4329. return
  4330. }
  4331. var respJSON map[string]interface{}
  4332. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4335. return
  4336. }
  4337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4338. userJSONBytes, _ := json.Marshal(respJSON)
  4339. fmt.Println("log")
  4340. fmt.Println(string(userJSONBytes))
  4341. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4342. utils.ErrorLog("解析失败:%v", err)
  4343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. return
  4345. }
  4346. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4347. bytesData, _ := json.Marshal(data)
  4348. var req *http.Request
  4349. if miConfig.MdtrtareaAdmvs == "320921" {
  4350. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4351. } else {
  4352. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4353. }
  4354. resp, _ := client.Do(req)
  4355. defer resp.Body.Close()
  4356. body, ioErr := ioutil.ReadAll(resp.Body)
  4357. if ioErr != nil {
  4358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4360. return
  4361. }
  4362. var respJSON map[string]interface{}
  4363. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4366. return
  4367. }
  4368. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4369. userJSONBytes, _ := json.Marshal(respJSON)
  4370. fmt.Println("log")
  4371. fmt.Println(string(userJSONBytes))
  4372. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4373. utils.ErrorLog("解析失败:%v", err)
  4374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4375. return
  4376. }
  4377. res.InfRefmsgid = resFour10265.InfRefmsgid
  4378. res.Output = resFour10265.Output
  4379. res.ErrMsg = resFour10265.ErrMsg
  4380. res.Cainfo = resFour10265.Cainfo
  4381. res.WarnMsg = resFour10265.WarnMsg
  4382. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4383. res.Infcode = infocode
  4384. } else {
  4385. if miConfig.Code == "H15049901371" {
  4386. 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)
  4387. var dat map[string]interface{}
  4388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4389. fmt.Println(dat)
  4390. } else {
  4391. fmt.Println(err)
  4392. }
  4393. saveLog(result, request_log, "2204", "上传费用明细")
  4394. userJSONBytes, _ := json.Marshal(dat)
  4395. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4396. utils.ErrorLog("解析失败:%v", err)
  4397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4398. return
  4399. }
  4400. res.InfRefmsgid = resFour10265.InfRefmsgid
  4401. res.Output = resFour10265.Output
  4402. res.ErrMsg = resFour10265.ErrMsg
  4403. res.Cainfo = resFour10265.Cainfo
  4404. res.WarnMsg = resFour10265.WarnMsg
  4405. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4406. res.Infcode = infocode
  4407. } else {
  4408. 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)
  4409. var dat map[string]interface{}
  4410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4411. fmt.Println(dat)
  4412. } else {
  4413. fmt.Println(err)
  4414. }
  4415. saveLog(result, request_log, "2204", "上传费用明细")
  4416. userJSONBytes, _ := json.Marshal(dat)
  4417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4418. utils.ErrorLog("解析失败:%v", err)
  4419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4420. return
  4421. }
  4422. }
  4423. }
  4424. if res.Infcode == 0 {
  4425. order := &models.HisOrder{
  4426. UserOrgId: adminUser.CurrentOrgId,
  4427. HisPatientId: his.ID,
  4428. PatientId: his.PatientId,
  4429. SettleAccountsDate: recordDateTime,
  4430. MdtrtId: his.Number,
  4431. PsnNo: his.PsnNo,
  4432. MedType: strconv.FormatInt(reg_type, 10),
  4433. Ctime: time.Now().Unix(),
  4434. Mtime: time.Now().Unix(),
  4435. Status: 1,
  4436. Number: chrg_bchno,
  4437. Infcode: res.Infcode,
  4438. WarnMsg: res.WarnMsg,
  4439. Cainfo: res.Cainfo,
  4440. ErrMsg: res.ErrMsg,
  4441. RespondTime: res.RefmsgTime,
  4442. InfRefmsgid: res.InfRefmsgid,
  4443. OrderStatus: 1,
  4444. PayWay: pay_way,
  4445. PayPrice: pay_price,
  4446. PayCardNo: pay_card_no,
  4447. DiscountPrice: discount_price,
  4448. PreferentialPrice: preferential_price,
  4449. RealityPrice: reality_price,
  4450. FoundPrice: found_price,
  4451. MedicalInsurancePrice: medical_insurance_price,
  4452. PrivatePrice: private_price,
  4453. IsMedicineInsurance: 1,
  4454. SettleType: settle_accounts_type,
  4455. SettleStartTime: start_time,
  4456. SettleEndTime: end_time,
  4457. Creator: roles.AdminUserId,
  4458. Modify: roles.AdminUserId,
  4459. FaPiaoNumber: fapiao_number,
  4460. FaPiaoCode: fapiao_code,
  4461. PType: 2,
  4462. Diagnosis: diagnosis_id,
  4463. }
  4464. err = service.CreateOrder(order)
  4465. if err != nil {
  4466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4467. return
  4468. }
  4469. for _, item := range res.Output.Result {
  4470. temp := strings.Split(item.FeedetlSn, "-")
  4471. var advice_id int64 = 0
  4472. var project_id int64 = 0
  4473. var types int64 = 0
  4474. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4475. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4476. if temp[1] == "1" {
  4477. advice_id = id
  4478. project_id = 0
  4479. } else if temp[1] == "2" {
  4480. advice_id = 0
  4481. project_id = id
  4482. }
  4483. info := &models.HisOrderInfo{
  4484. OrderNumber: order.Number,
  4485. FeedetlSn: item.FeedetlSn,
  4486. UploadDate: time.Now().Unix(),
  4487. AdviceId: advice_id,
  4488. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4489. Cnt: item.Cnt,
  4490. Pric: float64(item.Pric),
  4491. PatientId: his.PatientId,
  4492. PricUplmtAmt: item.PricUplmtAmt,
  4493. SelfpayProp: item.SelfpayProp,
  4494. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4495. OverlmtAmt: item.OverlmtAmt,
  4496. PreselfpayAmt: item.PreselfpayAmt,
  4497. BasMednFlag: item.BasMednFlag,
  4498. MedChrgitmType: item.MedChrgitmType,
  4499. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4500. Status: 1,
  4501. Memo: item.Memo,
  4502. Mtime: time.Now().Unix(),
  4503. InscpScpAmt: item.InscpScpAmt,
  4504. DrtReimFlag: item.DrtReimFlag,
  4505. Ctime: time.Now().Unix(),
  4506. ListSpItemFlag: item.ListSpItemFlag,
  4507. ChldMedcFlag: item.ChldMedcFlag,
  4508. LmtUsedFlag: item.LmtUsedFlag,
  4509. ChrgitmLv: item.ChrgitmLv,
  4510. UserOrgId: adminUser.CurrentOrgId,
  4511. HisPatientId: his.ID,
  4512. OrderId: order.ID,
  4513. ProjectId: project_id,
  4514. Type: types,
  4515. }
  4516. service.CreateOrderInfo(info)
  4517. }
  4518. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4519. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4520. var total float64
  4521. for _, item := range prescriptions {
  4522. if item.Type == 1 { //药品
  4523. for _, subItem := range item.HisDoctorAdviceInfo {
  4524. total = total + (subItem.Price * subItem.PrescribingNumber)
  4525. }
  4526. }
  4527. if item.Type == 2 { //项目
  4528. for _, subItem := range item.HisPrescriptionProject {
  4529. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4530. total = total + (subItem.Price * cnt)
  4531. }
  4532. }
  4533. }
  4534. for _, item := range prescriptions {
  4535. for _, subItem := range item.HisAdditionalCharge {
  4536. total = total + (subItem.Price * float64(subItem.Count))
  4537. }
  4538. }
  4539. var allTotal string
  4540. if adminUser.CurrentOrgId == 9919 {
  4541. allTotal = fmt.Sprintf("%.4f", total)
  4542. } else {
  4543. allTotal = fmt.Sprintf("%.4f", total)
  4544. }
  4545. if res.Infcode == 0 {
  4546. var rf []*ResultFive
  4547. json.Unmarshal([]byte(his.Iinfo), &rf)
  4548. chrg_bchno := chrg_bchno
  4549. cert_no := his.Certno
  4550. var insutypes []string
  4551. var insutype string
  4552. var is390 int = 0
  4553. var is310 int = 0
  4554. for _, item := range rf {
  4555. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4556. insutypes = append(insutypes, item.Insutype)
  4557. }
  4558. }
  4559. if len(insutypes) == 1 {
  4560. insutype = insutypes[0]
  4561. } else {
  4562. for _, i := range insutypes {
  4563. if i == "390" {
  4564. is390 = 1
  4565. }
  4566. if i == "310" {
  4567. is310 = 1
  4568. }
  4569. }
  4570. }
  4571. if is390 == 1 {
  4572. insutype = "390"
  4573. }
  4574. if is310 == 1 {
  4575. insutype = "310"
  4576. }
  4577. if len(insutypes) == 0 {
  4578. insutype = "310"
  4579. }
  4580. if len(insutypes) == 2 {
  4581. insutype = strconv.FormatInt(his.SocialType, 10)
  4582. }
  4583. insutype = strconv.FormatInt(his.SocialType, 10)
  4584. //insutype = "390"
  4585. if his.IdCardType == 1 {
  4586. // cert_no = his.MedicalInsuranceNumber
  4587. cert_no = his.Certno
  4588. } else {
  4589. cert_no = his.Certno
  4590. }
  4591. var res ResultSeven
  4592. var resSeven10265 ResultSeven10265
  4593. var src_resquest string
  4594. var result2 string
  4595. var acct_used_flag string
  4596. fmt.Println("pay_way")
  4597. fmt.Println(pay_way)
  4598. fmt.Println("pay_way")
  4599. if pay_way == 4 {
  4600. acct_used_flag = "1"
  4601. } else {
  4602. acct_used_flag = "0"
  4603. }
  4604. if miConfig.MdtrtareaAdmvs == "421300" {
  4605. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4606. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4607. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4608. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4609. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4610. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4611. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4612. resp, requestErr := http.Get(api)
  4613. if requestErr != nil {
  4614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4615. return
  4616. }
  4617. body, ioErr := ioutil.ReadAll(resp.Body)
  4618. if ioErr != nil {
  4619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4621. return
  4622. }
  4623. var respJSON map[string]interface{}
  4624. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4627. return
  4628. }
  4629. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4630. result, _ := json.Marshal(respJSON)
  4631. if miConfig.Code == "H15049901371" {
  4632. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4633. utils.ErrorLog("解析失败:%v", err)
  4634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4635. return
  4636. }
  4637. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4638. res.Output = resSeven10265.Output
  4639. res.ErrMsg = resSeven10265.ErrMsg
  4640. res.Cainfo = resSeven10265.Cainfo
  4641. res.WarnMsg = resSeven10265.WarnMsg
  4642. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4643. res.Infcode = infocode
  4644. } else {
  4645. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4646. utils.ErrorLog("解析失败:%v", err)
  4647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4648. return
  4649. }
  4650. }
  4651. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4652. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4653. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4654. //psn_info, _ := service.GetPsnByPatientId(id)
  4655. bas := strings.Split(psn_info.CardInfo, "|")
  4656. if his.IdCardType == 1 {
  4657. cert_no = bas[2]
  4658. } else if his.IdCardType == 3 {
  4659. cert_no = his.Certno
  4660. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  4661. } else {
  4662. cert_no = bas[1]
  4663. }
  4664. //江苏地区国家医保医疗类别
  4665. //职工透析:医疗类别选特殊情况门诊9933
  4666. //居民血透门慢: 医疗类别选门诊慢病1402
  4667. //var med_type string
  4668. //if his.Insutype == "310" {
  4669. // if reg_type == 14 {
  4670. // med_type = "9933"
  4671. // } else if reg_type == 11 {
  4672. // med_type = "11"
  4673. //
  4674. // }
  4675. //} else if his.Insutype == "390" {
  4676. // if reg_type == 14 {
  4677. // med_type = "1402"
  4678. // } else if reg_type == 11 {
  4679. // med_type = "11"
  4680. // }
  4681. //}
  4682. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4683. var api string
  4684. if miConfig.MdtrtareaAdmvs == "320921" {
  4685. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4686. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4687. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4688. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4689. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4690. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4691. "&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
  4692. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4693. } else {
  4694. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4695. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4696. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4697. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4698. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4699. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4700. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4701. "&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
  4702. }
  4703. resp, requestErr := http.Get(api)
  4704. if requestErr != nil {
  4705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4706. return
  4707. }
  4708. body, ioErr := ioutil.ReadAll(resp.Body)
  4709. if ioErr != nil {
  4710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4712. return
  4713. }
  4714. var respJSON map[string]interface{}
  4715. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4718. return
  4719. }
  4720. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4721. result, _ := json.Marshal(respJSON)
  4722. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4723. utils.ErrorLog("解析失败:%v", err)
  4724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4725. return
  4726. }
  4727. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4728. res.Output = resSeven10265.Output
  4729. res.ErrMsg = resSeven10265.ErrMsg
  4730. res.Cainfo = resSeven10265.Cainfo
  4731. res.WarnMsg = resSeven10265.WarnMsg
  4732. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4733. res.Infcode = infocode
  4734. } else {
  4735. if miConfig.Code == "H15049901371" {
  4736. //赤峰地区国家医保医疗类别
  4737. //职工透析:医疗类别选特殊情况门诊990502
  4738. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4739. var med_type string
  4740. if his.Insutype == "390" {
  4741. if reg_type == 14 {
  4742. med_type = "9933"
  4743. } else if reg_type == 11 {
  4744. med_type = "11"
  4745. }
  4746. } else if his.Insutype == "310" {
  4747. if reg_type == 14 {
  4748. med_type = "990502"
  4749. } else if reg_type == 11 {
  4750. med_type = "11"
  4751. }
  4752. }
  4753. 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)
  4754. } else {
  4755. 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)
  4756. }
  4757. //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)
  4758. var dat map[string]interface{}
  4759. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4760. fmt.Println(dat)
  4761. } else {
  4762. fmt.Println(err)
  4763. }
  4764. saveLog(result2, src_resquest, "2207", "结算")
  4765. userJSONBytes, _ := json.Marshal(dat)
  4766. if miConfig.Code == "H15049901371" {
  4767. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4768. utils.ErrorLog("解析失败:%v", err)
  4769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4770. return
  4771. }
  4772. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4773. res.Output = resSeven10265.Output
  4774. res.ErrMsg = resSeven10265.ErrMsg
  4775. res.Cainfo = resSeven10265.Cainfo
  4776. res.WarnMsg = resSeven10265.WarnMsg
  4777. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4778. res.Infcode = infocode
  4779. } else {
  4780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4781. utils.ErrorLog("解析失败:%v", err)
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. return
  4784. }
  4785. }
  4786. }
  4787. if res.Infcode != 0 {
  4788. errlog := &models.HisOrderError{
  4789. UserOrgId: adminUser.CurrentOrgId,
  4790. Ctime: time.Now().Unix(),
  4791. Mtime: time.Now().Unix(),
  4792. Number: chrg_bchno,
  4793. ErrMsg: res.ErrMsg,
  4794. Status: 1,
  4795. PatientId: id,
  4796. RecordTime: recordDateTime,
  4797. Stage: 6,
  4798. }
  4799. service.CreateErrMsgLog(errlog)
  4800. c.ServeSuccessJSON(map[string]interface{}{
  4801. "failed_code": -10,
  4802. "msg": res.ErrMsg,
  4803. })
  4804. return
  4805. } else {
  4806. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4807. order.OrderStatus = 2
  4808. order.Status = 1
  4809. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4810. order.SetlId = res.Output.Setlinfo.SetlID
  4811. order.PsnNo = res.Output.Setlinfo.PsnNo
  4812. order.PsnName = res.Output.Setlinfo.PsnName
  4813. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4814. order.Certno = res.Output.Setlinfo.Certno
  4815. order.Gend = res.Output.Setlinfo.Gend
  4816. order.Naty = res.Output.Setlinfo.Naty
  4817. order.Age = res.Output.Setlinfo.Age
  4818. order.Insutype = res.Output.Setlinfo.Insutype
  4819. order.PsnType = res.Output.Setlinfo.PsnType
  4820. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4821. order.SetlTime = res.Output.Setlinfo.SetlTime
  4822. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4823. if res.Output.Setlinfo.MedType == "140101" {
  4824. order.MedType = "14"
  4825. } else {
  4826. order.MedType = res.Output.Setlinfo.MedType
  4827. }
  4828. if reg_type == 1112 {
  4829. order.MedType = "1112"
  4830. }
  4831. if reg_type == 1111 {
  4832. order.MedType = "1111"
  4833. }
  4834. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4835. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4836. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4837. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4838. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4839. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4840. order.HifpPay = res.Output.Setlinfo.HifpPay
  4841. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4842. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4843. order.HifesPay = res.Output.Setlinfo.HifesPay
  4844. order.HifobPay = res.Output.Setlinfo.HifobPay
  4845. order.MafPay = res.Output.Setlinfo.MafPay
  4846. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4847. order.OthPay = res.Output.Setlinfo.OthPay
  4848. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4849. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4850. order.AcctPay = res.Output.Setlinfo.AcctPay
  4851. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4852. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4853. order.Balc = res.Output.Setlinfo.Balc
  4854. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4855. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4856. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4857. order.ClrType = res.Output.Setlinfo.ClrType
  4858. order.ClrWay = res.Output.Setlinfo.ClrWay
  4859. order.Creator = order.Creator
  4860. order.Modify = roles.AdminUserId
  4861. order.RequestLog = src_resquest
  4862. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4863. detailStr := string(setlDetail)
  4864. order.SetlDetail = detailStr
  4865. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4866. err = service.UpDateOrder(order)
  4867. if err == nil {
  4868. c.ServeSuccessJSON(map[string]interface{}{
  4869. "msg": "结算成功",
  4870. })
  4871. } else {
  4872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4873. return
  4874. }
  4875. }
  4876. } else {
  4877. adminUser := c.GetAdminUserInfo()
  4878. errlog := &models.HisOrderError{
  4879. UserOrgId: adminUser.CurrentOrgId,
  4880. Ctime: time.Now().Unix(),
  4881. Mtime: time.Now().Unix(),
  4882. ErrMsg: res.ErrMsg,
  4883. Status: 1,
  4884. PatientId: id,
  4885. RecordTime: recordDateTime,
  4886. Stage: 4,
  4887. }
  4888. service.CreateErrMsgLog(errlog)
  4889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4890. return
  4891. }
  4892. } else {
  4893. adminUser := c.GetAdminUserInfo()
  4894. errlog := &models.HisOrderError{
  4895. UserOrgId: adminUser.CurrentOrgId,
  4896. Ctime: time.Now().Unix(),
  4897. Mtime: time.Now().Unix(),
  4898. ErrMsg: res.ErrMsg,
  4899. Status: 1,
  4900. PatientId: id,
  4901. RecordTime: recordDateTime,
  4902. Stage: 4,
  4903. }
  4904. service.CreateErrMsgLog(errlog)
  4905. c.ServeSuccessJSON(map[string]interface{}{
  4906. "failed_code": -10,
  4907. "msg": res.ErrMsg,
  4908. })
  4909. return
  4910. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4911. //return
  4912. }
  4913. }
  4914. }
  4915. } else if tempOrder.ID > 0 {
  4916. if tempOrder.IsPre == 1 {
  4917. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4918. var rf []*ResultFive
  4919. json.Unmarshal([]byte(his.Iinfo), &rf)
  4920. chrg_bchno := tempOrder.Number
  4921. cert_no := his.Certno
  4922. var insutypes []string
  4923. var insutype string
  4924. var is390 int = 0
  4925. var is310 int = 0
  4926. for _, item := range rf {
  4927. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4928. insutypes = append(insutypes, item.Insutype)
  4929. }
  4930. }
  4931. if len(insutypes) == 1 {
  4932. insutype = insutypes[0]
  4933. } else {
  4934. for _, i := range insutypes {
  4935. if i == "390" {
  4936. is390 = 1
  4937. }
  4938. if i == "310" {
  4939. is310 = 1
  4940. }
  4941. }
  4942. }
  4943. if is390 == 1 {
  4944. insutype = "390"
  4945. }
  4946. if is310 == 1 {
  4947. insutype = "310"
  4948. }
  4949. if len(insutypes) == 0 {
  4950. insutype = "310"
  4951. }
  4952. if len(insutypes) == 2 {
  4953. insutype = strconv.FormatInt(his.SocialType, 64)
  4954. }
  4955. //insutype = "390"
  4956. if his.IdCardType == 1 {
  4957. // cert_no = his.MedicalInsuranceNumber
  4958. cert_no = his.Certno
  4959. } else {
  4960. cert_no = his.Certno
  4961. }
  4962. var res ResultSeven
  4963. var resSeven10265 ResultSeven10265
  4964. var src_resquest string
  4965. var result2 string
  4966. var acct_used_flag string
  4967. fmt.Println("pay_way")
  4968. fmt.Println(pay_way)
  4969. fmt.Println("pay_way")
  4970. if pay_way == 4 {
  4971. acct_used_flag = "1"
  4972. } else {
  4973. acct_used_flag = "0"
  4974. }
  4975. if miConfig.MdtrtareaAdmvs == "421300" {
  4976. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4977. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4978. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4980. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4981. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4982. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4983. resp, requestErr := http.Get(api)
  4984. if requestErr != nil {
  4985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4986. return
  4987. }
  4988. body, ioErr := ioutil.ReadAll(resp.Body)
  4989. if ioErr != nil {
  4990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4992. return
  4993. }
  4994. var respJSON map[string]interface{}
  4995. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4998. return
  4999. }
  5000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5001. result, _ := json.Marshal(respJSON)
  5002. fmt.Println("log")
  5003. fmt.Println(string(result))
  5004. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5005. utils.ErrorLog("解析失败:%v", err)
  5006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5007. return
  5008. }
  5009. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5010. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5011. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5012. //psn_info, _ := service.GetPsnByPatientId(id)
  5013. bas := strings.Split(psn_info.CardInfo, "|")
  5014. if his.IdCardType == 1 {
  5015. cert_no = bas[2]
  5016. } else {
  5017. cert_no = bas[1]
  5018. }
  5019. //江苏地区国家医保医疗类别
  5020. //职工透析:医疗类别选特殊情况门诊9933
  5021. //居民血透门慢: 医疗类别选门诊慢病1402
  5022. //var med_type string
  5023. //if his.Insutype == "310" {
  5024. // if reg_type == 14 {
  5025. // med_type = "9933"
  5026. // } else if reg_type == 11 {
  5027. // med_type = "11"
  5028. //
  5029. // }
  5030. //} else if his.Insutype == "390" {
  5031. // if reg_type == 14 {
  5032. // med_type = "1402"
  5033. // } else if reg_type == 11 {
  5034. // med_type = "11"
  5035. // }
  5036. //}
  5037. var api string
  5038. if miConfig.MdtrtareaAdmvs == "320921" {
  5039. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5040. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5041. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5042. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5043. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5044. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5045. "&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
  5046. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5047. } else {
  5048. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5049. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5050. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5051. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5052. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5053. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5054. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5055. "&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
  5056. }
  5057. resp, requestErr := http.Get(api)
  5058. if requestErr != nil {
  5059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5060. return
  5061. }
  5062. body, ioErr := ioutil.ReadAll(resp.Body)
  5063. if ioErr != nil {
  5064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5066. return
  5067. }
  5068. var respJSON map[string]interface{}
  5069. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5072. return
  5073. }
  5074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5075. result, _ := json.Marshal(respJSON)
  5076. fmt.Println("log")
  5077. fmt.Println(string(result))
  5078. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5079. utils.ErrorLog("解析失败:%v", err)
  5080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5081. return
  5082. }
  5083. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5084. res.Output = resSeven10265.Output
  5085. res.ErrMsg = resSeven10265.ErrMsg
  5086. res.Cainfo = resSeven10265.Cainfo
  5087. res.WarnMsg = resSeven10265.WarnMsg
  5088. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5089. res.Infcode = infocode
  5090. } else {
  5091. var src_resquest string
  5092. if miConfig.Code == "H15049901371" {
  5093. //赤峰地区国家医保医疗类别
  5094. //职工透析:医疗类别选特殊情况门诊990502
  5095. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5096. var med_type string
  5097. if his.Insutype == "390" {
  5098. if reg_type == 14 {
  5099. med_type = "9933"
  5100. } else if reg_type == 11 {
  5101. med_type = "11"
  5102. }
  5103. } else if his.Insutype == "310" {
  5104. if reg_type == 14 {
  5105. med_type = "990502"
  5106. } else if reg_type == 11 {
  5107. med_type = "11"
  5108. }
  5109. }
  5110. 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)
  5111. } else {
  5112. 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)
  5113. }
  5114. var dat map[string]interface{}
  5115. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5116. fmt.Println(dat)
  5117. } else {
  5118. fmt.Println(err)
  5119. }
  5120. saveLog(result2, src_resquest, "2207", "结算")
  5121. userJSONBytes, _ := json.Marshal(dat)
  5122. if miConfig.Code == "H15049901371" {
  5123. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5124. utils.ErrorLog("解析失败:%v", err)
  5125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5126. return
  5127. }
  5128. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5129. res.Output = resSeven10265.Output
  5130. res.ErrMsg = resSeven10265.ErrMsg
  5131. res.Cainfo = resSeven10265.Cainfo
  5132. res.WarnMsg = resSeven10265.WarnMsg
  5133. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5134. res.Infcode = infocode
  5135. } else {
  5136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5137. utils.ErrorLog("解析失败:%v", err)
  5138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5139. return
  5140. }
  5141. }
  5142. }
  5143. if res.Infcode != 0 {
  5144. errlog := &models.HisOrderError{
  5145. UserOrgId: adminUser.CurrentOrgId,
  5146. Ctime: time.Now().Unix(),
  5147. Mtime: time.Now().Unix(),
  5148. Number: chrg_bchno,
  5149. ErrMsg: res.ErrMsg,
  5150. Status: 1,
  5151. PatientId: id,
  5152. RecordTime: recordDateTime,
  5153. Stage: 6,
  5154. }
  5155. service.CreateErrMsgLog(errlog)
  5156. c.ServeSuccessJSON(map[string]interface{}{
  5157. "failed_code": -10,
  5158. "msg": res.ErrMsg,
  5159. })
  5160. return
  5161. } else {
  5162. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5163. order.OrderStatus = 2
  5164. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5165. order.SetlId = res.Output.Setlinfo.SetlID
  5166. order.PsnNo = res.Output.Setlinfo.PsnNo
  5167. order.PsnName = res.Output.Setlinfo.PsnName
  5168. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5169. order.Certno = res.Output.Setlinfo.Certno
  5170. order.Gend = res.Output.Setlinfo.Gend
  5171. order.Naty = res.Output.Setlinfo.Naty
  5172. order.Age = res.Output.Setlinfo.Age
  5173. order.Insutype = res.Output.Setlinfo.Insutype
  5174. order.PsnType = res.Output.Setlinfo.PsnType
  5175. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5176. order.SetlTime = res.Output.Setlinfo.SetlTime
  5177. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5178. //order.MedType = res.Output.Setlinfo.MedType
  5179. if reg_type == 1112 {
  5180. order.MedType = "1112"
  5181. }
  5182. if reg_type == 1111 {
  5183. order.MedType = "1111"
  5184. }
  5185. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5186. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5187. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5188. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5189. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5190. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5191. order.HifpPay = res.Output.Setlinfo.HifpPay
  5192. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5193. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5194. order.HifesPay = res.Output.Setlinfo.HifesPay
  5195. order.HifobPay = res.Output.Setlinfo.HifobPay
  5196. order.MafPay = res.Output.Setlinfo.MafPay
  5197. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5198. order.OthPay = res.Output.Setlinfo.OthPay
  5199. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5200. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5201. order.AcctPay = res.Output.Setlinfo.AcctPay
  5202. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5203. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5204. order.Balc = res.Output.Setlinfo.Balc
  5205. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5206. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5207. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5208. order.ClrWay = res.Output.Setlinfo.ClrWay
  5209. order.Creator = order.Creator
  5210. order.Modify = roles.AdminUserId
  5211. order.RequestLog = src_resquest
  5212. order.Diagnosis = diagnosis_id
  5213. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5214. detailStr := string(setlDetail)
  5215. order.SetlDetail = detailStr
  5216. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5217. err = service.UpDateOrder(order)
  5218. if err == nil {
  5219. c.ServeSuccessJSON(map[string]interface{}{
  5220. "msg": "结算成功",
  5221. })
  5222. } else {
  5223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5224. return
  5225. }
  5226. }
  5227. }
  5228. }
  5229. }
  5230. //func (c *HisApiController) GetPreUploadInfo() {
  5231. // id, _ := c.GetInt64("id")
  5232. // record_time := c.GetString("record_time")
  5233. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5234. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5235. //
  5236. // timeLayout := "2006-01-02"
  5237. // loc, _ := time.LoadLocation("Local")
  5238. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5239. // if err != nil {
  5240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5241. // return
  5242. // }
  5243. // recordDateTime := theTime.Unix()
  5244. // adminUser := c.GetAdminUserInfo()
  5245. //
  5246. // var prescriptions []*models.HisPrescription
  5247. //
  5248. // var start_time int64
  5249. // var end_time int64
  5250. //
  5251. // data := make(map[string]interface{})
  5252. // if settle_accounts_type == 1 { //日结
  5253. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5254. // data["pre"] = prescriptions
  5255. //
  5256. // } else { //月结
  5257. // start_time_str := c.GetString("start_time")
  5258. // end_time_str := c.GetString("end_time")
  5259. // timeLayout := "2006-01-02"
  5260. // loc, _ := time.LoadLocation("Local")
  5261. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5262. // if err != nil {
  5263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5264. // return
  5265. // }
  5266. // recordStartTime := theStartTime.Unix()
  5267. // start_time = recordStartTime
  5268. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5269. // if err != nil {
  5270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5271. // return
  5272. // }
  5273. // recordEndTime := theEndTime.Unix()
  5274. // end_time = recordEndTime
  5275. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5276. // data["pre"] = prescriptions
  5277. //
  5278. // }
  5279. //
  5280. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5281. //
  5282. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5283. // timestamp := time.Now().Unix()
  5284. // tempTime := time.Unix(timestamp, 0)
  5285. // timeFormat := tempTime.Format("20060102150405")
  5286. // chrgBchno := rand.Intn(100000) + 10000
  5287. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5288. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5289. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5290. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5291. // strconv.FormatInt(his.PatientId, 10)
  5292. // client := &http.Client{}
  5293. // data["psn_no"] = his.PsnNo
  5294. // data["mdtrt_id"] = his.Number
  5295. // data["chrg_bchno"] = chrg_bchno
  5296. // data["org_name"] = miConfig.OrgName
  5297. // data["doctor"] = roles.UserName
  5298. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5299. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5300. // data["fixmedins_code"] = miConfig.Code
  5301. // data["dept_code"] = department.Number
  5302. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5303. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5304. // data["secret_key"] = miConfig.SecretKey
  5305. // var ids []int64
  5306. //
  5307. // for _, item := range prescriptions {
  5308. // ids = append(ids, item.ID)
  5309. // }
  5310. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5311. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5312. // bytesData, _ := json.Marshal(data)
  5313. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5314. // resp, _ := client.Do(req)
  5315. // defer resp.Body.Close()
  5316. // body, ioErr := ioutil.ReadAll(resp.Body)
  5317. // if ioErr != nil {
  5318. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5320. // return
  5321. // }
  5322. // var respJSON map[string]interface{}
  5323. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5324. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5326. // return
  5327. // }
  5328. //
  5329. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5330. // userJSONBytes, _ := json.Marshal(respJSON)
  5331. // var res ResultFour
  5332. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5333. // utils.ErrorLog("解析失败:%v", err)
  5334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5335. // return
  5336. // }
  5337. //
  5338. // if res.Infcode == 0 {
  5339. // order := &models.HisOrder{
  5340. // UserOrgId: adminUser.CurrentOrgId,
  5341. // HisPatientId: his.ID,
  5342. // PatientId: his.PatientId,
  5343. // SettleAccountsDate: recordDateTime,
  5344. // Ctime: time.Now().Unix(),
  5345. // Mtime: time.Now().Unix(),
  5346. // Status: 1,
  5347. // Number: chrg_bchno,
  5348. // Infcode: res.Infcode,
  5349. // WarnMsg: res.WarnMsg,
  5350. // Cainfo: res.Cainfo,
  5351. // ErrMsg: res.ErrMsg,
  5352. // RespondTime: res.RefmsgTime,
  5353. // InfRefmsgid: res.InfRefmsgid,
  5354. // OrderStatus: 1,
  5355. // IsMedicineInsurance: 1,
  5356. // SettleType: settle_accounts_type,
  5357. // SettleStartTime: start_time,
  5358. // SettleEndTime: end_time,
  5359. // Creator: roles.ID,
  5360. // Modify: roles.ID,
  5361. // PType: 2,
  5362. // }
  5363. // err = service.CreateOrder(order)
  5364. // if err != nil {
  5365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5366. // return
  5367. // }
  5368. //
  5369. // for _, item := range res.Output.Result {
  5370. // temp := strings.Split(item.FeedetlSn, "-")
  5371. // var advice_id int64 = 0
  5372. // var project_id int64 = 0
  5373. // var types int64 = 0
  5374. //
  5375. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5376. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5377. //
  5378. // if temp[1] == "1" {
  5379. // advice_id = id
  5380. // project_id = 0
  5381. // } else if temp[1] == "2" {
  5382. // advice_id = 0
  5383. // project_id = id
  5384. // }
  5385. //
  5386. // info := &models.HisOrderInfo{
  5387. // OrderNumber: order.Number,
  5388. // FeedetlSn: item.FeedetlSn,
  5389. // UploadDate: time.Now().Unix(),
  5390. // AdviceId: advice_id,
  5391. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5392. // Cnt: item.Cnt,
  5393. // Pric: float64(item.Pric),
  5394. // PatientId: his.PatientId,
  5395. // PricUplmtAmt: item.PricUplmtAmt,
  5396. // SelfpayProp: item.SelfpayProp,
  5397. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5398. // OverlmtAmt: item.OverlmtAmt,
  5399. // PreselfpayAmt: item.PreselfpayAmt,
  5400. // BasMednFlag: item.BasMednFlag,
  5401. // MedChrgitmType: item.MedChrgitmType,
  5402. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5403. // Status: 1,
  5404. // Memo: item.Memo,
  5405. // Mtime: time.Now().Unix(),
  5406. // InscpScpAmt: item.InscpScpAmt,
  5407. // DrtReimFlag: item.DrtReimFlag,
  5408. // Ctime: time.Now().Unix(),
  5409. // ListSpItemFlag: item.ListSpItemFlag,
  5410. // ChldMedcFlag: item.ChldMedcFlag,
  5411. // LmtUsedFlag: item.LmtUsedFlag,
  5412. // ChrgitmLv: item.ChrgitmLv,
  5413. // UserOrgId: adminUser.CurrentOrgId,
  5414. // HisPatientId: his.ID,
  5415. // OrderId: order.ID,
  5416. // ProjectId: project_id,
  5417. // Type: types,
  5418. // }
  5419. // service.CreateOrderInfo(info)
  5420. //
  5421. // }
  5422. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5423. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5424. //
  5425. // var total float64
  5426. // for _, item := range prescriptions {
  5427. // if item.Type == 1 { //药品
  5428. // for _, subItem := range item.HisDoctorAdviceInfo {
  5429. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5430. // }
  5431. // }
  5432. // if item.Type == 2 { //项目
  5433. // for _, subItem := range item.HisPrescriptionProject {
  5434. // total = total + (subItem.Price * float64(subItem.Count))
  5435. // }
  5436. // }
  5437. // }
  5438. //
  5439. // for _, item := range prescriptions {
  5440. // for _, subItem := range item.HisAdditionalCharge {
  5441. // total = total + (subItem.Price * float64(subItem.Count))
  5442. // }
  5443. // }
  5444. //
  5445. // allTotal := fmt.Sprintf("%.2f", total)
  5446. // if res.Infcode == 0 {
  5447. // var rf []*ResultFive
  5448. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5449. // psn_no := his.PsnNo
  5450. // mdtrt_id := his.Number
  5451. // chrg_bchno := chrg_bchno
  5452. // cert_no := his.Certno
  5453. // insutype := rf[0].Insutype
  5454. //
  5455. // if his.IdCardType == 1 {
  5456. // cert_no = his.MedicalInsuranceNumber
  5457. //
  5458. // } else {
  5459. //
  5460. // cert_no = his.Certno
  5461. //
  5462. // }
  5463. //
  5464. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5465. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5466. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5467. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5468. // resp, requestErr := http.Get(api)
  5469. // if requestErr != nil {
  5470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5471. // return
  5472. // }
  5473. // defer resp.Body.Close()
  5474. // body, ioErr := ioutil.ReadAll(resp.Body)
  5475. // if ioErr != nil {
  5476. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5478. // return
  5479. // }
  5480. // var respJSON map[string]interface{}
  5481. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5482. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5484. // return
  5485. // }
  5486. // fmt.Println(respJSON)
  5487. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5488. // userJSONBytes, _ := json.Marshal(respJSON)
  5489. // var res ResultSeven
  5490. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5491. // utils.ErrorLog("解析失败:%v", err)
  5492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5493. // return
  5494. // }
  5495. // if res.Infcode != 0 {
  5496. // errlog := &models.HisOrderError{
  5497. // UserOrgId: adminUser.CurrentOrgId,
  5498. // Ctime: time.Now().Unix(),
  5499. // Mtime: time.Now().Unix(),
  5500. // Number: chrg_bchno,
  5501. // ErrMsg: res.ErrMsg,
  5502. // Status: 1,
  5503. // PatientId: id,
  5504. // RecordTime: recordDateTime,
  5505. // Stage: 7,
  5506. // }
  5507. // service.CreateErrMsgLog(errlog)
  5508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5509. // return
  5510. // } else {
  5511. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5512. // order.OrderStatus = 1
  5513. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5514. // order.SetlId = res.Output.Setlinfo.SetlID
  5515. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5516. // order.PsnName = res.Output.Setlinfo.PsnName
  5517. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5518. // order.Certno = res.Output.Setlinfo.Certno
  5519. // order.Gend = res.Output.Setlinfo.Gend
  5520. // order.Naty = res.Output.Setlinfo.Naty
  5521. // order.Age = res.Output.Setlinfo.Age
  5522. // order.Insutype = res.Output.Setlinfo.Insutype
  5523. // order.PsnType = res.Output.Setlinfo.PsnType
  5524. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5525. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5526. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5527. // order.MedType = res.Output.Setlinfo.MedType
  5528. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5529. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5530. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5531. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5532. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5533. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5534. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5535. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5536. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5537. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5538. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5539. // order.MafPay = res.Output.Setlinfo.MafPay
  5540. // order.OthPay = res.Output.Setlinfo.OthPay
  5541. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5542. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5543. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5544. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5545. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5546. // order.Balc = res.Output.Setlinfo.Balc
  5547. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5548. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5549. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5550. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5551. // order.Creator = order.Creator
  5552. // order.Modify = roles.ID
  5553. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5554. // detailStr := string(setlDetail)
  5555. // order.SetlDetail = detailStr
  5556. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5557. // err = service.UpDateOrder(order)
  5558. // if err == nil {
  5559. // c.ServeSuccessJSON(map[string]interface{}{
  5560. // "msg": "预结算成功",
  5561. // })
  5562. // } else {
  5563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5564. // return
  5565. // }
  5566. // }
  5567. // } else {
  5568. // adminUser := c.GetAdminUserInfo()
  5569. // errlog := &models.HisOrderError{
  5570. // UserOrgId: adminUser.CurrentOrgId,
  5571. // Ctime: time.Now().Unix(),
  5572. // Mtime: time.Now().Unix(),
  5573. // ErrMsg: res.ErrMsg,
  5574. // Status: 1,
  5575. // PatientId: id,
  5576. // RecordTime: recordDateTime,
  5577. // Stage: 4,
  5578. // }
  5579. // service.CreateErrMsgLog(errlog)
  5580. //
  5581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5582. // return
  5583. // }
  5584. // } else {
  5585. // adminUser := c.GetAdminUserInfo()
  5586. // errlog := &models.HisOrderError{
  5587. // UserOrgId: adminUser.CurrentOrgId,
  5588. // Ctime: time.Now().Unix(),
  5589. // Mtime: time.Now().Unix(),
  5590. // ErrMsg: res.ErrMsg,
  5591. // Status: 1,
  5592. // PatientId: id,
  5593. // RecordTime: recordDateTime,
  5594. // Stage: 4,
  5595. // }
  5596. // service.CreateErrMsgLog(errlog)
  5597. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5598. // return
  5599. // }
  5600. //
  5601. // } else {
  5602. // var total float64
  5603. // for _, item := range prescriptions {
  5604. // if item.Type == 1 { //药品
  5605. // for _, subItem := range item.HisDoctorAdviceInfo {
  5606. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5607. // }
  5608. // }
  5609. // if item.Type == 2 { //项目
  5610. // for _, subItem := range item.HisPrescriptionProject {
  5611. // total = total + (subItem.Price * float64(subItem.Count))
  5612. // }
  5613. // }
  5614. //
  5615. // for _, subItem := range item.HisAdditionalCharge {
  5616. // total = total + (subItem.Price * float64(subItem.Count))
  5617. // }
  5618. // }
  5619. //
  5620. // allTotal := fmt.Sprintf("%.2f", total)
  5621. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5622. // order := &models.HisOrder{
  5623. // UserOrgId: adminUser.CurrentOrgId,
  5624. // HisPatientId: his.ID,
  5625. // PatientId: id,
  5626. // SettleAccountsDate: recordDateTime,
  5627. // Ctime: time.Now().Unix(),
  5628. // Mtime: time.Now().Unix(),
  5629. // Status: 1,
  5630. // OrderStatus: 2,
  5631. // Number: chrg_bchno,
  5632. // MedfeeSumamt: totals,
  5633. // }
  5634. // err = service.CreateOrder(order)
  5635. // if err != nil {
  5636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5637. // return
  5638. // }
  5639. //
  5640. // var customs []*Custom
  5641. // for _, item := range prescriptions {
  5642. //
  5643. // if item.Type == 1 { //药品
  5644. // for _, subItem := range item.HisDoctorAdviceInfo {
  5645. // cus := &Custom{
  5646. // AdviceId: subItem.ID,
  5647. // ProjectId: 0,
  5648. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5649. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5650. // FeedetlSn: subItem.FeedetlSn,
  5651. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5652. // MedListCodg: subItem.MedListCodg,
  5653. // Type: 1,
  5654. // }
  5655. // customs = append(customs, cus)
  5656. // }
  5657. // }
  5658. //
  5659. // if item.Type == 2 { //项目
  5660. // for _, subItem := range item.HisPrescriptionProject {
  5661. //
  5662. // cus := &Custom{
  5663. // AdviceId: 0,
  5664. // ProjectId: subItem.ID,
  5665. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5666. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5667. // FeedetlSn: subItem.FeedetlSn,
  5668. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5669. // MedListCodg: subItem.MedListCodg,
  5670. // Type: 2,
  5671. // }
  5672. //
  5673. // customs = append(customs, cus)
  5674. // }
  5675. // }
  5676. //
  5677. // for _, item := range item.HisAdditionalCharge {
  5678. // cus := &Custom{
  5679. // ItemId: item.ID,
  5680. // AdviceId: 0,
  5681. // ProjectId: 0,
  5682. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5683. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5684. // FeedetlSn: item.FeedetlSn,
  5685. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5686. // MedListCodg: item.XtHisAddtionConfig.Code,
  5687. // Type: 3,
  5688. // }
  5689. //
  5690. // customs = append(customs, cus)
  5691. // }
  5692. //
  5693. // }
  5694. //
  5695. // for _, item := range customs {
  5696. // var advice_id int64 = 0
  5697. // var project_id int64 = 0
  5698. // var item_id int64 = 0
  5699. //
  5700. // var types int64 = 0
  5701. //
  5702. // if item.Type == 1 {
  5703. // advice_id = item.AdviceId
  5704. // project_id = 0
  5705. // item_id = 0
  5706. // } else if item.Type == 2 {
  5707. // advice_id = 0
  5708. // item_id = 0
  5709. //
  5710. // project_id = item.ProjectId
  5711. // } else if item.Type == 3 {
  5712. // advice_id = 0
  5713. // item_id = item.ItemId
  5714. // project_id = 0
  5715. // }
  5716. //
  5717. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5718. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5719. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5720. //
  5721. // info := &models.HisOrderInfo{
  5722. // OrderNumber: order.Number,
  5723. // UploadDate: time.Now().Unix(),
  5724. // AdviceId: advice_id,
  5725. // DetItemFeeSumamt: detItemFeeSumamt,
  5726. // Cnt: cut,
  5727. // Pric: pric,
  5728. // PatientId: id,
  5729. // Status: 1,
  5730. // Mtime: time.Now().Unix(),
  5731. // Ctime: time.Now().Unix(),
  5732. // UserOrgId: adminUser.CurrentOrgId,
  5733. // HisPatientId: his.ID,
  5734. // OrderId: order.ID,
  5735. // ProjectId: project_id,
  5736. // Type: types,
  5737. // ItemId: item_id,
  5738. // }
  5739. // service.CreateOrderInfo(info)
  5740. // }
  5741. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5742. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5743. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5744. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5745. // if err == nil {
  5746. // c.ServeSuccessJSON(map[string]interface{}{
  5747. // "msg": "结算成功",
  5748. // })
  5749. // } else {
  5750. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5751. // return
  5752. // }
  5753. // }
  5754. //}
  5755. //上传明细-预结算-
  5756. func (c *HisApiController) GetPreUploadInfo() {
  5757. id, _ := c.GetInt64("id")
  5758. record_time := c.GetString("record_time")
  5759. his_patient_id, _ := c.GetInt64("his_patient_id")
  5760. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5761. admin_user_id, _ := c.GetInt64("admin_user_id")
  5762. diagnosis_id := c.GetString("diagnosis")
  5763. sick_type, _ := c.GetInt64("sick_type")
  5764. reg_type, _ := c.GetInt64("p_type")
  5765. begin_time := c.GetString("begin_time")
  5766. id_str := c.GetString("ids")
  5767. ids_arr := strings.Split(id_str, ",")
  5768. timeLayout := "2006-01-02"
  5769. loc, _ := time.LoadLocation("Local")
  5770. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5771. if err != nil {
  5772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5773. return
  5774. }
  5775. recordDateTime := theTime.Unix()
  5776. adminUser := c.GetAdminUserInfo()
  5777. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5778. var config []*models.HisXtDiagnoseConfig
  5779. for _, item := range diagnosis_ids {
  5780. id, _ := strconv.ParseInt(item, 10, 64)
  5781. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5782. config = append(config, &diagnosisConfig)
  5783. }
  5784. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5785. sickConfig, _ := service.FindSickById(sick_type)
  5786. var prescriptions []*models.HisPrescription
  5787. var start_time int64
  5788. var end_time int64
  5789. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5790. fmt.Println(his_patient_id)
  5791. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5792. timestamp := time.Now().Unix()
  5793. tempTime := time.Unix(timestamp, 0)
  5794. timeFormat := tempTime.Format("20060102150405")
  5795. chrgBchno := rand.Intn(100000) + 10000
  5796. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5797. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5798. var patientPrescription models.HisPrescriptionInfo
  5799. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5800. if patientPrescription.ID == 0 {
  5801. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5802. }
  5803. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5804. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5805. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5806. strconv.FormatInt(his.PatientId, 10)
  5807. var res2 ResultSix
  5808. var resSix10265 ResultSix10265
  5809. var time_stamp string
  5810. if miConfig.MdtrtareaAdmvs == "421300" {
  5811. data := make(map[string]interface{})
  5812. client := &http.Client{}
  5813. data["psn_no"] = his.PsnNo
  5814. data["mdtrt_id"] = his.Number
  5815. data["doctor"] = roles.UserName
  5816. data["department"] = department.Name
  5817. data["org_name"] = miConfig.OrgName
  5818. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5819. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5820. data["fixmedins_code"] = miConfig.Code
  5821. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5822. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5823. data["secret_key"] = miConfig.SecretKey
  5824. data["sick_code"] = sickConfig.CountryCode
  5825. data["sick_name"] = sickConfig.ClassName
  5826. data["begin_time"] = begin_time
  5827. data["dept"] = strconv.FormatInt(department.ID, 10)
  5828. data["config"] = config
  5829. fmt.Println(data)
  5830. bytesData, _ := json.Marshal(data)
  5831. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5832. resp, _ := client.Do(req)
  5833. defer resp.Body.Close()
  5834. body, ioErr := ioutil.ReadAll(resp.Body)
  5835. if ioErr != nil {
  5836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5838. return
  5839. }
  5840. var respJSON map[string]interface{}
  5841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5844. return
  5845. }
  5846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5847. userJSONBytes, _ := json.Marshal(respJSON)
  5848. fmt.Println("log")
  5849. fmt.Println(string(userJSONBytes))
  5850. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5851. utils.ErrorLog("解析失败:%v", err)
  5852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5853. return
  5854. }
  5855. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5856. //江苏地区国家医保医疗类别
  5857. //职工透析:医疗类别选特殊情况门诊9933
  5858. //居民血透门慢: 医疗类别选门诊慢病1402
  5859. //var med_type string
  5860. //if his.Insutype == "310" {
  5861. // if reg_type == 14 {
  5862. // med_type = "9933"
  5863. // } else if reg_type == 11 {
  5864. // med_type = "11"
  5865. //
  5866. // }
  5867. //} else if his.Insutype == "390" {
  5868. // if reg_type == 14 {
  5869. // med_type = "1402"
  5870. // } else if reg_type == 11 {
  5871. // med_type = "11"
  5872. // }
  5873. //}
  5874. data := make(map[string]interface{})
  5875. client := &http.Client{}
  5876. data["psn_no"] = his.PsnNo
  5877. data["mdtrt_id"] = his.Number
  5878. data["doctor"] = roles.UserName
  5879. data["department"] = department.Name
  5880. data["org_name"] = miConfig.OrgName
  5881. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5882. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5883. data["fixmedins_code"] = miConfig.Code
  5884. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5885. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5886. data["secret_key"] = miConfig.SecretKey
  5887. data["sick_code"] = sickConfig.CountryCode
  5888. data["sick_name"] = sickConfig.ClassName
  5889. data["begin_time"] = begin_time
  5890. data["dept"] = strconv.FormatInt(department.ID, 10)
  5891. data["config"] = config
  5892. data["url"] = miConfig.Url
  5893. data["ak"] = miConfig.AccessKey
  5894. data["cainfo"] = miConfig.Cainfo
  5895. bytesData, _ := json.Marshal(data)
  5896. var req *http.Request
  5897. if miConfig.MdtrtareaAdmvs == "320921" {
  5898. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5899. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5900. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5901. } else {
  5902. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5903. }
  5904. resp, _ := client.Do(req)
  5905. defer resp.Body.Close()
  5906. body, ioErr := ioutil.ReadAll(resp.Body)
  5907. if ioErr != nil {
  5908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5910. return
  5911. }
  5912. var respJSON map[string]interface{}
  5913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return
  5917. }
  5918. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5919. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5920. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5922. userJSONBytes, _ := json.Marshal(respJSON)
  5923. fmt.Println("log")
  5924. fmt.Println(string(userJSONBytes))
  5925. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5926. utils.ErrorLog("解析失败:%v", err)
  5927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5928. return
  5929. }
  5930. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5931. res2.Output = resSix10265.Output
  5932. res2.ErrMsg = resSix10265.ErrMsg
  5933. res2.Cainfo = resSix10265.Cainfo
  5934. res2.WarnMsg = resSix10265.WarnMsg
  5935. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5936. res2.Infcode = infocode
  5937. } else {
  5938. var result string
  5939. var requestLog string
  5940. if miConfig.MdtrtareaAdmvs == "440781" { //
  5941. 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)
  5942. } else {
  5943. if miConfig.Code == "H15049901371" {
  5944. //赤峰地区国家医保医疗类别
  5945. //职工透析:医疗类别选特殊情况门诊990502
  5946. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5947. var med_type string
  5948. if his.Insutype == "390" {
  5949. if reg_type == 14 {
  5950. med_type = "9933"
  5951. } else if reg_type == 11 {
  5952. med_type = "11"
  5953. }
  5954. } else if his.Insutype == "310" {
  5955. if reg_type == 14 {
  5956. med_type = "990502"
  5957. } else if reg_type == 11 {
  5958. med_type = "11"
  5959. }
  5960. }
  5961. 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)
  5962. } else {
  5963. 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)
  5964. }
  5965. saveLog(result, requestLog, "2203", "上传就诊信息")
  5966. var respJSON2 map[string]interface{}
  5967. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5970. return
  5971. }
  5972. userJSONBytes2, _ := json.Marshal(respJSON2)
  5973. if miConfig.Code == "H15049901371" {
  5974. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5975. utils.ErrorLog("解析失败:%v", err)
  5976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5977. return
  5978. }
  5979. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5980. res2.Output = resSix10265.Output
  5981. res2.ErrMsg = resSix10265.ErrMsg
  5982. res2.Cainfo = resSix10265.Cainfo
  5983. res2.WarnMsg = resSix10265.WarnMsg
  5984. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5985. res2.Infcode = infocode
  5986. } else {
  5987. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5988. utils.ErrorLog("解析失败:%v", err)
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5990. return
  5991. }
  5992. }
  5993. }
  5994. }
  5995. if res2.Infcode != 0 {
  5996. adminUser := c.GetAdminUserInfo()
  5997. errlog := &models.HisOrderError{
  5998. UserOrgId: adminUser.CurrentOrgId,
  5999. Ctime: time.Now().Unix(),
  6000. Mtime: time.Now().Unix(),
  6001. ErrMsg: res2.ErrMsg,
  6002. Status: 1,
  6003. PatientId: id,
  6004. RecordTime: recordDateTime,
  6005. Stage: 3,
  6006. }
  6007. service.CreateErrMsgLog(errlog)
  6008. c.ServeSuccessJSON(map[string]interface{}{
  6009. "failed_code": -10,
  6010. "msg": res2.ErrMsg,
  6011. })
  6012. return
  6013. } else {
  6014. his.Diagnosis = diagnosis_id
  6015. his.SickType = sickConfig.ID
  6016. his.PType = fmt.Sprintf("%d", reg_type)
  6017. service.UpdateHisPatientThree(&his)
  6018. data := make(map[string]interface{})
  6019. if settle_accounts_type == 1 { //日结
  6020. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6021. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6022. } else {
  6023. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6024. }
  6025. data["pre"] = prescriptions
  6026. } else { //月结
  6027. start_time_str := c.GetString("start_time")
  6028. end_time_str := c.GetString("end_time")
  6029. timeLayout := "2006-01-02"
  6030. loc, _ := time.LoadLocation("Local")
  6031. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6032. if err != nil {
  6033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6034. return
  6035. }
  6036. recordStartTime := theStartTime.Unix()
  6037. start_time = recordStartTime
  6038. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6039. if err != nil {
  6040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6041. return
  6042. }
  6043. recordEndTime := theEndTime.Unix()
  6044. end_time = recordEndTime
  6045. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6046. data["pre"] = prescriptions
  6047. }
  6048. client := &http.Client{}
  6049. data["psn_no"] = his.PsnNo
  6050. data["mdtrt_id"] = his.Number
  6051. data["chrg_bchno"] = chrg_bchno
  6052. data["org_name"] = miConfig.OrgName
  6053. data["doctor"] = roles.UserName
  6054. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6055. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6056. data["fixmedins_code"] = miConfig.Code
  6057. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6058. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6059. data["dept_code"] = "15"
  6060. } else {
  6061. data["dept_code"] = department.Number
  6062. }
  6063. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6064. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6065. data["secret_key"] = miConfig.SecretKey
  6066. data["url"] = miConfig.Url
  6067. data["ak"] = miConfig.AccessKey
  6068. data["new_doctor_name"] = patientPrescription.Doctor
  6069. data["diag_code"] = sickConfig.CountryCode
  6070. data["time_stamp"] = time_stamp
  6071. data["cainfo"] = miConfig.Cainfo
  6072. var ids []int64
  6073. for _, item := range prescriptions {
  6074. ids = append(ids, item.ID)
  6075. }
  6076. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6077. if config.IsOpen == 1 { //对接了医保,走医保流程
  6078. var res ResultFour
  6079. var resFour10265 ResultFour10265
  6080. if miConfig.MdtrtareaAdmvs == "421300" {
  6081. bytesData, _ := json.Marshal(data)
  6082. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6083. resp, _ := client.Do(req)
  6084. defer resp.Body.Close()
  6085. body, ioErr := ioutil.ReadAll(resp.Body)
  6086. if ioErr != nil {
  6087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6089. return
  6090. }
  6091. var respJSON map[string]interface{}
  6092. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6095. return
  6096. }
  6097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6098. userJSONBytes, _ := json.Marshal(respJSON)
  6099. fmt.Println("log")
  6100. fmt.Println(string(userJSONBytes))
  6101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6102. utils.ErrorLog("解析失败:%v", err)
  6103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6104. return
  6105. }
  6106. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6107. bytesData, _ := json.Marshal(data)
  6108. var req *http.Request
  6109. if miConfig.MdtrtareaAdmvs == "320921" {
  6110. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6111. } else {
  6112. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6113. }
  6114. resp, _ := client.Do(req)
  6115. defer resp.Body.Close()
  6116. body, ioErr := ioutil.ReadAll(resp.Body)
  6117. if ioErr != nil {
  6118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6120. return
  6121. }
  6122. var respJSON map[string]interface{}
  6123. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6126. return
  6127. }
  6128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6129. userJSONBytes, _ := json.Marshal(respJSON)
  6130. fmt.Println("log")
  6131. fmt.Println(string(userJSONBytes))
  6132. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6133. utils.ErrorLog("解析失败:%v", err)
  6134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6135. return
  6136. }
  6137. res.InfRefmsgid = resFour10265.InfRefmsgid
  6138. res.Output = resFour10265.Output
  6139. res.ErrMsg = resFour10265.ErrMsg
  6140. res.Cainfo = resFour10265.Cainfo
  6141. res.WarnMsg = resFour10265.WarnMsg
  6142. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6143. res.Infcode = infocode
  6144. } else {
  6145. if miConfig.Code == "H15049901371" {
  6146. 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)
  6147. var dat map[string]interface{}
  6148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6149. fmt.Println(dat)
  6150. } else {
  6151. fmt.Println(err)
  6152. }
  6153. saveLog(result, request_log, "2204", "上传费用明细")
  6154. userJSONBytes, _ := json.Marshal(dat)
  6155. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6156. utils.ErrorLog("解析失败:%v", err)
  6157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6158. return
  6159. }
  6160. res.InfRefmsgid = resFour10265.InfRefmsgid
  6161. res.Output = resFour10265.Output
  6162. res.ErrMsg = resFour10265.ErrMsg
  6163. res.Cainfo = resFour10265.Cainfo
  6164. res.WarnMsg = resFour10265.WarnMsg
  6165. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6166. res.Infcode = infocode
  6167. } else {
  6168. 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)
  6169. var dat map[string]interface{}
  6170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6171. fmt.Println(dat)
  6172. } else {
  6173. fmt.Println(err)
  6174. }
  6175. saveLog(result, request_log, "2204", "上传费用明细")
  6176. userJSONBytes, _ := json.Marshal(dat)
  6177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6178. utils.ErrorLog("解析失败:%v", err)
  6179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6180. return
  6181. }
  6182. }
  6183. }
  6184. if res.Infcode == 0 {
  6185. order := &models.HisOrder{
  6186. UserOrgId: adminUser.CurrentOrgId,
  6187. HisPatientId: his.ID,
  6188. PatientId: his.PatientId,
  6189. SettleAccountsDate: recordDateTime,
  6190. Ctime: time.Now().Unix(),
  6191. Mtime: time.Now().Unix(),
  6192. MdtrtId: his.Number,
  6193. PsnNo: his.PsnNo,
  6194. MedType: strconv.FormatInt(reg_type, 10),
  6195. Status: 1,
  6196. Number: chrg_bchno,
  6197. Infcode: res.Infcode,
  6198. WarnMsg: res.WarnMsg,
  6199. Cainfo: res.Cainfo,
  6200. ErrMsg: res.ErrMsg,
  6201. RespondTime: res.RefmsgTime,
  6202. InfRefmsgid: res.InfRefmsgid,
  6203. OrderStatus: 1,
  6204. IsMedicineInsurance: 1,
  6205. SettleType: settle_accounts_type,
  6206. SettleStartTime: start_time,
  6207. SettleEndTime: end_time,
  6208. Creator: roles.AdminUserId,
  6209. Modify: roles.AdminUserId,
  6210. PType: 2,
  6211. Diagnosis: diagnosis_id,
  6212. }
  6213. err = service.CreateOrder(order)
  6214. if err != nil {
  6215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6216. return
  6217. }
  6218. for _, item := range res.Output.Result {
  6219. temp := strings.Split(item.FeedetlSn, "-")
  6220. var advice_id int64 = 0
  6221. var project_id int64 = 0
  6222. var types int64 = 0
  6223. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6224. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6225. if temp[1] == "1" {
  6226. advice_id = id
  6227. project_id = 0
  6228. } else if temp[1] == "2" {
  6229. advice_id = 0
  6230. project_id = id
  6231. }
  6232. info := &models.HisOrderInfo{
  6233. OrderNumber: order.Number,
  6234. FeedetlSn: item.FeedetlSn,
  6235. UploadDate: time.Now().Unix(),
  6236. AdviceId: advice_id,
  6237. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6238. Cnt: item.Cnt,
  6239. Pric: float64(item.Pric),
  6240. PatientId: his.PatientId,
  6241. PricUplmtAmt: item.PricUplmtAmt,
  6242. SelfpayProp: item.SelfpayProp,
  6243. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6244. OverlmtAmt: item.OverlmtAmt,
  6245. PreselfpayAmt: item.PreselfpayAmt,
  6246. BasMednFlag: item.BasMednFlag,
  6247. MedChrgitmType: item.MedChrgitmType,
  6248. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6249. Status: 1,
  6250. Memo: item.Memo,
  6251. Mtime: time.Now().Unix(),
  6252. InscpScpAmt: item.InscpScpAmt,
  6253. DrtReimFlag: item.DrtReimFlag,
  6254. Ctime: time.Now().Unix(),
  6255. ListSpItemFlag: item.ListSpItemFlag,
  6256. ChldMedcFlag: item.ChldMedcFlag,
  6257. LmtUsedFlag: item.LmtUsedFlag,
  6258. ChrgitmLv: item.ChrgitmLv,
  6259. UserOrgId: adminUser.CurrentOrgId,
  6260. HisPatientId: his.ID,
  6261. OrderId: order.ID,
  6262. ProjectId: project_id,
  6263. Type: types,
  6264. }
  6265. service.CreateOrderInfo(info)
  6266. }
  6267. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6268. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6269. var total float64
  6270. for _, item := range prescriptions {
  6271. if item.Type == 1 { //药品
  6272. for _, subItem := range item.HisDoctorAdviceInfo {
  6273. total = total + (subItem.Price * subItem.PrescribingNumber)
  6274. }
  6275. }
  6276. if item.Type == 2 { //项目
  6277. for _, subItem := range item.HisPrescriptionProject {
  6278. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6279. total = total + (subItem.Price * cnt)
  6280. }
  6281. }
  6282. }
  6283. for _, item := range prescriptions {
  6284. for _, subItem := range item.HisAdditionalCharge {
  6285. total = total + (subItem.Price * float64(subItem.Count))
  6286. }
  6287. }
  6288. allTotal := fmt.Sprintf("%.4f", total)
  6289. if res.Infcode == 0 {
  6290. var rf []*ResultFive
  6291. json.Unmarshal([]byte(his.Iinfo), &rf)
  6292. chrg_bchno := chrg_bchno
  6293. cert_no := his.Certno
  6294. var insutypes []string
  6295. var insutype string
  6296. var is390 int = 0
  6297. var is310 int = 0
  6298. for _, item := range rf {
  6299. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6300. insutypes = append(insutypes, item.Insutype)
  6301. }
  6302. }
  6303. if len(insutypes) == 1 {
  6304. insutype = insutypes[0]
  6305. } else {
  6306. for _, i := range insutypes {
  6307. if i == "390" {
  6308. is390 = 1
  6309. }
  6310. if i == "310" {
  6311. is310 = 1
  6312. }
  6313. }
  6314. }
  6315. if is390 == 1 {
  6316. insutype = "390"
  6317. }
  6318. if is310 == 1 {
  6319. insutype = "310"
  6320. }
  6321. if len(insutypes) == 0 {
  6322. insutype = "310"
  6323. }
  6324. if len(insutypes) == 2 {
  6325. insutype = strconv.FormatInt(his.SocialType, 64)
  6326. }
  6327. //insutype = "390"
  6328. if his.IdCardType == 1 {
  6329. cert_no = his.MedicalInsuranceNumber
  6330. } else {
  6331. cert_no = his.Certno
  6332. }
  6333. var res ResultSeven
  6334. var resSeven10265 ResultSeven10265
  6335. if miConfig.MdtrtareaAdmvs == "421300" {
  6336. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6337. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6338. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6339. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6340. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6341. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6342. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6343. resp, requestErr := http.Get(api)
  6344. if requestErr != nil {
  6345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6346. return
  6347. }
  6348. body, ioErr := ioutil.ReadAll(resp.Body)
  6349. if ioErr != nil {
  6350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6352. return
  6353. }
  6354. var respJSON map[string]interface{}
  6355. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6358. return
  6359. }
  6360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6361. result, _ := json.Marshal(respJSON)
  6362. fmt.Println("log")
  6363. fmt.Println(string(result))
  6364. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6365. utils.ErrorLog("解析失败:%v", err)
  6366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6367. return
  6368. }
  6369. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6370. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6371. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6372. bas := strings.Split(psn_info.CardInfo, "|")
  6373. if his.IdCardType == 1 {
  6374. cert_no = bas[2]
  6375. } else {
  6376. cert_no = bas[1]
  6377. }
  6378. //江苏地区国家医保医疗类别
  6379. //职工透析:医疗类别选特殊情况门诊9933
  6380. //居民血透门慢: 医疗类别选门诊慢病1402
  6381. //var med_type string
  6382. //if his.Insutype == "310" {
  6383. // if reg_type == 14 {
  6384. // med_type = "9933"
  6385. // } else if reg_type == 11 {
  6386. // med_type = "11"
  6387. //
  6388. // }
  6389. //} else if his.Insutype == "390" {
  6390. // if reg_type == 14 {
  6391. // med_type = "1402"
  6392. // } else if reg_type == 11 {
  6393. // med_type = "11"
  6394. // }
  6395. //}
  6396. var api string
  6397. if miConfig.MdtrtareaAdmvs == "320921" {
  6398. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6399. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6400. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6402. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6403. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6404. "&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
  6405. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6406. } else {
  6407. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6408. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6409. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6410. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6411. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6412. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6413. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6414. "&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
  6415. }
  6416. resp, requestErr := http.Get(api)
  6417. if requestErr != nil {
  6418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6419. return
  6420. }
  6421. body, ioErr := ioutil.ReadAll(resp.Body)
  6422. if ioErr != nil {
  6423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6425. return
  6426. }
  6427. var respJSON map[string]interface{}
  6428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6431. return
  6432. }
  6433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6434. result, _ := json.Marshal(respJSON)
  6435. fmt.Println("log")
  6436. fmt.Println(string(result))
  6437. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6438. utils.ErrorLog("解析失败:%v", err)
  6439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6440. return
  6441. }
  6442. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6443. res.Output = resSeven10265.Output
  6444. res.ErrMsg = resSeven10265.ErrMsg
  6445. res.Cainfo = resSeven10265.Cainfo
  6446. res.WarnMsg = resSeven10265.WarnMsg
  6447. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6448. res.Infcode = infocode
  6449. } else {
  6450. var result string
  6451. var request_log string
  6452. if miConfig.Code == "H15049901371" {
  6453. //赤峰地区国家医保医疗类别
  6454. //职工透析:医疗类别选特殊情况门诊990502
  6455. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6456. var med_type string
  6457. if his.Insutype == "390" {
  6458. if reg_type == 14 {
  6459. med_type = "9933"
  6460. } else if reg_type == 11 {
  6461. med_type = "11"
  6462. }
  6463. } else if his.Insutype == "310" {
  6464. if reg_type == 14 {
  6465. med_type = "990502"
  6466. } else if reg_type == 11 {
  6467. med_type = "11"
  6468. }
  6469. }
  6470. 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)
  6471. } else {
  6472. 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)
  6473. }
  6474. var dat map[string]interface{}
  6475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6476. fmt.Println(dat)
  6477. } else {
  6478. fmt.Println(err)
  6479. }
  6480. saveLog(result, request_log, "2206", "预结算")
  6481. //userJSONBytes, _ := json.Marshal(dat)
  6482. //
  6483. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6484. // utils.ErrorLog("解析失败:%v", err)
  6485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6486. // return
  6487. //}
  6488. userJSONBytes, _ := json.Marshal(dat)
  6489. if miConfig.Code == "H15049901371" {
  6490. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6491. utils.ErrorLog("解析失败:%v", err)
  6492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6493. return
  6494. }
  6495. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6496. res.Output = resSeven10265.Output
  6497. res.ErrMsg = resSeven10265.ErrMsg
  6498. res.Cainfo = resSeven10265.Cainfo
  6499. res.WarnMsg = resSeven10265.WarnMsg
  6500. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6501. res.Infcode = infocode
  6502. } else {
  6503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6504. utils.ErrorLog("解析失败:%v", err)
  6505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6506. return
  6507. }
  6508. }
  6509. }
  6510. if res.Infcode != 0 {
  6511. errlog := &models.HisOrderError{
  6512. UserOrgId: adminUser.CurrentOrgId,
  6513. Ctime: time.Now().Unix(),
  6514. Mtime: time.Now().Unix(),
  6515. Number: chrg_bchno,
  6516. ErrMsg: res.ErrMsg,
  6517. Status: 1,
  6518. PatientId: id,
  6519. RecordTime: recordDateTime,
  6520. Stage: 20,
  6521. }
  6522. service.CreateErrMsgLog(errlog)
  6523. c.ServeSuccessJSON(map[string]interface{}{
  6524. "failed_code": -10,
  6525. "msg": res.ErrMsg,
  6526. })
  6527. return
  6528. } else {
  6529. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6530. order.OrderStatus = 1
  6531. order.IsPre = 1
  6532. order.Status = 1
  6533. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6534. order.SetlId = res.Output.Setlinfo.SetlID
  6535. order.PsnNo = res.Output.Setlinfo.PsnNo
  6536. order.PsnName = res.Output.Setlinfo.PsnName
  6537. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6538. order.Certno = res.Output.Setlinfo.Certno
  6539. order.Gend = res.Output.Setlinfo.Gend
  6540. order.Naty = res.Output.Setlinfo.Naty
  6541. order.Age = res.Output.Setlinfo.Age
  6542. order.Insutype = res.Output.Setlinfo.Insutype
  6543. order.PsnType = res.Output.Setlinfo.PsnType
  6544. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6545. order.SetlTime = res.Output.Setlinfo.SetlTime
  6546. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6547. if res.Output.Setlinfo.MedType == "140101" {
  6548. order.MedType = "14"
  6549. } else {
  6550. order.MedType = res.Output.Setlinfo.MedType
  6551. }
  6552. if reg_type == 1112 {
  6553. order.MedType = "1112"
  6554. }
  6555. if reg_type == 1111 {
  6556. order.MedType = "1111"
  6557. }
  6558. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6559. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6560. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6561. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6562. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6563. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6564. order.HifpPay = res.Output.Setlinfo.HifpPay
  6565. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6566. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6567. order.HifesPay = res.Output.Setlinfo.HifesPay
  6568. order.HifobPay = res.Output.Setlinfo.HifobPay
  6569. order.MafPay = res.Output.Setlinfo.MafPay
  6570. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6571. order.OthPay = res.Output.Setlinfo.OthPay
  6572. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6573. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6574. order.AcctPay = res.Output.Setlinfo.AcctPay
  6575. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6576. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6577. order.Balc = res.Output.Setlinfo.Balc
  6578. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6579. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6580. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6581. order.ClrWay = res.Output.Setlinfo.ClrWay
  6582. order.Creator = order.Creator
  6583. order.Modify = roles.AdminUserId
  6584. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6585. detailStr := string(setlDetail)
  6586. order.SetlDetail = detailStr
  6587. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6588. err = service.UpDateOrder(order)
  6589. if err == nil {
  6590. c.ServeSuccessJSON(map[string]interface{}{
  6591. "msg": "预结算成功",
  6592. })
  6593. } else {
  6594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6595. return
  6596. }
  6597. }
  6598. } else {
  6599. adminUser := c.GetAdminUserInfo()
  6600. errlog := &models.HisOrderError{
  6601. UserOrgId: adminUser.CurrentOrgId,
  6602. Ctime: time.Now().Unix(),
  6603. Mtime: time.Now().Unix(),
  6604. ErrMsg: res.ErrMsg,
  6605. Status: 1,
  6606. PatientId: id,
  6607. RecordTime: recordDateTime,
  6608. Stage: 4,
  6609. }
  6610. service.CreateErrMsgLog(errlog)
  6611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6612. return
  6613. }
  6614. } else {
  6615. adminUser := c.GetAdminUserInfo()
  6616. errlog := &models.HisOrderError{
  6617. UserOrgId: adminUser.CurrentOrgId,
  6618. Ctime: time.Now().Unix(),
  6619. Mtime: time.Now().Unix(),
  6620. ErrMsg: res.ErrMsg,
  6621. Status: 1,
  6622. PatientId: id,
  6623. RecordTime: recordDateTime,
  6624. Stage: 4,
  6625. }
  6626. service.CreateErrMsgLog(errlog)
  6627. c.ServeSuccessJSON(map[string]interface{}{
  6628. "failed_code": -10,
  6629. "msg": res.ErrMsg,
  6630. })
  6631. return
  6632. }
  6633. }
  6634. }
  6635. }
  6636. //func (c *HisApiController) GetSettleInfo() {
  6637. // id, _ := c.GetInt64("id")
  6638. // order_id, _ := c.GetInt64("order_id")
  6639. //
  6640. // record_time := c.GetString("record_time")
  6641. // pay_way, _ := c.GetInt64("pay_way")
  6642. // pay_price, _ := c.GetFloat("pay_price")
  6643. // pay_card_no := c.GetString("pay_card_no")
  6644. // discount_price, _ := c.GetFloat("discount_price")
  6645. // preferential_price, _ := c.GetFloat("preferential_price")
  6646. // reality_price, _ := c.GetFloat("reality_price")
  6647. // found_price, _ := c.GetFloat("found_price")
  6648. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6649. // private_price, _ := c.GetFloat("private_price")
  6650. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6651. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6652. //
  6653. // timeLayout := "2006-01-02"
  6654. // loc, _ := time.LoadLocation("Local")
  6655. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6656. // if err != nil {
  6657. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6658. // return
  6659. // }
  6660. // recordDateTime := theTime.Unix()
  6661. // adminUser := c.GetAdminUserInfo()
  6662. //
  6663. // var prescriptions []*models.HisPrescription
  6664. //
  6665. // data := make(map[string]interface{})
  6666. // if settle_accounts_type == 1 { //日结
  6667. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6668. // data["pre"] = prescriptions
  6669. //
  6670. // } else { //月结
  6671. // start_time_str := c.GetString("start_time")
  6672. // end_time_str := c.GetString("end_time")
  6673. // timeLayout := "2006-01-02"
  6674. // loc, _ := time.LoadLocation("Local")
  6675. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6676. // if err != nil {
  6677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6678. // return
  6679. // }
  6680. // recordStartTime := theStartTime.Unix()
  6681. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6682. // if err != nil {
  6683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6684. // return
  6685. // }
  6686. // recordEndTime := theEndTime.Unix()
  6687. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6688. // data["pre"] = prescriptions
  6689. //
  6690. // }
  6691. //
  6692. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6693. //
  6694. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6695. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6696. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6697. // strconv.FormatInt(his.PatientId, 10)
  6698. //
  6699. // order_src, _ := service.GetHisOrderByID(order_id)
  6700. //
  6701. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6702. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6703. //
  6704. // var total float64
  6705. // for _, item := range prescriptions {
  6706. // if item.Type == 1 { //药品
  6707. // for _, subItem := range item.HisDoctorAdviceInfo {
  6708. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6709. // }
  6710. // }
  6711. // if item.Type == 2 { //项目
  6712. // for _, subItem := range item.HisPrescriptionProject {
  6713. // total = total + (subItem.Price * float64(subItem.Count))
  6714. // }
  6715. // }
  6716. // }
  6717. //
  6718. // for _, item := range prescriptions {
  6719. // for _, subItem := range item.HisAdditionalCharge {
  6720. // total = total + (subItem.Price * float64(subItem.Count))
  6721. // }
  6722. // }
  6723. //
  6724. // allTotal := fmt.Sprintf("%.2f", total)
  6725. // var rf []*ResultFive
  6726. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6727. // psn_no := order_src.PsnNo
  6728. // mdtrt_id := order_src.MdtrtId
  6729. // chrg_bchno := order_src.Number
  6730. // cert_no := order_src.Certno
  6731. // insutype := rf[0].Insutype
  6732. //
  6733. // if his.IdCardType == 1 {
  6734. // cert_no = his.MedicalInsuranceNumber
  6735. // } else {
  6736. // cert_no = his.Certno
  6737. // }
  6738. //
  6739. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  6740. // var dat map[string]interface{}
  6741. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6742. // fmt.Println(dat)
  6743. // } else {
  6744. // fmt.Println(err)
  6745. // }
  6746. //
  6747. // userJSONBytes, _ := json.Marshal(dat)
  6748. //
  6749. //
  6750. //
  6751. // var res ResultSeven
  6752. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6753. // utils.ErrorLog("解析失败:%v", err)
  6754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6755. // return
  6756. // }
  6757. // if res.Infcode == -1 {
  6758. // errlog := &models.HisOrderError{
  6759. // UserOrgId: adminUser.CurrentOrgId,
  6760. // Ctime: time.Now().Unix(),
  6761. // Mtime: time.Now().Unix(),
  6762. // Number: chrg_bchno,
  6763. // ErrMsg: res.ErrMsg,
  6764. // Status: 1,
  6765. // PatientId: id,
  6766. // RecordTime: recordDateTime,
  6767. // Stage: 6,
  6768. // }
  6769. // service.CreateErrMsgLog(errlog)
  6770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6771. // return
  6772. // } else {
  6773. // order_src.OrderStatus = 2
  6774. // order_src.PayWay = pay_way
  6775. // order_src.PayPrice = pay_price
  6776. // order_src.PayCardNo = pay_card_no
  6777. // order_src.DiscountPrice = discount_price
  6778. // order_src.PreferentialPrice = preferential_price
  6779. // order_src.RealityPrice = reality_price
  6780. // order_src.FoundPrice = found_price
  6781. // order_src.MedicalInsurancePrice = medical_insurance_price
  6782. // order_src.PrivatePrice = private_price
  6783. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6784. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6785. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6786. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6787. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6788. // order_src.Certno = res.Output.Setlinfo.Certno
  6789. // order_src.Gend = res.Output.Setlinfo.Gend
  6790. // order_src.Naty = res.Output.Setlinfo.Naty
  6791. // order_src.Age = res.Output.Setlinfo.Age
  6792. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6793. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6794. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6795. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6796. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6797. // order_src.MedType = res.Output.Setlinfo.MedType
  6798. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6799. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6800. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6801. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6802. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6803. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6804. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6805. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6806. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6807. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6808. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6809. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6810. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6811. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6812. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6813. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6814. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6815. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6816. // order_src.Balc = res.Output.Setlinfo.Balc
  6817. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6818. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6819. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6820. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6821. // order_src.Creator = order_src.Creator
  6822. // order_src.Modify = roles.ID
  6823. // order_src.RequestLog = src_resquest
  6824. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6825. // detailStr := string(setlDetail)
  6826. // order_src.SetlDetail = detailStr
  6827. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6828. // err = service.UpDateOrder(order_src)
  6829. //
  6830. // if err == nil {
  6831. // c.ServeSuccessJSON(map[string]interface{}{
  6832. // "msg": "结算成功",
  6833. // })
  6834. // } else {
  6835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6836. // return
  6837. // }
  6838. // }
  6839. // }
  6840. //}
  6841. //退款
  6842. func (c *HisApiController) Refund() {
  6843. order_id, _ := c.GetInt64("order_id")
  6844. admin_user_id, _ := c.GetInt64("admin_user_id")
  6845. adminUser := c.GetAdminUserInfo()
  6846. var order models.HisOrder
  6847. order, _ = service.GetHisOrderByID(order_id)
  6848. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6849. if order.ID == 0 {
  6850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6851. return
  6852. }
  6853. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6854. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6855. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6856. if config.IsOpen == 1 { //对接了医保,走医保流程
  6857. var res ResultSixteen
  6858. var resSixteen10265 ResultSixteen10265
  6859. var src_resquest string
  6860. var result string
  6861. if miConfig.MdtrtareaAdmvs == "421300" {
  6862. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6863. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6864. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6865. resp3, requestErr3 := http.Get(api3)
  6866. if requestErr3 != nil {
  6867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6868. return
  6869. }
  6870. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6871. if ioErr3 != nil {
  6872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6874. return
  6875. }
  6876. var respJSON3 map[string]interface{}
  6877. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6880. return
  6881. }
  6882. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6883. userJSONBytes3, _ := json.Marshal(respJSON3)
  6884. fmt.Println("log")
  6885. fmt.Println(string(userJSONBytes3))
  6886. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6887. utils.ErrorLog("解析失败:%v", err)
  6888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6889. return
  6890. }
  6891. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6892. var api3 string
  6893. if miConfig.MdtrtareaAdmvs == "320921" {
  6894. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6895. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6896. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6897. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6898. } else {
  6899. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6900. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6901. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6902. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6903. }
  6904. resp3, requestErr3 := http.Get(api3)
  6905. if requestErr3 != nil {
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6910. if ioErr3 != nil {
  6911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6913. return
  6914. }
  6915. var respJSON3 map[string]interface{}
  6916. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6919. return
  6920. }
  6921. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6922. userJSONBytes3, _ := json.Marshal(respJSON3)
  6923. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6924. utils.ErrorLog("解析失败:%v", err)
  6925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6926. return
  6927. }
  6928. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6929. res.Output = resSixteen10265.Output
  6930. res.ErrMsg = resSixteen10265.ErrMsg
  6931. res.Cainfo = resSixteen10265.Cainfo
  6932. res.WarnMsg = resSixteen10265.WarnMsg
  6933. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6934. res.Infcode = infocode
  6935. } else {
  6936. if miConfig.Code == "H15049901371" {
  6937. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6938. var dat map[string]interface{}
  6939. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6940. fmt.Println(dat)
  6941. } else {
  6942. fmt.Println(err)
  6943. }
  6944. saveLog(result, src_resquest, "2208", "退费")
  6945. userJSONBytes, _ := json.Marshal(dat)
  6946. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6947. utils.ErrorLog("解析失败:%v", err)
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. return
  6950. }
  6951. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6952. res.Output = resSixteen10265.Output
  6953. res.ErrMsg = resSixteen10265.ErrMsg
  6954. res.Cainfo = resSixteen10265.Cainfo
  6955. res.WarnMsg = resSixteen10265.WarnMsg
  6956. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6957. res.Infcode = infocode
  6958. } else {
  6959. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6960. var dat map[string]interface{}
  6961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6962. fmt.Println(dat)
  6963. } else {
  6964. fmt.Println(err)
  6965. }
  6966. saveLog(result, src_resquest, "2208", "退费")
  6967. userJSONBytes, _ := json.Marshal(dat)
  6968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6969. utils.ErrorLog("解析失败:%v", err)
  6970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6971. return
  6972. }
  6973. }
  6974. }
  6975. if res.Infcode == 0 {
  6976. var res2 ResultSix
  6977. var resSix10265 ResultSix10265
  6978. if miConfig.MdtrtareaAdmvs == "421300" {
  6979. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6980. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6981. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6982. resp3, requestErr3 := http.Get(api3)
  6983. if requestErr3 != nil {
  6984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6985. return
  6986. }
  6987. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6988. if ioErr3 != nil {
  6989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6991. return
  6992. }
  6993. var respJSON3 map[string]interface{}
  6994. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6997. return
  6998. }
  6999. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7000. userJSONBytes3, _ := json.Marshal(respJSON3)
  7001. fmt.Println("log")
  7002. fmt.Println(string(userJSONBytes3))
  7003. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7004. utils.ErrorLog("解析失败:%v", err)
  7005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7006. return
  7007. }
  7008. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7009. var api3 string
  7010. if miConfig.MdtrtareaAdmvs == "320921" {
  7011. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7012. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7013. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7014. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7015. } else {
  7016. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7017. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7018. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7019. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7020. }
  7021. resp3, requestErr3 := http.Get(api3)
  7022. if requestErr3 != nil {
  7023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7024. return
  7025. }
  7026. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7027. if ioErr3 != nil {
  7028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7030. return
  7031. }
  7032. var respJSON3 map[string]interface{}
  7033. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7036. return
  7037. }
  7038. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7039. userJSONBytes3, _ := json.Marshal(respJSON3)
  7040. fmt.Println("log")
  7041. fmt.Println(string(userJSONBytes3))
  7042. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7043. utils.ErrorLog("解析失败:%v", err)
  7044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7045. return
  7046. }
  7047. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7048. res2.Output = resSix10265.Output
  7049. res2.ErrMsg = resSix10265.ErrMsg
  7050. res2.Cainfo = resSix10265.Cainfo
  7051. res2.WarnMsg = resSix10265.WarnMsg
  7052. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7053. res2.Infcode = infocode
  7054. } else {
  7055. if miConfig.Code == "H15049901371" {
  7056. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7057. var dat map[string]interface{}
  7058. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7059. fmt.Println(dat)
  7060. } else {
  7061. fmt.Println(err)
  7062. }
  7063. saveLog(result2, src_request, "2205", "撤销明细")
  7064. userJSONBytes, _ := json.Marshal(dat)
  7065. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7066. utils.ErrorLog("解析失败:%v", err)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. return
  7069. }
  7070. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7071. res2.Output = resSix10265.Output
  7072. res2.ErrMsg = resSix10265.ErrMsg
  7073. res2.Cainfo = resSix10265.Cainfo
  7074. res2.WarnMsg = resSix10265.WarnMsg
  7075. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7076. res2.Infcode = infocode
  7077. } else {
  7078. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7079. var dat map[string]interface{}
  7080. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7081. fmt.Println(dat)
  7082. } else {
  7083. fmt.Println(err)
  7084. }
  7085. saveLog(result2, src_request, "2205", "撤销明细")
  7086. userJSONBytes, _ := json.Marshal(dat)
  7087. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7088. utils.ErrorLog("解析失败:%v", err)
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. return
  7091. }
  7092. }
  7093. }
  7094. if res2.Infcode == 0 {
  7095. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7096. if err == nil {
  7097. c.ServeSuccessJSON(map[string]interface{}{
  7098. "msg": "退费成功",
  7099. })
  7100. } else {
  7101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7102. return
  7103. }
  7104. } else {
  7105. c.ServeSuccessJSON(map[string]interface{}{
  7106. "code": -10,
  7107. "msg": res2.ErrMsg,
  7108. })
  7109. }
  7110. } else {
  7111. c.ServeSuccessJSON(map[string]interface{}{
  7112. "code": -10,
  7113. "msg": res.ErrMsg,
  7114. })
  7115. }
  7116. }
  7117. }
  7118. func (c *HisApiController) RefundNumber() {
  7119. record_time := c.GetString("record_time")
  7120. //patient_id, _ := c.GetInt64("patient_id")
  7121. admin_user_id, _ := c.GetInt64("admin_user_id")
  7122. his_patient_id, _ := c.GetInt64("id")
  7123. timeLayout := "2006-01-02"
  7124. loc, _ := time.LoadLocation("Local")
  7125. adminUser := c.GetAdminUserInfo()
  7126. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7127. fmt.Println(err)
  7128. if err != nil {
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7130. return
  7131. }
  7132. recordDateTime := theTime.Unix()
  7133. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7134. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7135. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7136. //order, _ := service.GetHisOrderByID(order_id)
  7137. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7138. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7139. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7140. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7141. if count > 0 {
  7142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7143. return
  7144. }
  7145. if config.IsOpen == 1 { //对接了医保,走医保流程
  7146. var res2 ResultSix
  7147. var resSix10265 ResultSix10265
  7148. if miConfig.MdtrtareaAdmvs == "421300" {
  7149. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7150. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7151. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7152. resp3, requestErr3 := http.Get(api3)
  7153. if requestErr3 != nil {
  7154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7155. return
  7156. }
  7157. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7158. if ioErr3 != nil {
  7159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7161. return
  7162. }
  7163. var respJSON3 map[string]interface{}
  7164. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7170. userJSONBytes3, _ := json.Marshal(respJSON3)
  7171. fmt.Println("log")
  7172. fmt.Println(string(userJSONBytes3))
  7173. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7174. utils.ErrorLog("解析失败:%v", err)
  7175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7176. return
  7177. }
  7178. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7179. var api3 string
  7180. if miConfig.MdtrtareaAdmvs == "320921" {
  7181. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7182. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7183. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7184. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7185. } else {
  7186. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7187. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7188. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7189. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7190. }
  7191. resp3, requestErr3 := http.Get(api3)
  7192. if requestErr3 != nil {
  7193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7194. return
  7195. }
  7196. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7197. if ioErr3 != nil {
  7198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7200. return
  7201. }
  7202. var respJSON3 map[string]interface{}
  7203. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7206. return
  7207. }
  7208. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7209. userJSONBytes3, _ := json.Marshal(respJSON3)
  7210. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7211. utils.ErrorLog("解析失败:%v", err)
  7212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. return
  7214. }
  7215. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7216. res2.Output = resSix10265.Output
  7217. res2.ErrMsg = resSix10265.ErrMsg
  7218. res2.Cainfo = resSix10265.Cainfo
  7219. res2.WarnMsg = resSix10265.WarnMsg
  7220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7221. res2.Infcode = infocode
  7222. } else {
  7223. var api3 string
  7224. if miConfig.Code == "H15049901371" {
  7225. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7226. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7227. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7228. } else {
  7229. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7230. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7231. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7232. }
  7233. resp3, requestErr3 := http.Get(api3)
  7234. if requestErr3 != nil {
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7236. return
  7237. }
  7238. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7239. if ioErr3 != nil {
  7240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7242. return
  7243. }
  7244. var respJSON3 map[string]interface{}
  7245. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7248. return
  7249. }
  7250. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7251. userJSONBytes3, _ := json.Marshal(respJSON3)
  7252. if miConfig.Code == "H15049901371" {
  7253. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7254. utils.ErrorLog("解析失败:%v", err)
  7255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7256. return
  7257. }
  7258. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7259. res2.Output = resSix10265.Output
  7260. res2.ErrMsg = resSix10265.ErrMsg
  7261. res2.Cainfo = resSix10265.Cainfo
  7262. res2.WarnMsg = resSix10265.WarnMsg
  7263. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7264. res2.Infcode = infocode
  7265. } else {
  7266. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7267. utils.ErrorLog("解析失败:%v", err)
  7268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7269. return
  7270. }
  7271. }
  7272. }
  7273. if res2.Infcode == 0 {
  7274. if err == nil {
  7275. c.ServeSuccessJSON(map[string]interface{}{
  7276. "msg": "退号成功",
  7277. })
  7278. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7279. } else {
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. return
  7282. }
  7283. } else {
  7284. c.ServeSuccessJSON(map[string]interface{}{
  7285. "code": -10,
  7286. "msg": res2.ErrMsg,
  7287. })
  7288. }
  7289. } else {
  7290. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7291. //if err == nil {
  7292. // c.ServeSuccessJSON(map[string]interface{}{
  7293. // "msg": "退费成功",
  7294. // })
  7295. //} else {
  7296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7297. // return
  7298. //}
  7299. }
  7300. }
  7301. func (c *HisApiController) RefundDetail() {
  7302. order_id, _ := c.GetInt64("order_id")
  7303. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7304. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7305. number := c.GetString("number")
  7306. record_time := c.GetString("record_time")
  7307. patient_id, _ := c.GetInt64("patient_id")
  7308. //med_type, _ := c.GetInt64("med_type")
  7309. timeLayout := "2006-01-02"
  7310. loc, _ := time.LoadLocation("Local")
  7311. adminUser := c.GetAdminUserInfo()
  7312. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7313. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7314. fmt.Println(err)
  7315. if err != nil {
  7316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7317. return
  7318. }
  7319. recordDateTime := theTime.Unix()
  7320. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7321. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7322. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7323. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7324. var order models.HisOrder
  7325. order, _ = service.GetHisOrderByID(order_id)
  7326. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7327. if config.IsOpen == 1 { //对接了医保,走医保流程
  7328. var res2 ResultSix
  7329. if miConfig.MdtrtareaAdmvs == "421300" {
  7330. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7331. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7332. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7333. resp3, requestErr3 := http.Get(api3)
  7334. if requestErr3 != nil {
  7335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7336. return
  7337. }
  7338. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7339. if ioErr3 != nil {
  7340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7342. return
  7343. }
  7344. var respJSON3 map[string]interface{}
  7345. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7348. return
  7349. }
  7350. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7351. userJSONBytes3, _ := json.Marshal(respJSON3)
  7352. fmt.Println("log")
  7353. fmt.Println(string(userJSONBytes3))
  7354. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7355. utils.ErrorLog("解析失败:%v", err)
  7356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7357. return
  7358. }
  7359. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7360. if err == nil {
  7361. c.ServeSuccessJSON(map[string]interface{}{
  7362. "msg": "撤销明细成功",
  7363. })
  7364. return
  7365. } else {
  7366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7367. return
  7368. }
  7369. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7370. var resSix10265 ResultSix10265
  7371. var api3 string
  7372. if miConfig.MdtrtareaAdmvs == "320921" {
  7373. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7374. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7375. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7376. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7377. } else {
  7378. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7379. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7380. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7381. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7382. }
  7383. resp3, requestErr3 := http.Get(api3)
  7384. if requestErr3 != nil {
  7385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7386. return
  7387. }
  7388. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7389. if ioErr3 != nil {
  7390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. return
  7393. }
  7394. var respJSON3 map[string]interface{}
  7395. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7398. return
  7399. }
  7400. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7401. userJSONBytes3, _ := json.Marshal(respJSON3)
  7402. fmt.Println("log")
  7403. fmt.Println(string(userJSONBytes3))
  7404. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7405. utils.ErrorLog("解析失败:%v", err)
  7406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7407. return
  7408. }
  7409. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7410. res2.Output = resSix10265.Output
  7411. res2.ErrMsg = resSix10265.ErrMsg
  7412. res2.Cainfo = resSix10265.Cainfo
  7413. res2.WarnMsg = resSix10265.WarnMsg
  7414. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7415. res2.Infcode = infocode
  7416. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7417. if err == nil {
  7418. c.ServeSuccessJSON(map[string]interface{}{
  7419. "msg": "撤销明细成功",
  7420. })
  7421. return
  7422. } else {
  7423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7424. return
  7425. }
  7426. } else {
  7427. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7428. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7429. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7430. resp2, requestErr2 := http.Get(api2)
  7431. if requestErr2 != nil {
  7432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7433. return
  7434. }
  7435. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7436. if ioErr2 != nil {
  7437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7439. return
  7440. }
  7441. var respJSON2 map[string]interface{}
  7442. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7445. return
  7446. }
  7447. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7448. if err == nil {
  7449. c.ServeSuccessJSON(map[string]interface{}{
  7450. "msg": "撤销明细成功",
  7451. })
  7452. return
  7453. } else {
  7454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7455. return
  7456. }
  7457. }
  7458. } else {
  7459. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7460. if err == nil {
  7461. c.ServeSuccessJSON(map[string]interface{}{
  7462. "msg": "退费成功",
  7463. })
  7464. } else {
  7465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7466. return
  7467. }
  7468. }
  7469. }
  7470. //对账
  7471. func (c *HisApiController) GetCheckAccount() {
  7472. start_time := c.GetString("start_time")
  7473. end_time := c.GetString("end_time")
  7474. insutype := c.GetString("insutype")
  7475. clr_type := c.GetString("clr_type")
  7476. clr_org := c.GetString("clr_optins")
  7477. admin_user_id, _ := c.GetInt64("admin_user_id")
  7478. adminUser := c.GetAdminUserInfo()
  7479. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7480. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7481. if len(clr_org) == 0 {
  7482. clr_org = miConfig.MdtrtareaAdmvs
  7483. }
  7484. timeLayout := "2006-01-02"
  7485. loc, _ := time.LoadLocation("Local")
  7486. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7487. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7488. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7489. fixmedins_setl_cnt := int64(len(orders))
  7490. var medfee_sumamt float64
  7491. var acct_pay float64
  7492. var fund_pay_sumamt float64
  7493. for _, item := range orders {
  7494. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7495. acct_pay = acct_pay + item.AcctPay
  7496. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7497. }
  7498. var user_name string
  7499. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7500. if role.ID == 0 {
  7501. user_name = "xxx"
  7502. } else {
  7503. user_name = role.UserName
  7504. }
  7505. var res ResultEight
  7506. var res10188 ResultEightFor10188
  7507. if config.IsOpen == 1 {
  7508. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7509. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7510. "insutype=" + insutype +
  7511. "&clr_type=" + "11" +
  7512. "&setl_optins=" + clr_org +
  7513. "&stmt_begndate=" + start_time +
  7514. "&stm_enddate=" + end_time +
  7515. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7516. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7517. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7518. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7519. "&fixmedins_code=" + miConfig.Code +
  7520. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7521. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7522. "&secret_key=" + miConfig.SecretKey +
  7523. "&org_name=" + miConfig.OrgName +
  7524. "&doctor=" + user_name +
  7525. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7526. fmt.Println(api)
  7527. resp, requestErr := http.Get(api)
  7528. if requestErr != nil {
  7529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7530. return
  7531. }
  7532. body, ioErr := ioutil.ReadAll(resp.Body)
  7533. fmt.Println(body)
  7534. if ioErr != nil {
  7535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7537. return
  7538. }
  7539. var respJSON map[string]interface{}
  7540. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7543. return
  7544. }
  7545. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7546. userJSONBytes, _ := json.Marshal(respJSON)
  7547. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7548. utils.ErrorLog("解析失败:%v", err)
  7549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7550. return
  7551. }
  7552. res.InfRefmsgid = res10188.InfRefmsgid
  7553. res.Output = res10188.Output
  7554. res.ErrMsg = res10188.ErrMsg
  7555. res.Cainfo = res10188.Cainfo
  7556. res.WarnMsg = res10188.WarnMsg
  7557. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7558. res.Infcode = infocode
  7559. } else {
  7560. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7561. "insutype=" + insutype +
  7562. "&clr_type=" + clr_type +
  7563. "&setl_optins=" + clr_org +
  7564. "&stmt_begndate=" + start_time +
  7565. "&stm_enddate=" + end_time +
  7566. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7567. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7568. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7569. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7570. "&fixmedins_code=" + miConfig.Code +
  7571. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7572. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7573. "&secret_key=" + miConfig.SecretKey +
  7574. "&org_name=" + miConfig.OrgName +
  7575. "&doctor=" + user_name
  7576. fmt.Println(api)
  7577. resp, requestErr := http.Get(api)
  7578. if requestErr != nil {
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7580. return
  7581. }
  7582. body, ioErr := ioutil.ReadAll(resp.Body)
  7583. fmt.Println(body)
  7584. if ioErr != nil {
  7585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7587. return
  7588. }
  7589. var respJSON map[string]interface{}
  7590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. return
  7594. }
  7595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7596. userJSONBytes, _ := json.Marshal(respJSON)
  7597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7598. utils.ErrorLog("解析失败:%v", err)
  7599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7600. return
  7601. }
  7602. }
  7603. if res.Infcode == 0 {
  7604. if res.Output.Stmtinfo.StmtRslt == "0" {
  7605. micc := &models.MedicalInsuranceCostCompare{
  7606. StartTime: startime.Unix(),
  7607. EndTime: endtime.Unix(),
  7608. Insutype: insutype,
  7609. CheckType: 1,
  7610. Num: fixmedins_setl_cnt,
  7611. Mtime: time.Now().Unix(),
  7612. Status: 1,
  7613. UserOrgId: adminUser.CurrentOrgId,
  7614. CostTotal: medfee_sumamt,
  7615. FuncTotal: fund_pay_sumamt,
  7616. PsnPay: acct_pay,
  7617. Creator: admin_user_id,
  7618. Ctime: time.Now().Unix(),
  7619. ClrType: clr_type,
  7620. }
  7621. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7622. if err == nil {
  7623. c.ServeSuccessJSON(map[string]interface{}{
  7624. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7625. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7626. })
  7627. } else {
  7628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7629. }
  7630. } else {
  7631. c.ServeSuccessJSON(map[string]interface{}{
  7632. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7633. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7634. })
  7635. }
  7636. } else {
  7637. c.ServeSuccessJSON(map[string]interface{}{
  7638. "code": -10,
  7639. "msg": res.ErrMsg,
  7640. })
  7641. }
  7642. }
  7643. }
  7644. func (c *HisApiController) Check310() {
  7645. adminUser := c.GetAdminUserInfo()
  7646. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7647. var user_name string
  7648. user_name = "高慧裕"
  7649. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7650. "insutype=" + "310" +
  7651. "&clr_type=" + "" +
  7652. "&setl_optins=" + "441202" +
  7653. "&stmt_begndate=" + "2022-03-01" +
  7654. "&stm_enddate=" + "2022-03-31" +
  7655. "&medfee_sumamt=" + "194930.12" +
  7656. "&fund_pay_sumamt=" + "188741.46" +
  7657. "&acct_pay=" + "0" +
  7658. "&fixmedins_setl_cnt=" + "452" +
  7659. "&fixmedins_code=" + miConfig.Code +
  7660. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7661. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7662. "&secret_key=" + miConfig.SecretKey +
  7663. "&org_name=" + miConfig.OrgName +
  7664. "&doctor=" + user_name
  7665. fmt.Println(api)
  7666. resp, requestErr := http.Get(api)
  7667. if requestErr != nil {
  7668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7669. return
  7670. }
  7671. body, ioErr := ioutil.ReadAll(resp.Body)
  7672. fmt.Println(body)
  7673. if ioErr != nil {
  7674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7676. return
  7677. }
  7678. var respJSON map[string]interface{}
  7679. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7682. return
  7683. }
  7684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7685. userJSONBytes, _ := json.Marshal(respJSON)
  7686. var res ResultEight
  7687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7688. utils.ErrorLog("解析失败:%v", err)
  7689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7690. return
  7691. }
  7692. }
  7693. func (c *HisApiController) Check390() {
  7694. adminUser := c.GetAdminUserInfo()
  7695. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7696. var user_name string
  7697. user_name = "高慧裕"
  7698. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7699. "insutype=" + "390" +
  7700. "&clr_type=" + "" +
  7701. "&setl_optins=" + "441202" +
  7702. "&stmt_begndate=" + "2022-03-01" +
  7703. "&stm_enddate=" + "2022-03-31" +
  7704. "&medfee_sumamt=" + "1068448.89" +
  7705. "&fund_pay_sumamt=" + "1014677.62" +
  7706. "&acct_pay=" + "0" +
  7707. "&fixmedins_setl_cnt=" + "1950" +
  7708. "&fixmedins_code=" + miConfig.Code +
  7709. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7710. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7711. "&secret_key=" + miConfig.SecretKey +
  7712. "&org_name=" + miConfig.OrgName +
  7713. "&doctor=" + user_name
  7714. fmt.Println(api)
  7715. resp, requestErr := http.Get(api)
  7716. if requestErr != nil {
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7718. return
  7719. }
  7720. body, ioErr := ioutil.ReadAll(resp.Body)
  7721. fmt.Println(body)
  7722. if ioErr != nil {
  7723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7725. return
  7726. }
  7727. var respJSON map[string]interface{}
  7728. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7731. return
  7732. }
  7733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7734. userJSONBytes, _ := json.Marshal(respJSON)
  7735. var res ResultEight
  7736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7737. utils.ErrorLog("解析失败:%v", err)
  7738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7739. return
  7740. }
  7741. }
  7742. //对账明细
  7743. func (c *HisApiController) GetCheckDetailAccount() {
  7744. start_time := c.GetString("start_time")
  7745. end_time := c.GetString("end_time")
  7746. admin_user_id, _ := c.GetInt64("admin_user_id")
  7747. adminUser := c.GetAdminUserInfo()
  7748. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7749. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7750. timeLayout := "2006-01-02"
  7751. loc, _ := time.LoadLocation("Local")
  7752. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7753. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7754. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7755. Mkdir(miConfig.OrgName)
  7756. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7757. file_name := file + ".txt"
  7758. zip_name := file + ".zip"
  7759. zip_path := miConfig.OrgName + "/" + zip_name
  7760. file_path := miConfig.OrgName + "/" + file_name
  7761. decimal.DivisionPrecision = 2
  7762. var medfee_sumamt float64
  7763. var psn_cash_pay float64
  7764. var fund_pay_sumamt float64
  7765. fixmedins_setl_cnt := int64(len(orders))
  7766. for _, item := range orders {
  7767. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7768. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7769. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7770. }
  7771. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7772. defer f.Close()
  7773. if err != nil {
  7774. fmt.Println(err.Error())
  7775. } else {
  7776. for _, item := range orders {
  7777. var refd_setl_flag string
  7778. if item.OrderStatus == 2 {
  7779. refd_setl_flag = "0"
  7780. var str string
  7781. str = item.SetlId + " " +
  7782. item.MdtrtId + " " +
  7783. item.PsnNo + " " +
  7784. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7785. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7786. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7787. _, err = f.Write([]byte(str))
  7788. }
  7789. if item.OrderStatus == 3 {
  7790. var str string
  7791. str = item.SetlId + " " +
  7792. item.MdtrtId + " " +
  7793. item.PsnNo + " " +
  7794. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7795. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7796. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7797. _, err = f.Write([]byte(str))
  7798. var str2 string
  7799. str2 = item.SetlId + " " +
  7800. item.MdtrtId + " " +
  7801. item.PsnNo + " " +
  7802. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7803. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7804. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7805. _, err = f.Write([]byte(str2))
  7806. }
  7807. }
  7808. }
  7809. Zip(file_path, zip_path)
  7810. fmt.Println(ReadFile(zip_path))
  7811. fmt.Println(string(ReadFile(zip_path)))
  7812. if config.IsOpen == 1 {
  7813. var user_name string
  7814. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7815. if role.ID == 0 {
  7816. user_name = "管理员"
  7817. } else {
  7818. user_name = role.UserName
  7819. }
  7820. baseParams := models.BaseParams{
  7821. SecretKey: miConfig.SecretKey,
  7822. FixmedinsCode: miConfig.Code,
  7823. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7824. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7825. OrgName: miConfig.OrgName,
  7826. Doctor: user_name,
  7827. }
  7828. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7829. var dat map[string]interface{}
  7830. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7831. fmt.Println(dat)
  7832. } else {
  7833. fmt.Println(err)
  7834. }
  7835. userJSONBytes, _ := json.Marshal(dat)
  7836. var res ResultNine
  7837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7838. utils.ErrorLog("解析失败:%v", err)
  7839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7840. return
  7841. }
  7842. if res.Infcode == 0 {
  7843. fileNo := res.Output.FileQuryNo
  7844. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7845. "file_qury_no=" + fileNo +
  7846. "&setl_optins=" + "定点医保中心" +
  7847. "&stmt_begndate=" + start_time +
  7848. "&stm_enddate=" + end_time +
  7849. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7850. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7851. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7852. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7853. "&fixmedins_code=" + miConfig.Code +
  7854. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7855. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7856. "&secret_key=" + miConfig.SecretKey +
  7857. "&org_name=" + miConfig.OrgName +
  7858. "&doctor=" + user_name
  7859. resp, requestErr := http.Get(api)
  7860. if requestErr != nil {
  7861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7862. return
  7863. }
  7864. body, ioErr := ioutil.ReadAll(resp.Body)
  7865. if ioErr != nil {
  7866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7868. return
  7869. }
  7870. var respJSON map[string]interface{}
  7871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7874. return
  7875. }
  7876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7877. userJSONBytes, _ := json.Marshal(respJSON)
  7878. var res ResultTen
  7879. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7880. utils.ErrorLog("解析失败:%v", err)
  7881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7882. return
  7883. }
  7884. if res.Infcode == 0 {
  7885. service.Gdyb9102(baseParams, zip_name, fileNo)
  7886. micc := &models.MedicalInsuranceCostCompare{
  7887. StartTime: startime.Unix(),
  7888. EndTime: endtime.Unix(),
  7889. Insutype: "0",
  7890. CheckType: 2,
  7891. Num: fixmedins_setl_cnt,
  7892. Mtime: time.Now().Unix(),
  7893. Status: 1,
  7894. UserOrgId: adminUser.CurrentOrgId,
  7895. CostTotal: medfee_sumamt,
  7896. FuncTotal: fund_pay_sumamt,
  7897. PsnPay: psn_cash_pay,
  7898. Creator: admin_user_id,
  7899. Ctime: time.Now().Unix(),
  7900. }
  7901. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7902. c.ServeSuccessJSON(map[string]interface{}{
  7903. "msg": "明细对账成功",
  7904. })
  7905. }
  7906. } else {
  7907. }
  7908. }
  7909. }
  7910. type CustomOrderInfo struct {
  7911. Name string
  7912. Spec string
  7913. Unit string
  7914. Count float64
  7915. Price float64
  7916. Total float64
  7917. }
  7918. func (c *HisApiController) GetSettleAccounts() {
  7919. //id, _ := c.GetInt64("id")
  7920. //record_time := c.GetString("record_time")
  7921. order_id, _ := c.GetInt64("order_id")
  7922. admin_user_id, _ := c.GetInt64("admin_user_id")
  7923. //timeLayout := "2006-01-02"
  7924. //loc, _ := time.LoadLocation("Local")
  7925. //
  7926. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7927. //if err != nil {
  7928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7929. // return
  7930. //}
  7931. //recordDateTime := theTime.Unix()
  7932. adminUser := c.GetAdminUserInfo()
  7933. order, _ := service.GetHisOrderByID(order_id)
  7934. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7935. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7936. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7937. orderInfos = append(orderInfos, orderInfos_two...)
  7938. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7939. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7940. var diagnosis_ids []string
  7941. if his.ID > 0 {
  7942. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  7943. } else {
  7944. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  7945. }
  7946. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7947. var dia_config []*models.HisXtDiagnoseConfig
  7948. var name string
  7949. for _, item := range diagnosis_ids {
  7950. id, _ := strconv.ParseInt(item, 10, 64)
  7951. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7952. dia_config = append(dia_config, &diagnosisConfig)
  7953. if len(name) == 0 {
  7954. name = diagnosisConfig.ClassName
  7955. } else {
  7956. name = name + "," + diagnosisConfig.ClassName
  7957. }
  7958. }
  7959. var bedCostTotal float64 = 0 //床位总费
  7960. var bedCostSelfTotal float64 = 0 //床位自费
  7961. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7962. var operationCostTotal float64 = 0 //手术费
  7963. var operationCostSelfTotal float64 = 0 //手术费
  7964. var operationCostPartSelfTotal float64 = 0 //手术费
  7965. var otherCostTotal float64 = 0 //其他费用
  7966. var otherCostSelfTotal float64 = 0 //其他费用
  7967. var otherCostPartSelfTotal float64 = 0 //其他费用
  7968. var materialCostTotal float64 = 0 //材料费
  7969. var materialCostSelfTotal float64 = 0 //材料费
  7970. var materialCostPartSelfTotal float64 = 0 //材料费
  7971. var westernMedicineCostTotal float64 = 0 //西药费
  7972. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7973. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7974. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7975. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7976. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7977. var checkCostTotal float64 = 0 //检查费
  7978. var checkCostSelfTotal float64 = 0 //检查费
  7979. var checkCostPartSelfTotal float64 = 0 //检查费
  7980. var laboratoryCostTotal float64 = 0 //化验费
  7981. var laboratoryCostSelfTotal float64 = 0 //化验费
  7982. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7983. var treatCostTotal float64 = 0 //治疗费用
  7984. var treatCostSelfTotal float64 = 0 //治疗费用
  7985. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7986. decimal.DivisionPrecision = 2
  7987. for _, item := range orderInfos {
  7988. if item.MedChrgitmType == "01" { //床位费
  7989. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7990. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7991. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7992. }
  7993. if item.MedChrgitmType == "03" { //检查费
  7994. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7995. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7996. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7997. }
  7998. if item.MedChrgitmType == "04" { //化验费
  7999. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8000. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8001. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8002. }
  8003. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8004. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8005. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8006. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8007. }
  8008. if item.MedChrgitmType == "06" { //手术费
  8009. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8010. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8011. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8012. }
  8013. if item.MedChrgitmType == "08" { //材料费
  8014. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8015. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8016. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8017. }
  8018. if item.MedChrgitmType == "09" { //西药费
  8019. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8020. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8021. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8022. }
  8023. if item.MedChrgitmType == "11" { //中成费
  8024. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8025. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8026. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8027. }
  8028. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8029. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8030. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8031. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8032. }
  8033. }
  8034. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8035. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8036. var user_name string
  8037. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8038. if role.ID == 0 {
  8039. user_name = "管理员"
  8040. } else {
  8041. user_name = role.UserName
  8042. }
  8043. baseParams := models.BaseParams{
  8044. SecretKey: miConfig.SecretKey,
  8045. FixmedinsCode: miConfig.Code,
  8046. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8047. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8048. OrgName: miConfig.OrgName,
  8049. Doctor: user_name,
  8050. }
  8051. businessParams := models.BusinessParams{
  8052. PsnNo: order.PsnNo,
  8053. MdtrtId: order.MdtrtId,
  8054. SetlId: order.SetlId,
  8055. }
  8056. var res ResultEleven
  8057. var resEleven10265 ResultEleven10265
  8058. if config.IsOpen == 1 {
  8059. if miConfig.MdtrtareaAdmvs == "421300" {
  8060. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8061. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8062. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8063. resp, requestErr := http.Get(api)
  8064. if requestErr != nil {
  8065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8066. return
  8067. }
  8068. body, ioErr := ioutil.ReadAll(resp.Body)
  8069. if ioErr != nil {
  8070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8072. return
  8073. }
  8074. var respJSON map[string]interface{}
  8075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. return
  8079. }
  8080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8081. result, _ := json.Marshal(respJSON)
  8082. fmt.Println("log")
  8083. fmt.Println(string(result))
  8084. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8085. utils.ErrorLog("解析失败:%v", err)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8090. var api string
  8091. if miConfig.MdtrtareaAdmvs == "320921" {
  8092. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8093. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8094. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8095. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8096. } else {
  8097. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8098. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8099. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8100. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8101. }
  8102. resp, requestErr := http.Get(api)
  8103. if requestErr != nil {
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8105. return
  8106. }
  8107. body, ioErr := ioutil.ReadAll(resp.Body)
  8108. if ioErr != nil {
  8109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8111. return
  8112. }
  8113. var respJSON map[string]interface{}
  8114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8117. return
  8118. }
  8119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8120. result, _ := json.Marshal(respJSON)
  8121. fmt.Println("log")
  8122. fmt.Println(string(result))
  8123. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8124. utils.ErrorLog("解析失败:%v", err)
  8125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8126. return
  8127. }
  8128. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8129. res.Output = resEleven10265.Output
  8130. res.ErrMsg = resEleven10265.ErrMsg
  8131. res.Cainfo = resEleven10265.Cainfo
  8132. res.WarnMsg = resEleven10265.WarnMsg
  8133. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8134. res.Infcode = infocode
  8135. } else {
  8136. //result2 := service.Gdyb1101()
  8137. //result2 := service.Gdyb5204(baseParams, businessParams)
  8138. //saveLog(result2, "", "5204", "查询")
  8139. result := service.Gdyb5203(baseParams, businessParams)
  8140. var dat map[string]interface{}
  8141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8142. fmt.Println(dat)
  8143. } else {
  8144. fmt.Println(err)
  8145. }
  8146. userJSONBytes, _ := json.Marshal(dat)
  8147. if miConfig.Code == "H15049901371" {
  8148. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8149. utils.ErrorLog("解析失败:%v", err)
  8150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8151. return
  8152. }
  8153. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8154. res.Output = resEleven10265.Output
  8155. res.ErrMsg = resEleven10265.ErrMsg
  8156. res.Cainfo = resEleven10265.Cainfo
  8157. res.WarnMsg = resEleven10265.WarnMsg
  8158. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8159. res.Infcode = infocode
  8160. } else {
  8161. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8162. utils.ErrorLog("解析失败:%v", err)
  8163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8164. return
  8165. }
  8166. }
  8167. }
  8168. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8169. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8170. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8171. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8172. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8173. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8174. var doctor_name string
  8175. if roles.ID == 0 {
  8176. doctor_name = "管理员"
  8177. } else {
  8178. doctor_name = roles.UserName
  8179. }
  8180. yiliao_leibie := ""
  8181. switch order.MedType {
  8182. case "11":
  8183. yiliao_leibie = "普通门诊"
  8184. break
  8185. case "12":
  8186. yiliao_leibie = "门诊挂号"
  8187. break
  8188. case "13":
  8189. yiliao_leibie = "急诊"
  8190. break
  8191. case "14":
  8192. yiliao_leibie = "门诊特殊病"
  8193. break
  8194. case "15":
  8195. yiliao_leibie = "门诊统筹"
  8196. break
  8197. case "16":
  8198. yiliao_leibie = "门诊慢性病"
  8199. break
  8200. case "21":
  8201. yiliao_leibie = "普通住院"
  8202. break
  8203. }
  8204. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8205. if res.Infcode == 0 {
  8206. c.ServeSuccessJSON(map[string]interface{}{
  8207. "diagnosis": name,
  8208. "order_infos": orderInfos,
  8209. "number": order.MdtrtId,
  8210. "date": order.SettleAccountsDate,
  8211. "charge_admin": charge_admin,
  8212. "printor_admin": printor_admin,
  8213. "info": res.Output.Setlinfo,
  8214. "order": order,
  8215. "bedCostTotal": bedCostTotal,
  8216. "bedCostSelfTotal": bedCostSelfTotal,
  8217. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8218. "operationCostTotal": operationCostTotal,
  8219. "operationCostSelfTotal": operationCostSelfTotal,
  8220. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8221. "otherCostTotal": otherCostTotal,
  8222. "otherCostSelfTotal": otherCostSelfTotal,
  8223. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8224. "materialCostTotal": materialCostTotal,
  8225. "materialCostSelfTotal": materialCostSelfTotal,
  8226. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8227. "westernMedicineCostTotal": westernMedicineCostTotal,
  8228. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8229. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8230. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8231. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8232. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8233. "checkCostTotal": checkCostTotal,
  8234. "checkCostSelfTotal": checkCostSelfTotal,
  8235. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8236. "laboratoryCostTotal": laboratoryCostTotal,
  8237. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8238. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8239. "treatCostTotal": treatCostTotal,
  8240. "treatCostSelfTotal": treatCostSelfTotal,
  8241. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8242. "doctor_info": doctor_info,
  8243. "doctor_code": adminRole_two.DoctorCode,
  8244. "doctor_name": doctor_name,
  8245. "health_card_no": order.PsnNo,
  8246. "department": departments.Name,
  8247. "yiliao_leibie": yiliao_leibie,
  8248. "after_money": order.AccountPrice,
  8249. "patient": patient,
  8250. "org_name": miConfig.OrgName,
  8251. "org_code": miConfig.Code,
  8252. "order_number": order.Number,
  8253. "his_hospital": his_hospital,
  8254. "his": his,
  8255. "dia_config": dia_config,
  8256. //"check_order_info": cus_slice,
  8257. })
  8258. }
  8259. }
  8260. }
  8261. func (c *HisApiController) CheckTreatment() {
  8262. patient_id, _ := c.GetInt64("patient_id")
  8263. id_card_no := c.GetString("id_card_no")
  8264. insutype := c.GetString("insutype")
  8265. med_type := c.GetString("med_type")
  8266. admin_user_id, _ := c.GetInt64("admin_user_id")
  8267. adminUser := c.GetAdminUserInfo()
  8268. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8269. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8270. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8271. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8272. if miConfig.MdtrtareaAdmvs == "421300" {
  8273. var res ResultTwo
  8274. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8275. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8276. "&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)
  8277. resp, requestErr := http.Get(api)
  8278. if requestErr != nil {
  8279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8280. return
  8281. }
  8282. body, ioErr := ioutil.ReadAll(resp.Body)
  8283. if ioErr != nil {
  8284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. var respJSON map[string]interface{}
  8289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8292. return
  8293. }
  8294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8295. result, _ := json.Marshal(respJSON)
  8296. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8297. utils.ErrorLog("解析失败:%v", err)
  8298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8299. return
  8300. }
  8301. if res.Infcode == 0 {
  8302. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8303. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8304. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8305. resp, requestErr := http.Get(api)
  8306. if requestErr != nil {
  8307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8308. return
  8309. }
  8310. body, ioErr := ioutil.ReadAll(resp.Body)
  8311. if ioErr != nil {
  8312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8314. return
  8315. }
  8316. var respJSON map[string]interface{}
  8317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8320. return
  8321. }
  8322. var res Result2001
  8323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8324. result2, _ := json.Marshal(respJSON)
  8325. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8326. utils.ErrorLog("解析失败:%v", err)
  8327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8328. return
  8329. }
  8330. if res.Infcode == 0 {
  8331. c.ServeSuccessJSON(map[string]interface{}{
  8332. "msg": res.Output.Trtinfo,
  8333. })
  8334. }
  8335. } else {
  8336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8337. return
  8338. }
  8339. } else {
  8340. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8341. var dat map[string]interface{}
  8342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8343. fmt.Println(dat)
  8344. } else {
  8345. fmt.Println(err)
  8346. }
  8347. userJSONBytes, _ := json.Marshal(dat)
  8348. var res ResultTwo
  8349. var res10265 ResultTwo10265
  8350. if miConfig.Code == "H15049901371" {
  8351. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8352. utils.ErrorLog("解析失败:%v", err)
  8353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8354. return
  8355. }
  8356. res.ErrMsg = res10265.ErrMsg
  8357. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8358. res.Infcode = infocode
  8359. res.Output = res10265.Output
  8360. res.InfRefmsgid = res10265.InfRefmsgid
  8361. } else {
  8362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8363. utils.ErrorLog("解析失败:%v", err)
  8364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8365. return
  8366. }
  8367. }
  8368. var user_name string
  8369. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8370. if role.ID == 0 {
  8371. user_name = "xxx"
  8372. } else {
  8373. user_name = role.UserName
  8374. }
  8375. baseParams := models.BaseParams{
  8376. SecretKey: miConfig.SecretKey,
  8377. FixmedinsCode: miConfig.Code,
  8378. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8379. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8380. OrgName: miConfig.OrgName,
  8381. Doctor: user_name,
  8382. }
  8383. if config.IsOpen == 1 {
  8384. if miConfig.Code == "H15049901371" {
  8385. if med_type == "14" {
  8386. if insutype == "390" {
  8387. med_type = "9933"
  8388. } else if insutype == "310" {
  8389. med_type = "990502"
  8390. }
  8391. } else if med_type == "11" {
  8392. med_type = "11"
  8393. }
  8394. }
  8395. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8396. var dat map[string]interface{}
  8397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8398. fmt.Println(dat)
  8399. } else {
  8400. fmt.Println(err)
  8401. }
  8402. var res Result2001
  8403. var res10265 Result2001Org10265
  8404. if miConfig.Code == "H15049901371" {
  8405. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8406. utils.ErrorLog("解析失败:%v", err)
  8407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8408. return
  8409. }
  8410. res.ErrMsg = res10265.ErrMsg
  8411. res.Output = res10265.Output
  8412. res.InfRefmsgid = res10265.InfRefmsgid
  8413. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8414. res.Infcode = infocode
  8415. } else {
  8416. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8417. utils.ErrorLog("解析失败:%v", err)
  8418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8419. return
  8420. }
  8421. }
  8422. if res.Infcode == 0 {
  8423. c.ServeSuccessJSON(map[string]interface{}{
  8424. "msg": res.Output.Trtinfo,
  8425. })
  8426. }
  8427. }
  8428. }
  8429. }
  8430. //func (c *HisApiController) PutRecord() {
  8431. // id, _ := c.GetInt64("id")
  8432. // record_time := c.GetString("record_time")
  8433. // timeLayout := "2006-01-02"
  8434. // loc, _ := time.LoadLocation("Local")
  8435. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8436. // if err != nil {
  8437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8438. // return
  8439. // }
  8440. // recordDateTime := theTime.Unix()
  8441. //
  8442. // adminInfo := c.GetAdminUserInfo()
  8443. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8444. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8445. //
  8446. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8447. //
  8448. // fmt.Println(miConfig.SecretKey)
  8449. //
  8450. // if patient == nil {
  8451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8452. // return
  8453. // }
  8454. // if len(patient.IdCardNo) == 0 {
  8455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8456. // return
  8457. // }
  8458. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8459. // if config.IsOpen == 1 {
  8460. // 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
  8461. // resp, requestErr := http.Get(api)
  8462. // if requestErr != nil {
  8463. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8464. // return
  8465. // }
  8466. // defer resp.Body.Close()
  8467. // body, ioErr := ioutil.ReadAll(resp.Body)
  8468. // if ioErr != nil {
  8469. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8471. // return
  8472. // }
  8473. // var respJSON map[string]interface{}
  8474. //
  8475. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8476. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8478. // return
  8479. // }
  8480. //
  8481. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8482. // userJSONBytes, _ := json.Marshal(userJSON)
  8483. // var res ResultTwo
  8484. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8485. // utils.ErrorLog("解析失败:%v", err)
  8486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8487. // return
  8488. // }
  8489. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8490. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8491. // infoStr := string(Iinfos)
  8492. // idetinfoStr := string(Idetinfos)
  8493. //
  8494. // if res.Infcode == 0 {
  8495. // his := models.VMHisPatient{
  8496. // Status: 1,
  8497. // Ctime: time.Now().Unix(),
  8498. // Mtime: time.Now().Unix(),
  8499. // PsnNo: res.Output.Baseinfo.PsnNo,
  8500. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8501. // Certno: res.Output.Baseinfo.Certno,
  8502. // PsnName: res.Output.Baseinfo.PsnName,
  8503. // Gend: res.Output.Baseinfo.Gend,
  8504. // Naty: res.Output.Baseinfo.Naty,
  8505. // Brdy: res.Output.Baseinfo.Brdy,
  8506. // Age: res.Output.Baseinfo.Age,
  8507. // Iinfo: infoStr,
  8508. // Idetinfo: idetinfoStr,
  8509. // PatientId: patient.ID,
  8510. // RecordDate: theTime.Unix(),
  8511. // UserOrgId: adminInfo.CurrentOrgId,
  8512. // AdminUserId: adminInfo.AdminUser.Id,
  8513. // IsReturn: 1,
  8514. // }
  8515. //
  8516. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8517. // //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")
  8518. // //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")
  8519. //
  8520. // //var dat map[string]interface{}
  8521. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8522. // // fmt.Println(dat)
  8523. // //} else {
  8524. // // fmt.Println(err)
  8525. // //}
  8526. //
  8527. // var dat2 map[string]interface{}
  8528. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8529. // fmt.Println(dat2)
  8530. // } else {
  8531. // fmt.Println(err)
  8532. // }
  8533. //
  8534. // } else {
  8535. // adminUser := c.GetAdminUserInfo()
  8536. // errlog := &models.HisOrderError{
  8537. // UserOrgId: adminUser.CurrentOrgId,
  8538. // Ctime: time.Now().Unix(),
  8539. // Mtime: time.Now().Unix(),
  8540. // ErrMsg: res.ErrMsg,
  8541. // Status: 1,
  8542. // PatientId: id,
  8543. // RecordTime: recordDateTime,
  8544. // Stage: 1,
  8545. // }
  8546. // service.CreateErrMsgLog(errlog)
  8547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8548. // return
  8549. // }
  8550. // }
  8551. //
  8552. //}
  8553. //func (c *HisApiController) GetUploadDiag() {
  8554. // id, _ := c.GetInt64("id")
  8555. // record_time := c.GetString("record_time")
  8556. //
  8557. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8558. // sick_type, _ := c.GetInt64("sick_type")
  8559. // reg_type, _ := c.GetInt64("reg_type")
  8560. //
  8561. // timeLayout := "2006-01-02"
  8562. // loc, _ := time.LoadLocation("Local")
  8563. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8564. // if err != nil {
  8565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8566. // return
  8567. // }
  8568. //
  8569. // var patientPrescription models.HisPrescriptionInfo
  8570. // recordDateTime := theTime.Unix()
  8571. // adminInfo := c.GetAdminUserInfo()
  8572. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8573. //
  8574. // if patientPrescription.ID == 0 {
  8575. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8576. // }
  8577. //
  8578. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8579. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8580. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8581. // sickConfig, _ := service.FindSickById(sick_type)
  8582. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8583. //
  8584. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8585. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8586. // "&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 +
  8587. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8588. // resp2, requestErr2 := http.Get(api2)
  8589. // if requestErr2 != nil {
  8590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8591. // return
  8592. // }
  8593. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8594. // if ioErr2 != nil {
  8595. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8597. // return
  8598. // }
  8599. // var respJSON2 map[string]interface{}
  8600. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8601. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8603. // return
  8604. // }
  8605. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8606. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8607. //
  8608. // var res2 ResultSix
  8609. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8610. // utils.ErrorLog("解析失败:%v", err)
  8611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8612. // return
  8613. // }
  8614. // if res2.Infcode != 0 {
  8615. // adminUser := c.GetAdminUserInfo()
  8616. // errlog := &models.HisOrderError{
  8617. // UserOrgId: adminUser.CurrentOrgId,
  8618. // Ctime: time.Now().Unix(),
  8619. // Mtime: time.Now().Unix(),
  8620. // ErrMsg: res2.ErrMsg,
  8621. // Status: 1,
  8622. // PatientId: id,
  8623. // RecordTime: recordDateTime,
  8624. // Stage: 3,
  8625. // }
  8626. // service.CreateErrMsgLog(errlog)
  8627. //
  8628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8629. // return
  8630. // }
  8631. //
  8632. // c.ServeSuccessJSON(map[string]interface{}{
  8633. // "msg": "上传成功",
  8634. // })
  8635. //
  8636. //}
  8637. type QueryResult struct {
  8638. ID int64
  8639. Name string
  8640. Code string
  8641. List_type_code string
  8642. }
  8643. func (c *HisApiController) GetCheckCode() {
  8644. ids_str := c.GetString("ids")
  8645. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8646. ids_arr := strings.Split(ids_str, ",")
  8647. var queryResult []QueryResult
  8648. ids := make([]int64, 0)
  8649. for _, item := range ids_arr {
  8650. id, _ := strconv.ParseInt(item, 10, 64)
  8651. ids = append(ids, id)
  8652. }
  8653. if record_type == 1 {
  8654. drugs, _ := service.GetBatchDrugList(ids)
  8655. for _, item := range drugs {
  8656. result := QueryResult{
  8657. ID: item.ID,
  8658. Name: item.DrugName,
  8659. Code: item.MedicalInsuranceNumber,
  8660. List_type_code: "101",
  8661. }
  8662. queryResult = append(queryResult, result)
  8663. }
  8664. } else if record_type == 2 {
  8665. goods, _ := service.GetBatchGoodInformationList(ids)
  8666. for _, item := range goods {
  8667. result := QueryResult{
  8668. ID: item.ID,
  8669. Name: item.GoodName,
  8670. Code: item.MedicalInsuranceNumber,
  8671. List_type_code: "301",
  8672. }
  8673. queryResult = append(queryResult, result)
  8674. }
  8675. } else if record_type == 3 {
  8676. projects, _ := service.GetBathchMyPorjecgList(ids)
  8677. for _, item := range projects {
  8678. result := QueryResult{
  8679. ID: item.ID,
  8680. Name: item.ProjectName,
  8681. Code: item.MedicalCode,
  8682. List_type_code: "201",
  8683. }
  8684. queryResult = append(queryResult, result)
  8685. }
  8686. }
  8687. admin_user_id, _ := c.GetInt64("admin_user_id")
  8688. adminUser := c.GetAdminUserInfo()
  8689. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8690. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8691. var user_name string
  8692. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8693. if role.ID == 0 {
  8694. user_name = "xxx"
  8695. } else {
  8696. user_name = role.UserName
  8697. }
  8698. baseParams := &models.BaseParams{
  8699. SecretKey: miConfig.SecretKey,
  8700. FixmedinsCode: miConfig.Code,
  8701. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8702. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8703. OrgName: miConfig.OrgName,
  8704. Doctor: user_name,
  8705. }
  8706. if config.IsOpen == 1 {
  8707. for _, item := range queryResult {
  8708. var result string
  8709. if record_type == 1 {
  8710. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8711. } else if record_type == 2 {
  8712. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8713. } else if record_type == 3 {
  8714. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8715. }
  8716. var dat map[string]interface{}
  8717. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8718. fmt.Println(dat)
  8719. } else {
  8720. fmt.Println(err)
  8721. }
  8722. userJSONBytes, _ := json.Marshal(dat)
  8723. var res ResultSix
  8724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8725. utils.ErrorLog("解析失败:%v", err)
  8726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8727. return
  8728. }
  8729. if res.Infcode == 0 {
  8730. if record_type == 1 {
  8731. service.UpdateBaseDrugById(item.ID)
  8732. } else if record_type == 2 {
  8733. service.UpdateGoodInformaitonByDetail(item.ID)
  8734. } else if record_type == 3 {
  8735. service.UpdateProjectById(item.ID)
  8736. }
  8737. c.ServeSuccessJSON(map[string]interface{}{
  8738. "failed_code": 0,
  8739. "msg": "目录对照成功",
  8740. })
  8741. } else {
  8742. c.ServeSuccessJSON(map[string]interface{}{
  8743. "failed_code": -10,
  8744. "msg": res.ErrMsg,
  8745. })
  8746. }
  8747. }
  8748. }
  8749. }
  8750. func (c *HisApiController) UnCheckCode() {
  8751. ids_str := c.GetString("ids")
  8752. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8753. admin_user_id, _ := c.GetInt64("admin_user_id")
  8754. ids_arr := strings.Split(ids_str, ",")
  8755. var queryResult []QueryResult
  8756. ids := make([]int64, 0)
  8757. for _, item := range ids_arr {
  8758. id, _ := strconv.ParseInt(item, 10, 64)
  8759. ids = append(ids, id)
  8760. }
  8761. if record_type == 1 {
  8762. drugs, _ := service.GetBatchDrugList(ids)
  8763. for _, item := range drugs {
  8764. result := QueryResult{
  8765. ID: item.ID,
  8766. Name: item.DrugName,
  8767. Code: item.MedicalInsuranceNumber,
  8768. List_type_code: "101",
  8769. }
  8770. queryResult = append(queryResult, result)
  8771. }
  8772. } else if record_type == 2 {
  8773. goods, _ := service.GetBatchGoodInformationList(ids)
  8774. for _, item := range goods {
  8775. result := QueryResult{
  8776. ID: item.ID,
  8777. Name: item.GoodName,
  8778. Code: item.MedicalInsuranceNumber,
  8779. List_type_code: "301",
  8780. }
  8781. queryResult = append(queryResult, result)
  8782. }
  8783. } else if record_type == 3 {
  8784. projects, _ := service.GetBathchMyPorjecgList(ids)
  8785. for _, item := range projects {
  8786. result := QueryResult{
  8787. ID: item.ID,
  8788. Name: item.ProjectName,
  8789. Code: item.MedicalCode,
  8790. List_type_code: "201",
  8791. }
  8792. queryResult = append(queryResult, result)
  8793. }
  8794. }
  8795. adminUser := c.GetAdminUserInfo()
  8796. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8797. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8798. var user_name string
  8799. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8800. if role.ID == 0 {
  8801. user_name = "xxx"
  8802. } else {
  8803. user_name = role.UserName
  8804. }
  8805. baseParams := &models.BaseParams{
  8806. SecretKey: miConfig.SecretKey,
  8807. FixmedinsCode: miConfig.Code,
  8808. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8809. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8810. OrgName: miConfig.OrgName,
  8811. Doctor: user_name,
  8812. }
  8813. if config.IsOpen == 1 {
  8814. for _, item := range queryResult {
  8815. var result string
  8816. if record_type == 1 {
  8817. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8818. } else if record_type == 2 {
  8819. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8820. } else if record_type == 3 {
  8821. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8822. }
  8823. var dat2 map[string]interface{}
  8824. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8825. fmt.Println(dat2)
  8826. } else {
  8827. fmt.Println(err)
  8828. }
  8829. userJSONBytes, _ := json.Marshal(dat2)
  8830. var res ResultSix
  8831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8832. utils.ErrorLog("解析失败:%v", err)
  8833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8834. return
  8835. }
  8836. if res.Infcode == 0 {
  8837. if record_type == 1 {
  8838. service.UpdateDrugByIdDetail(item.ID)
  8839. } else if record_type == 2 {
  8840. service.UpdateGoodInfoById(item.ID)
  8841. } else if record_type == 3 {
  8842. service.UpdateMyProjectById(item.ID)
  8843. }
  8844. c.ServeSuccessJSON(map[string]interface{}{
  8845. "failed_code": 0,
  8846. "msg": "撤销目录对照成功",
  8847. })
  8848. } else {
  8849. c.ServeSuccessJSON(map[string]interface{}{
  8850. "failed_code": -10,
  8851. "msg": res.ErrMsg,
  8852. })
  8853. }
  8854. }
  8855. }
  8856. }
  8857. func (c *HisApiController) GetPatientInfo() {
  8858. id_card_no := c.GetString("id_card_no")
  8859. admin_user_id, _ := c.GetInt64("admin_user_id")
  8860. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8861. if patient.ID == 0 {
  8862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8863. return
  8864. }
  8865. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8866. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8867. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8868. if config.IsOpen == 1 {
  8869. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8870. var dat map[string]interface{}
  8871. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8872. fmt.Println(dat)
  8873. } else {
  8874. fmt.Println(err)
  8875. }
  8876. userJSONBytes, _ := json.Marshal(dat)
  8877. var res ResultTwo
  8878. var res10265 ResultTwo10265
  8879. if miConfig.Code == "H15049901371" {
  8880. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8881. utils.ErrorLog("解析失败:%v", err)
  8882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8883. return
  8884. }
  8885. res.ErrMsg = res10265.ErrMsg
  8886. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8887. res.Infcode = infocode
  8888. res.Output = res10265.Output
  8889. res.InfRefmsgid = res10265.InfRefmsgid
  8890. } else {
  8891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8892. utils.ErrorLog("解析失败:%v", err)
  8893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8894. return
  8895. }
  8896. }
  8897. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8898. // utils.ErrorLog("解析失败:%v", err)
  8899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8900. // return
  8901. //}
  8902. if res.Infcode != 0 {
  8903. c.ServeSuccessJSON(map[string]interface{}{
  8904. "failed_code": -10,
  8905. "msg": res.ErrMsg,
  8906. })
  8907. } else {
  8908. c.ServeSuccessJSON(map[string]interface{}{
  8909. "failed_code": 0,
  8910. "info": res,
  8911. })
  8912. }
  8913. }
  8914. }
  8915. func (c *HisApiController) PsnPutOnRecord() {
  8916. record_type, _ := c.GetInt64("type")
  8917. patient_id, _ := c.GetInt64("patient_id")
  8918. admin_user_id, _ := c.GetInt64("admin_user_id")
  8919. start_time := c.GetString("start_time")
  8920. end_time := c.GetString("end_time")
  8921. adminUser := c.GetAdminUserInfo()
  8922. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8923. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8924. var patients []*models.Patients
  8925. if record_type == 1 { //全部备案
  8926. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8927. patients = append(patients, patient...)
  8928. } else { //单个备案
  8929. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8930. patients = append(patients, patient)
  8931. }
  8932. var user_name string
  8933. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8934. if role.ID == 0 {
  8935. user_name = "xxx"
  8936. } else {
  8937. user_name = role.UserName
  8938. }
  8939. if config.IsOpen == 1 {
  8940. for _, item := range patients {
  8941. 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
  8942. resp, requestErr := http.Get(api)
  8943. if requestErr != nil {
  8944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8945. return
  8946. }
  8947. defer resp.Body.Close()
  8948. body, ioErr := ioutil.ReadAll(resp.Body)
  8949. if ioErr != nil {
  8950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8952. return
  8953. }
  8954. var respJSON map[string]interface{}
  8955. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8958. return
  8959. }
  8960. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8961. userJSONBytes, _ := json.Marshal(userJSON)
  8962. var res ResultTwo
  8963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8964. utils.ErrorLog("解析失败:%v", err)
  8965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8966. return
  8967. }
  8968. if res.Infcode == 0 {
  8969. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8970. var dat map[string]interface{}
  8971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8972. fmt.Println(dat)
  8973. } else {
  8974. fmt.Println(err)
  8975. }
  8976. userJSONBytes, _ := json.Marshal(dat)
  8977. var res2 ResultThirteen
  8978. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8979. utils.ErrorLog("解析失败:%v", err)
  8980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8981. return
  8982. }
  8983. if res2.Infcode == 0 {
  8984. psnResult := &models.GdybPsnRecord{
  8985. UserOrgId: adminUser.CurrentOrgId,
  8986. PatientId: item.ID,
  8987. PsnNo: res.Output.Baseinfo.PsnNo,
  8988. Ctime: time.Now().Unix(),
  8989. Mtime: time.Now().Unix(),
  8990. Status: 1,
  8991. IsCancel: 1,
  8992. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8993. }
  8994. service.CreatePsnRecord(psnResult)
  8995. } else {
  8996. c.ServeSuccessJSON(map[string]interface{}{
  8997. "failed_code": -10,
  8998. "msg": res2.ErrMsg,
  8999. })
  9000. return
  9001. }
  9002. }
  9003. }
  9004. }
  9005. }
  9006. func (c *HisApiController) PsnUnPutOnRecord() {
  9007. id, _ := c.GetInt64("id")
  9008. //record_type, _ := c.GetInt64("type")
  9009. admin_user_id, _ := c.GetInt64("admin_user_id")
  9010. adminUser := c.GetAdminUserInfo()
  9011. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9012. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9013. var user_name string
  9014. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9015. if role.ID == 0 {
  9016. user_name = "xxx"
  9017. } else {
  9018. user_name = role.UserName
  9019. }
  9020. psn_record, _ := service.GetPsnRecordById(id)
  9021. if psn_record.ID == 0 {
  9022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9023. return
  9024. }
  9025. if config.IsOpen == 1 {
  9026. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9027. var dat map[string]interface{}
  9028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9029. fmt.Println(dat)
  9030. } else {
  9031. fmt.Println(err)
  9032. }
  9033. userJSONBytes, _ := json.Marshal(dat)
  9034. var res ResultFourteen
  9035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9036. utils.ErrorLog("解析失败:%v", err)
  9037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9038. return
  9039. }
  9040. if res.Infcode == 0 {
  9041. psn_record.IsCancel = 2
  9042. service.CreatePsnRecord(&psn_record)
  9043. } else {
  9044. c.ServeSuccessJSON(map[string]interface{}{
  9045. "failed_code": -10,
  9046. "msg": res.ErrMsg,
  9047. })
  9048. return
  9049. }
  9050. }
  9051. }
  9052. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9053. patient_id, _ := c.GetInt64("patient_id")
  9054. insutype_two := c.GetString("insutype")
  9055. psn_no := c.GetString("psn_no")
  9056. doctor_id, _ := c.GetInt64("doctor_id")
  9057. sick_id, _ := c.GetInt64("sick_id")
  9058. department_id, _ := c.GetInt64("department_id")
  9059. start_time := c.GetString("start_time")
  9060. end_time := c.GetString("end_time")
  9061. check_time := c.GetString("check_time")
  9062. adminUser := c.GetAdminUserInfo()
  9063. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9064. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9065. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9066. sick, _ := service.FindSickById(sick_id)
  9067. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9068. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9069. var res ResultTwo
  9070. var res10265 ResultTwo10265
  9071. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9072. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9073. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9074. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9075. "&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
  9076. resp, requestErr := http.Get(api)
  9077. if requestErr != nil {
  9078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9079. return
  9080. }
  9081. body, ioErr := ioutil.ReadAll(resp.Body)
  9082. if ioErr != nil {
  9083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9085. return
  9086. }
  9087. var respJSON map[string]interface{}
  9088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9091. return
  9092. }
  9093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9094. result, _ := json.Marshal(respJSON)
  9095. fmt.Println("log")
  9096. fmt.Println(string(result))
  9097. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9098. utils.ErrorLog("解析失败:%v", err)
  9099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9100. return
  9101. }
  9102. res.ErrMsg = res10265.ErrMsg
  9103. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9104. res.Infcode = infocode
  9105. res.Output = res10265.Output
  9106. res.InfRefmsgid = res10265.InfRefmsgid
  9107. } else {
  9108. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9109. if miConfig.Code == "H15049901371" {
  9110. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9111. utils.ErrorLog("解析失败:%v", err)
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9113. return
  9114. }
  9115. res.ErrMsg = res10265.ErrMsg
  9116. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9117. res.Infcode = infocode
  9118. res.Output = res10265.Output
  9119. res.InfRefmsgid = res10265.InfRefmsgid
  9120. } else {
  9121. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9122. utils.ErrorLog("解析失败:%v", err)
  9123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9124. return
  9125. }
  9126. }
  9127. }
  9128. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9129. infoStr := string(Iinfos)
  9130. var rf []*ResultFive
  9131. json.Unmarshal([]byte(infoStr), &rf)
  9132. var insuplc_admdvs string
  9133. var insutype string
  9134. var is390 int = 0
  9135. var is310 int = 0
  9136. var insutypes []*ResultFive
  9137. for _, item := range rf {
  9138. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9139. insutypes = append(insutypes, item)
  9140. }
  9141. }
  9142. if len(insutypes) == 1 {
  9143. insutype = insutypes[0].Insutype
  9144. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9145. } else {
  9146. for _, i := range insutypes {
  9147. if i.Insutype == "390" {
  9148. is390 = 1
  9149. }
  9150. if i.Insutype == "310" {
  9151. is310 = 1
  9152. }
  9153. }
  9154. }
  9155. if is390 == 1 {
  9156. insutype = "390"
  9157. }
  9158. if is310 == 1 {
  9159. insutype = "310"
  9160. }
  9161. if len(insutypes) == 2 {
  9162. insutype = insutype_two
  9163. }
  9164. if len(insutypes) == 0 {
  9165. insutype = "310"
  9166. }
  9167. insutype = insutype_two
  9168. fmt.Println(insutype)
  9169. for _, item := range rf {
  9170. fmt.Println(item.Insutype)
  9171. fmt.Println(insutype)
  9172. if item.Insutype == insutype {
  9173. fmt.Println(item.Insutype)
  9174. fmt.Println(insutype)
  9175. insuplc_admdvs = item.InsuplcAdmdvs
  9176. }
  9177. }
  9178. fmt.Println(insuplc_admdvs)
  9179. var res2 ResultThirteen
  9180. var res10265_2 ResultThirteen10265
  9181. if config.IsOpen == 1 {
  9182. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9183. } else {
  9184. 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)
  9185. var dat map[string]interface{}
  9186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9187. fmt.Println(dat)
  9188. } else {
  9189. fmt.Println(err)
  9190. }
  9191. userJSONBytes, _ := json.Marshal(dat)
  9192. if miConfig.Code == "H15049901371" {
  9193. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9194. utils.ErrorLog("解析失败:%v", err)
  9195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9196. return
  9197. }
  9198. res2.ErrMsg = res10265_2.ErrMsg
  9199. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9200. res2.Infcode = infocode
  9201. res2.Output = res10265_2.Output
  9202. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9203. } else {
  9204. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9205. utils.ErrorLog("解析失败:%v", err)
  9206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9207. return
  9208. }
  9209. }
  9210. }
  9211. if res2.Infcode == 0 {
  9212. psnResult := &models.GdybPsnNcdsRecord{
  9213. UserOrgId: adminUser.CurrentOrgId,
  9214. PatientId: patient.ID,
  9215. PsnNo: psn_no,
  9216. DoctorId: doctor.AdminUserId,
  9217. DepartmentId: department_id,
  9218. SickType: sick_id,
  9219. Insutype: insutype,
  9220. Ctime: time.Now().Unix(),
  9221. Mtime: time.Now().Unix(),
  9222. Status: 1,
  9223. IsCancel: 1,
  9224. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9225. }
  9226. service.CreatePsnNCDSRecord(psnResult)
  9227. c.ServeSuccessJSON(map[string]interface{}{
  9228. "failed_code": 0,
  9229. "msg": "备案成功",
  9230. "result": psnResult,
  9231. })
  9232. } else {
  9233. c.ServeSuccessJSON(map[string]interface{}{
  9234. "failed_code": -10,
  9235. "msg": res2.ErrMsg,
  9236. })
  9237. return
  9238. }
  9239. }
  9240. }
  9241. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9242. id, _ := c.GetInt64("id")
  9243. admin_user_id, _ := c.GetInt64("admin_user_id")
  9244. adminUser := c.GetAdminUserInfo()
  9245. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9246. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9247. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9248. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9249. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9250. //var user_name string
  9251. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9252. //if role.ID == 0 {
  9253. // user_name = "xxx"
  9254. //} else {
  9255. // user_name = role.UserName
  9256. //}
  9257. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9258. if psn_record.ID == 0 {
  9259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9260. return
  9261. }
  9262. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9263. var res ResultTwo
  9264. var res10265 ResultTwo10265
  9265. if miConfig.Code == "H15049901371" {
  9266. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9267. utils.ErrorLog("解析失败:%v", err)
  9268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9269. return
  9270. }
  9271. res.ErrMsg = res10265.ErrMsg
  9272. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9273. res.Infcode = infocode
  9274. res.Output = res10265.Output
  9275. res.InfRefmsgid = res10265.InfRefmsgid
  9276. } else {
  9277. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9278. utils.ErrorLog("解析失败:%v", err)
  9279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9280. return
  9281. }
  9282. }
  9283. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9284. infoStr := string(Iinfos)
  9285. var rf []*ResultFive
  9286. json.Unmarshal([]byte(infoStr), &rf)
  9287. var insuplc_admdvs string
  9288. var insutype string
  9289. var is390 int = 0
  9290. var is310 int = 0
  9291. var insutypes []*ResultFive
  9292. for _, item := range rf {
  9293. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9294. insutypes = append(insutypes, item)
  9295. }
  9296. }
  9297. if len(insutypes) == 1 {
  9298. insutype = insutypes[0].Insutype
  9299. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9300. } else {
  9301. for _, i := range insutypes {
  9302. if i.Insutype == "390" {
  9303. is390 = 1
  9304. }
  9305. if i.Insutype == "310" {
  9306. is310 = 1
  9307. }
  9308. }
  9309. }
  9310. if is390 == 1 {
  9311. insutype = "390"
  9312. }
  9313. if is310 == 1 {
  9314. insutype = "310"
  9315. }
  9316. if len(insutypes) == 0 {
  9317. insutype = "310"
  9318. }
  9319. insutype = psn_record.Insutype
  9320. for _, item := range rf {
  9321. if item.Insutype == insutype {
  9322. insuplc_admdvs = item.InsuplcAdmdvs
  9323. }
  9324. }
  9325. if config.IsOpen == 1 {
  9326. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9327. var dat map[string]interface{}
  9328. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9329. fmt.Println(dat)
  9330. } else {
  9331. fmt.Println(err)
  9332. }
  9333. userJSONBytes, _ := json.Marshal(dat)
  9334. var res ResultFourteen
  9335. var res10265 ResultFourteen10265
  9336. if miConfig.Code == "H15049901371" {
  9337. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9338. utils.ErrorLog("解析失败:%v", err)
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9340. return
  9341. }
  9342. res.ErrMsg = res10265.ErrMsg
  9343. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9344. res.Infcode = infocode
  9345. res.Output = res10265.Output
  9346. res.InfRefmsgid = res10265.InfRefmsgid
  9347. } else {
  9348. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9349. utils.ErrorLog("解析失败:%v", err)
  9350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9351. return
  9352. }
  9353. }
  9354. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9355. // utils.ErrorLog("解析失败:%v", err)
  9356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9357. // return
  9358. //}
  9359. if res.Infcode == 0 {
  9360. psn_record.IsCancel = 2
  9361. service.CreatePsnNCDSRecord(&psn_record)
  9362. c.ServeSuccessJSON(map[string]interface{}{
  9363. "failed_code": 0,
  9364. "msg": "撤销备案成功",
  9365. })
  9366. } else {
  9367. c.ServeSuccessJSON(map[string]interface{}{
  9368. "failed_code": -10,
  9369. "msg": res.ErrMsg,
  9370. })
  9371. return
  9372. }
  9373. }
  9374. }
  9375. func (c *HisApiController) TestTest() {
  9376. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9377. fmt.Println(patient.Iinfo)
  9378. }
  9379. type CustomData struct {
  9380. MsgId string
  9381. PsnNo string
  9382. Info string
  9383. }
  9384. func (c *HisApiController) ReversalData() {
  9385. var customData []*CustomData
  9386. custom := &CustomData{
  9387. MsgId: "H44022900158202103301714472004",
  9388. PsnNo: "44020000001101329945",
  9389. Info: "2207",
  9390. }
  9391. customData = append(customData, custom)
  9392. custom1 := &CustomData{
  9393. MsgId: "H4402290015820210330172057803",
  9394. PsnNo: "44020000001101161813",
  9395. Info: "2207",
  9396. }
  9397. customData = append(customData, custom1)
  9398. custom2 := &CustomData{
  9399. MsgId: "H44022900158202103301705198813",
  9400. PsnNo: "44190000133097375417",
  9401. Info: "2207",
  9402. }
  9403. customData = append(customData, custom2)
  9404. custom3 := &CustomData{
  9405. MsgId: "H44022900158202103301715524756",
  9406. PsnNo: "44020000001100187221",
  9407. Info: "2207",
  9408. }
  9409. customData = append(customData, custom3)
  9410. custom4 := &CustomData{
  9411. MsgId: "H44022900158202103301730376224",
  9412. PsnNo: "44020000001101959155",
  9413. Info: "2207",
  9414. }
  9415. customData = append(customData, custom4)
  9416. custom5 := &CustomData{
  9417. MsgId: "H44022900158202103301748008725",
  9418. PsnNo: "44020000001104246641",
  9419. Info: "2207",
  9420. }
  9421. customData = append(customData, custom5)
  9422. custom6 := &CustomData{
  9423. MsgId: "H44022900158202103301718096755",
  9424. PsnNo: "44020000001102211860",
  9425. Info: "2207",
  9426. }
  9427. customData = append(customData, custom6)
  9428. custom7 := &CustomData{
  9429. MsgId: "H44022900158202103301736551640",
  9430. PsnNo: "44020000001102687718",
  9431. Info: "2207",
  9432. }
  9433. customData = append(customData, custom7)
  9434. custom8 := &CustomData{
  9435. MsgId: "H44022900158202103301743097676",
  9436. PsnNo: "44020000001102127785",
  9437. Info: "2207",
  9438. }
  9439. customData = append(customData, custom8)
  9440. custom9 := &CustomData{
  9441. MsgId: "H44022900158202103301712304203",
  9442. PsnNo: "44020000001101518097",
  9443. Info: "2207",
  9444. }
  9445. customData = append(customData, custom9)
  9446. custom10 := &CustomData{
  9447. MsgId: "H44022900158202103301738448785",
  9448. PsnNo: "44020000001100500813",
  9449. Info: "2207",
  9450. }
  9451. customData = append(customData, custom10)
  9452. custom11 := &CustomData{
  9453. MsgId: "H44022900158202103301732455843",
  9454. PsnNo: "44020000001102690557",
  9455. Info: "2207",
  9456. }
  9457. customData = append(customData, custom11)
  9458. custom12 := &CustomData{
  9459. MsgId: "H44022900158202103301745421708",
  9460. PsnNo: "44020000001102211928",
  9461. Info: "2207",
  9462. }
  9463. customData = append(customData, custom12)
  9464. custom1212 := &CustomData{
  9465. MsgId: "H440229001582021033017351627",
  9466. PsnNo: "44020000001102481733",
  9467. Info: "2207",
  9468. }
  9469. customData = append(customData, custom1212)
  9470. custom13 := &CustomData{
  9471. MsgId: "H44022900158202103301740327951",
  9472. PsnNo: "44020000001103174866",
  9473. Info: "2207",
  9474. }
  9475. customData = append(customData, custom13)
  9476. custom14 := &CustomData{
  9477. MsgId: "H4402290015820210330174922668",
  9478. PsnNo: "44020000001102927272",
  9479. Info: "2207",
  9480. }
  9481. customData = append(customData, custom14)
  9482. custom15 := &CustomData{
  9483. MsgId: "H44022900158202103301752362273",
  9484. PsnNo: "44020000001102942890",
  9485. Info: "2207",
  9486. }
  9487. customData = append(customData, custom15)
  9488. custom16 := &CustomData{
  9489. MsgId: "H44022900158202103301751082917",
  9490. PsnNo: "44020000001101662162",
  9491. Info: "2207",
  9492. }
  9493. customData = append(customData, custom16)
  9494. custom17 := &CustomData{
  9495. MsgId: "H44022900158202103301754147728",
  9496. PsnNo: "44020000000229014511",
  9497. Info: "2207",
  9498. }
  9499. customData = append(customData, custom17)
  9500. adminUser := c.GetAdminUserInfo()
  9501. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9502. for _, item := range customData {
  9503. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9504. fmt.Println(result)
  9505. }
  9506. }
  9507. func (c *HisApiController) GetAllopatry() {
  9508. year := c.GetString("year")
  9509. month := c.GetString("month")
  9510. admin_user_id, _ := c.GetInt64("admin_user_id")
  9511. adminUser := c.GetAdminUserInfo()
  9512. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9513. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9514. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9515. var dat map[string]interface{}
  9516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9517. fmt.Println(dat)
  9518. } else {
  9519. fmt.Println(err)
  9520. }
  9521. userJSONBytes, _ := json.Marshal(dat)
  9522. var res models.Result9001
  9523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9524. utils.ErrorLog("解析失败:%v", err)
  9525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9526. return
  9527. }
  9528. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9529. var dat2 map[string]interface{}
  9530. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9531. fmt.Println(dat)
  9532. } else {
  9533. fmt.Println(err)
  9534. }
  9535. userJSONBytes2, _ := json.Marshal(dat2)
  9536. var res2 models.Result3260
  9537. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9538. utils.ErrorLog("解析失败:%v", err)
  9539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9540. return
  9541. }
  9542. if res2.Infcode == 0 {
  9543. c.ServeSuccessJSON(map[string]interface{}{
  9544. "list": res2.Output.Data,
  9545. })
  9546. return
  9547. } else {
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9549. return
  9550. }
  9551. }
  9552. func (c *HisApiController) ComfirmAllopatry() {
  9553. year := c.GetString("year")
  9554. month := c.GetString("month")
  9555. admin_user_id, _ := c.GetInt64("admin_user_id")
  9556. adminUser := c.GetAdminUserInfo()
  9557. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9558. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9559. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9560. var dat map[string]interface{}
  9561. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9562. fmt.Println(dat)
  9563. } else {
  9564. fmt.Println(err)
  9565. }
  9566. userJSONBytes, _ := json.Marshal(dat)
  9567. var res models.Result9001
  9568. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9569. utils.ErrorLog("解析失败:%v", err)
  9570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9571. return
  9572. }
  9573. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9574. var dat2 map[string]interface{}
  9575. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9576. fmt.Println(dat)
  9577. } else {
  9578. fmt.Println(err)
  9579. }
  9580. userJSONBytes2, _ := json.Marshal(dat2)
  9581. var res2 models.Result3260
  9582. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9583. utils.ErrorLog("解析失败:%v", err)
  9584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9585. return
  9586. }
  9587. if res2.Infcode == 0 {
  9588. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9589. var dat map[string]interface{}
  9590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9591. fmt.Println(dat)
  9592. } else {
  9593. fmt.Println(err)
  9594. }
  9595. userJSONBytes, _ := json.Marshal(dat)
  9596. var res3 models.Result3261
  9597. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9598. utils.ErrorLog("解析失败:%v", err)
  9599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9600. return
  9601. }
  9602. if res3.Infcode == 0 {
  9603. record := &models.HisYidiClearRecord{
  9604. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9605. Ctime: time.Now().Unix(),
  9606. Mtime: time.Now().Unix(),
  9607. Status: 1,
  9608. MsgId: msgId,
  9609. }
  9610. service.SaveClearRecord(record)
  9611. c.ServeSuccessJSON(map[string]interface{}{
  9612. "msg": "提取成功",
  9613. })
  9614. }
  9615. }
  9616. }
  9617. func (c *HisApiController) RefundAllopatry() {
  9618. year := c.GetString("year")
  9619. month := c.GetString("month")
  9620. id, _ := c.GetInt64("id")
  9621. admin_user_id, _ := c.GetInt64("admin_user_id")
  9622. adminUser := c.GetAdminUserInfo()
  9623. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9624. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9625. record, _ := service.GetClearRecordById(id)
  9626. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9627. var dat map[string]interface{}
  9628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9629. fmt.Println(dat)
  9630. } else {
  9631. fmt.Println(err)
  9632. }
  9633. userJSONBytes, _ := json.Marshal(dat)
  9634. var empty ResultFourteen
  9635. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9636. utils.ErrorLog("解析失败:%v", err)
  9637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9638. return
  9639. }
  9640. if empty.Infcode == 0 {
  9641. c.ServeSuccessJSON(map[string]interface{}{
  9642. "msg": "撤销成功",
  9643. })
  9644. return
  9645. }
  9646. }
  9647. func (c *HisApiController) ReversalOtherData() {
  9648. var customData []*CustomData
  9649. custom := &CustomData{
  9650. MsgId: "H44022900158202103301714472004",
  9651. PsnNo: "44020000001101329945",
  9652. Info: "2208",
  9653. }
  9654. customData = append(customData, custom)
  9655. custom1 := &CustomData{
  9656. MsgId: "H4402290015820210330172057803",
  9657. PsnNo: "44020000001101161813",
  9658. Info: "2208",
  9659. }
  9660. customData = append(customData, custom1)
  9661. custom2 := &CustomData{
  9662. MsgId: "H44022900158202103301705198813",
  9663. PsnNo: "44190000133097375417",
  9664. Info: "2208",
  9665. }
  9666. customData = append(customData, custom2)
  9667. custom3 := &CustomData{
  9668. MsgId: "H44022900158202103301715524756",
  9669. PsnNo: "44020000001100187221",
  9670. Info: "2208",
  9671. }
  9672. customData = append(customData, custom3)
  9673. custom4 := &CustomData{
  9674. MsgId: "H44022900158202103301730376224",
  9675. PsnNo: "44020000001101959155",
  9676. Info: "2208",
  9677. }
  9678. customData = append(customData, custom4)
  9679. custom5 := &CustomData{
  9680. MsgId: "H44022900158202103301748008725",
  9681. PsnNo: "44020000001104246641",
  9682. Info: "2208",
  9683. }
  9684. customData = append(customData, custom5)
  9685. custom6 := &CustomData{
  9686. MsgId: "H44022900158202103301718096755",
  9687. PsnNo: "44020000001102211860",
  9688. Info: "2208",
  9689. }
  9690. customData = append(customData, custom6)
  9691. custom7 := &CustomData{
  9692. MsgId: "H44022900158202103301736551640",
  9693. PsnNo: "44020000001102687718",
  9694. Info: "2208",
  9695. }
  9696. customData = append(customData, custom7)
  9697. custom8 := &CustomData{
  9698. MsgId: "H44022900158202103301743097676",
  9699. PsnNo: "44020000001102127785",
  9700. Info: "2208",
  9701. }
  9702. customData = append(customData, custom8)
  9703. custom9 := &CustomData{
  9704. MsgId: "H44022900158202103301712304203",
  9705. PsnNo: "44020000001101518097",
  9706. Info: "2208",
  9707. }
  9708. customData = append(customData, custom9)
  9709. custom10 := &CustomData{
  9710. MsgId: "H44022900158202103301738448785",
  9711. PsnNo: "44020000001100500813",
  9712. Info: "2208",
  9713. }
  9714. customData = append(customData, custom10)
  9715. custom11 := &CustomData{
  9716. MsgId: "H44022900158202103301732455843",
  9717. PsnNo: "44020000001102690557",
  9718. Info: "2208",
  9719. }
  9720. customData = append(customData, custom11)
  9721. custom12 := &CustomData{
  9722. MsgId: "H44022900158202103301745421708",
  9723. PsnNo: "44020000001102211928",
  9724. Info: "2208",
  9725. }
  9726. customData = append(customData, custom12)
  9727. custom1212 := &CustomData{
  9728. MsgId: "H440229001582021033017351627",
  9729. PsnNo: "44020000001102481733",
  9730. Info: "2208",
  9731. }
  9732. customData = append(customData, custom1212)
  9733. custom13 := &CustomData{
  9734. MsgId: "H44022900158202103301740327951",
  9735. PsnNo: "44020000001103174866",
  9736. Info: "2208",
  9737. }
  9738. customData = append(customData, custom13)
  9739. custom14 := &CustomData{
  9740. MsgId: "H4402290015820210330174922668",
  9741. PsnNo: "44020000001102927272",
  9742. Info: "2208",
  9743. }
  9744. customData = append(customData, custom14)
  9745. custom15 := &CustomData{
  9746. MsgId: "H44022900158202103301752362273",
  9747. PsnNo: "44020000001102942890",
  9748. Info: "2208",
  9749. }
  9750. customData = append(customData, custom15)
  9751. custom16 := &CustomData{
  9752. MsgId: "H44022900158202103301751082917",
  9753. PsnNo: "44020000001101662162",
  9754. Info: "2208",
  9755. }
  9756. customData = append(customData, custom16)
  9757. custom17 := &CustomData{
  9758. MsgId: "H44022900158202103301754147728",
  9759. PsnNo: "44020000000229014511",
  9760. Info: "2208",
  9761. }
  9762. customData = append(customData, custom17)
  9763. adminUser := c.GetAdminUserInfo()
  9764. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9765. for _, item := range customData {
  9766. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9767. fmt.Println(result)
  9768. }
  9769. }
  9770. func PathExists(path string) (bool, error) {
  9771. _, err := os.Stat(path)
  9772. if err == nil {
  9773. return true, nil
  9774. }
  9775. if os.IsNotExist(err) {
  9776. return false, nil
  9777. }
  9778. return false, err
  9779. }
  9780. //创建文件夹
  9781. func Mkdir(dir string) {
  9782. // 创建文件夹
  9783. exist, err := PathExists(dir)
  9784. if err != nil {
  9785. fmt.Println(err.Error())
  9786. } else {
  9787. if exist {
  9788. fmt.Println(dir + "文件夹已存在!")
  9789. } else {
  9790. // 文件夹名称,权限
  9791. err := os.Mkdir(dir, os.ModePerm)
  9792. if err != nil {
  9793. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9794. } else {
  9795. fmt.Println(dir + "文件夹创建成功!")
  9796. }
  9797. }
  9798. }
  9799. }
  9800. //压缩文件
  9801. func Zip(srcFile string, destZip string) error {
  9802. zipfile, err := os.Create(destZip)
  9803. if err != nil {
  9804. return err
  9805. }
  9806. defer zipfile.Close()
  9807. archive := zip.NewWriter(zipfile)
  9808. defer archive.Close()
  9809. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9810. if err != nil {
  9811. return err
  9812. }
  9813. header, err := zip.FileInfoHeader(info)
  9814. if err != nil {
  9815. return err
  9816. }
  9817. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9818. // header.Name = path
  9819. if info.IsDir() {
  9820. header.Name += "/"
  9821. } else {
  9822. header.Method = zip.Deflate
  9823. }
  9824. writer, err := archive.CreateHeader(header)
  9825. if err != nil {
  9826. return err
  9827. }
  9828. if !info.IsDir() {
  9829. file, err := os.Open(path)
  9830. if err != nil {
  9831. return err
  9832. }
  9833. defer file.Close()
  9834. _, err = io.Copy(writer, file)
  9835. }
  9836. return err
  9837. })
  9838. return err
  9839. }
  9840. func ReadFile(filePath string) []byte {
  9841. f, err := os.Open(filePath)
  9842. if err != nil {
  9843. fmt.Println("read file fail", err)
  9844. return nil
  9845. }
  9846. defer f.Close()
  9847. fd, err := ioutil.ReadAll(f)
  9848. if err != nil {
  9849. fmt.Println("read to fd fail", err)
  9850. return nil
  9851. }
  9852. return fd
  9853. }
  9854. func saveLog(result string, request string, infno string, desc string) {
  9855. org_id, _ := beego.AppConfig.Int64("org_id")
  9856. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9857. dir := miConfig.OrgName + "日志"
  9858. utils.Mkdir(dir)
  9859. month := time.Unix(1557042972, 0).Format("1")
  9860. year := time.Now().Format("2006")
  9861. month = time.Now().Format("01")
  9862. day := time.Now().Format("02")
  9863. hour := time.Now().Format("15")
  9864. min := time.Now().Format("04")
  9865. sec := time.Now().Format("05")
  9866. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9867. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9868. file_name := file + ".txt"
  9869. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9870. exist, _ := utils.PathExists(file_path)
  9871. if exist { //存在
  9872. fmt.Println("存在")
  9873. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9874. if err != nil {
  9875. fmt.Println("read fail")
  9876. }
  9877. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9878. n, _ := f.Seek(0, 2)
  9879. _, err = f.WriteAt([]byte(content), n)
  9880. } else { //不存在
  9881. fmt.Println("文件不存在,创建文件")
  9882. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9883. defer f.Close()
  9884. if err != nil {
  9885. } else {
  9886. _, err = f.Write([]byte("记录日志"))
  9887. }
  9888. }
  9889. }
  9890. type Charset string
  9891. const (
  9892. UTF8 = Charset("UTF-8")
  9893. GB18030 = Charset("GB18030")
  9894. )
  9895. func ConvertToString(src string, srcCode string, tagCode string) string {
  9896. srcCoder := mahonia.NewDecoder(srcCode)
  9897. srcResult := srcCoder.ConvertString(src)
  9898. tagCoder := mahonia.NewDecoder(tagCode)
  9899. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9900. result := string(cdata)
  9901. return result
  9902. }