his_api_controller.go 481KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162
  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. }
  80. type Result3101 struct {
  81. Infcode string `json:"infcode"`
  82. InfRefmsgid string `json:"inf_refmsgid"`
  83. RefmsgTime string `json:"refmsg_time"`
  84. RespondTime string `json:"respond_time"`
  85. Enctype string `json:"enctype"`
  86. Signtype string `json:"signtype"`
  87. ErrMsg string `json:"err_msg"`
  88. Output struct {
  89. Result []struct {
  90. JudgeResultDetailDtos []struct {
  91. VolaItemType string `json:"vola_item_type"`
  92. MdtrtID string `json:"mdtrt_id"`
  93. JrdID string `json:"jrd_id"`
  94. PatnID string `json:"patn_id"`
  95. RxID string `json:"rx_id"`
  96. VolaAmt interface{} `json:"vola_amt"`
  97. } `json:"judge_result_detail_dtos"`
  98. RuleID string `json:"rule_id"`
  99. VolaEvid string `json:"vola_evid"`
  100. MdtrtID string `json:"mdtrt_id"`
  101. RuleName string `json:"rule_name"`
  102. VolaAmtStas string `json:"vola_amt_stas"`
  103. JrID string `json:"jr_id"`
  104. PatnID string `json:"patn_id"`
  105. SevDeg string `json:"sev_deg"`
  106. VolaAmt float64 `json:"vola_amt"`
  107. VolaBhvrType string `json:"vola_bhvr_type"`
  108. VolaCont string `json:"vola_cont"`
  109. } `json:"result"`
  110. } `json:"output"`
  111. }
  112. func (c *HisApiController) Get9001() {
  113. adminUser := c.GetAdminUserInfo()
  114. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  115. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  116. if miConfig.MdtrtareaAdmvs == "350500" {
  117. service.GetFjAuthorizationInfo(miConfig.Code)
  118. } else {
  119. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  120. var dat map[string]interface{}
  121. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  122. fmt.Println(dat)
  123. } else {
  124. fmt.Println(err)
  125. }
  126. userJSONBytes, _ := json.Marshal(dat)
  127. var res models.Result9001
  128. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  129. utils.ErrorLog("解析失败:%v", err)
  130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  131. return
  132. }
  133. }
  134. }
  135. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  136. adminUser := c.GetAdminUserInfo()
  137. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  138. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  139. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  140. //record_time := c.GetString("record_time")
  141. //trig_scen := c.GetString("trig_scen")
  142. timeLayout := "2006-01-02"
  143. loc, _ := time.LoadLocation("Local")
  144. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  145. if err != nil {
  146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  147. return res
  148. }
  149. recordDateTime := theTime.Unix()
  150. var patientPrescription models.HisPrescriptionInfo
  151. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  152. //if patientPrescription.ID == 0 {
  153. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  154. //}
  155. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  156. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  157. //
  158. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  159. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  160. var pp models.PublicParams
  161. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  162. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  163. pp.FixmedinsName = miConfig.OrgName
  164. pp.FixmedinsCode = miConfig.Code
  165. pp.RequestUrl = miConfig.Url
  166. pp.Cainfo = miConfig.Cainfo
  167. pp.SecretKey = miConfig.SecretKey
  168. pp.AccessKey = miConfig.AccessKey
  169. pp.OpterName = roles.UserName
  170. var config []*models.HisXtDiagnoseConfig
  171. for _, item := range diagnosis_ids {
  172. id, _ := strconv.ParseInt(item, 10, 64)
  173. diagnosisConfig, _ := service.FindDiagnoseById(id)
  174. config = append(config, &diagnosisConfig)
  175. }
  176. var pd models.PatientDtos
  177. pd.PatnID = his.PsnNo
  178. pd.PatnName = his.Name
  179. pd.Gend = his.Gend
  180. pd.Brdy = his.Brdy
  181. pd.Poolarea = his.InsuplcAdmdvs
  182. pd.CurrMdtrtID = his.Number
  183. var fed models.FsiEncounterDtos
  184. fed.MdtrtID = his.Number
  185. fed.MedinsID = miConfig.Code
  186. fed.MedinsName = miConfig.OrgName
  187. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  188. fed.MedMdtrtType = "1"
  189. fed.MedinsType = "1"
  190. fed.MedinsLv = "11"
  191. tm := time.Unix(his.RecordDate, 0)
  192. s_tm := tm.Format("2006-01-02 15:04:05")
  193. fed.AdmDate = s_tm
  194. fed.DscgDate = s_tm
  195. fed.DscgMainDiseCodg = config[0].CountryCode
  196. fed.DscgMainDiseName = config[0].CountryContentName
  197. //诊断信息
  198. var fdds []*models.FsiDiagnoseDtos
  199. for index, item := range config {
  200. if index == 0 {
  201. var fdd models.FsiDiagnoseDtos
  202. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  203. fdd.InoutDiseType = "1"
  204. fdd.MaindiseFlag = "1"
  205. fdd.DiseDate = s_tm
  206. fdd.DiasSrtNo = "1"
  207. fdd.DiseName = item.CountryContentName
  208. fdd.DiseCodg = item.CountryCode
  209. fdds = append(fdds, &fdd)
  210. } else {
  211. var fdd models.FsiDiagnoseDtos
  212. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  213. fdd.InoutDiseType = "1"
  214. fdd.MaindiseFlag = "1"
  215. fdd.DiseDate = s_tm
  216. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  217. fdd.DiseName = item.CountryContentName
  218. fdd.DiseCodg = item.CountryCode
  219. fdds = append(fdds, &fdd)
  220. }
  221. }
  222. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  223. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  224. fed.AdmDeptName = department.Name
  225. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  226. fed.DscgDeptName = department.Name
  227. fed.MedMdtrtType = "1"
  228. fed.MedType = "11"
  229. //if his.Insutype == "390" {
  230. // fed.MedType = "1402"
  231. //} else {
  232. // fed.MedType = "9933"
  233. //}
  234. var orders []*models.FsiOrderDtos
  235. if trig_scen == "2" {
  236. //处方医嘱信息
  237. for _, item := range prescriptions {
  238. for _, subItem := range item.HisDoctorAdviceInfo {
  239. var order models.FsiOrderDtos
  240. order.RxID = strconv.FormatInt(item.ID, 10)
  241. order.Rxno = strconv.FormatInt(item.ID, 10)
  242. order.LongDrordFlag = "0"
  243. order.HilistType = "1"
  244. order.ChrgType = "1"
  245. order.DrordBhvr = "-"
  246. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  247. order.HosplistName = subItem.BaseDrugLib.DrugName
  248. order.HilistLv = "1"
  249. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  250. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  251. order.HosplistName = subItem.BaseDrugLib.DrugName
  252. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  253. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  254. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  255. order.OwnpayAmt = ""
  256. order.SelfpayAmt = ""
  257. order.Spec = ""
  258. order.SpecUnt = ""
  259. order.DrordBegnDate = s_tm
  260. order.DrordStopDate = ""
  261. order.DrordDrCodg = "1"
  262. order.DrordDeptName = department.Name
  263. order.DrordDrCodg = "1"
  264. order.DrordDrName = doctor_info.UserName
  265. order.DrordDrProfttl = ""
  266. order.CurrDrordFlag = "1"
  267. orders = append(orders, &order)
  268. }
  269. for _, subItem := range item.HisPrescriptionProject {
  270. if subItem.Type == 2 {
  271. var order models.FsiOrderDtos
  272. order.RxID = strconv.FormatInt(item.ID, 10)
  273. order.Rxno = strconv.FormatInt(item.ID, 10)
  274. order.LongDrordFlag = "0"
  275. order.HilistType = "1"
  276. order.ChrgType = "1"
  277. order.DrordBhvr = "-"
  278. order.HilistCode = subItem.HisProject.MedicalCode
  279. order.HosplistName = subItem.HisProject.ProjectName
  280. order.HilistLv = "1"
  281. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  282. order.HosplistCode = subItem.HisProject.MedicalCode
  283. order.HosplistName = subItem.HisProject.ProjectName
  284. order.Cnt = subItem.Count
  285. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  286. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  287. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  288. order.OwnpayAmt = ""
  289. order.SelfpayAmt = ""
  290. order.Spec = ""
  291. order.SpecUnt = ""
  292. order.DrordBegnDate = s_tm
  293. order.DrordStopDate = ""
  294. order.DrordDrCodg = "1"
  295. order.DrordDeptName = department.Name
  296. order.DrordDrCodg = "1"
  297. order.DrordDrName = doctor_info.UserName
  298. order.DrordDrProfttl = ""
  299. order.CurrDrordFlag = "1"
  300. orders = append(orders, &order)
  301. }
  302. if subItem.Type == 3 {
  303. var order models.FsiOrderDtos
  304. order.RxID = strconv.FormatInt(item.ID, 10)
  305. order.Rxno = strconv.FormatInt(item.ID, 10)
  306. order.LongDrordFlag = "0"
  307. order.HilistType = "1"
  308. order.ChrgType = "1"
  309. order.DrordBhvr = "-"
  310. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  311. order.HosplistName = subItem.GoodInfo.GoodName
  312. order.HilistLv = "1"
  313. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  314. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  315. order.HosplistName = subItem.GoodInfo.GoodName
  316. order.Cnt = subItem.Count
  317. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  318. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  319. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  320. order.OwnpayAmt = ""
  321. order.SelfpayAmt = ""
  322. order.Spec = ""
  323. order.SpecUnt = ""
  324. order.DrordBegnDate = s_tm
  325. order.DrordStopDate = ""
  326. order.DrordDrCodg = "1"
  327. order.DrordDeptName = department.Name
  328. order.DrordDrCodg = "1"
  329. order.DrordDrName = doctor_info.UserName
  330. order.DrordDrProfttl = ""
  331. order.CurrDrordFlag = "1"
  332. orders = append(orders, &order)
  333. }
  334. }
  335. }
  336. //处方医嘱信息
  337. }
  338. fed.MatnStas = "0"
  339. fed.MedfeeSumamt = "0"
  340. fed.OwnpayAmt = "0"
  341. fed.SelfpayAmt = "0"
  342. fed.AcctPayamt = "0"
  343. fed.MaAmt = "0"
  344. fed.HifpPayamt = "0"
  345. fed.SetlTotlnum = "1"
  346. fed.Insutype = his.Insutype
  347. fed.ReimFlag = "0"
  348. fed.OutSetlFlag = "0"
  349. var fopd []*models.FsiOperationDtosData
  350. data := make(map[string]interface{})
  351. data["fed"] = fed
  352. data["fdd"] = fdds
  353. data["fod"] = orders
  354. data["pd"] = pd
  355. data["pp"] = pp
  356. data["fopd"] = fopd
  357. data["trig_scen"] = trig_scen
  358. fmt.Println(data)
  359. fmt.Println(fed)
  360. fmt.Println(fdds)
  361. fmt.Println(orders)
  362. fmt.Println(pd)
  363. fmt.Println(pp)
  364. fmt.Println(fopd)
  365. client := &http.Client{}
  366. bytesData, _ := json.Marshal(data)
  367. var req *http.Request
  368. if miConfig.MdtrtareaAdmvs == "320921" {
  369. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  370. } else {
  371. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  372. }
  373. resp, _ := client.Do(req)
  374. defer resp.Body.Close()
  375. body, ioErr := ioutil.ReadAll(resp.Body)
  376. if ioErr != nil {
  377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  379. return res
  380. }
  381. var respJSON map[string]interface{}
  382. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  385. return res
  386. }
  387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  388. result, _ := json.Marshal(respJSON)
  389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  390. utils.ErrorLog("解析失败:%v", err)
  391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  392. return res
  393. }
  394. return res
  395. }
  396. 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) {
  397. adminUser := c.GetAdminUserInfo()
  398. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  399. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  400. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  401. //record_time := c.GetString("record_time")
  402. //trig_scen := c.GetString("trig_scen")
  403. timeLayout := "2006-01-02"
  404. loc, _ := time.LoadLocation("Local")
  405. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  406. if err != nil {
  407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  408. return res
  409. }
  410. recordDateTime := theTime.Unix()
  411. var patientPrescription models.HisPrescriptionInfo
  412. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  413. if patientPrescription.ID == 0 {
  414. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  415. }
  416. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  417. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  418. //
  419. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  420. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  421. var pp models.PublicParams
  422. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  423. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  424. pp.FixmedinsName = miConfig.OrgName
  425. pp.FixmedinsCode = miConfig.Code
  426. pp.RequestUrl = miConfig.Url
  427. pp.Cainfo = miConfig.Cainfo
  428. pp.SecretKey = miConfig.SecretKey
  429. pp.AccessKey = miConfig.AccessKey
  430. pp.OpterName = roles.UserName
  431. var config []*models.HisXtDiagnoseConfig
  432. for _, item := range diagnosis_ids {
  433. id, _ := strconv.ParseInt(item, 10, 64)
  434. diagnosisConfig, _ := service.FindDiagnoseById(id)
  435. config = append(config, &diagnosisConfig)
  436. }
  437. var pd models.PatientDtos
  438. pd.PatnID = his.PsnNo
  439. pd.PatnName = his.Name
  440. pd.Gend = his.Gend
  441. pd.Brdy = his.Brdy
  442. pd.Poolarea = his.InsuplcAdmdvs
  443. pd.CurrMdtrtID = his.Number
  444. var fed models.FsiEncounterDtos
  445. fed.MdtrtID = his.Number
  446. fed.MedinsID = miConfig.Code
  447. fed.MedinsName = miConfig.OrgName
  448. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  449. fed.MedMdtrtType = "1"
  450. fed.MedinsType = "1"
  451. fed.MedinsLv = "11"
  452. tm := time.Unix(his.RecordDate, 0)
  453. s_tm := tm.Format("2006-01-02 15:04:05")
  454. fed.AdmDate = s_tm
  455. fed.DscgDate = s_tm
  456. fed.DscgMainDiseCodg = config[0].CountryCode
  457. fed.DscgMainDiseName = config[0].CountryContentName
  458. //诊断信息
  459. var fdds []*models.FsiDiagnoseDtos
  460. for index, item := range config {
  461. if index == 0 {
  462. var fdd models.FsiDiagnoseDtos
  463. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  464. fdd.InoutDiseType = "1"
  465. fdd.MaindiseFlag = "1"
  466. fdd.DiseDate = s_tm
  467. fdd.DiasSrtNo = "1"
  468. fdd.DiseName = item.CountryContentName
  469. fdd.DiseCodg = item.CountryCode
  470. fdds = append(fdds, &fdd)
  471. } else {
  472. var fdd models.FsiDiagnoseDtos
  473. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  474. fdd.InoutDiseType = "1"
  475. fdd.MaindiseFlag = "1"
  476. fdd.DiseDate = s_tm
  477. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  478. fdd.DiseName = item.CountryContentName
  479. fdd.DiseCodg = item.CountryCode
  480. fdds = append(fdds, &fdd)
  481. }
  482. }
  483. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  484. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  485. fed.AdmDeptName = department.Name
  486. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  487. fed.DscgDeptName = department.Name
  488. fed.MedMdtrtType = "1"
  489. fed.MedType = "11"
  490. //if his.Insutype == "390" {
  491. // fed.MedType = "1402"
  492. //} else {
  493. // fed.MedType = "9933"
  494. //}
  495. var orders []*models.FsiOrderDtos
  496. if trig_scen == "2" {
  497. //处方医嘱信息
  498. for _, item := range prescriptions {
  499. for _, subItem := range item.HisDoctorAdviceInfo {
  500. var order models.FsiOrderDtos
  501. order.RxID = strconv.FormatInt(item.ID, 10)
  502. order.Rxno = strconv.FormatInt(item.ID, 10)
  503. order.LongDrordFlag = "0"
  504. order.HilistType = "1"
  505. order.ChrgType = "1"
  506. order.DrordBhvr = "-"
  507. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  508. order.HosplistName = subItem.BaseDrugLib.DrugName
  509. order.HilistLv = "1"
  510. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  511. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  512. order.HosplistName = subItem.BaseDrugLib.DrugName
  513. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  514. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  515. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  516. order.OwnpayAmt = ""
  517. order.SelfpayAmt = ""
  518. order.Spec = ""
  519. order.SpecUnt = ""
  520. order.DrordBegnDate = s_tm
  521. order.DrordStopDate = ""
  522. order.DrordDrCodg = "1"
  523. order.DrordDeptName = department.Name
  524. order.DrordDrCodg = "1"
  525. order.DrordDrName = doctor_info.UserName
  526. order.DrordDrProfttl = ""
  527. order.CurrDrordFlag = "1"
  528. orders = append(orders, &order)
  529. }
  530. for _, subItem := range item.HisPrescriptionProject {
  531. if subItem.Type == 2 {
  532. var order models.FsiOrderDtos
  533. order.RxID = strconv.FormatInt(item.ID, 10)
  534. order.Rxno = strconv.FormatInt(item.ID, 10)
  535. order.LongDrordFlag = "0"
  536. order.HilistType = "1"
  537. order.ChrgType = "1"
  538. order.DrordBhvr = "-"
  539. order.HilistCode = subItem.HisProject.MedicalCode
  540. order.HosplistName = subItem.HisProject.ProjectName
  541. order.HilistLv = "1"
  542. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  543. order.HosplistCode = subItem.HisProject.MedicalCode
  544. order.HosplistName = subItem.HisProject.ProjectName
  545. order.Cnt = subItem.Count
  546. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  547. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  548. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  549. order.OwnpayAmt = ""
  550. order.SelfpayAmt = ""
  551. order.Spec = ""
  552. order.SpecUnt = ""
  553. order.DrordBegnDate = s_tm
  554. order.DrordStopDate = ""
  555. order.DrordDrCodg = "1"
  556. order.DrordDeptName = department.Name
  557. order.DrordDrCodg = "1"
  558. order.DrordDrName = doctor_info.UserName
  559. order.DrordDrProfttl = ""
  560. order.CurrDrordFlag = "1"
  561. orders = append(orders, &order)
  562. }
  563. if subItem.Type == 3 {
  564. var order models.FsiOrderDtos
  565. order.RxID = strconv.FormatInt(item.ID, 10)
  566. order.Rxno = strconv.FormatInt(item.ID, 10)
  567. order.LongDrordFlag = "0"
  568. order.HilistType = "1"
  569. order.ChrgType = "1"
  570. order.DrordBhvr = "-"
  571. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  572. order.HosplistName = subItem.GoodInfo.GoodName
  573. order.HilistLv = "1"
  574. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  575. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  576. order.HosplistName = subItem.GoodInfo.GoodName
  577. order.Cnt = subItem.Count
  578. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  579. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  580. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  581. order.OwnpayAmt = ""
  582. order.SelfpayAmt = ""
  583. order.Spec = ""
  584. order.SpecUnt = ""
  585. order.DrordBegnDate = s_tm
  586. order.DrordStopDate = ""
  587. order.DrordDrCodg = "1"
  588. order.DrordDeptName = department.Name
  589. order.DrordDrCodg = "1"
  590. order.DrordDrName = doctor_info.UserName
  591. order.DrordDrProfttl = ""
  592. order.CurrDrordFlag = "1"
  593. orders = append(orders, &order)
  594. }
  595. }
  596. }
  597. //处方医嘱信息
  598. }
  599. fed.MatnStas = "0"
  600. fed.MedfeeSumamt = "0"
  601. fed.OwnpayAmt = "0"
  602. fed.SelfpayAmt = "0"
  603. fed.AcctPayamt = "0"
  604. fed.MaAmt = "0"
  605. fed.HifpPayamt = "0"
  606. fed.SetlTotlnum = "1"
  607. fed.Insutype = his.Insutype
  608. fed.ReimFlag = "0"
  609. fed.OutSetlFlag = "0"
  610. var fopd []*models.FsiOperationDtosData
  611. data := make(map[string]interface{})
  612. data["fed"] = fed
  613. data["fdd"] = fdds
  614. data["fod"] = orders
  615. data["pd"] = pd
  616. data["pp"] = pp
  617. data["fopd"] = fopd
  618. data["trig_scen"] = trig_scen
  619. fmt.Println(data)
  620. fmt.Println(fed)
  621. fmt.Println(fdds)
  622. fmt.Println(orders)
  623. fmt.Println(pd)
  624. fmt.Println(pp)
  625. fmt.Println(fopd)
  626. client := &http.Client{}
  627. bytesData, _ := json.Marshal(data)
  628. var req *http.Request
  629. if miConfig.MdtrtareaAdmvs == "320921" {
  630. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  631. } else {
  632. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  633. }
  634. resp, _ := client.Do(req)
  635. defer resp.Body.Close()
  636. body, ioErr := ioutil.ReadAll(resp.Body)
  637. if ioErr != nil {
  638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  640. return res
  641. }
  642. var respJSON map[string]interface{}
  643. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  646. return res
  647. }
  648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  649. result, _ := json.Marshal(respJSON)
  650. if err := json.Unmarshal([]byte(result), &res); err != nil {
  651. utils.ErrorLog("解析失败:%v", err)
  652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  653. return res
  654. }
  655. return res
  656. }
  657. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  658. ////patient_id, _ := c.GetInt64("patient_id")
  659. //order_id, _ := c.GetInt64("order_id")
  660. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  661. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  662. //trig_scen := c.GetString("trig_scen")
  663. adminUser := c.GetAdminUserInfo()
  664. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  665. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  666. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  667. record_time := c.GetString("record_time")
  668. order, _ := service.GetHisOrderByID(order_id)
  669. timeLayout := "2006-01-02"
  670. loc, _ := time.LoadLocation("Local")
  671. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  672. if err != nil {
  673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  674. return
  675. }
  676. recordDateTime := theTime.Unix()
  677. var patientPrescription models.HisPrescriptionInfo
  678. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  679. if patientPrescription.ID == 0 {
  680. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  681. }
  682. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  683. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  684. //
  685. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  686. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  687. var pp models.PublicParams
  688. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  689. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  690. pp.FixmedinsName = miConfig.OrgName
  691. pp.FixmedinsCode = miConfig.Code
  692. pp.RequestUrl = miConfig.Url
  693. pp.Cainfo = miConfig.Cainfo
  694. pp.SecretKey = miConfig.SecretKey
  695. pp.AccessKey = miConfig.AccessKey
  696. pp.OpterName = roles.UserName
  697. var config []*models.HisXtDiagnoseConfig
  698. for _, item := range diagnosis_ids {
  699. id, _ := strconv.ParseInt(item, 10, 64)
  700. diagnosisConfig, _ := service.FindDiagnoseById(id)
  701. config = append(config, &diagnosisConfig)
  702. }
  703. var pd models.PatientDtos
  704. pd.PatnID = his.PsnNo
  705. pd.PatnName = his.Name
  706. pd.Gend = his.Gend
  707. pd.Brdy = his.Brdy
  708. pd.Poolarea = his.InsuplcAdmdvs
  709. pd.CurrMdtrtID = his.Number
  710. var fed models.FsiEncounterDtos
  711. fed.MdtrtID = his.Number
  712. fed.MedinsID = miConfig.Code
  713. fed.MedinsName = miConfig.OrgName
  714. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  715. fed.MedMdtrtType = "1"
  716. fed.MedinsType = "1"
  717. fed.MedinsLv = "11"
  718. tm := time.Unix(his.RecordDate, 0)
  719. s_tm := tm.Format("2006-01-02 15:04:05")
  720. fed.AdmDate = s_tm
  721. fed.DscgDate = s_tm
  722. fed.DscgMainDiseCodg = config[0].CountryCode
  723. fed.DscgMainDiseName = config[0].CountryContentName
  724. //诊断信息
  725. var fdds []*models.FsiDiagnoseDtos
  726. for index, item := range config {
  727. if index == 0 {
  728. var fdd models.FsiDiagnoseDtos
  729. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  730. fdd.InoutDiseType = "1"
  731. fdd.MaindiseFlag = "1"
  732. fdd.DiseDate = s_tm
  733. fdd.DiasSrtNo = "1"
  734. fdd.DiseName = item.CountryContentName
  735. fdd.DiseCodg = item.CountryCode
  736. fdds = append(fdds, &fdd)
  737. } else {
  738. var fdd models.FsiDiagnoseDtos
  739. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  740. fdd.InoutDiseType = "1"
  741. fdd.MaindiseFlag = "1"
  742. fdd.DiseDate = s_tm
  743. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  744. fdd.DiseName = item.CountryContentName
  745. fdd.DiseCodg = item.CountryCode
  746. fdds = append(fdds, &fdd)
  747. }
  748. }
  749. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  750. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  751. fed.AdmDeptName = department.Name
  752. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  753. fed.DscgDeptName = department.Name
  754. fed.MedType = order.MedType
  755. //处方医嘱信息
  756. var orders []*models.FsiOrderDtos
  757. //for _, item := range prescriptions {
  758. // for _, subItem := range item.HisDoctorAdviceInfo {
  759. // var order models.FsiOrderDtos
  760. // order.RxID = strconv.FormatInt(item.ID, 10)
  761. // order.Rxno = strconv.FormatInt(item.ID, 10)
  762. // order.LongDrordFlag = "0"
  763. // order.HilistType = "1"
  764. // order.ChrgType = "1"
  765. // order.DrordBhvr = "-"
  766. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  767. // order.HosplistName = subItem.BaseDrugLib.DrugName
  768. // order.HilistLv = "1"
  769. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  770. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  771. // order.HosplistName = subItem.BaseDrugLib.DrugName
  772. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  773. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  774. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  775. // order.OwnpayAmt = ""
  776. // order.SelfpayAmt = ""
  777. // order.Spec = ""
  778. // order.SpecUnt = ""
  779. // order.DrordBegnDate = s_tm
  780. // order.DrordStopDate = ""
  781. // order.DrordDrCodg = "1"
  782. // order.DrordDeptName = department.Name
  783. // order.DrordDrCodg = "1"
  784. // order.DrordDrName = doctor_info.UserName
  785. // order.DrordDrProfttl = ""
  786. // order.CurrDrordFlag = "1"
  787. // orders = append(orders, &order)
  788. // }
  789. // for _, subItem := range item.HisPrescriptionProject {
  790. // if subItem.Type == 2 {
  791. // var order models.FsiOrderDtos
  792. // order.RxID = strconv.FormatInt(item.ID, 10)
  793. // order.Rxno = strconv.FormatInt(item.ID, 10)
  794. // order.LongDrordFlag = "0"
  795. // order.HilistType = "1"
  796. // order.ChrgType = "1"
  797. // order.DrordBhvr = "-"
  798. // order.HilistCode = subItem.HisProject.MedicalCode
  799. // order.HosplistName = subItem.HisProject.ProjectName
  800. // order.HilistLv = "1"
  801. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  802. // order.HosplistCode = subItem.HisProject.MedicalCode
  803. // order.HosplistName = subItem.HisProject.ProjectName
  804. // order.Cnt = subItem.Count
  805. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  806. //
  807. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  808. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  809. // order.OwnpayAmt = ""
  810. // order.SelfpayAmt = ""
  811. // order.Spec = ""
  812. // order.SpecUnt = ""
  813. // order.DrordBegnDate = s_tm
  814. // order.DrordStopDate = ""
  815. // order.DrordDrCodg = "1"
  816. // order.DrordDeptName = department.Name
  817. // order.DrordDrCodg = "1"
  818. // order.DrordDrName = doctor_info.UserName
  819. // order.DrordDrProfttl = ""
  820. // order.CurrDrordFlag = "1"
  821. // orders = append(orders, &order)
  822. //
  823. // }
  824. // if subItem.Type == 3 {
  825. //
  826. // var order models.FsiOrderDtos
  827. // order.RxID = strconv.FormatInt(item.ID, 10)
  828. // order.Rxno = strconv.FormatInt(item.ID, 10)
  829. // order.LongDrordFlag = "0"
  830. // order.HilistType = "1"
  831. // order.ChrgType = "1"
  832. // order.DrordBhvr = "-"
  833. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  834. // order.HosplistName = subItem.GoodInfo.GoodName
  835. // order.HilistLv = "1"
  836. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  837. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  838. // order.HosplistName = subItem.GoodInfo.GoodName
  839. // order.Cnt = subItem.Count
  840. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  841. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  842. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  843. // order.OwnpayAmt = ""
  844. // order.SelfpayAmt = ""
  845. // order.Spec = ""
  846. // order.SpecUnt = ""
  847. // order.DrordBegnDate = s_tm
  848. // order.DrordStopDate = ""
  849. // order.DrordDrCodg = "1"
  850. // order.DrordDeptName = department.Name
  851. // order.DrordDrCodg = "1"
  852. // order.DrordDrName = doctor_info.UserName
  853. // order.DrordDrProfttl = ""
  854. // order.CurrDrordFlag = "1"
  855. // orders = append(orders, &order)
  856. //
  857. // }
  858. // }
  859. //}
  860. for _, item := range prescriptions {
  861. for _, subItem := range item.HisDoctorAdviceInfo {
  862. var order models.FsiOrderDtos
  863. order.RxID = strconv.FormatInt(item.ID, 10)
  864. order.Rxno = strconv.FormatInt(item.ID, 10)
  865. order.LongDrordFlag = "0"
  866. order.HilistType = "1"
  867. order.ChrgType = "1"
  868. order.DrordBhvr = "-"
  869. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  870. order.HosplistName = subItem.BaseDrugLib.DrugName
  871. order.HilistLv = "1"
  872. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  873. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  874. order.HosplistName = subItem.BaseDrugLib.DrugName
  875. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  876. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  877. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  878. order.OwnpayAmt = ""
  879. order.SelfpayAmt = ""
  880. order.Spec = ""
  881. order.SpecUnt = ""
  882. order.DrordBegnDate = s_tm
  883. order.DrordStopDate = ""
  884. order.DrordDrCodg = "1"
  885. order.DrordDeptName = department.Name
  886. order.DrordDrCodg = "1"
  887. order.DrordDrName = doctor_info.UserName
  888. order.DrordDrProfttl = ""
  889. order.CurrDrordFlag = "1"
  890. orders = append(orders, &order)
  891. }
  892. for _, subItem := range item.HisPrescriptionProject {
  893. if subItem.Type == 2 {
  894. var order models.FsiOrderDtos
  895. order.RxID = strconv.FormatInt(item.ID, 10)
  896. order.Rxno = strconv.FormatInt(item.ID, 10)
  897. order.LongDrordFlag = "0"
  898. order.HilistType = "1"
  899. order.ChrgType = "1"
  900. order.DrordBhvr = "-"
  901. order.HilistCode = subItem.HisProject.MedicalCode
  902. order.HosplistName = subItem.HisProject.ProjectName
  903. order.HilistLv = "1"
  904. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  905. order.HosplistCode = subItem.HisProject.MedicalCode
  906. order.HosplistName = subItem.HisProject.ProjectName
  907. order.Cnt = subItem.Count
  908. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  909. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  910. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  911. order.OwnpayAmt = ""
  912. order.SelfpayAmt = ""
  913. order.Spec = ""
  914. order.SpecUnt = ""
  915. order.DrordBegnDate = s_tm
  916. order.DrordStopDate = ""
  917. order.DrordDrCodg = "1"
  918. order.DrordDeptName = department.Name
  919. order.DrordDrCodg = "1"
  920. order.DrordDrName = doctor_info.UserName
  921. order.DrordDrProfttl = ""
  922. order.CurrDrordFlag = "1"
  923. orders = append(orders, &order)
  924. }
  925. if subItem.Type == 3 {
  926. var order models.FsiOrderDtos
  927. order.RxID = strconv.FormatInt(item.ID, 10)
  928. order.Rxno = strconv.FormatInt(item.ID, 10)
  929. order.LongDrordFlag = "0"
  930. order.HilistType = "1"
  931. order.ChrgType = "1"
  932. order.DrordBhvr = "-"
  933. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  934. order.HosplistName = subItem.GoodInfo.GoodName
  935. order.HilistLv = "1"
  936. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  937. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  938. order.HosplistName = subItem.GoodInfo.GoodName
  939. order.Cnt = subItem.Count
  940. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  941. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  942. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  943. order.OwnpayAmt = ""
  944. order.SelfpayAmt = ""
  945. order.Spec = ""
  946. order.SpecUnt = ""
  947. order.DrordBegnDate = s_tm
  948. order.DrordStopDate = ""
  949. order.DrordDrCodg = "1"
  950. order.DrordDeptName = department.Name
  951. order.DrordDrCodg = "1"
  952. order.DrordDrName = doctor_info.UserName
  953. order.DrordDrProfttl = ""
  954. order.CurrDrordFlag = "1"
  955. orders = append(orders, &order)
  956. }
  957. }
  958. }
  959. //处方医嘱信息
  960. fed.MatnStas = "0"
  961. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  962. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  963. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  964. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  965. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  966. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  967. fed.SetlTotlnum = "1"
  968. fed.Insutype = his.Insutype
  969. fed.ReimFlag = "0"
  970. fed.OutSetlFlag = "0"
  971. var fopd []*models.FsiOperationDtosData
  972. data := make(map[string]interface{})
  973. data["fed"] = fed
  974. data["fdd"] = fdds
  975. data["fod"] = orders
  976. data["pd"] = pd
  977. data["pp"] = pp
  978. data["fopd"] = fopd
  979. data["trig_scen"] = trig_scen
  980. client := &http.Client{}
  981. bytesData, _ := json.Marshal(data)
  982. var req *http.Request
  983. if miConfig.MdtrtareaAdmvs == "320921" {
  984. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  985. } else {
  986. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  987. }
  988. resp, _ := client.Do(req)
  989. defer resp.Body.Close()
  990. body, ioErr := ioutil.ReadAll(resp.Body)
  991. if ioErr != nil {
  992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  994. return res
  995. }
  996. var respJSON map[string]interface{}
  997. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1000. return res
  1001. }
  1002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1003. result, _ := json.Marshal(respJSON)
  1004. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1005. utils.ErrorLog("解析失败:%v", err)
  1006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1007. return res
  1008. }
  1009. return res
  1010. //手术操作集合
  1011. //手术操作集合
  1012. }
  1013. func (c *HisApiController) Check() {
  1014. psn_no := c.GetString("psn_no")
  1015. in := c.GetString("in")
  1016. mt := c.GetString("mt")
  1017. baseParams := models.BaseParams{
  1018. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1019. FixmedinsCode: "H15049901371",
  1020. InsuplcAdmdvs: "150499",
  1021. MdtrtareaAdmvs: "150499",
  1022. OrgName: "赤峰费森血液透析中心",
  1023. Doctor: "1111",
  1024. }
  1025. service.Gdyb2001(baseParams, psn_no, in, mt)
  1026. }
  1027. func (c *HisApiController) GetPsnNcdsInfo() {
  1028. admin_user_id, _ := c.GetInt64("admin_user_id")
  1029. patient_id, _ := c.GetInt64("patient_id")
  1030. id, _ := c.GetInt64("id")
  1031. adminUser := c.GetAdminUserInfo()
  1032. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1033. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1034. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1035. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1036. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1037. //
  1038. //if psn_record.ID == 0 {
  1039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1040. // return
  1041. //}
  1042. var res Result5301
  1043. var res10265 Result5301For10265
  1044. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1045. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1046. var api string
  1047. if miConfig.MdtrtareaAdmvs == "320921" {
  1048. 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 +
  1049. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1050. } else {
  1051. 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 +
  1052. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1053. }
  1054. resp, requestErr := http.Get(api)
  1055. if requestErr != nil {
  1056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1057. return
  1058. }
  1059. body, ioErr := ioutil.ReadAll(resp.Body)
  1060. if ioErr != nil {
  1061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1063. return
  1064. }
  1065. var respJSON map[string]interface{}
  1066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1069. return
  1070. }
  1071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1072. result, _ := json.Marshal(respJSON)
  1073. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1074. utils.ErrorLog("解析失败:%v", err)
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1076. return
  1077. }
  1078. res.ErrMsg = res10265.ErrMsg
  1079. res.Output = res10265.Output
  1080. res.InfRefmsgid = res10265.InfRefmsgid
  1081. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1082. res.Infcode = infocode
  1083. } else {
  1084. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1085. var dat map[string]interface{}
  1086. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1087. fmt.Println(dat)
  1088. } else {
  1089. fmt.Println(err)
  1090. }
  1091. userJSONBytes, _ := json.Marshal(dat)
  1092. if miConfig.Code == "H15049901371" {
  1093. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1094. utils.ErrorLog("解析失败:%v", err)
  1095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1096. return
  1097. }
  1098. res.InfRefmsgid = res10265.InfRefmsgid
  1099. res.Output = res10265.Output
  1100. res.ErrMsg = res10265.ErrMsg
  1101. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1102. res.Infcode = infocode
  1103. } else {
  1104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1105. utils.ErrorLog("解析失败:%v", err)
  1106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1107. return
  1108. }
  1109. }
  1110. }
  1111. if res.Infcode == 0 {
  1112. c.ServeSuccessJSON(map[string]interface{}{
  1113. "result": res.Output.Result,
  1114. })
  1115. }
  1116. }
  1117. func (c *HisApiController) CheckInsutype() {
  1118. his_patient_id, _ := c.GetInt64("his_patient_id")
  1119. admin_user_id, _ := c.GetInt64("admin_user_id")
  1120. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1121. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1122. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1123. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1124. var dat map[string]interface{}
  1125. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1126. fmt.Println(dat)
  1127. } else {
  1128. fmt.Println(err)
  1129. }
  1130. userJSONBytes, _ := json.Marshal(dat)
  1131. var res Result90100
  1132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1133. utils.ErrorLog("解析失败:%v", err)
  1134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1135. return
  1136. }
  1137. if res.Infcode != 0 {
  1138. c.ServeSuccessJSON(map[string]interface{}{
  1139. "failed_code": -10,
  1140. "msg": res.ErrMsg,
  1141. })
  1142. return
  1143. } else {
  1144. fmt.Println(res)
  1145. }
  1146. }
  1147. func (c *HisApiController) CheckCardPWD() {
  1148. card_pwd := c.GetString("card_pwd")
  1149. his_patient_id, _ := c.GetInt64("his_patient_id")
  1150. admin_user_id, _ := c.GetInt64("admin_user_id")
  1151. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1152. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1153. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1154. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1155. bas := strings.Split(psn.CardInfo, "|")
  1156. basNumber := bas[2]
  1157. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1158. var dat map[string]interface{}
  1159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1160. fmt.Println(dat)
  1161. } else {
  1162. fmt.Println(err)
  1163. }
  1164. userJSONBytes, _ := json.Marshal(dat)
  1165. var res Result90991
  1166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1167. utils.ErrorLog("解析失败:%v", err)
  1168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1169. return
  1170. }
  1171. if res.Infcode != 0 {
  1172. c.ServeSuccessJSON(map[string]interface{}{
  1173. "failed_code": -10,
  1174. "msg": res.ErrMsg,
  1175. })
  1176. return
  1177. } else {
  1178. if res.Output.Result.SscnoCheckStat == "0" {
  1179. var msg string
  1180. switch res.Output.Result.CardStat {
  1181. case "00":
  1182. msg = "未激活"
  1183. break
  1184. case "10":
  1185. msg = "激活"
  1186. break
  1187. case "20":
  1188. msg = "窗口挂失"
  1189. break
  1190. case "21":
  1191. msg = "电话挂失"
  1192. break
  1193. case "22":
  1194. msg = "单位网上申报挂失"
  1195. break
  1196. case "23":
  1197. msg = "保健办挂失"
  1198. break
  1199. case "24":
  1200. msg = "个人网上挂失"
  1201. break
  1202. case "25":
  1203. msg = "网上服务大厅挂失"
  1204. break
  1205. case "30":
  1206. msg = "注销"
  1207. break
  1208. case "40":
  1209. msg = "回收"
  1210. break
  1211. case "99":
  1212. msg = "制卡中(无效卡)"
  1213. break
  1214. }
  1215. c.ServeSuccessJSON(map[string]interface{}{
  1216. "failed_code": -10,
  1217. "msg": msg,
  1218. })
  1219. return
  1220. } else {
  1221. c.ServeSuccessJSON(map[string]interface{}{
  1222. "msg": "校验成功",
  1223. })
  1224. return
  1225. }
  1226. }
  1227. }
  1228. func (c *HisApiController) CheckCardPWDTwo() {
  1229. //card_pwd := c.GetString("card_pwd")
  1230. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1231. admin_user_id, _ := c.GetInt64("admin_user_id")
  1232. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1233. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1234. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1235. var dat map[string]interface{}
  1236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1237. fmt.Println(dat)
  1238. } else {
  1239. fmt.Println(err)
  1240. }
  1241. userJSONBytes, _ := json.Marshal(dat)
  1242. var res Result90991
  1243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1244. utils.ErrorLog("解析失败:%v", err)
  1245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1246. return
  1247. }
  1248. if res.Infcode != 0 {
  1249. c.ServeSuccessJSON(map[string]interface{}{
  1250. "failed_code": -10,
  1251. "msg": res.ErrMsg,
  1252. })
  1253. return
  1254. } else {
  1255. if res.Output.Result.SscnoCheckStat == "0" {
  1256. var msg string
  1257. switch res.Output.Result.CardStat {
  1258. case "00":
  1259. msg = "未激活"
  1260. break
  1261. case "10":
  1262. msg = "激活"
  1263. break
  1264. case "20":
  1265. msg = "窗口挂失"
  1266. break
  1267. case "21":
  1268. msg = "电话挂失"
  1269. break
  1270. case "22":
  1271. msg = "单位网上申报挂失"
  1272. break
  1273. case "23":
  1274. msg = "保健办挂失"
  1275. break
  1276. case "24":
  1277. msg = "个人网上挂失"
  1278. break
  1279. case "25":
  1280. msg = "网上服务大厅挂失"
  1281. break
  1282. case "30":
  1283. msg = "注销"
  1284. break
  1285. case "40":
  1286. msg = "回收"
  1287. break
  1288. case "99":
  1289. msg = "制卡中(无效卡)"
  1290. break
  1291. }
  1292. c.ServeSuccessJSON(map[string]interface{}{
  1293. "failed_code": -10,
  1294. "msg": msg,
  1295. })
  1296. return
  1297. } else {
  1298. c.ServeSuccessJSON(map[string]interface{}{
  1299. "msg": "校验成功",
  1300. })
  1301. return
  1302. }
  1303. }
  1304. }
  1305. type ELeCertData struct {
  1306. Data struct {
  1307. Extra string `json:"extra"`
  1308. IDNo string `json:"idNo"`
  1309. IDType string `json:"idType"`
  1310. EcToken string `json:"ecToken"`
  1311. InsuOrg string `json:"insuOrg"`
  1312. UserName string `json:"userName"`
  1313. EcIndexNo string `json:"ecIndexNo"`
  1314. Gender string `json:"gender"`
  1315. Birthday string `json:"birthday"`
  1316. Nationality string `json:"nationality"`
  1317. Email string `json:"email"`
  1318. } `json:"OutData"`
  1319. }
  1320. func (c *HisApiController) ReadCard() {
  1321. id_card_type, _ := c.GetInt64("id_card_type")
  1322. admin_user_id, _ := c.GetInt64("admin_user_id")
  1323. certificates, _ := c.GetInt64("certificates")
  1324. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1325. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1326. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1327. switch id_card_type {
  1328. case 1:
  1329. if miConfig.MdtrtareaAdmvs == "421300" {
  1330. var res ResultTwo
  1331. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1332. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1333. "&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)
  1334. resp, requestErr := http.Get(api)
  1335. if requestErr != nil {
  1336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1337. return
  1338. }
  1339. body, ioErr := ioutil.ReadAll(resp.Body)
  1340. if ioErr != nil {
  1341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1343. return
  1344. }
  1345. var respJSON map[string]interface{}
  1346. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. return
  1350. }
  1351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1352. result, _ := json.Marshal(respJSON)
  1353. fmt.Println("log")
  1354. fmt.Println(string(result))
  1355. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1356. utils.ErrorLog("解析失败:%v", err)
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1358. return
  1359. }
  1360. if res.Infcode == 0 {
  1361. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1362. if err == gorm.ErrRecordNotFound {
  1363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1364. return
  1365. } else if err != nil {
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1367. return
  1368. } else {
  1369. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1370. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1371. infoStr := string(Iinfos)
  1372. idetinfoStr := string(Idetinfos)
  1373. psn := &models.HisPsn{
  1374. PsnNo: res.Output.Baseinfo.PsnNo,
  1375. Age: res.Output.Baseinfo.Age,
  1376. PatientId: patient.ID,
  1377. Certno: res.Output.Baseinfo.Certno,
  1378. Brdy: res.Output.Baseinfo.Brdy,
  1379. Gend: res.Output.Baseinfo.Gend,
  1380. Naty: res.Output.Baseinfo.Naty,
  1381. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1382. PsnName: res.Output.Baseinfo.PsnName,
  1383. Idetinfo: idetinfoStr,
  1384. Insuinfo: infoStr,
  1385. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1386. }
  1387. service.CreateHisPsn(psn)
  1388. c.ServeSuccessJSON(map[string]interface{}{
  1389. "patient": patient,
  1390. "number": res.Output.Baseinfo.Certno,
  1391. })
  1392. }
  1393. } else {
  1394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1395. return
  1396. }
  1397. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1398. var api string
  1399. if miConfig.MdtrtareaAdmvs == "320921" {
  1400. 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 +
  1401. "&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
  1402. fmt.Println(api)
  1403. } else {
  1404. 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 +
  1405. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1406. }
  1407. resp, requestErr := http.Get(api)
  1408. if requestErr != nil {
  1409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1410. return
  1411. }
  1412. body, ioErr := ioutil.ReadAll(resp.Body)
  1413. if ioErr != nil {
  1414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1416. return
  1417. }
  1418. var respJSON map[string]interface{}
  1419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1422. return
  1423. }
  1424. var status string
  1425. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1426. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1427. //console.log()
  1428. fmt.Println("type===")
  1429. fmt.Println(card_type)
  1430. var token string
  1431. var res ResultTwo //1101结果
  1432. var res10265 ResultTwo10265 //1101结果
  1433. var card_info string //卡信息
  1434. var busi_card_info string
  1435. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1436. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1437. if status == "0" { //读卡成功
  1438. if card_type == "1" {
  1439. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1440. result, _ := json.Marshal(respJSON)
  1441. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1442. utils.ErrorLog("解析失败:%v", err)
  1443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1444. return
  1445. }
  1446. res.ErrMsg = res10265.ErrMsg
  1447. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1448. res.Infcode = infocode
  1449. res.Output = res10265.Output
  1450. res.InfRefmsgid = res10265.InfRefmsgid
  1451. } else {
  1452. //var card_info string //卡信息
  1453. //var busi_card_info string
  1454. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1455. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1456. //fmt.Println(card_info)
  1457. //fmt.Println(busi_card_info)
  1458. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1459. result, _ := json.Marshal(respJSON)
  1460. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1461. utils.ErrorLog("解析失败:%v", err)
  1462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1463. return
  1464. }
  1465. res.ErrMsg = res10265.ErrMsg
  1466. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1467. res.Infcode = infocode
  1468. res.Output = res10265.Output
  1469. res.InfRefmsgid = res10265.InfRefmsgid
  1470. }
  1471. if res.Infcode == 0 {
  1472. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1473. if err == gorm.ErrRecordNotFound {
  1474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1475. return
  1476. } else if err != nil {
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1478. return
  1479. } else {
  1480. if card_type == "1" {
  1481. bas := strings.Split(card_info, "|")
  1482. basNumber := bas[2]
  1483. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1484. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1485. infoStr := string(Iinfos)
  1486. idetinfoStr := string(Idetinfos)
  1487. psn := &models.HisPsn{
  1488. PsnNo: res.Output.Baseinfo.PsnNo,
  1489. Age: res.Output.Baseinfo.Age,
  1490. PatientId: patient.ID,
  1491. Certno: res.Output.Baseinfo.Certno,
  1492. Brdy: res.Output.Baseinfo.Brdy,
  1493. Gend: res.Output.Baseinfo.Gend,
  1494. Naty: res.Output.Baseinfo.Naty,
  1495. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1496. PsnName: res.Output.Baseinfo.PsnName,
  1497. Idetinfo: idetinfoStr,
  1498. Insuinfo: infoStr,
  1499. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1500. CardInfo: card_info,
  1501. VerifyNumber: busi_card_info,
  1502. }
  1503. service.CreateHisPsn(psn)
  1504. var rf []*ResultFive
  1505. json.Unmarshal([]byte(infoStr), &rf)
  1506. var insutypes []*ResultFive
  1507. var insutype string
  1508. var is390 int = 0
  1509. var is310 int = 0
  1510. for _, item := range rf {
  1511. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1512. insutypes = append(insutypes, item)
  1513. }
  1514. }
  1515. if len(insutypes) == 1 {
  1516. insutype = insutypes[0].Insutype
  1517. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1518. } else {
  1519. for _, i := range insutypes {
  1520. if i.Insutype == "390" {
  1521. is390 = 1
  1522. }
  1523. if i.Insutype == "310" {
  1524. is310 = 1
  1525. }
  1526. }
  1527. }
  1528. if is390 == 1 {
  1529. insutype = "390"
  1530. }
  1531. if is310 == 1 {
  1532. insutype = "310"
  1533. }
  1534. if len(insutypes) == 0 {
  1535. insutype = "310"
  1536. }
  1537. c.ServeSuccessJSON(map[string]interface{}{
  1538. "patient": patient,
  1539. "number": basNumber,
  1540. "insutype": insutype,
  1541. })
  1542. } else {
  1543. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1544. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1545. infoStr := string(Iinfos)
  1546. idetinfoStr := string(Idetinfos)
  1547. psn := &models.HisPsn{
  1548. PsnNo: res.Output.Baseinfo.PsnNo,
  1549. Age: res.Output.Baseinfo.Age,
  1550. PatientId: patient.ID,
  1551. Certno: res.Output.Baseinfo.Certno,
  1552. Brdy: res.Output.Baseinfo.Brdy,
  1553. Gend: res.Output.Baseinfo.Gend,
  1554. Naty: res.Output.Baseinfo.Naty,
  1555. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1556. PsnName: res.Output.Baseinfo.PsnName,
  1557. Idetinfo: idetinfoStr,
  1558. Insuinfo: infoStr,
  1559. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1560. CardInfo: card_info,
  1561. VerifyNumber: token,
  1562. }
  1563. service.CreateHisPsn(psn)
  1564. c.ServeSuccessJSON(map[string]interface{}{
  1565. "patient": patient,
  1566. "number": token,
  1567. })
  1568. }
  1569. }
  1570. } else {
  1571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1572. return
  1573. }
  1574. } else { //读卡失败
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1576. return
  1577. }
  1578. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1579. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1580. cardnum = DeleteExtraSpaceTwo(cardnum)
  1581. cardCode = DeleteExtraSpaceTwo(cardCode)
  1582. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1583. name = DeleteExtraSpaceTwo(name)
  1584. errmsg = DeleteExtraSpaceTwo(errmsg)
  1585. cardnum = Remove0000(cardnum)
  1586. cardCode = Remove0000(cardCode)
  1587. id_card_no = Remove0000(id_card_no)
  1588. name = Remove0000(name)
  1589. errmsg = Remove0000(errmsg)
  1590. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1591. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1592. saveLog(result, requestLog, "1101", "获取人员信息")
  1593. fmt.Println(errMsgLog)
  1594. if len(errMsgLog) > 0 {
  1595. } else {
  1596. var dat map[string]interface{}
  1597. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1598. fmt.Println(dat)
  1599. } else {
  1600. fmt.Println(err)
  1601. }
  1602. userJSONBytes, _ := json.Marshal(dat)
  1603. var res ResultTwo
  1604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1605. utils.ErrorLog("解析失败:%v", err)
  1606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1607. return
  1608. }
  1609. res.ErrMsg = errMsgLog
  1610. if res.Infcode == 0 {
  1611. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1612. if err == gorm.ErrRecordNotFound {
  1613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1614. return
  1615. } else if err != nil {
  1616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1617. return
  1618. } else {
  1619. fmt.Println(res)
  1620. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1621. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1622. infoStr := string(Iinfos)
  1623. idetinfoStr := string(Idetinfos)
  1624. psn := &models.HisPsn{
  1625. PsnNo: res.Output.Baseinfo.PsnNo,
  1626. Age: res.Output.Baseinfo.Age,
  1627. PatientId: patient.ID,
  1628. Certno: res.Output.Baseinfo.Certno,
  1629. Brdy: res.Output.Baseinfo.Brdy,
  1630. Gend: res.Output.Baseinfo.Gend,
  1631. Naty: res.Output.Baseinfo.Naty,
  1632. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1633. PsnName: res.Output.Baseinfo.PsnName,
  1634. Idetinfo: idetinfoStr,
  1635. Insuinfo: infoStr,
  1636. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1637. CardInfo: basStr,
  1638. VerifyNumber: "",
  1639. }
  1640. service.CreateHisPsn(psn)
  1641. var rf []*ResultFive
  1642. json.Unmarshal([]byte(infoStr), &rf)
  1643. var insutypes []*ResultFive
  1644. var insutype string
  1645. var is390 int = 0
  1646. var is310 int = 0
  1647. for _, item := range rf {
  1648. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1649. insutypes = append(insutypes, item)
  1650. }
  1651. }
  1652. if len(insutypes) == 1 {
  1653. insutype = insutypes[0].Insutype
  1654. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1655. } else {
  1656. for _, i := range insutypes {
  1657. if i.Insutype == "390" {
  1658. is390 = 1
  1659. }
  1660. if i.Insutype == "310" {
  1661. is310 = 1
  1662. }
  1663. }
  1664. }
  1665. if is390 == 1 {
  1666. insutype = "390"
  1667. }
  1668. if is310 == 1 {
  1669. insutype = "310"
  1670. }
  1671. if len(insutypes) == 0 {
  1672. insutype = "310"
  1673. }
  1674. c.ServeSuccessJSON(map[string]interface{}{
  1675. "patient": patient,
  1676. "number": cardnum,
  1677. "insutype": insutype,
  1678. })
  1679. }
  1680. } else {
  1681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1682. return
  1683. }
  1684. }
  1685. } else {
  1686. if initFlag == 0 {
  1687. c.TestGetBasBaseInit()
  1688. }
  1689. basStr := c.GetBasBaseInfo()
  1690. if len(basStr) == 0 {
  1691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1692. return
  1693. }
  1694. fmt.Println(basStr)
  1695. bas := strings.Split(basStr, "|")
  1696. basNumber := bas[1]
  1697. fmt.Println(basNumber)
  1698. card_sn := bas[3]
  1699. fmt.Println(card_sn)
  1700. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1701. var dat map[string]interface{}
  1702. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1703. fmt.Println(dat)
  1704. } else {
  1705. fmt.Println(err)
  1706. }
  1707. userJSONBytes, _ := json.Marshal(dat)
  1708. var res ResultTwo
  1709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1710. utils.ErrorLog("解析失败:%v", err)
  1711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1712. return
  1713. }
  1714. if res.Infcode == 0 {
  1715. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1716. if err == gorm.ErrRecordNotFound {
  1717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1718. return
  1719. } else if err != nil {
  1720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1721. return
  1722. } else {
  1723. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1724. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1725. infoStr := string(Iinfos)
  1726. idetinfoStr := string(Idetinfos)
  1727. psn := &models.HisPsn{
  1728. PsnNo: res.Output.Baseinfo.PsnNo,
  1729. Age: res.Output.Baseinfo.Age,
  1730. PatientId: patient.ID,
  1731. Certno: res.Output.Baseinfo.Certno,
  1732. Brdy: res.Output.Baseinfo.Brdy,
  1733. Gend: res.Output.Baseinfo.Gend,
  1734. Naty: res.Output.Baseinfo.Naty,
  1735. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1736. PsnName: res.Output.Baseinfo.PsnName,
  1737. Idetinfo: idetinfoStr,
  1738. Insuinfo: infoStr,
  1739. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1740. CardInfo: basStr,
  1741. VerifyNumber: "",
  1742. }
  1743. service.CreateHisPsn(psn)
  1744. c.ServeSuccessJSON(map[string]interface{}{
  1745. "patient": patient,
  1746. "number": basNumber,
  1747. })
  1748. }
  1749. } else {
  1750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1751. return
  1752. }
  1753. break
  1754. }
  1755. case 2:
  1756. SFZStr := c.GetSFZBaseInfo()
  1757. id_card_str := strings.Split(SFZStr, "^")
  1758. id_card_number := id_card_str[0]
  1759. card_sn := ""
  1760. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1761. var dat map[string]interface{}
  1762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1763. fmt.Println(dat)
  1764. } else {
  1765. fmt.Println(err)
  1766. }
  1767. userJSONBytes, _ := json.Marshal(dat)
  1768. var res ResultTwo
  1769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1770. utils.ErrorLog("解析失败:%v", err)
  1771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1772. return
  1773. }
  1774. if res.Infcode == 0 {
  1775. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1776. if err == gorm.ErrRecordNotFound {
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1778. return
  1779. } else if err != nil {
  1780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1781. return
  1782. } else {
  1783. c.ServeSuccessJSON(map[string]interface{}{
  1784. "patient": patient,
  1785. "number": id_card_number,
  1786. })
  1787. }
  1788. } else {
  1789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1790. return
  1791. }
  1792. break
  1793. case 3:
  1794. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1795. var api string
  1796. if miConfig.MdtrtareaAdmvs == "320921" {
  1797. 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 +
  1798. "&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
  1799. fmt.Println(api)
  1800. } else {
  1801. 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 +
  1802. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1803. }
  1804. resp, requestErr := http.Get(api)
  1805. if requestErr != nil {
  1806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1807. return
  1808. }
  1809. body, ioErr := ioutil.ReadAll(resp.Body)
  1810. if ioErr != nil {
  1811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1813. return
  1814. }
  1815. var respJSON map[string]interface{}
  1816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1819. return
  1820. }
  1821. var status string
  1822. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1823. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1824. var token string
  1825. var res ResultTwo //1101结果
  1826. var res10265 ResultTwo10265 //1101结果
  1827. var card_info string //卡信息
  1828. var busi_card_info string
  1829. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1830. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1831. if status == "0" { //读卡成功
  1832. if card_type == "1" {
  1833. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1834. result, _ := json.Marshal(respJSON)
  1835. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1836. utils.ErrorLog("解析失败:%v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. res.ErrMsg = res10265.ErrMsg
  1841. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1842. res.Infcode = infocode
  1843. res.Output = res10265.Output
  1844. res.InfRefmsgid = res10265.InfRefmsgid
  1845. } else {
  1846. //var card_info string //卡信息
  1847. //var busi_card_info string
  1848. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1849. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1850. //fmt.Println(card_info)
  1851. //fmt.Println(busi_card_info)
  1852. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1853. result, _ := json.Marshal(respJSON)
  1854. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1855. utils.ErrorLog("解析失败:%v", err)
  1856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1857. return
  1858. }
  1859. res.ErrMsg = res10265.ErrMsg
  1860. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1861. res.Infcode = infocode
  1862. res.Output = res10265.Output
  1863. res.InfRefmsgid = res10265.InfRefmsgid
  1864. }
  1865. if res.Infcode == 0 {
  1866. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1867. if err == gorm.ErrRecordNotFound {
  1868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1869. return
  1870. } else if err != nil {
  1871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1872. return
  1873. } else {
  1874. if card_type == "1" {
  1875. bas := strings.Split(card_info, "|")
  1876. basNumber := bas[2]
  1877. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1878. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1879. infoStr := string(Iinfos)
  1880. idetinfoStr := string(Idetinfos)
  1881. psn := &models.HisPsn{
  1882. PsnNo: res.Output.Baseinfo.PsnNo,
  1883. Age: res.Output.Baseinfo.Age,
  1884. PatientId: patient.ID,
  1885. Certno: res.Output.Baseinfo.Certno,
  1886. Brdy: res.Output.Baseinfo.Brdy,
  1887. Gend: res.Output.Baseinfo.Gend,
  1888. Naty: res.Output.Baseinfo.Naty,
  1889. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1890. PsnName: res.Output.Baseinfo.PsnName,
  1891. Idetinfo: idetinfoStr,
  1892. Insuinfo: infoStr,
  1893. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1894. CardInfo: card_info,
  1895. VerifyNumber: busi_card_info,
  1896. }
  1897. service.CreateHisPsn(psn)
  1898. c.ServeSuccessJSON(map[string]interface{}{
  1899. "patient": patient,
  1900. "number": basNumber,
  1901. })
  1902. } else {
  1903. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1904. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1905. infoStr := string(Iinfos)
  1906. idetinfoStr := string(Idetinfos)
  1907. psn := &models.HisPsn{
  1908. PsnNo: res.Output.Baseinfo.PsnNo,
  1909. Age: res.Output.Baseinfo.Age,
  1910. PatientId: patient.ID,
  1911. Certno: res.Output.Baseinfo.Certno,
  1912. Brdy: res.Output.Baseinfo.Brdy,
  1913. Gend: res.Output.Baseinfo.Gend,
  1914. Naty: res.Output.Baseinfo.Naty,
  1915. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1916. PsnName: res.Output.Baseinfo.PsnName,
  1917. Idetinfo: idetinfoStr,
  1918. Insuinfo: infoStr,
  1919. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1920. CardInfo: card_info,
  1921. VerifyNumber: token,
  1922. }
  1923. service.CreateHisPsn(psn)
  1924. var rf []*ResultFive
  1925. json.Unmarshal([]byte(infoStr), &rf)
  1926. var insutypes []*ResultFive
  1927. var insutype string
  1928. var is390 int = 0
  1929. var is310 int = 0
  1930. for _, item := range rf {
  1931. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1932. insutypes = append(insutypes, item)
  1933. }
  1934. }
  1935. if len(insutypes) == 1 {
  1936. insutype = insutypes[0].Insutype
  1937. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1938. } else {
  1939. for _, i := range insutypes {
  1940. if i.Insutype == "390" {
  1941. is390 = 1
  1942. }
  1943. if i.Insutype == "310" {
  1944. is310 = 1
  1945. }
  1946. }
  1947. }
  1948. if is390 == 1 {
  1949. insutype = "390"
  1950. }
  1951. if is310 == 1 {
  1952. insutype = "310"
  1953. }
  1954. if len(insutypes) == 0 {
  1955. insutype = "310"
  1956. }
  1957. c.ServeSuccessJSON(map[string]interface{}{
  1958. "patient": patient,
  1959. "number": token,
  1960. "insutype": insutype,
  1961. })
  1962. }
  1963. }
  1964. } else {
  1965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1966. return
  1967. }
  1968. } else { //读卡失败
  1969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1970. return
  1971. }
  1972. }
  1973. break
  1974. case 4:
  1975. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1976. var api string
  1977. if miConfig.MdtrtareaAdmvs == "320921" {
  1978. 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 +
  1979. "&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
  1980. fmt.Println(api)
  1981. } else {
  1982. 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 +
  1983. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1984. }
  1985. resp, requestErr := http.Get(api)
  1986. if requestErr != nil {
  1987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1988. return
  1989. }
  1990. body, ioErr := ioutil.ReadAll(resp.Body)
  1991. if ioErr != nil {
  1992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1994. return
  1995. }
  1996. var respJSON map[string]interface{}
  1997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2000. return
  2001. }
  2002. var status string
  2003. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2004. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2005. var token string
  2006. var res ResultTwo //1101结果
  2007. var res10265 ResultTwo10265 //1101结果
  2008. if status == "0" { //读卡成功
  2009. var card_info string //卡信息
  2010. var busi_card_info string
  2011. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2012. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2013. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2014. fmt.Println(card_info)
  2015. fmt.Println(busi_card_info)
  2016. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2017. result, _ := json.Marshal(respJSON)
  2018. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2019. utils.ErrorLog("解析失败:%v", err)
  2020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2021. return
  2022. }
  2023. res.ErrMsg = res10265.ErrMsg
  2024. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2025. res.Infcode = infocode
  2026. res.Output = res10265.Output
  2027. res.InfRefmsgid = res10265.InfRefmsgid
  2028. if res.Infcode == 0 {
  2029. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2030. if err == gorm.ErrRecordNotFound {
  2031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2032. return
  2033. } else if err != nil {
  2034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2035. return
  2036. } else {
  2037. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2038. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2039. infoStr := string(Iinfos)
  2040. idetinfoStr := string(Idetinfos)
  2041. psn := &models.HisPsn{
  2042. PsnNo: res.Output.Baseinfo.PsnNo,
  2043. Age: res.Output.Baseinfo.Age,
  2044. PatientId: patient.ID,
  2045. Certno: res.Output.Baseinfo.Certno,
  2046. Brdy: res.Output.Baseinfo.Brdy,
  2047. Gend: res.Output.Baseinfo.Gend,
  2048. Naty: res.Output.Baseinfo.Naty,
  2049. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2050. PsnName: res.Output.Baseinfo.PsnName,
  2051. Idetinfo: idetinfoStr,
  2052. Insuinfo: infoStr,
  2053. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2054. CardInfo: card_info,
  2055. VerifyNumber: token,
  2056. }
  2057. service.CreateHisPsn(psn)
  2058. c.ServeSuccessJSON(map[string]interface{}{
  2059. "patient": patient,
  2060. "number": token,
  2061. })
  2062. }
  2063. } else {
  2064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2065. return
  2066. }
  2067. } else { //读卡失败
  2068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2069. return
  2070. }
  2071. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2072. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2073. saveLog(result, requestLog, "6101", "电子凭证")
  2074. var ele ELeCertData
  2075. err := json.Unmarshal([]byte(result), &ele)
  2076. if err != nil {
  2077. utils.ErrorLog("解析失败:%v", err)
  2078. }
  2079. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  2080. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2081. var res ResultTwo
  2082. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2083. utils.ErrorLog("解析失败:%v", err)
  2084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2085. return
  2086. }
  2087. if res.Infcode == 0 {
  2088. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2089. if err == gorm.ErrRecordNotFound {
  2090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2091. return
  2092. } else if err != nil {
  2093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2094. return
  2095. } else {
  2096. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2097. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2098. infoStr := string(Iinfos)
  2099. idetinfoStr := string(Idetinfos)
  2100. psn := &models.HisPsn{
  2101. PsnNo: res.Output.Baseinfo.PsnNo,
  2102. Age: res.Output.Baseinfo.Age,
  2103. PatientId: patient.ID,
  2104. Certno: res.Output.Baseinfo.Certno,
  2105. Brdy: res.Output.Baseinfo.Brdy,
  2106. Gend: res.Output.Baseinfo.Gend,
  2107. Naty: res.Output.Baseinfo.Naty,
  2108. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2109. PsnName: res.Output.Baseinfo.PsnName,
  2110. Idetinfo: idetinfoStr,
  2111. Insuinfo: infoStr,
  2112. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2113. CardInfo: "",
  2114. VerifyNumber: ele.Data.EcToken,
  2115. }
  2116. service.CreateHisPsn(psn)
  2117. c.ServeSuccessJSON(map[string]interface{}{
  2118. "patient": patient,
  2119. "number": ele.Data.EcToken,
  2120. })
  2121. }
  2122. } else {
  2123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2124. return
  2125. }
  2126. }
  2127. break
  2128. }
  2129. }
  2130. var initFlag int64 = 0
  2131. func (c *HisApiController) TestGetBasBaseInit() {
  2132. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2133. Iinit := DllDef.MustFindProc("Init")
  2134. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2135. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  2136. if ret != 0 {
  2137. fmt.Println("SSCard的报错原因:", err)
  2138. fmt.Println("SSCard的运算结果为:", ret)
  2139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2140. return
  2141. }
  2142. result := int(ret)
  2143. fmt.Println("SSCard的运算结果为1:", result)
  2144. initFlag = 1
  2145. return
  2146. }
  2147. func (c *HisApiController) GetSFZBaseInfo() string {
  2148. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2149. readCard := DllDef.MustFindProc("ReadSFZ")
  2150. if readCard == nil {
  2151. fmt.Println("readcard is nil")
  2152. readCard = DllDef.MustFindProc("ReadSFZ")
  2153. }
  2154. str := make([]byte, 256)
  2155. str1 := make([]byte, 256)
  2156. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2157. fmt.Println(r)
  2158. return string(str)
  2159. }
  2160. func (c *HisApiController) GetBasBaseInfo() string {
  2161. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2162. readCard := DllDef.MustFindProc("ReadCardBas")
  2163. if readCard == nil {
  2164. fmt.Println("readcard is nil")
  2165. readCard = DllDef.MustFindProc("ReadCardBas")
  2166. }
  2167. str := make([]byte, 1024)
  2168. str1 := make([]byte, 1024)
  2169. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2170. fmt.Println(string(str1))
  2171. fmt.Println(string(str))
  2172. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2173. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2174. if ret2 != 0 {
  2175. return ""
  2176. }
  2177. return string(str)
  2178. }
  2179. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  2180. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2181. readCard := DllDef.MustFindProc("read_cardinfo")
  2182. if readCard == nil {
  2183. fmt.Println("readcard is nil")
  2184. readCard = DllDef.MustFindProc("read_cardinfo")
  2185. }
  2186. str := make([]byte, 1024) //卡号
  2187. str1 := make([]byte, 1024) //卡识别码
  2188. str2 := make([]byte, 1024) //身份证号
  2189. str3 := make([]byte, 1024) //姓名
  2190. str4 := make([]byte, 1024) //错误信息
  2191. 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])))
  2192. fmt.Println(string(str1))
  2193. fmt.Println(string(str))
  2194. fmt.Println(string(str2))
  2195. fmt.Println(string(str3))
  2196. fmt.Println(string(str4))
  2197. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2198. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2199. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  2200. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  2201. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  2202. if ret2 != 0 {
  2203. return "", "", "", "", ""
  2204. }
  2205. return string(str), string(str1), string(str2), string(str3), string(str4)
  2206. }
  2207. type CustomFundPay struct {
  2208. FundPayType string `json:"fund_pay_type"`
  2209. FundPayamt float64 `json:"fund_payamt"`
  2210. }
  2211. func (c *HisApiController) GetSettleList() {
  2212. order_id, _ := c.GetInt64("order_id")
  2213. admin_user_id, _ := c.GetInt64("admin_user_id")
  2214. order, _ := service.GetHisOrderByIDTwo(order_id)
  2215. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2216. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2217. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2218. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2219. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2220. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2221. if order.ID == 0 {
  2222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2223. return
  2224. }
  2225. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2226. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2227. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2228. fmt.Println(count)
  2229. var zero string
  2230. number := count + 1
  2231. if number >= 1000 {
  2232. zero = "0000" + strconv.FormatInt(number, 10)
  2233. } else if number >= 10000 {
  2234. zero = "000" + strconv.FormatInt(number, 10)
  2235. } else if number >= 100000 {
  2236. zero = "00" + strconv.FormatInt(number, 10)
  2237. } else if number >= 1000000 {
  2238. zero = "0" + strconv.FormatInt(number, 10)
  2239. } else {
  2240. zero = strconv.FormatInt(number, 10)
  2241. }
  2242. fmt.Println(zero)
  2243. struct4101 := service.Struct4101{
  2244. PsnNo: order.PsnNo,
  2245. MdtrtId: order.MdtrtId,
  2246. SetlId: order.SetlId,
  2247. PsnName: order.PsnName,
  2248. Gend: order.Gend,
  2249. Brdy: his.Brdy,
  2250. Age: his.Age,
  2251. Naty: order.Naty,
  2252. PatnCertType: "01",
  2253. Certno: order.Certno,
  2254. Prfs: "90",
  2255. ConerName: roles[0].UserName,
  2256. PatnRlts: "99",
  2257. ConerAddr: miConfig.OrgName,
  2258. ConerTel: admin.Mobile,
  2259. HiType: order.Insutype,
  2260. Insuplc: miConfig.InsuplcAdmdvs,
  2261. MaindiagFlag: "1",
  2262. BillCode: last_order.FaPiaoCode,
  2263. BillNo: zero,
  2264. BizSn: order.Number,
  2265. PsnSelfPay: order.PsnPartAmt,
  2266. PsnOwnPay: order.PsnPartAmt,
  2267. AcctPay: order.AcctPay,
  2268. PsnCashpay: order.PsnCashPay,
  2269. HiPaymtd: "1",
  2270. Hsorg: miConfig.InsuplcAdmdvs,
  2271. HsorgOpter: miConfig.InsuplcAdmdvs,
  2272. MedinsFillPsn: curRoles.UserName,
  2273. MedinsFillDept: depart.Name,
  2274. IptMedType: "2",
  2275. }
  2276. struct4101.SetlBegnDate = order.SetlTime
  2277. struct4101.SetlEndDate = order.SetlTime
  2278. time_arr := strings.Split(order.SetlTime, " ")
  2279. struct4101.AdmTime = time_arr[0]
  2280. struct4101.AdmEndTime = time_arr[0]
  2281. var rf []CustomFundPay
  2282. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2283. var tempFunPays []service.CustomStruct
  2284. for _, item := range rf {
  2285. var tempFunPay service.CustomStruct
  2286. tempFunPay.FundPayamt = item.FundPayamt
  2287. tempFunPay.FundPayType = item.FundPayType
  2288. tempFunPays = append(tempFunPays, tempFunPay)
  2289. }
  2290. struct4101.CustomStruct = tempFunPays
  2291. var tempDiaginfos []service.DiaginfoStructTwo
  2292. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2293. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2294. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2295. var config []*models.HisXtDiagnoseConfig
  2296. for _, item := range diagnosis_ids {
  2297. id, _ := strconv.ParseInt(item, 10, 64)
  2298. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2299. config = append(config, &diagnosisConfig)
  2300. }
  2301. for index, item := range config {
  2302. if index == 0 {
  2303. var tempDiaginfo service.DiaginfoStructTwo
  2304. tempDiaginfo.DiagCode = item.CountryCode
  2305. tempDiaginfo.DiagName = item.CountryContentName
  2306. tempDiaginfo.DiagType = "1"
  2307. tempDiaginfo.MaindiagFlag = "1"
  2308. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2309. } else {
  2310. var tempDiaginfo service.DiaginfoStructTwo
  2311. tempDiaginfo.DiagCode = item.CountryCode
  2312. tempDiaginfo.DiagName = item.CountryContentName
  2313. tempDiaginfo.DiagType = "2"
  2314. tempDiaginfo.MaindiagFlag = "0"
  2315. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2316. }
  2317. }
  2318. struct4101.Diseinfo = tempDiaginfos
  2319. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2320. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2321. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2322. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2323. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2324. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2325. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2326. var iteminfo service.IteminfoStruct
  2327. var bedCostTotal float64 = 0 //床位总费
  2328. var bedCostSelfTotal float64 = 0 //床位自费
  2329. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2330. var operationCostTotal float64 = 0 //手术费
  2331. var operationCostSelfTotal float64 = 0 //手术费
  2332. var operationCostPartSelfTotal float64 = 0 //手术费
  2333. var otherCostTotal float64 = 0 //其他费用
  2334. var otherCostSelfTotal float64 = 0 //其他费用
  2335. var otherCostPartSelfTotal float64 = 0 //其他费用
  2336. var materialCostTotal float64 = 0 //材料费
  2337. var materialCostSelfTotal float64 = 0 //材料费
  2338. var materialCostPartSelfTotal float64 = 0 //材料费
  2339. var westernMedicineCostTotal float64 = 0 //西药费
  2340. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2341. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2342. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2343. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2344. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2345. var checkCostTotal float64 = 0 //检查费
  2346. var checkCostSelfTotal float64 = 0 //检查费
  2347. var checkCostPartSelfTotal float64 = 0 //检查费
  2348. var laboratoryCostTotal float64 = 0 //化验费
  2349. var laboratoryCostSelfTotal float64 = 0 //化验费
  2350. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2351. var treatCostTotal float64 = 0 //治疗费用
  2352. var treatCostSelfTotal float64 = 0 //治疗费用
  2353. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2354. decimal.DivisionPrecision = 2
  2355. var bed_fulamt_ownpay_amt float64 = 0
  2356. var operation_fulamt_ownpay_amt float64 = 0
  2357. var other_fulamt_ownpay_amt float64 = 0
  2358. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2359. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2360. var check_fulamt_ownpay_amt float64 = 0
  2361. var material_fulamt_ownpay_amt float64 = 0
  2362. var laboratory_fulamt_ownpay_amt float64 = 0
  2363. var treat_fulamt_ownpay_amt float64 = 0
  2364. var bed_claa_sunmfee float64 = 0
  2365. var bed_clab_amt float64 = 0
  2366. var bed_other_amt float64 = 0
  2367. var operation_claa_sunmfee float64 = 0
  2368. var operation_clab_amt float64 = 0
  2369. var operation_other_amt float64 = 0
  2370. var other_claa_sunmfee float64 = 0
  2371. var other_clab_amt float64 = 0
  2372. var other_other_amt float64 = 0
  2373. var westernMedicine_claa_sunmfee float64 = 0
  2374. var westernMedicine_clab_amt float64 = 0
  2375. var westernMedicine_other_amt float64 = 0
  2376. var chineseTraditional_claa_sunmfee float64 = 0
  2377. var chineseTraditional_clab_amt float64 = 0
  2378. var chineseTraditional_other_amt float64 = 0
  2379. var check_claa_sunmfee float64 = 0
  2380. var check_clab_amt float64 = 0
  2381. var check_other_amt float64 = 0
  2382. var material_claa_sunmfee float64 = 0
  2383. var material_clab_amt float64 = 0
  2384. var material_other_amt float64 = 0
  2385. var laboratory_claa_sunmfee float64 = 0
  2386. var laboratory_clab_amt float64 = 0
  2387. var laboratory_other_amt float64 = 0
  2388. var treat_claa_sunmfee float64 = 0
  2389. var treat_clab_amt float64 = 0
  2390. var treat_other_amt float64 = 0
  2391. for _, item := range order.HisOrderInfo {
  2392. if item.MedChrgitmType == "01" { //床位费
  2393. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2394. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2395. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2396. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2397. if item.ChrgitmLv == "1" {
  2398. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2399. }
  2400. if item.ChrgitmLv == "2" {
  2401. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2402. }
  2403. if item.ChrgitmLv == "3" {
  2404. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2405. }
  2406. }
  2407. if item.MedChrgitmType == "03" { //检查费
  2408. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2409. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2410. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2411. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2412. if item.ChrgitmLv == "1" {
  2413. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2414. }
  2415. if item.ChrgitmLv == "2" {
  2416. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2417. }
  2418. if item.ChrgitmLv == "3" {
  2419. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2420. }
  2421. }
  2422. if item.MedChrgitmType == "04" { //化验费
  2423. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2424. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2425. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2426. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2427. if item.ChrgitmLv == "1" {
  2428. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2429. }
  2430. if item.ChrgitmLv == "2" {
  2431. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2432. }
  2433. if item.ChrgitmLv == "3" {
  2434. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2435. }
  2436. }
  2437. if item.MedChrgitmType == "05" { //治疗费
  2438. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2439. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2440. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2441. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2442. if item.ChrgitmLv == "1" {
  2443. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2444. }
  2445. if item.ChrgitmLv == "2" {
  2446. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2447. }
  2448. if item.ChrgitmLv == "3" {
  2449. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2450. }
  2451. }
  2452. if item.MedChrgitmType == "06" { //手术费
  2453. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2454. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2455. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2456. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2457. if item.ChrgitmLv == "1" {
  2458. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2459. }
  2460. if item.ChrgitmLv == "2" {
  2461. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2462. }
  2463. if item.ChrgitmLv == "3" {
  2464. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2465. }
  2466. }
  2467. if item.MedChrgitmType == "08" { //材料费
  2468. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2469. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2470. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2471. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2472. if item.ChrgitmLv == "1" {
  2473. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2474. }
  2475. if item.ChrgitmLv == "2" {
  2476. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2477. }
  2478. if item.ChrgitmLv == "3" {
  2479. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2480. }
  2481. }
  2482. if item.MedChrgitmType == "09" { //西药费
  2483. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2484. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2485. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2486. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2487. if item.ChrgitmLv == "1" {
  2488. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2489. }
  2490. if item.ChrgitmLv == "2" {
  2491. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2492. }
  2493. if item.ChrgitmLv == "3" {
  2494. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2495. }
  2496. }
  2497. if item.MedChrgitmType == "11" { //中成费
  2498. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2499. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2500. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2501. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2502. if item.ChrgitmLv == "1" {
  2503. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2504. }
  2505. if item.ChrgitmLv == "2" {
  2506. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2507. }
  2508. if item.ChrgitmLv == "3" {
  2509. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2510. }
  2511. }
  2512. if item.MedChrgitmType == "14" { //其他费
  2513. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2514. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2515. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2516. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2517. if item.ChrgitmLv == "1" {
  2518. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2519. }
  2520. if item.ChrgitmLv == "2" {
  2521. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2522. }
  2523. if item.ChrgitmLv == "3" {
  2524. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2525. }
  2526. }
  2527. }
  2528. var iteminfoStructs []service.IteminfoStruct
  2529. if bedCostTotal != 0 {
  2530. iteminfo.MedChrgitm = "01"
  2531. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2532. iteminfo.Amt = bedCostTotal
  2533. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2534. iteminfo.ClabAmt = bed_clab_amt
  2535. iteminfo.OthAmt = bed_other_amt
  2536. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2537. }
  2538. if checkCostTotal != 0 {
  2539. iteminfo.MedChrgitm = "03"
  2540. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2541. iteminfo.Amt = checkCostTotal
  2542. iteminfo.ClaaSumfee = check_claa_sunmfee
  2543. iteminfo.ClabAmt = check_clab_amt
  2544. iteminfo.OthAmt = check_other_amt
  2545. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2546. }
  2547. if laboratoryCostTotal != 0 {
  2548. iteminfo.MedChrgitm = "04"
  2549. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2550. iteminfo.Amt = laboratoryCostTotal
  2551. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2552. iteminfo.ClabAmt = laboratory_clab_amt
  2553. iteminfo.OthAmt = laboratory_other_amt
  2554. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2555. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2556. }
  2557. if treatCostTotal != 0 {
  2558. iteminfo.MedChrgitm = "05"
  2559. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2560. iteminfo.Amt = treatCostTotal
  2561. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2562. iteminfo.ClabAmt = treat_clab_amt
  2563. iteminfo.OthAmt = treat_other_amt
  2564. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2565. //(struct4101.IteminfoStruct, iteminfo)
  2566. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2567. }
  2568. if operationCostTotal != 0 {
  2569. iteminfo.MedChrgitm = "06"
  2570. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2571. iteminfo.Amt = operationCostTotal
  2572. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2573. iteminfo.ClabAmt = operation_clab_amt
  2574. iteminfo.OthAmt = operation_other_amt
  2575. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2576. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2577. }
  2578. if materialCostTotal != 0 {
  2579. iteminfo.MedChrgitm = "08"
  2580. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2581. iteminfo.Amt = materialCostTotal
  2582. iteminfo.ClaaSumfee = material_claa_sunmfee
  2583. iteminfo.ClabAmt = material_clab_amt
  2584. iteminfo.OthAmt = material_other_amt
  2585. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2586. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2587. }
  2588. if westernMedicineCostTotal != 0 {
  2589. iteminfo.MedChrgitm = "09"
  2590. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2591. iteminfo.Amt = westernMedicineCostTotal
  2592. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2593. iteminfo.ClabAmt = westernMedicine_clab_amt
  2594. iteminfo.OthAmt = westernMedicine_other_amt
  2595. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2596. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2597. }
  2598. if chineseTraditionalMedicineCostTotal != 0 {
  2599. iteminfo.MedChrgitm = "11"
  2600. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2601. iteminfo.Amt = westernMedicineCostTotal
  2602. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2603. iteminfo.ClabAmt = westernMedicine_clab_amt
  2604. iteminfo.OthAmt = westernMedicine_other_amt
  2605. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2606. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2607. }
  2608. if otherCostTotal != 0 {
  2609. iteminfo.MedChrgitm = "14"
  2610. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2611. iteminfo.Amt = otherCostTotal
  2612. iteminfo.ClaaSumfee = other_claa_sunmfee
  2613. iteminfo.ClabAmt = other_clab_amt
  2614. iteminfo.OthAmt = other_other_amt
  2615. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2616. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2617. }
  2618. struct4101.IteminfoStruct = iteminfoStructs
  2619. struct4101.Ntly = "中国"
  2620. struct4101.AdmCaty = "A03.06"
  2621. var res ResultSeventeen
  2622. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2623. var resOther ResultSeventeenOther
  2624. var pp models.PublicParams
  2625. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2626. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2627. pp.FixmedinsName = miConfig.OrgName
  2628. pp.FixmedinsCode = miConfig.Code
  2629. pp.RequestUrl = miConfig.Url
  2630. pp.Cainfo = miConfig.Cainfo
  2631. pp.SecretKey = miConfig.SecretKey
  2632. pp.AccessKey = miConfig.AccessKey
  2633. pp.OpterName = curRoles.UserName
  2634. client := &http.Client{}
  2635. var req *http.Request
  2636. data := make(map[string]interface{})
  2637. data["struct4101"] = struct4101
  2638. data["pp"] = pp
  2639. bytesData, _ := json.Marshal(data)
  2640. if miConfig.MdtrtareaAdmvs == "320921" {
  2641. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2642. } else {
  2643. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2644. }
  2645. resp, _ := client.Do(req)
  2646. defer resp.Body.Close()
  2647. body, ioErr := ioutil.ReadAll(resp.Body)
  2648. if ioErr != nil {
  2649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2651. return
  2652. }
  2653. var respJSON map[string]interface{}
  2654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2657. return
  2658. }
  2659. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2660. userJSONBytes, _ := json.Marshal(respJSON)
  2661. fmt.Println("log")
  2662. fmt.Println(string(userJSONBytes))
  2663. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2664. utils.ErrorLog("解析失败:%v", err)
  2665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2666. return
  2667. }
  2668. res.InfRefmsgid = resOther.InfRefmsgid
  2669. res.Output = resOther.Output
  2670. res.ErrMsg = resOther.ErrMsg
  2671. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2672. res.Infcode = infocode
  2673. } else {
  2674. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2675. var dat map[string]interface{}
  2676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2677. fmt.Println(dat)
  2678. } else {
  2679. fmt.Println(err)
  2680. }
  2681. userJSONBytes, _ := json.Marshal(dat)
  2682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2683. utils.ErrorLog("解析失败:%v", err)
  2684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2685. return
  2686. }
  2687. }
  2688. if res.Infcode != 0 {
  2689. c.ServeSuccessJSON(map[string]interface{}{
  2690. "failed_code": -10,
  2691. "msg": res.ErrMsg,
  2692. })
  2693. return
  2694. } else {
  2695. order.FaPiaoNumber = zero
  2696. order.FaPiaoCode = last_order.FaPiaoCode
  2697. service.UpdateOrder(order)
  2698. hisFundSettleListResult := &models.HisFundSettleListResult{
  2699. Number: res.Output.SetlListId,
  2700. Status: 1,
  2701. Ctime: time.Now().Unix(),
  2702. Mtime: time.Now().Unix(),
  2703. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2704. IsUpload: 1,
  2705. OrderId: order_id,
  2706. }
  2707. service.CreateUploadRecord(hisFundSettleListResult)
  2708. c.ServeSuccessJSON(map[string]interface{}{
  2709. "msg": "上传成功",
  2710. "result": hisFundSettleListResult,
  2711. })
  2712. return
  2713. }
  2714. }
  2715. func (c *HisApiController) GetSettleListHospital() {
  2716. order_id, _ := c.GetInt64("order_id")
  2717. admin_user_id, _ := c.GetInt64("admin_user_id")
  2718. order, _ := service.GetHisOrderByIDTwo(order_id)
  2719. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2720. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2721. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2722. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2723. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2724. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2725. if order.ID == 0 {
  2726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2727. return
  2728. }
  2729. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2730. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2731. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2732. fmt.Println(count)
  2733. var zero string
  2734. number := count + 1
  2735. if number >= 1000 {
  2736. zero = "0000" + strconv.FormatInt(number, 10)
  2737. } else if number >= 10000 {
  2738. zero = "000" + strconv.FormatInt(number, 10)
  2739. } else if number >= 100000 {
  2740. zero = "00" + strconv.FormatInt(number, 10)
  2741. } else if number >= 1000000 {
  2742. zero = "0" + strconv.FormatInt(number, 10)
  2743. } else {
  2744. zero = strconv.FormatInt(number, 10)
  2745. }
  2746. fmt.Println(zero)
  2747. struct4101 := service.Struct4101{
  2748. PsnNo: order.PsnNo,
  2749. MdtrtId: order.MdtrtId,
  2750. SetlId: order.SetlId,
  2751. PsnName: order.PsnName,
  2752. Gend: order.Gend,
  2753. Brdy: his.Brdy,
  2754. Age: int64(order.Age),
  2755. Naty: order.Naty,
  2756. PatnCertType: "01",
  2757. Certno: order.Certno,
  2758. Prfs: "90",
  2759. ConerName: roles[0].UserName,
  2760. PatnRlts: "99",
  2761. ConerAddr: miConfig.OrgName,
  2762. ConerTel: admin.Mobile,
  2763. HiType: order.Insutype,
  2764. Insuplc: miConfig.InsuplcAdmdvs,
  2765. MaindiagFlag: "1",
  2766. BillCode: last_order.FaPiaoCode,
  2767. BillNo: zero,
  2768. BizSn: order.Number,
  2769. PsnSelfPay: order.PsnPartAmt,
  2770. PsnOwnPay: order.PsnPartAmt,
  2771. AcctPay: order.AcctPay,
  2772. PsnCashpay: order.PsnCashPay,
  2773. HiPaymtd: "1",
  2774. Hsorg: miConfig.InsuplcAdmdvs,
  2775. HsorgOpter: miConfig.InsuplcAdmdvs,
  2776. MedinsFillPsn: curRoles.UserName,
  2777. MedinsFillDept: depart.Name,
  2778. IptMedType: "2",
  2779. AdmTime: his.InHosptialTime,
  2780. AdmEndTime: his.OutHosptialTime,
  2781. }
  2782. struct4101.SetlBegnDate = order.SetlTime
  2783. struct4101.SetlEndDate = order.SetlTime
  2784. var rf []CustomFundPay
  2785. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2786. var tempFunPays []service.CustomStruct
  2787. for _, item := range rf {
  2788. var tempFunPay service.CustomStruct
  2789. tempFunPay.FundPayamt = item.FundPayamt
  2790. tempFunPay.FundPayType = item.FundPayType
  2791. tempFunPays = append(tempFunPays, tempFunPay)
  2792. }
  2793. struct4101.CustomStruct = tempFunPays
  2794. var tempDiaginfos []service.DiaginfoStructTwo
  2795. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2796. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2797. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2798. var config []*models.HisXtDiagnoseConfig
  2799. for _, item := range diagnosis_ids {
  2800. id, _ := strconv.ParseInt(item, 10, 64)
  2801. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2802. config = append(config, &diagnosisConfig)
  2803. }
  2804. for index, item := range config {
  2805. if index == 0 {
  2806. var tempDiaginfo service.DiaginfoStructTwo
  2807. tempDiaginfo.DiagCode = item.CountryCode
  2808. tempDiaginfo.DiagName = item.CountryContentName
  2809. tempDiaginfo.DiagType = "1"
  2810. tempDiaginfo.MaindiagFlag = "1"
  2811. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2812. } else {
  2813. var tempDiaginfo service.DiaginfoStructTwo
  2814. tempDiaginfo.DiagCode = item.CountryCode
  2815. tempDiaginfo.DiagName = item.CountryContentName
  2816. tempDiaginfo.DiagType = "2"
  2817. tempDiaginfo.MaindiagFlag = "0"
  2818. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2819. }
  2820. }
  2821. struct4101.Diseinfo = tempDiaginfos
  2822. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2823. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2824. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2825. tempOpspdiseinfo2.OprnOprtCode = ""
  2826. tempOpspdiseinfo2.OprnOprtName = ""
  2827. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2828. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2829. var iteminfo service.IteminfoStruct
  2830. var bedCostTotal float64 = 0 //床位总费
  2831. var bedCostSelfTotal float64 = 0 //床位自费
  2832. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2833. var operationCostTotal float64 = 0 //手术费
  2834. var operationCostSelfTotal float64 = 0 //手术费
  2835. var operationCostPartSelfTotal float64 = 0 //手术费
  2836. var otherCostTotal float64 = 0 //其他费用
  2837. var otherCostSelfTotal float64 = 0 //其他费用
  2838. var otherCostPartSelfTotal float64 = 0 //其他费用
  2839. var materialCostTotal float64 = 0 //材料费
  2840. var materialCostSelfTotal float64 = 0 //材料费
  2841. var materialCostPartSelfTotal float64 = 0 //材料费
  2842. var westernMedicineCostTotal float64 = 0 //西药费
  2843. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2844. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2845. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2846. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2847. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2848. var checkCostTotal float64 = 0 //检查费
  2849. var checkCostSelfTotal float64 = 0 //检查费
  2850. var checkCostPartSelfTotal float64 = 0 //检查费
  2851. var laboratoryCostTotal float64 = 0 //化验费
  2852. var laboratoryCostSelfTotal float64 = 0 //化验费
  2853. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2854. var treatCostTotal float64 = 0 //治疗费用
  2855. var treatCostSelfTotal float64 = 0 //治疗费用
  2856. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2857. decimal.DivisionPrecision = 2
  2858. var bed_fulamt_ownpay_amt float64 = 0
  2859. var operation_fulamt_ownpay_amt float64 = 0
  2860. var other_fulamt_ownpay_amt float64 = 0
  2861. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2862. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2863. var check_fulamt_ownpay_amt float64 = 0
  2864. var material_fulamt_ownpay_amt float64 = 0
  2865. var laboratory_fulamt_ownpay_amt float64 = 0
  2866. var treat_fulamt_ownpay_amt float64 = 0
  2867. var bed_claa_sunmfee float64 = 0
  2868. var bed_clab_amt float64 = 0
  2869. var bed_other_amt float64 = 0
  2870. var operation_claa_sunmfee float64 = 0
  2871. var operation_clab_amt float64 = 0
  2872. var operation_other_amt float64 = 0
  2873. var other_claa_sunmfee float64 = 0
  2874. var other_clab_amt float64 = 0
  2875. var other_other_amt float64 = 0
  2876. var westernMedicine_claa_sunmfee float64 = 0
  2877. var westernMedicine_clab_amt float64 = 0
  2878. var westernMedicine_other_amt float64 = 0
  2879. var chineseTraditional_claa_sunmfee float64 = 0
  2880. var chineseTraditional_clab_amt float64 = 0
  2881. var chineseTraditional_other_amt float64 = 0
  2882. var check_claa_sunmfee float64 = 0
  2883. var check_clab_amt float64 = 0
  2884. var check_other_amt float64 = 0
  2885. var material_claa_sunmfee float64 = 0
  2886. var material_clab_amt float64 = 0
  2887. var material_other_amt float64 = 0
  2888. var laboratory_claa_sunmfee float64 = 0
  2889. var laboratory_clab_amt float64 = 0
  2890. var laboratory_other_amt float64 = 0
  2891. var treat_claa_sunmfee float64 = 0
  2892. var treat_clab_amt float64 = 0
  2893. var treat_other_amt float64 = 0
  2894. for _, item := range order.HisOrderInfo {
  2895. if item.MedChrgitmType == "01" { //床位费
  2896. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2897. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2898. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2899. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2900. if item.ChrgitmLv == "1" {
  2901. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2902. }
  2903. if item.ChrgitmLv == "2" {
  2904. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2905. }
  2906. if item.ChrgitmLv == "3" {
  2907. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2908. }
  2909. }
  2910. if item.MedChrgitmType == "03" { //检查费
  2911. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2912. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2913. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2914. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2915. if item.ChrgitmLv == "1" {
  2916. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2917. }
  2918. if item.ChrgitmLv == "2" {
  2919. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2920. }
  2921. if item.ChrgitmLv == "3" {
  2922. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2923. }
  2924. }
  2925. if item.MedChrgitmType == "04" { //化验费
  2926. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2927. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2928. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2929. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2930. if item.ChrgitmLv == "1" {
  2931. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2932. }
  2933. if item.ChrgitmLv == "2" {
  2934. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2935. }
  2936. if item.ChrgitmLv == "3" {
  2937. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2938. }
  2939. }
  2940. if item.MedChrgitmType == "05" { //治疗费
  2941. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2942. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2943. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2944. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2945. if item.ChrgitmLv == "1" {
  2946. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2947. }
  2948. if item.ChrgitmLv == "2" {
  2949. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2950. }
  2951. if item.ChrgitmLv == "3" {
  2952. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2953. }
  2954. }
  2955. if item.MedChrgitmType == "06" { //手术费
  2956. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2957. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2958. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2959. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2960. if item.ChrgitmLv == "1" {
  2961. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2962. }
  2963. if item.ChrgitmLv == "2" {
  2964. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2965. }
  2966. if item.ChrgitmLv == "3" {
  2967. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2968. }
  2969. }
  2970. if item.MedChrgitmType == "08" { //材料费
  2971. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2972. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2973. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2974. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2975. if item.ChrgitmLv == "1" {
  2976. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2977. }
  2978. if item.ChrgitmLv == "2" {
  2979. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2980. }
  2981. if item.ChrgitmLv == "3" {
  2982. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2983. }
  2984. }
  2985. if item.MedChrgitmType == "09" { //西药费
  2986. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2987. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2988. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2989. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2990. if item.ChrgitmLv == "1" {
  2991. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2992. }
  2993. if item.ChrgitmLv == "2" {
  2994. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2995. }
  2996. if item.ChrgitmLv == "3" {
  2997. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2998. }
  2999. }
  3000. if item.MedChrgitmType == "11" { //中成费
  3001. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3002. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3003. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3004. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3005. if item.ChrgitmLv == "1" {
  3006. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3007. }
  3008. if item.ChrgitmLv == "2" {
  3009. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3010. }
  3011. if item.ChrgitmLv == "3" {
  3012. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3013. }
  3014. }
  3015. if item.MedChrgitmType == "14" { //其他费
  3016. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3017. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3018. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3019. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3020. if item.ChrgitmLv == "1" {
  3021. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3022. }
  3023. if item.ChrgitmLv == "2" {
  3024. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3025. }
  3026. if item.ChrgitmLv == "3" {
  3027. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3028. }
  3029. }
  3030. }
  3031. var iteminfoStructs []service.IteminfoStruct
  3032. if bedCostTotal != 0 {
  3033. iteminfo.MedChrgitm = "01"
  3034. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3035. iteminfo.Amt = bedCostTotal
  3036. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3037. iteminfo.ClabAmt = bed_clab_amt
  3038. iteminfo.OthAmt = bed_other_amt
  3039. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3040. }
  3041. if checkCostTotal != 0 {
  3042. iteminfo.MedChrgitm = "03"
  3043. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3044. iteminfo.Amt = checkCostTotal
  3045. iteminfo.ClaaSumfee = check_claa_sunmfee
  3046. iteminfo.ClabAmt = check_clab_amt
  3047. iteminfo.OthAmt = check_other_amt
  3048. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3049. }
  3050. if laboratoryCostTotal != 0 {
  3051. iteminfo.MedChrgitm = "04"
  3052. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3053. iteminfo.Amt = laboratoryCostTotal
  3054. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3055. iteminfo.ClabAmt = laboratory_clab_amt
  3056. iteminfo.OthAmt = laboratory_other_amt
  3057. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3058. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3059. }
  3060. if treatCostTotal != 0 {
  3061. iteminfo.MedChrgitm = "05"
  3062. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3063. iteminfo.Amt = treatCostTotal
  3064. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3065. iteminfo.ClabAmt = treat_clab_amt
  3066. iteminfo.OthAmt = treat_other_amt
  3067. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3068. //(struct4101.IteminfoStruct, iteminfo)
  3069. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3070. }
  3071. if operationCostTotal != 0 {
  3072. iteminfo.MedChrgitm = "06"
  3073. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3074. iteminfo.Amt = operationCostTotal
  3075. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3076. iteminfo.ClabAmt = operation_clab_amt
  3077. iteminfo.OthAmt = operation_other_amt
  3078. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3079. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3080. }
  3081. if materialCostTotal != 0 {
  3082. iteminfo.MedChrgitm = "08"
  3083. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3084. iteminfo.Amt = materialCostTotal
  3085. iteminfo.ClaaSumfee = material_claa_sunmfee
  3086. iteminfo.ClabAmt = material_clab_amt
  3087. iteminfo.OthAmt = material_other_amt
  3088. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3089. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3090. }
  3091. if westernMedicineCostTotal != 0 {
  3092. iteminfo.MedChrgitm = "09"
  3093. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3094. iteminfo.Amt = westernMedicineCostTotal
  3095. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3096. iteminfo.ClabAmt = westernMedicine_clab_amt
  3097. iteminfo.OthAmt = westernMedicine_other_amt
  3098. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3099. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3100. }
  3101. if chineseTraditionalMedicineCostTotal != 0 {
  3102. iteminfo.MedChrgitm = "11"
  3103. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3104. iteminfo.Amt = westernMedicineCostTotal
  3105. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3106. iteminfo.ClabAmt = westernMedicine_clab_amt
  3107. iteminfo.OthAmt = westernMedicine_other_amt
  3108. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3109. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3110. }
  3111. if otherCostTotal != 0 {
  3112. iteminfo.MedChrgitm = "14"
  3113. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3114. iteminfo.Amt = otherCostTotal
  3115. iteminfo.ClaaSumfee = other_claa_sunmfee
  3116. iteminfo.ClabAmt = other_clab_amt
  3117. iteminfo.OthAmt = other_other_amt
  3118. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3119. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3120. }
  3121. struct4101.IteminfoStruct = iteminfoStructs
  3122. struct4101.Ntly = "中国"
  3123. struct4101.AdmCaty = "A03.06"
  3124. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3125. fmt.Println(result)
  3126. var dat map[string]interface{}
  3127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3128. fmt.Println(dat)
  3129. } else {
  3130. fmt.Println(err)
  3131. }
  3132. userJSONBytes, _ := json.Marshal(dat)
  3133. var res ResultSeventeen
  3134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3135. utils.ErrorLog("解析失败:%v", err)
  3136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3137. return
  3138. }
  3139. if res.Infcode != 0 {
  3140. c.ServeSuccessJSON(map[string]interface{}{
  3141. "failed_code": -10,
  3142. "msg": res.ErrMsg,
  3143. })
  3144. return
  3145. } else {
  3146. order.FaPiaoNumber = zero
  3147. order.FaPiaoCode = last_order.FaPiaoCode
  3148. service.UpdateOrder(order)
  3149. hisFundSettleListResult := &models.HisFundSettleListResult{
  3150. Number: res.Output.SetlListId,
  3151. Status: 1,
  3152. Ctime: time.Now().Unix(),
  3153. Mtime: time.Now().Unix(),
  3154. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3155. IsUpload: 1,
  3156. OrderId: order_id,
  3157. }
  3158. service.CreateUploadRecord(hisFundSettleListResult)
  3159. c.ServeSuccessJSON(map[string]interface{}{
  3160. "msg": "上传成功",
  3161. "result": hisFundSettleListResult,
  3162. })
  3163. return
  3164. }
  3165. }
  3166. func (c *HisApiController) GetBatchSettleList() {
  3167. orders, _ := service.GetAllHisOrder(10138)
  3168. for _, item := range orders {
  3169. order_id := item.ID
  3170. order, _ := service.GetHisOrderByIDTwo(order_id)
  3171. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3172. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3173. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3174. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  3175. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3176. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3177. if order.ID == 0 {
  3178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3179. return
  3180. }
  3181. if his.BalanceAccountsType == 2 {
  3182. continue
  3183. }
  3184. struct4101 := service.Struct4101{
  3185. PsnNo: order.PsnNo,
  3186. MdtrtId: order.MdtrtId,
  3187. SetlId: order.SetlId,
  3188. PsnName: order.PsnName,
  3189. Gend: order.Gend,
  3190. Brdy: his.Brdy,
  3191. Age: his.Age,
  3192. Naty: order.Naty,
  3193. PatnCertType: "01",
  3194. Certno: order.Certno,
  3195. Prfs: "90",
  3196. ConerName: roles[0].UserName,
  3197. PatnRlts: "99",
  3198. ConerAddr: miConfig.OrgName,
  3199. ConerTel: admin.Mobile,
  3200. HiType: order.Insutype,
  3201. Insuplc: his.InsuplcAdmdvs,
  3202. MaindiagFlag: "1",
  3203. BillCode: order.FaPiaoCode,
  3204. BillNo: order.FaPiaoNumber,
  3205. BizSn: order.Number,
  3206. PsnSelfPay: order.PsnPartAmt,
  3207. PsnOwnPay: order.PsnPartAmt,
  3208. AcctPay: order.AcctPay,
  3209. PsnCashpay: order.PsnCashPay,
  3210. HiPaymtd: "1",
  3211. Hsorg: his.InsuplcAdmdvs,
  3212. HsorgOpter: his.InsuplcAdmdvs,
  3213. MedinsFillPsn: curRoles.UserName,
  3214. MedinsFillDept: depart.Name,
  3215. IptMedType: "2",
  3216. }
  3217. struct4101.SetlBegnDate = order.SetlTime
  3218. struct4101.SetlEndDate = order.SetlTime
  3219. //if order.SettleType == 1 {
  3220. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  3221. // dateStr := t.Format("2006-01-02")
  3222. // struct4101.SetlBegnDate = dateStr
  3223. // struct4101.SetlEndDate = dateStr
  3224. //} else {
  3225. // t := time.Unix(int64(order.SettleStartTime), 0)
  3226. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  3227. // dateStartStr := t.Format("2006-01-02")
  3228. // dateEndStr := t2.Format("2006-01-02")
  3229. // struct4101.SetlBegnDate = dateStartStr
  3230. // struct4101.SetlEndDate = dateEndStr
  3231. //}
  3232. var rf []CustomFundPay
  3233. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3234. var tempFunPays []service.CustomStruct
  3235. var tempFunPay610100 service.CustomStruct
  3236. for _, item := range rf {
  3237. if item.FundPayType == "610100" {
  3238. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  3239. tempFunPay610100.FundPayType = item.FundPayType
  3240. } else {
  3241. var tempFunPay service.CustomStruct
  3242. tempFunPay.FundPayamt = item.FundPayamt
  3243. tempFunPay.FundPayType = item.FundPayType
  3244. tempFunPays = append(tempFunPays, tempFunPay)
  3245. }
  3246. }
  3247. tempFunPays = append(tempFunPays, tempFunPay610100)
  3248. struct4101.CustomStruct = tempFunPays
  3249. var tempDiaginfos []service.DiaginfoStructTwo
  3250. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3251. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3252. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3253. var config []*models.HisXtDiagnoseConfig
  3254. for _, item := range diagnosis_ids {
  3255. id, _ := strconv.ParseInt(item, 10, 64)
  3256. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3257. config = append(config, &diagnosisConfig)
  3258. }
  3259. for index, item := range config {
  3260. if index == 0 {
  3261. var tempDiaginfo service.DiaginfoStructTwo
  3262. tempDiaginfo.DiagCode = item.CountryCode
  3263. tempDiaginfo.DiagName = item.CountryContentName
  3264. tempDiaginfo.DiagType = "1"
  3265. tempDiaginfo.MaindiagFlag = "1"
  3266. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3267. } else {
  3268. var tempDiaginfo service.DiaginfoStructTwo
  3269. tempDiaginfo.DiagCode = item.CountryCode
  3270. tempDiaginfo.DiagName = item.CountryContentName
  3271. tempDiaginfo.DiagType = "2"
  3272. tempDiaginfo.MaindiagFlag = "0"
  3273. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3274. }
  3275. }
  3276. struct4101.Diseinfo = tempDiaginfos
  3277. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3278. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3279. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3280. tempOpspdiseinfo2.OprnOprtCode = ""
  3281. tempOpspdiseinfo2.OprnOprtName = ""
  3282. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3283. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3284. var iteminfo service.IteminfoStruct
  3285. var bedCostTotal float64 = 0 //床位总费
  3286. var bedCostSelfTotal float64 = 0 //床位自费
  3287. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3288. var examineCostTotal float64 = 0 //诊查总费
  3289. var examineCostSelfTotal float64 = 0 //诊查自费
  3290. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3291. var nursingCostTotal float64 = 0 //护理总费
  3292. var nursingCostSelfTotal float64 = 0 //护理自费
  3293. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3294. var chineseMedicineCostTotal float64 = 0 //中成药
  3295. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3296. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3297. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3298. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3299. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3300. var registerCostTotal float64 = 0 //一般诊疗费
  3301. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3302. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3303. var operationCostTotal float64 = 0 //手术费
  3304. var operationCostSelfTotal float64 = 0 //手术费
  3305. var operationCostPartSelfTotal float64 = 0 //手术费
  3306. var otherCostTotal float64 = 0 //其他费用
  3307. var otherCostSelfTotal float64 = 0 //其他费用
  3308. var otherCostPartSelfTotal float64 = 0 //其他费用
  3309. var materialCostTotal float64 = 0 //材料费
  3310. var materialCostSelfTotal float64 = 0 //材料费
  3311. var materialCostPartSelfTotal float64 = 0 //材料费
  3312. var westernMedicineCostTotal float64 = 0 //西药费
  3313. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3314. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3315. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3316. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3317. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3318. var checkCostTotal float64 = 0 //检查费
  3319. var checkCostSelfTotal float64 = 0 //检查费
  3320. var checkCostPartSelfTotal float64 = 0 //检查费
  3321. var laboratoryCostTotal float64 = 0 //化验费
  3322. var laboratoryCostSelfTotal float64 = 0 //化验费
  3323. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3324. var treatCostTotal float64 = 0 //治疗费用
  3325. var treatCostSelfTotal float64 = 0 //治疗费用
  3326. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3327. decimal.DivisionPrecision = 2
  3328. var bed_fulamt_ownpay_amt float64 = 0
  3329. var examine_fulamt_ownpay_amt float64 = 0
  3330. var nursing_fulamt_ownpay_amt float64 = 0
  3331. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3332. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3333. var register_fulamt_ownpay_amt float64 = 0
  3334. var operation_fulamt_ownpay_amt float64 = 0
  3335. var other_fulamt_ownpay_amt float64 = 0
  3336. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3337. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3338. var check_fulamt_ownpay_amt float64 = 0
  3339. var material_fulamt_ownpay_amt float64 = 0
  3340. var laboratory_fulamt_ownpay_amt float64 = 0
  3341. var treat_fulamt_ownpay_amt float64 = 0
  3342. var bed_claa_sunmfee float64 = 0
  3343. var bed_clab_amt float64 = 0
  3344. var bed_other_amt float64 = 0
  3345. var examine_claa_sunmfee float64 = 0
  3346. var examine_clab_amt float64 = 0
  3347. var examine_other_amt float64 = 0
  3348. var nursing_claa_sunmfee float64 = 0
  3349. var nursing_clab_amt float64 = 0
  3350. var nursing_other_amt float64 = 0
  3351. var chinese_medicine_claa_sunmfee float64 = 0
  3352. var chinese_medicine_clab_amt float64 = 0
  3353. var chinese_medicine_other_amt float64 = 0
  3354. var commonly_treatment_claa_sunmfee float64 = 0
  3355. var commonly_treatment_clab_amt float64 = 0
  3356. var commonly_treatment_other_amt float64 = 0
  3357. var operation_claa_sunmfee float64 = 0
  3358. var operation_clab_amt float64 = 0
  3359. var operation_other_amt float64 = 0
  3360. var other_claa_sunmfee float64 = 0
  3361. var other_clab_amt float64 = 0
  3362. var other_other_amt float64 = 0
  3363. var westernMedicine_claa_sunmfee float64 = 0
  3364. var westernMedicine_clab_amt float64 = 0
  3365. var westernMedicine_other_amt float64 = 0
  3366. var chineseTraditional_claa_sunmfee float64 = 0
  3367. var chineseTraditional_clab_amt float64 = 0
  3368. var chineseTraditional_other_amt float64 = 0
  3369. var check_claa_sunmfee float64 = 0
  3370. var check_clab_amt float64 = 0
  3371. var check_other_amt float64 = 0
  3372. var material_claa_sunmfee float64 = 0
  3373. var material_clab_amt float64 = 0
  3374. var material_other_amt float64 = 0
  3375. var laboratory_claa_sunmfee float64 = 0
  3376. var laboratory_clab_amt float64 = 0
  3377. var laboratory_other_amt float64 = 0
  3378. var treat_claa_sunmfee float64 = 0
  3379. var treat_clab_amt float64 = 0
  3380. var treat_other_amt float64 = 0
  3381. var register_claa_sunmfee float64 = 0
  3382. var register_clab_amt float64 = 0
  3383. var register_other_amt float64 = 0
  3384. for _, item := range order.HisOrderInfo {
  3385. if item.MedChrgitmType == "01" { //床位费
  3386. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3387. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3388. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3389. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3390. if item.ChrgitmLv == "1" {
  3391. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3392. }
  3393. if item.ChrgitmLv == "2" {
  3394. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3395. }
  3396. if item.ChrgitmLv == "3" {
  3397. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3398. }
  3399. }
  3400. if item.MedChrgitmType == "02" { //诊查
  3401. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3402. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3403. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3404. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3405. if item.ChrgitmLv == "1" {
  3406. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3407. }
  3408. if item.ChrgitmLv == "2" {
  3409. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3410. }
  3411. if item.ChrgitmLv == "3" {
  3412. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3413. }
  3414. }
  3415. if item.MedChrgitmType == "03" { //检查费
  3416. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3417. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3418. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3419. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3420. if item.ChrgitmLv == "1" {
  3421. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3422. }
  3423. if item.ChrgitmLv == "2" {
  3424. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3425. }
  3426. if item.ChrgitmLv == "3" {
  3427. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3428. }
  3429. }
  3430. if item.MedChrgitmType == "04" { //化验费
  3431. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3432. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3433. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3434. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3435. if item.ChrgitmLv == "1" {
  3436. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3437. }
  3438. if item.ChrgitmLv == "2" {
  3439. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3440. }
  3441. if item.ChrgitmLv == "3" {
  3442. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3443. }
  3444. }
  3445. if item.MedChrgitmType == "05" { //治疗费
  3446. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3447. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3448. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3449. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3450. if item.ChrgitmLv == "1" {
  3451. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3452. }
  3453. if item.ChrgitmLv == "2" {
  3454. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3455. }
  3456. if item.ChrgitmLv == "3" {
  3457. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3458. }
  3459. }
  3460. if item.MedChrgitmType == "06" { //手术费
  3461. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3462. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3463. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3464. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3465. if item.ChrgitmLv == "1" {
  3466. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3467. }
  3468. if item.ChrgitmLv == "2" {
  3469. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3470. }
  3471. if item.ChrgitmLv == "3" {
  3472. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3473. }
  3474. }
  3475. if item.MedChrgitmType == "07" { //手术费
  3476. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3477. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3478. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3479. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3480. if item.ChrgitmLv == "1" {
  3481. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3482. }
  3483. if item.ChrgitmLv == "2" {
  3484. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3485. }
  3486. if item.ChrgitmLv == "3" {
  3487. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3488. }
  3489. }
  3490. if item.MedChrgitmType == "08" { //材料费
  3491. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3492. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3493. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3494. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3495. if item.ChrgitmLv == "1" {
  3496. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3497. }
  3498. if item.ChrgitmLv == "2" {
  3499. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3500. }
  3501. if item.ChrgitmLv == "3" {
  3502. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3503. }
  3504. }
  3505. if item.MedChrgitmType == "09" { //西药费
  3506. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3507. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3508. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3509. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3510. if item.ChrgitmLv == "1" {
  3511. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3512. }
  3513. if item.ChrgitmLv == "2" {
  3514. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3515. }
  3516. if item.ChrgitmLv == "3" {
  3517. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3518. }
  3519. }
  3520. if item.MedChrgitmType == "10" { //中药饮片
  3521. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3522. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3523. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3524. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3525. if item.ChrgitmLv == "1" {
  3526. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3527. }
  3528. if item.ChrgitmLv == "2" {
  3529. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3530. }
  3531. if item.ChrgitmLv == "3" {
  3532. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3533. }
  3534. }
  3535. if item.MedChrgitmType == "11" { //中成费
  3536. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3537. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3538. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3539. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3540. if item.ChrgitmLv == "1" {
  3541. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3542. }
  3543. if item.ChrgitmLv == "2" {
  3544. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3545. }
  3546. if item.ChrgitmLv == "3" {
  3547. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3548. }
  3549. }
  3550. if item.MedChrgitmType == "12" { //中成费
  3551. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3552. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3553. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3554. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3555. if item.ChrgitmLv == "1" {
  3556. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3557. }
  3558. if item.ChrgitmLv == "2" {
  3559. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3560. }
  3561. if item.ChrgitmLv == "3" {
  3562. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3563. }
  3564. }
  3565. if item.MedChrgitmType == "13" { //中成费
  3566. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3567. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3568. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3569. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3570. if item.ChrgitmLv == "1" {
  3571. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3572. }
  3573. if item.ChrgitmLv == "2" {
  3574. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3575. }
  3576. if item.ChrgitmLv == "3" {
  3577. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3578. }
  3579. }
  3580. if item.MedChrgitmType == "14" { //其他费
  3581. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3582. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3583. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3584. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3585. if item.ChrgitmLv == "1" {
  3586. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3587. }
  3588. if item.ChrgitmLv == "2" {
  3589. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3590. }
  3591. if item.ChrgitmLv == "3" {
  3592. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3593. }
  3594. }
  3595. }
  3596. var iteminfoStructs []service.IteminfoStruct
  3597. if bedCostTotal != 0 {
  3598. iteminfo.MedChrgitm = "01"
  3599. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3600. iteminfo.Amt = bedCostTotal
  3601. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3602. iteminfo.ClabAmt = bed_clab_amt
  3603. iteminfo.OthAmt = bed_other_amt
  3604. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3605. }
  3606. if examineCostTotal != 0 {
  3607. iteminfo.MedChrgitm = "02"
  3608. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3609. iteminfo.Amt = examineCostTotal
  3610. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3611. iteminfo.ClabAmt = examine_clab_amt
  3612. iteminfo.OthAmt = examine_other_amt
  3613. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3614. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3615. }
  3616. if checkCostTotal != 0 {
  3617. iteminfo.MedChrgitm = "03"
  3618. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3619. iteminfo.Amt = checkCostTotal
  3620. iteminfo.ClaaSumfee = check_claa_sunmfee
  3621. iteminfo.ClabAmt = check_clab_amt
  3622. iteminfo.OthAmt = check_other_amt
  3623. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3624. }
  3625. if laboratoryCostTotal != 0 {
  3626. iteminfo.MedChrgitm = "04"
  3627. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3628. iteminfo.Amt = laboratoryCostTotal
  3629. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3630. iteminfo.ClabAmt = laboratory_clab_amt
  3631. iteminfo.OthAmt = laboratory_other_amt
  3632. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3633. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3634. }
  3635. if treatCostTotal != 0 {
  3636. iteminfo.MedChrgitm = "05"
  3637. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3638. iteminfo.Amt = treatCostTotal
  3639. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3640. iteminfo.ClabAmt = treat_clab_amt
  3641. iteminfo.OthAmt = treat_other_amt
  3642. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3643. //(struct4101.IteminfoStruct, iteminfo)
  3644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3645. }
  3646. if operationCostTotal != 0 {
  3647. iteminfo.MedChrgitm = "06"
  3648. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3649. iteminfo.Amt = operationCostTotal
  3650. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3651. iteminfo.ClabAmt = operation_clab_amt
  3652. iteminfo.OthAmt = operation_other_amt
  3653. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3654. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3655. }
  3656. if nursingCostTotal != 0 {
  3657. iteminfo.MedChrgitm = "07"
  3658. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3659. iteminfo.Amt = nursingCostTotal
  3660. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3661. iteminfo.ClabAmt = nursing_clab_amt
  3662. iteminfo.OthAmt = nursing_other_amt
  3663. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3664. }
  3665. if materialCostTotal != 0 {
  3666. iteminfo.MedChrgitm = "08"
  3667. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3668. iteminfo.Amt = materialCostTotal
  3669. iteminfo.ClaaSumfee = material_claa_sunmfee
  3670. iteminfo.ClabAmt = material_clab_amt
  3671. iteminfo.OthAmt = material_other_amt
  3672. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3673. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3674. }
  3675. if westernMedicineCostTotal != 0 {
  3676. iteminfo.MedChrgitm = "09"
  3677. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3678. iteminfo.Amt = westernMedicineCostTotal
  3679. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3680. iteminfo.ClabAmt = westernMedicine_clab_amt
  3681. iteminfo.OthAmt = westernMedicine_other_amt
  3682. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3683. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3684. }
  3685. if chineseMedicineCostTotal != 0 {
  3686. iteminfo.MedChrgitm = "10"
  3687. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3688. iteminfo.Amt = chineseMedicineCostTotal
  3689. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3690. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3691. iteminfo.OthAmt = chinese_medicine_other_amt
  3692. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3693. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3694. }
  3695. if chineseTraditionalMedicineCostTotal != 0 {
  3696. iteminfo.MedChrgitm = "11"
  3697. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3698. iteminfo.Amt = westernMedicineCostTotal
  3699. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3700. iteminfo.ClabAmt = westernMedicine_clab_amt
  3701. iteminfo.OthAmt = westernMedicine_other_amt
  3702. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3703. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3704. }
  3705. if commonlyTreatmentCostTotal != 0 {
  3706. iteminfo.MedChrgitm = "12"
  3707. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3708. iteminfo.Amt = commonlyTreatmentCostTotal
  3709. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3710. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3711. iteminfo.OthAmt = commonly_treatment_other_amt
  3712. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3713. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3714. }
  3715. if registerCostTotal != 0 {
  3716. iteminfo.MedChrgitm = "13"
  3717. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3718. iteminfo.Amt = registerCostTotal
  3719. iteminfo.ClaaSumfee = register_claa_sunmfee
  3720. iteminfo.ClabAmt = register_clab_amt
  3721. iteminfo.OthAmt = register_other_amt
  3722. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3723. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3724. }
  3725. if otherCostTotal != 0 {
  3726. iteminfo.MedChrgitm = "14"
  3727. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3728. iteminfo.Amt = otherCostTotal
  3729. iteminfo.ClaaSumfee = other_claa_sunmfee
  3730. iteminfo.ClabAmt = other_clab_amt
  3731. iteminfo.OthAmt = other_other_amt
  3732. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3733. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3734. }
  3735. struct4101.IteminfoStruct = iteminfoStructs
  3736. struct4101.Ntly = "中国"
  3737. struct4101.AdmCaty = "A03.06"
  3738. var res ResultSeventeen
  3739. if miConfig.MdtrtareaAdmvs == "421300" {
  3740. data := make(map[string]interface{})
  3741. data["struct4101"] = struct4101
  3742. data["secret_key"] = miConfig.SecretKey
  3743. data["org_name"] = miConfig.OrgName
  3744. data["opera"] = curRoles.UserName
  3745. data["code"] = miConfig.Code
  3746. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3747. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3748. client := &http.Client{}
  3749. bytesData, _ := json.Marshal(data)
  3750. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3751. resp, _ := client.Do(req)
  3752. defer resp.Body.Close()
  3753. body, ioErr := ioutil.ReadAll(resp.Body)
  3754. if ioErr != nil {
  3755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3757. return
  3758. }
  3759. var respJSON map[string]interface{}
  3760. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3763. return
  3764. }
  3765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3766. userJSONBytes, _ := json.Marshal(respJSON)
  3767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3768. utils.ErrorLog("解析失败:%v", err)
  3769. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3770. adminUser := c.GetAdminUserInfo()
  3771. errlog := &models.HisOrderError{
  3772. UserOrgId: adminUser.CurrentOrgId,
  3773. Ctime: time.Now().Unix(),
  3774. Mtime: time.Now().Unix(),
  3775. ErrMsg: res.ErrMsg + "解析失败",
  3776. Status: 1,
  3777. PatientId: order_id,
  3778. Stage: 10138,
  3779. }
  3780. service.CreateErrMsgLog(errlog)
  3781. continue
  3782. }
  3783. } else {
  3784. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3785. fmt.Println(result)
  3786. var dat map[string]interface{}
  3787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3788. fmt.Println(dat)
  3789. } else {
  3790. fmt.Println(err)
  3791. }
  3792. userJSONBytes, _ := json.Marshal(dat)
  3793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3794. utils.ErrorLog("解析失败:%v", err)
  3795. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3796. adminUser := c.GetAdminUserInfo()
  3797. errlog := &models.HisOrderError{
  3798. UserOrgId: adminUser.CurrentOrgId,
  3799. Ctime: time.Now().Unix(),
  3800. Mtime: time.Now().Unix(),
  3801. ErrMsg: res.ErrMsg + "解析失败",
  3802. Status: 1,
  3803. PatientId: order_id,
  3804. Stage: 10138,
  3805. }
  3806. service.CreateErrMsgLog(errlog)
  3807. continue
  3808. }
  3809. }
  3810. if res.Infcode != 0 {
  3811. adminUser := c.GetAdminUserInfo()
  3812. errlog := &models.HisOrderError{
  3813. UserOrgId: adminUser.CurrentOrgId,
  3814. Ctime: time.Now().Unix(),
  3815. Mtime: time.Now().Unix(),
  3816. ErrMsg: res.ErrMsg,
  3817. Status: 1,
  3818. PatientId: order_id,
  3819. Stage: 10138,
  3820. }
  3821. service.CreateErrMsgLog(errlog)
  3822. continue
  3823. } else {
  3824. hisFundSettleListResult := &models.HisFundSettleListResult{
  3825. Number: res.Output.SetlListId,
  3826. Status: 1,
  3827. Ctime: time.Now().Unix(),
  3828. Mtime: time.Now().Unix(),
  3829. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3830. IsUpload: 1,
  3831. OrderId: order_id,
  3832. }
  3833. service.CreateUploadRecord(hisFundSettleListResult)
  3834. continue
  3835. }
  3836. }
  3837. }
  3838. func (c *HisApiController) GetOrgInfo() {
  3839. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3840. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3841. }
  3842. func (c *HisApiController) GetHisPatientInfo() {
  3843. medical_insurance_card := c.GetString("medical_insurance_card")
  3844. id_card_type, _ := c.GetInt64("id_card_type")
  3845. id_card := c.GetString("id_card")
  3846. adminInfo := c.GetAdminUserInfo()
  3847. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3848. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3849. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3850. IdCardNo := ""
  3851. if id_card_type == 1 {
  3852. IdCardNo = medical_insurance_card
  3853. } else if id_card_type == 2 {
  3854. IdCardNo = id_card
  3855. }
  3856. if config.IsOpen == 1 {
  3857. 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
  3858. resp, requestErr := http.Get(api)
  3859. if requestErr != nil {
  3860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3861. return
  3862. }
  3863. defer resp.Body.Close()
  3864. body, ioErr := ioutil.ReadAll(resp.Body)
  3865. if ioErr != nil {
  3866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3868. return
  3869. }
  3870. var respJSON map[string]interface{}
  3871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3874. return
  3875. }
  3876. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3877. userJSONBytes, _ := json.Marshal(userJSON)
  3878. var res ResultTwo
  3879. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3880. utils.ErrorLog("解析失败:%v", err)
  3881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3882. return
  3883. }
  3884. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3885. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3886. infoStr := string(Iinfos)
  3887. idetinfoStr := string(Idetinfos)
  3888. if res.Infcode == 0 {
  3889. his := models.VMHisPatient{
  3890. Status: 1,
  3891. Ctime: time.Now().Unix(),
  3892. Mtime: time.Now().Unix(),
  3893. PsnNo: res.Output.Baseinfo.PsnNo,
  3894. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3895. Certno: res.Output.Baseinfo.Certno,
  3896. PsnName: res.Output.Baseinfo.PsnName,
  3897. Gend: res.Output.Baseinfo.Gend,
  3898. Naty: res.Output.Baseinfo.Naty,
  3899. Brdy: res.Output.Baseinfo.Brdy,
  3900. Age: res.Output.Baseinfo.Age,
  3901. Iinfo: infoStr,
  3902. Idetinfo: idetinfoStr,
  3903. UserOrgId: adminInfo.CurrentOrgId,
  3904. IsReturn: 1,
  3905. IdCardType: id_card_type,
  3906. }
  3907. c.ServeSuccessJSON(map[string]interface{}{
  3908. "info": his,
  3909. })
  3910. } else {
  3911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3912. return
  3913. }
  3914. }
  3915. }
  3916. //func GetBasBaseInfo() (jsonStr string, err error) {
  3917. //
  3918. // handle := syscall.NewLazyDLL("SSCard.dll")
  3919. // add := handle.NewProc("ReadCardBas")
  3920. // str := make([]byte, 1024)
  3921. // str1 := make([]byte, 1024)
  3922. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3923. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3924. //
  3925. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3926. //
  3927. // fmt.Println("> Add(4,5)的结果为:", ret)
  3928. // handle.Release()
  3929. //
  3930. // return "", nil
  3931. //
  3932. //}
  3933. //func GetQRBaseInfo() (jsonStr string, err error) {
  3934. // handle := syscall.LoadDLL("SSCard.dll")
  3935. // ReadCardBas := handle.FindProc("GetQRBase")
  3936. //
  3937. // str := make([]byte, 256)
  3938. // str1 := make([]byte, 256)
  3939. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3940. //
  3941. // fmt.Println(string(str))
  3942. // fmt.Println(r)
  3943. // return string(str), nil
  3944. //}
  3945. //func CardInit() int {
  3946. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3947. // add := DllTestDef.MustFindProc("Init")
  3948. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3949. // if err != nil {
  3950. // fmt.Println("SSCard的运算结果为:", ret)
  3951. // }
  3952. // result := int(ret)
  3953. // return result
  3954. //}
  3955. //func CardInit() int {
  3956. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3957. // if err != nil {
  3958. // fmt.Println("SSCard的运算结果为:", ret)
  3959. // }
  3960. // fmt.Println(err)
  3961. // result := int(ret)
  3962. // return result
  3963. //}
  3964. func IntPtr(n int) uintptr {
  3965. return uintptr(n)
  3966. }
  3967. func StrPtr(s string) uintptr {
  3968. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3969. }
  3970. type Result2001 struct {
  3971. Cainfo interface{} `json:"cainfo"`
  3972. ErrMsg string `json:"err_msg"`
  3973. InfRefmsgid string `json:"inf_refmsgid"`
  3974. Infcode int64 `json:"infcode"`
  3975. Output struct {
  3976. Trtinfo struct {
  3977. PsnNo string `json:"psn_no"`
  3978. TrtChkType string `json:"trt_chk_type"`
  3979. FundPayType string `json:"fund_pay_type"`
  3980. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3981. Begndate string `json:"begndate"`
  3982. Enddate string `json:"enddate"`
  3983. TrtChkRslt string `json:"trt_chk_rslt"`
  3984. } `json:"trtinfo"`
  3985. } `json:"output"`
  3986. RefmsgTime string `json:"refmsg_time"`
  3987. RespondTime string `json:"respond_time"`
  3988. Signtype interface{} `json:"signtype"`
  3989. WarnMsg interface{} `json:"warn_msg"`
  3990. }
  3991. type Result2001Org10265 struct {
  3992. Cainfo interface{} `json:"cainfo"`
  3993. ErrMsg string `json:"err_msg"`
  3994. InfRefmsgid string `json:"inf_refmsgid"`
  3995. Infcode string `json:"infcode"`
  3996. Output struct {
  3997. Trtinfo struct {
  3998. PsnNo string `json:"psn_no"`
  3999. TrtChkType string `json:"trt_chk_type"`
  4000. FundPayType string `json:"fund_pay_type"`
  4001. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4002. Begndate string `json:"begndate"`
  4003. Enddate string `json:"enddate"`
  4004. TrtChkRslt string `json:"trt_chk_rslt"`
  4005. } `json:"trtinfo"`
  4006. } `json:"output"`
  4007. RefmsgTime string `json:"refmsg_time"`
  4008. RespondTime string `json:"respond_time"`
  4009. Signtype interface{} `json:"signtype"`
  4010. WarnMsg interface{} `json:"warn_msg"`
  4011. }
  4012. type ResultTwo struct {
  4013. ErrMsg string `json:"err_msg"`
  4014. InfRefmsgid string `json:"inf_refmsgid"`
  4015. Infcode int64 `json:"infcode"`
  4016. Output struct {
  4017. Baseinfo struct {
  4018. Age float64 `json:"age"`
  4019. Brdy string `json:"brdy"`
  4020. Certno string `json:"certno"`
  4021. Gend string `json:"gend"`
  4022. Naty string `json:"naty"`
  4023. PsnCertType string `json:"psn_cert_type"`
  4024. PsnName string `json:"psn_name"`
  4025. PsnNo string `json:"psn_no"`
  4026. } `json:"baseinfo"`
  4027. Idetinfo []interface{} `json:"idetinfo"`
  4028. Iinfo []struct {
  4029. Balc float64 `json:"balc"`
  4030. CvlservFlag string `json:"cvlserv_flag"`
  4031. EmpName string `json:"emp_name"`
  4032. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4033. Insutype string `json:"insutype"`
  4034. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4035. PausInsuDate string `json:"paus_insu_date"`
  4036. PsnInsuDate string `json:"psn_insu_date"`
  4037. PsnInsuStas string `json:"psn_insu_stas"`
  4038. PsnType string `json:"psn_type"`
  4039. } `json:"insuinfo"`
  4040. } `json:"output"`
  4041. RefmsgTime string `json:"refmsg_time"`
  4042. RespondTime string `json:"respond_time"`
  4043. Signtype interface{} `json:"signtype"`
  4044. WarnInfo interface{} `json:"warn_info"`
  4045. }
  4046. type ResultTwo10265 struct {
  4047. ErrMsg string `json:"err_msg"`
  4048. InfRefmsgid string `json:"inf_refmsgid"`
  4049. Infcode string `json:"infcode"`
  4050. Output struct {
  4051. Baseinfo struct {
  4052. Age float64 `json:"age"`
  4053. Brdy string `json:"brdy"`
  4054. Certno string `json:"certno"`
  4055. Gend string `json:"gend"`
  4056. Naty string `json:"naty"`
  4057. PsnCertType string `json:"psn_cert_type"`
  4058. PsnName string `json:"psn_name"`
  4059. PsnNo string `json:"psn_no"`
  4060. } `json:"baseinfo"`
  4061. Idetinfo []interface{} `json:"idetinfo"`
  4062. Iinfo []struct {
  4063. Balc float64 `json:"balc"`
  4064. CvlservFlag string `json:"cvlserv_flag"`
  4065. EmpName string `json:"emp_name"`
  4066. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4067. Insutype string `json:"insutype"`
  4068. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4069. PausInsuDate string `json:"paus_insu_date"`
  4070. PsnInsuDate string `json:"psn_insu_date"`
  4071. PsnInsuStas string `json:"psn_insu_stas"`
  4072. PsnType string `json:"psn_type"`
  4073. } `json:"insuinfo"`
  4074. } `json:"output"`
  4075. RefmsgTime string `json:"refmsg_time"`
  4076. RespondTime string `json:"respond_time"`
  4077. Signtype interface{} `json:"signtype"`
  4078. WarnInfo interface{} `json:"warn_info"`
  4079. }
  4080. type ResultThree struct {
  4081. Cainfo interface{} `json:"cainfo"`
  4082. ErrMsg string `json:"err_msg"`
  4083. InfRefmsgid string `json:"inf_refmsgid"`
  4084. Infcode int64 `json:"infcode"`
  4085. Output struct {
  4086. Data struct {
  4087. IptOtpNo string `json:"ipt_otp_no"`
  4088. MdtrtID string `json:"mdtrt_id"`
  4089. PsnNo string `json:"psn_no"`
  4090. } `json:"data"`
  4091. } `json:"output"`
  4092. RefmsgTime string `json:"refmsg_time"`
  4093. RespondTime string `json:"respond_time"`
  4094. Signtype interface{} `json:"signtype"`
  4095. WarnMsg interface{} `json:"warn_msg"`
  4096. }
  4097. type ResultThree10265 struct {
  4098. Cainfo interface{} `json:"cainfo"`
  4099. ErrMsg string `json:"err_msg"`
  4100. InfRefmsgid string `json:"inf_refmsgid"`
  4101. Infcode string `json:"infcode"`
  4102. Output struct {
  4103. Data struct {
  4104. IptOtpNo string `json:"ipt_otp_no"`
  4105. MdtrtID string `json:"mdtrt_id"`
  4106. PsnNo string `json:"psn_no"`
  4107. } `json:"data"`
  4108. } `json:"output"`
  4109. RefmsgTime string `json:"refmsg_time"`
  4110. RespondTime string `json:"respond_time"`
  4111. Signtype interface{} `json:"signtype"`
  4112. WarnMsg interface{} `json:"warn_msg"`
  4113. }
  4114. type ResultFour struct {
  4115. Cainfo string `json:"cainfo"`
  4116. ErrMsg string `json:"err_msg"`
  4117. InfRefmsgid string `json:"inf_refmsgid"`
  4118. Infcode int64 `json:"infcode"`
  4119. Output struct {
  4120. Result []struct {
  4121. BasMednFlag string `json:"bas_medn_flag"`
  4122. ChldMedcFlag string `json:"chld_medc_flag"`
  4123. ChrgitmLv string `json:"chrgitm_lv"`
  4124. Cnt float64 `json:"cnt"`
  4125. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4126. DrtReimFlag string `json:"drt_reim_flag"`
  4127. FeedetlSn string `json:"feedetl_sn"`
  4128. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4129. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4130. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4131. ListSpItemFlag string `json:"list_sp_item_flag"`
  4132. LmtUsedFlag string `json:"lmt_used_flag"`
  4133. MedChrgitmType string `json:"med_chrgitm_type"`
  4134. Memo string `json:"memo"`
  4135. OverlmtAmt float64 `json:"overlmt_amt"`
  4136. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4137. Pric float64 `json:"pric"`
  4138. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4139. SelfpayProp float64 `json:"selfpay_prop"`
  4140. } `json:"result"`
  4141. } `json:"output"`
  4142. RefmsgTime string `json:"refmsg_time"`
  4143. RespondTime string `json:"respond_time"`
  4144. Signtype string `json:"signtype"`
  4145. WarnMsg string `json:"warn_msg"`
  4146. }
  4147. type ResultFour10265 struct {
  4148. Cainfo string `json:"cainfo"`
  4149. ErrMsg string `json:"err_msg"`
  4150. InfRefmsgid string `json:"inf_refmsgid"`
  4151. Infcode string `json:"infcode"`
  4152. Output struct {
  4153. Result []struct {
  4154. BasMednFlag string `json:"bas_medn_flag"`
  4155. ChldMedcFlag string `json:"chld_medc_flag"`
  4156. ChrgitmLv string `json:"chrgitm_lv"`
  4157. Cnt float64 `json:"cnt"`
  4158. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4159. DrtReimFlag string `json:"drt_reim_flag"`
  4160. FeedetlSn string `json:"feedetl_sn"`
  4161. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4162. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4163. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4164. ListSpItemFlag string `json:"list_sp_item_flag"`
  4165. LmtUsedFlag string `json:"lmt_used_flag"`
  4166. MedChrgitmType string `json:"med_chrgitm_type"`
  4167. Memo string `json:"memo"`
  4168. OverlmtAmt float64 `json:"overlmt_amt"`
  4169. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4170. Pric float64 `json:"pric"`
  4171. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4172. SelfpayProp float64 `json:"selfpay_prop"`
  4173. } `json:"result"`
  4174. } `json:"output"`
  4175. RefmsgTime string `json:"refmsg_time"`
  4176. RespondTime string `json:"respond_time"`
  4177. Signtype string `json:"signtype"`
  4178. WarnMsg string `json:"warn_msg"`
  4179. }
  4180. type ResultFive struct {
  4181. Balc float64 `json:"balc"`
  4182. CvlservFlag string `json:"cvlserv_flag"`
  4183. EmpName string `json:"emp_name"`
  4184. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4185. Insutype string `json:"insutype"`
  4186. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4187. PausInsuDate string `json:"paus_insu_date"`
  4188. PsnInsuDate string `json:"psn_insu_date"`
  4189. PsnInsuStas string `json:"psn_insu_stas"`
  4190. PsnType string `json:"psn_type"`
  4191. }
  4192. type ResultSix struct {
  4193. Cainfo interface{} `json:"cainfo"`
  4194. ErrMsg string `json:"err_msg"`
  4195. InfRefmsgid string `json:"inf_refmsgid"`
  4196. Infcode int64 `json:"infcode"`
  4197. Output struct {
  4198. } `json:"output"`
  4199. RefmsgTime string `json:"refmsg_time"`
  4200. RespondTime string `json:"respond_time"`
  4201. Signtype interface{} `json:"signtype"`
  4202. WarnMsg interface{} `json:"warn_msg"`
  4203. }
  4204. type ResultSix10265 struct {
  4205. Cainfo interface{} `json:"cainfo"`
  4206. ErrMsg string `json:"err_msg"`
  4207. InfRefmsgid string `json:"inf_refmsgid"`
  4208. Infcode string `json:"infcode"`
  4209. Output struct {
  4210. } `json:"output"`
  4211. RefmsgTime string `json:"refmsg_time"`
  4212. RespondTime string `json:"respond_time"`
  4213. Signtype interface{} `json:"signtype"`
  4214. WarnMsg interface{} `json:"warn_msg"`
  4215. }
  4216. type ResultSeven struct {
  4217. Cainfo string `json:"cainfo"`
  4218. ErrMsg string `json:"err_msg"`
  4219. InfRefmsgid string `json:"inf_refmsgid"`
  4220. Infcode int64 `json:"infcode"`
  4221. Output struct {
  4222. Setldetail []interface{} `json:"setldetail"`
  4223. Setlinfo struct {
  4224. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4225. AcctPay float64 `json:"acct_pay"`
  4226. ActPayDedc float64 `json:"act_pay_dedc"`
  4227. Age float64 `json:"age"`
  4228. Balc float64 `json:"balc"`
  4229. Brdy string `json:"brdy"`
  4230. Certno string `json:"certno"`
  4231. ClrOptins string `json:"clr_optins"`
  4232. ClrType string `json:"clr_type"`
  4233. ClrWay string `json:"clr_way"`
  4234. CvlservFlag string `json:"cvlserv_flag"`
  4235. CvlservPay float64 `json:"cvlserv_pay"`
  4236. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4237. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4238. Gend string `json:"gend"`
  4239. HifesPay float64 `json:"hifes_pay"`
  4240. HifmiPay float64 `json:"hifmi_pay"`
  4241. HifpPay float64 `json:"hifp_pay"`
  4242. HospPartAmt float64 `json:"hosp_part_amt"`
  4243. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4244. Insutype string `json:"insutype"`
  4245. MafPay float64 `json:"maf_pay"`
  4246. MdtrtCertType string `json:"mdtrt_cert_type"`
  4247. HifobPay float64 `json:"hifob_pay"`
  4248. MdtrtID string `json:"mdtrt_id"`
  4249. MedType string `json:"med_type"`
  4250. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4251. MedinsSetlID string `json:"medins_setl_id"`
  4252. Naty string `json:"naty"`
  4253. OthPay float64 `json:"oth_pay"`
  4254. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4255. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4256. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4257. PsnCashPay float64 `json:"psn_cash_pay"`
  4258. PsnCertType string `json:"psn_cert_type"`
  4259. PsnName string `json:"psn_name"`
  4260. PsnNo string `json:"psn_no"`
  4261. PsnPartAmt float64 `json:"psn_part_amt"`
  4262. PsnType string `json:"psn_type"`
  4263. SetlID string `json:"setl_id"`
  4264. SetlTime string `json:"setl_time"`
  4265. } `json:"setlinfo"`
  4266. } `json:"output"`
  4267. RefmsgTime string `json:"refmsg_time"`
  4268. RespondTime string `json:"respond_time"`
  4269. Signtype interface{} `json:"signtype"`
  4270. WarnMsg interface{} `json:"warn_msg"`
  4271. }
  4272. type ResultSeven10265 struct {
  4273. Cainfo string `json:"cainfo"`
  4274. ErrMsg string `json:"err_msg"`
  4275. InfRefmsgid string `json:"inf_refmsgid"`
  4276. Infcode string `json:"infcode"`
  4277. Output struct {
  4278. Setldetail []interface{} `json:"setldetail"`
  4279. Setlinfo struct {
  4280. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4281. AcctPay float64 `json:"acct_pay"`
  4282. ActPayDedc float64 `json:"act_pay_dedc"`
  4283. Age float64 `json:"age"`
  4284. Balc float64 `json:"balc"`
  4285. Brdy string `json:"brdy"`
  4286. Certno string `json:"certno"`
  4287. ClrOptins string `json:"clr_optins"`
  4288. ClrType string `json:"clr_type"`
  4289. ClrWay string `json:"clr_way"`
  4290. CvlservFlag string `json:"cvlserv_flag"`
  4291. CvlservPay float64 `json:"cvlserv_pay"`
  4292. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4293. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4294. Gend string `json:"gend"`
  4295. HifesPay float64 `json:"hifes_pay"`
  4296. HifmiPay float64 `json:"hifmi_pay"`
  4297. HifpPay float64 `json:"hifp_pay"`
  4298. HospPartAmt float64 `json:"hosp_part_amt"`
  4299. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4300. Insutype string `json:"insutype"`
  4301. MafPay float64 `json:"maf_pay"`
  4302. MdtrtCertType string `json:"mdtrt_cert_type"`
  4303. HifobPay float64 `json:"hifob_pay"`
  4304. MdtrtID string `json:"mdtrt_id"`
  4305. MedType string `json:"med_type"`
  4306. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4307. MedinsSetlID string `json:"medins_setl_id"`
  4308. Naty string `json:"naty"`
  4309. OthPay float64 `json:"oth_pay"`
  4310. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4311. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4312. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4313. PsnCashPay float64 `json:"psn_cash_pay"`
  4314. PsnCertType string `json:"psn_cert_type"`
  4315. PsnName string `json:"psn_name"`
  4316. PsnNo string `json:"psn_no"`
  4317. PsnPartAmt float64 `json:"psn_part_amt"`
  4318. PsnType string `json:"psn_type"`
  4319. SetlID string `json:"setl_id"`
  4320. SetlTime string `json:"setl_time"`
  4321. } `json:"setlinfo"`
  4322. } `json:"output"`
  4323. RefmsgTime string `json:"refmsg_time"`
  4324. RespondTime string `json:"respond_time"`
  4325. Signtype interface{} `json:"signtype"`
  4326. WarnMsg interface{} `json:"warn_msg"`
  4327. }
  4328. type ResultEight struct {
  4329. Cainfo string `json:"cainfo"`
  4330. ErrMsg string `json:"err_msg"`
  4331. InfRefmsgid string `json:"inf_refmsgid"`
  4332. Infcode int64 `json:"infcode"`
  4333. Output struct {
  4334. Stmtinfo struct {
  4335. SetlOptins string `json:"setl_optins"`
  4336. StmtRslt string `json:"stmt_rslt"`
  4337. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4338. } `json:"stmtinfo"`
  4339. } `json:"output"`
  4340. RefmsgTime string `json:"refmsg_time"`
  4341. RespondTime string `json:"respond_time"`
  4342. Signtype interface{} `json:"signtype"`
  4343. WarnMsg interface{} `json:"warn_msg"`
  4344. }
  4345. type ResultEightFor10188 struct {
  4346. Cainfo string `json:"cainfo"`
  4347. ErrMsg string `json:"err_msg"`
  4348. InfRefmsgid string `json:"inf_refmsgid"`
  4349. Infcode string `json:"infcode"`
  4350. Output struct {
  4351. Stmtinfo struct {
  4352. SetlOptins string `json:"setl_optins"`
  4353. StmtRslt string `json:"stmt_rslt"`
  4354. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4355. } `json:"stmtinfo"`
  4356. } `json:"output"`
  4357. RefmsgTime string `json:"refmsg_time"`
  4358. RespondTime string `json:"respond_time"`
  4359. Signtype interface{} `json:"signtype"`
  4360. WarnMsg interface{} `json:"warn_msg"`
  4361. }
  4362. type ResultNine struct {
  4363. Cainfo string `json:"cainfo"`
  4364. ErrMsg string `json:"err_msg"`
  4365. InfRefmsgid string `json:"inf_refmsgid"`
  4366. Infcode int64 `json:"infcode"`
  4367. Output struct {
  4368. FileQuryNo string `json:"file_qury_no"`
  4369. } `json:"output"`
  4370. RefmsgTime string `json:"refmsg_time"`
  4371. RespondTime string `json:"respond_time"`
  4372. Signtype interface{} `json:"signtype"`
  4373. WarnMsg interface{} `json:"warn_msg"`
  4374. }
  4375. type ResultTen struct {
  4376. Cainfo string `json:"cainfo"`
  4377. ErrMsg string `json:"err_msg"`
  4378. InfRefmsgid string `json:"inf_refmsgid"`
  4379. Infcode int64 `json:"infcode"`
  4380. Output struct {
  4381. DldEndtime string `json:"dld_endtime"`
  4382. FileQuryNo string `json:"file_qury_no"`
  4383. Filename string `json:"filename"`
  4384. } `json:"output"`
  4385. RefmsgTime string `json:"refmsg_time"`
  4386. RespondTime string `json:"respond_time"`
  4387. Signtype interface{} `json:"signtype"`
  4388. WarnMsg interface{} `json:"warn_msg"`
  4389. }
  4390. //type Autogenerated struct {
  4391. // Output struct {
  4392. // Setlinfo struct {
  4393. // SetlTime string `json:"setl_time"`
  4394. // CvlservPay float64 `json:"cvlserv_pay"`
  4395. // Year string `json:"year"`
  4396. // MedType string `json:"med_type"`
  4397. // PsnPay float64 `json:"psn_pay"`
  4398. // OpterID string `json:"opter_id"`
  4399. // Begndate string `json:"begndate"`
  4400. // FlxempeFlag string `json:"flxempe_flag"`
  4401. // HifmiPay float64 `json:"hifmi_pay"`
  4402. // PsnNo string `json:"psn_no"`
  4403. // ActPayDedc float64 `json:"act_pay_dedc"`
  4404. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4405. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4406. // ClrWay string `json:"clr_way"`
  4407. // OthPay float64 `json:"oth_pay"`
  4408. // Gend string `json:"gend"`
  4409. // MdtrtID string `json:"mdtrt_id"`
  4410. // AcctPay float64 `json:"acct_pay"`
  4411. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4412. // Insutype string `json:"insutype"`
  4413. // Invono interface{} `json:"invono"`
  4414. // Enddate string `json:"enddate"`
  4415. // CashPayamt float64 `json:"cash_payamt"`
  4416. // PsnType string `json:"psn_type"`
  4417. // FixmedinsName string `json:"fixmedins_name"`
  4418. // HifpPay float64 `json:"hifp_pay"`
  4419. // NewFlag interface{} `json:"new_flag"`
  4420. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4421. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4422. // PayLoc string `json:"pay_loc"`
  4423. // ClrType string `json:"clr_type"`
  4424. // RefdSetlFlag string `json:"refd_setl_flag"`
  4425. // CvlservFlag string `json:"cvlserv_flag"`
  4426. // EmpName string `json:"emp_name"`
  4427. // Brdy string `json:"brdy"`
  4428. // Naty string `json:"naty"`
  4429. // Certno string `json:"certno"`
  4430. // DiseCode string `json:"dise_code"`
  4431. // FixmedinsCode string `json:"fixmedins_code"`
  4432. // DedcHospLv string `json:"dedc_hosp_lv"`
  4433. // OpterName string `json:"opter_name"`
  4434. // Balc float64 `json:"balc"`
  4435. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4436. // PsnCertType string `json:"psn_cert_type"`
  4437. // HifobPay float64 `json:"hifob_pay"`
  4438. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4439. // HifesPay float64 `json:"hifes_pay"`
  4440. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4441. // OptTime string `json:"opt_time"`
  4442. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4443. // SetlID string `json:"setl_id"`
  4444. // MafPay float64 `json:"maf_pay"`
  4445. // PsnName string `json:"psn_name"`
  4446. // InsuOptins interface{} `json:"insu_optins"`
  4447. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4448. // ClrOptins string `json:"clr_optins"`
  4449. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4450. // DiseName string `json:"dise_name"`
  4451. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4452. // Age float64 `json:"age"`
  4453. // DtrtCertType string `json:"dtrt_cert_type"`
  4454. // HospLv string `json:"hosp_lv"`
  4455. // } `json:"setlinfo"`
  4456. // Setldetail []struct {
  4457. // FundPayType string `json:"fund_pay_type"`
  4458. // FundPayamt float64 `json:"fund_payamt"`
  4459. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4460. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4461. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4462. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4463. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4464. // } `json:"setldetail"`
  4465. // } `json:"output"`
  4466. // Infcode int `json:"infcode"`
  4467. // WarnMsg interface{} `json:"warn_msg"`
  4468. // Cainfo interface{} `json:"cainfo"`
  4469. // ErrMsg interface{} `json:"err_msg"`
  4470. // RefmsgTime string `json:"refmsg_time"`
  4471. // Signtype interface{} `json:"signtype"`
  4472. // RespondTime string `json:"respond_time"`
  4473. // InfRefmsgid string `json:"inf_refmsgid"`
  4474. //}
  4475. type ResultEleven struct {
  4476. Cainfo string `json:"cainfo"`
  4477. ErrMsg string `json:"err_msg"`
  4478. InfRefmsgid string `json:"inf_refmsgid"`
  4479. Infcode int64 `json:"infcode"`
  4480. Output struct {
  4481. Setlinfo struct {
  4482. SetlTime string `json:"setl_time"`
  4483. CvlservPay float64 `json:"cvlserv_pay"`
  4484. Year string `json:"year"`
  4485. MedType string `json:"med_type"`
  4486. PsnPay float64 `json:"psn_pay"`
  4487. OpterID string `json:"opter_id"`
  4488. Begndate string `json:"begndate"`
  4489. FlxempeFlag string `json:"flxempe_flag"`
  4490. HifmiPay float64 `json:"hifmi_pay"`
  4491. PsnNo string `json:"psn_no"`
  4492. ActPayDedc float64 `json:"act_pay_dedc"`
  4493. MedinsSetlID interface{} `json:"medins_setl_id"`
  4494. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4495. ClrWay string `json:"clr_way"`
  4496. OthPay float64 `json:"oth_pay"`
  4497. Gend string `json:"gend"`
  4498. MdtrtID string `json:"mdtrt_id"`
  4499. AcctPay float64 `json:"acct_pay"`
  4500. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4501. Insutype string `json:"insutype"`
  4502. Invono interface{} `json:"invono"`
  4503. Enddate string `json:"enddate"`
  4504. CashPayamt float64 `json:"cash_payamt"`
  4505. PsnType string `json:"psn_type"`
  4506. FixmedinsName string `json:"fixmedins_name"`
  4507. HifpPay float64 `json:"hifp_pay"`
  4508. NewFlag interface{} `json:"new_flag"`
  4509. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4510. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4511. PayLoc string `json:"pay_loc"`
  4512. ClrType string `json:"clr_type"`
  4513. RefdSetlFlag string `json:"refd_setl_flag"`
  4514. CvlservFlag string `json:"cvlserv_flag"`
  4515. EmpName string `json:"emp_name"`
  4516. Brdy string `json:"brdy"`
  4517. Naty string `json:"naty"`
  4518. Certno string `json:"certno"`
  4519. DiseCode string `json:"dise_code"`
  4520. FixmedinsCode string `json:"fixmedins_code"`
  4521. DedcHospLv string `json:"dedc_hosp_lv"`
  4522. OpterName string `json:"opter_name"`
  4523. Balc float64 `json:"balc"`
  4524. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4525. PsnCertType string `json:"psn_cert_type"`
  4526. HifobPay float64 `json:"hifob_pay"`
  4527. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4528. HifesPay float64 `json:"hifes_pay"`
  4529. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4530. OptTime string `json:"opt_time"`
  4531. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4532. SetlID string `json:"setl_id"`
  4533. MafPay float64 `json:"maf_pay"`
  4534. PsnName string `json:"psn_name"`
  4535. InsuOptins interface{} `json:"insu_optins"`
  4536. PrefFundPay interface{} `json:"pref_fund_pay"`
  4537. ClrOptins string `json:"clr_optins"`
  4538. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4539. DiseName string `json:"dise_name"`
  4540. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4541. Age float64 `json:"age"`
  4542. DtrtCertType string `json:"dtrt_cert_type"`
  4543. HospLv string `json:"hosp_lv"`
  4544. } `json:"setlinfo"`
  4545. } `json:"output"`
  4546. RefmsgTime string `json:"refmsg_time"`
  4547. RespondTime string `json:"respond_time"`
  4548. Signtype interface{} `json:"signtype"`
  4549. WarnMsg interface{} `json:"warn_msg"`
  4550. }
  4551. type ResultEleven10265 struct {
  4552. Cainfo string `json:"cainfo"`
  4553. ErrMsg string `json:"err_msg"`
  4554. InfRefmsgid string `json:"inf_refmsgid"`
  4555. Infcode string `json:"infcode"`
  4556. Output struct {
  4557. Setlinfo struct {
  4558. SetlTime string `json:"setl_time"`
  4559. CvlservPay float64 `json:"cvlserv_pay"`
  4560. Year string `json:"year"`
  4561. MedType string `json:"med_type"`
  4562. PsnPay float64 `json:"psn_pay"`
  4563. OpterID string `json:"opter_id"`
  4564. Begndate string `json:"begndate"`
  4565. FlxempeFlag string `json:"flxempe_flag"`
  4566. HifmiPay float64 `json:"hifmi_pay"`
  4567. PsnNo string `json:"psn_no"`
  4568. ActPayDedc float64 `json:"act_pay_dedc"`
  4569. MedinsSetlID interface{} `json:"medins_setl_id"`
  4570. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4571. ClrWay string `json:"clr_way"`
  4572. OthPay float64 `json:"oth_pay"`
  4573. Gend string `json:"gend"`
  4574. MdtrtID string `json:"mdtrt_id"`
  4575. AcctPay float64 `json:"acct_pay"`
  4576. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4577. Insutype string `json:"insutype"`
  4578. Invono interface{} `json:"invono"`
  4579. Enddate string `json:"enddate"`
  4580. CashPayamt float64 `json:"cash_payamt"`
  4581. PsnType string `json:"psn_type"`
  4582. FixmedinsName string `json:"fixmedins_name"`
  4583. HifpPay float64 `json:"hifp_pay"`
  4584. NewFlag interface{} `json:"new_flag"`
  4585. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4586. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4587. PayLoc string `json:"pay_loc"`
  4588. ClrType string `json:"clr_type"`
  4589. RefdSetlFlag string `json:"refd_setl_flag"`
  4590. CvlservFlag string `json:"cvlserv_flag"`
  4591. EmpName string `json:"emp_name"`
  4592. Brdy string `json:"brdy"`
  4593. Naty string `json:"naty"`
  4594. Certno string `json:"certno"`
  4595. DiseCode string `json:"dise_code"`
  4596. FixmedinsCode string `json:"fixmedins_code"`
  4597. DedcHospLv string `json:"dedc_hosp_lv"`
  4598. OpterName string `json:"opter_name"`
  4599. Balc float64 `json:"balc"`
  4600. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4601. PsnCertType string `json:"psn_cert_type"`
  4602. HifobPay float64 `json:"hifob_pay"`
  4603. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4604. HifesPay float64 `json:"hifes_pay"`
  4605. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4606. OptTime string `json:"opt_time"`
  4607. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4608. SetlID string `json:"setl_id"`
  4609. MafPay float64 `json:"maf_pay"`
  4610. PsnName string `json:"psn_name"`
  4611. InsuOptins interface{} `json:"insu_optins"`
  4612. PrefFundPay interface{} `json:"pref_fund_pay"`
  4613. ClrOptins string `json:"clr_optins"`
  4614. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4615. DiseName string `json:"dise_name"`
  4616. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4617. Age float64 `json:"age"`
  4618. DtrtCertType string `json:"dtrt_cert_type"`
  4619. HospLv string `json:"hosp_lv"`
  4620. } `json:"setlinfo"`
  4621. } `json:"output"`
  4622. RefmsgTime string `json:"refmsg_time"`
  4623. RespondTime string `json:"respond_time"`
  4624. Signtype interface{} `json:"signtype"`
  4625. WarnMsg interface{} `json:"warn_msg"`
  4626. }
  4627. type ResultTwelve struct {
  4628. Cainfo string `json:"cainfo"`
  4629. ErrMsg string `json:"err_msg"`
  4630. InfRefmsgid string `json:"inf_refmsgid"`
  4631. Infcode int64 `json:"infcode"`
  4632. Output struct {
  4633. MdtrtId string `json:"mdtrt_id"`
  4634. ChrgBchno string `json:"chrg_bchno"`
  4635. PsnNo string `json:"psn_no"`
  4636. } `json:"output"`
  4637. RefmsgTime string `json:"refmsg_time"`
  4638. RespondTime string `json:"respond_time"`
  4639. Signtype interface{} `json:"signtype"`
  4640. WarnMsg interface{} `json:"warn_msg"`
  4641. }
  4642. type ResultThirteen struct {
  4643. ErrMsg string `json:"err_msg"`
  4644. InfRefmsgid string `json:"inf_refmsgid"`
  4645. Infcode int64 `json:"infcode"`
  4646. Output struct {
  4647. Result struct {
  4648. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4649. } `json:"result"`
  4650. } `json:"output"`
  4651. RefmsgTime string `json:"refmsg_time"`
  4652. RespondTime string `json:"respond_time"`
  4653. Signtype interface{} `json:"signtype"`
  4654. WarnInfo interface{} `json:"warn_info"`
  4655. }
  4656. type ResultThirteen10265 struct {
  4657. ErrMsg string `json:"err_msg"`
  4658. InfRefmsgid string `json:"inf_refmsgid"`
  4659. Infcode string `json:"infcode"`
  4660. Output struct {
  4661. Result struct {
  4662. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4663. } `json:"result"`
  4664. } `json:"output"`
  4665. RefmsgTime string `json:"refmsg_time"`
  4666. RespondTime string `json:"respond_time"`
  4667. Signtype interface{} `json:"signtype"`
  4668. WarnInfo interface{} `json:"warn_info"`
  4669. }
  4670. type ResultFourteen struct {
  4671. ErrMsg string `json:"err_msg"`
  4672. InfRefmsgid string `json:"inf_refmsgid"`
  4673. Infcode int64 `json:"infcode"`
  4674. Output struct {
  4675. } `json:"output"`
  4676. RefmsgTime string `json:"refmsg_time"`
  4677. RespondTime string `json:"respond_time"`
  4678. Signtype interface{} `json:"signtype"`
  4679. WarnInfo interface{} `json:"warn_info"`
  4680. }
  4681. type ResultFourteen10265 struct {
  4682. ErrMsg string `json:"err_msg"`
  4683. InfRefmsgid string `json:"inf_refmsgid"`
  4684. Infcode string `json:"infcode"`
  4685. Output struct {
  4686. } `json:"output"`
  4687. RefmsgTime string `json:"refmsg_time"`
  4688. RespondTime string `json:"respond_time"`
  4689. Signtype interface{} `json:"signtype"`
  4690. WarnInfo interface{} `json:"warn_info"`
  4691. }
  4692. type ResultSixteen struct {
  4693. Cainfo string `json:"cainfo"`
  4694. ErrMsg string `json:"err_msg"`
  4695. InfRefmsgid string `json:"inf_refmsgid"`
  4696. Infcode int64 `json:"infcode"`
  4697. Output struct {
  4698. Setldetail []interface{} `json:"setldetail"`
  4699. Setlinfo struct {
  4700. MdtrtID string `json:"mdtrt_id"`
  4701. SetlID string `json:"setl_id"`
  4702. ClrOptins string `json:"clr_optins"`
  4703. SetlTime string `json:"setl_time"`
  4704. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4705. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4706. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4707. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4708. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4709. ActPayDedc float64 `json:"act_pay_dedc"`
  4710. HifpPay float64 `json:"hifp_pay"`
  4711. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4712. Lfpay float64 `json:"selfpay"`
  4713. CvlservPay float64 `json:"cvlserv_pay"`
  4714. HifesPay float64 `json:"hifes_pay"`
  4715. HifmiPay float64 `json:"hifmi_pay"`
  4716. HifobPay float64 `json:"hifob_pay"`
  4717. MafPay float64 `json:"maf_pay"`
  4718. OthPay float64 `json:"oth_pay"`
  4719. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4720. PsnPartAmt float64 `json:"psn_part_amt"`
  4721. AcctPay float64 `json:"acct_pay"`
  4722. Balc float64 `json:"balc"`
  4723. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4724. HospPartAmt float64 `json:"hosp_part_amt"`
  4725. MedinsSetlID string `json:"medins_setl_id"`
  4726. PdnCashPay string `json:"pdn_cash_pay"`
  4727. } `json:"setlinfo"`
  4728. } `json:"output"`
  4729. RefmsgTime string `json:"refmsg_time"`
  4730. RespondTime string `json:"respond_time"`
  4731. Signtype interface{} `json:"signtype"`
  4732. WarnMsg interface{} `json:"warn_msg"`
  4733. }
  4734. type ResultSixteen10265 struct {
  4735. Cainfo string `json:"cainfo"`
  4736. ErrMsg string `json:"err_msg"`
  4737. InfRefmsgid string `json:"inf_refmsgid"`
  4738. Infcode string `json:"infcode"`
  4739. Output struct {
  4740. Setldetail []interface{} `json:"setldetail"`
  4741. Setlinfo struct {
  4742. MdtrtID string `json:"mdtrt_id"`
  4743. SetlID string `json:"setl_id"`
  4744. ClrOptins string `json:"clr_optins"`
  4745. SetlTime string `json:"setl_time"`
  4746. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4747. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4748. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4749. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4750. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4751. ActPayDedc float64 `json:"act_pay_dedc"`
  4752. HifpPay float64 `json:"hifp_pay"`
  4753. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4754. Lfpay float64 `json:"selfpay"`
  4755. CvlservPay float64 `json:"cvlserv_pay"`
  4756. HifesPay float64 `json:"hifes_pay"`
  4757. HifmiPay float64 `json:"hifmi_pay"`
  4758. HifobPay float64 `json:"hifob_pay"`
  4759. MafPay float64 `json:"maf_pay"`
  4760. OthPay float64 `json:"oth_pay"`
  4761. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4762. PsnPartAmt float64 `json:"psn_part_amt"`
  4763. AcctPay float64 `json:"acct_pay"`
  4764. Balc float64 `json:"balc"`
  4765. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4766. HospPartAmt float64 `json:"hosp_part_amt"`
  4767. MedinsSetlID string `json:"medins_setl_id"`
  4768. PdnCashPay string `json:"pdn_cash_pay"`
  4769. } `json:"setlinfo"`
  4770. } `json:"output"`
  4771. RefmsgTime string `json:"refmsg_time"`
  4772. RespondTime string `json:"respond_time"`
  4773. Signtype interface{} `json:"signtype"`
  4774. WarnMsg interface{} `json:"warn_msg"`
  4775. }
  4776. type ResultSeventeen struct {
  4777. ErrMsg string `json:"err_msg"`
  4778. InfRefmsgid string `json:"inf_refmsgid"`
  4779. Infcode int64 `json:"infcode"`
  4780. Output struct {
  4781. SetlListId string `json:"setl_list_id"`
  4782. } `json:"output"`
  4783. RefmsgTime string `json:"refmsg_time"`
  4784. RespondTime string `json:"respond_time"`
  4785. Signtype string `json:"signtype"`
  4786. WarnInfo string `json:"warn_info"`
  4787. }
  4788. type ResultSeventeenOther struct {
  4789. ErrMsg string `json:"err_msg"`
  4790. InfRefmsgid string `json:"inf_refmsgid"`
  4791. Infcode string `json:"infcode"`
  4792. Output struct {
  4793. SetlListId string `json:"setl_list_id"`
  4794. } `json:"output"`
  4795. RefmsgTime string `json:"refmsg_time"`
  4796. RespondTime string `json:"respond_time"`
  4797. Signtype string `json:"signtype"`
  4798. WarnInfo string `json:"warn_info"`
  4799. }
  4800. type Result90991 struct {
  4801. ErrMsg string `json:"err_msg"`
  4802. InfRefmsgid string `json:"inf_refmsgid"`
  4803. Infcode int64 `json:"infcode"`
  4804. Output struct {
  4805. Result struct {
  4806. PsnNo string `json:"psn_no"`
  4807. CardStat string `json:"card_stat"`
  4808. Certno string `json:"certno"`
  4809. PsnName string `json:"psn_name"`
  4810. CheckStat string `json:"check_stat"`
  4811. SscnoCheckStat string `json:"sscno_check_stat"`
  4812. } `json:"result"`
  4813. } `json:"output"`
  4814. RefmsgTime string `json:"refmsg_time"`
  4815. RespondTime string `json:"respond_time"`
  4816. Signtype interface{} `json:"signtype"`
  4817. WarnInfo interface{} `json:"warn_info"`
  4818. }
  4819. type Result90100 struct {
  4820. ErrMsg string `json:"err_msg"`
  4821. InfRefmsgid string `json:"inf_refmsgid"`
  4822. Infcode int64 `json:"infcode"`
  4823. Output struct {
  4824. PoolareaNo string `json:"poolarea_no"`
  4825. PoolareaNoName string `json:"poolarea_no_name"`
  4826. Insutype string `json:"insutype"`
  4827. InsutypeName string `json:"insutype_name"`
  4828. ClctType string `json:"clct_type"`
  4829. ClctTypeName string `json:"clct_type_name"`
  4830. ClctFlag string `json:"clct_flag"`
  4831. ClctFlagName string `json:"clct_flag_name"`
  4832. AccrymBegn string `json:"accrym_begn"`
  4833. AccrymEnd string `json:"accrym_end"`
  4834. ClctTime string `json:"clct_time"`
  4835. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4836. } `json:"output"`
  4837. RefmsgTime string `json:"refmsg_time"`
  4838. RespondTime string `json:"respond_time"`
  4839. Signtype interface{} `json:"signtype"`
  4840. WarnInfo interface{} `json:"warn_info"`
  4841. }
  4842. type Custom struct {
  4843. DetItemFeeSumamt string
  4844. Cut string
  4845. FeedetlSn string
  4846. Price string
  4847. MedListCodg string
  4848. Type int64
  4849. AdviceId int64
  4850. ProjectId int64
  4851. ItemId int64
  4852. }
  4853. type Result5301 struct {
  4854. ErrMsg string `json:"err_msg"`
  4855. InfRefmsgid string `json:"inf_refmsgid"`
  4856. Infcode int64 `json:"infcode"`
  4857. Output struct {
  4858. Result []struct {
  4859. OpspDiseCode string `json:"opsp_dise_code"`
  4860. OpspDiseName string `json:"opsp_dise_name"`
  4861. Begndate string `json:"begndate"`
  4862. Enddate string `json:"enddate"`
  4863. } `json:"feedetail"`
  4864. } `json:"output"`
  4865. RefmsgTime string `json:"refmsg_time"`
  4866. RespondTime string `json:"respond_time"`
  4867. Signtype interface{} `json:"signtype"`
  4868. WarnInfo interface{} `json:"warn_info"`
  4869. }
  4870. type Result5301For10265 struct {
  4871. ErrMsg string `json:"err_msg"`
  4872. InfRefmsgid string `json:"inf_refmsgid"`
  4873. Infcode string `json:"infcode"`
  4874. Output struct {
  4875. Result []struct {
  4876. OpspDiseCode string `json:"opsp_dise_code"`
  4877. OpspDiseName string `json:"opsp_dise_name"`
  4878. Begndate string `json:"begndate"`
  4879. Enddate string `json:"enddate"`
  4880. } `json:"feedetail"`
  4881. } `json:"output"`
  4882. RefmsgTime string `json:"refmsg_time"`
  4883. RespondTime string `json:"respond_time"`
  4884. Signtype interface{} `json:"signtype"`
  4885. WarnInfo interface{} `json:"warn_info"`
  4886. }
  4887. //获取个人信息----挂号-----上传就诊信息
  4888. func (c *HisApiController) GetRegisterInfo() {
  4889. id, _ := c.GetInt64("id")
  4890. record_time := c.GetString("record_time")
  4891. settlementValue, _ := c.GetInt64("settlement_value")
  4892. medical_insurance_card := c.GetString("medical_insurance_card")
  4893. name := c.GetString("name")
  4894. id_card_type, _ := c.GetInt64("id_card_type")
  4895. certificates, _ := c.GetInt64("certificates")
  4896. medical_care, _ := c.GetInt64("medical_care")
  4897. birthday := c.GetString("birthday")
  4898. id_card := c.GetString("id_card")
  4899. register_type, _ := c.GetInt64("register")
  4900. doctor, _ := c.GetInt64("doctor")
  4901. department, _ := c.GetInt64("department")
  4902. gender, _ := c.GetInt64("sex")
  4903. registration_fee, _ := c.GetFloat("registration_fee")
  4904. medical_expenses, _ := c.GetFloat("medical_expenses")
  4905. social_type, _ := c.GetInt64("social_type")
  4906. med_type := c.GetString("social_type")
  4907. admin_user_id, _ := c.GetInt64("admin_user_id")
  4908. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4909. timeLayout := "2006-01-02"
  4910. loc, _ := time.LoadLocation("Local")
  4911. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4912. birthUnix := birthdays.Unix()
  4913. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4914. if err != nil {
  4915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4916. return
  4917. }
  4918. recordDateTime := theTime.Unix()
  4919. adminInfo := c.GetAdminUserInfo()
  4920. var patient service.Patients
  4921. if id == 0 {
  4922. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4923. } else {
  4924. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4925. }
  4926. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4927. if patientPrescription.ID == 0 {
  4928. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4929. }
  4930. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4931. if patient.ID == 0 {
  4932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4933. return
  4934. }
  4935. if len(patient.IdCardNo) == 0 {
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4937. return
  4938. }
  4939. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4940. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4941. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4942. //就诊结算未完成,不能进行二次挂号
  4943. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4944. if len(his) >= 1 {
  4945. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4946. if len(his) >= 1 && order.ID == 0 {
  4947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4948. return
  4949. }
  4950. }
  4951. //var register_log string
  4952. if config.IsOpen == 1 {
  4953. var res ResultTwo
  4954. var res10265 ResultTwo10265
  4955. var PsnNo string
  4956. var PsnCertType string
  4957. var Certno string
  4958. var PsnName string
  4959. var Gend string
  4960. var Naty string
  4961. var Brdy string
  4962. var Age float64
  4963. var infoStr string
  4964. var idetinfoStr string
  4965. var infocode int64
  4966. var verify_number string
  4967. fmt.Println(verify_number)
  4968. if miConfig.MdtrtareaAdmvs == "421300" {
  4969. psn_info, _ := service.GetPsnByPatientId(id)
  4970. PsnNo = psn_info.PsnNo
  4971. PsnCertType = psn_info.PsnCertType
  4972. Certno = psn_info.Certno
  4973. PsnName = psn_info.PsnName
  4974. Gend = psn_info.Gend
  4975. Naty = psn_info.Naty
  4976. Brdy = psn_info.Brdy
  4977. Age = psn_info.Age
  4978. infoStr = psn_info.Insuinfo
  4979. idetinfoStr = psn_info.Idetinfo
  4980. infocode = 0
  4981. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4982. psn_info, _ := service.GetPsnByPatientId(id)
  4983. PsnNo = psn_info.PsnNo
  4984. PsnCertType = psn_info.PsnCertType
  4985. Certno = psn_info.Certno
  4986. PsnName = psn_info.PsnName
  4987. Gend = psn_info.Gend
  4988. Naty = psn_info.Naty
  4989. Brdy = psn_info.Brdy
  4990. Age = psn_info.Age
  4991. infoStr = psn_info.Insuinfo
  4992. idetinfoStr = psn_info.Idetinfo
  4993. infocode = 0
  4994. verify_number = psn_info.VerifyNumber
  4995. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4996. if id_card_type == 1 {
  4997. psn_info, _ := service.GetPsnByPatientId(id)
  4998. PsnNo = psn_info.PsnNo
  4999. PsnCertType = psn_info.PsnCertType
  5000. Certno = psn_info.Certno
  5001. PsnName = psn_info.PsnName
  5002. Gend = psn_info.Gend
  5003. Naty = psn_info.Naty
  5004. Brdy = psn_info.Brdy
  5005. Age = psn_info.Age
  5006. infoStr = psn_info.Insuinfo
  5007. idetinfoStr = psn_info.Idetinfo
  5008. infocode = 0
  5009. verify_number = psn_info.VerifyNumber
  5010. } else if id_card_type == 2 {
  5011. 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)
  5012. fmt.Println(errMsgLog)
  5013. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5014. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5015. utils.ErrorLog("解析失败:%v", err)
  5016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5017. return
  5018. }
  5019. PsnNo = res.Output.Baseinfo.PsnNo
  5020. PsnCertType = res.Output.Baseinfo.PsnCertType
  5021. Certno = res.Output.Baseinfo.Certno
  5022. PsnName = res.Output.Baseinfo.PsnName
  5023. Gend = res.Output.Baseinfo.Gend
  5024. Naty = res.Output.Baseinfo.Naty
  5025. Brdy = res.Output.Baseinfo.Brdy
  5026. Age = res.Output.Baseinfo.Age
  5027. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5028. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5029. infoStr = string(Iinfos)
  5030. idetinfoStr = string(Idetinfos)
  5031. infocode = res.Infcode
  5032. }
  5033. } else {
  5034. var result string
  5035. var requestLog string
  5036. if miConfig.UserOrgId == 10138 {
  5037. if id_card_type == 4 {
  5038. psn_info, _ := service.GetPsnByPatientId(id)
  5039. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  5040. } else {
  5041. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  5042. }
  5043. } else {
  5044. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  5045. }
  5046. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5047. if miConfig.Code == "H15049901371" {
  5048. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5049. utils.ErrorLog("解析失败:%v", err)
  5050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5051. return
  5052. }
  5053. res.ErrMsg = res10265.ErrMsg
  5054. res.Output = res10265.Output
  5055. res.InfRefmsgid = res10265.InfRefmsgid
  5056. } else {
  5057. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5058. utils.ErrorLog("解析失败:%v", err)
  5059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5060. return
  5061. }
  5062. }
  5063. PsnNo = res.Output.Baseinfo.PsnNo
  5064. PsnCertType = res.Output.Baseinfo.PsnCertType
  5065. Certno = res.Output.Baseinfo.Certno
  5066. PsnName = res.Output.Baseinfo.PsnName
  5067. Gend = res.Output.Baseinfo.Gend
  5068. Naty = res.Output.Baseinfo.Naty
  5069. Brdy = res.Output.Baseinfo.Brdy
  5070. Age = res.Output.Baseinfo.Age
  5071. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5072. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5073. infoStr = string(Iinfos)
  5074. idetinfoStr = string(Idetinfos)
  5075. if miConfig.Code == "H15049901371" {
  5076. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  5077. } else {
  5078. infocode = res.Infcode
  5079. }
  5080. }
  5081. if infocode == 0 {
  5082. his := models.VMHisPatient{
  5083. Name: name,
  5084. Gender: gender,
  5085. Birthday: birthUnix,
  5086. MedicalTreatmentType: medical_care,
  5087. IdType: certificates,
  5088. IdCardNo: id_card,
  5089. BalanceAccountsType: settlementValue,
  5090. SocialType: social_type,
  5091. MedicalInsuranceNumber: medical_insurance_card,
  5092. RegisterType: register_type,
  5093. RegisterCost: registration_fee,
  5094. TreatmentCost: medical_expenses,
  5095. Status: 1,
  5096. Ctime: time.Now().Unix(),
  5097. Mtime: time.Now().Unix(),
  5098. PsnNo: PsnNo,
  5099. PsnCertType: PsnCertType,
  5100. Certno: Certno,
  5101. PsnName: PsnName,
  5102. Gend: Gend,
  5103. Naty: Naty,
  5104. Brdy: Brdy,
  5105. Age: Age,
  5106. Iinfo: infoStr,
  5107. Idetinfo: idetinfoStr,
  5108. PatientId: patient.ID,
  5109. RecordDate: theTime.Unix(),
  5110. UserOrgId: adminInfo.CurrentOrgId,
  5111. AdminUserId: admin_user_id,
  5112. IsReturn: 1,
  5113. IdCardType: id_card_type,
  5114. Doctor: doctor,
  5115. Departments: department,
  5116. }
  5117. timestamp := time.Now().Unix()
  5118. tempTime := time.Unix(timestamp, 0)
  5119. timeFormat := tempTime.Format("20060102150405")
  5120. chrgBchno := rand.Intn(100000) + 10000
  5121. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5122. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  5123. department, _ := service.GetDepartMentDetail(department)
  5124. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  5125. IdCardNo := ""
  5126. if id_card_type == 1 {
  5127. // IdCardNo = medical_insurance_card
  5128. IdCardNo = patient.IdCardNo
  5129. } else {
  5130. IdCardNo = patient.IdCardNo
  5131. }
  5132. var rf []*ResultFive
  5133. json.Unmarshal([]byte(his.Iinfo), &rf)
  5134. var insutypes []*ResultFive
  5135. var insutype string
  5136. var insuplc_admdvs_temp string
  5137. var is390 int = 0
  5138. var is310 int = 0
  5139. for _, item := range rf {
  5140. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5141. insutypes = append(insutypes, item)
  5142. }
  5143. }
  5144. if len(insutypes) == 1 {
  5145. insutype = insutypes[0].Insutype
  5146. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5147. } else {
  5148. for _, i := range insutypes {
  5149. if i.Insutype == "390" {
  5150. is390 = 1
  5151. }
  5152. if i.Insutype == "310" {
  5153. is310 = 1
  5154. }
  5155. }
  5156. }
  5157. if is390 == 1 {
  5158. insutype = "390"
  5159. }
  5160. if is310 == 1 {
  5161. insutype = "310"
  5162. }
  5163. if len(insutypes) == 0 {
  5164. insutype = "310"
  5165. }
  5166. if len(insutypes) == 2 {
  5167. insutype = med_type
  5168. }
  5169. if len(med_type) > 0 {
  5170. insutype = med_type
  5171. }
  5172. //for _, item := range rf {
  5173. // if item.Insutype == insutype {
  5174. // insuplc_admdvs = item.InsuplcAdmdvs
  5175. // }
  5176. //}
  5177. var infocode int64
  5178. var resThree ResultThree
  5179. var resThree10265 ResultThree10265
  5180. if len(insuplc_admdvs) == 0 {
  5181. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  5182. } else {
  5183. insuplc_admdvs_temp = insuplc_admdvs
  5184. }
  5185. if miConfig.MdtrtareaAdmvs == "421300" {
  5186. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  5187. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  5188. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5189. "&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
  5190. resp, requestErr := http.Get(api)
  5191. if requestErr != nil {
  5192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5193. return
  5194. }
  5195. body, ioErr := ioutil.ReadAll(resp.Body)
  5196. if ioErr != nil {
  5197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5199. return
  5200. }
  5201. var respJSON map[string]interface{}
  5202. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5205. return
  5206. }
  5207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5208. result, _ := json.Marshal(respJSON)
  5209. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5210. utils.ErrorLog("解析失败:%v", err)
  5211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5212. return
  5213. }
  5214. infocode = resThree.Infcode
  5215. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5216. psn_info, _ := service.GetPsnByPatientId(id)
  5217. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5218. var cert_no string
  5219. if id_card_type == 3 {
  5220. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  5221. cert_no = IdCardNo
  5222. } else if id_card_type == 4 {
  5223. cert_no = IdCardNo
  5224. psn_info.VerifyNumber = psn_info.VerifyNumber
  5225. } else {
  5226. bas := strings.Split(psn_info.CardInfo, "|")
  5227. cert_no = bas[2]
  5228. }
  5229. var hisPrescription []*models.HisPrescription
  5230. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  5231. if res3101.Infcode == "0" && len(res3101.Output.Result) > 0 {
  5232. for _, item := range res3101.Output.Result {
  5233. if len(res3101.ErrMsg) == 0 {
  5234. res3101.ErrMsg = item.VolaCont
  5235. } else {
  5236. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  5237. }
  5238. }
  5239. c.ServeSuccessJSON(map[string]interface{}{
  5240. "failed_code": -10,
  5241. "msg": res3101.ErrMsg,
  5242. })
  5243. return
  5244. } else if res3101.Infcode != "0" {
  5245. c.ServeSuccessJSON(map[string]interface{}{
  5246. "failed_code": -10,
  5247. "msg": res3101.ErrMsg,
  5248. })
  5249. return
  5250. }
  5251. var api string
  5252. if miConfig.MdtrtareaAdmvs == "320921" {
  5253. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5254. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5255. "&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
  5256. } else {
  5257. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5258. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5259. "&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
  5260. }
  5261. resp, requestErr := http.Get(api)
  5262. if requestErr != nil {
  5263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5264. return
  5265. }
  5266. body, ioErr := ioutil.ReadAll(resp.Body)
  5267. if ioErr != nil {
  5268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5270. return
  5271. }
  5272. var respJSON map[string]interface{}
  5273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5276. return
  5277. }
  5278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5279. result, _ := json.Marshal(respJSON)
  5280. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5281. utils.ErrorLog("解析失败:%v", err)
  5282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5283. return
  5284. }
  5285. resThree.ErrMsg = resThree10265.ErrMsg
  5286. resThree.Output = resThree10265.Output
  5287. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5288. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5289. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5290. psn_info, _ := service.GetPsnByPatientId(id)
  5291. var cert_no string
  5292. if id_card_type == 1 {
  5293. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5294. } else {
  5295. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  5296. }
  5297. fmt.Println(cert_no)
  5298. 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)
  5299. saveLog(result, requestLog, "2201", "挂号")
  5300. if miConfig.Code == "H15049901371" {
  5301. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5302. utils.ErrorLog("解析失败:%v", err)
  5303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5304. return
  5305. }
  5306. resThree.ErrMsg = resThree10265.ErrMsg
  5307. resThree.Output = resThree10265.Output
  5308. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5309. } else {
  5310. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5311. utils.ErrorLog("解析失败:%v", err)
  5312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5313. return
  5314. }
  5315. }
  5316. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5317. } else {
  5318. psn_info, _ := service.GetPsnByPatientId(id)
  5319. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  5320. saveLog(result, requestLog, "2201A", "挂号")
  5321. if miConfig.Code == "H15049901371" {
  5322. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5323. utils.ErrorLog("解析失败:%v", err)
  5324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5325. return
  5326. }
  5327. resThree.ErrMsg = resThree10265.ErrMsg
  5328. resThree.Output = resThree10265.Output
  5329. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5330. } else {
  5331. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5332. utils.ErrorLog("解析失败:%v", err)
  5333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5334. return
  5335. }
  5336. }
  5337. if miConfig.Code == "H15049901371" {
  5338. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5339. } else {
  5340. infocode = resThree.Infcode
  5341. }
  5342. }
  5343. if infocode != 0 {
  5344. adminUser := c.GetAdminUserInfo()
  5345. errlog := &models.HisOrderError{
  5346. UserOrgId: adminUser.CurrentOrgId,
  5347. Ctime: time.Now().Unix(),
  5348. Mtime: time.Now().Unix(),
  5349. ErrMsg: resThree.ErrMsg,
  5350. Status: 1,
  5351. PatientId: id,
  5352. RecordTime: recordDateTime,
  5353. Stage: 2,
  5354. }
  5355. service.CreateErrMsgLog(errlog)
  5356. c.ServeSuccessJSON(map[string]interface{}{
  5357. "failed_code": -10,
  5358. "msg": resThree.ErrMsg,
  5359. })
  5360. return
  5361. }
  5362. his.Number = resThree.Output.Data.MdtrtID
  5363. his.PsnNo = resThree.Output.Data.PsnNo
  5364. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5365. his.IdCardNo = patient.IdCardNo
  5366. his.PhoneNumber = patient.Phone
  5367. his.UserOrgId = adminInfo.CurrentOrgId
  5368. his.Insutype = insutype
  5369. his.Ctime = time.Now().Unix()
  5370. his.Mtime = time.Now().Unix()
  5371. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5372. his.Status = 1
  5373. service.UpdateHisPatientStatus(&his)
  5374. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5375. c.ServeSuccessJSON(map[string]interface{}{
  5376. "his_info": his,
  5377. })
  5378. } else {
  5379. adminUser := c.GetAdminUserInfo()
  5380. errlog := &models.HisOrderError{
  5381. UserOrgId: adminUser.CurrentOrgId,
  5382. Ctime: time.Now().Unix(),
  5383. Mtime: time.Now().Unix(),
  5384. ErrMsg: res.ErrMsg,
  5385. Status: 1,
  5386. PatientId: id,
  5387. RecordTime: recordDateTime,
  5388. Stage: 1,
  5389. }
  5390. service.CreateErrMsgLog(errlog)
  5391. c.ServeSuccessJSON(map[string]interface{}{
  5392. "failed_code": -10,
  5393. "msg": res.ErrMsg,
  5394. })
  5395. return
  5396. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5397. }
  5398. }
  5399. }
  5400. //上传明细----预结算----确认订单
  5401. func (c *HisApiController) GetUploadInfo() {
  5402. id, _ := c.GetInt64("id")
  5403. record_time := c.GetString("record_time")
  5404. his_patient_id, _ := c.GetInt64("his_patient_id")
  5405. order_id, _ := c.GetInt64("order_id")
  5406. pay_way, _ := c.GetInt64("pay_way")
  5407. pay_price, _ := c.GetFloat("pay_price")
  5408. pay_card_no := c.GetString("pay_card_no")
  5409. token := c.GetString("token")
  5410. discount_price, _ := c.GetFloat("discount_price")
  5411. preferential_price, _ := c.GetFloat("preferential_price")
  5412. reality_price, _ := c.GetFloat("reality_price")
  5413. found_price, _ := c.GetFloat("found_price")
  5414. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5415. private_price, _ := c.GetFloat("private_price")
  5416. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5417. admin_user_id, _ := c.GetInt64("admin_user_id")
  5418. fapiao_code := c.GetString("fapiao_code")
  5419. fapiao_number := c.GetString("fapiao_number")
  5420. diagnosis_id := c.GetString("diagnosis")
  5421. sick_type, _ := c.GetInt64("sick_type")
  5422. reg_type, _ := c.GetInt64("p_type")
  5423. begin_time := c.GetString("begin_time")
  5424. id_str := c.GetString("ids")
  5425. ids_arr := strings.Split(id_str, ",")
  5426. timeLayout := "2006-01-02"
  5427. loc, _ := time.LoadLocation("Local")
  5428. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5429. if err != nil {
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5431. return
  5432. }
  5433. recordDateTime := theTime.Unix()
  5434. adminUser := c.GetAdminUserInfo()
  5435. var tempOrder models.HisOrder
  5436. tempOrder, _ = service.GetHisOrderByID(order_id)
  5437. var prescriptions []*models.HisPrescription
  5438. var start_time int64
  5439. var end_time int64
  5440. //押金模块
  5441. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5442. tmp_decimal := c.GetString("tmp_decimal")
  5443. var decimal float64 //本次使用的押金
  5444. var errmsg error
  5445. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5446. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5447. return
  5448. }
  5449. if len(tmp_decimal) > 0 {
  5450. if tmp_decimal[0] == 45 {
  5451. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5452. return
  5453. }
  5454. }
  5455. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5456. fmt.Println(errs)
  5457. decimal = tt
  5458. //if adminUser.CurrentOrgId == 10106{
  5459. // if len(fapiao_code) == 0{
  5460. // fapiao_code = "144072080589"
  5461. // }
  5462. // if len(fapiao_number) == 0{
  5463. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5464. // if order.ID == 0{
  5465. // fapiao_number = "00001520"
  5466. // }else{
  5467. // //fapiao_code = "00001520"
  5468. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5469. // var zero string
  5470. // if fpNumber >= 1000{
  5471. // zero = "0000" + strconv.Itoa(fpNumber)
  5472. // }else if fpNumber >= 10000{
  5473. // zero = "000" + strconv.Itoa(fpNumber)
  5474. // } else if fpNumber >= 100000{
  5475. // zero = "00" + strconv.Itoa(fpNumber)
  5476. // } else if fpNumber >= 1000000{
  5477. // zero = "0" + strconv.Itoa(fpNumber)
  5478. // }else {
  5479. // zero = strconv.Itoa(fpNumber)
  5480. // }
  5481. // fapiao_number = zero
  5482. // }
  5483. // }
  5484. //}
  5485. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5486. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5487. var patientPrescription models.HisPrescriptionInfo
  5488. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5489. if patientPrescription.ID == 0 {
  5490. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5491. }
  5492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5493. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5494. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5495. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5496. var config []*models.HisXtDiagnoseConfig
  5497. for _, item := range diagnosis_ids {
  5498. id, _ := strconv.ParseInt(item, 10, 64)
  5499. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5500. config = append(config, &diagnosisConfig)
  5501. }
  5502. sickConfig, _ := service.FindSickById(sick_type)
  5503. //if tempOrder.ID == 0 {
  5504. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5505. //}
  5506. if tempOrder.ID == 0 {
  5507. var result string
  5508. var requestLog string
  5509. var res2 ResultSix
  5510. var ressix10265 ResultSix10265
  5511. if miConfig.MdtrtareaAdmvs == "421300" {
  5512. data := make(map[string]interface{})
  5513. client := &http.Client{}
  5514. data["psn_no"] = his.PsnNo
  5515. data["mdtrt_id"] = his.Number
  5516. data["opter"] = roles.UserName
  5517. data["org_name"] = miConfig.OrgName
  5518. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5519. data["doctor_id"] = doctor_info.DoctorNumber
  5520. data["doctor_name"] = doctor_info.UserName
  5521. data["department"] = department.Name
  5522. data["fixmedins_code"] = miConfig.Code
  5523. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5524. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5525. data["secret_key"] = miConfig.SecretKey
  5526. data["sick_code"] = sickConfig.CountryCode
  5527. data["sick_name"] = sickConfig.ClassName
  5528. data["dept"] = strconv.FormatInt(department.ID, 10)
  5529. data["config"] = config
  5530. data["begin_time"] = begin_time
  5531. bytesData, _ := json.Marshal(data)
  5532. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5533. resp, _ := client.Do(req)
  5534. defer resp.Body.Close()
  5535. body, ioErr := ioutil.ReadAll(resp.Body)
  5536. if ioErr != nil {
  5537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5539. return
  5540. }
  5541. var respJSON map[string]interface{}
  5542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5545. return
  5546. }
  5547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5548. userJSONBytes, _ := json.Marshal(respJSON)
  5549. fmt.Println("log")
  5550. fmt.Println(string(userJSONBytes))
  5551. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5552. utils.ErrorLog("解析失败:%v", err)
  5553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5554. return
  5555. }
  5556. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5557. //江苏地区国家医保医疗类别
  5558. //职工透析:医疗类别选特殊情况门诊9933
  5559. //居民血透门慢: 医疗类别选门诊慢病1402
  5560. //var med_type string
  5561. //if his.Insutype == "310" {
  5562. // if reg_type == 14 {
  5563. // med_type = "9933"
  5564. // } else if reg_type == 11 {
  5565. // med_type = "11"
  5566. //
  5567. // }
  5568. //} else if his.Insutype == "390" {
  5569. // if reg_type == 14 {
  5570. // med_type = "1402"
  5571. // } else if reg_type == 11 {
  5572. // med_type = "11"
  5573. // }
  5574. //}
  5575. data := make(map[string]interface{})
  5576. client := &http.Client{}
  5577. data["psn_no"] = his.PsnNo
  5578. data["mdtrt_id"] = his.Number
  5579. data["doctor"] = roles.UserName
  5580. data["department"] = department.Name
  5581. data["org_name"] = miConfig.OrgName
  5582. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5583. data["doctor_id"] = doctor_info.DoctorNumber
  5584. data["new_doctor_name"] = doctor_info.UserName
  5585. data["fixmedins_code"] = miConfig.Code
  5586. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5587. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5588. data["secret_key"] = miConfig.SecretKey
  5589. data["sick_code"] = sickConfig.CountryCode
  5590. data["sick_name"] = sickConfig.ClassName
  5591. data["url"] = miConfig.Url
  5592. data["ak"] = miConfig.AccessKey
  5593. data["begin_time"] = begin_time
  5594. data["cainfo"] = miConfig.Cainfo
  5595. data["dept"] = strconv.FormatInt(department.ID, 10)
  5596. data["config"] = config
  5597. bytesData, _ := json.Marshal(data)
  5598. var req *http.Request
  5599. if miConfig.MdtrtareaAdmvs == "320921" {
  5600. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5601. //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 +
  5602. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5603. } else {
  5604. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5605. }
  5606. resp, _ := client.Do(req)
  5607. defer resp.Body.Close()
  5608. body, ioErr := ioutil.ReadAll(resp.Body)
  5609. if ioErr != nil {
  5610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5612. return
  5613. }
  5614. var respJSON map[string]interface{}
  5615. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5618. return
  5619. }
  5620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5621. userJSONBytes, _ := json.Marshal(respJSON)
  5622. fmt.Println("log")
  5623. fmt.Println(string(userJSONBytes))
  5624. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5625. utils.ErrorLog("解析失败:%v", err)
  5626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5627. return
  5628. }
  5629. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5630. res2.Output = ressix10265.Output
  5631. res2.ErrMsg = ressix10265.ErrMsg
  5632. res2.Cainfo = ressix10265.Cainfo
  5633. res2.WarnMsg = ressix10265.WarnMsg
  5634. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5635. res2.Infcode = infocode
  5636. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5637. 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)
  5638. saveLog(result, requestLog, "2203", "上传就诊信息")
  5639. var respJSON2 map[string]interface{}
  5640. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5643. return
  5644. }
  5645. userJSONBytes2, _ := json.Marshal(respJSON2)
  5646. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5647. utils.ErrorLog("解析失败:%v", err)
  5648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5649. return
  5650. }
  5651. } else {
  5652. if miConfig.MdtrtareaAdmvs == "440781" { //
  5653. 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)
  5654. } else {
  5655. if miConfig.Code == "H15049901371" {
  5656. //赤峰地区国家医保医疗类别
  5657. //职工透析:医疗类别选特殊情况门诊990502
  5658. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5659. var med_type string
  5660. if his.Insutype == "390" {
  5661. if reg_type == 14 {
  5662. med_type = "9933"
  5663. } else if reg_type == 11 {
  5664. med_type = "11"
  5665. }
  5666. } else if his.Insutype == "310" {
  5667. if reg_type == 14 {
  5668. med_type = "990502"
  5669. } else if reg_type == 11 {
  5670. med_type = "11"
  5671. }
  5672. }
  5673. 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)
  5674. } else {
  5675. 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)
  5676. }
  5677. }
  5678. saveLog(result, requestLog, "2203", "上传就诊信息")
  5679. var respJSON2 map[string]interface{}
  5680. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5683. return
  5684. }
  5685. userJSONBytes2, _ := json.Marshal(respJSON2)
  5686. if miConfig.Code == "H15049901371" {
  5687. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5688. utils.ErrorLog("解析失败:%v", err)
  5689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5690. return
  5691. }
  5692. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5693. res2.Output = ressix10265.Output
  5694. res2.ErrMsg = ressix10265.ErrMsg
  5695. res2.Cainfo = ressix10265.Cainfo
  5696. res2.WarnMsg = ressix10265.WarnMsg
  5697. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5698. res2.Infcode = infocode
  5699. } else {
  5700. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5701. utils.ErrorLog("解析失败:%v", err)
  5702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5703. return
  5704. }
  5705. }
  5706. }
  5707. if res2.Infcode != 0 {
  5708. adminUser := c.GetAdminUserInfo()
  5709. errlog := &models.HisOrderError{
  5710. UserOrgId: adminUser.CurrentOrgId,
  5711. Ctime: time.Now().Unix(),
  5712. Mtime: time.Now().Unix(),
  5713. ErrMsg: res2.ErrMsg,
  5714. Status: 1,
  5715. PatientId: id,
  5716. RecordTime: recordDateTime,
  5717. Stage: 3,
  5718. }
  5719. service.CreateErrMsgLog(errlog)
  5720. c.ServeSuccessJSON(map[string]interface{}{
  5721. "failed_code": -10,
  5722. "msg": res2.ErrMsg,
  5723. })
  5724. return
  5725. } else {
  5726. his.Diagnosis = diagnosis_id
  5727. his.SickType = sickConfig.ID
  5728. //var p_type int64
  5729. //if reg_type == 1111 || reg_type == 1112 {
  5730. // p_type = 11
  5731. //
  5732. //}
  5733. his.PType = fmt.Sprintf("%d", reg_type)
  5734. service.UpdateHisPatientThree(&his)
  5735. data := make(map[string]interface{})
  5736. if settle_accounts_type == 1 { //日结
  5737. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5738. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5739. } else {
  5740. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5741. }
  5742. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5743. data["pre"] = prescriptions
  5744. } else { //月结
  5745. start_time_str := c.GetString("start_time")
  5746. end_time_str := c.GetString("end_time")
  5747. timeLayout := "2006-01-02"
  5748. loc, _ := time.LoadLocation("Local")
  5749. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5750. if err != nil {
  5751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5752. return
  5753. }
  5754. recordStartTime := theStartTime.Unix()
  5755. start_time = recordStartTime
  5756. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5757. if err != nil {
  5758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5759. return
  5760. }
  5761. recordEndTime := theEndTime.Unix()
  5762. end_time = recordEndTime
  5763. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5764. data["pre"] = prescriptions
  5765. }
  5766. timestamp := time.Now().Unix()
  5767. tempTime := time.Unix(timestamp, 0)
  5768. timeFormat := tempTime.Format("20060102150405")
  5769. chrgBchno := rand.Intn(100000) + 10000
  5770. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5771. strconv.FormatInt(his.PatientId, 10)
  5772. client := &http.Client{}
  5773. data["psn_no"] = his.PsnNo
  5774. data["mdtrt_id"] = his.Number
  5775. data["chrg_bchno"] = chrg_bchno
  5776. data["org_name"] = miConfig.OrgName
  5777. data["doctor"] = doctor_info.UserName
  5778. data["doctor_id"] = doctor_info.DoctorNumber
  5779. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5780. data["fixmedins_code"] = miConfig.Code
  5781. data["opter"] = roles.UserName
  5782. data["dept_code"] = department.Number
  5783. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5784. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5785. data["secret_key"] = miConfig.SecretKey
  5786. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5787. data["url"] = miConfig.Url
  5788. data["ak"] = miConfig.AccessKey
  5789. data["new_doctor_name"] = patientPrescription.Doctor
  5790. data["diag_code"] = sickConfig.CountryCode
  5791. data["cainfo"] = miConfig.Cainfo
  5792. var ids []int64
  5793. for _, item := range prescriptions {
  5794. ids = append(ids, item.ID)
  5795. }
  5796. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5797. if config.IsOpen == 1 { //对接了医保,走医保流程
  5798. var res ResultFour
  5799. var resFour10265 ResultFour10265
  5800. if miConfig.MdtrtareaAdmvs == "421300" {
  5801. bytesData, _ := json.Marshal(data)
  5802. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5803. resp, _ := client.Do(req)
  5804. defer resp.Body.Close()
  5805. body, ioErr := ioutil.ReadAll(resp.Body)
  5806. if ioErr != nil {
  5807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5809. return
  5810. }
  5811. var respJSON map[string]interface{}
  5812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5815. return
  5816. }
  5817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5818. userJSONBytes, _ := json.Marshal(respJSON)
  5819. fmt.Println("log")
  5820. fmt.Println(string(userJSONBytes))
  5821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5822. utils.ErrorLog("解析失败:%v", err)
  5823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5824. return
  5825. }
  5826. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5827. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5828. if result3101.Infcode == "0" {
  5829. if len(result3101.Output.Result) > 0 {
  5830. var errMsgs []string
  5831. for _, item := range result3101.Output.Result {
  5832. errMsgs = append(errMsgs, item.VolaCont)
  5833. }
  5834. c.ServeSuccessJSON(map[string]interface{}{
  5835. "failed_code": -10,
  5836. "msg": errMsgs,
  5837. })
  5838. return
  5839. }
  5840. }
  5841. bytesData, _ := json.Marshal(data)
  5842. var req *http.Request
  5843. if miConfig.MdtrtareaAdmvs == "320921" {
  5844. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5845. } else {
  5846. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5847. }
  5848. resp, _ := client.Do(req)
  5849. defer resp.Body.Close()
  5850. body, ioErr := ioutil.ReadAll(resp.Body)
  5851. if ioErr != nil {
  5852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5854. return
  5855. }
  5856. var respJSON map[string]interface{}
  5857. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5860. return
  5861. }
  5862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5863. userJSONBytes, _ := json.Marshal(respJSON)
  5864. fmt.Println("log")
  5865. fmt.Println(string(userJSONBytes))
  5866. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5867. utils.ErrorLog("解析失败:%v", err)
  5868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5869. return
  5870. }
  5871. res.InfRefmsgid = resFour10265.InfRefmsgid
  5872. res.Output = resFour10265.Output
  5873. res.ErrMsg = resFour10265.ErrMsg
  5874. res.Cainfo = resFour10265.Cainfo
  5875. res.WarnMsg = resFour10265.WarnMsg
  5876. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5877. res.Infcode = infocode
  5878. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5879. 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)
  5880. var dat map[string]interface{}
  5881. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5882. fmt.Println(dat)
  5883. } else {
  5884. fmt.Println(err)
  5885. }
  5886. saveLog(result, request_log, "2204", "上传费用明细")
  5887. userJSONBytes, _ := json.Marshal(dat)
  5888. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5889. utils.ErrorLog("解析失败:%v", err)
  5890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5891. return
  5892. }
  5893. res.InfRefmsgid = resFour10265.InfRefmsgid
  5894. res.Output = resFour10265.Output
  5895. res.ErrMsg = resFour10265.ErrMsg
  5896. res.Cainfo = resFour10265.Cainfo
  5897. res.WarnMsg = resFour10265.WarnMsg
  5898. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5899. res.Infcode = infocode
  5900. } else {
  5901. if miConfig.Code == "H15049901371" {
  5902. 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)
  5903. var dat map[string]interface{}
  5904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5905. fmt.Println(dat)
  5906. } else {
  5907. fmt.Println(err)
  5908. }
  5909. saveLog(result, request_log, "2204", "上传费用明细")
  5910. userJSONBytes, _ := json.Marshal(dat)
  5911. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5912. utils.ErrorLog("解析失败:%v", err)
  5913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5914. return
  5915. }
  5916. res.InfRefmsgid = resFour10265.InfRefmsgid
  5917. res.Output = resFour10265.Output
  5918. res.ErrMsg = resFour10265.ErrMsg
  5919. res.Cainfo = resFour10265.Cainfo
  5920. res.WarnMsg = resFour10265.WarnMsg
  5921. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5922. res.Infcode = infocode
  5923. } else {
  5924. 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)
  5925. var dat map[string]interface{}
  5926. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5927. fmt.Println(dat)
  5928. } else {
  5929. fmt.Println(err)
  5930. }
  5931. saveLog(result, request_log, "2204", "上传费用明细")
  5932. userJSONBytes, _ := json.Marshal(dat)
  5933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5934. utils.ErrorLog("解析失败:%v", err)
  5935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5936. return
  5937. }
  5938. }
  5939. }
  5940. if res.Infcode == 0 {
  5941. order := &models.HisOrder{
  5942. UserOrgId: adminUser.CurrentOrgId,
  5943. HisPatientId: his.ID,
  5944. PatientId: his.PatientId,
  5945. SettleAccountsDate: recordDateTime,
  5946. MdtrtId: his.Number,
  5947. PsnNo: his.PsnNo,
  5948. MedType: strconv.FormatInt(reg_type, 10),
  5949. Ctime: time.Now().Unix(),
  5950. Mtime: time.Now().Unix(),
  5951. Status: 1,
  5952. Number: chrg_bchno,
  5953. Infcode: res.Infcode,
  5954. WarnMsg: res.WarnMsg,
  5955. Cainfo: res.Cainfo,
  5956. ErrMsg: res.ErrMsg,
  5957. RespondTime: res.RefmsgTime,
  5958. InfRefmsgid: res.InfRefmsgid,
  5959. OrderStatus: 1,
  5960. PayWay: pay_way,
  5961. PayPrice: pay_price,
  5962. PayCardNo: pay_card_no,
  5963. DiscountPrice: discount_price,
  5964. PreferentialPrice: preferential_price,
  5965. RealityPrice: reality_price,
  5966. FoundPrice: found_price,
  5967. MedicalInsurancePrice: medical_insurance_price,
  5968. PrivatePrice: private_price,
  5969. IsMedicineInsurance: 1,
  5970. SettleType: settle_accounts_type,
  5971. SettleStartTime: start_time,
  5972. SettleEndTime: end_time,
  5973. Creator: roles.AdminUserId,
  5974. Modify: roles.AdminUserId,
  5975. FaPiaoNumber: fapiao_number,
  5976. FaPiaoCode: fapiao_code,
  5977. PType: 2,
  5978. Diagnosis: diagnosis_id,
  5979. }
  5980. err = service.CreateOrder(order)
  5981. if err != nil {
  5982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5983. return
  5984. }
  5985. for _, item := range res.Output.Result {
  5986. temp := strings.Split(item.FeedetlSn, "-")
  5987. var advice_id int64 = 0
  5988. var project_id int64 = 0
  5989. var types int64 = 0
  5990. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5991. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5992. if temp[1] == "1" {
  5993. advice_id = id
  5994. project_id = 0
  5995. } else if temp[1] == "2" {
  5996. advice_id = 0
  5997. project_id = id
  5998. }
  5999. info := &models.HisOrderInfo{
  6000. OrderNumber: order.Number,
  6001. FeedetlSn: item.FeedetlSn,
  6002. UploadDate: time.Now().Unix(),
  6003. AdviceId: advice_id,
  6004. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6005. Cnt: item.Cnt,
  6006. Pric: float64(item.Pric),
  6007. PatientId: his.PatientId,
  6008. PricUplmtAmt: item.PricUplmtAmt,
  6009. SelfpayProp: item.SelfpayProp,
  6010. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6011. OverlmtAmt: item.OverlmtAmt,
  6012. PreselfpayAmt: item.PreselfpayAmt,
  6013. BasMednFlag: item.BasMednFlag,
  6014. MedChrgitmType: item.MedChrgitmType,
  6015. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6016. Status: 1,
  6017. Memo: item.Memo,
  6018. Mtime: time.Now().Unix(),
  6019. InscpScpAmt: item.InscpScpAmt,
  6020. DrtReimFlag: item.DrtReimFlag,
  6021. Ctime: time.Now().Unix(),
  6022. ListSpItemFlag: item.ListSpItemFlag,
  6023. ChldMedcFlag: item.ChldMedcFlag,
  6024. LmtUsedFlag: item.LmtUsedFlag,
  6025. ChrgitmLv: item.ChrgitmLv,
  6026. UserOrgId: adminUser.CurrentOrgId,
  6027. HisPatientId: his.ID,
  6028. OrderId: order.ID,
  6029. ProjectId: project_id,
  6030. Type: types,
  6031. }
  6032. service.CreateOrderInfo(info)
  6033. }
  6034. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6035. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6036. var total float64
  6037. for _, item := range prescriptions {
  6038. if item.Type == 1 { //药品
  6039. for _, subItem := range item.HisDoctorAdviceInfo {
  6040. total = total + (subItem.Price * subItem.PrescribingNumber)
  6041. }
  6042. }
  6043. if item.Type == 2 { //项目
  6044. for _, subItem := range item.HisPrescriptionProject {
  6045. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6046. total = total + (subItem.Price * cnt)
  6047. }
  6048. }
  6049. }
  6050. for _, item := range prescriptions {
  6051. for _, subItem := range item.HisAdditionalCharge {
  6052. total = total + (subItem.Price * float64(subItem.Count))
  6053. }
  6054. }
  6055. var allTotal string
  6056. if adminUser.CurrentOrgId == 9919 {
  6057. allTotal = fmt.Sprintf("%.4f", total)
  6058. } else {
  6059. allTotal = fmt.Sprintf("%.4f", total)
  6060. }
  6061. if res.Infcode == 0 {
  6062. var rf []*ResultFive
  6063. json.Unmarshal([]byte(his.Iinfo), &rf)
  6064. chrg_bchno := chrg_bchno
  6065. cert_no := his.Certno
  6066. var insutypes []string
  6067. var insutype string
  6068. var is390 int = 0
  6069. var is310 int = 0
  6070. for _, item := range rf {
  6071. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6072. insutypes = append(insutypes, item.Insutype)
  6073. }
  6074. }
  6075. if len(insutypes) == 1 {
  6076. insutype = insutypes[0]
  6077. } else {
  6078. for _, i := range insutypes {
  6079. if i == "390" {
  6080. is390 = 1
  6081. }
  6082. if i == "310" {
  6083. is310 = 1
  6084. }
  6085. }
  6086. }
  6087. if is390 == 1 {
  6088. insutype = "390"
  6089. }
  6090. if is310 == 1 {
  6091. insutype = "310"
  6092. }
  6093. if len(insutypes) == 0 {
  6094. insutype = "310"
  6095. }
  6096. if len(insutypes) == 2 {
  6097. insutype = strconv.FormatInt(his.SocialType, 10)
  6098. }
  6099. insutype = strconv.FormatInt(his.SocialType, 10)
  6100. //insutype = "390"
  6101. if his.IdCardType == 1 {
  6102. // cert_no = his.MedicalInsuranceNumber
  6103. cert_no = his.Certno
  6104. } else {
  6105. cert_no = his.Certno
  6106. }
  6107. var res ResultSeven
  6108. var resSeven10265 ResultSeven10265
  6109. var src_resquest string
  6110. var result2 string
  6111. var acct_used_flag string
  6112. fmt.Println("pay_way")
  6113. fmt.Println(pay_way)
  6114. fmt.Println("pay_way")
  6115. if pay_way == 4 {
  6116. acct_used_flag = "1"
  6117. } else {
  6118. acct_used_flag = "0"
  6119. }
  6120. if miConfig.MdtrtareaAdmvs == "421300" {
  6121. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6122. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6123. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6124. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6125. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6126. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6127. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6128. resp, requestErr := http.Get(api)
  6129. if requestErr != nil {
  6130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6131. return
  6132. }
  6133. body, ioErr := ioutil.ReadAll(resp.Body)
  6134. if ioErr != nil {
  6135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6137. return
  6138. }
  6139. var respJSON map[string]interface{}
  6140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6143. return
  6144. }
  6145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6146. result, _ := json.Marshal(respJSON)
  6147. if miConfig.Code == "H15049901371" {
  6148. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6149. utils.ErrorLog("解析失败:%v", err)
  6150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6151. return
  6152. }
  6153. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6154. res.Output = resSeven10265.Output
  6155. res.ErrMsg = resSeven10265.ErrMsg
  6156. res.Cainfo = resSeven10265.Cainfo
  6157. res.WarnMsg = resSeven10265.WarnMsg
  6158. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6159. res.Infcode = infocode
  6160. } else {
  6161. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6162. utils.ErrorLog("解析失败:%v", err)
  6163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6164. return
  6165. }
  6166. }
  6167. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6168. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  6169. if result3101.Infcode == "0" {
  6170. if len(result3101.Output.Result) > 0 {
  6171. var errMsgs []string
  6172. for _, item := range result3101.Output.Result {
  6173. errMsgs = append(errMsgs, item.VolaCont)
  6174. }
  6175. c.ServeSuccessJSON(map[string]interface{}{
  6176. "failed_code": -10,
  6177. "msg": errMsgs,
  6178. })
  6179. return
  6180. }
  6181. }
  6182. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6183. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6184. bas := strings.Split(psn_info.CardInfo, "|")
  6185. if his.IdCardType == 1 {
  6186. cert_no = bas[2]
  6187. } else if his.IdCardType == 3 {
  6188. cert_no = his.Certno
  6189. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6190. } else if his.IdCardType == 4 {
  6191. cert_no = his.Certno
  6192. psn_info.VerifyNumber = token
  6193. }
  6194. var api string
  6195. if miConfig.MdtrtareaAdmvs == "320921" {
  6196. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6197. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6198. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6199. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6200. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6201. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6202. "&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
  6203. } else {
  6204. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6205. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6206. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6208. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6209. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6210. "&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
  6211. }
  6212. resp, requestErr := http.Get(api)
  6213. if requestErr != nil {
  6214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6215. return
  6216. }
  6217. body, ioErr := ioutil.ReadAll(resp.Body)
  6218. if ioErr != nil {
  6219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6221. return
  6222. }
  6223. var respJSON map[string]interface{}
  6224. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6227. return
  6228. }
  6229. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6230. result, _ := json.Marshal(respJSON)
  6231. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6232. utils.ErrorLog("解析失败:%v", err)
  6233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6234. return
  6235. }
  6236. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6237. res.Output = resSeven10265.Output
  6238. res.ErrMsg = resSeven10265.ErrMsg
  6239. res.Cainfo = resSeven10265.Cainfo
  6240. res.WarnMsg = resSeven10265.WarnMsg
  6241. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6242. res.Infcode = infocode
  6243. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6244. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6245. var cert_no string
  6246. if his.IdCardType == 1 {
  6247. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6248. }
  6249. fmt.Println(cert_no)
  6250. 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)
  6251. //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)
  6252. var dat map[string]interface{}
  6253. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6254. fmt.Println(dat)
  6255. } else {
  6256. fmt.Println(err)
  6257. }
  6258. saveLog(result2, src_resquest, "2207", "结算")
  6259. userJSONBytes, _ := json.Marshal(dat)
  6260. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6261. utils.ErrorLog("解析失败:%v", err)
  6262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. return
  6264. }
  6265. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6266. res.Output = resSeven10265.Output
  6267. res.ErrMsg = resSeven10265.ErrMsg
  6268. res.Cainfo = resSeven10265.Cainfo
  6269. res.WarnMsg = resSeven10265.WarnMsg
  6270. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6271. res.Infcode = infocode
  6272. } else {
  6273. if miConfig.Code == "H15049901371" {
  6274. //赤峰地区国家医保医疗类别
  6275. //职工透析:医疗类别选特殊情况门诊990502
  6276. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6277. var med_type string
  6278. if his.Insutype == "390" {
  6279. if reg_type == 14 {
  6280. med_type = "9933"
  6281. } else if reg_type == 11 {
  6282. med_type = "11"
  6283. }
  6284. } else if his.Insutype == "310" {
  6285. if reg_type == 14 {
  6286. med_type = "990502"
  6287. } else if reg_type == 11 {
  6288. med_type = "11"
  6289. }
  6290. }
  6291. 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)
  6292. } else {
  6293. 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)
  6294. }
  6295. //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)
  6296. var dat map[string]interface{}
  6297. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6298. fmt.Println(dat)
  6299. } else {
  6300. fmt.Println(err)
  6301. }
  6302. saveLog(result2, src_resquest, "2207", "结算")
  6303. userJSONBytes, _ := json.Marshal(dat)
  6304. if miConfig.Code == "H15049901371" {
  6305. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6306. utils.ErrorLog("解析失败:%v", err)
  6307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6308. return
  6309. }
  6310. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6311. res.Output = resSeven10265.Output
  6312. res.ErrMsg = resSeven10265.ErrMsg
  6313. res.Cainfo = resSeven10265.Cainfo
  6314. res.WarnMsg = resSeven10265.WarnMsg
  6315. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6316. res.Infcode = infocode
  6317. } else {
  6318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6319. utils.ErrorLog("解析失败:%v", err)
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. return
  6322. }
  6323. }
  6324. }
  6325. if res.Infcode != 0 {
  6326. errlog := &models.HisOrderError{
  6327. UserOrgId: adminUser.CurrentOrgId,
  6328. Ctime: time.Now().Unix(),
  6329. Mtime: time.Now().Unix(),
  6330. Number: chrg_bchno,
  6331. ErrMsg: res.ErrMsg,
  6332. Status: 1,
  6333. PatientId: id,
  6334. RecordTime: recordDateTime,
  6335. Stage: 6,
  6336. }
  6337. service.CreateErrMsgLog(errlog)
  6338. c.ServeSuccessJSON(map[string]interface{}{
  6339. "failed_code": -10,
  6340. "msg": res.ErrMsg,
  6341. })
  6342. return
  6343. } else {
  6344. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6345. order.OrderStatus = 2
  6346. order.Status = 1
  6347. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6348. order.SetlId = res.Output.Setlinfo.SetlID
  6349. order.PsnNo = res.Output.Setlinfo.PsnNo
  6350. order.PsnName = res.Output.Setlinfo.PsnName
  6351. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6352. order.Certno = res.Output.Setlinfo.Certno
  6353. order.Gend = res.Output.Setlinfo.Gend
  6354. order.Naty = res.Output.Setlinfo.Naty
  6355. order.Age = res.Output.Setlinfo.Age
  6356. order.Insutype = res.Output.Setlinfo.Insutype
  6357. order.PsnType = res.Output.Setlinfo.PsnType
  6358. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6359. order.SetlTime = res.Output.Setlinfo.SetlTime
  6360. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6361. if res.Output.Setlinfo.MedType == "140101" {
  6362. order.MedType = "14"
  6363. } else {
  6364. order.MedType = res.Output.Setlinfo.MedType
  6365. }
  6366. if reg_type == 1112 {
  6367. order.MedType = "1112"
  6368. }
  6369. if reg_type == 1111 {
  6370. order.MedType = "1111"
  6371. }
  6372. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6373. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6374. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6375. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6376. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6377. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6378. order.HifpPay = res.Output.Setlinfo.HifpPay
  6379. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6380. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6381. order.HifesPay = res.Output.Setlinfo.HifesPay
  6382. order.HifobPay = res.Output.Setlinfo.HifobPay
  6383. order.MafPay = res.Output.Setlinfo.MafPay
  6384. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6385. order.OthPay = res.Output.Setlinfo.OthPay
  6386. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6387. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6388. order.AcctPay = res.Output.Setlinfo.AcctPay
  6389. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6390. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6391. order.Balc = res.Output.Setlinfo.Balc
  6392. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6393. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6394. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6395. order.ClrType = res.Output.Setlinfo.ClrType
  6396. order.ClrWay = res.Output.Setlinfo.ClrWay
  6397. order.Creator = order.Creator
  6398. order.Modify = roles.AdminUserId
  6399. order.RequestLog = src_resquest
  6400. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6401. detailStr := string(setlDetail)
  6402. order.SetlDetail = detailStr
  6403. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6404. err = service.UpDateOrder(order)
  6405. if err == nil {
  6406. //判断是否使用了押金
  6407. if dec_way == "true" {
  6408. tmpstring := strconv.FormatInt(order.ID, 10)
  6409. order.Decimal = decimal
  6410. service.UpDateOrder(order)
  6411. //扣押金
  6412. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6413. if errmsg != nil {
  6414. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6415. return
  6416. }
  6417. }
  6418. c.ServeSuccessJSON(map[string]interface{}{
  6419. "msg": "结算成功",
  6420. })
  6421. } else {
  6422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6423. return
  6424. }
  6425. }
  6426. } else {
  6427. adminUser := c.GetAdminUserInfo()
  6428. errlog := &models.HisOrderError{
  6429. UserOrgId: adminUser.CurrentOrgId,
  6430. Ctime: time.Now().Unix(),
  6431. Mtime: time.Now().Unix(),
  6432. ErrMsg: res.ErrMsg,
  6433. Status: 1,
  6434. PatientId: id,
  6435. RecordTime: recordDateTime,
  6436. Stage: 4,
  6437. }
  6438. service.CreateErrMsgLog(errlog)
  6439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6440. return
  6441. }
  6442. } else {
  6443. adminUser := c.GetAdminUserInfo()
  6444. errlog := &models.HisOrderError{
  6445. UserOrgId: adminUser.CurrentOrgId,
  6446. Ctime: time.Now().Unix(),
  6447. Mtime: time.Now().Unix(),
  6448. ErrMsg: res.ErrMsg,
  6449. Status: 1,
  6450. PatientId: id,
  6451. RecordTime: recordDateTime,
  6452. Stage: 4,
  6453. }
  6454. service.CreateErrMsgLog(errlog)
  6455. c.ServeSuccessJSON(map[string]interface{}{
  6456. "failed_code": -10,
  6457. "msg": res.ErrMsg,
  6458. })
  6459. return
  6460. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6461. //return
  6462. }
  6463. }
  6464. }
  6465. } else if tempOrder.ID > 0 {
  6466. if tempOrder.IsPre == 1 {
  6467. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6468. var rf []*ResultFive
  6469. json.Unmarshal([]byte(his.Iinfo), &rf)
  6470. chrg_bchno := tempOrder.Number
  6471. cert_no := his.Certno
  6472. var insutypes []string
  6473. var insutype string
  6474. var is390 int = 0
  6475. var is310 int = 0
  6476. for _, item := range rf {
  6477. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6478. insutypes = append(insutypes, item.Insutype)
  6479. }
  6480. }
  6481. if len(insutypes) == 1 {
  6482. insutype = insutypes[0]
  6483. } else {
  6484. for _, i := range insutypes {
  6485. if i == "390" {
  6486. is390 = 1
  6487. }
  6488. if i == "310" {
  6489. is310 = 1
  6490. }
  6491. }
  6492. }
  6493. if is390 == 1 {
  6494. insutype = "390"
  6495. }
  6496. if is310 == 1 {
  6497. insutype = "310"
  6498. }
  6499. if len(insutypes) == 0 {
  6500. insutype = "310"
  6501. }
  6502. if len(insutypes) == 2 {
  6503. insutype = strconv.FormatInt(his.SocialType, 64)
  6504. }
  6505. //insutype = "390"
  6506. if his.IdCardType == 1 {
  6507. // cert_no = his.MedicalInsuranceNumber
  6508. cert_no = his.Certno
  6509. } else {
  6510. cert_no = his.Certno
  6511. }
  6512. var res ResultSeven
  6513. var resSeven10265 ResultSeven10265
  6514. var src_resquest string
  6515. var result2 string
  6516. var acct_used_flag string
  6517. fmt.Println("pay_way")
  6518. fmt.Println(pay_way)
  6519. fmt.Println("pay_way")
  6520. if pay_way == 4 {
  6521. acct_used_flag = "1"
  6522. } else {
  6523. acct_used_flag = "0"
  6524. }
  6525. if miConfig.MdtrtareaAdmvs == "421300" {
  6526. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6527. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6528. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6529. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6530. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6531. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6532. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6533. resp, requestErr := http.Get(api)
  6534. if requestErr != nil {
  6535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6536. return
  6537. }
  6538. body, ioErr := ioutil.ReadAll(resp.Body)
  6539. if ioErr != nil {
  6540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6542. return
  6543. }
  6544. var respJSON map[string]interface{}
  6545. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6548. return
  6549. }
  6550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6551. result, _ := json.Marshal(respJSON)
  6552. fmt.Println("log")
  6553. fmt.Println(string(result))
  6554. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6555. utils.ErrorLog("解析失败:%v", err)
  6556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6557. return
  6558. }
  6559. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6560. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  6561. if result3101.Infcode == "0" {
  6562. if len(result3101.Output.Result) > 0 {
  6563. var errMsgs []string
  6564. for _, item := range result3101.Output.Result {
  6565. errMsgs = append(errMsgs, item.VolaCont)
  6566. }
  6567. c.ServeSuccessJSON(map[string]interface{}{
  6568. "failed_code": -10,
  6569. "msg": errMsgs,
  6570. })
  6571. return
  6572. }
  6573. }
  6574. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6575. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6576. //psn_info, _ := service.GetPsnByPatientId(id)
  6577. bas := strings.Split(psn_info.CardInfo, "|")
  6578. if his.IdCardType == 1 {
  6579. cert_no = bas[2]
  6580. } else {
  6581. cert_no = bas[1]
  6582. }
  6583. //江苏地区国家医保医疗类别
  6584. //职工透析:医疗类别选特殊情况门诊9933
  6585. //居民血透门慢: 医疗类别选门诊慢病1402
  6586. //var med_type string
  6587. //if his.Insutype == "310" {
  6588. // if reg_type == 14 {
  6589. // med_type = "9933"
  6590. // } else if reg_type == 11 {
  6591. // med_type = "11"
  6592. //
  6593. // }
  6594. //} else if his.Insutype == "390" {
  6595. // if reg_type == 14 {
  6596. // med_type = "1402"
  6597. // } else if reg_type == 11 {
  6598. // med_type = "11"
  6599. // }
  6600. //}
  6601. var api string
  6602. if miConfig.MdtrtareaAdmvs == "320921" {
  6603. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6604. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6605. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6606. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6607. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6608. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6609. "&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
  6610. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6611. } else {
  6612. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6613. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6614. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6615. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6616. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6617. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6618. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6619. "&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
  6620. }
  6621. resp, requestErr := http.Get(api)
  6622. if requestErr != nil {
  6623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6624. return
  6625. }
  6626. body, ioErr := ioutil.ReadAll(resp.Body)
  6627. if ioErr != nil {
  6628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6630. return
  6631. }
  6632. var respJSON map[string]interface{}
  6633. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6636. return
  6637. }
  6638. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6639. result, _ := json.Marshal(respJSON)
  6640. fmt.Println("log")
  6641. fmt.Println(string(result))
  6642. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6643. utils.ErrorLog("解析失败:%v", err)
  6644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6645. return
  6646. }
  6647. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6648. res.Output = resSeven10265.Output
  6649. res.ErrMsg = resSeven10265.ErrMsg
  6650. res.Cainfo = resSeven10265.Cainfo
  6651. res.WarnMsg = resSeven10265.WarnMsg
  6652. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6653. res.Infcode = infocode
  6654. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6655. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6656. var cert_no string
  6657. if his.IdCardType == 1 {
  6658. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6659. }
  6660. fmt.Println(cert_no)
  6661. 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)
  6662. var dat map[string]interface{}
  6663. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6664. fmt.Println(dat)
  6665. } else {
  6666. fmt.Println(err)
  6667. }
  6668. saveLog(result2, src_resquest, "2207", "结算")
  6669. userJSONBytes, _ := json.Marshal(dat)
  6670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6671. utils.ErrorLog("解析失败:%v", err)
  6672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6673. return
  6674. }
  6675. } else {
  6676. var src_resquest string
  6677. if miConfig.Code == "H15049901371" {
  6678. //赤峰地区国家医保医疗类别
  6679. //职工透析:医疗类别选特殊情况门诊990502
  6680. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6681. var med_type string
  6682. if his.Insutype == "390" {
  6683. if reg_type == 14 {
  6684. med_type = "9933"
  6685. } else if reg_type == 11 {
  6686. med_type = "11"
  6687. }
  6688. } else if his.Insutype == "310" {
  6689. if reg_type == 14 {
  6690. med_type = "990502"
  6691. } else if reg_type == 11 {
  6692. med_type = "11"
  6693. }
  6694. }
  6695. 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)
  6696. } else {
  6697. 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)
  6698. }
  6699. var dat map[string]interface{}
  6700. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6701. fmt.Println(dat)
  6702. } else {
  6703. fmt.Println(err)
  6704. }
  6705. saveLog(result2, src_resquest, "2207", "结算")
  6706. userJSONBytes, _ := json.Marshal(dat)
  6707. if miConfig.Code == "H15049901371" {
  6708. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6709. utils.ErrorLog("解析失败:%v", err)
  6710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6711. return
  6712. }
  6713. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6714. res.Output = resSeven10265.Output
  6715. res.ErrMsg = resSeven10265.ErrMsg
  6716. res.Cainfo = resSeven10265.Cainfo
  6717. res.WarnMsg = resSeven10265.WarnMsg
  6718. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6719. res.Infcode = infocode
  6720. } else {
  6721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6722. utils.ErrorLog("解析失败:%v", err)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. return
  6725. }
  6726. }
  6727. }
  6728. if res.Infcode != 0 {
  6729. errlog := &models.HisOrderError{
  6730. UserOrgId: adminUser.CurrentOrgId,
  6731. Ctime: time.Now().Unix(),
  6732. Mtime: time.Now().Unix(),
  6733. Number: chrg_bchno,
  6734. ErrMsg: res.ErrMsg,
  6735. Status: 1,
  6736. PatientId: id,
  6737. RecordTime: recordDateTime,
  6738. Stage: 6,
  6739. }
  6740. service.CreateErrMsgLog(errlog)
  6741. c.ServeSuccessJSON(map[string]interface{}{
  6742. "failed_code": -10,
  6743. "msg": res.ErrMsg,
  6744. })
  6745. return
  6746. } else {
  6747. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6748. order.OrderStatus = 2
  6749. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6750. order.SetlId = res.Output.Setlinfo.SetlID
  6751. order.PsnNo = res.Output.Setlinfo.PsnNo
  6752. order.PsnName = res.Output.Setlinfo.PsnName
  6753. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6754. order.Certno = res.Output.Setlinfo.Certno
  6755. order.Gend = res.Output.Setlinfo.Gend
  6756. order.Naty = res.Output.Setlinfo.Naty
  6757. order.Age = res.Output.Setlinfo.Age
  6758. order.Insutype = res.Output.Setlinfo.Insutype
  6759. order.PsnType = res.Output.Setlinfo.PsnType
  6760. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6761. order.SetlTime = res.Output.Setlinfo.SetlTime
  6762. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6763. //order.MedType = res.Output.Setlinfo.MedType
  6764. if reg_type == 1112 {
  6765. order.MedType = "1112"
  6766. }
  6767. if reg_type == 1111 {
  6768. order.MedType = "1111"
  6769. }
  6770. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6771. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6772. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6773. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6774. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6775. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6776. order.HifpPay = res.Output.Setlinfo.HifpPay
  6777. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6778. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6779. order.HifesPay = res.Output.Setlinfo.HifesPay
  6780. order.HifobPay = res.Output.Setlinfo.HifobPay
  6781. order.MafPay = res.Output.Setlinfo.MafPay
  6782. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6783. order.OthPay = res.Output.Setlinfo.OthPay
  6784. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6785. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6786. order.AcctPay = res.Output.Setlinfo.AcctPay
  6787. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6788. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6789. order.Balc = res.Output.Setlinfo.Balc
  6790. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6791. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6792. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6793. order.ClrWay = res.Output.Setlinfo.ClrWay
  6794. order.Creator = order.Creator
  6795. order.Modify = roles.AdminUserId
  6796. order.RequestLog = src_resquest
  6797. order.Diagnosis = diagnosis_id
  6798. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6799. detailStr := string(setlDetail)
  6800. order.SetlDetail = detailStr
  6801. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6802. err = service.UpDateOrder(order)
  6803. if err == nil {
  6804. //判断是否使用了押金
  6805. if dec_way == "true" {
  6806. tmpstring := strconv.FormatInt(order.ID, 10)
  6807. //扣押金
  6808. order.Decimal = decimal
  6809. service.UpDateOrder(order)
  6810. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6811. if errmsg != nil {
  6812. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6813. return
  6814. }
  6815. }
  6816. c.ServeSuccessJSON(map[string]interface{}{
  6817. "msg": "结算成功",
  6818. })
  6819. } else {
  6820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6821. return
  6822. }
  6823. }
  6824. }
  6825. }
  6826. }
  6827. //func (c *HisApiController) GetPreUploadInfo() {
  6828. // id, _ := c.GetInt64("id")
  6829. // record_time := c.GetString("record_time")
  6830. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6831. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6832. //
  6833. // timeLayout := "2006-01-02"
  6834. // loc, _ := time.LoadLocation("Local")
  6835. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6836. // if err != nil {
  6837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6838. // return
  6839. // }
  6840. // recordDateTime := theTime.Unix()
  6841. // adminUser := c.GetAdminUserInfo()
  6842. //
  6843. // var prescriptions []*models.HisPrescription
  6844. //
  6845. // var start_time int64
  6846. // var end_time int64
  6847. //
  6848. // data := make(map[string]interface{})
  6849. // if settle_accounts_type == 1 { //日结
  6850. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6851. // data["pre"] = prescriptions
  6852. //
  6853. // } else { //月结
  6854. // start_time_str := c.GetString("start_time")
  6855. // end_time_str := c.GetString("end_time")
  6856. // timeLayout := "2006-01-02"
  6857. // loc, _ := time.LoadLocation("Local")
  6858. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6859. // if err != nil {
  6860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6861. // return
  6862. // }
  6863. // recordStartTime := theStartTime.Unix()
  6864. // start_time = recordStartTime
  6865. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6866. // if err != nil {
  6867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6868. // return
  6869. // }
  6870. // recordEndTime := theEndTime.Unix()
  6871. // end_time = recordEndTime
  6872. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6873. // data["pre"] = prescriptions
  6874. //
  6875. // }
  6876. //
  6877. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6878. //
  6879. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6880. // timestamp := time.Now().Unix()
  6881. // tempTime := time.Unix(timestamp, 0)
  6882. // timeFormat := tempTime.Format("20060102150405")
  6883. // chrgBchno := rand.Intn(100000) + 10000
  6884. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6885. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6886. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6887. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6888. // strconv.FormatInt(his.PatientId, 10)
  6889. // client := &http.Client{}
  6890. // data["psn_no"] = his.PsnNo
  6891. // data["mdtrt_id"] = his.Number
  6892. // data["chrg_bchno"] = chrg_bchno
  6893. // data["org_name"] = miConfig.OrgName
  6894. // data["doctor"] = roles.UserName
  6895. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6896. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6897. // data["fixmedins_code"] = miConfig.Code
  6898. // data["dept_code"] = department.Number
  6899. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6900. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6901. // data["secret_key"] = miConfig.SecretKey
  6902. // var ids []int64
  6903. //
  6904. // for _, item := range prescriptions {
  6905. // ids = append(ids, item.ID)
  6906. // }
  6907. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6908. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6909. // bytesData, _ := json.Marshal(data)
  6910. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6911. // resp, _ := client.Do(req)
  6912. // defer resp.Body.Close()
  6913. // body, ioErr := ioutil.ReadAll(resp.Body)
  6914. // if ioErr != nil {
  6915. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. // return
  6918. // }
  6919. // var respJSON map[string]interface{}
  6920. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6921. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6922. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6923. // return
  6924. // }
  6925. //
  6926. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6927. // userJSONBytes, _ := json.Marshal(respJSON)
  6928. // var res ResultFour
  6929. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6930. // utils.ErrorLog("解析失败:%v", err)
  6931. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6932. // return
  6933. // }
  6934. //
  6935. // if res.Infcode == 0 {
  6936. // order := &models.HisOrder{
  6937. // UserOrgId: adminUser.CurrentOrgId,
  6938. // HisPatientId: his.ID,
  6939. // PatientId: his.PatientId,
  6940. // SettleAccountsDate: recordDateTime,
  6941. // Ctime: time.Now().Unix(),
  6942. // Mtime: time.Now().Unix(),
  6943. // Status: 1,
  6944. // Number: chrg_bchno,
  6945. // Infcode: res.Infcode,
  6946. // WarnMsg: res.WarnMsg,
  6947. // Cainfo: res.Cainfo,
  6948. // ErrMsg: res.ErrMsg,
  6949. // RespondTime: res.RefmsgTime,
  6950. // InfRefmsgid: res.InfRefmsgid,
  6951. // OrderStatus: 1,
  6952. // IsMedicineInsurance: 1,
  6953. // SettleType: settle_accounts_type,
  6954. // SettleStartTime: start_time,
  6955. // SettleEndTime: end_time,
  6956. // Creator: roles.ID,
  6957. // Modify: roles.ID,
  6958. // PType: 2,
  6959. // }
  6960. // err = service.CreateOrder(order)
  6961. // if err != nil {
  6962. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6963. // return
  6964. // }
  6965. //
  6966. // for _, item := range res.Output.Result {
  6967. // temp := strings.Split(item.FeedetlSn, "-")
  6968. // var advice_id int64 = 0
  6969. // var project_id int64 = 0
  6970. // var types int64 = 0
  6971. //
  6972. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6973. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6974. //
  6975. // if temp[1] == "1" {
  6976. // advice_id = id
  6977. // project_id = 0
  6978. // } else if temp[1] == "2" {
  6979. // advice_id = 0
  6980. // project_id = id
  6981. // }
  6982. //
  6983. // info := &models.HisOrderInfo{
  6984. // OrderNumber: order.Number,
  6985. // FeedetlSn: item.FeedetlSn,
  6986. // UploadDate: time.Now().Unix(),
  6987. // AdviceId: advice_id,
  6988. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6989. // Cnt: item.Cnt,
  6990. // Pric: float64(item.Pric),
  6991. // PatientId: his.PatientId,
  6992. // PricUplmtAmt: item.PricUplmtAmt,
  6993. // SelfpayProp: item.SelfpayProp,
  6994. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6995. // OverlmtAmt: item.OverlmtAmt,
  6996. // PreselfpayAmt: item.PreselfpayAmt,
  6997. // BasMednFlag: item.BasMednFlag,
  6998. // MedChrgitmType: item.MedChrgitmType,
  6999. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  7000. // Status: 1,
  7001. // Memo: item.Memo,
  7002. // Mtime: time.Now().Unix(),
  7003. // InscpScpAmt: item.InscpScpAmt,
  7004. // DrtReimFlag: item.DrtReimFlag,
  7005. // Ctime: time.Now().Unix(),
  7006. // ListSpItemFlag: item.ListSpItemFlag,
  7007. // ChldMedcFlag: item.ChldMedcFlag,
  7008. // LmtUsedFlag: item.LmtUsedFlag,
  7009. // ChrgitmLv: item.ChrgitmLv,
  7010. // UserOrgId: adminUser.CurrentOrgId,
  7011. // HisPatientId: his.ID,
  7012. // OrderId: order.ID,
  7013. // ProjectId: project_id,
  7014. // Type: types,
  7015. // }
  7016. // service.CreateOrderInfo(info)
  7017. //
  7018. // }
  7019. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7020. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  7021. //
  7022. // var total float64
  7023. // for _, item := range prescriptions {
  7024. // if item.Type == 1 { //药品
  7025. // for _, subItem := range item.HisDoctorAdviceInfo {
  7026. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7027. // }
  7028. // }
  7029. // if item.Type == 2 { //项目
  7030. // for _, subItem := range item.HisPrescriptionProject {
  7031. // total = total + (subItem.Price * float64(subItem.Count))
  7032. // }
  7033. // }
  7034. // }
  7035. //
  7036. // for _, item := range prescriptions {
  7037. // for _, subItem := range item.HisAdditionalCharge {
  7038. // total = total + (subItem.Price * float64(subItem.Count))
  7039. // }
  7040. // }
  7041. //
  7042. // allTotal := fmt.Sprintf("%.2f", total)
  7043. // if res.Infcode == 0 {
  7044. // var rf []*ResultFive
  7045. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7046. // psn_no := his.PsnNo
  7047. // mdtrt_id := his.Number
  7048. // chrg_bchno := chrg_bchno
  7049. // cert_no := his.Certno
  7050. // insutype := rf[0].Insutype
  7051. //
  7052. // if his.IdCardType == 1 {
  7053. // cert_no = his.MedicalInsuranceNumber
  7054. //
  7055. // } else {
  7056. //
  7057. // cert_no = his.Certno
  7058. //
  7059. // }
  7060. //
  7061. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  7062. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  7063. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  7064. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  7065. // resp, requestErr := http.Get(api)
  7066. // if requestErr != nil {
  7067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. // return
  7069. // }
  7070. // defer resp.Body.Close()
  7071. // body, ioErr := ioutil.ReadAll(resp.Body)
  7072. // if ioErr != nil {
  7073. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7074. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7075. // return
  7076. // }
  7077. // var respJSON map[string]interface{}
  7078. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7079. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. // return
  7082. // }
  7083. // fmt.Println(respJSON)
  7084. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7085. // userJSONBytes, _ := json.Marshal(respJSON)
  7086. // var res ResultSeven
  7087. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7088. // utils.ErrorLog("解析失败:%v", err)
  7089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. // return
  7091. // }
  7092. // if res.Infcode != 0 {
  7093. // errlog := &models.HisOrderError{
  7094. // UserOrgId: adminUser.CurrentOrgId,
  7095. // Ctime: time.Now().Unix(),
  7096. // Mtime: time.Now().Unix(),
  7097. // Number: chrg_bchno,
  7098. // ErrMsg: res.ErrMsg,
  7099. // Status: 1,
  7100. // PatientId: id,
  7101. // RecordTime: recordDateTime,
  7102. // Stage: 7,
  7103. // }
  7104. // service.CreateErrMsgLog(errlog)
  7105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7106. // return
  7107. // } else {
  7108. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7109. // order.OrderStatus = 1
  7110. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7111. // order.SetlId = res.Output.Setlinfo.SetlID
  7112. // order.PsnNo = res.Output.Setlinfo.PsnNo
  7113. // order.PsnName = res.Output.Setlinfo.PsnName
  7114. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7115. // order.Certno = res.Output.Setlinfo.Certno
  7116. // order.Gend = res.Output.Setlinfo.Gend
  7117. // order.Naty = res.Output.Setlinfo.Naty
  7118. // order.Age = res.Output.Setlinfo.Age
  7119. // order.Insutype = res.Output.Setlinfo.Insutype
  7120. // order.PsnType = res.Output.Setlinfo.PsnType
  7121. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7122. // order.SetlTime = res.Output.Setlinfo.SetlTime
  7123. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7124. // order.MedType = res.Output.Setlinfo.MedType
  7125. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7126. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7127. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7128. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7129. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7130. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7131. // order.HifpPay = res.Output.Setlinfo.HifpPay
  7132. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7133. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7134. // order.HifesPay = res.Output.Setlinfo.HifesPay
  7135. // order.HifobPay = res.Output.Setlinfo.HifobPay
  7136. // order.MafPay = res.Output.Setlinfo.MafPay
  7137. // order.OthPay = res.Output.Setlinfo.OthPay
  7138. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7139. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7140. // order.AcctPay = res.Output.Setlinfo.AcctPay
  7141. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7142. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7143. // order.Balc = res.Output.Setlinfo.Balc
  7144. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7145. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7146. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7147. // order.ClrWay = res.Output.Setlinfo.ClrWay
  7148. // order.Creator = order.Creator
  7149. // order.Modify = roles.ID
  7150. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7151. // detailStr := string(setlDetail)
  7152. // order.SetlDetail = detailStr
  7153. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7154. // err = service.UpDateOrder(order)
  7155. // if err == nil {
  7156. // c.ServeSuccessJSON(map[string]interface{}{
  7157. // "msg": "预结算成功",
  7158. // })
  7159. // } else {
  7160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7161. // return
  7162. // }
  7163. // }
  7164. // } else {
  7165. // adminUser := c.GetAdminUserInfo()
  7166. // errlog := &models.HisOrderError{
  7167. // UserOrgId: adminUser.CurrentOrgId,
  7168. // Ctime: time.Now().Unix(),
  7169. // Mtime: time.Now().Unix(),
  7170. // ErrMsg: res.ErrMsg,
  7171. // Status: 1,
  7172. // PatientId: id,
  7173. // RecordTime: recordDateTime,
  7174. // Stage: 4,
  7175. // }
  7176. // service.CreateErrMsgLog(errlog)
  7177. //
  7178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7179. // return
  7180. // }
  7181. // } else {
  7182. // adminUser := c.GetAdminUserInfo()
  7183. // errlog := &models.HisOrderError{
  7184. // UserOrgId: adminUser.CurrentOrgId,
  7185. // Ctime: time.Now().Unix(),
  7186. // Mtime: time.Now().Unix(),
  7187. // ErrMsg: res.ErrMsg,
  7188. // Status: 1,
  7189. // PatientId: id,
  7190. // RecordTime: recordDateTime,
  7191. // Stage: 4,
  7192. // }
  7193. // service.CreateErrMsgLog(errlog)
  7194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7195. // return
  7196. // }
  7197. //
  7198. // } else {
  7199. // var total float64
  7200. // for _, item := range prescriptions {
  7201. // if item.Type == 1 { //药品
  7202. // for _, subItem := range item.HisDoctorAdviceInfo {
  7203. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7204. // }
  7205. // }
  7206. // if item.Type == 2 { //项目
  7207. // for _, subItem := range item.HisPrescriptionProject {
  7208. // total = total + (subItem.Price * float64(subItem.Count))
  7209. // }
  7210. // }
  7211. //
  7212. // for _, subItem := range item.HisAdditionalCharge {
  7213. // total = total + (subItem.Price * float64(subItem.Count))
  7214. // }
  7215. // }
  7216. //
  7217. // allTotal := fmt.Sprintf("%.2f", total)
  7218. // totals, _ := strconv.ParseFloat(allTotal, 64)
  7219. // order := &models.HisOrder{
  7220. // UserOrgId: adminUser.CurrentOrgId,
  7221. // HisPatientId: his.ID,
  7222. // PatientId: id,
  7223. // SettleAccountsDate: recordDateTime,
  7224. // Ctime: time.Now().Unix(),
  7225. // Mtime: time.Now().Unix(),
  7226. // Status: 1,
  7227. // OrderStatus: 2,
  7228. // Number: chrg_bchno,
  7229. // MedfeeSumamt: totals,
  7230. // }
  7231. // err = service.CreateOrder(order)
  7232. // if err != nil {
  7233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7234. // return
  7235. // }
  7236. //
  7237. // var customs []*Custom
  7238. // for _, item := range prescriptions {
  7239. //
  7240. // if item.Type == 1 { //药品
  7241. // for _, subItem := range item.HisDoctorAdviceInfo {
  7242. // cus := &Custom{
  7243. // AdviceId: subItem.ID,
  7244. // ProjectId: 0,
  7245. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7246. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7247. // FeedetlSn: subItem.FeedetlSn,
  7248. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7249. // MedListCodg: subItem.MedListCodg,
  7250. // Type: 1,
  7251. // }
  7252. // customs = append(customs, cus)
  7253. // }
  7254. // }
  7255. //
  7256. // if item.Type == 2 { //项目
  7257. // for _, subItem := range item.HisPrescriptionProject {
  7258. //
  7259. // cus := &Custom{
  7260. // AdviceId: 0,
  7261. // ProjectId: subItem.ID,
  7262. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7263. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7264. // FeedetlSn: subItem.FeedetlSn,
  7265. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7266. // MedListCodg: subItem.MedListCodg,
  7267. // Type: 2,
  7268. // }
  7269. //
  7270. // customs = append(customs, cus)
  7271. // }
  7272. // }
  7273. //
  7274. // for _, item := range item.HisAdditionalCharge {
  7275. // cus := &Custom{
  7276. // ItemId: item.ID,
  7277. // AdviceId: 0,
  7278. // ProjectId: 0,
  7279. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7280. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7281. // FeedetlSn: item.FeedetlSn,
  7282. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7283. // MedListCodg: item.XtHisAddtionConfig.Code,
  7284. // Type: 3,
  7285. // }
  7286. //
  7287. // customs = append(customs, cus)
  7288. // }
  7289. //
  7290. // }
  7291. //
  7292. // for _, item := range customs {
  7293. // var advice_id int64 = 0
  7294. // var project_id int64 = 0
  7295. // var item_id int64 = 0
  7296. //
  7297. // var types int64 = 0
  7298. //
  7299. // if item.Type == 1 {
  7300. // advice_id = item.AdviceId
  7301. // project_id = 0
  7302. // item_id = 0
  7303. // } else if item.Type == 2 {
  7304. // advice_id = 0
  7305. // item_id = 0
  7306. //
  7307. // project_id = item.ProjectId
  7308. // } else if item.Type == 3 {
  7309. // advice_id = 0
  7310. // item_id = item.ItemId
  7311. // project_id = 0
  7312. // }
  7313. //
  7314. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7315. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7316. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7317. //
  7318. // info := &models.HisOrderInfo{
  7319. // OrderNumber: order.Number,
  7320. // UploadDate: time.Now().Unix(),
  7321. // AdviceId: advice_id,
  7322. // DetItemFeeSumamt: detItemFeeSumamt,
  7323. // Cnt: cut,
  7324. // Pric: pric,
  7325. // PatientId: id,
  7326. // Status: 1,
  7327. // Mtime: time.Now().Unix(),
  7328. // Ctime: time.Now().Unix(),
  7329. // UserOrgId: adminUser.CurrentOrgId,
  7330. // HisPatientId: his.ID,
  7331. // OrderId: order.ID,
  7332. // ProjectId: project_id,
  7333. // Type: types,
  7334. // ItemId: item_id,
  7335. // }
  7336. // service.CreateOrderInfo(info)
  7337. // }
  7338. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7339. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7340. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7341. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7342. // if err == nil {
  7343. // c.ServeSuccessJSON(map[string]interface{}{
  7344. // "msg": "结算成功",
  7345. // })
  7346. // } else {
  7347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7348. // return
  7349. // }
  7350. // }
  7351. //}
  7352. //上传明细-预结算-
  7353. func (c *HisApiController) GetPreUploadInfo() {
  7354. id, _ := c.GetInt64("id")
  7355. record_time := c.GetString("record_time")
  7356. his_patient_id, _ := c.GetInt64("his_patient_id")
  7357. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7358. admin_user_id, _ := c.GetInt64("admin_user_id")
  7359. diagnosis_id := c.GetString("diagnosis")
  7360. sick_type, _ := c.GetInt64("sick_type")
  7361. reg_type, _ := c.GetInt64("p_type")
  7362. begin_time := c.GetString("begin_time")
  7363. id_str := c.GetString("ids")
  7364. ids_arr := strings.Split(id_str, ",")
  7365. timeLayout := "2006-01-02"
  7366. loc, _ := time.LoadLocation("Local")
  7367. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7368. if err != nil {
  7369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7370. return
  7371. }
  7372. recordDateTime := theTime.Unix()
  7373. adminUser := c.GetAdminUserInfo()
  7374. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7375. var config []*models.HisXtDiagnoseConfig
  7376. for _, item := range diagnosis_ids {
  7377. id, _ := strconv.ParseInt(item, 10, 64)
  7378. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7379. config = append(config, &diagnosisConfig)
  7380. }
  7381. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7382. sickConfig, _ := service.FindSickById(sick_type)
  7383. var prescriptions []*models.HisPrescription
  7384. var start_time int64
  7385. var end_time int64
  7386. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7387. fmt.Println(his_patient_id)
  7388. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7389. timestamp := time.Now().Unix()
  7390. tempTime := time.Unix(timestamp, 0)
  7391. timeFormat := tempTime.Format("20060102150405")
  7392. chrgBchno := rand.Intn(100000) + 10000
  7393. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7394. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7395. var patientPrescription models.HisPrescriptionInfo
  7396. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7397. if patientPrescription.ID == 0 {
  7398. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7399. }
  7400. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7401. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7402. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7403. strconv.FormatInt(his.PatientId, 10)
  7404. var res2 ResultSix
  7405. var resSix10265 ResultSix10265
  7406. var time_stamp string
  7407. if miConfig.MdtrtareaAdmvs == "421300" {
  7408. data := make(map[string]interface{})
  7409. client := &http.Client{}
  7410. data["psn_no"] = his.PsnNo
  7411. data["mdtrt_id"] = his.Number
  7412. data["department"] = department.Name
  7413. data["org_name"] = miConfig.OrgName
  7414. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7415. data["doctor_id"] = doctor_info.DoctorNumber
  7416. data["doctor_name"] = roles.UserName
  7417. data["fixmedins_code"] = miConfig.Code
  7418. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7419. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7420. data["secret_key"] = miConfig.SecretKey
  7421. data["sick_code"] = sickConfig.CountryCode
  7422. data["sick_name"] = sickConfig.ClassName
  7423. data["begin_time"] = begin_time
  7424. data["dept"] = strconv.FormatInt(department.ID, 10)
  7425. data["config"] = config
  7426. data["opter"] = roles.UserName
  7427. fmt.Println(data)
  7428. bytesData, _ := json.Marshal(data)
  7429. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7430. resp, _ := client.Do(req)
  7431. defer resp.Body.Close()
  7432. body, ioErr := ioutil.ReadAll(resp.Body)
  7433. if ioErr != nil {
  7434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7436. return
  7437. }
  7438. var respJSON map[string]interface{}
  7439. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7442. return
  7443. }
  7444. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7445. userJSONBytes, _ := json.Marshal(respJSON)
  7446. fmt.Println("log")
  7447. fmt.Println(string(userJSONBytes))
  7448. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7449. utils.ErrorLog("解析失败:%v", err)
  7450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7451. return
  7452. }
  7453. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7454. data := make(map[string]interface{})
  7455. client := &http.Client{}
  7456. data["psn_no"] = his.PsnNo
  7457. data["mdtrt_id"] = his.Number
  7458. data["doctor"] = roles.UserName
  7459. data["department"] = department.Name
  7460. data["org_name"] = miConfig.OrgName
  7461. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7462. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7463. data["fixmedins_code"] = miConfig.Code
  7464. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7465. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7466. data["secret_key"] = miConfig.SecretKey
  7467. data["sick_code"] = sickConfig.CountryCode
  7468. data["sick_name"] = sickConfig.ClassName
  7469. data["begin_time"] = begin_time
  7470. data["dept"] = strconv.FormatInt(department.ID, 10)
  7471. data["config"] = config
  7472. data["url"] = miConfig.Url
  7473. data["ak"] = miConfig.AccessKey
  7474. data["cainfo"] = miConfig.Cainfo
  7475. bytesData, _ := json.Marshal(data)
  7476. var req *http.Request
  7477. if miConfig.MdtrtareaAdmvs == "320921" {
  7478. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7479. //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 +
  7480. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7481. } else {
  7482. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7483. }
  7484. resp, _ := client.Do(req)
  7485. defer resp.Body.Close()
  7486. body, ioErr := ioutil.ReadAll(resp.Body)
  7487. if ioErr != nil {
  7488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7490. return
  7491. }
  7492. var respJSON map[string]interface{}
  7493. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7496. return
  7497. }
  7498. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7499. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7500. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7501. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7502. userJSONBytes, _ := json.Marshal(respJSON)
  7503. fmt.Println("log")
  7504. fmt.Println(string(userJSONBytes))
  7505. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7506. utils.ErrorLog("解析失败:%v", err)
  7507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7508. return
  7509. }
  7510. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7511. res2.Output = resSix10265.Output
  7512. res2.ErrMsg = resSix10265.ErrMsg
  7513. res2.Cainfo = resSix10265.Cainfo
  7514. res2.WarnMsg = resSix10265.WarnMsg
  7515. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7516. res2.Infcode = infocode
  7517. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7518. 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)
  7519. saveLog(result, requestLog, "2203", "上传就诊信息")
  7520. var respJSON2 map[string]interface{}
  7521. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7524. return
  7525. }
  7526. userJSONBytes2, _ := json.Marshal(respJSON2)
  7527. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7528. utils.ErrorLog("解析失败:%v", err)
  7529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7530. return
  7531. }
  7532. } else {
  7533. var result string
  7534. var requestLog string
  7535. if miConfig.MdtrtareaAdmvs == "440781" { //
  7536. 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)
  7537. } else {
  7538. if miConfig.Code == "H15049901371" {
  7539. //赤峰地区国家医保医疗类别
  7540. //职工透析:医疗类别选特殊情况门诊990502
  7541. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7542. var med_type string
  7543. if his.Insutype == "390" {
  7544. if reg_type == 14 {
  7545. med_type = "9933"
  7546. } else if reg_type == 11 {
  7547. med_type = "11"
  7548. }
  7549. } else if his.Insutype == "310" {
  7550. if reg_type == 14 {
  7551. med_type = "990502"
  7552. } else if reg_type == 11 {
  7553. med_type = "11"
  7554. }
  7555. }
  7556. 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)
  7557. } else {
  7558. 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)
  7559. }
  7560. saveLog(result, requestLog, "2203", "上传就诊信息")
  7561. var respJSON2 map[string]interface{}
  7562. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7565. return
  7566. }
  7567. userJSONBytes2, _ := json.Marshal(respJSON2)
  7568. if miConfig.Code == "H15049901371" {
  7569. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7570. utils.ErrorLog("解析失败:%v", err)
  7571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7572. return
  7573. }
  7574. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7575. res2.Output = resSix10265.Output
  7576. res2.ErrMsg = resSix10265.ErrMsg
  7577. res2.Cainfo = resSix10265.Cainfo
  7578. res2.WarnMsg = resSix10265.WarnMsg
  7579. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7580. res2.Infcode = infocode
  7581. } else {
  7582. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7583. utils.ErrorLog("解析失败:%v", err)
  7584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. return
  7586. }
  7587. }
  7588. }
  7589. }
  7590. if res2.Infcode != 0 {
  7591. adminUser := c.GetAdminUserInfo()
  7592. errlog := &models.HisOrderError{
  7593. UserOrgId: adminUser.CurrentOrgId,
  7594. Ctime: time.Now().Unix(),
  7595. Mtime: time.Now().Unix(),
  7596. ErrMsg: res2.ErrMsg,
  7597. Status: 1,
  7598. PatientId: id,
  7599. RecordTime: recordDateTime,
  7600. Stage: 3,
  7601. }
  7602. service.CreateErrMsgLog(errlog)
  7603. c.ServeSuccessJSON(map[string]interface{}{
  7604. "failed_code": -10,
  7605. "msg": res2.ErrMsg,
  7606. })
  7607. return
  7608. } else {
  7609. his.Diagnosis = diagnosis_id
  7610. his.SickType = sickConfig.ID
  7611. his.PType = fmt.Sprintf("%d", reg_type)
  7612. service.UpdateHisPatientThree(&his)
  7613. data := make(map[string]interface{})
  7614. if settle_accounts_type == 1 { //日结
  7615. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7616. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7617. } else {
  7618. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7619. }
  7620. data["pre"] = prescriptions
  7621. } else { //月结
  7622. start_time_str := c.GetString("start_time")
  7623. end_time_str := c.GetString("end_time")
  7624. timeLayout := "2006-01-02"
  7625. loc, _ := time.LoadLocation("Local")
  7626. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7627. if err != nil {
  7628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7629. return
  7630. }
  7631. recordStartTime := theStartTime.Unix()
  7632. start_time = recordStartTime
  7633. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7634. if err != nil {
  7635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7636. return
  7637. }
  7638. recordEndTime := theEndTime.Unix()
  7639. end_time = recordEndTime
  7640. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7641. data["pre"] = prescriptions
  7642. }
  7643. client := &http.Client{}
  7644. data["psn_no"] = his.PsnNo
  7645. data["mdtrt_id"] = his.Number
  7646. data["chrg_bchno"] = chrg_bchno
  7647. data["org_name"] = miConfig.OrgName
  7648. data["doctor"] = roles.UserName
  7649. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7650. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7651. data["fixmedins_code"] = miConfig.Code
  7652. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7653. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7654. data["dept_code"] = "15"
  7655. } else {
  7656. data["dept_code"] = department.Number
  7657. }
  7658. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7659. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7660. data["secret_key"] = miConfig.SecretKey
  7661. data["url"] = miConfig.Url
  7662. data["ak"] = miConfig.AccessKey
  7663. data["new_doctor_name"] = patientPrescription.Doctor
  7664. data["diag_code"] = sickConfig.CountryCode
  7665. data["time_stamp"] = time_stamp
  7666. data["cainfo"] = miConfig.Cainfo
  7667. var ids []int64
  7668. for _, item := range prescriptions {
  7669. ids = append(ids, item.ID)
  7670. }
  7671. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7672. if config.IsOpen == 1 { //对接了医保,走医保流程
  7673. var res ResultFour
  7674. var resFour10265 ResultFour10265
  7675. if miConfig.MdtrtareaAdmvs == "421300" {
  7676. bytesData, _ := json.Marshal(data)
  7677. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7678. resp, _ := client.Do(req)
  7679. defer resp.Body.Close()
  7680. body, ioErr := ioutil.ReadAll(resp.Body)
  7681. if ioErr != nil {
  7682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7684. return
  7685. }
  7686. var respJSON map[string]interface{}
  7687. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7690. return
  7691. }
  7692. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7693. userJSONBytes, _ := json.Marshal(respJSON)
  7694. fmt.Println("log")
  7695. fmt.Println(string(userJSONBytes))
  7696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7697. utils.ErrorLog("解析失败:%v", err)
  7698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7699. return
  7700. }
  7701. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7702. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7703. if result3101.Infcode == "0" {
  7704. if len(result3101.Output.Result) > 0 {
  7705. var errMsgs []string
  7706. for _, item := range result3101.Output.Result {
  7707. errMsgs = append(errMsgs, item.VolaCont)
  7708. }
  7709. c.ServeSuccessJSON(map[string]interface{}{
  7710. "failed_code": -10,
  7711. "msg": errMsgs,
  7712. })
  7713. return
  7714. }
  7715. }
  7716. bytesData, _ := json.Marshal(data)
  7717. var req *http.Request
  7718. if miConfig.MdtrtareaAdmvs == "320921" {
  7719. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7720. } else {
  7721. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7722. }
  7723. resp, _ := client.Do(req)
  7724. defer resp.Body.Close()
  7725. body, ioErr := ioutil.ReadAll(resp.Body)
  7726. if ioErr != nil {
  7727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7729. return
  7730. }
  7731. var respJSON map[string]interface{}
  7732. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7735. return
  7736. }
  7737. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7738. userJSONBytes, _ := json.Marshal(respJSON)
  7739. fmt.Println("log")
  7740. fmt.Println(string(userJSONBytes))
  7741. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7742. utils.ErrorLog("解析失败:%v", err)
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7744. return
  7745. }
  7746. res.InfRefmsgid = resFour10265.InfRefmsgid
  7747. res.Output = resFour10265.Output
  7748. res.ErrMsg = resFour10265.ErrMsg
  7749. res.Cainfo = resFour10265.Cainfo
  7750. res.WarnMsg = resFour10265.WarnMsg
  7751. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7752. res.Infcode = infocode
  7753. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7754. 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)
  7755. var dat map[string]interface{}
  7756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7757. fmt.Println(dat)
  7758. } else {
  7759. fmt.Println(err)
  7760. }
  7761. saveLog(result, request_log, "2204", "上传费用明细")
  7762. userJSONBytes, _ := json.Marshal(dat)
  7763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7764. utils.ErrorLog("解析失败:%v", err)
  7765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7766. return
  7767. }
  7768. } else {
  7769. if miConfig.Code == "H15049901371" {
  7770. 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)
  7771. var dat map[string]interface{}
  7772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7773. fmt.Println(dat)
  7774. } else {
  7775. fmt.Println(err)
  7776. }
  7777. saveLog(result, request_log, "2204", "上传费用明细")
  7778. userJSONBytes, _ := json.Marshal(dat)
  7779. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7780. utils.ErrorLog("解析失败:%v", err)
  7781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7782. return
  7783. }
  7784. res.InfRefmsgid = resFour10265.InfRefmsgid
  7785. res.Output = resFour10265.Output
  7786. res.ErrMsg = resFour10265.ErrMsg
  7787. res.Cainfo = resFour10265.Cainfo
  7788. res.WarnMsg = resFour10265.WarnMsg
  7789. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7790. res.Infcode = infocode
  7791. } else {
  7792. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  7793. var dat map[string]interface{}
  7794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7795. fmt.Println(dat)
  7796. } else {
  7797. fmt.Println(err)
  7798. }
  7799. saveLog(result, request_log, "2204", "上传费用明细")
  7800. userJSONBytes, _ := json.Marshal(dat)
  7801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7802. utils.ErrorLog("解析失败:%v", err)
  7803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7804. return
  7805. }
  7806. }
  7807. }
  7808. if res.Infcode == 0 {
  7809. order := &models.HisOrder{
  7810. UserOrgId: adminUser.CurrentOrgId,
  7811. HisPatientId: his.ID,
  7812. PatientId: his.PatientId,
  7813. SettleAccountsDate: recordDateTime,
  7814. Ctime: time.Now().Unix(),
  7815. Mtime: time.Now().Unix(),
  7816. MdtrtId: his.Number,
  7817. PsnNo: his.PsnNo,
  7818. MedType: strconv.FormatInt(reg_type, 10),
  7819. Status: 1,
  7820. Number: chrg_bchno,
  7821. Infcode: res.Infcode,
  7822. WarnMsg: res.WarnMsg,
  7823. Cainfo: res.Cainfo,
  7824. ErrMsg: res.ErrMsg,
  7825. RespondTime: res.RefmsgTime,
  7826. InfRefmsgid: res.InfRefmsgid,
  7827. OrderStatus: 1,
  7828. IsMedicineInsurance: 1,
  7829. SettleType: settle_accounts_type,
  7830. SettleStartTime: start_time,
  7831. SettleEndTime: end_time,
  7832. Creator: roles.AdminUserId,
  7833. Modify: roles.AdminUserId,
  7834. PType: 2,
  7835. Diagnosis: diagnosis_id,
  7836. }
  7837. err = service.CreateOrder(order)
  7838. if err != nil {
  7839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7840. return
  7841. }
  7842. for _, item := range res.Output.Result {
  7843. temp := strings.Split(item.FeedetlSn, "-")
  7844. var advice_id int64 = 0
  7845. var project_id int64 = 0
  7846. var types int64 = 0
  7847. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7848. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7849. if temp[1] == "1" {
  7850. advice_id = id
  7851. project_id = 0
  7852. } else if temp[1] == "2" {
  7853. advice_id = 0
  7854. project_id = id
  7855. }
  7856. info := &models.HisOrderInfo{
  7857. OrderNumber: order.Number,
  7858. FeedetlSn: item.FeedetlSn,
  7859. UploadDate: time.Now().Unix(),
  7860. AdviceId: advice_id,
  7861. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7862. Cnt: item.Cnt,
  7863. Pric: float64(item.Pric),
  7864. PatientId: his.PatientId,
  7865. PricUplmtAmt: item.PricUplmtAmt,
  7866. SelfpayProp: item.SelfpayProp,
  7867. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7868. OverlmtAmt: item.OverlmtAmt,
  7869. PreselfpayAmt: item.PreselfpayAmt,
  7870. BasMednFlag: item.BasMednFlag,
  7871. MedChrgitmType: item.MedChrgitmType,
  7872. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7873. Status: 1,
  7874. Memo: item.Memo,
  7875. Mtime: time.Now().Unix(),
  7876. InscpScpAmt: item.InscpScpAmt,
  7877. DrtReimFlag: item.DrtReimFlag,
  7878. Ctime: time.Now().Unix(),
  7879. ListSpItemFlag: item.ListSpItemFlag,
  7880. ChldMedcFlag: item.ChldMedcFlag,
  7881. LmtUsedFlag: item.LmtUsedFlag,
  7882. ChrgitmLv: item.ChrgitmLv,
  7883. UserOrgId: adminUser.CurrentOrgId,
  7884. HisPatientId: his.ID,
  7885. OrderId: order.ID,
  7886. ProjectId: project_id,
  7887. Type: types,
  7888. }
  7889. service.CreateOrderInfo(info)
  7890. }
  7891. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7892. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7893. var total float64
  7894. for _, item := range prescriptions {
  7895. if item.Type == 1 { //药品
  7896. for _, subItem := range item.HisDoctorAdviceInfo {
  7897. total = total + (subItem.Price * subItem.PrescribingNumber)
  7898. }
  7899. }
  7900. if item.Type == 2 { //项目
  7901. for _, subItem := range item.HisPrescriptionProject {
  7902. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7903. total = total + (subItem.Price * cnt)
  7904. }
  7905. }
  7906. }
  7907. for _, item := range prescriptions {
  7908. for _, subItem := range item.HisAdditionalCharge {
  7909. total = total + (subItem.Price * float64(subItem.Count))
  7910. }
  7911. }
  7912. allTotal := fmt.Sprintf("%.4f", total)
  7913. if res.Infcode == 0 {
  7914. var rf []*ResultFive
  7915. json.Unmarshal([]byte(his.Iinfo), &rf)
  7916. chrg_bchno := chrg_bchno
  7917. cert_no := his.Certno
  7918. var insutypes []string
  7919. var insutype string
  7920. var is390 int = 0
  7921. var is310 int = 0
  7922. for _, item := range rf {
  7923. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7924. insutypes = append(insutypes, item.Insutype)
  7925. }
  7926. }
  7927. if len(insutypes) == 1 {
  7928. insutype = insutypes[0]
  7929. } else {
  7930. for _, i := range insutypes {
  7931. if i == "390" {
  7932. is390 = 1
  7933. }
  7934. if i == "310" {
  7935. is310 = 1
  7936. }
  7937. }
  7938. }
  7939. if is390 == 1 {
  7940. insutype = "390"
  7941. }
  7942. if is310 == 1 {
  7943. insutype = "310"
  7944. }
  7945. if len(insutypes) == 0 {
  7946. insutype = "310"
  7947. }
  7948. if len(insutypes) == 2 {
  7949. insutype = strconv.FormatInt(his.SocialType, 64)
  7950. }
  7951. //insutype = "390"
  7952. if his.IdCardType == 1 {
  7953. cert_no = his.MedicalInsuranceNumber
  7954. } else {
  7955. cert_no = his.Certno
  7956. }
  7957. var res ResultSeven
  7958. var resSeven10265 ResultSeven10265
  7959. if miConfig.MdtrtareaAdmvs == "421300" {
  7960. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7961. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7962. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7963. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7964. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7965. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7966. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7967. resp, requestErr := http.Get(api)
  7968. if requestErr != nil {
  7969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7970. return
  7971. }
  7972. body, ioErr := ioutil.ReadAll(resp.Body)
  7973. if ioErr != nil {
  7974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7976. return
  7977. }
  7978. var respJSON map[string]interface{}
  7979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7982. return
  7983. }
  7984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7985. result, _ := json.Marshal(respJSON)
  7986. fmt.Println("log")
  7987. fmt.Println(string(result))
  7988. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7989. utils.ErrorLog("解析失败:%v", err)
  7990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7991. return
  7992. }
  7993. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7994. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  7995. if result3101.Infcode == "0" {
  7996. if len(result3101.Output.Result) > 0 {
  7997. var errMsgs []string
  7998. for _, item := range result3101.Output.Result {
  7999. errMsgs = append(errMsgs, item.VolaCont)
  8000. }
  8001. c.ServeSuccessJSON(map[string]interface{}{
  8002. "failed_code": -10,
  8003. "msg": errMsgs,
  8004. })
  8005. return
  8006. }
  8007. }
  8008. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8009. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8010. bas := strings.Split(psn_info.CardInfo, "|")
  8011. if his.IdCardType == 1 {
  8012. cert_no = bas[2]
  8013. } else {
  8014. cert_no = bas[1]
  8015. }
  8016. //江苏地区国家医保医疗类别
  8017. //职工透析:医疗类别选特殊情况门诊9933
  8018. //居民血透门慢: 医疗类别选门诊慢病1402
  8019. //var med_type string
  8020. //if his.Insutype == "310" {
  8021. // if reg_type == 14 {
  8022. // med_type = "9933"
  8023. // } else if reg_type == 11 {
  8024. // med_type = "11"
  8025. //
  8026. // }
  8027. //} else if his.Insutype == "390" {
  8028. // if reg_type == 14 {
  8029. // med_type = "1402"
  8030. // } else if reg_type == 11 {
  8031. // med_type = "11"
  8032. // }
  8033. //}
  8034. var api string
  8035. if miConfig.MdtrtareaAdmvs == "320921" {
  8036. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8037. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8038. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8039. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8040. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8041. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8042. "&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
  8043. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8044. } else {
  8045. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8046. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8047. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8048. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8049. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8050. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8051. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8052. "&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
  8053. }
  8054. resp, requestErr := http.Get(api)
  8055. if requestErr != nil {
  8056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8057. return
  8058. }
  8059. body, ioErr := ioutil.ReadAll(resp.Body)
  8060. if ioErr != nil {
  8061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8063. return
  8064. }
  8065. var respJSON map[string]interface{}
  8066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8069. return
  8070. }
  8071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8072. result, _ := json.Marshal(respJSON)
  8073. fmt.Println("log")
  8074. fmt.Println(string(result))
  8075. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8076. utils.ErrorLog("解析失败:%v", err)
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. return
  8079. }
  8080. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8081. res.Output = resSeven10265.Output
  8082. res.ErrMsg = resSeven10265.ErrMsg
  8083. res.Cainfo = resSeven10265.Cainfo
  8084. res.WarnMsg = resSeven10265.WarnMsg
  8085. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8086. res.Infcode = infocode
  8087. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8088. 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)
  8089. var dat map[string]interface{}
  8090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8091. fmt.Println(dat)
  8092. } else {
  8093. fmt.Println(err)
  8094. }
  8095. saveLog(result, request_log, "2206", "预结算")
  8096. userJSONBytes, _ := json.Marshal(dat)
  8097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8098. utils.ErrorLog("解析失败:%v", err)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. } else {
  8103. var result string
  8104. var request_log string
  8105. if miConfig.Code == "H15049901371" {
  8106. //赤峰地区国家医保医疗类别
  8107. //职工透析:医疗类别选特殊情况门诊990502
  8108. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8109. var med_type string
  8110. if his.Insutype == "390" {
  8111. if reg_type == 14 {
  8112. med_type = "9933"
  8113. } else if reg_type == 11 {
  8114. med_type = "11"
  8115. }
  8116. } else if his.Insutype == "310" {
  8117. if reg_type == 14 {
  8118. med_type = "990502"
  8119. } else if reg_type == 11 {
  8120. med_type = "11"
  8121. }
  8122. }
  8123. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  8124. } else {
  8125. 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)
  8126. }
  8127. var dat map[string]interface{}
  8128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8129. fmt.Println(dat)
  8130. } else {
  8131. fmt.Println(err)
  8132. }
  8133. saveLog(result, request_log, "2206", "预结算")
  8134. //userJSONBytes, _ := json.Marshal(dat)
  8135. //
  8136. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8137. // utils.ErrorLog("解析失败:%v", err)
  8138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8139. // return
  8140. //}
  8141. userJSONBytes, _ := json.Marshal(dat)
  8142. if miConfig.Code == "H15049901371" {
  8143. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8144. utils.ErrorLog("解析失败:%v", err)
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8146. return
  8147. }
  8148. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8149. res.Output = resSeven10265.Output
  8150. res.ErrMsg = resSeven10265.ErrMsg
  8151. res.Cainfo = resSeven10265.Cainfo
  8152. res.WarnMsg = resSeven10265.WarnMsg
  8153. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8154. res.Infcode = infocode
  8155. } else {
  8156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8157. utils.ErrorLog("解析失败:%v", err)
  8158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8159. return
  8160. }
  8161. }
  8162. }
  8163. if res.Infcode != 0 {
  8164. errlog := &models.HisOrderError{
  8165. UserOrgId: adminUser.CurrentOrgId,
  8166. Ctime: time.Now().Unix(),
  8167. Mtime: time.Now().Unix(),
  8168. Number: chrg_bchno,
  8169. ErrMsg: res.ErrMsg,
  8170. Status: 1,
  8171. PatientId: id,
  8172. RecordTime: recordDateTime,
  8173. Stage: 20,
  8174. }
  8175. service.CreateErrMsgLog(errlog)
  8176. c.ServeSuccessJSON(map[string]interface{}{
  8177. "failed_code": -10,
  8178. "msg": res.ErrMsg,
  8179. })
  8180. return
  8181. } else {
  8182. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8183. order.OrderStatus = 1
  8184. order.IsPre = 1
  8185. order.Status = 1
  8186. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8187. order.SetlId = res.Output.Setlinfo.SetlID
  8188. order.PsnNo = res.Output.Setlinfo.PsnNo
  8189. order.PsnName = res.Output.Setlinfo.PsnName
  8190. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8191. order.Certno = res.Output.Setlinfo.Certno
  8192. order.Gend = res.Output.Setlinfo.Gend
  8193. order.Naty = res.Output.Setlinfo.Naty
  8194. order.Age = res.Output.Setlinfo.Age
  8195. order.Insutype = res.Output.Setlinfo.Insutype
  8196. order.PsnType = res.Output.Setlinfo.PsnType
  8197. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8198. order.SetlTime = res.Output.Setlinfo.SetlTime
  8199. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8200. if res.Output.Setlinfo.MedType == "140101" {
  8201. order.MedType = "14"
  8202. } else {
  8203. order.MedType = res.Output.Setlinfo.MedType
  8204. }
  8205. if reg_type == 1112 {
  8206. order.MedType = "1112"
  8207. }
  8208. if reg_type == 1111 {
  8209. order.MedType = "1111"
  8210. }
  8211. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8212. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8213. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8214. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8215. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8216. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8217. order.HifpPay = res.Output.Setlinfo.HifpPay
  8218. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8219. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8220. order.HifesPay = res.Output.Setlinfo.HifesPay
  8221. order.HifobPay = res.Output.Setlinfo.HifobPay
  8222. order.MafPay = res.Output.Setlinfo.MafPay
  8223. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8224. order.OthPay = res.Output.Setlinfo.OthPay
  8225. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8226. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8227. order.AcctPay = res.Output.Setlinfo.AcctPay
  8228. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8229. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8230. order.Balc = res.Output.Setlinfo.Balc
  8231. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8232. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8233. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8234. order.ClrWay = res.Output.Setlinfo.ClrWay
  8235. order.Creator = order.Creator
  8236. order.Modify = roles.AdminUserId
  8237. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8238. detailStr := string(setlDetail)
  8239. order.SetlDetail = detailStr
  8240. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8241. err = service.UpDateOrder(order)
  8242. if err == nil {
  8243. c.ServeSuccessJSON(map[string]interface{}{
  8244. "msg": "预结算成功",
  8245. })
  8246. } else {
  8247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8248. return
  8249. }
  8250. }
  8251. } else {
  8252. adminUser := c.GetAdminUserInfo()
  8253. errlog := &models.HisOrderError{
  8254. UserOrgId: adminUser.CurrentOrgId,
  8255. Ctime: time.Now().Unix(),
  8256. Mtime: time.Now().Unix(),
  8257. ErrMsg: res.ErrMsg,
  8258. Status: 1,
  8259. PatientId: id,
  8260. RecordTime: recordDateTime,
  8261. Stage: 4,
  8262. }
  8263. service.CreateErrMsgLog(errlog)
  8264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8265. return
  8266. }
  8267. } else {
  8268. adminUser := c.GetAdminUserInfo()
  8269. errlog := &models.HisOrderError{
  8270. UserOrgId: adminUser.CurrentOrgId,
  8271. Ctime: time.Now().Unix(),
  8272. Mtime: time.Now().Unix(),
  8273. ErrMsg: res.ErrMsg,
  8274. Status: 1,
  8275. PatientId: id,
  8276. RecordTime: recordDateTime,
  8277. Stage: 4,
  8278. }
  8279. service.CreateErrMsgLog(errlog)
  8280. c.ServeSuccessJSON(map[string]interface{}{
  8281. "failed_code": -10,
  8282. "msg": res.ErrMsg,
  8283. })
  8284. return
  8285. }
  8286. }
  8287. }
  8288. }
  8289. //退款
  8290. func (c *HisApiController) Refund() {
  8291. order_id, _ := c.GetInt64("order_id")
  8292. admin_user_id, _ := c.GetInt64("admin_user_id")
  8293. adminUser := c.GetAdminUserInfo()
  8294. var order models.HisOrder
  8295. order, _ = service.GetHisOrderByID(order_id)
  8296. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8297. if order.ID == 0 {
  8298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8299. return
  8300. }
  8301. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8302. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8303. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8304. if config.IsOpen == 1 { //对接了医保,走医保流程
  8305. var res ResultSixteen
  8306. var resSixteen10265 ResultSixteen10265
  8307. var src_resquest string
  8308. var result string
  8309. if miConfig.MdtrtareaAdmvs == "421300" {
  8310. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8311. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8312. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8313. resp3, requestErr3 := http.Get(api3)
  8314. if requestErr3 != nil {
  8315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8316. return
  8317. }
  8318. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8319. if ioErr3 != nil {
  8320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8322. return
  8323. }
  8324. var respJSON3 map[string]interface{}
  8325. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8328. return
  8329. }
  8330. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8331. userJSONBytes3, _ := json.Marshal(respJSON3)
  8332. fmt.Println("log")
  8333. fmt.Println(string(userJSONBytes3))
  8334. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8335. utils.ErrorLog("解析失败:%v", err)
  8336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8337. return
  8338. }
  8339. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8340. var api3 string
  8341. if miConfig.MdtrtareaAdmvs == "320921" {
  8342. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8343. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8345. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8346. } else {
  8347. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8348. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8349. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8350. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8351. }
  8352. resp3, requestErr3 := http.Get(api3)
  8353. if requestErr3 != nil {
  8354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8355. return
  8356. }
  8357. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8358. if ioErr3 != nil {
  8359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8361. return
  8362. }
  8363. var respJSON3 map[string]interface{}
  8364. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8367. return
  8368. }
  8369. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8370. userJSONBytes3, _ := json.Marshal(respJSON3)
  8371. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8372. utils.ErrorLog("解析失败:%v", err)
  8373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8374. return
  8375. }
  8376. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8377. res.Output = resSixteen10265.Output
  8378. res.ErrMsg = resSixteen10265.ErrMsg
  8379. res.Cainfo = resSixteen10265.Cainfo
  8380. res.WarnMsg = resSixteen10265.WarnMsg
  8381. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8382. res.Infcode = infocode
  8383. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8384. 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)
  8385. var dat map[string]interface{}
  8386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8387. fmt.Println(dat)
  8388. } else {
  8389. fmt.Println(err)
  8390. }
  8391. saveLog(result, src_resquest, "2208", "退费")
  8392. userJSONBytes, _ := json.Marshal(dat)
  8393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8394. utils.ErrorLog("解析失败:%v", err)
  8395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. return
  8397. }
  8398. } else {
  8399. if miConfig.Code == "H15049901371" {
  8400. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8401. var dat map[string]interface{}
  8402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8403. fmt.Println(dat)
  8404. } else {
  8405. fmt.Println(err)
  8406. }
  8407. saveLog(result, src_resquest, "2208", "退费")
  8408. userJSONBytes, _ := json.Marshal(dat)
  8409. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8410. utils.ErrorLog("解析失败:%v", err)
  8411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8412. return
  8413. }
  8414. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8415. res.Output = resSixteen10265.Output
  8416. res.ErrMsg = resSixteen10265.ErrMsg
  8417. res.Cainfo = resSixteen10265.Cainfo
  8418. res.WarnMsg = resSixteen10265.WarnMsg
  8419. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8420. res.Infcode = infocode
  8421. } else {
  8422. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8423. var dat map[string]interface{}
  8424. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8425. fmt.Println(dat)
  8426. } else {
  8427. fmt.Println(err)
  8428. }
  8429. saveLog(result, src_resquest, "2208", "退费")
  8430. userJSONBytes, _ := json.Marshal(dat)
  8431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8432. utils.ErrorLog("解析失败:%v", err)
  8433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8434. return
  8435. }
  8436. }
  8437. }
  8438. if res.Infcode == 0 {
  8439. var res2 ResultSix
  8440. var resSix10265 ResultSix10265
  8441. if miConfig.MdtrtareaAdmvs == "421300" {
  8442. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8443. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8444. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8445. resp3, requestErr3 := http.Get(api3)
  8446. if requestErr3 != nil {
  8447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8448. return
  8449. }
  8450. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8451. if ioErr3 != nil {
  8452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8454. return
  8455. }
  8456. var respJSON3 map[string]interface{}
  8457. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8460. return
  8461. }
  8462. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8463. userJSONBytes3, _ := json.Marshal(respJSON3)
  8464. fmt.Println("log")
  8465. fmt.Println(string(userJSONBytes3))
  8466. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8467. utils.ErrorLog("解析失败:%v", err)
  8468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8469. return
  8470. }
  8471. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8472. var api3 string
  8473. if miConfig.MdtrtareaAdmvs == "320921" {
  8474. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8475. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8476. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8477. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8478. } else {
  8479. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8480. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8481. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8482. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8483. }
  8484. resp3, requestErr3 := http.Get(api3)
  8485. if requestErr3 != nil {
  8486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8487. return
  8488. }
  8489. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8490. if ioErr3 != nil {
  8491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8493. return
  8494. }
  8495. var respJSON3 map[string]interface{}
  8496. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8499. return
  8500. }
  8501. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8502. userJSONBytes3, _ := json.Marshal(respJSON3)
  8503. fmt.Println("log")
  8504. fmt.Println(string(userJSONBytes3))
  8505. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8506. utils.ErrorLog("解析失败:%v", err)
  8507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8508. return
  8509. }
  8510. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8511. res2.Output = resSix10265.Output
  8512. res2.ErrMsg = resSix10265.ErrMsg
  8513. res2.Cainfo = resSix10265.Cainfo
  8514. res2.WarnMsg = resSix10265.WarnMsg
  8515. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8516. res2.Infcode = infocode
  8517. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8518. 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)
  8519. var dat map[string]interface{}
  8520. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8521. fmt.Println(dat)
  8522. } else {
  8523. fmt.Println(err)
  8524. }
  8525. saveLog(result2, src_request, "2205", "撤销明细")
  8526. userJSONBytes, _ := json.Marshal(dat)
  8527. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8528. utils.ErrorLog("解析失败:%v", err)
  8529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8530. return
  8531. }
  8532. } else {
  8533. if miConfig.Code == "H15049901371" {
  8534. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8535. var dat map[string]interface{}
  8536. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8537. fmt.Println(dat)
  8538. } else {
  8539. fmt.Println(err)
  8540. }
  8541. saveLog(result2, src_request, "2205", "撤销明细")
  8542. userJSONBytes, _ := json.Marshal(dat)
  8543. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8544. utils.ErrorLog("解析失败:%v", err)
  8545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8546. return
  8547. }
  8548. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8549. res2.Output = resSix10265.Output
  8550. res2.ErrMsg = resSix10265.ErrMsg
  8551. res2.Cainfo = resSix10265.Cainfo
  8552. res2.WarnMsg = resSix10265.WarnMsg
  8553. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8554. res2.Infcode = infocode
  8555. } else {
  8556. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8557. var dat map[string]interface{}
  8558. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8559. fmt.Println(dat)
  8560. } else {
  8561. fmt.Println(err)
  8562. }
  8563. saveLog(result2, src_request, "2205", "撤销明细")
  8564. userJSONBytes, _ := json.Marshal(dat)
  8565. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8566. utils.ErrorLog("解析失败:%v", err)
  8567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8568. return
  8569. }
  8570. }
  8571. }
  8572. if res2.Infcode == 0 {
  8573. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8574. if err == nil {
  8575. //当押金不为零时产生退费记录
  8576. if order.Decimal != 0 {
  8577. tmp := strconv.FormatInt(order.ID, 10)
  8578. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8579. if err != nil {
  8580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8581. return
  8582. }
  8583. }
  8584. c.ServeSuccessJSON(map[string]interface{}{
  8585. "msg": "退费成功",
  8586. })
  8587. } else {
  8588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8589. return
  8590. }
  8591. } else {
  8592. c.ServeSuccessJSON(map[string]interface{}{
  8593. "code": -10,
  8594. "msg": res2.ErrMsg,
  8595. })
  8596. }
  8597. } else {
  8598. c.ServeSuccessJSON(map[string]interface{}{
  8599. "code": -10,
  8600. "msg": res.ErrMsg,
  8601. })
  8602. }
  8603. }
  8604. }
  8605. func (c *HisApiController) RefundNumber() {
  8606. record_time := c.GetString("record_time")
  8607. //patient_id, _ := c.GetInt64("patient_id")
  8608. admin_user_id, _ := c.GetInt64("admin_user_id")
  8609. his_patient_id, _ := c.GetInt64("id")
  8610. timeLayout := "2006-01-02"
  8611. loc, _ := time.LoadLocation("Local")
  8612. adminUser := c.GetAdminUserInfo()
  8613. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8614. fmt.Println(err)
  8615. if err != nil {
  8616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8617. return
  8618. }
  8619. recordDateTime := theTime.Unix()
  8620. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8621. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8622. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8623. //order, _ := service.GetHisOrderByID(order_id)
  8624. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8625. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8626. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8627. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8628. if count > 0 {
  8629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8630. return
  8631. }
  8632. if config.IsOpen == 1 { //对接了医保,走医保流程
  8633. var res2 ResultSix
  8634. var resSix10265 ResultSix10265
  8635. if miConfig.MdtrtareaAdmvs == "421300" {
  8636. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8637. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8638. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8639. resp3, requestErr3 := http.Get(api3)
  8640. if requestErr3 != nil {
  8641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8642. return
  8643. }
  8644. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8645. if ioErr3 != nil {
  8646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8648. return
  8649. }
  8650. var respJSON3 map[string]interface{}
  8651. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8654. return
  8655. }
  8656. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8657. userJSONBytes3, _ := json.Marshal(respJSON3)
  8658. fmt.Println("log")
  8659. fmt.Println(string(userJSONBytes3))
  8660. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8661. utils.ErrorLog("解析失败:%v", err)
  8662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8663. return
  8664. }
  8665. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8666. var api3 string
  8667. if miConfig.MdtrtareaAdmvs == "320921" {
  8668. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8669. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8670. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8671. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8672. } else {
  8673. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8674. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8675. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8676. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8677. }
  8678. resp3, requestErr3 := http.Get(api3)
  8679. if requestErr3 != nil {
  8680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8681. return
  8682. }
  8683. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8684. if ioErr3 != nil {
  8685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8687. return
  8688. }
  8689. var respJSON3 map[string]interface{}
  8690. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8693. return
  8694. }
  8695. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8696. userJSONBytes3, _ := json.Marshal(respJSON3)
  8697. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8698. utils.ErrorLog("解析失败:%v", err)
  8699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8700. return
  8701. }
  8702. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8703. res2.Output = resSix10265.Output
  8704. res2.ErrMsg = resSix10265.ErrMsg
  8705. res2.Cainfo = resSix10265.Cainfo
  8706. res2.WarnMsg = resSix10265.WarnMsg
  8707. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8708. res2.Infcode = infocode
  8709. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8710. 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)
  8711. var dat map[string]interface{}
  8712. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8713. fmt.Println(dat)
  8714. } else {
  8715. fmt.Println(err)
  8716. }
  8717. saveLog(result, request, "2202", "退号")
  8718. userJSONBytes, _ := json.Marshal(dat)
  8719. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8720. utils.ErrorLog("解析失败:%v", err)
  8721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8722. return
  8723. }
  8724. } else {
  8725. var api3 string
  8726. if miConfig.Code == "H15049901371" {
  8727. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8728. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8729. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8730. } else {
  8731. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8732. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8733. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8734. }
  8735. resp3, requestErr3 := http.Get(api3)
  8736. if requestErr3 != nil {
  8737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8738. return
  8739. }
  8740. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8741. if ioErr3 != nil {
  8742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8744. return
  8745. }
  8746. var respJSON3 map[string]interface{}
  8747. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8750. return
  8751. }
  8752. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8753. userJSONBytes3, _ := json.Marshal(respJSON3)
  8754. if miConfig.Code == "H15049901371" {
  8755. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8756. utils.ErrorLog("解析失败:%v", err)
  8757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8758. return
  8759. }
  8760. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8761. res2.Output = resSix10265.Output
  8762. res2.ErrMsg = resSix10265.ErrMsg
  8763. res2.Cainfo = resSix10265.Cainfo
  8764. res2.WarnMsg = resSix10265.WarnMsg
  8765. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8766. res2.Infcode = infocode
  8767. } else {
  8768. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8769. utils.ErrorLog("解析失败:%v", err)
  8770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8771. return
  8772. }
  8773. }
  8774. }
  8775. if res2.Infcode == 0 {
  8776. if err == nil {
  8777. c.ServeSuccessJSON(map[string]interface{}{
  8778. "msg": "退号成功",
  8779. })
  8780. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8781. } else {
  8782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8783. return
  8784. }
  8785. } else {
  8786. c.ServeSuccessJSON(map[string]interface{}{
  8787. "code": -10,
  8788. "msg": res2.ErrMsg,
  8789. })
  8790. }
  8791. } else {
  8792. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8793. //if err == nil {
  8794. // c.ServeSuccessJSON(map[string]interface{}{
  8795. // "msg": "退费成功",
  8796. // })
  8797. //} else {
  8798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8799. // return
  8800. //}
  8801. }
  8802. }
  8803. func (c *HisApiController) RefundDetail() {
  8804. order_id, _ := c.GetInt64("order_id")
  8805. admin_user_id, _ := c.GetInt64("admin_user_id")
  8806. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8807. number := c.GetString("number")
  8808. record_time := c.GetString("record_time")
  8809. patient_id, _ := c.GetInt64("patient_id")
  8810. //med_type, _ := c.GetInt64("med_type")
  8811. timeLayout := "2006-01-02"
  8812. loc, _ := time.LoadLocation("Local")
  8813. adminUser := c.GetAdminUserInfo()
  8814. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8815. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8816. fmt.Println(err)
  8817. if err != nil {
  8818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8819. return
  8820. }
  8821. recordDateTime := theTime.Unix()
  8822. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8823. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8824. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8825. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8826. var order models.HisOrder
  8827. order, _ = service.GetHisOrderByID(order_id)
  8828. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8829. if config.IsOpen == 1 { //对接了医保,走医保流程
  8830. var res2 ResultSix
  8831. if miConfig.MdtrtareaAdmvs == "421300" {
  8832. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8833. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8834. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8835. resp3, requestErr3 := http.Get(api3)
  8836. if requestErr3 != nil {
  8837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8838. return
  8839. }
  8840. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8841. if ioErr3 != nil {
  8842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8844. return
  8845. }
  8846. var respJSON3 map[string]interface{}
  8847. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8850. return
  8851. }
  8852. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8853. userJSONBytes3, _ := json.Marshal(respJSON3)
  8854. fmt.Println("log")
  8855. fmt.Println(string(userJSONBytes3))
  8856. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8857. utils.ErrorLog("解析失败:%v", err)
  8858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8859. return
  8860. }
  8861. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8862. if err == nil {
  8863. c.ServeSuccessJSON(map[string]interface{}{
  8864. "msg": "撤销明细成功",
  8865. })
  8866. return
  8867. } else {
  8868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8869. return
  8870. }
  8871. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8872. var resSix10265 ResultSix10265
  8873. var api3 string
  8874. if miConfig.MdtrtareaAdmvs == "320921" {
  8875. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8876. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8878. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8879. } else {
  8880. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8881. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8882. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8883. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8884. }
  8885. resp3, requestErr3 := http.Get(api3)
  8886. if requestErr3 != nil {
  8887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8888. return
  8889. }
  8890. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8891. if ioErr3 != nil {
  8892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8894. return
  8895. }
  8896. var respJSON3 map[string]interface{}
  8897. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8900. return
  8901. }
  8902. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8903. userJSONBytes3, _ := json.Marshal(respJSON3)
  8904. fmt.Println("log")
  8905. fmt.Println(string(userJSONBytes3))
  8906. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8907. utils.ErrorLog("解析失败:%v", err)
  8908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8909. return
  8910. }
  8911. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8912. res2.Output = resSix10265.Output
  8913. res2.ErrMsg = resSix10265.ErrMsg
  8914. res2.Cainfo = resSix10265.Cainfo
  8915. res2.WarnMsg = resSix10265.WarnMsg
  8916. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8917. res2.Infcode = infocode
  8918. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8919. if err == nil {
  8920. c.ServeSuccessJSON(map[string]interface{}{
  8921. "msg": "撤销明细成功",
  8922. })
  8923. return
  8924. } else {
  8925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8926. return
  8927. }
  8928. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8929. 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)
  8930. var dat map[string]interface{}
  8931. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8932. fmt.Println(dat)
  8933. } else {
  8934. fmt.Println(err)
  8935. }
  8936. saveLog(result2, src_request, "2205", "撤销明细")
  8937. userJSONBytes, _ := json.Marshal(dat)
  8938. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8939. utils.ErrorLog("解析失败:%v", err)
  8940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8941. return
  8942. }
  8943. if res2.Infcode == 0 {
  8944. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8945. if err == nil {
  8946. c.ServeSuccessJSON(map[string]interface{}{
  8947. "msg": "撤销明细成功",
  8948. })
  8949. return
  8950. } else {
  8951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8952. return
  8953. }
  8954. } else {
  8955. c.ServeSuccessJSON(map[string]interface{}{
  8956. "code": -10,
  8957. "msg": res2.ErrMsg,
  8958. })
  8959. }
  8960. } else {
  8961. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8962. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8963. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8964. resp2, requestErr2 := http.Get(api2)
  8965. if requestErr2 != nil {
  8966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8967. return
  8968. }
  8969. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8970. if ioErr2 != nil {
  8971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8973. return
  8974. }
  8975. var respJSON2 map[string]interface{}
  8976. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8979. return
  8980. }
  8981. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8982. if err == nil {
  8983. c.ServeSuccessJSON(map[string]interface{}{
  8984. "msg": "撤销明细成功",
  8985. })
  8986. return
  8987. } else {
  8988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8989. return
  8990. }
  8991. }
  8992. } else {
  8993. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8994. if err == nil {
  8995. c.ServeSuccessJSON(map[string]interface{}{
  8996. "msg": "退费成功",
  8997. })
  8998. } else {
  8999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9000. return
  9001. }
  9002. }
  9003. }
  9004. //对账
  9005. func (c *HisApiController) GetCheckAccount() {
  9006. start_time := c.GetString("start_time")
  9007. end_time := c.GetString("end_time")
  9008. insutype := c.GetString("insutype")
  9009. clr_type := c.GetString("clr_type")
  9010. clr_org := c.GetString("clr_optins")
  9011. admin_user_id, _ := c.GetInt64("admin_user_id")
  9012. adminUser := c.GetAdminUserInfo()
  9013. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9014. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9015. if len(clr_org) == 0 {
  9016. clr_org = miConfig.MdtrtareaAdmvs
  9017. }
  9018. timeLayout := "2006-01-02"
  9019. loc, _ := time.LoadLocation("Local")
  9020. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9021. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9022. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9023. fixmedins_setl_cnt := int64(len(orders))
  9024. var medfee_sumamt float64
  9025. var acct_pay float64
  9026. var fund_pay_sumamt float64
  9027. for _, item := range orders {
  9028. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9029. acct_pay = acct_pay + item.AcctPay
  9030. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9031. }
  9032. var user_name string
  9033. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9034. if role.ID == 0 {
  9035. user_name = "xxx"
  9036. } else {
  9037. user_name = role.UserName
  9038. }
  9039. var res ResultEight
  9040. var res10188 ResultEightFor10188
  9041. if config.IsOpen == 1 {
  9042. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9043. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  9044. "insutype=" + insutype +
  9045. "&clr_type=" + clr_type +
  9046. "&setl_optins=" + clr_org +
  9047. "&stmt_begndate=" + start_time +
  9048. "&stm_enddate=" + end_time +
  9049. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9050. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9051. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9052. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9053. "&fixmedins_code=" + miConfig.Code +
  9054. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9055. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9056. "&secret_key=" + miConfig.SecretKey +
  9057. "&org_name=" + miConfig.OrgName +
  9058. "&doctor=" + user_name +
  9059. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9060. fmt.Println(api)
  9061. resp, requestErr := http.Get(api)
  9062. if requestErr != nil {
  9063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9064. return
  9065. }
  9066. body, ioErr := ioutil.ReadAll(resp.Body)
  9067. fmt.Println(body)
  9068. if ioErr != nil {
  9069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9071. return
  9072. }
  9073. var respJSON map[string]interface{}
  9074. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9077. return
  9078. }
  9079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9080. userJSONBytes, _ := json.Marshal(respJSON)
  9081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9082. utils.ErrorLog("解析失败:%v", err)
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9084. return
  9085. }
  9086. res.InfRefmsgid = res10188.InfRefmsgid
  9087. res.Output = res10188.Output
  9088. res.ErrMsg = res10188.ErrMsg
  9089. res.Cainfo = res10188.Cainfo
  9090. res.WarnMsg = res10188.WarnMsg
  9091. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9092. res.Infcode = infocode
  9093. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9094. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  9095. "insutype=" + insutype +
  9096. "&clr_type=" + clr_type +
  9097. "&setl_optins=" + clr_org +
  9098. "&stmt_begndate=" + start_time +
  9099. "&stm_enddate=" + end_time +
  9100. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9101. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9102. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9103. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9104. "&fixmedins_code=" + miConfig.Code +
  9105. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9106. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9107. "&secret_key=" + miConfig.SecretKey +
  9108. "&org_name=" + miConfig.OrgName +
  9109. "&doctor=" + user_name
  9110. resp, requestErr := http.Get(api)
  9111. if requestErr != nil {
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9113. return
  9114. }
  9115. body, ioErr := ioutil.ReadAll(resp.Body)
  9116. if ioErr != nil {
  9117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9119. return
  9120. }
  9121. var respJSON map[string]interface{}
  9122. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9125. return
  9126. }
  9127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9128. result, _ := json.Marshal(respJSON)
  9129. fmt.Println("log")
  9130. fmt.Println(string(result))
  9131. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  9132. utils.ErrorLog("解析失败:%v", err)
  9133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9134. return
  9135. }
  9136. res.InfRefmsgid = res10188.InfRefmsgid
  9137. res.Output = res10188.Output
  9138. res.ErrMsg = res10188.ErrMsg
  9139. res.Cainfo = res10188.Cainfo
  9140. res.WarnMsg = res10188.WarnMsg
  9141. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9142. res.Infcode = infocode
  9143. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9144. var baseParams models.BaseParams
  9145. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9146. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9147. baseParams.SecretKey = miConfig.SecretKey
  9148. baseParams.OrgName = miConfig.OrgName
  9149. baseParams.FixmedinsCode = miConfig.Code
  9150. baseParams.EncKey = miConfig.EncKey
  9151. baseParams.AppSecret = miConfig.AppSecret
  9152. baseParams.SignKey = miConfig.SignKey
  9153. baseParams.AppID = miConfig.Code
  9154. baseParams.Doctor = role.UserName
  9155. baseParams.RequestUrl = miConfig.Url
  9156. businessParams := models.BusinessParams{
  9157. Insutype: insutype,
  9158. ClrType: clr_type,
  9159. SetlOptins: clr_org,
  9160. StmtBegndate: start_time,
  9161. StmtEnddate: end_time,
  9162. MedfeeSumamt: medfee_sumamt,
  9163. FundPaySumamt: fund_pay_sumamt,
  9164. AcctPay: acct_pay,
  9165. FixmedinsSetlCnt: fixmedins_setl_cnt,
  9166. }
  9167. result, requestLog := service.FJyb3201(baseParams, businessParams)
  9168. fmt.Println(requestLog)
  9169. fmt.Println(result)
  9170. } else {
  9171. if len(clr_type) == 0 {
  9172. clr_type = "11"
  9173. }
  9174. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9175. "insutype=" + insutype +
  9176. "&clr_type=" + clr_type +
  9177. "&setl_optins=" + clr_org +
  9178. "&stmt_begndate=" + start_time +
  9179. "&stm_enddate=" + end_time +
  9180. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9181. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9182. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9183. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9184. "&fixmedins_code=" + miConfig.Code +
  9185. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9186. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9187. "&secret_key=" + miConfig.SecretKey +
  9188. "&org_name=" + miConfig.OrgName +
  9189. "&doctor=" + user_name
  9190. fmt.Println(api)
  9191. resp, requestErr := http.Get(api)
  9192. if requestErr != nil {
  9193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9194. return
  9195. }
  9196. body, ioErr := ioutil.ReadAll(resp.Body)
  9197. fmt.Println(body)
  9198. if ioErr != nil {
  9199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9201. return
  9202. }
  9203. var respJSON map[string]interface{}
  9204. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9207. return
  9208. }
  9209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9210. userJSONBytes, _ := json.Marshal(respJSON)
  9211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9212. utils.ErrorLog("解析失败:%v", err)
  9213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9214. return
  9215. }
  9216. }
  9217. if res.Infcode == 0 {
  9218. if res.Output.Stmtinfo.StmtRslt == "0" {
  9219. micc := &models.MedicalInsuranceCostCompare{
  9220. StartTime: startime.Unix(),
  9221. EndTime: endtime.Unix(),
  9222. Insutype: insutype,
  9223. CheckType: 1,
  9224. Num: fixmedins_setl_cnt,
  9225. Mtime: time.Now().Unix(),
  9226. Status: 1,
  9227. UserOrgId: adminUser.CurrentOrgId,
  9228. CostTotal: medfee_sumamt,
  9229. FuncTotal: fund_pay_sumamt,
  9230. PsnPay: acct_pay,
  9231. Creator: admin_user_id,
  9232. Ctime: time.Now().Unix(),
  9233. ClrType: clr_type,
  9234. }
  9235. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  9236. if err == nil {
  9237. c.ServeSuccessJSON(map[string]interface{}{
  9238. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9239. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9240. })
  9241. } else {
  9242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9243. }
  9244. } else {
  9245. c.ServeSuccessJSON(map[string]interface{}{
  9246. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9247. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9248. })
  9249. }
  9250. } else {
  9251. c.ServeSuccessJSON(map[string]interface{}{
  9252. "code": -10,
  9253. "msg": res.ErrMsg,
  9254. })
  9255. }
  9256. }
  9257. }
  9258. func (c *HisApiController) Check310() {
  9259. adminUser := c.GetAdminUserInfo()
  9260. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9261. var user_name string
  9262. user_name = "高慧裕"
  9263. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9264. "insutype=" + "310" +
  9265. "&clr_type=" + "" +
  9266. "&setl_optins=" + "441202" +
  9267. "&stmt_begndate=" + "2022-03-01" +
  9268. "&stm_enddate=" + "2022-03-31" +
  9269. "&medfee_sumamt=" + "194930.12" +
  9270. "&fund_pay_sumamt=" + "188741.46" +
  9271. "&acct_pay=" + "0" +
  9272. "&fixmedins_setl_cnt=" + "452" +
  9273. "&fixmedins_code=" + miConfig.Code +
  9274. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9275. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9276. "&secret_key=" + miConfig.SecretKey +
  9277. "&org_name=" + miConfig.OrgName +
  9278. "&doctor=" + user_name
  9279. fmt.Println(api)
  9280. resp, requestErr := http.Get(api)
  9281. if requestErr != nil {
  9282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9283. return
  9284. }
  9285. body, ioErr := ioutil.ReadAll(resp.Body)
  9286. fmt.Println(body)
  9287. if ioErr != nil {
  9288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9290. return
  9291. }
  9292. var respJSON map[string]interface{}
  9293. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9296. return
  9297. }
  9298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9299. userJSONBytes, _ := json.Marshal(respJSON)
  9300. var res ResultEight
  9301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9302. utils.ErrorLog("解析失败:%v", err)
  9303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9304. return
  9305. }
  9306. }
  9307. func (c *HisApiController) Check390() {
  9308. adminUser := c.GetAdminUserInfo()
  9309. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9310. var user_name string
  9311. user_name = "高慧裕"
  9312. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9313. "insutype=" + "390" +
  9314. "&clr_type=" + "" +
  9315. "&setl_optins=" + "441202" +
  9316. "&stmt_begndate=" + "2022-03-01" +
  9317. "&stm_enddate=" + "2022-03-31" +
  9318. "&medfee_sumamt=" + "1068448.89" +
  9319. "&fund_pay_sumamt=" + "1014677.62" +
  9320. "&acct_pay=" + "0" +
  9321. "&fixmedins_setl_cnt=" + "1950" +
  9322. "&fixmedins_code=" + miConfig.Code +
  9323. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9324. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9325. "&secret_key=" + miConfig.SecretKey +
  9326. "&org_name=" + miConfig.OrgName +
  9327. "&doctor=" + user_name
  9328. fmt.Println(api)
  9329. resp, requestErr := http.Get(api)
  9330. if requestErr != nil {
  9331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9332. return
  9333. }
  9334. body, ioErr := ioutil.ReadAll(resp.Body)
  9335. fmt.Println(body)
  9336. if ioErr != nil {
  9337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9339. return
  9340. }
  9341. var respJSON map[string]interface{}
  9342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9345. return
  9346. }
  9347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9348. userJSONBytes, _ := json.Marshal(respJSON)
  9349. var res ResultEight
  9350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9351. utils.ErrorLog("解析失败:%v", err)
  9352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9353. return
  9354. }
  9355. }
  9356. //对账明细
  9357. func (c *HisApiController) GetCheckDetailAccount() {
  9358. start_time := c.GetString("start_time")
  9359. end_time := c.GetString("end_time")
  9360. admin_user_id, _ := c.GetInt64("admin_user_id")
  9361. adminUser := c.GetAdminUserInfo()
  9362. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9363. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9364. timeLayout := "2006-01-02"
  9365. loc, _ := time.LoadLocation("Local")
  9366. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9367. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9368. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9369. rand.Seed(time.Now().UnixNano())
  9370. num := rand.Intn(30000)
  9371. Mkdir(miConfig.OrgName)
  9372. file := strconv.FormatInt(int64(num), 10)
  9373. file_name := file + ".txt"
  9374. zip_name := file + ".zip"
  9375. zip_path := miConfig.OrgName + "/" + zip_name
  9376. file_path := miConfig.OrgName + "/" + file_name
  9377. decimal.DivisionPrecision = 2
  9378. var medfee_sumamt float64
  9379. var psn_cash_pay float64
  9380. var fund_pay_sumamt float64
  9381. fixmedins_setl_cnt := int64(len(orders))
  9382. for _, item := range orders {
  9383. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9384. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9385. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9386. }
  9387. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9388. defer f.Close()
  9389. if err != nil {
  9390. fmt.Println(err.Error())
  9391. } else {
  9392. for _, item := range orders {
  9393. var refd_setl_flag string
  9394. if item.OrderStatus == 2 {
  9395. refd_setl_flag = "0"
  9396. var str string
  9397. str = item.SetlId + " " +
  9398. item.MdtrtId + " " +
  9399. item.PsnNo + " " +
  9400. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9401. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9402. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9403. _, err = f.Write([]byte(str))
  9404. }
  9405. if item.OrderStatus == 3 {
  9406. var str string
  9407. str = item.SetlId + " " +
  9408. item.MdtrtId + " " +
  9409. item.PsnNo + " " +
  9410. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9411. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9412. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9413. _, err = f.Write([]byte(str))
  9414. var str2 string
  9415. str2 = item.SetlId + " " +
  9416. item.MdtrtId + " " +
  9417. item.PsnNo + " " +
  9418. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9419. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9420. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9421. _, err = f.Write([]byte(str2))
  9422. }
  9423. }
  9424. }
  9425. Zip(file_path, zip_path)
  9426. fmt.Println(ReadFile(zip_path))
  9427. fmt.Println(string(ReadFile(zip_path)))
  9428. if config.IsOpen == 1 {
  9429. var user_name string
  9430. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9431. if role.ID == 0 {
  9432. user_name = "管理员"
  9433. } else {
  9434. user_name = role.UserName
  9435. }
  9436. baseParams := models.BaseParams{
  9437. SecretKey: miConfig.SecretKey,
  9438. FixmedinsCode: miConfig.Code,
  9439. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9440. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9441. OrgName: miConfig.OrgName,
  9442. Doctor: user_name,
  9443. }
  9444. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9445. var dat map[string]interface{}
  9446. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9447. fmt.Println(dat)
  9448. } else {
  9449. fmt.Println(err)
  9450. }
  9451. userJSONBytes, _ := json.Marshal(dat)
  9452. var res ResultNine
  9453. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9454. utils.ErrorLog("解析失败:%v", err)
  9455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9456. return
  9457. }
  9458. if res.Infcode == 0 {
  9459. fileNo := res.Output.FileQuryNo
  9460. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9461. "file_qury_no=" + fileNo +
  9462. "&setl_optins=" + "定点医保中心" +
  9463. "&stmt_begndate=" + start_time +
  9464. "&stm_enddate=" + end_time +
  9465. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9466. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9467. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9468. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9469. "&fixmedins_code=" + miConfig.Code +
  9470. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9471. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9472. "&secret_key=" + miConfig.SecretKey +
  9473. "&org_name=" + miConfig.OrgName +
  9474. "&doctor=" + user_name
  9475. resp, requestErr := http.Get(api)
  9476. if requestErr != nil {
  9477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9478. return
  9479. }
  9480. body, ioErr := ioutil.ReadAll(resp.Body)
  9481. if ioErr != nil {
  9482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9484. return
  9485. }
  9486. var respJSON map[string]interface{}
  9487. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9490. return
  9491. }
  9492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9493. userJSONBytes, _ := json.Marshal(respJSON)
  9494. var res ResultTen
  9495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9496. utils.ErrorLog("解析失败:%v", err)
  9497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9498. return
  9499. }
  9500. if res.Infcode == 0 {
  9501. service.Gdyb9102(baseParams, zip_name, fileNo)
  9502. micc := &models.MedicalInsuranceCostCompare{
  9503. StartTime: startime.Unix(),
  9504. EndTime: endtime.Unix(),
  9505. Insutype: "0",
  9506. CheckType: 2,
  9507. Num: fixmedins_setl_cnt,
  9508. Mtime: time.Now().Unix(),
  9509. Status: 1,
  9510. UserOrgId: adminUser.CurrentOrgId,
  9511. CostTotal: medfee_sumamt,
  9512. FuncTotal: fund_pay_sumamt,
  9513. PsnPay: psn_cash_pay,
  9514. Creator: admin_user_id,
  9515. Ctime: time.Now().Unix(),
  9516. }
  9517. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9518. c.ServeSuccessJSON(map[string]interface{}{
  9519. "msg": "明细对账成功",
  9520. })
  9521. }
  9522. } else {
  9523. }
  9524. }
  9525. }
  9526. type CustomOrderInfo struct {
  9527. Name string
  9528. Spec string
  9529. Unit string
  9530. Count float64
  9531. Price float64
  9532. Total float64
  9533. }
  9534. func (c *HisApiController) GetSettleAccounts() {
  9535. //id, _ := c.GetInt64("id")
  9536. //record_time := c.GetString("record_time")
  9537. order_id, _ := c.GetInt64("order_id")
  9538. admin_user_id, _ := c.GetInt64("admin_user_id")
  9539. //timeLayout := "2006-01-02"
  9540. //loc, _ := time.LoadLocation("Local")
  9541. //
  9542. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9543. //if err != nil {
  9544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9545. // return
  9546. //}
  9547. //recordDateTime := theTime.Unix()
  9548. adminUser := c.GetAdminUserInfo()
  9549. order, _ := service.GetHisOrderByID(order_id)
  9550. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9551. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9552. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9553. orderInfos = append(orderInfos, orderInfos_two...)
  9554. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9555. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9556. var diagnosis_ids []string
  9557. if his.ID > 0 {
  9558. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9559. } else {
  9560. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9561. }
  9562. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9563. var dia_config []*models.HisXtDiagnoseConfig
  9564. var name string
  9565. for _, item := range diagnosis_ids {
  9566. id, _ := strconv.ParseInt(item, 10, 64)
  9567. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9568. dia_config = append(dia_config, &diagnosisConfig)
  9569. if len(name) == 0 {
  9570. name = diagnosisConfig.ClassName
  9571. } else {
  9572. name = name + "," + diagnosisConfig.ClassName
  9573. }
  9574. }
  9575. var bedCostTotal float64 = 0 //床位总费
  9576. var bedCostSelfTotal float64 = 0 //床位自费
  9577. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9578. var operationCostTotal float64 = 0 //手术费
  9579. var operationCostSelfTotal float64 = 0 //手术费
  9580. var operationCostPartSelfTotal float64 = 0 //手术费
  9581. var otherCostTotal float64 = 0 //其他费用
  9582. var otherCostSelfTotal float64 = 0 //其他费用
  9583. var otherCostPartSelfTotal float64 = 0 //其他费用
  9584. var materialCostTotal float64 = 0 //材料费
  9585. var materialCostSelfTotal float64 = 0 //材料费
  9586. var materialCostPartSelfTotal float64 = 0 //材料费
  9587. var westernMedicineCostTotal float64 = 0 //西药费
  9588. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9589. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9590. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9591. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9592. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9593. var checkCostTotal float64 = 0 //检查费
  9594. var checkCostSelfTotal float64 = 0 //检查费
  9595. var checkCostPartSelfTotal float64 = 0 //检查费
  9596. var laboratoryCostTotal float64 = 0 //化验费
  9597. var laboratoryCostSelfTotal float64 = 0 //化验费
  9598. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9599. var treatCostTotal float64 = 0 //治疗费用
  9600. var treatCostSelfTotal float64 = 0 //治疗费用
  9601. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9602. decimal.DivisionPrecision = 2
  9603. for _, item := range orderInfos {
  9604. if item.MedChrgitmType == "01" { //床位费
  9605. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9606. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9607. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9608. }
  9609. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9610. if item.MedChrgitmType == "03" { //检查费
  9611. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9612. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9613. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9614. }
  9615. } else {
  9616. if item.MedChrgitmType == "03" { //检查费
  9617. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9618. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9619. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9620. }
  9621. }
  9622. if item.MedChrgitmType == "04" { //化验费
  9623. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9624. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9625. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9626. }
  9627. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9628. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9629. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9630. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9631. }
  9632. if item.MedChrgitmType == "06" { //手术费
  9633. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9634. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9635. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9636. }
  9637. if item.MedChrgitmType == "08" { //材料费
  9638. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9639. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9640. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9641. }
  9642. if item.MedChrgitmType == "09" { //西药费
  9643. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9644. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9645. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9646. }
  9647. if item.MedChrgitmType == "11" { //中成费
  9648. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9649. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9650. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9651. }
  9652. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9653. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9654. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9655. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9656. }
  9657. }
  9658. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9659. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9660. var user_name string
  9661. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9662. if role.ID == 0 {
  9663. user_name = "管理员"
  9664. } else {
  9665. user_name = role.UserName
  9666. }
  9667. baseParams := models.BaseParams{
  9668. SecretKey: miConfig.SecretKey,
  9669. FixmedinsCode: miConfig.Code,
  9670. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9671. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9672. OrgName: miConfig.OrgName,
  9673. Doctor: user_name,
  9674. }
  9675. businessParams := models.BusinessParams{
  9676. PsnNo: order.PsnNo,
  9677. MdtrtId: order.MdtrtId,
  9678. SetlId: order.SetlId,
  9679. }
  9680. var res ResultEleven
  9681. var resEleven10265 ResultEleven10265
  9682. if config.IsOpen == 1 {
  9683. if miConfig.MdtrtareaAdmvs == "421300" {
  9684. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9685. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9686. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9687. resp, requestErr := http.Get(api)
  9688. if requestErr != nil {
  9689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9690. return
  9691. }
  9692. body, ioErr := ioutil.ReadAll(resp.Body)
  9693. if ioErr != nil {
  9694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9696. return
  9697. }
  9698. var respJSON map[string]interface{}
  9699. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9702. return
  9703. }
  9704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9705. result, _ := json.Marshal(respJSON)
  9706. fmt.Println("log")
  9707. fmt.Println(string(result))
  9708. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9709. utils.ErrorLog("解析失败:%v", err)
  9710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9711. return
  9712. }
  9713. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9714. var api string
  9715. if miConfig.MdtrtareaAdmvs == "320921" {
  9716. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9717. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9719. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9720. } else {
  9721. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9722. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9723. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9724. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9725. }
  9726. resp, requestErr := http.Get(api)
  9727. if requestErr != nil {
  9728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9729. return
  9730. }
  9731. body, ioErr := ioutil.ReadAll(resp.Body)
  9732. if ioErr != nil {
  9733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9735. return
  9736. }
  9737. var respJSON map[string]interface{}
  9738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9741. return
  9742. }
  9743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9744. result, _ := json.Marshal(respJSON)
  9745. fmt.Println("log")
  9746. fmt.Println(string(result))
  9747. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9748. utils.ErrorLog("解析失败:%v", err)
  9749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9750. return
  9751. }
  9752. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9753. res.Output = resEleven10265.Output
  9754. res.ErrMsg = resEleven10265.ErrMsg
  9755. res.Cainfo = resEleven10265.Cainfo
  9756. res.WarnMsg = resEleven10265.WarnMsg
  9757. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9758. res.Infcode = infocode
  9759. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9760. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9761. saveLog(result, requestLog, "5203", "结算单")
  9762. var dat map[string]interface{}
  9763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9764. fmt.Println(dat)
  9765. } else {
  9766. fmt.Println(err)
  9767. }
  9768. userJSONBytes, _ := json.Marshal(dat)
  9769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9770. utils.ErrorLog("解析失败:%v", err)
  9771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9772. return
  9773. }
  9774. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9775. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9776. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9777. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9778. resp, requestErr := http.Get(api)
  9779. if requestErr != nil {
  9780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9781. return
  9782. }
  9783. body, ioErr := ioutil.ReadAll(resp.Body)
  9784. if ioErr != nil {
  9785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9787. return
  9788. }
  9789. var respJSON map[string]interface{}
  9790. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9793. return
  9794. }
  9795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9796. result, _ := json.Marshal(respJSON)
  9797. fmt.Println("log")
  9798. fmt.Println(string(result))
  9799. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9800. utils.ErrorLog("解析失败:%v", err)
  9801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9802. return
  9803. }
  9804. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9805. res.Output = resEleven10265.Output
  9806. res.ErrMsg = resEleven10265.ErrMsg
  9807. res.Cainfo = resEleven10265.Cainfo
  9808. res.WarnMsg = resEleven10265.WarnMsg
  9809. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9810. res.Infcode = infocode
  9811. } else {
  9812. result := service.Gdyb5203(baseParams, businessParams)
  9813. //service.Gdyb5204(baseParams, businessParams)
  9814. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9815. var dat map[string]interface{}
  9816. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9817. fmt.Println(dat)
  9818. } else {
  9819. fmt.Println(err)
  9820. }
  9821. userJSONBytes, _ := json.Marshal(dat)
  9822. if miConfig.Code == "H15049901371" {
  9823. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9824. utils.ErrorLog("解析失败:%v", err)
  9825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9826. return
  9827. }
  9828. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9829. res.Output = resEleven10265.Output
  9830. res.ErrMsg = resEleven10265.ErrMsg
  9831. res.Cainfo = resEleven10265.Cainfo
  9832. res.WarnMsg = resEleven10265.WarnMsg
  9833. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9834. res.Infcode = infocode
  9835. } else {
  9836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9837. utils.ErrorLog("解析失败:%v", err)
  9838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9839. return
  9840. }
  9841. }
  9842. }
  9843. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9844. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9845. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9846. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9847. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9848. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9849. var doctor_name string
  9850. if roles.ID == 0 {
  9851. doctor_name = "管理员"
  9852. } else {
  9853. doctor_name = roles.UserName
  9854. }
  9855. yiliao_leibie := ""
  9856. switch order.MedType {
  9857. case "11":
  9858. yiliao_leibie = "普通门诊"
  9859. break
  9860. case "12":
  9861. yiliao_leibie = "门诊挂号"
  9862. break
  9863. case "13":
  9864. yiliao_leibie = "急诊"
  9865. break
  9866. case "14":
  9867. yiliao_leibie = "门诊特殊病"
  9868. break
  9869. case "15":
  9870. yiliao_leibie = "门诊统筹"
  9871. break
  9872. case "16":
  9873. yiliao_leibie = "门诊慢性病"
  9874. break
  9875. case "21":
  9876. yiliao_leibie = "普通住院"
  9877. break
  9878. }
  9879. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9880. if res.Infcode == 0 {
  9881. c.ServeSuccessJSON(map[string]interface{}{
  9882. "diagnosis": name,
  9883. "order_infos": orderInfos,
  9884. "number": order.MdtrtId,
  9885. "date": order.SettleAccountsDate,
  9886. "charge_admin": charge_admin,
  9887. "printor_admin": printor_admin,
  9888. "info": res.Output.Setlinfo,
  9889. "order": order,
  9890. "bedCostTotal": bedCostTotal,
  9891. "bedCostSelfTotal": bedCostSelfTotal,
  9892. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9893. "operationCostTotal": operationCostTotal,
  9894. "operationCostSelfTotal": operationCostSelfTotal,
  9895. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9896. "otherCostTotal": otherCostTotal,
  9897. "otherCostSelfTotal": otherCostSelfTotal,
  9898. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9899. "materialCostTotal": materialCostTotal,
  9900. "materialCostSelfTotal": materialCostSelfTotal,
  9901. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9902. "westernMedicineCostTotal": westernMedicineCostTotal,
  9903. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9904. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9905. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9906. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9907. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9908. "checkCostTotal": checkCostTotal,
  9909. "checkCostSelfTotal": checkCostSelfTotal,
  9910. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9911. "laboratoryCostTotal": laboratoryCostTotal,
  9912. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9913. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9914. "treatCostTotal": treatCostTotal,
  9915. "treatCostSelfTotal": treatCostSelfTotal,
  9916. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9917. "doctor_info": doctor_info,
  9918. "doctor_code": adminRole_two.DoctorCode,
  9919. "doctor_name": doctor_name,
  9920. "health_card_no": order.PsnNo,
  9921. "department": departments.Name,
  9922. "yiliao_leibie": yiliao_leibie,
  9923. "after_money": order.AccountPrice,
  9924. "patient": patient,
  9925. "org_name": miConfig.OrgName,
  9926. "org_code": miConfig.Code,
  9927. "order_number": order.Number,
  9928. "his_hospital": his_hospital,
  9929. "his": his,
  9930. "dia_config": dia_config,
  9931. //"check_order_info": cus_slice,
  9932. })
  9933. }
  9934. }
  9935. }
  9936. func (c *HisApiController) CheckTreatment() {
  9937. patient_id, _ := c.GetInt64("patient_id")
  9938. id_card_no := c.GetString("id_card_no")
  9939. insutype := c.GetString("insutype")
  9940. med_type := c.GetString("med_type")
  9941. admin_user_id, _ := c.GetInt64("admin_user_id")
  9942. adminUser := c.GetAdminUserInfo()
  9943. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9945. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9946. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9947. if miConfig.MdtrtareaAdmvs == "421300" {
  9948. var res ResultTwo
  9949. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9950. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9951. "&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)
  9952. resp, requestErr := http.Get(api)
  9953. if requestErr != nil {
  9954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9955. return
  9956. }
  9957. body, ioErr := ioutil.ReadAll(resp.Body)
  9958. if ioErr != nil {
  9959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9961. return
  9962. }
  9963. var respJSON map[string]interface{}
  9964. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9967. return
  9968. }
  9969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9970. result, _ := json.Marshal(respJSON)
  9971. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9972. utils.ErrorLog("解析失败:%v", err)
  9973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9974. return
  9975. }
  9976. if res.Infcode == 0 {
  9977. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9978. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9979. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9980. resp, requestErr := http.Get(api)
  9981. if requestErr != nil {
  9982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9983. return
  9984. }
  9985. body, ioErr := ioutil.ReadAll(resp.Body)
  9986. if ioErr != nil {
  9987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9989. return
  9990. }
  9991. var respJSON map[string]interface{}
  9992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9995. return
  9996. }
  9997. var res Result2001
  9998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9999. result2, _ := json.Marshal(respJSON)
  10000. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10001. utils.ErrorLog("解析失败:%v", err)
  10002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10003. return
  10004. }
  10005. if res.Infcode == 0 {
  10006. c.ServeSuccessJSON(map[string]interface{}{
  10007. "msg": res.Output.Trtinfo,
  10008. })
  10009. }
  10010. } else {
  10011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10012. return
  10013. }
  10014. } else {
  10015. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10016. var dat map[string]interface{}
  10017. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10018. fmt.Println(dat)
  10019. } else {
  10020. fmt.Println(err)
  10021. }
  10022. userJSONBytes, _ := json.Marshal(dat)
  10023. var res ResultTwo
  10024. var res10265 ResultTwo10265
  10025. if miConfig.Code == "H15049901371" {
  10026. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10027. utils.ErrorLog("解析失败:%v", err)
  10028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10029. return
  10030. }
  10031. res.ErrMsg = res10265.ErrMsg
  10032. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10033. res.Infcode = infocode
  10034. res.Output = res10265.Output
  10035. res.InfRefmsgid = res10265.InfRefmsgid
  10036. } else {
  10037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10038. utils.ErrorLog("解析失败:%v", err)
  10039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10040. return
  10041. }
  10042. }
  10043. var user_name string
  10044. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  10045. if role.ID == 0 {
  10046. user_name = "xxx"
  10047. } else {
  10048. user_name = role.UserName
  10049. }
  10050. baseParams := models.BaseParams{
  10051. SecretKey: miConfig.SecretKey,
  10052. FixmedinsCode: miConfig.Code,
  10053. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10054. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10055. OrgName: miConfig.OrgName,
  10056. Doctor: user_name,
  10057. }
  10058. if config.IsOpen == 1 {
  10059. if miConfig.Code == "H15049901371" {
  10060. if med_type == "14" {
  10061. if insutype == "390" {
  10062. med_type = "9933"
  10063. } else if insutype == "310" {
  10064. med_type = "990502"
  10065. }
  10066. } else if med_type == "11" {
  10067. med_type = "11"
  10068. }
  10069. }
  10070. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  10071. var dat map[string]interface{}
  10072. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10073. fmt.Println(dat)
  10074. } else {
  10075. fmt.Println(err)
  10076. }
  10077. var res Result2001
  10078. var res10265 Result2001Org10265
  10079. if miConfig.Code == "H15049901371" {
  10080. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10081. utils.ErrorLog("解析失败:%v", err)
  10082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10083. return
  10084. }
  10085. res.ErrMsg = res10265.ErrMsg
  10086. res.Output = res10265.Output
  10087. res.InfRefmsgid = res10265.InfRefmsgid
  10088. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10089. res.Infcode = infocode
  10090. } else {
  10091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10092. utils.ErrorLog("解析失败:%v", err)
  10093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10094. return
  10095. }
  10096. }
  10097. if res.Infcode == 0 {
  10098. c.ServeSuccessJSON(map[string]interface{}{
  10099. "msg": res.Output.Trtinfo,
  10100. })
  10101. }
  10102. }
  10103. }
  10104. }
  10105. //func (c *HisApiController) PutRecord() {
  10106. // id, _ := c.GetInt64("id")
  10107. // record_time := c.GetString("record_time")
  10108. // timeLayout := "2006-01-02"
  10109. // loc, _ := time.LoadLocation("Local")
  10110. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10111. // if err != nil {
  10112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10113. // return
  10114. // }
  10115. // recordDateTime := theTime.Unix()
  10116. //
  10117. // adminInfo := c.GetAdminUserInfo()
  10118. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  10119. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10120. //
  10121. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10122. //
  10123. // fmt.Println(miConfig.SecretKey)
  10124. //
  10125. // if patient == nil {
  10126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10127. // return
  10128. // }
  10129. // if len(patient.IdCardNo) == 0 {
  10130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10131. // return
  10132. // }
  10133. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10134. // if config.IsOpen == 1 {
  10135. // 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
  10136. // resp, requestErr := http.Get(api)
  10137. // if requestErr != nil {
  10138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10139. // return
  10140. // }
  10141. // defer resp.Body.Close()
  10142. // body, ioErr := ioutil.ReadAll(resp.Body)
  10143. // if ioErr != nil {
  10144. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10146. // return
  10147. // }
  10148. // var respJSON map[string]interface{}
  10149. //
  10150. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10151. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10153. // return
  10154. // }
  10155. //
  10156. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10157. // userJSONBytes, _ := json.Marshal(userJSON)
  10158. // var res ResultTwo
  10159. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10160. // utils.ErrorLog("解析失败:%v", err)
  10161. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. // return
  10163. // }
  10164. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10165. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10166. // infoStr := string(Iinfos)
  10167. // idetinfoStr := string(Idetinfos)
  10168. //
  10169. // if res.Infcode == 0 {
  10170. // his := models.VMHisPatient{
  10171. // Status: 1,
  10172. // Ctime: time.Now().Unix(),
  10173. // Mtime: time.Now().Unix(),
  10174. // PsnNo: res.Output.Baseinfo.PsnNo,
  10175. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10176. // Certno: res.Output.Baseinfo.Certno,
  10177. // PsnName: res.Output.Baseinfo.PsnName,
  10178. // Gend: res.Output.Baseinfo.Gend,
  10179. // Naty: res.Output.Baseinfo.Naty,
  10180. // Brdy: res.Output.Baseinfo.Brdy,
  10181. // Age: res.Output.Baseinfo.Age,
  10182. // Iinfo: infoStr,
  10183. // Idetinfo: idetinfoStr,
  10184. // PatientId: patient.ID,
  10185. // RecordDate: theTime.Unix(),
  10186. // UserOrgId: adminInfo.CurrentOrgId,
  10187. // AdminUserId: adminInfo.AdminUser.Id,
  10188. // IsReturn: 1,
  10189. // }
  10190. //
  10191. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  10192. // //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")
  10193. // //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")
  10194. //
  10195. // //var dat map[string]interface{}
  10196. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10197. // // fmt.Println(dat)
  10198. // //} else {
  10199. // // fmt.Println(err)
  10200. // //}
  10201. //
  10202. // var dat2 map[string]interface{}
  10203. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10204. // fmt.Println(dat2)
  10205. // } else {
  10206. // fmt.Println(err)
  10207. // }
  10208. //
  10209. // } else {
  10210. // adminUser := c.GetAdminUserInfo()
  10211. // errlog := &models.HisOrderError{
  10212. // UserOrgId: adminUser.CurrentOrgId,
  10213. // Ctime: time.Now().Unix(),
  10214. // Mtime: time.Now().Unix(),
  10215. // ErrMsg: res.ErrMsg,
  10216. // Status: 1,
  10217. // PatientId: id,
  10218. // RecordTime: recordDateTime,
  10219. // Stage: 1,
  10220. // }
  10221. // service.CreateErrMsgLog(errlog)
  10222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10223. // return
  10224. // }
  10225. // }
  10226. //
  10227. //}
  10228. //func (c *HisApiController) GetUploadDiag() {
  10229. // id, _ := c.GetInt64("id")
  10230. // record_time := c.GetString("record_time")
  10231. //
  10232. // diagnosis_id, _ := c.GetInt64("diagnosis")
  10233. // sick_type, _ := c.GetInt64("sick_type")
  10234. // reg_type, _ := c.GetInt64("reg_type")
  10235. //
  10236. // timeLayout := "2006-01-02"
  10237. // loc, _ := time.LoadLocation("Local")
  10238. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10239. // if err != nil {
  10240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10241. // return
  10242. // }
  10243. //
  10244. // var patientPrescription models.HisPrescriptionInfo
  10245. // recordDateTime := theTime.Unix()
  10246. // adminInfo := c.GetAdminUserInfo()
  10247. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10248. //
  10249. // if patientPrescription.ID == 0 {
  10250. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10251. // }
  10252. //
  10253. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10254. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10255. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10256. // sickConfig, _ := service.FindSickById(sick_type)
  10257. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10258. //
  10259. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  10260. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  10261. // "&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 +
  10262. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  10263. // resp2, requestErr2 := http.Get(api2)
  10264. // if requestErr2 != nil {
  10265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10266. // return
  10267. // }
  10268. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10269. // if ioErr2 != nil {
  10270. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10272. // return
  10273. // }
  10274. // var respJSON2 map[string]interface{}
  10275. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10276. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10278. // return
  10279. // }
  10280. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10281. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10282. //
  10283. // var res2 ResultSix
  10284. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10285. // utils.ErrorLog("解析失败:%v", err)
  10286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10287. // return
  10288. // }
  10289. // if res2.Infcode != 0 {
  10290. // adminUser := c.GetAdminUserInfo()
  10291. // errlog := &models.HisOrderError{
  10292. // UserOrgId: adminUser.CurrentOrgId,
  10293. // Ctime: time.Now().Unix(),
  10294. // Mtime: time.Now().Unix(),
  10295. // ErrMsg: res2.ErrMsg,
  10296. // Status: 1,
  10297. // PatientId: id,
  10298. // RecordTime: recordDateTime,
  10299. // Stage: 3,
  10300. // }
  10301. // service.CreateErrMsgLog(errlog)
  10302. //
  10303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10304. // return
  10305. // }
  10306. //
  10307. // c.ServeSuccessJSON(map[string]interface{}{
  10308. // "msg": "上传成功",
  10309. // })
  10310. //
  10311. //}
  10312. type QueryResult struct {
  10313. ID int64
  10314. Name string
  10315. Code string
  10316. List_type_code string
  10317. }
  10318. func (c *HisApiController) GetCheckCode() {
  10319. ids_str := c.GetString("ids")
  10320. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10321. ids_arr := strings.Split(ids_str, ",")
  10322. var queryResult []QueryResult
  10323. ids := make([]int64, 0)
  10324. for _, item := range ids_arr {
  10325. id, _ := strconv.ParseInt(item, 10, 64)
  10326. ids = append(ids, id)
  10327. }
  10328. if record_type == 1 {
  10329. drugs, _ := service.GetBatchDrugList(ids)
  10330. for _, item := range drugs {
  10331. result := QueryResult{
  10332. ID: item.ID,
  10333. Name: item.DrugName,
  10334. Code: item.MedicalInsuranceNumber,
  10335. List_type_code: "101",
  10336. }
  10337. queryResult = append(queryResult, result)
  10338. }
  10339. } else if record_type == 2 {
  10340. goods, _ := service.GetBatchGoodInformationList(ids)
  10341. for _, item := range goods {
  10342. result := QueryResult{
  10343. ID: item.ID,
  10344. Name: item.GoodName,
  10345. Code: item.MedicalInsuranceNumber,
  10346. List_type_code: "301",
  10347. }
  10348. queryResult = append(queryResult, result)
  10349. }
  10350. } else if record_type == 3 {
  10351. projects, _ := service.GetBathchMyPorjecgList(ids)
  10352. for _, item := range projects {
  10353. result := QueryResult{
  10354. ID: item.ID,
  10355. Name: item.ProjectName,
  10356. Code: item.MedicalCode,
  10357. List_type_code: "201",
  10358. }
  10359. queryResult = append(queryResult, result)
  10360. }
  10361. }
  10362. admin_user_id, _ := c.GetInt64("admin_user_id")
  10363. adminUser := c.GetAdminUserInfo()
  10364. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10365. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10366. var user_name string
  10367. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10368. if role.ID == 0 {
  10369. user_name = "xxx"
  10370. } else {
  10371. user_name = role.UserName
  10372. }
  10373. baseParams := &models.BaseParams{
  10374. SecretKey: miConfig.SecretKey,
  10375. FixmedinsCode: miConfig.Code,
  10376. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10377. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10378. OrgName: miConfig.OrgName,
  10379. Doctor: user_name,
  10380. }
  10381. if config.IsOpen == 1 {
  10382. for _, item := range queryResult {
  10383. var result string
  10384. if record_type == 1 {
  10385. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10386. } else if record_type == 2 {
  10387. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10388. } else if record_type == 3 {
  10389. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10390. }
  10391. var dat map[string]interface{}
  10392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10393. fmt.Println(dat)
  10394. } else {
  10395. fmt.Println(err)
  10396. }
  10397. userJSONBytes, _ := json.Marshal(dat)
  10398. var res ResultSix
  10399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10400. utils.ErrorLog("解析失败:%v", err)
  10401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10402. return
  10403. }
  10404. if res.Infcode == 0 {
  10405. if record_type == 1 {
  10406. service.UpdateBaseDrugById(item.ID)
  10407. } else if record_type == 2 {
  10408. service.UpdateGoodInformaitonByDetail(item.ID)
  10409. } else if record_type == 3 {
  10410. service.UpdateProjectById(item.ID)
  10411. }
  10412. c.ServeSuccessJSON(map[string]interface{}{
  10413. "failed_code": 0,
  10414. "msg": "目录对照成功",
  10415. })
  10416. } else {
  10417. c.ServeSuccessJSON(map[string]interface{}{
  10418. "failed_code": -10,
  10419. "msg": res.ErrMsg,
  10420. })
  10421. }
  10422. }
  10423. }
  10424. }
  10425. func (c *HisApiController) UnCheckCode() {
  10426. ids_str := c.GetString("ids")
  10427. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10428. admin_user_id, _ := c.GetInt64("admin_user_id")
  10429. ids_arr := strings.Split(ids_str, ",")
  10430. var queryResult []QueryResult
  10431. ids := make([]int64, 0)
  10432. for _, item := range ids_arr {
  10433. id, _ := strconv.ParseInt(item, 10, 64)
  10434. ids = append(ids, id)
  10435. }
  10436. if record_type == 1 {
  10437. drugs, _ := service.GetBatchDrugList(ids)
  10438. for _, item := range drugs {
  10439. result := QueryResult{
  10440. ID: item.ID,
  10441. Name: item.DrugName,
  10442. Code: item.MedicalInsuranceNumber,
  10443. List_type_code: "101",
  10444. }
  10445. queryResult = append(queryResult, result)
  10446. }
  10447. } else if record_type == 2 {
  10448. goods, _ := service.GetBatchGoodInformationList(ids)
  10449. for _, item := range goods {
  10450. result := QueryResult{
  10451. ID: item.ID,
  10452. Name: item.GoodName,
  10453. Code: item.MedicalInsuranceNumber,
  10454. List_type_code: "301",
  10455. }
  10456. queryResult = append(queryResult, result)
  10457. }
  10458. } else if record_type == 3 {
  10459. projects, _ := service.GetBathchMyPorjecgList(ids)
  10460. for _, item := range projects {
  10461. result := QueryResult{
  10462. ID: item.ID,
  10463. Name: item.ProjectName,
  10464. Code: item.MedicalCode,
  10465. List_type_code: "201",
  10466. }
  10467. queryResult = append(queryResult, result)
  10468. }
  10469. }
  10470. adminUser := c.GetAdminUserInfo()
  10471. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10472. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10473. var user_name string
  10474. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10475. if role.ID == 0 {
  10476. user_name = "xxx"
  10477. } else {
  10478. user_name = role.UserName
  10479. }
  10480. baseParams := &models.BaseParams{
  10481. SecretKey: miConfig.SecretKey,
  10482. FixmedinsCode: miConfig.Code,
  10483. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10484. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10485. OrgName: miConfig.OrgName,
  10486. Doctor: user_name,
  10487. }
  10488. if config.IsOpen == 1 {
  10489. for _, item := range queryResult {
  10490. var result string
  10491. if record_type == 1 {
  10492. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10493. } else if record_type == 2 {
  10494. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10495. } else if record_type == 3 {
  10496. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10497. }
  10498. var dat2 map[string]interface{}
  10499. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10500. fmt.Println(dat2)
  10501. } else {
  10502. fmt.Println(err)
  10503. }
  10504. userJSONBytes, _ := json.Marshal(dat2)
  10505. var res ResultSix
  10506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10507. utils.ErrorLog("解析失败:%v", err)
  10508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10509. return
  10510. }
  10511. if res.Infcode == 0 {
  10512. if record_type == 1 {
  10513. service.UpdateDrugByIdDetail(item.ID)
  10514. } else if record_type == 2 {
  10515. service.UpdateGoodInfoById(item.ID)
  10516. } else if record_type == 3 {
  10517. service.UpdateMyProjectById(item.ID)
  10518. }
  10519. c.ServeSuccessJSON(map[string]interface{}{
  10520. "failed_code": 0,
  10521. "msg": "撤销目录对照成功",
  10522. })
  10523. } else {
  10524. c.ServeSuccessJSON(map[string]interface{}{
  10525. "failed_code": -10,
  10526. "msg": res.ErrMsg,
  10527. })
  10528. }
  10529. }
  10530. }
  10531. }
  10532. func (c *HisApiController) GetPatientInfo() {
  10533. id_card_no := c.GetString("id_card_no")
  10534. admin_user_id, _ := c.GetInt64("admin_user_id")
  10535. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10536. if patient.ID == 0 {
  10537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10538. return
  10539. }
  10540. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10541. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10542. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10543. if config.IsOpen == 1 {
  10544. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10545. var dat map[string]interface{}
  10546. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10547. fmt.Println(dat)
  10548. } else {
  10549. fmt.Println(err)
  10550. }
  10551. userJSONBytes, _ := json.Marshal(dat)
  10552. var res ResultTwo
  10553. var res10265 ResultTwo10265
  10554. if miConfig.Code == "H15049901371" {
  10555. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10556. utils.ErrorLog("解析失败:%v", err)
  10557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10558. return
  10559. }
  10560. res.ErrMsg = res10265.ErrMsg
  10561. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10562. res.Infcode = infocode
  10563. res.Output = res10265.Output
  10564. res.InfRefmsgid = res10265.InfRefmsgid
  10565. } else {
  10566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10567. utils.ErrorLog("解析失败:%v", err)
  10568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10569. return
  10570. }
  10571. }
  10572. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10573. // utils.ErrorLog("解析失败:%v", err)
  10574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10575. // return
  10576. //}
  10577. if res.Infcode != 0 {
  10578. c.ServeSuccessJSON(map[string]interface{}{
  10579. "failed_code": -10,
  10580. "msg": res.ErrMsg,
  10581. })
  10582. } else {
  10583. c.ServeSuccessJSON(map[string]interface{}{
  10584. "failed_code": 0,
  10585. "info": res,
  10586. })
  10587. }
  10588. }
  10589. }
  10590. func (c *HisApiController) PsnPutOnRecord() {
  10591. record_type, _ := c.GetInt64("type")
  10592. patient_id, _ := c.GetInt64("patient_id")
  10593. admin_user_id, _ := c.GetInt64("admin_user_id")
  10594. start_time := c.GetString("start_time")
  10595. end_time := c.GetString("end_time")
  10596. adminUser := c.GetAdminUserInfo()
  10597. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10598. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10599. var patients []*models.Patients
  10600. if record_type == 1 { //全部备案
  10601. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10602. patients = append(patients, patient...)
  10603. } else { //单个备案
  10604. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10605. patients = append(patients, patient)
  10606. }
  10607. var user_name string
  10608. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10609. if role.ID == 0 {
  10610. user_name = "xxx"
  10611. } else {
  10612. user_name = role.UserName
  10613. }
  10614. if config.IsOpen == 1 {
  10615. for _, item := range patients {
  10616. 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
  10617. resp, requestErr := http.Get(api)
  10618. if requestErr != nil {
  10619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10620. return
  10621. }
  10622. defer resp.Body.Close()
  10623. body, ioErr := ioutil.ReadAll(resp.Body)
  10624. if ioErr != nil {
  10625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10627. return
  10628. }
  10629. var respJSON map[string]interface{}
  10630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10633. return
  10634. }
  10635. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10636. userJSONBytes, _ := json.Marshal(userJSON)
  10637. var res ResultTwo
  10638. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10639. utils.ErrorLog("解析失败:%v", err)
  10640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10641. return
  10642. }
  10643. if res.Infcode == 0 {
  10644. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10645. var dat map[string]interface{}
  10646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10647. fmt.Println(dat)
  10648. } else {
  10649. fmt.Println(err)
  10650. }
  10651. userJSONBytes, _ := json.Marshal(dat)
  10652. var res2 ResultThirteen
  10653. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10654. utils.ErrorLog("解析失败:%v", err)
  10655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10656. return
  10657. }
  10658. if res2.Infcode == 0 {
  10659. psnResult := &models.GdybPsnRecord{
  10660. UserOrgId: adminUser.CurrentOrgId,
  10661. PatientId: item.ID,
  10662. PsnNo: res.Output.Baseinfo.PsnNo,
  10663. Ctime: time.Now().Unix(),
  10664. Mtime: time.Now().Unix(),
  10665. Status: 1,
  10666. IsCancel: 1,
  10667. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10668. }
  10669. service.CreatePsnRecord(psnResult)
  10670. } else {
  10671. c.ServeSuccessJSON(map[string]interface{}{
  10672. "failed_code": -10,
  10673. "msg": res2.ErrMsg,
  10674. })
  10675. return
  10676. }
  10677. }
  10678. }
  10679. }
  10680. }
  10681. func (c *HisApiController) PsnUnPutOnRecord() {
  10682. id, _ := c.GetInt64("id")
  10683. //record_type, _ := c.GetInt64("type")
  10684. admin_user_id, _ := c.GetInt64("admin_user_id")
  10685. adminUser := c.GetAdminUserInfo()
  10686. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10687. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10688. var user_name string
  10689. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10690. if role.ID == 0 {
  10691. user_name = "xxx"
  10692. } else {
  10693. user_name = role.UserName
  10694. }
  10695. psn_record, _ := service.GetPsnRecordById(id)
  10696. if psn_record.ID == 0 {
  10697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10698. return
  10699. }
  10700. if config.IsOpen == 1 {
  10701. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10702. var dat map[string]interface{}
  10703. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10704. fmt.Println(dat)
  10705. } else {
  10706. fmt.Println(err)
  10707. }
  10708. userJSONBytes, _ := json.Marshal(dat)
  10709. var res ResultFourteen
  10710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10711. utils.ErrorLog("解析失败:%v", err)
  10712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10713. return
  10714. }
  10715. if res.Infcode == 0 {
  10716. psn_record.IsCancel = 2
  10717. service.CreatePsnRecord(&psn_record)
  10718. } else {
  10719. c.ServeSuccessJSON(map[string]interface{}{
  10720. "failed_code": -10,
  10721. "msg": res.ErrMsg,
  10722. })
  10723. return
  10724. }
  10725. }
  10726. }
  10727. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10728. patient_id, _ := c.GetInt64("patient_id")
  10729. insutype_two := c.GetString("insutype")
  10730. psn_no := c.GetString("psn_no")
  10731. doctor_id, _ := c.GetInt64("doctor_id")
  10732. sick_id, _ := c.GetInt64("sick_id")
  10733. department_id, _ := c.GetInt64("department_id")
  10734. start_time := c.GetString("start_time")
  10735. end_time := c.GetString("end_time")
  10736. check_time := c.GetString("check_time")
  10737. adminUser := c.GetAdminUserInfo()
  10738. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10739. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10740. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10741. sick, _ := service.FindSickById(sick_id)
  10742. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10743. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10744. var res ResultTwo
  10745. var res10265 ResultTwo10265
  10746. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10747. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10748. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10749. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10750. "&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
  10751. resp, requestErr := http.Get(api)
  10752. if requestErr != nil {
  10753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10754. return
  10755. }
  10756. body, ioErr := ioutil.ReadAll(resp.Body)
  10757. if ioErr != nil {
  10758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10760. return
  10761. }
  10762. var respJSON map[string]interface{}
  10763. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10766. return
  10767. }
  10768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10769. result, _ := json.Marshal(respJSON)
  10770. fmt.Println("log")
  10771. fmt.Println(string(result))
  10772. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10773. utils.ErrorLog("解析失败:%v", err)
  10774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10775. return
  10776. }
  10777. res.ErrMsg = res10265.ErrMsg
  10778. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10779. res.Infcode = infocode
  10780. res.Output = res10265.Output
  10781. res.InfRefmsgid = res10265.InfRefmsgid
  10782. } else {
  10783. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10784. if miConfig.Code == "H15049901371" {
  10785. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10786. utils.ErrorLog("解析失败:%v", err)
  10787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10788. return
  10789. }
  10790. res.ErrMsg = res10265.ErrMsg
  10791. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10792. res.Infcode = infocode
  10793. res.Output = res10265.Output
  10794. res.InfRefmsgid = res10265.InfRefmsgid
  10795. } else {
  10796. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10797. utils.ErrorLog("解析失败:%v", err)
  10798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10799. return
  10800. }
  10801. }
  10802. }
  10803. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10804. infoStr := string(Iinfos)
  10805. var rf []*ResultFive
  10806. json.Unmarshal([]byte(infoStr), &rf)
  10807. var insuplc_admdvs string
  10808. var insutype string
  10809. var is390 int = 0
  10810. var is310 int = 0
  10811. var insutypes []*ResultFive
  10812. for _, item := range rf {
  10813. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10814. insutypes = append(insutypes, item)
  10815. }
  10816. }
  10817. if len(insutypes) == 1 {
  10818. insutype = insutypes[0].Insutype
  10819. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10820. } else {
  10821. for _, i := range insutypes {
  10822. if i.Insutype == "390" {
  10823. is390 = 1
  10824. }
  10825. if i.Insutype == "310" {
  10826. is310 = 1
  10827. }
  10828. }
  10829. }
  10830. if is390 == 1 {
  10831. insutype = "390"
  10832. }
  10833. if is310 == 1 {
  10834. insutype = "310"
  10835. }
  10836. if len(insutypes) == 2 {
  10837. insutype = insutype_two
  10838. }
  10839. if len(insutypes) == 0 {
  10840. insutype = "310"
  10841. }
  10842. insutype = insutype_two
  10843. fmt.Println(insutype)
  10844. for _, item := range rf {
  10845. fmt.Println(item.Insutype)
  10846. fmt.Println(insutype)
  10847. if item.Insutype == insutype {
  10848. fmt.Println(item.Insutype)
  10849. fmt.Println(insutype)
  10850. insuplc_admdvs = item.InsuplcAdmdvs
  10851. }
  10852. }
  10853. fmt.Println(insuplc_admdvs)
  10854. var res2 ResultThirteen
  10855. var res10265_2 ResultThirteen10265
  10856. if config.IsOpen == 1 {
  10857. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10858. } else {
  10859. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  10860. var dat map[string]interface{}
  10861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10862. fmt.Println(dat)
  10863. } else {
  10864. fmt.Println(err)
  10865. }
  10866. userJSONBytes, _ := json.Marshal(dat)
  10867. if miConfig.Code == "H15049901371" {
  10868. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10869. utils.ErrorLog("解析失败:%v", err)
  10870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10871. return
  10872. }
  10873. res2.ErrMsg = res10265_2.ErrMsg
  10874. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10875. res2.Infcode = infocode
  10876. res2.Output = res10265_2.Output
  10877. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10878. } else {
  10879. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10880. utils.ErrorLog("解析失败:%v", err)
  10881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10882. return
  10883. }
  10884. }
  10885. }
  10886. if res2.Infcode == 0 {
  10887. psnResult := &models.GdybPsnNcdsRecord{
  10888. UserOrgId: adminUser.CurrentOrgId,
  10889. PatientId: patient.ID,
  10890. PsnNo: psn_no,
  10891. DoctorId: doctor.AdminUserId,
  10892. DepartmentId: department_id,
  10893. SickType: sick_id,
  10894. Insutype: insutype,
  10895. Ctime: time.Now().Unix(),
  10896. Mtime: time.Now().Unix(),
  10897. Status: 1,
  10898. IsCancel: 1,
  10899. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10900. }
  10901. service.CreatePsnNCDSRecord(psnResult)
  10902. c.ServeSuccessJSON(map[string]interface{}{
  10903. "failed_code": 0,
  10904. "msg": "备案成功",
  10905. "result": psnResult,
  10906. })
  10907. } else {
  10908. c.ServeSuccessJSON(map[string]interface{}{
  10909. "failed_code": -10,
  10910. "msg": res2.ErrMsg,
  10911. })
  10912. return
  10913. }
  10914. }
  10915. }
  10916. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10917. id, _ := c.GetInt64("id")
  10918. admin_user_id, _ := c.GetInt64("admin_user_id")
  10919. adminUser := c.GetAdminUserInfo()
  10920. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10921. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10922. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10923. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10924. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10925. //var user_name string
  10926. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10927. //if role.ID == 0 {
  10928. // user_name = "xxx"
  10929. //} else {
  10930. // user_name = role.UserName
  10931. //}
  10932. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10933. if psn_record.ID == 0 {
  10934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10935. return
  10936. }
  10937. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10938. var res ResultTwo
  10939. var res10265 ResultTwo10265
  10940. if miConfig.Code == "H15049901371" {
  10941. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10942. utils.ErrorLog("解析失败:%v", err)
  10943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10944. return
  10945. }
  10946. res.ErrMsg = res10265.ErrMsg
  10947. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10948. res.Infcode = infocode
  10949. res.Output = res10265.Output
  10950. res.InfRefmsgid = res10265.InfRefmsgid
  10951. } else {
  10952. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10953. utils.ErrorLog("解析失败:%v", err)
  10954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10955. return
  10956. }
  10957. }
  10958. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10959. infoStr := string(Iinfos)
  10960. var rf []*ResultFive
  10961. json.Unmarshal([]byte(infoStr), &rf)
  10962. var insuplc_admdvs string
  10963. var insutype string
  10964. var is390 int = 0
  10965. var is310 int = 0
  10966. var insutypes []*ResultFive
  10967. for _, item := range rf {
  10968. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10969. insutypes = append(insutypes, item)
  10970. }
  10971. }
  10972. if len(insutypes) == 1 {
  10973. insutype = insutypes[0].Insutype
  10974. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10975. } else {
  10976. for _, i := range insutypes {
  10977. if i.Insutype == "390" {
  10978. is390 = 1
  10979. }
  10980. if i.Insutype == "310" {
  10981. is310 = 1
  10982. }
  10983. }
  10984. }
  10985. if is390 == 1 {
  10986. insutype = "390"
  10987. }
  10988. if is310 == 1 {
  10989. insutype = "310"
  10990. }
  10991. if len(insutypes) == 0 {
  10992. insutype = "310"
  10993. }
  10994. insutype = psn_record.Insutype
  10995. for _, item := range rf {
  10996. if item.Insutype == insutype {
  10997. insuplc_admdvs = item.InsuplcAdmdvs
  10998. }
  10999. }
  11000. if config.IsOpen == 1 {
  11001. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  11002. var dat map[string]interface{}
  11003. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11004. fmt.Println(dat)
  11005. } else {
  11006. fmt.Println(err)
  11007. }
  11008. userJSONBytes, _ := json.Marshal(dat)
  11009. var res ResultFourteen
  11010. var res10265 ResultFourteen10265
  11011. if miConfig.Code == "H15049901371" {
  11012. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11013. utils.ErrorLog("解析失败:%v", err)
  11014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11015. return
  11016. }
  11017. res.ErrMsg = res10265.ErrMsg
  11018. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11019. res.Infcode = infocode
  11020. res.Output = res10265.Output
  11021. res.InfRefmsgid = res10265.InfRefmsgid
  11022. } else {
  11023. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11024. utils.ErrorLog("解析失败:%v", err)
  11025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11026. return
  11027. }
  11028. }
  11029. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11030. // utils.ErrorLog("解析失败:%v", err)
  11031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11032. // return
  11033. //}
  11034. if res.Infcode == 0 {
  11035. psn_record.IsCancel = 2
  11036. service.CreatePsnNCDSRecord(&psn_record)
  11037. c.ServeSuccessJSON(map[string]interface{}{
  11038. "failed_code": 0,
  11039. "msg": "撤销备案成功",
  11040. })
  11041. } else {
  11042. c.ServeSuccessJSON(map[string]interface{}{
  11043. "failed_code": -10,
  11044. "msg": res.ErrMsg,
  11045. })
  11046. return
  11047. }
  11048. }
  11049. }
  11050. func (c *HisApiController) TestTest() {
  11051. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  11052. fmt.Println(patient.Iinfo)
  11053. }
  11054. type CustomData struct {
  11055. MsgId string
  11056. PsnNo string
  11057. Info string
  11058. }
  11059. func (c *HisApiController) ReversalData() {
  11060. var customData []*CustomData
  11061. custom := &CustomData{
  11062. MsgId: "H44022900158202103301714472004",
  11063. PsnNo: "44020000001101329945",
  11064. Info: "2207",
  11065. }
  11066. customData = append(customData, custom)
  11067. custom1 := &CustomData{
  11068. MsgId: "H4402290015820210330172057803",
  11069. PsnNo: "44020000001101161813",
  11070. Info: "2207",
  11071. }
  11072. customData = append(customData, custom1)
  11073. custom2 := &CustomData{
  11074. MsgId: "H44022900158202103301705198813",
  11075. PsnNo: "44190000133097375417",
  11076. Info: "2207",
  11077. }
  11078. customData = append(customData, custom2)
  11079. custom3 := &CustomData{
  11080. MsgId: "H44022900158202103301715524756",
  11081. PsnNo: "44020000001100187221",
  11082. Info: "2207",
  11083. }
  11084. customData = append(customData, custom3)
  11085. custom4 := &CustomData{
  11086. MsgId: "H44022900158202103301730376224",
  11087. PsnNo: "44020000001101959155",
  11088. Info: "2207",
  11089. }
  11090. customData = append(customData, custom4)
  11091. custom5 := &CustomData{
  11092. MsgId: "H44022900158202103301748008725",
  11093. PsnNo: "44020000001104246641",
  11094. Info: "2207",
  11095. }
  11096. customData = append(customData, custom5)
  11097. custom6 := &CustomData{
  11098. MsgId: "H44022900158202103301718096755",
  11099. PsnNo: "44020000001102211860",
  11100. Info: "2207",
  11101. }
  11102. customData = append(customData, custom6)
  11103. custom7 := &CustomData{
  11104. MsgId: "H44022900158202103301736551640",
  11105. PsnNo: "44020000001102687718",
  11106. Info: "2207",
  11107. }
  11108. customData = append(customData, custom7)
  11109. custom8 := &CustomData{
  11110. MsgId: "H44022900158202103301743097676",
  11111. PsnNo: "44020000001102127785",
  11112. Info: "2207",
  11113. }
  11114. customData = append(customData, custom8)
  11115. custom9 := &CustomData{
  11116. MsgId: "H44022900158202103301712304203",
  11117. PsnNo: "44020000001101518097",
  11118. Info: "2207",
  11119. }
  11120. customData = append(customData, custom9)
  11121. custom10 := &CustomData{
  11122. MsgId: "H44022900158202103301738448785",
  11123. PsnNo: "44020000001100500813",
  11124. Info: "2207",
  11125. }
  11126. customData = append(customData, custom10)
  11127. custom11 := &CustomData{
  11128. MsgId: "H44022900158202103301732455843",
  11129. PsnNo: "44020000001102690557",
  11130. Info: "2207",
  11131. }
  11132. customData = append(customData, custom11)
  11133. custom12 := &CustomData{
  11134. MsgId: "H44022900158202103301745421708",
  11135. PsnNo: "44020000001102211928",
  11136. Info: "2207",
  11137. }
  11138. customData = append(customData, custom12)
  11139. custom1212 := &CustomData{
  11140. MsgId: "H440229001582021033017351627",
  11141. PsnNo: "44020000001102481733",
  11142. Info: "2207",
  11143. }
  11144. customData = append(customData, custom1212)
  11145. custom13 := &CustomData{
  11146. MsgId: "H44022900158202103301740327951",
  11147. PsnNo: "44020000001103174866",
  11148. Info: "2207",
  11149. }
  11150. customData = append(customData, custom13)
  11151. custom14 := &CustomData{
  11152. MsgId: "H4402290015820210330174922668",
  11153. PsnNo: "44020000001102927272",
  11154. Info: "2207",
  11155. }
  11156. customData = append(customData, custom14)
  11157. custom15 := &CustomData{
  11158. MsgId: "H44022900158202103301752362273",
  11159. PsnNo: "44020000001102942890",
  11160. Info: "2207",
  11161. }
  11162. customData = append(customData, custom15)
  11163. custom16 := &CustomData{
  11164. MsgId: "H44022900158202103301751082917",
  11165. PsnNo: "44020000001101662162",
  11166. Info: "2207",
  11167. }
  11168. customData = append(customData, custom16)
  11169. custom17 := &CustomData{
  11170. MsgId: "H44022900158202103301754147728",
  11171. PsnNo: "44020000000229014511",
  11172. Info: "2207",
  11173. }
  11174. customData = append(customData, custom17)
  11175. adminUser := c.GetAdminUserInfo()
  11176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11177. for _, item := range customData {
  11178. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11179. fmt.Println(result)
  11180. }
  11181. }
  11182. //func (c *HisApiController) GetAllopatry() {
  11183. // year := c.GetString("year")
  11184. // month := c.GetString("month")
  11185. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11186. // adminUser := c.GetAdminUserInfo()
  11187. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11188. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11189. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11190. //
  11191. // var dat map[string]interface{}
  11192. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11193. // fmt.Println(dat)
  11194. // } else {
  11195. // fmt.Println(err)
  11196. // }
  11197. // userJSONBytes, _ := json.Marshal(dat)
  11198. // var res models.Result9001
  11199. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11200. // utils.ErrorLog("解析失败:%v", err)
  11201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11202. // return
  11203. // }
  11204. //
  11205. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11206. // var dat2 map[string]interface{}
  11207. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11208. // fmt.Println(dat)
  11209. // } else {
  11210. // fmt.Println(err)
  11211. // }
  11212. // userJSONBytes2, _ := json.Marshal(dat2)
  11213. // var res2 models.Result3260
  11214. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11215. // utils.ErrorLog("解析失败:%v", err)
  11216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11217. // return
  11218. // }
  11219. // if res2.Infcode == 0 {
  11220. // c.ServeSuccessJSON(map[string]interface{}{
  11221. // "list": res2.Output.Data,
  11222. // })
  11223. // return
  11224. // } else {
  11225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11226. // return
  11227. // }
  11228. //
  11229. //}
  11230. //func (c *HisApiController) ComfirmAllopatry() {
  11231. // year := c.GetString("year")
  11232. // month := c.GetString("month")
  11233. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11234. // adminUser := c.GetAdminUserInfo()
  11235. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11236. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11237. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11238. // var dat map[string]interface{}
  11239. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11240. // fmt.Println(dat)
  11241. // } else {
  11242. // fmt.Println(err)
  11243. // }
  11244. // userJSONBytes, _ := json.Marshal(dat)
  11245. // var res models.Result9001
  11246. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11247. // utils.ErrorLog("解析失败:%v", err)
  11248. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11249. // return
  11250. // }
  11251. //
  11252. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11253. // var dat2 map[string]interface{}
  11254. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11255. // fmt.Println(dat)
  11256. // } else {
  11257. // fmt.Println(err)
  11258. // }
  11259. // userJSONBytes2, _ := json.Marshal(dat2)
  11260. // var res2 models.Result3260
  11261. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11262. // utils.ErrorLog("解析失败:%v", err)
  11263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11264. // return
  11265. // }
  11266. //
  11267. // if res2.Infcode == 0 {
  11268. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  11269. // var dat map[string]interface{}
  11270. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11271. // fmt.Println(dat)
  11272. // } else {
  11273. // fmt.Println(err)
  11274. // }
  11275. // userJSONBytes, _ := json.Marshal(dat)
  11276. // var res3 models.Result3261
  11277. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11278. // utils.ErrorLog("解析失败:%v", err)
  11279. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11280. // return
  11281. // }
  11282. //
  11283. // if res3.Infcode == 0 {
  11284. // record := &models.HisYidiClearRecord{
  11285. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11286. // Ctime: time.Now().Unix(),
  11287. // Mtime: time.Now().Unix(),
  11288. // Status: 1,
  11289. // MsgId: msgId,
  11290. // }
  11291. // service.SaveClearRecord(record)
  11292. // c.ServeSuccessJSON(map[string]interface{}{
  11293. // "msg": "提取成功",
  11294. // })
  11295. // }
  11296. // }
  11297. //}
  11298. func (c *HisApiController) RefundAllopatry() {
  11299. year := c.GetString("year")
  11300. month := c.GetString("month")
  11301. id, _ := c.GetInt64("id")
  11302. admin_user_id, _ := c.GetInt64("admin_user_id")
  11303. adminUser := c.GetAdminUserInfo()
  11304. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11305. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11306. record, _ := service.GetClearRecordById(id)
  11307. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11308. var dat map[string]interface{}
  11309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11310. fmt.Println(dat)
  11311. } else {
  11312. fmt.Println(err)
  11313. }
  11314. userJSONBytes, _ := json.Marshal(dat)
  11315. var empty ResultFourteen
  11316. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11317. utils.ErrorLog("解析失败:%v", err)
  11318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11319. return
  11320. }
  11321. if empty.Infcode == 0 {
  11322. c.ServeSuccessJSON(map[string]interface{}{
  11323. "msg": "撤销成功",
  11324. })
  11325. return
  11326. }
  11327. }
  11328. func (c *HisApiController) ReversalOtherData() {
  11329. var customData []*CustomData
  11330. custom := &CustomData{
  11331. MsgId: "H44022900158202103301714472004",
  11332. PsnNo: "44020000001101329945",
  11333. Info: "2208",
  11334. }
  11335. customData = append(customData, custom)
  11336. custom1 := &CustomData{
  11337. MsgId: "H4402290015820210330172057803",
  11338. PsnNo: "44020000001101161813",
  11339. Info: "2208",
  11340. }
  11341. customData = append(customData, custom1)
  11342. custom2 := &CustomData{
  11343. MsgId: "H44022900158202103301705198813",
  11344. PsnNo: "44190000133097375417",
  11345. Info: "2208",
  11346. }
  11347. customData = append(customData, custom2)
  11348. custom3 := &CustomData{
  11349. MsgId: "H44022900158202103301715524756",
  11350. PsnNo: "44020000001100187221",
  11351. Info: "2208",
  11352. }
  11353. customData = append(customData, custom3)
  11354. custom4 := &CustomData{
  11355. MsgId: "H44022900158202103301730376224",
  11356. PsnNo: "44020000001101959155",
  11357. Info: "2208",
  11358. }
  11359. customData = append(customData, custom4)
  11360. custom5 := &CustomData{
  11361. MsgId: "H44022900158202103301748008725",
  11362. PsnNo: "44020000001104246641",
  11363. Info: "2208",
  11364. }
  11365. customData = append(customData, custom5)
  11366. custom6 := &CustomData{
  11367. MsgId: "H44022900158202103301718096755",
  11368. PsnNo: "44020000001102211860",
  11369. Info: "2208",
  11370. }
  11371. customData = append(customData, custom6)
  11372. custom7 := &CustomData{
  11373. MsgId: "H44022900158202103301736551640",
  11374. PsnNo: "44020000001102687718",
  11375. Info: "2208",
  11376. }
  11377. customData = append(customData, custom7)
  11378. custom8 := &CustomData{
  11379. MsgId: "H44022900158202103301743097676",
  11380. PsnNo: "44020000001102127785",
  11381. Info: "2208",
  11382. }
  11383. customData = append(customData, custom8)
  11384. custom9 := &CustomData{
  11385. MsgId: "H44022900158202103301712304203",
  11386. PsnNo: "44020000001101518097",
  11387. Info: "2208",
  11388. }
  11389. customData = append(customData, custom9)
  11390. custom10 := &CustomData{
  11391. MsgId: "H44022900158202103301738448785",
  11392. PsnNo: "44020000001100500813",
  11393. Info: "2208",
  11394. }
  11395. customData = append(customData, custom10)
  11396. custom11 := &CustomData{
  11397. MsgId: "H44022900158202103301732455843",
  11398. PsnNo: "44020000001102690557",
  11399. Info: "2208",
  11400. }
  11401. customData = append(customData, custom11)
  11402. custom12 := &CustomData{
  11403. MsgId: "H44022900158202103301745421708",
  11404. PsnNo: "44020000001102211928",
  11405. Info: "2208",
  11406. }
  11407. customData = append(customData, custom12)
  11408. custom1212 := &CustomData{
  11409. MsgId: "H440229001582021033017351627",
  11410. PsnNo: "44020000001102481733",
  11411. Info: "2208",
  11412. }
  11413. customData = append(customData, custom1212)
  11414. custom13 := &CustomData{
  11415. MsgId: "H44022900158202103301740327951",
  11416. PsnNo: "44020000001103174866",
  11417. Info: "2208",
  11418. }
  11419. customData = append(customData, custom13)
  11420. custom14 := &CustomData{
  11421. MsgId: "H4402290015820210330174922668",
  11422. PsnNo: "44020000001102927272",
  11423. Info: "2208",
  11424. }
  11425. customData = append(customData, custom14)
  11426. custom15 := &CustomData{
  11427. MsgId: "H44022900158202103301752362273",
  11428. PsnNo: "44020000001102942890",
  11429. Info: "2208",
  11430. }
  11431. customData = append(customData, custom15)
  11432. custom16 := &CustomData{
  11433. MsgId: "H44022900158202103301751082917",
  11434. PsnNo: "44020000001101662162",
  11435. Info: "2208",
  11436. }
  11437. customData = append(customData, custom16)
  11438. custom17 := &CustomData{
  11439. MsgId: "H44022900158202103301754147728",
  11440. PsnNo: "44020000000229014511",
  11441. Info: "2208",
  11442. }
  11443. customData = append(customData, custom17)
  11444. adminUser := c.GetAdminUserInfo()
  11445. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11446. for _, item := range customData {
  11447. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11448. fmt.Println(result)
  11449. }
  11450. }
  11451. func PathExists(path string) (bool, error) {
  11452. _, err := os.Stat(path)
  11453. if err == nil {
  11454. return true, nil
  11455. }
  11456. if os.IsNotExist(err) {
  11457. return false, nil
  11458. }
  11459. return false, err
  11460. }
  11461. //创建文件夹
  11462. func Mkdir(dir string) {
  11463. // 创建文件夹
  11464. exist, err := PathExists(dir)
  11465. if err != nil {
  11466. fmt.Println(err.Error())
  11467. } else {
  11468. if exist {
  11469. fmt.Println(dir + "文件夹已存在!")
  11470. } else {
  11471. // 文件夹名称,权限
  11472. err := os.Mkdir(dir, os.ModePerm)
  11473. if err != nil {
  11474. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11475. } else {
  11476. fmt.Println(dir + "文件夹创建成功!")
  11477. }
  11478. }
  11479. }
  11480. }
  11481. //压缩文件
  11482. func Zip(srcFile string, destZip string) error {
  11483. zipfile, err := os.Create(destZip)
  11484. if err != nil {
  11485. return err
  11486. }
  11487. defer zipfile.Close()
  11488. archive := zip.NewWriter(zipfile)
  11489. defer archive.Close()
  11490. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11491. if err != nil {
  11492. return err
  11493. }
  11494. header, err := zip.FileInfoHeader(info)
  11495. if err != nil {
  11496. return err
  11497. }
  11498. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11499. // header.Name = path
  11500. if info.IsDir() {
  11501. header.Name += "/"
  11502. } else {
  11503. header.Method = zip.Deflate
  11504. }
  11505. writer, err := archive.CreateHeader(header)
  11506. if err != nil {
  11507. return err
  11508. }
  11509. if !info.IsDir() {
  11510. file, err := os.Open(path)
  11511. if err != nil {
  11512. return err
  11513. }
  11514. defer file.Close()
  11515. _, err = io.Copy(writer, file)
  11516. }
  11517. return err
  11518. })
  11519. return err
  11520. }
  11521. func ReadFile(filePath string) []byte {
  11522. f, err := os.Open(filePath)
  11523. if err != nil {
  11524. fmt.Println("read file fail", err)
  11525. return nil
  11526. }
  11527. defer f.Close()
  11528. fd, err := ioutil.ReadAll(f)
  11529. if err != nil {
  11530. fmt.Println("read to fd fail", err)
  11531. return nil
  11532. }
  11533. return fd
  11534. }
  11535. func saveLog(result string, request string, infno string, desc string) {
  11536. org_id, _ := beego.AppConfig.Int64("org_id")
  11537. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11538. dir := miConfig.OrgName + "日志"
  11539. utils.Mkdir(dir)
  11540. month := time.Unix(1557042972, 0).Format("1")
  11541. year := time.Now().Format("2006")
  11542. month = time.Now().Format("01")
  11543. day := time.Now().Format("02")
  11544. hour := time.Now().Format("15")
  11545. min := time.Now().Format("04")
  11546. sec := time.Now().Format("05")
  11547. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11548. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11549. file_name := file + ".txt"
  11550. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11551. exist, _ := utils.PathExists(file_path)
  11552. if exist { //存在
  11553. fmt.Println("存在")
  11554. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11555. if err != nil {
  11556. fmt.Println("read fail")
  11557. }
  11558. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11559. n, _ := f.Seek(0, 2)
  11560. _, err = f.WriteAt([]byte(content), n)
  11561. } else { //不存在
  11562. fmt.Println("文件不存在,创建文件")
  11563. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11564. defer f.Close()
  11565. if err != nil {
  11566. } else {
  11567. _, err = f.Write([]byte("记录日志"))
  11568. }
  11569. }
  11570. }
  11571. type Charset string
  11572. const (
  11573. UTF8 = Charset("UTF-8")
  11574. GB18030 = Charset("GB18030")
  11575. )
  11576. func ConvertToString(src string, srcCode string, tagCode string) string {
  11577. srcCoder := mahonia.NewDecoder(srcCode)
  11578. srcResult := srcCoder.ConvertString(src)
  11579. tagCoder := mahonia.NewDecoder(tagCode)
  11580. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11581. result := string(cdata)
  11582. return result
  11583. }
  11584. func (c *HisApiController) ReadEleCard() {
  11585. id_card_type, _ := c.GetInt64("id_card_type")
  11586. admin_user_id, _ := c.GetInt64("admin_user_id")
  11587. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11588. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11589. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11590. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11591. var api string
  11592. if miConfig.MdtrtareaAdmvs == "320921" {
  11593. 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 +
  11594. "&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
  11595. fmt.Println(api)
  11596. } else {
  11597. 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 +
  11598. "&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
  11599. }
  11600. resp, requestErr := http.Get(api)
  11601. if requestErr != nil {
  11602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11603. return
  11604. }
  11605. body, ioErr := ioutil.ReadAll(resp.Body)
  11606. if ioErr != nil {
  11607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11609. return
  11610. }
  11611. var respJSON map[string]interface{}
  11612. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11615. return
  11616. }
  11617. var status string
  11618. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11619. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11620. var token string
  11621. var res ResultTwo //1101结果
  11622. var res10265 ResultTwo10265 //1101结果
  11623. if status == "0" { //读卡成功
  11624. var card_info string //卡信息
  11625. var busi_card_info string
  11626. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11627. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11628. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11629. fmt.Println(card_info)
  11630. fmt.Println(busi_card_info)
  11631. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11632. result, _ := json.Marshal(respJSON)
  11633. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11634. utils.ErrorLog("解析失败:%v", err)
  11635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11636. return
  11637. }
  11638. res.ErrMsg = res10265.ErrMsg
  11639. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11640. res.Infcode = infocode
  11641. res.Output = res10265.Output
  11642. res.InfRefmsgid = res10265.InfRefmsgid
  11643. if res.Infcode == 0 {
  11644. c.ServeSuccessJSON(map[string]interface{}{
  11645. "number": token,
  11646. })
  11647. }
  11648. } else {
  11649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11650. return
  11651. }
  11652. } else { //读卡失败
  11653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11654. return
  11655. }
  11656. }
  11657. func DeleteExtraSpaceTwo(s string) string {
  11658. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11659. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11660. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11661. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11662. s2 := make([]byte, len(s1)) //定义字符数组切片
  11663. copy(s2, s1) //将字符串复制到切片
  11664. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11665. for len(spc_index) > 0 { //找到适配项
  11666. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11667. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11668. }
  11669. return string(s2)
  11670. }
  11671. func Remove0000(s string) string {
  11672. str := make([]rune, 0, len(s))
  11673. for _, v := range []rune(s) {
  11674. if v == 0 {
  11675. continue
  11676. }
  11677. str = append(str, v)
  11678. }
  11679. return string(str)
  11680. }
  11681. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11682. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11683. readCard := DllDef.MustFindProc("EcQuery")
  11684. pCardInfo := make([]byte, 8192)
  11685. pBusiCardInfo := make([]byte, 8192)
  11686. data := make(map[string]interface{})
  11687. //pData := make(map[string]interface{})
  11688. inputData := make(map[string]interface{})
  11689. inputData["orgId"] = code
  11690. inputData["businessType"] = "01101"
  11691. inputData["operatorId"] = operator_id
  11692. inputData["operatorName"] = operator_name
  11693. inputData["officeId"] = "001"
  11694. inputData["officeName"] = "血透室"
  11695. //
  11696. data["data"] = inputData
  11697. data["transType"] = "ec.query"
  11698. data["orgId"] = code
  11699. bytesData, _ := json.Marshal(data)
  11700. pCardInfo = bytesData
  11701. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11702. fmt.Println(ret2)
  11703. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11704. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11705. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11706. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11707. if ret2 != 0 {
  11708. return "", ""
  11709. }
  11710. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11711. }
  11712. func DeleteExtraSpace(s string) string {
  11713. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11714. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11715. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11716. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11717. s2 := make([]byte, len(s1)) //定义字符数组切片
  11718. copy(s2, s1) //将字符串复制到切片
  11719. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11720. for len(spc_index) > 0 { //找到适配项
  11721. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11722. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11723. }
  11724. return string(s2)
  11725. }
  11726. //对账
  11727. func (c *HisApiController) Post3202() {
  11728. start_time := c.GetString("start_time")
  11729. end_time := c.GetString("end_time")
  11730. insutype := c.GetString("insutype")
  11731. clr_type := c.GetString("clr_type")
  11732. clr_org := c.GetString("clr_optins")
  11733. admin_user_id, _ := c.GetInt64("admin_user_id")
  11734. adminUser := c.GetAdminUserInfo()
  11735. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11736. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11737. if len(clr_org) == 0 {
  11738. clr_org = miConfig.MdtrtareaAdmvs
  11739. }
  11740. timeLayout := "2006-01-02"
  11741. loc, _ := time.LoadLocation("Local")
  11742. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11743. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11744. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11745. fixmedins_setl_cnt := int64(len(orders))
  11746. var medfee_sumamt float64
  11747. var acct_pay float64
  11748. var fund_pay_sumamt float64
  11749. for _, item := range orders {
  11750. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11751. acct_pay = acct_pay + item.AcctPay
  11752. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11753. }
  11754. var user_name string
  11755. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11756. if role.ID == 0 {
  11757. user_name = "xxx"
  11758. } else {
  11759. user_name = role.UserName
  11760. }
  11761. var res ResultSix
  11762. if config.IsOpen == 1 {
  11763. if miConfig.MdtrtareaAdmvs == "421300" {
  11764. api := "http://192.168.124.4:9532/" + "hbyb/3202?" +
  11765. "insutype=" + insutype +
  11766. "&clr_type=" + clr_type +
  11767. "&setl_optins=" + clr_org +
  11768. "&stmt_begndate=" + start_time +
  11769. "&stm_enddate=" + end_time +
  11770. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11771. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11772. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11773. "&fixmedins_code=" + miConfig.Code +
  11774. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11775. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11776. "&secret_key=" + miConfig.SecretKey +
  11777. "&org_name=" + miConfig.OrgName +
  11778. "&doctor=" + user_name
  11779. resp, requestErr := http.Get(api)
  11780. if requestErr != nil {
  11781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11782. return
  11783. }
  11784. body, ioErr := ioutil.ReadAll(resp.Body)
  11785. if ioErr != nil {
  11786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11788. return
  11789. }
  11790. var respJSON map[string]interface{}
  11791. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11794. return
  11795. }
  11796. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11797. result, _ := json.Marshal(respJSON)
  11798. fmt.Println("log")
  11799. fmt.Println(string(result))
  11800. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11801. utils.ErrorLog("解析失败:%v", err)
  11802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11803. return
  11804. }
  11805. }
  11806. if res.Infcode == 0 {
  11807. c.ServeSuccessJSON(map[string]interface{}{
  11808. "msg": "发起成功",
  11809. })
  11810. } else {
  11811. c.ServeSuccessJSON(map[string]interface{}{
  11812. "code": -10,
  11813. "msg": res.ErrMsg,
  11814. })
  11815. }
  11816. }
  11817. }