his_api_controller.go 643KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  82. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  83. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  84. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  85. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  86. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  87. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  88. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  89. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  90. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  91. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  92. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  93. }
  94. func (c *HisApiController) Get2505() {
  95. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  96. service.Gdyb2505("44120000000010585742", "高慧裕", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-12-23 09:00:00", "2023-12-31 23:00:00")
  97. }
  98. func (c *HisApiController) Get4201A() {
  99. order_id, _ := c.GetInt64("order_id")
  100. admin_user_id, _ := c.GetInt64("admin_user_id")
  101. order, _ := service.GetHisOrderByIDTwo(order_id)
  102. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  103. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  104. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  105. //order_info = append(order_info, order_info_two...)
  106. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  108. department, _ := service.GetDepartMentDetail(his.Departments)
  109. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  110. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  111. if order.ID == 0 {
  112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  113. return
  114. }
  115. var struct4201A models.Struct4201A
  116. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  117. for _, items := range order_info {
  118. memo := make(map[string]interface{})
  119. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  120. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  121. fsiOPFLD.MedType = "14"
  122. fsiOPFLD.BkkpSn = items.FeedetlSn
  123. fsiOPFLD.FixmedinsCode = miConfig.Code
  124. fsiOPFLD.FixmedinsName = miConfig.OrgName
  125. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  126. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  127. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  128. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  129. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  130. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  131. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  132. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  133. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  134. fsiOPFLD.BilgDeptName = department.Name
  135. fsiOPFLD.BilgDeptCodg = department.Number
  136. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  137. fsiOPFLD.BilgDrName = doctor.UserName
  138. fsiOPFLD.MedChrgitmType = "09"
  139. memo["hosp_appr_flag"] = "1"
  140. memo["invoice_no"] = order.MdtrtId
  141. memo["memo"] = "自费"
  142. bytesData, _ := json.Marshal(memo)
  143. fsiOPFLD.Memo = string(bytesData)
  144. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  145. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  146. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  147. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  148. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  149. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  150. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  151. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  152. fsiOPFLD.BilgDeptName = department.Name
  153. fsiOPFLD.BilgDeptCodg = department.Number
  154. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  155. fsiOPFLD.BilgDrName = doctor.UserName
  156. switch items.HisPrescriptionProject.HisProject.CostClassify {
  157. case 0:
  158. break
  159. case 1:
  160. fsiOPFLD.MedChrgitmType = "14"
  161. break
  162. case 2:
  163. fsiOPFLD.MedChrgitmType = "05"
  164. break
  165. case 3:
  166. fsiOPFLD.MedChrgitmType = "03"
  167. break
  168. case 4:
  169. fsiOPFLD.MedChrgitmType = "03"
  170. break
  171. case 5:
  172. fsiOPFLD.MedChrgitmType = "08"
  173. break
  174. case 6:
  175. fsiOPFLD.MedChrgitmType = "14"
  176. break
  177. case 7:
  178. fsiOPFLD.MedChrgitmType = "14"
  179. break
  180. case 8:
  181. fsiOPFLD.MedChrgitmType = "03"
  182. break
  183. case 9:
  184. fsiOPFLD.MedChrgitmType = "14"
  185. break
  186. case 10:
  187. fsiOPFLD.MedChrgitmType = "14"
  188. break
  189. case 11:
  190. fsiOPFLD.MedChrgitmType = "06"
  191. break
  192. case 12:
  193. fsiOPFLD.MedChrgitmType = "12"
  194. break
  195. case 13:
  196. fsiOPFLD.MedChrgitmType = "01"
  197. break
  198. case 14:
  199. fsiOPFLD.MedChrgitmType = "04"
  200. break
  201. case 15:
  202. fsiOPFLD.MedChrgitmType = "14"
  203. break
  204. }
  205. memo["hosp_appr_flag"] = "1"
  206. memo["invoice_no"] = order.MdtrtId
  207. memo["memo"] = "自费"
  208. bytesData, _ := json.Marshal(memo)
  209. fsiOPFLD.Memo = string(bytesData)
  210. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  211. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  212. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  213. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  214. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  215. fsiOPFLD.BilgDeptName = department.Name
  216. fsiOPFLD.BilgDeptCodg = department.Number
  217. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  218. fsiOPFLD.BilgDrName = doctor.UserName
  219. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  220. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  221. fsiOPFLD.MedChrgitmType = "08"
  222. memo["hosp_appr_flag"] = "1"
  223. memo["invoice_no"] = order.MdtrtId
  224. memo["memo"] = "自费"
  225. bytesData, _ := json.Marshal(memo)
  226. fsiOPFLD.Memo = string(bytesData)
  227. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  228. }
  229. }
  230. }
  231. for _, items := range order_info_two {
  232. memo := make(map[string]interface{})
  233. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  234. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  235. fsiOPFLD.MedType = "14"
  236. fsiOPFLD.BkkpSn = items.FeedetlSn
  237. fsiOPFLD.FixmedinsCode = miConfig.Code
  238. fsiOPFLD.FixmedinsName = miConfig.OrgName
  239. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  240. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  241. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  242. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  243. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  244. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  245. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  246. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  247. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  248. fsiOPFLD.BilgDeptName = department.Name
  249. fsiOPFLD.BilgDeptCodg = department.Number
  250. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  251. fsiOPFLD.BilgDrName = doctor.UserName
  252. fsiOPFLD.MedChrgitmType = "09"
  253. memo["hosp_appr_flag"] = "1"
  254. memo["invoice_no"] = order.MdtrtId
  255. memo["memo"] = "自费"
  256. bytesData, _ := json.Marshal(memo)
  257. fsiOPFLD.Memo = string(bytesData)
  258. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  259. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  260. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  261. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  262. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  263. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  264. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  265. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  266. fsiOPFLD.BilgDeptName = department.Name
  267. fsiOPFLD.BilgDeptCodg = department.Number
  268. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  269. fsiOPFLD.BilgDrName = doctor.UserName
  270. switch items.HisPrescriptionProject.HisProject.CostClassify {
  271. case 0:
  272. break
  273. case 1:
  274. fsiOPFLD.MedChrgitmType = "14"
  275. break
  276. case 2:
  277. fsiOPFLD.MedChrgitmType = "05"
  278. break
  279. case 3:
  280. fsiOPFLD.MedChrgitmType = "03"
  281. break
  282. case 4:
  283. fsiOPFLD.MedChrgitmType = "03"
  284. break
  285. case 5:
  286. fsiOPFLD.MedChrgitmType = "08"
  287. break
  288. case 6:
  289. fsiOPFLD.MedChrgitmType = "14"
  290. break
  291. case 7:
  292. fsiOPFLD.MedChrgitmType = "14"
  293. break
  294. case 8:
  295. fsiOPFLD.MedChrgitmType = "03"
  296. break
  297. case 9:
  298. fsiOPFLD.MedChrgitmType = "14"
  299. break
  300. case 10:
  301. fsiOPFLD.MedChrgitmType = "14"
  302. break
  303. case 11:
  304. fsiOPFLD.MedChrgitmType = "06"
  305. break
  306. case 12:
  307. fsiOPFLD.MedChrgitmType = "12"
  308. break
  309. case 13:
  310. fsiOPFLD.MedChrgitmType = "01"
  311. break
  312. case 14:
  313. fsiOPFLD.MedChrgitmType = "04"
  314. break
  315. case 15:
  316. fsiOPFLD.MedChrgitmType = "14"
  317. break
  318. }
  319. memo["hosp_appr_flag"] = "1"
  320. memo["invoice_no"] = order.MdtrtId
  321. memo["memo"] = "自费"
  322. bytesData, _ := json.Marshal(memo)
  323. fsiOPFLD.Memo = string(bytesData)
  324. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  325. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  326. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  327. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  328. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  329. fsiOPFLD.BilgDeptName = department.Name
  330. fsiOPFLD.BilgDeptCodg = department.Number
  331. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  332. fsiOPFLD.BilgDrName = doctor.UserName
  333. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  334. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  335. fsiOPFLD.MedChrgitmType = "08"
  336. memo["hosp_appr_flag"] = "1"
  337. memo["invoice_no"] = order.MdtrtId
  338. memo["memo"] = "自费"
  339. bytesData, _ := json.Marshal(memo)
  340. fsiOPFLD.Memo = string(bytesData)
  341. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  342. }
  343. }
  344. }
  345. fmt.Println(fsiOPFLDs)
  346. struct4201A.Fopfd = fsiOPFLDs
  347. fmt.Println(struct4201A.Fopfd)
  348. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  349. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  350. var res2 ResultSix
  351. var respJSON2 map[string]interface{}
  352. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  355. return
  356. }
  357. userJSONBytes2, _ := json.Marshal(respJSON2)
  358. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  359. utils.ErrorLog("解析失败:%v", err)
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  361. return
  362. }
  363. if res2.Infcode != 0 {
  364. c.ServeSuccessJSON(map[string]interface{}{
  365. "failed_code": -10,
  366. "msg": res2.ErrMsg,
  367. })
  368. return
  369. } else {
  370. order.IsUploadOrderInfo = 1
  371. service.UpdateOrder(order)
  372. c.ServeSuccessJSON(map[string]interface{}{
  373. "msg": "上传成功",
  374. })
  375. }
  376. }
  377. func (c *HisApiController) Get4202() {
  378. order_id, _ := c.GetInt64("order_id")
  379. admin_user_id, _ := c.GetInt64("admin_user_id")
  380. order, _ := service.GetHisOrderByIDTwo(order_id)
  381. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  382. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  383. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  384. if order.ID == 0 {
  385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  386. return
  387. }
  388. var struct4202 models.Struct4202
  389. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  390. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  391. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  392. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  393. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  394. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  395. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  396. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  397. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  398. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  399. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  400. var config []*models.HisXtDiagnoseConfig
  401. for _, item := range diagnosis_ids {
  402. id, _ := strconv.ParseInt(item, 10, 64)
  403. diagnosisConfig, _ := service.FindDiagnoseById(id)
  404. config = append(config, &diagnosisConfig)
  405. }
  406. var tempDiaginfos []models.OwnPayPatnDiagListD
  407. for index, item := range config {
  408. if index == 0 {
  409. var tempDiaginfo models.OwnPayPatnDiagListD
  410. tempDiaginfo.InoutDiagType = "1"
  411. tempDiaginfo.DiagCode = item.CountryCode
  412. tempDiaginfo.DiagName = item.CountryContentName
  413. tempDiaginfo.DiagType = "1"
  414. tempDiaginfo.DiagSrtNo = "1"
  415. tempDiaginfo.MaindiagFlag = "1"
  416. tempDiaginfo.ValiFlag = "1"
  417. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  418. } else {
  419. var tempDiaginfo models.OwnPayPatnDiagListD
  420. tempDiaginfo.DiagCode = item.CountryCode
  421. tempDiaginfo.DiagName = item.CountryContentName
  422. tempDiaginfo.DiagType = "2"
  423. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  424. tempDiaginfo.MaindiagFlag = "0"
  425. tempDiaginfo.ValiFlag = "1"
  426. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  427. }
  428. }
  429. struct4202.ODiagListD = tempDiaginfos
  430. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  431. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  432. var res2 ResultSix
  433. var respJSON2 map[string]interface{}
  434. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  437. return
  438. }
  439. userJSONBytes2, _ := json.Marshal(respJSON2)
  440. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  441. utils.ErrorLog("解析失败:%v", err)
  442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  443. return
  444. }
  445. if res2.Infcode != 0 {
  446. c.ServeSuccessJSON(map[string]interface{}{
  447. "failed_code": -10,
  448. "msg": res2.ErrMsg,
  449. })
  450. return
  451. } else {
  452. order.IsUploadDiagnose = 1
  453. service.UpdateOrder(order)
  454. c.ServeSuccessJSON(map[string]interface{}{
  455. "msg": "上传成功",
  456. })
  457. }
  458. }
  459. func (c *HisApiController) Get4203() {
  460. admin_user_id, _ := c.GetInt64("admin_user_id")
  461. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  462. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  463. order_id, _ := c.GetInt64("order_id")
  464. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  465. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  466. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, his.Number)
  467. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  468. var res2 ResultSix
  469. var respJSON2 map[string]interface{}
  470. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  473. return
  474. }
  475. userJSONBytes2, _ := json.Marshal(respJSON2)
  476. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  477. utils.ErrorLog("解析失败:%v", err)
  478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  479. return
  480. }
  481. if res2.Infcode != 0 {
  482. c.ServeSuccessJSON(map[string]interface{}{
  483. "failed_code": -10,
  484. "msg": res2.ErrMsg,
  485. })
  486. return
  487. } else {
  488. order.IsUploadSuccess = 1
  489. service.UpdateOrderTwo(order)
  490. c.ServeSuccessJSON(map[string]interface{}{
  491. "msg": "上传成功",
  492. })
  493. }
  494. }
  495. func (c *HisApiController) Get4205() {
  496. order_id, _ := c.GetInt64("order_id")
  497. admin_user_id, _ := c.GetInt64("admin_user_id")
  498. fapiao_code := c.GetString("fapiao_code")
  499. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  500. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  501. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  502. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  503. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  504. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  505. //order_info = append(order_info, order_info_two...)
  506. department, _ := service.GetDepartMentDetail(his.Departments)
  507. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  508. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  509. if order.ID == 0 {
  510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  511. return
  512. }
  513. var struct4201A models.Struct4201A
  514. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  515. for _, items := range order_info {
  516. memo := make(map[string]interface{})
  517. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  518. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  519. fsiOPFLD.MedType = pre.MedType
  520. fsiOPFLD.FixmedinsCode = miConfig.Code
  521. fsiOPFLD.FixmedinsName = miConfig.OrgName
  522. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  523. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  524. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  525. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  526. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  527. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  528. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  529. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  530. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  531. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  532. fsiOPFLD.BilgDeptName = department.Name
  533. fsiOPFLD.BilgDeptCodg = department.Number
  534. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  535. fsiOPFLD.BilgDrName = doctor.UserName
  536. fsiOPFLD.MedChrgitmType = "09"
  537. memo["hosp_appr_flag"] = "1"
  538. memo["invoice_no"] = fapiao_code
  539. memo["memo"] = "自费"
  540. bytesData, _ := json.Marshal(memo)
  541. fsiOPFLD.Memo = string(bytesData)
  542. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  543. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  544. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  545. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  546. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  547. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  548. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  549. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  550. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  551. fsiOPFLD.BilgDeptName = department.Name
  552. fsiOPFLD.BilgDeptCodg = department.Number
  553. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  554. fsiOPFLD.BilgDrName = doctor.UserName
  555. switch items.HisPrescriptionProject.HisProject.CostClassify {
  556. case 0:
  557. break
  558. case 1:
  559. fsiOPFLD.MedChrgitmType = "14"
  560. break
  561. case 2:
  562. fsiOPFLD.MedChrgitmType = "05"
  563. break
  564. case 3:
  565. fsiOPFLD.MedChrgitmType = "03"
  566. break
  567. case 4:
  568. fsiOPFLD.MedChrgitmType = "03"
  569. break
  570. case 5:
  571. fsiOPFLD.MedChrgitmType = "08"
  572. break
  573. case 6:
  574. fsiOPFLD.MedChrgitmType = "14"
  575. break
  576. case 7:
  577. fsiOPFLD.MedChrgitmType = "14"
  578. break
  579. case 8:
  580. fsiOPFLD.MedChrgitmType = "03"
  581. break
  582. case 9:
  583. fsiOPFLD.MedChrgitmType = "14"
  584. break
  585. case 10:
  586. fsiOPFLD.MedChrgitmType = "14"
  587. break
  588. case 11:
  589. fsiOPFLD.MedChrgitmType = "06"
  590. break
  591. case 12:
  592. fsiOPFLD.MedChrgitmType = "12"
  593. break
  594. case 13:
  595. fsiOPFLD.MedChrgitmType = "01"
  596. break
  597. case 14:
  598. fsiOPFLD.MedChrgitmType = "04"
  599. break
  600. case 15:
  601. fsiOPFLD.MedChrgitmType = "14"
  602. break
  603. }
  604. memo["hosp_appr_flag"] = "1"
  605. memo["invoice_no"] = fapiao_code
  606. memo["memo"] = "自费"
  607. bytesData, _ := json.Marshal(memo)
  608. fsiOPFLD.Memo = string(bytesData)
  609. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  610. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  611. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  612. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  613. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  614. fsiOPFLD.BilgDeptName = department.Name
  615. fsiOPFLD.BilgDeptCodg = department.Number
  616. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  617. fsiOPFLD.BilgDrName = doctor.UserName
  618. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  619. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  620. fsiOPFLD.MedChrgitmType = "08"
  621. memo["hosp_appr_flag"] = "1"
  622. memo["invoice_no"] = fapiao_code
  623. memo["memo"] = "自费"
  624. bytesData, _ := json.Marshal(memo)
  625. fsiOPFLD.Memo = string(bytesData)
  626. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  627. }
  628. }
  629. }
  630. for _, items := range order_info_two {
  631. memo := make(map[string]interface{})
  632. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  633. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  634. fsiOPFLD.MedType = pre.MedType
  635. fsiOPFLD.BkkpSn = items.FeedetlSn
  636. fsiOPFLD.FixmedinsCode = miConfig.Code
  637. fsiOPFLD.FixmedinsName = miConfig.OrgName
  638. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  639. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  640. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  641. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  642. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  643. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  644. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  645. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  646. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  647. fsiOPFLD.BilgDeptName = department.Name
  648. fsiOPFLD.BilgDeptCodg = department.Number
  649. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  650. fsiOPFLD.BilgDrName = doctor.UserName
  651. fsiOPFLD.MedChrgitmType = "09"
  652. memo["hosp_appr_flag"] = "1"
  653. memo["invoice_no"] = fapiao_code
  654. memo["memo"] = "自费"
  655. bytesData, _ := json.Marshal(memo)
  656. fsiOPFLD.Memo = string(bytesData)
  657. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  658. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  659. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  660. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  661. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  662. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  663. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  664. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  665. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  666. fsiOPFLD.BilgDeptName = department.Name
  667. fsiOPFLD.BilgDeptCodg = department.Number
  668. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  669. fsiOPFLD.BilgDrName = doctor.UserName
  670. switch items.HisPrescriptionProject.HisProject.CostClassify {
  671. case 0:
  672. break
  673. case 1:
  674. fsiOPFLD.MedChrgitmType = "14"
  675. break
  676. case 2:
  677. fsiOPFLD.MedChrgitmType = "05"
  678. break
  679. case 3:
  680. fsiOPFLD.MedChrgitmType = "03"
  681. break
  682. case 4:
  683. fsiOPFLD.MedChrgitmType = "03"
  684. break
  685. case 5:
  686. fsiOPFLD.MedChrgitmType = "08"
  687. break
  688. case 6:
  689. fsiOPFLD.MedChrgitmType = "14"
  690. break
  691. case 7:
  692. fsiOPFLD.MedChrgitmType = "14"
  693. break
  694. case 8:
  695. fsiOPFLD.MedChrgitmType = "03"
  696. break
  697. case 9:
  698. fsiOPFLD.MedChrgitmType = "14"
  699. break
  700. case 10:
  701. fsiOPFLD.MedChrgitmType = "14"
  702. break
  703. case 11:
  704. fsiOPFLD.MedChrgitmType = "06"
  705. break
  706. case 12:
  707. fsiOPFLD.MedChrgitmType = "12"
  708. break
  709. case 13:
  710. fsiOPFLD.MedChrgitmType = "01"
  711. break
  712. case 14:
  713. fsiOPFLD.MedChrgitmType = "04"
  714. break
  715. case 15:
  716. fsiOPFLD.MedChrgitmType = "14"
  717. break
  718. }
  719. memo["hosp_appr_flag"] = "1"
  720. memo["invoice_no"] = fapiao_code
  721. memo["memo"] = "自费"
  722. bytesData, _ := json.Marshal(memo)
  723. fsiOPFLD.Memo = string(bytesData)
  724. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  725. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  726. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  727. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  728. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  729. fsiOPFLD.BilgDeptName = department.Name
  730. fsiOPFLD.BilgDeptCodg = department.Number
  731. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  732. fsiOPFLD.BilgDrName = doctor.UserName
  733. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  734. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  735. fsiOPFLD.MedChrgitmType = "08"
  736. memo["hosp_appr_flag"] = "1"
  737. memo["invoice_no"] = fapiao_code
  738. memo["memo"] = "自费"
  739. bytesData, _ := json.Marshal(memo)
  740. fsiOPFLD.Memo = string(bytesData)
  741. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  742. }
  743. }
  744. }
  745. fmt.Println(fsiOPFLDs)
  746. struct4201A.Fopfd = fsiOPFLDs
  747. fmt.Println(struct4201A.Fopfd)
  748. var struct4202 models.Struct4202
  749. timeLayout := "2006-01-02 15:04:05"
  750. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  751. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  752. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  753. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  754. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  755. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  756. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  757. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  758. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  759. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  760. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  761. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  762. var config []*models.HisXtDiagnoseConfig
  763. for _, item := range diagnosis_ids {
  764. id, _ := strconv.ParseInt(item, 10, 64)
  765. diagnosisConfig, _ := service.FindDiagnoseById(id)
  766. config = append(config, &diagnosisConfig)
  767. }
  768. var tempDiaginfos []models.OwnPayPatnDiagListD
  769. for index, item := range config {
  770. if index == 0 {
  771. var tempDiaginfo models.OwnPayPatnDiagListD
  772. tempDiaginfo.InoutDiagType = "1"
  773. tempDiaginfo.DiagCode = item.CountryCode
  774. tempDiaginfo.DiagName = item.CountryContentName
  775. tempDiaginfo.DiagType = "1"
  776. tempDiaginfo.DiagSrtNo = "1"
  777. tempDiaginfo.MaindiagFlag = "1"
  778. tempDiaginfo.ValiFlag = "1"
  779. tempDiaginfo.DiagDrName = doctor.UserName
  780. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  781. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  782. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  783. } else {
  784. var tempDiaginfo models.OwnPayPatnDiagListD
  785. tempDiaginfo.DiagCode = item.CountryCode
  786. tempDiaginfo.DiagName = item.CountryContentName
  787. tempDiaginfo.DiagType = "2"
  788. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  789. tempDiaginfo.MaindiagFlag = "0"
  790. tempDiaginfo.ValiFlag = "1"
  791. tempDiaginfo.DiagDrName = doctor.UserName
  792. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  793. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  794. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  795. }
  796. }
  797. struct4202.ODiagListD = tempDiaginfos
  798. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  799. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  800. var res2 ResultSix
  801. var respJSON2 map[string]interface{}
  802. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  805. return
  806. }
  807. userJSONBytes2, _ := json.Marshal(respJSON2)
  808. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  809. utils.ErrorLog("解析失败:%v", err)
  810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  811. return
  812. }
  813. if res2.Infcode != 0 {
  814. c.ServeSuccessJSON(map[string]interface{}{
  815. "failed_code": -10,
  816. "msg": res2.ErrMsg,
  817. })
  818. return
  819. } else {
  820. order.IsUploadDiagnose = 1
  821. order.IsUploadOrderInfo = 1
  822. service.UpdateOrderTwo(order)
  823. c.ServeSuccessJSON(map[string]interface{}{
  824. "msg": "上传成功",
  825. })
  826. }
  827. }
  828. func (c *HisApiController) Get4207() {
  829. admin_user_id, _ := c.GetInt64("admin_user_id")
  830. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  831. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  832. order_id, _ := c.GetInt64("order_id")
  833. order, _ := service.GetHisOrderByIDTwo(order_id)
  834. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  835. var struct4207 models.Struct4207
  836. struct4207.PageNum = "1"
  837. struct4207.PageSize = "1000"
  838. struct4207.FixmedinsCode = miConfig.Code
  839. struct4207.FixmedinsMdtrtID = order.Number
  840. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  841. saveLog(result, requestLog, "4207", "查询")
  842. var res2 ResultSix
  843. var respJSON2 map[string]interface{}
  844. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  847. return
  848. }
  849. userJSONBytes2, _ := json.Marshal(respJSON2)
  850. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  851. utils.ErrorLog("解析失败:%v", err)
  852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  853. return
  854. }
  855. if res2.Infcode != 0 {
  856. c.ServeSuccessJSON(map[string]interface{}{
  857. "failed_code": -10,
  858. "msg": res2.ErrMsg,
  859. })
  860. return
  861. } else {
  862. c.ServeSuccessJSON(map[string]interface{}{
  863. "msg": "查询成功",
  864. })
  865. }
  866. }
  867. func (c *HisApiController) Get4208() {
  868. admin_user_id, _ := c.GetInt64("admin_user_id")
  869. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  870. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  871. order_id, _ := c.GetInt64("order_id")
  872. order, _ := service.GetHisOrderByIDTwo(order_id)
  873. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  874. var struct4208 models.Struct4208
  875. struct4208.PageNum = "1"
  876. struct4208.PageSize = "1000"
  877. struct4208.PsnCertType = "01"
  878. struct4208.Certno = his.Certno
  879. struct4208.MedType = order.MedType
  880. struct4208.PsnName = his.Name
  881. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  882. saveLog(result, requestLog, "4208", "查询")
  883. var res2 ResultSix
  884. var respJSON2 map[string]interface{}
  885. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  888. return
  889. }
  890. userJSONBytes2, _ := json.Marshal(respJSON2)
  891. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  892. utils.ErrorLog("解析失败:%v", err)
  893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  894. return
  895. }
  896. if res2.Infcode != 0 {
  897. c.ServeSuccessJSON(map[string]interface{}{
  898. "failed_code": -10,
  899. "msg": res2.ErrMsg,
  900. })
  901. return
  902. } else {
  903. c.ServeSuccessJSON(map[string]interface{}{
  904. "msg": "查询成功",
  905. })
  906. }
  907. }
  908. func (c *HisApiController) Get4209() {
  909. admin_user_id, _ := c.GetInt64("admin_user_id")
  910. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  911. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  912. order_id, _ := c.GetInt64("order_id")
  913. order, _ := service.GetHisOrderByIDTwo(order_id)
  914. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  915. var struct4209 models.Struct4209
  916. struct4209.FixmedinsMdtrtID = order.Number
  917. struct4209.FixmedinsCode = miConfig.Code
  918. struct4209.PageSize = "1000"
  919. struct4209.PageNum = "1"
  920. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  921. saveLog(result, requestLog, "4209", "查询")
  922. var res2 ResultSix
  923. var respJSON2 map[string]interface{}
  924. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  927. return
  928. }
  929. userJSONBytes2, _ := json.Marshal(respJSON2)
  930. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  931. utils.ErrorLog("解析失败:%v", err)
  932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  933. return
  934. }
  935. if res2.Infcode != 0 {
  936. c.ServeSuccessJSON(map[string]interface{}{
  937. "failed_code": -10,
  938. "msg": res2.ErrMsg,
  939. })
  940. return
  941. } else {
  942. c.ServeSuccessJSON(map[string]interface{}{
  943. "msg": "查询成功",
  944. })
  945. }
  946. }
  947. type Result3101 struct {
  948. Infcode string `json:"infcode"`
  949. InfRefmsgid string `json:"inf_refmsgid"`
  950. RefmsgTime string `json:"refmsg_time"`
  951. RespondTime string `json:"respond_time"`
  952. Enctype string `json:"enctype"`
  953. Signtype string `json:"signtype"`
  954. ErrMsg string `json:"err_msg"`
  955. Output struct {
  956. Result []struct {
  957. JudgeResultDetailDtos []struct {
  958. VolaItemType string `json:"vola_item_type"`
  959. MdtrtID string `json:"mdtrt_id"`
  960. JrdID string `json:"jrd_id"`
  961. PatnID string `json:"patn_id"`
  962. RxID string `json:"rx_id"`
  963. VolaAmt interface{} `json:"vola_amt"`
  964. } `json:"judge_result_detail_dtos"`
  965. RuleID string `json:"rule_id"`
  966. VolaEvid string `json:"vola_evid"`
  967. MdtrtID string `json:"mdtrt_id"`
  968. RuleName string `json:"rule_name"`
  969. VolaAmtStas string `json:"vola_amt_stas"`
  970. JrID string `json:"jr_id"`
  971. PatnID string `json:"patn_id"`
  972. SevDeg string `json:"sev_deg"`
  973. VolaAmt float64 `json:"vola_amt"`
  974. VolaBhvrType string `json:"vola_bhvr_type"`
  975. VolaCont string `json:"vola_cont"`
  976. } `json:"result"`
  977. } `json:"output"`
  978. }
  979. func (c *HisApiController) ReadEleToken() {
  980. admin_user_id, _ := c.GetInt64("admin_user_id")
  981. his_patient_id, _ := c.GetInt64("his_patient_id")
  982. adminUser := c.GetAdminUserInfo()
  983. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  984. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  985. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  986. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  987. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  988. if len(tokens) > 0 {
  989. c.ServeSuccessJSON(map[string]interface{}{
  990. "msg": "读取成功",
  991. })
  992. } else {
  993. c.ServeSuccessJSON(map[string]interface{}{
  994. "failed_code": -10,
  995. "msg": "读取失败",
  996. })
  997. }
  998. } else if miConfig.MdtrtareaAdmvs == "350500" {
  999. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  1000. if len(errMsg) == 0 {
  1001. type ELeData struct {
  1002. Data struct {
  1003. IdNo string `json:"idNo"`
  1004. IdType string `json:"idType"`
  1005. UserName string `json:"userName"`
  1006. EcToken string `json:"ecToken"`
  1007. InsuOrg string `json:"insuOrg"`
  1008. Gender string `json:"gender"`
  1009. Birthday string `json:"birthday"`
  1010. Nationality string `json:"nationality"`
  1011. Email string `json:"email"`
  1012. Extra string `json:"extra"`
  1013. } `json:"data"`
  1014. Code int `json:"code"`
  1015. Message string `json:"message"`
  1016. }
  1017. var ele ELeData
  1018. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1019. if err != nil {
  1020. utils.ErrorLog("解析失败:%v", err)
  1021. }
  1022. token := ele.Data.EcToken
  1023. if len(token) > 0 {
  1024. psn := &models.HisPsn{
  1025. PsnNo: his.PsnNo,
  1026. Age: 0,
  1027. PatientId: his.PatientId,
  1028. Certno: his.Certno,
  1029. Brdy: his.Brdy,
  1030. Gend: his.Gend,
  1031. Naty: his.Naty,
  1032. PsnCertType: his.PsnCertType,
  1033. PsnName: his.PsnName,
  1034. Idetinfo: his.Idetinfo,
  1035. Insuinfo: his.Iinfo,
  1036. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1037. CardInfo: outPutInfo,
  1038. VerifyNumber: token,
  1039. }
  1040. service.CreateHisPsn(psn)
  1041. }
  1042. if len(token) > 0 {
  1043. c.ServeSuccessJSON(map[string]interface{}{
  1044. "msg": "读取成功",
  1045. })
  1046. } else {
  1047. c.ServeSuccessJSON(map[string]interface{}{
  1048. "failed_code": -10,
  1049. "msg": "读取失败",
  1050. })
  1051. }
  1052. }
  1053. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1054. if initFlag == 0 {
  1055. c.TestGetJiangXiBasBaseInit()
  1056. }
  1057. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1058. type ELeData struct {
  1059. Data struct {
  1060. IdNo string `json:"idNo"`
  1061. IdType string `json:"idType"`
  1062. UserName string `json:"userName"`
  1063. EcToken string `json:"ecToken"`
  1064. InsuOrg string `json:"insuOrg"`
  1065. Gender string `json:"gender"`
  1066. Birthday string `json:"birthday"`
  1067. Nationality string `json:"nationality"`
  1068. Email string `json:"email"`
  1069. Extra string `json:"extra"`
  1070. } `json:"data"`
  1071. Code int `json:"code"`
  1072. Message string `json:"message"`
  1073. }
  1074. var ele ELeData
  1075. err := json.Unmarshal([]byte(json_result), &ele)
  1076. if err != nil {
  1077. utils.ErrorLog("解析失败:%v", err)
  1078. }
  1079. token := ele.Data.EcToken
  1080. token = Remove0000(token)
  1081. fmt.Println(ele.Data.UserName)
  1082. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  1083. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1084. var res ResultTwo
  1085. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1086. utils.ErrorLog("解析失败:%v", err)
  1087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1088. return
  1089. }
  1090. if res.Infcode == 0 {
  1091. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1092. if err == gorm.ErrRecordNotFound {
  1093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1094. return
  1095. } else if err != nil {
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1097. return
  1098. } else {
  1099. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1100. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1101. infoStr := string(Iinfos)
  1102. idetinfoStr := string(Idetinfos)
  1103. psn := &models.HisPsn{
  1104. PsnNo: res.Output.Baseinfo.PsnNo,
  1105. Age: res.Output.Baseinfo.Age,
  1106. PatientId: patient.ID,
  1107. Certno: res.Output.Baseinfo.Certno,
  1108. Brdy: res.Output.Baseinfo.Brdy,
  1109. Gend: res.Output.Baseinfo.Gend,
  1110. Naty: res.Output.Baseinfo.Naty,
  1111. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1112. PsnName: res.Output.Baseinfo.PsnName,
  1113. Idetinfo: idetinfoStr,
  1114. Insuinfo: infoStr,
  1115. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1116. CardInfo: "",
  1117. VerifyNumber: token,
  1118. }
  1119. service.CreateHisPsn(psn)
  1120. c.ServeSuccessJSON(map[string]interface{}{
  1121. "patient": patient,
  1122. "number": token,
  1123. })
  1124. }
  1125. } else {
  1126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1127. return
  1128. }
  1129. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1130. if initFlag == 0 {
  1131. c.TestGetJiangXiBasBaseInit()
  1132. }
  1133. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1134. type ELeData struct {
  1135. Data struct {
  1136. IdNo string `json:"idNo"`
  1137. IdType string `json:"idType"`
  1138. UserName string `json:"userName"`
  1139. EcToken string `json:"ecToken"`
  1140. InsuOrg string `json:"insuOrg"`
  1141. Gender string `json:"gender"`
  1142. Birthday string `json:"birthday"`
  1143. Nationality string `json:"nationality"`
  1144. Email string `json:"email"`
  1145. Extra string `json:"extra"`
  1146. } `json:"data"`
  1147. Code int `json:"code"`
  1148. Message string `json:"message"`
  1149. }
  1150. var ele ELeData
  1151. err := json.Unmarshal([]byte(json_result), &ele)
  1152. if err != nil {
  1153. utils.ErrorLog("解析失败:%v", err)
  1154. }
  1155. token := ele.Data.EcToken
  1156. token = Remove0000(token)
  1157. fmt.Println(ele.Data.UserName)
  1158. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  1159. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1160. var res ResultTwo
  1161. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1162. utils.ErrorLog("解析失败:%v", err)
  1163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1164. return
  1165. }
  1166. if res.Infcode == 0 {
  1167. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1168. if err == gorm.ErrRecordNotFound {
  1169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1170. return
  1171. } else if err != nil {
  1172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1173. return
  1174. } else {
  1175. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1176. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1177. infoStr := string(Iinfos)
  1178. idetinfoStr := string(Idetinfos)
  1179. psn := &models.HisPsn{
  1180. PsnNo: res.Output.Baseinfo.PsnNo,
  1181. Age: res.Output.Baseinfo.Age,
  1182. PatientId: patient.ID,
  1183. Certno: res.Output.Baseinfo.Certno,
  1184. Brdy: res.Output.Baseinfo.Brdy,
  1185. Gend: res.Output.Baseinfo.Gend,
  1186. Naty: res.Output.Baseinfo.Naty,
  1187. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1188. PsnName: res.Output.Baseinfo.PsnName,
  1189. Idetinfo: idetinfoStr,
  1190. Insuinfo: infoStr,
  1191. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1192. CardInfo: "",
  1193. VerifyNumber: token,
  1194. }
  1195. service.CreateHisPsn(psn)
  1196. c.ServeSuccessJSON(map[string]interface{}{
  1197. "patient": patient,
  1198. "number": token,
  1199. })
  1200. }
  1201. } else {
  1202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1203. return
  1204. }
  1205. } else {
  1206. //if initFlag == 0 {
  1207. // c.TestGetBasBaseInit()
  1208. //}
  1209. //token := c.GetEleBaseInfo()
  1210. //token = Remove0000(token)
  1211. type ELeData struct {
  1212. Code string `json:"code"`
  1213. Data struct {
  1214. Aac002 string `json:"aac002"`
  1215. Aaz500 string `json:"aaz500"`
  1216. ActCardNo string `json:"actCardNo"`
  1217. Bab520 string `json:"bab520"`
  1218. Bkz543 string `json:"bkz543"`
  1219. BusinessType string `json:"businessType"`
  1220. CertfCodg string `json:"certfCodg"`
  1221. EcIndexNo string `json:"ecIndexNo"`
  1222. EcToken string `json:"ecToken"`
  1223. ID0000 string `json:"id0000"`
  1224. IDNo string `json:"idNo"`
  1225. IDType string `json:"idType"`
  1226. Idcode string `json:"idcode"`
  1227. IdentityToken string `json:"identity_token"`
  1228. InsuOrg string `json:"insuOrg"`
  1229. OfficeID string `json:"officeId"`
  1230. OfficeName string `json:"officeName"`
  1231. OperatorID string `json:"operatorId"`
  1232. OperatorName string `json:"operatorName"`
  1233. OrgID string `json:"orgId"`
  1234. UserName string `json:"userName"`
  1235. } `json:"data"`
  1236. Infno interface{} `json:"infno"`
  1237. Message string `json:"message"`
  1238. OrgID string `json:"orgId"`
  1239. TransType string `json:"transType"`
  1240. }
  1241. _, result := GetgdEleBaseInfoTwo(miConfig.Code, admin_user_id, roles.UserName)
  1242. fmt.Println(result)
  1243. outPutInfo := Remove0000(result)
  1244. fmt.Println(outPutInfo)
  1245. var ele ELeData
  1246. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1247. if err != nil {
  1248. utils.ErrorLog("解析失败:%v", err)
  1249. }
  1250. token := ele.Data.EcToken
  1251. if len(token) > 0 {
  1252. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  1253. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1254. var res ResultTwo
  1255. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1256. utils.ErrorLog("解析失败:%v", err)
  1257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1258. return
  1259. }
  1260. if res.Infcode == 0 {
  1261. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1262. if err == gorm.ErrRecordNotFound {
  1263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1264. return
  1265. } else if err != nil {
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1267. return
  1268. } else {
  1269. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1270. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1271. infoStr := string(Iinfos)
  1272. idetinfoStr := string(Idetinfos)
  1273. psn := &models.HisPsn{
  1274. PsnNo: res.Output.Baseinfo.PsnNo,
  1275. Age: res.Output.Baseinfo.Age,
  1276. PatientId: patient.ID,
  1277. Certno: res.Output.Baseinfo.Certno,
  1278. Brdy: res.Output.Baseinfo.Brdy,
  1279. Gend: res.Output.Baseinfo.Gend,
  1280. Naty: res.Output.Baseinfo.Naty,
  1281. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1282. PsnName: res.Output.Baseinfo.PsnName,
  1283. Idetinfo: idetinfoStr,
  1284. Insuinfo: infoStr,
  1285. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1286. CardInfo: "",
  1287. VerifyNumber: token,
  1288. }
  1289. service.CreateHisPsn(psn)
  1290. c.ServeSuccessJSON(map[string]interface{}{
  1291. "msg": "读取成功",
  1292. })
  1293. }
  1294. } else {
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1296. return
  1297. }
  1298. } else {
  1299. c.ServeSuccessJSON(map[string]interface{}{
  1300. "failed_code": -10,
  1301. "msg": "读取失败",
  1302. })
  1303. }
  1304. }
  1305. }
  1306. func (c *HisApiController) Get9001() {
  1307. adminUser := c.GetAdminUserInfo()
  1308. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1309. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  1310. if miConfig.MdtrtareaAdmvs == "350500" {
  1311. service.GetFjAuthorizationInfo(miConfig.Code)
  1312. } else if miConfig.MdtrtareaAdmvs == "131023" {
  1313. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1314. var dat map[string]interface{}
  1315. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1316. fmt.Println(dat)
  1317. } else {
  1318. fmt.Println(err)
  1319. }
  1320. userJSONBytes, _ := json.Marshal(dat)
  1321. var res models.Result9001
  1322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1323. utils.ErrorLog("解析失败:%v", err)
  1324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1325. return
  1326. }
  1327. } else {
  1328. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1329. var dat map[string]interface{}
  1330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1331. fmt.Println(dat)
  1332. } else {
  1333. fmt.Println(err)
  1334. }
  1335. userJSONBytes, _ := json.Marshal(dat)
  1336. var res models.Result9001
  1337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1338. utils.ErrorLog("解析失败:%v", err)
  1339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1340. return
  1341. }
  1342. }
  1343. }
  1344. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  1345. var res Result3101
  1346. adminUser := c.GetAdminUserInfo()
  1347. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1348. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1349. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1350. //record_time := c.GetString("record_time")
  1351. //trig_scen := c.GetString("trig_scen")
  1352. timeLayout := "2006-01-02"
  1353. loc, _ := time.LoadLocation("Local")
  1354. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1355. if err != nil {
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1357. return res
  1358. }
  1359. recordDateTime := theTime.Unix()
  1360. var patientPrescription models.HisPrescriptionInfo
  1361. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1362. //if patientPrescription.ID == 0 {
  1363. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1364. //}
  1365. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1366. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1367. //
  1368. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1369. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1370. var pp models.PublicParams
  1371. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1372. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1373. pp.FixmedinsName = miConfig.OrgName
  1374. pp.FixmedinsCode = miConfig.Code
  1375. pp.RequestUrl = miConfig.Url
  1376. pp.Cainfo = miConfig.Cainfo
  1377. pp.SecretKey = miConfig.SecretKey
  1378. pp.AccessKey = miConfig.AccessKey
  1379. pp.OpterName = roles.UserName
  1380. var config []*models.HisXtDiagnoseConfig
  1381. for _, item := range diagnosis_ids {
  1382. id, _ := strconv.ParseInt(item, 10, 64)
  1383. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1384. config = append(config, &diagnosisConfig)
  1385. }
  1386. var pd models.PatientDtos
  1387. pd.PatnID = his.PsnNo
  1388. pd.PatnName = his.Name
  1389. pd.Gend = his.Gend
  1390. pd.Brdy = his.Brdy
  1391. pd.Poolarea = miConfig.MdtrtareaAdmvs
  1392. pd.CurrMdtrtID = his.Number
  1393. var fed models.FsiEncounterDtos
  1394. fed.MdtrtID = his.Number
  1395. fed.MedinsID = miConfig.Code
  1396. fed.MedinsName = miConfig.OrgName
  1397. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1398. fed.MedMdtrtType = "1"
  1399. fed.MedinsType = "1"
  1400. fed.MedinsLv = "11"
  1401. tm := time.Unix(his.RecordDate, 0)
  1402. s_tm := tm.Format("2006-01-02 15:04:05")
  1403. fed.AdmDate = s_tm
  1404. fed.DscgDate = s_tm
  1405. fed.DscgMainDiseCodg = config[0].CountryCode
  1406. fed.DscgMainDiseName = config[0].CountryContentName
  1407. //诊断信息
  1408. var fdds []*models.FsiDiagnoseDtos
  1409. for index, item := range config {
  1410. if index == 0 {
  1411. var fdd models.FsiDiagnoseDtos
  1412. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1413. fdd.InoutDiseType = "1"
  1414. fdd.MaindiseFlag = "1"
  1415. fdd.DiseDate = s_tm
  1416. fdd.DiasSrtNo = "1"
  1417. fdd.DiseName = item.CountryContentName
  1418. fdd.DiseCodg = item.CountryCode
  1419. fdds = append(fdds, &fdd)
  1420. } else {
  1421. var fdd models.FsiDiagnoseDtos
  1422. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1423. fdd.InoutDiseType = "1"
  1424. fdd.MaindiseFlag = "1"
  1425. fdd.DiseDate = s_tm
  1426. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1427. fdd.DiseName = item.CountryContentName
  1428. fdd.DiseCodg = item.CountryCode
  1429. fdds = append(fdds, &fdd)
  1430. }
  1431. }
  1432. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1433. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1434. fed.AdmDeptName = department.Name
  1435. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1436. fed.DscgDeptName = department.Name
  1437. fed.MedMdtrtType = "1"
  1438. fed.MedType = "11"
  1439. //if his.Insutype == "390" {
  1440. // fed.MedType = "1402"
  1441. //} else {
  1442. // fed.MedType = "9933"
  1443. //}
  1444. var orders []*models.FsiOrderDtos
  1445. if trig_scen == "2" {
  1446. //处方医嘱信息
  1447. for _, item := range prescriptions {
  1448. for _, subItem := range item.HisDoctorAdviceInfo {
  1449. var order models.FsiOrderDtos
  1450. order.RxID = strconv.FormatInt(item.ID, 10)
  1451. order.Rxno = strconv.FormatInt(item.ID, 10)
  1452. order.LongDrordFlag = "0"
  1453. order.HilistType = "1"
  1454. order.ChrgType = "1"
  1455. order.DrordBhvr = "-"
  1456. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1457. order.HosplistName = subItem.BaseDrugLib.DrugName
  1458. order.HilistLv = "1"
  1459. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1460. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1461. order.HosplistName = subItem.BaseDrugLib.DrugName
  1462. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1463. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1464. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1465. order.OwnpayAmt = ""
  1466. order.SelfpayAmt = ""
  1467. order.Spec = ""
  1468. order.SpecUnt = ""
  1469. order.DrordBegnDate = s_tm
  1470. order.DrordStopDate = ""
  1471. order.DrordDrCodg = "1"
  1472. order.DrordDeptName = department.Name
  1473. order.DrordDrCodg = "1"
  1474. order.DrordDrName = doctor_info.UserName
  1475. order.DrordDrProfttl = ""
  1476. order.CurrDrordFlag = "1"
  1477. orders = append(orders, &order)
  1478. }
  1479. for _, subItem := range item.HisPrescriptionProject {
  1480. if subItem.Type == 2 {
  1481. var order models.FsiOrderDtos
  1482. order.RxID = strconv.FormatInt(item.ID, 10)
  1483. order.Rxno = strconv.FormatInt(item.ID, 10)
  1484. order.LongDrordFlag = "0"
  1485. order.HilistType = "1"
  1486. order.ChrgType = "1"
  1487. order.DrordBhvr = "-"
  1488. order.HilistCode = subItem.HisProject.MedicalCode
  1489. order.HosplistName = subItem.HisProject.ProjectName
  1490. order.HilistLv = "1"
  1491. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1492. order.HosplistCode = subItem.HisProject.MedicalCode
  1493. order.HosplistName = subItem.HisProject.ProjectName
  1494. order.Cnt = subItem.Count
  1495. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1496. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1497. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1498. order.OwnpayAmt = ""
  1499. order.SelfpayAmt = ""
  1500. order.Spec = ""
  1501. order.SpecUnt = ""
  1502. order.DrordBegnDate = s_tm
  1503. order.DrordStopDate = ""
  1504. order.DrordDrCodg = "1"
  1505. order.DrordDeptName = department.Name
  1506. order.DrordDrCodg = "1"
  1507. order.DrordDrName = doctor_info.UserName
  1508. order.DrordDrProfttl = ""
  1509. order.CurrDrordFlag = "1"
  1510. orders = append(orders, &order)
  1511. }
  1512. if subItem.Type == 3 {
  1513. var order models.FsiOrderDtos
  1514. order.RxID = strconv.FormatInt(item.ID, 10)
  1515. order.Rxno = strconv.FormatInt(item.ID, 10)
  1516. order.LongDrordFlag = "0"
  1517. order.HilistType = "1"
  1518. order.ChrgType = "1"
  1519. order.DrordBhvr = "-"
  1520. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1521. order.HosplistName = subItem.GoodInfo.GoodName
  1522. order.HilistLv = "1"
  1523. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1524. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1525. order.HosplistName = subItem.GoodInfo.GoodName
  1526. order.Cnt = subItem.Count
  1527. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1528. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1529. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1530. order.OwnpayAmt = ""
  1531. order.SelfpayAmt = ""
  1532. order.Spec = ""
  1533. order.SpecUnt = ""
  1534. order.DrordBegnDate = s_tm
  1535. order.DrordStopDate = ""
  1536. order.DrordDrCodg = "1"
  1537. order.DrordDeptName = department.Name
  1538. order.DrordDrCodg = "1"
  1539. order.DrordDrName = doctor_info.UserName
  1540. order.DrordDrProfttl = ""
  1541. order.CurrDrordFlag = "1"
  1542. orders = append(orders, &order)
  1543. }
  1544. }
  1545. }
  1546. //处方医嘱信息
  1547. }
  1548. fed.MatnStas = "0"
  1549. fed.MedfeeSumamt = "0"
  1550. fed.OwnpayAmt = "0"
  1551. fed.SelfpayAmt = "0"
  1552. fed.AcctPayamt = "0"
  1553. fed.MaAmt = "0"
  1554. fed.HifpPayamt = "0"
  1555. fed.SetlTotlnum = "1"
  1556. fed.Insutype = his.Insutype
  1557. fed.ReimFlag = "0"
  1558. fed.OutSetlFlag = "0"
  1559. var fopd []*models.FsiOperationDtosData
  1560. data := make(map[string]interface{})
  1561. data["fed"] = fed
  1562. data["fdd"] = fdds
  1563. data["fod"] = orders
  1564. data["pd"] = pd
  1565. data["pp"] = pp
  1566. data["fopd"] = fopd
  1567. data["trig_scen"] = trig_scen
  1568. fmt.Println(data)
  1569. fmt.Println(fed)
  1570. fmt.Println(fdds)
  1571. fmt.Println(orders)
  1572. fmt.Println(pd)
  1573. fmt.Println(pp)
  1574. fmt.Println(fopd)
  1575. client := &http.Client{}
  1576. bytesData, _ := json.Marshal(data)
  1577. var req *http.Request
  1578. if miConfig.MdtrtareaAdmvs == "320921" {
  1579. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1580. } else {
  1581. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1582. }
  1583. resp, _ := client.Do(req)
  1584. defer resp.Body.Close()
  1585. body, ioErr := ioutil.ReadAll(resp.Body)
  1586. if ioErr != nil {
  1587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1589. return res
  1590. }
  1591. var respJSON map[string]interface{}
  1592. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1595. return res
  1596. }
  1597. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1598. fmt.Println(respJSON)
  1599. result, _ := json.Marshal(respJSON)
  1600. fmt.Println(result)
  1601. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1602. utils.ErrorLog("解析失败:%v", err)
  1603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1604. return res
  1605. }
  1606. return res
  1607. }
  1608. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  1609. adminUser := c.GetAdminUserInfo()
  1610. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1611. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1612. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1613. //record_time := c.GetString("record_time")
  1614. //trig_scen := c.GetString("trig_scen")
  1615. timeLayout := "2006-01-02"
  1616. loc, _ := time.LoadLocation("Local")
  1617. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1618. if err != nil {
  1619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1620. return res
  1621. }
  1622. recordDateTime := theTime.Unix()
  1623. var patientPrescription models.HisPrescriptionInfo
  1624. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1625. if patientPrescription.ID == 0 {
  1626. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1627. }
  1628. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1629. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1630. //
  1631. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1632. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1633. var pp models.PublicParams
  1634. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1635. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1636. pp.FixmedinsName = miConfig.OrgName
  1637. pp.FixmedinsCode = miConfig.Code
  1638. pp.RequestUrl = miConfig.Url
  1639. pp.Cainfo = miConfig.Cainfo
  1640. pp.SecretKey = miConfig.SecretKey
  1641. pp.AccessKey = miConfig.AccessKey
  1642. pp.OpterName = roles.UserName
  1643. var config []*models.HisXtDiagnoseConfig
  1644. for _, item := range diagnosis_ids {
  1645. id, _ := strconv.ParseInt(item, 10, 64)
  1646. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1647. config = append(config, &diagnosisConfig)
  1648. }
  1649. var pd models.PatientDtos
  1650. pd.PatnID = his.PsnNo
  1651. pd.PatnName = his.Name
  1652. pd.Gend = his.Gend
  1653. pd.Brdy = his.Brdy
  1654. pd.Poolarea = his.InsuplcAdmdvs
  1655. pd.CurrMdtrtID = his.Number
  1656. var fed models.FsiEncounterDtos
  1657. fed.MdtrtID = his.Number
  1658. fed.MedinsID = miConfig.Code
  1659. fed.MedinsName = miConfig.OrgName
  1660. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1661. fed.MedMdtrtType = "1"
  1662. fed.MedinsType = "1"
  1663. fed.MedinsLv = "11"
  1664. tm := time.Unix(his.RecordDate, 0)
  1665. s_tm := tm.Format("2006-01-02 15:04:05")
  1666. fed.AdmDate = s_tm
  1667. fed.DscgDate = s_tm
  1668. fed.DscgMainDiseCodg = config[0].CountryCode
  1669. fed.DscgMainDiseName = config[0].CountryContentName
  1670. //诊断信息
  1671. var fdds []*models.FsiDiagnoseDtos
  1672. for index, item := range config {
  1673. if index == 0 {
  1674. var fdd models.FsiDiagnoseDtos
  1675. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1676. fdd.InoutDiseType = "1"
  1677. fdd.MaindiseFlag = "1"
  1678. fdd.DiseDate = s_tm
  1679. fdd.DiasSrtNo = "1"
  1680. fdd.DiseName = item.CountryContentName
  1681. fdd.DiseCodg = item.CountryCode
  1682. fdds = append(fdds, &fdd)
  1683. } else {
  1684. var fdd models.FsiDiagnoseDtos
  1685. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1686. fdd.InoutDiseType = "1"
  1687. fdd.MaindiseFlag = "1"
  1688. fdd.DiseDate = s_tm
  1689. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1690. fdd.DiseName = item.CountryContentName
  1691. fdd.DiseCodg = item.CountryCode
  1692. fdds = append(fdds, &fdd)
  1693. }
  1694. }
  1695. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1696. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1697. fed.AdmDeptName = department.Name
  1698. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1699. fed.DscgDeptName = department.Name
  1700. fed.MedMdtrtType = "1"
  1701. fed.MedType = "11"
  1702. //if his.Insutype == "390" {
  1703. // fed.MedType = "1402"
  1704. //} else {
  1705. // fed.MedType = "9933"
  1706. //}
  1707. var orders []*models.FsiOrderDtos
  1708. if trig_scen == "2" {
  1709. //处方医嘱信息
  1710. for _, item := range prescriptions {
  1711. for _, subItem := range item.HisDoctorAdviceInfo {
  1712. var order models.FsiOrderDtos
  1713. order.RxID = strconv.FormatInt(item.ID, 10)
  1714. order.Rxno = strconv.FormatInt(item.ID, 10)
  1715. order.LongDrordFlag = "0"
  1716. order.HilistType = "1"
  1717. order.ChrgType = "1"
  1718. order.DrordBhvr = "-"
  1719. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1720. order.HosplistName = subItem.BaseDrugLib.DrugName
  1721. order.HilistLv = "1"
  1722. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1723. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1724. order.HosplistName = subItem.BaseDrugLib.DrugName
  1725. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1726. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1727. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1728. order.OwnpayAmt = ""
  1729. order.SelfpayAmt = ""
  1730. order.Spec = ""
  1731. order.SpecUnt = ""
  1732. order.DrordBegnDate = s_tm
  1733. order.DrordStopDate = ""
  1734. order.DrordDrCodg = "1"
  1735. order.DrordDeptName = department.Name
  1736. order.DrordDrCodg = "1"
  1737. order.DrordDrName = doctor_info.UserName
  1738. order.DrordDrProfttl = ""
  1739. order.CurrDrordFlag = "1"
  1740. orders = append(orders, &order)
  1741. }
  1742. for _, subItem := range item.HisPrescriptionProject {
  1743. if subItem.Type == 2 {
  1744. var order models.FsiOrderDtos
  1745. order.RxID = strconv.FormatInt(item.ID, 10)
  1746. order.Rxno = strconv.FormatInt(item.ID, 10)
  1747. order.LongDrordFlag = "0"
  1748. order.HilistType = "1"
  1749. order.ChrgType = "1"
  1750. order.DrordBhvr = "-"
  1751. order.HilistCode = subItem.HisProject.MedicalCode
  1752. order.HosplistName = subItem.HisProject.ProjectName
  1753. order.HilistLv = "1"
  1754. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1755. order.HosplistCode = subItem.HisProject.MedicalCode
  1756. order.HosplistName = subItem.HisProject.ProjectName
  1757. order.Cnt = subItem.Count
  1758. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1759. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1760. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1761. order.OwnpayAmt = ""
  1762. order.SelfpayAmt = ""
  1763. order.Spec = ""
  1764. order.SpecUnt = ""
  1765. order.DrordBegnDate = s_tm
  1766. order.DrordStopDate = ""
  1767. order.DrordDrCodg = "1"
  1768. order.DrordDeptName = department.Name
  1769. order.DrordDrCodg = "1"
  1770. order.DrordDrName = doctor_info.UserName
  1771. order.DrordDrProfttl = ""
  1772. order.CurrDrordFlag = "1"
  1773. orders = append(orders, &order)
  1774. }
  1775. if subItem.Type == 3 {
  1776. var order models.FsiOrderDtos
  1777. order.RxID = strconv.FormatInt(item.ID, 10)
  1778. order.Rxno = strconv.FormatInt(item.ID, 10)
  1779. order.LongDrordFlag = "0"
  1780. order.HilistType = "1"
  1781. order.ChrgType = "1"
  1782. order.DrordBhvr = "-"
  1783. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1784. order.HosplistName = subItem.GoodInfo.GoodName
  1785. order.HilistLv = "1"
  1786. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1787. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1788. order.HosplistName = subItem.GoodInfo.GoodName
  1789. order.Cnt = subItem.Count
  1790. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1791. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1792. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1793. order.OwnpayAmt = ""
  1794. order.SelfpayAmt = ""
  1795. order.Spec = ""
  1796. order.SpecUnt = ""
  1797. order.DrordBegnDate = s_tm
  1798. order.DrordStopDate = ""
  1799. order.DrordDrCodg = "1"
  1800. order.DrordDeptName = department.Name
  1801. order.DrordDrCodg = "1"
  1802. order.DrordDrName = doctor_info.UserName
  1803. order.DrordDrProfttl = ""
  1804. order.CurrDrordFlag = "1"
  1805. orders = append(orders, &order)
  1806. }
  1807. }
  1808. }
  1809. //处方医嘱信息
  1810. }
  1811. fed.MatnStas = "0"
  1812. fed.MedfeeSumamt = "0"
  1813. fed.OwnpayAmt = "0"
  1814. fed.SelfpayAmt = "0"
  1815. fed.AcctPayamt = "0"
  1816. fed.MaAmt = "0"
  1817. fed.HifpPayamt = "0"
  1818. fed.SetlTotlnum = "1"
  1819. fed.Insutype = his.Insutype
  1820. fed.ReimFlag = "0"
  1821. fed.OutSetlFlag = "0"
  1822. var fopd []*models.FsiOperationDtosData
  1823. data := make(map[string]interface{})
  1824. data["fed"] = fed
  1825. data["fdd"] = fdds
  1826. data["fod"] = orders
  1827. data["pd"] = pd
  1828. data["pp"] = pp
  1829. data["fopd"] = fopd
  1830. data["trig_scen"] = trig_scen
  1831. fmt.Println(data)
  1832. fmt.Println(fed)
  1833. fmt.Println(fdds)
  1834. fmt.Println(orders)
  1835. fmt.Println(pd)
  1836. fmt.Println(pp)
  1837. fmt.Println(fopd)
  1838. client := &http.Client{}
  1839. bytesData, _ := json.Marshal(data)
  1840. var req *http.Request
  1841. if miConfig.MdtrtareaAdmvs == "320921" {
  1842. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1843. } else {
  1844. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1845. }
  1846. resp, _ := client.Do(req)
  1847. defer resp.Body.Close()
  1848. body, ioErr := ioutil.ReadAll(resp.Body)
  1849. if ioErr != nil {
  1850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1852. return res
  1853. }
  1854. var respJSON map[string]interface{}
  1855. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1858. return res
  1859. }
  1860. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1861. result, _ := json.Marshal(respJSON)
  1862. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1863. utils.ErrorLog("解析失败:%v", err)
  1864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1865. return res
  1866. }
  1867. return res
  1868. }
  1869. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1870. ////patient_id, _ := c.GetInt64("patient_id")
  1871. //order_id, _ := c.GetInt64("order_id")
  1872. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1873. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1874. //trig_scen := c.GetString("trig_scen")
  1875. adminUser := c.GetAdminUserInfo()
  1876. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1877. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1878. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1879. record_time := c.GetString("record_time")
  1880. order, _ := service.GetHisOrderByID(order_id)
  1881. timeLayout := "2006-01-02"
  1882. loc, _ := time.LoadLocation("Local")
  1883. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1884. if err != nil {
  1885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1886. return
  1887. }
  1888. recordDateTime := theTime.Unix()
  1889. var patientPrescription models.HisPrescriptionInfo
  1890. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1891. if patientPrescription.ID == 0 {
  1892. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1893. }
  1894. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1895. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1896. //
  1897. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1898. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1899. var pp models.PublicParams
  1900. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1901. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1902. pp.FixmedinsName = miConfig.OrgName
  1903. pp.FixmedinsCode = miConfig.Code
  1904. pp.RequestUrl = miConfig.Url
  1905. pp.Cainfo = miConfig.Cainfo
  1906. pp.SecretKey = miConfig.SecretKey
  1907. pp.AccessKey = miConfig.AccessKey
  1908. pp.OpterName = roles.UserName
  1909. var config []*models.HisXtDiagnoseConfig
  1910. for _, item := range diagnosis_ids {
  1911. id, _ := strconv.ParseInt(item, 10, 64)
  1912. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1913. config = append(config, &diagnosisConfig)
  1914. }
  1915. var pd models.PatientDtos
  1916. pd.PatnID = his.PsnNo
  1917. pd.PatnName = his.Name
  1918. pd.Gend = his.Gend
  1919. pd.Brdy = his.Brdy
  1920. pd.Poolarea = his.InsuplcAdmdvs
  1921. pd.CurrMdtrtID = his.Number
  1922. var fed models.FsiEncounterDtos
  1923. fed.MdtrtID = his.Number
  1924. fed.MedinsID = miConfig.Code
  1925. fed.MedinsName = miConfig.OrgName
  1926. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1927. fed.MedMdtrtType = "1"
  1928. fed.MedinsType = "1"
  1929. fed.MedinsLv = "11"
  1930. tm := time.Unix(his.RecordDate, 0)
  1931. s_tm := tm.Format("2006-01-02 15:04:05")
  1932. fed.AdmDate = s_tm
  1933. fed.DscgDate = s_tm
  1934. fed.DscgMainDiseCodg = config[0].CountryCode
  1935. fed.DscgMainDiseName = config[0].CountryContentName
  1936. //诊断信息
  1937. var fdds []*models.FsiDiagnoseDtos
  1938. for index, item := range config {
  1939. if index == 0 {
  1940. var fdd models.FsiDiagnoseDtos
  1941. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1942. fdd.InoutDiseType = "1"
  1943. fdd.MaindiseFlag = "1"
  1944. fdd.DiseDate = s_tm
  1945. fdd.DiasSrtNo = "1"
  1946. fdd.DiseName = item.CountryContentName
  1947. fdd.DiseCodg = item.CountryCode
  1948. fdds = append(fdds, &fdd)
  1949. } else {
  1950. var fdd models.FsiDiagnoseDtos
  1951. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1952. fdd.InoutDiseType = "1"
  1953. fdd.MaindiseFlag = "1"
  1954. fdd.DiseDate = s_tm
  1955. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1956. fdd.DiseName = item.CountryContentName
  1957. fdd.DiseCodg = item.CountryCode
  1958. fdds = append(fdds, &fdd)
  1959. }
  1960. }
  1961. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1962. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1963. fed.AdmDeptName = department.Name
  1964. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1965. fed.DscgDeptName = department.Name
  1966. fed.MedType = order.MedType
  1967. //处方医嘱信息
  1968. var orders []*models.FsiOrderDtos
  1969. //for _, item := range prescriptions {
  1970. // for _, subItem := range item.HisDoctorAdviceInfo {
  1971. // var order models.FsiOrderDtos
  1972. // order.RxID = strconv.FormatInt(item.ID, 10)
  1973. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1974. // order.LongDrordFlag = "0"
  1975. // order.HilistType = "1"
  1976. // order.ChrgType = "1"
  1977. // order.DrordBhvr = "-"
  1978. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1979. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1980. // order.HilistLv = "1"
  1981. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1982. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1983. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1984. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1985. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1986. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1987. // order.OwnpayAmt = ""
  1988. // order.SelfpayAmt = ""
  1989. // order.Spec = ""
  1990. // order.SpecUnt = ""
  1991. // order.DrordBegnDate = s_tm
  1992. // order.DrordStopDate = ""
  1993. // order.DrordDrCodg = "1"
  1994. // order.DrordDeptName = department.Name
  1995. // order.DrordDrCodg = "1"
  1996. // order.DrordDrName = doctor_info.UserName
  1997. // order.DrordDrProfttl = ""
  1998. // order.CurrDrordFlag = "1"
  1999. // orders = append(orders, &order)
  2000. // }
  2001. // for _, subItem := range item.HisPrescriptionProject {
  2002. // if subItem.Type == 2 {
  2003. // var order models.FsiOrderDtos
  2004. // order.RxID = strconv.FormatInt(item.ID, 10)
  2005. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2006. // order.LongDrordFlag = "0"
  2007. // order.HilistType = "1"
  2008. // order.ChrgType = "1"
  2009. // order.DrordBhvr = "-"
  2010. // order.HilistCode = subItem.HisProject.MedicalCode
  2011. // order.HosplistName = subItem.HisProject.ProjectName
  2012. // order.HilistLv = "1"
  2013. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2014. // order.HosplistCode = subItem.HisProject.MedicalCode
  2015. // order.HosplistName = subItem.HisProject.ProjectName
  2016. // order.Cnt = subItem.Count
  2017. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2018. //
  2019. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2020. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2021. // order.OwnpayAmt = ""
  2022. // order.SelfpayAmt = ""
  2023. // order.Spec = ""
  2024. // order.SpecUnt = ""
  2025. // order.DrordBegnDate = s_tm
  2026. // order.DrordStopDate = ""
  2027. // order.DrordDrCodg = "1"
  2028. // order.DrordDeptName = department.Name
  2029. // order.DrordDrCodg = "1"
  2030. // order.DrordDrName = doctor_info.UserName
  2031. // order.DrordDrProfttl = ""
  2032. // order.CurrDrordFlag = "1"
  2033. // orders = append(orders, &order)
  2034. //
  2035. // }
  2036. // if subItem.Type == 3 {
  2037. //
  2038. // var order models.FsiOrderDtos
  2039. // order.RxID = strconv.FormatInt(item.ID, 10)
  2040. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2041. // order.LongDrordFlag = "0"
  2042. // order.HilistType = "1"
  2043. // order.ChrgType = "1"
  2044. // order.DrordBhvr = "-"
  2045. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2046. // order.HosplistName = subItem.GoodInfo.GoodName
  2047. // order.HilistLv = "1"
  2048. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2049. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2050. // order.HosplistName = subItem.GoodInfo.GoodName
  2051. // order.Cnt = subItem.Count
  2052. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2053. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2054. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2055. // order.OwnpayAmt = ""
  2056. // order.SelfpayAmt = ""
  2057. // order.Spec = ""
  2058. // order.SpecUnt = ""
  2059. // order.DrordBegnDate = s_tm
  2060. // order.DrordStopDate = ""
  2061. // order.DrordDrCodg = "1"
  2062. // order.DrordDeptName = department.Name
  2063. // order.DrordDrCodg = "1"
  2064. // order.DrordDrName = doctor_info.UserName
  2065. // order.DrordDrProfttl = ""
  2066. // order.CurrDrordFlag = "1"
  2067. // orders = append(orders, &order)
  2068. //
  2069. // }
  2070. // }
  2071. //}
  2072. for _, item := range prescriptions {
  2073. for _, subItem := range item.HisDoctorAdviceInfo {
  2074. var order models.FsiOrderDtos
  2075. order.RxID = strconv.FormatInt(item.ID, 10)
  2076. order.Rxno = strconv.FormatInt(item.ID, 10)
  2077. order.LongDrordFlag = "0"
  2078. order.HilistType = "1"
  2079. order.ChrgType = "1"
  2080. order.DrordBhvr = "-"
  2081. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2082. order.HosplistName = subItem.BaseDrugLib.DrugName
  2083. order.HilistLv = "1"
  2084. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2085. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2086. order.HosplistName = subItem.BaseDrugLib.DrugName
  2087. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2088. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2089. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2090. order.OwnpayAmt = ""
  2091. order.SelfpayAmt = ""
  2092. order.Spec = ""
  2093. order.SpecUnt = ""
  2094. order.DrordBegnDate = s_tm
  2095. order.DrordStopDate = ""
  2096. order.DrordDrCodg = "1"
  2097. order.DrordDeptName = department.Name
  2098. order.DrordDrCodg = "1"
  2099. order.DrordDrName = doctor_info.UserName
  2100. order.DrordDrProfttl = ""
  2101. order.CurrDrordFlag = "1"
  2102. orders = append(orders, &order)
  2103. }
  2104. for _, subItem := range item.HisPrescriptionProject {
  2105. if subItem.Type == 2 {
  2106. var order models.FsiOrderDtos
  2107. order.RxID = strconv.FormatInt(item.ID, 10)
  2108. order.Rxno = strconv.FormatInt(item.ID, 10)
  2109. order.LongDrordFlag = "0"
  2110. order.HilistType = "1"
  2111. order.ChrgType = "1"
  2112. order.DrordBhvr = "-"
  2113. order.HilistCode = subItem.HisProject.MedicalCode
  2114. order.HosplistName = subItem.HisProject.ProjectName
  2115. order.HilistLv = "1"
  2116. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2117. order.HosplistCode = subItem.HisProject.MedicalCode
  2118. order.HosplistName = subItem.HisProject.ProjectName
  2119. order.Cnt = subItem.Count
  2120. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2121. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2122. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2123. order.OwnpayAmt = ""
  2124. order.SelfpayAmt = ""
  2125. order.Spec = ""
  2126. order.SpecUnt = ""
  2127. order.DrordBegnDate = s_tm
  2128. order.DrordStopDate = ""
  2129. order.DrordDrCodg = "1"
  2130. order.DrordDeptName = department.Name
  2131. order.DrordDrCodg = "1"
  2132. order.DrordDrName = doctor_info.UserName
  2133. order.DrordDrProfttl = ""
  2134. order.CurrDrordFlag = "1"
  2135. orders = append(orders, &order)
  2136. }
  2137. if subItem.Type == 3 {
  2138. var order models.FsiOrderDtos
  2139. order.RxID = strconv.FormatInt(item.ID, 10)
  2140. order.Rxno = strconv.FormatInt(item.ID, 10)
  2141. order.LongDrordFlag = "0"
  2142. order.HilistType = "1"
  2143. order.ChrgType = "1"
  2144. order.DrordBhvr = "-"
  2145. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2146. order.HosplistName = subItem.GoodInfo.GoodName
  2147. order.HilistLv = "1"
  2148. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2149. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2150. order.HosplistName = subItem.GoodInfo.GoodName
  2151. order.Cnt = subItem.Count
  2152. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2153. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2154. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2155. order.OwnpayAmt = ""
  2156. order.SelfpayAmt = ""
  2157. order.Spec = ""
  2158. order.SpecUnt = ""
  2159. order.DrordBegnDate = s_tm
  2160. order.DrordStopDate = ""
  2161. order.DrordDrCodg = "1"
  2162. order.DrordDeptName = department.Name
  2163. order.DrordDrCodg = "1"
  2164. order.DrordDrName = doctor_info.UserName
  2165. order.DrordDrProfttl = ""
  2166. order.CurrDrordFlag = "1"
  2167. orders = append(orders, &order)
  2168. }
  2169. }
  2170. }
  2171. //处方医嘱信息
  2172. fed.MatnStas = "0"
  2173. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2174. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  2175. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  2176. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  2177. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  2178. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  2179. fed.SetlTotlnum = "1"
  2180. fed.Insutype = his.Insutype
  2181. fed.ReimFlag = "0"
  2182. fed.OutSetlFlag = "0"
  2183. var fopd []*models.FsiOperationDtosData
  2184. data := make(map[string]interface{})
  2185. data["fed"] = fed
  2186. data["fdd"] = fdds
  2187. data["fod"] = orders
  2188. data["pd"] = pd
  2189. data["pp"] = pp
  2190. data["fopd"] = fopd
  2191. data["trig_scen"] = trig_scen
  2192. client := &http.Client{}
  2193. bytesData, _ := json.Marshal(data)
  2194. var req *http.Request
  2195. if miConfig.MdtrtareaAdmvs == "320921" {
  2196. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2197. } else {
  2198. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2199. }
  2200. resp, _ := client.Do(req)
  2201. defer resp.Body.Close()
  2202. body, ioErr := ioutil.ReadAll(resp.Body)
  2203. if ioErr != nil {
  2204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2206. return res
  2207. }
  2208. var respJSON map[string]interface{}
  2209. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2212. return res
  2213. }
  2214. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2215. result, _ := json.Marshal(respJSON)
  2216. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2217. utils.ErrorLog("解析失败:%v", err)
  2218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2219. return res
  2220. }
  2221. return res
  2222. //手术操作集合
  2223. //手术操作集合
  2224. }
  2225. func (c *HisApiController) Check() {
  2226. psn_no := c.GetString("psn_no")
  2227. in := c.GetString("in")
  2228. mt := c.GetString("mt")
  2229. baseParams := models.BaseParams{
  2230. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  2231. FixmedinsCode: "H15049901371",
  2232. InsuplcAdmdvs: "150499",
  2233. MdtrtareaAdmvs: "150499",
  2234. OrgName: "赤峰费森血液透析中心",
  2235. Doctor: "1111",
  2236. }
  2237. service.Gdyb2001(baseParams, psn_no, in, mt)
  2238. }
  2239. func (c *HisApiController) GetPsnNcdsInfo() {
  2240. admin_user_id, _ := c.GetInt64("admin_user_id")
  2241. patient_id, _ := c.GetInt64("patient_id")
  2242. id, _ := c.GetInt64("id")
  2243. adminUser := c.GetAdminUserInfo()
  2244. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2245. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2246. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  2247. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2248. psn_record, _ := service.GetPsnNCDSRecordById(id)
  2249. //
  2250. //if psn_record.ID == 0 {
  2251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  2252. // return
  2253. //}
  2254. var res Result5301
  2255. var res10265 Result5301For10265
  2256. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2257. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2258. var api string
  2259. if miConfig.MdtrtareaAdmvs == "320921" {
  2260. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  2261. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2262. } else {
  2263. 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 +
  2264. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2265. }
  2266. resp, requestErr := http.Get(api)
  2267. if requestErr != nil {
  2268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2269. return
  2270. }
  2271. body, ioErr := ioutil.ReadAll(resp.Body)
  2272. if ioErr != nil {
  2273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2275. return
  2276. }
  2277. var respJSON map[string]interface{}
  2278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. return
  2282. }
  2283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2284. result, _ := json.Marshal(respJSON)
  2285. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2286. utils.ErrorLog("解析失败:%v", err)
  2287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2288. return
  2289. }
  2290. res.ErrMsg = res10265.ErrMsg
  2291. res.Output = res10265.Output
  2292. res.InfRefmsgid = res10265.InfRefmsgid
  2293. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2294. res.Infcode = infocode
  2295. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2296. p, _ := service.GetHisPatientById(patient_id)
  2297. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2298. var dat map[string]interface{}
  2299. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2300. fmt.Println(dat)
  2301. } else {
  2302. fmt.Println(err)
  2303. }
  2304. userJSONBytes, _ := json.Marshal(dat)
  2305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2306. utils.ErrorLog("解析失败:%v", err)
  2307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2308. return
  2309. }
  2310. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2311. p, _ := service.GetHisPatientById(patient_id)
  2312. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2313. var dat map[string]interface{}
  2314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2315. fmt.Println(dat)
  2316. } else {
  2317. fmt.Println(err)
  2318. }
  2319. userJSONBytes, _ := json.Marshal(dat)
  2320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2321. utils.ErrorLog("解析失败:%v", err)
  2322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2323. return
  2324. }
  2325. } else {
  2326. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2327. var dat map[string]interface{}
  2328. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2329. fmt.Println(dat)
  2330. } else {
  2331. fmt.Println(err)
  2332. }
  2333. userJSONBytes, _ := json.Marshal(dat)
  2334. if miConfig.Code == "H15049901371" {
  2335. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  2336. utils.ErrorLog("解析失败:%v", err)
  2337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2338. return
  2339. }
  2340. res.InfRefmsgid = res10265.InfRefmsgid
  2341. res.Output = res10265.Output
  2342. res.ErrMsg = res10265.ErrMsg
  2343. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2344. res.Infcode = infocode
  2345. } else {
  2346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2347. utils.ErrorLog("解析失败:%v", err)
  2348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2349. return
  2350. }
  2351. }
  2352. }
  2353. if res.Infcode == 0 {
  2354. c.ServeSuccessJSON(map[string]interface{}{
  2355. "result": res.Output.Result,
  2356. })
  2357. }
  2358. }
  2359. func (c *HisApiController) CheckInsutype() {
  2360. his_patient_id, _ := c.GetInt64("his_patient_id")
  2361. admin_user_id, _ := c.GetInt64("admin_user_id")
  2362. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2363. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2364. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2365. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2366. var dat map[string]interface{}
  2367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2368. fmt.Println(dat)
  2369. } else {
  2370. fmt.Println(err)
  2371. }
  2372. userJSONBytes, _ := json.Marshal(dat)
  2373. var res Result90100
  2374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2375. utils.ErrorLog("解析失败:%v", err)
  2376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2377. return
  2378. }
  2379. if res.Infcode != 0 {
  2380. c.ServeSuccessJSON(map[string]interface{}{
  2381. "failed_code": -10,
  2382. "msg": res.ErrMsg,
  2383. })
  2384. return
  2385. } else {
  2386. fmt.Println(res)
  2387. }
  2388. }
  2389. func (c *HisApiController) CheckCardPWD() {
  2390. card_pwd := c.GetString("card_pwd")
  2391. his_patient_id, _ := c.GetInt64("his_patient_id")
  2392. admin_user_id, _ := c.GetInt64("admin_user_id")
  2393. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2394. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2395. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2396. psn, _ := service.GetPsnByPatientId(his.PatientId)
  2397. bas := strings.Split(psn.CardInfo, "|")
  2398. basNumber := bas[2]
  2399. if psn.InsuplcAdmdvs[:4] == "4403" {
  2400. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  2401. var dat map[string]interface{}
  2402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2403. fmt.Println(dat)
  2404. } else {
  2405. fmt.Println(err)
  2406. }
  2407. userJSONBytes, _ := json.Marshal(dat)
  2408. var res Result90991
  2409. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2410. utils.ErrorLog("解析失败:%v", err)
  2411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2412. return
  2413. }
  2414. if res.Infcode != 0 {
  2415. c.ServeSuccessJSON(map[string]interface{}{
  2416. "failed_code": -10,
  2417. "msg": res.ErrMsg,
  2418. })
  2419. return
  2420. } else {
  2421. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  2422. var msg string
  2423. switch res.Output.Result.CardStat {
  2424. case "00":
  2425. msg = "未激活"
  2426. break
  2427. case "10":
  2428. msg = "激活"
  2429. break
  2430. case "20":
  2431. msg = "窗口挂失"
  2432. break
  2433. case "21":
  2434. msg = "电话挂失"
  2435. break
  2436. case "22":
  2437. msg = "单位网上申报挂失"
  2438. break
  2439. case "23":
  2440. msg = "保健办挂失"
  2441. break
  2442. case "24":
  2443. msg = "个人网上挂失"
  2444. break
  2445. case "25":
  2446. msg = "网上服务大厅挂失"
  2447. break
  2448. case "30":
  2449. msg = "注销"
  2450. break
  2451. case "40":
  2452. msg = "回收"
  2453. break
  2454. case "99":
  2455. msg = "制卡中(无效卡)"
  2456. break
  2457. }
  2458. c.ServeSuccessJSON(map[string]interface{}{
  2459. "failed_code": -10,
  2460. "msg": msg,
  2461. })
  2462. return
  2463. } else {
  2464. c.ServeSuccessJSON(map[string]interface{}{
  2465. "msg": "校验成功",
  2466. })
  2467. return
  2468. }
  2469. }
  2470. } else {
  2471. c.ServeSuccessJSON(map[string]interface{}{
  2472. "msg": "校验成功",
  2473. })
  2474. return
  2475. }
  2476. }
  2477. func (c *HisApiController) CheckCardPWDTwo() {
  2478. //card_pwd := c.GetString("card_pwd")
  2479. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2480. admin_user_id, _ := c.GetInt64("admin_user_id")
  2481. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2482. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2483. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  2484. var dat map[string]interface{}
  2485. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2486. fmt.Println(dat)
  2487. } else {
  2488. fmt.Println(err)
  2489. }
  2490. userJSONBytes, _ := json.Marshal(dat)
  2491. var res Result90991
  2492. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2493. utils.ErrorLog("解析失败:%v", err)
  2494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2495. return
  2496. }
  2497. if res.Infcode != 0 {
  2498. c.ServeSuccessJSON(map[string]interface{}{
  2499. "failed_code": -10,
  2500. "msg": res.ErrMsg,
  2501. })
  2502. return
  2503. } else {
  2504. if res.Output.Result.SscnoCheckStat == "0" {
  2505. var msg string
  2506. switch res.Output.Result.CardStat {
  2507. case "00":
  2508. msg = "未激活"
  2509. break
  2510. case "10":
  2511. msg = "激活"
  2512. break
  2513. case "20":
  2514. msg = "窗口挂失"
  2515. break
  2516. case "21":
  2517. msg = "电话挂失"
  2518. break
  2519. case "22":
  2520. msg = "单位网上申报挂失"
  2521. break
  2522. case "23":
  2523. msg = "保健办挂失"
  2524. break
  2525. case "24":
  2526. msg = "个人网上挂失"
  2527. break
  2528. case "25":
  2529. msg = "网上服务大厅挂失"
  2530. break
  2531. case "30":
  2532. msg = "注销"
  2533. break
  2534. case "40":
  2535. msg = "回收"
  2536. break
  2537. case "99":
  2538. msg = "制卡中(无效卡)"
  2539. break
  2540. }
  2541. c.ServeSuccessJSON(map[string]interface{}{
  2542. "failed_code": -10,
  2543. "msg": msg,
  2544. })
  2545. return
  2546. } else {
  2547. c.ServeSuccessJSON(map[string]interface{}{
  2548. "msg": "校验成功",
  2549. })
  2550. return
  2551. }
  2552. }
  2553. }
  2554. type ELeCertData struct {
  2555. Data struct {
  2556. Extra string `json:"extra"`
  2557. IDNo string `json:"idNo"`
  2558. IDType string `json:"idType"`
  2559. EcToken string `json:"ecToken"`
  2560. InsuOrg string `json:"insuOrg"`
  2561. UserName string `json:"userName"`
  2562. EcIndexNo string `json:"ecIndexNo"`
  2563. Gender string `json:"gender"`
  2564. Birthday string `json:"birthday"`
  2565. Nationality string `json:"nationality"`
  2566. Email string `json:"email"`
  2567. } `json:"OutData"`
  2568. }
  2569. func (c *HisApiController) ReadCard() {
  2570. id_card_type, _ := c.GetInt64("id_card_type")
  2571. admin_user_id, _ := c.GetInt64("admin_user_id")
  2572. certificates, _ := c.GetInt64("certificates")
  2573. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  2574. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2575. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2576. switch id_card_type {
  2577. case 1:
  2578. if miConfig.MdtrtareaAdmvs == "421300" {
  2579. var res ResultTwo
  2580. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  2581. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2582. "&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)
  2583. resp, requestErr := http.Get(api)
  2584. if requestErr != nil {
  2585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2586. return
  2587. }
  2588. body, ioErr := ioutil.ReadAll(resp.Body)
  2589. if ioErr != nil {
  2590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2592. return
  2593. }
  2594. var respJSON map[string]interface{}
  2595. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2598. return
  2599. }
  2600. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2601. result, _ := json.Marshal(respJSON)
  2602. fmt.Println("log")
  2603. fmt.Println(string(result))
  2604. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2605. utils.ErrorLog("解析失败:%v", err)
  2606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2607. return
  2608. }
  2609. if res.Infcode == 0 {
  2610. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2611. if err == gorm.ErrRecordNotFound {
  2612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2613. return
  2614. } else if err != nil {
  2615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2616. return
  2617. } else {
  2618. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2619. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2620. infoStr := string(Iinfos)
  2621. idetinfoStr := string(Idetinfos)
  2622. psn := &models.HisPsn{
  2623. PsnNo: res.Output.Baseinfo.PsnNo,
  2624. Age: res.Output.Baseinfo.Age,
  2625. PatientId: patient.ID,
  2626. Certno: res.Output.Baseinfo.Certno,
  2627. Brdy: res.Output.Baseinfo.Brdy,
  2628. Gend: res.Output.Baseinfo.Gend,
  2629. Naty: res.Output.Baseinfo.Naty,
  2630. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2631. PsnName: res.Output.Baseinfo.PsnName,
  2632. Idetinfo: idetinfoStr,
  2633. Insuinfo: infoStr,
  2634. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2635. }
  2636. service.CreateHisPsn(psn)
  2637. c.ServeSuccessJSON(map[string]interface{}{
  2638. "patient": patient,
  2639. "number": res.Output.Baseinfo.Certno,
  2640. })
  2641. }
  2642. } else {
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2644. return
  2645. }
  2646. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2647. var api string
  2648. if miConfig.MdtrtareaAdmvs == "320921" {
  2649. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  2650. "&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
  2651. fmt.Println(api)
  2652. } else {
  2653. 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 +
  2654. "&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)
  2655. }
  2656. resp, requestErr := http.Get(api)
  2657. if requestErr != nil {
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. body, ioErr := ioutil.ReadAll(resp.Body)
  2662. if ioErr != nil {
  2663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. var respJSON map[string]interface{}
  2668. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2671. return
  2672. }
  2673. var status string
  2674. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2675. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2676. //console.log()
  2677. fmt.Println("type===")
  2678. fmt.Println(card_type)
  2679. var token string
  2680. var res ResultTwo //1101结果
  2681. var res10265 ResultTwo10265 //1101结果
  2682. var card_info string //卡信息
  2683. var busi_card_info string
  2684. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2685. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2686. if status == "0" { //读卡成功
  2687. if card_type == "1" {
  2688. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2689. result, _ := json.Marshal(respJSON)
  2690. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2691. utils.ErrorLog("解析失败:%v", err)
  2692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2693. return
  2694. }
  2695. res.ErrMsg = res10265.ErrMsg
  2696. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2697. res.Infcode = infocode
  2698. res.Output = res10265.Output
  2699. res.InfRefmsgid = res10265.InfRefmsgid
  2700. } else {
  2701. //var card_info string //卡信息
  2702. //var busi_card_info string
  2703. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2704. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2705. //fmt.Println(card_info)
  2706. //fmt.Println(busi_card_info)
  2707. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2708. result, _ := json.Marshal(respJSON)
  2709. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2710. utils.ErrorLog("解析失败:%v", err)
  2711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2712. return
  2713. }
  2714. res.ErrMsg = res10265.ErrMsg
  2715. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2716. res.Infcode = infocode
  2717. res.Output = res10265.Output
  2718. res.InfRefmsgid = res10265.InfRefmsgid
  2719. }
  2720. if res.Infcode == 0 {
  2721. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2722. if err == gorm.ErrRecordNotFound {
  2723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2724. return
  2725. } else if err != nil {
  2726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2727. return
  2728. } else {
  2729. if card_type == "1" {
  2730. bas := strings.Split(card_info, "|")
  2731. basNumber := bas[2]
  2732. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2733. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2734. infoStr := string(Iinfos)
  2735. idetinfoStr := string(Idetinfos)
  2736. psn := &models.HisPsn{
  2737. PsnNo: res.Output.Baseinfo.PsnNo,
  2738. Age: res.Output.Baseinfo.Age,
  2739. PatientId: patient.ID,
  2740. Certno: res.Output.Baseinfo.Certno,
  2741. Brdy: res.Output.Baseinfo.Brdy,
  2742. Gend: res.Output.Baseinfo.Gend,
  2743. Naty: res.Output.Baseinfo.Naty,
  2744. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2745. PsnName: res.Output.Baseinfo.PsnName,
  2746. Idetinfo: idetinfoStr,
  2747. Insuinfo: infoStr,
  2748. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2749. CardInfo: card_info,
  2750. VerifyNumber: busi_card_info,
  2751. }
  2752. service.CreateHisPsn(psn)
  2753. var rf []*ResultFive
  2754. json.Unmarshal([]byte(infoStr), &rf)
  2755. var insutypes []*ResultFive
  2756. var insutype string
  2757. var is390 int = 0
  2758. var is310 int = 0
  2759. for _, item := range rf {
  2760. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2761. insutypes = append(insutypes, item)
  2762. }
  2763. }
  2764. if len(insutypes) == 1 {
  2765. insutype = insutypes[0].Insutype
  2766. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2767. } else {
  2768. for _, i := range insutypes {
  2769. if i.Insutype == "390" {
  2770. is390 = 1
  2771. }
  2772. if i.Insutype == "310" {
  2773. is310 = 1
  2774. }
  2775. }
  2776. }
  2777. if is390 == 1 {
  2778. insutype = "390"
  2779. }
  2780. if is310 == 1 {
  2781. insutype = "310"
  2782. }
  2783. if len(insutypes) == 0 {
  2784. insutype = "310"
  2785. }
  2786. c.ServeSuccessJSON(map[string]interface{}{
  2787. "patient": patient,
  2788. "number": basNumber,
  2789. "insutype": insutype,
  2790. })
  2791. } else {
  2792. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2793. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2794. infoStr := string(Iinfos)
  2795. idetinfoStr := string(Idetinfos)
  2796. psn := &models.HisPsn{
  2797. PsnNo: res.Output.Baseinfo.PsnNo,
  2798. Age: res.Output.Baseinfo.Age,
  2799. PatientId: patient.ID,
  2800. Certno: res.Output.Baseinfo.Certno,
  2801. Brdy: res.Output.Baseinfo.Brdy,
  2802. Gend: res.Output.Baseinfo.Gend,
  2803. Naty: res.Output.Baseinfo.Naty,
  2804. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2805. PsnName: res.Output.Baseinfo.PsnName,
  2806. Idetinfo: idetinfoStr,
  2807. Insuinfo: infoStr,
  2808. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2809. CardInfo: card_info,
  2810. VerifyNumber: token,
  2811. }
  2812. service.CreateHisPsn(psn)
  2813. c.ServeSuccessJSON(map[string]interface{}{
  2814. "patient": patient,
  2815. "number": token,
  2816. })
  2817. }
  2818. }
  2819. } else {
  2820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2821. return
  2822. }
  2823. } else { //读卡失败
  2824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2825. return
  2826. }
  2827. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2828. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2829. cardnum = DeleteExtraSpaceTwo(cardnum)
  2830. cardCode = DeleteExtraSpaceTwo(cardCode)
  2831. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2832. name = DeleteExtraSpaceTwo(name)
  2833. errmsg = DeleteExtraSpaceTwo(errmsg)
  2834. cardnum = Remove0000(cardnum)
  2835. cardCode = Remove0000(cardCode)
  2836. id_card_no = Remove0000(id_card_no)
  2837. name = Remove0000(name)
  2838. errmsg = Remove0000(errmsg)
  2839. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  2840. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2841. //result2, requestLog2, errMsgLog2 := service.FJybidcomfirm(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  2842. //fmt.Println(result2)
  2843. //fmt.Println(requestLog2)
  2844. //fmt.Println(errMsgLog2)
  2845. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, "", miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name, id_card_no)
  2846. saveLog(result, requestLog, "1101", "获取人员信息")
  2847. fmt.Println(errMsgLog)
  2848. if len(errMsgLog) > 0 {
  2849. } else {
  2850. var dat map[string]interface{}
  2851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2852. fmt.Println(dat)
  2853. } else {
  2854. fmt.Println(err)
  2855. }
  2856. userJSONBytes, _ := json.Marshal(dat)
  2857. var res ResultTwo
  2858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2859. utils.ErrorLog("解析失败:%v", err)
  2860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2861. return
  2862. }
  2863. res.ErrMsg = errMsgLog
  2864. if res.Infcode == 0 {
  2865. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2866. if err == gorm.ErrRecordNotFound {
  2867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2868. return
  2869. } else if err != nil {
  2870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2871. return
  2872. } else {
  2873. fmt.Println(res)
  2874. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2875. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2876. infoStr := string(Iinfos)
  2877. idetinfoStr := string(Idetinfos)
  2878. var rf []*ResultFive
  2879. json.Unmarshal([]byte(infoStr), &rf)
  2880. var insutypes []*ResultFive
  2881. var insutype string
  2882. var is390 int = 0
  2883. var is310 int = 0
  2884. for _, item := range rf {
  2885. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2886. insutypes = append(insutypes, item)
  2887. }
  2888. }
  2889. if len(insutypes) == 1 {
  2890. insutype = insutypes[0].Insutype
  2891. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2892. } else {
  2893. for _, i := range insutypes {
  2894. if i.Insutype == "390" {
  2895. is390 = 1
  2896. }
  2897. if i.Insutype == "310" {
  2898. is310 = 1
  2899. }
  2900. }
  2901. }
  2902. if is390 == 1 {
  2903. insutype = "390"
  2904. }
  2905. if is310 == 1 {
  2906. insutype = "310"
  2907. }
  2908. if len(insutypes) == 0 {
  2909. insutype = "390"
  2910. }
  2911. var insuplc_admdvs string
  2912. for _, item := range rf {
  2913. if item.Insutype == insutype {
  2914. insuplc_admdvs = item.InsuplcAdmdvs
  2915. }
  2916. }
  2917. psn := &models.HisPsn{
  2918. PsnNo: res.Output.Baseinfo.PsnNo,
  2919. Age: res.Output.Baseinfo.Age,
  2920. PatientId: patient.ID,
  2921. Certno: res.Output.Baseinfo.Certno,
  2922. Brdy: res.Output.Baseinfo.Brdy,
  2923. Gend: res.Output.Baseinfo.Gend,
  2924. Naty: res.Output.Baseinfo.Naty,
  2925. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2926. PsnName: res.Output.Baseinfo.PsnName,
  2927. Idetinfo: idetinfoStr,
  2928. Insuinfo: infoStr,
  2929. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2930. CardInfo: basStr,
  2931. VerifyNumber: "",
  2932. InsuplcAdmdvs: insuplc_admdvs,
  2933. }
  2934. service.CreateHisPsn(psn)
  2935. c.ServeSuccessJSON(map[string]interface{}{
  2936. "patient": patient,
  2937. "number": cardnum,
  2938. "insutype": insutype,
  2939. })
  2940. }
  2941. } else {
  2942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2943. return
  2944. }
  2945. }
  2946. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2947. fmt.Println(initFlag)
  2948. fmt.Println("initFlag")
  2949. if initFlag == 0 {
  2950. c.TestGetJiangXiBasBaseInit()
  2951. }
  2952. basStr := c.GetBasBaseInfo()
  2953. if len(basStr) == 0 {
  2954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2955. return
  2956. }
  2957. fmt.Println(basStr)
  2958. bas := strings.Split(basStr, "|")
  2959. basNumber := bas[1]
  2960. fmt.Println(basNumber)
  2961. card_sn := bas[3]
  2962. fmt.Println(card_sn)
  2963. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  2964. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2965. var dat map[string]interface{}
  2966. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2967. fmt.Println(dat)
  2968. } else {
  2969. fmt.Println(err)
  2970. }
  2971. userJSONBytes, _ := json.Marshal(dat)
  2972. var res ResultTwo
  2973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2974. utils.ErrorLog("解析失败:%v", err)
  2975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2976. return
  2977. }
  2978. if res.Infcode == 0 {
  2979. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2980. if err == gorm.ErrRecordNotFound {
  2981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2982. return
  2983. } else if err != nil {
  2984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2985. return
  2986. } else {
  2987. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2988. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2989. infoStr := string(Iinfos)
  2990. idetinfoStr := string(Idetinfos)
  2991. psn := &models.HisPsn{
  2992. PsnNo: res.Output.Baseinfo.PsnNo,
  2993. Age: res.Output.Baseinfo.Age,
  2994. PatientId: patient.ID,
  2995. Certno: res.Output.Baseinfo.Certno,
  2996. Brdy: res.Output.Baseinfo.Brdy,
  2997. Gend: res.Output.Baseinfo.Gend,
  2998. Naty: res.Output.Baseinfo.Naty,
  2999. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3000. PsnName: res.Output.Baseinfo.PsnName,
  3001. Idetinfo: idetinfoStr,
  3002. Insuinfo: infoStr,
  3003. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3004. CardInfo: basStr,
  3005. VerifyNumber: "",
  3006. }
  3007. service.CreateHisPsn(psn)
  3008. var rf []*ResultFive
  3009. json.Unmarshal([]byte(infoStr), &rf)
  3010. var insutypes []*ResultFive
  3011. var insutype string
  3012. var is390 int = 0
  3013. var is310 int = 0
  3014. for _, item := range rf {
  3015. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3016. insutypes = append(insutypes, item)
  3017. }
  3018. }
  3019. if len(insutypes) == 1 {
  3020. insutype = insutypes[0].Insutype
  3021. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3022. } else {
  3023. for _, i := range insutypes {
  3024. if i.Insutype == "390" {
  3025. is390 = 1
  3026. }
  3027. if i.Insutype == "310" {
  3028. is310 = 1
  3029. }
  3030. }
  3031. }
  3032. if is390 == 1 {
  3033. insutype = "390"
  3034. }
  3035. if is310 == 1 {
  3036. insutype = "310"
  3037. }
  3038. if len(insutypes) == 0 {
  3039. insutype = "310"
  3040. }
  3041. c.ServeSuccessJSON(map[string]interface{}{
  3042. "patient": patient,
  3043. "number": basNumber,
  3044. "insutype": insutype,
  3045. })
  3046. }
  3047. } else {
  3048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3049. return
  3050. }
  3051. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3052. fmt.Println(initFlag)
  3053. fmt.Println("initFlag")
  3054. if initFlag == 0 {
  3055. c.TestGetHnBasBaseInit()
  3056. }
  3057. basStr := c.GetBasBaseInfo()
  3058. if len(basStr) == 0 {
  3059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3060. return
  3061. }
  3062. fmt.Println(basStr)
  3063. bas := strings.Split(basStr, "|")
  3064. basNumber := bas[1]
  3065. fmt.Println(basNumber)
  3066. card_sn := bas[3]
  3067. card_no := bas[2]
  3068. fmt.Println(card_sn)
  3069. name := bas[4]
  3070. name = ConvertToString(name, "gbk", "utf-8")
  3071. result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
  3072. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3073. var dat map[string]interface{}
  3074. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3075. fmt.Println(dat)
  3076. } else {
  3077. fmt.Println(err)
  3078. }
  3079. userJSONBytes, _ := json.Marshal(dat)
  3080. var res ResultTwo
  3081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3082. utils.ErrorLog("解析失败:%v", err)
  3083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3084. return
  3085. }
  3086. if res.Infcode == 0 {
  3087. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3088. if err == gorm.ErrRecordNotFound {
  3089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3090. return
  3091. } else if err != nil {
  3092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3093. return
  3094. } else {
  3095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3096. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3097. infoStr := string(Iinfos)
  3098. idetinfoStr := string(Idetinfos)
  3099. psn := &models.HisPsn{
  3100. PsnNo: res.Output.Baseinfo.PsnNo,
  3101. Age: res.Output.Baseinfo.Age,
  3102. PatientId: patient.ID,
  3103. Certno: res.Output.Baseinfo.Certno,
  3104. Brdy: res.Output.Baseinfo.Brdy,
  3105. Gend: res.Output.Baseinfo.Gend,
  3106. Naty: res.Output.Baseinfo.Naty,
  3107. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3108. PsnName: res.Output.Baseinfo.PsnName,
  3109. Idetinfo: idetinfoStr,
  3110. Insuinfo: infoStr,
  3111. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3112. CardInfo: basStr,
  3113. VerifyNumber: "",
  3114. }
  3115. service.CreateHisPsn(psn)
  3116. var rf []*ResultFive
  3117. json.Unmarshal([]byte(infoStr), &rf)
  3118. var insutypes []*ResultFive
  3119. var insutype string
  3120. var is390 int = 0
  3121. var is310 int = 0
  3122. for _, item := range rf {
  3123. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3124. insutypes = append(insutypes, item)
  3125. }
  3126. }
  3127. if len(insutypes) == 1 {
  3128. insutype = insutypes[0].Insutype
  3129. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3130. } else {
  3131. for _, i := range insutypes {
  3132. if i.Insutype == "390" {
  3133. is390 = 1
  3134. }
  3135. if i.Insutype == "310" {
  3136. is310 = 1
  3137. }
  3138. }
  3139. }
  3140. if is390 == 1 {
  3141. insutype = "390"
  3142. }
  3143. if is310 == 1 {
  3144. insutype = "310"
  3145. }
  3146. if len(insutypes) == 0 {
  3147. insutype = "310"
  3148. }
  3149. c.ServeSuccessJSON(map[string]interface{}{
  3150. "patient": patient,
  3151. "number": basNumber,
  3152. "insutype": insutype,
  3153. })
  3154. }
  3155. } else {
  3156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3157. return
  3158. }
  3159. } else {
  3160. if initFlag == 0 {
  3161. c.TestGetBasBaseInit()
  3162. }
  3163. basStr := c.GetBasBaseInfo()
  3164. if len(basStr) == 0 {
  3165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3166. return
  3167. }
  3168. fmt.Println(basStr)
  3169. bas := strings.Split(basStr, "|")
  3170. basNumber := bas[1]
  3171. fmt.Println(basNumber)
  3172. card_sn := bas[3]
  3173. fmt.Println(card_sn)
  3174. cardNumber := bas[2]
  3175. fmt.Println(cardNumber)
  3176. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  3177. var result string
  3178. if bas[0][:2] == "44" {
  3179. result = service.Gdyb1101f(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  3180. } else {
  3181. result = service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  3182. }
  3183. var dat map[string]interface{}
  3184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3185. fmt.Println(dat)
  3186. } else {
  3187. fmt.Println(err)
  3188. }
  3189. userJSONBytes, _ := json.Marshal(dat)
  3190. var res ResultTwo
  3191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3192. utils.ErrorLog("解析失败:%v", err)
  3193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3194. return
  3195. }
  3196. if res.Infcode == 0 {
  3197. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3198. if err == gorm.ErrRecordNotFound {
  3199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3200. return
  3201. } else if err != nil {
  3202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3203. return
  3204. } else {
  3205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3207. infoStr := string(Iinfos)
  3208. idetinfoStr := string(Idetinfos)
  3209. var rf []*ResultFive
  3210. json.Unmarshal([]byte(infoStr), &rf)
  3211. var insutypes []*ResultFive
  3212. var insutype string
  3213. var is390 int = 0
  3214. var is310 int = 0
  3215. var insuplc_admdvs string
  3216. for _, item := range rf {
  3217. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3218. insutypes = append(insutypes, item)
  3219. }
  3220. }
  3221. if len(insutypes) == 1 {
  3222. insutype = insutypes[0].Insutype
  3223. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3224. } else {
  3225. for _, i := range insutypes {
  3226. if i.Insutype == "390" {
  3227. is390 = 1
  3228. }
  3229. if i.Insutype == "310" {
  3230. is310 = 1
  3231. }
  3232. }
  3233. }
  3234. if is390 == 1 {
  3235. insutype = "390"
  3236. }
  3237. if is310 == 1 {
  3238. insutype = "310"
  3239. }
  3240. if len(insutypes) == 0 {
  3241. insutype = "310"
  3242. }
  3243. for _, item := range rf {
  3244. if item.Insutype == insutype {
  3245. insuplc_admdvs = item.InsuplcAdmdvs
  3246. }
  3247. }
  3248. psn := &models.HisPsn{
  3249. PsnNo: res.Output.Baseinfo.PsnNo,
  3250. Age: res.Output.Baseinfo.Age,
  3251. PatientId: patient.ID,
  3252. Certno: res.Output.Baseinfo.Certno,
  3253. Brdy: res.Output.Baseinfo.Brdy,
  3254. Gend: res.Output.Baseinfo.Gend,
  3255. Naty: res.Output.Baseinfo.Naty,
  3256. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3257. PsnName: res.Output.Baseinfo.PsnName,
  3258. Idetinfo: idetinfoStr,
  3259. Insuinfo: infoStr,
  3260. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3261. CardInfo: basStr,
  3262. VerifyNumber: "",
  3263. InsuplcAdmdvs: insuplc_admdvs,
  3264. }
  3265. service.CreateHisPsn(psn)
  3266. c.ServeSuccessJSON(map[string]interface{}{
  3267. "patient": patient,
  3268. "number": basNumber,
  3269. })
  3270. }
  3271. } else {
  3272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3273. return
  3274. }
  3275. break
  3276. }
  3277. case 2:
  3278. if miConfig.MdtrtareaAdmvs == "430800" {
  3279. if initFlag == 0 {
  3280. c.TestGetHnBasBaseInit()
  3281. }
  3282. SFZStr := c.GetSFZBaseInfo()
  3283. if len(SFZStr) == 0 {
  3284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3285. return
  3286. }
  3287. fmt.Println(SFZStr)
  3288. id_card_str := strings.Split(SFZStr, "^")
  3289. card_no := id_card_str[0]
  3290. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3291. //name := id_card_str[1]
  3292. //name = ConvertToString(name, "gbk", "utf-8")
  3293. result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", patient.Name, card_no)
  3294. var dat map[string]interface{}
  3295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3296. fmt.Println(dat)
  3297. } else {
  3298. fmt.Println(err)
  3299. }
  3300. userJSONBytes, _ := json.Marshal(dat)
  3301. var res ResultTwo
  3302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3303. utils.ErrorLog("解析失败:%v", err)
  3304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3305. return
  3306. }
  3307. if res.Infcode == 0 {
  3308. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3309. if err == gorm.ErrRecordNotFound {
  3310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3311. return
  3312. } else if err != nil {
  3313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3314. return
  3315. } else {
  3316. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3317. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3318. infoStr := string(Iinfos)
  3319. idetinfoStr := string(Idetinfos)
  3320. psn := &models.HisPsn{
  3321. PsnNo: res.Output.Baseinfo.PsnNo,
  3322. Age: res.Output.Baseinfo.Age,
  3323. PatientId: patient.ID,
  3324. Certno: res.Output.Baseinfo.Certno,
  3325. Brdy: res.Output.Baseinfo.Brdy,
  3326. Gend: res.Output.Baseinfo.Gend,
  3327. Naty: res.Output.Baseinfo.Naty,
  3328. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3329. PsnName: res.Output.Baseinfo.PsnName,
  3330. Idetinfo: idetinfoStr,
  3331. Insuinfo: infoStr,
  3332. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3333. CardInfo: SFZStr,
  3334. VerifyNumber: "",
  3335. }
  3336. service.CreateHisPsn(psn)
  3337. var rf []*ResultFive
  3338. json.Unmarshal([]byte(infoStr), &rf)
  3339. var insutypes []*ResultFive
  3340. var insutype string
  3341. var is390 int = 0
  3342. var is310 int = 0
  3343. for _, item := range rf {
  3344. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3345. insutypes = append(insutypes, item)
  3346. }
  3347. }
  3348. if len(insutypes) == 1 {
  3349. insutype = insutypes[0].Insutype
  3350. } else {
  3351. for _, i := range insutypes {
  3352. if i.Insutype == "390" {
  3353. is390 = 1
  3354. }
  3355. if i.Insutype == "310" {
  3356. is310 = 1
  3357. }
  3358. }
  3359. }
  3360. if is390 == 1 {
  3361. insutype = "390"
  3362. }
  3363. if is310 == 1 {
  3364. insutype = "310"
  3365. }
  3366. if len(insutypes) == 0 {
  3367. insutype = "310"
  3368. }
  3369. c.ServeSuccessJSON(map[string]interface{}{
  3370. "patient": patient,
  3371. "number": card_no,
  3372. "insutype": insutype,
  3373. })
  3374. }
  3375. } else {
  3376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3377. return
  3378. }
  3379. } else {
  3380. SFZStr := c.GetSFZBaseInfo()
  3381. id_card_str := strings.Split(SFZStr, "^")
  3382. id_card_number := id_card_str[0]
  3383. card_sn := ""
  3384. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  3385. var dat map[string]interface{}
  3386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3387. fmt.Println(dat)
  3388. } else {
  3389. fmt.Println(err)
  3390. }
  3391. userJSONBytes, _ := json.Marshal(dat)
  3392. var res ResultTwo
  3393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3394. utils.ErrorLog("解析失败:%v", err)
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3396. return
  3397. }
  3398. if res.Infcode == 0 {
  3399. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  3400. if err == gorm.ErrRecordNotFound {
  3401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3402. return
  3403. } else if err != nil {
  3404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3405. return
  3406. } else {
  3407. c.ServeSuccessJSON(map[string]interface{}{
  3408. "patient": patient,
  3409. "number": id_card_number,
  3410. })
  3411. }
  3412. } else {
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3414. return
  3415. }
  3416. }
  3417. break
  3418. case 3:
  3419. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3420. var api string
  3421. if miConfig.MdtrtareaAdmvs == "320921" {
  3422. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3423. "&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
  3424. fmt.Println(api)
  3425. } else {
  3426. 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 +
  3427. "&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)
  3428. }
  3429. resp, requestErr := http.Get(api)
  3430. if requestErr != nil {
  3431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3432. return
  3433. }
  3434. body, ioErr := ioutil.ReadAll(resp.Body)
  3435. if ioErr != nil {
  3436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3438. return
  3439. }
  3440. var respJSON map[string]interface{}
  3441. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3444. return
  3445. }
  3446. var status string
  3447. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3448. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3449. var token string
  3450. var res ResultTwo //1101结果
  3451. var res10265 ResultTwo10265 //1101结果
  3452. var card_info string //卡信息
  3453. var busi_card_info string
  3454. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3455. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3456. if status == "0" { //读卡成功
  3457. if card_type == "1" {
  3458. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3459. result, _ := json.Marshal(respJSON)
  3460. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3461. utils.ErrorLog("解析失败:%v", err)
  3462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3463. return
  3464. }
  3465. res.ErrMsg = res10265.ErrMsg
  3466. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3467. res.Infcode = infocode
  3468. res.Output = res10265.Output
  3469. res.InfRefmsgid = res10265.InfRefmsgid
  3470. } else {
  3471. //var card_info string //卡信息
  3472. //var busi_card_info string
  3473. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3474. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3475. //fmt.Println(card_info)
  3476. //fmt.Println(busi_card_info)
  3477. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3478. result, _ := json.Marshal(respJSON)
  3479. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3480. utils.ErrorLog("解析失败:%v", err)
  3481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3482. return
  3483. }
  3484. res.ErrMsg = res10265.ErrMsg
  3485. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3486. res.Infcode = infocode
  3487. res.Output = res10265.Output
  3488. res.InfRefmsgid = res10265.InfRefmsgid
  3489. }
  3490. if res.Infcode == 0 {
  3491. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3492. if err == gorm.ErrRecordNotFound {
  3493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3494. return
  3495. } else if err != nil {
  3496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3497. return
  3498. } else {
  3499. if card_type == "1" {
  3500. bas := strings.Split(card_info, "|")
  3501. basNumber := bas[2]
  3502. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3503. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3504. infoStr := string(Iinfos)
  3505. idetinfoStr := string(Idetinfos)
  3506. psn := &models.HisPsn{
  3507. PsnNo: res.Output.Baseinfo.PsnNo,
  3508. Age: res.Output.Baseinfo.Age,
  3509. PatientId: patient.ID,
  3510. Certno: res.Output.Baseinfo.Certno,
  3511. Brdy: res.Output.Baseinfo.Brdy,
  3512. Gend: res.Output.Baseinfo.Gend,
  3513. Naty: res.Output.Baseinfo.Naty,
  3514. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3515. PsnName: res.Output.Baseinfo.PsnName,
  3516. Idetinfo: idetinfoStr,
  3517. Insuinfo: infoStr,
  3518. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3519. CardInfo: card_info,
  3520. VerifyNumber: busi_card_info,
  3521. }
  3522. service.CreateHisPsn(psn)
  3523. c.ServeSuccessJSON(map[string]interface{}{
  3524. "patient": patient,
  3525. "number": basNumber,
  3526. })
  3527. } else {
  3528. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3529. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3530. infoStr := string(Iinfos)
  3531. idetinfoStr := string(Idetinfos)
  3532. psn := &models.HisPsn{
  3533. PsnNo: res.Output.Baseinfo.PsnNo,
  3534. Age: res.Output.Baseinfo.Age,
  3535. PatientId: patient.ID,
  3536. Certno: res.Output.Baseinfo.Certno,
  3537. Brdy: res.Output.Baseinfo.Brdy,
  3538. Gend: res.Output.Baseinfo.Gend,
  3539. Naty: res.Output.Baseinfo.Naty,
  3540. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3541. PsnName: res.Output.Baseinfo.PsnName,
  3542. Idetinfo: idetinfoStr,
  3543. Insuinfo: infoStr,
  3544. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3545. CardInfo: card_info,
  3546. VerifyNumber: token,
  3547. }
  3548. service.CreateHisPsn(psn)
  3549. var rf []*ResultFive
  3550. json.Unmarshal([]byte(infoStr), &rf)
  3551. var insutypes []*ResultFive
  3552. var insutype string
  3553. var is390 int = 0
  3554. var is310 int = 0
  3555. for _, item := range rf {
  3556. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3557. insutypes = append(insutypes, item)
  3558. }
  3559. }
  3560. if len(insutypes) == 1 {
  3561. insutype = insutypes[0].Insutype
  3562. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3563. } else {
  3564. for _, i := range insutypes {
  3565. if i.Insutype == "390" {
  3566. is390 = 1
  3567. }
  3568. if i.Insutype == "310" {
  3569. is310 = 1
  3570. }
  3571. }
  3572. }
  3573. if is390 == 1 {
  3574. insutype = "390"
  3575. }
  3576. if is310 == 1 {
  3577. insutype = "310"
  3578. }
  3579. if len(insutypes) == 0 {
  3580. insutype = "310"
  3581. }
  3582. c.ServeSuccessJSON(map[string]interface{}{
  3583. "patient": patient,
  3584. "number": token,
  3585. "insutype": insutype,
  3586. })
  3587. }
  3588. }
  3589. } else {
  3590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3591. return
  3592. }
  3593. } else { //读卡失败
  3594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3595. return
  3596. }
  3597. }
  3598. break
  3599. case 4:
  3600. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3601. var api string
  3602. if miConfig.MdtrtareaAdmvs == "320921" {
  3603. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3604. "&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
  3605. fmt.Println(api)
  3606. } else {
  3607. 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 +
  3608. "&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)
  3609. }
  3610. resp, requestErr := http.Get(api)
  3611. if requestErr != nil {
  3612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3613. return
  3614. }
  3615. body, ioErr := ioutil.ReadAll(resp.Body)
  3616. if ioErr != nil {
  3617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3619. return
  3620. }
  3621. var respJSON map[string]interface{}
  3622. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3625. return
  3626. }
  3627. var status string
  3628. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3629. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3630. var token string
  3631. var res ResultTwo //1101结果
  3632. var res10265 ResultTwo10265 //1101结果
  3633. if status == "0" { //读卡成功
  3634. var card_info string //卡信息
  3635. var busi_card_info string
  3636. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3637. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3638. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3639. fmt.Println(card_info)
  3640. fmt.Println(busi_card_info)
  3641. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3642. result, _ := json.Marshal(respJSON)
  3643. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3644. utils.ErrorLog("解析失败:%v", err)
  3645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3646. return
  3647. }
  3648. res.ErrMsg = res10265.ErrMsg
  3649. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3650. res.Infcode = infocode
  3651. res.Output = res10265.Output
  3652. res.InfRefmsgid = res10265.InfRefmsgid
  3653. if res.Infcode == 0 {
  3654. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3655. if err == gorm.ErrRecordNotFound {
  3656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3657. return
  3658. } else if err != nil {
  3659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3660. return
  3661. } else {
  3662. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3663. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3664. infoStr := string(Iinfos)
  3665. idetinfoStr := string(Idetinfos)
  3666. psn := &models.HisPsn{
  3667. PsnNo: res.Output.Baseinfo.PsnNo,
  3668. Age: res.Output.Baseinfo.Age,
  3669. PatientId: patient.ID,
  3670. Certno: res.Output.Baseinfo.Certno,
  3671. Brdy: res.Output.Baseinfo.Brdy,
  3672. Gend: res.Output.Baseinfo.Gend,
  3673. Naty: res.Output.Baseinfo.Naty,
  3674. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3675. PsnName: res.Output.Baseinfo.PsnName,
  3676. Idetinfo: idetinfoStr,
  3677. Insuinfo: infoStr,
  3678. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3679. CardInfo: card_info,
  3680. VerifyNumber: token,
  3681. }
  3682. var rf []*ResultFive
  3683. json.Unmarshal([]byte(infoStr), &rf)
  3684. var insutypes []*ResultFive
  3685. var insutype string
  3686. var is390 int = 0
  3687. var is310 int = 0
  3688. for _, item := range rf {
  3689. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3690. insutypes = append(insutypes, item)
  3691. }
  3692. }
  3693. if len(insutypes) == 1 {
  3694. insutype = insutypes[0].Insutype
  3695. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3696. } else {
  3697. for _, i := range insutypes {
  3698. if i.Insutype == "390" {
  3699. is390 = 1
  3700. }
  3701. if i.Insutype == "310" {
  3702. is310 = 1
  3703. }
  3704. }
  3705. }
  3706. if is390 == 1 {
  3707. insutype = "390"
  3708. }
  3709. if is310 == 1 {
  3710. insutype = "310"
  3711. }
  3712. if len(insutypes) == 0 {
  3713. insutype = "310"
  3714. }
  3715. service.CreateHisPsn(psn)
  3716. c.ServeSuccessJSON(map[string]interface{}{
  3717. "patient": patient,
  3718. "number": token,
  3719. "insutype": insutype,
  3720. })
  3721. }
  3722. } else {
  3723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3724. return
  3725. }
  3726. } else { //读卡失败
  3727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3728. return
  3729. }
  3730. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3731. _, result := GetHnEleBaseInfo(miConfig.Code, admin_user_id, roles.UserName)
  3732. fmt.Println(result)
  3733. //token = Remove0000(token)
  3734. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  3735. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  3736. ////
  3737. //var res ResultTwo
  3738. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3739. // utils.ErrorLog("解析失败:%v", err)
  3740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3741. // return
  3742. //}
  3743. //
  3744. //if res.Infcode == 0 {
  3745. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3746. // if err == gorm.ErrRecordNotFound {
  3747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3748. // return
  3749. // } else if err != nil {
  3750. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3751. // return
  3752. //
  3753. // } else {
  3754. //
  3755. // //month := time.Unix(1557042972, 0).Format("1")
  3756. // //year := time.Now().Format("2006")
  3757. // //month = time.Now().Format("01")
  3758. // //day := time.Now().Format("02")
  3759. // //date := year+"-"+month+"-"+day + " "+"00:00:00"
  3760. //
  3761. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3762. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3763. // infoStr := string(Iinfos)
  3764. // idetinfoStr := string(Idetinfos)
  3765. // psn := &models.HisPsn{
  3766. // PsnNo: res.Output.Baseinfo.PsnNo,
  3767. // Age: res.Output.Baseinfo.Age,
  3768. // PatientId: patient.ID,
  3769. // Certno: res.Output.Baseinfo.Certno,
  3770. // Brdy: res.Output.Baseinfo.Brdy,
  3771. // Gend: res.Output.Baseinfo.Gend,
  3772. // Naty: res.Output.Baseinfo.Naty,
  3773. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  3774. // PsnName: res.Output.Baseinfo.PsnName,
  3775. // Idetinfo: idetinfoStr,
  3776. // Insuinfo: infoStr,
  3777. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3778. // CardInfo: "",
  3779. // Stage: "1",
  3780. // //RecordDate:
  3781. // VerifyNumber: token,
  3782. // }
  3783. // service.CreateHisPsn(psn)
  3784. //
  3785. // c.ServeSuccessJSON(map[string]interface{}{
  3786. // "patient": patient,
  3787. // "number": token,
  3788. // })
  3789. // }
  3790. //} else {
  3791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3792. // return
  3793. //}
  3794. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3795. //if initFlag == 0 {
  3796. c.TestGetJiangXiBasBaseInit()
  3797. //}
  3798. //if initEleFlag == 0 {
  3799. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3800. //}
  3801. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3802. type ELeData struct {
  3803. Data struct {
  3804. IdNo string `json:"idNo"`
  3805. IdType string `json:"idType"`
  3806. UserName string `json:"userName"`
  3807. EcToken string `json:"ecToken"`
  3808. InsuOrg string `json:"insuOrg"`
  3809. Gender string `json:"gender"`
  3810. Birthday string `json:"birthday"`
  3811. Nationality string `json:"nationality"`
  3812. Email string `json:"email"`
  3813. Extra string `json:"extra"`
  3814. } `json:"data"`
  3815. Code int `json:"code"`
  3816. Message string `json:"message"`
  3817. }
  3818. var ele ELeData
  3819. err := json.Unmarshal([]byte(json_result), &ele)
  3820. if err != nil {
  3821. utils.ErrorLog("解析失败:%v", err)
  3822. }
  3823. token := ele.Data.EcToken
  3824. token = Remove0000(token)
  3825. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  3826. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3827. var res ResultTwo
  3828. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3829. utils.ErrorLog("解析失败:%v", err)
  3830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3831. return
  3832. }
  3833. if res.Infcode == 0 {
  3834. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3835. if err == gorm.ErrRecordNotFound {
  3836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3837. return
  3838. } else if err != nil {
  3839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3840. return
  3841. } else {
  3842. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3843. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3844. infoStr := string(Iinfos)
  3845. idetinfoStr := string(Idetinfos)
  3846. psn := &models.HisPsn{
  3847. PsnNo: res.Output.Baseinfo.PsnNo,
  3848. Age: res.Output.Baseinfo.Age,
  3849. PatientId: patient.ID,
  3850. Certno: res.Output.Baseinfo.Certno,
  3851. Brdy: res.Output.Baseinfo.Brdy,
  3852. Gend: res.Output.Baseinfo.Gend,
  3853. Naty: res.Output.Baseinfo.Naty,
  3854. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3855. PsnName: res.Output.Baseinfo.PsnName,
  3856. Idetinfo: idetinfoStr,
  3857. Insuinfo: infoStr,
  3858. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3859. CardInfo: "",
  3860. //RecordDate:
  3861. VerifyNumber: token,
  3862. }
  3863. service.CreateHisPsn(psn)
  3864. var rf []*ResultFive
  3865. json.Unmarshal([]byte(infoStr), &rf)
  3866. var insutypes []*ResultFive
  3867. var insutype string
  3868. var is390 int = 0
  3869. var is310 int = 0
  3870. for _, item := range rf {
  3871. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3872. insutypes = append(insutypes, item)
  3873. }
  3874. }
  3875. if len(insutypes) == 1 {
  3876. insutype = insutypes[0].Insutype
  3877. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3878. } else {
  3879. for _, i := range insutypes {
  3880. if i.Insutype == "390" {
  3881. is390 = 1
  3882. }
  3883. if i.Insutype == "310" {
  3884. is310 = 1
  3885. }
  3886. }
  3887. }
  3888. if is390 == 1 {
  3889. insutype = "390"
  3890. }
  3891. if is310 == 1 {
  3892. insutype = "310"
  3893. }
  3894. if len(insutypes) == 0 {
  3895. insutype = "310"
  3896. }
  3897. c.ServeSuccessJSON(map[string]interface{}{
  3898. "patient": patient,
  3899. "number": token,
  3900. "insutype": insutype,
  3901. })
  3902. }
  3903. } else {
  3904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3905. return
  3906. }
  3907. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3908. //if initFlag == 0 {
  3909. c.TestGetJiangXiBasBaseInit()
  3910. //}
  3911. //if initEleFlag == 0 {
  3912. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3913. //}
  3914. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3915. type ELeData struct {
  3916. Data struct {
  3917. IdNo string `json:"idNo"`
  3918. IdType string `json:"idType"`
  3919. UserName string `json:"userName"`
  3920. EcToken string `json:"ecToken"`
  3921. InsuOrg string `json:"insuOrg"`
  3922. Gender string `json:"gender"`
  3923. Birthday string `json:"birthday"`
  3924. Nationality string `json:"nationality"`
  3925. Email string `json:"email"`
  3926. Extra string `json:"extra"`
  3927. } `json:"data"`
  3928. Code int `json:"code"`
  3929. Message string `json:"message"`
  3930. }
  3931. var ele ELeData
  3932. err := json.Unmarshal([]byte(json_result), &ele)
  3933. if err != nil {
  3934. utils.ErrorLog("解析失败:%v", err)
  3935. }
  3936. token := ele.Data.EcToken
  3937. token = Remove0000(token)
  3938. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  3939. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3940. var res ResultTwo
  3941. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3942. utils.ErrorLog("解析失败:%v", err)
  3943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3944. return
  3945. }
  3946. if res.Infcode == 0 {
  3947. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3948. if err == gorm.ErrRecordNotFound {
  3949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3950. return
  3951. } else if err != nil {
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3953. return
  3954. } else {
  3955. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3956. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3957. infoStr := string(Iinfos)
  3958. idetinfoStr := string(Idetinfos)
  3959. psn := &models.HisPsn{
  3960. PsnNo: res.Output.Baseinfo.PsnNo,
  3961. Age: res.Output.Baseinfo.Age,
  3962. PatientId: patient.ID,
  3963. Certno: res.Output.Baseinfo.Certno,
  3964. Brdy: res.Output.Baseinfo.Brdy,
  3965. Gend: res.Output.Baseinfo.Gend,
  3966. Naty: res.Output.Baseinfo.Naty,
  3967. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3968. PsnName: res.Output.Baseinfo.PsnName,
  3969. Idetinfo: idetinfoStr,
  3970. Insuinfo: infoStr,
  3971. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3972. CardInfo: "",
  3973. VerifyNumber: token,
  3974. }
  3975. service.CreateHisPsn(psn)
  3976. var rf []*ResultFive
  3977. json.Unmarshal([]byte(infoStr), &rf)
  3978. var insutypes []*ResultFive
  3979. var insutype string
  3980. var is390 int = 0
  3981. var is310 int = 0
  3982. for _, item := range rf {
  3983. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3984. insutypes = append(insutypes, item)
  3985. }
  3986. }
  3987. if len(insutypes) == 1 {
  3988. insutype = insutypes[0].Insutype
  3989. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3990. } else {
  3991. for _, i := range insutypes {
  3992. if i.Insutype == "390" {
  3993. is390 = 1
  3994. }
  3995. if i.Insutype == "310" {
  3996. is310 = 1
  3997. }
  3998. }
  3999. }
  4000. if is390 == 1 {
  4001. insutype = "390"
  4002. }
  4003. if is310 == 1 {
  4004. insutype = "310"
  4005. }
  4006. if len(insutypes) == 0 {
  4007. insutype = "310"
  4008. }
  4009. c.ServeSuccessJSON(map[string]interface{}{
  4010. "patient": patient,
  4011. "number": token,
  4012. "insutype": insutype,
  4013. })
  4014. }
  4015. } else {
  4016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4017. return
  4018. }
  4019. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4020. type ELeData struct {
  4021. Code string `json:"code"`
  4022. Data struct {
  4023. Aac002 string `json:"aac002"`
  4024. Aaz500 string `json:"aaz500"`
  4025. ActCardNo string `json:"actCardNo"`
  4026. Bab520 string `json:"bab520"`
  4027. Bkz543 string `json:"bkz543"`
  4028. BusinessType string `json:"businessType"`
  4029. CertfCodg string `json:"certfCodg"`
  4030. EcIndexNo string `json:"ecIndexNo"`
  4031. EcToken string `json:"ecToken"`
  4032. ID0000 string `json:"id0000"`
  4033. IDNo string `json:"idNo"`
  4034. IDType string `json:"idType"`
  4035. Idcode string `json:"idcode"`
  4036. IdentityToken string `json:"identity_token"`
  4037. InsuOrg string `json:"insuOrg"`
  4038. OfficeID string `json:"officeId"`
  4039. OfficeName string `json:"officeName"`
  4040. OperatorID string `json:"operatorId"`
  4041. OperatorName string `json:"operatorName"`
  4042. OrgID string `json:"orgId"`
  4043. UserName string `json:"userName"`
  4044. } `json:"data"`
  4045. Infno interface{} `json:"infno"`
  4046. Message string `json:"message"`
  4047. OrgID string `json:"orgId"`
  4048. TransType string `json:"transType"`
  4049. }
  4050. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  4051. outPutInfo = Remove0000(outPutInfo)
  4052. if len(outPutInfo) > 0 {
  4053. var ele ELeData
  4054. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4055. if err != nil {
  4056. utils.ErrorLog("解析失败:%v", err)
  4057. }
  4058. token := ele.Data.EcToken
  4059. fmt.Println(inputInfo)
  4060. fmt.Println(outPutInfo)
  4061. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  4062. saveLog(result, requestLog, "1101", "获取人员信息")
  4063. var dat map[string]interface{}
  4064. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4065. fmt.Println(dat)
  4066. } else {
  4067. fmt.Println(err)
  4068. }
  4069. userJSONBytes, _ := json.Marshal(dat)
  4070. var res ResultTwo
  4071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4072. utils.ErrorLog("解析失败:%v", err)
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4074. return
  4075. }
  4076. res.ErrMsg = errMsgLog
  4077. if res.Infcode == 0 {
  4078. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4079. if err == gorm.ErrRecordNotFound {
  4080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4081. return
  4082. } else if err != nil {
  4083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4084. return
  4085. } else {
  4086. fmt.Println(res)
  4087. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4088. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4089. infoStr := string(Iinfos)
  4090. idetinfoStr := string(Idetinfos)
  4091. psn := &models.HisPsn{
  4092. PsnNo: res.Output.Baseinfo.PsnNo,
  4093. Age: res.Output.Baseinfo.Age,
  4094. PatientId: patient.ID,
  4095. Certno: res.Output.Baseinfo.Certno,
  4096. Brdy: res.Output.Baseinfo.Brdy,
  4097. Gend: res.Output.Baseinfo.Gend,
  4098. Naty: res.Output.Baseinfo.Naty,
  4099. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4100. PsnName: res.Output.Baseinfo.PsnName,
  4101. Idetinfo: idetinfoStr,
  4102. Insuinfo: infoStr,
  4103. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4104. CardInfo: outPutInfo,
  4105. VerifyNumber: token,
  4106. InsuplcAdmdvs: ele.Data.InsuOrg,
  4107. }
  4108. service.CreateHisPsn(psn)
  4109. var rf []*ResultFive
  4110. json.Unmarshal([]byte(infoStr), &rf)
  4111. var insutypes []*ResultFive
  4112. var insutype string
  4113. var is390 int = 0
  4114. var is310 int = 0
  4115. for _, item := range rf {
  4116. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4117. insutypes = append(insutypes, item)
  4118. }
  4119. }
  4120. if len(insutypes) == 1 {
  4121. insutype = insutypes[0].Insutype
  4122. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4123. } else {
  4124. for _, i := range insutypes {
  4125. if i.Insutype == "390" {
  4126. is390 = 1
  4127. }
  4128. if i.Insutype == "310" {
  4129. is310 = 1
  4130. }
  4131. }
  4132. }
  4133. if is390 == 1 {
  4134. insutype = "390"
  4135. }
  4136. if is310 == 1 {
  4137. insutype = "310"
  4138. }
  4139. if len(insutypes) == 0 {
  4140. insutype = "310"
  4141. }
  4142. c.ServeSuccessJSON(map[string]interface{}{
  4143. "patient": patient,
  4144. "number": token,
  4145. "insutype": insutype,
  4146. })
  4147. }
  4148. } else {
  4149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4150. return
  4151. }
  4152. }
  4153. } else {
  4154. type ELeData struct {
  4155. Code string `json:"code"`
  4156. Data struct {
  4157. Aac002 string `json:"aac002"`
  4158. Aaz500 string `json:"aaz500"`
  4159. ActCardNo string `json:"actCardNo"`
  4160. Bab520 string `json:"bab520"`
  4161. Bkz543 string `json:"bkz543"`
  4162. BusinessType string `json:"businessType"`
  4163. CertfCodg string `json:"certfCodg"`
  4164. EcIndexNo string `json:"ecIndexNo"`
  4165. EcToken string `json:"ecToken"`
  4166. ID0000 string `json:"id0000"`
  4167. IDNo string `json:"idNo"`
  4168. IDType string `json:"idType"`
  4169. Idcode string `json:"idcode"`
  4170. IdentityToken string `json:"identity_token"`
  4171. InsuOrg string `json:"insuOrg"`
  4172. OfficeID string `json:"officeId"`
  4173. OfficeName string `json:"officeName"`
  4174. OperatorID string `json:"operatorId"`
  4175. OperatorName string `json:"operatorName"`
  4176. OrgID string `json:"orgId"`
  4177. UserName string `json:"userName"`
  4178. } `json:"data"`
  4179. Infno interface{} `json:"infno"`
  4180. Message string `json:"message"`
  4181. OrgID string `json:"orgId"`
  4182. TransType string `json:"transType"`
  4183. }
  4184. _, result := GetgdEleBaseInfo(miConfig.Code, admin_user_id, roles.UserName)
  4185. fmt.Println(result)
  4186. outPutInfo := Remove0000(result)
  4187. fmt.Println(outPutInfo)
  4188. if len(outPutInfo) > 0 {
  4189. var ele ELeData
  4190. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4191. if err != nil {
  4192. utils.ErrorLog("解析失败:%v", err)
  4193. }
  4194. token := ele.Data.EcToken
  4195. fmt.Println(outPutInfo)
  4196. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4197. saveLog(result, requestLog, "1101", "获取人员信息")
  4198. var dat map[string]interface{}
  4199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4200. fmt.Println(dat)
  4201. } else {
  4202. fmt.Println(err)
  4203. }
  4204. userJSONBytes, _ := json.Marshal(dat)
  4205. var res ResultTwo
  4206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4207. utils.ErrorLog("解析失败:%v", err)
  4208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4209. return
  4210. }
  4211. if res.Infcode == 0 {
  4212. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4213. if err == gorm.ErrRecordNotFound {
  4214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4215. return
  4216. } else if err != nil {
  4217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4218. return
  4219. } else {
  4220. fmt.Println(res)
  4221. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4222. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4223. infoStr := string(Iinfos)
  4224. idetinfoStr := string(Idetinfos)
  4225. psn := &models.HisPsn{
  4226. PsnNo: res.Output.Baseinfo.PsnNo,
  4227. Age: res.Output.Baseinfo.Age,
  4228. PatientId: patient.ID,
  4229. Certno: res.Output.Baseinfo.Certno,
  4230. Brdy: res.Output.Baseinfo.Brdy,
  4231. Gend: res.Output.Baseinfo.Gend,
  4232. Naty: res.Output.Baseinfo.Naty,
  4233. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4234. PsnName: res.Output.Baseinfo.PsnName,
  4235. Idetinfo: idetinfoStr,
  4236. Insuinfo: infoStr,
  4237. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4238. CardInfo: outPutInfo,
  4239. VerifyNumber: token,
  4240. InsuplcAdmdvs: ele.Data.InsuOrg,
  4241. }
  4242. service.CreateHisPsn(psn)
  4243. var rf []*ResultFive
  4244. json.Unmarshal([]byte(infoStr), &rf)
  4245. var insutypes []*ResultFive
  4246. var insutype string
  4247. var is390 int = 0
  4248. var is310 int = 0
  4249. for _, item := range rf {
  4250. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4251. insutypes = append(insutypes, item)
  4252. }
  4253. }
  4254. if len(insutypes) == 1 {
  4255. insutype = insutypes[0].Insutype
  4256. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4257. } else {
  4258. for _, i := range insutypes {
  4259. if i.Insutype == "390" {
  4260. is390 = 1
  4261. }
  4262. if i.Insutype == "310" {
  4263. is310 = 1
  4264. }
  4265. }
  4266. }
  4267. if is390 == 1 {
  4268. insutype = "390"
  4269. }
  4270. if is310 == 1 {
  4271. insutype = "310"
  4272. }
  4273. if len(insutypes) == 0 {
  4274. insutype = "310"
  4275. }
  4276. c.ServeSuccessJSON(map[string]interface{}{
  4277. "patient": patient,
  4278. "number": token,
  4279. "insutype": insutype,
  4280. })
  4281. }
  4282. } else {
  4283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4284. return
  4285. }
  4286. }
  4287. //fmt.Println(result)
  4288. //
  4289. //if initFlag == 0 {
  4290. // c.TestGetBasBaseInit()
  4291. //}
  4292. //token := c.GetEleBaseInfo()
  4293. //
  4294. //token = Remove0000(token)
  4295. //
  4296. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  4297. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  4298. ////
  4299. //var res ResultTwo
  4300. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4301. // utils.ErrorLog("解析失败:%v", err)
  4302. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4303. // return
  4304. //}
  4305. //
  4306. //if res.Infcode == 0 {
  4307. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4308. // if err == gorm.ErrRecordNotFound {
  4309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4310. // return
  4311. // } else if err != nil {
  4312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4313. // return
  4314. //
  4315. // } else {
  4316. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4317. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4318. // infoStr := string(Iinfos)
  4319. // idetinfoStr := string(Idetinfos)
  4320. //
  4321. //
  4322. //
  4323. //
  4324. // var rf []*ResultFive
  4325. // json.Unmarshal([]byte(infoStr), &rf)
  4326. //
  4327. // var insutypes []*ResultFive
  4328. // var insutype string
  4329. // var is390 int = 0
  4330. // var is310 int = 0
  4331. // var insuplc_admdvs string
  4332. //
  4333. // for _, item := range rf {
  4334. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4335. // insutypes = append(insutypes, item)
  4336. // }
  4337. // }
  4338. //
  4339. // if len(insutypes) == 1 {
  4340. // insutype = insutypes[0].Insutype
  4341. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4342. // } else {
  4343. // for _, i := range insutypes {
  4344. // if i.Insutype == "390" {
  4345. // is390 = 1
  4346. // }
  4347. //
  4348. // if i.Insutype == "310" {
  4349. // is310 = 1
  4350. // }
  4351. // }
  4352. // }
  4353. // if is390 == 1 {
  4354. // insutype = "390"
  4355. // }
  4356. //
  4357. // if is310 == 1 {
  4358. // insutype = "310"
  4359. // }
  4360. // if len(insutypes) == 0 {
  4361. // insutype = "310"
  4362. // }
  4363. // for _, item := range rf {
  4364. // if item.Insutype == insutype {
  4365. // insuplc_admdvs = item.InsuplcAdmdvs
  4366. // }
  4367. // }
  4368. // psn := &models.HisPsn{
  4369. // PsnNo: res.Output.Baseinfo.PsnNo,
  4370. // Age: res.Output.Baseinfo.Age,
  4371. // PatientId: patient.ID,
  4372. // Certno: res.Output.Baseinfo.Certno,
  4373. // Brdy: res.Output.Baseinfo.Brdy,
  4374. // Gend: res.Output.Baseinfo.Gend,
  4375. // Naty: res.Output.Baseinfo.Naty,
  4376. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  4377. // PsnName: res.Output.Baseinfo.PsnName,
  4378. // Idetinfo: idetinfoStr,
  4379. // Insuinfo: infoStr,
  4380. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4381. // CardInfo: "",
  4382. // VerifyNumber: token,
  4383. // InsuplcAdmdvs: insuplc_admdvs,
  4384. // }
  4385. // service.CreateHisPsn(psn)
  4386. //
  4387. // c.ServeSuccessJSON(map[string]interface{}{
  4388. // "patient": patient,
  4389. // "number": token,
  4390. // })
  4391. // }
  4392. //} else {
  4393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4394. // return
  4395. //}
  4396. }
  4397. break
  4398. }
  4399. }
  4400. var initFlag int64 = 0
  4401. var initEleFlag int64 = 0
  4402. func (c *HisApiController) TestGetBasBaseInit() {
  4403. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4404. Iinit := DllDef.MustFindProc("Init")
  4405. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4406. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  4407. if ret != 0 {
  4408. fmt.Println("SSCard的报错原因:", err)
  4409. fmt.Println("SSCard的运算结果为:", ret)
  4410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4411. return
  4412. }
  4413. result := int(ret)
  4414. fmt.Println("SSCard的运算结果为1:", result)
  4415. initFlag = 1
  4416. return
  4417. }
  4418. func (c *HisApiController) HandleJiangXiReadCard() {
  4419. fmt.Println("~~~~~~")
  4420. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4421. admin_user_id, _ := c.GetInt64("admin_user_id")
  4422. id_card_type, _ := c.GetInt64("id_card_type")
  4423. //certificates, _ := c.GetInt64("certificates")
  4424. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4425. if initFlag == 0 {
  4426. c.TestGetJiangXiBasBaseInit()
  4427. }
  4428. basStr := c.GetBasBaseInfo()
  4429. if len(basStr) == 0 {
  4430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4431. return
  4432. }
  4433. fmt.Println(basStr)
  4434. bas := strings.Split(basStr, "|")
  4435. basNumber := bas[1]
  4436. fmt.Println(basNumber)
  4437. card_sn := bas[3]
  4438. fmt.Println(card_sn)
  4439. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  4440. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4441. var dat map[string]interface{}
  4442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4443. fmt.Println(dat)
  4444. } else {
  4445. fmt.Println(err)
  4446. }
  4447. userJSONBytes, _ := json.Marshal(dat)
  4448. var res ResultTwo
  4449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4450. utils.ErrorLog("解析失败:%v", err)
  4451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4452. return
  4453. }
  4454. if res.Infcode == 0 {
  4455. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4456. if err == gorm.ErrRecordNotFound {
  4457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4458. return
  4459. } else if err != nil {
  4460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4461. return
  4462. } else {
  4463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4465. infoStr := string(Iinfos)
  4466. idetinfoStr := string(Idetinfos)
  4467. psn := &models.HisPsn{
  4468. PsnNo: res.Output.Baseinfo.PsnNo,
  4469. Age: res.Output.Baseinfo.Age,
  4470. PatientId: patient.ID,
  4471. Certno: res.Output.Baseinfo.Certno,
  4472. Brdy: res.Output.Baseinfo.Brdy,
  4473. Gend: res.Output.Baseinfo.Gend,
  4474. Naty: res.Output.Baseinfo.Naty,
  4475. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4476. PsnName: res.Output.Baseinfo.PsnName,
  4477. Idetinfo: idetinfoStr,
  4478. Insuinfo: infoStr,
  4479. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4480. CardInfo: basStr,
  4481. VerifyNumber: "",
  4482. }
  4483. service.CreateHisPsn(psn)
  4484. c.ServeSuccessJSON(map[string]interface{}{
  4485. "patient": patient,
  4486. "number": basNumber,
  4487. })
  4488. }
  4489. } else {
  4490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4491. return
  4492. }
  4493. }
  4494. func (c *HisApiController) TestGetHnBasBaseInit() {
  4495. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4496. Iinit := DllDef.MustFindProc("Init")
  4497. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4498. //http://10.77.211.236/CSB/hsa-fsi-1303
  4499. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  4500. if ret != 0 {
  4501. fmt.Println("SSCard的报错原因:", err)
  4502. fmt.Println("SSCard的运算结果为:", ret)
  4503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4504. return
  4505. }
  4506. result := int(ret)
  4507. fmt.Println("SSCard的运算结果为1:", result)
  4508. initFlag = 1
  4509. return
  4510. }
  4511. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  4512. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4513. Iinit := DllDef.MustFindProc("Init")
  4514. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4515. //http://10.77.211.236/CSB/hsa-fsi-1303
  4516. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  4517. if ret != 0 {
  4518. fmt.Println("SSCard的报错原因:", err)
  4519. fmt.Println("SSCard的运算结果为:", ret)
  4520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4521. return
  4522. }
  4523. result := int(ret)
  4524. fmt.Println("SSCard的运算结果为1:", result)
  4525. initFlag = 1
  4526. return
  4527. }
  4528. func (c *HisApiController) GetSFZBaseInfo() string {
  4529. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4530. readCard := DllDef.MustFindProc("ReadSFZ")
  4531. if readCard == nil {
  4532. fmt.Println("readcard is nil")
  4533. readCard = DllDef.MustFindProc("ReadSFZ")
  4534. }
  4535. str := make([]byte, 8096)
  4536. str1 := make([]byte, 8096)
  4537. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  4538. fmt.Println(r)
  4539. return Remove0000(string(str))
  4540. }
  4541. func (c *HisApiController) GetEleBaseInfo() string {
  4542. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4543. readCard := DllDef.MustFindProc("GetQRBase")
  4544. fmt.Println(readCard)
  4545. if readCard == nil {
  4546. fmt.Println("readcard is nil")
  4547. readCard = DllDef.MustFindProc("GetQRBase")
  4548. }
  4549. str := make([]byte, 1024)
  4550. str1 := make([]byte, 1024)
  4551. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4552. fmt.Println(ret2)
  4553. fmt.Println(string(str1))
  4554. fmt.Println(string(str))
  4555. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4556. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4557. if ret2 != 0 {
  4558. return ""
  4559. }
  4560. return string(str)
  4561. }
  4562. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  4563. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  4564. readCard := DllDef.MustFindProc("NationEcTrans")
  4565. fmt.Println(readCard)
  4566. fmt.Println("!!!!!")
  4567. pBusiCardInfo := make([]byte, 2048)
  4568. input := make(map[string]interface{})
  4569. inputData := make(map[string]interface{})
  4570. inputData["orgId"] = code
  4571. inputData["businessType"] = "01101"
  4572. inputData["operatorId"] = "1"
  4573. inputData["operatorName"] = "admin"
  4574. inputData["officeId"] = "001"
  4575. inputData["officeName"] = "血透室"
  4576. inputData["deviceType"] = ""
  4577. input["data"] = inputData
  4578. input["orgId"] = code
  4579. input["transType"] = "ec.query"
  4580. bytesData, _ := json.Marshal(input)
  4581. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  4582. fmt.Println(ret2)
  4583. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  4584. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  4585. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  4586. }
  4587. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  4588. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  4589. readCard := DllDef.MustFindProc("NationEcTrans")
  4590. fmt.Println(readCard)
  4591. fmt.Println("!!!!!")
  4592. pBusiCardInfo := make([]byte, 2048)
  4593. input := make(map[string]interface{})
  4594. inputData := make(map[string]interface{})
  4595. inputData["orgId"] = code
  4596. inputData["businessType"] = "01101"
  4597. inputData["operatorId"] = "9"
  4598. inputData["operatorName"] = "admin"
  4599. inputData["officeId"] = "001"
  4600. inputData["officeName"] = "血透室"
  4601. inputData["deviceType"] = ""
  4602. input["data"] = inputData
  4603. input["orgId"] = code
  4604. input["transType"] = "ec.query"
  4605. bytesData, _ := json.Marshal(input)
  4606. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  4607. fmt.Println(ret2)
  4608. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  4609. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  4610. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  4611. }
  4612. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  4613. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  4614. readCard := DllDef.MustFindProc("NationEcTrans")
  4615. fmt.Println(readCard)
  4616. fmt.Println("!!!!!")
  4617. pBusiCardInfo := make([]byte, 2048)
  4618. input := make(map[string]interface{})
  4619. inputData := make(map[string]interface{})
  4620. inputData["orgId"] = code
  4621. inputData["businessType"] = "01301"
  4622. inputData["operatorId"] = "9"
  4623. inputData["operatorName"] = "admin"
  4624. inputData["officeId"] = "001"
  4625. inputData["officeName"] = "血透室"
  4626. inputData["deviceType"] = ""
  4627. input["data"] = inputData
  4628. input["orgId"] = code
  4629. input["transType"] = "ec.query"
  4630. bytesData, _ := json.Marshal(input)
  4631. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  4632. fmt.Println(ret2)
  4633. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  4634. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  4635. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  4636. }
  4637. func GetJxEleBaseInfo(org_id int64) string {
  4638. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4639. readCard := DllDef.MustFindProc("NationEcTrans")
  4640. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4641. if readCard == nil {
  4642. fmt.Println("readcard is nil")
  4643. readCard = DllDef.MustFindProc("NationEcTrans")
  4644. }
  4645. str1 := make([]byte, 1024)
  4646. data := make(map[string]interface{})
  4647. inputData := make(map[string]interface{})
  4648. inputData["orgId"] = miConfig.Code
  4649. inputData["businessType"] = "01101"
  4650. inputData["operatorId"] = "test001"
  4651. inputData["operatorName"] = "cn"
  4652. inputData["officeId"] = "32760"
  4653. inputData["officeName"] = "waike"
  4654. inputData["deviceType"] = ""
  4655. data["data"] = inputData
  4656. data["transType"] = "ec.query"
  4657. data["extra "] = ""
  4658. data["orgId"] = miConfig.Code
  4659. bytesData, _ := json.Marshal(data)
  4660. //bytesData, _ := json.Marshal(data)
  4661. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4662. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4663. fmt.Println(ret2)
  4664. fmt.Println(string(str1))
  4665. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4666. if ret2 != 0 {
  4667. return ""
  4668. }
  4669. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4670. }
  4671. func GetJxEleBaseInitInfo(org_id int64) string {
  4672. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4673. readCard := DllDef.MustFindProc("NationEcTrans")
  4674. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4675. if readCard == nil {
  4676. fmt.Println("readcard is nil")
  4677. readCard = DllDef.MustFindProc("NationEcTrans")
  4678. }
  4679. str1 := make([]byte, 2048)
  4680. data := make(map[string]interface{})
  4681. inputData := make(map[string]interface{})
  4682. inputData["orgId"] = miConfig.Code
  4683. inputData["businessType"] = "01101"
  4684. inputData["operatorId"] = "1"
  4685. inputData["operatorName"] = "huangchuang"
  4686. inputData["officeId"] = "101"
  4687. inputData["officeName"] = "xuetou"
  4688. inputData["deviceType"] = ""
  4689. data["data"] = inputData
  4690. data["transType"] = "ec.query"
  4691. data["orgId"] = miConfig.Code
  4692. bytesData, _ := json.Marshal(data)
  4693. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  4694. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  4695. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  4696. fmt.Println(ret2)
  4697. fmt.Println(string(str1))
  4698. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4699. if ret2 != 0 {
  4700. return ""
  4701. }
  4702. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  4703. initEleFlag = 1
  4704. }
  4705. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  4706. }
  4707. func (c *HisApiController) GetBasBaseInfo() string {
  4708. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4709. readCard := DllDef.MustFindProc("ReadCardBas")
  4710. if readCard == nil {
  4711. fmt.Println("readcard is nil")
  4712. readCard = DllDef.MustFindProc("ReadCardBas")
  4713. }
  4714. str := make([]byte, 1024)
  4715. str1 := make([]byte, 1024)
  4716. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4717. fmt.Println(string(str1))
  4718. fmt.Println(string(str))
  4719. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4720. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4721. if ret2 != 0 {
  4722. return ""
  4723. }
  4724. return string(str)
  4725. }
  4726. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  4727. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  4728. readCard := DllDef.MustFindProc("read_cardinfo")
  4729. if readCard == nil {
  4730. fmt.Println("readcard is nil")
  4731. readCard = DllDef.MustFindProc("read_cardinfo")
  4732. }
  4733. str := make([]byte, 1024) //卡号
  4734. str1 := make([]byte, 1024) //卡识别码
  4735. str2 := make([]byte, 1024) //身份证号
  4736. str3 := make([]byte, 1024) //姓名
  4737. str4 := make([]byte, 1024) //错误信息
  4738. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  4739. fmt.Println(string(str1))
  4740. fmt.Println(string(str))
  4741. fmt.Println(string(str2))
  4742. fmt.Println(string(str3))
  4743. fmt.Println(string(str4))
  4744. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4745. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4746. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  4747. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  4748. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  4749. if ret2 != 0 {
  4750. return "", "", "", "", ""
  4751. }
  4752. return string(str), string(str1), string(str2), string(str3), string(str4)
  4753. }
  4754. type CustomFundPay struct {
  4755. FundPayType string `json:"fund_pay_type"`
  4756. FundPayamt float64 `json:"fund_payamt"`
  4757. }
  4758. func (c *HisApiController) GetSettleList() {
  4759. order_id, _ := c.GetInt64("order_id")
  4760. admin_user_id, _ := c.GetInt64("admin_user_id")
  4761. order, _ := service.GetHisOrderByIDTwo(order_id)
  4762. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4763. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4764. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4765. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4766. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4767. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4768. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4769. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4770. if order.ID == 0 {
  4771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4772. return
  4773. }
  4774. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4775. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4776. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4777. //fmt.Println(count)
  4778. //var zero string
  4779. //number := count + 1
  4780. //if number >= 1000 {
  4781. // zero = "0000" + strconv.FormatInt(number, 10)
  4782. //} else if number >= 10000 {
  4783. // zero = "000" + strconv.FormatInt(number, 10)
  4784. //} else if number >= 100000 {
  4785. // zero = "00" + strconv.FormatInt(number, 10)
  4786. //} else if number >= 1000000 {
  4787. // zero = "0" + strconv.FormatInt(number, 10)
  4788. //} else {
  4789. // zero = strconv.FormatInt(number, 10)
  4790. //}
  4791. //fmt.Println(zero)
  4792. struct4101 := service.Struct4101{
  4793. PsnNo: order.PsnNo,
  4794. MdtrtId: order.MdtrtId,
  4795. SetlId: order.SetlId,
  4796. PsnName: order.PsnName,
  4797. Gend: order.Gend,
  4798. Brdy: his.Brdy,
  4799. Age: his.Age,
  4800. Naty: order.Naty,
  4801. PatnCertType: "01",
  4802. Certno: order.Certno,
  4803. Prfs: "90",
  4804. ConerName: roles[0].UserName,
  4805. PatnRlts: "99",
  4806. ConerAddr: miConfig.OrgName,
  4807. ConerTel: admin.Mobile,
  4808. HiType: order.Insutype,
  4809. Insuplc: miConfig.InsuplcAdmdvs,
  4810. MaindiagFlag: "1",
  4811. BillCode: order.SetlId,
  4812. BillNo: order.SetlId,
  4813. BizSn: order.Number,
  4814. PsnSelfPay: order.PsnPartAmt,
  4815. PsnOwnPay: order.PsnPartAmt,
  4816. AcctPay: order.AcctPay,
  4817. PsnCashpay: order.PsnCashPay,
  4818. HiPaymtd: "1",
  4819. Hsorg: miConfig.InsuplcAdmdvs,
  4820. HsorgOpter: miConfig.InsuplcAdmdvs,
  4821. MedinsFillPsn: curRoles.UserName,
  4822. MedinsFillDept: depart.Name,
  4823. IptMedType: "2",
  4824. }
  4825. struct4101.SetlBegnDate = order.SetlTime
  4826. struct4101.SetlEndDate = order.SetlTime
  4827. time_arr := strings.Split(order.SetlTime, " ")
  4828. struct4101.AdmTime = time_arr[0]
  4829. struct4101.AdmEndTime = time_arr[0]
  4830. var rf []CustomFundPay
  4831. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4832. var tempFunPays []service.CustomStruct
  4833. for _, item := range rf {
  4834. var tempFunPay service.CustomStruct
  4835. tempFunPay.FundPayamt = item.FundPayamt
  4836. tempFunPay.FundPayType = item.FundPayType
  4837. tempFunPays = append(tempFunPays, tempFunPay)
  4838. }
  4839. struct4101.CustomStruct = tempFunPays
  4840. var tempDiaginfos []service.DiaginfoStructTwo
  4841. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4842. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4843. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4844. var config []*models.HisXtDiagnoseConfig
  4845. for _, item := range diagnosis_ids {
  4846. id, _ := strconv.ParseInt(item, 10, 64)
  4847. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4848. config = append(config, &diagnosisConfig)
  4849. }
  4850. for index, item := range config {
  4851. if index == 0 {
  4852. var tempDiaginfo service.DiaginfoStructTwo
  4853. tempDiaginfo.DiagCode = item.CountryCode
  4854. tempDiaginfo.DiagName = item.CountryContentName
  4855. tempDiaginfo.DiagType = "1"
  4856. tempDiaginfo.MaindiagFlag = "1"
  4857. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4858. } else {
  4859. var tempDiaginfo service.DiaginfoStructTwo
  4860. tempDiaginfo.DiagCode = item.CountryCode
  4861. tempDiaginfo.DiagName = item.CountryContentName
  4862. tempDiaginfo.DiagType = "2"
  4863. tempDiaginfo.MaindiagFlag = "0"
  4864. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4865. }
  4866. }
  4867. struct4101.Diseinfo = tempDiaginfos
  4868. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4869. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4870. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4871. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  4872. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  4873. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4874. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4875. var iteminfo service.IteminfoStruct
  4876. var bedCostTotal float64 = 0 //床位总费
  4877. var bedCostSelfTotal float64 = 0 //床位自费
  4878. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4879. var operationCostTotal float64 = 0 //手术费
  4880. var operationCostSelfTotal float64 = 0 //手术费
  4881. var operationCostPartSelfTotal float64 = 0 //手术费
  4882. var otherCostTotal float64 = 0 //其他费用
  4883. var otherCostSelfTotal float64 = 0 //其他费用
  4884. var otherCostPartSelfTotal float64 = 0 //其他费用
  4885. var materialCostTotal float64 = 0 //材料费
  4886. var materialCostSelfTotal float64 = 0 //材料费
  4887. var materialCostPartSelfTotal float64 = 0 //材料费
  4888. var westernMedicineCostTotal float64 = 0 //西药费
  4889. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4890. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4891. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4892. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4893. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4894. var checkCostTotal float64 = 0 //检查费
  4895. var checkCostSelfTotal float64 = 0 //检查费
  4896. var checkCostPartSelfTotal float64 = 0 //检查费
  4897. var laboratoryCostTotal float64 = 0 //化验费
  4898. var laboratoryCostSelfTotal float64 = 0 //化验费
  4899. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4900. var treatCostTotal float64 = 0 //治疗费用
  4901. var treatCostSelfTotal float64 = 0 //治疗费用
  4902. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4903. decimal.DivisionPrecision = 2
  4904. var bed_fulamt_ownpay_amt float64 = 0
  4905. var operation_fulamt_ownpay_amt float64 = 0
  4906. var other_fulamt_ownpay_amt float64 = 0
  4907. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4908. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4909. var check_fulamt_ownpay_amt float64 = 0
  4910. var material_fulamt_ownpay_amt float64 = 0
  4911. var laboratory_fulamt_ownpay_amt float64 = 0
  4912. var treat_fulamt_ownpay_amt float64 = 0
  4913. var bed_claa_sunmfee float64 = 0
  4914. var bed_clab_amt float64 = 0
  4915. var bed_other_amt float64 = 0
  4916. var operation_claa_sunmfee float64 = 0
  4917. var operation_clab_amt float64 = 0
  4918. var operation_other_amt float64 = 0
  4919. var other_claa_sunmfee float64 = 0
  4920. var other_clab_amt float64 = 0
  4921. var other_other_amt float64 = 0
  4922. var westernMedicine_claa_sunmfee float64 = 0
  4923. var westernMedicine_clab_amt float64 = 0
  4924. var westernMedicine_other_amt float64 = 0
  4925. var chineseTraditional_claa_sunmfee float64 = 0
  4926. var chineseTraditional_clab_amt float64 = 0
  4927. var chineseTraditional_other_amt float64 = 0
  4928. var check_claa_sunmfee float64 = 0
  4929. var check_clab_amt float64 = 0
  4930. var check_other_amt float64 = 0
  4931. var material_claa_sunmfee float64 = 0
  4932. var material_clab_amt float64 = 0
  4933. var material_other_amt float64 = 0
  4934. var laboratory_claa_sunmfee float64 = 0
  4935. var laboratory_clab_amt float64 = 0
  4936. var laboratory_other_amt float64 = 0
  4937. var treat_claa_sunmfee float64 = 0
  4938. var treat_clab_amt float64 = 0
  4939. var treat_other_amt float64 = 0
  4940. for _, item := range order.HisOrderInfo {
  4941. if item.MedChrgitmType == "01" { //床位费
  4942. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4943. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4944. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4945. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4946. if item.ChrgitmLv == "1" {
  4947. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4948. }
  4949. if item.ChrgitmLv == "2" {
  4950. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4951. }
  4952. if item.ChrgitmLv == "3" {
  4953. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4954. }
  4955. }
  4956. if item.MedChrgitmType == "03" { //检查费
  4957. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4958. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4959. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4960. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4961. if item.ChrgitmLv == "1" {
  4962. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4963. }
  4964. if item.ChrgitmLv == "2" {
  4965. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4966. }
  4967. if item.ChrgitmLv == "3" {
  4968. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4969. }
  4970. }
  4971. if item.MedChrgitmType == "04" { //化验费
  4972. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4973. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4974. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4975. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4976. if item.ChrgitmLv == "1" {
  4977. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4978. }
  4979. if item.ChrgitmLv == "2" {
  4980. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4981. }
  4982. if item.ChrgitmLv == "3" {
  4983. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4984. }
  4985. }
  4986. if item.MedChrgitmType == "05" { //治疗费
  4987. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4988. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4989. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4990. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4991. if item.ChrgitmLv == "1" {
  4992. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4993. }
  4994. if item.ChrgitmLv == "2" {
  4995. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4996. }
  4997. if item.ChrgitmLv == "3" {
  4998. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4999. }
  5000. }
  5001. if item.MedChrgitmType == "06" { //手术费
  5002. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5003. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5004. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5005. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5006. if item.ChrgitmLv == "1" {
  5007. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5008. }
  5009. if item.ChrgitmLv == "2" {
  5010. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5011. }
  5012. if item.ChrgitmLv == "3" {
  5013. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5014. }
  5015. }
  5016. if item.MedChrgitmType == "08" { //材料费
  5017. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5018. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5019. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5020. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5021. if item.ChrgitmLv == "1" {
  5022. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5023. }
  5024. if item.ChrgitmLv == "2" {
  5025. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5026. }
  5027. if item.ChrgitmLv == "3" {
  5028. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5029. }
  5030. }
  5031. if item.MedChrgitmType == "09" { //西药费
  5032. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5033. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5034. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5035. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5036. if item.ChrgitmLv == "1" {
  5037. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5038. }
  5039. if item.ChrgitmLv == "2" {
  5040. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5041. }
  5042. if item.ChrgitmLv == "3" {
  5043. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5044. }
  5045. }
  5046. if item.MedChrgitmType == "11" { //中成费
  5047. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5048. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5049. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5050. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5051. if item.ChrgitmLv == "1" {
  5052. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5053. }
  5054. if item.ChrgitmLv == "2" {
  5055. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5056. }
  5057. if item.ChrgitmLv == "3" {
  5058. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5059. }
  5060. }
  5061. if item.MedChrgitmType == "14" { //其他费
  5062. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5063. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5064. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5065. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5066. if item.ChrgitmLv == "1" {
  5067. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5068. }
  5069. if item.ChrgitmLv == "2" {
  5070. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5071. }
  5072. if item.ChrgitmLv == "3" {
  5073. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5074. }
  5075. }
  5076. }
  5077. var iteminfoStructs []service.IteminfoStruct
  5078. if bedCostTotal != 0 {
  5079. iteminfo.MedChrgitm = "01"
  5080. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5081. iteminfo.Amt = bedCostTotal
  5082. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5083. iteminfo.ClabAmt = bed_clab_amt
  5084. iteminfo.OthAmt = bed_other_amt
  5085. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5086. }
  5087. if checkCostTotal != 0 {
  5088. iteminfo.MedChrgitm = "03"
  5089. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5090. iteminfo.Amt = checkCostTotal
  5091. iteminfo.ClaaSumfee = check_claa_sunmfee
  5092. iteminfo.ClabAmt = check_clab_amt
  5093. iteminfo.OthAmt = check_other_amt
  5094. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5095. }
  5096. if laboratoryCostTotal != 0 {
  5097. iteminfo.MedChrgitm = "04"
  5098. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5099. iteminfo.Amt = laboratoryCostTotal
  5100. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5101. iteminfo.ClabAmt = laboratory_clab_amt
  5102. iteminfo.OthAmt = laboratory_other_amt
  5103. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5104. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5105. }
  5106. if treatCostTotal != 0 {
  5107. iteminfo.MedChrgitm = "05"
  5108. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5109. iteminfo.Amt = treatCostTotal
  5110. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5111. iteminfo.ClabAmt = treat_clab_amt
  5112. iteminfo.OthAmt = treat_other_amt
  5113. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5114. //(struct4101.IteminfoStruct, iteminfo)
  5115. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5116. }
  5117. if operationCostTotal != 0 {
  5118. iteminfo.MedChrgitm = "06"
  5119. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5120. iteminfo.Amt = operationCostTotal
  5121. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5122. iteminfo.ClabAmt = operation_clab_amt
  5123. iteminfo.OthAmt = operation_other_amt
  5124. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5125. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5126. }
  5127. if materialCostTotal != 0 {
  5128. iteminfo.MedChrgitm = "08"
  5129. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5130. iteminfo.Amt = materialCostTotal
  5131. iteminfo.ClaaSumfee = material_claa_sunmfee
  5132. iteminfo.ClabAmt = material_clab_amt
  5133. iteminfo.OthAmt = material_other_amt
  5134. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5135. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5136. }
  5137. if westernMedicineCostTotal != 0 {
  5138. iteminfo.MedChrgitm = "09"
  5139. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5140. iteminfo.Amt = westernMedicineCostTotal
  5141. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5142. iteminfo.ClabAmt = westernMedicine_clab_amt
  5143. iteminfo.OthAmt = westernMedicine_other_amt
  5144. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5145. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5146. }
  5147. if chineseTraditionalMedicineCostTotal != 0 {
  5148. iteminfo.MedChrgitm = "11"
  5149. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5150. iteminfo.Amt = westernMedicineCostTotal
  5151. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5152. iteminfo.ClabAmt = westernMedicine_clab_amt
  5153. iteminfo.OthAmt = westernMedicine_other_amt
  5154. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5155. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5156. }
  5157. if otherCostTotal != 0 {
  5158. iteminfo.MedChrgitm = "14"
  5159. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5160. iteminfo.Amt = otherCostTotal
  5161. iteminfo.ClaaSumfee = other_claa_sunmfee
  5162. iteminfo.ClabAmt = other_clab_amt
  5163. iteminfo.OthAmt = other_other_amt
  5164. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5165. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5166. }
  5167. struct4101.IteminfoStruct = iteminfoStructs
  5168. struct4101.Ntly = "中国"
  5169. struct4101.AdmCaty = "A03.06"
  5170. struct4101.DoctorName = doctor.UserName
  5171. struct4101.DoctorCode = doctor.DoctorNumber
  5172. var res ResultSeventeen
  5173. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5174. struct4101.BillCode = order.Number
  5175. struct4101.BillNo = order.SetlId
  5176. var resOther ResultSeventeenOther
  5177. var pp models.PublicParams
  5178. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5179. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5180. pp.FixmedinsName = miConfig.OrgName
  5181. pp.FixmedinsCode = miConfig.Code
  5182. pp.RequestUrl = miConfig.Url
  5183. pp.Cainfo = miConfig.Cainfo
  5184. pp.SecretKey = miConfig.SecretKey
  5185. pp.AccessKey = miConfig.AccessKey
  5186. pp.OpterName = curRoles.UserName
  5187. client := &http.Client{}
  5188. var req *http.Request
  5189. data := make(map[string]interface{})
  5190. data["struct4101"] = struct4101
  5191. data["pp"] = pp
  5192. bytesData, _ := json.Marshal(data)
  5193. if miConfig.MdtrtareaAdmvs == "320921" {
  5194. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  5195. } else {
  5196. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  5197. }
  5198. resp, _ := client.Do(req)
  5199. defer resp.Body.Close()
  5200. body, ioErr := ioutil.ReadAll(resp.Body)
  5201. if ioErr != nil {
  5202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5204. return
  5205. }
  5206. var respJSON map[string]interface{}
  5207. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5210. return
  5211. }
  5212. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5213. userJSONBytes, _ := json.Marshal(respJSON)
  5214. fmt.Println("log")
  5215. fmt.Println(string(userJSONBytes))
  5216. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  5217. utils.ErrorLog("解析失败:%v", err)
  5218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5219. return
  5220. }
  5221. res.InfRefmsgid = resOther.InfRefmsgid
  5222. res.Output = resOther.Output
  5223. res.ErrMsg = resOther.ErrMsg
  5224. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  5225. res.Infcode = infocode
  5226. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5227. var pp models.PublicParams
  5228. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5229. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5230. pp.FixmedinsName = miConfig.OrgName
  5231. pp.FixmedinsCode = miConfig.Code
  5232. pp.RequestUrl = miConfig.Url
  5233. pp.Cainfo = miConfig.Cainfo
  5234. pp.SecretKey = miConfig.SecretKey
  5235. pp.AccessKey = miConfig.AccessKey
  5236. pp.OpterName = curRoles.UserName
  5237. result, _ := service.Jxyb4101(struct4101, pp)
  5238. var dat map[string]interface{}
  5239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5240. fmt.Println(dat)
  5241. } else {
  5242. fmt.Println(err)
  5243. }
  5244. userJSONBytes, _ := json.Marshal(dat)
  5245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5246. utils.ErrorLog("解析失败:%v", err)
  5247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5248. return
  5249. }
  5250. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5251. var pp models.PublicParams
  5252. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5253. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5254. pp.FixmedinsName = miConfig.OrgName
  5255. pp.FixmedinsCode = miConfig.Code
  5256. pp.RequestUrl = miConfig.Url
  5257. pp.Cainfo = miConfig.Cainfo
  5258. pp.SecretKey = miConfig.SecretKey
  5259. pp.AccessKey = miConfig.AccessKey
  5260. pp.OpterName = curRoles.UserName
  5261. result, _ := service.Hnyb4101(struct4101, pp)
  5262. var dat map[string]interface{}
  5263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5264. fmt.Println(dat)
  5265. } else {
  5266. fmt.Println(err)
  5267. }
  5268. userJSONBytes, _ := json.Marshal(dat)
  5269. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5270. utils.ErrorLog("解析失败:%v", err)
  5271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5272. return
  5273. }
  5274. } else {
  5275. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  5276. var dat map[string]interface{}
  5277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5278. fmt.Println(dat)
  5279. } else {
  5280. fmt.Println(err)
  5281. }
  5282. userJSONBytes, _ := json.Marshal(dat)
  5283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5284. utils.ErrorLog("解析失败:%v", err)
  5285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5286. return
  5287. }
  5288. }
  5289. if res.Infcode != 0 {
  5290. c.ServeSuccessJSON(map[string]interface{}{
  5291. "failed_code": -10,
  5292. "msg": res.ErrMsg,
  5293. })
  5294. return
  5295. } else {
  5296. //order.FaPiaoNumber = zero
  5297. //order.FaPiaoCode = last_order.FaPiaoCode
  5298. //service.UpdateOrder(order)
  5299. hisFundSettleListResult := &models.HisFundSettleListResult{
  5300. Number: res.Output.SetlListId,
  5301. Status: 1,
  5302. Ctime: time.Now().Unix(),
  5303. Mtime: time.Now().Unix(),
  5304. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5305. IsUpload: 1,
  5306. OrderId: order_id,
  5307. }
  5308. service.CreateUploadRecord(hisFundSettleListResult)
  5309. c.ServeSuccessJSON(map[string]interface{}{
  5310. "msg": "上传成功",
  5311. "result": hisFundSettleListResult,
  5312. })
  5313. return
  5314. }
  5315. }
  5316. func (c *HisApiController) GetSettleListHospital() {
  5317. order_id, _ := c.GetInt64("order_id")
  5318. admin_user_id, _ := c.GetInt64("admin_user_id")
  5319. order, _ := service.GetHisOrderByIDTwo(order_id)
  5320. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5321. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5322. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5323. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5324. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5325. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5326. if order.ID == 0 {
  5327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5328. return
  5329. }
  5330. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5331. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5332. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5333. fmt.Println(count)
  5334. var zero string
  5335. number := count + 1
  5336. if number >= 1000 {
  5337. zero = "0000" + strconv.FormatInt(number, 10)
  5338. } else if number >= 10000 {
  5339. zero = "000" + strconv.FormatInt(number, 10)
  5340. } else if number >= 100000 {
  5341. zero = "00" + strconv.FormatInt(number, 10)
  5342. } else if number >= 1000000 {
  5343. zero = "0" + strconv.FormatInt(number, 10)
  5344. } else {
  5345. zero = strconv.FormatInt(number, 10)
  5346. }
  5347. fmt.Println(zero)
  5348. struct4101 := service.Struct4101{
  5349. PsnNo: order.PsnNo,
  5350. MdtrtId: order.MdtrtId,
  5351. SetlId: order.SetlId,
  5352. PsnName: order.PsnName,
  5353. Gend: order.Gend,
  5354. Brdy: his.Brdy,
  5355. Age: int64(order.Age),
  5356. Naty: order.Naty,
  5357. PatnCertType: "01",
  5358. Certno: order.Certno,
  5359. Prfs: "90",
  5360. ConerName: roles[0].UserName,
  5361. PatnRlts: "99",
  5362. ConerAddr: miConfig.OrgName,
  5363. ConerTel: admin.Mobile,
  5364. HiType: order.Insutype,
  5365. Insuplc: miConfig.InsuplcAdmdvs,
  5366. MaindiagFlag: "1",
  5367. BillCode: order.SetlId,
  5368. BillNo: order.SetlId,
  5369. BizSn: order.Number,
  5370. PsnSelfPay: order.PsnPartAmt,
  5371. PsnOwnPay: order.PsnPartAmt,
  5372. AcctPay: order.AcctPay,
  5373. PsnCashpay: order.PsnCashPay,
  5374. HiPaymtd: "1",
  5375. Hsorg: miConfig.InsuplcAdmdvs,
  5376. HsorgOpter: miConfig.InsuplcAdmdvs,
  5377. MedinsFillPsn: curRoles.UserName,
  5378. MedinsFillDept: depart.Name,
  5379. IptMedType: "2",
  5380. AdmTime: his.InHosptialTime,
  5381. AdmEndTime: his.OutHosptialTime,
  5382. }
  5383. struct4101.SetlBegnDate = order.SetlTime
  5384. struct4101.SetlEndDate = order.SetlTime
  5385. var rf []CustomFundPay
  5386. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5387. var tempFunPays []service.CustomStruct
  5388. for _, item := range rf {
  5389. var tempFunPay service.CustomStruct
  5390. tempFunPay.FundPayamt = item.FundPayamt
  5391. tempFunPay.FundPayType = item.FundPayType
  5392. tempFunPays = append(tempFunPays, tempFunPay)
  5393. }
  5394. struct4101.CustomStruct = tempFunPays
  5395. var tempDiaginfos []service.DiaginfoStructTwo
  5396. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5397. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5398. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5399. var config []*models.HisXtDiagnoseConfig
  5400. for _, item := range diagnosis_ids {
  5401. id, _ := strconv.ParseInt(item, 10, 64)
  5402. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5403. config = append(config, &diagnosisConfig)
  5404. }
  5405. for index, item := range config {
  5406. if index == 0 {
  5407. var tempDiaginfo service.DiaginfoStructTwo
  5408. tempDiaginfo.DiagCode = item.CountryCode
  5409. tempDiaginfo.DiagName = item.CountryContentName
  5410. tempDiaginfo.DiagType = "1"
  5411. tempDiaginfo.MaindiagFlag = "1"
  5412. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5413. } else {
  5414. var tempDiaginfo service.DiaginfoStructTwo
  5415. tempDiaginfo.DiagCode = item.CountryCode
  5416. tempDiaginfo.DiagName = item.CountryContentName
  5417. tempDiaginfo.DiagType = "2"
  5418. tempDiaginfo.MaindiagFlag = "0"
  5419. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5420. }
  5421. }
  5422. struct4101.Diseinfo = tempDiaginfos
  5423. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5424. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5425. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5426. tempOpspdiseinfo2.OprnOprtCode = ""
  5427. tempOpspdiseinfo2.OprnOprtName = ""
  5428. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5429. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5430. var iteminfo service.IteminfoStruct
  5431. var bedCostTotal float64 = 0 //床位总费
  5432. var bedCostSelfTotal float64 = 0 //床位自费
  5433. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5434. var operationCostTotal float64 = 0 //手术费
  5435. var operationCostSelfTotal float64 = 0 //手术费
  5436. var operationCostPartSelfTotal float64 = 0 //手术费
  5437. var otherCostTotal float64 = 0 //其他费用
  5438. var otherCostSelfTotal float64 = 0 //其他费用
  5439. var otherCostPartSelfTotal float64 = 0 //其他费用
  5440. var materialCostTotal float64 = 0 //材料费
  5441. var materialCostSelfTotal float64 = 0 //材料费
  5442. var materialCostPartSelfTotal float64 = 0 //材料费
  5443. var westernMedicineCostTotal float64 = 0 //西药费
  5444. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5445. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5446. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5447. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5448. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5449. var checkCostTotal float64 = 0 //检查费
  5450. var checkCostSelfTotal float64 = 0 //检查费
  5451. var checkCostPartSelfTotal float64 = 0 //检查费
  5452. var laboratoryCostTotal float64 = 0 //化验费
  5453. var laboratoryCostSelfTotal float64 = 0 //化验费
  5454. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5455. var treatCostTotal float64 = 0 //治疗费用
  5456. var treatCostSelfTotal float64 = 0 //治疗费用
  5457. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5458. decimal.DivisionPrecision = 2
  5459. var bed_fulamt_ownpay_amt float64 = 0
  5460. var operation_fulamt_ownpay_amt float64 = 0
  5461. var other_fulamt_ownpay_amt float64 = 0
  5462. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5463. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5464. var check_fulamt_ownpay_amt float64 = 0
  5465. var material_fulamt_ownpay_amt float64 = 0
  5466. var laboratory_fulamt_ownpay_amt float64 = 0
  5467. var treat_fulamt_ownpay_amt float64 = 0
  5468. var bed_claa_sunmfee float64 = 0
  5469. var bed_clab_amt float64 = 0
  5470. var bed_other_amt float64 = 0
  5471. var operation_claa_sunmfee float64 = 0
  5472. var operation_clab_amt float64 = 0
  5473. var operation_other_amt float64 = 0
  5474. var other_claa_sunmfee float64 = 0
  5475. var other_clab_amt float64 = 0
  5476. var other_other_amt float64 = 0
  5477. var westernMedicine_claa_sunmfee float64 = 0
  5478. var westernMedicine_clab_amt float64 = 0
  5479. var westernMedicine_other_amt float64 = 0
  5480. var chineseTraditional_claa_sunmfee float64 = 0
  5481. var chineseTraditional_clab_amt float64 = 0
  5482. var chineseTraditional_other_amt float64 = 0
  5483. var check_claa_sunmfee float64 = 0
  5484. var check_clab_amt float64 = 0
  5485. var check_other_amt float64 = 0
  5486. var material_claa_sunmfee float64 = 0
  5487. var material_clab_amt float64 = 0
  5488. var material_other_amt float64 = 0
  5489. var laboratory_claa_sunmfee float64 = 0
  5490. var laboratory_clab_amt float64 = 0
  5491. var laboratory_other_amt float64 = 0
  5492. var treat_claa_sunmfee float64 = 0
  5493. var treat_clab_amt float64 = 0
  5494. var treat_other_amt float64 = 0
  5495. for _, item := range order.HisOrderInfo {
  5496. if item.MedChrgitmType == "01" { //床位费
  5497. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5498. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5499. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5500. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5501. if item.ChrgitmLv == "1" {
  5502. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5503. }
  5504. if item.ChrgitmLv == "2" {
  5505. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5506. }
  5507. if item.ChrgitmLv == "3" {
  5508. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5509. }
  5510. }
  5511. if item.MedChrgitmType == "03" { //检查费
  5512. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5513. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5514. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5515. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5516. if item.ChrgitmLv == "1" {
  5517. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5518. }
  5519. if item.ChrgitmLv == "2" {
  5520. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5521. }
  5522. if item.ChrgitmLv == "3" {
  5523. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5524. }
  5525. }
  5526. if item.MedChrgitmType == "04" { //化验费
  5527. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5528. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5529. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5530. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5531. if item.ChrgitmLv == "1" {
  5532. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5533. }
  5534. if item.ChrgitmLv == "2" {
  5535. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5536. }
  5537. if item.ChrgitmLv == "3" {
  5538. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5539. }
  5540. }
  5541. if item.MedChrgitmType == "05" { //治疗费
  5542. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5543. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5544. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5545. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5546. if item.ChrgitmLv == "1" {
  5547. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5548. }
  5549. if item.ChrgitmLv == "2" {
  5550. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5551. }
  5552. if item.ChrgitmLv == "3" {
  5553. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5554. }
  5555. }
  5556. if item.MedChrgitmType == "06" { //手术费
  5557. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5558. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5559. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5560. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5561. if item.ChrgitmLv == "1" {
  5562. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5563. }
  5564. if item.ChrgitmLv == "2" {
  5565. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5566. }
  5567. if item.ChrgitmLv == "3" {
  5568. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5569. }
  5570. }
  5571. if item.MedChrgitmType == "08" { //材料费
  5572. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5573. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5574. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5575. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5576. if item.ChrgitmLv == "1" {
  5577. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5578. }
  5579. if item.ChrgitmLv == "2" {
  5580. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5581. }
  5582. if item.ChrgitmLv == "3" {
  5583. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5584. }
  5585. }
  5586. if item.MedChrgitmType == "09" { //西药费
  5587. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5588. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5589. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5590. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5591. if item.ChrgitmLv == "1" {
  5592. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5593. }
  5594. if item.ChrgitmLv == "2" {
  5595. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5596. }
  5597. if item.ChrgitmLv == "3" {
  5598. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5599. }
  5600. }
  5601. if item.MedChrgitmType == "11" { //中成费
  5602. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5603. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5604. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5605. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5606. if item.ChrgitmLv == "1" {
  5607. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5608. }
  5609. if item.ChrgitmLv == "2" {
  5610. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5611. }
  5612. if item.ChrgitmLv == "3" {
  5613. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5614. }
  5615. }
  5616. if item.MedChrgitmType == "14" { //其他费
  5617. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5618. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5619. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5620. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5621. if item.ChrgitmLv == "1" {
  5622. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5623. }
  5624. if item.ChrgitmLv == "2" {
  5625. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5626. }
  5627. if item.ChrgitmLv == "3" {
  5628. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5629. }
  5630. }
  5631. }
  5632. var iteminfoStructs []service.IteminfoStruct
  5633. if bedCostTotal != 0 {
  5634. iteminfo.MedChrgitm = "01"
  5635. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5636. iteminfo.Amt = bedCostTotal
  5637. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5638. iteminfo.ClabAmt = bed_clab_amt
  5639. iteminfo.OthAmt = bed_other_amt
  5640. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5641. }
  5642. if checkCostTotal != 0 {
  5643. iteminfo.MedChrgitm = "03"
  5644. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5645. iteminfo.Amt = checkCostTotal
  5646. iteminfo.ClaaSumfee = check_claa_sunmfee
  5647. iteminfo.ClabAmt = check_clab_amt
  5648. iteminfo.OthAmt = check_other_amt
  5649. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5650. }
  5651. if laboratoryCostTotal != 0 {
  5652. iteminfo.MedChrgitm = "04"
  5653. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5654. iteminfo.Amt = laboratoryCostTotal
  5655. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5656. iteminfo.ClabAmt = laboratory_clab_amt
  5657. iteminfo.OthAmt = laboratory_other_amt
  5658. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5659. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5660. }
  5661. if treatCostTotal != 0 {
  5662. iteminfo.MedChrgitm = "05"
  5663. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5664. iteminfo.Amt = treatCostTotal
  5665. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5666. iteminfo.ClabAmt = treat_clab_amt
  5667. iteminfo.OthAmt = treat_other_amt
  5668. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5669. //(struct4101.IteminfoStruct, iteminfo)
  5670. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5671. }
  5672. if operationCostTotal != 0 {
  5673. iteminfo.MedChrgitm = "06"
  5674. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5675. iteminfo.Amt = operationCostTotal
  5676. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5677. iteminfo.ClabAmt = operation_clab_amt
  5678. iteminfo.OthAmt = operation_other_amt
  5679. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5680. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5681. }
  5682. if materialCostTotal != 0 {
  5683. iteminfo.MedChrgitm = "08"
  5684. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5685. iteminfo.Amt = materialCostTotal
  5686. iteminfo.ClaaSumfee = material_claa_sunmfee
  5687. iteminfo.ClabAmt = material_clab_amt
  5688. iteminfo.OthAmt = material_other_amt
  5689. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5690. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5691. }
  5692. if westernMedicineCostTotal != 0 {
  5693. iteminfo.MedChrgitm = "09"
  5694. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5695. iteminfo.Amt = westernMedicineCostTotal
  5696. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5697. iteminfo.ClabAmt = westernMedicine_clab_amt
  5698. iteminfo.OthAmt = westernMedicine_other_amt
  5699. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5700. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5701. }
  5702. if chineseTraditionalMedicineCostTotal != 0 {
  5703. iteminfo.MedChrgitm = "11"
  5704. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5705. iteminfo.Amt = westernMedicineCostTotal
  5706. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5707. iteminfo.ClabAmt = westernMedicine_clab_amt
  5708. iteminfo.OthAmt = westernMedicine_other_amt
  5709. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5710. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5711. }
  5712. if otherCostTotal != 0 {
  5713. iteminfo.MedChrgitm = "14"
  5714. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5715. iteminfo.Amt = otherCostTotal
  5716. iteminfo.ClaaSumfee = other_claa_sunmfee
  5717. iteminfo.ClabAmt = other_clab_amt
  5718. iteminfo.OthAmt = other_other_amt
  5719. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5720. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5721. }
  5722. struct4101.IteminfoStruct = iteminfoStructs
  5723. struct4101.Ntly = "中国"
  5724. struct4101.AdmCaty = "A03.06"
  5725. var resOther ResultSeventeenOther
  5726. var res ResultSeventeen
  5727. if miConfig.MdtrtareaAdmvs == "150499" {
  5728. var pp models.PublicParams
  5729. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5730. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5731. pp.FixmedinsName = miConfig.OrgName
  5732. pp.FixmedinsCode = miConfig.Code
  5733. pp.RequestUrl = miConfig.Url
  5734. pp.Cainfo = miConfig.Cainfo
  5735. pp.SecretKey = miConfig.SecretKey
  5736. pp.AccessKey = miConfig.AccessKey
  5737. pp.OpterName = curRoles.UserName
  5738. client := &http.Client{}
  5739. var req *http.Request
  5740. data := make(map[string]interface{})
  5741. data["struct4101"] = struct4101
  5742. data["pp"] = pp
  5743. bytesData, _ := json.Marshal(data)
  5744. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  5745. resp, _ := client.Do(req)
  5746. defer resp.Body.Close()
  5747. body, ioErr := ioutil.ReadAll(resp.Body)
  5748. if ioErr != nil {
  5749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5751. return
  5752. }
  5753. var respJSON map[string]interface{}
  5754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5757. return
  5758. }
  5759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5760. userJSONBytes, _ := json.Marshal(respJSON)
  5761. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  5762. utils.ErrorLog("解析失败:%v", err)
  5763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5764. return
  5765. }
  5766. res.InfRefmsgid = resOther.InfRefmsgid
  5767. res.Output = resOther.Output
  5768. res.ErrMsg = resOther.ErrMsg
  5769. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  5770. res.Infcode = infocode
  5771. } else {
  5772. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  5773. var dat map[string]interface{}
  5774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5775. fmt.Println(dat)
  5776. } else {
  5777. fmt.Println(err)
  5778. }
  5779. userJSONBytes, _ := json.Marshal(dat)
  5780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5781. utils.ErrorLog("解析失败:%v", err)
  5782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5783. return
  5784. }
  5785. }
  5786. if res.Infcode != 0 {
  5787. c.ServeSuccessJSON(map[string]interface{}{
  5788. "failed_code": -10,
  5789. "msg": res.ErrMsg,
  5790. })
  5791. return
  5792. } else {
  5793. if miConfig.MdtrtareaAdmvs != "150499" {
  5794. order.FaPiaoNumber = zero
  5795. order.FaPiaoCode = last_order.FaPiaoCode
  5796. service.UpdateOrder(order)
  5797. }
  5798. hisFundSettleListResult := &models.HisFundSettleListResult{
  5799. Number: res.Output.SetlListId,
  5800. Status: 1,
  5801. Ctime: time.Now().Unix(),
  5802. Mtime: time.Now().Unix(),
  5803. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5804. IsUpload: 1,
  5805. OrderId: order_id,
  5806. }
  5807. service.CreateUploadRecord(hisFundSettleListResult)
  5808. c.ServeSuccessJSON(map[string]interface{}{
  5809. "msg": "上传成功",
  5810. "result": hisFundSettleListResult,
  5811. })
  5812. return
  5813. }
  5814. }
  5815. //func (c *HisApiController) GetBatchSettleList() {
  5816. // orders, _ := service.GetAllHisOrder(10106)
  5817. // for _, item := range orders {
  5818. // order_id := item.ID
  5819. // order, _ := service.GetHisOrderByIDTwo(order_id)
  5820. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5821. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5822. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5823. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  5824. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5825. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5826. //
  5827. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5828. //
  5829. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5830. //
  5831. // if order.ID == 0 {
  5832. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5833. // return
  5834. // }
  5835. // if his.BalanceAccountsType == 2 {
  5836. // continue
  5837. // }
  5838. // struct4101 := service.Struct4101{
  5839. // PsnNo: order.PsnNo,
  5840. // MdtrtId: order.MdtrtId,
  5841. // SetlId: order.SetlId,
  5842. // PsnName: order.PsnName,
  5843. // Gend: order.Gend,
  5844. // Brdy: his.Brdy,
  5845. // Age: his.Age,
  5846. // Naty: order.Naty,
  5847. // PatnCertType: "01",
  5848. // Certno: order.Certno,
  5849. // Prfs: "90",
  5850. // ConerName: roles[0].UserName,
  5851. // PatnRlts: "99",
  5852. // ConerAddr: miConfig.OrgName,
  5853. // ConerTel: admin.Mobile,
  5854. // HiType: order.Insutype,
  5855. // Insuplc: his.InsuplcAdmdvs,
  5856. // MaindiagFlag: "1",
  5857. // BillCode: order.SetlId,
  5858. // BillNo: order.SetlId,
  5859. // BizSn: order.Number,
  5860. // PsnSelfPay: order.PsnPartAmt,
  5861. // PsnOwnPay: order.PsnPartAmt,
  5862. // AcctPay: order.AcctPay,
  5863. // PsnCashpay: order.PsnCashPay,
  5864. // HiPaymtd: "1",
  5865. // Hsorg: his.InsuplcAdmdvs,
  5866. // HsorgOpter: his.InsuplcAdmdvs,
  5867. // MedinsFillPsn: curRoles.UserName,
  5868. // MedinsFillDept: depart.Name,
  5869. // IptMedType: "2",
  5870. // }
  5871. // struct4101.SetlBegnDate = order.SetlTime
  5872. // struct4101.SetlEndDate = order.SetlTime
  5873. // //if order.SettleType == 1 {
  5874. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  5875. // // dateStr := t.Format("2006-01-02")
  5876. // // struct4101.SetlBegnDate = dateStr
  5877. // // struct4101.SetlEndDate = dateStr
  5878. // //} else {
  5879. // // t := time.Unix(int64(order.SettleStartTime), 0)
  5880. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  5881. // // dateStartStr := t.Format("2006-01-02")
  5882. // // dateEndStr := t2.Format("2006-01-02")
  5883. // // struct4101.SetlBegnDate = dateStartStr
  5884. // // struct4101.SetlEndDate = dateEndStr
  5885. // //}
  5886. //
  5887. // var rf []CustomFundPay
  5888. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  5889. //
  5890. // var tempFunPays []service.CustomStruct
  5891. // var tempFunPay610100 service.CustomStruct
  5892. //
  5893. // for _, item := range rf {
  5894. // if item.FundPayType == "610100" {
  5895. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  5896. // tempFunPay610100.FundPayType = item.FundPayType
  5897. // } else {
  5898. // var tempFunPay service.CustomStruct
  5899. // tempFunPay.FundPayamt = item.FundPayamt
  5900. // tempFunPay.FundPayType = item.FundPayType
  5901. // tempFunPays = append(tempFunPays, tempFunPay)
  5902. // }
  5903. // }
  5904. // tempFunPays = append(tempFunPays, tempFunPay610100)
  5905. // struct4101.CustomStruct = tempFunPays
  5906. //
  5907. // var tempDiaginfos []service.DiaginfoStructTwo
  5908. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5909. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5910. //
  5911. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5912. // var config []*models.HisXtDiagnoseConfig
  5913. // for _, item := range diagnosis_ids {
  5914. // id, _ := strconv.ParseInt(item, 10, 64)
  5915. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5916. // config = append(config, &diagnosisConfig)
  5917. // }
  5918. //
  5919. // for index, item := range config {
  5920. // if index == 0 {
  5921. // var tempDiaginfo service.DiaginfoStructTwo
  5922. // tempDiaginfo.DiagCode = item.CountryCode
  5923. // tempDiaginfo.DiagName = item.CountryContentName
  5924. // tempDiaginfo.DiagType = "1"
  5925. // tempDiaginfo.MaindiagFlag = "1"
  5926. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5927. // } else {
  5928. //
  5929. // var tempDiaginfo service.DiaginfoStructTwo
  5930. // tempDiaginfo.DiagCode = item.CountryCode
  5931. // tempDiaginfo.DiagName = item.CountryContentName
  5932. // tempDiaginfo.DiagType = "2"
  5933. // tempDiaginfo.MaindiagFlag = "0"
  5934. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5935. // }
  5936. // }
  5937. // struct4101.Diseinfo = tempDiaginfos
  5938. //
  5939. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  5940. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5941. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5942. // tempOpspdiseinfo2.OprnOprtCode = ""
  5943. // tempOpspdiseinfo2.OprnOprtName = ""
  5944. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5945. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5946. //
  5947. // var iteminfo service.IteminfoStruct
  5948. //
  5949. // var bedCostTotal float64 = 0 //床位总费
  5950. // var bedCostSelfTotal float64 = 0 //床位自费
  5951. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5952. //
  5953. // var examineCostTotal float64 = 0 //诊查总费
  5954. // var examineCostSelfTotal float64 = 0 //诊查自费
  5955. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  5956. //
  5957. // var nursingCostTotal float64 = 0 //护理总费
  5958. // var nursingCostSelfTotal float64 = 0 //护理自费
  5959. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  5960. //
  5961. // var chineseMedicineCostTotal float64 = 0 //中成药
  5962. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  5963. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  5964. //
  5965. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  5966. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  5967. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  5968. //
  5969. // var registerCostTotal float64 = 0 //一般诊疗费
  5970. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  5971. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  5972. //
  5973. // var operationCostTotal float64 = 0 //手术费
  5974. // var operationCostSelfTotal float64 = 0 //手术费
  5975. // var operationCostPartSelfTotal float64 = 0 //手术费
  5976. //
  5977. // var otherCostTotal float64 = 0 //其他费用
  5978. // var otherCostSelfTotal float64 = 0 //其他费用
  5979. // var otherCostPartSelfTotal float64 = 0 //其他费用
  5980. //
  5981. // var materialCostTotal float64 = 0 //材料费
  5982. // var materialCostSelfTotal float64 = 0 //材料费
  5983. // var materialCostPartSelfTotal float64 = 0 //材料费
  5984. //
  5985. // var westernMedicineCostTotal float64 = 0 //西药费
  5986. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  5987. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5988. //
  5989. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5990. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5991. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5992. //
  5993. // var checkCostTotal float64 = 0 //检查费
  5994. // var checkCostSelfTotal float64 = 0 //检查费
  5995. // var checkCostPartSelfTotal float64 = 0 //检查费
  5996. //
  5997. // var laboratoryCostTotal float64 = 0 //化验费
  5998. // var laboratoryCostSelfTotal float64 = 0 //化验费
  5999. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6000. //
  6001. // var treatCostTotal float64 = 0 //治疗费用
  6002. // var treatCostSelfTotal float64 = 0 //治疗费用
  6003. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  6004. //
  6005. // decimal.DivisionPrecision = 2
  6006. //
  6007. // var bed_fulamt_ownpay_amt float64 = 0
  6008. //
  6009. // var examine_fulamt_ownpay_amt float64 = 0
  6010. //
  6011. // var nursing_fulamt_ownpay_amt float64 = 0
  6012. //
  6013. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  6014. //
  6015. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  6016. //
  6017. // var register_fulamt_ownpay_amt float64 = 0
  6018. //
  6019. // var operation_fulamt_ownpay_amt float64 = 0
  6020. // var other_fulamt_ownpay_amt float64 = 0
  6021. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  6022. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6023. // var check_fulamt_ownpay_amt float64 = 0
  6024. // var material_fulamt_ownpay_amt float64 = 0
  6025. // var laboratory_fulamt_ownpay_amt float64 = 0
  6026. // var treat_fulamt_ownpay_amt float64 = 0
  6027. //
  6028. // var bed_claa_sunmfee float64 = 0
  6029. // var bed_clab_amt float64 = 0
  6030. // var bed_other_amt float64 = 0
  6031. //
  6032. // var examine_claa_sunmfee float64 = 0
  6033. // var examine_clab_amt float64 = 0
  6034. // var examine_other_amt float64 = 0
  6035. //
  6036. // var nursing_claa_sunmfee float64 = 0
  6037. // var nursing_clab_amt float64 = 0
  6038. // var nursing_other_amt float64 = 0
  6039. //
  6040. // var chinese_medicine_claa_sunmfee float64 = 0
  6041. // var chinese_medicine_clab_amt float64 = 0
  6042. // var chinese_medicine_other_amt float64 = 0
  6043. //
  6044. // var commonly_treatment_claa_sunmfee float64 = 0
  6045. // var commonly_treatment_clab_amt float64 = 0
  6046. // var commonly_treatment_other_amt float64 = 0
  6047. //
  6048. // var operation_claa_sunmfee float64 = 0
  6049. // var operation_clab_amt float64 = 0
  6050. // var operation_other_amt float64 = 0
  6051. //
  6052. // var other_claa_sunmfee float64 = 0
  6053. // var other_clab_amt float64 = 0
  6054. // var other_other_amt float64 = 0
  6055. //
  6056. // var westernMedicine_claa_sunmfee float64 = 0
  6057. // var westernMedicine_clab_amt float64 = 0
  6058. // var westernMedicine_other_amt float64 = 0
  6059. //
  6060. // var chineseTraditional_claa_sunmfee float64 = 0
  6061. // var chineseTraditional_clab_amt float64 = 0
  6062. // var chineseTraditional_other_amt float64 = 0
  6063. //
  6064. // var check_claa_sunmfee float64 = 0
  6065. // var check_clab_amt float64 = 0
  6066. // var check_other_amt float64 = 0
  6067. //
  6068. // var material_claa_sunmfee float64 = 0
  6069. // var material_clab_amt float64 = 0
  6070. // var material_other_amt float64 = 0
  6071. //
  6072. // var laboratory_claa_sunmfee float64 = 0
  6073. // var laboratory_clab_amt float64 = 0
  6074. // var laboratory_other_amt float64 = 0
  6075. //
  6076. // var treat_claa_sunmfee float64 = 0
  6077. // var treat_clab_amt float64 = 0
  6078. // var treat_other_amt float64 = 0
  6079. //
  6080. // var register_claa_sunmfee float64 = 0
  6081. // var register_clab_amt float64 = 0
  6082. // var register_other_amt float64 = 0
  6083. //
  6084. // for _, item := range order.HisOrderInfo {
  6085. // if item.MedChrgitmType == "01" { //床位费
  6086. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6087. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6088. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6089. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6090. // if item.ChrgitmLv == "1" {
  6091. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6092. // }
  6093. // if item.ChrgitmLv == "2" {
  6094. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6095. //
  6096. // }
  6097. // if item.ChrgitmLv == "3" {
  6098. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6099. // }
  6100. //
  6101. // }
  6102. //
  6103. // if item.MedChrgitmType == "02" { //诊查
  6104. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6105. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6106. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6107. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6108. // if item.ChrgitmLv == "1" {
  6109. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6110. // }
  6111. // if item.ChrgitmLv == "2" {
  6112. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6113. //
  6114. // }
  6115. // if item.ChrgitmLv == "3" {
  6116. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6117. // }
  6118. //
  6119. // }
  6120. //
  6121. // if item.MedChrgitmType == "03" { //检查费
  6122. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6123. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6124. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6125. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6126. // if item.ChrgitmLv == "1" {
  6127. //
  6128. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6129. //
  6130. // }
  6131. // if item.ChrgitmLv == "2" {
  6132. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6133. //
  6134. // }
  6135. // if item.ChrgitmLv == "3" {
  6136. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6137. // }
  6138. // }
  6139. //
  6140. // if item.MedChrgitmType == "04" { //化验费
  6141. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6142. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6143. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6144. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6145. // if item.ChrgitmLv == "1" {
  6146. //
  6147. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6148. //
  6149. // }
  6150. // if item.ChrgitmLv == "2" {
  6151. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6152. //
  6153. // }
  6154. // if item.ChrgitmLv == "3" {
  6155. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6156. // }
  6157. // }
  6158. //
  6159. // if item.MedChrgitmType == "05" { //治疗费
  6160. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6161. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6162. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6163. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6164. // if item.ChrgitmLv == "1" {
  6165. //
  6166. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6167. //
  6168. // }
  6169. // if item.ChrgitmLv == "2" {
  6170. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6171. //
  6172. // }
  6173. // if item.ChrgitmLv == "3" {
  6174. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6175. // }
  6176. // }
  6177. //
  6178. // if item.MedChrgitmType == "06" { //手术费
  6179. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6180. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6181. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6182. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6183. //
  6184. // if item.ChrgitmLv == "1" {
  6185. //
  6186. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6187. //
  6188. // }
  6189. // if item.ChrgitmLv == "2" {
  6190. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6191. //
  6192. // }
  6193. // if item.ChrgitmLv == "3" {
  6194. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6195. // }
  6196. // }
  6197. //
  6198. // if item.MedChrgitmType == "07" { //手术费
  6199. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6200. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6201. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6202. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6203. //
  6204. // if item.ChrgitmLv == "1" {
  6205. //
  6206. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6207. //
  6208. // }
  6209. // if item.ChrgitmLv == "2" {
  6210. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6211. //
  6212. // }
  6213. // if item.ChrgitmLv == "3" {
  6214. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6215. // }
  6216. // }
  6217. //
  6218. // if item.MedChrgitmType == "08" { //材料费
  6219. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6220. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6221. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6222. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6223. // if item.ChrgitmLv == "1" {
  6224. //
  6225. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6226. //
  6227. // }
  6228. // if item.ChrgitmLv == "2" {
  6229. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6230. //
  6231. // }
  6232. // if item.ChrgitmLv == "3" {
  6233. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6234. // }
  6235. // }
  6236. // if item.MedChrgitmType == "09" { //西药费
  6237. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6238. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6239. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6240. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6241. // if item.ChrgitmLv == "1" {
  6242. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6243. // }
  6244. // if item.ChrgitmLv == "2" {
  6245. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6246. // }
  6247. // if item.ChrgitmLv == "3" {
  6248. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6249. // }
  6250. // }
  6251. // if item.MedChrgitmType == "10" { //中药饮片
  6252. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6253. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6254. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6255. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6256. // if item.ChrgitmLv == "1" {
  6257. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6258. // }
  6259. // if item.ChrgitmLv == "2" {
  6260. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6261. // }
  6262. // if item.ChrgitmLv == "3" {
  6263. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6264. // }
  6265. // }
  6266. //
  6267. // if item.MedChrgitmType == "11" { //中成费
  6268. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6269. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6270. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6271. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6272. // if item.ChrgitmLv == "1" {
  6273. //
  6274. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6275. //
  6276. // }
  6277. // if item.ChrgitmLv == "2" {
  6278. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6279. //
  6280. // }
  6281. // if item.ChrgitmLv == "3" {
  6282. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6283. // }
  6284. // }
  6285. //
  6286. // if item.MedChrgitmType == "12" { //中成费
  6287. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6288. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6289. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6290. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6291. // if item.ChrgitmLv == "1" {
  6292. //
  6293. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6294. //
  6295. // }
  6296. // if item.ChrgitmLv == "2" {
  6297. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6298. //
  6299. // }
  6300. // if item.ChrgitmLv == "3" {
  6301. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6302. // }
  6303. // }
  6304. //
  6305. // if item.MedChrgitmType == "13" { //中成费
  6306. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6307. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6308. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6309. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6310. // if item.ChrgitmLv == "1" {
  6311. //
  6312. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6313. //
  6314. // }
  6315. // if item.ChrgitmLv == "2" {
  6316. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6317. //
  6318. // }
  6319. // if item.ChrgitmLv == "3" {
  6320. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6321. // }
  6322. // }
  6323. //
  6324. // if item.MedChrgitmType == "14" { //其他费
  6325. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6326. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6327. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6328. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6329. // if item.ChrgitmLv == "1" {
  6330. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6331. //
  6332. // }
  6333. // if item.ChrgitmLv == "2" {
  6334. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6335. //
  6336. // }
  6337. // if item.ChrgitmLv == "3" {
  6338. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6339. // }
  6340. // }
  6341. //
  6342. // }
  6343. //
  6344. // var iteminfoStructs []service.IteminfoStruct
  6345. //
  6346. // if bedCostTotal != 0 {
  6347. // iteminfo.MedChrgitm = "01"
  6348. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6349. // iteminfo.Amt = bedCostTotal
  6350. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  6351. // iteminfo.ClabAmt = bed_clab_amt
  6352. // iteminfo.OthAmt = bed_other_amt
  6353. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6354. // }
  6355. //
  6356. // if examineCostTotal != 0 {
  6357. // iteminfo.MedChrgitm = "02"
  6358. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  6359. // iteminfo.Amt = examineCostTotal
  6360. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  6361. // iteminfo.ClabAmt = examine_clab_amt
  6362. // iteminfo.OthAmt = examine_other_amt
  6363. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6364. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6365. // }
  6366. //
  6367. // if checkCostTotal != 0 {
  6368. // iteminfo.MedChrgitm = "03"
  6369. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6370. // iteminfo.Amt = checkCostTotal
  6371. // iteminfo.ClaaSumfee = check_claa_sunmfee
  6372. // iteminfo.ClabAmt = check_clab_amt
  6373. // iteminfo.OthAmt = check_other_amt
  6374. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6375. //
  6376. // }
  6377. //
  6378. // if laboratoryCostTotal != 0 {
  6379. // iteminfo.MedChrgitm = "04"
  6380. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6381. // iteminfo.Amt = laboratoryCostTotal
  6382. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6383. // iteminfo.ClabAmt = laboratory_clab_amt
  6384. // iteminfo.OthAmt = laboratory_other_amt
  6385. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6386. //
  6387. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6388. //
  6389. // }
  6390. //
  6391. // if treatCostTotal != 0 {
  6392. // iteminfo.MedChrgitm = "05"
  6393. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6394. // iteminfo.Amt = treatCostTotal
  6395. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  6396. // iteminfo.ClabAmt = treat_clab_amt
  6397. // iteminfo.OthAmt = treat_other_amt
  6398. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6399. // //(struct4101.IteminfoStruct, iteminfo)
  6400. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6401. // }
  6402. //
  6403. // if operationCostTotal != 0 {
  6404. // iteminfo.MedChrgitm = "06"
  6405. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6406. // iteminfo.Amt = operationCostTotal
  6407. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  6408. // iteminfo.ClabAmt = operation_clab_amt
  6409. // iteminfo.OthAmt = operation_other_amt
  6410. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6411. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6412. // }
  6413. //
  6414. // if nursingCostTotal != 0 {
  6415. // iteminfo.MedChrgitm = "07"
  6416. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  6417. // iteminfo.Amt = nursingCostTotal
  6418. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  6419. // iteminfo.ClabAmt = nursing_clab_amt
  6420. // iteminfo.OthAmt = nursing_other_amt
  6421. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6422. // }
  6423. //
  6424. // if materialCostTotal != 0 {
  6425. // iteminfo.MedChrgitm = "08"
  6426. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6427. // iteminfo.Amt = materialCostTotal
  6428. // iteminfo.ClaaSumfee = material_claa_sunmfee
  6429. // iteminfo.ClabAmt = material_clab_amt
  6430. // iteminfo.OthAmt = material_other_amt
  6431. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6432. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6433. // }
  6434. //
  6435. // if westernMedicineCostTotal != 0 {
  6436. // iteminfo.MedChrgitm = "09"
  6437. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6438. // iteminfo.Amt = westernMedicineCostTotal
  6439. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6440. // iteminfo.ClabAmt = westernMedicine_clab_amt
  6441. // iteminfo.OthAmt = westernMedicine_other_amt
  6442. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6443. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6444. //
  6445. // }
  6446. //
  6447. // if chineseMedicineCostTotal != 0 {
  6448. // iteminfo.MedChrgitm = "10"
  6449. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  6450. // iteminfo.Amt = chineseMedicineCostTotal
  6451. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  6452. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  6453. // iteminfo.OthAmt = chinese_medicine_other_amt
  6454. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6455. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6456. //
  6457. // }
  6458. //
  6459. // if chineseTraditionalMedicineCostTotal != 0 {
  6460. // iteminfo.MedChrgitm = "11"
  6461. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6462. // iteminfo.Amt = westernMedicineCostTotal
  6463. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6464. // iteminfo.ClabAmt = westernMedicine_clab_amt
  6465. // iteminfo.OthAmt = westernMedicine_other_amt
  6466. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6467. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6468. //
  6469. // }
  6470. //
  6471. // if commonlyTreatmentCostTotal != 0 {
  6472. // iteminfo.MedChrgitm = "12"
  6473. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  6474. // iteminfo.Amt = commonlyTreatmentCostTotal
  6475. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  6476. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  6477. // iteminfo.OthAmt = commonly_treatment_other_amt
  6478. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6479. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6480. //
  6481. // }
  6482. //
  6483. // if registerCostTotal != 0 {
  6484. // iteminfo.MedChrgitm = "13"
  6485. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  6486. // iteminfo.Amt = registerCostTotal
  6487. // iteminfo.ClaaSumfee = register_claa_sunmfee
  6488. // iteminfo.ClabAmt = register_clab_amt
  6489. // iteminfo.OthAmt = register_other_amt
  6490. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6491. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6492. //
  6493. // }
  6494. //
  6495. // if otherCostTotal != 0 {
  6496. // iteminfo.MedChrgitm = "14"
  6497. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6498. // iteminfo.Amt = otherCostTotal
  6499. // iteminfo.ClaaSumfee = other_claa_sunmfee
  6500. // iteminfo.ClabAmt = other_clab_amt
  6501. // iteminfo.OthAmt = other_other_amt
  6502. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6503. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6504. //
  6505. // }
  6506. // struct4101.IteminfoStruct = iteminfoStructs
  6507. // time_arr := strings.Split(order.SetlTime, " ")
  6508. // struct4101.AdmTime = time_arr[0]
  6509. // struct4101.AdmEndTime = time_arr[0]
  6510. //
  6511. // struct4101.DoctorName = doctor.UserName
  6512. // struct4101.DoctorCode = doctor.DoctorNumber
  6513. //
  6514. // struct4101.Ntly = "中国"
  6515. // struct4101.AdmCaty = "A03.06"
  6516. // var res ResultSeventeen
  6517. // if miConfig.MdtrtareaAdmvs == "421300" {
  6518. // data := make(map[string]interface{})
  6519. // data["struct4101"] = struct4101
  6520. // data["secret_key"] = miConfig.SecretKey
  6521. // data["org_name"] = miConfig.OrgName
  6522. // data["opera"] = curRoles.UserName
  6523. // data["code"] = miConfig.Code
  6524. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6525. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6526. //
  6527. // client := &http.Client{}
  6528. // bytesData, _ := json.Marshal(data)
  6529. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  6530. // resp, _ := client.Do(req)
  6531. // defer resp.Body.Close()
  6532. // body, ioErr := ioutil.ReadAll(resp.Body)
  6533. // if ioErr != nil {
  6534. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6536. // return
  6537. // }
  6538. // var respJSON map[string]interface{}
  6539. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6540. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6542. // return
  6543. // }
  6544. //
  6545. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6546. // userJSONBytes, _ := json.Marshal(respJSON)
  6547. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6548. // utils.ErrorLog("解析失败:%v", err)
  6549. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6550. // adminUser := c.GetAdminUserInfo()
  6551. // errlog := &models.HisOrderError{
  6552. // UserOrgId: adminUser.CurrentOrgId,
  6553. // Ctime: time.Now().Unix(),
  6554. // Mtime: time.Now().Unix(),
  6555. // ErrMsg: res.ErrMsg + "解析失败",
  6556. // Status: 1,
  6557. // PatientId: order_id,
  6558. // Stage: 10088,
  6559. // }
  6560. // service.CreateErrMsgLog(errlog)
  6561. // continue
  6562. // }
  6563. //
  6564. // } else {
  6565. // result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  6566. // fmt.Println(result)
  6567. //
  6568. // var dat map[string]interface{}
  6569. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6570. // fmt.Println(dat)
  6571. // } else {
  6572. // fmt.Println(err)
  6573. // }
  6574. // userJSONBytes, _ := json.Marshal(dat)
  6575. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6576. // utils.ErrorLog("解析失败:%v", err)
  6577. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6578. // adminUser := c.GetAdminUserInfo()
  6579. // errlog := &models.HisOrderError{
  6580. // UserOrgId: adminUser.CurrentOrgId,
  6581. // Ctime: time.Now().Unix(),
  6582. // Mtime: time.Now().Unix(),
  6583. // ErrMsg: res.ErrMsg + "解析失败",
  6584. // Status: 1,
  6585. // PatientId: order_id,
  6586. // Stage: 10106,
  6587. // }
  6588. // service.CreateErrMsgLog(errlog)
  6589. // continue
  6590. // }
  6591. // }
  6592. //
  6593. // if res.Infcode != 0 {
  6594. // adminUser := c.GetAdminUserInfo()
  6595. // errlog := &models.HisOrderError{
  6596. // UserOrgId: adminUser.CurrentOrgId,
  6597. // Ctime: time.Now().Unix(),
  6598. // Mtime: time.Now().Unix(),
  6599. // ErrMsg: res.ErrMsg,
  6600. // Status: 1,
  6601. // PatientId: order_id,
  6602. // Stage: 10106,
  6603. // }
  6604. // service.CreateErrMsgLog(errlog)
  6605. // continue
  6606. // } else {
  6607. // hisFundSettleListResult := &models.HisFundSettleListResult{
  6608. // Number: res.Output.SetlListId,
  6609. // Status: 1,
  6610. // Ctime: time.Now().Unix(),
  6611. // Mtime: time.Now().Unix(),
  6612. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6613. // IsUpload: 1,
  6614. // OrderId: order_id,
  6615. // }
  6616. // service.CreateUploadRecord(hisFundSettleListResult)
  6617. // continue
  6618. // }
  6619. // }
  6620. //}
  6621. func (c *HisApiController) GetOrgInfo() {
  6622. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  6623. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  6624. }
  6625. func (c *HisApiController) GetHisPatientInfo() {
  6626. medical_insurance_card := c.GetString("medical_insurance_card")
  6627. id_card_type, _ := c.GetInt64("id_card_type")
  6628. id_card := c.GetString("id_card")
  6629. adminInfo := c.GetAdminUserInfo()
  6630. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6631. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6632. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  6633. IdCardNo := ""
  6634. if id_card_type == 1 {
  6635. IdCardNo = medical_insurance_card
  6636. } else if id_card_type == 2 {
  6637. IdCardNo = id_card
  6638. }
  6639. if config.IsOpen == 1 {
  6640. 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
  6641. resp, requestErr := http.Get(api)
  6642. if requestErr != nil {
  6643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6644. return
  6645. }
  6646. defer resp.Body.Close()
  6647. body, ioErr := ioutil.ReadAll(resp.Body)
  6648. if ioErr != nil {
  6649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6651. return
  6652. }
  6653. var respJSON map[string]interface{}
  6654. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6657. return
  6658. }
  6659. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6660. userJSONBytes, _ := json.Marshal(userJSON)
  6661. var res ResultTwo
  6662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6663. utils.ErrorLog("解析失败:%v", err)
  6664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6665. return
  6666. }
  6667. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6668. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6669. infoStr := string(Iinfos)
  6670. idetinfoStr := string(Idetinfos)
  6671. if res.Infcode == 0 {
  6672. his := models.VMHisPatient{
  6673. Status: 1,
  6674. Ctime: time.Now().Unix(),
  6675. Mtime: time.Now().Unix(),
  6676. PsnNo: res.Output.Baseinfo.PsnNo,
  6677. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6678. Certno: res.Output.Baseinfo.Certno,
  6679. PsnName: res.Output.Baseinfo.PsnName,
  6680. Gend: res.Output.Baseinfo.Gend,
  6681. Naty: res.Output.Baseinfo.Naty,
  6682. Brdy: res.Output.Baseinfo.Brdy,
  6683. Age: res.Output.Baseinfo.Age,
  6684. Iinfo: infoStr,
  6685. Idetinfo: idetinfoStr,
  6686. UserOrgId: adminInfo.CurrentOrgId,
  6687. IsReturn: 1,
  6688. IdCardType: id_card_type,
  6689. }
  6690. c.ServeSuccessJSON(map[string]interface{}{
  6691. "info": his,
  6692. })
  6693. } else {
  6694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6695. return
  6696. }
  6697. }
  6698. }
  6699. //func GetBasBaseInfo() (jsonStr string, err error) {
  6700. //
  6701. // handle := syscall.NewLazyDLL("SSCard.dll")
  6702. // add := handle.NewProc("ReadCardBas")
  6703. // str := make([]byte, 1024)
  6704. // str1 := make([]byte, 1024)
  6705. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6706. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  6707. //
  6708. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  6709. //
  6710. // fmt.Println("> Add(4,5)的结果为:", ret)
  6711. // handle.Release()
  6712. //
  6713. // return "", nil
  6714. //
  6715. //}
  6716. //func GetQRBaseInfo() (jsonStr string, err error) {
  6717. // handle := syscall.LoadDLL("SSCard.dll")
  6718. // ReadCardBas := handle.FindProc("GetQRBase")
  6719. //
  6720. // str := make([]byte, 256)
  6721. // str1 := make([]byte, 256)
  6722. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6723. //
  6724. // fmt.Println(string(str))
  6725. // fmt.Println(r)
  6726. // return string(str), nil
  6727. //}
  6728. //func CardInit() int {
  6729. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  6730. // add := DllTestDef.MustFindProc("Init")
  6731. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6732. // if err != nil {
  6733. // fmt.Println("SSCard的运算结果为:", ret)
  6734. // }
  6735. // result := int(ret)
  6736. // return result
  6737. //}
  6738. //func CardInit() int {
  6739. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  6740. // if err != nil {
  6741. // fmt.Println("SSCard的运算结果为:", ret)
  6742. // }
  6743. // fmt.Println(err)
  6744. // result := int(ret)
  6745. // return result
  6746. //}
  6747. func IntPtr(n int) uintptr {
  6748. return uintptr(n)
  6749. }
  6750. func StrPtr(s string) uintptr {
  6751. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  6752. }
  6753. type Result2001 struct {
  6754. Cainfo interface{} `json:"cainfo"`
  6755. ErrMsg string `json:"err_msg"`
  6756. InfRefmsgid string `json:"inf_refmsgid"`
  6757. Infcode int64 `json:"infcode"`
  6758. Output struct {
  6759. Trtinfo struct {
  6760. PsnNo string `json:"psn_no"`
  6761. TrtChkType string `json:"trt_chk_type"`
  6762. FundPayType string `json:"fund_pay_type"`
  6763. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6764. Begndate string `json:"begndate"`
  6765. Enddate string `json:"enddate"`
  6766. TrtChkRslt string `json:"trt_chk_rslt"`
  6767. } `json:"trtinfo"`
  6768. } `json:"output"`
  6769. RefmsgTime string `json:"refmsg_time"`
  6770. RespondTime string `json:"respond_time"`
  6771. Signtype interface{} `json:"signtype"`
  6772. WarnMsg interface{} `json:"warn_msg"`
  6773. }
  6774. type Result2001Org10265 struct {
  6775. Cainfo interface{} `json:"cainfo"`
  6776. ErrMsg string `json:"err_msg"`
  6777. InfRefmsgid string `json:"inf_refmsgid"`
  6778. Infcode string `json:"infcode"`
  6779. Output struct {
  6780. Trtinfo struct {
  6781. PsnNo string `json:"psn_no"`
  6782. TrtChkType string `json:"trt_chk_type"`
  6783. FundPayType string `json:"fund_pay_type"`
  6784. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  6785. Begndate string `json:"begndate"`
  6786. Enddate string `json:"enddate"`
  6787. TrtChkRslt string `json:"trt_chk_rslt"`
  6788. } `json:"trtinfo"`
  6789. } `json:"output"`
  6790. RefmsgTime string `json:"refmsg_time"`
  6791. RespondTime string `json:"respond_time"`
  6792. Signtype interface{} `json:"signtype"`
  6793. WarnMsg interface{} `json:"warn_msg"`
  6794. }
  6795. type ResultTwo struct {
  6796. ErrMsg string `json:"err_msg"`
  6797. InfRefmsgid string `json:"inf_refmsgid"`
  6798. Infcode int64 `json:"infcode"`
  6799. Output struct {
  6800. Baseinfo struct {
  6801. Age float64 `json:"age"`
  6802. Brdy string `json:"brdy"`
  6803. Certno string `json:"certno"`
  6804. Gend string `json:"gend"`
  6805. Naty string `json:"naty"`
  6806. PsnCertType string `json:"psn_cert_type"`
  6807. PsnName string `json:"psn_name"`
  6808. PsnNo string `json:"psn_no"`
  6809. } `json:"baseinfo"`
  6810. Idetinfo []interface{} `json:"idetinfo"`
  6811. Iinfo []struct {
  6812. Balc float64 `json:"balc"`
  6813. CvlservFlag string `json:"cvlserv_flag"`
  6814. EmpName string `json:"emp_name"`
  6815. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6816. Insutype string `json:"insutype"`
  6817. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6818. PausInsuDate string `json:"paus_insu_date"`
  6819. PsnInsuDate string `json:"psn_insu_date"`
  6820. PsnInsuStas string `json:"psn_insu_stas"`
  6821. PsnType string `json:"psn_type"`
  6822. } `json:"insuinfo"`
  6823. } `json:"output"`
  6824. RefmsgTime string `json:"refmsg_time"`
  6825. RespondTime string `json:"respond_time"`
  6826. Signtype interface{} `json:"signtype"`
  6827. WarnInfo interface{} `json:"warn_info"`
  6828. }
  6829. type ResultTwo10265 struct {
  6830. ErrMsg string `json:"err_msg"`
  6831. InfRefmsgid string `json:"inf_refmsgid"`
  6832. Infcode string `json:"infcode"`
  6833. Output struct {
  6834. Baseinfo struct {
  6835. Age float64 `json:"age"`
  6836. Brdy string `json:"brdy"`
  6837. Certno string `json:"certno"`
  6838. Gend string `json:"gend"`
  6839. Naty string `json:"naty"`
  6840. PsnCertType string `json:"psn_cert_type"`
  6841. PsnName string `json:"psn_name"`
  6842. PsnNo string `json:"psn_no"`
  6843. } `json:"baseinfo"`
  6844. Idetinfo []interface{} `json:"idetinfo"`
  6845. Iinfo []struct {
  6846. Balc float64 `json:"balc"`
  6847. CvlservFlag string `json:"cvlserv_flag"`
  6848. EmpName string `json:"emp_name"`
  6849. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6850. Insutype string `json:"insutype"`
  6851. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6852. PausInsuDate string `json:"paus_insu_date"`
  6853. PsnInsuDate string `json:"psn_insu_date"`
  6854. PsnInsuStas string `json:"psn_insu_stas"`
  6855. PsnType string `json:"psn_type"`
  6856. } `json:"insuinfo"`
  6857. } `json:"output"`
  6858. RefmsgTime string `json:"refmsg_time"`
  6859. RespondTime string `json:"respond_time"`
  6860. Signtype interface{} `json:"signtype"`
  6861. WarnInfo interface{} `json:"warn_info"`
  6862. }
  6863. type ResultThree struct {
  6864. Cainfo interface{} `json:"cainfo"`
  6865. ErrMsg string `json:"err_msg"`
  6866. InfRefmsgid string `json:"inf_refmsgid"`
  6867. Infcode int64 `json:"infcode"`
  6868. Output struct {
  6869. Data struct {
  6870. IptOtpNo string `json:"ipt_otp_no"`
  6871. MdtrtID string `json:"mdtrt_id"`
  6872. PsnNo string `json:"psn_no"`
  6873. } `json:"data"`
  6874. } `json:"output"`
  6875. RefmsgTime string `json:"refmsg_time"`
  6876. RespondTime string `json:"respond_time"`
  6877. Signtype interface{} `json:"signtype"`
  6878. WarnMsg interface{} `json:"warn_msg"`
  6879. }
  6880. type ResultThree10265 struct {
  6881. Cainfo interface{} `json:"cainfo"`
  6882. ErrMsg string `json:"err_msg"`
  6883. InfRefmsgid string `json:"inf_refmsgid"`
  6884. Infcode string `json:"infcode"`
  6885. Output struct {
  6886. Data struct {
  6887. IptOtpNo string `json:"ipt_otp_no"`
  6888. MdtrtID string `json:"mdtrt_id"`
  6889. PsnNo string `json:"psn_no"`
  6890. } `json:"data"`
  6891. } `json:"output"`
  6892. RefmsgTime string `json:"refmsg_time"`
  6893. RespondTime string `json:"respond_time"`
  6894. Signtype interface{} `json:"signtype"`
  6895. WarnMsg interface{} `json:"warn_msg"`
  6896. }
  6897. type ResultFour struct {
  6898. Cainfo string `json:"cainfo"`
  6899. ErrMsg string `json:"err_msg"`
  6900. InfRefmsgid string `json:"inf_refmsgid"`
  6901. Infcode int64 `json:"infcode"`
  6902. Output struct {
  6903. Result []struct {
  6904. BasMednFlag string `json:"bas_medn_flag"`
  6905. ChldMedcFlag string `json:"chld_medc_flag"`
  6906. ChrgitmLv string `json:"chrgitm_lv"`
  6907. Cnt float64 `json:"cnt"`
  6908. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6909. DrtReimFlag string `json:"drt_reim_flag"`
  6910. FeedetlSn string `json:"feedetl_sn"`
  6911. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6912. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6913. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6914. ListSpItemFlag string `json:"list_sp_item_flag"`
  6915. LmtUsedFlag string `json:"lmt_used_flag"`
  6916. MedChrgitmType string `json:"med_chrgitm_type"`
  6917. Memo string `json:"memo"`
  6918. OverlmtAmt float64 `json:"overlmt_amt"`
  6919. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6920. Pric float64 `json:"pric"`
  6921. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6922. SelfpayProp float64 `json:"selfpay_prop"`
  6923. } `json:"result"`
  6924. } `json:"output"`
  6925. RefmsgTime string `json:"refmsg_time"`
  6926. RespondTime string `json:"respond_time"`
  6927. Signtype string `json:"signtype"`
  6928. WarnMsg string `json:"warn_msg"`
  6929. }
  6930. type ResultFour10265 struct {
  6931. Cainfo string `json:"cainfo"`
  6932. ErrMsg string `json:"err_msg"`
  6933. InfRefmsgid string `json:"inf_refmsgid"`
  6934. Infcode string `json:"infcode"`
  6935. Output struct {
  6936. Result []struct {
  6937. BasMednFlag string `json:"bas_medn_flag"`
  6938. ChldMedcFlag string `json:"chld_medc_flag"`
  6939. ChrgitmLv string `json:"chrgitm_lv"`
  6940. Cnt float64 `json:"cnt"`
  6941. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6942. DrtReimFlag string `json:"drt_reim_flag"`
  6943. FeedetlSn string `json:"feedetl_sn"`
  6944. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6945. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6946. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6947. ListSpItemFlag string `json:"list_sp_item_flag"`
  6948. LmtUsedFlag string `json:"lmt_used_flag"`
  6949. MedChrgitmType string `json:"med_chrgitm_type"`
  6950. Memo string `json:"memo"`
  6951. OverlmtAmt float64 `json:"overlmt_amt"`
  6952. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6953. Pric float64 `json:"pric"`
  6954. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6955. SelfpayProp float64 `json:"selfpay_prop"`
  6956. } `json:"result"`
  6957. } `json:"output"`
  6958. RefmsgTime string `json:"refmsg_time"`
  6959. RespondTime string `json:"respond_time"`
  6960. Signtype string `json:"signtype"`
  6961. WarnMsg string `json:"warn_msg"`
  6962. }
  6963. type ResultMemo struct {
  6964. InsuAdmdvs string `json:"insuAdmdvs"`
  6965. }
  6966. // [{"begntime":"2022-01-01 00:00:00","endtime":"2022-12-31 00:00:00","memo":"{\"matIdetCode\":\"20\",\"insuAdmdvs\":\"350481\"}","psn_idet_type":"23","psn_type_lv":null}]
  6967. type ResultIDInfo struct {
  6968. Begntime string `json:"begntime"`
  6969. Endtime string `json:"endtime"`
  6970. Memo string `json:"memo"`
  6971. }
  6972. type ResultFive struct {
  6973. Balc float64 `json:"balc"`
  6974. CvlservFlag string `json:"cvlserv_flag"`
  6975. EmpName string `json:"emp_name"`
  6976. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6977. Insutype string `json:"insutype"`
  6978. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  6979. PausInsuDate string `json:"paus_insu_date"`
  6980. PsnInsuDate string `json:"psn_insu_date"`
  6981. PsnInsuStas string `json:"psn_insu_stas"`
  6982. PsnType string `json:"psn_type"`
  6983. }
  6984. type ResultSix struct {
  6985. Cainfo interface{} `json:"cainfo"`
  6986. ErrMsg string `json:"err_msg"`
  6987. InfRefmsgid string `json:"inf_refmsgid"`
  6988. Infcode int64 `json:"infcode"`
  6989. Output struct {
  6990. } `json:"output"`
  6991. RefmsgTime string `json:"refmsg_time"`
  6992. RespondTime string `json:"respond_time"`
  6993. Signtype interface{} `json:"signtype"`
  6994. WarnMsg interface{} `json:"warn_msg"`
  6995. }
  6996. type ResultSix10265 struct {
  6997. Cainfo interface{} `json:"cainfo"`
  6998. ErrMsg string `json:"err_msg"`
  6999. InfRefmsgid string `json:"inf_refmsgid"`
  7000. Infcode string `json:"infcode"`
  7001. Output struct {
  7002. } `json:"output"`
  7003. RefmsgTime string `json:"refmsg_time"`
  7004. RespondTime string `json:"respond_time"`
  7005. Signtype interface{} `json:"signtype"`
  7006. WarnMsg interface{} `json:"warn_msg"`
  7007. }
  7008. type ResultSeven struct {
  7009. Cainfo string `json:"cainfo"`
  7010. ErrMsg string `json:"err_msg"`
  7011. InfRefmsgid string `json:"inf_refmsgid"`
  7012. Infcode int64 `json:"infcode"`
  7013. Output struct {
  7014. Setldetail []interface{} `json:"setldetail"`
  7015. Setlinfo struct {
  7016. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7017. AcctPay float64 `json:"acct_pay"`
  7018. ActPayDedc float64 `json:"act_pay_dedc"`
  7019. Age float64 `json:"age"`
  7020. Balc float64 `json:"balc"`
  7021. Brdy string `json:"brdy"`
  7022. Certno string `json:"certno"`
  7023. ClrOptins string `json:"clr_optins"`
  7024. ClrType string `json:"clr_type"`
  7025. ClrWay string `json:"clr_way"`
  7026. CvlservFlag string `json:"cvlserv_flag"`
  7027. CvlservPay float64 `json:"cvlserv_pay"`
  7028. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7029. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7030. Gend string `json:"gend"`
  7031. HifesPay float64 `json:"hifes_pay"`
  7032. HifmiPay float64 `json:"hifmi_pay"`
  7033. HifpPay float64 `json:"hifp_pay"`
  7034. HospPartAmt float64 `json:"hosp_part_amt"`
  7035. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7036. Insutype string `json:"insutype"`
  7037. MafPay float64 `json:"maf_pay"`
  7038. MdtrtCertType string `json:"mdtrt_cert_type"`
  7039. HifobPay float64 `json:"hifob_pay"`
  7040. MdtrtID string `json:"mdtrt_id"`
  7041. MedType string `json:"med_type"`
  7042. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7043. MedinsSetlID string `json:"medins_setl_id"`
  7044. Naty string `json:"naty"`
  7045. OthPay float64 `json:"oth_pay"`
  7046. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7047. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7048. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7049. PsnCashPay float64 `json:"psn_cash_pay"`
  7050. PsnCertType string `json:"psn_cert_type"`
  7051. PsnName string `json:"psn_name"`
  7052. PsnNo string `json:"psn_no"`
  7053. PsnPartAmt float64 `json:"psn_part_amt"`
  7054. PsnType string `json:"psn_type"`
  7055. SetlID string `json:"setl_id"`
  7056. SetlTime string `json:"setl_time"`
  7057. } `json:"setlinfo"`
  7058. } `json:"output"`
  7059. RefmsgTime string `json:"refmsg_time"`
  7060. RespondTime string `json:"respond_time"`
  7061. Signtype interface{} `json:"signtype"`
  7062. WarnMsg interface{} `json:"warn_msg"`
  7063. }
  7064. type ResultSeven10265 struct {
  7065. Cainfo string `json:"cainfo"`
  7066. ErrMsg string `json:"err_msg"`
  7067. InfRefmsgid string `json:"inf_refmsgid"`
  7068. Infcode string `json:"infcode"`
  7069. Output struct {
  7070. Setldetail []interface{} `json:"setldetail"`
  7071. Setlinfo struct {
  7072. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7073. AcctPay float64 `json:"acct_pay"`
  7074. ActPayDedc float64 `json:"act_pay_dedc"`
  7075. Age float64 `json:"age"`
  7076. Balc float64 `json:"balc"`
  7077. Brdy string `json:"brdy"`
  7078. Certno string `json:"certno"`
  7079. ClrOptins string `json:"clr_optins"`
  7080. ClrType string `json:"clr_type"`
  7081. ClrWay string `json:"clr_way"`
  7082. CvlservFlag string `json:"cvlserv_flag"`
  7083. CvlservPay float64 `json:"cvlserv_pay"`
  7084. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7085. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7086. Gend string `json:"gend"`
  7087. HifesPay float64 `json:"hifes_pay"`
  7088. HifmiPay float64 `json:"hifmi_pay"`
  7089. HifpPay float64 `json:"hifp_pay"`
  7090. HospPartAmt float64 `json:"hosp_part_amt"`
  7091. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7092. Insutype string `json:"insutype"`
  7093. MafPay float64 `json:"maf_pay"`
  7094. MdtrtCertType string `json:"mdtrt_cert_type"`
  7095. HifobPay float64 `json:"hifob_pay"`
  7096. MdtrtID string `json:"mdtrt_id"`
  7097. MedType string `json:"med_type"`
  7098. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7099. MedinsSetlID string `json:"medins_setl_id"`
  7100. Naty string `json:"naty"`
  7101. OthPay float64 `json:"oth_pay"`
  7102. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7103. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7104. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7105. PsnCashPay float64 `json:"psn_cash_pay"`
  7106. PsnCertType string `json:"psn_cert_type"`
  7107. PsnName string `json:"psn_name"`
  7108. PsnNo string `json:"psn_no"`
  7109. PsnPartAmt float64 `json:"psn_part_amt"`
  7110. PsnType string `json:"psn_type"`
  7111. SetlID string `json:"setl_id"`
  7112. SetlTime string `json:"setl_time"`
  7113. } `json:"setlinfo"`
  7114. } `json:"output"`
  7115. RefmsgTime string `json:"refmsg_time"`
  7116. RespondTime string `json:"respond_time"`
  7117. Signtype interface{} `json:"signtype"`
  7118. WarnMsg interface{} `json:"warn_msg"`
  7119. }
  7120. type ResultEight struct {
  7121. Cainfo string `json:"cainfo"`
  7122. ErrMsg string `json:"err_msg"`
  7123. InfRefmsgid string `json:"inf_refmsgid"`
  7124. Infcode int64 `json:"infcode"`
  7125. Output struct {
  7126. Stmtinfo struct {
  7127. SetlOptins string `json:"setl_optins"`
  7128. StmtRslt string `json:"stmt_rslt"`
  7129. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7130. } `json:"stmtinfo"`
  7131. } `json:"output"`
  7132. RefmsgTime string `json:"refmsg_time"`
  7133. RespondTime string `json:"respond_time"`
  7134. Signtype interface{} `json:"signtype"`
  7135. WarnMsg interface{} `json:"warn_msg"`
  7136. }
  7137. type ResultEightFor10188 struct {
  7138. Cainfo string `json:"cainfo"`
  7139. ErrMsg string `json:"err_msg"`
  7140. InfRefmsgid string `json:"inf_refmsgid"`
  7141. Infcode string `json:"infcode"`
  7142. Output struct {
  7143. Stmtinfo struct {
  7144. SetlOptins string `json:"setl_optins"`
  7145. StmtRslt string `json:"stmt_rslt"`
  7146. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7147. } `json:"stmtinfo"`
  7148. } `json:"output"`
  7149. RefmsgTime string `json:"refmsg_time"`
  7150. RespondTime string `json:"respond_time"`
  7151. Signtype interface{} `json:"signtype"`
  7152. WarnMsg interface{} `json:"warn_msg"`
  7153. }
  7154. type ResultNine struct {
  7155. Cainfo string `json:"cainfo"`
  7156. ErrMsg string `json:"err_msg"`
  7157. InfRefmsgid string `json:"inf_refmsgid"`
  7158. Infcode int64 `json:"infcode"`
  7159. Output struct {
  7160. FileQuryNo string `json:"file_qury_no"`
  7161. } `json:"output"`
  7162. RefmsgTime string `json:"refmsg_time"`
  7163. RespondTime string `json:"respond_time"`
  7164. Signtype interface{} `json:"signtype"`
  7165. WarnMsg interface{} `json:"warn_msg"`
  7166. }
  7167. type ResultTen struct {
  7168. Cainfo string `json:"cainfo"`
  7169. ErrMsg string `json:"err_msg"`
  7170. InfRefmsgid string `json:"inf_refmsgid"`
  7171. Infcode int64 `json:"infcode"`
  7172. Output struct {
  7173. DldEndtime string `json:"dld_endtime"`
  7174. FileQuryNo string `json:"file_qury_no"`
  7175. Filename string `json:"filename"`
  7176. } `json:"output"`
  7177. RefmsgTime string `json:"refmsg_time"`
  7178. RespondTime string `json:"respond_time"`
  7179. Signtype interface{} `json:"signtype"`
  7180. WarnMsg interface{} `json:"warn_msg"`
  7181. }
  7182. //type Autogenerated struct {
  7183. // Output struct {
  7184. // Setlinfo struct {
  7185. // SetlTime string `json:"setl_time"`
  7186. // CvlservPay float64 `json:"cvlserv_pay"`
  7187. // Year string `json:"year"`
  7188. // MedType string `json:"med_type"`
  7189. // PsnPay float64 `json:"psn_pay"`
  7190. // OpterID string `json:"opter_id"`
  7191. // Begndate string `json:"begndate"`
  7192. // FlxempeFlag string `json:"flxempe_flag"`
  7193. // HifmiPay float64 `json:"hifmi_pay"`
  7194. // PsnNo string `json:"psn_no"`
  7195. // ActPayDedc float64 `json:"act_pay_dedc"`
  7196. // MedinsSetlID interface{} `json:"medins_setl_id"`
  7197. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7198. // ClrWay string `json:"clr_way"`
  7199. // OthPay float64 `json:"oth_pay"`
  7200. // Gend string `json:"gend"`
  7201. // MdtrtID string `json:"mdtrt_id"`
  7202. // AcctPay float64 `json:"acct_pay"`
  7203. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  7204. // Insutype string `json:"insutype"`
  7205. // Invono interface{} `json:"invono"`
  7206. // Enddate string `json:"enddate"`
  7207. // CashPayamt float64 `json:"cash_payamt"`
  7208. // PsnType string `json:"psn_type"`
  7209. // FixmedinsName string `json:"fixmedins_name"`
  7210. // HifpPay float64 `json:"hifp_pay"`
  7211. // NewFlag interface{} `json:"new_flag"`
  7212. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7213. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  7214. // PayLoc string `json:"pay_loc"`
  7215. // ClrType string `json:"clr_type"`
  7216. // RefdSetlFlag string `json:"refd_setl_flag"`
  7217. // CvlservFlag string `json:"cvlserv_flag"`
  7218. // EmpName string `json:"emp_name"`
  7219. // Brdy string `json:"brdy"`
  7220. // Naty string `json:"naty"`
  7221. // Certno string `json:"certno"`
  7222. // DiseCode string `json:"dise_code"`
  7223. // FixmedinsCode string `json:"fixmedins_code"`
  7224. // DedcHospLv string `json:"dedc_hosp_lv"`
  7225. // OpterName string `json:"opter_name"`
  7226. // Balc float64 `json:"balc"`
  7227. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7228. // PsnCertType string `json:"psn_cert_type"`
  7229. // HifobPay float64 `json:"hifob_pay"`
  7230. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  7231. // HifesPay float64 `json:"hifes_pay"`
  7232. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7233. // OptTime string `json:"opt_time"`
  7234. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7235. // SetlID string `json:"setl_id"`
  7236. // MafPay float64 `json:"maf_pay"`
  7237. // PsnName string `json:"psn_name"`
  7238. // InsuOptins interface{} `json:"insu_optins"`
  7239. // PrefFundPay interface{} `json:"pref_fund_pay"`
  7240. // ClrOptins string `json:"clr_optins"`
  7241. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7242. // DiseName string `json:"dise_name"`
  7243. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7244. // Age float64 `json:"age"`
  7245. // DtrtCertType string `json:"dtrt_cert_type"`
  7246. // HospLv string `json:"hosp_lv"`
  7247. // } `json:"setlinfo"`
  7248. // Setldetail []struct {
  7249. // FundPayType string `json:"fund_pay_type"`
  7250. // FundPayamt float64 `json:"fund_payamt"`
  7251. // SetlProcInfo interface{} `json:"setl_proc_info"`
  7252. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  7253. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  7254. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  7255. // PrefFundPay interface{} `json:"pref_fund_pay"`
  7256. // } `json:"setldetail"`
  7257. // } `json:"output"`
  7258. // Infcode int `json:"infcode"`
  7259. // WarnMsg interface{} `json:"warn_msg"`
  7260. // Cainfo interface{} `json:"cainfo"`
  7261. // ErrMsg interface{} `json:"err_msg"`
  7262. // RefmsgTime string `json:"refmsg_time"`
  7263. // Signtype interface{} `json:"signtype"`
  7264. // RespondTime string `json:"respond_time"`
  7265. // InfRefmsgid string `json:"inf_refmsgid"`
  7266. //}
  7267. type ResultEleven struct {
  7268. Cainfo string `json:"cainfo"`
  7269. ErrMsg string `json:"err_msg"`
  7270. InfRefmsgid string `json:"inf_refmsgid"`
  7271. Infcode int64 `json:"infcode"`
  7272. Output struct {
  7273. Setlinfo struct {
  7274. SetlTime string `json:"setl_time"`
  7275. CvlservPay float64 `json:"cvlserv_pay"`
  7276. Year string `json:"year"`
  7277. MedType string `json:"med_type"`
  7278. PsnPay float64 `json:"psn_pay"`
  7279. OpterID string `json:"opter_id"`
  7280. Begndate string `json:"begndate"`
  7281. FlxempeFlag string `json:"flxempe_flag"`
  7282. HifmiPay float64 `json:"hifmi_pay"`
  7283. PsnNo string `json:"psn_no"`
  7284. ActPayDedc float64 `json:"act_pay_dedc"`
  7285. MedinsSetlID interface{} `json:"medins_setl_id"`
  7286. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7287. ClrWay string `json:"clr_way"`
  7288. OthPay float64 `json:"oth_pay"`
  7289. Gend string `json:"gend"`
  7290. MdtrtID string `json:"mdtrt_id"`
  7291. AcctPay float64 `json:"acct_pay"`
  7292. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7293. Insutype string `json:"insutype"`
  7294. Invono interface{} `json:"invono"`
  7295. Enddate string `json:"enddate"`
  7296. CashPayamt float64 `json:"cash_payamt"`
  7297. PsnType string `json:"psn_type"`
  7298. FixmedinsName string `json:"fixmedins_name"`
  7299. HifpPay float64 `json:"hifp_pay"`
  7300. NewFlag interface{} `json:"new_flag"`
  7301. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7302. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7303. PayLoc string `json:"pay_loc"`
  7304. ClrType string `json:"clr_type"`
  7305. RefdSetlFlag string `json:"refd_setl_flag"`
  7306. CvlservFlag string `json:"cvlserv_flag"`
  7307. EmpName string `json:"emp_name"`
  7308. Brdy string `json:"brdy"`
  7309. Naty string `json:"naty"`
  7310. Certno string `json:"certno"`
  7311. DiseCode string `json:"dise_code"`
  7312. FixmedinsCode string `json:"fixmedins_code"`
  7313. DedcHospLv string `json:"dedc_hosp_lv"`
  7314. OpterName string `json:"opter_name"`
  7315. Balc float64 `json:"balc"`
  7316. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7317. PsnCertType string `json:"psn_cert_type"`
  7318. HifobPay float64 `json:"hifob_pay"`
  7319. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7320. HifesPay float64 `json:"hifes_pay"`
  7321. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7322. OptTime string `json:"opt_time"`
  7323. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7324. SetlID string `json:"setl_id"`
  7325. MafPay float64 `json:"maf_pay"`
  7326. PsnName string `json:"psn_name"`
  7327. InsuOptins interface{} `json:"insu_optins"`
  7328. PrefFundPay interface{} `json:"pref_fund_pay"`
  7329. ClrOptins string `json:"clr_optins"`
  7330. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7331. DiseName string `json:"dise_name"`
  7332. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7333. Age float64 `json:"age"`
  7334. DtrtCertType string `json:"dtrt_cert_type"`
  7335. HospLv string `json:"hosp_lv"`
  7336. PsnCashPay float64
  7337. } `json:"setlinfo"`
  7338. } `json:"output"`
  7339. RefmsgTime string `json:"refmsg_time"`
  7340. RespondTime string `json:"respond_time"`
  7341. Signtype interface{} `json:"signtype"`
  7342. WarnMsg interface{} `json:"warn_msg"`
  7343. }
  7344. type ResultEleven10265 struct {
  7345. Cainfo string `json:"cainfo"`
  7346. ErrMsg string `json:"err_msg"`
  7347. InfRefmsgid string `json:"inf_refmsgid"`
  7348. Infcode string `json:"infcode"`
  7349. Output struct {
  7350. Setlinfo struct {
  7351. SetlTime string `json:"setl_time"`
  7352. CvlservPay float64 `json:"cvlserv_pay"`
  7353. Year string `json:"year"`
  7354. MedType string `json:"med_type"`
  7355. PsnPay float64 `json:"psn_pay"`
  7356. OpterID string `json:"opter_id"`
  7357. Begndate string `json:"begndate"`
  7358. FlxempeFlag string `json:"flxempe_flag"`
  7359. HifmiPay float64 `json:"hifmi_pay"`
  7360. PsnNo string `json:"psn_no"`
  7361. ActPayDedc float64 `json:"act_pay_dedc"`
  7362. MedinsSetlID interface{} `json:"medins_setl_id"`
  7363. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7364. ClrWay string `json:"clr_way"`
  7365. OthPay float64 `json:"oth_pay"`
  7366. Gend string `json:"gend"`
  7367. MdtrtID string `json:"mdtrt_id"`
  7368. AcctPay float64 `json:"acct_pay"`
  7369. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7370. Insutype string `json:"insutype"`
  7371. Invono interface{} `json:"invono"`
  7372. Enddate string `json:"enddate"`
  7373. CashPayamt float64 `json:"cash_payamt"`
  7374. PsnType string `json:"psn_type"`
  7375. FixmedinsName string `json:"fixmedins_name"`
  7376. HifpPay float64 `json:"hifp_pay"`
  7377. NewFlag interface{} `json:"new_flag"`
  7378. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7379. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7380. PayLoc string `json:"pay_loc"`
  7381. ClrType string `json:"clr_type"`
  7382. RefdSetlFlag string `json:"refd_setl_flag"`
  7383. CvlservFlag string `json:"cvlserv_flag"`
  7384. EmpName string `json:"emp_name"`
  7385. Brdy string `json:"brdy"`
  7386. Naty string `json:"naty"`
  7387. Certno string `json:"certno"`
  7388. DiseCode string `json:"dise_code"`
  7389. FixmedinsCode string `json:"fixmedins_code"`
  7390. DedcHospLv string `json:"dedc_hosp_lv"`
  7391. OpterName string `json:"opter_name"`
  7392. Balc float64 `json:"balc"`
  7393. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7394. PsnCertType string `json:"psn_cert_type"`
  7395. HifobPay float64 `json:"hifob_pay"`
  7396. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7397. HifesPay float64 `json:"hifes_pay"`
  7398. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7399. OptTime string `json:"opt_time"`
  7400. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7401. SetlID string `json:"setl_id"`
  7402. MafPay float64 `json:"maf_pay"`
  7403. PsnName string `json:"psn_name"`
  7404. InsuOptins interface{} `json:"insu_optins"`
  7405. PrefFundPay interface{} `json:"pref_fund_pay"`
  7406. ClrOptins string `json:"clr_optins"`
  7407. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7408. DiseName string `json:"dise_name"`
  7409. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7410. Age float64 `json:"age"`
  7411. DtrtCertType string `json:"dtrt_cert_type"`
  7412. HospLv string `json:"hosp_lv"`
  7413. PsnCashPay float64
  7414. } `json:"setlinfo"`
  7415. } `json:"output"`
  7416. RefmsgTime string `json:"refmsg_time"`
  7417. RespondTime string `json:"respond_time"`
  7418. Signtype interface{} `json:"signtype"`
  7419. WarnMsg interface{} `json:"warn_msg"`
  7420. }
  7421. type ResultTwelve struct {
  7422. Cainfo string `json:"cainfo"`
  7423. ErrMsg string `json:"err_msg"`
  7424. InfRefmsgid string `json:"inf_refmsgid"`
  7425. Infcode int64 `json:"infcode"`
  7426. Output struct {
  7427. MdtrtId string `json:"mdtrt_id"`
  7428. ChrgBchno string `json:"chrg_bchno"`
  7429. PsnNo string `json:"psn_no"`
  7430. } `json:"output"`
  7431. RefmsgTime string `json:"refmsg_time"`
  7432. RespondTime string `json:"respond_time"`
  7433. Signtype interface{} `json:"signtype"`
  7434. WarnMsg interface{} `json:"warn_msg"`
  7435. }
  7436. type ResultThirteen struct {
  7437. ErrMsg string `json:"err_msg"`
  7438. InfRefmsgid string `json:"inf_refmsgid"`
  7439. Infcode int64 `json:"infcode"`
  7440. Output struct {
  7441. Result struct {
  7442. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7443. } `json:"result"`
  7444. } `json:"output"`
  7445. RefmsgTime string `json:"refmsg_time"`
  7446. RespondTime string `json:"respond_time"`
  7447. Signtype interface{} `json:"signtype"`
  7448. WarnInfo interface{} `json:"warn_info"`
  7449. }
  7450. type ResultThirteen10265 struct {
  7451. ErrMsg string `json:"err_msg"`
  7452. InfRefmsgid string `json:"inf_refmsgid"`
  7453. Infcode string `json:"infcode"`
  7454. Output struct {
  7455. Result struct {
  7456. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7457. } `json:"result"`
  7458. } `json:"output"`
  7459. RefmsgTime string `json:"refmsg_time"`
  7460. RespondTime string `json:"respond_time"`
  7461. Signtype interface{} `json:"signtype"`
  7462. WarnInfo interface{} `json:"warn_info"`
  7463. }
  7464. type ResultFourteen struct {
  7465. ErrMsg string `json:"err_msg"`
  7466. InfRefmsgid string `json:"inf_refmsgid"`
  7467. Infcode int64 `json:"infcode"`
  7468. Output struct {
  7469. } `json:"output"`
  7470. RefmsgTime string `json:"refmsg_time"`
  7471. RespondTime string `json:"respond_time"`
  7472. Signtype interface{} `json:"signtype"`
  7473. WarnInfo interface{} `json:"warn_info"`
  7474. }
  7475. type ResultFourteen10265 struct {
  7476. ErrMsg string `json:"err_msg"`
  7477. InfRefmsgid string `json:"inf_refmsgid"`
  7478. Infcode string `json:"infcode"`
  7479. Output struct {
  7480. } `json:"output"`
  7481. RefmsgTime string `json:"refmsg_time"`
  7482. RespondTime string `json:"respond_time"`
  7483. Signtype interface{} `json:"signtype"`
  7484. WarnInfo interface{} `json:"warn_info"`
  7485. }
  7486. type ResultSixteen struct {
  7487. Cainfo string `json:"cainfo"`
  7488. ErrMsg string `json:"err_msg"`
  7489. InfRefmsgid string `json:"inf_refmsgid"`
  7490. Infcode int64 `json:"infcode"`
  7491. Output struct {
  7492. Setldetail []interface{} `json:"setldetail"`
  7493. Setlinfo struct {
  7494. MdtrtID string `json:"mdtrt_id"`
  7495. SetlID string `json:"setl_id"`
  7496. ClrOptins string `json:"clr_optins"`
  7497. SetlTime string `json:"setl_time"`
  7498. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7499. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7500. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7501. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7502. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7503. ActPayDedc float64 `json:"act_pay_dedc"`
  7504. HifpPay float64 `json:"hifp_pay"`
  7505. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7506. Lfpay float64 `json:"selfpay"`
  7507. CvlservPay float64 `json:"cvlserv_pay"`
  7508. HifesPay float64 `json:"hifes_pay"`
  7509. HifmiPay float64 `json:"hifmi_pay"`
  7510. HifobPay float64 `json:"hifob_pay"`
  7511. MafPay float64 `json:"maf_pay"`
  7512. OthPay float64 `json:"oth_pay"`
  7513. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7514. PsnPartAmt float64 `json:"psn_part_amt"`
  7515. AcctPay float64 `json:"acct_pay"`
  7516. Balc float64 `json:"balc"`
  7517. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7518. HospPartAmt float64 `json:"hosp_part_amt"`
  7519. MedinsSetlID string `json:"medins_setl_id"`
  7520. PdnCashPay string `json:"pdn_cash_pay"`
  7521. } `json:"setlinfo"`
  7522. } `json:"output"`
  7523. RefmsgTime string `json:"refmsg_time"`
  7524. RespondTime string `json:"respond_time"`
  7525. Signtype interface{} `json:"signtype"`
  7526. WarnMsg interface{} `json:"warn_msg"`
  7527. }
  7528. type ResultSixteen10265 struct {
  7529. Cainfo string `json:"cainfo"`
  7530. ErrMsg string `json:"err_msg"`
  7531. InfRefmsgid string `json:"inf_refmsgid"`
  7532. Infcode string `json:"infcode"`
  7533. Output struct {
  7534. Setldetail []interface{} `json:"setldetail"`
  7535. Setlinfo struct {
  7536. MdtrtID string `json:"mdtrt_id"`
  7537. SetlID string `json:"setl_id"`
  7538. ClrOptins string `json:"clr_optins"`
  7539. SetlTime string `json:"setl_time"`
  7540. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7541. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7542. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7543. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7544. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7545. ActPayDedc float64 `json:"act_pay_dedc"`
  7546. HifpPay float64 `json:"hifp_pay"`
  7547. PoolPropSe float64 `json:"pool_prop_selfpay"`
  7548. Lfpay float64 `json:"selfpay"`
  7549. CvlservPay float64 `json:"cvlserv_pay"`
  7550. HifesPay float64 `json:"hifes_pay"`
  7551. HifmiPay float64 `json:"hifmi_pay"`
  7552. HifobPay float64 `json:"hifob_pay"`
  7553. MafPay float64 `json:"maf_pay"`
  7554. OthPay float64 `json:"oth_pay"`
  7555. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7556. PsnPartAmt float64 `json:"psn_part_amt"`
  7557. AcctPay float64 `json:"acct_pay"`
  7558. Balc float64 `json:"balc"`
  7559. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7560. HospPartAmt float64 `json:"hosp_part_amt"`
  7561. MedinsSetlID string `json:"medins_setl_id"`
  7562. PdnCashPay string `json:"pdn_cash_pay"`
  7563. } `json:"setlinfo"`
  7564. } `json:"output"`
  7565. RefmsgTime string `json:"refmsg_time"`
  7566. RespondTime string `json:"respond_time"`
  7567. Signtype interface{} `json:"signtype"`
  7568. WarnMsg interface{} `json:"warn_msg"`
  7569. }
  7570. type ResultSeventeen struct {
  7571. ErrMsg string `json:"err_msg"`
  7572. InfRefmsgid string `json:"inf_refmsgid"`
  7573. Infcode int64 `json:"infcode"`
  7574. Output struct {
  7575. SetlListId string `json:"setl_list_id"`
  7576. } `json:"output"`
  7577. RefmsgTime string `json:"refmsg_time"`
  7578. RespondTime string `json:"respond_time"`
  7579. Signtype string `json:"signtype"`
  7580. WarnInfo string `json:"warn_info"`
  7581. }
  7582. type ResultSeventeenOther struct {
  7583. ErrMsg string `json:"err_msg"`
  7584. InfRefmsgid string `json:"inf_refmsgid"`
  7585. Infcode string `json:"infcode"`
  7586. Output struct {
  7587. SetlListId string `json:"setl_list_id"`
  7588. } `json:"output"`
  7589. RefmsgTime string `json:"refmsg_time"`
  7590. RespondTime string `json:"respond_time"`
  7591. Signtype string `json:"signtype"`
  7592. WarnInfo string `json:"warn_info"`
  7593. }
  7594. type Result90991 struct {
  7595. ErrMsg string `json:"err_msg"`
  7596. InfRefmsgid string `json:"inf_refmsgid"`
  7597. Infcode int64 `json:"infcode"`
  7598. Output struct {
  7599. Result struct {
  7600. PsnNo string `json:"psn_no"`
  7601. CardStat string `json:"card_stat"`
  7602. Certno string `json:"certno"`
  7603. PsnName string `json:"psn_name"`
  7604. CheckStat string `json:"check_stat"`
  7605. SscnoCheckStat string `json:"sscno_check_stat"`
  7606. } `json:"result"`
  7607. } `json:"output"`
  7608. RefmsgTime string `json:"refmsg_time"`
  7609. RespondTime string `json:"respond_time"`
  7610. Signtype interface{} `json:"signtype"`
  7611. WarnInfo interface{} `json:"warn_info"`
  7612. }
  7613. type Result90100 struct {
  7614. ErrMsg string `json:"err_msg"`
  7615. InfRefmsgid string `json:"inf_refmsgid"`
  7616. Infcode int64 `json:"infcode"`
  7617. Output struct {
  7618. PoolareaNo string `json:"poolarea_no"`
  7619. PoolareaNoName string `json:"poolarea_no_name"`
  7620. Insutype string `json:"insutype"`
  7621. InsutypeName string `json:"insutype_name"`
  7622. ClctType string `json:"clct_type"`
  7623. ClctTypeName string `json:"clct_type_name"`
  7624. ClctFlag string `json:"clct_flag"`
  7625. ClctFlagName string `json:"clct_flag_name"`
  7626. AccrymBegn string `json:"accrym_begn"`
  7627. AccrymEnd string `json:"accrym_end"`
  7628. ClctTime string `json:"clct_time"`
  7629. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  7630. } `json:"output"`
  7631. RefmsgTime string `json:"refmsg_time"`
  7632. RespondTime string `json:"respond_time"`
  7633. Signtype interface{} `json:"signtype"`
  7634. WarnInfo interface{} `json:"warn_info"`
  7635. }
  7636. type Custom struct {
  7637. DetItemFeeSumamt string
  7638. Cut string
  7639. FeedetlSn string
  7640. Price string
  7641. MedListCodg string
  7642. Type int64
  7643. AdviceId int64
  7644. ProjectId int64
  7645. ItemId int64
  7646. }
  7647. type Result5301 struct {
  7648. ErrMsg string `json:"err_msg"`
  7649. InfRefmsgid string `json:"inf_refmsgid"`
  7650. Infcode int64 `json:"infcode"`
  7651. Output struct {
  7652. Result []struct {
  7653. OpspDiseCode string `json:"opsp_dise_code"`
  7654. OpspDiseName string `json:"opsp_dise_name"`
  7655. Begndate string `json:"begndate"`
  7656. Enddate string `json:"enddate"`
  7657. } `json:"feedetail"`
  7658. } `json:"output"`
  7659. RefmsgTime string `json:"refmsg_time"`
  7660. RespondTime string `json:"respond_time"`
  7661. Signtype interface{} `json:"signtype"`
  7662. WarnInfo interface{} `json:"warn_info"`
  7663. }
  7664. type Result5301For10265 struct {
  7665. ErrMsg string `json:"err_msg"`
  7666. InfRefmsgid string `json:"inf_refmsgid"`
  7667. Infcode string `json:"infcode"`
  7668. Output struct {
  7669. Result []struct {
  7670. OpspDiseCode string `json:"opsp_dise_code"`
  7671. OpspDiseName string `json:"opsp_dise_name"`
  7672. Begndate string `json:"begndate"`
  7673. Enddate string `json:"enddate"`
  7674. } `json:"feedetail"`
  7675. } `json:"output"`
  7676. RefmsgTime string `json:"refmsg_time"`
  7677. RespondTime string `json:"respond_time"`
  7678. Signtype interface{} `json:"signtype"`
  7679. WarnInfo interface{} `json:"warn_info"`
  7680. }
  7681. //获取个人信息----挂号-----上传就诊信息
  7682. func (c *HisApiController) GetRegisterInfo() {
  7683. id, _ := c.GetInt64("id")
  7684. record_time := c.GetString("record_time")
  7685. settlementValue, _ := c.GetInt64("settlement_value")
  7686. medical_insurance_card := c.GetString("medical_insurance_card")
  7687. name := c.GetString("name")
  7688. id_card_type, _ := c.GetInt64("id_card_type")
  7689. certificates, _ := c.GetInt64("certificates")
  7690. medical_care, _ := c.GetInt64("medical_care")
  7691. birthday := c.GetString("birthday")
  7692. id_card := c.GetString("id_card")
  7693. register_type, _ := c.GetInt64("register")
  7694. doctor, _ := c.GetInt64("doctor")
  7695. department, _ := c.GetInt64("department")
  7696. gender, _ := c.GetInt64("sex")
  7697. registration_fee, _ := c.GetFloat("registration_fee")
  7698. medical_expenses, _ := c.GetFloat("medical_expenses")
  7699. social_type, _ := c.GetInt64("social_type")
  7700. admin_user_id, _ := c.GetInt64("admin_user_id")
  7701. insuplc_admdvs := c.GetString("insuplc_admdvs")
  7702. mdtrt_type := c.GetString("mdtrt_type")
  7703. timeLayout := "2006-01-02"
  7704. loc, _ := time.LoadLocation("Local")
  7705. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  7706. birthUnix := birthdays.Unix()
  7707. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7708. if err != nil {
  7709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7710. return
  7711. }
  7712. recordDateTime := theTime.Unix()
  7713. adminInfo := c.GetAdminUserInfo()
  7714. var patient service.Patients
  7715. if id == 0 {
  7716. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  7717. } else {
  7718. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  7719. }
  7720. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7721. if patientPrescription.ID == 0 {
  7722. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7723. }
  7724. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7725. if patient.ID == 0 {
  7726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7727. return
  7728. }
  7729. if len(patient.IdCardNo) == 0 {
  7730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7731. return
  7732. }
  7733. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7734. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  7735. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  7736. //就诊结算未完成,不能进行二次挂号
  7737. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  7738. if len(his) >= 1 {
  7739. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  7740. if len(his) >= 1 && order.ID == 0 {
  7741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  7742. return
  7743. }
  7744. }
  7745. //var register_log string
  7746. if config.IsOpen == 1 {
  7747. var res ResultTwo
  7748. var res10265 ResultTwo10265
  7749. var PsnNo string
  7750. var PsnCertType string
  7751. var Certno string
  7752. var PsnName string
  7753. var Gend string
  7754. var Naty string
  7755. var Brdy string
  7756. var Age float64
  7757. var infoStr string
  7758. var idetinfoStr string
  7759. var infocode int64
  7760. var verify_number string
  7761. fmt.Println(verify_number)
  7762. if miConfig.MdtrtareaAdmvs == "421300" {
  7763. psn_info, _ := service.GetPsnByPatientId(id)
  7764. PsnNo = psn_info.PsnNo
  7765. PsnCertType = psn_info.PsnCertType
  7766. Certno = psn_info.Certno
  7767. PsnName = psn_info.PsnName
  7768. Gend = psn_info.Gend
  7769. Naty = psn_info.Naty
  7770. Brdy = psn_info.Brdy
  7771. Age = psn_info.Age
  7772. infoStr = psn_info.Insuinfo
  7773. idetinfoStr = psn_info.Idetinfo
  7774. infocode = 0
  7775. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7776. psn_info, _ := service.GetPsnByPatientId(id)
  7777. PsnNo = psn_info.PsnNo
  7778. PsnCertType = psn_info.PsnCertType
  7779. Certno = psn_info.Certno
  7780. PsnName = psn_info.PsnName
  7781. Gend = psn_info.Gend
  7782. Naty = psn_info.Naty
  7783. Brdy = psn_info.Brdy
  7784. Age = psn_info.Age
  7785. infoStr = psn_info.Insuinfo
  7786. idetinfoStr = psn_info.Idetinfo
  7787. infocode = 0
  7788. verify_number = psn_info.VerifyNumber
  7789. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7790. if id_card_type == 1 {
  7791. psn_info, _ := service.GetPsnByPatientId(id)
  7792. PsnNo = psn_info.PsnNo
  7793. PsnCertType = psn_info.PsnCertType
  7794. Certno = psn_info.Certno
  7795. PsnName = psn_info.PsnName
  7796. Gend = psn_info.Gend
  7797. Naty = psn_info.Naty
  7798. Brdy = psn_info.Brdy
  7799. Age = psn_info.Age
  7800. infoStr = psn_info.Insuinfo
  7801. idetinfoStr = psn_info.Idetinfo
  7802. infocode = 0
  7803. verify_number = psn_info.VerifyNumber
  7804. } else if id_card_type == 2 {
  7805. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, "", id_card)
  7806. fmt.Println(errMsgLog)
  7807. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7808. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7809. utils.ErrorLog("解析失败:%v", err)
  7810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7811. return
  7812. }
  7813. PsnNo = res.Output.Baseinfo.PsnNo
  7814. PsnCertType = res.Output.Baseinfo.PsnCertType
  7815. Certno = res.Output.Baseinfo.Certno
  7816. PsnName = res.Output.Baseinfo.PsnName
  7817. Gend = res.Output.Baseinfo.Gend
  7818. Naty = res.Output.Baseinfo.Naty
  7819. Brdy = res.Output.Baseinfo.Brdy
  7820. Age = res.Output.Baseinfo.Age
  7821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7822. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7823. infoStr = string(Iinfos)
  7824. idetinfoStr = string(Idetinfos)
  7825. infocode = res.Infcode
  7826. }
  7827. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7828. if id_card_type == 1 {
  7829. psn_info, _ := service.GetPsnByPatientId(id)
  7830. PsnNo = psn_info.PsnNo
  7831. PsnCertType = psn_info.PsnCertType
  7832. Certno = psn_info.Certno
  7833. PsnName = psn_info.PsnName
  7834. Gend = psn_info.Gend
  7835. Naty = psn_info.Naty
  7836. Brdy = psn_info.Brdy
  7837. Age = psn_info.Age
  7838. infoStr = psn_info.Insuinfo
  7839. idetinfoStr = psn_info.Idetinfo
  7840. infocode = 0
  7841. verify_number = psn_info.VerifyNumber
  7842. } else if id_card_type == 2 {
  7843. result, requestLog := service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "")
  7844. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7845. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7846. utils.ErrorLog("解析失败:%v", err)
  7847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7848. return
  7849. }
  7850. PsnNo = res.Output.Baseinfo.PsnNo
  7851. PsnCertType = res.Output.Baseinfo.PsnCertType
  7852. Certno = res.Output.Baseinfo.Certno
  7853. PsnName = res.Output.Baseinfo.PsnName
  7854. Gend = res.Output.Baseinfo.Gend
  7855. Naty = res.Output.Baseinfo.Naty
  7856. Brdy = res.Output.Baseinfo.Brdy
  7857. Age = res.Output.Baseinfo.Age
  7858. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7859. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7860. infoStr = string(Iinfos)
  7861. idetinfoStr = string(Idetinfos)
  7862. infocode = res.Infcode
  7863. }
  7864. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7865. if id_card_type == 1 {
  7866. psn_info, _ := service.GetPsnByPatientId(id)
  7867. PsnNo = psn_info.PsnNo
  7868. PsnCertType = psn_info.PsnCertType
  7869. Certno = psn_info.Certno
  7870. PsnName = psn_info.PsnName
  7871. Gend = psn_info.Gend
  7872. Naty = psn_info.Naty
  7873. Brdy = psn_info.Brdy
  7874. Age = psn_info.Age
  7875. infoStr = psn_info.Insuinfo
  7876. idetinfoStr = psn_info.Idetinfo
  7877. infocode = 0
  7878. verify_number = psn_info.VerifyNumber
  7879. } else if id_card_type == 2 {
  7880. result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", "", Certno)
  7881. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7882. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7883. utils.ErrorLog("解析失败:%v", err)
  7884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7885. return
  7886. }
  7887. PsnNo = res.Output.Baseinfo.PsnNo
  7888. PsnCertType = res.Output.Baseinfo.PsnCertType
  7889. Certno = res.Output.Baseinfo.Certno
  7890. PsnName = res.Output.Baseinfo.PsnName
  7891. Gend = res.Output.Baseinfo.Gend
  7892. Naty = res.Output.Baseinfo.Naty
  7893. Brdy = res.Output.Baseinfo.Brdy
  7894. Age = res.Output.Baseinfo.Age
  7895. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7896. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7897. infoStr = string(Iinfos)
  7898. idetinfoStr = string(Idetinfos)
  7899. infocode = res.Infcode
  7900. }
  7901. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7902. var result string
  7903. var requestLog string
  7904. result, requestLog = service.HeBeiyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), "")
  7905. if id_card_type == 4 {
  7906. psn_info, _ := service.GetPsnByPatientId(id)
  7907. PsnNo = psn_info.PsnNo
  7908. PsnCertType = psn_info.PsnCertType
  7909. Certno = psn_info.Certno
  7910. PsnName = psn_info.PsnName
  7911. Gend = psn_info.Gend
  7912. Naty = psn_info.Naty
  7913. Brdy = psn_info.Brdy
  7914. Age = psn_info.Age
  7915. infoStr = psn_info.Insuinfo
  7916. idetinfoStr = psn_info.Idetinfo
  7917. infocode = 0
  7918. verify_number = psn_info.VerifyNumber
  7919. } else {
  7920. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7921. if miConfig.Code == "H15049901371" {
  7922. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7923. utils.ErrorLog("解析失败:%v", err)
  7924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7925. return
  7926. }
  7927. res.ErrMsg = res10265.ErrMsg
  7928. res.Output = res10265.Output
  7929. res.InfRefmsgid = res10265.InfRefmsgid
  7930. } else {
  7931. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7932. utils.ErrorLog("解析失败:%v", err)
  7933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7934. return
  7935. }
  7936. }
  7937. PsnNo = res.Output.Baseinfo.PsnNo
  7938. PsnCertType = res.Output.Baseinfo.PsnCertType
  7939. Certno = res.Output.Baseinfo.Certno
  7940. PsnName = res.Output.Baseinfo.PsnName
  7941. Gend = res.Output.Baseinfo.Gend
  7942. Naty = res.Output.Baseinfo.Naty
  7943. Brdy = res.Output.Baseinfo.Brdy
  7944. Age = res.Output.Baseinfo.Age
  7945. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7946. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7947. infoStr = string(Iinfos)
  7948. idetinfoStr = string(Idetinfos)
  7949. if miConfig.Code == "H15049901371" {
  7950. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  7951. } else {
  7952. infocode = res.Infcode
  7953. }
  7954. }
  7955. } else {
  7956. var result string
  7957. var requestLog string
  7958. if miConfig.UserOrgId == 10138 {
  7959. if id_card_type != 4 || id_card_type != 1 {
  7960. var insa string
  7961. if len(patient.InsuplcAdmdvs) > 0 {
  7962. insa = patient.InsuplcAdmdvs
  7963. } else {
  7964. insa = miConfig.InsuplcAdmdvs
  7965. }
  7966. //psn_info, _ := service.GetPsnByPatientId(id)
  7967. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  7968. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  7969. }
  7970. } else {
  7971. var insa string
  7972. if len(patient.InsuplcAdmdvs) > 0 {
  7973. insa = patient.InsuplcAdmdvs
  7974. } else {
  7975. insa = miConfig.InsuplcAdmdvs
  7976. }
  7977. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  7978. }
  7979. if id_card_type == 4 || id_card_type == 1 {
  7980. psn_info, _ := service.GetPsnByPatientId(id)
  7981. PsnNo = psn_info.PsnNo
  7982. PsnCertType = psn_info.PsnCertType
  7983. Certno = psn_info.Certno
  7984. PsnName = psn_info.PsnName
  7985. Gend = psn_info.Gend
  7986. Naty = psn_info.Naty
  7987. Brdy = psn_info.Brdy
  7988. Age = psn_info.Age
  7989. infoStr = psn_info.Insuinfo
  7990. idetinfoStr = psn_info.Idetinfo
  7991. infocode = 0
  7992. verify_number = psn_info.VerifyNumber
  7993. } else {
  7994. saveLog(result, requestLog, "1101", "人员基本信息获取")
  7995. if miConfig.Code == "H15049901371" {
  7996. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7997. utils.ErrorLog("解析失败:%v", err)
  7998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7999. return
  8000. }
  8001. res.ErrMsg = res10265.ErrMsg
  8002. res.Output = res10265.Output
  8003. res.InfRefmsgid = res10265.InfRefmsgid
  8004. } else {
  8005. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8006. utils.ErrorLog("解析失败:%v", err)
  8007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8008. return
  8009. }
  8010. }
  8011. PsnNo = res.Output.Baseinfo.PsnNo
  8012. PsnCertType = res.Output.Baseinfo.PsnCertType
  8013. Certno = res.Output.Baseinfo.Certno
  8014. PsnName = res.Output.Baseinfo.PsnName
  8015. Gend = res.Output.Baseinfo.Gend
  8016. Naty = res.Output.Baseinfo.Naty
  8017. Brdy = res.Output.Baseinfo.Brdy
  8018. Age = res.Output.Baseinfo.Age
  8019. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8020. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8021. infoStr = string(Iinfos)
  8022. idetinfoStr = string(Idetinfos)
  8023. if miConfig.Code == "H15049901371" {
  8024. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8025. } else {
  8026. infocode = res.Infcode
  8027. }
  8028. }
  8029. }
  8030. if infocode == 0 {
  8031. his := models.VMHisPatient{
  8032. Name: name,
  8033. Gender: gender,
  8034. Birthday: birthUnix,
  8035. MedicalTreatmentType: medical_care,
  8036. IdType: certificates,
  8037. IdCardNo: id_card,
  8038. BalanceAccountsType: settlementValue,
  8039. SocialType: social_type,
  8040. MedicalInsuranceNumber: medical_insurance_card,
  8041. RegisterType: register_type,
  8042. RegisterCost: registration_fee,
  8043. TreatmentCost: medical_expenses,
  8044. Status: 1,
  8045. Ctime: time.Now().Unix(),
  8046. Mtime: time.Now().Unix(),
  8047. PsnNo: PsnNo,
  8048. PsnCertType: PsnCertType,
  8049. Certno: Certno,
  8050. PsnName: PsnName,
  8051. Gend: Gend,
  8052. Naty: Naty,
  8053. Brdy: Brdy,
  8054. Age: Age,
  8055. Iinfo: infoStr,
  8056. Idetinfo: idetinfoStr,
  8057. PatientId: patient.ID,
  8058. RecordDate: theTime.Unix(),
  8059. UserOrgId: adminInfo.CurrentOrgId,
  8060. AdminUserId: admin_user_id,
  8061. IsReturn: 1,
  8062. IdCardType: id_card_type,
  8063. Doctor: doctor,
  8064. Departments: department,
  8065. MdtrtGrpType: mdtrt_type,
  8066. }
  8067. timestamp := time.Now().Unix()
  8068. tempTime := time.Unix(timestamp, 0)
  8069. timeFormat := tempTime.Format("20060102150405")
  8070. chrgBchno := rand.Intn(100000) + 10000
  8071. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8072. his.Number = ipt_otp_no
  8073. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  8074. department, _ := service.GetDepartMentDetail(department)
  8075. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  8076. IdCardNo := ""
  8077. if id_card_type == 1 {
  8078. // IdCardNo = medical_insurance_card
  8079. IdCardNo = patient.IdCardNo
  8080. } else {
  8081. IdCardNo = patient.IdCardNo
  8082. }
  8083. var rf []*ResultFive
  8084. json.Unmarshal([]byte(his.Iinfo), &rf)
  8085. var insutypes []*ResultFive
  8086. var insutype string
  8087. var insuplc_admdvs_temp string
  8088. var is390 int = 0
  8089. var is310 int = 0
  8090. for _, item := range rf {
  8091. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8092. insutypes = append(insutypes, item)
  8093. }
  8094. }
  8095. if len(insutypes) == 1 {
  8096. insutype = insutypes[0].Insutype
  8097. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8098. } else {
  8099. for _, i := range insutypes {
  8100. if i.Insutype == "390" {
  8101. is390 = 1
  8102. }
  8103. if i.Insutype == "310" {
  8104. is310 = 1
  8105. }
  8106. }
  8107. }
  8108. if is390 == 1 {
  8109. insutype = "390"
  8110. }
  8111. if is310 == 1 {
  8112. insutype = "310"
  8113. }
  8114. fmt.Println(social_type)
  8115. if social_type > 0 {
  8116. insutype = strconv.FormatInt(social_type, 10)
  8117. }
  8118. var infocode int64
  8119. var resThree ResultThree
  8120. var resThree10265 ResultThree10265
  8121. if len(insuplc_admdvs) == 0 {
  8122. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  8123. } else {
  8124. insuplc_admdvs_temp = insuplc_admdvs
  8125. }
  8126. if miConfig.MdtrtareaAdmvs == "421300" {
  8127. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  8128. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  8129. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8130. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  8131. resp, requestErr := http.Get(api)
  8132. if requestErr != nil {
  8133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8134. return
  8135. }
  8136. body, ioErr := ioutil.ReadAll(resp.Body)
  8137. if ioErr != nil {
  8138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8140. return
  8141. }
  8142. var respJSON map[string]interface{}
  8143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8146. return
  8147. }
  8148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8149. result, _ := json.Marshal(respJSON)
  8150. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8151. utils.ErrorLog("解析失败:%v", err)
  8152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8153. return
  8154. }
  8155. infocode = resThree.Infcode
  8156. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8157. psn_info, _ := service.GetPsnByPatientId(id)
  8158. his.PsnNo = psn_info.PsnNo
  8159. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8160. var cert_no string
  8161. if id_card_type == 3 {
  8162. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  8163. cert_no = IdCardNo
  8164. } else if id_card_type == 4 {
  8165. cert_no = IdCardNo
  8166. psn_info.VerifyNumber = psn_info.VerifyNumber
  8167. } else {
  8168. bas := strings.Split(psn_info.CardInfo, "|")
  8169. cert_no = bas[2]
  8170. }
  8171. var hisPrescription []*models.HisPrescription
  8172. for _, item := range rf {
  8173. if item.Insutype == insutype {
  8174. //insuplc_admdvs = item.InsuplcAdmdvs
  8175. his.InsuplcAdmdvs = insuplc_admdvs
  8176. }
  8177. }
  8178. his.Insutype = insutype
  8179. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  8180. fmt.Println(res3101)
  8181. fmt.Println(res3101.Infcode)
  8182. if res3101.Infcode == "0" {
  8183. fmt.Println("33333333")
  8184. if len(res3101.Output.Result) > 0 {
  8185. fmt.Println("222222")
  8186. for _, item := range res3101.Output.Result {
  8187. if len(res3101.ErrMsg) == 0 {
  8188. res3101.ErrMsg = item.VolaCont
  8189. } else {
  8190. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  8191. }
  8192. }
  8193. c.ServeSuccessJSON(map[string]interface{}{
  8194. "failed_code": -10,
  8195. "msg": res3101.ErrMsg,
  8196. })
  8197. return
  8198. } else {
  8199. fmt.Println("11111")
  8200. var api string
  8201. if miConfig.MdtrtareaAdmvs == "320921" {
  8202. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  8203. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8204. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8205. } else {
  8206. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  8207. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8208. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8209. }
  8210. resp, requestErr := http.Get(api)
  8211. if requestErr != nil {
  8212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8213. return
  8214. }
  8215. body, ioErr := ioutil.ReadAll(resp.Body)
  8216. if ioErr != nil {
  8217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8219. return
  8220. }
  8221. var respJSON map[string]interface{}
  8222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8225. return
  8226. }
  8227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8228. result, _ := json.Marshal(respJSON)
  8229. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8230. utils.ErrorLog("解析失败:%v", err)
  8231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8232. return
  8233. }
  8234. resThree.ErrMsg = resThree10265.ErrMsg
  8235. resThree.Output = resThree10265.Output
  8236. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8237. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8238. }
  8239. } else if res3101.Infcode != "0" {
  8240. c.ServeSuccessJSON(map[string]interface{}{
  8241. "failed_code": -10,
  8242. "msg": res3101.ErrMsg,
  8243. })
  8244. return
  8245. }
  8246. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8247. psn_info, _ := service.GetPsnByPatientId(id)
  8248. var cert_no string
  8249. if id_card_type == 1 {
  8250. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8251. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8252. } else if id_card_type == 4 {
  8253. cert_no = psn_info.VerifyNumber
  8254. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8255. } else {
  8256. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8257. cert_no = psn_info.VerifyNumber
  8258. }
  8259. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no, record_time)
  8260. saveLog(result, requestLog, "2201", "挂号")
  8261. if miConfig.Code == "H15049901371" {
  8262. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8263. utils.ErrorLog("解析失败:%v", err)
  8264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8265. return
  8266. }
  8267. resThree.ErrMsg = resThree10265.ErrMsg
  8268. resThree.Output = resThree10265.Output
  8269. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8270. } else {
  8271. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8272. utils.ErrorLog("解析失败:%v", err)
  8273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8274. return
  8275. }
  8276. }
  8277. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8278. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  8279. psn_info, _ := service.GetPsnByPatientId(id)
  8280. var result string
  8281. var requestLog string
  8282. if id_card_type == 1 {
  8283. bas := strings.Split(psn_info.CardInfo, "|")
  8284. basNumber := bas[2]
  8285. card_sn := bas[3]
  8286. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  8287. saveLog(result, requestLog, "2201A", "挂号")
  8288. } else if id_card_type == 2 {
  8289. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  8290. saveLog(result, requestLog, "2201A", "挂号")
  8291. } else {
  8292. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "")
  8293. saveLog(result, requestLog, "2201A", "挂号")
  8294. }
  8295. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8296. utils.ErrorLog("解析失败:%v", err)
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. return
  8299. }
  8300. infocode = resThree.Infcode
  8301. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  8302. psn_info, _ := service.GetPsnByPatientId(id)
  8303. var result string
  8304. var requestLog string
  8305. if id_card_type == 1 {
  8306. bas := strings.Split(psn_info.CardInfo, "|")
  8307. basNumber := bas[2]
  8308. card_sn := bas[3]
  8309. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  8310. saveLog(result, requestLog, "2201A", "挂号")
  8311. } else if id_card_type == 2 {
  8312. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  8313. saveLog(result, requestLog, "2201A", "挂号")
  8314. } else {
  8315. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "")
  8316. saveLog(result, requestLog, "2201A", "挂号")
  8317. }
  8318. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8319. utils.ErrorLog("解析失败:%v", err)
  8320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8321. return
  8322. }
  8323. infocode = resThree.Infcode
  8324. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8325. psn_info, _ := service.GetPsnByPatientId(id)
  8326. result, requestLog := service.HeBeiyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  8327. saveLog(result, requestLog, "2201A", "挂号")
  8328. if miConfig.Code == "H15049901371" {
  8329. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8330. utils.ErrorLog("解析失败:%v", err)
  8331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8332. return
  8333. }
  8334. resThree.ErrMsg = resThree10265.ErrMsg
  8335. resThree.Output = resThree10265.Output
  8336. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8337. } else {
  8338. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8339. utils.ErrorLog("解析失败:%v", err)
  8340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8341. return
  8342. }
  8343. }
  8344. if miConfig.Code == "H15049901371" {
  8345. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8346. } else {
  8347. infocode = resThree.Infcode
  8348. }
  8349. } else {
  8350. psn_info, _ := service.GetPsnByPatientId(id)
  8351. if id_card_type == 4 || id_card_type == 1 {
  8352. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8353. }
  8354. var rf []*ResultFive
  8355. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  8356. var insutypes []*ResultFive
  8357. var insutype string
  8358. var is390 int = 0
  8359. var is310 int = 0
  8360. for _, item := range rf {
  8361. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8362. insutypes = append(insutypes, item)
  8363. }
  8364. }
  8365. if len(insutypes) == 1 {
  8366. insutype = insutypes[0].Insutype
  8367. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8368. } else {
  8369. for _, i := range insutypes {
  8370. if i.Insutype == "390" {
  8371. is390 = 1
  8372. }
  8373. if i.Insutype == "310" {
  8374. is310 = 1
  8375. }
  8376. }
  8377. }
  8378. if is390 == 1 {
  8379. insutype = "390"
  8380. }
  8381. if is310 == 1 {
  8382. insutype = "310"
  8383. }
  8384. fmt.Println(len(insutypes))
  8385. if len(insutypes) == 0 {
  8386. for index, item := range rf {
  8387. if index == 0 {
  8388. insutype = item.Insutype
  8389. insuplc_admdvs = item.InsuplcAdmdvs
  8390. }
  8391. }
  8392. fmt.Println(insutype)
  8393. fmt.Println(insuplc_admdvs)
  8394. }
  8395. if social_type > 0 {
  8396. insutype = strconv.FormatInt(social_type, 10)
  8397. }
  8398. result, requestLog := service.Gdyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  8399. saveLog(result, requestLog, "2201A", "挂号")
  8400. if miConfig.Code == "H15049901371" {
  8401. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8402. utils.ErrorLog("解析失败:%v", err)
  8403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8404. return
  8405. }
  8406. resThree.ErrMsg = resThree10265.ErrMsg
  8407. resThree.Output = resThree10265.Output
  8408. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8409. } else {
  8410. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8411. utils.ErrorLog("解析失败:%v", err)
  8412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8413. return
  8414. }
  8415. }
  8416. if miConfig.Code == "H15049901371" {
  8417. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8418. } else {
  8419. infocode = resThree.Infcode
  8420. }
  8421. }
  8422. if infocode != 0 {
  8423. adminUser := c.GetAdminUserInfo()
  8424. errlog := &models.HisOrderError{
  8425. UserOrgId: adminUser.CurrentOrgId,
  8426. Ctime: time.Now().Unix(),
  8427. Mtime: time.Now().Unix(),
  8428. ErrMsg: resThree.ErrMsg,
  8429. Status: 1,
  8430. PatientId: id,
  8431. RecordTime: recordDateTime,
  8432. Stage: 2,
  8433. }
  8434. service.CreateErrMsgLog(errlog)
  8435. c.ServeSuccessJSON(map[string]interface{}{
  8436. "failed_code": -10,
  8437. "msg": resThree.ErrMsg,
  8438. })
  8439. return
  8440. }
  8441. his.Number = resThree.Output.Data.MdtrtID
  8442. his.PsnNo = resThree.Output.Data.PsnNo
  8443. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  8444. his.IdCardNo = patient.IdCardNo
  8445. his.PhoneNumber = patient.Phone
  8446. his.UserOrgId = adminInfo.CurrentOrgId
  8447. his.Insutype = insutype
  8448. his.Ctime = time.Now().Unix()
  8449. his.Mtime = time.Now().Unix()
  8450. his.InsuplcAdmdvs = insuplc_admdvs_temp
  8451. his.Status = 1
  8452. his.MdtrtGrpType = mdtrt_type
  8453. service.UpdateHisPatientStatus(&his)
  8454. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  8455. c.ServeSuccessJSON(map[string]interface{}{
  8456. "his_info": his,
  8457. })
  8458. } else {
  8459. adminUser := c.GetAdminUserInfo()
  8460. errlog := &models.HisOrderError{
  8461. UserOrgId: adminUser.CurrentOrgId,
  8462. Ctime: time.Now().Unix(),
  8463. Mtime: time.Now().Unix(),
  8464. ErrMsg: res.ErrMsg,
  8465. Status: 1,
  8466. PatientId: id,
  8467. RecordTime: recordDateTime,
  8468. Stage: 1,
  8469. }
  8470. service.CreateErrMsgLog(errlog)
  8471. c.ServeSuccessJSON(map[string]interface{}{
  8472. "failed_code": -10,
  8473. "msg": res.ErrMsg,
  8474. })
  8475. return
  8476. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8477. }
  8478. }
  8479. }
  8480. func (c *HisApiController) GetUploadInfo() {
  8481. id, _ := c.GetInt64("id")
  8482. record_time := c.GetString("record_time")
  8483. his_patient_id, _ := c.GetInt64("his_patient_id")
  8484. order_id, _ := c.GetInt64("order_id")
  8485. pay_way, _ := c.GetInt64("pay_way")
  8486. pay_ways := c.GetString("pay_ways")
  8487. oth_desc := c.GetString("oth_desc")
  8488. pay_price, _ := c.GetFloat("pay_price")
  8489. pay_card_no := c.GetString("pay_card_no")
  8490. discount_price, _ := c.GetFloat("discount_price")
  8491. preferential_price, _ := c.GetFloat("preferential_price")
  8492. reality_price, _ := c.GetFloat("reality_price")
  8493. found_price, _ := c.GetFloat("found_price")
  8494. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  8495. private_price, _ := c.GetFloat("private_price")
  8496. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8497. admin_user_id, _ := c.GetInt64("admin_user_id")
  8498. fapiao_code := c.GetString("fapiao_code")
  8499. fapiao_number := c.GetString("fapiao_number")
  8500. diagnosis_id := c.GetString("diagnosis")
  8501. sick_type, _ := c.GetInt64("sick_type")
  8502. reg_type, _ := c.GetInt64("p_type")
  8503. begin_time := c.GetString("begin_time")
  8504. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  8505. cash_pay := c.GetString("cash_pay")
  8506. band_card_pay := c.GetString("band_card_pay")
  8507. wechat_pay := c.GetString("wechat_pay")
  8508. ali_pay := c.GetString("ali_pay")
  8509. jifen_pay := c.GetString("jifen_pay")
  8510. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  8511. fmt.Println(acct_used_flag)
  8512. id_str := c.GetString("ids")
  8513. ids_arr := strings.Split(id_str, ",")
  8514. timeLayout := "2006-01-02"
  8515. loc, _ := time.LoadLocation("Local")
  8516. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8517. if err != nil {
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8519. return
  8520. }
  8521. recordDateTime := theTime.Unix()
  8522. adminUser := c.GetAdminUserInfo()
  8523. var tempOrder models.HisOrder
  8524. tempOrder, _ = service.GetHisOrderByID(order_id)
  8525. var prescriptions []*models.HisPrescription
  8526. var start_time int64
  8527. var end_time int64
  8528. //押金模块
  8529. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  8530. tmp_decimal := c.GetString("tmp_decimal")
  8531. var decimal float64 //本次使用的押金
  8532. var errmsg error
  8533. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  8534. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  8535. return
  8536. }
  8537. if len(tmp_decimal) > 0 {
  8538. if tmp_decimal[0] == 45 {
  8539. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  8540. return
  8541. }
  8542. }
  8543. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  8544. fmt.Println(errs)
  8545. decimal = tt
  8546. //if adminUser.CurrentOrgId == 10106{
  8547. // if len(fapiao_code) == 0{
  8548. // fapiao_code = "144072080589"
  8549. // }
  8550. // if len(fapiao_number) == 0{
  8551. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  8552. // if order.ID == 0{
  8553. // fapiao_number = "00001520"
  8554. // }else{
  8555. // //fapiao_code = "00001520"
  8556. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  8557. // var zero string
  8558. // if fpNumber >= 1000{
  8559. // zero = "0000" + strconv.Itoa(fpNumber)
  8560. // }else if fpNumber >= 10000{
  8561. // zero = "000" + strconv.Itoa(fpNumber)
  8562. // } else if fpNumber >= 100000{
  8563. // zero = "00" + strconv.Itoa(fpNumber)
  8564. // } else if fpNumber >= 1000000{
  8565. // zero = "0" + strconv.Itoa(fpNumber)
  8566. // }else {
  8567. // zero = strconv.Itoa(fpNumber)
  8568. // }
  8569. // fapiao_number = zero
  8570. // }
  8571. // }
  8572. //}
  8573. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8574. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8575. var patientPrescription models.HisPrescriptionInfo
  8576. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8577. if patientPrescription.ID == 0 {
  8578. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8579. }
  8580. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8581. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8582. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8583. diagnosis_ids := strings.Split(diagnosis_id, ",")
  8584. var config []*models.HisXtDiagnoseConfig
  8585. for _, item := range diagnosis_ids {
  8586. id, _ := strconv.ParseInt(item, 10, 64)
  8587. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8588. config = append(config, &diagnosisConfig)
  8589. }
  8590. sickConfig, _ := service.FindSickById(sick_type)
  8591. //if tempOrder.ID == 0 {
  8592. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  8593. //}
  8594. if tempOrder.ID == 0 {
  8595. var result string
  8596. var requestLog string
  8597. var res2 ResultSix
  8598. var ressix10265 ResultSix10265
  8599. if miConfig.MdtrtareaAdmvs == "421300" {
  8600. data := make(map[string]interface{})
  8601. client := &http.Client{}
  8602. data["psn_no"] = his.PsnNo
  8603. data["mdtrt_id"] = his.Number
  8604. data["opter"] = roles.UserName
  8605. data["org_name"] = miConfig.OrgName
  8606. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8607. data["doctor_id"] = doctor_info.DoctorNumber
  8608. data["doctor_name"] = doctor_info.UserName
  8609. data["department"] = department.Name
  8610. data["fixmedins_code"] = miConfig.Code
  8611. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8612. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8613. data["secret_key"] = miConfig.SecretKey
  8614. data["sick_code"] = sickConfig.CountryCode
  8615. data["sick_name"] = sickConfig.ClassName
  8616. data["dept"] = strconv.FormatInt(department.ID, 10)
  8617. data["config"] = config
  8618. data["begin_time"] = begin_time
  8619. bytesData, _ := json.Marshal(data)
  8620. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  8621. resp, _ := client.Do(req)
  8622. defer resp.Body.Close()
  8623. body, ioErr := ioutil.ReadAll(resp.Body)
  8624. if ioErr != nil {
  8625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8627. return
  8628. }
  8629. var respJSON map[string]interface{}
  8630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8633. return
  8634. }
  8635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8636. userJSONBytes, _ := json.Marshal(respJSON)
  8637. fmt.Println("log")
  8638. fmt.Println(string(userJSONBytes))
  8639. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8640. utils.ErrorLog("解析失败:%v", err)
  8641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8642. return
  8643. }
  8644. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8645. data := make(map[string]interface{})
  8646. client := &http.Client{}
  8647. data["psn_no"] = his.PsnNo
  8648. data["mdtrt_id"] = his.Number
  8649. data["doctor"] = roles.UserName
  8650. data["department"] = department.Name
  8651. data["org_name"] = miConfig.OrgName
  8652. data["med_type"] = strconv.FormatInt(reg_type, 10)
  8653. data["doctor_id"] = doctor_info.DoctorNumber
  8654. data["new_doctor_name"] = doctor_info.UserName
  8655. data["fixmedins_code"] = miConfig.Code
  8656. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8657. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8658. data["secret_key"] = miConfig.SecretKey
  8659. data["sick_code"] = sickConfig.CountryCode
  8660. data["sick_name"] = sickConfig.ClassName
  8661. data["url"] = miConfig.Url
  8662. data["ak"] = miConfig.AccessKey
  8663. data["begin_time"] = begin_time
  8664. data["cainfo"] = miConfig.Cainfo
  8665. data["dept"] = strconv.FormatInt(department.ID, 10)
  8666. data["config"] = config
  8667. bytesData, _ := json.Marshal(data)
  8668. var req *http.Request
  8669. if miConfig.MdtrtareaAdmvs == "320921" {
  8670. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8671. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8672. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  8673. } else {
  8674. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  8675. }
  8676. resp, _ := client.Do(req)
  8677. defer resp.Body.Close()
  8678. body, ioErr := ioutil.ReadAll(resp.Body)
  8679. if ioErr != nil {
  8680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8682. return
  8683. }
  8684. var respJSON map[string]interface{}
  8685. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8688. return
  8689. }
  8690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8691. userJSONBytes, _ := json.Marshal(respJSON)
  8692. fmt.Println("log")
  8693. fmt.Println(string(userJSONBytes))
  8694. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  8695. utils.ErrorLog("解析失败:%v", err)
  8696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8697. return
  8698. }
  8699. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8700. res2.Output = ressix10265.Output
  8701. res2.ErrMsg = ressix10265.ErrMsg
  8702. res2.Cainfo = ressix10265.Cainfo
  8703. res2.WarnMsg = ressix10265.WarnMsg
  8704. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8705. res2.Infcode = infocode
  8706. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8707. result, requestLog, _ = service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8708. saveLog(result, requestLog, "2203", "上传就诊信息")
  8709. var respJSON2 map[string]interface{}
  8710. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8713. return
  8714. }
  8715. userJSONBytes2, _ := json.Marshal(respJSON2)
  8716. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8717. utils.ErrorLog("解析失败:%v", err)
  8718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8719. return
  8720. }
  8721. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8722. fmt.Println(result2)
  8723. fmt.Println(src_request)
  8724. } else {
  8725. if miConfig.MdtrtareaAdmvs == "440781" { //
  8726. 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)
  8727. } else {
  8728. if miConfig.Code == "H15049901371" {
  8729. //赤峰地区国家医保医疗类别
  8730. //职工透析:医疗类别选特殊情况门诊990502
  8731. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8732. var med_type string
  8733. if his.Insutype == "390" {
  8734. if reg_type == 14 {
  8735. med_type = "9933"
  8736. } else if reg_type == 11 {
  8737. med_type = "11"
  8738. }
  8739. } else if his.Insutype == "310" {
  8740. if reg_type == 14 {
  8741. med_type = "990502"
  8742. } else if reg_type == 11 {
  8743. med_type = "11"
  8744. }
  8745. }
  8746. 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)
  8747. } else {
  8748. 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)
  8749. }
  8750. }
  8751. saveLog(result, requestLog, "2203", "上传就诊信息")
  8752. var respJSON2 map[string]interface{}
  8753. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8756. return
  8757. }
  8758. userJSONBytes2, _ := json.Marshal(respJSON2)
  8759. if miConfig.Code == "H15049901371" {
  8760. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  8761. utils.ErrorLog("解析失败:%v", err)
  8762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8763. return
  8764. }
  8765. res2.InfRefmsgid = ressix10265.InfRefmsgid
  8766. res2.Output = ressix10265.Output
  8767. res2.ErrMsg = ressix10265.ErrMsg
  8768. res2.Cainfo = ressix10265.Cainfo
  8769. res2.WarnMsg = ressix10265.WarnMsg
  8770. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  8771. res2.Infcode = infocode
  8772. } else {
  8773. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8774. utils.ErrorLog("解析失败:%v", err)
  8775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8776. return
  8777. }
  8778. }
  8779. }
  8780. if res2.Infcode != 0 {
  8781. adminUser := c.GetAdminUserInfo()
  8782. errlog := &models.HisOrderError{
  8783. UserOrgId: adminUser.CurrentOrgId,
  8784. Ctime: time.Now().Unix(),
  8785. Mtime: time.Now().Unix(),
  8786. ErrMsg: res2.ErrMsg,
  8787. Status: 1,
  8788. PatientId: id,
  8789. RecordTime: recordDateTime,
  8790. Stage: 3,
  8791. }
  8792. service.CreateErrMsgLog(errlog)
  8793. c.ServeSuccessJSON(map[string]interface{}{
  8794. "failed_code": -10,
  8795. "msg": res2.ErrMsg,
  8796. })
  8797. return
  8798. } else {
  8799. his.Diagnosis = diagnosis_id
  8800. his.SickType = sickConfig.ID
  8801. //var p_type int64
  8802. //if reg_type == 1111 || reg_type == 1112 {
  8803. // p_type = 11
  8804. //
  8805. //}
  8806. his.PType = fmt.Sprintf("%d", reg_type)
  8807. service.UpdateHisPatientThree(&his)
  8808. data := make(map[string]interface{})
  8809. if settle_accounts_type == 1 { //日结
  8810. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  8811. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  8812. } else {
  8813. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  8814. }
  8815. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  8816. data["pre"] = prescriptions
  8817. } else { //月结
  8818. start_time_str := c.GetString("start_time")
  8819. end_time_str := c.GetString("end_time")
  8820. timeLayout := "2006-01-02"
  8821. loc, _ := time.LoadLocation("Local")
  8822. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8823. if err != nil {
  8824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8825. return
  8826. }
  8827. recordStartTime := theStartTime.Unix()
  8828. start_time = recordStartTime
  8829. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8830. if err != nil {
  8831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8832. return
  8833. }
  8834. recordEndTime := theEndTime.Unix()
  8835. end_time = recordEndTime
  8836. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  8837. data["pre"] = prescriptions
  8838. }
  8839. timestamp := time.Now().Unix()
  8840. tempTime := time.Unix(timestamp, 0)
  8841. timeFormat := tempTime.Format("20060102150405")
  8842. chrgBchno := rand.Intn(100000) + 10000
  8843. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8844. strconv.FormatInt(his.PatientId, 10)
  8845. client := &http.Client{}
  8846. data["psn_no"] = his.PsnNo
  8847. data["mdtrt_id"] = his.Number
  8848. data["chrg_bchno"] = chrg_bchno
  8849. data["org_name"] = miConfig.OrgName
  8850. data["doctor"] = doctor_info.UserName
  8851. data["doctor_id"] = doctor_info.DoctorNumber
  8852. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8853. data["fixmedins_code"] = miConfig.Code
  8854. data["opter"] = roles.UserName
  8855. data["dept_code"] = department.Number
  8856. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  8857. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8858. data["secret_key"] = miConfig.SecretKey
  8859. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  8860. data["url"] = miConfig.Url
  8861. data["ak"] = miConfig.AccessKey
  8862. data["new_doctor_name"] = patientPrescription.Doctor
  8863. data["diag_code"] = sickConfig.CountryCode
  8864. data["cainfo"] = miConfig.Cainfo
  8865. data["opter"] = roles.UserName
  8866. var ids []int64
  8867. for _, item := range prescriptions {
  8868. ids = append(ids, item.ID)
  8869. }
  8870. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8871. if config.IsOpen == 1 { //对接了医保,走医保流程
  8872. var res ResultFour
  8873. var resFour10265 ResultFour10265
  8874. if miConfig.MdtrtareaAdmvs == "421300" {
  8875. bytesData, _ := json.Marshal(data)
  8876. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  8877. resp, _ := client.Do(req)
  8878. defer resp.Body.Close()
  8879. body, ioErr := ioutil.ReadAll(resp.Body)
  8880. if ioErr != nil {
  8881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8883. return
  8884. }
  8885. var respJSON map[string]interface{}
  8886. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8889. return
  8890. }
  8891. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8892. userJSONBytes, _ := json.Marshal(respJSON)
  8893. fmt.Println("log")
  8894. fmt.Println(string(userJSONBytes))
  8895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8896. utils.ErrorLog("解析失败:%v", err)
  8897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8898. return
  8899. }
  8900. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8901. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  8902. if result3101.Infcode == "0" {
  8903. if len(result3101.Output.Result) > 0 {
  8904. var errMsgs []string
  8905. for _, item := range result3101.Output.Result {
  8906. errMsgs = append(errMsgs, item.VolaCont)
  8907. }
  8908. c.ServeSuccessJSON(map[string]interface{}{
  8909. "failed_code": -10,
  8910. "msg": errMsgs,
  8911. })
  8912. return
  8913. }
  8914. }
  8915. if miConfig.MdtrtareaAdmvs == "320921" {
  8916. data["doctor_id"] = "D320923012139"
  8917. } else {
  8918. data["doctor_id"] = "D371621008686"
  8919. }
  8920. bytesData, _ := json.Marshal(data)
  8921. var req *http.Request
  8922. if miConfig.MdtrtareaAdmvs == "320921" {
  8923. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8924. } else {
  8925. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8926. }
  8927. resp, _ := client.Do(req)
  8928. defer resp.Body.Close()
  8929. body, ioErr := ioutil.ReadAll(resp.Body)
  8930. if ioErr != nil {
  8931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8933. return
  8934. }
  8935. var respJSON map[string]interface{}
  8936. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8939. return
  8940. }
  8941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8942. userJSONBytes, _ := json.Marshal(respJSON)
  8943. fmt.Println("log")
  8944. fmt.Println(string(userJSONBytes))
  8945. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8946. utils.ErrorLog("解析失败:%v", err)
  8947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8948. return
  8949. }
  8950. res.InfRefmsgid = resFour10265.InfRefmsgid
  8951. res.Output = resFour10265.Output
  8952. res.ErrMsg = resFour10265.ErrMsg
  8953. res.Cainfo = resFour10265.Cainfo
  8954. res.WarnMsg = resFour10265.WarnMsg
  8955. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8956. res.Infcode = infocode
  8957. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8958. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  8959. var dat map[string]interface{}
  8960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8961. fmt.Println(dat)
  8962. } else {
  8963. fmt.Println(err)
  8964. }
  8965. saveLog(result, request_log, "2204", "上传费用明细")
  8966. userJSONBytes, _ := json.Marshal(dat)
  8967. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8968. utils.ErrorLog("解析失败:%v", err)
  8969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8970. return
  8971. }
  8972. res.InfRefmsgid = resFour10265.InfRefmsgid
  8973. res.Output = resFour10265.Output
  8974. res.ErrMsg = resFour10265.ErrMsg
  8975. res.Cainfo = resFour10265.Cainfo
  8976. res.WarnMsg = resFour10265.WarnMsg
  8977. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  8978. res.Infcode = infocode
  8979. } else {
  8980. if miConfig.Code == "H15049901371" {
  8981. 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)
  8982. var dat map[string]interface{}
  8983. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8984. fmt.Println(dat)
  8985. } else {
  8986. fmt.Println(err)
  8987. }
  8988. saveLog(result, request_log, "2204", "上传费用明细")
  8989. userJSONBytes, _ := json.Marshal(dat)
  8990. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  8991. utils.ErrorLog("解析失败:%v", err)
  8992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8993. return
  8994. }
  8995. res.InfRefmsgid = resFour10265.InfRefmsgid
  8996. res.Output = resFour10265.Output
  8997. res.ErrMsg = resFour10265.ErrMsg
  8998. res.Cainfo = resFour10265.Cainfo
  8999. res.WarnMsg = resFour10265.WarnMsg
  9000. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9001. res.Infcode = infocode
  9002. } else {
  9003. 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)
  9004. var dat map[string]interface{}
  9005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9006. fmt.Println(dat)
  9007. } else {
  9008. fmt.Println(err)
  9009. }
  9010. saveLog(result, request_log, "2204", "上传费用明细")
  9011. userJSONBytes, _ := json.Marshal(dat)
  9012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9013. utils.ErrorLog("解析失败:%v", err)
  9014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9015. return
  9016. }
  9017. }
  9018. }
  9019. if res.Infcode == 0 {
  9020. order := &models.HisOrder{
  9021. UserOrgId: adminUser.CurrentOrgId,
  9022. HisPatientId: his.ID,
  9023. PatientId: his.PatientId,
  9024. SettleAccountsDate: recordDateTime,
  9025. MdtrtId: his.Number,
  9026. PsnNo: his.PsnNo,
  9027. MedType: strconv.FormatInt(reg_type, 10),
  9028. Ctime: time.Now().Unix(),
  9029. Mtime: time.Now().Unix(),
  9030. Status: 1,
  9031. Number: chrg_bchno,
  9032. Infcode: res.Infcode,
  9033. WarnMsg: res.WarnMsg,
  9034. Cainfo: res.Cainfo,
  9035. ErrMsg: res.ErrMsg,
  9036. RespondTime: res.RefmsgTime,
  9037. InfRefmsgid: res.InfRefmsgid,
  9038. OrderStatus: 1,
  9039. PayWay: pay_way,
  9040. PayWays: pay_ways,
  9041. OthDesc: oth_desc,
  9042. PayPrice: pay_price,
  9043. PayCardNo: pay_card_no,
  9044. DiscountPrice: discount_price,
  9045. PreferentialPrice: preferential_price,
  9046. RealityPrice: reality_price,
  9047. FoundPrice: found_price,
  9048. MedicalInsurancePrice: medical_insurance_price,
  9049. PrivatePrice: private_price,
  9050. IsMedicineInsurance: 1,
  9051. SettleType: settle_accounts_type,
  9052. SettleStartTime: start_time,
  9053. SettleEndTime: end_time,
  9054. Creator: roles.AdminUserId,
  9055. Modify: roles.AdminUserId,
  9056. FaPiaoNumber: fapiao_number,
  9057. FaPiaoCode: fapiao_code,
  9058. PType: 2,
  9059. Diagnosis: diagnosis_id,
  9060. CashPay: cash_pay,
  9061. WechatPay: wechat_pay,
  9062. AliPay: ali_pay,
  9063. JifenPay: jifen_pay,
  9064. BandCardPay: band_card_pay,
  9065. }
  9066. err = service.CreateOrder(order)
  9067. if err != nil {
  9068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9069. return
  9070. }
  9071. for _, item := range res.Output.Result {
  9072. temp := strings.Split(item.FeedetlSn, "-")
  9073. var advice_id int64 = 0
  9074. var project_id int64 = 0
  9075. var types int64 = 0
  9076. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9077. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9078. if temp[1] == "1" {
  9079. advice_id = id
  9080. project_id = 0
  9081. } else if temp[1] == "2" {
  9082. advice_id = 0
  9083. project_id = id
  9084. }
  9085. if item.MedChrgitmType == "9" {
  9086. item.MedChrgitmType = "09"
  9087. }
  9088. info := &models.HisOrderInfo{
  9089. OrderNumber: order.Number,
  9090. FeedetlSn: item.FeedetlSn,
  9091. UploadDate: time.Now().Unix(),
  9092. AdviceId: advice_id,
  9093. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9094. Cnt: item.Cnt,
  9095. Pric: float64(item.Pric),
  9096. PatientId: his.PatientId,
  9097. PricUplmtAmt: item.PricUplmtAmt,
  9098. SelfpayProp: item.SelfpayProp,
  9099. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9100. OverlmtAmt: item.OverlmtAmt,
  9101. PreselfpayAmt: item.PreselfpayAmt,
  9102. BasMednFlag: item.BasMednFlag,
  9103. MedChrgitmType: item.MedChrgitmType,
  9104. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9105. Status: 1,
  9106. Memo: item.Memo,
  9107. Mtime: time.Now().Unix(),
  9108. InscpScpAmt: item.InscpScpAmt,
  9109. DrtReimFlag: item.DrtReimFlag,
  9110. Ctime: time.Now().Unix(),
  9111. ListSpItemFlag: item.ListSpItemFlag,
  9112. ChldMedcFlag: item.ChldMedcFlag,
  9113. LmtUsedFlag: item.LmtUsedFlag,
  9114. ChrgitmLv: item.ChrgitmLv,
  9115. UserOrgId: adminUser.CurrentOrgId,
  9116. HisPatientId: his.ID,
  9117. OrderId: order.ID,
  9118. ProjectId: project_id,
  9119. Type: types,
  9120. }
  9121. service.CreateOrderInfo(info)
  9122. }
  9123. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9124. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9125. var total float64
  9126. for _, item := range prescriptions {
  9127. if item.Type == 1 { //药品
  9128. for _, subItem := range item.HisDoctorAdviceInfo {
  9129. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9130. total_one := price * subItem.PrescribingNumber
  9131. total = total + total_one
  9132. }
  9133. }
  9134. if item.Type == 2 { //项目
  9135. for _, subItem := range item.HisPrescriptionProject {
  9136. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9137. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9138. total_one := price * cnt
  9139. total = total + total_one
  9140. }
  9141. }
  9142. }
  9143. allTotal := fmt.Sprintf("%f", total)
  9144. //if adminUser.CurrentOrgId == 9919 {
  9145. //
  9146. // allTotal = fmt.Sprintf("%.2f", total)
  9147. //
  9148. //} else {
  9149. //
  9150. // allTotal = fmt.Sprintf("%.2f", total)
  9151. //
  9152. //}
  9153. if res.Infcode == 0 {
  9154. var rf []*ResultFive
  9155. json.Unmarshal([]byte(his.Iinfo), &rf)
  9156. chrg_bchno := chrg_bchno
  9157. cert_no := his.Certno
  9158. var insutypes []string
  9159. var insutype string
  9160. var is390 int = 0
  9161. var is310 int = 0
  9162. for _, item := range rf {
  9163. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9164. insutypes = append(insutypes, item.Insutype)
  9165. }
  9166. }
  9167. if len(insutypes) == 1 {
  9168. insutype = insutypes[0]
  9169. } else {
  9170. for _, i := range insutypes {
  9171. if i == "390" {
  9172. is390 = 1
  9173. }
  9174. if i == "310" {
  9175. is310 = 1
  9176. }
  9177. }
  9178. }
  9179. if is390 == 1 {
  9180. insutype = "390"
  9181. }
  9182. if is310 == 1 {
  9183. insutype = "310"
  9184. }
  9185. if len(insutypes) == 0 {
  9186. insutype = "310"
  9187. }
  9188. if len(insutypes) == 2 {
  9189. insutype = strconv.FormatInt(his.SocialType, 10)
  9190. }
  9191. insutype = strconv.FormatInt(his.SocialType, 10)
  9192. //insutype = "390"
  9193. if his.IdCardType == 1 {
  9194. // cert_no = his.MedicalInsuranceNumber
  9195. cert_no = his.Certno
  9196. } else {
  9197. cert_no = his.Certno
  9198. }
  9199. var res ResultSeven
  9200. var resSeven10265 ResultSeven10265
  9201. var src_resquest string
  9202. var result2 string
  9203. if miConfig.MdtrtareaAdmvs == "421300" {
  9204. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9205. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9206. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9208. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9209. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9210. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  9211. resp, requestErr := http.Get(api)
  9212. if requestErr != nil {
  9213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9214. return
  9215. }
  9216. body, ioErr := ioutil.ReadAll(resp.Body)
  9217. if ioErr != nil {
  9218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9220. return
  9221. }
  9222. var respJSON map[string]interface{}
  9223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9226. return
  9227. }
  9228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9229. result, _ := json.Marshal(respJSON)
  9230. if miConfig.Code == "H15049901371" {
  9231. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9232. utils.ErrorLog("解析失败:%v", err)
  9233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9234. return
  9235. }
  9236. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9237. res.Output = resSeven10265.Output
  9238. res.ErrMsg = resSeven10265.ErrMsg
  9239. res.Cainfo = resSeven10265.Cainfo
  9240. res.WarnMsg = resSeven10265.WarnMsg
  9241. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9242. res.Infcode = infocode
  9243. } else {
  9244. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9245. utils.ErrorLog("解析失败:%v", err)
  9246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9247. return
  9248. }
  9249. }
  9250. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9251. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  9252. if result3101.Infcode == "0" {
  9253. if len(result3101.Output.Result) > 0 {
  9254. var errMsgs []string
  9255. for _, item := range result3101.Output.Result {
  9256. errMsgs = append(errMsgs, item.VolaCont)
  9257. }
  9258. c.ServeSuccessJSON(map[string]interface{}{
  9259. "failed_code": -10,
  9260. "msg": errMsgs,
  9261. })
  9262. return
  9263. } else {
  9264. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9265. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9266. bas := strings.Split(psn_info.CardInfo, "|")
  9267. if his.IdCardType == 1 {
  9268. cert_no = bas[2]
  9269. } else if his.IdCardType == 3 {
  9270. cert_no = his.Certno
  9271. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  9272. } else if his.IdCardType == 4 {
  9273. cert_no = his.Certno
  9274. psn_info.VerifyNumber = psn_info.VerifyNumber
  9275. }
  9276. var api string
  9277. if miConfig.MdtrtareaAdmvs == "320921" {
  9278. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9279. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9280. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9281. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9282. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9283. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9284. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9285. } else {
  9286. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9287. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9288. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9289. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9290. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9291. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9292. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9293. }
  9294. resp, requestErr := http.Get(api)
  9295. if requestErr != nil {
  9296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9297. return
  9298. }
  9299. body, ioErr := ioutil.ReadAll(resp.Body)
  9300. if ioErr != nil {
  9301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9303. return
  9304. }
  9305. var respJSON map[string]interface{}
  9306. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9309. return
  9310. }
  9311. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9312. result, _ := json.Marshal(respJSON)
  9313. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9314. utils.ErrorLog("解析失败:%v", err)
  9315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9316. return
  9317. }
  9318. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9319. res.Output = resSeven10265.Output
  9320. res.ErrMsg = resSeven10265.ErrMsg
  9321. res.Cainfo = resSeven10265.Cainfo
  9322. res.WarnMsg = resSeven10265.WarnMsg
  9323. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9324. res.Infcode = infocode
  9325. }
  9326. }
  9327. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9328. var cert_no string
  9329. if his.IdCardType == 4 {
  9330. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9331. cert_no = psn_info.VerifyNumber
  9332. result2, src_resquest, _ = service.FJyb2207ForToken(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9333. } else if his.IdCardType == 1 {
  9334. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9335. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9336. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9337. }
  9338. //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)
  9339. var dat map[string]interface{}
  9340. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9341. fmt.Println(dat)
  9342. } else {
  9343. fmt.Println(err)
  9344. }
  9345. saveLog(result2, src_resquest, "2207", "结算")
  9346. userJSONBytes, _ := json.Marshal(dat)
  9347. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9348. utils.ErrorLog("解析失败:%v", err)
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9353. res.Output = resSeven10265.Output
  9354. res.ErrMsg = resSeven10265.ErrMsg
  9355. res.Cainfo = resSeven10265.Cainfo
  9356. res.WarnMsg = resSeven10265.WarnMsg
  9357. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9358. res.Infcode = infocode
  9359. } else {
  9360. if miConfig.Code == "H15049901371" {
  9361. //赤峰地区国家医保医疗类别
  9362. //职工透析:医疗类别选特殊情况门诊990502
  9363. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9364. var med_type string
  9365. if his.Insutype == "390" {
  9366. if reg_type == 14 {
  9367. med_type = "9933"
  9368. } else if reg_type == 11 {
  9369. med_type = "11"
  9370. }
  9371. } else if his.Insutype == "310" {
  9372. if reg_type == 14 {
  9373. med_type = "990502"
  9374. } else if reg_type == 11 {
  9375. med_type = "11"
  9376. }
  9377. }
  9378. 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, "")
  9379. } else {
  9380. if his.IdCardType == 4 {
  9381. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9382. var token string
  9383. token = psn_info.VerifyNumber
  9384. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token)
  9385. } else {
  9386. 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, "")
  9387. }
  9388. }
  9389. //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)
  9390. var dat map[string]interface{}
  9391. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9392. fmt.Println(dat)
  9393. } else {
  9394. fmt.Println(err)
  9395. }
  9396. saveLog(result2, src_resquest, "2207", "结算")
  9397. userJSONBytes, _ := json.Marshal(dat)
  9398. if miConfig.Code == "H15049901371" {
  9399. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9400. utils.ErrorLog("解析失败:%v", err)
  9401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9402. return
  9403. }
  9404. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9405. res.Output = resSeven10265.Output
  9406. res.ErrMsg = resSeven10265.ErrMsg
  9407. res.Cainfo = resSeven10265.Cainfo
  9408. res.WarnMsg = resSeven10265.WarnMsg
  9409. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9410. res.Infcode = infocode
  9411. } else {
  9412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9413. utils.ErrorLog("解析失败:%v", err)
  9414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9415. return
  9416. }
  9417. }
  9418. }
  9419. if res.Infcode != 0 {
  9420. errlog := &models.HisOrderError{
  9421. UserOrgId: adminUser.CurrentOrgId,
  9422. Ctime: time.Now().Unix(),
  9423. Mtime: time.Now().Unix(),
  9424. Number: chrg_bchno,
  9425. ErrMsg: res.ErrMsg,
  9426. Status: 1,
  9427. PatientId: id,
  9428. RecordTime: recordDateTime,
  9429. Stage: 6,
  9430. }
  9431. service.CreateErrMsgLog(errlog)
  9432. c.ServeSuccessJSON(map[string]interface{}{
  9433. "failed_code": -10,
  9434. "msg": res.ErrMsg,
  9435. })
  9436. return
  9437. } else {
  9438. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9439. order.OrderStatus = 2
  9440. order.Status = 1
  9441. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9442. order.SetlId = res.Output.Setlinfo.SetlID
  9443. order.PsnNo = res.Output.Setlinfo.PsnNo
  9444. order.PsnName = res.Output.Setlinfo.PsnName
  9445. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9446. order.Certno = res.Output.Setlinfo.Certno
  9447. order.Gend = res.Output.Setlinfo.Gend
  9448. order.Naty = res.Output.Setlinfo.Naty
  9449. order.Age = res.Output.Setlinfo.Age
  9450. order.Insutype = res.Output.Setlinfo.Insutype
  9451. order.PsnType = res.Output.Setlinfo.PsnType
  9452. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9453. order.SetlTime = res.Output.Setlinfo.SetlTime
  9454. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9455. if res.Output.Setlinfo.MedType == "140101" {
  9456. order.MedType = "14"
  9457. } else {
  9458. order.MedType = res.Output.Setlinfo.MedType
  9459. }
  9460. if reg_type == 1112 {
  9461. order.MedType = "1112"
  9462. }
  9463. if reg_type == 1111 {
  9464. order.MedType = "1111"
  9465. }
  9466. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9467. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9468. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9469. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9470. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9471. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9472. order.HifpPay = res.Output.Setlinfo.HifpPay
  9473. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9474. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9475. order.HifesPay = res.Output.Setlinfo.HifesPay
  9476. order.HifobPay = res.Output.Setlinfo.HifobPay
  9477. order.MafPay = res.Output.Setlinfo.MafPay
  9478. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9479. order.OthPay = res.Output.Setlinfo.OthPay
  9480. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9481. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9482. order.AcctPay = res.Output.Setlinfo.AcctPay
  9483. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9484. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9485. order.Balc = res.Output.Setlinfo.Balc
  9486. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9487. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9488. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9489. order.ClrType = res.Output.Setlinfo.ClrType
  9490. order.ClrWay = res.Output.Setlinfo.ClrWay
  9491. order.Creator = order.Creator
  9492. order.Modify = roles.AdminUserId
  9493. order.RequestLog = src_resquest
  9494. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9495. detailStr := string(setlDetail)
  9496. order.SetlDetail = detailStr
  9497. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9498. err = service.UpDateOrder(order)
  9499. if err == nil {
  9500. //判断是否使用了押金
  9501. if dec_way == "true" {
  9502. tmpstring := strconv.FormatInt(order.ID, 10)
  9503. order.Decimal = decimal
  9504. service.UpDateOrder(order)
  9505. //扣押金
  9506. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9507. if errmsg != nil {
  9508. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9509. return
  9510. }
  9511. }
  9512. c.ServeSuccessJSON(map[string]interface{}{
  9513. "msg": "结算成功",
  9514. })
  9515. } else {
  9516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9517. return
  9518. }
  9519. }
  9520. } else {
  9521. adminUser := c.GetAdminUserInfo()
  9522. errlog := &models.HisOrderError{
  9523. UserOrgId: adminUser.CurrentOrgId,
  9524. Ctime: time.Now().Unix(),
  9525. Mtime: time.Now().Unix(),
  9526. ErrMsg: res.ErrMsg,
  9527. Status: 1,
  9528. PatientId: id,
  9529. RecordTime: recordDateTime,
  9530. Stage: 4,
  9531. }
  9532. service.CreateErrMsgLog(errlog)
  9533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9534. return
  9535. }
  9536. } else {
  9537. adminUser := c.GetAdminUserInfo()
  9538. errlog := &models.HisOrderError{
  9539. UserOrgId: adminUser.CurrentOrgId,
  9540. Ctime: time.Now().Unix(),
  9541. Mtime: time.Now().Unix(),
  9542. ErrMsg: res.ErrMsg,
  9543. Status: 1,
  9544. PatientId: id,
  9545. RecordTime: recordDateTime,
  9546. Stage: 4,
  9547. }
  9548. service.CreateErrMsgLog(errlog)
  9549. c.ServeSuccessJSON(map[string]interface{}{
  9550. "failed_code": -10,
  9551. "msg": res.ErrMsg,
  9552. })
  9553. return
  9554. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9555. //return
  9556. }
  9557. }
  9558. }
  9559. } else if tempOrder.ID > 0 {
  9560. if tempOrder.IsPre == 1 {
  9561. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  9562. var rf []*ResultFive
  9563. json.Unmarshal([]byte(his.Iinfo), &rf)
  9564. chrg_bchno := tempOrder.Number
  9565. cert_no := his.Certno
  9566. var insutypes []string
  9567. var insutype string
  9568. var is390 int = 0
  9569. var is310 int = 0
  9570. for _, item := range rf {
  9571. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9572. insutypes = append(insutypes, item.Insutype)
  9573. }
  9574. }
  9575. if len(insutypes) == 1 {
  9576. insutype = insutypes[0]
  9577. } else {
  9578. for _, i := range insutypes {
  9579. if i == "390" {
  9580. is390 = 1
  9581. }
  9582. if i == "310" {
  9583. is310 = 1
  9584. }
  9585. }
  9586. }
  9587. if is390 == 1 {
  9588. insutype = "390"
  9589. }
  9590. if is310 == 1 {
  9591. insutype = "310"
  9592. }
  9593. if len(insutypes) == 0 {
  9594. insutype = "310"
  9595. }
  9596. if len(insutypes) == 2 {
  9597. insutype = strconv.FormatInt(his.SocialType, 10)
  9598. }
  9599. //insutype = "390"
  9600. if his.IdCardType == 1 {
  9601. // cert_no = his.MedicalInsuranceNumber
  9602. cert_no = his.Certno
  9603. } else {
  9604. cert_no = his.Certno
  9605. }
  9606. var res ResultSeven
  9607. var resSeven10265 ResultSeven10265
  9608. var src_resquest string
  9609. var result2 string
  9610. if miConfig.MdtrtareaAdmvs == "421300" {
  9611. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9612. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9613. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9614. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9615. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9616. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9617. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  9618. resp, requestErr := http.Get(api)
  9619. if requestErr != nil {
  9620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9621. return
  9622. }
  9623. body, ioErr := ioutil.ReadAll(resp.Body)
  9624. if ioErr != nil {
  9625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9627. return
  9628. }
  9629. var respJSON map[string]interface{}
  9630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9633. return
  9634. }
  9635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9636. result, _ := json.Marshal(respJSON)
  9637. fmt.Println("log")
  9638. fmt.Println(string(result))
  9639. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9640. utils.ErrorLog("解析失败:%v", err)
  9641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9642. return
  9643. }
  9644. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9645. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  9646. if result3101.Infcode == "0" {
  9647. if len(result3101.Output.Result) > 0 {
  9648. var errMsgs []string
  9649. for _, item := range result3101.Output.Result {
  9650. errMsgs = append(errMsgs, item.VolaCont)
  9651. }
  9652. c.ServeSuccessJSON(map[string]interface{}{
  9653. "failed_code": -10,
  9654. "msg": errMsgs,
  9655. })
  9656. return
  9657. } else {
  9658. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9659. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9660. bas := strings.Split(psn_info.CardInfo, "|")
  9661. if his.IdCardType == 1 {
  9662. cert_no = bas[2]
  9663. } else if his.IdCardType == 3 {
  9664. cert_no = his.Certno
  9665. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  9666. } else if his.IdCardType == 4 {
  9667. cert_no = his.Certno
  9668. psn_info.VerifyNumber = psn_info.VerifyNumber
  9669. }
  9670. //江苏地区国家医保医疗类别
  9671. //职工透析:医疗类别选特殊情况门诊9933
  9672. //居民血透门慢: 医疗类别选门诊慢病1402
  9673. //var med_type string
  9674. //if his.Insutype == "310" {
  9675. // if reg_type == 14 {
  9676. // med_type = "9933"
  9677. // } else if reg_type == 11 {
  9678. // med_type = "11"
  9679. //
  9680. // }
  9681. //} else if his.Insutype == "390" {
  9682. // if reg_type == 14 {
  9683. // med_type = "1402"
  9684. // } else if reg_type == 11 {
  9685. // med_type = "11"
  9686. // }
  9687. //}
  9688. var api string
  9689. if miConfig.MdtrtareaAdmvs == "320921" {
  9690. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9691. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9692. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9693. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9694. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9695. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9696. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9697. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9698. } else {
  9699. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9700. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9701. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9702. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9703. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9704. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9705. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9706. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  9707. }
  9708. resp, requestErr := http.Get(api)
  9709. if requestErr != nil {
  9710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9711. return
  9712. }
  9713. body, ioErr := ioutil.ReadAll(resp.Body)
  9714. if ioErr != nil {
  9715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9717. return
  9718. }
  9719. var respJSON map[string]interface{}
  9720. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9723. return
  9724. }
  9725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9726. result, _ := json.Marshal(respJSON)
  9727. fmt.Println("log")
  9728. fmt.Println(string(result))
  9729. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9730. utils.ErrorLog("解析失败:%v", err)
  9731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9732. return
  9733. }
  9734. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9735. res.Output = resSeven10265.Output
  9736. res.ErrMsg = resSeven10265.ErrMsg
  9737. res.Cainfo = resSeven10265.Cainfo
  9738. res.WarnMsg = resSeven10265.WarnMsg
  9739. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9740. res.Infcode = infocode
  9741. }
  9742. }
  9743. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9744. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9745. var cert_no string
  9746. if his.IdCardType == 1 {
  9747. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9748. } else {
  9749. cert_no = psn_info.VerifyNumber
  9750. }
  9751. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9752. var dat map[string]interface{}
  9753. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9754. fmt.Println(dat)
  9755. } else {
  9756. fmt.Println(err)
  9757. }
  9758. saveLog(result2, src_resquest, "2207", "结算")
  9759. userJSONBytes, _ := json.Marshal(dat)
  9760. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9761. utils.ErrorLog("解析失败:%v", err)
  9762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9763. return
  9764. }
  9765. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9766. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9767. var cert_no string
  9768. if his.IdCardType == 1 {
  9769. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9770. } else if his.IdCardType == 2 {
  9771. cert_no = his.IdCardNo
  9772. } else {
  9773. cert_no = psn_info.VerifyNumber
  9774. }
  9775. result2, src_resquest := service.Jxyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "")
  9776. var dat map[string]interface{}
  9777. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9778. fmt.Println(dat)
  9779. } else {
  9780. fmt.Println(err)
  9781. }
  9782. saveLog(result2, src_resquest, "2207", "结算")
  9783. userJSONBytes, _ := json.Marshal(dat)
  9784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9785. utils.ErrorLog("解析失败:%v", err)
  9786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9787. return
  9788. }
  9789. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9790. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9791. var cert_no string
  9792. if his.IdCardType == 1 {
  9793. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9794. } else if his.IdCardType == 2 {
  9795. cert_no = his.IdCardNo
  9796. } else {
  9797. cert_no = psn_info.VerifyNumber
  9798. }
  9799. result2, src_resquest := service.Hnyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "")
  9800. var dat map[string]interface{}
  9801. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9802. fmt.Println(dat)
  9803. } else {
  9804. fmt.Println(err)
  9805. }
  9806. saveLog(result2, src_resquest, "2207", "结算")
  9807. userJSONBytes, _ := json.Marshal(dat)
  9808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9809. utils.ErrorLog("解析失败:%v", err)
  9810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9811. return
  9812. }
  9813. } else {
  9814. var src_resquest string
  9815. if miConfig.Code == "H15049901371" {
  9816. //赤峰地区国家医保医疗类别
  9817. //职工透析:医疗类别选特殊情况门诊990502
  9818. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9819. var med_type string
  9820. if his.Insutype == "390" {
  9821. if reg_type == 14 {
  9822. med_type = "9933"
  9823. } else if reg_type == 11 {
  9824. med_type = "11"
  9825. }
  9826. } else if his.Insutype == "310" {
  9827. if reg_type == 14 {
  9828. med_type = "990502"
  9829. } else if reg_type == 11 {
  9830. med_type = "11"
  9831. }
  9832. }
  9833. 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, "")
  9834. } else {
  9835. if his.IdCardType == 4 {
  9836. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9837. token := psn_info.VerifyNumber
  9838. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token)
  9839. } else {
  9840. 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, "")
  9841. }
  9842. }
  9843. var dat map[string]interface{}
  9844. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9845. fmt.Println(dat)
  9846. } else {
  9847. fmt.Println(err)
  9848. }
  9849. saveLog(result2, src_resquest, "2207", "结算")
  9850. userJSONBytes, _ := json.Marshal(dat)
  9851. if miConfig.Code == "H15049901371" {
  9852. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9853. utils.ErrorLog("解析失败:%v", err)
  9854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9855. return
  9856. }
  9857. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9858. res.Output = resSeven10265.Output
  9859. res.ErrMsg = resSeven10265.ErrMsg
  9860. res.Cainfo = resSeven10265.Cainfo
  9861. res.WarnMsg = resSeven10265.WarnMsg
  9862. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9863. res.Infcode = infocode
  9864. } else {
  9865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9866. utils.ErrorLog("解析失败:%v", err)
  9867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9868. return
  9869. }
  9870. }
  9871. }
  9872. if res.Infcode != 0 {
  9873. errlog := &models.HisOrderError{
  9874. UserOrgId: adminUser.CurrentOrgId,
  9875. Ctime: time.Now().Unix(),
  9876. Mtime: time.Now().Unix(),
  9877. Number: chrg_bchno,
  9878. ErrMsg: res.ErrMsg,
  9879. Status: 1,
  9880. PatientId: id,
  9881. RecordTime: recordDateTime,
  9882. Stage: 6,
  9883. }
  9884. service.CreateErrMsgLog(errlog)
  9885. c.ServeSuccessJSON(map[string]interface{}{
  9886. "failed_code": -10,
  9887. "msg": res.ErrMsg,
  9888. })
  9889. return
  9890. } else {
  9891. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9892. order.OrderStatus = 2
  9893. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9894. order.SetlId = res.Output.Setlinfo.SetlID
  9895. order.PsnNo = res.Output.Setlinfo.PsnNo
  9896. order.PsnName = res.Output.Setlinfo.PsnName
  9897. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9898. order.Certno = res.Output.Setlinfo.Certno
  9899. order.Gend = res.Output.Setlinfo.Gend
  9900. order.Naty = res.Output.Setlinfo.Naty
  9901. order.Age = res.Output.Setlinfo.Age
  9902. order.Insutype = res.Output.Setlinfo.Insutype
  9903. order.PsnType = res.Output.Setlinfo.PsnType
  9904. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9905. order.SetlTime = res.Output.Setlinfo.SetlTime
  9906. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9907. order.PayWays = pay_ways
  9908. order.AcctUsedFlag = acct_used_flag
  9909. order.WechatPay = wechat_pay
  9910. order.AliPay = ali_pay
  9911. order.JifenPay = jifen_pay
  9912. order.BandCardPay = band_card_pay
  9913. order.CashPay = cash_pay
  9914. order.OthDesc = oth_desc
  9915. //order.MedType = res.Output.Setlinfo.MedType
  9916. if reg_type == 1112 {
  9917. order.MedType = "1112"
  9918. }
  9919. if reg_type == 1111 {
  9920. order.MedType = "1111"
  9921. }
  9922. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9923. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9924. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9925. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  9926. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  9927. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  9928. order.HifpPay = res.Output.Setlinfo.HifpPay
  9929. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  9930. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  9931. order.HifesPay = res.Output.Setlinfo.HifesPay
  9932. order.HifobPay = res.Output.Setlinfo.HifobPay
  9933. order.MafPay = res.Output.Setlinfo.MafPay
  9934. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  9935. order.OthPay = res.Output.Setlinfo.OthPay
  9936. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  9937. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  9938. order.AcctPay = res.Output.Setlinfo.AcctPay
  9939. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  9940. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  9941. order.Balc = res.Output.Setlinfo.Balc
  9942. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  9943. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  9944. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  9945. order.ClrWay = res.Output.Setlinfo.ClrWay
  9946. order.Creator = order.Creator
  9947. order.Modify = roles.AdminUserId
  9948. order.RequestLog = src_resquest
  9949. order.Diagnosis = diagnosis_id
  9950. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  9951. detailStr := string(setlDetail)
  9952. order.SetlDetail = detailStr
  9953. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9954. err = service.UpDateOrder(order)
  9955. if err == nil {
  9956. //判断是否使用了押金
  9957. if dec_way == "true" {
  9958. tmpstring := strconv.FormatInt(order.ID, 10)
  9959. //扣押金
  9960. order.Decimal = decimal
  9961. service.UpDateOrder(order)
  9962. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  9963. if errmsg != nil {
  9964. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  9965. return
  9966. }
  9967. }
  9968. c.ServeSuccessJSON(map[string]interface{}{
  9969. "msg": "结算成功",
  9970. })
  9971. } else {
  9972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9973. return
  9974. }
  9975. }
  9976. }
  9977. }
  9978. }
  9979. //func (c *HisApiController) GetPreUploadInfo() {
  9980. // id, _ := c.GetInt64("id")
  9981. // record_time := c.GetString("record_time")
  9982. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9983. // admin_user_id, _ := c.GetInt64("admin_user_id")
  9984. //
  9985. // timeLayout := "2006-01-02"
  9986. // loc, _ := time.LoadLocation("Local")
  9987. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9988. // if err != nil {
  9989. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9990. // return
  9991. // }
  9992. // recordDateTime := theTime.Unix()
  9993. // adminUser := c.GetAdminUserInfo()
  9994. //
  9995. // var prescriptions []*models.HisPrescription
  9996. //
  9997. // var start_time int64
  9998. // var end_time int64
  9999. //
  10000. // data := make(map[string]interface{})
  10001. // if settle_accounts_type == 1 { //日结
  10002. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  10003. // data["pre"] = prescriptions
  10004. //
  10005. // } else { //月结
  10006. // start_time_str := c.GetString("start_time")
  10007. // end_time_str := c.GetString("end_time")
  10008. // timeLayout := "2006-01-02"
  10009. // loc, _ := time.LoadLocation("Local")
  10010. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10011. // if err != nil {
  10012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10013. // return
  10014. // }
  10015. // recordStartTime := theStartTime.Unix()
  10016. // start_time = recordStartTime
  10017. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10018. // if err != nil {
  10019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10020. // return
  10021. // }
  10022. // recordEndTime := theEndTime.Unix()
  10023. // end_time = recordEndTime
  10024. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  10025. // data["pre"] = prescriptions
  10026. //
  10027. // }
  10028. //
  10029. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10030. //
  10031. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10032. // timestamp := time.Now().Unix()
  10033. // tempTime := time.Unix(timestamp, 0)
  10034. // timeFormat := tempTime.Format("20060102150405")
  10035. // chrgBchno := rand.Intn(100000) + 10000
  10036. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10037. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10038. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10039. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10040. // strconv.FormatInt(his.PatientId, 10)
  10041. // client := &http.Client{}
  10042. // data["psn_no"] = his.PsnNo
  10043. // data["mdtrt_id"] = his.Number
  10044. // data["chrg_bchno"] = chrg_bchno
  10045. // data["org_name"] = miConfig.OrgName
  10046. // data["doctor"] = roles.UserName
  10047. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  10048. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  10049. // data["fixmedins_code"] = miConfig.Code
  10050. // data["dept_code"] = department.Number
  10051. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10052. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10053. // data["secret_key"] = miConfig.SecretKey
  10054. // var ids []int64
  10055. //
  10056. // for _, item := range prescriptions {
  10057. // ids = append(ids, item.ID)
  10058. // }
  10059. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10060. // if config.IsOpen == 1 { //对接了医保,走医保流程
  10061. // bytesData, _ := json.Marshal(data)
  10062. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  10063. // resp, _ := client.Do(req)
  10064. // defer resp.Body.Close()
  10065. // body, ioErr := ioutil.ReadAll(resp.Body)
  10066. // if ioErr != nil {
  10067. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10069. // return
  10070. // }
  10071. // var respJSON map[string]interface{}
  10072. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10073. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10074. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10075. // return
  10076. // }
  10077. //
  10078. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10079. // userJSONBytes, _ := json.Marshal(respJSON)
  10080. // var res ResultFour
  10081. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10082. // utils.ErrorLog("解析失败:%v", err)
  10083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10084. // return
  10085. // }
  10086. //
  10087. // if res.Infcode == 0 {
  10088. // order := &models.HisOrder{
  10089. // UserOrgId: adminUser.CurrentOrgId,
  10090. // HisPatientId: his.ID,
  10091. // PatientId: his.PatientId,
  10092. // SettleAccountsDate: recordDateTime,
  10093. // Ctime: time.Now().Unix(),
  10094. // Mtime: time.Now().Unix(),
  10095. // Status: 1,
  10096. // Number: chrg_bchno,
  10097. // Infcode: res.Infcode,
  10098. // WarnMsg: res.WarnMsg,
  10099. // Cainfo: res.Cainfo,
  10100. // ErrMsg: res.ErrMsg,
  10101. // RespondTime: res.RefmsgTime,
  10102. // InfRefmsgid: res.InfRefmsgid,
  10103. // OrderStatus: 1,
  10104. // IsMedicineInsurance: 1,
  10105. // SettleType: settle_accounts_type,
  10106. // SettleStartTime: start_time,
  10107. // SettleEndTime: end_time,
  10108. // Creator: roles.ID,
  10109. // Modify: roles.ID,
  10110. // PType: 2,
  10111. // }
  10112. // err = service.CreateOrder(order)
  10113. // if err != nil {
  10114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10115. // return
  10116. // }
  10117. //
  10118. // for _, item := range res.Output.Result {
  10119. // temp := strings.Split(item.FeedetlSn, "-")
  10120. // var advice_id int64 = 0
  10121. // var project_id int64 = 0
  10122. // var types int64 = 0
  10123. //
  10124. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  10125. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  10126. //
  10127. // if temp[1] == "1" {
  10128. // advice_id = id
  10129. // project_id = 0
  10130. // } else if temp[1] == "2" {
  10131. // advice_id = 0
  10132. // project_id = id
  10133. // }
  10134. //
  10135. // info := &models.HisOrderInfo{
  10136. // OrderNumber: order.Number,
  10137. // FeedetlSn: item.FeedetlSn,
  10138. // UploadDate: time.Now().Unix(),
  10139. // AdviceId: advice_id,
  10140. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  10141. // Cnt: item.Cnt,
  10142. // Pric: float64(item.Pric),
  10143. // PatientId: his.PatientId,
  10144. // PricUplmtAmt: item.PricUplmtAmt,
  10145. // SelfpayProp: item.SelfpayProp,
  10146. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10147. // OverlmtAmt: item.OverlmtAmt,
  10148. // PreselfpayAmt: item.PreselfpayAmt,
  10149. // BasMednFlag: item.BasMednFlag,
  10150. // MedChrgitmType: item.MedChrgitmType,
  10151. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  10152. // Status: 1,
  10153. // Memo: item.Memo,
  10154. // Mtime: time.Now().Unix(),
  10155. // InscpScpAmt: item.InscpScpAmt,
  10156. // DrtReimFlag: item.DrtReimFlag,
  10157. // Ctime: time.Now().Unix(),
  10158. // ListSpItemFlag: item.ListSpItemFlag,
  10159. // ChldMedcFlag: item.ChldMedcFlag,
  10160. // LmtUsedFlag: item.LmtUsedFlag,
  10161. // ChrgitmLv: item.ChrgitmLv,
  10162. // UserOrgId: adminUser.CurrentOrgId,
  10163. // HisPatientId: his.ID,
  10164. // OrderId: order.ID,
  10165. // ProjectId: project_id,
  10166. // Type: types,
  10167. // }
  10168. // service.CreateOrderInfo(info)
  10169. //
  10170. // }
  10171. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10172. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  10173. //
  10174. // var total float64
  10175. // for _, item := range prescriptions {
  10176. // if item.Type == 1 { //药品
  10177. // for _, subItem := range item.HisDoctorAdviceInfo {
  10178. // total = total + (subItem.Price * subItem.PrescribingNumber)
  10179. // }
  10180. // }
  10181. // if item.Type == 2 { //项目
  10182. // for _, subItem := range item.HisPrescriptionProject {
  10183. // total = total + (subItem.Price * float64(subItem.Count))
  10184. // }
  10185. // }
  10186. // }
  10187. //
  10188. // for _, item := range prescriptions {
  10189. // for _, subItem := range item.HisAdditionalCharge {
  10190. // total = total + (subItem.Price * float64(subItem.Count))
  10191. // }
  10192. // }
  10193. //
  10194. // allTotal := fmt.Sprintf("%.2f", total)
  10195. // if res.Infcode == 0 {
  10196. // var rf []*ResultFive
  10197. // json.Unmarshal([]byte(his.Iinfo), &rf)
  10198. // psn_no := his.PsnNo
  10199. // mdtrt_id := his.Number
  10200. // chrg_bchno := chrg_bchno
  10201. // cert_no := his.Certno
  10202. // insutype := rf[0].Insutype
  10203. //
  10204. // if his.IdCardType == 1 {
  10205. // cert_no = his.MedicalInsuranceNumber
  10206. //
  10207. // } else {
  10208. //
  10209. // cert_no = his.Certno
  10210. //
  10211. // }
  10212. //
  10213. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  10214. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  10215. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  10216. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  10217. // resp, requestErr := http.Get(api)
  10218. // if requestErr != nil {
  10219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10220. // return
  10221. // }
  10222. // defer resp.Body.Close()
  10223. // body, ioErr := ioutil.ReadAll(resp.Body)
  10224. // if ioErr != nil {
  10225. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10227. // return
  10228. // }
  10229. // var respJSON map[string]interface{}
  10230. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10231. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10233. // return
  10234. // }
  10235. // fmt.Println(respJSON)
  10236. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10237. // userJSONBytes, _ := json.Marshal(respJSON)
  10238. // var res ResultSeven
  10239. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10240. // utils.ErrorLog("解析失败:%v", err)
  10241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10242. // return
  10243. // }
  10244. // if res.Infcode != 0 {
  10245. // errlog := &models.HisOrderError{
  10246. // UserOrgId: adminUser.CurrentOrgId,
  10247. // Ctime: time.Now().Unix(),
  10248. // Mtime: time.Now().Unix(),
  10249. // Number: chrg_bchno,
  10250. // ErrMsg: res.ErrMsg,
  10251. // Status: 1,
  10252. // PatientId: id,
  10253. // RecordTime: recordDateTime,
  10254. // Stage: 7,
  10255. // }
  10256. // service.CreateErrMsgLog(errlog)
  10257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10258. // return
  10259. // } else {
  10260. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10261. // order.OrderStatus = 1
  10262. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10263. // order.SetlId = res.Output.Setlinfo.SetlID
  10264. // order.PsnNo = res.Output.Setlinfo.PsnNo
  10265. // order.PsnName = res.Output.Setlinfo.PsnName
  10266. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10267. // order.Certno = res.Output.Setlinfo.Certno
  10268. // order.Gend = res.Output.Setlinfo.Gend
  10269. // order.Naty = res.Output.Setlinfo.Naty
  10270. // order.Age = res.Output.Setlinfo.Age
  10271. // order.Insutype = res.Output.Setlinfo.Insutype
  10272. // order.PsnType = res.Output.Setlinfo.PsnType
  10273. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10274. // order.SetlTime = res.Output.Setlinfo.SetlTime
  10275. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10276. // order.MedType = res.Output.Setlinfo.MedType
  10277. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10278. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10279. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10280. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10281. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10282. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10283. // order.HifpPay = res.Output.Setlinfo.HifpPay
  10284. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10285. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10286. // order.HifesPay = res.Output.Setlinfo.HifesPay
  10287. // order.HifobPay = res.Output.Setlinfo.HifobPay
  10288. // order.MafPay = res.Output.Setlinfo.MafPay
  10289. // order.OthPay = res.Output.Setlinfo.OthPay
  10290. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10291. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10292. // order.AcctPay = res.Output.Setlinfo.AcctPay
  10293. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10294. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10295. // order.Balc = res.Output.Setlinfo.Balc
  10296. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10297. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10298. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10299. // order.ClrWay = res.Output.Setlinfo.ClrWay
  10300. // order.Creator = order.Creator
  10301. // order.Modify = roles.ID
  10302. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10303. // detailStr := string(setlDetail)
  10304. // order.SetlDetail = detailStr
  10305. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10306. // err = service.UpDateOrder(order)
  10307. // if err == nil {
  10308. // c.ServeSuccessJSON(map[string]interface{}{
  10309. // "msg": "预结算成功",
  10310. // })
  10311. // } else {
  10312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10313. // return
  10314. // }
  10315. // }
  10316. // } else {
  10317. // adminUser := c.GetAdminUserInfo()
  10318. // errlog := &models.HisOrderError{
  10319. // UserOrgId: adminUser.CurrentOrgId,
  10320. // Ctime: time.Now().Unix(),
  10321. // Mtime: time.Now().Unix(),
  10322. // ErrMsg: res.ErrMsg,
  10323. // Status: 1,
  10324. // PatientId: id,
  10325. // RecordTime: recordDateTime,
  10326. // Stage: 4,
  10327. // }
  10328. // service.CreateErrMsgLog(errlog)
  10329. //
  10330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10331. // return
  10332. // }
  10333. // } else {
  10334. // adminUser := c.GetAdminUserInfo()
  10335. // errlog := &models.HisOrderError{
  10336. // UserOrgId: adminUser.CurrentOrgId,
  10337. // Ctime: time.Now().Unix(),
  10338. // Mtime: time.Now().Unix(),
  10339. // ErrMsg: res.ErrMsg,
  10340. // Status: 1,
  10341. // PatientId: id,
  10342. // RecordTime: recordDateTime,
  10343. // Stage: 4,
  10344. // }
  10345. // service.CreateErrMsgLog(errlog)
  10346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  10347. // return
  10348. // }
  10349. //
  10350. // } else {
  10351. // var total float64
  10352. // for _, item := range prescriptions {
  10353. // if item.Type == 1 { //药品
  10354. // for _, subItem := range item.HisDoctorAdviceInfo {
  10355. // total = total + (subItem.Price * subItem.PrescribingNumber)
  10356. // }
  10357. // }
  10358. // if item.Type == 2 { //项目
  10359. // for _, subItem := range item.HisPrescriptionProject {
  10360. // total = total + (subItem.Price * float64(subItem.Count))
  10361. // }
  10362. // }
  10363. //
  10364. // for _, subItem := range item.HisAdditionalCharge {
  10365. // total = total + (subItem.Price * float64(subItem.Count))
  10366. // }
  10367. // }
  10368. //
  10369. // allTotal := fmt.Sprintf("%.2f", total)
  10370. // totals, _ := strconv.ParseFloat(allTotal, 64)
  10371. // order := &models.HisOrder{
  10372. // UserOrgId: adminUser.CurrentOrgId,
  10373. // HisPatientId: his.ID,
  10374. // PatientId: id,
  10375. // SettleAccountsDate: recordDateTime,
  10376. // Ctime: time.Now().Unix(),
  10377. // Mtime: time.Now().Unix(),
  10378. // Status: 1,
  10379. // OrderStatus: 2,
  10380. // Number: chrg_bchno,
  10381. // MedfeeSumamt: totals,
  10382. // }
  10383. // err = service.CreateOrder(order)
  10384. // if err != nil {
  10385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10386. // return
  10387. // }
  10388. //
  10389. // var customs []*Custom
  10390. // for _, item := range prescriptions {
  10391. //
  10392. // if item.Type == 1 { //药品
  10393. // for _, subItem := range item.HisDoctorAdviceInfo {
  10394. // cus := &Custom{
  10395. // AdviceId: subItem.ID,
  10396. // ProjectId: 0,
  10397. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  10398. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  10399. // FeedetlSn: subItem.FeedetlSn,
  10400. // Price: fmt.Sprintf("%.2f", subItem.Price),
  10401. // MedListCodg: subItem.MedListCodg,
  10402. // Type: 1,
  10403. // }
  10404. // customs = append(customs, cus)
  10405. // }
  10406. // }
  10407. //
  10408. // if item.Type == 2 { //项目
  10409. // for _, subItem := range item.HisPrescriptionProject {
  10410. //
  10411. // cus := &Custom{
  10412. // AdviceId: 0,
  10413. // ProjectId: subItem.ID,
  10414. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  10415. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  10416. // FeedetlSn: subItem.FeedetlSn,
  10417. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  10418. // MedListCodg: subItem.MedListCodg,
  10419. // Type: 2,
  10420. // }
  10421. //
  10422. // customs = append(customs, cus)
  10423. // }
  10424. // }
  10425. //
  10426. // for _, item := range item.HisAdditionalCharge {
  10427. // cus := &Custom{
  10428. // ItemId: item.ID,
  10429. // AdviceId: 0,
  10430. // ProjectId: 0,
  10431. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  10432. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  10433. // FeedetlSn: item.FeedetlSn,
  10434. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  10435. // MedListCodg: item.XtHisAddtionConfig.Code,
  10436. // Type: 3,
  10437. // }
  10438. //
  10439. // customs = append(customs, cus)
  10440. // }
  10441. //
  10442. // }
  10443. //
  10444. // for _, item := range customs {
  10445. // var advice_id int64 = 0
  10446. // var project_id int64 = 0
  10447. // var item_id int64 = 0
  10448. //
  10449. // var types int64 = 0
  10450. //
  10451. // if item.Type == 1 {
  10452. // advice_id = item.AdviceId
  10453. // project_id = 0
  10454. // item_id = 0
  10455. // } else if item.Type == 2 {
  10456. // advice_id = 0
  10457. // item_id = 0
  10458. //
  10459. // project_id = item.ProjectId
  10460. // } else if item.Type == 3 {
  10461. // advice_id = 0
  10462. // item_id = item.ItemId
  10463. // project_id = 0
  10464. // }
  10465. //
  10466. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  10467. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  10468. // pric, _ := strconv.ParseFloat(item.Price, 32)
  10469. //
  10470. // info := &models.HisOrderInfo{
  10471. // OrderNumber: order.Number,
  10472. // UploadDate: time.Now().Unix(),
  10473. // AdviceId: advice_id,
  10474. // DetItemFeeSumamt: detItemFeeSumamt,
  10475. // Cnt: cut,
  10476. // Pric: pric,
  10477. // PatientId: id,
  10478. // Status: 1,
  10479. // Mtime: time.Now().Unix(),
  10480. // Ctime: time.Now().Unix(),
  10481. // UserOrgId: adminUser.CurrentOrgId,
  10482. // HisPatientId: his.ID,
  10483. // OrderId: order.ID,
  10484. // ProjectId: project_id,
  10485. // Type: types,
  10486. // ItemId: item_id,
  10487. // }
  10488. // service.CreateOrderInfo(info)
  10489. // }
  10490. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10491. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10492. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  10493. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10494. // if err == nil {
  10495. // c.ServeSuccessJSON(map[string]interface{}{
  10496. // "msg": "结算成功",
  10497. // })
  10498. // } else {
  10499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10500. // return
  10501. // }
  10502. // }
  10503. //}
  10504. // 上传明细-预结算-
  10505. func (c *HisApiController) GetPreUploadInfo() {
  10506. id, _ := c.GetInt64("id")
  10507. record_time := c.GetString("record_time")
  10508. his_patient_id, _ := c.GetInt64("his_patient_id")
  10509. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10510. admin_user_id, _ := c.GetInt64("admin_user_id")
  10511. diagnosis_id := c.GetString("diagnosis")
  10512. sick_type, _ := c.GetInt64("sick_type")
  10513. reg_type, _ := c.GetInt64("p_type")
  10514. begin_time := c.GetString("begin_time")
  10515. acct_used_flag := c.GetString("acct_used_flag")
  10516. id_str := c.GetString("ids")
  10517. ids_arr := strings.Split(id_str, ",")
  10518. timeLayout := "2006-01-02"
  10519. loc, _ := time.LoadLocation("Local")
  10520. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10521. if err != nil {
  10522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10523. return
  10524. }
  10525. recordDateTime := theTime.Unix()
  10526. adminUser := c.GetAdminUserInfo()
  10527. diagnosis_ids := strings.Split(diagnosis_id, ",")
  10528. var config []*models.HisXtDiagnoseConfig
  10529. for _, item := range diagnosis_ids {
  10530. id, _ := strconv.ParseInt(item, 10, 64)
  10531. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10532. config = append(config, &diagnosisConfig)
  10533. }
  10534. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10535. sickConfig, _ := service.FindSickById(sick_type)
  10536. var prescriptions []*models.HisPrescription
  10537. var start_time int64
  10538. var end_time int64
  10539. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10540. fmt.Println(his_patient_id)
  10541. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10542. timestamp := time.Now().Unix()
  10543. tempTime := time.Unix(timestamp, 0)
  10544. timeFormat := tempTime.Format("20060102150405")
  10545. chrgBchno := rand.Intn(100000) + 10000
  10546. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10547. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10548. var patientPrescription models.HisPrescriptionInfo
  10549. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10550. if patientPrescription.ID == 0 {
  10551. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10552. }
  10553. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10554. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10555. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10556. strconv.FormatInt(his.PatientId, 10)
  10557. var res2 ResultSix
  10558. var resSix10265 ResultSix10265
  10559. //var time_stamp string
  10560. if miConfig.MdtrtareaAdmvs == "421300" {
  10561. data := make(map[string]interface{})
  10562. client := &http.Client{}
  10563. data["psn_no"] = his.PsnNo
  10564. data["mdtrt_id"] = his.Number
  10565. data["department"] = department.Name
  10566. data["org_name"] = miConfig.OrgName
  10567. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10568. data["doctor_id"] = doctor_info.DoctorNumber
  10569. data["doctor_name"] = roles.UserName
  10570. data["fixmedins_code"] = miConfig.Code
  10571. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10572. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10573. data["secret_key"] = miConfig.SecretKey
  10574. data["sick_code"] = sickConfig.CountryCode
  10575. data["sick_name"] = sickConfig.ClassName
  10576. data["begin_time"] = begin_time
  10577. data["dept"] = strconv.FormatInt(department.ID, 10)
  10578. data["config"] = config
  10579. data["opter"] = roles.UserName
  10580. fmt.Println(data)
  10581. bytesData, _ := json.Marshal(data)
  10582. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  10583. resp, _ := client.Do(req)
  10584. defer resp.Body.Close()
  10585. body, ioErr := ioutil.ReadAll(resp.Body)
  10586. if ioErr != nil {
  10587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10589. return
  10590. }
  10591. var respJSON map[string]interface{}
  10592. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10595. return
  10596. }
  10597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10598. userJSONBytes, _ := json.Marshal(respJSON)
  10599. fmt.Println("log")
  10600. fmt.Println(string(userJSONBytes))
  10601. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10602. utils.ErrorLog("解析失败:%v", err)
  10603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10604. return
  10605. }
  10606. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10607. data := make(map[string]interface{})
  10608. client := &http.Client{}
  10609. data["psn_no"] = his.PsnNo
  10610. data["mdtrt_id"] = his.Number
  10611. data["doctor"] = roles.UserName
  10612. data["department"] = department.Name
  10613. data["org_name"] = miConfig.OrgName
  10614. data["med_type"] = strconv.FormatInt(reg_type, 10)
  10615. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  10616. data["fixmedins_code"] = miConfig.Code
  10617. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10618. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10619. data["secret_key"] = miConfig.SecretKey
  10620. data["sick_code"] = sickConfig.CountryCode
  10621. data["sick_name"] = sickConfig.ClassName
  10622. data["begin_time"] = begin_time
  10623. data["dept"] = strconv.FormatInt(department.ID, 10)
  10624. data["config"] = config
  10625. data["url"] = miConfig.Url
  10626. data["ak"] = miConfig.AccessKey
  10627. data["cainfo"] = miConfig.Cainfo
  10628. bytesData, _ := json.Marshal(data)
  10629. var req *http.Request
  10630. if miConfig.MdtrtareaAdmvs == "320921" {
  10631. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10632. } else {
  10633. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  10634. }
  10635. resp, _ := client.Do(req)
  10636. defer resp.Body.Close()
  10637. body, ioErr := ioutil.ReadAll(resp.Body)
  10638. if ioErr != nil {
  10639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10641. return
  10642. }
  10643. var respJSON map[string]interface{}
  10644. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10647. return
  10648. }
  10649. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  10650. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  10651. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  10652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10653. userJSONBytes, _ := json.Marshal(respJSON)
  10654. fmt.Println("log")
  10655. fmt.Println(string(userJSONBytes))
  10656. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10657. utils.ErrorLog("解析失败:%v", err)
  10658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10659. return
  10660. }
  10661. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10662. res2.Output = resSix10265.Output
  10663. res2.ErrMsg = resSix10265.ErrMsg
  10664. res2.Cainfo = resSix10265.Cainfo
  10665. res2.WarnMsg = resSix10265.WarnMsg
  10666. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10667. res2.Infcode = infocode
  10668. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10669. result, requestLog, _ := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10670. saveLog(result, requestLog, "2203", "上传就诊信息")
  10671. var respJSON2 map[string]interface{}
  10672. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10675. return
  10676. }
  10677. userJSONBytes2, _ := json.Marshal(respJSON2)
  10678. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10679. utils.ErrorLog("解析失败:%v", err)
  10680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10681. return
  10682. }
  10683. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10684. var result string
  10685. var requestLog string
  10686. result, requestLog = service.Jxyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "")
  10687. saveLog(result, requestLog, "2203", "上传就诊信息")
  10688. var respJSON2 map[string]interface{}
  10689. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10692. return
  10693. }
  10694. userJSONBytes2, _ := json.Marshal(respJSON2)
  10695. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10696. utils.ErrorLog("解析失败:%v", err)
  10697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10698. return
  10699. }
  10700. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10701. var result string
  10702. var requestLog string
  10703. result, requestLog = service.Hnyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "")
  10704. saveLog(result, requestLog, "2203", "上传就诊信息")
  10705. var respJSON2 map[string]interface{}
  10706. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10709. return
  10710. }
  10711. userJSONBytes2, _ := json.Marshal(respJSON2)
  10712. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10713. utils.ErrorLog("解析失败:%v", err)
  10714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10715. return
  10716. }
  10717. } else {
  10718. var result string
  10719. var requestLog string
  10720. if miConfig.MdtrtareaAdmvs == "440781" { //
  10721. 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)
  10722. } else {
  10723. if miConfig.Code == "H15049901371" {
  10724. //赤峰地区国家医保医疗类别
  10725. //职工透析:医疗类别选特殊情况门诊990502
  10726. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10727. var med_type string
  10728. if his.Insutype == "390" {
  10729. if reg_type == 14 {
  10730. med_type = "9933"
  10731. } else if reg_type == 11 {
  10732. med_type = "11"
  10733. }
  10734. } else if his.Insutype == "310" {
  10735. if reg_type == 14 {
  10736. med_type = "990502"
  10737. } else if reg_type == 11 {
  10738. med_type = "11"
  10739. }
  10740. }
  10741. 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)
  10742. } else {
  10743. 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)
  10744. }
  10745. saveLog(result, requestLog, "2203", "上传就诊信息")
  10746. var respJSON2 map[string]interface{}
  10747. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10750. return
  10751. }
  10752. userJSONBytes2, _ := json.Marshal(respJSON2)
  10753. if miConfig.Code == "H15049901371" {
  10754. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  10755. utils.ErrorLog("解析失败:%v", err)
  10756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10757. return
  10758. }
  10759. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10760. res2.Output = resSix10265.Output
  10761. res2.ErrMsg = resSix10265.ErrMsg
  10762. res2.Cainfo = resSix10265.Cainfo
  10763. res2.WarnMsg = resSix10265.WarnMsg
  10764. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10765. res2.Infcode = infocode
  10766. } else {
  10767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10768. utils.ErrorLog("解析失败:%v", err)
  10769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10770. return
  10771. }
  10772. }
  10773. }
  10774. }
  10775. if res2.Infcode != 0 {
  10776. adminUser := c.GetAdminUserInfo()
  10777. errlog := &models.HisOrderError{
  10778. UserOrgId: adminUser.CurrentOrgId,
  10779. Ctime: time.Now().Unix(),
  10780. Mtime: time.Now().Unix(),
  10781. ErrMsg: res2.ErrMsg,
  10782. Status: 1,
  10783. PatientId: id,
  10784. RecordTime: recordDateTime,
  10785. Stage: 3,
  10786. }
  10787. service.CreateErrMsgLog(errlog)
  10788. c.ServeSuccessJSON(map[string]interface{}{
  10789. "failed_code": -10,
  10790. "msg": res2.ErrMsg,
  10791. })
  10792. return
  10793. } else {
  10794. his.Diagnosis = diagnosis_id
  10795. his.SickType = sickConfig.ID
  10796. his.PType = fmt.Sprintf("%d", reg_type)
  10797. service.UpdateHisPatientThree(&his)
  10798. data := make(map[string]interface{})
  10799. if settle_accounts_type == 1 { //日结
  10800. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  10801. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  10802. } else {
  10803. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  10804. }
  10805. data["pre"] = prescriptions
  10806. } else { //月结
  10807. start_time_str := c.GetString("start_time")
  10808. end_time_str := c.GetString("end_time")
  10809. timeLayout := "2006-01-02"
  10810. loc, _ := time.LoadLocation("Local")
  10811. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10812. if err != nil {
  10813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10814. return
  10815. }
  10816. recordStartTime := theStartTime.Unix()
  10817. start_time = recordStartTime
  10818. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10819. if err != nil {
  10820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10821. return
  10822. }
  10823. recordEndTime := theEndTime.Unix()
  10824. end_time = recordEndTime
  10825. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  10826. data["pre"] = prescriptions
  10827. }
  10828. client := &http.Client{}
  10829. data["psn_no"] = his.PsnNo
  10830. data["mdtrt_id"] = his.Number
  10831. data["chrg_bchno"] = chrg_bchno
  10832. data["org_name"] = miConfig.OrgName
  10833. data["doctor"] = doctor_info.UserName
  10834. data["doctor_id"] = doctor_info.DoctorNumber
  10835. data["dept"] = department.Name
  10836. data["fixmedins_code"] = miConfig.Code
  10837. data["opter"] = roles.UserName
  10838. data["dept_code"] = department.Number
  10839. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  10840. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10841. data["secret_key"] = miConfig.SecretKey
  10842. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  10843. data["url"] = miConfig.Url
  10844. data["ak"] = miConfig.AccessKey
  10845. data["new_doctor_name"] = patientPrescription.Doctor
  10846. data["diag_code"] = sickConfig.CountryCode
  10847. data["cainfo"] = miConfig.Cainfo
  10848. data["opter"] = roles.UserName
  10849. var ids []int64
  10850. for _, item := range prescriptions {
  10851. ids = append(ids, item.ID)
  10852. }
  10853. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10854. if config.IsOpen == 1 { //对接了医保,走医保流程
  10855. var res ResultFour
  10856. var resFour10265 ResultFour10265
  10857. if miConfig.MdtrtareaAdmvs == "421300" {
  10858. bytesData, _ := json.Marshal(data)
  10859. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  10860. resp, _ := client.Do(req)
  10861. defer resp.Body.Close()
  10862. body, ioErr := ioutil.ReadAll(resp.Body)
  10863. if ioErr != nil {
  10864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10866. return
  10867. }
  10868. var respJSON map[string]interface{}
  10869. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10872. return
  10873. }
  10874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10875. userJSONBytes, _ := json.Marshal(respJSON)
  10876. fmt.Println("log")
  10877. fmt.Println(string(userJSONBytes))
  10878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10879. utils.ErrorLog("解析失败:%v", err)
  10880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10881. return
  10882. }
  10883. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10884. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  10885. if result3101.Infcode == "0" {
  10886. if len(result3101.Output.Result) > 0 {
  10887. var errMsgs []string
  10888. for _, item := range result3101.Output.Result {
  10889. errMsgs = append(errMsgs, item.VolaCont)
  10890. }
  10891. c.ServeSuccessJSON(map[string]interface{}{
  10892. "failed_code": -10,
  10893. "msg": errMsgs,
  10894. })
  10895. return
  10896. } else {
  10897. if miConfig.MdtrtareaAdmvs == "320921" {
  10898. data["doctor_id"] = "D320923012139"
  10899. } else {
  10900. data["doctor_id"] = "D371621008686"
  10901. }
  10902. bytesData, _ := json.Marshal(data)
  10903. var req *http.Request
  10904. if miConfig.MdtrtareaAdmvs == "320921" {
  10905. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10906. } else {
  10907. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10908. }
  10909. resp, _ := client.Do(req)
  10910. defer resp.Body.Close()
  10911. body, ioErr := ioutil.ReadAll(resp.Body)
  10912. if ioErr != nil {
  10913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10915. return
  10916. }
  10917. var respJSON map[string]interface{}
  10918. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10921. return
  10922. }
  10923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10924. userJSONBytes, _ := json.Marshal(respJSON)
  10925. fmt.Println("log")
  10926. fmt.Println(string(userJSONBytes))
  10927. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10928. utils.ErrorLog("解析失败:%v", err)
  10929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10930. return
  10931. }
  10932. res.InfRefmsgid = resFour10265.InfRefmsgid
  10933. res.Output = resFour10265.Output
  10934. res.ErrMsg = resFour10265.ErrMsg
  10935. res.Cainfo = resFour10265.Cainfo
  10936. res.WarnMsg = resFour10265.WarnMsg
  10937. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  10938. res.Infcode = infocode
  10939. }
  10940. }
  10941. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10942. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  10943. var dat map[string]interface{}
  10944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10945. fmt.Println(dat)
  10946. } else {
  10947. fmt.Println(err)
  10948. }
  10949. saveLog(result, request_log, "2204", "上传费用明细")
  10950. userJSONBytes, _ := json.Marshal(dat)
  10951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10952. utils.ErrorLog("解析失败:%v", err)
  10953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10954. return
  10955. }
  10956. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10957. result, request_log := service.Jxyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  10958. var dat map[string]interface{}
  10959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10960. fmt.Println(dat)
  10961. } else {
  10962. fmt.Println(err)
  10963. }
  10964. saveLog(result, request_log, "2204", "上传费用明细")
  10965. userJSONBytes, _ := json.Marshal(dat)
  10966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10967. utils.ErrorLog("解析失败:%v", err)
  10968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10969. return
  10970. }
  10971. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10972. result, request_log := service.Hnyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  10973. var dat map[string]interface{}
  10974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10975. fmt.Println(dat)
  10976. } else {
  10977. fmt.Println(err)
  10978. }
  10979. saveLog(result, request_log, "2204", "上传费用明细")
  10980. userJSONBytes, _ := json.Marshal(dat)
  10981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10982. utils.ErrorLog("解析失败:%v", err)
  10983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10984. return
  10985. }
  10986. } else {
  10987. if miConfig.Code == "H15049901371" {
  10988. 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)
  10989. var dat map[string]interface{}
  10990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10991. fmt.Println(dat)
  10992. } else {
  10993. fmt.Println(err)
  10994. }
  10995. saveLog(result, request_log, "2204", "上传费用明细")
  10996. userJSONBytes, _ := json.Marshal(dat)
  10997. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  10998. utils.ErrorLog("解析失败:%v", err)
  10999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11000. return
  11001. }
  11002. res.InfRefmsgid = resFour10265.InfRefmsgid
  11003. res.Output = resFour10265.Output
  11004. res.ErrMsg = resFour10265.ErrMsg
  11005. res.Cainfo = resFour10265.Cainfo
  11006. res.WarnMsg = resFour10265.WarnMsg
  11007. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11008. res.Infcode = infocode
  11009. } else {
  11010. 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)
  11011. var dat map[string]interface{}
  11012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11013. fmt.Println(dat)
  11014. } else {
  11015. fmt.Println(err)
  11016. }
  11017. saveLog(result, request_log, "2204", "上传费用明细")
  11018. userJSONBytes, _ := json.Marshal(dat)
  11019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11020. utils.ErrorLog("解析失败:%v", err)
  11021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11022. return
  11023. }
  11024. }
  11025. }
  11026. var total_two float64
  11027. if res.Infcode == 0 {
  11028. order := &models.HisOrder{
  11029. UserOrgId: adminUser.CurrentOrgId,
  11030. HisPatientId: his.ID,
  11031. PatientId: his.PatientId,
  11032. SettleAccountsDate: recordDateTime,
  11033. Ctime: time.Now().Unix(),
  11034. Mtime: time.Now().Unix(),
  11035. MdtrtId: his.Number,
  11036. PsnNo: his.PsnNo,
  11037. MedType: strconv.FormatInt(reg_type, 10),
  11038. Status: 1,
  11039. Number: chrg_bchno,
  11040. Infcode: res.Infcode,
  11041. WarnMsg: res.WarnMsg,
  11042. Cainfo: res.Cainfo,
  11043. ErrMsg: res.ErrMsg,
  11044. RespondTime: res.RefmsgTime,
  11045. InfRefmsgid: res.InfRefmsgid,
  11046. OrderStatus: 1,
  11047. IsMedicineInsurance: 1,
  11048. SettleType: settle_accounts_type,
  11049. SettleStartTime: start_time,
  11050. SettleEndTime: end_time,
  11051. Creator: roles.AdminUserId,
  11052. Modify: roles.AdminUserId,
  11053. PType: 2,
  11054. Diagnosis: diagnosis_id,
  11055. }
  11056. err = service.CreateOrder(order)
  11057. if err != nil {
  11058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11059. return
  11060. }
  11061. for _, item := range res.Output.Result {
  11062. temp := strings.Split(item.FeedetlSn, "-")
  11063. var advice_id int64 = 0
  11064. var project_id int64 = 0
  11065. var types int64 = 0
  11066. id, _ := strconv.ParseInt(temp[2], 10, 64)
  11067. types, _ = strconv.ParseInt(temp[1], 10, 64)
  11068. if temp[1] == "1" {
  11069. advice_id = id
  11070. project_id = 0
  11071. } else if temp[1] == "2" {
  11072. advice_id = 0
  11073. project_id = id
  11074. }
  11075. total_two = total_two + item.DetItemFeeSumamt
  11076. info := &models.HisOrderInfo{
  11077. OrderNumber: order.Number,
  11078. FeedetlSn: item.FeedetlSn,
  11079. UploadDate: time.Now().Unix(),
  11080. AdviceId: advice_id,
  11081. DetItemFeeSumamt: item.DetItemFeeSumamt,
  11082. Cnt: item.Cnt,
  11083. Pric: float64(item.Pric),
  11084. PatientId: his.PatientId,
  11085. PricUplmtAmt: item.PricUplmtAmt,
  11086. SelfpayProp: item.SelfpayProp,
  11087. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11088. OverlmtAmt: item.OverlmtAmt,
  11089. PreselfpayAmt: item.PreselfpayAmt,
  11090. BasMednFlag: item.BasMednFlag,
  11091. MedChrgitmType: item.MedChrgitmType,
  11092. HiNegoDrugFlag: item.HiNegoDrugFlag,
  11093. Status: 1,
  11094. Memo: item.Memo,
  11095. Mtime: time.Now().Unix(),
  11096. InscpScpAmt: item.InscpScpAmt,
  11097. DrtReimFlag: item.DrtReimFlag,
  11098. Ctime: time.Now().Unix(),
  11099. ListSpItemFlag: item.ListSpItemFlag,
  11100. ChldMedcFlag: item.ChldMedcFlag,
  11101. LmtUsedFlag: item.LmtUsedFlag,
  11102. ChrgitmLv: item.ChrgitmLv,
  11103. UserOrgId: adminUser.CurrentOrgId,
  11104. HisPatientId: his.ID,
  11105. OrderId: order.ID,
  11106. ProjectId: project_id,
  11107. Type: types,
  11108. }
  11109. service.CreateOrderInfo(info)
  11110. }
  11111. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11112. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  11113. var total float64
  11114. for _, item := range prescriptions {
  11115. if item.Type == 1 { //药品
  11116. for _, subItem := range item.HisDoctorAdviceInfo {
  11117. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11118. total_one := price * subItem.PrescribingNumber
  11119. fmt.Println("subItem")
  11120. fmt.Println(subItem.Price)
  11121. fmt.Println("price")
  11122. fmt.Println(price)
  11123. fmt.Println("total_one")
  11124. fmt.Println(total_one)
  11125. total = total + total_one
  11126. fmt.Println(total)
  11127. }
  11128. }
  11129. if item.Type == 2 { //项目
  11130. for _, subItem := range item.HisPrescriptionProject {
  11131. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11132. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11133. total_one := price * cnt
  11134. total = total + total_one
  11135. }
  11136. }
  11137. }
  11138. allTotal := fmt.Sprintf("%2f", total)
  11139. if res.Infcode == 0 {
  11140. var rf []*ResultFive
  11141. json.Unmarshal([]byte(his.Iinfo), &rf)
  11142. chrg_bchno := chrg_bchno
  11143. cert_no := his.Certno
  11144. var insutypes []string
  11145. var insutype string
  11146. var is390 int = 0
  11147. var is310 int = 0
  11148. for _, item := range rf {
  11149. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11150. insutypes = append(insutypes, item.Insutype)
  11151. }
  11152. }
  11153. if len(insutypes) == 1 {
  11154. insutype = insutypes[0]
  11155. } else {
  11156. for _, i := range insutypes {
  11157. if i == "390" {
  11158. is390 = 1
  11159. }
  11160. if i == "310" {
  11161. is310 = 1
  11162. }
  11163. }
  11164. }
  11165. if is390 == 1 {
  11166. insutype = "390"
  11167. }
  11168. if is310 == 1 {
  11169. insutype = "310"
  11170. }
  11171. if len(insutypes) == 0 {
  11172. insutype = "390"
  11173. }
  11174. if len(insutypes) == 2 {
  11175. insutype = strconv.FormatInt(his.SocialType, 10)
  11176. }
  11177. //insutype = "390"
  11178. if his.IdCardType == 1 {
  11179. cert_no = his.MedicalInsuranceNumber
  11180. } else {
  11181. cert_no = his.Certno
  11182. }
  11183. var res ResultSeven
  11184. var resSeven10265 ResultSeven10265
  11185. if miConfig.MdtrtareaAdmvs == "421300" {
  11186. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11187. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11188. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11189. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11190. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11191. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11192. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  11193. resp, requestErr := http.Get(api)
  11194. if requestErr != nil {
  11195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11196. return
  11197. }
  11198. body, ioErr := ioutil.ReadAll(resp.Body)
  11199. if ioErr != nil {
  11200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11202. return
  11203. }
  11204. var respJSON map[string]interface{}
  11205. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11208. return
  11209. }
  11210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11211. result, _ := json.Marshal(respJSON)
  11212. fmt.Println("log")
  11213. fmt.Println(string(result))
  11214. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11215. utils.ErrorLog("解析失败:%v", err)
  11216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11217. return
  11218. }
  11219. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11220. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  11221. if result3101.Infcode == "0" {
  11222. if len(result3101.Output.Result) > 0 {
  11223. var errMsgs []string
  11224. for _, item := range result3101.Output.Result {
  11225. errMsgs = append(errMsgs, item.VolaCont)
  11226. }
  11227. c.ServeSuccessJSON(map[string]interface{}{
  11228. "failed_code": -10,
  11229. "msg": errMsgs,
  11230. })
  11231. return
  11232. } else {
  11233. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11234. if his.IdCardType != 4 {
  11235. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11236. bas := strings.Split(psn_info.CardInfo, "|")
  11237. if his.IdCardType == 1 {
  11238. cert_no = bas[2]
  11239. } else {
  11240. cert_no = bas[1]
  11241. }
  11242. } else {
  11243. cert_no = his.Certno
  11244. }
  11245. //江苏地区国家医保医疗类别
  11246. //职工透析:医疗类别选特殊情况门诊9933
  11247. //居民血透门慢: 医疗类别选门诊慢病1402
  11248. //var med_type string
  11249. //if his.Insutype == "310" {
  11250. // if reg_type == 14 {
  11251. // med_type = "9933"
  11252. // } else if reg_type == 11 {
  11253. // med_type = "11"
  11254. //
  11255. // }
  11256. //} else if his.Insutype == "390" {
  11257. // if reg_type == 14 {
  11258. // med_type = "1402"
  11259. // } else if reg_type == 11 {
  11260. // med_type = "11"
  11261. // }
  11262. //}
  11263. var api string
  11264. if miConfig.MdtrtareaAdmvs == "320921" {
  11265. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11266. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11267. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11268. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11269. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11270. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11271. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  11272. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11273. } else {
  11274. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11275. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11276. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11277. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11278. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11279. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11280. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11281. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  11282. }
  11283. resp, requestErr := http.Get(api)
  11284. if requestErr != nil {
  11285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11286. return
  11287. }
  11288. body, ioErr := ioutil.ReadAll(resp.Body)
  11289. if ioErr != nil {
  11290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11292. return
  11293. }
  11294. var respJSON map[string]interface{}
  11295. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11298. return
  11299. }
  11300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11301. result, _ := json.Marshal(respJSON)
  11302. fmt.Println("log")
  11303. fmt.Println(string(result))
  11304. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11305. utils.ErrorLog("解析失败:%v", err)
  11306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11307. return
  11308. }
  11309. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11310. res.Output = resSeven10265.Output
  11311. res.ErrMsg = resSeven10265.ErrMsg
  11312. res.Cainfo = resSeven10265.Cainfo
  11313. res.WarnMsg = resSeven10265.WarnMsg
  11314. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11315. res.Infcode = infocode
  11316. }
  11317. }
  11318. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11319. acct_used_flag := "1"
  11320. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  11321. var result string
  11322. var request_log string
  11323. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  11324. result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  11325. } else {
  11326. result, request_log, _ = service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  11327. }
  11328. var dat map[string]interface{}
  11329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11330. fmt.Println(dat)
  11331. } else {
  11332. fmt.Println(err)
  11333. }
  11334. saveLog(result, request_log, "2206", "预结算")
  11335. userJSONBytes, _ := json.Marshal(dat)
  11336. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11337. utils.ErrorLog("解析失败:%v", err)
  11338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11339. return
  11340. }
  11341. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11342. var result string
  11343. var request_log string
  11344. if his.IdCardType == 2 {
  11345. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "")
  11346. } else if his.IdCardType == 1 {
  11347. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11348. bas := strings.Split(psn_info.CardInfo, "|")
  11349. basNumber := bas[2]
  11350. card_sn := bas[3]
  11351. result, request_log = service.Jxyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  11352. } else {
  11353. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11354. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "")
  11355. }
  11356. var dat map[string]interface{}
  11357. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11358. fmt.Println(dat)
  11359. } else {
  11360. fmt.Println(err)
  11361. }
  11362. saveLog(result, request_log, "2206", "预结算")
  11363. userJSONBytes, _ := json.Marshal(dat)
  11364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11365. utils.ErrorLog("解析失败:%v", err)
  11366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11367. return
  11368. }
  11369. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11370. var result string
  11371. var request_log string
  11372. if his.IdCardType == 2 {
  11373. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "", acct_used_flag)
  11374. } else if his.IdCardType == 1 {
  11375. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11376. bas := strings.Split(psn_info.CardInfo, "|")
  11377. basNumber := bas[2]
  11378. card_sn := bas[3]
  11379. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, acct_used_flag)
  11380. } else {
  11381. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11382. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", acct_used_flag)
  11383. }
  11384. var dat map[string]interface{}
  11385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11386. fmt.Println(dat)
  11387. } else {
  11388. fmt.Println(err)
  11389. }
  11390. saveLog(result, request_log, "2206", "预结算")
  11391. userJSONBytes, _ := json.Marshal(dat)
  11392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11393. utils.ErrorLog("解析失败:%v", err)
  11394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11395. return
  11396. }
  11397. } else {
  11398. var result string
  11399. var request_log string
  11400. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11401. allTotal = fmt.Sprintf("%2f", total_two)
  11402. if his.IdCardType == 4 {
  11403. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  11404. } else {
  11405. 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)
  11406. }
  11407. var dat map[string]interface{}
  11408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11409. fmt.Println(dat)
  11410. } else {
  11411. fmt.Println(err)
  11412. }
  11413. saveLog(result, request_log, "2206", "预结算")
  11414. //userJSONBytes, _ := json.Marshal(dat)
  11415. //
  11416. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11417. // utils.ErrorLog("解析失败:%v", err)
  11418. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11419. // return
  11420. //}
  11421. userJSONBytes, _ := json.Marshal(dat)
  11422. if miConfig.Code == "H15049901371" {
  11423. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11424. utils.ErrorLog("解析失败:%v", err)
  11425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11426. return
  11427. }
  11428. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11429. res.Output = resSeven10265.Output
  11430. res.ErrMsg = resSeven10265.ErrMsg
  11431. res.Cainfo = resSeven10265.Cainfo
  11432. res.WarnMsg = resSeven10265.WarnMsg
  11433. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11434. res.Infcode = infocode
  11435. } else {
  11436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11437. utils.ErrorLog("解析失败:%v", err)
  11438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11439. return
  11440. }
  11441. }
  11442. }
  11443. if res.Infcode != 0 {
  11444. errlog := &models.HisOrderError{
  11445. UserOrgId: adminUser.CurrentOrgId,
  11446. Ctime: time.Now().Unix(),
  11447. Mtime: time.Now().Unix(),
  11448. Number: chrg_bchno,
  11449. ErrMsg: res.ErrMsg,
  11450. Status: 1,
  11451. PatientId: id,
  11452. RecordTime: recordDateTime,
  11453. Stage: 20,
  11454. }
  11455. service.CreateErrMsgLog(errlog)
  11456. c.ServeSuccessJSON(map[string]interface{}{
  11457. "failed_code": -10,
  11458. "msg": res.ErrMsg,
  11459. })
  11460. return
  11461. } else {
  11462. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11463. order.OrderStatus = 1
  11464. order.IsPre = 1
  11465. order.Status = 1
  11466. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11467. order.SetlId = res.Output.Setlinfo.SetlID
  11468. order.PsnNo = res.Output.Setlinfo.PsnNo
  11469. order.PsnName = res.Output.Setlinfo.PsnName
  11470. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11471. order.Certno = res.Output.Setlinfo.Certno
  11472. order.Gend = res.Output.Setlinfo.Gend
  11473. order.Naty = res.Output.Setlinfo.Naty
  11474. order.Age = res.Output.Setlinfo.Age
  11475. order.Insutype = res.Output.Setlinfo.Insutype
  11476. order.PsnType = res.Output.Setlinfo.PsnType
  11477. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11478. order.SetlTime = res.Output.Setlinfo.SetlTime
  11479. order.AcctUsedFlag = acct_used_flag
  11480. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11481. if res.Output.Setlinfo.MedType == "140101" {
  11482. order.MedType = "14"
  11483. } else {
  11484. order.MedType = res.Output.Setlinfo.MedType
  11485. }
  11486. if reg_type == 1112 {
  11487. order.MedType = "1112"
  11488. }
  11489. if reg_type == 1111 {
  11490. order.MedType = "1111"
  11491. }
  11492. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11493. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11494. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11495. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11496. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11497. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11498. order.HifpPay = res.Output.Setlinfo.HifpPay
  11499. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11500. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11501. order.HifesPay = res.Output.Setlinfo.HifesPay
  11502. order.HifobPay = res.Output.Setlinfo.HifobPay
  11503. order.MafPay = res.Output.Setlinfo.MafPay
  11504. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  11505. order.OthPay = res.Output.Setlinfo.OthPay
  11506. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11507. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11508. order.AcctPay = res.Output.Setlinfo.AcctPay
  11509. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11510. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11511. order.Balc = res.Output.Setlinfo.Balc
  11512. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11513. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11514. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11515. order.ClrWay = res.Output.Setlinfo.ClrWay
  11516. order.Creator = order.Creator
  11517. order.Modify = roles.AdminUserId
  11518. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11519. detailStr := string(setlDetail)
  11520. order.SetlDetail = detailStr
  11521. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11522. err = service.UpDateOrder(order)
  11523. if err == nil {
  11524. c.ServeSuccessJSON(map[string]interface{}{
  11525. "msg": "预结算成功",
  11526. })
  11527. } else {
  11528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11529. return
  11530. }
  11531. }
  11532. } else {
  11533. adminUser := c.GetAdminUserInfo()
  11534. errlog := &models.HisOrderError{
  11535. UserOrgId: adminUser.CurrentOrgId,
  11536. Ctime: time.Now().Unix(),
  11537. Mtime: time.Now().Unix(),
  11538. ErrMsg: res.ErrMsg,
  11539. Status: 1,
  11540. PatientId: id,
  11541. RecordTime: recordDateTime,
  11542. Stage: 4,
  11543. }
  11544. service.CreateErrMsgLog(errlog)
  11545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11546. return
  11547. }
  11548. } else {
  11549. adminUser := c.GetAdminUserInfo()
  11550. errlog := &models.HisOrderError{
  11551. UserOrgId: adminUser.CurrentOrgId,
  11552. Ctime: time.Now().Unix(),
  11553. Mtime: time.Now().Unix(),
  11554. ErrMsg: res.ErrMsg,
  11555. Status: 1,
  11556. PatientId: id,
  11557. RecordTime: recordDateTime,
  11558. Stage: 4,
  11559. }
  11560. service.CreateErrMsgLog(errlog)
  11561. c.ServeSuccessJSON(map[string]interface{}{
  11562. "failed_code": -10,
  11563. "msg": res.ErrMsg,
  11564. })
  11565. return
  11566. }
  11567. }
  11568. }
  11569. }
  11570. // 退款
  11571. func (c *HisApiController) Refund() {
  11572. order_id, _ := c.GetInt64("order_id")
  11573. admin_user_id, _ := c.GetInt64("admin_user_id")
  11574. adminUser := c.GetAdminUserInfo()
  11575. var order models.HisOrder
  11576. order, _ = service.GetHisOrderByID(order_id)
  11577. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11578. if order.ID == 0 {
  11579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11580. return
  11581. }
  11582. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11583. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11584. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11585. if config.IsOpen == 1 { //对接了医保,走医保流程
  11586. var res ResultSixteen
  11587. var resSixteen10265 ResultSixteen10265
  11588. var src_resquest string
  11589. var result string
  11590. if miConfig.MdtrtareaAdmvs == "421300" {
  11591. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  11592. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11593. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11594. resp3, requestErr3 := http.Get(api3)
  11595. if requestErr3 != nil {
  11596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11597. return
  11598. }
  11599. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11600. if ioErr3 != nil {
  11601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11603. return
  11604. }
  11605. var respJSON3 map[string]interface{}
  11606. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11609. return
  11610. }
  11611. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11612. userJSONBytes3, _ := json.Marshal(respJSON3)
  11613. fmt.Println("log")
  11614. fmt.Println(string(userJSONBytes3))
  11615. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  11616. utils.ErrorLog("解析失败:%v", err)
  11617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11618. return
  11619. }
  11620. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11621. var api3 string
  11622. if miConfig.MdtrtareaAdmvs == "320921" {
  11623. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11624. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11625. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11626. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11627. } else {
  11628. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11629. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  11630. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11631. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11632. }
  11633. resp3, requestErr3 := http.Get(api3)
  11634. if requestErr3 != nil {
  11635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11636. return
  11637. }
  11638. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11639. if ioErr3 != nil {
  11640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11642. return
  11643. }
  11644. var respJSON3 map[string]interface{}
  11645. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11648. return
  11649. }
  11650. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11651. userJSONBytes3, _ := json.Marshal(respJSON3)
  11652. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  11653. utils.ErrorLog("解析失败:%v", err)
  11654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11655. return
  11656. }
  11657. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11658. res.Output = resSixteen10265.Output
  11659. res.ErrMsg = resSixteen10265.ErrMsg
  11660. res.Cainfo = resSixteen10265.Cainfo
  11661. res.WarnMsg = resSixteen10265.WarnMsg
  11662. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11663. res.Infcode = infocode
  11664. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11665. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11666. var dat map[string]interface{}
  11667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11668. fmt.Println(dat)
  11669. } else {
  11670. fmt.Println(err)
  11671. }
  11672. saveLog(result, src_resquest, "2208", "退费")
  11673. userJSONBytes, _ := json.Marshal(dat)
  11674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11675. utils.ErrorLog("解析失败:%v", err)
  11676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11677. return
  11678. }
  11679. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11680. result, src_resquest = service.Jxyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  11681. var dat map[string]interface{}
  11682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11683. fmt.Println(dat)
  11684. } else {
  11685. fmt.Println(err)
  11686. }
  11687. saveLog(result, src_resquest, "2208", "退费")
  11688. userJSONBytes, _ := json.Marshal(dat)
  11689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11690. utils.ErrorLog("解析失败:%v", err)
  11691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11692. return
  11693. }
  11694. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11695. result, src_resquest = service.Hnyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  11696. var dat map[string]interface{}
  11697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11698. fmt.Println(dat)
  11699. } else {
  11700. fmt.Println(err)
  11701. }
  11702. saveLog(result, src_resquest, "2208", "退费")
  11703. userJSONBytes, _ := json.Marshal(dat)
  11704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11705. utils.ErrorLog("解析失败:%v", err)
  11706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11707. return
  11708. }
  11709. } else {
  11710. if miConfig.Code == "H15049901371" {
  11711. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11712. var dat map[string]interface{}
  11713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11714. fmt.Println(dat)
  11715. } else {
  11716. fmt.Println(err)
  11717. }
  11718. saveLog(result, src_resquest, "2208", "退费")
  11719. userJSONBytes, _ := json.Marshal(dat)
  11720. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  11721. utils.ErrorLog("解析失败:%v", err)
  11722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11723. return
  11724. }
  11725. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  11726. res.Output = resSixteen10265.Output
  11727. res.ErrMsg = resSixteen10265.ErrMsg
  11728. res.Cainfo = resSixteen10265.Cainfo
  11729. res.WarnMsg = resSixteen10265.WarnMsg
  11730. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  11731. res.Infcode = infocode
  11732. } else {
  11733. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  11734. var dat map[string]interface{}
  11735. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11736. fmt.Println(dat)
  11737. } else {
  11738. fmt.Println(err)
  11739. }
  11740. saveLog(result, src_resquest, "2208", "退费")
  11741. userJSONBytes, _ := json.Marshal(dat)
  11742. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11743. utils.ErrorLog("解析失败:%v", err)
  11744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11745. return
  11746. }
  11747. }
  11748. }
  11749. if res.Infcode == 0 {
  11750. var res2 ResultSix
  11751. var resSix10265 ResultSix10265
  11752. if miConfig.MdtrtareaAdmvs == "421300" {
  11753. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  11754. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11755. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11756. resp3, requestErr3 := http.Get(api3)
  11757. if requestErr3 != nil {
  11758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11759. return
  11760. }
  11761. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11762. if ioErr3 != nil {
  11763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11765. return
  11766. }
  11767. var respJSON3 map[string]interface{}
  11768. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11771. return
  11772. }
  11773. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11774. userJSONBytes3, _ := json.Marshal(respJSON3)
  11775. fmt.Println("log")
  11776. fmt.Println(string(userJSONBytes3))
  11777. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  11778. utils.ErrorLog("解析失败:%v", err)
  11779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11780. return
  11781. }
  11782. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11783. var api3 string
  11784. if miConfig.MdtrtareaAdmvs == "320921" {
  11785. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11786. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11787. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11788. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11789. } else {
  11790. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11791. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  11792. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11793. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11794. }
  11795. resp3, requestErr3 := http.Get(api3)
  11796. if requestErr3 != nil {
  11797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11798. return
  11799. }
  11800. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11801. if ioErr3 != nil {
  11802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11804. return
  11805. }
  11806. var respJSON3 map[string]interface{}
  11807. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11810. return
  11811. }
  11812. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11813. userJSONBytes3, _ := json.Marshal(respJSON3)
  11814. fmt.Println("log")
  11815. fmt.Println(string(userJSONBytes3))
  11816. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  11817. utils.ErrorLog("解析失败:%v", err)
  11818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11819. return
  11820. }
  11821. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11822. res2.Output = resSix10265.Output
  11823. res2.ErrMsg = resSix10265.ErrMsg
  11824. res2.Cainfo = resSix10265.Cainfo
  11825. res2.WarnMsg = resSix10265.WarnMsg
  11826. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11827. res2.Infcode = infocode
  11828. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11829. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11830. var dat map[string]interface{}
  11831. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11832. fmt.Println(dat)
  11833. } else {
  11834. fmt.Println(err)
  11835. }
  11836. saveLog(result2, src_request, "2205", "撤销明细")
  11837. userJSONBytes, _ := json.Marshal(dat)
  11838. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11839. utils.ErrorLog("解析失败:%v", err)
  11840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11841. return
  11842. }
  11843. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11844. result2, src_request := service.Jxyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11845. var dat map[string]interface{}
  11846. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11847. fmt.Println(dat)
  11848. } else {
  11849. fmt.Println(err)
  11850. }
  11851. saveLog(result2, src_request, "2205", "撤销明细")
  11852. userJSONBytes, _ := json.Marshal(dat)
  11853. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11854. utils.ErrorLog("解析失败:%v", err)
  11855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11856. return
  11857. }
  11858. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11859. result2, src_request := service.Hnyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  11860. var dat map[string]interface{}
  11861. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11862. fmt.Println(dat)
  11863. } else {
  11864. fmt.Println(err)
  11865. }
  11866. saveLog(result2, src_request, "2205", "撤销明细")
  11867. userJSONBytes, _ := json.Marshal(dat)
  11868. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11869. utils.ErrorLog("解析失败:%v", err)
  11870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11871. return
  11872. }
  11873. } else {
  11874. if miConfig.Code == "H15049901371" {
  11875. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11876. var dat map[string]interface{}
  11877. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11878. fmt.Println(dat)
  11879. } else {
  11880. fmt.Println(err)
  11881. }
  11882. saveLog(result2, src_request, "2205", "撤销明细")
  11883. userJSONBytes, _ := json.Marshal(dat)
  11884. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11885. utils.ErrorLog("解析失败:%v", err)
  11886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11887. return
  11888. }
  11889. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11890. res2.Output = resSix10265.Output
  11891. res2.ErrMsg = resSix10265.ErrMsg
  11892. res2.Cainfo = resSix10265.Cainfo
  11893. res2.WarnMsg = resSix10265.WarnMsg
  11894. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11895. res2.Infcode = infocode
  11896. } else {
  11897. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  11898. var dat map[string]interface{}
  11899. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11900. fmt.Println(dat)
  11901. } else {
  11902. fmt.Println(err)
  11903. }
  11904. saveLog(result2, src_request, "2205", "撤销明细")
  11905. userJSONBytes, _ := json.Marshal(dat)
  11906. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11907. utils.ErrorLog("解析失败:%v", err)
  11908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11909. return
  11910. }
  11911. }
  11912. }
  11913. if res2.Infcode == 0 {
  11914. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  11915. if err == nil {
  11916. //当押金不为零时产生退费记录
  11917. if order.Decimal != 0 {
  11918. tmp := strconv.FormatInt(order.ID, 10)
  11919. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  11920. if err != nil {
  11921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11922. return
  11923. }
  11924. }
  11925. c.ServeSuccessJSON(map[string]interface{}{
  11926. "msg": "退费成功",
  11927. })
  11928. } else {
  11929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11930. return
  11931. }
  11932. } else {
  11933. c.ServeSuccessJSON(map[string]interface{}{
  11934. "code": -10,
  11935. "msg": res2.ErrMsg,
  11936. })
  11937. }
  11938. } else {
  11939. c.ServeSuccessJSON(map[string]interface{}{
  11940. "code": -10,
  11941. "msg": res.ErrMsg,
  11942. })
  11943. }
  11944. }
  11945. }
  11946. func (c *HisApiController) RefundNumber() {
  11947. record_time := c.GetString("record_time")
  11948. //patient_id, _ := c.GetInt64("patient_id")
  11949. admin_user_id, _ := c.GetInt64("admin_user_id")
  11950. his_patient_id, _ := c.GetInt64("id")
  11951. timeLayout := "2006-01-02"
  11952. loc, _ := time.LoadLocation("Local")
  11953. adminUser := c.GetAdminUserInfo()
  11954. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11955. fmt.Println(err)
  11956. if err != nil {
  11957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11958. return
  11959. }
  11960. recordDateTime := theTime.Unix()
  11961. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11962. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  11963. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11964. //order, _ := service.GetHisOrderByID(order_id)
  11965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11966. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11967. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11968. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  11969. if count > 0 {
  11970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  11971. return
  11972. }
  11973. if config.IsOpen == 1 { //对接了医保,走医保流程
  11974. var res2 ResultSix
  11975. var resSix10265 ResultSix10265
  11976. if miConfig.MdtrtareaAdmvs == "421300" {
  11977. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  11978. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11980. resp3, requestErr3 := http.Get(api3)
  11981. if requestErr3 != nil {
  11982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11983. return
  11984. }
  11985. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  11986. if ioErr3 != nil {
  11987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  11988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11989. return
  11990. }
  11991. var respJSON3 map[string]interface{}
  11992. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  11993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11995. return
  11996. }
  11997. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11998. userJSONBytes3, _ := json.Marshal(respJSON3)
  11999. fmt.Println("log")
  12000. fmt.Println(string(userJSONBytes3))
  12001. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12002. utils.ErrorLog("解析失败:%v", err)
  12003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12004. return
  12005. }
  12006. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12007. var api3 string
  12008. if miConfig.MdtrtareaAdmvs == "320921" {
  12009. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12010. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12011. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12012. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12013. } else {
  12014. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12015. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12016. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12017. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12018. }
  12019. resp3, requestErr3 := http.Get(api3)
  12020. if requestErr3 != nil {
  12021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12022. return
  12023. }
  12024. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12025. if ioErr3 != nil {
  12026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12028. return
  12029. }
  12030. var respJSON3 map[string]interface{}
  12031. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12034. return
  12035. }
  12036. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12037. userJSONBytes3, _ := json.Marshal(respJSON3)
  12038. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12039. utils.ErrorLog("解析失败:%v", err)
  12040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12041. return
  12042. }
  12043. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12044. res2.Output = resSix10265.Output
  12045. res2.ErrMsg = resSix10265.ErrMsg
  12046. res2.Cainfo = resSix10265.Cainfo
  12047. res2.WarnMsg = resSix10265.WarnMsg
  12048. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12049. res2.Infcode = infocode
  12050. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12051. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12052. var dat map[string]interface{}
  12053. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12054. fmt.Println(dat)
  12055. } else {
  12056. fmt.Println(err)
  12057. }
  12058. saveLog(result, request, "2202", "退号")
  12059. userJSONBytes, _ := json.Marshal(dat)
  12060. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12061. utils.ErrorLog("解析失败:%v", err)
  12062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12063. return
  12064. }
  12065. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12066. result, request := service.Jxyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  12067. var dat map[string]interface{}
  12068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12069. fmt.Println(dat)
  12070. } else {
  12071. fmt.Println(err)
  12072. }
  12073. saveLog(result, request, "2202", "退号")
  12074. userJSONBytes, _ := json.Marshal(dat)
  12075. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12076. utils.ErrorLog("解析失败:%v", err)
  12077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12078. return
  12079. }
  12080. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12081. result, request := service.Hnyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  12082. var dat map[string]interface{}
  12083. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12084. fmt.Println(dat)
  12085. } else {
  12086. fmt.Println(err)
  12087. }
  12088. saveLog(result, request, "2202", "退号")
  12089. userJSONBytes, _ := json.Marshal(dat)
  12090. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12091. utils.ErrorLog("解析失败:%v", err)
  12092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12093. return
  12094. }
  12095. } else {
  12096. var api3 string
  12097. if miConfig.Code == "H15049901371" {
  12098. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  12099. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12100. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12101. } else {
  12102. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  12103. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12104. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12105. }
  12106. resp3, requestErr3 := http.Get(api3)
  12107. if requestErr3 != nil {
  12108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12109. return
  12110. }
  12111. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12112. if ioErr3 != nil {
  12113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12115. return
  12116. }
  12117. var respJSON3 map[string]interface{}
  12118. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12121. return
  12122. }
  12123. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12124. userJSONBytes3, _ := json.Marshal(respJSON3)
  12125. if miConfig.Code == "H15049901371" {
  12126. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12127. utils.ErrorLog("解析失败:%v", err)
  12128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12129. return
  12130. }
  12131. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12132. res2.Output = resSix10265.Output
  12133. res2.ErrMsg = resSix10265.ErrMsg
  12134. res2.Cainfo = resSix10265.Cainfo
  12135. res2.WarnMsg = resSix10265.WarnMsg
  12136. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12137. res2.Infcode = infocode
  12138. } else {
  12139. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12140. utils.ErrorLog("解析失败:%v", err)
  12141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12142. return
  12143. }
  12144. }
  12145. }
  12146. if res2.Infcode == 0 {
  12147. if err == nil {
  12148. c.ServeSuccessJSON(map[string]interface{}{
  12149. "msg": "退号成功",
  12150. })
  12151. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  12152. } else {
  12153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12154. return
  12155. }
  12156. } else {
  12157. c.ServeSuccessJSON(map[string]interface{}{
  12158. "code": -10,
  12159. "msg": res2.ErrMsg,
  12160. })
  12161. }
  12162. } else {
  12163. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  12164. //if err == nil {
  12165. // c.ServeSuccessJSON(map[string]interface{}{
  12166. // "msg": "退费成功",
  12167. // })
  12168. //} else {
  12169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12170. // return
  12171. //}
  12172. }
  12173. }
  12174. func (c *HisApiController) RefundDetail() {
  12175. order_id, _ := c.GetInt64("order_id")
  12176. admin_user_id, _ := c.GetInt64("admin_user_id")
  12177. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12178. number := c.GetString("number")
  12179. record_time := c.GetString("record_time")
  12180. patient_id, _ := c.GetInt64("patient_id")
  12181. //med_type, _ := c.GetInt64("med_type")
  12182. timeLayout := "2006-01-02"
  12183. loc, _ := time.LoadLocation("Local")
  12184. adminUser := c.GetAdminUserInfo()
  12185. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12186. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12187. fmt.Println(err)
  12188. if err != nil {
  12189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12190. return
  12191. }
  12192. recordDateTime := theTime.Unix()
  12193. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12194. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12196. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12197. var order models.HisOrder
  12198. order, _ = service.GetHisOrderByID(order_id)
  12199. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12200. if config.IsOpen == 1 { //对接了医保,走医保流程
  12201. var res2 ResultSix
  12202. if miConfig.MdtrtareaAdmvs == "421300" {
  12203. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  12204. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12205. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12206. resp3, requestErr3 := http.Get(api3)
  12207. if requestErr3 != nil {
  12208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12209. return
  12210. }
  12211. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12212. if ioErr3 != nil {
  12213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12215. return
  12216. }
  12217. var respJSON3 map[string]interface{}
  12218. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12221. return
  12222. }
  12223. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12224. userJSONBytes3, _ := json.Marshal(respJSON3)
  12225. fmt.Println("log")
  12226. fmt.Println(string(userJSONBytes3))
  12227. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12228. utils.ErrorLog("解析失败:%v", err)
  12229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12230. return
  12231. }
  12232. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12233. if err == nil {
  12234. c.ServeSuccessJSON(map[string]interface{}{
  12235. "msg": "撤销明细成功",
  12236. })
  12237. return
  12238. } else {
  12239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12240. return
  12241. }
  12242. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12243. var resSix10265 ResultSix10265
  12244. var api3 string
  12245. if miConfig.MdtrtareaAdmvs == "320921" {
  12246. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12247. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12248. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12249. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12250. } else {
  12251. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12252. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12253. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12254. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12255. }
  12256. resp3, requestErr3 := http.Get(api3)
  12257. if requestErr3 != nil {
  12258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12259. return
  12260. }
  12261. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12262. if ioErr3 != nil {
  12263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12265. return
  12266. }
  12267. var respJSON3 map[string]interface{}
  12268. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12271. return
  12272. }
  12273. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12274. userJSONBytes3, _ := json.Marshal(respJSON3)
  12275. fmt.Println("log")
  12276. fmt.Println(string(userJSONBytes3))
  12277. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12278. utils.ErrorLog("解析失败:%v", err)
  12279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12280. return
  12281. }
  12282. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12283. res2.Output = resSix10265.Output
  12284. res2.ErrMsg = resSix10265.ErrMsg
  12285. res2.Cainfo = resSix10265.Cainfo
  12286. res2.WarnMsg = resSix10265.WarnMsg
  12287. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12288. res2.Infcode = infocode
  12289. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12290. if err == nil {
  12291. c.ServeSuccessJSON(map[string]interface{}{
  12292. "msg": "撤销明细成功",
  12293. })
  12294. return
  12295. } else {
  12296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12297. return
  12298. }
  12299. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12300. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  12301. var dat map[string]interface{}
  12302. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12303. fmt.Println(dat)
  12304. } else {
  12305. fmt.Println(err)
  12306. }
  12307. saveLog(result2, src_request, "2205", "撤销明细")
  12308. userJSONBytes, _ := json.Marshal(dat)
  12309. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12310. utils.ErrorLog("解析失败:%v", err)
  12311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12312. return
  12313. }
  12314. if res2.Infcode == 0 {
  12315. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12316. if err == nil {
  12317. c.ServeSuccessJSON(map[string]interface{}{
  12318. "msg": "撤销明细成功",
  12319. })
  12320. return
  12321. } else {
  12322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12323. return
  12324. }
  12325. } else {
  12326. c.ServeSuccessJSON(map[string]interface{}{
  12327. "code": -10,
  12328. "msg": res2.ErrMsg,
  12329. })
  12330. }
  12331. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12332. result2, src_request := service.Jxyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  12333. var dat map[string]interface{}
  12334. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12335. fmt.Println(dat)
  12336. } else {
  12337. fmt.Println(err)
  12338. }
  12339. saveLog(result2, src_request, "2205", "撤销明细")
  12340. userJSONBytes, _ := json.Marshal(dat)
  12341. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12342. utils.ErrorLog("解析失败:%v", err)
  12343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12344. return
  12345. }
  12346. if res2.Infcode == 0 {
  12347. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12348. if err == nil {
  12349. c.ServeSuccessJSON(map[string]interface{}{
  12350. "msg": "撤销明细成功",
  12351. })
  12352. return
  12353. } else {
  12354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12355. return
  12356. }
  12357. } else {
  12358. c.ServeSuccessJSON(map[string]interface{}{
  12359. "code": -10,
  12360. "msg": res2.ErrMsg,
  12361. })
  12362. }
  12363. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12364. result2, src_request := service.Hnyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  12365. var dat map[string]interface{}
  12366. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12367. fmt.Println(dat)
  12368. } else {
  12369. fmt.Println(err)
  12370. }
  12371. saveLog(result2, src_request, "2205", "撤销明细")
  12372. userJSONBytes, _ := json.Marshal(dat)
  12373. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12374. utils.ErrorLog("解析失败:%v", err)
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return
  12377. }
  12378. if res2.Infcode == 0 {
  12379. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12380. if err == nil {
  12381. c.ServeSuccessJSON(map[string]interface{}{
  12382. "msg": "撤销明细成功",
  12383. })
  12384. return
  12385. } else {
  12386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12387. return
  12388. }
  12389. } else {
  12390. c.ServeSuccessJSON(map[string]interface{}{
  12391. "code": -10,
  12392. "msg": res2.ErrMsg,
  12393. })
  12394. }
  12395. } else {
  12396. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  12397. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12398. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12399. resp2, requestErr2 := http.Get(api2)
  12400. if requestErr2 != nil {
  12401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12402. return
  12403. }
  12404. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12405. if ioErr2 != nil {
  12406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12408. return
  12409. }
  12410. var respJSON2 map[string]interface{}
  12411. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12414. return
  12415. }
  12416. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12417. if err == nil {
  12418. c.ServeSuccessJSON(map[string]interface{}{
  12419. "msg": "撤销明细成功",
  12420. })
  12421. return
  12422. } else {
  12423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12424. return
  12425. }
  12426. }
  12427. } else {
  12428. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12429. if err == nil {
  12430. c.ServeSuccessJSON(map[string]interface{}{
  12431. "msg": "退费成功",
  12432. })
  12433. } else {
  12434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12435. return
  12436. }
  12437. }
  12438. }
  12439. // 对账
  12440. func (c *HisApiController) GetCheckAccount() {
  12441. start_time := c.GetString("start_time")
  12442. end_time := c.GetString("end_time")
  12443. insutype := c.GetString("insutype")
  12444. clr_type := c.GetString("clr_type")
  12445. clr_org := c.GetString("clr_optins")
  12446. admin_user_id, _ := c.GetInt64("admin_user_id")
  12447. adminUser := c.GetAdminUserInfo()
  12448. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12449. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12450. if len(clr_org) == 0 {
  12451. clr_org = miConfig.MdtrtareaAdmvs
  12452. }
  12453. timeLayout := "2006-01-02"
  12454. loc, _ := time.LoadLocation("Local")
  12455. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12456. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12457. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12458. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12459. fixmedins_setl_cnt := int64(len(orders))
  12460. var medfee_sumamt float64
  12461. var acct_pay float64
  12462. var fund_pay_sumamt float64
  12463. for _, item := range orders {
  12464. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12465. acct_pay = acct_pay + item.AcctPay
  12466. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12467. }
  12468. var user_name string
  12469. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12470. if role.ID == 0 {
  12471. user_name = "xxx"
  12472. } else {
  12473. user_name = role.UserName
  12474. }
  12475. var res ResultEight
  12476. var res10188 ResultEightFor10188
  12477. if config.IsOpen == 1 {
  12478. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12479. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  12480. "insutype=" + insutype +
  12481. "&clr_type=" + clr_type +
  12482. "&setl_optins=" + clr_org +
  12483. "&stmt_begndate=" + start_time +
  12484. "&stm_enddate=" + end_time +
  12485. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12486. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12487. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12488. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  12489. "&fixmedins_code=" + miConfig.Code +
  12490. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12491. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12492. "&secret_key=" + miConfig.SecretKey +
  12493. "&org_name=" + miConfig.OrgName +
  12494. "&doctor=" + user_name +
  12495. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12496. fmt.Println(api)
  12497. resp, requestErr := http.Get(api)
  12498. if requestErr != nil {
  12499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12500. return
  12501. }
  12502. body, ioErr := ioutil.ReadAll(resp.Body)
  12503. fmt.Println(body)
  12504. if ioErr != nil {
  12505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12507. return
  12508. }
  12509. var respJSON map[string]interface{}
  12510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12513. return
  12514. }
  12515. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12516. userJSONBytes, _ := json.Marshal(respJSON)
  12517. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12518. utils.ErrorLog("解析失败:%v", err)
  12519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12520. return
  12521. }
  12522. res.InfRefmsgid = res10188.InfRefmsgid
  12523. res.Output = res10188.Output
  12524. res.ErrMsg = res10188.ErrMsg
  12525. res.Cainfo = res10188.Cainfo
  12526. res.WarnMsg = res10188.WarnMsg
  12527. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12528. res.Infcode = infocode
  12529. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12530. if clr_type == "11" {
  12531. fixmedins_setl_cnt = 2
  12532. }
  12533. if clr_type == "21" {
  12534. clr_type = "22"
  12535. }
  12536. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  12537. "insutype=" + insutype +
  12538. "&clr_type=" + clr_type +
  12539. "&setl_optins=" + clr_org +
  12540. "&stmt_begndate=" + start_time +
  12541. "&stm_enddate=" + end_time +
  12542. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12543. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12544. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12545. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  12546. "&fixmedins_code=" + miConfig.Code +
  12547. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12548. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12549. "&secret_key=" + miConfig.SecretKey +
  12550. "&org_name=" + miConfig.OrgName +
  12551. "&doctor=" + user_name
  12552. resp, requestErr := http.Get(api)
  12553. if requestErr != nil {
  12554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12555. return
  12556. }
  12557. body, ioErr := ioutil.ReadAll(resp.Body)
  12558. if ioErr != nil {
  12559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12561. return
  12562. }
  12563. var respJSON map[string]interface{}
  12564. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12567. return
  12568. }
  12569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12570. result, _ := json.Marshal(respJSON)
  12571. fmt.Println("log")
  12572. fmt.Println(string(result))
  12573. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  12574. utils.ErrorLog("解析失败:%v", err)
  12575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12576. return
  12577. }
  12578. res.InfRefmsgid = res10188.InfRefmsgid
  12579. res.Output = res10188.Output
  12580. res.ErrMsg = res10188.ErrMsg
  12581. res.Cainfo = res10188.Cainfo
  12582. res.WarnMsg = res10188.WarnMsg
  12583. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  12584. res.Infcode = infocode
  12585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12586. var baseParams models.BaseParams
  12587. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12588. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12589. baseParams.SecretKey = miConfig.SecretKey
  12590. baseParams.OrgName = miConfig.OrgName
  12591. baseParams.FixmedinsCode = miConfig.Code
  12592. baseParams.EncKey = miConfig.EncKey
  12593. baseParams.AppSecret = miConfig.AppSecret
  12594. baseParams.SignKey = miConfig.SignKey
  12595. baseParams.AppID = miConfig.Code
  12596. baseParams.Doctor = role.UserName
  12597. baseParams.RequestUrl = miConfig.Url
  12598. businessParams := models.BusinessParams{
  12599. Insutype: insutype,
  12600. ClrType: clr_type,
  12601. SetlOptins: clr_org,
  12602. StmtBegndate: start_time,
  12603. StmtEnddate: end_time,
  12604. MedfeeSumamt: medfee_sumamt,
  12605. FundPaySumamt: fund_pay_sumamt,
  12606. AcctPay: acct_pay,
  12607. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12608. }
  12609. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12610. fmt.Println(requestLog)
  12611. fmt.Println(result)
  12612. fmt.Println(err_msg)
  12613. var dat map[string]interface{}
  12614. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12615. fmt.Println(dat)
  12616. } else {
  12617. fmt.Println(err)
  12618. }
  12619. userJSONBytes, _ := json.Marshal(dat)
  12620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12621. utils.ErrorLog("解析失败:%v", err)
  12622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12623. return
  12624. }
  12625. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12626. var baseParams models.BaseParams
  12627. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12628. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12629. baseParams.SecretKey = miConfig.SecretKey
  12630. baseParams.OrgName = miConfig.OrgName
  12631. baseParams.FixmedinsCode = miConfig.Code
  12632. baseParams.EncKey = miConfig.EncKey
  12633. baseParams.AppSecret = miConfig.AppSecret
  12634. baseParams.SignKey = miConfig.SignKey
  12635. baseParams.AppID = miConfig.Code
  12636. baseParams.Doctor = role.UserName
  12637. baseParams.RequestUrl = miConfig.Url
  12638. baseParams.AccessKey = miConfig.AccessKey
  12639. businessParams := models.BusinessParams{
  12640. Insutype: insutype,
  12641. ClrType: clr_type,
  12642. SetlOptins: "430822",
  12643. StmtBegndate: start_time,
  12644. StmtEnddate: end_time,
  12645. MedfeeSumamt: medfee_sumamt,
  12646. FundPaySumamt: fund_pay_sumamt,
  12647. AcctPay: acct_pay,
  12648. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12649. }
  12650. result, requestLog := service.Hnyb3201(businessParams.FixmedinsSetlCnt, businessParams.AcctPay, businessParams.FundPaySumamt, businessParams.MedfeeSumamt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.SetlOptins, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, baseParams.Cainfo)
  12651. fmt.Println(requestLog)
  12652. fmt.Println(result)
  12653. var dat map[string]interface{}
  12654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12655. fmt.Println(dat)
  12656. } else {
  12657. fmt.Println(err)
  12658. }
  12659. userJSONBytes, _ := json.Marshal(dat)
  12660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12661. utils.ErrorLog("解析失败:%v", err)
  12662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12663. return
  12664. }
  12665. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12666. var baseParams models.BaseParams
  12667. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12668. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12669. baseParams.SecretKey = miConfig.SecretKey
  12670. baseParams.OrgName = miConfig.OrgName
  12671. baseParams.FixmedinsCode = miConfig.Code
  12672. baseParams.EncKey = miConfig.EncKey
  12673. baseParams.AppSecret = miConfig.AppSecret
  12674. baseParams.SignKey = miConfig.SignKey
  12675. baseParams.AppID = miConfig.Code
  12676. baseParams.Doctor = role.UserName
  12677. baseParams.RequestUrl = miConfig.Url
  12678. businessParams := models.BusinessParams{
  12679. Insutype: insutype,
  12680. ClrType: clr_type,
  12681. SetlOptins: clr_org,
  12682. StmtBegndate: start_time,
  12683. StmtEnddate: end_time,
  12684. MedfeeSumamt: medfee_sumamt,
  12685. FundPaySumamt: fund_pay_sumamt,
  12686. AcctPay: acct_pay,
  12687. FixmedinsSetlCnt: fixmedins_setl_cnt,
  12688. }
  12689. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  12690. fmt.Println(requestLog)
  12691. fmt.Println(result)
  12692. fmt.Println(err_msg)
  12693. var dat map[string]interface{}
  12694. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12695. fmt.Println(dat)
  12696. } else {
  12697. fmt.Println(err)
  12698. }
  12699. userJSONBytes, _ := json.Marshal(dat)
  12700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12701. utils.ErrorLog("解析失败:%v", err)
  12702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12703. return
  12704. }
  12705. } else {
  12706. if len(clr_type) == 0 {
  12707. clr_type = "11"
  12708. }
  12709. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12710. "insutype=" + insutype +
  12711. "&clr_type=" + clr_type +
  12712. "&setl_optins=" + clr_org +
  12713. "&stmt_begndate=" + start_time +
  12714. "&stm_enddate=" + end_time +
  12715. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  12716. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  12717. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  12718. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  12719. "&fixmedins_code=" + miConfig.Code +
  12720. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12721. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12722. "&secret_key=" + miConfig.SecretKey +
  12723. "&org_name=" + miConfig.OrgName +
  12724. "&doctor=" + user_name
  12725. fmt.Println(api)
  12726. resp, requestErr := http.Get(api)
  12727. if requestErr != nil {
  12728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12729. return
  12730. }
  12731. body, ioErr := ioutil.ReadAll(resp.Body)
  12732. fmt.Println(body)
  12733. if ioErr != nil {
  12734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12736. return
  12737. }
  12738. var respJSON map[string]interface{}
  12739. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12742. return
  12743. }
  12744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12745. userJSONBytes, _ := json.Marshal(respJSON)
  12746. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12747. utils.ErrorLog("解析失败:%v", err)
  12748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12749. return
  12750. }
  12751. }
  12752. if res.Infcode == 0 {
  12753. if res.Output.Stmtinfo.StmtRslt == "0" {
  12754. micc := &models.MedicalInsuranceCostCompare{
  12755. StartTime: startime.Unix(),
  12756. EndTime: endtime.Unix(),
  12757. Insutype: insutype,
  12758. CheckType: 1,
  12759. Num: fixmedins_setl_cnt,
  12760. Mtime: time.Now().Unix(),
  12761. Status: 1,
  12762. UserOrgId: adminUser.CurrentOrgId,
  12763. CostTotal: medfee_sumamt,
  12764. FuncTotal: fund_pay_sumamt,
  12765. PsnPay: acct_pay,
  12766. Creator: admin_user_id,
  12767. Ctime: time.Now().Unix(),
  12768. ClrType: clr_type,
  12769. }
  12770. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  12771. if err == nil {
  12772. c.ServeSuccessJSON(map[string]interface{}{
  12773. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12774. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12775. })
  12776. } else {
  12777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12778. }
  12779. } else {
  12780. c.ServeSuccessJSON(map[string]interface{}{
  12781. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  12782. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  12783. })
  12784. }
  12785. } else {
  12786. c.ServeSuccessJSON(map[string]interface{}{
  12787. "code": -10,
  12788. "msg": res.ErrMsg,
  12789. })
  12790. }
  12791. }
  12792. }
  12793. func (c *HisApiController) Check310() {
  12794. adminUser := c.GetAdminUserInfo()
  12795. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12796. var user_name string
  12797. user_name = "高慧裕"
  12798. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12799. "insutype=" + "310" +
  12800. "&clr_type=" + "" +
  12801. "&setl_optins=" + "441202" +
  12802. "&stmt_begndate=" + "2022-03-01" +
  12803. "&stm_enddate=" + "2022-03-31" +
  12804. "&medfee_sumamt=" + "194930.12" +
  12805. "&fund_pay_sumamt=" + "188741.46" +
  12806. "&acct_pay=" + "0" +
  12807. "&fixmedins_setl_cnt=" + "452" +
  12808. "&fixmedins_code=" + miConfig.Code +
  12809. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12810. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12811. "&secret_key=" + miConfig.SecretKey +
  12812. "&org_name=" + miConfig.OrgName +
  12813. "&doctor=" + user_name
  12814. fmt.Println(api)
  12815. resp, requestErr := http.Get(api)
  12816. if requestErr != nil {
  12817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12818. return
  12819. }
  12820. body, ioErr := ioutil.ReadAll(resp.Body)
  12821. fmt.Println(body)
  12822. if ioErr != nil {
  12823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12825. return
  12826. }
  12827. var respJSON map[string]interface{}
  12828. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12831. return
  12832. }
  12833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12834. userJSONBytes, _ := json.Marshal(respJSON)
  12835. var res ResultEight
  12836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12837. utils.ErrorLog("解析失败:%v", err)
  12838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12839. return
  12840. }
  12841. }
  12842. func (c *HisApiController) Check390() {
  12843. adminUser := c.GetAdminUserInfo()
  12844. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12845. var user_name string
  12846. user_name = "高慧裕"
  12847. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  12848. "insutype=" + "390" +
  12849. "&clr_type=" + "" +
  12850. "&setl_optins=" + "441202" +
  12851. "&stmt_begndate=" + "2022-03-01" +
  12852. "&stm_enddate=" + "2022-03-31" +
  12853. "&medfee_sumamt=" + "1068448.89" +
  12854. "&fund_pay_sumamt=" + "1014677.62" +
  12855. "&acct_pay=" + "0" +
  12856. "&fixmedins_setl_cnt=" + "1950" +
  12857. "&fixmedins_code=" + miConfig.Code +
  12858. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  12859. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12860. "&secret_key=" + miConfig.SecretKey +
  12861. "&org_name=" + miConfig.OrgName +
  12862. "&doctor=" + user_name
  12863. fmt.Println(api)
  12864. resp, requestErr := http.Get(api)
  12865. if requestErr != nil {
  12866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12867. return
  12868. }
  12869. body, ioErr := ioutil.ReadAll(resp.Body)
  12870. fmt.Println(body)
  12871. if ioErr != nil {
  12872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12874. return
  12875. }
  12876. var respJSON map[string]interface{}
  12877. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12880. return
  12881. }
  12882. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12883. userJSONBytes, _ := json.Marshal(respJSON)
  12884. var res ResultEight
  12885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12886. utils.ErrorLog("解析失败:%v", err)
  12887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12888. return
  12889. }
  12890. }
  12891. // 对账明细
  12892. func (c *HisApiController) GetCheckDetailAccount() {
  12893. start_time := c.GetString("start_time")
  12894. end_time := c.GetString("end_time")
  12895. admin_user_id, _ := c.GetInt64("admin_user_id")
  12896. adminUser := c.GetAdminUserInfo()
  12897. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12898. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12899. timeLayout := "2006-01-02"
  12900. loc, _ := time.LoadLocation("Local")
  12901. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12902. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12903. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  12904. rand.Seed(time.Now().UnixNano())
  12905. num := rand.Intn(30000)
  12906. Mkdir(miConfig.OrgName)
  12907. file := strconv.FormatInt(int64(num), 10)
  12908. file_name := file + ".txt"
  12909. zip_name := file + ".zip"
  12910. zip_path := miConfig.OrgName + "/" + zip_name
  12911. file_path := miConfig.OrgName + "/" + file_name
  12912. decimal.DivisionPrecision = 2
  12913. var medfee_sumamt float64
  12914. var psn_cash_pay float64
  12915. var fund_pay_sumamt float64
  12916. fixmedins_setl_cnt := int64(len(orders))
  12917. for _, item := range orders {
  12918. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12919. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  12920. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12921. }
  12922. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  12923. defer f.Close()
  12924. if err != nil {
  12925. fmt.Println(err.Error())
  12926. } else {
  12927. for _, item := range orders {
  12928. var refd_setl_flag string
  12929. if item.OrderStatus == 2 {
  12930. refd_setl_flag = "0"
  12931. var str string
  12932. str = item.SetlId + " " +
  12933. item.MdtrtId + " " +
  12934. item.PsnNo + " " +
  12935. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12936. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12937. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  12938. _, err = f.Write([]byte(str))
  12939. }
  12940. if item.OrderStatus == 3 {
  12941. var str string
  12942. str = item.SetlId + " " +
  12943. item.MdtrtId + " " +
  12944. item.PsnNo + " " +
  12945. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  12946. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  12947. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  12948. _, err = f.Write([]byte(str))
  12949. var str2 string
  12950. str2 = item.SetlId + " " +
  12951. item.MdtrtId + " " +
  12952. item.PsnNo + " " +
  12953. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  12954. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  12955. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  12956. _, err = f.Write([]byte(str2))
  12957. }
  12958. }
  12959. }
  12960. Zip(file_path, zip_path)
  12961. fmt.Println(ReadFile(zip_path))
  12962. fmt.Println(string(ReadFile(zip_path)))
  12963. if config.IsOpen == 1 {
  12964. var user_name string
  12965. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12966. if role.ID == 0 {
  12967. user_name = "管理员"
  12968. } else {
  12969. user_name = role.UserName
  12970. }
  12971. baseParams := models.BaseParams{
  12972. SecretKey: miConfig.SecretKey,
  12973. FixmedinsCode: miConfig.Code,
  12974. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12975. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12976. OrgName: miConfig.OrgName,
  12977. Doctor: user_name,
  12978. }
  12979. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  12980. var dat map[string]interface{}
  12981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12982. fmt.Println(dat)
  12983. } else {
  12984. fmt.Println(err)
  12985. }
  12986. userJSONBytes, _ := json.Marshal(dat)
  12987. var res ResultNine
  12988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12989. utils.ErrorLog("解析失败:%v", err)
  12990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12991. return
  12992. }
  12993. if res.Infcode == 0 {
  12994. fileNo := res.Output.FileQuryNo
  12995. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  12996. "file_qury_no=" + fileNo +
  12997. "&setl_optins=" + "定点医保中心" +
  12998. "&stmt_begndate=" + start_time +
  12999. "&stm_enddate=" + end_time +
  13000. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13001. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13002. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  13003. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13004. "&fixmedins_code=" + miConfig.Code +
  13005. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13006. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13007. "&secret_key=" + miConfig.SecretKey +
  13008. "&org_name=" + miConfig.OrgName +
  13009. "&doctor=" + user_name
  13010. resp, requestErr := http.Get(api)
  13011. if requestErr != nil {
  13012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13013. return
  13014. }
  13015. body, ioErr := ioutil.ReadAll(resp.Body)
  13016. if ioErr != nil {
  13017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13019. return
  13020. }
  13021. var respJSON map[string]interface{}
  13022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13025. return
  13026. }
  13027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13028. userJSONBytes, _ := json.Marshal(respJSON)
  13029. var res ResultTen
  13030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13031. utils.ErrorLog("解析失败:%v", err)
  13032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13033. return
  13034. }
  13035. if res.Infcode == 0 {
  13036. service.Gdyb9102(baseParams, zip_name, fileNo)
  13037. micc := &models.MedicalInsuranceCostCompare{
  13038. StartTime: startime.Unix(),
  13039. EndTime: endtime.Unix(),
  13040. Insutype: "0",
  13041. CheckType: 2,
  13042. Num: fixmedins_setl_cnt,
  13043. Mtime: time.Now().Unix(),
  13044. Status: 1,
  13045. UserOrgId: adminUser.CurrentOrgId,
  13046. CostTotal: medfee_sumamt,
  13047. FuncTotal: fund_pay_sumamt,
  13048. PsnPay: psn_cash_pay,
  13049. Creator: admin_user_id,
  13050. Ctime: time.Now().Unix(),
  13051. }
  13052. service.CreateMedicalInsuranceCostCompareRecord(micc)
  13053. c.ServeSuccessJSON(map[string]interface{}{
  13054. "msg": "明细对账成功",
  13055. })
  13056. }
  13057. } else {
  13058. }
  13059. }
  13060. }
  13061. type CustomOrderInfo struct {
  13062. Name string
  13063. Spec string
  13064. Unit string
  13065. Count float64
  13066. Price float64
  13067. Total float64
  13068. }
  13069. func (c *HisApiController) GetSettleAccounts() {
  13070. //id, _ := c.GetInt64("id")
  13071. //record_time := c.GetString("record_time")
  13072. order_id, _ := c.GetInt64("order_id")
  13073. admin_user_id, _ := c.GetInt64("admin_user_id")
  13074. //timeLayout := "2006-01-02"
  13075. //loc, _ := time.LoadLocation("Local")
  13076. //
  13077. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13078. //if err != nil {
  13079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13080. // return
  13081. //}
  13082. //recordDateTime := theTime.Unix()
  13083. adminUser := c.GetAdminUserInfo()
  13084. order, _ := service.GetHisOrderByID(order_id)
  13085. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13086. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  13087. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  13088. orderInfos = append(orderInfos, orderInfos_two...)
  13089. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13090. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  13091. var diagnosis_ids []string
  13092. if his.ID > 0 {
  13093. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  13094. } else {
  13095. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  13096. }
  13097. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  13098. var dia_config []*models.HisXtDiagnoseConfig
  13099. var name string
  13100. for _, item := range diagnosis_ids {
  13101. id, _ := strconv.ParseInt(item, 10, 64)
  13102. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13103. dia_config = append(dia_config, &diagnosisConfig)
  13104. if len(name) == 0 {
  13105. name = diagnosisConfig.ClassName
  13106. } else {
  13107. name = name + "," + diagnosisConfig.ClassName
  13108. }
  13109. }
  13110. var bedCostTotal float64 = 0 //床位总费
  13111. var bedCostSelfTotal float64 = 0 //床位自费
  13112. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13113. var bedSelfTotal float64 = 0 //床位部分项目自费
  13114. var bedInscpTotal float64 = 0 //床位部分项目自费
  13115. var operationCostTotal float64 = 0 //手术费
  13116. var operationCostSelfTotal float64 = 0 //手术费
  13117. var operationCostPartSelfTotal float64 = 0 //手术费
  13118. var operationSelfTotal float64 = 0 //床位部分项目自费
  13119. var operationInscpTotal float64 = 0 //床位部分项目自费
  13120. var otherCostTotal float64 = 0 //其他费用
  13121. var otherCostSelfTotal float64 = 0 //其他费用
  13122. var otherCostPartSelfTotal float64 = 0 //其他费用
  13123. var otherSelfTotal float64 = 0 //床位部分项目自费
  13124. var otherInscpTotal float64 = 0 //床位部分项目自费
  13125. var materialCostTotal float64 = 0 //材料费
  13126. var materialCostSelfTotal float64 = 0 //材料费
  13127. var materialCostPartSelfTotal float64 = 0 //材料费
  13128. var materialSelfTotal float64 = 0 //床位部分项目自费
  13129. var materialInscpTotal float64 = 0 //床位部分项目自费
  13130. var westernMedicineCostTotal float64 = 0 //西药费
  13131. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13132. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13133. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  13134. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  13135. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13136. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13137. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13138. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  13139. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  13140. var checkCostTotal float64 = 0 //检查费
  13141. var checkCostSelfTotal float64 = 0 //检查费
  13142. var checkCostPartSelfTotal float64 = 0 //检查费
  13143. var checkSelfTotal float64 = 0 //床位部分项目自费
  13144. var checkInscpTotal float64 = 0 //床位部分项目自费
  13145. var laboratoryCostTotal float64 = 0 //化验费
  13146. var laboratoryCostSelfTotal float64 = 0 //化验费
  13147. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13148. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  13149. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  13150. var treatCostTotal float64 = 0 //治疗费用
  13151. var treatCostSelfTotal float64 = 0 //治疗费用
  13152. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13153. var treatSelfTotal float64 = 0 //床位部分项目自费
  13154. var treatInscpTotal float64 = 0 //床位部分项目自费
  13155. decimal.DivisionPrecision = 2
  13156. for _, item := range orderInfos {
  13157. if item.MedChrgitmType == "01" { //床位费
  13158. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13159. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13160. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13161. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13162. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13163. }
  13164. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  13165. if item.MedChrgitmType == "03" { //检查费
  13166. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13167. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13168. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13169. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13170. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13171. }
  13172. } else {
  13173. if item.MedChrgitmType == "03" { //检查费
  13174. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13175. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13176. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13177. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13178. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13179. }
  13180. }
  13181. if item.MedChrgitmType == "04" { //化验费
  13182. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13183. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13184. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13185. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13186. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13187. }
  13188. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  13189. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13190. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13191. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13192. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13193. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13194. }
  13195. if item.MedChrgitmType == "06" { //手术费
  13196. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13197. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13198. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13199. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13200. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13201. }
  13202. if item.MedChrgitmType == "08" { //材料费
  13203. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13204. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13205. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13206. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13207. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13208. }
  13209. if item.MedChrgitmType == "09" { //西药费
  13210. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13211. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13212. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13213. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13214. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13215. }
  13216. if item.MedChrgitmType == "11" { //中成费
  13217. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13218. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13219. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13220. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13221. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13222. }
  13223. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  13224. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13225. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13226. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13227. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13228. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13229. }
  13230. }
  13231. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13232. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13233. var user_name string
  13234. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13235. if role.ID == 0 {
  13236. user_name = "管理员"
  13237. } else {
  13238. user_name = role.UserName
  13239. }
  13240. baseParams := models.BaseParams{
  13241. SecretKey: miConfig.SecretKey,
  13242. FixmedinsCode: miConfig.Code,
  13243. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13244. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13245. OrgName: miConfig.OrgName,
  13246. Doctor: user_name,
  13247. RequestUrl: miConfig.Url,
  13248. AccessKey: miConfig.AccessKey,
  13249. }
  13250. businessParams := models.BusinessParams{
  13251. PsnNo: order.PsnNo,
  13252. MdtrtId: order.MdtrtId,
  13253. SetlId: order.SetlId,
  13254. }
  13255. var res ResultEleven
  13256. var resEleven10265 ResultEleven10265
  13257. if config.IsOpen == 1 {
  13258. if miConfig.MdtrtareaAdmvs == "421300" {
  13259. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  13260. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  13261. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13262. resp, requestErr := http.Get(api)
  13263. if requestErr != nil {
  13264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13265. return
  13266. }
  13267. body, ioErr := ioutil.ReadAll(resp.Body)
  13268. if ioErr != nil {
  13269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13271. return
  13272. }
  13273. var respJSON map[string]interface{}
  13274. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13277. return
  13278. }
  13279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13280. result, _ := json.Marshal(respJSON)
  13281. fmt.Println("log")
  13282. fmt.Println(string(result))
  13283. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13284. utils.ErrorLog("解析失败:%v", err)
  13285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13286. return
  13287. }
  13288. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13289. var api string
  13290. if miConfig.MdtrtareaAdmvs == "320921" {
  13291. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  13292. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  13293. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13294. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13295. } else {
  13296. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13297. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  13298. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  13299. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13300. }
  13301. resp, requestErr := http.Get(api)
  13302. if requestErr != nil {
  13303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13304. return
  13305. }
  13306. body, ioErr := ioutil.ReadAll(resp.Body)
  13307. if ioErr != nil {
  13308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13310. return
  13311. }
  13312. var respJSON map[string]interface{}
  13313. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13316. return
  13317. }
  13318. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13319. result, _ := json.Marshal(respJSON)
  13320. fmt.Println("log")
  13321. fmt.Println(string(result))
  13322. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  13323. utils.ErrorLog("解析失败:%v", err)
  13324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13325. return
  13326. }
  13327. res.InfRefmsgid = resEleven10265.InfRefmsgid
  13328. res.Output = resEleven10265.Output
  13329. res.ErrMsg = resEleven10265.ErrMsg
  13330. res.Cainfo = resEleven10265.Cainfo
  13331. res.WarnMsg = resEleven10265.WarnMsg
  13332. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  13333. res.Infcode = infocode
  13334. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13335. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  13336. saveLog(result, requestLog, "5203", "结算单")
  13337. var dat map[string]interface{}
  13338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13339. fmt.Println(dat)
  13340. } else {
  13341. fmt.Println(err)
  13342. }
  13343. userJSONBytes, _ := json.Marshal(dat)
  13344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13345. utils.ErrorLog("解析失败:%v", err)
  13346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13347. return
  13348. }
  13349. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13350. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  13351. saveLog(result, requestLog, "5203", "结算单")
  13352. var dat map[string]interface{}
  13353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13354. fmt.Println(dat)
  13355. } else {
  13356. fmt.Println(err)
  13357. }
  13358. userJSONBytes, _ := json.Marshal(dat)
  13359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13360. utils.ErrorLog("解析失败:%v", err)
  13361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13362. return
  13363. }
  13364. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13365. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  13366. saveLog(result, requestLog, "5203", "结算单")
  13367. var dat map[string]interface{}
  13368. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13369. fmt.Println(dat)
  13370. } else {
  13371. fmt.Println(err)
  13372. }
  13373. userJSONBytes, _ := json.Marshal(dat)
  13374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13375. utils.ErrorLog("解析失败:%v", err)
  13376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13377. return
  13378. }
  13379. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13380. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  13381. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  13382. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13383. resp, requestErr := http.Get(api)
  13384. if requestErr != nil {
  13385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13386. return
  13387. }
  13388. body, ioErr := ioutil.ReadAll(resp.Body)
  13389. if ioErr != nil {
  13390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13392. return
  13393. }
  13394. var respJSON map[string]interface{}
  13395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13398. return
  13399. }
  13400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13401. result, _ := json.Marshal(respJSON)
  13402. fmt.Println("log")
  13403. fmt.Println(string(result))
  13404. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  13405. utils.ErrorLog("解析失败:%v", err)
  13406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13407. return
  13408. }
  13409. res.InfRefmsgid = resEleven10265.InfRefmsgid
  13410. res.Output = resEleven10265.Output
  13411. res.ErrMsg = resEleven10265.ErrMsg
  13412. res.Cainfo = resEleven10265.Cainfo
  13413. res.WarnMsg = resEleven10265.WarnMsg
  13414. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  13415. res.Infcode = infocode
  13416. } else {
  13417. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  13418. result := service.Gdyb5203(baseParams, businessParams)
  13419. //service.Gdyb5204(baseParams, businessParams)
  13420. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  13421. var dat map[string]interface{}
  13422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13423. fmt.Println(dat)
  13424. } else {
  13425. fmt.Println(err)
  13426. }
  13427. userJSONBytes, _ := json.Marshal(dat)
  13428. if miConfig.Code == "H15049901371" {
  13429. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  13430. utils.ErrorLog("解析失败:%v", err)
  13431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13432. return
  13433. }
  13434. res.InfRefmsgid = resEleven10265.InfRefmsgid
  13435. res.Output = resEleven10265.Output
  13436. res.ErrMsg = resEleven10265.ErrMsg
  13437. res.Cainfo = resEleven10265.Cainfo
  13438. res.WarnMsg = resEleven10265.WarnMsg
  13439. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  13440. res.Infcode = infocode
  13441. } else {
  13442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13443. utils.ErrorLog("解析失败:%v", err)
  13444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13445. return
  13446. }
  13447. }
  13448. }
  13449. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13450. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  13451. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  13452. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13453. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  13454. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13455. var doctor_name string
  13456. if roles.ID == 0 {
  13457. doctor_name = "管理员"
  13458. } else {
  13459. doctor_name = roles.UserName
  13460. }
  13461. yiliao_leibie := ""
  13462. switch order.MedType {
  13463. case "11":
  13464. yiliao_leibie = "普通门诊"
  13465. break
  13466. case "12":
  13467. yiliao_leibie = "门诊挂号"
  13468. break
  13469. case "13":
  13470. yiliao_leibie = "急诊"
  13471. break
  13472. case "14":
  13473. yiliao_leibie = "门诊特殊病"
  13474. break
  13475. case "15":
  13476. yiliao_leibie = "门诊统筹"
  13477. break
  13478. case "16":
  13479. yiliao_leibie = "门诊慢性病"
  13480. break
  13481. case "21":
  13482. yiliao_leibie = "普通住院"
  13483. break
  13484. }
  13485. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13486. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  13487. if res.Infcode == 0 {
  13488. c.ServeSuccessJSON(map[string]interface{}{
  13489. "diagnosis": name,
  13490. "order_infos": orderInfos,
  13491. "number": order.MdtrtId,
  13492. "date": order.SettleAccountsDate,
  13493. "charge_admin": charge_admin,
  13494. "printor_admin": printor_admin,
  13495. "info": res.Output.Setlinfo,
  13496. "order": order,
  13497. "bedCostTotal": bedCostTotal,
  13498. "bedCostSelfTotal": bedCostSelfTotal,
  13499. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  13500. "bedSelfTotal": bedSelfTotal,
  13501. "bedInscpTotal": bedInscpTotal,
  13502. "operationCostTotal": operationCostTotal,
  13503. "operationCostSelfTotal": operationCostSelfTotal,
  13504. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  13505. "operationSelfTotal": operationSelfTotal,
  13506. "operationInscpTotal": operationInscpTotal,
  13507. "otherCostTotal": otherCostTotal,
  13508. "otherCostSelfTotal": otherCostSelfTotal,
  13509. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  13510. "otherSelfTotal": otherSelfTotal,
  13511. "otherInscpTotal": otherInscpTotal,
  13512. "materialCostTotal": materialCostTotal,
  13513. "materialCostSelfTotal": materialCostSelfTotal,
  13514. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  13515. "materialSelfTotal": materialSelfTotal,
  13516. "materialInscpTotal": materialInscpTotal,
  13517. "westernMedicineCostTotal": westernMedicineCostTotal,
  13518. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  13519. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  13520. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  13521. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  13522. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  13523. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  13524. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  13525. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  13526. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  13527. "checkCostTotal": checkCostTotal,
  13528. "checkCostSelfTotal": checkCostSelfTotal,
  13529. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  13530. "checkSelfTotal": checkSelfTotal,
  13531. "checkInscpTotal": checkInscpTotal,
  13532. "laboratoryCostTotal": laboratoryCostTotal,
  13533. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  13534. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  13535. "laboratorySelfTotal": laboratorySelfTotal,
  13536. "laboratoryInscpTotal": laboratoryInscpTotal,
  13537. "treatCostTotal": treatCostTotal,
  13538. "treatCostSelfTotal": treatCostSelfTotal,
  13539. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  13540. "treatSelfTotal": treatSelfTotal,
  13541. "treatInscpTotal": treatInscpTotal,
  13542. "doctor_info": doctor_info,
  13543. "doctor_code": adminRole_two.DoctorCode,
  13544. "doctor_name": doctor_name,
  13545. "health_card_no": order.PsnNo,
  13546. "department": departments.Name,
  13547. "yiliao_leibie": yiliao_leibie,
  13548. "after_money": order.AccountPrice,
  13549. "patient": patient,
  13550. "org_name": miConfig.OrgName,
  13551. "org_code": miConfig.Code,
  13552. "order_number": order.Number,
  13553. "his_hospital": his_hospital,
  13554. "his": his,
  13555. "dia_config": dia_config,
  13556. "psn_cash_pay": order.PsnCashPay,
  13557. //"check_order_info": cus_slice,
  13558. })
  13559. }
  13560. }
  13561. }
  13562. func (c *HisApiController) CheckTreatment() {
  13563. patient_id, _ := c.GetInt64("patient_id")
  13564. id_card_no := c.GetString("id_card_no")
  13565. insutype := c.GetString("insutype")
  13566. med_type := c.GetString("med_type")
  13567. admin_user_id, _ := c.GetInt64("admin_user_id")
  13568. adminUser := c.GetAdminUserInfo()
  13569. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  13570. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13571. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13572. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13573. if miConfig.MdtrtareaAdmvs == "421300" {
  13574. var res ResultTwo
  13575. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13576. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13577. "&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)
  13578. resp, requestErr := http.Get(api)
  13579. if requestErr != nil {
  13580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13581. return
  13582. }
  13583. body, ioErr := ioutil.ReadAll(resp.Body)
  13584. if ioErr != nil {
  13585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13587. return
  13588. }
  13589. var respJSON map[string]interface{}
  13590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13593. return
  13594. }
  13595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13596. result, _ := json.Marshal(respJSON)
  13597. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13598. utils.ErrorLog("解析失败:%v", err)
  13599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13600. return
  13601. }
  13602. if res.Infcode == 0 {
  13603. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  13604. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13605. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  13606. resp, requestErr := http.Get(api)
  13607. if requestErr != nil {
  13608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13609. return
  13610. }
  13611. body, ioErr := ioutil.ReadAll(resp.Body)
  13612. if ioErr != nil {
  13613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13615. return
  13616. }
  13617. var respJSON map[string]interface{}
  13618. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13621. return
  13622. }
  13623. var res Result2001
  13624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13625. result2, _ := json.Marshal(respJSON)
  13626. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  13627. utils.ErrorLog("解析失败:%v", err)
  13628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13629. return
  13630. }
  13631. if res.Infcode == 0 {
  13632. c.ServeSuccessJSON(map[string]interface{}{
  13633. "msg": res.Output.Trtinfo,
  13634. })
  13635. }
  13636. } else {
  13637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13638. return
  13639. }
  13640. } else {
  13641. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  13642. var dat map[string]interface{}
  13643. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13644. fmt.Println(dat)
  13645. } else {
  13646. fmt.Println(err)
  13647. }
  13648. userJSONBytes, _ := json.Marshal(dat)
  13649. var res ResultTwo
  13650. var res10265 ResultTwo10265
  13651. if miConfig.Code == "H15049901371" {
  13652. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13653. utils.ErrorLog("解析失败:%v", err)
  13654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13655. return
  13656. }
  13657. res.ErrMsg = res10265.ErrMsg
  13658. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13659. res.Infcode = infocode
  13660. res.Output = res10265.Output
  13661. res.InfRefmsgid = res10265.InfRefmsgid
  13662. } else {
  13663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13664. utils.ErrorLog("解析失败:%v", err)
  13665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13666. return
  13667. }
  13668. }
  13669. var user_name string
  13670. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  13671. if role.ID == 0 {
  13672. user_name = "xxx"
  13673. } else {
  13674. user_name = role.UserName
  13675. }
  13676. baseParams := models.BaseParams{
  13677. SecretKey: miConfig.SecretKey,
  13678. FixmedinsCode: miConfig.Code,
  13679. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13680. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13681. OrgName: miConfig.OrgName,
  13682. Doctor: user_name,
  13683. }
  13684. if config.IsOpen == 1 {
  13685. if miConfig.Code == "H15049901371" {
  13686. if med_type == "14" {
  13687. if insutype == "390" {
  13688. med_type = "9933"
  13689. } else if insutype == "310" {
  13690. med_type = "990502"
  13691. }
  13692. } else if med_type == "11" {
  13693. med_type = "11"
  13694. }
  13695. }
  13696. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  13697. var dat map[string]interface{}
  13698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13699. fmt.Println(dat)
  13700. } else {
  13701. fmt.Println(err)
  13702. }
  13703. var res Result2001
  13704. var res10265 Result2001Org10265
  13705. if miConfig.Code == "H15049901371" {
  13706. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13707. utils.ErrorLog("解析失败:%v", err)
  13708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13709. return
  13710. }
  13711. res.ErrMsg = res10265.ErrMsg
  13712. res.Output = res10265.Output
  13713. res.InfRefmsgid = res10265.InfRefmsgid
  13714. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13715. res.Infcode = infocode
  13716. } else {
  13717. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13718. utils.ErrorLog("解析失败:%v", err)
  13719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13720. return
  13721. }
  13722. }
  13723. if res.Infcode == 0 {
  13724. c.ServeSuccessJSON(map[string]interface{}{
  13725. "msg": res.Output.Trtinfo,
  13726. })
  13727. }
  13728. }
  13729. }
  13730. }
  13731. //func (c *HisApiController) PutRecord() {
  13732. // id, _ := c.GetInt64("id")
  13733. // record_time := c.GetString("record_time")
  13734. // timeLayout := "2006-01-02"
  13735. // loc, _ := time.LoadLocation("Local")
  13736. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13737. // if err != nil {
  13738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13739. // return
  13740. // }
  13741. // recordDateTime := theTime.Unix()
  13742. //
  13743. // adminInfo := c.GetAdminUserInfo()
  13744. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  13745. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13746. //
  13747. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13748. //
  13749. // fmt.Println(miConfig.SecretKey)
  13750. //
  13751. // if patient == nil {
  13752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  13753. // return
  13754. // }
  13755. // if len(patient.IdCardNo) == 0 {
  13756. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  13757. // return
  13758. // }
  13759. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  13760. // if config.IsOpen == 1 {
  13761. // 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
  13762. // resp, requestErr := http.Get(api)
  13763. // if requestErr != nil {
  13764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13765. // return
  13766. // }
  13767. // defer resp.Body.Close()
  13768. // body, ioErr := ioutil.ReadAll(resp.Body)
  13769. // if ioErr != nil {
  13770. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13772. // return
  13773. // }
  13774. // var respJSON map[string]interface{}
  13775. //
  13776. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13777. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13779. // return
  13780. // }
  13781. //
  13782. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13783. // userJSONBytes, _ := json.Marshal(userJSON)
  13784. // var res ResultTwo
  13785. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13786. // utils.ErrorLog("解析失败:%v", err)
  13787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13788. // return
  13789. // }
  13790. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13791. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13792. // infoStr := string(Iinfos)
  13793. // idetinfoStr := string(Idetinfos)
  13794. //
  13795. // if res.Infcode == 0 {
  13796. // his := models.VMHisPatient{
  13797. // Status: 1,
  13798. // Ctime: time.Now().Unix(),
  13799. // Mtime: time.Now().Unix(),
  13800. // PsnNo: res.Output.Baseinfo.PsnNo,
  13801. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  13802. // Certno: res.Output.Baseinfo.Certno,
  13803. // PsnName: res.Output.Baseinfo.PsnName,
  13804. // Gend: res.Output.Baseinfo.Gend,
  13805. // Naty: res.Output.Baseinfo.Naty,
  13806. // Brdy: res.Output.Baseinfo.Brdy,
  13807. // Age: res.Output.Baseinfo.Age,
  13808. // Iinfo: infoStr,
  13809. // Idetinfo: idetinfoStr,
  13810. // PatientId: patient.ID,
  13811. // RecordDate: theTime.Unix(),
  13812. // UserOrgId: adminInfo.CurrentOrgId,
  13813. // AdminUserId: adminInfo.AdminUser.Id,
  13814. // IsReturn: 1,
  13815. // }
  13816. //
  13817. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  13818. // //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")
  13819. // //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")
  13820. //
  13821. // //var dat map[string]interface{}
  13822. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13823. // // fmt.Println(dat)
  13824. // //} else {
  13825. // // fmt.Println(err)
  13826. // //}
  13827. //
  13828. // var dat2 map[string]interface{}
  13829. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13830. // fmt.Println(dat2)
  13831. // } else {
  13832. // fmt.Println(err)
  13833. // }
  13834. //
  13835. // } else {
  13836. // adminUser := c.GetAdminUserInfo()
  13837. // errlog := &models.HisOrderError{
  13838. // UserOrgId: adminUser.CurrentOrgId,
  13839. // Ctime: time.Now().Unix(),
  13840. // Mtime: time.Now().Unix(),
  13841. // ErrMsg: res.ErrMsg,
  13842. // Status: 1,
  13843. // PatientId: id,
  13844. // RecordTime: recordDateTime,
  13845. // Stage: 1,
  13846. // }
  13847. // service.CreateErrMsgLog(errlog)
  13848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  13849. // return
  13850. // }
  13851. // }
  13852. //
  13853. //}
  13854. //func (c *HisApiController) GetUploadDiag() {
  13855. // id, _ := c.GetInt64("id")
  13856. // record_time := c.GetString("record_time")
  13857. //
  13858. // diagnosis_id, _ := c.GetInt64("diagnosis")
  13859. // sick_type, _ := c.GetInt64("sick_type")
  13860. // reg_type, _ := c.GetInt64("reg_type")
  13861. //
  13862. // timeLayout := "2006-01-02"
  13863. // loc, _ := time.LoadLocation("Local")
  13864. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13865. // if err != nil {
  13866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13867. // return
  13868. // }
  13869. //
  13870. // var patientPrescription models.HisPrescriptionInfo
  13871. // recordDateTime := theTime.Unix()
  13872. // adminInfo := c.GetAdminUserInfo()
  13873. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13874. //
  13875. // if patientPrescription.ID == 0 {
  13876. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13877. // }
  13878. //
  13879. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  13880. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  13881. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  13882. // sickConfig, _ := service.FindSickById(sick_type)
  13883. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13884. //
  13885. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  13886. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  13887. // "&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 +
  13888. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  13889. // resp2, requestErr2 := http.Get(api2)
  13890. // if requestErr2 != nil {
  13891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13892. // return
  13893. // }
  13894. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  13895. // if ioErr2 != nil {
  13896. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  13897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13898. // return
  13899. // }
  13900. // var respJSON2 map[string]interface{}
  13901. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  13902. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13904. // return
  13905. // }
  13906. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13907. // userJSONBytes2, _ := json.Marshal(respJSON2)
  13908. //
  13909. // var res2 ResultSix
  13910. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13911. // utils.ErrorLog("解析失败:%v", err)
  13912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13913. // return
  13914. // }
  13915. // if res2.Infcode != 0 {
  13916. // adminUser := c.GetAdminUserInfo()
  13917. // errlog := &models.HisOrderError{
  13918. // UserOrgId: adminUser.CurrentOrgId,
  13919. // Ctime: time.Now().Unix(),
  13920. // Mtime: time.Now().Unix(),
  13921. // ErrMsg: res2.ErrMsg,
  13922. // Status: 1,
  13923. // PatientId: id,
  13924. // RecordTime: recordDateTime,
  13925. // Stage: 3,
  13926. // }
  13927. // service.CreateErrMsgLog(errlog)
  13928. //
  13929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  13930. // return
  13931. // }
  13932. //
  13933. // c.ServeSuccessJSON(map[string]interface{}{
  13934. // "msg": "上传成功",
  13935. // })
  13936. //
  13937. //}
  13938. type QueryResult struct {
  13939. ID int64
  13940. Name string
  13941. Code string
  13942. List_type_code string
  13943. }
  13944. func (c *HisApiController) GetCheckCode() {
  13945. ids_str := c.GetString("ids")
  13946. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  13947. ids_arr := strings.Split(ids_str, ",")
  13948. var queryResult []QueryResult
  13949. ids := make([]int64, 0)
  13950. for _, item := range ids_arr {
  13951. id, _ := strconv.ParseInt(item, 10, 64)
  13952. ids = append(ids, id)
  13953. }
  13954. if record_type == 1 {
  13955. drugs, _ := service.GetBatchDrugList(ids)
  13956. for _, item := range drugs {
  13957. result := QueryResult{
  13958. ID: item.ID,
  13959. Name: item.DrugName,
  13960. Code: item.MedicalInsuranceNumber,
  13961. List_type_code: "101",
  13962. }
  13963. queryResult = append(queryResult, result)
  13964. }
  13965. } else if record_type == 2 {
  13966. goods, _ := service.GetBatchGoodInformationList(ids)
  13967. for _, item := range goods {
  13968. result := QueryResult{
  13969. ID: item.ID,
  13970. Name: item.GoodName,
  13971. Code: item.MedicalInsuranceNumber,
  13972. List_type_code: "301",
  13973. }
  13974. queryResult = append(queryResult, result)
  13975. }
  13976. } else if record_type == 3 {
  13977. projects, _ := service.GetBathchMyPorjecgList(ids)
  13978. for _, item := range projects {
  13979. result := QueryResult{
  13980. ID: item.ID,
  13981. Name: item.ProjectName,
  13982. Code: item.MedicalCode,
  13983. List_type_code: "201",
  13984. }
  13985. queryResult = append(queryResult, result)
  13986. }
  13987. }
  13988. admin_user_id, _ := c.GetInt64("admin_user_id")
  13989. adminUser := c.GetAdminUserInfo()
  13990. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13991. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13992. var user_name string
  13993. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13994. if role.ID == 0 {
  13995. user_name = "xxx"
  13996. } else {
  13997. user_name = role.UserName
  13998. }
  13999. baseParams := &models.BaseParams{
  14000. SecretKey: miConfig.SecretKey,
  14001. FixmedinsCode: miConfig.Code,
  14002. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14003. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14004. OrgName: miConfig.OrgName,
  14005. Doctor: user_name,
  14006. }
  14007. if config.IsOpen == 1 {
  14008. for _, item := range queryResult {
  14009. var result string
  14010. if record_type == 1 {
  14011. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14012. } else if record_type == 2 {
  14013. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14014. } else if record_type == 3 {
  14015. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14016. }
  14017. var dat map[string]interface{}
  14018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14019. fmt.Println(dat)
  14020. } else {
  14021. fmt.Println(err)
  14022. }
  14023. userJSONBytes, _ := json.Marshal(dat)
  14024. var res ResultSix
  14025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14026. utils.ErrorLog("解析失败:%v", err)
  14027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14028. return
  14029. }
  14030. if res.Infcode == 0 {
  14031. if record_type == 1 {
  14032. service.UpdateBaseDrugById(item.ID)
  14033. } else if record_type == 2 {
  14034. service.UpdateGoodInformaitonByDetail(item.ID)
  14035. } else if record_type == 3 {
  14036. service.UpdateProjectById(item.ID)
  14037. }
  14038. c.ServeSuccessJSON(map[string]interface{}{
  14039. "failed_code": 0,
  14040. "msg": "目录对照成功",
  14041. })
  14042. } else {
  14043. c.ServeSuccessJSON(map[string]interface{}{
  14044. "failed_code": -10,
  14045. "msg": res.ErrMsg,
  14046. })
  14047. }
  14048. }
  14049. }
  14050. }
  14051. func (c *HisApiController) UnCheckCode() {
  14052. ids_str := c.GetString("ids")
  14053. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  14054. admin_user_id, _ := c.GetInt64("admin_user_id")
  14055. ids_arr := strings.Split(ids_str, ",")
  14056. var queryResult []QueryResult
  14057. ids := make([]int64, 0)
  14058. for _, item := range ids_arr {
  14059. id, _ := strconv.ParseInt(item, 10, 64)
  14060. ids = append(ids, id)
  14061. }
  14062. if record_type == 1 {
  14063. drugs, _ := service.GetBatchDrugList(ids)
  14064. for _, item := range drugs {
  14065. result := QueryResult{
  14066. ID: item.ID,
  14067. Name: item.DrugName,
  14068. Code: item.MedicalInsuranceNumber,
  14069. List_type_code: "101",
  14070. }
  14071. queryResult = append(queryResult, result)
  14072. }
  14073. } else if record_type == 2 {
  14074. goods, _ := service.GetBatchGoodInformationList(ids)
  14075. for _, item := range goods {
  14076. result := QueryResult{
  14077. ID: item.ID,
  14078. Name: item.GoodName,
  14079. Code: item.MedicalInsuranceNumber,
  14080. List_type_code: "301",
  14081. }
  14082. queryResult = append(queryResult, result)
  14083. }
  14084. } else if record_type == 3 {
  14085. projects, _ := service.GetBathchMyPorjecgList(ids)
  14086. for _, item := range projects {
  14087. result := QueryResult{
  14088. ID: item.ID,
  14089. Name: item.ProjectName,
  14090. Code: item.MedicalCode,
  14091. List_type_code: "201",
  14092. }
  14093. queryResult = append(queryResult, result)
  14094. }
  14095. }
  14096. adminUser := c.GetAdminUserInfo()
  14097. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14098. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14099. var user_name string
  14100. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14101. if role.ID == 0 {
  14102. user_name = "xxx"
  14103. } else {
  14104. user_name = role.UserName
  14105. }
  14106. baseParams := &models.BaseParams{
  14107. SecretKey: miConfig.SecretKey,
  14108. FixmedinsCode: miConfig.Code,
  14109. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14110. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14111. OrgName: miConfig.OrgName,
  14112. Doctor: user_name,
  14113. }
  14114. if config.IsOpen == 1 {
  14115. for _, item := range queryResult {
  14116. var result string
  14117. if record_type == 1 {
  14118. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14119. } else if record_type == 2 {
  14120. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14121. } else if record_type == 3 {
  14122. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14123. }
  14124. var dat2 map[string]interface{}
  14125. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  14126. fmt.Println(dat2)
  14127. } else {
  14128. fmt.Println(err)
  14129. }
  14130. userJSONBytes, _ := json.Marshal(dat2)
  14131. var res ResultSix
  14132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14133. utils.ErrorLog("解析失败:%v", err)
  14134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14135. return
  14136. }
  14137. if res.Infcode == 0 {
  14138. if record_type == 1 {
  14139. service.UpdateDrugByIdDetail(item.ID)
  14140. } else if record_type == 2 {
  14141. service.UpdateGoodInfoById(item.ID)
  14142. } else if record_type == 3 {
  14143. service.UpdateMyProjectById(item.ID)
  14144. }
  14145. c.ServeSuccessJSON(map[string]interface{}{
  14146. "failed_code": 0,
  14147. "msg": "撤销目录对照成功",
  14148. })
  14149. } else {
  14150. c.ServeSuccessJSON(map[string]interface{}{
  14151. "failed_code": -10,
  14152. "msg": res.ErrMsg,
  14153. })
  14154. }
  14155. }
  14156. }
  14157. }
  14158. func (c *HisApiController) GetPatientInfo() {
  14159. id_card_no := c.GetString("id_card_no")
  14160. admin_user_id, _ := c.GetInt64("admin_user_id")
  14161. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14162. if patient.ID == 0 {
  14163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  14164. return
  14165. }
  14166. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  14167. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14168. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  14169. if config.IsOpen == 1 {
  14170. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  14171. var dat map[string]interface{}
  14172. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14173. fmt.Println(dat)
  14174. } else {
  14175. fmt.Println(err)
  14176. }
  14177. userJSONBytes, _ := json.Marshal(dat)
  14178. var res ResultTwo
  14179. var res10265 ResultTwo10265
  14180. if miConfig.Code == "H15049901371" {
  14181. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14182. utils.ErrorLog("解析失败:%v", err)
  14183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14184. return
  14185. }
  14186. res.ErrMsg = res10265.ErrMsg
  14187. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14188. res.Infcode = infocode
  14189. res.Output = res10265.Output
  14190. res.InfRefmsgid = res10265.InfRefmsgid
  14191. } else {
  14192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14193. utils.ErrorLog("解析失败:%v", err)
  14194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14195. return
  14196. }
  14197. }
  14198. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14199. // utils.ErrorLog("解析失败:%v", err)
  14200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14201. // return
  14202. //}
  14203. for index, item := range res.Output.Iinfo {
  14204. if item.PsnInsuStas == "2" {
  14205. fmt.Println("--------")
  14206. res.Output.Iinfo[index].Insutype = "300"
  14207. res.Output.Iinfo[index].PsnInsuStas = "1"
  14208. }
  14209. }
  14210. fmt.Println(res.Output.Iinfo)
  14211. if res.Infcode != 0 {
  14212. c.ServeSuccessJSON(map[string]interface{}{
  14213. "failed_code": -10,
  14214. "msg": res.ErrMsg,
  14215. })
  14216. } else {
  14217. c.ServeSuccessJSON(map[string]interface{}{
  14218. "failed_code": 0,
  14219. "info": res,
  14220. })
  14221. }
  14222. }
  14223. }
  14224. func (c *HisApiController) PsnPutOnRecord() {
  14225. record_type, _ := c.GetInt64("type")
  14226. patient_id, _ := c.GetInt64("patient_id")
  14227. admin_user_id, _ := c.GetInt64("admin_user_id")
  14228. start_time := c.GetString("start_time")
  14229. end_time := c.GetString("end_time")
  14230. adminUser := c.GetAdminUserInfo()
  14231. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14232. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14233. var patients []*models.Patients
  14234. if record_type == 1 { //全部备案
  14235. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  14236. patients = append(patients, patient...)
  14237. } else { //单个备案
  14238. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  14239. patients = append(patients, patient)
  14240. }
  14241. var user_name string
  14242. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14243. if role.ID == 0 {
  14244. user_name = "xxx"
  14245. } else {
  14246. user_name = role.UserName
  14247. }
  14248. if config.IsOpen == 1 {
  14249. for _, item := range patients {
  14250. 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
  14251. resp, requestErr := http.Get(api)
  14252. if requestErr != nil {
  14253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14254. return
  14255. }
  14256. defer resp.Body.Close()
  14257. body, ioErr := ioutil.ReadAll(resp.Body)
  14258. if ioErr != nil {
  14259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14261. return
  14262. }
  14263. var respJSON map[string]interface{}
  14264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14267. return
  14268. }
  14269. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14270. userJSONBytes, _ := json.Marshal(userJSON)
  14271. var res ResultTwo
  14272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14273. utils.ErrorLog("解析失败:%v", err)
  14274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14275. return
  14276. }
  14277. if res.Infcode == 0 {
  14278. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  14279. var dat map[string]interface{}
  14280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14281. fmt.Println(dat)
  14282. } else {
  14283. fmt.Println(err)
  14284. }
  14285. userJSONBytes, _ := json.Marshal(dat)
  14286. var res2 ResultThirteen
  14287. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14288. utils.ErrorLog("解析失败:%v", err)
  14289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14290. return
  14291. }
  14292. if res2.Infcode == 0 {
  14293. psnResult := &models.GdybPsnRecord{
  14294. UserOrgId: adminUser.CurrentOrgId,
  14295. PatientId: item.ID,
  14296. PsnNo: res.Output.Baseinfo.PsnNo,
  14297. Ctime: time.Now().Unix(),
  14298. Mtime: time.Now().Unix(),
  14299. Status: 1,
  14300. IsCancel: 1,
  14301. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  14302. }
  14303. service.CreatePsnRecord(psnResult)
  14304. } else {
  14305. c.ServeSuccessJSON(map[string]interface{}{
  14306. "failed_code": -10,
  14307. "msg": res2.ErrMsg,
  14308. })
  14309. return
  14310. }
  14311. }
  14312. }
  14313. }
  14314. }
  14315. func (c *HisApiController) PsnUnPutOnRecord() {
  14316. id, _ := c.GetInt64("id")
  14317. //record_type, _ := c.GetInt64("type")
  14318. admin_user_id, _ := c.GetInt64("admin_user_id")
  14319. adminUser := c.GetAdminUserInfo()
  14320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14321. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14322. var user_name string
  14323. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14324. if role.ID == 0 {
  14325. user_name = "xxx"
  14326. } else {
  14327. user_name = role.UserName
  14328. }
  14329. psn_record, _ := service.GetPsnRecordById(id)
  14330. if psn_record.ID == 0 {
  14331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  14332. return
  14333. }
  14334. if config.IsOpen == 1 {
  14335. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  14336. var dat map[string]interface{}
  14337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14338. fmt.Println(dat)
  14339. } else {
  14340. fmt.Println(err)
  14341. }
  14342. userJSONBytes, _ := json.Marshal(dat)
  14343. var res ResultFourteen
  14344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14345. utils.ErrorLog("解析失败:%v", err)
  14346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14347. return
  14348. }
  14349. if res.Infcode == 0 {
  14350. psn_record.IsCancel = 2
  14351. service.CreatePsnRecord(&psn_record)
  14352. } else {
  14353. c.ServeSuccessJSON(map[string]interface{}{
  14354. "failed_code": -10,
  14355. "msg": res.ErrMsg,
  14356. })
  14357. return
  14358. }
  14359. }
  14360. }
  14361. func (c *HisApiController) PsnPutNCDSOnRecord() {
  14362. patient_id, _ := c.GetInt64("patient_id")
  14363. insutype_two := c.GetString("insutype")
  14364. psn_no := c.GetString("psn_no")
  14365. doctor_id, _ := c.GetInt64("doctor_id")
  14366. sick_id, _ := c.GetInt64("sick_id")
  14367. department_id, _ := c.GetInt64("department_id")
  14368. start_time := c.GetString("start_time")
  14369. end_time := c.GetString("end_time")
  14370. check_time := c.GetString("check_time")
  14371. hospital_code := c.GetString("hospital_code")
  14372. hospital_name := c.GetString("hospital_name")
  14373. adminUser := c.GetAdminUserInfo()
  14374. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  14375. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14376. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14377. sick, _ := service.FindSickById(sick_id)
  14378. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  14379. if len(hospital_code) == 0 {
  14380. hospital_code = miConfig.Code
  14381. }
  14382. if len(hospital_name) == 0 {
  14383. hospital_name = miConfig.OrgName
  14384. }
  14385. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  14386. var res ResultTwo
  14387. var res10265 ResultTwo10265
  14388. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14389. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  14390. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  14391. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  14392. "&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
  14393. resp, requestErr := http.Get(api)
  14394. if requestErr != nil {
  14395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14396. return
  14397. }
  14398. body, ioErr := ioutil.ReadAll(resp.Body)
  14399. if ioErr != nil {
  14400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14402. return
  14403. }
  14404. var respJSON map[string]interface{}
  14405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14408. return
  14409. }
  14410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14411. result, _ := json.Marshal(respJSON)
  14412. fmt.Println("log")
  14413. fmt.Println(string(result))
  14414. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14415. utils.ErrorLog("解析失败:%v", err)
  14416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14417. return
  14418. }
  14419. res.ErrMsg = res10265.ErrMsg
  14420. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14421. res.Infcode = infocode
  14422. res.Output = res10265.Output
  14423. res.InfRefmsgid = res10265.InfRefmsgid
  14424. } else {
  14425. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  14426. if miConfig.Code == "H15049901371" {
  14427. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14428. utils.ErrorLog("解析失败:%v", err)
  14429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14430. return
  14431. }
  14432. res.ErrMsg = res10265.ErrMsg
  14433. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14434. res.Infcode = infocode
  14435. res.Output = res10265.Output
  14436. res.InfRefmsgid = res10265.InfRefmsgid
  14437. } else {
  14438. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14439. utils.ErrorLog("解析失败:%v", err)
  14440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14441. return
  14442. }
  14443. }
  14444. }
  14445. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14446. infoStr := string(Iinfos)
  14447. var rf []*ResultFive
  14448. json.Unmarshal([]byte(infoStr), &rf)
  14449. var insuplc_admdvs string
  14450. var insutype string
  14451. var is390 int = 0
  14452. var is310 int = 0
  14453. var insutypes []*ResultFive
  14454. for _, item := range rf {
  14455. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14456. insutypes = append(insutypes, item)
  14457. }
  14458. }
  14459. if len(insutypes) == 1 {
  14460. insutype = insutypes[0].Insutype
  14461. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14462. } else {
  14463. for _, i := range insutypes {
  14464. if i.Insutype == "390" {
  14465. is390 = 1
  14466. }
  14467. if i.Insutype == "310" {
  14468. is310 = 1
  14469. }
  14470. }
  14471. }
  14472. if is390 == 1 {
  14473. insutype = "390"
  14474. }
  14475. if is310 == 1 {
  14476. insutype = "310"
  14477. }
  14478. if len(insutypes) == 2 {
  14479. insutype = insutype_two
  14480. }
  14481. if len(insutypes) == 0 {
  14482. insutype = "310"
  14483. }
  14484. insutype = insutype_two
  14485. fmt.Println(insutype)
  14486. for _, item := range rf {
  14487. fmt.Println(item.Insutype)
  14488. fmt.Println(insutype)
  14489. if item.Insutype == insutype {
  14490. fmt.Println(item.Insutype)
  14491. fmt.Println(insutype)
  14492. insuplc_admdvs = item.InsuplcAdmdvs
  14493. }
  14494. }
  14495. fmt.Println(insuplc_admdvs)
  14496. var res2 ResultThirteen
  14497. var res10265_2 ResultThirteen10265
  14498. if config.IsOpen == 1 {
  14499. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14500. } else {
  14501. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  14502. var dat map[string]interface{}
  14503. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14504. fmt.Println(dat)
  14505. } else {
  14506. fmt.Println(err)
  14507. }
  14508. userJSONBytes, _ := json.Marshal(dat)
  14509. if miConfig.Code == "H15049901371" {
  14510. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  14511. utils.ErrorLog("解析失败:%v", err)
  14512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14513. return
  14514. }
  14515. res2.ErrMsg = res10265_2.ErrMsg
  14516. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  14517. res2.Infcode = infocode
  14518. res2.Output = res10265_2.Output
  14519. res2.InfRefmsgid = res10265_2.InfRefmsgid
  14520. } else {
  14521. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14522. utils.ErrorLog("解析失败:%v", err)
  14523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14524. return
  14525. }
  14526. }
  14527. }
  14528. if res2.Infcode == 0 {
  14529. psnResult := &models.GdybPsnNcdsRecord{
  14530. UserOrgId: adminUser.CurrentOrgId,
  14531. PatientId: patient.ID,
  14532. PsnNo: psn_no,
  14533. DoctorId: doctor.AdminUserId,
  14534. DepartmentId: department_id,
  14535. SickType: sick_id,
  14536. Insutype: insutype,
  14537. Ctime: time.Now().Unix(),
  14538. Mtime: time.Now().Unix(),
  14539. Status: 1,
  14540. IsCancel: 1,
  14541. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  14542. }
  14543. service.CreatePsnNCDSRecord(psnResult)
  14544. c.ServeSuccessJSON(map[string]interface{}{
  14545. "failed_code": 0,
  14546. "msg": "备案成功",
  14547. "result": psnResult,
  14548. })
  14549. } else {
  14550. c.ServeSuccessJSON(map[string]interface{}{
  14551. "failed_code": -10,
  14552. "msg": res2.ErrMsg,
  14553. })
  14554. return
  14555. }
  14556. }
  14557. }
  14558. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  14559. id, _ := c.GetInt64("id")
  14560. admin_user_id, _ := c.GetInt64("admin_user_id")
  14561. adminUser := c.GetAdminUserInfo()
  14562. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14563. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14564. //config, _ := service.Ge(adminUser.CurrentOrgId)
  14565. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  14566. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14567. //var user_name string
  14568. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14569. //if role.ID == 0 {
  14570. // user_name = "xxx"
  14571. //} else {
  14572. // user_name = role.UserName
  14573. //}
  14574. psn_record, _ := service.GetPsnNCDSRecordById(id)
  14575. if psn_record.ID == 0 {
  14576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  14577. return
  14578. }
  14579. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  14580. var res ResultTwo
  14581. var res10265 ResultTwo10265
  14582. if miConfig.Code == "H15049901371" {
  14583. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14584. utils.ErrorLog("解析失败:%v", err)
  14585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14586. return
  14587. }
  14588. res.ErrMsg = res10265.ErrMsg
  14589. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14590. res.Infcode = infocode
  14591. res.Output = res10265.Output
  14592. res.InfRefmsgid = res10265.InfRefmsgid
  14593. } else {
  14594. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14595. utils.ErrorLog("解析失败:%v", err)
  14596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14597. return
  14598. }
  14599. }
  14600. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14601. infoStr := string(Iinfos)
  14602. var rf []*ResultFive
  14603. json.Unmarshal([]byte(infoStr), &rf)
  14604. var insuplc_admdvs string
  14605. var insutype string
  14606. var is390 int = 0
  14607. var is310 int = 0
  14608. var insutypes []*ResultFive
  14609. for _, item := range rf {
  14610. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14611. insutypes = append(insutypes, item)
  14612. }
  14613. }
  14614. if len(insutypes) == 1 {
  14615. insutype = insutypes[0].Insutype
  14616. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14617. } else {
  14618. for _, i := range insutypes {
  14619. if i.Insutype == "390" {
  14620. is390 = 1
  14621. }
  14622. if i.Insutype == "310" {
  14623. is310 = 1
  14624. }
  14625. }
  14626. }
  14627. if is390 == 1 {
  14628. insutype = "390"
  14629. }
  14630. if is310 == 1 {
  14631. insutype = "310"
  14632. }
  14633. if len(insutypes) == 0 {
  14634. insutype = "310"
  14635. }
  14636. insutype = psn_record.Insutype
  14637. for _, item := range rf {
  14638. if item.Insutype == insutype {
  14639. insuplc_admdvs = item.InsuplcAdmdvs
  14640. }
  14641. }
  14642. if config.IsOpen == 1 {
  14643. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  14644. var dat map[string]interface{}
  14645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14646. fmt.Println(dat)
  14647. } else {
  14648. fmt.Println(err)
  14649. }
  14650. userJSONBytes, _ := json.Marshal(dat)
  14651. var res ResultFourteen
  14652. var res10265 ResultFourteen10265
  14653. if miConfig.Code == "H15049901371" {
  14654. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14655. utils.ErrorLog("解析失败:%v", err)
  14656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14657. return
  14658. }
  14659. res.ErrMsg = res10265.ErrMsg
  14660. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14661. res.Infcode = infocode
  14662. res.Output = res10265.Output
  14663. res.InfRefmsgid = res10265.InfRefmsgid
  14664. } else {
  14665. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14666. utils.ErrorLog("解析失败:%v", err)
  14667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14668. return
  14669. }
  14670. }
  14671. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14672. // utils.ErrorLog("解析失败:%v", err)
  14673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14674. // return
  14675. //}
  14676. if res.Infcode == 0 {
  14677. psn_record.IsCancel = 2
  14678. service.CreatePsnNCDSRecord(&psn_record)
  14679. c.ServeSuccessJSON(map[string]interface{}{
  14680. "failed_code": 0,
  14681. "msg": "撤销备案成功",
  14682. })
  14683. } else {
  14684. c.ServeSuccessJSON(map[string]interface{}{
  14685. "failed_code": -10,
  14686. "msg": res.ErrMsg,
  14687. })
  14688. return
  14689. }
  14690. }
  14691. }
  14692. func (c *HisApiController) TestTest() {
  14693. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  14694. fmt.Println(patient.Iinfo)
  14695. }
  14696. type CustomData struct {
  14697. MsgId string
  14698. PsnNo string
  14699. Info string
  14700. }
  14701. func (c *HisApiController) ReversalData() {
  14702. var customData []*CustomData
  14703. custom := &CustomData{
  14704. MsgId: "H44022900158202103301714472004",
  14705. PsnNo: "44020000001101329945",
  14706. Info: "2207",
  14707. }
  14708. customData = append(customData, custom)
  14709. custom1 := &CustomData{
  14710. MsgId: "H4402290015820210330172057803",
  14711. PsnNo: "44020000001101161813",
  14712. Info: "2207",
  14713. }
  14714. customData = append(customData, custom1)
  14715. custom2 := &CustomData{
  14716. MsgId: "H44022900158202103301705198813",
  14717. PsnNo: "44190000133097375417",
  14718. Info: "2207",
  14719. }
  14720. customData = append(customData, custom2)
  14721. custom3 := &CustomData{
  14722. MsgId: "H44022900158202103301715524756",
  14723. PsnNo: "44020000001100187221",
  14724. Info: "2207",
  14725. }
  14726. customData = append(customData, custom3)
  14727. custom4 := &CustomData{
  14728. MsgId: "H44022900158202103301730376224",
  14729. PsnNo: "44020000001101959155",
  14730. Info: "2207",
  14731. }
  14732. customData = append(customData, custom4)
  14733. custom5 := &CustomData{
  14734. MsgId: "H44022900158202103301748008725",
  14735. PsnNo: "44020000001104246641",
  14736. Info: "2207",
  14737. }
  14738. customData = append(customData, custom5)
  14739. custom6 := &CustomData{
  14740. MsgId: "H44022900158202103301718096755",
  14741. PsnNo: "44020000001102211860",
  14742. Info: "2207",
  14743. }
  14744. customData = append(customData, custom6)
  14745. custom7 := &CustomData{
  14746. MsgId: "H44022900158202103301736551640",
  14747. PsnNo: "44020000001102687718",
  14748. Info: "2207",
  14749. }
  14750. customData = append(customData, custom7)
  14751. custom8 := &CustomData{
  14752. MsgId: "H44022900158202103301743097676",
  14753. PsnNo: "44020000001102127785",
  14754. Info: "2207",
  14755. }
  14756. customData = append(customData, custom8)
  14757. custom9 := &CustomData{
  14758. MsgId: "H44022900158202103301712304203",
  14759. PsnNo: "44020000001101518097",
  14760. Info: "2207",
  14761. }
  14762. customData = append(customData, custom9)
  14763. custom10 := &CustomData{
  14764. MsgId: "H44022900158202103301738448785",
  14765. PsnNo: "44020000001100500813",
  14766. Info: "2207",
  14767. }
  14768. customData = append(customData, custom10)
  14769. custom11 := &CustomData{
  14770. MsgId: "H44022900158202103301732455843",
  14771. PsnNo: "44020000001102690557",
  14772. Info: "2207",
  14773. }
  14774. customData = append(customData, custom11)
  14775. custom12 := &CustomData{
  14776. MsgId: "H44022900158202103301745421708",
  14777. PsnNo: "44020000001102211928",
  14778. Info: "2207",
  14779. }
  14780. customData = append(customData, custom12)
  14781. custom1212 := &CustomData{
  14782. MsgId: "H440229001582021033017351627",
  14783. PsnNo: "44020000001102481733",
  14784. Info: "2207",
  14785. }
  14786. customData = append(customData, custom1212)
  14787. custom13 := &CustomData{
  14788. MsgId: "H44022900158202103301740327951",
  14789. PsnNo: "44020000001103174866",
  14790. Info: "2207",
  14791. }
  14792. customData = append(customData, custom13)
  14793. custom14 := &CustomData{
  14794. MsgId: "H4402290015820210330174922668",
  14795. PsnNo: "44020000001102927272",
  14796. Info: "2207",
  14797. }
  14798. customData = append(customData, custom14)
  14799. custom15 := &CustomData{
  14800. MsgId: "H44022900158202103301752362273",
  14801. PsnNo: "44020000001102942890",
  14802. Info: "2207",
  14803. }
  14804. customData = append(customData, custom15)
  14805. custom16 := &CustomData{
  14806. MsgId: "H44022900158202103301751082917",
  14807. PsnNo: "44020000001101662162",
  14808. Info: "2207",
  14809. }
  14810. customData = append(customData, custom16)
  14811. custom17 := &CustomData{
  14812. MsgId: "H44022900158202103301754147728",
  14813. PsnNo: "44020000000229014511",
  14814. Info: "2207",
  14815. }
  14816. customData = append(customData, custom17)
  14817. adminUser := c.GetAdminUserInfo()
  14818. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14819. for _, item := range customData {
  14820. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  14821. fmt.Println(result)
  14822. }
  14823. }
  14824. func (c *HisApiController) GetAllopatry() {
  14825. year := c.GetString("year")
  14826. month := c.GetString("month")
  14827. admin_user_id, _ := c.GetInt64("admin_user_id")
  14828. adminUser := c.GetAdminUserInfo()
  14829. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14830. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14831. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  14832. var dat map[string]interface{}
  14833. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14834. fmt.Println(dat)
  14835. } else {
  14836. fmt.Println(err)
  14837. }
  14838. userJSONBytes, _ := json.Marshal(dat)
  14839. var res models.Result9001
  14840. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14841. utils.ErrorLog("解析失败:%v", err)
  14842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14843. return
  14844. }
  14845. fmt.Println(res.Output.Signinoutb)
  14846. fmt.Println(res.Output.Signinoutb.SignNo)
  14847. fmt.Println(string(userJSONBytes))
  14848. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14849. var dat2 map[string]interface{}
  14850. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14851. fmt.Println(dat)
  14852. } else {
  14853. fmt.Println(err)
  14854. }
  14855. userJSONBytes2, _ := json.Marshal(dat2)
  14856. var res2 models.Result3260
  14857. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14858. utils.ErrorLog("解析失败:%v", err)
  14859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14860. return
  14861. }
  14862. if res2.Infcode == 0 {
  14863. result3, _, _ := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  14864. var dat2 map[string]interface{}
  14865. if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  14866. fmt.Println(dat)
  14867. } else {
  14868. fmt.Println(err)
  14869. }
  14870. c.ServeSuccessJSON(map[string]interface{}{
  14871. "list": res2.Output.Data,
  14872. })
  14873. return
  14874. } else {
  14875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14876. return
  14877. }
  14878. }
  14879. func (c *HisApiController) ComfirmAllopatry() {
  14880. year := c.GetString("year")
  14881. month := c.GetString("month")
  14882. admin_user_id, _ := c.GetInt64("admin_user_id")
  14883. adminUser := c.GetAdminUserInfo()
  14884. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14885. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14886. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  14887. var dat map[string]interface{}
  14888. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14889. fmt.Println(dat)
  14890. } else {
  14891. fmt.Println(err)
  14892. }
  14893. userJSONBytes, _ := json.Marshal(dat)
  14894. var res models.Result9001
  14895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14896. utils.ErrorLog("解析失败:%v", err)
  14897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14898. return
  14899. }
  14900. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  14901. var dat2 map[string]interface{}
  14902. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14903. fmt.Println(dat)
  14904. } else {
  14905. fmt.Println(err)
  14906. }
  14907. userJSONBytes2, _ := json.Marshal(dat2)
  14908. var res2 models.Result3260
  14909. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14910. utils.ErrorLog("解析失败:%v", err)
  14911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14912. return
  14913. }
  14914. if res2.Infcode == 0 {
  14915. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  14916. var dat map[string]interface{}
  14917. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14918. fmt.Println(dat)
  14919. } else {
  14920. fmt.Println(err)
  14921. }
  14922. userJSONBytes, _ := json.Marshal(dat)
  14923. var res3 models.Result3261
  14924. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  14925. utils.ErrorLog("解析失败:%v", err)
  14926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14927. return
  14928. }
  14929. if res3.Infcode == 0 {
  14930. record := &models.HisYidiClearRecord{
  14931. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14932. Ctime: time.Now().Unix(),
  14933. Mtime: time.Now().Unix(),
  14934. Status: 1,
  14935. MsgId: msgId,
  14936. }
  14937. service.SaveClearRecord(record)
  14938. c.ServeSuccessJSON(map[string]interface{}{
  14939. "msg": "提取成功",
  14940. })
  14941. }
  14942. }
  14943. }
  14944. func (c *HisApiController) RefundAllopatry() {
  14945. year := c.GetString("year")
  14946. month := c.GetString("month")
  14947. //id, _ := c.GetInt64("id")
  14948. admin_user_id, _ := c.GetInt64("admin_user_id")
  14949. adminUser := c.GetAdminUserInfo()
  14950. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14951. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14952. //record, _ := service.GetClearRecordById(id)
  14953. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  14954. var dat map[string]interface{}
  14955. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  14956. fmt.Println(dat)
  14957. } else {
  14958. fmt.Println(err)
  14959. }
  14960. userJSONBytes, _ := json.Marshal(dat)
  14961. var res models.Result9001
  14962. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14963. utils.ErrorLog("解析失败:%v", err)
  14964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14965. return
  14966. }
  14967. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  14968. var dat2 map[string]interface{}
  14969. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  14970. fmt.Println(dat)
  14971. } else {
  14972. fmt.Println(err)
  14973. }
  14974. userJSONBytes2, _ := json.Marshal(dat2)
  14975. var empty ResultFourteen
  14976. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  14977. utils.ErrorLog("解析失败:%v", err)
  14978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14979. return
  14980. }
  14981. if empty.Infcode == 0 {
  14982. c.ServeSuccessJSON(map[string]interface{}{
  14983. "msg": "撤销成功",
  14984. })
  14985. return
  14986. }
  14987. }
  14988. func (c *HisApiController) ReversalOtherData() {
  14989. var customData []*CustomData
  14990. custom := &CustomData{
  14991. MsgId: "H44022900158202103301714472004",
  14992. PsnNo: "44020000001101329945",
  14993. Info: "2208",
  14994. }
  14995. customData = append(customData, custom)
  14996. custom1 := &CustomData{
  14997. MsgId: "H4402290015820210330172057803",
  14998. PsnNo: "44020000001101161813",
  14999. Info: "2208",
  15000. }
  15001. customData = append(customData, custom1)
  15002. custom2 := &CustomData{
  15003. MsgId: "H44022900158202103301705198813",
  15004. PsnNo: "44190000133097375417",
  15005. Info: "2208",
  15006. }
  15007. customData = append(customData, custom2)
  15008. custom3 := &CustomData{
  15009. MsgId: "H44022900158202103301715524756",
  15010. PsnNo: "44020000001100187221",
  15011. Info: "2208",
  15012. }
  15013. customData = append(customData, custom3)
  15014. custom4 := &CustomData{
  15015. MsgId: "H44022900158202103301730376224",
  15016. PsnNo: "44020000001101959155",
  15017. Info: "2208",
  15018. }
  15019. customData = append(customData, custom4)
  15020. custom5 := &CustomData{
  15021. MsgId: "H44022900158202103301748008725",
  15022. PsnNo: "44020000001104246641",
  15023. Info: "2208",
  15024. }
  15025. customData = append(customData, custom5)
  15026. custom6 := &CustomData{
  15027. MsgId: "H44022900158202103301718096755",
  15028. PsnNo: "44020000001102211860",
  15029. Info: "2208",
  15030. }
  15031. customData = append(customData, custom6)
  15032. custom7 := &CustomData{
  15033. MsgId: "H44022900158202103301736551640",
  15034. PsnNo: "44020000001102687718",
  15035. Info: "2208",
  15036. }
  15037. customData = append(customData, custom7)
  15038. custom8 := &CustomData{
  15039. MsgId: "H44022900158202103301743097676",
  15040. PsnNo: "44020000001102127785",
  15041. Info: "2208",
  15042. }
  15043. customData = append(customData, custom8)
  15044. custom9 := &CustomData{
  15045. MsgId: "H44022900158202103301712304203",
  15046. PsnNo: "44020000001101518097",
  15047. Info: "2208",
  15048. }
  15049. customData = append(customData, custom9)
  15050. custom10 := &CustomData{
  15051. MsgId: "H44022900158202103301738448785",
  15052. PsnNo: "44020000001100500813",
  15053. Info: "2208",
  15054. }
  15055. customData = append(customData, custom10)
  15056. custom11 := &CustomData{
  15057. MsgId: "H44022900158202103301732455843",
  15058. PsnNo: "44020000001102690557",
  15059. Info: "2208",
  15060. }
  15061. customData = append(customData, custom11)
  15062. custom12 := &CustomData{
  15063. MsgId: "H44022900158202103301745421708",
  15064. PsnNo: "44020000001102211928",
  15065. Info: "2208",
  15066. }
  15067. customData = append(customData, custom12)
  15068. custom1212 := &CustomData{
  15069. MsgId: "H440229001582021033017351627",
  15070. PsnNo: "44020000001102481733",
  15071. Info: "2208",
  15072. }
  15073. customData = append(customData, custom1212)
  15074. custom13 := &CustomData{
  15075. MsgId: "H44022900158202103301740327951",
  15076. PsnNo: "44020000001103174866",
  15077. Info: "2208",
  15078. }
  15079. customData = append(customData, custom13)
  15080. custom14 := &CustomData{
  15081. MsgId: "H4402290015820210330174922668",
  15082. PsnNo: "44020000001102927272",
  15083. Info: "2208",
  15084. }
  15085. customData = append(customData, custom14)
  15086. custom15 := &CustomData{
  15087. MsgId: "H44022900158202103301752362273",
  15088. PsnNo: "44020000001102942890",
  15089. Info: "2208",
  15090. }
  15091. customData = append(customData, custom15)
  15092. custom16 := &CustomData{
  15093. MsgId: "H44022900158202103301751082917",
  15094. PsnNo: "44020000001101662162",
  15095. Info: "2208",
  15096. }
  15097. customData = append(customData, custom16)
  15098. custom17 := &CustomData{
  15099. MsgId: "H44022900158202103301754147728",
  15100. PsnNo: "44020000000229014511",
  15101. Info: "2208",
  15102. }
  15103. customData = append(customData, custom17)
  15104. adminUser := c.GetAdminUserInfo()
  15105. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15106. for _, item := range customData {
  15107. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  15108. fmt.Println(result)
  15109. }
  15110. }
  15111. func PathExists(path string) (bool, error) {
  15112. _, err := os.Stat(path)
  15113. if err == nil {
  15114. return true, nil
  15115. }
  15116. if os.IsNotExist(err) {
  15117. return false, nil
  15118. }
  15119. return false, err
  15120. }
  15121. // 创建文件夹
  15122. func Mkdir(dir string) {
  15123. // 创建文件夹
  15124. exist, err := PathExists(dir)
  15125. if err != nil {
  15126. fmt.Println(err.Error())
  15127. } else {
  15128. if exist {
  15129. fmt.Println(dir + "文件夹已存在!")
  15130. } else {
  15131. // 文件夹名称,权限
  15132. err := os.Mkdir(dir, os.ModePerm)
  15133. if err != nil {
  15134. fmt.Println(dir+"文件夹创建失败:", err.Error())
  15135. } else {
  15136. fmt.Println(dir + "文件夹创建成功!")
  15137. }
  15138. }
  15139. }
  15140. }
  15141. // 压缩文件
  15142. func Zip(srcFile string, destZip string) error {
  15143. zipfile, err := os.Create(destZip)
  15144. if err != nil {
  15145. return err
  15146. }
  15147. defer zipfile.Close()
  15148. archive := zip.NewWriter(zipfile)
  15149. defer archive.Close()
  15150. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  15151. if err != nil {
  15152. return err
  15153. }
  15154. header, err := zip.FileInfoHeader(info)
  15155. if err != nil {
  15156. return err
  15157. }
  15158. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  15159. // header.Name = path
  15160. if info.IsDir() {
  15161. header.Name += "/"
  15162. } else {
  15163. header.Method = zip.Deflate
  15164. }
  15165. writer, err := archive.CreateHeader(header)
  15166. if err != nil {
  15167. return err
  15168. }
  15169. if !info.IsDir() {
  15170. file, err := os.Open(path)
  15171. if err != nil {
  15172. return err
  15173. }
  15174. defer file.Close()
  15175. _, err = io.Copy(writer, file)
  15176. }
  15177. return err
  15178. })
  15179. return err
  15180. }
  15181. func ReadFile(filePath string) []byte {
  15182. f, err := os.Open(filePath)
  15183. if err != nil {
  15184. fmt.Println("read file fail", err)
  15185. return nil
  15186. }
  15187. defer f.Close()
  15188. fd, err := ioutil.ReadAll(f)
  15189. if err != nil {
  15190. fmt.Println("read to fd fail", err)
  15191. return nil
  15192. }
  15193. return fd
  15194. }
  15195. func saveLog(result string, request string, infno string, desc string) {
  15196. org_id, _ := beego.AppConfig.Int64("org_id")
  15197. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15198. dir := miConfig.OrgName + "日志"
  15199. utils.Mkdir(dir)
  15200. month := time.Unix(1557042972, 0).Format("1")
  15201. year := time.Now().Format("2006")
  15202. month = time.Now().Format("01")
  15203. day := time.Now().Format("02")
  15204. hour := time.Now().Format("15")
  15205. min := time.Now().Format("04")
  15206. sec := time.Now().Format("05")
  15207. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  15208. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  15209. file_name := file + ".txt"
  15210. file_path := miConfig.OrgName + "日志" + "/" + file_name
  15211. exist, _ := utils.PathExists(file_path)
  15212. if exist { //存在
  15213. fmt.Println("存在")
  15214. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  15215. if err != nil {
  15216. fmt.Println("read fail")
  15217. }
  15218. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  15219. n, _ := f.Seek(0, 2)
  15220. _, err = f.WriteAt([]byte(content), n)
  15221. } else { //不存在
  15222. fmt.Println("文件不存在,创建文件")
  15223. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  15224. defer f.Close()
  15225. if err != nil {
  15226. } else {
  15227. _, err = f.Write([]byte("记录日志"))
  15228. }
  15229. }
  15230. }
  15231. type Charset string
  15232. const (
  15233. UTF8 = Charset("UTF-8")
  15234. GB18030 = Charset("GB18030")
  15235. )
  15236. func ConvertToString(src string, srcCode string, tagCode string) string {
  15237. srcCoder := mahonia.NewDecoder(srcCode)
  15238. srcResult := srcCoder.ConvertString(src)
  15239. tagCoder := mahonia.NewDecoder(tagCode)
  15240. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  15241. result := string(cdata)
  15242. return result
  15243. }
  15244. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  15245. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  15246. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15247. var token string
  15248. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15249. var api string
  15250. if miConfig.MdtrtareaAdmvs == "320921" {
  15251. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15252. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  15253. fmt.Println(api)
  15254. } else {
  15255. 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 +
  15256. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  15257. }
  15258. resp, requestErr := http.Get(api)
  15259. if requestErr != nil {
  15260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15261. return ""
  15262. }
  15263. body, ioErr := ioutil.ReadAll(resp.Body)
  15264. if ioErr != nil {
  15265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15267. return ""
  15268. }
  15269. var respJSON map[string]interface{}
  15270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15273. return ""
  15274. }
  15275. var status string
  15276. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15277. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15278. var res ResultTwo //1101结果
  15279. var res10265 ResultTwo10265 //1101结果
  15280. if status == "0" { //读卡成功
  15281. var card_info string //卡信息
  15282. var busi_card_info string
  15283. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15284. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15285. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15286. fmt.Println(card_info)
  15287. fmt.Println(busi_card_info)
  15288. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15289. result, _ := json.Marshal(respJSON)
  15290. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15291. utils.ErrorLog("解析失败:%v", err)
  15292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15293. return ""
  15294. }
  15295. res.ErrMsg = res10265.ErrMsg
  15296. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15297. res.Infcode = infocode
  15298. res.Output = res10265.Output
  15299. res.InfRefmsgid = res10265.InfRefmsgid
  15300. if res.Infcode == 0 {
  15301. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15302. if err == gorm.ErrRecordNotFound {
  15303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15304. return ""
  15305. } else if err != nil {
  15306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15307. return ""
  15308. } else {
  15309. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15310. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15311. infoStr := string(Iinfos)
  15312. idetinfoStr := string(Idetinfos)
  15313. psn := &models.HisPsn{
  15314. PsnNo: res.Output.Baseinfo.PsnNo,
  15315. Age: res.Output.Baseinfo.Age,
  15316. PatientId: patient.ID,
  15317. Certno: res.Output.Baseinfo.Certno,
  15318. Brdy: res.Output.Baseinfo.Brdy,
  15319. Gend: res.Output.Baseinfo.Gend,
  15320. Naty: res.Output.Baseinfo.Naty,
  15321. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15322. PsnName: res.Output.Baseinfo.PsnName,
  15323. Idetinfo: idetinfoStr,
  15324. Insuinfo: infoStr,
  15325. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15326. CardInfo: card_info,
  15327. VerifyNumber: token,
  15328. }
  15329. service.CreateHisPsn(psn)
  15330. return token
  15331. }
  15332. }
  15333. } else {
  15334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15335. return ""
  15336. }
  15337. } else { //读卡失败
  15338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15339. return ""
  15340. }
  15341. return token
  15342. }
  15343. func DeleteExtraSpaceTwo(s string) string {
  15344. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  15345. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  15346. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  15347. reg, _ := regexp.Compile(regstr) //编译正则表达式
  15348. s2 := make([]byte, len(s1)) //定义字符数组切片
  15349. copy(s2, s1) //将字符串复制到切片
  15350. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  15351. for len(spc_index) > 0 { //找到适配项
  15352. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  15353. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  15354. }
  15355. return string(s2)
  15356. }
  15357. func Remove0000(s string) string {
  15358. str := make([]rune, 0, len(s))
  15359. for _, v := range []rune(s) {
  15360. if v == 0 {
  15361. continue
  15362. }
  15363. str = append(str, v)
  15364. }
  15365. return string(str)
  15366. }
  15367. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  15368. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  15369. readCard := DllDef.MustFindProc("EcQuery")
  15370. pCardInfo := make([]byte, 8192)
  15371. pBusiCardInfo := make([]byte, 8192)
  15372. data := make(map[string]interface{})
  15373. //pData := make(map[string]interface{})
  15374. inputData := make(map[string]interface{})
  15375. inputData["orgId"] = code
  15376. inputData["businessType"] = "01101"
  15377. inputData["operatorId"] = operator_id
  15378. inputData["operatorName"] = operator_name
  15379. inputData["officeId"] = "001"
  15380. inputData["officeName"] = "血透室"
  15381. //
  15382. data["data"] = inputData
  15383. data["transType"] = "ec.query"
  15384. data["orgId"] = code
  15385. bytesData, _ := json.Marshal(data)
  15386. pCardInfo = bytesData
  15387. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  15388. fmt.Println(ret2)
  15389. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  15390. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15391. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  15392. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15393. if ret2 != 0 {
  15394. return "", ""
  15395. }
  15396. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  15397. }
  15398. func DeleteExtraSpace(s string) string {
  15399. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  15400. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  15401. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  15402. reg, _ := regexp.Compile(regstr) //编译正则表达式
  15403. s2 := make([]byte, len(s1)) //定义字符数组切片
  15404. copy(s2, s1) //将字符串复制到切片
  15405. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  15406. for len(spc_index) > 0 { //找到适配项
  15407. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  15408. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  15409. }
  15410. return string(s2)
  15411. }
  15412. // 对账
  15413. func (c *HisApiController) Post3202() {
  15414. start_time := c.GetString("start_time")
  15415. end_time := c.GetString("end_time")
  15416. //insutype := c.GetString("insutype")
  15417. clr_type := c.GetString("clr_type")
  15418. clr_org := c.GetString("clr_optins")
  15419. admin_user_id, _ := c.GetInt64("admin_user_id")
  15420. adminUser := c.GetAdminUserInfo()
  15421. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15422. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15423. if len(clr_org) == 0 {
  15424. clr_org = miConfig.MdtrtareaAdmvs
  15425. }
  15426. timeLayout := "2006-01-02"
  15427. loc, _ := time.LoadLocation("Local")
  15428. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  15429. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  15430. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  15431. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  15432. //fixmedins_setl_cnt := int64(len(orders))
  15433. var medfee_sumamt float64
  15434. var acct_pay float64
  15435. var fund_pay_sumamt float64
  15436. for _, item := range orders {
  15437. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  15438. acct_pay = acct_pay + item.AcctPay
  15439. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  15440. }
  15441. //var medfee_sumamt_two float64
  15442. //var acct_pay_two float64
  15443. //var fund_pay_sumamt_two float64
  15444. //for _, item := range orders_two {
  15445. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  15446. // acct_pay_two = acct_pay_two + item.AcctPay
  15447. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  15448. //}
  15449. //var user_name string
  15450. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15451. //if role.ID == 0 {
  15452. // user_name = "xxx"
  15453. //} else {
  15454. // user_name = role.UserName
  15455. //}
  15456. var res ResultSix
  15457. if config.IsOpen == 1 {
  15458. var bps []*models.BusinessParamsTwo
  15459. var bp models.BusinessParamsTwo
  15460. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  15461. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  15462. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  15463. bp.MedfeeSumamt = medfee_sumamt_str
  15464. bp.AcctPay = acct_pay_str
  15465. bp.FundPaySumamt = fund_pay_sumamt_str
  15466. bp.Insutype = "390"
  15467. bp.StmtBegndate = start_time
  15468. bp.ClrType = clr_type
  15469. bp.SetlOptins = clr_org
  15470. bp.StmtEnddate = end_time
  15471. bps = append(bps, &bp)
  15472. data := make(map[string]interface{})
  15473. data["bps"] = bps
  15474. data["org_name"] = miConfig.OrgName
  15475. data["doctor"] = role.UserName
  15476. data["fixmedins_code"] = miConfig.Code
  15477. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15478. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15479. if miConfig.MdtrtareaAdmvs == "421300" {
  15480. client := &http.Client{}
  15481. bytesData, _ := json.Marshal(data)
  15482. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  15483. resp, _ := client.Do(req)
  15484. defer resp.Body.Close()
  15485. body, ioErr := ioutil.ReadAll(resp.Body)
  15486. if ioErr != nil {
  15487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15489. return
  15490. }
  15491. var respJSON map[string]interface{}
  15492. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15495. return
  15496. }
  15497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15498. userJSONBytes, _ := json.Marshal(respJSON)
  15499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15500. utils.ErrorLog("解析失败:%v", err)
  15501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15502. return
  15503. }
  15504. }
  15505. if res.Infcode == 0 {
  15506. c.ServeSuccessJSON(map[string]interface{}{
  15507. "msg": "发起成功",
  15508. })
  15509. } else {
  15510. c.ServeSuccessJSON(map[string]interface{}{
  15511. "code": -10,
  15512. "msg": res.ErrMsg,
  15513. })
  15514. }
  15515. }
  15516. }
  15517. func (c *HisApiController) Post3501() {
  15518. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15519. data := make(map[string]interface{})
  15520. var struct3501s []models.Struct3501
  15521. var struct3501 models.Struct3501
  15522. struct3501.OrgName = miConfig.OrgName
  15523. struct3501.AccessKey = miConfig.AccessKey
  15524. struct3501.RequestUrl = miConfig.Url
  15525. struct3501.SecretKey = miConfig.SecretKey
  15526. struct3501.ManuDate = "2022-08-17"
  15527. struct3501.FixmedinsBchno = ""
  15528. struct3501.ManuLotnum = ""
  15529. struct3501.RxFlag = "0"
  15530. struct3501.ExpyEnd = "2022-08-17"
  15531. struct3501.Invdate = "2022-08-17"
  15532. struct3501.InvCnt = "20.25"
  15533. struct3501.Memo = ""
  15534. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15535. struct3501.FixmedinsHilistId = miConfig.Code
  15536. struct3501.FixmedinsHilistName = miConfig.OrgName
  15537. struct3501s = append(struct3501s, struct3501)
  15538. data["struct_3501s"] = struct3501s
  15539. client := &http.Client{}
  15540. bytesData, _ := json.Marshal(data)
  15541. var req *http.Request
  15542. if miConfig.MdtrtareaAdmvs == "320921" {
  15543. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15544. } else {
  15545. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15546. }
  15547. resp, _ := client.Do(req)
  15548. defer resp.Body.Close()
  15549. body, ioErr := ioutil.ReadAll(resp.Body)
  15550. if ioErr != nil {
  15551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15553. return
  15554. }
  15555. var respJSON map[string]interface{}
  15556. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15559. return
  15560. }
  15561. var res ResultSix
  15562. var resSix10265 ResultSix10265 //1101结果
  15563. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15564. result, _ := json.Marshal(respJSON)
  15565. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15566. utils.ErrorLog("解析失败:%v", err)
  15567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15568. return
  15569. }
  15570. res.InfRefmsgid = resSix10265.InfRefmsgid
  15571. res.Output = resSix10265.Output
  15572. res.ErrMsg = resSix10265.ErrMsg
  15573. res.Cainfo = resSix10265.Cainfo
  15574. res.WarnMsg = resSix10265.WarnMsg
  15575. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15576. res.Infcode = infocode
  15577. if infocode == 0 {
  15578. c.ServeSuccessJSON(map[string]interface{}{
  15579. "msg": "上传成功",
  15580. })
  15581. return
  15582. } else {
  15583. c.ServeSuccessJSON(map[string]interface{}{
  15584. "failed_code": -10,
  15585. "msg": res.ErrMsg,
  15586. })
  15587. return
  15588. }
  15589. }
  15590. func (c *HisApiController) Post3502() {
  15591. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15592. data := make(map[string]interface{})
  15593. var struct3502s []models.Struct3502
  15594. var struct3502 models.Struct3502
  15595. struct3502.OrgName = miConfig.OrgName
  15596. struct3502.AccessKey = miConfig.AccessKey
  15597. struct3502.RequestUrl = miConfig.Url
  15598. struct3502.SecretKey = miConfig.SecretKey
  15599. struct3502.ManuDate = "2022-08-15"
  15600. struct3502.FixmedinsBchno = ""
  15601. struct3502.ManuLotnum = ""
  15602. struct3502.RxFlag = "0"
  15603. struct3502.ExpyEnd = "2022-08-15"
  15604. struct3502.Invdate = "2022-08-15"
  15605. struct3502.InvCnt = "20.25"
  15606. struct3502.Memo = ""
  15607. struct3502.MedListCodg = "XB01ABD056B002020200517"
  15608. struct3502.FixmedinsHilistId = miConfig.Code
  15609. struct3502.FixmedinsHilistName = miConfig.OrgName
  15610. struct3502s = append(struct3502s, struct3502)
  15611. data["struct_3502s"] = struct3502s
  15612. client := &http.Client{}
  15613. bytesData, _ := json.Marshal(data)
  15614. var req *http.Request
  15615. if miConfig.MdtrtareaAdmvs == "320921" {
  15616. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15617. } else {
  15618. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15619. }
  15620. resp, _ := client.Do(req)
  15621. defer resp.Body.Close()
  15622. body, ioErr := ioutil.ReadAll(resp.Body)
  15623. if ioErr != nil {
  15624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15626. return
  15627. }
  15628. var respJSON map[string]interface{}
  15629. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15632. return
  15633. }
  15634. var res ResultSix
  15635. var resSix10265 ResultSix10265 //1101结果
  15636. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15637. result, _ := json.Marshal(respJSON)
  15638. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15639. utils.ErrorLog("解析失败:%v", err)
  15640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15641. return
  15642. }
  15643. res.InfRefmsgid = resSix10265.InfRefmsgid
  15644. res.Output = resSix10265.Output
  15645. res.ErrMsg = resSix10265.ErrMsg
  15646. res.Cainfo = resSix10265.Cainfo
  15647. res.WarnMsg = resSix10265.WarnMsg
  15648. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15649. res.Infcode = infocode
  15650. if infocode == 0 {
  15651. c.ServeSuccessJSON(map[string]interface{}{
  15652. "msg": "上传成功",
  15653. })
  15654. return
  15655. } else {
  15656. c.ServeSuccessJSON(map[string]interface{}{
  15657. "failed_code": -10,
  15658. "msg": res.ErrMsg,
  15659. })
  15660. return
  15661. }
  15662. }
  15663. func (c *HisApiController) Post3503() {
  15664. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15665. data := make(map[string]interface{})
  15666. var struct3501s []models.Struct3501
  15667. var struct3501 models.Struct3501
  15668. struct3501.OrgName = miConfig.OrgName
  15669. struct3501.AccessKey = miConfig.AccessKey
  15670. struct3501.RequestUrl = miConfig.Url
  15671. struct3501.SecretKey = miConfig.SecretKey
  15672. struct3501.ManuDate = "2022-08-15"
  15673. struct3501.FixmedinsBchno = ""
  15674. struct3501.ManuLotnum = ""
  15675. struct3501.RxFlag = "0"
  15676. struct3501.ExpyEnd = "2022-08-15"
  15677. struct3501.Invdate = "2022-08-15"
  15678. struct3501.InvCnt = "20.25"
  15679. struct3501.Memo = ""
  15680. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15681. struct3501.FixmedinsHilistId = miConfig.Code
  15682. struct3501.FixmedinsHilistName = miConfig.OrgName
  15683. struct3501s = append(struct3501s, struct3501)
  15684. data["struct_3501s"] = struct3501s
  15685. client := &http.Client{}
  15686. bytesData, _ := json.Marshal(data)
  15687. var req *http.Request
  15688. if miConfig.MdtrtareaAdmvs == "320921" {
  15689. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15690. } else {
  15691. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15692. }
  15693. resp, _ := client.Do(req)
  15694. defer resp.Body.Close()
  15695. body, ioErr := ioutil.ReadAll(resp.Body)
  15696. if ioErr != nil {
  15697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15699. return
  15700. }
  15701. var respJSON map[string]interface{}
  15702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15705. return
  15706. }
  15707. var res ResultSix
  15708. var resSix10265 ResultSix10265 //1101结果
  15709. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15710. result, _ := json.Marshal(respJSON)
  15711. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15712. utils.ErrorLog("解析失败:%v", err)
  15713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15714. return
  15715. }
  15716. res.InfRefmsgid = resSix10265.InfRefmsgid
  15717. res.Output = resSix10265.Output
  15718. res.ErrMsg = resSix10265.ErrMsg
  15719. res.Cainfo = resSix10265.Cainfo
  15720. res.WarnMsg = resSix10265.WarnMsg
  15721. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15722. res.Infcode = infocode
  15723. if infocode == 0 {
  15724. c.ServeSuccessJSON(map[string]interface{}{
  15725. "msg": "上传成功",
  15726. })
  15727. return
  15728. } else {
  15729. c.ServeSuccessJSON(map[string]interface{}{
  15730. "failed_code": -10,
  15731. "msg": res.ErrMsg,
  15732. })
  15733. return
  15734. }
  15735. }
  15736. func (c *HisApiController) Post3504() {
  15737. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15738. data := make(map[string]interface{})
  15739. var struct3501s []models.Struct3501
  15740. var struct3501 models.Struct3501
  15741. struct3501.OrgName = miConfig.OrgName
  15742. struct3501.AccessKey = miConfig.AccessKey
  15743. struct3501.RequestUrl = miConfig.Url
  15744. struct3501.SecretKey = miConfig.SecretKey
  15745. struct3501.ManuDate = "2022-08-15"
  15746. struct3501.FixmedinsBchno = ""
  15747. struct3501.ManuLotnum = ""
  15748. struct3501.RxFlag = "0"
  15749. struct3501.ExpyEnd = "2022-08-15"
  15750. struct3501.Invdate = "2022-08-15"
  15751. struct3501.InvCnt = "20.25"
  15752. struct3501.Memo = ""
  15753. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15754. struct3501.FixmedinsHilistId = miConfig.Code
  15755. struct3501.FixmedinsHilistName = miConfig.OrgName
  15756. struct3501s = append(struct3501s, struct3501)
  15757. data["struct_3501s"] = struct3501s
  15758. client := &http.Client{}
  15759. bytesData, _ := json.Marshal(data)
  15760. var req *http.Request
  15761. if miConfig.MdtrtareaAdmvs == "320921" {
  15762. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15763. } else {
  15764. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15765. }
  15766. resp, _ := client.Do(req)
  15767. defer resp.Body.Close()
  15768. body, ioErr := ioutil.ReadAll(resp.Body)
  15769. if ioErr != nil {
  15770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15772. return
  15773. }
  15774. var respJSON map[string]interface{}
  15775. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15778. return
  15779. }
  15780. var res ResultSix
  15781. var resSix10265 ResultSix10265 //1101结果
  15782. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15783. result, _ := json.Marshal(respJSON)
  15784. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15785. utils.ErrorLog("解析失败:%v", err)
  15786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15787. return
  15788. }
  15789. res.InfRefmsgid = resSix10265.InfRefmsgid
  15790. res.Output = resSix10265.Output
  15791. res.ErrMsg = resSix10265.ErrMsg
  15792. res.Cainfo = resSix10265.Cainfo
  15793. res.WarnMsg = resSix10265.WarnMsg
  15794. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15795. res.Infcode = infocode
  15796. if infocode == 0 {
  15797. c.ServeSuccessJSON(map[string]interface{}{
  15798. "msg": "上传成功",
  15799. })
  15800. return
  15801. } else {
  15802. c.ServeSuccessJSON(map[string]interface{}{
  15803. "failed_code": -10,
  15804. "msg": res.ErrMsg,
  15805. })
  15806. return
  15807. }
  15808. }
  15809. func (c *HisApiController) Post3505() {
  15810. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15811. data := make(map[string]interface{})
  15812. var struct3501s []models.Struct3501
  15813. var struct3501 models.Struct3501
  15814. struct3501.OrgName = miConfig.OrgName
  15815. struct3501.AccessKey = miConfig.AccessKey
  15816. struct3501.RequestUrl = miConfig.Url
  15817. struct3501.SecretKey = miConfig.SecretKey
  15818. struct3501.ManuDate = "2022-08-15"
  15819. struct3501.FixmedinsBchno = ""
  15820. struct3501.ManuLotnum = ""
  15821. struct3501.RxFlag = "0"
  15822. struct3501.ExpyEnd = "2022-08-15"
  15823. struct3501.Invdate = "2022-08-15"
  15824. struct3501.InvCnt = "20.25"
  15825. struct3501.Memo = ""
  15826. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15827. struct3501.FixmedinsHilistId = miConfig.Code
  15828. struct3501.FixmedinsHilistName = miConfig.OrgName
  15829. struct3501s = append(struct3501s, struct3501)
  15830. data["struct_3501s"] = struct3501s
  15831. client := &http.Client{}
  15832. bytesData, _ := json.Marshal(data)
  15833. var req *http.Request
  15834. if miConfig.MdtrtareaAdmvs == "320921" {
  15835. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15836. } else {
  15837. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15838. }
  15839. resp, _ := client.Do(req)
  15840. defer resp.Body.Close()
  15841. body, ioErr := ioutil.ReadAll(resp.Body)
  15842. if ioErr != nil {
  15843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15845. return
  15846. }
  15847. var respJSON map[string]interface{}
  15848. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15851. return
  15852. }
  15853. var res ResultSix
  15854. var resSix10265 ResultSix10265 //1101结果
  15855. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15856. result, _ := json.Marshal(respJSON)
  15857. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15858. utils.ErrorLog("解析失败:%v", err)
  15859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15860. return
  15861. }
  15862. res.InfRefmsgid = resSix10265.InfRefmsgid
  15863. res.Output = resSix10265.Output
  15864. res.ErrMsg = resSix10265.ErrMsg
  15865. res.Cainfo = resSix10265.Cainfo
  15866. res.WarnMsg = resSix10265.WarnMsg
  15867. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15868. res.Infcode = infocode
  15869. if infocode == 0 {
  15870. c.ServeSuccessJSON(map[string]interface{}{
  15871. "msg": "上传成功",
  15872. })
  15873. return
  15874. } else {
  15875. c.ServeSuccessJSON(map[string]interface{}{
  15876. "failed_code": -10,
  15877. "msg": res.ErrMsg,
  15878. })
  15879. return
  15880. }
  15881. }
  15882. func (c *HisApiController) Post3506() {
  15883. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15884. data := make(map[string]interface{})
  15885. var struct3501s []models.Struct3501
  15886. var struct3501 models.Struct3501
  15887. struct3501.OrgName = miConfig.OrgName
  15888. struct3501.AccessKey = miConfig.AccessKey
  15889. struct3501.RequestUrl = miConfig.Url
  15890. struct3501.SecretKey = miConfig.SecretKey
  15891. struct3501.ManuDate = "2022-08-15"
  15892. struct3501.FixmedinsBchno = ""
  15893. struct3501.ManuLotnum = ""
  15894. struct3501.RxFlag = "0"
  15895. struct3501.ExpyEnd = "2022-08-15"
  15896. struct3501.Invdate = "2022-08-15"
  15897. struct3501.InvCnt = "20.25"
  15898. struct3501.Memo = ""
  15899. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15900. struct3501.FixmedinsHilistId = miConfig.Code
  15901. struct3501.FixmedinsHilistName = miConfig.OrgName
  15902. struct3501s = append(struct3501s, struct3501)
  15903. data["struct_3501s"] = struct3501s
  15904. client := &http.Client{}
  15905. bytesData, _ := json.Marshal(data)
  15906. var req *http.Request
  15907. if miConfig.MdtrtareaAdmvs == "320921" {
  15908. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15909. } else {
  15910. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15911. }
  15912. resp, _ := client.Do(req)
  15913. defer resp.Body.Close()
  15914. body, ioErr := ioutil.ReadAll(resp.Body)
  15915. if ioErr != nil {
  15916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15918. return
  15919. }
  15920. var respJSON map[string]interface{}
  15921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15924. return
  15925. }
  15926. var res ResultSix
  15927. var resSix10265 ResultSix10265 //1101结果
  15928. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  15929. result, _ := json.Marshal(respJSON)
  15930. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  15931. utils.ErrorLog("解析失败:%v", err)
  15932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15933. return
  15934. }
  15935. res.InfRefmsgid = resSix10265.InfRefmsgid
  15936. res.Output = resSix10265.Output
  15937. res.ErrMsg = resSix10265.ErrMsg
  15938. res.Cainfo = resSix10265.Cainfo
  15939. res.WarnMsg = resSix10265.WarnMsg
  15940. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15941. res.Infcode = infocode
  15942. if infocode == 0 {
  15943. c.ServeSuccessJSON(map[string]interface{}{
  15944. "msg": "上传成功",
  15945. })
  15946. return
  15947. } else {
  15948. c.ServeSuccessJSON(map[string]interface{}{
  15949. "failed_code": -10,
  15950. "msg": res.ErrMsg,
  15951. })
  15952. return
  15953. }
  15954. }
  15955. func (c *HisApiController) Post3507() {
  15956. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15957. data := make(map[string]interface{})
  15958. var struct3501s []models.Struct3501
  15959. var struct3501 models.Struct3501
  15960. struct3501.OrgName = miConfig.OrgName
  15961. struct3501.AccessKey = miConfig.AccessKey
  15962. struct3501.RequestUrl = miConfig.Url
  15963. struct3501.SecretKey = miConfig.SecretKey
  15964. struct3501.ManuDate = "2022-08-15"
  15965. struct3501.FixmedinsBchno = ""
  15966. struct3501.ManuLotnum = ""
  15967. struct3501.RxFlag = "0"
  15968. struct3501.ExpyEnd = "2022-08-15"
  15969. struct3501.Invdate = "2022-08-15"
  15970. struct3501.InvCnt = "20.25"
  15971. struct3501.Memo = ""
  15972. struct3501.MedListCodg = "XB01ABD056B002020200517"
  15973. struct3501.FixmedinsHilistId = miConfig.Code
  15974. struct3501.FixmedinsHilistName = miConfig.OrgName
  15975. struct3501s = append(struct3501s, struct3501)
  15976. data["struct_3501s"] = struct3501s
  15977. client := &http.Client{}
  15978. bytesData, _ := json.Marshal(data)
  15979. var req *http.Request
  15980. if miConfig.MdtrtareaAdmvs == "320921" {
  15981. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15982. } else {
  15983. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  15984. }
  15985. resp, _ := client.Do(req)
  15986. defer resp.Body.Close()
  15987. body, ioErr := ioutil.ReadAll(resp.Body)
  15988. if ioErr != nil {
  15989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15991. return
  15992. }
  15993. var respJSON map[string]interface{}
  15994. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15997. return
  15998. }
  15999. var res ResultSix
  16000. var resSix10265 ResultSix10265 //1101结果
  16001. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16002. result, _ := json.Marshal(respJSON)
  16003. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16004. utils.ErrorLog("解析失败:%v", err)
  16005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16006. return
  16007. }
  16008. res.InfRefmsgid = resSix10265.InfRefmsgid
  16009. res.Output = resSix10265.Output
  16010. res.ErrMsg = resSix10265.ErrMsg
  16011. res.Cainfo = resSix10265.Cainfo
  16012. res.WarnMsg = resSix10265.WarnMsg
  16013. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16014. res.Infcode = infocode
  16015. if infocode == 0 {
  16016. c.ServeSuccessJSON(map[string]interface{}{
  16017. "msg": "上传成功",
  16018. })
  16019. return
  16020. } else {
  16021. c.ServeSuccessJSON(map[string]interface{}{
  16022. "failed_code": -10,
  16023. "msg": res.ErrMsg,
  16024. })
  16025. return
  16026. }
  16027. }