his_api_controller.go 485KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273
  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) (res2 Result3101) {
  136. var res Result3101
  137. adminUser := c.GetAdminUserInfo()
  138. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  139. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  140. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  141. //record_time := c.GetString("record_time")
  142. //trig_scen := c.GetString("trig_scen")
  143. timeLayout := "2006-01-02"
  144. loc, _ := time.LoadLocation("Local")
  145. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  146. if err != nil {
  147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  148. return res
  149. }
  150. recordDateTime := theTime.Unix()
  151. var patientPrescription models.HisPrescriptionInfo
  152. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  153. //if patientPrescription.ID == 0 {
  154. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  155. //}
  156. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  157. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  158. //
  159. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  160. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  161. var pp models.PublicParams
  162. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  163. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  164. pp.FixmedinsName = miConfig.OrgName
  165. pp.FixmedinsCode = miConfig.Code
  166. pp.RequestUrl = miConfig.Url
  167. pp.Cainfo = miConfig.Cainfo
  168. pp.SecretKey = miConfig.SecretKey
  169. pp.AccessKey = miConfig.AccessKey
  170. pp.OpterName = roles.UserName
  171. var config []*models.HisXtDiagnoseConfig
  172. for _, item := range diagnosis_ids {
  173. id, _ := strconv.ParseInt(item, 10, 64)
  174. diagnosisConfig, _ := service.FindDiagnoseById(id)
  175. config = append(config, &diagnosisConfig)
  176. }
  177. var pd models.PatientDtos
  178. pd.PatnID = his.PsnNo
  179. pd.PatnName = his.Name
  180. pd.Gend = his.Gend
  181. pd.Brdy = his.Brdy
  182. pd.Poolarea = miConfig.MdtrtareaAdmvs
  183. pd.CurrMdtrtID = his.Number
  184. var fed models.FsiEncounterDtos
  185. fed.MdtrtID = his.Number
  186. fed.MedinsID = miConfig.Code
  187. fed.MedinsName = miConfig.OrgName
  188. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  189. fed.MedMdtrtType = "1"
  190. fed.MedinsType = "1"
  191. fed.MedinsLv = "11"
  192. tm := time.Unix(his.RecordDate, 0)
  193. s_tm := tm.Format("2006-01-02 15:04:05")
  194. fed.AdmDate = s_tm
  195. fed.DscgDate = s_tm
  196. fed.DscgMainDiseCodg = config[0].CountryCode
  197. fed.DscgMainDiseName = config[0].CountryContentName
  198. //诊断信息
  199. var fdds []*models.FsiDiagnoseDtos
  200. for index, item := range config {
  201. if index == 0 {
  202. var fdd models.FsiDiagnoseDtos
  203. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  204. fdd.InoutDiseType = "1"
  205. fdd.MaindiseFlag = "1"
  206. fdd.DiseDate = s_tm
  207. fdd.DiasSrtNo = "1"
  208. fdd.DiseName = item.CountryContentName
  209. fdd.DiseCodg = item.CountryCode
  210. fdds = append(fdds, &fdd)
  211. } else {
  212. var fdd models.FsiDiagnoseDtos
  213. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  214. fdd.InoutDiseType = "1"
  215. fdd.MaindiseFlag = "1"
  216. fdd.DiseDate = s_tm
  217. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  218. fdd.DiseName = item.CountryContentName
  219. fdd.DiseCodg = item.CountryCode
  220. fdds = append(fdds, &fdd)
  221. }
  222. }
  223. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  224. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  225. fed.AdmDeptName = department.Name
  226. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  227. fed.DscgDeptName = department.Name
  228. fed.MedMdtrtType = "1"
  229. fed.MedType = "11"
  230. //if his.Insutype == "390" {
  231. // fed.MedType = "1402"
  232. //} else {
  233. // fed.MedType = "9933"
  234. //}
  235. var orders []*models.FsiOrderDtos
  236. if trig_scen == "2" {
  237. //处方医嘱信息
  238. for _, item := range prescriptions {
  239. for _, subItem := range item.HisDoctorAdviceInfo {
  240. var order models.FsiOrderDtos
  241. order.RxID = strconv.FormatInt(item.ID, 10)
  242. order.Rxno = strconv.FormatInt(item.ID, 10)
  243. order.LongDrordFlag = "0"
  244. order.HilistType = "1"
  245. order.ChrgType = "1"
  246. order.DrordBhvr = "-"
  247. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  248. order.HosplistName = subItem.BaseDrugLib.DrugName
  249. order.HilistLv = "1"
  250. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  251. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  252. order.HosplistName = subItem.BaseDrugLib.DrugName
  253. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  254. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  255. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  256. order.OwnpayAmt = ""
  257. order.SelfpayAmt = ""
  258. order.Spec = ""
  259. order.SpecUnt = ""
  260. order.DrordBegnDate = s_tm
  261. order.DrordStopDate = ""
  262. order.DrordDrCodg = "1"
  263. order.DrordDeptName = department.Name
  264. order.DrordDrCodg = "1"
  265. order.DrordDrName = doctor_info.UserName
  266. order.DrordDrProfttl = ""
  267. order.CurrDrordFlag = "1"
  268. orders = append(orders, &order)
  269. }
  270. for _, subItem := range item.HisPrescriptionProject {
  271. if subItem.Type == 2 {
  272. var order models.FsiOrderDtos
  273. order.RxID = strconv.FormatInt(item.ID, 10)
  274. order.Rxno = strconv.FormatInt(item.ID, 10)
  275. order.LongDrordFlag = "0"
  276. order.HilistType = "1"
  277. order.ChrgType = "1"
  278. order.DrordBhvr = "-"
  279. order.HilistCode = subItem.HisProject.MedicalCode
  280. order.HosplistName = subItem.HisProject.ProjectName
  281. order.HilistLv = "1"
  282. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  283. order.HosplistCode = subItem.HisProject.MedicalCode
  284. order.HosplistName = subItem.HisProject.ProjectName
  285. order.Cnt = subItem.Count
  286. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  287. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  288. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  289. order.OwnpayAmt = ""
  290. order.SelfpayAmt = ""
  291. order.Spec = ""
  292. order.SpecUnt = ""
  293. order.DrordBegnDate = s_tm
  294. order.DrordStopDate = ""
  295. order.DrordDrCodg = "1"
  296. order.DrordDeptName = department.Name
  297. order.DrordDrCodg = "1"
  298. order.DrordDrName = doctor_info.UserName
  299. order.DrordDrProfttl = ""
  300. order.CurrDrordFlag = "1"
  301. orders = append(orders, &order)
  302. }
  303. if subItem.Type == 3 {
  304. var order models.FsiOrderDtos
  305. order.RxID = strconv.FormatInt(item.ID, 10)
  306. order.Rxno = strconv.FormatInt(item.ID, 10)
  307. order.LongDrordFlag = "0"
  308. order.HilistType = "1"
  309. order.ChrgType = "1"
  310. order.DrordBhvr = "-"
  311. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  312. order.HosplistName = subItem.GoodInfo.GoodName
  313. order.HilistLv = "1"
  314. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  315. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  316. order.HosplistName = subItem.GoodInfo.GoodName
  317. order.Cnt = subItem.Count
  318. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  319. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  320. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  321. order.OwnpayAmt = ""
  322. order.SelfpayAmt = ""
  323. order.Spec = ""
  324. order.SpecUnt = ""
  325. order.DrordBegnDate = s_tm
  326. order.DrordStopDate = ""
  327. order.DrordDrCodg = "1"
  328. order.DrordDeptName = department.Name
  329. order.DrordDrCodg = "1"
  330. order.DrordDrName = doctor_info.UserName
  331. order.DrordDrProfttl = ""
  332. order.CurrDrordFlag = "1"
  333. orders = append(orders, &order)
  334. }
  335. }
  336. }
  337. //处方医嘱信息
  338. }
  339. fed.MatnStas = "0"
  340. fed.MedfeeSumamt = "0"
  341. fed.OwnpayAmt = "0"
  342. fed.SelfpayAmt = "0"
  343. fed.AcctPayamt = "0"
  344. fed.MaAmt = "0"
  345. fed.HifpPayamt = "0"
  346. fed.SetlTotlnum = "1"
  347. fed.Insutype = his.Insutype
  348. fed.ReimFlag = "0"
  349. fed.OutSetlFlag = "0"
  350. var fopd []*models.FsiOperationDtosData
  351. data := make(map[string]interface{})
  352. data["fed"] = fed
  353. data["fdd"] = fdds
  354. data["fod"] = orders
  355. data["pd"] = pd
  356. data["pp"] = pp
  357. data["fopd"] = fopd
  358. data["trig_scen"] = trig_scen
  359. fmt.Println(data)
  360. fmt.Println(fed)
  361. fmt.Println(fdds)
  362. fmt.Println(orders)
  363. fmt.Println(pd)
  364. fmt.Println(pp)
  365. fmt.Println(fopd)
  366. client := &http.Client{}
  367. bytesData, _ := json.Marshal(data)
  368. var req *http.Request
  369. if miConfig.MdtrtareaAdmvs == "320921" {
  370. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  371. } else {
  372. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  373. }
  374. resp, _ := client.Do(req)
  375. defer resp.Body.Close()
  376. body, ioErr := ioutil.ReadAll(resp.Body)
  377. if ioErr != nil {
  378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  380. return res
  381. }
  382. var respJSON map[string]interface{}
  383. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  386. return res
  387. }
  388. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  389. fmt.Println(respJSON)
  390. result, _ := json.Marshal(respJSON)
  391. fmt.Println(result)
  392. if err := json.Unmarshal([]byte(result), &res); err != nil {
  393. utils.ErrorLog("解析失败:%v", err)
  394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  395. return res
  396. }
  397. return res
  398. }
  399. 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) {
  400. adminUser := c.GetAdminUserInfo()
  401. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  402. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  403. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  404. //record_time := c.GetString("record_time")
  405. //trig_scen := c.GetString("trig_scen")
  406. timeLayout := "2006-01-02"
  407. loc, _ := time.LoadLocation("Local")
  408. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  409. if err != nil {
  410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  411. return res
  412. }
  413. recordDateTime := theTime.Unix()
  414. var patientPrescription models.HisPrescriptionInfo
  415. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  416. if patientPrescription.ID == 0 {
  417. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  418. }
  419. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  420. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  421. //
  422. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  423. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  424. var pp models.PublicParams
  425. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  426. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  427. pp.FixmedinsName = miConfig.OrgName
  428. pp.FixmedinsCode = miConfig.Code
  429. pp.RequestUrl = miConfig.Url
  430. pp.Cainfo = miConfig.Cainfo
  431. pp.SecretKey = miConfig.SecretKey
  432. pp.AccessKey = miConfig.AccessKey
  433. pp.OpterName = roles.UserName
  434. var config []*models.HisXtDiagnoseConfig
  435. for _, item := range diagnosis_ids {
  436. id, _ := strconv.ParseInt(item, 10, 64)
  437. diagnosisConfig, _ := service.FindDiagnoseById(id)
  438. config = append(config, &diagnosisConfig)
  439. }
  440. var pd models.PatientDtos
  441. pd.PatnID = his.PsnNo
  442. pd.PatnName = his.Name
  443. pd.Gend = his.Gend
  444. pd.Brdy = his.Brdy
  445. pd.Poolarea = his.InsuplcAdmdvs
  446. pd.CurrMdtrtID = his.Number
  447. var fed models.FsiEncounterDtos
  448. fed.MdtrtID = his.Number
  449. fed.MedinsID = miConfig.Code
  450. fed.MedinsName = miConfig.OrgName
  451. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  452. fed.MedMdtrtType = "1"
  453. fed.MedinsType = "1"
  454. fed.MedinsLv = "11"
  455. tm := time.Unix(his.RecordDate, 0)
  456. s_tm := tm.Format("2006-01-02 15:04:05")
  457. fed.AdmDate = s_tm
  458. fed.DscgDate = s_tm
  459. fed.DscgMainDiseCodg = config[0].CountryCode
  460. fed.DscgMainDiseName = config[0].CountryContentName
  461. //诊断信息
  462. var fdds []*models.FsiDiagnoseDtos
  463. for index, item := range config {
  464. if index == 0 {
  465. var fdd models.FsiDiagnoseDtos
  466. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  467. fdd.InoutDiseType = "1"
  468. fdd.MaindiseFlag = "1"
  469. fdd.DiseDate = s_tm
  470. fdd.DiasSrtNo = "1"
  471. fdd.DiseName = item.CountryContentName
  472. fdd.DiseCodg = item.CountryCode
  473. fdds = append(fdds, &fdd)
  474. } else {
  475. var fdd models.FsiDiagnoseDtos
  476. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  477. fdd.InoutDiseType = "1"
  478. fdd.MaindiseFlag = "1"
  479. fdd.DiseDate = s_tm
  480. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  481. fdd.DiseName = item.CountryContentName
  482. fdd.DiseCodg = item.CountryCode
  483. fdds = append(fdds, &fdd)
  484. }
  485. }
  486. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  487. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  488. fed.AdmDeptName = department.Name
  489. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  490. fed.DscgDeptName = department.Name
  491. fed.MedMdtrtType = "1"
  492. fed.MedType = "11"
  493. //if his.Insutype == "390" {
  494. // fed.MedType = "1402"
  495. //} else {
  496. // fed.MedType = "9933"
  497. //}
  498. var orders []*models.FsiOrderDtos
  499. if trig_scen == "2" {
  500. //处方医嘱信息
  501. for _, item := range prescriptions {
  502. for _, subItem := range item.HisDoctorAdviceInfo {
  503. var order models.FsiOrderDtos
  504. order.RxID = strconv.FormatInt(item.ID, 10)
  505. order.Rxno = strconv.FormatInt(item.ID, 10)
  506. order.LongDrordFlag = "0"
  507. order.HilistType = "1"
  508. order.ChrgType = "1"
  509. order.DrordBhvr = "-"
  510. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  511. order.HosplistName = subItem.BaseDrugLib.DrugName
  512. order.HilistLv = "1"
  513. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  514. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  515. order.HosplistName = subItem.BaseDrugLib.DrugName
  516. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  517. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  518. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  519. order.OwnpayAmt = ""
  520. order.SelfpayAmt = ""
  521. order.Spec = ""
  522. order.SpecUnt = ""
  523. order.DrordBegnDate = s_tm
  524. order.DrordStopDate = ""
  525. order.DrordDrCodg = "1"
  526. order.DrordDeptName = department.Name
  527. order.DrordDrCodg = "1"
  528. order.DrordDrName = doctor_info.UserName
  529. order.DrordDrProfttl = ""
  530. order.CurrDrordFlag = "1"
  531. orders = append(orders, &order)
  532. }
  533. for _, subItem := range item.HisPrescriptionProject {
  534. if subItem.Type == 2 {
  535. var order models.FsiOrderDtos
  536. order.RxID = strconv.FormatInt(item.ID, 10)
  537. order.Rxno = strconv.FormatInt(item.ID, 10)
  538. order.LongDrordFlag = "0"
  539. order.HilistType = "1"
  540. order.ChrgType = "1"
  541. order.DrordBhvr = "-"
  542. order.HilistCode = subItem.HisProject.MedicalCode
  543. order.HosplistName = subItem.HisProject.ProjectName
  544. order.HilistLv = "1"
  545. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  546. order.HosplistCode = subItem.HisProject.MedicalCode
  547. order.HosplistName = subItem.HisProject.ProjectName
  548. order.Cnt = subItem.Count
  549. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  550. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  551. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  552. order.OwnpayAmt = ""
  553. order.SelfpayAmt = ""
  554. order.Spec = ""
  555. order.SpecUnt = ""
  556. order.DrordBegnDate = s_tm
  557. order.DrordStopDate = ""
  558. order.DrordDrCodg = "1"
  559. order.DrordDeptName = department.Name
  560. order.DrordDrCodg = "1"
  561. order.DrordDrName = doctor_info.UserName
  562. order.DrordDrProfttl = ""
  563. order.CurrDrordFlag = "1"
  564. orders = append(orders, &order)
  565. }
  566. if subItem.Type == 3 {
  567. var order models.FsiOrderDtos
  568. order.RxID = strconv.FormatInt(item.ID, 10)
  569. order.Rxno = strconv.FormatInt(item.ID, 10)
  570. order.LongDrordFlag = "0"
  571. order.HilistType = "1"
  572. order.ChrgType = "1"
  573. order.DrordBhvr = "-"
  574. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  575. order.HosplistName = subItem.GoodInfo.GoodName
  576. order.HilistLv = "1"
  577. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  578. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  579. order.HosplistName = subItem.GoodInfo.GoodName
  580. order.Cnt = subItem.Count
  581. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  582. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  583. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  584. order.OwnpayAmt = ""
  585. order.SelfpayAmt = ""
  586. order.Spec = ""
  587. order.SpecUnt = ""
  588. order.DrordBegnDate = s_tm
  589. order.DrordStopDate = ""
  590. order.DrordDrCodg = "1"
  591. order.DrordDeptName = department.Name
  592. order.DrordDrCodg = "1"
  593. order.DrordDrName = doctor_info.UserName
  594. order.DrordDrProfttl = ""
  595. order.CurrDrordFlag = "1"
  596. orders = append(orders, &order)
  597. }
  598. }
  599. }
  600. //处方医嘱信息
  601. }
  602. fed.MatnStas = "0"
  603. fed.MedfeeSumamt = "0"
  604. fed.OwnpayAmt = "0"
  605. fed.SelfpayAmt = "0"
  606. fed.AcctPayamt = "0"
  607. fed.MaAmt = "0"
  608. fed.HifpPayamt = "0"
  609. fed.SetlTotlnum = "1"
  610. fed.Insutype = his.Insutype
  611. fed.ReimFlag = "0"
  612. fed.OutSetlFlag = "0"
  613. var fopd []*models.FsiOperationDtosData
  614. data := make(map[string]interface{})
  615. data["fed"] = fed
  616. data["fdd"] = fdds
  617. data["fod"] = orders
  618. data["pd"] = pd
  619. data["pp"] = pp
  620. data["fopd"] = fopd
  621. data["trig_scen"] = trig_scen
  622. fmt.Println(data)
  623. fmt.Println(fed)
  624. fmt.Println(fdds)
  625. fmt.Println(orders)
  626. fmt.Println(pd)
  627. fmt.Println(pp)
  628. fmt.Println(fopd)
  629. client := &http.Client{}
  630. bytesData, _ := json.Marshal(data)
  631. var req *http.Request
  632. if miConfig.MdtrtareaAdmvs == "320921" {
  633. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  634. } else {
  635. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  636. }
  637. resp, _ := client.Do(req)
  638. defer resp.Body.Close()
  639. body, ioErr := ioutil.ReadAll(resp.Body)
  640. if ioErr != nil {
  641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  643. return res
  644. }
  645. var respJSON map[string]interface{}
  646. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  649. return res
  650. }
  651. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  652. result, _ := json.Marshal(respJSON)
  653. if err := json.Unmarshal([]byte(result), &res); err != nil {
  654. utils.ErrorLog("解析失败:%v", err)
  655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  656. return res
  657. }
  658. return res
  659. }
  660. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  661. ////patient_id, _ := c.GetInt64("patient_id")
  662. //order_id, _ := c.GetInt64("order_id")
  663. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  664. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  665. //trig_scen := c.GetString("trig_scen")
  666. adminUser := c.GetAdminUserInfo()
  667. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  668. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  669. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  670. record_time := c.GetString("record_time")
  671. order, _ := service.GetHisOrderByID(order_id)
  672. timeLayout := "2006-01-02"
  673. loc, _ := time.LoadLocation("Local")
  674. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  675. if err != nil {
  676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  677. return
  678. }
  679. recordDateTime := theTime.Unix()
  680. var patientPrescription models.HisPrescriptionInfo
  681. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  682. if patientPrescription.ID == 0 {
  683. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  684. }
  685. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  686. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  687. //
  688. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  689. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  690. var pp models.PublicParams
  691. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  692. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  693. pp.FixmedinsName = miConfig.OrgName
  694. pp.FixmedinsCode = miConfig.Code
  695. pp.RequestUrl = miConfig.Url
  696. pp.Cainfo = miConfig.Cainfo
  697. pp.SecretKey = miConfig.SecretKey
  698. pp.AccessKey = miConfig.AccessKey
  699. pp.OpterName = roles.UserName
  700. var config []*models.HisXtDiagnoseConfig
  701. for _, item := range diagnosis_ids {
  702. id, _ := strconv.ParseInt(item, 10, 64)
  703. diagnosisConfig, _ := service.FindDiagnoseById(id)
  704. config = append(config, &diagnosisConfig)
  705. }
  706. var pd models.PatientDtos
  707. pd.PatnID = his.PsnNo
  708. pd.PatnName = his.Name
  709. pd.Gend = his.Gend
  710. pd.Brdy = his.Brdy
  711. pd.Poolarea = his.InsuplcAdmdvs
  712. pd.CurrMdtrtID = his.Number
  713. var fed models.FsiEncounterDtos
  714. fed.MdtrtID = his.Number
  715. fed.MedinsID = miConfig.Code
  716. fed.MedinsName = miConfig.OrgName
  717. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  718. fed.MedMdtrtType = "1"
  719. fed.MedinsType = "1"
  720. fed.MedinsLv = "11"
  721. tm := time.Unix(his.RecordDate, 0)
  722. s_tm := tm.Format("2006-01-02 15:04:05")
  723. fed.AdmDate = s_tm
  724. fed.DscgDate = s_tm
  725. fed.DscgMainDiseCodg = config[0].CountryCode
  726. fed.DscgMainDiseName = config[0].CountryContentName
  727. //诊断信息
  728. var fdds []*models.FsiDiagnoseDtos
  729. for index, item := range config {
  730. if index == 0 {
  731. var fdd models.FsiDiagnoseDtos
  732. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  733. fdd.InoutDiseType = "1"
  734. fdd.MaindiseFlag = "1"
  735. fdd.DiseDate = s_tm
  736. fdd.DiasSrtNo = "1"
  737. fdd.DiseName = item.CountryContentName
  738. fdd.DiseCodg = item.CountryCode
  739. fdds = append(fdds, &fdd)
  740. } else {
  741. var fdd models.FsiDiagnoseDtos
  742. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  743. fdd.InoutDiseType = "1"
  744. fdd.MaindiseFlag = "1"
  745. fdd.DiseDate = s_tm
  746. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  747. fdd.DiseName = item.CountryContentName
  748. fdd.DiseCodg = item.CountryCode
  749. fdds = append(fdds, &fdd)
  750. }
  751. }
  752. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  753. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  754. fed.AdmDeptName = department.Name
  755. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  756. fed.DscgDeptName = department.Name
  757. fed.MedType = order.MedType
  758. //处方医嘱信息
  759. var orders []*models.FsiOrderDtos
  760. //for _, item := range prescriptions {
  761. // for _, subItem := range item.HisDoctorAdviceInfo {
  762. // var order models.FsiOrderDtos
  763. // order.RxID = strconv.FormatInt(item.ID, 10)
  764. // order.Rxno = strconv.FormatInt(item.ID, 10)
  765. // order.LongDrordFlag = "0"
  766. // order.HilistType = "1"
  767. // order.ChrgType = "1"
  768. // order.DrordBhvr = "-"
  769. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  770. // order.HosplistName = subItem.BaseDrugLib.DrugName
  771. // order.HilistLv = "1"
  772. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  773. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  774. // order.HosplistName = subItem.BaseDrugLib.DrugName
  775. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  776. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  777. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  778. // order.OwnpayAmt = ""
  779. // order.SelfpayAmt = ""
  780. // order.Spec = ""
  781. // order.SpecUnt = ""
  782. // order.DrordBegnDate = s_tm
  783. // order.DrordStopDate = ""
  784. // order.DrordDrCodg = "1"
  785. // order.DrordDeptName = department.Name
  786. // order.DrordDrCodg = "1"
  787. // order.DrordDrName = doctor_info.UserName
  788. // order.DrordDrProfttl = ""
  789. // order.CurrDrordFlag = "1"
  790. // orders = append(orders, &order)
  791. // }
  792. // for _, subItem := range item.HisPrescriptionProject {
  793. // if subItem.Type == 2 {
  794. // var order models.FsiOrderDtos
  795. // order.RxID = strconv.FormatInt(item.ID, 10)
  796. // order.Rxno = strconv.FormatInt(item.ID, 10)
  797. // order.LongDrordFlag = "0"
  798. // order.HilistType = "1"
  799. // order.ChrgType = "1"
  800. // order.DrordBhvr = "-"
  801. // order.HilistCode = subItem.HisProject.MedicalCode
  802. // order.HosplistName = subItem.HisProject.ProjectName
  803. // order.HilistLv = "1"
  804. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  805. // order.HosplistCode = subItem.HisProject.MedicalCode
  806. // order.HosplistName = subItem.HisProject.ProjectName
  807. // order.Cnt = subItem.Count
  808. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  809. //
  810. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  811. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  812. // order.OwnpayAmt = ""
  813. // order.SelfpayAmt = ""
  814. // order.Spec = ""
  815. // order.SpecUnt = ""
  816. // order.DrordBegnDate = s_tm
  817. // order.DrordStopDate = ""
  818. // order.DrordDrCodg = "1"
  819. // order.DrordDeptName = department.Name
  820. // order.DrordDrCodg = "1"
  821. // order.DrordDrName = doctor_info.UserName
  822. // order.DrordDrProfttl = ""
  823. // order.CurrDrordFlag = "1"
  824. // orders = append(orders, &order)
  825. //
  826. // }
  827. // if subItem.Type == 3 {
  828. //
  829. // var order models.FsiOrderDtos
  830. // order.RxID = strconv.FormatInt(item.ID, 10)
  831. // order.Rxno = strconv.FormatInt(item.ID, 10)
  832. // order.LongDrordFlag = "0"
  833. // order.HilistType = "1"
  834. // order.ChrgType = "1"
  835. // order.DrordBhvr = "-"
  836. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  837. // order.HosplistName = subItem.GoodInfo.GoodName
  838. // order.HilistLv = "1"
  839. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  840. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  841. // order.HosplistName = subItem.GoodInfo.GoodName
  842. // order.Cnt = subItem.Count
  843. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  844. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  845. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  846. // order.OwnpayAmt = ""
  847. // order.SelfpayAmt = ""
  848. // order.Spec = ""
  849. // order.SpecUnt = ""
  850. // order.DrordBegnDate = s_tm
  851. // order.DrordStopDate = ""
  852. // order.DrordDrCodg = "1"
  853. // order.DrordDeptName = department.Name
  854. // order.DrordDrCodg = "1"
  855. // order.DrordDrName = doctor_info.UserName
  856. // order.DrordDrProfttl = ""
  857. // order.CurrDrordFlag = "1"
  858. // orders = append(orders, &order)
  859. //
  860. // }
  861. // }
  862. //}
  863. for _, item := range prescriptions {
  864. for _, subItem := range item.HisDoctorAdviceInfo {
  865. var order models.FsiOrderDtos
  866. order.RxID = strconv.FormatInt(item.ID, 10)
  867. order.Rxno = strconv.FormatInt(item.ID, 10)
  868. order.LongDrordFlag = "0"
  869. order.HilistType = "1"
  870. order.ChrgType = "1"
  871. order.DrordBhvr = "-"
  872. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  873. order.HosplistName = subItem.BaseDrugLib.DrugName
  874. order.HilistLv = "1"
  875. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  876. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  877. order.HosplistName = subItem.BaseDrugLib.DrugName
  878. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  879. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  880. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  881. order.OwnpayAmt = ""
  882. order.SelfpayAmt = ""
  883. order.Spec = ""
  884. order.SpecUnt = ""
  885. order.DrordBegnDate = s_tm
  886. order.DrordStopDate = ""
  887. order.DrordDrCodg = "1"
  888. order.DrordDeptName = department.Name
  889. order.DrordDrCodg = "1"
  890. order.DrordDrName = doctor_info.UserName
  891. order.DrordDrProfttl = ""
  892. order.CurrDrordFlag = "1"
  893. orders = append(orders, &order)
  894. }
  895. for _, subItem := range item.HisPrescriptionProject {
  896. if subItem.Type == 2 {
  897. var order models.FsiOrderDtos
  898. order.RxID = strconv.FormatInt(item.ID, 10)
  899. order.Rxno = strconv.FormatInt(item.ID, 10)
  900. order.LongDrordFlag = "0"
  901. order.HilistType = "1"
  902. order.ChrgType = "1"
  903. order.DrordBhvr = "-"
  904. order.HilistCode = subItem.HisProject.MedicalCode
  905. order.HosplistName = subItem.HisProject.ProjectName
  906. order.HilistLv = "1"
  907. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  908. order.HosplistCode = subItem.HisProject.MedicalCode
  909. order.HosplistName = subItem.HisProject.ProjectName
  910. order.Cnt = subItem.Count
  911. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  912. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  913. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  914. order.OwnpayAmt = ""
  915. order.SelfpayAmt = ""
  916. order.Spec = ""
  917. order.SpecUnt = ""
  918. order.DrordBegnDate = s_tm
  919. order.DrordStopDate = ""
  920. order.DrordDrCodg = "1"
  921. order.DrordDeptName = department.Name
  922. order.DrordDrCodg = "1"
  923. order.DrordDrName = doctor_info.UserName
  924. order.DrordDrProfttl = ""
  925. order.CurrDrordFlag = "1"
  926. orders = append(orders, &order)
  927. }
  928. if subItem.Type == 3 {
  929. var order models.FsiOrderDtos
  930. order.RxID = strconv.FormatInt(item.ID, 10)
  931. order.Rxno = strconv.FormatInt(item.ID, 10)
  932. order.LongDrordFlag = "0"
  933. order.HilistType = "1"
  934. order.ChrgType = "1"
  935. order.DrordBhvr = "-"
  936. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  937. order.HosplistName = subItem.GoodInfo.GoodName
  938. order.HilistLv = "1"
  939. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  940. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  941. order.HosplistName = subItem.GoodInfo.GoodName
  942. order.Cnt = subItem.Count
  943. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  944. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  945. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  946. order.OwnpayAmt = ""
  947. order.SelfpayAmt = ""
  948. order.Spec = ""
  949. order.SpecUnt = ""
  950. order.DrordBegnDate = s_tm
  951. order.DrordStopDate = ""
  952. order.DrordDrCodg = "1"
  953. order.DrordDeptName = department.Name
  954. order.DrordDrCodg = "1"
  955. order.DrordDrName = doctor_info.UserName
  956. order.DrordDrProfttl = ""
  957. order.CurrDrordFlag = "1"
  958. orders = append(orders, &order)
  959. }
  960. }
  961. }
  962. //处方医嘱信息
  963. fed.MatnStas = "0"
  964. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  965. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  966. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  967. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  968. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  969. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  970. fed.SetlTotlnum = "1"
  971. fed.Insutype = his.Insutype
  972. fed.ReimFlag = "0"
  973. fed.OutSetlFlag = "0"
  974. var fopd []*models.FsiOperationDtosData
  975. data := make(map[string]interface{})
  976. data["fed"] = fed
  977. data["fdd"] = fdds
  978. data["fod"] = orders
  979. data["pd"] = pd
  980. data["pp"] = pp
  981. data["fopd"] = fopd
  982. data["trig_scen"] = trig_scen
  983. client := &http.Client{}
  984. bytesData, _ := json.Marshal(data)
  985. var req *http.Request
  986. if miConfig.MdtrtareaAdmvs == "320921" {
  987. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  988. } else {
  989. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  990. }
  991. resp, _ := client.Do(req)
  992. defer resp.Body.Close()
  993. body, ioErr := ioutil.ReadAll(resp.Body)
  994. if ioErr != nil {
  995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  997. return res
  998. }
  999. var respJSON map[string]interface{}
  1000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1003. return res
  1004. }
  1005. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1006. result, _ := json.Marshal(respJSON)
  1007. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1008. utils.ErrorLog("解析失败:%v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return res
  1011. }
  1012. return res
  1013. //手术操作集合
  1014. //手术操作集合
  1015. }
  1016. func (c *HisApiController) Check() {
  1017. psn_no := c.GetString("psn_no")
  1018. in := c.GetString("in")
  1019. mt := c.GetString("mt")
  1020. baseParams := models.BaseParams{
  1021. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1022. FixmedinsCode: "H15049901371",
  1023. InsuplcAdmdvs: "150499",
  1024. MdtrtareaAdmvs: "150499",
  1025. OrgName: "赤峰费森血液透析中心",
  1026. Doctor: "1111",
  1027. }
  1028. service.Gdyb2001(baseParams, psn_no, in, mt)
  1029. }
  1030. func (c *HisApiController) GetPsnNcdsInfo() {
  1031. admin_user_id, _ := c.GetInt64("admin_user_id")
  1032. patient_id, _ := c.GetInt64("patient_id")
  1033. id, _ := c.GetInt64("id")
  1034. adminUser := c.GetAdminUserInfo()
  1035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1036. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1037. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1038. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1039. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1040. //
  1041. //if psn_record.ID == 0 {
  1042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1043. // return
  1044. //}
  1045. var res Result5301
  1046. var res10265 Result5301For10265
  1047. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1048. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1049. var api string
  1050. if miConfig.MdtrtareaAdmvs == "320921" {
  1051. 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 +
  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. } else {
  1054. 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 +
  1055. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1056. }
  1057. resp, requestErr := http.Get(api)
  1058. if requestErr != nil {
  1059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1060. return
  1061. }
  1062. body, ioErr := ioutil.ReadAll(resp.Body)
  1063. if ioErr != nil {
  1064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1066. return
  1067. }
  1068. var respJSON map[string]interface{}
  1069. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1072. return
  1073. }
  1074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1075. result, _ := json.Marshal(respJSON)
  1076. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1077. utils.ErrorLog("解析失败:%v", err)
  1078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1079. return
  1080. }
  1081. res.ErrMsg = res10265.ErrMsg
  1082. res.Output = res10265.Output
  1083. res.InfRefmsgid = res10265.InfRefmsgid
  1084. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1085. res.Infcode = infocode
  1086. } else {
  1087. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1088. var dat map[string]interface{}
  1089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1090. fmt.Println(dat)
  1091. } else {
  1092. fmt.Println(err)
  1093. }
  1094. userJSONBytes, _ := json.Marshal(dat)
  1095. if miConfig.Code == "H15049901371" {
  1096. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1097. utils.ErrorLog("解析失败:%v", err)
  1098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1099. return
  1100. }
  1101. res.InfRefmsgid = res10265.InfRefmsgid
  1102. res.Output = res10265.Output
  1103. res.ErrMsg = res10265.ErrMsg
  1104. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1105. res.Infcode = infocode
  1106. } else {
  1107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1108. utils.ErrorLog("解析失败:%v", err)
  1109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1110. return
  1111. }
  1112. }
  1113. }
  1114. if res.Infcode == 0 {
  1115. c.ServeSuccessJSON(map[string]interface{}{
  1116. "result": res.Output.Result,
  1117. })
  1118. }
  1119. }
  1120. func (c *HisApiController) CheckInsutype() {
  1121. his_patient_id, _ := c.GetInt64("his_patient_id")
  1122. admin_user_id, _ := c.GetInt64("admin_user_id")
  1123. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1124. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1125. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1126. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1127. var dat map[string]interface{}
  1128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1129. fmt.Println(dat)
  1130. } else {
  1131. fmt.Println(err)
  1132. }
  1133. userJSONBytes, _ := json.Marshal(dat)
  1134. var res Result90100
  1135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1136. utils.ErrorLog("解析失败:%v", err)
  1137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1138. return
  1139. }
  1140. if res.Infcode != 0 {
  1141. c.ServeSuccessJSON(map[string]interface{}{
  1142. "failed_code": -10,
  1143. "msg": res.ErrMsg,
  1144. })
  1145. return
  1146. } else {
  1147. fmt.Println(res)
  1148. }
  1149. }
  1150. func (c *HisApiController) CheckCardPWD() {
  1151. card_pwd := c.GetString("card_pwd")
  1152. his_patient_id, _ := c.GetInt64("his_patient_id")
  1153. admin_user_id, _ := c.GetInt64("admin_user_id")
  1154. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1155. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1156. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1157. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1158. bas := strings.Split(psn.CardInfo, "|")
  1159. basNumber := bas[2]
  1160. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1161. var dat map[string]interface{}
  1162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1163. fmt.Println(dat)
  1164. } else {
  1165. fmt.Println(err)
  1166. }
  1167. userJSONBytes, _ := json.Marshal(dat)
  1168. var res Result90991
  1169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1170. utils.ErrorLog("解析失败:%v", err)
  1171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1172. return
  1173. }
  1174. if res.Infcode != 0 {
  1175. c.ServeSuccessJSON(map[string]interface{}{
  1176. "failed_code": -10,
  1177. "msg": res.ErrMsg,
  1178. })
  1179. return
  1180. } else {
  1181. if res.Output.Result.SscnoCheckStat == "0" {
  1182. var msg string
  1183. switch res.Output.Result.CardStat {
  1184. case "00":
  1185. msg = "未激活"
  1186. break
  1187. case "10":
  1188. msg = "激活"
  1189. break
  1190. case "20":
  1191. msg = "窗口挂失"
  1192. break
  1193. case "21":
  1194. msg = "电话挂失"
  1195. break
  1196. case "22":
  1197. msg = "单位网上申报挂失"
  1198. break
  1199. case "23":
  1200. msg = "保健办挂失"
  1201. break
  1202. case "24":
  1203. msg = "个人网上挂失"
  1204. break
  1205. case "25":
  1206. msg = "网上服务大厅挂失"
  1207. break
  1208. case "30":
  1209. msg = "注销"
  1210. break
  1211. case "40":
  1212. msg = "回收"
  1213. break
  1214. case "99":
  1215. msg = "制卡中(无效卡)"
  1216. break
  1217. }
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "failed_code": -10,
  1220. "msg": msg,
  1221. })
  1222. return
  1223. } else {
  1224. c.ServeSuccessJSON(map[string]interface{}{
  1225. "msg": "校验成功",
  1226. })
  1227. return
  1228. }
  1229. }
  1230. }
  1231. func (c *HisApiController) CheckCardPWDTwo() {
  1232. //card_pwd := c.GetString("card_pwd")
  1233. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1234. admin_user_id, _ := c.GetInt64("admin_user_id")
  1235. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1236. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1237. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1238. var dat map[string]interface{}
  1239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1240. fmt.Println(dat)
  1241. } else {
  1242. fmt.Println(err)
  1243. }
  1244. userJSONBytes, _ := json.Marshal(dat)
  1245. var res Result90991
  1246. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1247. utils.ErrorLog("解析失败:%v", err)
  1248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1249. return
  1250. }
  1251. if res.Infcode != 0 {
  1252. c.ServeSuccessJSON(map[string]interface{}{
  1253. "failed_code": -10,
  1254. "msg": res.ErrMsg,
  1255. })
  1256. return
  1257. } else {
  1258. if res.Output.Result.SscnoCheckStat == "0" {
  1259. var msg string
  1260. switch res.Output.Result.CardStat {
  1261. case "00":
  1262. msg = "未激活"
  1263. break
  1264. case "10":
  1265. msg = "激活"
  1266. break
  1267. case "20":
  1268. msg = "窗口挂失"
  1269. break
  1270. case "21":
  1271. msg = "电话挂失"
  1272. break
  1273. case "22":
  1274. msg = "单位网上申报挂失"
  1275. break
  1276. case "23":
  1277. msg = "保健办挂失"
  1278. break
  1279. case "24":
  1280. msg = "个人网上挂失"
  1281. break
  1282. case "25":
  1283. msg = "网上服务大厅挂失"
  1284. break
  1285. case "30":
  1286. msg = "注销"
  1287. break
  1288. case "40":
  1289. msg = "回收"
  1290. break
  1291. case "99":
  1292. msg = "制卡中(无效卡)"
  1293. break
  1294. }
  1295. c.ServeSuccessJSON(map[string]interface{}{
  1296. "failed_code": -10,
  1297. "msg": msg,
  1298. })
  1299. return
  1300. } else {
  1301. c.ServeSuccessJSON(map[string]interface{}{
  1302. "msg": "校验成功",
  1303. })
  1304. return
  1305. }
  1306. }
  1307. }
  1308. type ELeCertData struct {
  1309. Data struct {
  1310. Extra string `json:"extra"`
  1311. IDNo string `json:"idNo"`
  1312. IDType string `json:"idType"`
  1313. EcToken string `json:"ecToken"`
  1314. InsuOrg string `json:"insuOrg"`
  1315. UserName string `json:"userName"`
  1316. EcIndexNo string `json:"ecIndexNo"`
  1317. Gender string `json:"gender"`
  1318. Birthday string `json:"birthday"`
  1319. Nationality string `json:"nationality"`
  1320. Email string `json:"email"`
  1321. } `json:"OutData"`
  1322. }
  1323. func (c *HisApiController) ReadCard() {
  1324. id_card_type, _ := c.GetInt64("id_card_type")
  1325. admin_user_id, _ := c.GetInt64("admin_user_id")
  1326. certificates, _ := c.GetInt64("certificates")
  1327. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1328. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1329. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1330. switch id_card_type {
  1331. case 1:
  1332. if miConfig.MdtrtareaAdmvs == "421300" {
  1333. var res ResultTwo
  1334. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1335. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1336. "&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)
  1337. resp, requestErr := http.Get(api)
  1338. if requestErr != nil {
  1339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1340. return
  1341. }
  1342. body, ioErr := ioutil.ReadAll(resp.Body)
  1343. if ioErr != nil {
  1344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1346. return
  1347. }
  1348. var respJSON map[string]interface{}
  1349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1352. return
  1353. }
  1354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1355. result, _ := json.Marshal(respJSON)
  1356. fmt.Println("log")
  1357. fmt.Println(string(result))
  1358. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1359. utils.ErrorLog("解析失败:%v", err)
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1361. return
  1362. }
  1363. if res.Infcode == 0 {
  1364. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1365. if err == gorm.ErrRecordNotFound {
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1367. return
  1368. } else if err != nil {
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1370. return
  1371. } else {
  1372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1374. infoStr := string(Iinfos)
  1375. idetinfoStr := string(Idetinfos)
  1376. psn := &models.HisPsn{
  1377. PsnNo: res.Output.Baseinfo.PsnNo,
  1378. Age: res.Output.Baseinfo.Age,
  1379. PatientId: patient.ID,
  1380. Certno: res.Output.Baseinfo.Certno,
  1381. Brdy: res.Output.Baseinfo.Brdy,
  1382. Gend: res.Output.Baseinfo.Gend,
  1383. Naty: res.Output.Baseinfo.Naty,
  1384. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1385. PsnName: res.Output.Baseinfo.PsnName,
  1386. Idetinfo: idetinfoStr,
  1387. Insuinfo: infoStr,
  1388. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1389. }
  1390. service.CreateHisPsn(psn)
  1391. c.ServeSuccessJSON(map[string]interface{}{
  1392. "patient": patient,
  1393. "number": res.Output.Baseinfo.Certno,
  1394. })
  1395. }
  1396. } else {
  1397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1398. return
  1399. }
  1400. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1401. var api string
  1402. if miConfig.MdtrtareaAdmvs == "320921" {
  1403. 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 +
  1404. "&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
  1405. fmt.Println(api)
  1406. } else {
  1407. 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 +
  1408. "&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)
  1409. }
  1410. resp, requestErr := http.Get(api)
  1411. if requestErr != nil {
  1412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1413. return
  1414. }
  1415. body, ioErr := ioutil.ReadAll(resp.Body)
  1416. if ioErr != nil {
  1417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1419. return
  1420. }
  1421. var respJSON map[string]interface{}
  1422. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1425. return
  1426. }
  1427. var status string
  1428. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1429. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1430. //console.log()
  1431. fmt.Println("type===")
  1432. fmt.Println(card_type)
  1433. var token string
  1434. var res ResultTwo //1101结果
  1435. var res10265 ResultTwo10265 //1101结果
  1436. var card_info string //卡信息
  1437. var busi_card_info string
  1438. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1439. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1440. if status == "0" { //读卡成功
  1441. if card_type == "1" {
  1442. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1443. result, _ := json.Marshal(respJSON)
  1444. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1445. utils.ErrorLog("解析失败:%v", err)
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return
  1448. }
  1449. res.ErrMsg = res10265.ErrMsg
  1450. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1451. res.Infcode = infocode
  1452. res.Output = res10265.Output
  1453. res.InfRefmsgid = res10265.InfRefmsgid
  1454. } else {
  1455. //var card_info string //卡信息
  1456. //var busi_card_info string
  1457. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1458. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1459. //fmt.Println(card_info)
  1460. //fmt.Println(busi_card_info)
  1461. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1462. result, _ := json.Marshal(respJSON)
  1463. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1464. utils.ErrorLog("解析失败:%v", err)
  1465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1466. return
  1467. }
  1468. res.ErrMsg = res10265.ErrMsg
  1469. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1470. res.Infcode = infocode
  1471. res.Output = res10265.Output
  1472. res.InfRefmsgid = res10265.InfRefmsgid
  1473. }
  1474. if res.Infcode == 0 {
  1475. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1476. if err == gorm.ErrRecordNotFound {
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1478. return
  1479. } else if err != nil {
  1480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1481. return
  1482. } else {
  1483. if card_type == "1" {
  1484. bas := strings.Split(card_info, "|")
  1485. basNumber := bas[2]
  1486. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1487. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1488. infoStr := string(Iinfos)
  1489. idetinfoStr := string(Idetinfos)
  1490. psn := &models.HisPsn{
  1491. PsnNo: res.Output.Baseinfo.PsnNo,
  1492. Age: res.Output.Baseinfo.Age,
  1493. PatientId: patient.ID,
  1494. Certno: res.Output.Baseinfo.Certno,
  1495. Brdy: res.Output.Baseinfo.Brdy,
  1496. Gend: res.Output.Baseinfo.Gend,
  1497. Naty: res.Output.Baseinfo.Naty,
  1498. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1499. PsnName: res.Output.Baseinfo.PsnName,
  1500. Idetinfo: idetinfoStr,
  1501. Insuinfo: infoStr,
  1502. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1503. CardInfo: card_info,
  1504. VerifyNumber: busi_card_info,
  1505. }
  1506. service.CreateHisPsn(psn)
  1507. var rf []*ResultFive
  1508. json.Unmarshal([]byte(infoStr), &rf)
  1509. var insutypes []*ResultFive
  1510. var insutype string
  1511. var is390 int = 0
  1512. var is310 int = 0
  1513. for _, item := range rf {
  1514. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1515. insutypes = append(insutypes, item)
  1516. }
  1517. }
  1518. if len(insutypes) == 1 {
  1519. insutype = insutypes[0].Insutype
  1520. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1521. } else {
  1522. for _, i := range insutypes {
  1523. if i.Insutype == "390" {
  1524. is390 = 1
  1525. }
  1526. if i.Insutype == "310" {
  1527. is310 = 1
  1528. }
  1529. }
  1530. }
  1531. if is390 == 1 {
  1532. insutype = "390"
  1533. }
  1534. if is310 == 1 {
  1535. insutype = "310"
  1536. }
  1537. if len(insutypes) == 0 {
  1538. insutype = "310"
  1539. }
  1540. c.ServeSuccessJSON(map[string]interface{}{
  1541. "patient": patient,
  1542. "number": basNumber,
  1543. "insutype": insutype,
  1544. })
  1545. } else {
  1546. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1547. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1548. infoStr := string(Iinfos)
  1549. idetinfoStr := string(Idetinfos)
  1550. psn := &models.HisPsn{
  1551. PsnNo: res.Output.Baseinfo.PsnNo,
  1552. Age: res.Output.Baseinfo.Age,
  1553. PatientId: patient.ID,
  1554. Certno: res.Output.Baseinfo.Certno,
  1555. Brdy: res.Output.Baseinfo.Brdy,
  1556. Gend: res.Output.Baseinfo.Gend,
  1557. Naty: res.Output.Baseinfo.Naty,
  1558. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1559. PsnName: res.Output.Baseinfo.PsnName,
  1560. Idetinfo: idetinfoStr,
  1561. Insuinfo: infoStr,
  1562. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1563. CardInfo: card_info,
  1564. VerifyNumber: token,
  1565. }
  1566. service.CreateHisPsn(psn)
  1567. c.ServeSuccessJSON(map[string]interface{}{
  1568. "patient": patient,
  1569. "number": token,
  1570. })
  1571. }
  1572. }
  1573. } else {
  1574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1575. return
  1576. }
  1577. } else { //读卡失败
  1578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1579. return
  1580. }
  1581. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1582. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1583. cardnum = DeleteExtraSpaceTwo(cardnum)
  1584. cardCode = DeleteExtraSpaceTwo(cardCode)
  1585. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1586. name = DeleteExtraSpaceTwo(name)
  1587. errmsg = DeleteExtraSpaceTwo(errmsg)
  1588. cardnum = Remove0000(cardnum)
  1589. cardCode = Remove0000(cardCode)
  1590. id_card_no = Remove0000(id_card_no)
  1591. name = Remove0000(name)
  1592. errmsg = Remove0000(errmsg)
  1593. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1594. 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)
  1595. saveLog(result, requestLog, "1101", "获取人员信息")
  1596. fmt.Println(errMsgLog)
  1597. if len(errMsgLog) > 0 {
  1598. } else {
  1599. var dat map[string]interface{}
  1600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1601. fmt.Println(dat)
  1602. } else {
  1603. fmt.Println(err)
  1604. }
  1605. userJSONBytes, _ := json.Marshal(dat)
  1606. var res ResultTwo
  1607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1608. utils.ErrorLog("解析失败:%v", err)
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1610. return
  1611. }
  1612. res.ErrMsg = errMsgLog
  1613. if res.Infcode == 0 {
  1614. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1615. if err == gorm.ErrRecordNotFound {
  1616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1617. return
  1618. } else if err != nil {
  1619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1620. return
  1621. } else {
  1622. fmt.Println(res)
  1623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1625. infoStr := string(Iinfos)
  1626. idetinfoStr := string(Idetinfos)
  1627. psn := &models.HisPsn{
  1628. PsnNo: res.Output.Baseinfo.PsnNo,
  1629. Age: res.Output.Baseinfo.Age,
  1630. PatientId: patient.ID,
  1631. Certno: res.Output.Baseinfo.Certno,
  1632. Brdy: res.Output.Baseinfo.Brdy,
  1633. Gend: res.Output.Baseinfo.Gend,
  1634. Naty: res.Output.Baseinfo.Naty,
  1635. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1636. PsnName: res.Output.Baseinfo.PsnName,
  1637. Idetinfo: idetinfoStr,
  1638. Insuinfo: infoStr,
  1639. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1640. CardInfo: basStr,
  1641. VerifyNumber: "",
  1642. }
  1643. service.CreateHisPsn(psn)
  1644. var rf []*ResultFive
  1645. json.Unmarshal([]byte(infoStr), &rf)
  1646. var insutypes []*ResultFive
  1647. var insutype string
  1648. var is390 int = 0
  1649. var is310 int = 0
  1650. for _, item := range rf {
  1651. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1652. insutypes = append(insutypes, item)
  1653. }
  1654. }
  1655. if len(insutypes) == 1 {
  1656. insutype = insutypes[0].Insutype
  1657. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1658. } else {
  1659. for _, i := range insutypes {
  1660. if i.Insutype == "390" {
  1661. is390 = 1
  1662. }
  1663. if i.Insutype == "310" {
  1664. is310 = 1
  1665. }
  1666. }
  1667. }
  1668. if is390 == 1 {
  1669. insutype = "390"
  1670. }
  1671. if is310 == 1 {
  1672. insutype = "310"
  1673. }
  1674. if len(insutypes) == 0 {
  1675. insutype = "310"
  1676. }
  1677. c.ServeSuccessJSON(map[string]interface{}{
  1678. "patient": patient,
  1679. "number": cardnum,
  1680. "insutype": insutype,
  1681. })
  1682. }
  1683. } else {
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1685. return
  1686. }
  1687. }
  1688. } else {
  1689. if initFlag == 0 {
  1690. c.TestGetBasBaseInit()
  1691. }
  1692. basStr := c.GetBasBaseInfo()
  1693. if len(basStr) == 0 {
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1695. return
  1696. }
  1697. fmt.Println(basStr)
  1698. bas := strings.Split(basStr, "|")
  1699. basNumber := bas[1]
  1700. fmt.Println(basNumber)
  1701. card_sn := bas[3]
  1702. fmt.Println(card_sn)
  1703. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1704. var dat map[string]interface{}
  1705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1706. fmt.Println(dat)
  1707. } else {
  1708. fmt.Println(err)
  1709. }
  1710. userJSONBytes, _ := json.Marshal(dat)
  1711. var res ResultTwo
  1712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1713. utils.ErrorLog("解析失败:%v", err)
  1714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1715. return
  1716. }
  1717. if res.Infcode == 0 {
  1718. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1719. if err == gorm.ErrRecordNotFound {
  1720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1721. return
  1722. } else if err != nil {
  1723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1724. return
  1725. } else {
  1726. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1727. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1728. infoStr := string(Iinfos)
  1729. idetinfoStr := string(Idetinfos)
  1730. psn := &models.HisPsn{
  1731. PsnNo: res.Output.Baseinfo.PsnNo,
  1732. Age: res.Output.Baseinfo.Age,
  1733. PatientId: patient.ID,
  1734. Certno: res.Output.Baseinfo.Certno,
  1735. Brdy: res.Output.Baseinfo.Brdy,
  1736. Gend: res.Output.Baseinfo.Gend,
  1737. Naty: res.Output.Baseinfo.Naty,
  1738. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1739. PsnName: res.Output.Baseinfo.PsnName,
  1740. Idetinfo: idetinfoStr,
  1741. Insuinfo: infoStr,
  1742. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1743. CardInfo: basStr,
  1744. VerifyNumber: "",
  1745. }
  1746. service.CreateHisPsn(psn)
  1747. c.ServeSuccessJSON(map[string]interface{}{
  1748. "patient": patient,
  1749. "number": basNumber,
  1750. })
  1751. }
  1752. } else {
  1753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1754. return
  1755. }
  1756. break
  1757. }
  1758. case 2:
  1759. SFZStr := c.GetSFZBaseInfo()
  1760. id_card_str := strings.Split(SFZStr, "^")
  1761. id_card_number := id_card_str[0]
  1762. card_sn := ""
  1763. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1764. var dat map[string]interface{}
  1765. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1766. fmt.Println(dat)
  1767. } else {
  1768. fmt.Println(err)
  1769. }
  1770. userJSONBytes, _ := json.Marshal(dat)
  1771. var res ResultTwo
  1772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1773. utils.ErrorLog("解析失败:%v", err)
  1774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1775. return
  1776. }
  1777. if res.Infcode == 0 {
  1778. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1779. if err == gorm.ErrRecordNotFound {
  1780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1781. return
  1782. } else if err != nil {
  1783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1784. return
  1785. } else {
  1786. c.ServeSuccessJSON(map[string]interface{}{
  1787. "patient": patient,
  1788. "number": id_card_number,
  1789. })
  1790. }
  1791. } else {
  1792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1793. return
  1794. }
  1795. break
  1796. case 3:
  1797. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1798. var api string
  1799. if miConfig.MdtrtareaAdmvs == "320921" {
  1800. 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 +
  1801. "&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
  1802. fmt.Println(api)
  1803. } else {
  1804. 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 +
  1805. "&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)
  1806. }
  1807. resp, requestErr := http.Get(api)
  1808. if requestErr != nil {
  1809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1810. return
  1811. }
  1812. body, ioErr := ioutil.ReadAll(resp.Body)
  1813. if ioErr != nil {
  1814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1816. return
  1817. }
  1818. var respJSON map[string]interface{}
  1819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. return
  1823. }
  1824. var status string
  1825. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1826. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1827. var token string
  1828. var res ResultTwo //1101结果
  1829. var res10265 ResultTwo10265 //1101结果
  1830. var card_info string //卡信息
  1831. var busi_card_info string
  1832. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1833. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1834. if status == "0" { //读卡成功
  1835. if card_type == "1" {
  1836. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1837. result, _ := json.Marshal(respJSON)
  1838. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1839. utils.ErrorLog("解析失败:%v", err)
  1840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1841. return
  1842. }
  1843. res.ErrMsg = res10265.ErrMsg
  1844. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1845. res.Infcode = infocode
  1846. res.Output = res10265.Output
  1847. res.InfRefmsgid = res10265.InfRefmsgid
  1848. } else {
  1849. //var card_info string //卡信息
  1850. //var busi_card_info string
  1851. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1852. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1853. //fmt.Println(card_info)
  1854. //fmt.Println(busi_card_info)
  1855. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1856. result, _ := json.Marshal(respJSON)
  1857. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1858. utils.ErrorLog("解析失败:%v", err)
  1859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1860. return
  1861. }
  1862. res.ErrMsg = res10265.ErrMsg
  1863. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1864. res.Infcode = infocode
  1865. res.Output = res10265.Output
  1866. res.InfRefmsgid = res10265.InfRefmsgid
  1867. }
  1868. if res.Infcode == 0 {
  1869. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1870. if err == gorm.ErrRecordNotFound {
  1871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1872. return
  1873. } else if err != nil {
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1875. return
  1876. } else {
  1877. if card_type == "1" {
  1878. bas := strings.Split(card_info, "|")
  1879. basNumber := bas[2]
  1880. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1881. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1882. infoStr := string(Iinfos)
  1883. idetinfoStr := string(Idetinfos)
  1884. psn := &models.HisPsn{
  1885. PsnNo: res.Output.Baseinfo.PsnNo,
  1886. Age: res.Output.Baseinfo.Age,
  1887. PatientId: patient.ID,
  1888. Certno: res.Output.Baseinfo.Certno,
  1889. Brdy: res.Output.Baseinfo.Brdy,
  1890. Gend: res.Output.Baseinfo.Gend,
  1891. Naty: res.Output.Baseinfo.Naty,
  1892. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1893. PsnName: res.Output.Baseinfo.PsnName,
  1894. Idetinfo: idetinfoStr,
  1895. Insuinfo: infoStr,
  1896. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1897. CardInfo: card_info,
  1898. VerifyNumber: busi_card_info,
  1899. }
  1900. service.CreateHisPsn(psn)
  1901. c.ServeSuccessJSON(map[string]interface{}{
  1902. "patient": patient,
  1903. "number": basNumber,
  1904. })
  1905. } else {
  1906. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1907. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1908. infoStr := string(Iinfos)
  1909. idetinfoStr := string(Idetinfos)
  1910. psn := &models.HisPsn{
  1911. PsnNo: res.Output.Baseinfo.PsnNo,
  1912. Age: res.Output.Baseinfo.Age,
  1913. PatientId: patient.ID,
  1914. Certno: res.Output.Baseinfo.Certno,
  1915. Brdy: res.Output.Baseinfo.Brdy,
  1916. Gend: res.Output.Baseinfo.Gend,
  1917. Naty: res.Output.Baseinfo.Naty,
  1918. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1919. PsnName: res.Output.Baseinfo.PsnName,
  1920. Idetinfo: idetinfoStr,
  1921. Insuinfo: infoStr,
  1922. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1923. CardInfo: card_info,
  1924. VerifyNumber: token,
  1925. }
  1926. service.CreateHisPsn(psn)
  1927. var rf []*ResultFive
  1928. json.Unmarshal([]byte(infoStr), &rf)
  1929. var insutypes []*ResultFive
  1930. var insutype string
  1931. var is390 int = 0
  1932. var is310 int = 0
  1933. for _, item := range rf {
  1934. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1935. insutypes = append(insutypes, item)
  1936. }
  1937. }
  1938. if len(insutypes) == 1 {
  1939. insutype = insutypes[0].Insutype
  1940. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1941. } else {
  1942. for _, i := range insutypes {
  1943. if i.Insutype == "390" {
  1944. is390 = 1
  1945. }
  1946. if i.Insutype == "310" {
  1947. is310 = 1
  1948. }
  1949. }
  1950. }
  1951. if is390 == 1 {
  1952. insutype = "390"
  1953. }
  1954. if is310 == 1 {
  1955. insutype = "310"
  1956. }
  1957. if len(insutypes) == 0 {
  1958. insutype = "310"
  1959. }
  1960. c.ServeSuccessJSON(map[string]interface{}{
  1961. "patient": patient,
  1962. "number": token,
  1963. "insutype": insutype,
  1964. })
  1965. }
  1966. }
  1967. } else {
  1968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1969. return
  1970. }
  1971. } else { //读卡失败
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1973. return
  1974. }
  1975. }
  1976. break
  1977. case 4:
  1978. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1979. var api string
  1980. if miConfig.MdtrtareaAdmvs == "320921" {
  1981. 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 +
  1982. "&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
  1983. fmt.Println(api)
  1984. } else {
  1985. 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 +
  1986. "&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)
  1987. }
  1988. resp, requestErr := http.Get(api)
  1989. if requestErr != nil {
  1990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1991. return
  1992. }
  1993. body, ioErr := ioutil.ReadAll(resp.Body)
  1994. if ioErr != nil {
  1995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1997. return
  1998. }
  1999. var respJSON map[string]interface{}
  2000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2003. return
  2004. }
  2005. var status string
  2006. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2007. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2008. var token string
  2009. var res ResultTwo //1101结果
  2010. var res10265 ResultTwo10265 //1101结果
  2011. if status == "0" { //读卡成功
  2012. var card_info string //卡信息
  2013. var busi_card_info string
  2014. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2015. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2016. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2017. fmt.Println(card_info)
  2018. fmt.Println(busi_card_info)
  2019. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2020. result, _ := json.Marshal(respJSON)
  2021. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2022. utils.ErrorLog("解析失败:%v", err)
  2023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2024. return
  2025. }
  2026. res.ErrMsg = res10265.ErrMsg
  2027. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2028. res.Infcode = infocode
  2029. res.Output = res10265.Output
  2030. res.InfRefmsgid = res10265.InfRefmsgid
  2031. if res.Infcode == 0 {
  2032. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2033. if err == gorm.ErrRecordNotFound {
  2034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2035. return
  2036. } else if err != nil {
  2037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2038. return
  2039. } else {
  2040. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2041. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2042. infoStr := string(Iinfos)
  2043. idetinfoStr := string(Idetinfos)
  2044. psn := &models.HisPsn{
  2045. PsnNo: res.Output.Baseinfo.PsnNo,
  2046. Age: res.Output.Baseinfo.Age,
  2047. PatientId: patient.ID,
  2048. Certno: res.Output.Baseinfo.Certno,
  2049. Brdy: res.Output.Baseinfo.Brdy,
  2050. Gend: res.Output.Baseinfo.Gend,
  2051. Naty: res.Output.Baseinfo.Naty,
  2052. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2053. PsnName: res.Output.Baseinfo.PsnName,
  2054. Idetinfo: idetinfoStr,
  2055. Insuinfo: infoStr,
  2056. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2057. CardInfo: card_info,
  2058. VerifyNumber: token,
  2059. }
  2060. service.CreateHisPsn(psn)
  2061. c.ServeSuccessJSON(map[string]interface{}{
  2062. "patient": patient,
  2063. "number": token,
  2064. })
  2065. }
  2066. } else {
  2067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2068. return
  2069. }
  2070. } else { //读卡失败
  2071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2072. return
  2073. }
  2074. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2075. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2076. saveLog(result, requestLog, "6101", "电子凭证")
  2077. var ele ELeCertData
  2078. err := json.Unmarshal([]byte(result), &ele)
  2079. if err != nil {
  2080. utils.ErrorLog("解析失败:%v", err)
  2081. }
  2082. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  2083. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2084. var res ResultTwo
  2085. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2086. utils.ErrorLog("解析失败:%v", err)
  2087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2088. return
  2089. }
  2090. if res.Infcode == 0 {
  2091. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2092. if err == gorm.ErrRecordNotFound {
  2093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2094. return
  2095. } else if err != nil {
  2096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2097. return
  2098. } else {
  2099. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2100. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2101. infoStr := string(Iinfos)
  2102. idetinfoStr := string(Idetinfos)
  2103. psn := &models.HisPsn{
  2104. PsnNo: res.Output.Baseinfo.PsnNo,
  2105. Age: res.Output.Baseinfo.Age,
  2106. PatientId: patient.ID,
  2107. Certno: res.Output.Baseinfo.Certno,
  2108. Brdy: res.Output.Baseinfo.Brdy,
  2109. Gend: res.Output.Baseinfo.Gend,
  2110. Naty: res.Output.Baseinfo.Naty,
  2111. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2112. PsnName: res.Output.Baseinfo.PsnName,
  2113. Idetinfo: idetinfoStr,
  2114. Insuinfo: infoStr,
  2115. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2116. CardInfo: "",
  2117. VerifyNumber: ele.Data.EcToken,
  2118. }
  2119. service.CreateHisPsn(psn)
  2120. c.ServeSuccessJSON(map[string]interface{}{
  2121. "patient": patient,
  2122. "number": ele.Data.EcToken,
  2123. })
  2124. }
  2125. } else {
  2126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2127. return
  2128. }
  2129. }
  2130. break
  2131. }
  2132. }
  2133. var initFlag int64 = 0
  2134. func (c *HisApiController) TestGetBasBaseInit() {
  2135. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2136. Iinit := DllDef.MustFindProc("Init")
  2137. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2138. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  2139. if ret != 0 {
  2140. fmt.Println("SSCard的报错原因:", err)
  2141. fmt.Println("SSCard的运算结果为:", ret)
  2142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2143. return
  2144. }
  2145. result := int(ret)
  2146. fmt.Println("SSCard的运算结果为1:", result)
  2147. initFlag = 1
  2148. return
  2149. }
  2150. func (c *HisApiController) GetSFZBaseInfo() string {
  2151. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2152. readCard := DllDef.MustFindProc("ReadSFZ")
  2153. if readCard == nil {
  2154. fmt.Println("readcard is nil")
  2155. readCard = DllDef.MustFindProc("ReadSFZ")
  2156. }
  2157. str := make([]byte, 256)
  2158. str1 := make([]byte, 256)
  2159. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2160. fmt.Println(r)
  2161. return string(str)
  2162. }
  2163. func (c *HisApiController) GetBasBaseInfo() string {
  2164. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2165. readCard := DllDef.MustFindProc("ReadCardBas")
  2166. if readCard == nil {
  2167. fmt.Println("readcard is nil")
  2168. readCard = DllDef.MustFindProc("ReadCardBas")
  2169. }
  2170. str := make([]byte, 1024)
  2171. str1 := make([]byte, 1024)
  2172. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2173. fmt.Println(string(str1))
  2174. fmt.Println(string(str))
  2175. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2176. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2177. if ret2 != 0 {
  2178. return ""
  2179. }
  2180. return string(str)
  2181. }
  2182. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  2183. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2184. readCard := DllDef.MustFindProc("read_cardinfo")
  2185. if readCard == nil {
  2186. fmt.Println("readcard is nil")
  2187. readCard = DllDef.MustFindProc("read_cardinfo")
  2188. }
  2189. str := make([]byte, 1024) //卡号
  2190. str1 := make([]byte, 1024) //卡识别码
  2191. str2 := make([]byte, 1024) //身份证号
  2192. str3 := make([]byte, 1024) //姓名
  2193. str4 := make([]byte, 1024) //错误信息
  2194. 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])))
  2195. fmt.Println(string(str1))
  2196. fmt.Println(string(str))
  2197. fmt.Println(string(str2))
  2198. fmt.Println(string(str3))
  2199. fmt.Println(string(str4))
  2200. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2201. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2202. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  2203. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  2204. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  2205. if ret2 != 0 {
  2206. return "", "", "", "", ""
  2207. }
  2208. return string(str), string(str1), string(str2), string(str3), string(str4)
  2209. }
  2210. type CustomFundPay struct {
  2211. FundPayType string `json:"fund_pay_type"`
  2212. FundPayamt float64 `json:"fund_payamt"`
  2213. }
  2214. func (c *HisApiController) GetSettleList() {
  2215. order_id, _ := c.GetInt64("order_id")
  2216. admin_user_id, _ := c.GetInt64("admin_user_id")
  2217. order, _ := service.GetHisOrderByIDTwo(order_id)
  2218. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2219. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2220. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2221. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2222. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2223. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2224. if order.ID == 0 {
  2225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2226. return
  2227. }
  2228. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2229. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2230. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2231. fmt.Println(count)
  2232. var zero string
  2233. number := count + 1
  2234. if number >= 1000 {
  2235. zero = "0000" + strconv.FormatInt(number, 10)
  2236. } else if number >= 10000 {
  2237. zero = "000" + strconv.FormatInt(number, 10)
  2238. } else if number >= 100000 {
  2239. zero = "00" + strconv.FormatInt(number, 10)
  2240. } else if number >= 1000000 {
  2241. zero = "0" + strconv.FormatInt(number, 10)
  2242. } else {
  2243. zero = strconv.FormatInt(number, 10)
  2244. }
  2245. fmt.Println(zero)
  2246. struct4101 := service.Struct4101{
  2247. PsnNo: order.PsnNo,
  2248. MdtrtId: order.MdtrtId,
  2249. SetlId: order.SetlId,
  2250. PsnName: order.PsnName,
  2251. Gend: order.Gend,
  2252. Brdy: his.Brdy,
  2253. Age: his.Age,
  2254. Naty: order.Naty,
  2255. PatnCertType: "01",
  2256. Certno: order.Certno,
  2257. Prfs: "90",
  2258. ConerName: roles[0].UserName,
  2259. PatnRlts: "99",
  2260. ConerAddr: miConfig.OrgName,
  2261. ConerTel: admin.Mobile,
  2262. HiType: order.Insutype,
  2263. Insuplc: miConfig.InsuplcAdmdvs,
  2264. MaindiagFlag: "1",
  2265. BillCode: last_order.FaPiaoCode,
  2266. BillNo: zero,
  2267. BizSn: order.Number,
  2268. PsnSelfPay: order.PsnPartAmt,
  2269. PsnOwnPay: order.PsnPartAmt,
  2270. AcctPay: order.AcctPay,
  2271. PsnCashpay: order.PsnCashPay,
  2272. HiPaymtd: "1",
  2273. Hsorg: miConfig.InsuplcAdmdvs,
  2274. HsorgOpter: miConfig.InsuplcAdmdvs,
  2275. MedinsFillPsn: curRoles.UserName,
  2276. MedinsFillDept: depart.Name,
  2277. IptMedType: "2",
  2278. }
  2279. struct4101.SetlBegnDate = order.SetlTime
  2280. struct4101.SetlEndDate = order.SetlTime
  2281. time_arr := strings.Split(order.SetlTime, " ")
  2282. struct4101.AdmTime = time_arr[0]
  2283. struct4101.AdmEndTime = time_arr[0]
  2284. var rf []CustomFundPay
  2285. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2286. var tempFunPays []service.CustomStruct
  2287. for _, item := range rf {
  2288. var tempFunPay service.CustomStruct
  2289. tempFunPay.FundPayamt = item.FundPayamt
  2290. tempFunPay.FundPayType = item.FundPayType
  2291. tempFunPays = append(tempFunPays, tempFunPay)
  2292. }
  2293. struct4101.CustomStruct = tempFunPays
  2294. var tempDiaginfos []service.DiaginfoStructTwo
  2295. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2296. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2297. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2298. var config []*models.HisXtDiagnoseConfig
  2299. for _, item := range diagnosis_ids {
  2300. id, _ := strconv.ParseInt(item, 10, 64)
  2301. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2302. config = append(config, &diagnosisConfig)
  2303. }
  2304. for index, item := range config {
  2305. if index == 0 {
  2306. var tempDiaginfo service.DiaginfoStructTwo
  2307. tempDiaginfo.DiagCode = item.CountryCode
  2308. tempDiaginfo.DiagName = item.CountryContentName
  2309. tempDiaginfo.DiagType = "1"
  2310. tempDiaginfo.MaindiagFlag = "1"
  2311. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2312. } else {
  2313. var tempDiaginfo service.DiaginfoStructTwo
  2314. tempDiaginfo.DiagCode = item.CountryCode
  2315. tempDiaginfo.DiagName = item.CountryContentName
  2316. tempDiaginfo.DiagType = "2"
  2317. tempDiaginfo.MaindiagFlag = "0"
  2318. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2319. }
  2320. }
  2321. struct4101.Diseinfo = tempDiaginfos
  2322. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2323. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2324. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2325. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2326. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2327. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2328. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2329. var iteminfo service.IteminfoStruct
  2330. var bedCostTotal float64 = 0 //床位总费
  2331. var bedCostSelfTotal float64 = 0 //床位自费
  2332. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2333. var operationCostTotal float64 = 0 //手术费
  2334. var operationCostSelfTotal float64 = 0 //手术费
  2335. var operationCostPartSelfTotal float64 = 0 //手术费
  2336. var otherCostTotal float64 = 0 //其他费用
  2337. var otherCostSelfTotal float64 = 0 //其他费用
  2338. var otherCostPartSelfTotal float64 = 0 //其他费用
  2339. var materialCostTotal float64 = 0 //材料费
  2340. var materialCostSelfTotal float64 = 0 //材料费
  2341. var materialCostPartSelfTotal float64 = 0 //材料费
  2342. var westernMedicineCostTotal float64 = 0 //西药费
  2343. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2344. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2345. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2346. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2347. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2348. var checkCostTotal float64 = 0 //检查费
  2349. var checkCostSelfTotal float64 = 0 //检查费
  2350. var checkCostPartSelfTotal float64 = 0 //检查费
  2351. var laboratoryCostTotal float64 = 0 //化验费
  2352. var laboratoryCostSelfTotal float64 = 0 //化验费
  2353. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2354. var treatCostTotal float64 = 0 //治疗费用
  2355. var treatCostSelfTotal float64 = 0 //治疗费用
  2356. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2357. decimal.DivisionPrecision = 2
  2358. var bed_fulamt_ownpay_amt float64 = 0
  2359. var operation_fulamt_ownpay_amt float64 = 0
  2360. var other_fulamt_ownpay_amt float64 = 0
  2361. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2362. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2363. var check_fulamt_ownpay_amt float64 = 0
  2364. var material_fulamt_ownpay_amt float64 = 0
  2365. var laboratory_fulamt_ownpay_amt float64 = 0
  2366. var treat_fulamt_ownpay_amt float64 = 0
  2367. var bed_claa_sunmfee float64 = 0
  2368. var bed_clab_amt float64 = 0
  2369. var bed_other_amt float64 = 0
  2370. var operation_claa_sunmfee float64 = 0
  2371. var operation_clab_amt float64 = 0
  2372. var operation_other_amt float64 = 0
  2373. var other_claa_sunmfee float64 = 0
  2374. var other_clab_amt float64 = 0
  2375. var other_other_amt float64 = 0
  2376. var westernMedicine_claa_sunmfee float64 = 0
  2377. var westernMedicine_clab_amt float64 = 0
  2378. var westernMedicine_other_amt float64 = 0
  2379. var chineseTraditional_claa_sunmfee float64 = 0
  2380. var chineseTraditional_clab_amt float64 = 0
  2381. var chineseTraditional_other_amt float64 = 0
  2382. var check_claa_sunmfee float64 = 0
  2383. var check_clab_amt float64 = 0
  2384. var check_other_amt float64 = 0
  2385. var material_claa_sunmfee float64 = 0
  2386. var material_clab_amt float64 = 0
  2387. var material_other_amt float64 = 0
  2388. var laboratory_claa_sunmfee float64 = 0
  2389. var laboratory_clab_amt float64 = 0
  2390. var laboratory_other_amt float64 = 0
  2391. var treat_claa_sunmfee float64 = 0
  2392. var treat_clab_amt float64 = 0
  2393. var treat_other_amt float64 = 0
  2394. for _, item := range order.HisOrderInfo {
  2395. if item.MedChrgitmType == "01" { //床位费
  2396. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2397. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2398. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2399. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2400. if item.ChrgitmLv == "1" {
  2401. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2402. }
  2403. if item.ChrgitmLv == "2" {
  2404. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2405. }
  2406. if item.ChrgitmLv == "3" {
  2407. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2408. }
  2409. }
  2410. if item.MedChrgitmType == "03" { //检查费
  2411. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2412. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2413. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2414. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2415. if item.ChrgitmLv == "1" {
  2416. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2417. }
  2418. if item.ChrgitmLv == "2" {
  2419. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2420. }
  2421. if item.ChrgitmLv == "3" {
  2422. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2423. }
  2424. }
  2425. if item.MedChrgitmType == "04" { //化验费
  2426. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2427. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2428. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2429. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2430. if item.ChrgitmLv == "1" {
  2431. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2432. }
  2433. if item.ChrgitmLv == "2" {
  2434. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2435. }
  2436. if item.ChrgitmLv == "3" {
  2437. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2438. }
  2439. }
  2440. if item.MedChrgitmType == "05" { //治疗费
  2441. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2442. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2443. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2444. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2445. if item.ChrgitmLv == "1" {
  2446. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2447. }
  2448. if item.ChrgitmLv == "2" {
  2449. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2450. }
  2451. if item.ChrgitmLv == "3" {
  2452. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2453. }
  2454. }
  2455. if item.MedChrgitmType == "06" { //手术费
  2456. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2457. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2458. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2459. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2460. if item.ChrgitmLv == "1" {
  2461. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2462. }
  2463. if item.ChrgitmLv == "2" {
  2464. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2465. }
  2466. if item.ChrgitmLv == "3" {
  2467. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2468. }
  2469. }
  2470. if item.MedChrgitmType == "08" { //材料费
  2471. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2472. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2473. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2474. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2475. if item.ChrgitmLv == "1" {
  2476. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2477. }
  2478. if item.ChrgitmLv == "2" {
  2479. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2480. }
  2481. if item.ChrgitmLv == "3" {
  2482. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2483. }
  2484. }
  2485. if item.MedChrgitmType == "09" { //西药费
  2486. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2487. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2488. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2489. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2490. if item.ChrgitmLv == "1" {
  2491. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2492. }
  2493. if item.ChrgitmLv == "2" {
  2494. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2495. }
  2496. if item.ChrgitmLv == "3" {
  2497. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2498. }
  2499. }
  2500. if item.MedChrgitmType == "11" { //中成费
  2501. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2502. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2503. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2504. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2505. if item.ChrgitmLv == "1" {
  2506. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2507. }
  2508. if item.ChrgitmLv == "2" {
  2509. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2510. }
  2511. if item.ChrgitmLv == "3" {
  2512. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2513. }
  2514. }
  2515. if item.MedChrgitmType == "14" { //其他费
  2516. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2517. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2518. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2519. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2520. if item.ChrgitmLv == "1" {
  2521. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2522. }
  2523. if item.ChrgitmLv == "2" {
  2524. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2525. }
  2526. if item.ChrgitmLv == "3" {
  2527. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2528. }
  2529. }
  2530. }
  2531. var iteminfoStructs []service.IteminfoStruct
  2532. if bedCostTotal != 0 {
  2533. iteminfo.MedChrgitm = "01"
  2534. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2535. iteminfo.Amt = bedCostTotal
  2536. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2537. iteminfo.ClabAmt = bed_clab_amt
  2538. iteminfo.OthAmt = bed_other_amt
  2539. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2540. }
  2541. if checkCostTotal != 0 {
  2542. iteminfo.MedChrgitm = "03"
  2543. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2544. iteminfo.Amt = checkCostTotal
  2545. iteminfo.ClaaSumfee = check_claa_sunmfee
  2546. iteminfo.ClabAmt = check_clab_amt
  2547. iteminfo.OthAmt = check_other_amt
  2548. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2549. }
  2550. if laboratoryCostTotal != 0 {
  2551. iteminfo.MedChrgitm = "04"
  2552. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2553. iteminfo.Amt = laboratoryCostTotal
  2554. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2555. iteminfo.ClabAmt = laboratory_clab_amt
  2556. iteminfo.OthAmt = laboratory_other_amt
  2557. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2558. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2559. }
  2560. if treatCostTotal != 0 {
  2561. iteminfo.MedChrgitm = "05"
  2562. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2563. iteminfo.Amt = treatCostTotal
  2564. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2565. iteminfo.ClabAmt = treat_clab_amt
  2566. iteminfo.OthAmt = treat_other_amt
  2567. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2568. //(struct4101.IteminfoStruct, iteminfo)
  2569. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2570. }
  2571. if operationCostTotal != 0 {
  2572. iteminfo.MedChrgitm = "06"
  2573. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2574. iteminfo.Amt = operationCostTotal
  2575. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2576. iteminfo.ClabAmt = operation_clab_amt
  2577. iteminfo.OthAmt = operation_other_amt
  2578. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2579. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2580. }
  2581. if materialCostTotal != 0 {
  2582. iteminfo.MedChrgitm = "08"
  2583. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2584. iteminfo.Amt = materialCostTotal
  2585. iteminfo.ClaaSumfee = material_claa_sunmfee
  2586. iteminfo.ClabAmt = material_clab_amt
  2587. iteminfo.OthAmt = material_other_amt
  2588. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2589. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2590. }
  2591. if westernMedicineCostTotal != 0 {
  2592. iteminfo.MedChrgitm = "09"
  2593. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2594. iteminfo.Amt = westernMedicineCostTotal
  2595. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2596. iteminfo.ClabAmt = westernMedicine_clab_amt
  2597. iteminfo.OthAmt = westernMedicine_other_amt
  2598. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2599. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2600. }
  2601. if chineseTraditionalMedicineCostTotal != 0 {
  2602. iteminfo.MedChrgitm = "11"
  2603. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2604. iteminfo.Amt = westernMedicineCostTotal
  2605. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2606. iteminfo.ClabAmt = westernMedicine_clab_amt
  2607. iteminfo.OthAmt = westernMedicine_other_amt
  2608. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2609. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2610. }
  2611. if otherCostTotal != 0 {
  2612. iteminfo.MedChrgitm = "14"
  2613. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2614. iteminfo.Amt = otherCostTotal
  2615. iteminfo.ClaaSumfee = other_claa_sunmfee
  2616. iteminfo.ClabAmt = other_clab_amt
  2617. iteminfo.OthAmt = other_other_amt
  2618. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2619. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2620. }
  2621. struct4101.IteminfoStruct = iteminfoStructs
  2622. struct4101.Ntly = "中国"
  2623. struct4101.AdmCaty = "A03.06"
  2624. var res ResultSeventeen
  2625. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2626. struct4101.BillCode = order.Number
  2627. struct4101.BillNo = order.SetlId
  2628. var resOther ResultSeventeenOther
  2629. var pp models.PublicParams
  2630. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2631. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2632. pp.FixmedinsName = miConfig.OrgName
  2633. pp.FixmedinsCode = miConfig.Code
  2634. pp.RequestUrl = miConfig.Url
  2635. pp.Cainfo = miConfig.Cainfo
  2636. pp.SecretKey = miConfig.SecretKey
  2637. pp.AccessKey = miConfig.AccessKey
  2638. pp.OpterName = curRoles.UserName
  2639. client := &http.Client{}
  2640. var req *http.Request
  2641. data := make(map[string]interface{})
  2642. data["struct4101"] = struct4101
  2643. data["pp"] = pp
  2644. bytesData, _ := json.Marshal(data)
  2645. if miConfig.MdtrtareaAdmvs == "320921" {
  2646. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2647. } else {
  2648. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2649. }
  2650. resp, _ := client.Do(req)
  2651. defer resp.Body.Close()
  2652. body, ioErr := ioutil.ReadAll(resp.Body)
  2653. if ioErr != nil {
  2654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2656. return
  2657. }
  2658. var respJSON map[string]interface{}
  2659. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2662. return
  2663. }
  2664. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2665. userJSONBytes, _ := json.Marshal(respJSON)
  2666. fmt.Println("log")
  2667. fmt.Println(string(userJSONBytes))
  2668. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2669. utils.ErrorLog("解析失败:%v", err)
  2670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2671. return
  2672. }
  2673. res.InfRefmsgid = resOther.InfRefmsgid
  2674. res.Output = resOther.Output
  2675. res.ErrMsg = resOther.ErrMsg
  2676. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2677. res.Infcode = infocode
  2678. } else {
  2679. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2680. var dat map[string]interface{}
  2681. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2682. fmt.Println(dat)
  2683. } else {
  2684. fmt.Println(err)
  2685. }
  2686. userJSONBytes, _ := json.Marshal(dat)
  2687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2688. utils.ErrorLog("解析失败:%v", err)
  2689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. return
  2691. }
  2692. }
  2693. if res.Infcode != 0 {
  2694. c.ServeSuccessJSON(map[string]interface{}{
  2695. "failed_code": -10,
  2696. "msg": res.ErrMsg,
  2697. })
  2698. return
  2699. } else {
  2700. order.FaPiaoNumber = zero
  2701. order.FaPiaoCode = last_order.FaPiaoCode
  2702. service.UpdateOrder(order)
  2703. hisFundSettleListResult := &models.HisFundSettleListResult{
  2704. Number: res.Output.SetlListId,
  2705. Status: 1,
  2706. Ctime: time.Now().Unix(),
  2707. Mtime: time.Now().Unix(),
  2708. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2709. IsUpload: 1,
  2710. OrderId: order_id,
  2711. }
  2712. service.CreateUploadRecord(hisFundSettleListResult)
  2713. c.ServeSuccessJSON(map[string]interface{}{
  2714. "msg": "上传成功",
  2715. "result": hisFundSettleListResult,
  2716. })
  2717. return
  2718. }
  2719. }
  2720. func (c *HisApiController) GetSettleListHospital() {
  2721. order_id, _ := c.GetInt64("order_id")
  2722. admin_user_id, _ := c.GetInt64("admin_user_id")
  2723. order, _ := service.GetHisOrderByIDTwo(order_id)
  2724. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2725. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2726. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2727. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2728. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2729. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2730. if order.ID == 0 {
  2731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2732. return
  2733. }
  2734. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2735. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2736. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2737. fmt.Println(count)
  2738. var zero string
  2739. number := count + 1
  2740. if number >= 1000 {
  2741. zero = "0000" + strconv.FormatInt(number, 10)
  2742. } else if number >= 10000 {
  2743. zero = "000" + strconv.FormatInt(number, 10)
  2744. } else if number >= 100000 {
  2745. zero = "00" + strconv.FormatInt(number, 10)
  2746. } else if number >= 1000000 {
  2747. zero = "0" + strconv.FormatInt(number, 10)
  2748. } else {
  2749. zero = strconv.FormatInt(number, 10)
  2750. }
  2751. fmt.Println(zero)
  2752. struct4101 := service.Struct4101{
  2753. PsnNo: order.PsnNo,
  2754. MdtrtId: order.MdtrtId,
  2755. SetlId: order.SetlId,
  2756. PsnName: order.PsnName,
  2757. Gend: order.Gend,
  2758. Brdy: his.Brdy,
  2759. Age: int64(order.Age),
  2760. Naty: order.Naty,
  2761. PatnCertType: "01",
  2762. Certno: order.Certno,
  2763. Prfs: "90",
  2764. ConerName: roles[0].UserName,
  2765. PatnRlts: "99",
  2766. ConerAddr: miConfig.OrgName,
  2767. ConerTel: admin.Mobile,
  2768. HiType: order.Insutype,
  2769. Insuplc: miConfig.InsuplcAdmdvs,
  2770. MaindiagFlag: "1",
  2771. BillCode: order.FaPiaoCode,
  2772. BillNo: order.FaPiaoCode,
  2773. BizSn: order.Number,
  2774. PsnSelfPay: order.PsnPartAmt,
  2775. PsnOwnPay: order.PsnPartAmt,
  2776. AcctPay: order.AcctPay,
  2777. PsnCashpay: order.PsnCashPay,
  2778. HiPaymtd: "1",
  2779. Hsorg: miConfig.InsuplcAdmdvs,
  2780. HsorgOpter: miConfig.InsuplcAdmdvs,
  2781. MedinsFillPsn: curRoles.UserName,
  2782. MedinsFillDept: depart.Name,
  2783. IptMedType: "2",
  2784. AdmTime: his.InHosptialTime,
  2785. AdmEndTime: his.OutHosptialTime,
  2786. }
  2787. struct4101.SetlBegnDate = order.SetlTime
  2788. struct4101.SetlEndDate = order.SetlTime
  2789. var rf []CustomFundPay
  2790. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2791. var tempFunPays []service.CustomStruct
  2792. for _, item := range rf {
  2793. var tempFunPay service.CustomStruct
  2794. tempFunPay.FundPayamt = item.FundPayamt
  2795. tempFunPay.FundPayType = item.FundPayType
  2796. tempFunPays = append(tempFunPays, tempFunPay)
  2797. }
  2798. struct4101.CustomStruct = tempFunPays
  2799. var tempDiaginfos []service.DiaginfoStructTwo
  2800. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2801. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2802. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2803. var config []*models.HisXtDiagnoseConfig
  2804. for _, item := range diagnosis_ids {
  2805. id, _ := strconv.ParseInt(item, 10, 64)
  2806. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2807. config = append(config, &diagnosisConfig)
  2808. }
  2809. for index, item := range config {
  2810. if index == 0 {
  2811. var tempDiaginfo service.DiaginfoStructTwo
  2812. tempDiaginfo.DiagCode = item.CountryCode
  2813. tempDiaginfo.DiagName = item.CountryContentName
  2814. tempDiaginfo.DiagType = "1"
  2815. tempDiaginfo.MaindiagFlag = "1"
  2816. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2817. } else {
  2818. var tempDiaginfo service.DiaginfoStructTwo
  2819. tempDiaginfo.DiagCode = item.CountryCode
  2820. tempDiaginfo.DiagName = item.CountryContentName
  2821. tempDiaginfo.DiagType = "2"
  2822. tempDiaginfo.MaindiagFlag = "0"
  2823. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2824. }
  2825. }
  2826. struct4101.Diseinfo = tempDiaginfos
  2827. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2828. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2829. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2830. tempOpspdiseinfo2.OprnOprtCode = ""
  2831. tempOpspdiseinfo2.OprnOprtName = ""
  2832. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2833. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2834. var iteminfo service.IteminfoStruct
  2835. var bedCostTotal float64 = 0 //床位总费
  2836. var bedCostSelfTotal float64 = 0 //床位自费
  2837. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2838. var operationCostTotal float64 = 0 //手术费
  2839. var operationCostSelfTotal float64 = 0 //手术费
  2840. var operationCostPartSelfTotal float64 = 0 //手术费
  2841. var otherCostTotal float64 = 0 //其他费用
  2842. var otherCostSelfTotal float64 = 0 //其他费用
  2843. var otherCostPartSelfTotal float64 = 0 //其他费用
  2844. var materialCostTotal float64 = 0 //材料费
  2845. var materialCostSelfTotal float64 = 0 //材料费
  2846. var materialCostPartSelfTotal float64 = 0 //材料费
  2847. var westernMedicineCostTotal float64 = 0 //西药费
  2848. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2849. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2850. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2851. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2852. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2853. var checkCostTotal float64 = 0 //检查费
  2854. var checkCostSelfTotal float64 = 0 //检查费
  2855. var checkCostPartSelfTotal float64 = 0 //检查费
  2856. var laboratoryCostTotal float64 = 0 //化验费
  2857. var laboratoryCostSelfTotal float64 = 0 //化验费
  2858. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2859. var treatCostTotal float64 = 0 //治疗费用
  2860. var treatCostSelfTotal float64 = 0 //治疗费用
  2861. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2862. decimal.DivisionPrecision = 2
  2863. var bed_fulamt_ownpay_amt float64 = 0
  2864. var operation_fulamt_ownpay_amt float64 = 0
  2865. var other_fulamt_ownpay_amt float64 = 0
  2866. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2867. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2868. var check_fulamt_ownpay_amt float64 = 0
  2869. var material_fulamt_ownpay_amt float64 = 0
  2870. var laboratory_fulamt_ownpay_amt float64 = 0
  2871. var treat_fulamt_ownpay_amt float64 = 0
  2872. var bed_claa_sunmfee float64 = 0
  2873. var bed_clab_amt float64 = 0
  2874. var bed_other_amt float64 = 0
  2875. var operation_claa_sunmfee float64 = 0
  2876. var operation_clab_amt float64 = 0
  2877. var operation_other_amt float64 = 0
  2878. var other_claa_sunmfee float64 = 0
  2879. var other_clab_amt float64 = 0
  2880. var other_other_amt float64 = 0
  2881. var westernMedicine_claa_sunmfee float64 = 0
  2882. var westernMedicine_clab_amt float64 = 0
  2883. var westernMedicine_other_amt float64 = 0
  2884. var chineseTraditional_claa_sunmfee float64 = 0
  2885. var chineseTraditional_clab_amt float64 = 0
  2886. var chineseTraditional_other_amt float64 = 0
  2887. var check_claa_sunmfee float64 = 0
  2888. var check_clab_amt float64 = 0
  2889. var check_other_amt float64 = 0
  2890. var material_claa_sunmfee float64 = 0
  2891. var material_clab_amt float64 = 0
  2892. var material_other_amt float64 = 0
  2893. var laboratory_claa_sunmfee float64 = 0
  2894. var laboratory_clab_amt float64 = 0
  2895. var laboratory_other_amt float64 = 0
  2896. var treat_claa_sunmfee float64 = 0
  2897. var treat_clab_amt float64 = 0
  2898. var treat_other_amt float64 = 0
  2899. for _, item := range order.HisOrderInfo {
  2900. if item.MedChrgitmType == "01" { //床位费
  2901. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2902. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2903. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2904. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2905. if item.ChrgitmLv == "1" {
  2906. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2907. }
  2908. if item.ChrgitmLv == "2" {
  2909. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2910. }
  2911. if item.ChrgitmLv == "3" {
  2912. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2913. }
  2914. }
  2915. if item.MedChrgitmType == "03" { //检查费
  2916. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2917. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2918. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2919. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2920. if item.ChrgitmLv == "1" {
  2921. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2922. }
  2923. if item.ChrgitmLv == "2" {
  2924. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2925. }
  2926. if item.ChrgitmLv == "3" {
  2927. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2928. }
  2929. }
  2930. if item.MedChrgitmType == "04" { //化验费
  2931. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2932. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2933. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2934. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2935. if item.ChrgitmLv == "1" {
  2936. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2937. }
  2938. if item.ChrgitmLv == "2" {
  2939. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2940. }
  2941. if item.ChrgitmLv == "3" {
  2942. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2943. }
  2944. }
  2945. if item.MedChrgitmType == "05" { //治疗费
  2946. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2947. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2948. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2949. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2950. if item.ChrgitmLv == "1" {
  2951. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2952. }
  2953. if item.ChrgitmLv == "2" {
  2954. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2955. }
  2956. if item.ChrgitmLv == "3" {
  2957. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2958. }
  2959. }
  2960. if item.MedChrgitmType == "06" { //手术费
  2961. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2962. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2963. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2964. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2965. if item.ChrgitmLv == "1" {
  2966. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2967. }
  2968. if item.ChrgitmLv == "2" {
  2969. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2970. }
  2971. if item.ChrgitmLv == "3" {
  2972. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2973. }
  2974. }
  2975. if item.MedChrgitmType == "08" { //材料费
  2976. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2977. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2978. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2979. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2980. if item.ChrgitmLv == "1" {
  2981. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2982. }
  2983. if item.ChrgitmLv == "2" {
  2984. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2985. }
  2986. if item.ChrgitmLv == "3" {
  2987. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2988. }
  2989. }
  2990. if item.MedChrgitmType == "09" { //西药费
  2991. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2992. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2993. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2994. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2995. if item.ChrgitmLv == "1" {
  2996. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2997. }
  2998. if item.ChrgitmLv == "2" {
  2999. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3000. }
  3001. if item.ChrgitmLv == "3" {
  3002. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3003. }
  3004. }
  3005. if item.MedChrgitmType == "11" { //中成费
  3006. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3007. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3008. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3009. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3010. if item.ChrgitmLv == "1" {
  3011. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3012. }
  3013. if item.ChrgitmLv == "2" {
  3014. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3015. }
  3016. if item.ChrgitmLv == "3" {
  3017. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3018. }
  3019. }
  3020. if item.MedChrgitmType == "14" { //其他费
  3021. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3022. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3023. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3024. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3025. if item.ChrgitmLv == "1" {
  3026. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3027. }
  3028. if item.ChrgitmLv == "2" {
  3029. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3030. }
  3031. if item.ChrgitmLv == "3" {
  3032. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3033. }
  3034. }
  3035. }
  3036. var iteminfoStructs []service.IteminfoStruct
  3037. if bedCostTotal != 0 {
  3038. iteminfo.MedChrgitm = "01"
  3039. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3040. iteminfo.Amt = bedCostTotal
  3041. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3042. iteminfo.ClabAmt = bed_clab_amt
  3043. iteminfo.OthAmt = bed_other_amt
  3044. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3045. }
  3046. if checkCostTotal != 0 {
  3047. iteminfo.MedChrgitm = "03"
  3048. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3049. iteminfo.Amt = checkCostTotal
  3050. iteminfo.ClaaSumfee = check_claa_sunmfee
  3051. iteminfo.ClabAmt = check_clab_amt
  3052. iteminfo.OthAmt = check_other_amt
  3053. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3054. }
  3055. if laboratoryCostTotal != 0 {
  3056. iteminfo.MedChrgitm = "04"
  3057. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3058. iteminfo.Amt = laboratoryCostTotal
  3059. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3060. iteminfo.ClabAmt = laboratory_clab_amt
  3061. iteminfo.OthAmt = laboratory_other_amt
  3062. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3063. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3064. }
  3065. if treatCostTotal != 0 {
  3066. iteminfo.MedChrgitm = "05"
  3067. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3068. iteminfo.Amt = treatCostTotal
  3069. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3070. iteminfo.ClabAmt = treat_clab_amt
  3071. iteminfo.OthAmt = treat_other_amt
  3072. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3073. //(struct4101.IteminfoStruct, iteminfo)
  3074. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3075. }
  3076. if operationCostTotal != 0 {
  3077. iteminfo.MedChrgitm = "06"
  3078. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3079. iteminfo.Amt = operationCostTotal
  3080. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3081. iteminfo.ClabAmt = operation_clab_amt
  3082. iteminfo.OthAmt = operation_other_amt
  3083. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3084. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3085. }
  3086. if materialCostTotal != 0 {
  3087. iteminfo.MedChrgitm = "08"
  3088. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3089. iteminfo.Amt = materialCostTotal
  3090. iteminfo.ClaaSumfee = material_claa_sunmfee
  3091. iteminfo.ClabAmt = material_clab_amt
  3092. iteminfo.OthAmt = material_other_amt
  3093. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3094. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3095. }
  3096. if westernMedicineCostTotal != 0 {
  3097. iteminfo.MedChrgitm = "09"
  3098. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3099. iteminfo.Amt = westernMedicineCostTotal
  3100. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3101. iteminfo.ClabAmt = westernMedicine_clab_amt
  3102. iteminfo.OthAmt = westernMedicine_other_amt
  3103. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3104. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3105. }
  3106. if chineseTraditionalMedicineCostTotal != 0 {
  3107. iteminfo.MedChrgitm = "11"
  3108. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3109. iteminfo.Amt = westernMedicineCostTotal
  3110. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3111. iteminfo.ClabAmt = westernMedicine_clab_amt
  3112. iteminfo.OthAmt = westernMedicine_other_amt
  3113. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3114. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3115. }
  3116. if otherCostTotal != 0 {
  3117. iteminfo.MedChrgitm = "14"
  3118. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3119. iteminfo.Amt = otherCostTotal
  3120. iteminfo.ClaaSumfee = other_claa_sunmfee
  3121. iteminfo.ClabAmt = other_clab_amt
  3122. iteminfo.OthAmt = other_other_amt
  3123. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3124. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3125. }
  3126. struct4101.IteminfoStruct = iteminfoStructs
  3127. struct4101.Ntly = "中国"
  3128. struct4101.AdmCaty = "A03.06"
  3129. var resOther ResultSeventeenOther
  3130. var res ResultSeventeen
  3131. if miConfig.MdtrtareaAdmvs == "150499" {
  3132. var pp models.PublicParams
  3133. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3134. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3135. pp.FixmedinsName = miConfig.OrgName
  3136. pp.FixmedinsCode = miConfig.Code
  3137. pp.RequestUrl = miConfig.Url
  3138. pp.Cainfo = miConfig.Cainfo
  3139. pp.SecretKey = miConfig.SecretKey
  3140. pp.AccessKey = miConfig.AccessKey
  3141. pp.OpterName = curRoles.UserName
  3142. client := &http.Client{}
  3143. var req *http.Request
  3144. data := make(map[string]interface{})
  3145. data["struct4101"] = struct4101
  3146. data["pp"] = pp
  3147. bytesData, _ := json.Marshal(data)
  3148. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  3149. resp, _ := client.Do(req)
  3150. defer resp.Body.Close()
  3151. body, ioErr := ioutil.ReadAll(resp.Body)
  3152. if ioErr != nil {
  3153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3155. return
  3156. }
  3157. var respJSON map[string]interface{}
  3158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3161. return
  3162. }
  3163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3164. userJSONBytes, _ := json.Marshal(respJSON)
  3165. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3166. utils.ErrorLog("解析失败:%v", err)
  3167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3168. return
  3169. }
  3170. res.InfRefmsgid = resOther.InfRefmsgid
  3171. res.Output = resOther.Output
  3172. res.ErrMsg = resOther.ErrMsg
  3173. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3174. res.Infcode = infocode
  3175. } else {
  3176. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3177. var dat map[string]interface{}
  3178. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3179. fmt.Println(dat)
  3180. } else {
  3181. fmt.Println(err)
  3182. }
  3183. userJSONBytes, _ := json.Marshal(dat)
  3184. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3185. utils.ErrorLog("解析失败:%v", err)
  3186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3187. return
  3188. }
  3189. }
  3190. if res.Infcode != 0 {
  3191. c.ServeSuccessJSON(map[string]interface{}{
  3192. "failed_code": -10,
  3193. "msg": res.ErrMsg,
  3194. })
  3195. return
  3196. } else {
  3197. if miConfig.MdtrtareaAdmvs != "150499" {
  3198. order.FaPiaoNumber = zero
  3199. order.FaPiaoCode = last_order.FaPiaoCode
  3200. service.UpdateOrder(order)
  3201. }
  3202. hisFundSettleListResult := &models.HisFundSettleListResult{
  3203. Number: res.Output.SetlListId,
  3204. Status: 1,
  3205. Ctime: time.Now().Unix(),
  3206. Mtime: time.Now().Unix(),
  3207. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3208. IsUpload: 1,
  3209. OrderId: order_id,
  3210. }
  3211. service.CreateUploadRecord(hisFundSettleListResult)
  3212. c.ServeSuccessJSON(map[string]interface{}{
  3213. "msg": "上传成功",
  3214. "result": hisFundSettleListResult,
  3215. })
  3216. return
  3217. }
  3218. }
  3219. func (c *HisApiController) GetBatchSettleList() {
  3220. orders, _ := service.GetAllHisOrder(10106)
  3221. for _, item := range orders {
  3222. order_id := item.ID
  3223. order, _ := service.GetHisOrderByIDTwo(order_id)
  3224. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3225. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3226. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3227. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  3228. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3230. if order.ID == 0 {
  3231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3232. return
  3233. }
  3234. if his.BalanceAccountsType == 2 {
  3235. continue
  3236. }
  3237. struct4101 := service.Struct4101{
  3238. PsnNo: order.PsnNo,
  3239. MdtrtId: order.MdtrtId,
  3240. SetlId: order.SetlId,
  3241. PsnName: order.PsnName,
  3242. Gend: order.Gend,
  3243. Brdy: his.Brdy,
  3244. Age: his.Age,
  3245. Naty: order.Naty,
  3246. PatnCertType: "01",
  3247. Certno: order.Certno,
  3248. Prfs: "90",
  3249. ConerName: roles[0].UserName,
  3250. PatnRlts: "99",
  3251. ConerAddr: miConfig.OrgName,
  3252. ConerTel: admin.Mobile,
  3253. HiType: order.Insutype,
  3254. Insuplc: his.InsuplcAdmdvs,
  3255. MaindiagFlag: "1",
  3256. BillCode: order.FaPiaoCode,
  3257. BillNo: order.FaPiaoNumber,
  3258. BizSn: order.Number,
  3259. PsnSelfPay: order.PsnPartAmt,
  3260. PsnOwnPay: order.PsnPartAmt,
  3261. AcctPay: order.AcctPay,
  3262. PsnCashpay: order.PsnCashPay,
  3263. HiPaymtd: "1",
  3264. Hsorg: his.InsuplcAdmdvs,
  3265. HsorgOpter: his.InsuplcAdmdvs,
  3266. MedinsFillPsn: curRoles.UserName,
  3267. MedinsFillDept: depart.Name,
  3268. IptMedType: "2",
  3269. }
  3270. struct4101.SetlBegnDate = order.SetlTime
  3271. struct4101.SetlEndDate = order.SetlTime
  3272. //if order.SettleType == 1 {
  3273. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  3274. // dateStr := t.Format("2006-01-02")
  3275. // struct4101.SetlBegnDate = dateStr
  3276. // struct4101.SetlEndDate = dateStr
  3277. //} else {
  3278. // t := time.Unix(int64(order.SettleStartTime), 0)
  3279. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  3280. // dateStartStr := t.Format("2006-01-02")
  3281. // dateEndStr := t2.Format("2006-01-02")
  3282. // struct4101.SetlBegnDate = dateStartStr
  3283. // struct4101.SetlEndDate = dateEndStr
  3284. //}
  3285. var rf []CustomFundPay
  3286. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3287. var tempFunPays []service.CustomStruct
  3288. var tempFunPay610100 service.CustomStruct
  3289. for _, item := range rf {
  3290. if item.FundPayType == "610100" {
  3291. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  3292. tempFunPay610100.FundPayType = item.FundPayType
  3293. } else {
  3294. var tempFunPay service.CustomStruct
  3295. tempFunPay.FundPayamt = item.FundPayamt
  3296. tempFunPay.FundPayType = item.FundPayType
  3297. tempFunPays = append(tempFunPays, tempFunPay)
  3298. }
  3299. }
  3300. tempFunPays = append(tempFunPays, tempFunPay610100)
  3301. struct4101.CustomStruct = tempFunPays
  3302. var tempDiaginfos []service.DiaginfoStructTwo
  3303. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3304. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3305. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3306. var config []*models.HisXtDiagnoseConfig
  3307. for _, item := range diagnosis_ids {
  3308. id, _ := strconv.ParseInt(item, 10, 64)
  3309. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3310. config = append(config, &diagnosisConfig)
  3311. }
  3312. for index, item := range config {
  3313. if index == 0 {
  3314. var tempDiaginfo service.DiaginfoStructTwo
  3315. tempDiaginfo.DiagCode = item.CountryCode
  3316. tempDiaginfo.DiagName = item.CountryContentName
  3317. tempDiaginfo.DiagType = "1"
  3318. tempDiaginfo.MaindiagFlag = "1"
  3319. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3320. } else {
  3321. var tempDiaginfo service.DiaginfoStructTwo
  3322. tempDiaginfo.DiagCode = item.CountryCode
  3323. tempDiaginfo.DiagName = item.CountryContentName
  3324. tempDiaginfo.DiagType = "2"
  3325. tempDiaginfo.MaindiagFlag = "0"
  3326. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3327. }
  3328. }
  3329. struct4101.Diseinfo = tempDiaginfos
  3330. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3331. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3332. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3333. tempOpspdiseinfo2.OprnOprtCode = ""
  3334. tempOpspdiseinfo2.OprnOprtName = ""
  3335. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3336. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3337. var iteminfo service.IteminfoStruct
  3338. var bedCostTotal float64 = 0 //床位总费
  3339. var bedCostSelfTotal float64 = 0 //床位自费
  3340. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3341. var examineCostTotal float64 = 0 //诊查总费
  3342. var examineCostSelfTotal float64 = 0 //诊查自费
  3343. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3344. var nursingCostTotal float64 = 0 //护理总费
  3345. var nursingCostSelfTotal float64 = 0 //护理自费
  3346. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3347. var chineseMedicineCostTotal float64 = 0 //中成药
  3348. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3349. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3350. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3351. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3352. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3353. var registerCostTotal float64 = 0 //一般诊疗费
  3354. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3355. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3356. var operationCostTotal float64 = 0 //手术费
  3357. var operationCostSelfTotal float64 = 0 //手术费
  3358. var operationCostPartSelfTotal float64 = 0 //手术费
  3359. var otherCostTotal float64 = 0 //其他费用
  3360. var otherCostSelfTotal float64 = 0 //其他费用
  3361. var otherCostPartSelfTotal float64 = 0 //其他费用
  3362. var materialCostTotal float64 = 0 //材料费
  3363. var materialCostSelfTotal float64 = 0 //材料费
  3364. var materialCostPartSelfTotal float64 = 0 //材料费
  3365. var westernMedicineCostTotal float64 = 0 //西药费
  3366. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3367. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3368. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3369. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3370. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3371. var checkCostTotal float64 = 0 //检查费
  3372. var checkCostSelfTotal float64 = 0 //检查费
  3373. var checkCostPartSelfTotal float64 = 0 //检查费
  3374. var laboratoryCostTotal float64 = 0 //化验费
  3375. var laboratoryCostSelfTotal float64 = 0 //化验费
  3376. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3377. var treatCostTotal float64 = 0 //治疗费用
  3378. var treatCostSelfTotal float64 = 0 //治疗费用
  3379. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3380. decimal.DivisionPrecision = 2
  3381. var bed_fulamt_ownpay_amt float64 = 0
  3382. var examine_fulamt_ownpay_amt float64 = 0
  3383. var nursing_fulamt_ownpay_amt float64 = 0
  3384. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3385. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3386. var register_fulamt_ownpay_amt float64 = 0
  3387. var operation_fulamt_ownpay_amt float64 = 0
  3388. var other_fulamt_ownpay_amt float64 = 0
  3389. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3390. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3391. var check_fulamt_ownpay_amt float64 = 0
  3392. var material_fulamt_ownpay_amt float64 = 0
  3393. var laboratory_fulamt_ownpay_amt float64 = 0
  3394. var treat_fulamt_ownpay_amt float64 = 0
  3395. var bed_claa_sunmfee float64 = 0
  3396. var bed_clab_amt float64 = 0
  3397. var bed_other_amt float64 = 0
  3398. var examine_claa_sunmfee float64 = 0
  3399. var examine_clab_amt float64 = 0
  3400. var examine_other_amt float64 = 0
  3401. var nursing_claa_sunmfee float64 = 0
  3402. var nursing_clab_amt float64 = 0
  3403. var nursing_other_amt float64 = 0
  3404. var chinese_medicine_claa_sunmfee float64 = 0
  3405. var chinese_medicine_clab_amt float64 = 0
  3406. var chinese_medicine_other_amt float64 = 0
  3407. var commonly_treatment_claa_sunmfee float64 = 0
  3408. var commonly_treatment_clab_amt float64 = 0
  3409. var commonly_treatment_other_amt float64 = 0
  3410. var operation_claa_sunmfee float64 = 0
  3411. var operation_clab_amt float64 = 0
  3412. var operation_other_amt float64 = 0
  3413. var other_claa_sunmfee float64 = 0
  3414. var other_clab_amt float64 = 0
  3415. var other_other_amt float64 = 0
  3416. var westernMedicine_claa_sunmfee float64 = 0
  3417. var westernMedicine_clab_amt float64 = 0
  3418. var westernMedicine_other_amt float64 = 0
  3419. var chineseTraditional_claa_sunmfee float64 = 0
  3420. var chineseTraditional_clab_amt float64 = 0
  3421. var chineseTraditional_other_amt float64 = 0
  3422. var check_claa_sunmfee float64 = 0
  3423. var check_clab_amt float64 = 0
  3424. var check_other_amt float64 = 0
  3425. var material_claa_sunmfee float64 = 0
  3426. var material_clab_amt float64 = 0
  3427. var material_other_amt float64 = 0
  3428. var laboratory_claa_sunmfee float64 = 0
  3429. var laboratory_clab_amt float64 = 0
  3430. var laboratory_other_amt float64 = 0
  3431. var treat_claa_sunmfee float64 = 0
  3432. var treat_clab_amt float64 = 0
  3433. var treat_other_amt float64 = 0
  3434. var register_claa_sunmfee float64 = 0
  3435. var register_clab_amt float64 = 0
  3436. var register_other_amt float64 = 0
  3437. for _, item := range order.HisOrderInfo {
  3438. if item.MedChrgitmType == "01" { //床位费
  3439. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3440. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3441. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3442. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3443. if item.ChrgitmLv == "1" {
  3444. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3445. }
  3446. if item.ChrgitmLv == "2" {
  3447. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3448. }
  3449. if item.ChrgitmLv == "3" {
  3450. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3451. }
  3452. }
  3453. if item.MedChrgitmType == "02" { //诊查
  3454. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3455. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3456. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3457. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3458. if item.ChrgitmLv == "1" {
  3459. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3460. }
  3461. if item.ChrgitmLv == "2" {
  3462. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3463. }
  3464. if item.ChrgitmLv == "3" {
  3465. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3466. }
  3467. }
  3468. if item.MedChrgitmType == "03" { //检查费
  3469. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3470. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3471. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3472. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3473. if item.ChrgitmLv == "1" {
  3474. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3475. }
  3476. if item.ChrgitmLv == "2" {
  3477. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3478. }
  3479. if item.ChrgitmLv == "3" {
  3480. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3481. }
  3482. }
  3483. if item.MedChrgitmType == "04" { //化验费
  3484. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3485. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3486. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3487. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3488. if item.ChrgitmLv == "1" {
  3489. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3490. }
  3491. if item.ChrgitmLv == "2" {
  3492. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3493. }
  3494. if item.ChrgitmLv == "3" {
  3495. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3496. }
  3497. }
  3498. if item.MedChrgitmType == "05" { //治疗费
  3499. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3500. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3501. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3502. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3503. if item.ChrgitmLv == "1" {
  3504. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3505. }
  3506. if item.ChrgitmLv == "2" {
  3507. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3508. }
  3509. if item.ChrgitmLv == "3" {
  3510. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3511. }
  3512. }
  3513. if item.MedChrgitmType == "06" { //手术费
  3514. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3515. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3516. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3517. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3518. if item.ChrgitmLv == "1" {
  3519. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3520. }
  3521. if item.ChrgitmLv == "2" {
  3522. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3523. }
  3524. if item.ChrgitmLv == "3" {
  3525. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3526. }
  3527. }
  3528. if item.MedChrgitmType == "07" { //手术费
  3529. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3530. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3531. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3532. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3533. if item.ChrgitmLv == "1" {
  3534. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3535. }
  3536. if item.ChrgitmLv == "2" {
  3537. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3538. }
  3539. if item.ChrgitmLv == "3" {
  3540. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3541. }
  3542. }
  3543. if item.MedChrgitmType == "08" { //材料费
  3544. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3545. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3546. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3547. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3548. if item.ChrgitmLv == "1" {
  3549. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3550. }
  3551. if item.ChrgitmLv == "2" {
  3552. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3553. }
  3554. if item.ChrgitmLv == "3" {
  3555. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3556. }
  3557. }
  3558. if item.MedChrgitmType == "09" { //西药费
  3559. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3560. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3561. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3562. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3563. if item.ChrgitmLv == "1" {
  3564. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3565. }
  3566. if item.ChrgitmLv == "2" {
  3567. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3568. }
  3569. if item.ChrgitmLv == "3" {
  3570. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3571. }
  3572. }
  3573. if item.MedChrgitmType == "10" { //中药饮片
  3574. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3575. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3576. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3577. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3578. if item.ChrgitmLv == "1" {
  3579. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3580. }
  3581. if item.ChrgitmLv == "2" {
  3582. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3583. }
  3584. if item.ChrgitmLv == "3" {
  3585. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3586. }
  3587. }
  3588. if item.MedChrgitmType == "11" { //中成费
  3589. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3590. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3591. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3592. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3593. if item.ChrgitmLv == "1" {
  3594. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3595. }
  3596. if item.ChrgitmLv == "2" {
  3597. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3598. }
  3599. if item.ChrgitmLv == "3" {
  3600. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3601. }
  3602. }
  3603. if item.MedChrgitmType == "12" { //中成费
  3604. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3605. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3606. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3607. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3608. if item.ChrgitmLv == "1" {
  3609. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3610. }
  3611. if item.ChrgitmLv == "2" {
  3612. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3613. }
  3614. if item.ChrgitmLv == "3" {
  3615. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3616. }
  3617. }
  3618. if item.MedChrgitmType == "13" { //中成费
  3619. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3620. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3621. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3622. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3623. if item.ChrgitmLv == "1" {
  3624. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3625. }
  3626. if item.ChrgitmLv == "2" {
  3627. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3628. }
  3629. if item.ChrgitmLv == "3" {
  3630. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3631. }
  3632. }
  3633. if item.MedChrgitmType == "14" { //其他费
  3634. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3635. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3636. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3637. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3638. if item.ChrgitmLv == "1" {
  3639. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3640. }
  3641. if item.ChrgitmLv == "2" {
  3642. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3643. }
  3644. if item.ChrgitmLv == "3" {
  3645. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3646. }
  3647. }
  3648. }
  3649. var iteminfoStructs []service.IteminfoStruct
  3650. if bedCostTotal != 0 {
  3651. iteminfo.MedChrgitm = "01"
  3652. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3653. iteminfo.Amt = bedCostTotal
  3654. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3655. iteminfo.ClabAmt = bed_clab_amt
  3656. iteminfo.OthAmt = bed_other_amt
  3657. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3658. }
  3659. if examineCostTotal != 0 {
  3660. iteminfo.MedChrgitm = "02"
  3661. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3662. iteminfo.Amt = examineCostTotal
  3663. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3664. iteminfo.ClabAmt = examine_clab_amt
  3665. iteminfo.OthAmt = examine_other_amt
  3666. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3667. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3668. }
  3669. if checkCostTotal != 0 {
  3670. iteminfo.MedChrgitm = "03"
  3671. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3672. iteminfo.Amt = checkCostTotal
  3673. iteminfo.ClaaSumfee = check_claa_sunmfee
  3674. iteminfo.ClabAmt = check_clab_amt
  3675. iteminfo.OthAmt = check_other_amt
  3676. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3677. }
  3678. if laboratoryCostTotal != 0 {
  3679. iteminfo.MedChrgitm = "04"
  3680. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3681. iteminfo.Amt = laboratoryCostTotal
  3682. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3683. iteminfo.ClabAmt = laboratory_clab_amt
  3684. iteminfo.OthAmt = laboratory_other_amt
  3685. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3686. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3687. }
  3688. if treatCostTotal != 0 {
  3689. iteminfo.MedChrgitm = "05"
  3690. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3691. iteminfo.Amt = treatCostTotal
  3692. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3693. iteminfo.ClabAmt = treat_clab_amt
  3694. iteminfo.OthAmt = treat_other_amt
  3695. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3696. //(struct4101.IteminfoStruct, iteminfo)
  3697. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3698. }
  3699. if operationCostTotal != 0 {
  3700. iteminfo.MedChrgitm = "06"
  3701. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3702. iteminfo.Amt = operationCostTotal
  3703. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3704. iteminfo.ClabAmt = operation_clab_amt
  3705. iteminfo.OthAmt = operation_other_amt
  3706. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3707. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3708. }
  3709. if nursingCostTotal != 0 {
  3710. iteminfo.MedChrgitm = "07"
  3711. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3712. iteminfo.Amt = nursingCostTotal
  3713. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3714. iteminfo.ClabAmt = nursing_clab_amt
  3715. iteminfo.OthAmt = nursing_other_amt
  3716. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3717. }
  3718. if materialCostTotal != 0 {
  3719. iteminfo.MedChrgitm = "08"
  3720. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3721. iteminfo.Amt = materialCostTotal
  3722. iteminfo.ClaaSumfee = material_claa_sunmfee
  3723. iteminfo.ClabAmt = material_clab_amt
  3724. iteminfo.OthAmt = material_other_amt
  3725. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3726. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3727. }
  3728. if westernMedicineCostTotal != 0 {
  3729. iteminfo.MedChrgitm = "09"
  3730. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3731. iteminfo.Amt = westernMedicineCostTotal
  3732. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3733. iteminfo.ClabAmt = westernMedicine_clab_amt
  3734. iteminfo.OthAmt = westernMedicine_other_amt
  3735. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3736. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3737. }
  3738. if chineseMedicineCostTotal != 0 {
  3739. iteminfo.MedChrgitm = "10"
  3740. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3741. iteminfo.Amt = chineseMedicineCostTotal
  3742. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3743. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3744. iteminfo.OthAmt = chinese_medicine_other_amt
  3745. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3746. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3747. }
  3748. if chineseTraditionalMedicineCostTotal != 0 {
  3749. iteminfo.MedChrgitm = "11"
  3750. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3751. iteminfo.Amt = westernMedicineCostTotal
  3752. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3753. iteminfo.ClabAmt = westernMedicine_clab_amt
  3754. iteminfo.OthAmt = westernMedicine_other_amt
  3755. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3756. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3757. }
  3758. if commonlyTreatmentCostTotal != 0 {
  3759. iteminfo.MedChrgitm = "12"
  3760. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3761. iteminfo.Amt = commonlyTreatmentCostTotal
  3762. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3763. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3764. iteminfo.OthAmt = commonly_treatment_other_amt
  3765. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3766. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3767. }
  3768. if registerCostTotal != 0 {
  3769. iteminfo.MedChrgitm = "13"
  3770. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3771. iteminfo.Amt = registerCostTotal
  3772. iteminfo.ClaaSumfee = register_claa_sunmfee
  3773. iteminfo.ClabAmt = register_clab_amt
  3774. iteminfo.OthAmt = register_other_amt
  3775. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3776. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3777. }
  3778. if otherCostTotal != 0 {
  3779. iteminfo.MedChrgitm = "14"
  3780. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3781. iteminfo.Amt = otherCostTotal
  3782. iteminfo.ClaaSumfee = other_claa_sunmfee
  3783. iteminfo.ClabAmt = other_clab_amt
  3784. iteminfo.OthAmt = other_other_amt
  3785. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3786. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3787. }
  3788. struct4101.IteminfoStruct = iteminfoStructs
  3789. struct4101.Ntly = "中国"
  3790. struct4101.AdmCaty = "A03.06"
  3791. var res ResultSeventeen
  3792. if miConfig.MdtrtareaAdmvs == "421300" {
  3793. data := make(map[string]interface{})
  3794. data["struct4101"] = struct4101
  3795. data["secret_key"] = miConfig.SecretKey
  3796. data["org_name"] = miConfig.OrgName
  3797. data["opera"] = curRoles.UserName
  3798. data["code"] = miConfig.Code
  3799. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3800. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3801. client := &http.Client{}
  3802. bytesData, _ := json.Marshal(data)
  3803. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3804. resp, _ := client.Do(req)
  3805. defer resp.Body.Close()
  3806. body, ioErr := ioutil.ReadAll(resp.Body)
  3807. if ioErr != nil {
  3808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3810. return
  3811. }
  3812. var respJSON map[string]interface{}
  3813. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3816. return
  3817. }
  3818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3819. userJSONBytes, _ := json.Marshal(respJSON)
  3820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3821. utils.ErrorLog("解析失败:%v", err)
  3822. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3823. adminUser := c.GetAdminUserInfo()
  3824. errlog := &models.HisOrderError{
  3825. UserOrgId: adminUser.CurrentOrgId,
  3826. Ctime: time.Now().Unix(),
  3827. Mtime: time.Now().Unix(),
  3828. ErrMsg: res.ErrMsg + "解析失败",
  3829. Status: 1,
  3830. PatientId: order_id,
  3831. Stage: 10088,
  3832. }
  3833. service.CreateErrMsgLog(errlog)
  3834. continue
  3835. }
  3836. } else {
  3837. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3838. fmt.Println(result)
  3839. var dat map[string]interface{}
  3840. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3841. fmt.Println(dat)
  3842. } else {
  3843. fmt.Println(err)
  3844. }
  3845. userJSONBytes, _ := json.Marshal(dat)
  3846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3847. utils.ErrorLog("解析失败:%v", err)
  3848. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3849. adminUser := c.GetAdminUserInfo()
  3850. errlog := &models.HisOrderError{
  3851. UserOrgId: adminUser.CurrentOrgId,
  3852. Ctime: time.Now().Unix(),
  3853. Mtime: time.Now().Unix(),
  3854. ErrMsg: res.ErrMsg + "解析失败",
  3855. Status: 1,
  3856. PatientId: order_id,
  3857. Stage: 10106,
  3858. }
  3859. service.CreateErrMsgLog(errlog)
  3860. continue
  3861. }
  3862. }
  3863. if res.Infcode != 0 {
  3864. adminUser := c.GetAdminUserInfo()
  3865. errlog := &models.HisOrderError{
  3866. UserOrgId: adminUser.CurrentOrgId,
  3867. Ctime: time.Now().Unix(),
  3868. Mtime: time.Now().Unix(),
  3869. ErrMsg: res.ErrMsg,
  3870. Status: 1,
  3871. PatientId: order_id,
  3872. Stage: 10106,
  3873. }
  3874. service.CreateErrMsgLog(errlog)
  3875. continue
  3876. } else {
  3877. hisFundSettleListResult := &models.HisFundSettleListResult{
  3878. Number: res.Output.SetlListId,
  3879. Status: 1,
  3880. Ctime: time.Now().Unix(),
  3881. Mtime: time.Now().Unix(),
  3882. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3883. IsUpload: 1,
  3884. OrderId: order_id,
  3885. }
  3886. service.CreateUploadRecord(hisFundSettleListResult)
  3887. continue
  3888. }
  3889. }
  3890. }
  3891. func (c *HisApiController) GetOrgInfo() {
  3892. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3893. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3894. }
  3895. func (c *HisApiController) GetHisPatientInfo() {
  3896. medical_insurance_card := c.GetString("medical_insurance_card")
  3897. id_card_type, _ := c.GetInt64("id_card_type")
  3898. id_card := c.GetString("id_card")
  3899. adminInfo := c.GetAdminUserInfo()
  3900. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3901. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3902. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3903. IdCardNo := ""
  3904. if id_card_type == 1 {
  3905. IdCardNo = medical_insurance_card
  3906. } else if id_card_type == 2 {
  3907. IdCardNo = id_card
  3908. }
  3909. if config.IsOpen == 1 {
  3910. 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
  3911. resp, requestErr := http.Get(api)
  3912. if requestErr != nil {
  3913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3914. return
  3915. }
  3916. defer resp.Body.Close()
  3917. body, ioErr := ioutil.ReadAll(resp.Body)
  3918. if ioErr != nil {
  3919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3921. return
  3922. }
  3923. var respJSON map[string]interface{}
  3924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3927. return
  3928. }
  3929. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3930. userJSONBytes, _ := json.Marshal(userJSON)
  3931. var res ResultTwo
  3932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3933. utils.ErrorLog("解析失败:%v", err)
  3934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3935. return
  3936. }
  3937. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3938. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3939. infoStr := string(Iinfos)
  3940. idetinfoStr := string(Idetinfos)
  3941. if res.Infcode == 0 {
  3942. his := models.VMHisPatient{
  3943. Status: 1,
  3944. Ctime: time.Now().Unix(),
  3945. Mtime: time.Now().Unix(),
  3946. PsnNo: res.Output.Baseinfo.PsnNo,
  3947. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3948. Certno: res.Output.Baseinfo.Certno,
  3949. PsnName: res.Output.Baseinfo.PsnName,
  3950. Gend: res.Output.Baseinfo.Gend,
  3951. Naty: res.Output.Baseinfo.Naty,
  3952. Brdy: res.Output.Baseinfo.Brdy,
  3953. Age: res.Output.Baseinfo.Age,
  3954. Iinfo: infoStr,
  3955. Idetinfo: idetinfoStr,
  3956. UserOrgId: adminInfo.CurrentOrgId,
  3957. IsReturn: 1,
  3958. IdCardType: id_card_type,
  3959. }
  3960. c.ServeSuccessJSON(map[string]interface{}{
  3961. "info": his,
  3962. })
  3963. } else {
  3964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3965. return
  3966. }
  3967. }
  3968. }
  3969. //func GetBasBaseInfo() (jsonStr string, err error) {
  3970. //
  3971. // handle := syscall.NewLazyDLL("SSCard.dll")
  3972. // add := handle.NewProc("ReadCardBas")
  3973. // str := make([]byte, 1024)
  3974. // str1 := make([]byte, 1024)
  3975. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3976. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3977. //
  3978. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3979. //
  3980. // fmt.Println("> Add(4,5)的结果为:", ret)
  3981. // handle.Release()
  3982. //
  3983. // return "", nil
  3984. //
  3985. //}
  3986. //func GetQRBaseInfo() (jsonStr string, err error) {
  3987. // handle := syscall.LoadDLL("SSCard.dll")
  3988. // ReadCardBas := handle.FindProc("GetQRBase")
  3989. //
  3990. // str := make([]byte, 256)
  3991. // str1 := make([]byte, 256)
  3992. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3993. //
  3994. // fmt.Println(string(str))
  3995. // fmt.Println(r)
  3996. // return string(str), nil
  3997. //}
  3998. //func CardInit() int {
  3999. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  4000. // add := DllTestDef.MustFindProc("Init")
  4001. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4002. // if err != nil {
  4003. // fmt.Println("SSCard的运算结果为:", ret)
  4004. // }
  4005. // result := int(ret)
  4006. // return result
  4007. //}
  4008. //func CardInit() int {
  4009. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4010. // if err != nil {
  4011. // fmt.Println("SSCard的运算结果为:", ret)
  4012. // }
  4013. // fmt.Println(err)
  4014. // result := int(ret)
  4015. // return result
  4016. //}
  4017. func IntPtr(n int) uintptr {
  4018. return uintptr(n)
  4019. }
  4020. func StrPtr(s string) uintptr {
  4021. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  4022. }
  4023. type Result2001 struct {
  4024. Cainfo interface{} `json:"cainfo"`
  4025. ErrMsg string `json:"err_msg"`
  4026. InfRefmsgid string `json:"inf_refmsgid"`
  4027. Infcode int64 `json:"infcode"`
  4028. Output struct {
  4029. Trtinfo struct {
  4030. PsnNo string `json:"psn_no"`
  4031. TrtChkType string `json:"trt_chk_type"`
  4032. FundPayType string `json:"fund_pay_type"`
  4033. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4034. Begndate string `json:"begndate"`
  4035. Enddate string `json:"enddate"`
  4036. TrtChkRslt string `json:"trt_chk_rslt"`
  4037. } `json:"trtinfo"`
  4038. } `json:"output"`
  4039. RefmsgTime string `json:"refmsg_time"`
  4040. RespondTime string `json:"respond_time"`
  4041. Signtype interface{} `json:"signtype"`
  4042. WarnMsg interface{} `json:"warn_msg"`
  4043. }
  4044. type Result2001Org10265 struct {
  4045. Cainfo interface{} `json:"cainfo"`
  4046. ErrMsg string `json:"err_msg"`
  4047. InfRefmsgid string `json:"inf_refmsgid"`
  4048. Infcode string `json:"infcode"`
  4049. Output struct {
  4050. Trtinfo struct {
  4051. PsnNo string `json:"psn_no"`
  4052. TrtChkType string `json:"trt_chk_type"`
  4053. FundPayType string `json:"fund_pay_type"`
  4054. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4055. Begndate string `json:"begndate"`
  4056. Enddate string `json:"enddate"`
  4057. TrtChkRslt string `json:"trt_chk_rslt"`
  4058. } `json:"trtinfo"`
  4059. } `json:"output"`
  4060. RefmsgTime string `json:"refmsg_time"`
  4061. RespondTime string `json:"respond_time"`
  4062. Signtype interface{} `json:"signtype"`
  4063. WarnMsg interface{} `json:"warn_msg"`
  4064. }
  4065. type ResultTwo struct {
  4066. ErrMsg string `json:"err_msg"`
  4067. InfRefmsgid string `json:"inf_refmsgid"`
  4068. Infcode int64 `json:"infcode"`
  4069. Output struct {
  4070. Baseinfo struct {
  4071. Age float64 `json:"age"`
  4072. Brdy string `json:"brdy"`
  4073. Certno string `json:"certno"`
  4074. Gend string `json:"gend"`
  4075. Naty string `json:"naty"`
  4076. PsnCertType string `json:"psn_cert_type"`
  4077. PsnName string `json:"psn_name"`
  4078. PsnNo string `json:"psn_no"`
  4079. } `json:"baseinfo"`
  4080. Idetinfo []interface{} `json:"idetinfo"`
  4081. Iinfo []struct {
  4082. Balc float64 `json:"balc"`
  4083. CvlservFlag string `json:"cvlserv_flag"`
  4084. EmpName string `json:"emp_name"`
  4085. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4086. Insutype string `json:"insutype"`
  4087. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4088. PausInsuDate string `json:"paus_insu_date"`
  4089. PsnInsuDate string `json:"psn_insu_date"`
  4090. PsnInsuStas string `json:"psn_insu_stas"`
  4091. PsnType string `json:"psn_type"`
  4092. } `json:"insuinfo"`
  4093. } `json:"output"`
  4094. RefmsgTime string `json:"refmsg_time"`
  4095. RespondTime string `json:"respond_time"`
  4096. Signtype interface{} `json:"signtype"`
  4097. WarnInfo interface{} `json:"warn_info"`
  4098. }
  4099. type ResultTwo10265 struct {
  4100. ErrMsg string `json:"err_msg"`
  4101. InfRefmsgid string `json:"inf_refmsgid"`
  4102. Infcode string `json:"infcode"`
  4103. Output struct {
  4104. Baseinfo struct {
  4105. Age float64 `json:"age"`
  4106. Brdy string `json:"brdy"`
  4107. Certno string `json:"certno"`
  4108. Gend string `json:"gend"`
  4109. Naty string `json:"naty"`
  4110. PsnCertType string `json:"psn_cert_type"`
  4111. PsnName string `json:"psn_name"`
  4112. PsnNo string `json:"psn_no"`
  4113. } `json:"baseinfo"`
  4114. Idetinfo []interface{} `json:"idetinfo"`
  4115. Iinfo []struct {
  4116. Balc float64 `json:"balc"`
  4117. CvlservFlag string `json:"cvlserv_flag"`
  4118. EmpName string `json:"emp_name"`
  4119. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4120. Insutype string `json:"insutype"`
  4121. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4122. PausInsuDate string `json:"paus_insu_date"`
  4123. PsnInsuDate string `json:"psn_insu_date"`
  4124. PsnInsuStas string `json:"psn_insu_stas"`
  4125. PsnType string `json:"psn_type"`
  4126. } `json:"insuinfo"`
  4127. } `json:"output"`
  4128. RefmsgTime string `json:"refmsg_time"`
  4129. RespondTime string `json:"respond_time"`
  4130. Signtype interface{} `json:"signtype"`
  4131. WarnInfo interface{} `json:"warn_info"`
  4132. }
  4133. type ResultThree struct {
  4134. Cainfo interface{} `json:"cainfo"`
  4135. ErrMsg string `json:"err_msg"`
  4136. InfRefmsgid string `json:"inf_refmsgid"`
  4137. Infcode int64 `json:"infcode"`
  4138. Output struct {
  4139. Data struct {
  4140. IptOtpNo string `json:"ipt_otp_no"`
  4141. MdtrtID string `json:"mdtrt_id"`
  4142. PsnNo string `json:"psn_no"`
  4143. } `json:"data"`
  4144. } `json:"output"`
  4145. RefmsgTime string `json:"refmsg_time"`
  4146. RespondTime string `json:"respond_time"`
  4147. Signtype interface{} `json:"signtype"`
  4148. WarnMsg interface{} `json:"warn_msg"`
  4149. }
  4150. type ResultThree10265 struct {
  4151. Cainfo interface{} `json:"cainfo"`
  4152. ErrMsg string `json:"err_msg"`
  4153. InfRefmsgid string `json:"inf_refmsgid"`
  4154. Infcode string `json:"infcode"`
  4155. Output struct {
  4156. Data struct {
  4157. IptOtpNo string `json:"ipt_otp_no"`
  4158. MdtrtID string `json:"mdtrt_id"`
  4159. PsnNo string `json:"psn_no"`
  4160. } `json:"data"`
  4161. } `json:"output"`
  4162. RefmsgTime string `json:"refmsg_time"`
  4163. RespondTime string `json:"respond_time"`
  4164. Signtype interface{} `json:"signtype"`
  4165. WarnMsg interface{} `json:"warn_msg"`
  4166. }
  4167. type ResultFour struct {
  4168. Cainfo string `json:"cainfo"`
  4169. ErrMsg string `json:"err_msg"`
  4170. InfRefmsgid string `json:"inf_refmsgid"`
  4171. Infcode int64 `json:"infcode"`
  4172. Output struct {
  4173. Result []struct {
  4174. BasMednFlag string `json:"bas_medn_flag"`
  4175. ChldMedcFlag string `json:"chld_medc_flag"`
  4176. ChrgitmLv string `json:"chrgitm_lv"`
  4177. Cnt float64 `json:"cnt"`
  4178. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4179. DrtReimFlag string `json:"drt_reim_flag"`
  4180. FeedetlSn string `json:"feedetl_sn"`
  4181. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4182. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4183. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4184. ListSpItemFlag string `json:"list_sp_item_flag"`
  4185. LmtUsedFlag string `json:"lmt_used_flag"`
  4186. MedChrgitmType string `json:"med_chrgitm_type"`
  4187. Memo string `json:"memo"`
  4188. OverlmtAmt float64 `json:"overlmt_amt"`
  4189. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4190. Pric float64 `json:"pric"`
  4191. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4192. SelfpayProp float64 `json:"selfpay_prop"`
  4193. } `json:"result"`
  4194. } `json:"output"`
  4195. RefmsgTime string `json:"refmsg_time"`
  4196. RespondTime string `json:"respond_time"`
  4197. Signtype string `json:"signtype"`
  4198. WarnMsg string `json:"warn_msg"`
  4199. }
  4200. type ResultFour10265 struct {
  4201. Cainfo string `json:"cainfo"`
  4202. ErrMsg string `json:"err_msg"`
  4203. InfRefmsgid string `json:"inf_refmsgid"`
  4204. Infcode string `json:"infcode"`
  4205. Output struct {
  4206. Result []struct {
  4207. BasMednFlag string `json:"bas_medn_flag"`
  4208. ChldMedcFlag string `json:"chld_medc_flag"`
  4209. ChrgitmLv string `json:"chrgitm_lv"`
  4210. Cnt float64 `json:"cnt"`
  4211. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4212. DrtReimFlag string `json:"drt_reim_flag"`
  4213. FeedetlSn string `json:"feedetl_sn"`
  4214. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4215. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4216. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4217. ListSpItemFlag string `json:"list_sp_item_flag"`
  4218. LmtUsedFlag string `json:"lmt_used_flag"`
  4219. MedChrgitmType string `json:"med_chrgitm_type"`
  4220. Memo string `json:"memo"`
  4221. OverlmtAmt float64 `json:"overlmt_amt"`
  4222. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4223. Pric float64 `json:"pric"`
  4224. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4225. SelfpayProp float64 `json:"selfpay_prop"`
  4226. } `json:"result"`
  4227. } `json:"output"`
  4228. RefmsgTime string `json:"refmsg_time"`
  4229. RespondTime string `json:"respond_time"`
  4230. Signtype string `json:"signtype"`
  4231. WarnMsg string `json:"warn_msg"`
  4232. }
  4233. type ResultFive struct {
  4234. Balc float64 `json:"balc"`
  4235. CvlservFlag string `json:"cvlserv_flag"`
  4236. EmpName string `json:"emp_name"`
  4237. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4238. Insutype string `json:"insutype"`
  4239. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4240. PausInsuDate string `json:"paus_insu_date"`
  4241. PsnInsuDate string `json:"psn_insu_date"`
  4242. PsnInsuStas string `json:"psn_insu_stas"`
  4243. PsnType string `json:"psn_type"`
  4244. }
  4245. type ResultSix struct {
  4246. Cainfo interface{} `json:"cainfo"`
  4247. ErrMsg string `json:"err_msg"`
  4248. InfRefmsgid string `json:"inf_refmsgid"`
  4249. Infcode int64 `json:"infcode"`
  4250. Output struct {
  4251. } `json:"output"`
  4252. RefmsgTime string `json:"refmsg_time"`
  4253. RespondTime string `json:"respond_time"`
  4254. Signtype interface{} `json:"signtype"`
  4255. WarnMsg interface{} `json:"warn_msg"`
  4256. }
  4257. type ResultSix10265 struct {
  4258. Cainfo interface{} `json:"cainfo"`
  4259. ErrMsg string `json:"err_msg"`
  4260. InfRefmsgid string `json:"inf_refmsgid"`
  4261. Infcode string `json:"infcode"`
  4262. Output struct {
  4263. } `json:"output"`
  4264. RefmsgTime string `json:"refmsg_time"`
  4265. RespondTime string `json:"respond_time"`
  4266. Signtype interface{} `json:"signtype"`
  4267. WarnMsg interface{} `json:"warn_msg"`
  4268. }
  4269. type ResultSeven struct {
  4270. Cainfo string `json:"cainfo"`
  4271. ErrMsg string `json:"err_msg"`
  4272. InfRefmsgid string `json:"inf_refmsgid"`
  4273. Infcode int64 `json:"infcode"`
  4274. Output struct {
  4275. Setldetail []interface{} `json:"setldetail"`
  4276. Setlinfo struct {
  4277. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4278. AcctPay float64 `json:"acct_pay"`
  4279. ActPayDedc float64 `json:"act_pay_dedc"`
  4280. Age float64 `json:"age"`
  4281. Balc float64 `json:"balc"`
  4282. Brdy string `json:"brdy"`
  4283. Certno string `json:"certno"`
  4284. ClrOptins string `json:"clr_optins"`
  4285. ClrType string `json:"clr_type"`
  4286. ClrWay string `json:"clr_way"`
  4287. CvlservFlag string `json:"cvlserv_flag"`
  4288. CvlservPay float64 `json:"cvlserv_pay"`
  4289. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4290. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4291. Gend string `json:"gend"`
  4292. HifesPay float64 `json:"hifes_pay"`
  4293. HifmiPay float64 `json:"hifmi_pay"`
  4294. HifpPay float64 `json:"hifp_pay"`
  4295. HospPartAmt float64 `json:"hosp_part_amt"`
  4296. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4297. Insutype string `json:"insutype"`
  4298. MafPay float64 `json:"maf_pay"`
  4299. MdtrtCertType string `json:"mdtrt_cert_type"`
  4300. HifobPay float64 `json:"hifob_pay"`
  4301. MdtrtID string `json:"mdtrt_id"`
  4302. MedType string `json:"med_type"`
  4303. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4304. MedinsSetlID string `json:"medins_setl_id"`
  4305. Naty string `json:"naty"`
  4306. OthPay float64 `json:"oth_pay"`
  4307. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4308. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4309. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4310. PsnCashPay float64 `json:"psn_cash_pay"`
  4311. PsnCertType string `json:"psn_cert_type"`
  4312. PsnName string `json:"psn_name"`
  4313. PsnNo string `json:"psn_no"`
  4314. PsnPartAmt float64 `json:"psn_part_amt"`
  4315. PsnType string `json:"psn_type"`
  4316. SetlID string `json:"setl_id"`
  4317. SetlTime string `json:"setl_time"`
  4318. } `json:"setlinfo"`
  4319. } `json:"output"`
  4320. RefmsgTime string `json:"refmsg_time"`
  4321. RespondTime string `json:"respond_time"`
  4322. Signtype interface{} `json:"signtype"`
  4323. WarnMsg interface{} `json:"warn_msg"`
  4324. }
  4325. type ResultSeven10265 struct {
  4326. Cainfo string `json:"cainfo"`
  4327. ErrMsg string `json:"err_msg"`
  4328. InfRefmsgid string `json:"inf_refmsgid"`
  4329. Infcode string `json:"infcode"`
  4330. Output struct {
  4331. Setldetail []interface{} `json:"setldetail"`
  4332. Setlinfo struct {
  4333. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4334. AcctPay float64 `json:"acct_pay"`
  4335. ActPayDedc float64 `json:"act_pay_dedc"`
  4336. Age float64 `json:"age"`
  4337. Balc float64 `json:"balc"`
  4338. Brdy string `json:"brdy"`
  4339. Certno string `json:"certno"`
  4340. ClrOptins string `json:"clr_optins"`
  4341. ClrType string `json:"clr_type"`
  4342. ClrWay string `json:"clr_way"`
  4343. CvlservFlag string `json:"cvlserv_flag"`
  4344. CvlservPay float64 `json:"cvlserv_pay"`
  4345. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4346. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4347. Gend string `json:"gend"`
  4348. HifesPay float64 `json:"hifes_pay"`
  4349. HifmiPay float64 `json:"hifmi_pay"`
  4350. HifpPay float64 `json:"hifp_pay"`
  4351. HospPartAmt float64 `json:"hosp_part_amt"`
  4352. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4353. Insutype string `json:"insutype"`
  4354. MafPay float64 `json:"maf_pay"`
  4355. MdtrtCertType string `json:"mdtrt_cert_type"`
  4356. HifobPay float64 `json:"hifob_pay"`
  4357. MdtrtID string `json:"mdtrt_id"`
  4358. MedType string `json:"med_type"`
  4359. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4360. MedinsSetlID string `json:"medins_setl_id"`
  4361. Naty string `json:"naty"`
  4362. OthPay float64 `json:"oth_pay"`
  4363. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4364. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4365. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4366. PsnCashPay float64 `json:"psn_cash_pay"`
  4367. PsnCertType string `json:"psn_cert_type"`
  4368. PsnName string `json:"psn_name"`
  4369. PsnNo string `json:"psn_no"`
  4370. PsnPartAmt float64 `json:"psn_part_amt"`
  4371. PsnType string `json:"psn_type"`
  4372. SetlID string `json:"setl_id"`
  4373. SetlTime string `json:"setl_time"`
  4374. } `json:"setlinfo"`
  4375. } `json:"output"`
  4376. RefmsgTime string `json:"refmsg_time"`
  4377. RespondTime string `json:"respond_time"`
  4378. Signtype interface{} `json:"signtype"`
  4379. WarnMsg interface{} `json:"warn_msg"`
  4380. }
  4381. type ResultEight struct {
  4382. Cainfo string `json:"cainfo"`
  4383. ErrMsg string `json:"err_msg"`
  4384. InfRefmsgid string `json:"inf_refmsgid"`
  4385. Infcode int64 `json:"infcode"`
  4386. Output struct {
  4387. Stmtinfo struct {
  4388. SetlOptins string `json:"setl_optins"`
  4389. StmtRslt string `json:"stmt_rslt"`
  4390. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4391. } `json:"stmtinfo"`
  4392. } `json:"output"`
  4393. RefmsgTime string `json:"refmsg_time"`
  4394. RespondTime string `json:"respond_time"`
  4395. Signtype interface{} `json:"signtype"`
  4396. WarnMsg interface{} `json:"warn_msg"`
  4397. }
  4398. type ResultEightFor10188 struct {
  4399. Cainfo string `json:"cainfo"`
  4400. ErrMsg string `json:"err_msg"`
  4401. InfRefmsgid string `json:"inf_refmsgid"`
  4402. Infcode string `json:"infcode"`
  4403. Output struct {
  4404. Stmtinfo struct {
  4405. SetlOptins string `json:"setl_optins"`
  4406. StmtRslt string `json:"stmt_rslt"`
  4407. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4408. } `json:"stmtinfo"`
  4409. } `json:"output"`
  4410. RefmsgTime string `json:"refmsg_time"`
  4411. RespondTime string `json:"respond_time"`
  4412. Signtype interface{} `json:"signtype"`
  4413. WarnMsg interface{} `json:"warn_msg"`
  4414. }
  4415. type ResultNine struct {
  4416. Cainfo string `json:"cainfo"`
  4417. ErrMsg string `json:"err_msg"`
  4418. InfRefmsgid string `json:"inf_refmsgid"`
  4419. Infcode int64 `json:"infcode"`
  4420. Output struct {
  4421. FileQuryNo string `json:"file_qury_no"`
  4422. } `json:"output"`
  4423. RefmsgTime string `json:"refmsg_time"`
  4424. RespondTime string `json:"respond_time"`
  4425. Signtype interface{} `json:"signtype"`
  4426. WarnMsg interface{} `json:"warn_msg"`
  4427. }
  4428. type ResultTen struct {
  4429. Cainfo string `json:"cainfo"`
  4430. ErrMsg string `json:"err_msg"`
  4431. InfRefmsgid string `json:"inf_refmsgid"`
  4432. Infcode int64 `json:"infcode"`
  4433. Output struct {
  4434. DldEndtime string `json:"dld_endtime"`
  4435. FileQuryNo string `json:"file_qury_no"`
  4436. Filename string `json:"filename"`
  4437. } `json:"output"`
  4438. RefmsgTime string `json:"refmsg_time"`
  4439. RespondTime string `json:"respond_time"`
  4440. Signtype interface{} `json:"signtype"`
  4441. WarnMsg interface{} `json:"warn_msg"`
  4442. }
  4443. //type Autogenerated struct {
  4444. // Output struct {
  4445. // Setlinfo struct {
  4446. // SetlTime string `json:"setl_time"`
  4447. // CvlservPay float64 `json:"cvlserv_pay"`
  4448. // Year string `json:"year"`
  4449. // MedType string `json:"med_type"`
  4450. // PsnPay float64 `json:"psn_pay"`
  4451. // OpterID string `json:"opter_id"`
  4452. // Begndate string `json:"begndate"`
  4453. // FlxempeFlag string `json:"flxempe_flag"`
  4454. // HifmiPay float64 `json:"hifmi_pay"`
  4455. // PsnNo string `json:"psn_no"`
  4456. // ActPayDedc float64 `json:"act_pay_dedc"`
  4457. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4458. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4459. // ClrWay string `json:"clr_way"`
  4460. // OthPay float64 `json:"oth_pay"`
  4461. // Gend string `json:"gend"`
  4462. // MdtrtID string `json:"mdtrt_id"`
  4463. // AcctPay float64 `json:"acct_pay"`
  4464. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4465. // Insutype string `json:"insutype"`
  4466. // Invono interface{} `json:"invono"`
  4467. // Enddate string `json:"enddate"`
  4468. // CashPayamt float64 `json:"cash_payamt"`
  4469. // PsnType string `json:"psn_type"`
  4470. // FixmedinsName string `json:"fixmedins_name"`
  4471. // HifpPay float64 `json:"hifp_pay"`
  4472. // NewFlag interface{} `json:"new_flag"`
  4473. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4474. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4475. // PayLoc string `json:"pay_loc"`
  4476. // ClrType string `json:"clr_type"`
  4477. // RefdSetlFlag string `json:"refd_setl_flag"`
  4478. // CvlservFlag string `json:"cvlserv_flag"`
  4479. // EmpName string `json:"emp_name"`
  4480. // Brdy string `json:"brdy"`
  4481. // Naty string `json:"naty"`
  4482. // Certno string `json:"certno"`
  4483. // DiseCode string `json:"dise_code"`
  4484. // FixmedinsCode string `json:"fixmedins_code"`
  4485. // DedcHospLv string `json:"dedc_hosp_lv"`
  4486. // OpterName string `json:"opter_name"`
  4487. // Balc float64 `json:"balc"`
  4488. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4489. // PsnCertType string `json:"psn_cert_type"`
  4490. // HifobPay float64 `json:"hifob_pay"`
  4491. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4492. // HifesPay float64 `json:"hifes_pay"`
  4493. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4494. // OptTime string `json:"opt_time"`
  4495. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4496. // SetlID string `json:"setl_id"`
  4497. // MafPay float64 `json:"maf_pay"`
  4498. // PsnName string `json:"psn_name"`
  4499. // InsuOptins interface{} `json:"insu_optins"`
  4500. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4501. // ClrOptins string `json:"clr_optins"`
  4502. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4503. // DiseName string `json:"dise_name"`
  4504. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4505. // Age float64 `json:"age"`
  4506. // DtrtCertType string `json:"dtrt_cert_type"`
  4507. // HospLv string `json:"hosp_lv"`
  4508. // } `json:"setlinfo"`
  4509. // Setldetail []struct {
  4510. // FundPayType string `json:"fund_pay_type"`
  4511. // FundPayamt float64 `json:"fund_payamt"`
  4512. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4513. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4514. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4515. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4516. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4517. // } `json:"setldetail"`
  4518. // } `json:"output"`
  4519. // Infcode int `json:"infcode"`
  4520. // WarnMsg interface{} `json:"warn_msg"`
  4521. // Cainfo interface{} `json:"cainfo"`
  4522. // ErrMsg interface{} `json:"err_msg"`
  4523. // RefmsgTime string `json:"refmsg_time"`
  4524. // Signtype interface{} `json:"signtype"`
  4525. // RespondTime string `json:"respond_time"`
  4526. // InfRefmsgid string `json:"inf_refmsgid"`
  4527. //}
  4528. type ResultEleven struct {
  4529. Cainfo string `json:"cainfo"`
  4530. ErrMsg string `json:"err_msg"`
  4531. InfRefmsgid string `json:"inf_refmsgid"`
  4532. Infcode int64 `json:"infcode"`
  4533. Output struct {
  4534. Setlinfo struct {
  4535. SetlTime string `json:"setl_time"`
  4536. CvlservPay float64 `json:"cvlserv_pay"`
  4537. Year string `json:"year"`
  4538. MedType string `json:"med_type"`
  4539. PsnPay float64 `json:"psn_pay"`
  4540. OpterID string `json:"opter_id"`
  4541. Begndate string `json:"begndate"`
  4542. FlxempeFlag string `json:"flxempe_flag"`
  4543. HifmiPay float64 `json:"hifmi_pay"`
  4544. PsnNo string `json:"psn_no"`
  4545. ActPayDedc float64 `json:"act_pay_dedc"`
  4546. MedinsSetlID interface{} `json:"medins_setl_id"`
  4547. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4548. ClrWay string `json:"clr_way"`
  4549. OthPay float64 `json:"oth_pay"`
  4550. Gend string `json:"gend"`
  4551. MdtrtID string `json:"mdtrt_id"`
  4552. AcctPay float64 `json:"acct_pay"`
  4553. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4554. Insutype string `json:"insutype"`
  4555. Invono interface{} `json:"invono"`
  4556. Enddate string `json:"enddate"`
  4557. CashPayamt float64 `json:"cash_payamt"`
  4558. PsnType string `json:"psn_type"`
  4559. FixmedinsName string `json:"fixmedins_name"`
  4560. HifpPay float64 `json:"hifp_pay"`
  4561. NewFlag interface{} `json:"new_flag"`
  4562. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4563. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4564. PayLoc string `json:"pay_loc"`
  4565. ClrType string `json:"clr_type"`
  4566. RefdSetlFlag string `json:"refd_setl_flag"`
  4567. CvlservFlag string `json:"cvlserv_flag"`
  4568. EmpName string `json:"emp_name"`
  4569. Brdy string `json:"brdy"`
  4570. Naty string `json:"naty"`
  4571. Certno string `json:"certno"`
  4572. DiseCode string `json:"dise_code"`
  4573. FixmedinsCode string `json:"fixmedins_code"`
  4574. DedcHospLv string `json:"dedc_hosp_lv"`
  4575. OpterName string `json:"opter_name"`
  4576. Balc float64 `json:"balc"`
  4577. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4578. PsnCertType string `json:"psn_cert_type"`
  4579. HifobPay float64 `json:"hifob_pay"`
  4580. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4581. HifesPay float64 `json:"hifes_pay"`
  4582. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4583. OptTime string `json:"opt_time"`
  4584. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4585. SetlID string `json:"setl_id"`
  4586. MafPay float64 `json:"maf_pay"`
  4587. PsnName string `json:"psn_name"`
  4588. InsuOptins interface{} `json:"insu_optins"`
  4589. PrefFundPay interface{} `json:"pref_fund_pay"`
  4590. ClrOptins string `json:"clr_optins"`
  4591. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4592. DiseName string `json:"dise_name"`
  4593. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4594. Age float64 `json:"age"`
  4595. DtrtCertType string `json:"dtrt_cert_type"`
  4596. HospLv string `json:"hosp_lv"`
  4597. } `json:"setlinfo"`
  4598. } `json:"output"`
  4599. RefmsgTime string `json:"refmsg_time"`
  4600. RespondTime string `json:"respond_time"`
  4601. Signtype interface{} `json:"signtype"`
  4602. WarnMsg interface{} `json:"warn_msg"`
  4603. }
  4604. type ResultEleven10265 struct {
  4605. Cainfo string `json:"cainfo"`
  4606. ErrMsg string `json:"err_msg"`
  4607. InfRefmsgid string `json:"inf_refmsgid"`
  4608. Infcode string `json:"infcode"`
  4609. Output struct {
  4610. Setlinfo struct {
  4611. SetlTime string `json:"setl_time"`
  4612. CvlservPay float64 `json:"cvlserv_pay"`
  4613. Year string `json:"year"`
  4614. MedType string `json:"med_type"`
  4615. PsnPay float64 `json:"psn_pay"`
  4616. OpterID string `json:"opter_id"`
  4617. Begndate string `json:"begndate"`
  4618. FlxempeFlag string `json:"flxempe_flag"`
  4619. HifmiPay float64 `json:"hifmi_pay"`
  4620. PsnNo string `json:"psn_no"`
  4621. ActPayDedc float64 `json:"act_pay_dedc"`
  4622. MedinsSetlID interface{} `json:"medins_setl_id"`
  4623. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4624. ClrWay string `json:"clr_way"`
  4625. OthPay float64 `json:"oth_pay"`
  4626. Gend string `json:"gend"`
  4627. MdtrtID string `json:"mdtrt_id"`
  4628. AcctPay float64 `json:"acct_pay"`
  4629. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4630. Insutype string `json:"insutype"`
  4631. Invono interface{} `json:"invono"`
  4632. Enddate string `json:"enddate"`
  4633. CashPayamt float64 `json:"cash_payamt"`
  4634. PsnType string `json:"psn_type"`
  4635. FixmedinsName string `json:"fixmedins_name"`
  4636. HifpPay float64 `json:"hifp_pay"`
  4637. NewFlag interface{} `json:"new_flag"`
  4638. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4639. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4640. PayLoc string `json:"pay_loc"`
  4641. ClrType string `json:"clr_type"`
  4642. RefdSetlFlag string `json:"refd_setl_flag"`
  4643. CvlservFlag string `json:"cvlserv_flag"`
  4644. EmpName string `json:"emp_name"`
  4645. Brdy string `json:"brdy"`
  4646. Naty string `json:"naty"`
  4647. Certno string `json:"certno"`
  4648. DiseCode string `json:"dise_code"`
  4649. FixmedinsCode string `json:"fixmedins_code"`
  4650. DedcHospLv string `json:"dedc_hosp_lv"`
  4651. OpterName string `json:"opter_name"`
  4652. Balc float64 `json:"balc"`
  4653. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4654. PsnCertType string `json:"psn_cert_type"`
  4655. HifobPay float64 `json:"hifob_pay"`
  4656. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4657. HifesPay float64 `json:"hifes_pay"`
  4658. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4659. OptTime string `json:"opt_time"`
  4660. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4661. SetlID string `json:"setl_id"`
  4662. MafPay float64 `json:"maf_pay"`
  4663. PsnName string `json:"psn_name"`
  4664. InsuOptins interface{} `json:"insu_optins"`
  4665. PrefFundPay interface{} `json:"pref_fund_pay"`
  4666. ClrOptins string `json:"clr_optins"`
  4667. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4668. DiseName string `json:"dise_name"`
  4669. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4670. Age float64 `json:"age"`
  4671. DtrtCertType string `json:"dtrt_cert_type"`
  4672. HospLv string `json:"hosp_lv"`
  4673. } `json:"setlinfo"`
  4674. } `json:"output"`
  4675. RefmsgTime string `json:"refmsg_time"`
  4676. RespondTime string `json:"respond_time"`
  4677. Signtype interface{} `json:"signtype"`
  4678. WarnMsg interface{} `json:"warn_msg"`
  4679. }
  4680. type ResultTwelve struct {
  4681. Cainfo string `json:"cainfo"`
  4682. ErrMsg string `json:"err_msg"`
  4683. InfRefmsgid string `json:"inf_refmsgid"`
  4684. Infcode int64 `json:"infcode"`
  4685. Output struct {
  4686. MdtrtId string `json:"mdtrt_id"`
  4687. ChrgBchno string `json:"chrg_bchno"`
  4688. PsnNo string `json:"psn_no"`
  4689. } `json:"output"`
  4690. RefmsgTime string `json:"refmsg_time"`
  4691. RespondTime string `json:"respond_time"`
  4692. Signtype interface{} `json:"signtype"`
  4693. WarnMsg interface{} `json:"warn_msg"`
  4694. }
  4695. type ResultThirteen struct {
  4696. ErrMsg string `json:"err_msg"`
  4697. InfRefmsgid string `json:"inf_refmsgid"`
  4698. Infcode int64 `json:"infcode"`
  4699. Output struct {
  4700. Result struct {
  4701. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4702. } `json:"result"`
  4703. } `json:"output"`
  4704. RefmsgTime string `json:"refmsg_time"`
  4705. RespondTime string `json:"respond_time"`
  4706. Signtype interface{} `json:"signtype"`
  4707. WarnInfo interface{} `json:"warn_info"`
  4708. }
  4709. type ResultThirteen10265 struct {
  4710. ErrMsg string `json:"err_msg"`
  4711. InfRefmsgid string `json:"inf_refmsgid"`
  4712. Infcode string `json:"infcode"`
  4713. Output struct {
  4714. Result struct {
  4715. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4716. } `json:"result"`
  4717. } `json:"output"`
  4718. RefmsgTime string `json:"refmsg_time"`
  4719. RespondTime string `json:"respond_time"`
  4720. Signtype interface{} `json:"signtype"`
  4721. WarnInfo interface{} `json:"warn_info"`
  4722. }
  4723. type ResultFourteen struct {
  4724. ErrMsg string `json:"err_msg"`
  4725. InfRefmsgid string `json:"inf_refmsgid"`
  4726. Infcode int64 `json:"infcode"`
  4727. Output struct {
  4728. } `json:"output"`
  4729. RefmsgTime string `json:"refmsg_time"`
  4730. RespondTime string `json:"respond_time"`
  4731. Signtype interface{} `json:"signtype"`
  4732. WarnInfo interface{} `json:"warn_info"`
  4733. }
  4734. type ResultFourteen10265 struct {
  4735. ErrMsg string `json:"err_msg"`
  4736. InfRefmsgid string `json:"inf_refmsgid"`
  4737. Infcode string `json:"infcode"`
  4738. Output struct {
  4739. } `json:"output"`
  4740. RefmsgTime string `json:"refmsg_time"`
  4741. RespondTime string `json:"respond_time"`
  4742. Signtype interface{} `json:"signtype"`
  4743. WarnInfo interface{} `json:"warn_info"`
  4744. }
  4745. type ResultSixteen struct {
  4746. Cainfo string `json:"cainfo"`
  4747. ErrMsg string `json:"err_msg"`
  4748. InfRefmsgid string `json:"inf_refmsgid"`
  4749. Infcode int64 `json:"infcode"`
  4750. Output struct {
  4751. Setldetail []interface{} `json:"setldetail"`
  4752. Setlinfo struct {
  4753. MdtrtID string `json:"mdtrt_id"`
  4754. SetlID string `json:"setl_id"`
  4755. ClrOptins string `json:"clr_optins"`
  4756. SetlTime string `json:"setl_time"`
  4757. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4758. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4759. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4760. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4761. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4762. ActPayDedc float64 `json:"act_pay_dedc"`
  4763. HifpPay float64 `json:"hifp_pay"`
  4764. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4765. Lfpay float64 `json:"selfpay"`
  4766. CvlservPay float64 `json:"cvlserv_pay"`
  4767. HifesPay float64 `json:"hifes_pay"`
  4768. HifmiPay float64 `json:"hifmi_pay"`
  4769. HifobPay float64 `json:"hifob_pay"`
  4770. MafPay float64 `json:"maf_pay"`
  4771. OthPay float64 `json:"oth_pay"`
  4772. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4773. PsnPartAmt float64 `json:"psn_part_amt"`
  4774. AcctPay float64 `json:"acct_pay"`
  4775. Balc float64 `json:"balc"`
  4776. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4777. HospPartAmt float64 `json:"hosp_part_amt"`
  4778. MedinsSetlID string `json:"medins_setl_id"`
  4779. PdnCashPay string `json:"pdn_cash_pay"`
  4780. } `json:"setlinfo"`
  4781. } `json:"output"`
  4782. RefmsgTime string `json:"refmsg_time"`
  4783. RespondTime string `json:"respond_time"`
  4784. Signtype interface{} `json:"signtype"`
  4785. WarnMsg interface{} `json:"warn_msg"`
  4786. }
  4787. type ResultSixteen10265 struct {
  4788. Cainfo string `json:"cainfo"`
  4789. ErrMsg string `json:"err_msg"`
  4790. InfRefmsgid string `json:"inf_refmsgid"`
  4791. Infcode string `json:"infcode"`
  4792. Output struct {
  4793. Setldetail []interface{} `json:"setldetail"`
  4794. Setlinfo struct {
  4795. MdtrtID string `json:"mdtrt_id"`
  4796. SetlID string `json:"setl_id"`
  4797. ClrOptins string `json:"clr_optins"`
  4798. SetlTime string `json:"setl_time"`
  4799. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4800. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4801. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4802. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4803. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4804. ActPayDedc float64 `json:"act_pay_dedc"`
  4805. HifpPay float64 `json:"hifp_pay"`
  4806. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4807. Lfpay float64 `json:"selfpay"`
  4808. CvlservPay float64 `json:"cvlserv_pay"`
  4809. HifesPay float64 `json:"hifes_pay"`
  4810. HifmiPay float64 `json:"hifmi_pay"`
  4811. HifobPay float64 `json:"hifob_pay"`
  4812. MafPay float64 `json:"maf_pay"`
  4813. OthPay float64 `json:"oth_pay"`
  4814. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4815. PsnPartAmt float64 `json:"psn_part_amt"`
  4816. AcctPay float64 `json:"acct_pay"`
  4817. Balc float64 `json:"balc"`
  4818. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4819. HospPartAmt float64 `json:"hosp_part_amt"`
  4820. MedinsSetlID string `json:"medins_setl_id"`
  4821. PdnCashPay string `json:"pdn_cash_pay"`
  4822. } `json:"setlinfo"`
  4823. } `json:"output"`
  4824. RefmsgTime string `json:"refmsg_time"`
  4825. RespondTime string `json:"respond_time"`
  4826. Signtype interface{} `json:"signtype"`
  4827. WarnMsg interface{} `json:"warn_msg"`
  4828. }
  4829. type ResultSeventeen struct {
  4830. ErrMsg string `json:"err_msg"`
  4831. InfRefmsgid string `json:"inf_refmsgid"`
  4832. Infcode int64 `json:"infcode"`
  4833. Output struct {
  4834. SetlListId string `json:"setl_list_id"`
  4835. } `json:"output"`
  4836. RefmsgTime string `json:"refmsg_time"`
  4837. RespondTime string `json:"respond_time"`
  4838. Signtype string `json:"signtype"`
  4839. WarnInfo string `json:"warn_info"`
  4840. }
  4841. type ResultSeventeenOther struct {
  4842. ErrMsg string `json:"err_msg"`
  4843. InfRefmsgid string `json:"inf_refmsgid"`
  4844. Infcode string `json:"infcode"`
  4845. Output struct {
  4846. SetlListId string `json:"setl_list_id"`
  4847. } `json:"output"`
  4848. RefmsgTime string `json:"refmsg_time"`
  4849. RespondTime string `json:"respond_time"`
  4850. Signtype string `json:"signtype"`
  4851. WarnInfo string `json:"warn_info"`
  4852. }
  4853. type Result90991 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. PsnNo string `json:"psn_no"`
  4860. CardStat string `json:"card_stat"`
  4861. Certno string `json:"certno"`
  4862. PsnName string `json:"psn_name"`
  4863. CheckStat string `json:"check_stat"`
  4864. SscnoCheckStat string `json:"sscno_check_stat"`
  4865. } `json:"result"`
  4866. } `json:"output"`
  4867. RefmsgTime string `json:"refmsg_time"`
  4868. RespondTime string `json:"respond_time"`
  4869. Signtype interface{} `json:"signtype"`
  4870. WarnInfo interface{} `json:"warn_info"`
  4871. }
  4872. type Result90100 struct {
  4873. ErrMsg string `json:"err_msg"`
  4874. InfRefmsgid string `json:"inf_refmsgid"`
  4875. Infcode int64 `json:"infcode"`
  4876. Output struct {
  4877. PoolareaNo string `json:"poolarea_no"`
  4878. PoolareaNoName string `json:"poolarea_no_name"`
  4879. Insutype string `json:"insutype"`
  4880. InsutypeName string `json:"insutype_name"`
  4881. ClctType string `json:"clct_type"`
  4882. ClctTypeName string `json:"clct_type_name"`
  4883. ClctFlag string `json:"clct_flag"`
  4884. ClctFlagName string `json:"clct_flag_name"`
  4885. AccrymBegn string `json:"accrym_begn"`
  4886. AccrymEnd string `json:"accrym_end"`
  4887. ClctTime string `json:"clct_time"`
  4888. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4889. } `json:"output"`
  4890. RefmsgTime string `json:"refmsg_time"`
  4891. RespondTime string `json:"respond_time"`
  4892. Signtype interface{} `json:"signtype"`
  4893. WarnInfo interface{} `json:"warn_info"`
  4894. }
  4895. type Custom struct {
  4896. DetItemFeeSumamt string
  4897. Cut string
  4898. FeedetlSn string
  4899. Price string
  4900. MedListCodg string
  4901. Type int64
  4902. AdviceId int64
  4903. ProjectId int64
  4904. ItemId int64
  4905. }
  4906. type Result5301 struct {
  4907. ErrMsg string `json:"err_msg"`
  4908. InfRefmsgid string `json:"inf_refmsgid"`
  4909. Infcode int64 `json:"infcode"`
  4910. Output struct {
  4911. Result []struct {
  4912. OpspDiseCode string `json:"opsp_dise_code"`
  4913. OpspDiseName string `json:"opsp_dise_name"`
  4914. Begndate string `json:"begndate"`
  4915. Enddate string `json:"enddate"`
  4916. } `json:"feedetail"`
  4917. } `json:"output"`
  4918. RefmsgTime string `json:"refmsg_time"`
  4919. RespondTime string `json:"respond_time"`
  4920. Signtype interface{} `json:"signtype"`
  4921. WarnInfo interface{} `json:"warn_info"`
  4922. }
  4923. type Result5301For10265 struct {
  4924. ErrMsg string `json:"err_msg"`
  4925. InfRefmsgid string `json:"inf_refmsgid"`
  4926. Infcode string `json:"infcode"`
  4927. Output struct {
  4928. Result []struct {
  4929. OpspDiseCode string `json:"opsp_dise_code"`
  4930. OpspDiseName string `json:"opsp_dise_name"`
  4931. Begndate string `json:"begndate"`
  4932. Enddate string `json:"enddate"`
  4933. } `json:"feedetail"`
  4934. } `json:"output"`
  4935. RefmsgTime string `json:"refmsg_time"`
  4936. RespondTime string `json:"respond_time"`
  4937. Signtype interface{} `json:"signtype"`
  4938. WarnInfo interface{} `json:"warn_info"`
  4939. }
  4940. //获取个人信息----挂号-----上传就诊信息
  4941. func (c *HisApiController) GetRegisterInfo() {
  4942. id, _ := c.GetInt64("id")
  4943. record_time := c.GetString("record_time")
  4944. settlementValue, _ := c.GetInt64("settlement_value")
  4945. medical_insurance_card := c.GetString("medical_insurance_card")
  4946. name := c.GetString("name")
  4947. id_card_type, _ := c.GetInt64("id_card_type")
  4948. certificates, _ := c.GetInt64("certificates")
  4949. medical_care, _ := c.GetInt64("medical_care")
  4950. birthday := c.GetString("birthday")
  4951. id_card := c.GetString("id_card")
  4952. register_type, _ := c.GetInt64("register")
  4953. doctor, _ := c.GetInt64("doctor")
  4954. department, _ := c.GetInt64("department")
  4955. gender, _ := c.GetInt64("sex")
  4956. registration_fee, _ := c.GetFloat("registration_fee")
  4957. medical_expenses, _ := c.GetFloat("medical_expenses")
  4958. social_type, _ := c.GetInt64("social_type")
  4959. med_type := c.GetString("social_type")
  4960. admin_user_id, _ := c.GetInt64("admin_user_id")
  4961. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4962. timeLayout := "2006-01-02"
  4963. loc, _ := time.LoadLocation("Local")
  4964. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4965. birthUnix := birthdays.Unix()
  4966. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4967. if err != nil {
  4968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4969. return
  4970. }
  4971. recordDateTime := theTime.Unix()
  4972. adminInfo := c.GetAdminUserInfo()
  4973. var patient service.Patients
  4974. if id == 0 {
  4975. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4976. } else {
  4977. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4978. }
  4979. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4980. if patientPrescription.ID == 0 {
  4981. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4982. }
  4983. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4984. if patient.ID == 0 {
  4985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4986. return
  4987. }
  4988. if len(patient.IdCardNo) == 0 {
  4989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4990. return
  4991. }
  4992. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4993. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4994. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4995. //就诊结算未完成,不能进行二次挂号
  4996. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4997. if len(his) >= 1 {
  4998. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4999. if len(his) >= 1 && order.ID == 0 {
  5000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  5001. return
  5002. }
  5003. }
  5004. //var register_log string
  5005. if config.IsOpen == 1 {
  5006. var res ResultTwo
  5007. var res10265 ResultTwo10265
  5008. var PsnNo string
  5009. var PsnCertType string
  5010. var Certno string
  5011. var PsnName string
  5012. var Gend string
  5013. var Naty string
  5014. var Brdy string
  5015. var Age float64
  5016. var infoStr string
  5017. var idetinfoStr string
  5018. var infocode int64
  5019. var verify_number string
  5020. fmt.Println(verify_number)
  5021. if miConfig.MdtrtareaAdmvs == "421300" {
  5022. psn_info, _ := service.GetPsnByPatientId(id)
  5023. PsnNo = psn_info.PsnNo
  5024. PsnCertType = psn_info.PsnCertType
  5025. Certno = psn_info.Certno
  5026. PsnName = psn_info.PsnName
  5027. Gend = psn_info.Gend
  5028. Naty = psn_info.Naty
  5029. Brdy = psn_info.Brdy
  5030. Age = psn_info.Age
  5031. infoStr = psn_info.Insuinfo
  5032. idetinfoStr = psn_info.Idetinfo
  5033. infocode = 0
  5034. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5035. psn_info, _ := service.GetPsnByPatientId(id)
  5036. PsnNo = psn_info.PsnNo
  5037. PsnCertType = psn_info.PsnCertType
  5038. Certno = psn_info.Certno
  5039. PsnName = psn_info.PsnName
  5040. Gend = psn_info.Gend
  5041. Naty = psn_info.Naty
  5042. Brdy = psn_info.Brdy
  5043. Age = psn_info.Age
  5044. infoStr = psn_info.Insuinfo
  5045. idetinfoStr = psn_info.Idetinfo
  5046. infocode = 0
  5047. verify_number = psn_info.VerifyNumber
  5048. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5049. if id_card_type == 1 {
  5050. psn_info, _ := service.GetPsnByPatientId(id)
  5051. PsnNo = psn_info.PsnNo
  5052. PsnCertType = psn_info.PsnCertType
  5053. Certno = psn_info.Certno
  5054. PsnName = psn_info.PsnName
  5055. Gend = psn_info.Gend
  5056. Naty = psn_info.Naty
  5057. Brdy = psn_info.Brdy
  5058. Age = psn_info.Age
  5059. infoStr = psn_info.Insuinfo
  5060. idetinfoStr = psn_info.Idetinfo
  5061. infocode = 0
  5062. verify_number = psn_info.VerifyNumber
  5063. } else if id_card_type == 2 {
  5064. 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)
  5065. fmt.Println(errMsgLog)
  5066. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5067. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5068. utils.ErrorLog("解析失败:%v", err)
  5069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5070. return
  5071. }
  5072. PsnNo = res.Output.Baseinfo.PsnNo
  5073. PsnCertType = res.Output.Baseinfo.PsnCertType
  5074. Certno = res.Output.Baseinfo.Certno
  5075. PsnName = res.Output.Baseinfo.PsnName
  5076. Gend = res.Output.Baseinfo.Gend
  5077. Naty = res.Output.Baseinfo.Naty
  5078. Brdy = res.Output.Baseinfo.Brdy
  5079. Age = res.Output.Baseinfo.Age
  5080. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5081. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5082. infoStr = string(Iinfos)
  5083. idetinfoStr = string(Idetinfos)
  5084. infocode = res.Infcode
  5085. }
  5086. } else {
  5087. var result string
  5088. var requestLog string
  5089. if miConfig.UserOrgId == 10138 {
  5090. if id_card_type == 4 {
  5091. psn_info, _ := service.GetPsnByPatientId(id)
  5092. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  5093. } else {
  5094. 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)
  5095. }
  5096. } else {
  5097. 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)
  5098. }
  5099. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5100. if miConfig.Code == "H15049901371" {
  5101. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5102. utils.ErrorLog("解析失败:%v", err)
  5103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5104. return
  5105. }
  5106. res.ErrMsg = res10265.ErrMsg
  5107. res.Output = res10265.Output
  5108. res.InfRefmsgid = res10265.InfRefmsgid
  5109. } else {
  5110. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5111. utils.ErrorLog("解析失败:%v", err)
  5112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5113. return
  5114. }
  5115. }
  5116. PsnNo = res.Output.Baseinfo.PsnNo
  5117. PsnCertType = res.Output.Baseinfo.PsnCertType
  5118. Certno = res.Output.Baseinfo.Certno
  5119. PsnName = res.Output.Baseinfo.PsnName
  5120. Gend = res.Output.Baseinfo.Gend
  5121. Naty = res.Output.Baseinfo.Naty
  5122. Brdy = res.Output.Baseinfo.Brdy
  5123. Age = res.Output.Baseinfo.Age
  5124. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5125. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5126. infoStr = string(Iinfos)
  5127. idetinfoStr = string(Idetinfos)
  5128. if miConfig.Code == "H15049901371" {
  5129. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  5130. } else {
  5131. infocode = res.Infcode
  5132. }
  5133. }
  5134. if infocode == 0 {
  5135. his := models.VMHisPatient{
  5136. Name: name,
  5137. Gender: gender,
  5138. Birthday: birthUnix,
  5139. MedicalTreatmentType: medical_care,
  5140. IdType: certificates,
  5141. IdCardNo: id_card,
  5142. BalanceAccountsType: settlementValue,
  5143. SocialType: social_type,
  5144. MedicalInsuranceNumber: medical_insurance_card,
  5145. RegisterType: register_type,
  5146. RegisterCost: registration_fee,
  5147. TreatmentCost: medical_expenses,
  5148. Status: 1,
  5149. Ctime: time.Now().Unix(),
  5150. Mtime: time.Now().Unix(),
  5151. PsnNo: PsnNo,
  5152. PsnCertType: PsnCertType,
  5153. Certno: Certno,
  5154. PsnName: PsnName,
  5155. Gend: Gend,
  5156. Naty: Naty,
  5157. Brdy: Brdy,
  5158. Age: Age,
  5159. Iinfo: infoStr,
  5160. Idetinfo: idetinfoStr,
  5161. PatientId: patient.ID,
  5162. RecordDate: theTime.Unix(),
  5163. UserOrgId: adminInfo.CurrentOrgId,
  5164. AdminUserId: admin_user_id,
  5165. IsReturn: 1,
  5166. IdCardType: id_card_type,
  5167. Doctor: doctor,
  5168. Departments: department,
  5169. }
  5170. timestamp := time.Now().Unix()
  5171. tempTime := time.Unix(timestamp, 0)
  5172. timeFormat := tempTime.Format("20060102150405")
  5173. chrgBchno := rand.Intn(100000) + 10000
  5174. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5175. his.Number = ipt_otp_no
  5176. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  5177. department, _ := service.GetDepartMentDetail(department)
  5178. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  5179. IdCardNo := ""
  5180. if id_card_type == 1 {
  5181. // IdCardNo = medical_insurance_card
  5182. IdCardNo = patient.IdCardNo
  5183. } else {
  5184. IdCardNo = patient.IdCardNo
  5185. }
  5186. var rf []*ResultFive
  5187. json.Unmarshal([]byte(his.Iinfo), &rf)
  5188. var insutypes []*ResultFive
  5189. var insutype string
  5190. var insuplc_admdvs_temp string
  5191. var is390 int = 0
  5192. var is310 int = 0
  5193. for _, item := range rf {
  5194. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5195. insutypes = append(insutypes, item)
  5196. }
  5197. }
  5198. if len(insutypes) == 1 {
  5199. insutype = insutypes[0].Insutype
  5200. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5201. } else {
  5202. for _, i := range insutypes {
  5203. if i.Insutype == "390" {
  5204. is390 = 1
  5205. }
  5206. if i.Insutype == "310" {
  5207. is310 = 1
  5208. }
  5209. }
  5210. }
  5211. if is390 == 1 {
  5212. insutype = "390"
  5213. }
  5214. if is310 == 1 {
  5215. insutype = "310"
  5216. }
  5217. if len(insutypes) == 0 {
  5218. insutype = "310"
  5219. }
  5220. if len(insutypes) == 2 {
  5221. insutype = med_type
  5222. }
  5223. if len(med_type) > 0 {
  5224. insutype = med_type
  5225. }
  5226. var infocode int64
  5227. var resThree ResultThree
  5228. var resThree10265 ResultThree10265
  5229. if len(insuplc_admdvs) == 0 {
  5230. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  5231. } else {
  5232. insuplc_admdvs_temp = insuplc_admdvs
  5233. }
  5234. if miConfig.MdtrtareaAdmvs == "421300" {
  5235. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  5236. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  5237. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5238. "&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
  5239. resp, requestErr := http.Get(api)
  5240. if requestErr != nil {
  5241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5242. return
  5243. }
  5244. body, ioErr := ioutil.ReadAll(resp.Body)
  5245. if ioErr != nil {
  5246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5248. return
  5249. }
  5250. var respJSON map[string]interface{}
  5251. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5254. return
  5255. }
  5256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5257. result, _ := json.Marshal(respJSON)
  5258. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5259. utils.ErrorLog("解析失败:%v", err)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return
  5262. }
  5263. infocode = resThree.Infcode
  5264. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5265. psn_info, _ := service.GetPsnByPatientId(id)
  5266. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5267. var cert_no string
  5268. if id_card_type == 3 {
  5269. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  5270. cert_no = IdCardNo
  5271. } else if id_card_type == 4 {
  5272. cert_no = IdCardNo
  5273. psn_info.VerifyNumber = psn_info.VerifyNumber
  5274. } else {
  5275. bas := strings.Split(psn_info.CardInfo, "|")
  5276. cert_no = bas[2]
  5277. }
  5278. var hisPrescription []*models.HisPrescription
  5279. for _, item := range rf {
  5280. if item.Insutype == insutype {
  5281. //insuplc_admdvs = item.InsuplcAdmdvs
  5282. his.InsuplcAdmdvs = insuplc_admdvs
  5283. }
  5284. }
  5285. his.Insutype = insutype
  5286. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  5287. fmt.Println(res3101)
  5288. fmt.Println(res3101.Infcode)
  5289. if res3101.Infcode == "0" {
  5290. fmt.Println("33333333")
  5291. if len(res3101.Output.Result) > 0 {
  5292. fmt.Println("222222")
  5293. for _, item := range res3101.Output.Result {
  5294. if len(res3101.ErrMsg) == 0 {
  5295. res3101.ErrMsg = item.VolaCont
  5296. } else {
  5297. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  5298. }
  5299. }
  5300. c.ServeSuccessJSON(map[string]interface{}{
  5301. "failed_code": -10,
  5302. "msg": res3101.ErrMsg,
  5303. })
  5304. return
  5305. } else {
  5306. fmt.Println("11111")
  5307. var api string
  5308. if miConfig.MdtrtareaAdmvs == "320921" {
  5309. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5310. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5311. "&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
  5312. } else {
  5313. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5314. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5315. "&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
  5316. }
  5317. resp, requestErr := http.Get(api)
  5318. if requestErr != nil {
  5319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5320. return
  5321. }
  5322. body, ioErr := ioutil.ReadAll(resp.Body)
  5323. if ioErr != nil {
  5324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5326. return
  5327. }
  5328. var respJSON map[string]interface{}
  5329. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5332. return
  5333. }
  5334. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5335. result, _ := json.Marshal(respJSON)
  5336. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5337. utils.ErrorLog("解析失败:%v", err)
  5338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5339. return
  5340. }
  5341. resThree.ErrMsg = resThree10265.ErrMsg
  5342. resThree.Output = resThree10265.Output
  5343. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5344. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5345. }
  5346. } else if res3101.Infcode != "0" {
  5347. c.ServeSuccessJSON(map[string]interface{}{
  5348. "failed_code": -10,
  5349. "msg": res3101.ErrMsg,
  5350. })
  5351. return
  5352. }
  5353. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5354. psn_info, _ := service.GetPsnByPatientId(id)
  5355. var cert_no string
  5356. if id_card_type == 1 {
  5357. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5358. } else {
  5359. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  5360. }
  5361. fmt.Println(cert_no)
  5362. 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)
  5363. saveLog(result, requestLog, "2201", "挂号")
  5364. if miConfig.Code == "H15049901371" {
  5365. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5366. utils.ErrorLog("解析失败:%v", err)
  5367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5368. return
  5369. }
  5370. resThree.ErrMsg = resThree10265.ErrMsg
  5371. resThree.Output = resThree10265.Output
  5372. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5373. } else {
  5374. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5375. utils.ErrorLog("解析失败:%v", err)
  5376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5377. return
  5378. }
  5379. }
  5380. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5381. } else {
  5382. psn_info, _ := service.GetPsnByPatientId(id)
  5383. 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)
  5384. saveLog(result, requestLog, "2201A", "挂号")
  5385. if miConfig.Code == "H15049901371" {
  5386. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5387. utils.ErrorLog("解析失败:%v", err)
  5388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5389. return
  5390. }
  5391. resThree.ErrMsg = resThree10265.ErrMsg
  5392. resThree.Output = resThree10265.Output
  5393. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5394. } else {
  5395. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5396. utils.ErrorLog("解析失败:%v", err)
  5397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5398. return
  5399. }
  5400. }
  5401. if miConfig.Code == "H15049901371" {
  5402. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5403. } else {
  5404. infocode = resThree.Infcode
  5405. }
  5406. }
  5407. if infocode != 0 {
  5408. adminUser := c.GetAdminUserInfo()
  5409. errlog := &models.HisOrderError{
  5410. UserOrgId: adminUser.CurrentOrgId,
  5411. Ctime: time.Now().Unix(),
  5412. Mtime: time.Now().Unix(),
  5413. ErrMsg: resThree.ErrMsg,
  5414. Status: 1,
  5415. PatientId: id,
  5416. RecordTime: recordDateTime,
  5417. Stage: 2,
  5418. }
  5419. service.CreateErrMsgLog(errlog)
  5420. c.ServeSuccessJSON(map[string]interface{}{
  5421. "failed_code": -10,
  5422. "msg": resThree.ErrMsg,
  5423. })
  5424. return
  5425. }
  5426. his.Number = resThree.Output.Data.MdtrtID
  5427. his.PsnNo = resThree.Output.Data.PsnNo
  5428. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5429. his.IdCardNo = patient.IdCardNo
  5430. his.PhoneNumber = patient.Phone
  5431. his.UserOrgId = adminInfo.CurrentOrgId
  5432. his.Insutype = insutype
  5433. his.Ctime = time.Now().Unix()
  5434. his.Mtime = time.Now().Unix()
  5435. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5436. his.Status = 1
  5437. service.UpdateHisPatientStatus(&his)
  5438. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5439. c.ServeSuccessJSON(map[string]interface{}{
  5440. "his_info": his,
  5441. })
  5442. } else {
  5443. adminUser := c.GetAdminUserInfo()
  5444. errlog := &models.HisOrderError{
  5445. UserOrgId: adminUser.CurrentOrgId,
  5446. Ctime: time.Now().Unix(),
  5447. Mtime: time.Now().Unix(),
  5448. ErrMsg: res.ErrMsg,
  5449. Status: 1,
  5450. PatientId: id,
  5451. RecordTime: recordDateTime,
  5452. Stage: 1,
  5453. }
  5454. service.CreateErrMsgLog(errlog)
  5455. c.ServeSuccessJSON(map[string]interface{}{
  5456. "failed_code": -10,
  5457. "msg": res.ErrMsg,
  5458. })
  5459. return
  5460. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5461. }
  5462. }
  5463. }
  5464. //上传明细----预结算----确认订单
  5465. func (c *HisApiController) GetUploadInfo() {
  5466. id, _ := c.GetInt64("id")
  5467. record_time := c.GetString("record_time")
  5468. his_patient_id, _ := c.GetInt64("his_patient_id")
  5469. order_id, _ := c.GetInt64("order_id")
  5470. pay_way, _ := c.GetInt64("pay_way")
  5471. pay_price, _ := c.GetFloat("pay_price")
  5472. pay_card_no := c.GetString("pay_card_no")
  5473. token := c.GetString("token")
  5474. discount_price, _ := c.GetFloat("discount_price")
  5475. preferential_price, _ := c.GetFloat("preferential_price")
  5476. reality_price, _ := c.GetFloat("reality_price")
  5477. found_price, _ := c.GetFloat("found_price")
  5478. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5479. private_price, _ := c.GetFloat("private_price")
  5480. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5481. admin_user_id, _ := c.GetInt64("admin_user_id")
  5482. fapiao_code := c.GetString("fapiao_code")
  5483. fapiao_number := c.GetString("fapiao_number")
  5484. diagnosis_id := c.GetString("diagnosis")
  5485. sick_type, _ := c.GetInt64("sick_type")
  5486. reg_type, _ := c.GetInt64("p_type")
  5487. begin_time := c.GetString("begin_time")
  5488. id_str := c.GetString("ids")
  5489. ids_arr := strings.Split(id_str, ",")
  5490. timeLayout := "2006-01-02"
  5491. loc, _ := time.LoadLocation("Local")
  5492. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5493. if err != nil {
  5494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5495. return
  5496. }
  5497. recordDateTime := theTime.Unix()
  5498. adminUser := c.GetAdminUserInfo()
  5499. var tempOrder models.HisOrder
  5500. tempOrder, _ = service.GetHisOrderByID(order_id)
  5501. var prescriptions []*models.HisPrescription
  5502. var start_time int64
  5503. var end_time int64
  5504. //押金模块
  5505. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5506. tmp_decimal := c.GetString("tmp_decimal")
  5507. var decimal float64 //本次使用的押金
  5508. var errmsg error
  5509. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5510. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5511. return
  5512. }
  5513. if len(tmp_decimal) > 0 {
  5514. if tmp_decimal[0] == 45 {
  5515. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5516. return
  5517. }
  5518. }
  5519. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5520. fmt.Println(errs)
  5521. decimal = tt
  5522. //if adminUser.CurrentOrgId == 10106{
  5523. // if len(fapiao_code) == 0{
  5524. // fapiao_code = "144072080589"
  5525. // }
  5526. // if len(fapiao_number) == 0{
  5527. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5528. // if order.ID == 0{
  5529. // fapiao_number = "00001520"
  5530. // }else{
  5531. // //fapiao_code = "00001520"
  5532. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5533. // var zero string
  5534. // if fpNumber >= 1000{
  5535. // zero = "0000" + strconv.Itoa(fpNumber)
  5536. // }else if fpNumber >= 10000{
  5537. // zero = "000" + strconv.Itoa(fpNumber)
  5538. // } else if fpNumber >= 100000{
  5539. // zero = "00" + strconv.Itoa(fpNumber)
  5540. // } else if fpNumber >= 1000000{
  5541. // zero = "0" + strconv.Itoa(fpNumber)
  5542. // }else {
  5543. // zero = strconv.Itoa(fpNumber)
  5544. // }
  5545. // fapiao_number = zero
  5546. // }
  5547. // }
  5548. //}
  5549. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5550. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5551. var patientPrescription models.HisPrescriptionInfo
  5552. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5553. if patientPrescription.ID == 0 {
  5554. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5555. }
  5556. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5557. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5558. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5559. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5560. var config []*models.HisXtDiagnoseConfig
  5561. for _, item := range diagnosis_ids {
  5562. id, _ := strconv.ParseInt(item, 10, 64)
  5563. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5564. config = append(config, &diagnosisConfig)
  5565. }
  5566. sickConfig, _ := service.FindSickById(sick_type)
  5567. //if tempOrder.ID == 0 {
  5568. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5569. //}
  5570. if tempOrder.ID == 0 {
  5571. var result string
  5572. var requestLog string
  5573. var res2 ResultSix
  5574. var ressix10265 ResultSix10265
  5575. if miConfig.MdtrtareaAdmvs == "421300" {
  5576. data := make(map[string]interface{})
  5577. client := &http.Client{}
  5578. data["psn_no"] = his.PsnNo
  5579. data["mdtrt_id"] = his.Number
  5580. data["opter"] = roles.UserName
  5581. data["org_name"] = miConfig.OrgName
  5582. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5583. data["doctor_id"] = doctor_info.DoctorNumber
  5584. data["doctor_name"] = doctor_info.UserName
  5585. data["department"] = department.Name
  5586. data["fixmedins_code"] = miConfig.Code
  5587. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5588. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5589. data["secret_key"] = miConfig.SecretKey
  5590. data["sick_code"] = sickConfig.CountryCode
  5591. data["sick_name"] = sickConfig.ClassName
  5592. data["dept"] = strconv.FormatInt(department.ID, 10)
  5593. data["config"] = config
  5594. data["begin_time"] = begin_time
  5595. bytesData, _ := json.Marshal(data)
  5596. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5597. resp, _ := client.Do(req)
  5598. defer resp.Body.Close()
  5599. body, ioErr := ioutil.ReadAll(resp.Body)
  5600. if ioErr != nil {
  5601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5603. return
  5604. }
  5605. var respJSON map[string]interface{}
  5606. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5609. return
  5610. }
  5611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5612. userJSONBytes, _ := json.Marshal(respJSON)
  5613. fmt.Println("log")
  5614. fmt.Println(string(userJSONBytes))
  5615. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5616. utils.ErrorLog("解析失败:%v", err)
  5617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5618. return
  5619. }
  5620. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5621. //江苏地区国家医保医疗类别
  5622. //职工透析:医疗类别选特殊情况门诊9933
  5623. //居民血透门慢: 医疗类别选门诊慢病1402
  5624. //var med_type string
  5625. //if his.Insutype == "310" {
  5626. // if reg_type == 14 {
  5627. // med_type = "9933"
  5628. // } else if reg_type == 11 {
  5629. // med_type = "11"
  5630. //
  5631. // }
  5632. //} else if his.Insutype == "390" {
  5633. // if reg_type == 14 {
  5634. // med_type = "1402"
  5635. // } else if reg_type == 11 {
  5636. // med_type = "11"
  5637. // }
  5638. //}
  5639. data := make(map[string]interface{})
  5640. client := &http.Client{}
  5641. data["psn_no"] = his.PsnNo
  5642. data["mdtrt_id"] = his.Number
  5643. data["doctor"] = roles.UserName
  5644. data["department"] = department.Name
  5645. data["org_name"] = miConfig.OrgName
  5646. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5647. data["doctor_id"] = doctor_info.DoctorNumber
  5648. data["new_doctor_name"] = doctor_info.UserName
  5649. data["fixmedins_code"] = miConfig.Code
  5650. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5651. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5652. data["secret_key"] = miConfig.SecretKey
  5653. data["sick_code"] = sickConfig.CountryCode
  5654. data["sick_name"] = sickConfig.ClassName
  5655. data["url"] = miConfig.Url
  5656. data["ak"] = miConfig.AccessKey
  5657. data["begin_time"] = begin_time
  5658. data["cainfo"] = miConfig.Cainfo
  5659. data["dept"] = strconv.FormatInt(department.ID, 10)
  5660. data["config"] = config
  5661. bytesData, _ := json.Marshal(data)
  5662. var req *http.Request
  5663. if miConfig.MdtrtareaAdmvs == "320921" {
  5664. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5665. //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 +
  5666. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5667. } else {
  5668. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5669. }
  5670. resp, _ := client.Do(req)
  5671. defer resp.Body.Close()
  5672. body, ioErr := ioutil.ReadAll(resp.Body)
  5673. if ioErr != nil {
  5674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5676. return
  5677. }
  5678. var respJSON map[string]interface{}
  5679. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5682. return
  5683. }
  5684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5685. userJSONBytes, _ := json.Marshal(respJSON)
  5686. fmt.Println("log")
  5687. fmt.Println(string(userJSONBytes))
  5688. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5689. utils.ErrorLog("解析失败:%v", err)
  5690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5691. return
  5692. }
  5693. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5694. res2.Output = ressix10265.Output
  5695. res2.ErrMsg = ressix10265.ErrMsg
  5696. res2.Cainfo = ressix10265.Cainfo
  5697. res2.WarnMsg = ressix10265.WarnMsg
  5698. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5699. res2.Infcode = infocode
  5700. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5701. 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)
  5702. saveLog(result, requestLog, "2203", "上传就诊信息")
  5703. var respJSON2 map[string]interface{}
  5704. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5707. return
  5708. }
  5709. userJSONBytes2, _ := json.Marshal(respJSON2)
  5710. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5711. utils.ErrorLog("解析失败:%v", err)
  5712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5713. return
  5714. }
  5715. } else {
  5716. if miConfig.MdtrtareaAdmvs == "440781" { //
  5717. 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)
  5718. } else {
  5719. if miConfig.Code == "H15049901371" {
  5720. //赤峰地区国家医保医疗类别
  5721. //职工透析:医疗类别选特殊情况门诊990502
  5722. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5723. var med_type string
  5724. if his.Insutype == "390" {
  5725. if reg_type == 14 {
  5726. med_type = "9933"
  5727. } else if reg_type == 11 {
  5728. med_type = "11"
  5729. }
  5730. } else if his.Insutype == "310" {
  5731. if reg_type == 14 {
  5732. med_type = "990502"
  5733. } else if reg_type == 11 {
  5734. med_type = "11"
  5735. }
  5736. }
  5737. 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)
  5738. } else {
  5739. 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)
  5740. }
  5741. }
  5742. saveLog(result, requestLog, "2203", "上传就诊信息")
  5743. var respJSON2 map[string]interface{}
  5744. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5747. return
  5748. }
  5749. userJSONBytes2, _ := json.Marshal(respJSON2)
  5750. if miConfig.Code == "H15049901371" {
  5751. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5752. utils.ErrorLog("解析失败:%v", err)
  5753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5754. return
  5755. }
  5756. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5757. res2.Output = ressix10265.Output
  5758. res2.ErrMsg = ressix10265.ErrMsg
  5759. res2.Cainfo = ressix10265.Cainfo
  5760. res2.WarnMsg = ressix10265.WarnMsg
  5761. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5762. res2.Infcode = infocode
  5763. } else {
  5764. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5765. utils.ErrorLog("解析失败:%v", err)
  5766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5767. return
  5768. }
  5769. }
  5770. }
  5771. if res2.Infcode != 0 {
  5772. adminUser := c.GetAdminUserInfo()
  5773. errlog := &models.HisOrderError{
  5774. UserOrgId: adminUser.CurrentOrgId,
  5775. Ctime: time.Now().Unix(),
  5776. Mtime: time.Now().Unix(),
  5777. ErrMsg: res2.ErrMsg,
  5778. Status: 1,
  5779. PatientId: id,
  5780. RecordTime: recordDateTime,
  5781. Stage: 3,
  5782. }
  5783. service.CreateErrMsgLog(errlog)
  5784. c.ServeSuccessJSON(map[string]interface{}{
  5785. "failed_code": -10,
  5786. "msg": res2.ErrMsg,
  5787. })
  5788. return
  5789. } else {
  5790. his.Diagnosis = diagnosis_id
  5791. his.SickType = sickConfig.ID
  5792. //var p_type int64
  5793. //if reg_type == 1111 || reg_type == 1112 {
  5794. // p_type = 11
  5795. //
  5796. //}
  5797. his.PType = fmt.Sprintf("%d", reg_type)
  5798. service.UpdateHisPatientThree(&his)
  5799. data := make(map[string]interface{})
  5800. if settle_accounts_type == 1 { //日结
  5801. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5802. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5803. } else {
  5804. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5805. }
  5806. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5807. data["pre"] = prescriptions
  5808. } else { //月结
  5809. start_time_str := c.GetString("start_time")
  5810. end_time_str := c.GetString("end_time")
  5811. timeLayout := "2006-01-02"
  5812. loc, _ := time.LoadLocation("Local")
  5813. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5814. if err != nil {
  5815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5816. return
  5817. }
  5818. recordStartTime := theStartTime.Unix()
  5819. start_time = recordStartTime
  5820. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5821. if err != nil {
  5822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5823. return
  5824. }
  5825. recordEndTime := theEndTime.Unix()
  5826. end_time = recordEndTime
  5827. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5828. data["pre"] = prescriptions
  5829. }
  5830. timestamp := time.Now().Unix()
  5831. tempTime := time.Unix(timestamp, 0)
  5832. timeFormat := tempTime.Format("20060102150405")
  5833. chrgBchno := rand.Intn(100000) + 10000
  5834. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5835. strconv.FormatInt(his.PatientId, 10)
  5836. client := &http.Client{}
  5837. data["psn_no"] = his.PsnNo
  5838. data["mdtrt_id"] = his.Number
  5839. data["chrg_bchno"] = chrg_bchno
  5840. data["org_name"] = miConfig.OrgName
  5841. data["doctor"] = doctor_info.UserName
  5842. data["doctor_id"] = doctor_info.DoctorNumber
  5843. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5844. data["fixmedins_code"] = miConfig.Code
  5845. data["opter"] = roles.UserName
  5846. data["dept_code"] = department.Number
  5847. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5848. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5849. data["secret_key"] = miConfig.SecretKey
  5850. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5851. data["url"] = miConfig.Url
  5852. data["ak"] = miConfig.AccessKey
  5853. data["new_doctor_name"] = patientPrescription.Doctor
  5854. data["diag_code"] = sickConfig.CountryCode
  5855. data["cainfo"] = miConfig.Cainfo
  5856. var ids []int64
  5857. for _, item := range prescriptions {
  5858. ids = append(ids, item.ID)
  5859. }
  5860. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5861. if config.IsOpen == 1 { //对接了医保,走医保流程
  5862. var res ResultFour
  5863. var resFour10265 ResultFour10265
  5864. if miConfig.MdtrtareaAdmvs == "421300" {
  5865. bytesData, _ := json.Marshal(data)
  5866. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5867. resp, _ := client.Do(req)
  5868. defer resp.Body.Close()
  5869. body, ioErr := ioutil.ReadAll(resp.Body)
  5870. if ioErr != nil {
  5871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5873. return
  5874. }
  5875. var respJSON map[string]interface{}
  5876. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5879. return
  5880. }
  5881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5882. userJSONBytes, _ := json.Marshal(respJSON)
  5883. fmt.Println("log")
  5884. fmt.Println(string(userJSONBytes))
  5885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5886. utils.ErrorLog("解析失败:%v", err)
  5887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5888. return
  5889. }
  5890. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5891. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5892. if result3101.Infcode == "0" {
  5893. if len(result3101.Output.Result) > 0 {
  5894. var errMsgs []string
  5895. for _, item := range result3101.Output.Result {
  5896. errMsgs = append(errMsgs, item.VolaCont)
  5897. }
  5898. c.ServeSuccessJSON(map[string]interface{}{
  5899. "failed_code": -10,
  5900. "msg": errMsgs,
  5901. })
  5902. return
  5903. }
  5904. }
  5905. bytesData, _ := json.Marshal(data)
  5906. var req *http.Request
  5907. if miConfig.MdtrtareaAdmvs == "320921" {
  5908. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5909. } else {
  5910. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5911. }
  5912. resp, _ := client.Do(req)
  5913. defer resp.Body.Close()
  5914. body, ioErr := ioutil.ReadAll(resp.Body)
  5915. if ioErr != nil {
  5916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5918. return
  5919. }
  5920. var respJSON map[string]interface{}
  5921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5924. return
  5925. }
  5926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5927. userJSONBytes, _ := json.Marshal(respJSON)
  5928. fmt.Println("log")
  5929. fmt.Println(string(userJSONBytes))
  5930. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5931. utils.ErrorLog("解析失败:%v", err)
  5932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5933. return
  5934. }
  5935. res.InfRefmsgid = resFour10265.InfRefmsgid
  5936. res.Output = resFour10265.Output
  5937. res.ErrMsg = resFour10265.ErrMsg
  5938. res.Cainfo = resFour10265.Cainfo
  5939. res.WarnMsg = resFour10265.WarnMsg
  5940. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5941. res.Infcode = infocode
  5942. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5943. 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)
  5944. var dat map[string]interface{}
  5945. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5946. fmt.Println(dat)
  5947. } else {
  5948. fmt.Println(err)
  5949. }
  5950. saveLog(result, request_log, "2204", "上传费用明细")
  5951. userJSONBytes, _ := json.Marshal(dat)
  5952. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5953. utils.ErrorLog("解析失败:%v", err)
  5954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5955. return
  5956. }
  5957. res.InfRefmsgid = resFour10265.InfRefmsgid
  5958. res.Output = resFour10265.Output
  5959. res.ErrMsg = resFour10265.ErrMsg
  5960. res.Cainfo = resFour10265.Cainfo
  5961. res.WarnMsg = resFour10265.WarnMsg
  5962. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5963. res.Infcode = infocode
  5964. } else {
  5965. if miConfig.Code == "H15049901371" {
  5966. 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)
  5967. var dat map[string]interface{}
  5968. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5969. fmt.Println(dat)
  5970. } else {
  5971. fmt.Println(err)
  5972. }
  5973. saveLog(result, request_log, "2204", "上传费用明细")
  5974. userJSONBytes, _ := json.Marshal(dat)
  5975. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5976. utils.ErrorLog("解析失败:%v", err)
  5977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5978. return
  5979. }
  5980. res.InfRefmsgid = resFour10265.InfRefmsgid
  5981. res.Output = resFour10265.Output
  5982. res.ErrMsg = resFour10265.ErrMsg
  5983. res.Cainfo = resFour10265.Cainfo
  5984. res.WarnMsg = resFour10265.WarnMsg
  5985. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5986. res.Infcode = infocode
  5987. } else {
  5988. 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)
  5989. var dat map[string]interface{}
  5990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5991. fmt.Println(dat)
  5992. } else {
  5993. fmt.Println(err)
  5994. }
  5995. saveLog(result, request_log, "2204", "上传费用明细")
  5996. userJSONBytes, _ := json.Marshal(dat)
  5997. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5998. utils.ErrorLog("解析失败:%v", err)
  5999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6000. return
  6001. }
  6002. }
  6003. }
  6004. if res.Infcode == 0 {
  6005. order := &models.HisOrder{
  6006. UserOrgId: adminUser.CurrentOrgId,
  6007. HisPatientId: his.ID,
  6008. PatientId: his.PatientId,
  6009. SettleAccountsDate: recordDateTime,
  6010. MdtrtId: his.Number,
  6011. PsnNo: his.PsnNo,
  6012. MedType: strconv.FormatInt(reg_type, 10),
  6013. Ctime: time.Now().Unix(),
  6014. Mtime: time.Now().Unix(),
  6015. Status: 1,
  6016. Number: chrg_bchno,
  6017. Infcode: res.Infcode,
  6018. WarnMsg: res.WarnMsg,
  6019. Cainfo: res.Cainfo,
  6020. ErrMsg: res.ErrMsg,
  6021. RespondTime: res.RefmsgTime,
  6022. InfRefmsgid: res.InfRefmsgid,
  6023. OrderStatus: 1,
  6024. PayWay: pay_way,
  6025. PayPrice: pay_price,
  6026. PayCardNo: pay_card_no,
  6027. DiscountPrice: discount_price,
  6028. PreferentialPrice: preferential_price,
  6029. RealityPrice: reality_price,
  6030. FoundPrice: found_price,
  6031. MedicalInsurancePrice: medical_insurance_price,
  6032. PrivatePrice: private_price,
  6033. IsMedicineInsurance: 1,
  6034. SettleType: settle_accounts_type,
  6035. SettleStartTime: start_time,
  6036. SettleEndTime: end_time,
  6037. Creator: roles.AdminUserId,
  6038. Modify: roles.AdminUserId,
  6039. FaPiaoNumber: fapiao_number,
  6040. FaPiaoCode: fapiao_code,
  6041. PType: 2,
  6042. Diagnosis: diagnosis_id,
  6043. }
  6044. err = service.CreateOrder(order)
  6045. if err != nil {
  6046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6047. return
  6048. }
  6049. for _, item := range res.Output.Result {
  6050. temp := strings.Split(item.FeedetlSn, "-")
  6051. var advice_id int64 = 0
  6052. var project_id int64 = 0
  6053. var types int64 = 0
  6054. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6055. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6056. if temp[1] == "1" {
  6057. advice_id = id
  6058. project_id = 0
  6059. } else if temp[1] == "2" {
  6060. advice_id = 0
  6061. project_id = id
  6062. }
  6063. info := &models.HisOrderInfo{
  6064. OrderNumber: order.Number,
  6065. FeedetlSn: item.FeedetlSn,
  6066. UploadDate: time.Now().Unix(),
  6067. AdviceId: advice_id,
  6068. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6069. Cnt: item.Cnt,
  6070. Pric: float64(item.Pric),
  6071. PatientId: his.PatientId,
  6072. PricUplmtAmt: item.PricUplmtAmt,
  6073. SelfpayProp: item.SelfpayProp,
  6074. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6075. OverlmtAmt: item.OverlmtAmt,
  6076. PreselfpayAmt: item.PreselfpayAmt,
  6077. BasMednFlag: item.BasMednFlag,
  6078. MedChrgitmType: item.MedChrgitmType,
  6079. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6080. Status: 1,
  6081. Memo: item.Memo,
  6082. Mtime: time.Now().Unix(),
  6083. InscpScpAmt: item.InscpScpAmt,
  6084. DrtReimFlag: item.DrtReimFlag,
  6085. Ctime: time.Now().Unix(),
  6086. ListSpItemFlag: item.ListSpItemFlag,
  6087. ChldMedcFlag: item.ChldMedcFlag,
  6088. LmtUsedFlag: item.LmtUsedFlag,
  6089. ChrgitmLv: item.ChrgitmLv,
  6090. UserOrgId: adminUser.CurrentOrgId,
  6091. HisPatientId: his.ID,
  6092. OrderId: order.ID,
  6093. ProjectId: project_id,
  6094. Type: types,
  6095. }
  6096. service.CreateOrderInfo(info)
  6097. }
  6098. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6099. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6100. var total float64
  6101. for _, item := range prescriptions {
  6102. if item.Type == 1 { //药品
  6103. for _, subItem := range item.HisDoctorAdviceInfo {
  6104. total = total + (subItem.Price * subItem.PrescribingNumber)
  6105. }
  6106. }
  6107. if item.Type == 2 { //项目
  6108. for _, subItem := range item.HisPrescriptionProject {
  6109. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6110. total = total + (subItem.Price * cnt)
  6111. }
  6112. }
  6113. }
  6114. for _, item := range prescriptions {
  6115. for _, subItem := range item.HisAdditionalCharge {
  6116. total = total + (subItem.Price * float64(subItem.Count))
  6117. }
  6118. }
  6119. var allTotal string
  6120. if adminUser.CurrentOrgId == 9919 {
  6121. allTotal = fmt.Sprintf("%.4f", total)
  6122. } else {
  6123. allTotal = fmt.Sprintf("%.4f", total)
  6124. }
  6125. if res.Infcode == 0 {
  6126. var rf []*ResultFive
  6127. json.Unmarshal([]byte(his.Iinfo), &rf)
  6128. chrg_bchno := chrg_bchno
  6129. cert_no := his.Certno
  6130. var insutypes []string
  6131. var insutype string
  6132. var is390 int = 0
  6133. var is310 int = 0
  6134. for _, item := range rf {
  6135. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6136. insutypes = append(insutypes, item.Insutype)
  6137. }
  6138. }
  6139. if len(insutypes) == 1 {
  6140. insutype = insutypes[0]
  6141. } else {
  6142. for _, i := range insutypes {
  6143. if i == "390" {
  6144. is390 = 1
  6145. }
  6146. if i == "310" {
  6147. is310 = 1
  6148. }
  6149. }
  6150. }
  6151. if is390 == 1 {
  6152. insutype = "390"
  6153. }
  6154. if is310 == 1 {
  6155. insutype = "310"
  6156. }
  6157. if len(insutypes) == 0 {
  6158. insutype = "310"
  6159. }
  6160. if len(insutypes) == 2 {
  6161. insutype = strconv.FormatInt(his.SocialType, 10)
  6162. }
  6163. insutype = strconv.FormatInt(his.SocialType, 10)
  6164. //insutype = "390"
  6165. if his.IdCardType == 1 {
  6166. // cert_no = his.MedicalInsuranceNumber
  6167. cert_no = his.Certno
  6168. } else {
  6169. cert_no = his.Certno
  6170. }
  6171. var res ResultSeven
  6172. var resSeven10265 ResultSeven10265
  6173. var src_resquest string
  6174. var result2 string
  6175. var acct_used_flag string
  6176. fmt.Println("pay_way")
  6177. fmt.Println(pay_way)
  6178. fmt.Println("pay_way")
  6179. if pay_way == 4 {
  6180. acct_used_flag = "1"
  6181. } else {
  6182. acct_used_flag = "0"
  6183. }
  6184. if miConfig.MdtrtareaAdmvs == "421300" {
  6185. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6186. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6187. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6189. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6190. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6191. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6192. resp, requestErr := http.Get(api)
  6193. if requestErr != nil {
  6194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6195. return
  6196. }
  6197. body, ioErr := ioutil.ReadAll(resp.Body)
  6198. if ioErr != nil {
  6199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6201. return
  6202. }
  6203. var respJSON map[string]interface{}
  6204. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6207. return
  6208. }
  6209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6210. result, _ := json.Marshal(respJSON)
  6211. if miConfig.Code == "H15049901371" {
  6212. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6213. utils.ErrorLog("解析失败:%v", err)
  6214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6215. return
  6216. }
  6217. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6218. res.Output = resSeven10265.Output
  6219. res.ErrMsg = resSeven10265.ErrMsg
  6220. res.Cainfo = resSeven10265.Cainfo
  6221. res.WarnMsg = resSeven10265.WarnMsg
  6222. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6223. res.Infcode = infocode
  6224. } else {
  6225. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6226. utils.ErrorLog("解析失败:%v", err)
  6227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6228. return
  6229. }
  6230. }
  6231. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6232. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  6233. if result3101.Infcode == "0" {
  6234. if len(result3101.Output.Result) > 0 {
  6235. var errMsgs []string
  6236. for _, item := range result3101.Output.Result {
  6237. errMsgs = append(errMsgs, item.VolaCont)
  6238. }
  6239. c.ServeSuccessJSON(map[string]interface{}{
  6240. "failed_code": -10,
  6241. "msg": errMsgs,
  6242. })
  6243. return
  6244. } else {
  6245. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6246. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6247. bas := strings.Split(psn_info.CardInfo, "|")
  6248. if his.IdCardType == 1 {
  6249. cert_no = bas[2]
  6250. } else if his.IdCardType == 3 {
  6251. cert_no = his.Certno
  6252. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6253. } else if his.IdCardType == 4 {
  6254. cert_no = his.Certno
  6255. psn_info.VerifyNumber = token
  6256. }
  6257. var api string
  6258. if miConfig.MdtrtareaAdmvs == "320921" {
  6259. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6260. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6261. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6262. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6263. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6264. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6265. "&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
  6266. } else {
  6267. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6268. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6269. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6270. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6271. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6272. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6273. "&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
  6274. }
  6275. resp, requestErr := http.Get(api)
  6276. if requestErr != nil {
  6277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6278. return
  6279. }
  6280. body, ioErr := ioutil.ReadAll(resp.Body)
  6281. if ioErr != nil {
  6282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6284. return
  6285. }
  6286. var respJSON map[string]interface{}
  6287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6290. return
  6291. }
  6292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6293. result, _ := json.Marshal(respJSON)
  6294. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6295. utils.ErrorLog("解析失败:%v", err)
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. return
  6298. }
  6299. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6300. res.Output = resSeven10265.Output
  6301. res.ErrMsg = resSeven10265.ErrMsg
  6302. res.Cainfo = resSeven10265.Cainfo
  6303. res.WarnMsg = resSeven10265.WarnMsg
  6304. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6305. res.Infcode = infocode
  6306. }
  6307. }
  6308. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6309. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6310. var cert_no string
  6311. if his.IdCardType == 1 {
  6312. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6313. }
  6314. fmt.Println(cert_no)
  6315. 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)
  6316. //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)
  6317. var dat map[string]interface{}
  6318. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6319. fmt.Println(dat)
  6320. } else {
  6321. fmt.Println(err)
  6322. }
  6323. saveLog(result2, src_resquest, "2207", "结算")
  6324. userJSONBytes, _ := json.Marshal(dat)
  6325. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6326. utils.ErrorLog("解析失败:%v", err)
  6327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6328. return
  6329. }
  6330. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6331. res.Output = resSeven10265.Output
  6332. res.ErrMsg = resSeven10265.ErrMsg
  6333. res.Cainfo = resSeven10265.Cainfo
  6334. res.WarnMsg = resSeven10265.WarnMsg
  6335. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6336. res.Infcode = infocode
  6337. } else {
  6338. if miConfig.Code == "H15049901371" {
  6339. //赤峰地区国家医保医疗类别
  6340. //职工透析:医疗类别选特殊情况门诊990502
  6341. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6342. var med_type string
  6343. if his.Insutype == "390" {
  6344. if reg_type == 14 {
  6345. med_type = "9933"
  6346. } else if reg_type == 11 {
  6347. med_type = "11"
  6348. }
  6349. } else if his.Insutype == "310" {
  6350. if reg_type == 14 {
  6351. med_type = "990502"
  6352. } else if reg_type == 11 {
  6353. med_type = "11"
  6354. }
  6355. }
  6356. 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)
  6357. } else {
  6358. 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)
  6359. }
  6360. //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)
  6361. var dat map[string]interface{}
  6362. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6363. fmt.Println(dat)
  6364. } else {
  6365. fmt.Println(err)
  6366. }
  6367. saveLog(result2, src_resquest, "2207", "结算")
  6368. userJSONBytes, _ := json.Marshal(dat)
  6369. if miConfig.Code == "H15049901371" {
  6370. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6371. utils.ErrorLog("解析失败:%v", err)
  6372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6373. return
  6374. }
  6375. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6376. res.Output = resSeven10265.Output
  6377. res.ErrMsg = resSeven10265.ErrMsg
  6378. res.Cainfo = resSeven10265.Cainfo
  6379. res.WarnMsg = resSeven10265.WarnMsg
  6380. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6381. res.Infcode = infocode
  6382. } else {
  6383. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6384. utils.ErrorLog("解析失败:%v", err)
  6385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6386. return
  6387. }
  6388. }
  6389. }
  6390. if res.Infcode != 0 {
  6391. errlog := &models.HisOrderError{
  6392. UserOrgId: adminUser.CurrentOrgId,
  6393. Ctime: time.Now().Unix(),
  6394. Mtime: time.Now().Unix(),
  6395. Number: chrg_bchno,
  6396. ErrMsg: res.ErrMsg,
  6397. Status: 1,
  6398. PatientId: id,
  6399. RecordTime: recordDateTime,
  6400. Stage: 6,
  6401. }
  6402. service.CreateErrMsgLog(errlog)
  6403. c.ServeSuccessJSON(map[string]interface{}{
  6404. "failed_code": -10,
  6405. "msg": res.ErrMsg,
  6406. })
  6407. return
  6408. } else {
  6409. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6410. order.OrderStatus = 2
  6411. order.Status = 1
  6412. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6413. order.SetlId = res.Output.Setlinfo.SetlID
  6414. order.PsnNo = res.Output.Setlinfo.PsnNo
  6415. order.PsnName = res.Output.Setlinfo.PsnName
  6416. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6417. order.Certno = res.Output.Setlinfo.Certno
  6418. order.Gend = res.Output.Setlinfo.Gend
  6419. order.Naty = res.Output.Setlinfo.Naty
  6420. order.Age = res.Output.Setlinfo.Age
  6421. order.Insutype = res.Output.Setlinfo.Insutype
  6422. order.PsnType = res.Output.Setlinfo.PsnType
  6423. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6424. order.SetlTime = res.Output.Setlinfo.SetlTime
  6425. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6426. if res.Output.Setlinfo.MedType == "140101" {
  6427. order.MedType = "14"
  6428. } else {
  6429. order.MedType = res.Output.Setlinfo.MedType
  6430. }
  6431. if reg_type == 1112 {
  6432. order.MedType = "1112"
  6433. }
  6434. if reg_type == 1111 {
  6435. order.MedType = "1111"
  6436. }
  6437. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6438. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6439. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6440. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6441. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6442. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6443. order.HifpPay = res.Output.Setlinfo.HifpPay
  6444. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6445. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6446. order.HifesPay = res.Output.Setlinfo.HifesPay
  6447. order.HifobPay = res.Output.Setlinfo.HifobPay
  6448. order.MafPay = res.Output.Setlinfo.MafPay
  6449. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6450. order.OthPay = res.Output.Setlinfo.OthPay
  6451. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6452. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6453. order.AcctPay = res.Output.Setlinfo.AcctPay
  6454. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6455. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6456. order.Balc = res.Output.Setlinfo.Balc
  6457. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6458. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6459. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6460. order.ClrType = res.Output.Setlinfo.ClrType
  6461. order.ClrWay = res.Output.Setlinfo.ClrWay
  6462. order.Creator = order.Creator
  6463. order.Modify = roles.AdminUserId
  6464. order.RequestLog = src_resquest
  6465. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6466. detailStr := string(setlDetail)
  6467. order.SetlDetail = detailStr
  6468. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6469. err = service.UpDateOrder(order)
  6470. if err == nil {
  6471. //判断是否使用了押金
  6472. if dec_way == "true" {
  6473. tmpstring := strconv.FormatInt(order.ID, 10)
  6474. order.Decimal = decimal
  6475. service.UpDateOrder(order)
  6476. //扣押金
  6477. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6478. if errmsg != nil {
  6479. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6480. return
  6481. }
  6482. }
  6483. c.ServeSuccessJSON(map[string]interface{}{
  6484. "msg": "结算成功",
  6485. })
  6486. } else {
  6487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6488. return
  6489. }
  6490. }
  6491. } else {
  6492. adminUser := c.GetAdminUserInfo()
  6493. errlog := &models.HisOrderError{
  6494. UserOrgId: adminUser.CurrentOrgId,
  6495. Ctime: time.Now().Unix(),
  6496. Mtime: time.Now().Unix(),
  6497. ErrMsg: res.ErrMsg,
  6498. Status: 1,
  6499. PatientId: id,
  6500. RecordTime: recordDateTime,
  6501. Stage: 4,
  6502. }
  6503. service.CreateErrMsgLog(errlog)
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6505. return
  6506. }
  6507. } else {
  6508. adminUser := c.GetAdminUserInfo()
  6509. errlog := &models.HisOrderError{
  6510. UserOrgId: adminUser.CurrentOrgId,
  6511. Ctime: time.Now().Unix(),
  6512. Mtime: time.Now().Unix(),
  6513. ErrMsg: res.ErrMsg,
  6514. Status: 1,
  6515. PatientId: id,
  6516. RecordTime: recordDateTime,
  6517. Stage: 4,
  6518. }
  6519. service.CreateErrMsgLog(errlog)
  6520. c.ServeSuccessJSON(map[string]interface{}{
  6521. "failed_code": -10,
  6522. "msg": res.ErrMsg,
  6523. })
  6524. return
  6525. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6526. //return
  6527. }
  6528. }
  6529. }
  6530. } else if tempOrder.ID > 0 {
  6531. if tempOrder.IsPre == 1 {
  6532. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6533. var rf []*ResultFive
  6534. json.Unmarshal([]byte(his.Iinfo), &rf)
  6535. chrg_bchno := tempOrder.Number
  6536. cert_no := his.Certno
  6537. var insutypes []string
  6538. var insutype string
  6539. var is390 int = 0
  6540. var is310 int = 0
  6541. for _, item := range rf {
  6542. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6543. insutypes = append(insutypes, item.Insutype)
  6544. }
  6545. }
  6546. if len(insutypes) == 1 {
  6547. insutype = insutypes[0]
  6548. } else {
  6549. for _, i := range insutypes {
  6550. if i == "390" {
  6551. is390 = 1
  6552. }
  6553. if i == "310" {
  6554. is310 = 1
  6555. }
  6556. }
  6557. }
  6558. if is390 == 1 {
  6559. insutype = "390"
  6560. }
  6561. if is310 == 1 {
  6562. insutype = "310"
  6563. }
  6564. if len(insutypes) == 0 {
  6565. insutype = "310"
  6566. }
  6567. if len(insutypes) == 2 {
  6568. insutype = strconv.FormatInt(his.SocialType, 64)
  6569. }
  6570. //insutype = "390"
  6571. if his.IdCardType == 1 {
  6572. // cert_no = his.MedicalInsuranceNumber
  6573. cert_no = his.Certno
  6574. } else {
  6575. cert_no = his.Certno
  6576. }
  6577. var res ResultSeven
  6578. var resSeven10265 ResultSeven10265
  6579. var src_resquest string
  6580. var result2 string
  6581. var acct_used_flag string
  6582. fmt.Println("pay_way")
  6583. fmt.Println(pay_way)
  6584. fmt.Println("pay_way")
  6585. if pay_way == 4 {
  6586. acct_used_flag = "1"
  6587. } else {
  6588. acct_used_flag = "0"
  6589. }
  6590. if miConfig.MdtrtareaAdmvs == "421300" {
  6591. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6592. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6593. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6594. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6595. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6596. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6597. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6598. resp, requestErr := http.Get(api)
  6599. if requestErr != nil {
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6601. return
  6602. }
  6603. body, ioErr := ioutil.ReadAll(resp.Body)
  6604. if ioErr != nil {
  6605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6607. return
  6608. }
  6609. var respJSON map[string]interface{}
  6610. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6613. return
  6614. }
  6615. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6616. result, _ := json.Marshal(respJSON)
  6617. fmt.Println("log")
  6618. fmt.Println(string(result))
  6619. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6620. utils.ErrorLog("解析失败:%v", err)
  6621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6622. return
  6623. }
  6624. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6625. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  6626. if result3101.Infcode == "0" {
  6627. if len(result3101.Output.Result) > 0 {
  6628. var errMsgs []string
  6629. for _, item := range result3101.Output.Result {
  6630. errMsgs = append(errMsgs, item.VolaCont)
  6631. }
  6632. c.ServeSuccessJSON(map[string]interface{}{
  6633. "failed_code": -10,
  6634. "msg": errMsgs,
  6635. })
  6636. return
  6637. } else {
  6638. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6639. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6640. //psn_info, _ := service.GetPsnByPatientId(id)
  6641. bas := strings.Split(psn_info.CardInfo, "|")
  6642. if his.IdCardType == 1 {
  6643. cert_no = bas[2]
  6644. } else {
  6645. cert_no = bas[1]
  6646. }
  6647. //江苏地区国家医保医疗类别
  6648. //职工透析:医疗类别选特殊情况门诊9933
  6649. //居民血透门慢: 医疗类别选门诊慢病1402
  6650. //var med_type string
  6651. //if his.Insutype == "310" {
  6652. // if reg_type == 14 {
  6653. // med_type = "9933"
  6654. // } else if reg_type == 11 {
  6655. // med_type = "11"
  6656. //
  6657. // }
  6658. //} else if his.Insutype == "390" {
  6659. // if reg_type == 14 {
  6660. // med_type = "1402"
  6661. // } else if reg_type == 11 {
  6662. // med_type = "11"
  6663. // }
  6664. //}
  6665. var api string
  6666. if miConfig.MdtrtareaAdmvs == "320921" {
  6667. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6668. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6669. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6670. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6671. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6672. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6673. "&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
  6674. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6675. } else {
  6676. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6677. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6678. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6679. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6680. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6681. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6682. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6683. "&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
  6684. }
  6685. resp, requestErr := http.Get(api)
  6686. if requestErr != nil {
  6687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6688. return
  6689. }
  6690. body, ioErr := ioutil.ReadAll(resp.Body)
  6691. if ioErr != nil {
  6692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6694. return
  6695. }
  6696. var respJSON map[string]interface{}
  6697. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6700. return
  6701. }
  6702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6703. result, _ := json.Marshal(respJSON)
  6704. fmt.Println("log")
  6705. fmt.Println(string(result))
  6706. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6707. utils.ErrorLog("解析失败:%v", err)
  6708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6709. return
  6710. }
  6711. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6712. res.Output = resSeven10265.Output
  6713. res.ErrMsg = resSeven10265.ErrMsg
  6714. res.Cainfo = resSeven10265.Cainfo
  6715. res.WarnMsg = resSeven10265.WarnMsg
  6716. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6717. res.Infcode = infocode
  6718. }
  6719. }
  6720. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6721. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6722. var cert_no string
  6723. if his.IdCardType == 1 {
  6724. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6725. }
  6726. fmt.Println(cert_no)
  6727. 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)
  6728. var dat map[string]interface{}
  6729. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6730. fmt.Println(dat)
  6731. } else {
  6732. fmt.Println(err)
  6733. }
  6734. saveLog(result2, src_resquest, "2207", "结算")
  6735. userJSONBytes, _ := json.Marshal(dat)
  6736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6737. utils.ErrorLog("解析失败:%v", err)
  6738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6739. return
  6740. }
  6741. } else {
  6742. var src_resquest string
  6743. if miConfig.Code == "H15049901371" {
  6744. //赤峰地区国家医保医疗类别
  6745. //职工透析:医疗类别选特殊情况门诊990502
  6746. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6747. var med_type string
  6748. if his.Insutype == "390" {
  6749. if reg_type == 14 {
  6750. med_type = "9933"
  6751. } else if reg_type == 11 {
  6752. med_type = "11"
  6753. }
  6754. } else if his.Insutype == "310" {
  6755. if reg_type == 14 {
  6756. med_type = "990502"
  6757. } else if reg_type == 11 {
  6758. med_type = "11"
  6759. }
  6760. }
  6761. 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)
  6762. } else {
  6763. 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)
  6764. }
  6765. var dat map[string]interface{}
  6766. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6767. fmt.Println(dat)
  6768. } else {
  6769. fmt.Println(err)
  6770. }
  6771. saveLog(result2, src_resquest, "2207", "结算")
  6772. userJSONBytes, _ := json.Marshal(dat)
  6773. if miConfig.Code == "H15049901371" {
  6774. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6775. utils.ErrorLog("解析失败:%v", err)
  6776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6777. return
  6778. }
  6779. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6780. res.Output = resSeven10265.Output
  6781. res.ErrMsg = resSeven10265.ErrMsg
  6782. res.Cainfo = resSeven10265.Cainfo
  6783. res.WarnMsg = resSeven10265.WarnMsg
  6784. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6785. res.Infcode = infocode
  6786. } else {
  6787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6788. utils.ErrorLog("解析失败:%v", err)
  6789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6790. return
  6791. }
  6792. }
  6793. }
  6794. if res.Infcode != 0 {
  6795. errlog := &models.HisOrderError{
  6796. UserOrgId: adminUser.CurrentOrgId,
  6797. Ctime: time.Now().Unix(),
  6798. Mtime: time.Now().Unix(),
  6799. Number: chrg_bchno,
  6800. ErrMsg: res.ErrMsg,
  6801. Status: 1,
  6802. PatientId: id,
  6803. RecordTime: recordDateTime,
  6804. Stage: 6,
  6805. }
  6806. service.CreateErrMsgLog(errlog)
  6807. c.ServeSuccessJSON(map[string]interface{}{
  6808. "failed_code": -10,
  6809. "msg": res.ErrMsg,
  6810. })
  6811. return
  6812. } else {
  6813. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6814. order.OrderStatus = 2
  6815. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6816. order.SetlId = res.Output.Setlinfo.SetlID
  6817. order.PsnNo = res.Output.Setlinfo.PsnNo
  6818. order.PsnName = res.Output.Setlinfo.PsnName
  6819. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6820. order.Certno = res.Output.Setlinfo.Certno
  6821. order.Gend = res.Output.Setlinfo.Gend
  6822. order.Naty = res.Output.Setlinfo.Naty
  6823. order.Age = res.Output.Setlinfo.Age
  6824. order.Insutype = res.Output.Setlinfo.Insutype
  6825. order.PsnType = res.Output.Setlinfo.PsnType
  6826. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6827. order.SetlTime = res.Output.Setlinfo.SetlTime
  6828. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6829. //order.MedType = res.Output.Setlinfo.MedType
  6830. if reg_type == 1112 {
  6831. order.MedType = "1112"
  6832. }
  6833. if reg_type == 1111 {
  6834. order.MedType = "1111"
  6835. }
  6836. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6837. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6838. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6839. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6840. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6841. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6842. order.HifpPay = res.Output.Setlinfo.HifpPay
  6843. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6844. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6845. order.HifesPay = res.Output.Setlinfo.HifesPay
  6846. order.HifobPay = res.Output.Setlinfo.HifobPay
  6847. order.MafPay = res.Output.Setlinfo.MafPay
  6848. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6849. order.OthPay = res.Output.Setlinfo.OthPay
  6850. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6851. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6852. order.AcctPay = res.Output.Setlinfo.AcctPay
  6853. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6854. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6855. order.Balc = res.Output.Setlinfo.Balc
  6856. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6857. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6858. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6859. order.ClrWay = res.Output.Setlinfo.ClrWay
  6860. order.Creator = order.Creator
  6861. order.Modify = roles.AdminUserId
  6862. order.RequestLog = src_resquest
  6863. order.Diagnosis = diagnosis_id
  6864. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6865. detailStr := string(setlDetail)
  6866. order.SetlDetail = detailStr
  6867. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6868. err = service.UpDateOrder(order)
  6869. if err == nil {
  6870. //判断是否使用了押金
  6871. if dec_way == "true" {
  6872. tmpstring := strconv.FormatInt(order.ID, 10)
  6873. //扣押金
  6874. order.Decimal = decimal
  6875. service.UpDateOrder(order)
  6876. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6877. if errmsg != nil {
  6878. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6879. return
  6880. }
  6881. }
  6882. c.ServeSuccessJSON(map[string]interface{}{
  6883. "msg": "结算成功",
  6884. })
  6885. } else {
  6886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6887. return
  6888. }
  6889. }
  6890. }
  6891. }
  6892. }
  6893. //func (c *HisApiController) GetPreUploadInfo() {
  6894. // id, _ := c.GetInt64("id")
  6895. // record_time := c.GetString("record_time")
  6896. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6897. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6898. //
  6899. // timeLayout := "2006-01-02"
  6900. // loc, _ := time.LoadLocation("Local")
  6901. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6902. // if err != nil {
  6903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6904. // return
  6905. // }
  6906. // recordDateTime := theTime.Unix()
  6907. // adminUser := c.GetAdminUserInfo()
  6908. //
  6909. // var prescriptions []*models.HisPrescription
  6910. //
  6911. // var start_time int64
  6912. // var end_time int64
  6913. //
  6914. // data := make(map[string]interface{})
  6915. // if settle_accounts_type == 1 { //日结
  6916. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6917. // data["pre"] = prescriptions
  6918. //
  6919. // } else { //月结
  6920. // start_time_str := c.GetString("start_time")
  6921. // end_time_str := c.GetString("end_time")
  6922. // timeLayout := "2006-01-02"
  6923. // loc, _ := time.LoadLocation("Local")
  6924. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6925. // if err != nil {
  6926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6927. // return
  6928. // }
  6929. // recordStartTime := theStartTime.Unix()
  6930. // start_time = recordStartTime
  6931. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6932. // if err != nil {
  6933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6934. // return
  6935. // }
  6936. // recordEndTime := theEndTime.Unix()
  6937. // end_time = recordEndTime
  6938. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6939. // data["pre"] = prescriptions
  6940. //
  6941. // }
  6942. //
  6943. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6944. //
  6945. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6946. // timestamp := time.Now().Unix()
  6947. // tempTime := time.Unix(timestamp, 0)
  6948. // timeFormat := tempTime.Format("20060102150405")
  6949. // chrgBchno := rand.Intn(100000) + 10000
  6950. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6951. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6952. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6953. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6954. // strconv.FormatInt(his.PatientId, 10)
  6955. // client := &http.Client{}
  6956. // data["psn_no"] = his.PsnNo
  6957. // data["mdtrt_id"] = his.Number
  6958. // data["chrg_bchno"] = chrg_bchno
  6959. // data["org_name"] = miConfig.OrgName
  6960. // data["doctor"] = roles.UserName
  6961. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6962. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6963. // data["fixmedins_code"] = miConfig.Code
  6964. // data["dept_code"] = department.Number
  6965. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6966. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6967. // data["secret_key"] = miConfig.SecretKey
  6968. // var ids []int64
  6969. //
  6970. // for _, item := range prescriptions {
  6971. // ids = append(ids, item.ID)
  6972. // }
  6973. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6974. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6975. // bytesData, _ := json.Marshal(data)
  6976. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6977. // resp, _ := client.Do(req)
  6978. // defer resp.Body.Close()
  6979. // body, ioErr := ioutil.ReadAll(resp.Body)
  6980. // if ioErr != nil {
  6981. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6982. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6983. // return
  6984. // }
  6985. // var respJSON map[string]interface{}
  6986. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6987. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6989. // return
  6990. // }
  6991. //
  6992. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6993. // userJSONBytes, _ := json.Marshal(respJSON)
  6994. // var res ResultFour
  6995. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6996. // utils.ErrorLog("解析失败:%v", err)
  6997. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6998. // return
  6999. // }
  7000. //
  7001. // if res.Infcode == 0 {
  7002. // order := &models.HisOrder{
  7003. // UserOrgId: adminUser.CurrentOrgId,
  7004. // HisPatientId: his.ID,
  7005. // PatientId: his.PatientId,
  7006. // SettleAccountsDate: recordDateTime,
  7007. // Ctime: time.Now().Unix(),
  7008. // Mtime: time.Now().Unix(),
  7009. // Status: 1,
  7010. // Number: chrg_bchno,
  7011. // Infcode: res.Infcode,
  7012. // WarnMsg: res.WarnMsg,
  7013. // Cainfo: res.Cainfo,
  7014. // ErrMsg: res.ErrMsg,
  7015. // RespondTime: res.RefmsgTime,
  7016. // InfRefmsgid: res.InfRefmsgid,
  7017. // OrderStatus: 1,
  7018. // IsMedicineInsurance: 1,
  7019. // SettleType: settle_accounts_type,
  7020. // SettleStartTime: start_time,
  7021. // SettleEndTime: end_time,
  7022. // Creator: roles.ID,
  7023. // Modify: roles.ID,
  7024. // PType: 2,
  7025. // }
  7026. // err = service.CreateOrder(order)
  7027. // if err != nil {
  7028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7029. // return
  7030. // }
  7031. //
  7032. // for _, item := range res.Output.Result {
  7033. // temp := strings.Split(item.FeedetlSn, "-")
  7034. // var advice_id int64 = 0
  7035. // var project_id int64 = 0
  7036. // var types int64 = 0
  7037. //
  7038. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  7039. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  7040. //
  7041. // if temp[1] == "1" {
  7042. // advice_id = id
  7043. // project_id = 0
  7044. // } else if temp[1] == "2" {
  7045. // advice_id = 0
  7046. // project_id = id
  7047. // }
  7048. //
  7049. // info := &models.HisOrderInfo{
  7050. // OrderNumber: order.Number,
  7051. // FeedetlSn: item.FeedetlSn,
  7052. // UploadDate: time.Now().Unix(),
  7053. // AdviceId: advice_id,
  7054. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  7055. // Cnt: item.Cnt,
  7056. // Pric: float64(item.Pric),
  7057. // PatientId: his.PatientId,
  7058. // PricUplmtAmt: item.PricUplmtAmt,
  7059. // SelfpayProp: item.SelfpayProp,
  7060. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7061. // OverlmtAmt: item.OverlmtAmt,
  7062. // PreselfpayAmt: item.PreselfpayAmt,
  7063. // BasMednFlag: item.BasMednFlag,
  7064. // MedChrgitmType: item.MedChrgitmType,
  7065. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  7066. // Status: 1,
  7067. // Memo: item.Memo,
  7068. // Mtime: time.Now().Unix(),
  7069. // InscpScpAmt: item.InscpScpAmt,
  7070. // DrtReimFlag: item.DrtReimFlag,
  7071. // Ctime: time.Now().Unix(),
  7072. // ListSpItemFlag: item.ListSpItemFlag,
  7073. // ChldMedcFlag: item.ChldMedcFlag,
  7074. // LmtUsedFlag: item.LmtUsedFlag,
  7075. // ChrgitmLv: item.ChrgitmLv,
  7076. // UserOrgId: adminUser.CurrentOrgId,
  7077. // HisPatientId: his.ID,
  7078. // OrderId: order.ID,
  7079. // ProjectId: project_id,
  7080. // Type: types,
  7081. // }
  7082. // service.CreateOrderInfo(info)
  7083. //
  7084. // }
  7085. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7086. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  7087. //
  7088. // var total float64
  7089. // for _, item := range prescriptions {
  7090. // if item.Type == 1 { //药品
  7091. // for _, subItem := range item.HisDoctorAdviceInfo {
  7092. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7093. // }
  7094. // }
  7095. // if item.Type == 2 { //项目
  7096. // for _, subItem := range item.HisPrescriptionProject {
  7097. // total = total + (subItem.Price * float64(subItem.Count))
  7098. // }
  7099. // }
  7100. // }
  7101. //
  7102. // for _, item := range prescriptions {
  7103. // for _, subItem := range item.HisAdditionalCharge {
  7104. // total = total + (subItem.Price * float64(subItem.Count))
  7105. // }
  7106. // }
  7107. //
  7108. // allTotal := fmt.Sprintf("%.2f", total)
  7109. // if res.Infcode == 0 {
  7110. // var rf []*ResultFive
  7111. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7112. // psn_no := his.PsnNo
  7113. // mdtrt_id := his.Number
  7114. // chrg_bchno := chrg_bchno
  7115. // cert_no := his.Certno
  7116. // insutype := rf[0].Insutype
  7117. //
  7118. // if his.IdCardType == 1 {
  7119. // cert_no = his.MedicalInsuranceNumber
  7120. //
  7121. // } else {
  7122. //
  7123. // cert_no = his.Certno
  7124. //
  7125. // }
  7126. //
  7127. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  7128. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  7129. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  7130. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  7131. // resp, requestErr := http.Get(api)
  7132. // if requestErr != nil {
  7133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7134. // return
  7135. // }
  7136. // defer resp.Body.Close()
  7137. // body, ioErr := ioutil.ReadAll(resp.Body)
  7138. // if ioErr != nil {
  7139. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7141. // return
  7142. // }
  7143. // var respJSON map[string]interface{}
  7144. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7145. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7147. // return
  7148. // }
  7149. // fmt.Println(respJSON)
  7150. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7151. // userJSONBytes, _ := json.Marshal(respJSON)
  7152. // var res ResultSeven
  7153. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7154. // utils.ErrorLog("解析失败:%v", err)
  7155. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7156. // return
  7157. // }
  7158. // if res.Infcode != 0 {
  7159. // errlog := &models.HisOrderError{
  7160. // UserOrgId: adminUser.CurrentOrgId,
  7161. // Ctime: time.Now().Unix(),
  7162. // Mtime: time.Now().Unix(),
  7163. // Number: chrg_bchno,
  7164. // ErrMsg: res.ErrMsg,
  7165. // Status: 1,
  7166. // PatientId: id,
  7167. // RecordTime: recordDateTime,
  7168. // Stage: 7,
  7169. // }
  7170. // service.CreateErrMsgLog(errlog)
  7171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7172. // return
  7173. // } else {
  7174. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7175. // order.OrderStatus = 1
  7176. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7177. // order.SetlId = res.Output.Setlinfo.SetlID
  7178. // order.PsnNo = res.Output.Setlinfo.PsnNo
  7179. // order.PsnName = res.Output.Setlinfo.PsnName
  7180. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7181. // order.Certno = res.Output.Setlinfo.Certno
  7182. // order.Gend = res.Output.Setlinfo.Gend
  7183. // order.Naty = res.Output.Setlinfo.Naty
  7184. // order.Age = res.Output.Setlinfo.Age
  7185. // order.Insutype = res.Output.Setlinfo.Insutype
  7186. // order.PsnType = res.Output.Setlinfo.PsnType
  7187. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7188. // order.SetlTime = res.Output.Setlinfo.SetlTime
  7189. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7190. // order.MedType = res.Output.Setlinfo.MedType
  7191. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7192. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7193. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7194. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7195. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7196. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7197. // order.HifpPay = res.Output.Setlinfo.HifpPay
  7198. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7199. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7200. // order.HifesPay = res.Output.Setlinfo.HifesPay
  7201. // order.HifobPay = res.Output.Setlinfo.HifobPay
  7202. // order.MafPay = res.Output.Setlinfo.MafPay
  7203. // order.OthPay = res.Output.Setlinfo.OthPay
  7204. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7205. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7206. // order.AcctPay = res.Output.Setlinfo.AcctPay
  7207. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7208. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7209. // order.Balc = res.Output.Setlinfo.Balc
  7210. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7211. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7212. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7213. // order.ClrWay = res.Output.Setlinfo.ClrWay
  7214. // order.Creator = order.Creator
  7215. // order.Modify = roles.ID
  7216. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7217. // detailStr := string(setlDetail)
  7218. // order.SetlDetail = detailStr
  7219. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7220. // err = service.UpDateOrder(order)
  7221. // if err == nil {
  7222. // c.ServeSuccessJSON(map[string]interface{}{
  7223. // "msg": "预结算成功",
  7224. // })
  7225. // } else {
  7226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7227. // return
  7228. // }
  7229. // }
  7230. // } else {
  7231. // adminUser := c.GetAdminUserInfo()
  7232. // errlog := &models.HisOrderError{
  7233. // UserOrgId: adminUser.CurrentOrgId,
  7234. // Ctime: time.Now().Unix(),
  7235. // Mtime: time.Now().Unix(),
  7236. // ErrMsg: res.ErrMsg,
  7237. // Status: 1,
  7238. // PatientId: id,
  7239. // RecordTime: recordDateTime,
  7240. // Stage: 4,
  7241. // }
  7242. // service.CreateErrMsgLog(errlog)
  7243. //
  7244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7245. // return
  7246. // }
  7247. // } else {
  7248. // adminUser := c.GetAdminUserInfo()
  7249. // errlog := &models.HisOrderError{
  7250. // UserOrgId: adminUser.CurrentOrgId,
  7251. // Ctime: time.Now().Unix(),
  7252. // Mtime: time.Now().Unix(),
  7253. // ErrMsg: res.ErrMsg,
  7254. // Status: 1,
  7255. // PatientId: id,
  7256. // RecordTime: recordDateTime,
  7257. // Stage: 4,
  7258. // }
  7259. // service.CreateErrMsgLog(errlog)
  7260. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7261. // return
  7262. // }
  7263. //
  7264. // } else {
  7265. // var total float64
  7266. // for _, item := range prescriptions {
  7267. // if item.Type == 1 { //药品
  7268. // for _, subItem := range item.HisDoctorAdviceInfo {
  7269. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7270. // }
  7271. // }
  7272. // if item.Type == 2 { //项目
  7273. // for _, subItem := range item.HisPrescriptionProject {
  7274. // total = total + (subItem.Price * float64(subItem.Count))
  7275. // }
  7276. // }
  7277. //
  7278. // for _, subItem := range item.HisAdditionalCharge {
  7279. // total = total + (subItem.Price * float64(subItem.Count))
  7280. // }
  7281. // }
  7282. //
  7283. // allTotal := fmt.Sprintf("%.2f", total)
  7284. // totals, _ := strconv.ParseFloat(allTotal, 64)
  7285. // order := &models.HisOrder{
  7286. // UserOrgId: adminUser.CurrentOrgId,
  7287. // HisPatientId: his.ID,
  7288. // PatientId: id,
  7289. // SettleAccountsDate: recordDateTime,
  7290. // Ctime: time.Now().Unix(),
  7291. // Mtime: time.Now().Unix(),
  7292. // Status: 1,
  7293. // OrderStatus: 2,
  7294. // Number: chrg_bchno,
  7295. // MedfeeSumamt: totals,
  7296. // }
  7297. // err = service.CreateOrder(order)
  7298. // if err != nil {
  7299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7300. // return
  7301. // }
  7302. //
  7303. // var customs []*Custom
  7304. // for _, item := range prescriptions {
  7305. //
  7306. // if item.Type == 1 { //药品
  7307. // for _, subItem := range item.HisDoctorAdviceInfo {
  7308. // cus := &Custom{
  7309. // AdviceId: subItem.ID,
  7310. // ProjectId: 0,
  7311. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7312. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7313. // FeedetlSn: subItem.FeedetlSn,
  7314. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7315. // MedListCodg: subItem.MedListCodg,
  7316. // Type: 1,
  7317. // }
  7318. // customs = append(customs, cus)
  7319. // }
  7320. // }
  7321. //
  7322. // if item.Type == 2 { //项目
  7323. // for _, subItem := range item.HisPrescriptionProject {
  7324. //
  7325. // cus := &Custom{
  7326. // AdviceId: 0,
  7327. // ProjectId: subItem.ID,
  7328. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7329. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7330. // FeedetlSn: subItem.FeedetlSn,
  7331. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7332. // MedListCodg: subItem.MedListCodg,
  7333. // Type: 2,
  7334. // }
  7335. //
  7336. // customs = append(customs, cus)
  7337. // }
  7338. // }
  7339. //
  7340. // for _, item := range item.HisAdditionalCharge {
  7341. // cus := &Custom{
  7342. // ItemId: item.ID,
  7343. // AdviceId: 0,
  7344. // ProjectId: 0,
  7345. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7346. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7347. // FeedetlSn: item.FeedetlSn,
  7348. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7349. // MedListCodg: item.XtHisAddtionConfig.Code,
  7350. // Type: 3,
  7351. // }
  7352. //
  7353. // customs = append(customs, cus)
  7354. // }
  7355. //
  7356. // }
  7357. //
  7358. // for _, item := range customs {
  7359. // var advice_id int64 = 0
  7360. // var project_id int64 = 0
  7361. // var item_id int64 = 0
  7362. //
  7363. // var types int64 = 0
  7364. //
  7365. // if item.Type == 1 {
  7366. // advice_id = item.AdviceId
  7367. // project_id = 0
  7368. // item_id = 0
  7369. // } else if item.Type == 2 {
  7370. // advice_id = 0
  7371. // item_id = 0
  7372. //
  7373. // project_id = item.ProjectId
  7374. // } else if item.Type == 3 {
  7375. // advice_id = 0
  7376. // item_id = item.ItemId
  7377. // project_id = 0
  7378. // }
  7379. //
  7380. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7381. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7382. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7383. //
  7384. // info := &models.HisOrderInfo{
  7385. // OrderNumber: order.Number,
  7386. // UploadDate: time.Now().Unix(),
  7387. // AdviceId: advice_id,
  7388. // DetItemFeeSumamt: detItemFeeSumamt,
  7389. // Cnt: cut,
  7390. // Pric: pric,
  7391. // PatientId: id,
  7392. // Status: 1,
  7393. // Mtime: time.Now().Unix(),
  7394. // Ctime: time.Now().Unix(),
  7395. // UserOrgId: adminUser.CurrentOrgId,
  7396. // HisPatientId: his.ID,
  7397. // OrderId: order.ID,
  7398. // ProjectId: project_id,
  7399. // Type: types,
  7400. // ItemId: item_id,
  7401. // }
  7402. // service.CreateOrderInfo(info)
  7403. // }
  7404. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7405. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7406. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7407. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7408. // if err == nil {
  7409. // c.ServeSuccessJSON(map[string]interface{}{
  7410. // "msg": "结算成功",
  7411. // })
  7412. // } else {
  7413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7414. // return
  7415. // }
  7416. // }
  7417. //}
  7418. //上传明细-预结算-
  7419. func (c *HisApiController) GetPreUploadInfo() {
  7420. id, _ := c.GetInt64("id")
  7421. record_time := c.GetString("record_time")
  7422. his_patient_id, _ := c.GetInt64("his_patient_id")
  7423. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7424. admin_user_id, _ := c.GetInt64("admin_user_id")
  7425. diagnosis_id := c.GetString("diagnosis")
  7426. sick_type, _ := c.GetInt64("sick_type")
  7427. reg_type, _ := c.GetInt64("p_type")
  7428. begin_time := c.GetString("begin_time")
  7429. id_str := c.GetString("ids")
  7430. ids_arr := strings.Split(id_str, ",")
  7431. timeLayout := "2006-01-02"
  7432. loc, _ := time.LoadLocation("Local")
  7433. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7434. if err != nil {
  7435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7436. return
  7437. }
  7438. recordDateTime := theTime.Unix()
  7439. adminUser := c.GetAdminUserInfo()
  7440. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7441. var config []*models.HisXtDiagnoseConfig
  7442. for _, item := range diagnosis_ids {
  7443. id, _ := strconv.ParseInt(item, 10, 64)
  7444. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7445. config = append(config, &diagnosisConfig)
  7446. }
  7447. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7448. sickConfig, _ := service.FindSickById(sick_type)
  7449. var prescriptions []*models.HisPrescription
  7450. var start_time int64
  7451. var end_time int64
  7452. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7453. fmt.Println(his_patient_id)
  7454. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7455. timestamp := time.Now().Unix()
  7456. tempTime := time.Unix(timestamp, 0)
  7457. timeFormat := tempTime.Format("20060102150405")
  7458. chrgBchno := rand.Intn(100000) + 10000
  7459. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7460. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7461. var patientPrescription models.HisPrescriptionInfo
  7462. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7463. if patientPrescription.ID == 0 {
  7464. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7465. }
  7466. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7467. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7468. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7469. strconv.FormatInt(his.PatientId, 10)
  7470. var res2 ResultSix
  7471. var resSix10265 ResultSix10265
  7472. var time_stamp string
  7473. if miConfig.MdtrtareaAdmvs == "421300" {
  7474. data := make(map[string]interface{})
  7475. client := &http.Client{}
  7476. data["psn_no"] = his.PsnNo
  7477. data["mdtrt_id"] = his.Number
  7478. data["department"] = department.Name
  7479. data["org_name"] = miConfig.OrgName
  7480. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7481. data["doctor_id"] = doctor_info.DoctorNumber
  7482. data["doctor_name"] = roles.UserName
  7483. data["fixmedins_code"] = miConfig.Code
  7484. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7485. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7486. data["secret_key"] = miConfig.SecretKey
  7487. data["sick_code"] = sickConfig.CountryCode
  7488. data["sick_name"] = sickConfig.ClassName
  7489. data["begin_time"] = begin_time
  7490. data["dept"] = strconv.FormatInt(department.ID, 10)
  7491. data["config"] = config
  7492. data["opter"] = roles.UserName
  7493. fmt.Println(data)
  7494. bytesData, _ := json.Marshal(data)
  7495. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7496. resp, _ := client.Do(req)
  7497. defer resp.Body.Close()
  7498. body, ioErr := ioutil.ReadAll(resp.Body)
  7499. if ioErr != nil {
  7500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7502. return
  7503. }
  7504. var respJSON map[string]interface{}
  7505. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7508. return
  7509. }
  7510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7511. userJSONBytes, _ := json.Marshal(respJSON)
  7512. fmt.Println("log")
  7513. fmt.Println(string(userJSONBytes))
  7514. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7515. utils.ErrorLog("解析失败:%v", err)
  7516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7517. return
  7518. }
  7519. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7520. data := make(map[string]interface{})
  7521. client := &http.Client{}
  7522. data["psn_no"] = his.PsnNo
  7523. data["mdtrt_id"] = his.Number
  7524. data["doctor"] = roles.UserName
  7525. data["department"] = department.Name
  7526. data["org_name"] = miConfig.OrgName
  7527. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7528. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7529. data["fixmedins_code"] = miConfig.Code
  7530. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7531. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7532. data["secret_key"] = miConfig.SecretKey
  7533. data["sick_code"] = sickConfig.CountryCode
  7534. data["sick_name"] = sickConfig.ClassName
  7535. data["begin_time"] = begin_time
  7536. data["dept"] = strconv.FormatInt(department.ID, 10)
  7537. data["config"] = config
  7538. data["url"] = miConfig.Url
  7539. data["ak"] = miConfig.AccessKey
  7540. data["cainfo"] = miConfig.Cainfo
  7541. bytesData, _ := json.Marshal(data)
  7542. var req *http.Request
  7543. if miConfig.MdtrtareaAdmvs == "320921" {
  7544. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7545. //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 +
  7546. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7547. } else {
  7548. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7549. }
  7550. resp, _ := client.Do(req)
  7551. defer resp.Body.Close()
  7552. body, ioErr := ioutil.ReadAll(resp.Body)
  7553. if ioErr != nil {
  7554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7556. return
  7557. }
  7558. var respJSON map[string]interface{}
  7559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7562. return
  7563. }
  7564. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7565. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7566. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7568. userJSONBytes, _ := json.Marshal(respJSON)
  7569. fmt.Println("log")
  7570. fmt.Println(string(userJSONBytes))
  7571. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7572. utils.ErrorLog("解析失败:%v", err)
  7573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7574. return
  7575. }
  7576. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7577. res2.Output = resSix10265.Output
  7578. res2.ErrMsg = resSix10265.ErrMsg
  7579. res2.Cainfo = resSix10265.Cainfo
  7580. res2.WarnMsg = resSix10265.WarnMsg
  7581. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7582. res2.Infcode = infocode
  7583. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7584. 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)
  7585. saveLog(result, requestLog, "2203", "上传就诊信息")
  7586. var respJSON2 map[string]interface{}
  7587. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7590. return
  7591. }
  7592. userJSONBytes2, _ := json.Marshal(respJSON2)
  7593. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7594. utils.ErrorLog("解析失败:%v", err)
  7595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7596. return
  7597. }
  7598. } else {
  7599. var result string
  7600. var requestLog string
  7601. if miConfig.MdtrtareaAdmvs == "440781" { //
  7602. 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)
  7603. } else {
  7604. if miConfig.Code == "H15049901371" {
  7605. //赤峰地区国家医保医疗类别
  7606. //职工透析:医疗类别选特殊情况门诊990502
  7607. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7608. var med_type string
  7609. if his.Insutype == "390" {
  7610. if reg_type == 14 {
  7611. med_type = "9933"
  7612. } else if reg_type == 11 {
  7613. med_type = "11"
  7614. }
  7615. } else if his.Insutype == "310" {
  7616. if reg_type == 14 {
  7617. med_type = "990502"
  7618. } else if reg_type == 11 {
  7619. med_type = "11"
  7620. }
  7621. }
  7622. 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)
  7623. } else {
  7624. 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)
  7625. }
  7626. saveLog(result, requestLog, "2203", "上传就诊信息")
  7627. var respJSON2 map[string]interface{}
  7628. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7631. return
  7632. }
  7633. userJSONBytes2, _ := json.Marshal(respJSON2)
  7634. if miConfig.Code == "H15049901371" {
  7635. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7636. utils.ErrorLog("解析失败:%v", err)
  7637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7638. return
  7639. }
  7640. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7641. res2.Output = resSix10265.Output
  7642. res2.ErrMsg = resSix10265.ErrMsg
  7643. res2.Cainfo = resSix10265.Cainfo
  7644. res2.WarnMsg = resSix10265.WarnMsg
  7645. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7646. res2.Infcode = infocode
  7647. } else {
  7648. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7649. utils.ErrorLog("解析失败:%v", err)
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7651. return
  7652. }
  7653. }
  7654. }
  7655. }
  7656. if res2.Infcode != 0 {
  7657. adminUser := c.GetAdminUserInfo()
  7658. errlog := &models.HisOrderError{
  7659. UserOrgId: adminUser.CurrentOrgId,
  7660. Ctime: time.Now().Unix(),
  7661. Mtime: time.Now().Unix(),
  7662. ErrMsg: res2.ErrMsg,
  7663. Status: 1,
  7664. PatientId: id,
  7665. RecordTime: recordDateTime,
  7666. Stage: 3,
  7667. }
  7668. service.CreateErrMsgLog(errlog)
  7669. c.ServeSuccessJSON(map[string]interface{}{
  7670. "failed_code": -10,
  7671. "msg": res2.ErrMsg,
  7672. })
  7673. return
  7674. } else {
  7675. his.Diagnosis = diagnosis_id
  7676. his.SickType = sickConfig.ID
  7677. his.PType = fmt.Sprintf("%d", reg_type)
  7678. service.UpdateHisPatientThree(&his)
  7679. data := make(map[string]interface{})
  7680. if settle_accounts_type == 1 { //日结
  7681. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7682. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7683. } else {
  7684. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7685. }
  7686. data["pre"] = prescriptions
  7687. } else { //月结
  7688. start_time_str := c.GetString("start_time")
  7689. end_time_str := c.GetString("end_time")
  7690. timeLayout := "2006-01-02"
  7691. loc, _ := time.LoadLocation("Local")
  7692. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7693. if err != nil {
  7694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7695. return
  7696. }
  7697. recordStartTime := theStartTime.Unix()
  7698. start_time = recordStartTime
  7699. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7700. if err != nil {
  7701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7702. return
  7703. }
  7704. recordEndTime := theEndTime.Unix()
  7705. end_time = recordEndTime
  7706. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7707. data["pre"] = prescriptions
  7708. }
  7709. client := &http.Client{}
  7710. data["psn_no"] = his.PsnNo
  7711. data["mdtrt_id"] = his.Number
  7712. data["chrg_bchno"] = chrg_bchno
  7713. data["org_name"] = miConfig.OrgName
  7714. data["doctor"] = roles.UserName
  7715. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7716. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7717. data["fixmedins_code"] = miConfig.Code
  7718. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7719. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7720. data["dept_code"] = "15"
  7721. } else {
  7722. data["dept_code"] = department.Number
  7723. }
  7724. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7725. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7726. data["secret_key"] = miConfig.SecretKey
  7727. data["url"] = miConfig.Url
  7728. data["ak"] = miConfig.AccessKey
  7729. data["new_doctor_name"] = patientPrescription.Doctor
  7730. data["diag_code"] = sickConfig.CountryCode
  7731. data["time_stamp"] = time_stamp
  7732. data["cainfo"] = miConfig.Cainfo
  7733. var ids []int64
  7734. for _, item := range prescriptions {
  7735. ids = append(ids, item.ID)
  7736. }
  7737. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7738. if config.IsOpen == 1 { //对接了医保,走医保流程
  7739. var res ResultFour
  7740. var resFour10265 ResultFour10265
  7741. if miConfig.MdtrtareaAdmvs == "421300" {
  7742. bytesData, _ := json.Marshal(data)
  7743. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7744. resp, _ := client.Do(req)
  7745. defer resp.Body.Close()
  7746. body, ioErr := ioutil.ReadAll(resp.Body)
  7747. if ioErr != nil {
  7748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7750. return
  7751. }
  7752. var respJSON map[string]interface{}
  7753. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7756. return
  7757. }
  7758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7759. userJSONBytes, _ := json.Marshal(respJSON)
  7760. fmt.Println("log")
  7761. fmt.Println(string(userJSONBytes))
  7762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7763. utils.ErrorLog("解析失败:%v", err)
  7764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7765. return
  7766. }
  7767. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7768. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7769. if result3101.Infcode == "0" {
  7770. if len(result3101.Output.Result) > 0 {
  7771. var errMsgs []string
  7772. for _, item := range result3101.Output.Result {
  7773. errMsgs = append(errMsgs, item.VolaCont)
  7774. }
  7775. c.ServeSuccessJSON(map[string]interface{}{
  7776. "failed_code": -10,
  7777. "msg": errMsgs,
  7778. })
  7779. return
  7780. } else {
  7781. bytesData, _ := json.Marshal(data)
  7782. var req *http.Request
  7783. if miConfig.MdtrtareaAdmvs == "320921" {
  7784. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7785. } else {
  7786. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7787. }
  7788. resp, _ := client.Do(req)
  7789. defer resp.Body.Close()
  7790. body, ioErr := ioutil.ReadAll(resp.Body)
  7791. if ioErr != nil {
  7792. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7794. return
  7795. }
  7796. var respJSON map[string]interface{}
  7797. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7800. return
  7801. }
  7802. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7803. userJSONBytes, _ := json.Marshal(respJSON)
  7804. fmt.Println("log")
  7805. fmt.Println(string(userJSONBytes))
  7806. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7807. utils.ErrorLog("解析失败:%v", err)
  7808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. return
  7810. }
  7811. res.InfRefmsgid = resFour10265.InfRefmsgid
  7812. res.Output = resFour10265.Output
  7813. res.ErrMsg = resFour10265.ErrMsg
  7814. res.Cainfo = resFour10265.Cainfo
  7815. res.WarnMsg = resFour10265.WarnMsg
  7816. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7817. res.Infcode = infocode
  7818. }
  7819. }
  7820. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7821. 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)
  7822. var dat map[string]interface{}
  7823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7824. fmt.Println(dat)
  7825. } else {
  7826. fmt.Println(err)
  7827. }
  7828. saveLog(result, request_log, "2204", "上传费用明细")
  7829. userJSONBytes, _ := json.Marshal(dat)
  7830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7831. utils.ErrorLog("解析失败:%v", err)
  7832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7833. return
  7834. }
  7835. } else {
  7836. if miConfig.Code == "H15049901371" {
  7837. 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)
  7838. var dat map[string]interface{}
  7839. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7840. fmt.Println(dat)
  7841. } else {
  7842. fmt.Println(err)
  7843. }
  7844. saveLog(result, request_log, "2204", "上传费用明细")
  7845. userJSONBytes, _ := json.Marshal(dat)
  7846. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7847. utils.ErrorLog("解析失败:%v", err)
  7848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7849. return
  7850. }
  7851. res.InfRefmsgid = resFour10265.InfRefmsgid
  7852. res.Output = resFour10265.Output
  7853. res.ErrMsg = resFour10265.ErrMsg
  7854. res.Cainfo = resFour10265.Cainfo
  7855. res.WarnMsg = resFour10265.WarnMsg
  7856. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7857. res.Infcode = infocode
  7858. } else {
  7859. 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)
  7860. var dat map[string]interface{}
  7861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7862. fmt.Println(dat)
  7863. } else {
  7864. fmt.Println(err)
  7865. }
  7866. saveLog(result, request_log, "2204", "上传费用明细")
  7867. userJSONBytes, _ := json.Marshal(dat)
  7868. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7869. utils.ErrorLog("解析失败:%v", err)
  7870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7871. return
  7872. }
  7873. }
  7874. }
  7875. if res.Infcode == 0 {
  7876. order := &models.HisOrder{
  7877. UserOrgId: adminUser.CurrentOrgId,
  7878. HisPatientId: his.ID,
  7879. PatientId: his.PatientId,
  7880. SettleAccountsDate: recordDateTime,
  7881. Ctime: time.Now().Unix(),
  7882. Mtime: time.Now().Unix(),
  7883. MdtrtId: his.Number,
  7884. PsnNo: his.PsnNo,
  7885. MedType: strconv.FormatInt(reg_type, 10),
  7886. Status: 1,
  7887. Number: chrg_bchno,
  7888. Infcode: res.Infcode,
  7889. WarnMsg: res.WarnMsg,
  7890. Cainfo: res.Cainfo,
  7891. ErrMsg: res.ErrMsg,
  7892. RespondTime: res.RefmsgTime,
  7893. InfRefmsgid: res.InfRefmsgid,
  7894. OrderStatus: 1,
  7895. IsMedicineInsurance: 1,
  7896. SettleType: settle_accounts_type,
  7897. SettleStartTime: start_time,
  7898. SettleEndTime: end_time,
  7899. Creator: roles.AdminUserId,
  7900. Modify: roles.AdminUserId,
  7901. PType: 2,
  7902. Diagnosis: diagnosis_id,
  7903. }
  7904. err = service.CreateOrder(order)
  7905. if err != nil {
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7907. return
  7908. }
  7909. for _, item := range res.Output.Result {
  7910. temp := strings.Split(item.FeedetlSn, "-")
  7911. var advice_id int64 = 0
  7912. var project_id int64 = 0
  7913. var types int64 = 0
  7914. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7915. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7916. if temp[1] == "1" {
  7917. advice_id = id
  7918. project_id = 0
  7919. } else if temp[1] == "2" {
  7920. advice_id = 0
  7921. project_id = id
  7922. }
  7923. info := &models.HisOrderInfo{
  7924. OrderNumber: order.Number,
  7925. FeedetlSn: item.FeedetlSn,
  7926. UploadDate: time.Now().Unix(),
  7927. AdviceId: advice_id,
  7928. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7929. Cnt: item.Cnt,
  7930. Pric: float64(item.Pric),
  7931. PatientId: his.PatientId,
  7932. PricUplmtAmt: item.PricUplmtAmt,
  7933. SelfpayProp: item.SelfpayProp,
  7934. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7935. OverlmtAmt: item.OverlmtAmt,
  7936. PreselfpayAmt: item.PreselfpayAmt,
  7937. BasMednFlag: item.BasMednFlag,
  7938. MedChrgitmType: item.MedChrgitmType,
  7939. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7940. Status: 1,
  7941. Memo: item.Memo,
  7942. Mtime: time.Now().Unix(),
  7943. InscpScpAmt: item.InscpScpAmt,
  7944. DrtReimFlag: item.DrtReimFlag,
  7945. Ctime: time.Now().Unix(),
  7946. ListSpItemFlag: item.ListSpItemFlag,
  7947. ChldMedcFlag: item.ChldMedcFlag,
  7948. LmtUsedFlag: item.LmtUsedFlag,
  7949. ChrgitmLv: item.ChrgitmLv,
  7950. UserOrgId: adminUser.CurrentOrgId,
  7951. HisPatientId: his.ID,
  7952. OrderId: order.ID,
  7953. ProjectId: project_id,
  7954. Type: types,
  7955. }
  7956. service.CreateOrderInfo(info)
  7957. }
  7958. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7959. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7960. var total float64
  7961. for _, item := range prescriptions {
  7962. if item.Type == 1 { //药品
  7963. for _, subItem := range item.HisDoctorAdviceInfo {
  7964. total = total + (subItem.Price * subItem.PrescribingNumber)
  7965. }
  7966. }
  7967. if item.Type == 2 { //项目
  7968. for _, subItem := range item.HisPrescriptionProject {
  7969. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7970. total = total + (subItem.Price * cnt)
  7971. }
  7972. }
  7973. }
  7974. for _, item := range prescriptions {
  7975. for _, subItem := range item.HisAdditionalCharge {
  7976. total = total + (subItem.Price * float64(subItem.Count))
  7977. }
  7978. }
  7979. allTotal := fmt.Sprintf("%.4f", total)
  7980. if res.Infcode == 0 {
  7981. var rf []*ResultFive
  7982. json.Unmarshal([]byte(his.Iinfo), &rf)
  7983. chrg_bchno := chrg_bchno
  7984. cert_no := his.Certno
  7985. var insutypes []string
  7986. var insutype string
  7987. var is390 int = 0
  7988. var is310 int = 0
  7989. for _, item := range rf {
  7990. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7991. insutypes = append(insutypes, item.Insutype)
  7992. }
  7993. }
  7994. if len(insutypes) == 1 {
  7995. insutype = insutypes[0]
  7996. } else {
  7997. for _, i := range insutypes {
  7998. if i == "390" {
  7999. is390 = 1
  8000. }
  8001. if i == "310" {
  8002. is310 = 1
  8003. }
  8004. }
  8005. }
  8006. if is390 == 1 {
  8007. insutype = "390"
  8008. }
  8009. if is310 == 1 {
  8010. insutype = "310"
  8011. }
  8012. if len(insutypes) == 0 {
  8013. insutype = "310"
  8014. }
  8015. if len(insutypes) == 2 {
  8016. insutype = strconv.FormatInt(his.SocialType, 64)
  8017. }
  8018. //insutype = "390"
  8019. if his.IdCardType == 1 {
  8020. cert_no = his.MedicalInsuranceNumber
  8021. } else {
  8022. cert_no = his.Certno
  8023. }
  8024. var res ResultSeven
  8025. var resSeven10265 ResultSeven10265
  8026. if miConfig.MdtrtareaAdmvs == "421300" {
  8027. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8028. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8029. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8030. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8031. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8032. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8033. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  8034. resp, requestErr := http.Get(api)
  8035. if requestErr != nil {
  8036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8037. return
  8038. }
  8039. body, ioErr := ioutil.ReadAll(resp.Body)
  8040. if ioErr != nil {
  8041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8043. return
  8044. }
  8045. var respJSON map[string]interface{}
  8046. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8049. return
  8050. }
  8051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8052. result, _ := json.Marshal(respJSON)
  8053. fmt.Println("log")
  8054. fmt.Println(string(result))
  8055. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8056. utils.ErrorLog("解析失败:%v", err)
  8057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8058. return
  8059. }
  8060. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8061. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  8062. if result3101.Infcode == "0" {
  8063. if len(result3101.Output.Result) > 0 {
  8064. var errMsgs []string
  8065. for _, item := range result3101.Output.Result {
  8066. errMsgs = append(errMsgs, item.VolaCont)
  8067. }
  8068. c.ServeSuccessJSON(map[string]interface{}{
  8069. "failed_code": -10,
  8070. "msg": errMsgs,
  8071. })
  8072. return
  8073. } else {
  8074. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8075. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8076. bas := strings.Split(psn_info.CardInfo, "|")
  8077. if his.IdCardType == 1 {
  8078. cert_no = bas[2]
  8079. } else {
  8080. cert_no = bas[1]
  8081. }
  8082. //江苏地区国家医保医疗类别
  8083. //职工透析:医疗类别选特殊情况门诊9933
  8084. //居民血透门慢: 医疗类别选门诊慢病1402
  8085. //var med_type string
  8086. //if his.Insutype == "310" {
  8087. // if reg_type == 14 {
  8088. // med_type = "9933"
  8089. // } else if reg_type == 11 {
  8090. // med_type = "11"
  8091. //
  8092. // }
  8093. //} else if his.Insutype == "390" {
  8094. // if reg_type == 14 {
  8095. // med_type = "1402"
  8096. // } else if reg_type == 11 {
  8097. // med_type = "11"
  8098. // }
  8099. //}
  8100. var api string
  8101. if miConfig.MdtrtareaAdmvs == "320921" {
  8102. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8103. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8104. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8106. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8107. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8108. "&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
  8109. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8110. } else {
  8111. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8112. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8113. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8114. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8115. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8116. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8117. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8118. "&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
  8119. }
  8120. resp, requestErr := http.Get(api)
  8121. if requestErr != nil {
  8122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8123. return
  8124. }
  8125. body, ioErr := ioutil.ReadAll(resp.Body)
  8126. if ioErr != nil {
  8127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8129. return
  8130. }
  8131. var respJSON map[string]interface{}
  8132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8135. return
  8136. }
  8137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8138. result, _ := json.Marshal(respJSON)
  8139. fmt.Println("log")
  8140. fmt.Println(string(result))
  8141. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8142. utils.ErrorLog("解析失败:%v", err)
  8143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8144. return
  8145. }
  8146. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8147. res.Output = resSeven10265.Output
  8148. res.ErrMsg = resSeven10265.ErrMsg
  8149. res.Cainfo = resSeven10265.Cainfo
  8150. res.WarnMsg = resSeven10265.WarnMsg
  8151. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8152. res.Infcode = infocode
  8153. }
  8154. }
  8155. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8156. 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)
  8157. var dat map[string]interface{}
  8158. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8159. fmt.Println(dat)
  8160. } else {
  8161. fmt.Println(err)
  8162. }
  8163. saveLog(result, request_log, "2206", "预结算")
  8164. userJSONBytes, _ := json.Marshal(dat)
  8165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8166. utils.ErrorLog("解析失败:%v", err)
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8168. return
  8169. }
  8170. } else {
  8171. var result string
  8172. var request_log string
  8173. if miConfig.Code == "H15049901371" {
  8174. //赤峰地区国家医保医疗类别
  8175. //职工透析:医疗类别选特殊情况门诊990502
  8176. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8177. var med_type string
  8178. if his.Insutype == "390" {
  8179. if reg_type == 14 {
  8180. med_type = "9933"
  8181. } else if reg_type == 11 {
  8182. med_type = "11"
  8183. }
  8184. } else if his.Insutype == "310" {
  8185. if reg_type == 14 {
  8186. med_type = "990502"
  8187. } else if reg_type == 11 {
  8188. med_type = "11"
  8189. }
  8190. }
  8191. 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)
  8192. } else {
  8193. 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)
  8194. }
  8195. var dat map[string]interface{}
  8196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8197. fmt.Println(dat)
  8198. } else {
  8199. fmt.Println(err)
  8200. }
  8201. saveLog(result, request_log, "2206", "预结算")
  8202. //userJSONBytes, _ := json.Marshal(dat)
  8203. //
  8204. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8205. // utils.ErrorLog("解析失败:%v", err)
  8206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8207. // return
  8208. //}
  8209. userJSONBytes, _ := json.Marshal(dat)
  8210. if miConfig.Code == "H15049901371" {
  8211. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8212. utils.ErrorLog("解析失败:%v", err)
  8213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8214. return
  8215. }
  8216. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8217. res.Output = resSeven10265.Output
  8218. res.ErrMsg = resSeven10265.ErrMsg
  8219. res.Cainfo = resSeven10265.Cainfo
  8220. res.WarnMsg = resSeven10265.WarnMsg
  8221. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8222. res.Infcode = infocode
  8223. } else {
  8224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8225. utils.ErrorLog("解析失败:%v", err)
  8226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8227. return
  8228. }
  8229. }
  8230. }
  8231. if res.Infcode != 0 {
  8232. errlog := &models.HisOrderError{
  8233. UserOrgId: adminUser.CurrentOrgId,
  8234. Ctime: time.Now().Unix(),
  8235. Mtime: time.Now().Unix(),
  8236. Number: chrg_bchno,
  8237. ErrMsg: res.ErrMsg,
  8238. Status: 1,
  8239. PatientId: id,
  8240. RecordTime: recordDateTime,
  8241. Stage: 20,
  8242. }
  8243. service.CreateErrMsgLog(errlog)
  8244. c.ServeSuccessJSON(map[string]interface{}{
  8245. "failed_code": -10,
  8246. "msg": res.ErrMsg,
  8247. })
  8248. return
  8249. } else {
  8250. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8251. order.OrderStatus = 1
  8252. order.IsPre = 1
  8253. order.Status = 1
  8254. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8255. order.SetlId = res.Output.Setlinfo.SetlID
  8256. order.PsnNo = res.Output.Setlinfo.PsnNo
  8257. order.PsnName = res.Output.Setlinfo.PsnName
  8258. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8259. order.Certno = res.Output.Setlinfo.Certno
  8260. order.Gend = res.Output.Setlinfo.Gend
  8261. order.Naty = res.Output.Setlinfo.Naty
  8262. order.Age = res.Output.Setlinfo.Age
  8263. order.Insutype = res.Output.Setlinfo.Insutype
  8264. order.PsnType = res.Output.Setlinfo.PsnType
  8265. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8266. order.SetlTime = res.Output.Setlinfo.SetlTime
  8267. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8268. if res.Output.Setlinfo.MedType == "140101" {
  8269. order.MedType = "14"
  8270. } else {
  8271. order.MedType = res.Output.Setlinfo.MedType
  8272. }
  8273. if reg_type == 1112 {
  8274. order.MedType = "1112"
  8275. }
  8276. if reg_type == 1111 {
  8277. order.MedType = "1111"
  8278. }
  8279. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8280. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8281. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8282. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8283. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8284. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8285. order.HifpPay = res.Output.Setlinfo.HifpPay
  8286. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8287. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8288. order.HifesPay = res.Output.Setlinfo.HifesPay
  8289. order.HifobPay = res.Output.Setlinfo.HifobPay
  8290. order.MafPay = res.Output.Setlinfo.MafPay
  8291. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8292. order.OthPay = res.Output.Setlinfo.OthPay
  8293. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8294. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8295. order.AcctPay = res.Output.Setlinfo.AcctPay
  8296. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8297. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8298. order.Balc = res.Output.Setlinfo.Balc
  8299. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8300. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8301. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8302. order.ClrWay = res.Output.Setlinfo.ClrWay
  8303. order.Creator = order.Creator
  8304. order.Modify = roles.AdminUserId
  8305. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8306. detailStr := string(setlDetail)
  8307. order.SetlDetail = detailStr
  8308. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8309. err = service.UpDateOrder(order)
  8310. if err == nil {
  8311. c.ServeSuccessJSON(map[string]interface{}{
  8312. "msg": "预结算成功",
  8313. })
  8314. } else {
  8315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8316. return
  8317. }
  8318. }
  8319. } else {
  8320. adminUser := c.GetAdminUserInfo()
  8321. errlog := &models.HisOrderError{
  8322. UserOrgId: adminUser.CurrentOrgId,
  8323. Ctime: time.Now().Unix(),
  8324. Mtime: time.Now().Unix(),
  8325. ErrMsg: res.ErrMsg,
  8326. Status: 1,
  8327. PatientId: id,
  8328. RecordTime: recordDateTime,
  8329. Stage: 4,
  8330. }
  8331. service.CreateErrMsgLog(errlog)
  8332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8333. return
  8334. }
  8335. } else {
  8336. adminUser := c.GetAdminUserInfo()
  8337. errlog := &models.HisOrderError{
  8338. UserOrgId: adminUser.CurrentOrgId,
  8339. Ctime: time.Now().Unix(),
  8340. Mtime: time.Now().Unix(),
  8341. ErrMsg: res.ErrMsg,
  8342. Status: 1,
  8343. PatientId: id,
  8344. RecordTime: recordDateTime,
  8345. Stage: 4,
  8346. }
  8347. service.CreateErrMsgLog(errlog)
  8348. c.ServeSuccessJSON(map[string]interface{}{
  8349. "failed_code": -10,
  8350. "msg": res.ErrMsg,
  8351. })
  8352. return
  8353. }
  8354. }
  8355. }
  8356. }
  8357. //退款
  8358. func (c *HisApiController) Refund() {
  8359. order_id, _ := c.GetInt64("order_id")
  8360. admin_user_id, _ := c.GetInt64("admin_user_id")
  8361. adminUser := c.GetAdminUserInfo()
  8362. var order models.HisOrder
  8363. order, _ = service.GetHisOrderByID(order_id)
  8364. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8365. if order.ID == 0 {
  8366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8367. return
  8368. }
  8369. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8370. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8371. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8372. if config.IsOpen == 1 { //对接了医保,走医保流程
  8373. var res ResultSixteen
  8374. var resSixteen10265 ResultSixteen10265
  8375. var src_resquest string
  8376. var result string
  8377. if miConfig.MdtrtareaAdmvs == "421300" {
  8378. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8379. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8380. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8381. resp3, requestErr3 := http.Get(api3)
  8382. if requestErr3 != nil {
  8383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8384. return
  8385. }
  8386. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8387. if ioErr3 != nil {
  8388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8390. return
  8391. }
  8392. var respJSON3 map[string]interface{}
  8393. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. return
  8397. }
  8398. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8399. userJSONBytes3, _ := json.Marshal(respJSON3)
  8400. fmt.Println("log")
  8401. fmt.Println(string(userJSONBytes3))
  8402. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8403. utils.ErrorLog("解析失败:%v", err)
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8405. return
  8406. }
  8407. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8408. var api3 string
  8409. if miConfig.MdtrtareaAdmvs == "320921" {
  8410. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8411. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8412. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8413. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8414. } else {
  8415. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8416. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8417. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8418. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8419. }
  8420. resp3, requestErr3 := http.Get(api3)
  8421. if requestErr3 != nil {
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8426. if ioErr3 != nil {
  8427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8429. return
  8430. }
  8431. var respJSON3 map[string]interface{}
  8432. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8435. return
  8436. }
  8437. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8438. userJSONBytes3, _ := json.Marshal(respJSON3)
  8439. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8440. utils.ErrorLog("解析失败:%v", err)
  8441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8442. return
  8443. }
  8444. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8445. res.Output = resSixteen10265.Output
  8446. res.ErrMsg = resSixteen10265.ErrMsg
  8447. res.Cainfo = resSixteen10265.Cainfo
  8448. res.WarnMsg = resSixteen10265.WarnMsg
  8449. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8450. res.Infcode = infocode
  8451. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8452. 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)
  8453. var dat map[string]interface{}
  8454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8455. fmt.Println(dat)
  8456. } else {
  8457. fmt.Println(err)
  8458. }
  8459. saveLog(result, src_resquest, "2208", "退费")
  8460. userJSONBytes, _ := json.Marshal(dat)
  8461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8462. utils.ErrorLog("解析失败:%v", err)
  8463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8464. return
  8465. }
  8466. } else {
  8467. if miConfig.Code == "H15049901371" {
  8468. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8469. var dat map[string]interface{}
  8470. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8471. fmt.Println(dat)
  8472. } else {
  8473. fmt.Println(err)
  8474. }
  8475. saveLog(result, src_resquest, "2208", "退费")
  8476. userJSONBytes, _ := json.Marshal(dat)
  8477. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8478. utils.ErrorLog("解析失败:%v", err)
  8479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8480. return
  8481. }
  8482. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8483. res.Output = resSixteen10265.Output
  8484. res.ErrMsg = resSixteen10265.ErrMsg
  8485. res.Cainfo = resSixteen10265.Cainfo
  8486. res.WarnMsg = resSixteen10265.WarnMsg
  8487. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8488. res.Infcode = infocode
  8489. } else {
  8490. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8491. var dat map[string]interface{}
  8492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8493. fmt.Println(dat)
  8494. } else {
  8495. fmt.Println(err)
  8496. }
  8497. saveLog(result, src_resquest, "2208", "退费")
  8498. userJSONBytes, _ := json.Marshal(dat)
  8499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8500. utils.ErrorLog("解析失败:%v", err)
  8501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8502. return
  8503. }
  8504. }
  8505. }
  8506. if res.Infcode == 0 {
  8507. var res2 ResultSix
  8508. var resSix10265 ResultSix10265
  8509. if miConfig.MdtrtareaAdmvs == "421300" {
  8510. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8511. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8512. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8513. resp3, requestErr3 := http.Get(api3)
  8514. if requestErr3 != nil {
  8515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. return
  8517. }
  8518. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8519. if ioErr3 != nil {
  8520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8522. return
  8523. }
  8524. var respJSON3 map[string]interface{}
  8525. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8531. userJSONBytes3, _ := json.Marshal(respJSON3)
  8532. fmt.Println("log")
  8533. fmt.Println(string(userJSONBytes3))
  8534. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8535. utils.ErrorLog("解析失败:%v", err)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8540. var api3 string
  8541. if miConfig.MdtrtareaAdmvs == "320921" {
  8542. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8543. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8544. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8545. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8546. } else {
  8547. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8548. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8549. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8550. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8551. }
  8552. resp3, requestErr3 := http.Get(api3)
  8553. if requestErr3 != nil {
  8554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8555. return
  8556. }
  8557. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8558. if ioErr3 != nil {
  8559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8561. return
  8562. }
  8563. var respJSON3 map[string]interface{}
  8564. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8567. return
  8568. }
  8569. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8570. userJSONBytes3, _ := json.Marshal(respJSON3)
  8571. fmt.Println("log")
  8572. fmt.Println(string(userJSONBytes3))
  8573. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8574. utils.ErrorLog("解析失败:%v", err)
  8575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8576. return
  8577. }
  8578. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8579. res2.Output = resSix10265.Output
  8580. res2.ErrMsg = resSix10265.ErrMsg
  8581. res2.Cainfo = resSix10265.Cainfo
  8582. res2.WarnMsg = resSix10265.WarnMsg
  8583. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8584. res2.Infcode = infocode
  8585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8586. 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)
  8587. var dat map[string]interface{}
  8588. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8589. fmt.Println(dat)
  8590. } else {
  8591. fmt.Println(err)
  8592. }
  8593. saveLog(result2, src_request, "2205", "撤销明细")
  8594. userJSONBytes, _ := json.Marshal(dat)
  8595. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8596. utils.ErrorLog("解析失败:%v", err)
  8597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8598. return
  8599. }
  8600. } else {
  8601. if miConfig.Code == "H15049901371" {
  8602. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8603. var dat map[string]interface{}
  8604. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8605. fmt.Println(dat)
  8606. } else {
  8607. fmt.Println(err)
  8608. }
  8609. saveLog(result2, src_request, "2205", "撤销明细")
  8610. userJSONBytes, _ := json.Marshal(dat)
  8611. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8612. utils.ErrorLog("解析失败:%v", err)
  8613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8614. return
  8615. }
  8616. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8617. res2.Output = resSix10265.Output
  8618. res2.ErrMsg = resSix10265.ErrMsg
  8619. res2.Cainfo = resSix10265.Cainfo
  8620. res2.WarnMsg = resSix10265.WarnMsg
  8621. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8622. res2.Infcode = infocode
  8623. } else {
  8624. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8625. var dat map[string]interface{}
  8626. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8627. fmt.Println(dat)
  8628. } else {
  8629. fmt.Println(err)
  8630. }
  8631. saveLog(result2, src_request, "2205", "撤销明细")
  8632. userJSONBytes, _ := json.Marshal(dat)
  8633. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8634. utils.ErrorLog("解析失败:%v", err)
  8635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8636. return
  8637. }
  8638. }
  8639. }
  8640. if res2.Infcode == 0 {
  8641. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8642. if err == nil {
  8643. //当押金不为零时产生退费记录
  8644. if order.Decimal != 0 {
  8645. tmp := strconv.FormatInt(order.ID, 10)
  8646. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8647. if err != nil {
  8648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8649. return
  8650. }
  8651. }
  8652. c.ServeSuccessJSON(map[string]interface{}{
  8653. "msg": "退费成功",
  8654. })
  8655. } else {
  8656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8657. return
  8658. }
  8659. } else {
  8660. c.ServeSuccessJSON(map[string]interface{}{
  8661. "code": -10,
  8662. "msg": res2.ErrMsg,
  8663. })
  8664. }
  8665. } else {
  8666. c.ServeSuccessJSON(map[string]interface{}{
  8667. "code": -10,
  8668. "msg": res.ErrMsg,
  8669. })
  8670. }
  8671. }
  8672. }
  8673. func (c *HisApiController) RefundNumber() {
  8674. record_time := c.GetString("record_time")
  8675. //patient_id, _ := c.GetInt64("patient_id")
  8676. admin_user_id, _ := c.GetInt64("admin_user_id")
  8677. his_patient_id, _ := c.GetInt64("id")
  8678. timeLayout := "2006-01-02"
  8679. loc, _ := time.LoadLocation("Local")
  8680. adminUser := c.GetAdminUserInfo()
  8681. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8682. fmt.Println(err)
  8683. if err != nil {
  8684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8685. return
  8686. }
  8687. recordDateTime := theTime.Unix()
  8688. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8689. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8690. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8691. //order, _ := service.GetHisOrderByID(order_id)
  8692. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8693. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8694. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8695. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8696. if count > 0 {
  8697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8698. return
  8699. }
  8700. if config.IsOpen == 1 { //对接了医保,走医保流程
  8701. var res2 ResultSix
  8702. var resSix10265 ResultSix10265
  8703. if miConfig.MdtrtareaAdmvs == "421300" {
  8704. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8705. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8707. resp3, requestErr3 := http.Get(api3)
  8708. if requestErr3 != nil {
  8709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8710. return
  8711. }
  8712. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8713. if ioErr3 != nil {
  8714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8716. return
  8717. }
  8718. var respJSON3 map[string]interface{}
  8719. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8722. return
  8723. }
  8724. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8725. userJSONBytes3, _ := json.Marshal(respJSON3)
  8726. fmt.Println("log")
  8727. fmt.Println(string(userJSONBytes3))
  8728. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8729. utils.ErrorLog("解析失败:%v", err)
  8730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8731. return
  8732. }
  8733. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8734. var api3 string
  8735. if miConfig.MdtrtareaAdmvs == "320921" {
  8736. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8737. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8738. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8739. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8740. } else {
  8741. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8742. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8743. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8745. }
  8746. resp3, requestErr3 := http.Get(api3)
  8747. if requestErr3 != nil {
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8749. return
  8750. }
  8751. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8752. if ioErr3 != nil {
  8753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8755. return
  8756. }
  8757. var respJSON3 map[string]interface{}
  8758. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8761. return
  8762. }
  8763. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8764. userJSONBytes3, _ := json.Marshal(respJSON3)
  8765. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8766. utils.ErrorLog("解析失败:%v", err)
  8767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8768. return
  8769. }
  8770. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8771. res2.Output = resSix10265.Output
  8772. res2.ErrMsg = resSix10265.ErrMsg
  8773. res2.Cainfo = resSix10265.Cainfo
  8774. res2.WarnMsg = resSix10265.WarnMsg
  8775. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8776. res2.Infcode = infocode
  8777. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8778. 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)
  8779. var dat map[string]interface{}
  8780. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8781. fmt.Println(dat)
  8782. } else {
  8783. fmt.Println(err)
  8784. }
  8785. saveLog(result, request, "2202", "退号")
  8786. userJSONBytes, _ := json.Marshal(dat)
  8787. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8788. utils.ErrorLog("解析失败:%v", err)
  8789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8790. return
  8791. }
  8792. } else {
  8793. var api3 string
  8794. if miConfig.Code == "H15049901371" {
  8795. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8796. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8798. } else {
  8799. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8800. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8801. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8802. }
  8803. resp3, requestErr3 := http.Get(api3)
  8804. if requestErr3 != nil {
  8805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8806. return
  8807. }
  8808. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8809. if ioErr3 != nil {
  8810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8812. return
  8813. }
  8814. var respJSON3 map[string]interface{}
  8815. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8818. return
  8819. }
  8820. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8821. userJSONBytes3, _ := json.Marshal(respJSON3)
  8822. if miConfig.Code == "H15049901371" {
  8823. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8824. utils.ErrorLog("解析失败:%v", err)
  8825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8826. return
  8827. }
  8828. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8829. res2.Output = resSix10265.Output
  8830. res2.ErrMsg = resSix10265.ErrMsg
  8831. res2.Cainfo = resSix10265.Cainfo
  8832. res2.WarnMsg = resSix10265.WarnMsg
  8833. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8834. res2.Infcode = infocode
  8835. } else {
  8836. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8837. utils.ErrorLog("解析失败:%v", err)
  8838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8839. return
  8840. }
  8841. }
  8842. }
  8843. if res2.Infcode == 0 {
  8844. if err == nil {
  8845. c.ServeSuccessJSON(map[string]interface{}{
  8846. "msg": "退号成功",
  8847. })
  8848. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8849. } else {
  8850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8851. return
  8852. }
  8853. } else {
  8854. c.ServeSuccessJSON(map[string]interface{}{
  8855. "code": -10,
  8856. "msg": res2.ErrMsg,
  8857. })
  8858. }
  8859. } else {
  8860. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8861. //if err == nil {
  8862. // c.ServeSuccessJSON(map[string]interface{}{
  8863. // "msg": "退费成功",
  8864. // })
  8865. //} else {
  8866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8867. // return
  8868. //}
  8869. }
  8870. }
  8871. func (c *HisApiController) RefundDetail() {
  8872. order_id, _ := c.GetInt64("order_id")
  8873. admin_user_id, _ := c.GetInt64("admin_user_id")
  8874. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8875. number := c.GetString("number")
  8876. record_time := c.GetString("record_time")
  8877. patient_id, _ := c.GetInt64("patient_id")
  8878. //med_type, _ := c.GetInt64("med_type")
  8879. timeLayout := "2006-01-02"
  8880. loc, _ := time.LoadLocation("Local")
  8881. adminUser := c.GetAdminUserInfo()
  8882. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8883. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8884. fmt.Println(err)
  8885. if err != nil {
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8887. return
  8888. }
  8889. recordDateTime := theTime.Unix()
  8890. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8891. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8893. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8894. var order models.HisOrder
  8895. order, _ = service.GetHisOrderByID(order_id)
  8896. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8897. if config.IsOpen == 1 { //对接了医保,走医保流程
  8898. var res2 ResultSix
  8899. if miConfig.MdtrtareaAdmvs == "421300" {
  8900. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8901. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8903. resp3, requestErr3 := http.Get(api3)
  8904. if requestErr3 != nil {
  8905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8906. return
  8907. }
  8908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8909. if ioErr3 != nil {
  8910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8912. return
  8913. }
  8914. var respJSON3 map[string]interface{}
  8915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8918. return
  8919. }
  8920. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8921. userJSONBytes3, _ := json.Marshal(respJSON3)
  8922. fmt.Println("log")
  8923. fmt.Println(string(userJSONBytes3))
  8924. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8925. utils.ErrorLog("解析失败:%v", err)
  8926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8927. return
  8928. }
  8929. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8930. if err == nil {
  8931. c.ServeSuccessJSON(map[string]interface{}{
  8932. "msg": "撤销明细成功",
  8933. })
  8934. return
  8935. } else {
  8936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8937. return
  8938. }
  8939. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8940. var resSix10265 ResultSix10265
  8941. var api3 string
  8942. if miConfig.MdtrtareaAdmvs == "320921" {
  8943. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8944. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8945. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8946. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8947. } else {
  8948. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8949. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8950. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8951. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8952. }
  8953. resp3, requestErr3 := http.Get(api3)
  8954. if requestErr3 != nil {
  8955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8956. return
  8957. }
  8958. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8959. if ioErr3 != nil {
  8960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8962. return
  8963. }
  8964. var respJSON3 map[string]interface{}
  8965. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8968. return
  8969. }
  8970. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8971. userJSONBytes3, _ := json.Marshal(respJSON3)
  8972. fmt.Println("log")
  8973. fmt.Println(string(userJSONBytes3))
  8974. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8975. utils.ErrorLog("解析失败:%v", err)
  8976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8977. return
  8978. }
  8979. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8980. res2.Output = resSix10265.Output
  8981. res2.ErrMsg = resSix10265.ErrMsg
  8982. res2.Cainfo = resSix10265.Cainfo
  8983. res2.WarnMsg = resSix10265.WarnMsg
  8984. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8985. res2.Infcode = infocode
  8986. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8987. if err == nil {
  8988. c.ServeSuccessJSON(map[string]interface{}{
  8989. "msg": "撤销明细成功",
  8990. })
  8991. return
  8992. } else {
  8993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8994. return
  8995. }
  8996. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8997. 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)
  8998. var dat map[string]interface{}
  8999. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9000. fmt.Println(dat)
  9001. } else {
  9002. fmt.Println(err)
  9003. }
  9004. saveLog(result2, src_request, "2205", "撤销明细")
  9005. userJSONBytes, _ := json.Marshal(dat)
  9006. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9007. utils.ErrorLog("解析失败:%v", err)
  9008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9009. return
  9010. }
  9011. if res2.Infcode == 0 {
  9012. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9013. if err == nil {
  9014. c.ServeSuccessJSON(map[string]interface{}{
  9015. "msg": "撤销明细成功",
  9016. })
  9017. return
  9018. } else {
  9019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9020. return
  9021. }
  9022. } else {
  9023. c.ServeSuccessJSON(map[string]interface{}{
  9024. "code": -10,
  9025. "msg": res2.ErrMsg,
  9026. })
  9027. }
  9028. } else {
  9029. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  9030. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9031. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9032. resp2, requestErr2 := http.Get(api2)
  9033. if requestErr2 != nil {
  9034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9035. return
  9036. }
  9037. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9038. if ioErr2 != nil {
  9039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9041. return
  9042. }
  9043. var respJSON2 map[string]interface{}
  9044. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9047. return
  9048. }
  9049. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9050. if err == nil {
  9051. c.ServeSuccessJSON(map[string]interface{}{
  9052. "msg": "撤销明细成功",
  9053. })
  9054. return
  9055. } else {
  9056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9057. return
  9058. }
  9059. }
  9060. } else {
  9061. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9062. if err == nil {
  9063. c.ServeSuccessJSON(map[string]interface{}{
  9064. "msg": "退费成功",
  9065. })
  9066. } else {
  9067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9068. return
  9069. }
  9070. }
  9071. }
  9072. //对账
  9073. func (c *HisApiController) GetCheckAccount() {
  9074. start_time := c.GetString("start_time")
  9075. end_time := c.GetString("end_time")
  9076. insutype := c.GetString("insutype")
  9077. clr_type := c.GetString("clr_type")
  9078. clr_org := c.GetString("clr_optins")
  9079. admin_user_id, _ := c.GetInt64("admin_user_id")
  9080. adminUser := c.GetAdminUserInfo()
  9081. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9082. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9083. if len(clr_org) == 0 {
  9084. clr_org = miConfig.MdtrtareaAdmvs
  9085. }
  9086. timeLayout := "2006-01-02"
  9087. loc, _ := time.LoadLocation("Local")
  9088. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9089. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9090. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9091. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9092. fixmedins_setl_cnt := int64(len(orders))
  9093. var medfee_sumamt float64
  9094. var acct_pay float64
  9095. var fund_pay_sumamt float64
  9096. for _, item := range orders {
  9097. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9098. acct_pay = acct_pay + item.AcctPay
  9099. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9100. }
  9101. var user_name string
  9102. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9103. if role.ID == 0 {
  9104. user_name = "xxx"
  9105. } else {
  9106. user_name = role.UserName
  9107. }
  9108. var res ResultEight
  9109. var res10188 ResultEightFor10188
  9110. if config.IsOpen == 1 {
  9111. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9112. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  9113. "insutype=" + insutype +
  9114. "&clr_type=" + clr_type +
  9115. "&setl_optins=" + clr_org +
  9116. "&stmt_begndate=" + start_time +
  9117. "&stm_enddate=" + end_time +
  9118. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9119. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9120. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9121. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9122. "&fixmedins_code=" + miConfig.Code +
  9123. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9124. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9125. "&secret_key=" + miConfig.SecretKey +
  9126. "&org_name=" + miConfig.OrgName +
  9127. "&doctor=" + user_name +
  9128. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9129. fmt.Println(api)
  9130. resp, requestErr := http.Get(api)
  9131. if requestErr != nil {
  9132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9133. return
  9134. }
  9135. body, ioErr := ioutil.ReadAll(resp.Body)
  9136. fmt.Println(body)
  9137. if ioErr != nil {
  9138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9140. return
  9141. }
  9142. var respJSON map[string]interface{}
  9143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9146. return
  9147. }
  9148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9149. userJSONBytes, _ := json.Marshal(respJSON)
  9150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9151. utils.ErrorLog("解析失败:%v", err)
  9152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9153. return
  9154. }
  9155. res.InfRefmsgid = res10188.InfRefmsgid
  9156. res.Output = res10188.Output
  9157. res.ErrMsg = res10188.ErrMsg
  9158. res.Cainfo = res10188.Cainfo
  9159. res.WarnMsg = res10188.WarnMsg
  9160. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9161. res.Infcode = infocode
  9162. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9163. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  9164. "insutype=" + insutype +
  9165. "&clr_type=" + "21" +
  9166. "&setl_optins=" + clr_org +
  9167. "&stmt_begndate=" + start_time +
  9168. "&stm_enddate=" + end_time +
  9169. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9170. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9171. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9172. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9173. "&fixmedins_code=" + miConfig.Code +
  9174. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9175. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9176. "&secret_key=" + miConfig.SecretKey +
  9177. "&org_name=" + miConfig.OrgName +
  9178. "&doctor=" + user_name
  9179. resp, requestErr := http.Get(api)
  9180. if requestErr != nil {
  9181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9182. return
  9183. }
  9184. body, ioErr := ioutil.ReadAll(resp.Body)
  9185. if ioErr != nil {
  9186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. return
  9189. }
  9190. var respJSON map[string]interface{}
  9191. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9194. return
  9195. }
  9196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9197. result, _ := json.Marshal(respJSON)
  9198. fmt.Println("log")
  9199. fmt.Println(string(result))
  9200. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  9201. utils.ErrorLog("解析失败:%v", err)
  9202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9203. return
  9204. }
  9205. res.InfRefmsgid = res10188.InfRefmsgid
  9206. res.Output = res10188.Output
  9207. res.ErrMsg = res10188.ErrMsg
  9208. res.Cainfo = res10188.Cainfo
  9209. res.WarnMsg = res10188.WarnMsg
  9210. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9211. res.Infcode = infocode
  9212. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9213. var baseParams models.BaseParams
  9214. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9215. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9216. baseParams.SecretKey = miConfig.SecretKey
  9217. baseParams.OrgName = miConfig.OrgName
  9218. baseParams.FixmedinsCode = miConfig.Code
  9219. baseParams.EncKey = miConfig.EncKey
  9220. baseParams.AppSecret = miConfig.AppSecret
  9221. baseParams.SignKey = miConfig.SignKey
  9222. baseParams.AppID = miConfig.Code
  9223. baseParams.Doctor = role.UserName
  9224. baseParams.RequestUrl = miConfig.Url
  9225. businessParams := models.BusinessParams{
  9226. Insutype: insutype,
  9227. ClrType: clr_type,
  9228. SetlOptins: clr_org,
  9229. StmtBegndate: start_time,
  9230. StmtEnddate: end_time,
  9231. MedfeeSumamt: medfee_sumamt,
  9232. FundPaySumamt: fund_pay_sumamt,
  9233. AcctPay: acct_pay,
  9234. FixmedinsSetlCnt: fixmedins_setl_cnt + int64(len(orders_two)*2),
  9235. }
  9236. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams)
  9237. fmt.Println(requestLog)
  9238. fmt.Println(result)
  9239. fmt.Println(err_msg)
  9240. } else {
  9241. if len(clr_type) == 0 {
  9242. clr_type = "11"
  9243. }
  9244. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9245. "insutype=" + insutype +
  9246. "&clr_type=" + clr_type +
  9247. "&setl_optins=" + clr_org +
  9248. "&stmt_begndate=" + start_time +
  9249. "&stm_enddate=" + end_time +
  9250. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9251. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9252. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9253. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9254. "&fixmedins_code=" + miConfig.Code +
  9255. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9256. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9257. "&secret_key=" + miConfig.SecretKey +
  9258. "&org_name=" + miConfig.OrgName +
  9259. "&doctor=" + user_name
  9260. fmt.Println(api)
  9261. resp, requestErr := http.Get(api)
  9262. if requestErr != nil {
  9263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9264. return
  9265. }
  9266. body, ioErr := ioutil.ReadAll(resp.Body)
  9267. fmt.Println(body)
  9268. if ioErr != nil {
  9269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9271. return
  9272. }
  9273. var respJSON map[string]interface{}
  9274. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9277. return
  9278. }
  9279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9280. userJSONBytes, _ := json.Marshal(respJSON)
  9281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9282. utils.ErrorLog("解析失败:%v", err)
  9283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9284. return
  9285. }
  9286. }
  9287. if res.Infcode == 0 {
  9288. if res.Output.Stmtinfo.StmtRslt == "0" {
  9289. micc := &models.MedicalInsuranceCostCompare{
  9290. StartTime: startime.Unix(),
  9291. EndTime: endtime.Unix(),
  9292. Insutype: insutype,
  9293. CheckType: 1,
  9294. Num: fixmedins_setl_cnt,
  9295. Mtime: time.Now().Unix(),
  9296. Status: 1,
  9297. UserOrgId: adminUser.CurrentOrgId,
  9298. CostTotal: medfee_sumamt,
  9299. FuncTotal: fund_pay_sumamt,
  9300. PsnPay: acct_pay,
  9301. Creator: admin_user_id,
  9302. Ctime: time.Now().Unix(),
  9303. ClrType: clr_type,
  9304. }
  9305. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  9306. if err == nil {
  9307. c.ServeSuccessJSON(map[string]interface{}{
  9308. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9309. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9310. })
  9311. } else {
  9312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9313. }
  9314. } else {
  9315. c.ServeSuccessJSON(map[string]interface{}{
  9316. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9317. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9318. })
  9319. }
  9320. } else {
  9321. c.ServeSuccessJSON(map[string]interface{}{
  9322. "code": -10,
  9323. "msg": res.ErrMsg,
  9324. })
  9325. }
  9326. }
  9327. }
  9328. func (c *HisApiController) Check310() {
  9329. adminUser := c.GetAdminUserInfo()
  9330. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9331. var user_name string
  9332. user_name = "高慧裕"
  9333. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9334. "insutype=" + "310" +
  9335. "&clr_type=" + "" +
  9336. "&setl_optins=" + "441202" +
  9337. "&stmt_begndate=" + "2022-03-01" +
  9338. "&stm_enddate=" + "2022-03-31" +
  9339. "&medfee_sumamt=" + "194930.12" +
  9340. "&fund_pay_sumamt=" + "188741.46" +
  9341. "&acct_pay=" + "0" +
  9342. "&fixmedins_setl_cnt=" + "452" +
  9343. "&fixmedins_code=" + miConfig.Code +
  9344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9345. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9346. "&secret_key=" + miConfig.SecretKey +
  9347. "&org_name=" + miConfig.OrgName +
  9348. "&doctor=" + user_name
  9349. fmt.Println(api)
  9350. resp, requestErr := http.Get(api)
  9351. if requestErr != nil {
  9352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9353. return
  9354. }
  9355. body, ioErr := ioutil.ReadAll(resp.Body)
  9356. fmt.Println(body)
  9357. if ioErr != nil {
  9358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9360. return
  9361. }
  9362. var respJSON map[string]interface{}
  9363. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9366. return
  9367. }
  9368. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9369. userJSONBytes, _ := json.Marshal(respJSON)
  9370. var res ResultEight
  9371. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9372. utils.ErrorLog("解析失败:%v", err)
  9373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9374. return
  9375. }
  9376. }
  9377. func (c *HisApiController) Check390() {
  9378. adminUser := c.GetAdminUserInfo()
  9379. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9380. var user_name string
  9381. user_name = "高慧裕"
  9382. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9383. "insutype=" + "390" +
  9384. "&clr_type=" + "" +
  9385. "&setl_optins=" + "441202" +
  9386. "&stmt_begndate=" + "2022-03-01" +
  9387. "&stm_enddate=" + "2022-03-31" +
  9388. "&medfee_sumamt=" + "1068448.89" +
  9389. "&fund_pay_sumamt=" + "1014677.62" +
  9390. "&acct_pay=" + "0" +
  9391. "&fixmedins_setl_cnt=" + "1950" +
  9392. "&fixmedins_code=" + miConfig.Code +
  9393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9394. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9395. "&secret_key=" + miConfig.SecretKey +
  9396. "&org_name=" + miConfig.OrgName +
  9397. "&doctor=" + user_name
  9398. fmt.Println(api)
  9399. resp, requestErr := http.Get(api)
  9400. if requestErr != nil {
  9401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9402. return
  9403. }
  9404. body, ioErr := ioutil.ReadAll(resp.Body)
  9405. fmt.Println(body)
  9406. if ioErr != nil {
  9407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9409. return
  9410. }
  9411. var respJSON map[string]interface{}
  9412. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9415. return
  9416. }
  9417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9418. userJSONBytes, _ := json.Marshal(respJSON)
  9419. var res ResultEight
  9420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9421. utils.ErrorLog("解析失败:%v", err)
  9422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9423. return
  9424. }
  9425. }
  9426. //对账明细
  9427. func (c *HisApiController) GetCheckDetailAccount() {
  9428. start_time := c.GetString("start_time")
  9429. end_time := c.GetString("end_time")
  9430. admin_user_id, _ := c.GetInt64("admin_user_id")
  9431. adminUser := c.GetAdminUserInfo()
  9432. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9433. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9434. timeLayout := "2006-01-02"
  9435. loc, _ := time.LoadLocation("Local")
  9436. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9437. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9438. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9439. rand.Seed(time.Now().UnixNano())
  9440. num := rand.Intn(30000)
  9441. Mkdir(miConfig.OrgName)
  9442. file := strconv.FormatInt(int64(num), 10)
  9443. file_name := file + ".txt"
  9444. zip_name := file + ".zip"
  9445. zip_path := miConfig.OrgName + "/" + zip_name
  9446. file_path := miConfig.OrgName + "/" + file_name
  9447. decimal.DivisionPrecision = 2
  9448. var medfee_sumamt float64
  9449. var psn_cash_pay float64
  9450. var fund_pay_sumamt float64
  9451. fixmedins_setl_cnt := int64(len(orders))
  9452. for _, item := range orders {
  9453. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9454. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9455. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9456. }
  9457. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9458. defer f.Close()
  9459. if err != nil {
  9460. fmt.Println(err.Error())
  9461. } else {
  9462. for _, item := range orders {
  9463. var refd_setl_flag string
  9464. if item.OrderStatus == 2 {
  9465. refd_setl_flag = "0"
  9466. var str string
  9467. str = item.SetlId + " " +
  9468. item.MdtrtId + " " +
  9469. item.PsnNo + " " +
  9470. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9471. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9472. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9473. _, err = f.Write([]byte(str))
  9474. }
  9475. if item.OrderStatus == 3 {
  9476. var str string
  9477. str = item.SetlId + " " +
  9478. item.MdtrtId + " " +
  9479. item.PsnNo + " " +
  9480. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9481. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9482. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9483. _, err = f.Write([]byte(str))
  9484. var str2 string
  9485. str2 = item.SetlId + " " +
  9486. item.MdtrtId + " " +
  9487. item.PsnNo + " " +
  9488. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9489. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9490. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9491. _, err = f.Write([]byte(str2))
  9492. }
  9493. }
  9494. }
  9495. Zip(file_path, zip_path)
  9496. fmt.Println(ReadFile(zip_path))
  9497. fmt.Println(string(ReadFile(zip_path)))
  9498. if config.IsOpen == 1 {
  9499. var user_name string
  9500. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9501. if role.ID == 0 {
  9502. user_name = "管理员"
  9503. } else {
  9504. user_name = role.UserName
  9505. }
  9506. baseParams := models.BaseParams{
  9507. SecretKey: miConfig.SecretKey,
  9508. FixmedinsCode: miConfig.Code,
  9509. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9510. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9511. OrgName: miConfig.OrgName,
  9512. Doctor: user_name,
  9513. }
  9514. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9515. var dat map[string]interface{}
  9516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9517. fmt.Println(dat)
  9518. } else {
  9519. fmt.Println(err)
  9520. }
  9521. userJSONBytes, _ := json.Marshal(dat)
  9522. var res ResultNine
  9523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9524. utils.ErrorLog("解析失败:%v", err)
  9525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9526. return
  9527. }
  9528. if res.Infcode == 0 {
  9529. fileNo := res.Output.FileQuryNo
  9530. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9531. "file_qury_no=" + fileNo +
  9532. "&setl_optins=" + "定点医保中心" +
  9533. "&stmt_begndate=" + start_time +
  9534. "&stm_enddate=" + end_time +
  9535. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9536. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9537. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9538. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9539. "&fixmedins_code=" + miConfig.Code +
  9540. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9541. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9542. "&secret_key=" + miConfig.SecretKey +
  9543. "&org_name=" + miConfig.OrgName +
  9544. "&doctor=" + user_name
  9545. resp, requestErr := http.Get(api)
  9546. if requestErr != nil {
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9548. return
  9549. }
  9550. body, ioErr := ioutil.ReadAll(resp.Body)
  9551. if ioErr != nil {
  9552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9554. return
  9555. }
  9556. var respJSON map[string]interface{}
  9557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9560. return
  9561. }
  9562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9563. userJSONBytes, _ := json.Marshal(respJSON)
  9564. var res ResultTen
  9565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9566. utils.ErrorLog("解析失败:%v", err)
  9567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9568. return
  9569. }
  9570. if res.Infcode == 0 {
  9571. service.Gdyb9102(baseParams, zip_name, fileNo)
  9572. micc := &models.MedicalInsuranceCostCompare{
  9573. StartTime: startime.Unix(),
  9574. EndTime: endtime.Unix(),
  9575. Insutype: "0",
  9576. CheckType: 2,
  9577. Num: fixmedins_setl_cnt,
  9578. Mtime: time.Now().Unix(),
  9579. Status: 1,
  9580. UserOrgId: adminUser.CurrentOrgId,
  9581. CostTotal: medfee_sumamt,
  9582. FuncTotal: fund_pay_sumamt,
  9583. PsnPay: psn_cash_pay,
  9584. Creator: admin_user_id,
  9585. Ctime: time.Now().Unix(),
  9586. }
  9587. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9588. c.ServeSuccessJSON(map[string]interface{}{
  9589. "msg": "明细对账成功",
  9590. })
  9591. }
  9592. } else {
  9593. }
  9594. }
  9595. }
  9596. type CustomOrderInfo struct {
  9597. Name string
  9598. Spec string
  9599. Unit string
  9600. Count float64
  9601. Price float64
  9602. Total float64
  9603. }
  9604. func (c *HisApiController) GetSettleAccounts() {
  9605. //id, _ := c.GetInt64("id")
  9606. //record_time := c.GetString("record_time")
  9607. order_id, _ := c.GetInt64("order_id")
  9608. admin_user_id, _ := c.GetInt64("admin_user_id")
  9609. //timeLayout := "2006-01-02"
  9610. //loc, _ := time.LoadLocation("Local")
  9611. //
  9612. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9613. //if err != nil {
  9614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9615. // return
  9616. //}
  9617. //recordDateTime := theTime.Unix()
  9618. adminUser := c.GetAdminUserInfo()
  9619. order, _ := service.GetHisOrderByID(order_id)
  9620. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9621. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9622. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9623. orderInfos = append(orderInfos, orderInfos_two...)
  9624. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9625. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9626. var diagnosis_ids []string
  9627. if his.ID > 0 {
  9628. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9629. } else {
  9630. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9631. }
  9632. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9633. var dia_config []*models.HisXtDiagnoseConfig
  9634. var name string
  9635. for _, item := range diagnosis_ids {
  9636. id, _ := strconv.ParseInt(item, 10, 64)
  9637. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9638. dia_config = append(dia_config, &diagnosisConfig)
  9639. if len(name) == 0 {
  9640. name = diagnosisConfig.ClassName
  9641. } else {
  9642. name = name + "," + diagnosisConfig.ClassName
  9643. }
  9644. }
  9645. var bedCostTotal float64 = 0 //床位总费
  9646. var bedCostSelfTotal float64 = 0 //床位自费
  9647. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9648. var operationCostTotal float64 = 0 //手术费
  9649. var operationCostSelfTotal float64 = 0 //手术费
  9650. var operationCostPartSelfTotal float64 = 0 //手术费
  9651. var otherCostTotal float64 = 0 //其他费用
  9652. var otherCostSelfTotal float64 = 0 //其他费用
  9653. var otherCostPartSelfTotal float64 = 0 //其他费用
  9654. var materialCostTotal float64 = 0 //材料费
  9655. var materialCostSelfTotal float64 = 0 //材料费
  9656. var materialCostPartSelfTotal float64 = 0 //材料费
  9657. var westernMedicineCostTotal float64 = 0 //西药费
  9658. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9659. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9660. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9661. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9662. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9663. var checkCostTotal float64 = 0 //检查费
  9664. var checkCostSelfTotal float64 = 0 //检查费
  9665. var checkCostPartSelfTotal float64 = 0 //检查费
  9666. var laboratoryCostTotal float64 = 0 //化验费
  9667. var laboratoryCostSelfTotal float64 = 0 //化验费
  9668. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9669. var treatCostTotal float64 = 0 //治疗费用
  9670. var treatCostSelfTotal float64 = 0 //治疗费用
  9671. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9672. decimal.DivisionPrecision = 2
  9673. for _, item := range orderInfos {
  9674. if item.MedChrgitmType == "01" { //床位费
  9675. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9676. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9677. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9678. }
  9679. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9680. if item.MedChrgitmType == "03" { //检查费
  9681. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9682. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9683. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9684. }
  9685. } else {
  9686. if item.MedChrgitmType == "03" { //检查费
  9687. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9688. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9689. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9690. }
  9691. }
  9692. if item.MedChrgitmType == "04" { //化验费
  9693. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9694. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9695. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9696. }
  9697. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9698. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9699. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9700. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9701. }
  9702. if item.MedChrgitmType == "06" { //手术费
  9703. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9704. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9705. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9706. }
  9707. if item.MedChrgitmType == "08" { //材料费
  9708. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9709. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9710. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9711. }
  9712. if item.MedChrgitmType == "09" { //西药费
  9713. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9714. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9715. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9716. }
  9717. if item.MedChrgitmType == "11" { //中成费
  9718. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9719. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9720. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9721. }
  9722. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9723. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9724. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9725. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9726. }
  9727. }
  9728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9729. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9730. var user_name string
  9731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9732. if role.ID == 0 {
  9733. user_name = "管理员"
  9734. } else {
  9735. user_name = role.UserName
  9736. }
  9737. baseParams := models.BaseParams{
  9738. SecretKey: miConfig.SecretKey,
  9739. FixmedinsCode: miConfig.Code,
  9740. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9741. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9742. OrgName: miConfig.OrgName,
  9743. Doctor: user_name,
  9744. }
  9745. businessParams := models.BusinessParams{
  9746. PsnNo: order.PsnNo,
  9747. MdtrtId: order.MdtrtId,
  9748. SetlId: order.SetlId,
  9749. }
  9750. var res ResultEleven
  9751. var resEleven10265 ResultEleven10265
  9752. if config.IsOpen == 1 {
  9753. if miConfig.MdtrtareaAdmvs == "421300" {
  9754. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9755. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9756. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9757. resp, requestErr := http.Get(api)
  9758. if requestErr != nil {
  9759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9760. return
  9761. }
  9762. body, ioErr := ioutil.ReadAll(resp.Body)
  9763. if ioErr != nil {
  9764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9766. return
  9767. }
  9768. var respJSON map[string]interface{}
  9769. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9772. return
  9773. }
  9774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9775. result, _ := json.Marshal(respJSON)
  9776. fmt.Println("log")
  9777. fmt.Println(string(result))
  9778. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9779. utils.ErrorLog("解析失败:%v", err)
  9780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9781. return
  9782. }
  9783. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9784. var api string
  9785. if miConfig.MdtrtareaAdmvs == "320921" {
  9786. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9787. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9788. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9789. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9790. } else {
  9791. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9792. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9793. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9794. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9795. }
  9796. resp, requestErr := http.Get(api)
  9797. if requestErr != nil {
  9798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9799. return
  9800. }
  9801. body, ioErr := ioutil.ReadAll(resp.Body)
  9802. if ioErr != nil {
  9803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9805. return
  9806. }
  9807. var respJSON map[string]interface{}
  9808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9811. return
  9812. }
  9813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9814. result, _ := json.Marshal(respJSON)
  9815. fmt.Println("log")
  9816. fmt.Println(string(result))
  9817. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9818. utils.ErrorLog("解析失败:%v", err)
  9819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9820. return
  9821. }
  9822. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9823. res.Output = resEleven10265.Output
  9824. res.ErrMsg = resEleven10265.ErrMsg
  9825. res.Cainfo = resEleven10265.Cainfo
  9826. res.WarnMsg = resEleven10265.WarnMsg
  9827. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9828. res.Infcode = infocode
  9829. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9830. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9831. saveLog(result, requestLog, "5203", "结算单")
  9832. var dat map[string]interface{}
  9833. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9834. fmt.Println(dat)
  9835. } else {
  9836. fmt.Println(err)
  9837. }
  9838. userJSONBytes, _ := json.Marshal(dat)
  9839. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9840. utils.ErrorLog("解析失败:%v", err)
  9841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9842. return
  9843. }
  9844. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9845. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9846. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9847. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9848. resp, requestErr := http.Get(api)
  9849. if requestErr != nil {
  9850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9851. return
  9852. }
  9853. body, ioErr := ioutil.ReadAll(resp.Body)
  9854. if ioErr != nil {
  9855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9857. return
  9858. }
  9859. var respJSON map[string]interface{}
  9860. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9863. return
  9864. }
  9865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9866. result, _ := json.Marshal(respJSON)
  9867. fmt.Println("log")
  9868. fmt.Println(string(result))
  9869. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9870. utils.ErrorLog("解析失败:%v", err)
  9871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9872. return
  9873. }
  9874. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9875. res.Output = resEleven10265.Output
  9876. res.ErrMsg = resEleven10265.ErrMsg
  9877. res.Cainfo = resEleven10265.Cainfo
  9878. res.WarnMsg = resEleven10265.WarnMsg
  9879. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9880. res.Infcode = infocode
  9881. } else {
  9882. result := service.Gdyb5203(baseParams, businessParams)
  9883. //service.Gdyb5204(baseParams, businessParams)
  9884. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9885. var dat map[string]interface{}
  9886. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9887. fmt.Println(dat)
  9888. } else {
  9889. fmt.Println(err)
  9890. }
  9891. userJSONBytes, _ := json.Marshal(dat)
  9892. if miConfig.Code == "H15049901371" {
  9893. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9894. utils.ErrorLog("解析失败:%v", err)
  9895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9896. return
  9897. }
  9898. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9899. res.Output = resEleven10265.Output
  9900. res.ErrMsg = resEleven10265.ErrMsg
  9901. res.Cainfo = resEleven10265.Cainfo
  9902. res.WarnMsg = resEleven10265.WarnMsg
  9903. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9904. res.Infcode = infocode
  9905. } else {
  9906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9907. utils.ErrorLog("解析失败:%v", err)
  9908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9909. return
  9910. }
  9911. }
  9912. }
  9913. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9914. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9915. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9916. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9917. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9918. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9919. var doctor_name string
  9920. if roles.ID == 0 {
  9921. doctor_name = "管理员"
  9922. } else {
  9923. doctor_name = roles.UserName
  9924. }
  9925. yiliao_leibie := ""
  9926. switch order.MedType {
  9927. case "11":
  9928. yiliao_leibie = "普通门诊"
  9929. break
  9930. case "12":
  9931. yiliao_leibie = "门诊挂号"
  9932. break
  9933. case "13":
  9934. yiliao_leibie = "急诊"
  9935. break
  9936. case "14":
  9937. yiliao_leibie = "门诊特殊病"
  9938. break
  9939. case "15":
  9940. yiliao_leibie = "门诊统筹"
  9941. break
  9942. case "16":
  9943. yiliao_leibie = "门诊慢性病"
  9944. break
  9945. case "21":
  9946. yiliao_leibie = "普通住院"
  9947. break
  9948. }
  9949. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9950. if res.Infcode == 0 {
  9951. c.ServeSuccessJSON(map[string]interface{}{
  9952. "diagnosis": name,
  9953. "order_infos": orderInfos,
  9954. "number": order.MdtrtId,
  9955. "date": order.SettleAccountsDate,
  9956. "charge_admin": charge_admin,
  9957. "printor_admin": printor_admin,
  9958. "info": res.Output.Setlinfo,
  9959. "order": order,
  9960. "bedCostTotal": bedCostTotal,
  9961. "bedCostSelfTotal": bedCostSelfTotal,
  9962. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9963. "operationCostTotal": operationCostTotal,
  9964. "operationCostSelfTotal": operationCostSelfTotal,
  9965. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9966. "otherCostTotal": otherCostTotal,
  9967. "otherCostSelfTotal": otherCostSelfTotal,
  9968. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9969. "materialCostTotal": materialCostTotal,
  9970. "materialCostSelfTotal": materialCostSelfTotal,
  9971. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9972. "westernMedicineCostTotal": westernMedicineCostTotal,
  9973. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9974. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9975. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9976. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9977. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9978. "checkCostTotal": checkCostTotal,
  9979. "checkCostSelfTotal": checkCostSelfTotal,
  9980. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9981. "laboratoryCostTotal": laboratoryCostTotal,
  9982. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9983. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9984. "treatCostTotal": treatCostTotal,
  9985. "treatCostSelfTotal": treatCostSelfTotal,
  9986. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9987. "doctor_info": doctor_info,
  9988. "doctor_code": adminRole_two.DoctorCode,
  9989. "doctor_name": doctor_name,
  9990. "health_card_no": order.PsnNo,
  9991. "department": departments.Name,
  9992. "yiliao_leibie": yiliao_leibie,
  9993. "after_money": order.AccountPrice,
  9994. "patient": patient,
  9995. "org_name": miConfig.OrgName,
  9996. "org_code": miConfig.Code,
  9997. "order_number": order.Number,
  9998. "his_hospital": his_hospital,
  9999. "his": his,
  10000. "dia_config": dia_config,
  10001. //"check_order_info": cus_slice,
  10002. })
  10003. }
  10004. }
  10005. }
  10006. func (c *HisApiController) CheckTreatment() {
  10007. patient_id, _ := c.GetInt64("patient_id")
  10008. id_card_no := c.GetString("id_card_no")
  10009. insutype := c.GetString("insutype")
  10010. med_type := c.GetString("med_type")
  10011. admin_user_id, _ := c.GetInt64("admin_user_id")
  10012. adminUser := c.GetAdminUserInfo()
  10013. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10014. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10015. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10016. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10017. if miConfig.MdtrtareaAdmvs == "421300" {
  10018. var res ResultTwo
  10019. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  10020. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10021. "&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)
  10022. resp, requestErr := http.Get(api)
  10023. if requestErr != nil {
  10024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10025. return
  10026. }
  10027. body, ioErr := ioutil.ReadAll(resp.Body)
  10028. if ioErr != nil {
  10029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10031. return
  10032. }
  10033. var respJSON map[string]interface{}
  10034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10037. return
  10038. }
  10039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10040. result, _ := json.Marshal(respJSON)
  10041. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10042. utils.ErrorLog("解析失败:%v", err)
  10043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10044. return
  10045. }
  10046. if res.Infcode == 0 {
  10047. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  10048. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10049. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  10050. resp, requestErr := http.Get(api)
  10051. if requestErr != nil {
  10052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10053. return
  10054. }
  10055. body, ioErr := ioutil.ReadAll(resp.Body)
  10056. if ioErr != nil {
  10057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10059. return
  10060. }
  10061. var respJSON map[string]interface{}
  10062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10065. return
  10066. }
  10067. var res Result2001
  10068. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10069. result2, _ := json.Marshal(respJSON)
  10070. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10071. utils.ErrorLog("解析失败:%v", err)
  10072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10073. return
  10074. }
  10075. if res.Infcode == 0 {
  10076. c.ServeSuccessJSON(map[string]interface{}{
  10077. "msg": res.Output.Trtinfo,
  10078. })
  10079. }
  10080. } else {
  10081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10082. return
  10083. }
  10084. } else {
  10085. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10086. var dat map[string]interface{}
  10087. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10088. fmt.Println(dat)
  10089. } else {
  10090. fmt.Println(err)
  10091. }
  10092. userJSONBytes, _ := json.Marshal(dat)
  10093. var res ResultTwo
  10094. var res10265 ResultTwo10265
  10095. if miConfig.Code == "H15049901371" {
  10096. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10097. utils.ErrorLog("解析失败:%v", err)
  10098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10099. return
  10100. }
  10101. res.ErrMsg = res10265.ErrMsg
  10102. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10103. res.Infcode = infocode
  10104. res.Output = res10265.Output
  10105. res.InfRefmsgid = res10265.InfRefmsgid
  10106. } else {
  10107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10108. utils.ErrorLog("解析失败:%v", err)
  10109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10110. return
  10111. }
  10112. }
  10113. var user_name string
  10114. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  10115. if role.ID == 0 {
  10116. user_name = "xxx"
  10117. } else {
  10118. user_name = role.UserName
  10119. }
  10120. baseParams := models.BaseParams{
  10121. SecretKey: miConfig.SecretKey,
  10122. FixmedinsCode: miConfig.Code,
  10123. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10124. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10125. OrgName: miConfig.OrgName,
  10126. Doctor: user_name,
  10127. }
  10128. if config.IsOpen == 1 {
  10129. if miConfig.Code == "H15049901371" {
  10130. if med_type == "14" {
  10131. if insutype == "390" {
  10132. med_type = "9933"
  10133. } else if insutype == "310" {
  10134. med_type = "990502"
  10135. }
  10136. } else if med_type == "11" {
  10137. med_type = "11"
  10138. }
  10139. }
  10140. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  10141. var dat map[string]interface{}
  10142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10143. fmt.Println(dat)
  10144. } else {
  10145. fmt.Println(err)
  10146. }
  10147. var res Result2001
  10148. var res10265 Result2001Org10265
  10149. if miConfig.Code == "H15049901371" {
  10150. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10151. utils.ErrorLog("解析失败:%v", err)
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10153. return
  10154. }
  10155. res.ErrMsg = res10265.ErrMsg
  10156. res.Output = res10265.Output
  10157. res.InfRefmsgid = res10265.InfRefmsgid
  10158. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10159. res.Infcode = infocode
  10160. } else {
  10161. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10162. utils.ErrorLog("解析失败:%v", err)
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. return
  10165. }
  10166. }
  10167. if res.Infcode == 0 {
  10168. c.ServeSuccessJSON(map[string]interface{}{
  10169. "msg": res.Output.Trtinfo,
  10170. })
  10171. }
  10172. }
  10173. }
  10174. }
  10175. //func (c *HisApiController) PutRecord() {
  10176. // id, _ := c.GetInt64("id")
  10177. // record_time := c.GetString("record_time")
  10178. // timeLayout := "2006-01-02"
  10179. // loc, _ := time.LoadLocation("Local")
  10180. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10181. // if err != nil {
  10182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10183. // return
  10184. // }
  10185. // recordDateTime := theTime.Unix()
  10186. //
  10187. // adminInfo := c.GetAdminUserInfo()
  10188. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  10189. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10190. //
  10191. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10192. //
  10193. // fmt.Println(miConfig.SecretKey)
  10194. //
  10195. // if patient == nil {
  10196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10197. // return
  10198. // }
  10199. // if len(patient.IdCardNo) == 0 {
  10200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10201. // return
  10202. // }
  10203. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10204. // if config.IsOpen == 1 {
  10205. // 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
  10206. // resp, requestErr := http.Get(api)
  10207. // if requestErr != nil {
  10208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10209. // return
  10210. // }
  10211. // defer resp.Body.Close()
  10212. // body, ioErr := ioutil.ReadAll(resp.Body)
  10213. // if ioErr != nil {
  10214. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10216. // return
  10217. // }
  10218. // var respJSON map[string]interface{}
  10219. //
  10220. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10221. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10223. // return
  10224. // }
  10225. //
  10226. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10227. // userJSONBytes, _ := json.Marshal(userJSON)
  10228. // var res ResultTwo
  10229. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10230. // utils.ErrorLog("解析失败:%v", err)
  10231. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10232. // return
  10233. // }
  10234. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10235. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10236. // infoStr := string(Iinfos)
  10237. // idetinfoStr := string(Idetinfos)
  10238. //
  10239. // if res.Infcode == 0 {
  10240. // his := models.VMHisPatient{
  10241. // Status: 1,
  10242. // Ctime: time.Now().Unix(),
  10243. // Mtime: time.Now().Unix(),
  10244. // PsnNo: res.Output.Baseinfo.PsnNo,
  10245. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10246. // Certno: res.Output.Baseinfo.Certno,
  10247. // PsnName: res.Output.Baseinfo.PsnName,
  10248. // Gend: res.Output.Baseinfo.Gend,
  10249. // Naty: res.Output.Baseinfo.Naty,
  10250. // Brdy: res.Output.Baseinfo.Brdy,
  10251. // Age: res.Output.Baseinfo.Age,
  10252. // Iinfo: infoStr,
  10253. // Idetinfo: idetinfoStr,
  10254. // PatientId: patient.ID,
  10255. // RecordDate: theTime.Unix(),
  10256. // UserOrgId: adminInfo.CurrentOrgId,
  10257. // AdminUserId: adminInfo.AdminUser.Id,
  10258. // IsReturn: 1,
  10259. // }
  10260. //
  10261. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  10262. // //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")
  10263. // //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")
  10264. //
  10265. // //var dat map[string]interface{}
  10266. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10267. // // fmt.Println(dat)
  10268. // //} else {
  10269. // // fmt.Println(err)
  10270. // //}
  10271. //
  10272. // var dat2 map[string]interface{}
  10273. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10274. // fmt.Println(dat2)
  10275. // } else {
  10276. // fmt.Println(err)
  10277. // }
  10278. //
  10279. // } else {
  10280. // adminUser := c.GetAdminUserInfo()
  10281. // errlog := &models.HisOrderError{
  10282. // UserOrgId: adminUser.CurrentOrgId,
  10283. // Ctime: time.Now().Unix(),
  10284. // Mtime: time.Now().Unix(),
  10285. // ErrMsg: res.ErrMsg,
  10286. // Status: 1,
  10287. // PatientId: id,
  10288. // RecordTime: recordDateTime,
  10289. // Stage: 1,
  10290. // }
  10291. // service.CreateErrMsgLog(errlog)
  10292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10293. // return
  10294. // }
  10295. // }
  10296. //
  10297. //}
  10298. //func (c *HisApiController) GetUploadDiag() {
  10299. // id, _ := c.GetInt64("id")
  10300. // record_time := c.GetString("record_time")
  10301. //
  10302. // diagnosis_id, _ := c.GetInt64("diagnosis")
  10303. // sick_type, _ := c.GetInt64("sick_type")
  10304. // reg_type, _ := c.GetInt64("reg_type")
  10305. //
  10306. // timeLayout := "2006-01-02"
  10307. // loc, _ := time.LoadLocation("Local")
  10308. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10309. // if err != nil {
  10310. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10311. // return
  10312. // }
  10313. //
  10314. // var patientPrescription models.HisPrescriptionInfo
  10315. // recordDateTime := theTime.Unix()
  10316. // adminInfo := c.GetAdminUserInfo()
  10317. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10318. //
  10319. // if patientPrescription.ID == 0 {
  10320. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10321. // }
  10322. //
  10323. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10324. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10325. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10326. // sickConfig, _ := service.FindSickById(sick_type)
  10327. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10328. //
  10329. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  10330. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  10331. // "&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 +
  10332. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  10333. // resp2, requestErr2 := http.Get(api2)
  10334. // if requestErr2 != nil {
  10335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10336. // return
  10337. // }
  10338. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10339. // if ioErr2 != nil {
  10340. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10342. // return
  10343. // }
  10344. // var respJSON2 map[string]interface{}
  10345. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10346. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10348. // return
  10349. // }
  10350. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10351. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10352. //
  10353. // var res2 ResultSix
  10354. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10355. // utils.ErrorLog("解析失败:%v", err)
  10356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10357. // return
  10358. // }
  10359. // if res2.Infcode != 0 {
  10360. // adminUser := c.GetAdminUserInfo()
  10361. // errlog := &models.HisOrderError{
  10362. // UserOrgId: adminUser.CurrentOrgId,
  10363. // Ctime: time.Now().Unix(),
  10364. // Mtime: time.Now().Unix(),
  10365. // ErrMsg: res2.ErrMsg,
  10366. // Status: 1,
  10367. // PatientId: id,
  10368. // RecordTime: recordDateTime,
  10369. // Stage: 3,
  10370. // }
  10371. // service.CreateErrMsgLog(errlog)
  10372. //
  10373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10374. // return
  10375. // }
  10376. //
  10377. // c.ServeSuccessJSON(map[string]interface{}{
  10378. // "msg": "上传成功",
  10379. // })
  10380. //
  10381. //}
  10382. type QueryResult struct {
  10383. ID int64
  10384. Name string
  10385. Code string
  10386. List_type_code string
  10387. }
  10388. func (c *HisApiController) GetCheckCode() {
  10389. ids_str := c.GetString("ids")
  10390. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10391. ids_arr := strings.Split(ids_str, ",")
  10392. var queryResult []QueryResult
  10393. ids := make([]int64, 0)
  10394. for _, item := range ids_arr {
  10395. id, _ := strconv.ParseInt(item, 10, 64)
  10396. ids = append(ids, id)
  10397. }
  10398. if record_type == 1 {
  10399. drugs, _ := service.GetBatchDrugList(ids)
  10400. for _, item := range drugs {
  10401. result := QueryResult{
  10402. ID: item.ID,
  10403. Name: item.DrugName,
  10404. Code: item.MedicalInsuranceNumber,
  10405. List_type_code: "101",
  10406. }
  10407. queryResult = append(queryResult, result)
  10408. }
  10409. } else if record_type == 2 {
  10410. goods, _ := service.GetBatchGoodInformationList(ids)
  10411. for _, item := range goods {
  10412. result := QueryResult{
  10413. ID: item.ID,
  10414. Name: item.GoodName,
  10415. Code: item.MedicalInsuranceNumber,
  10416. List_type_code: "301",
  10417. }
  10418. queryResult = append(queryResult, result)
  10419. }
  10420. } else if record_type == 3 {
  10421. projects, _ := service.GetBathchMyPorjecgList(ids)
  10422. for _, item := range projects {
  10423. result := QueryResult{
  10424. ID: item.ID,
  10425. Name: item.ProjectName,
  10426. Code: item.MedicalCode,
  10427. List_type_code: "201",
  10428. }
  10429. queryResult = append(queryResult, result)
  10430. }
  10431. }
  10432. admin_user_id, _ := c.GetInt64("admin_user_id")
  10433. adminUser := c.GetAdminUserInfo()
  10434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10435. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10436. var user_name string
  10437. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10438. if role.ID == 0 {
  10439. user_name = "xxx"
  10440. } else {
  10441. user_name = role.UserName
  10442. }
  10443. baseParams := &models.BaseParams{
  10444. SecretKey: miConfig.SecretKey,
  10445. FixmedinsCode: miConfig.Code,
  10446. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10447. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10448. OrgName: miConfig.OrgName,
  10449. Doctor: user_name,
  10450. }
  10451. if config.IsOpen == 1 {
  10452. for _, item := range queryResult {
  10453. var result string
  10454. if record_type == 1 {
  10455. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10456. } else if record_type == 2 {
  10457. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10458. } else if record_type == 3 {
  10459. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10460. }
  10461. var dat map[string]interface{}
  10462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10463. fmt.Println(dat)
  10464. } else {
  10465. fmt.Println(err)
  10466. }
  10467. userJSONBytes, _ := json.Marshal(dat)
  10468. var res ResultSix
  10469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10470. utils.ErrorLog("解析失败:%v", err)
  10471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10472. return
  10473. }
  10474. if res.Infcode == 0 {
  10475. if record_type == 1 {
  10476. service.UpdateBaseDrugById(item.ID)
  10477. } else if record_type == 2 {
  10478. service.UpdateGoodInformaitonByDetail(item.ID)
  10479. } else if record_type == 3 {
  10480. service.UpdateProjectById(item.ID)
  10481. }
  10482. c.ServeSuccessJSON(map[string]interface{}{
  10483. "failed_code": 0,
  10484. "msg": "目录对照成功",
  10485. })
  10486. } else {
  10487. c.ServeSuccessJSON(map[string]interface{}{
  10488. "failed_code": -10,
  10489. "msg": res.ErrMsg,
  10490. })
  10491. }
  10492. }
  10493. }
  10494. }
  10495. func (c *HisApiController) UnCheckCode() {
  10496. ids_str := c.GetString("ids")
  10497. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10498. admin_user_id, _ := c.GetInt64("admin_user_id")
  10499. ids_arr := strings.Split(ids_str, ",")
  10500. var queryResult []QueryResult
  10501. ids := make([]int64, 0)
  10502. for _, item := range ids_arr {
  10503. id, _ := strconv.ParseInt(item, 10, 64)
  10504. ids = append(ids, id)
  10505. }
  10506. if record_type == 1 {
  10507. drugs, _ := service.GetBatchDrugList(ids)
  10508. for _, item := range drugs {
  10509. result := QueryResult{
  10510. ID: item.ID,
  10511. Name: item.DrugName,
  10512. Code: item.MedicalInsuranceNumber,
  10513. List_type_code: "101",
  10514. }
  10515. queryResult = append(queryResult, result)
  10516. }
  10517. } else if record_type == 2 {
  10518. goods, _ := service.GetBatchGoodInformationList(ids)
  10519. for _, item := range goods {
  10520. result := QueryResult{
  10521. ID: item.ID,
  10522. Name: item.GoodName,
  10523. Code: item.MedicalInsuranceNumber,
  10524. List_type_code: "301",
  10525. }
  10526. queryResult = append(queryResult, result)
  10527. }
  10528. } else if record_type == 3 {
  10529. projects, _ := service.GetBathchMyPorjecgList(ids)
  10530. for _, item := range projects {
  10531. result := QueryResult{
  10532. ID: item.ID,
  10533. Name: item.ProjectName,
  10534. Code: item.MedicalCode,
  10535. List_type_code: "201",
  10536. }
  10537. queryResult = append(queryResult, result)
  10538. }
  10539. }
  10540. adminUser := c.GetAdminUserInfo()
  10541. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10542. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10543. var user_name string
  10544. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10545. if role.ID == 0 {
  10546. user_name = "xxx"
  10547. } else {
  10548. user_name = role.UserName
  10549. }
  10550. baseParams := &models.BaseParams{
  10551. SecretKey: miConfig.SecretKey,
  10552. FixmedinsCode: miConfig.Code,
  10553. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10554. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10555. OrgName: miConfig.OrgName,
  10556. Doctor: user_name,
  10557. }
  10558. if config.IsOpen == 1 {
  10559. for _, item := range queryResult {
  10560. var result string
  10561. if record_type == 1 {
  10562. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10563. } else if record_type == 2 {
  10564. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10565. } else if record_type == 3 {
  10566. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10567. }
  10568. var dat2 map[string]interface{}
  10569. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10570. fmt.Println(dat2)
  10571. } else {
  10572. fmt.Println(err)
  10573. }
  10574. userJSONBytes, _ := json.Marshal(dat2)
  10575. var res ResultSix
  10576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10577. utils.ErrorLog("解析失败:%v", err)
  10578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10579. return
  10580. }
  10581. if res.Infcode == 0 {
  10582. if record_type == 1 {
  10583. service.UpdateDrugByIdDetail(item.ID)
  10584. } else if record_type == 2 {
  10585. service.UpdateGoodInfoById(item.ID)
  10586. } else if record_type == 3 {
  10587. service.UpdateMyProjectById(item.ID)
  10588. }
  10589. c.ServeSuccessJSON(map[string]interface{}{
  10590. "failed_code": 0,
  10591. "msg": "撤销目录对照成功",
  10592. })
  10593. } else {
  10594. c.ServeSuccessJSON(map[string]interface{}{
  10595. "failed_code": -10,
  10596. "msg": res.ErrMsg,
  10597. })
  10598. }
  10599. }
  10600. }
  10601. }
  10602. func (c *HisApiController) GetPatientInfo() {
  10603. id_card_no := c.GetString("id_card_no")
  10604. admin_user_id, _ := c.GetInt64("admin_user_id")
  10605. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10606. if patient.ID == 0 {
  10607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10608. return
  10609. }
  10610. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10611. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10612. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10613. if config.IsOpen == 1 {
  10614. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10615. var dat map[string]interface{}
  10616. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10617. fmt.Println(dat)
  10618. } else {
  10619. fmt.Println(err)
  10620. }
  10621. userJSONBytes, _ := json.Marshal(dat)
  10622. var res ResultTwo
  10623. var res10265 ResultTwo10265
  10624. if miConfig.Code == "H15049901371" {
  10625. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10626. utils.ErrorLog("解析失败:%v", err)
  10627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10628. return
  10629. }
  10630. res.ErrMsg = res10265.ErrMsg
  10631. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10632. res.Infcode = infocode
  10633. res.Output = res10265.Output
  10634. res.InfRefmsgid = res10265.InfRefmsgid
  10635. } else {
  10636. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10637. utils.ErrorLog("解析失败:%v", err)
  10638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10639. return
  10640. }
  10641. }
  10642. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10643. // utils.ErrorLog("解析失败:%v", err)
  10644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10645. // return
  10646. //}
  10647. if res.Infcode != 0 {
  10648. c.ServeSuccessJSON(map[string]interface{}{
  10649. "failed_code": -10,
  10650. "msg": res.ErrMsg,
  10651. })
  10652. } else {
  10653. c.ServeSuccessJSON(map[string]interface{}{
  10654. "failed_code": 0,
  10655. "info": res,
  10656. })
  10657. }
  10658. }
  10659. }
  10660. func (c *HisApiController) PsnPutOnRecord() {
  10661. record_type, _ := c.GetInt64("type")
  10662. patient_id, _ := c.GetInt64("patient_id")
  10663. admin_user_id, _ := c.GetInt64("admin_user_id")
  10664. start_time := c.GetString("start_time")
  10665. end_time := c.GetString("end_time")
  10666. adminUser := c.GetAdminUserInfo()
  10667. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10668. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10669. var patients []*models.Patients
  10670. if record_type == 1 { //全部备案
  10671. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10672. patients = append(patients, patient...)
  10673. } else { //单个备案
  10674. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10675. patients = append(patients, patient)
  10676. }
  10677. var user_name string
  10678. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10679. if role.ID == 0 {
  10680. user_name = "xxx"
  10681. } else {
  10682. user_name = role.UserName
  10683. }
  10684. if config.IsOpen == 1 {
  10685. for _, item := range patients {
  10686. 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
  10687. resp, requestErr := http.Get(api)
  10688. if requestErr != nil {
  10689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10690. return
  10691. }
  10692. defer resp.Body.Close()
  10693. body, ioErr := ioutil.ReadAll(resp.Body)
  10694. if ioErr != nil {
  10695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10697. return
  10698. }
  10699. var respJSON map[string]interface{}
  10700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10703. return
  10704. }
  10705. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10706. userJSONBytes, _ := json.Marshal(userJSON)
  10707. var res ResultTwo
  10708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10709. utils.ErrorLog("解析失败:%v", err)
  10710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10711. return
  10712. }
  10713. if res.Infcode == 0 {
  10714. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10715. var dat map[string]interface{}
  10716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10717. fmt.Println(dat)
  10718. } else {
  10719. fmt.Println(err)
  10720. }
  10721. userJSONBytes, _ := json.Marshal(dat)
  10722. var res2 ResultThirteen
  10723. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10724. utils.ErrorLog("解析失败:%v", err)
  10725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10726. return
  10727. }
  10728. if res2.Infcode == 0 {
  10729. psnResult := &models.GdybPsnRecord{
  10730. UserOrgId: adminUser.CurrentOrgId,
  10731. PatientId: item.ID,
  10732. PsnNo: res.Output.Baseinfo.PsnNo,
  10733. Ctime: time.Now().Unix(),
  10734. Mtime: time.Now().Unix(),
  10735. Status: 1,
  10736. IsCancel: 1,
  10737. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10738. }
  10739. service.CreatePsnRecord(psnResult)
  10740. } else {
  10741. c.ServeSuccessJSON(map[string]interface{}{
  10742. "failed_code": -10,
  10743. "msg": res2.ErrMsg,
  10744. })
  10745. return
  10746. }
  10747. }
  10748. }
  10749. }
  10750. }
  10751. func (c *HisApiController) PsnUnPutOnRecord() {
  10752. id, _ := c.GetInt64("id")
  10753. //record_type, _ := c.GetInt64("type")
  10754. admin_user_id, _ := c.GetInt64("admin_user_id")
  10755. adminUser := c.GetAdminUserInfo()
  10756. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10757. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10758. var user_name string
  10759. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10760. if role.ID == 0 {
  10761. user_name = "xxx"
  10762. } else {
  10763. user_name = role.UserName
  10764. }
  10765. psn_record, _ := service.GetPsnRecordById(id)
  10766. if psn_record.ID == 0 {
  10767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10768. return
  10769. }
  10770. if config.IsOpen == 1 {
  10771. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10772. var dat map[string]interface{}
  10773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10774. fmt.Println(dat)
  10775. } else {
  10776. fmt.Println(err)
  10777. }
  10778. userJSONBytes, _ := json.Marshal(dat)
  10779. var res ResultFourteen
  10780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10781. utils.ErrorLog("解析失败:%v", err)
  10782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10783. return
  10784. }
  10785. if res.Infcode == 0 {
  10786. psn_record.IsCancel = 2
  10787. service.CreatePsnRecord(&psn_record)
  10788. } else {
  10789. c.ServeSuccessJSON(map[string]interface{}{
  10790. "failed_code": -10,
  10791. "msg": res.ErrMsg,
  10792. })
  10793. return
  10794. }
  10795. }
  10796. }
  10797. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10798. patient_id, _ := c.GetInt64("patient_id")
  10799. insutype_two := c.GetString("insutype")
  10800. psn_no := c.GetString("psn_no")
  10801. doctor_id, _ := c.GetInt64("doctor_id")
  10802. sick_id, _ := c.GetInt64("sick_id")
  10803. department_id, _ := c.GetInt64("department_id")
  10804. start_time := c.GetString("start_time")
  10805. end_time := c.GetString("end_time")
  10806. check_time := c.GetString("check_time")
  10807. adminUser := c.GetAdminUserInfo()
  10808. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10809. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10810. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10811. sick, _ := service.FindSickById(sick_id)
  10812. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10813. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10814. var res ResultTwo
  10815. var res10265 ResultTwo10265
  10816. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10817. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10818. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10819. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10820. "&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
  10821. resp, requestErr := http.Get(api)
  10822. if requestErr != nil {
  10823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10824. return
  10825. }
  10826. body, ioErr := ioutil.ReadAll(resp.Body)
  10827. if ioErr != nil {
  10828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10830. return
  10831. }
  10832. var respJSON map[string]interface{}
  10833. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10836. return
  10837. }
  10838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10839. result, _ := json.Marshal(respJSON)
  10840. fmt.Println("log")
  10841. fmt.Println(string(result))
  10842. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10843. utils.ErrorLog("解析失败:%v", err)
  10844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10845. return
  10846. }
  10847. res.ErrMsg = res10265.ErrMsg
  10848. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10849. res.Infcode = infocode
  10850. res.Output = res10265.Output
  10851. res.InfRefmsgid = res10265.InfRefmsgid
  10852. } else {
  10853. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10854. if miConfig.Code == "H15049901371" {
  10855. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10856. utils.ErrorLog("解析失败:%v", err)
  10857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10858. return
  10859. }
  10860. res.ErrMsg = res10265.ErrMsg
  10861. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10862. res.Infcode = infocode
  10863. res.Output = res10265.Output
  10864. res.InfRefmsgid = res10265.InfRefmsgid
  10865. } else {
  10866. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10867. utils.ErrorLog("解析失败:%v", err)
  10868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10869. return
  10870. }
  10871. }
  10872. }
  10873. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10874. infoStr := string(Iinfos)
  10875. var rf []*ResultFive
  10876. json.Unmarshal([]byte(infoStr), &rf)
  10877. var insuplc_admdvs string
  10878. var insutype string
  10879. var is390 int = 0
  10880. var is310 int = 0
  10881. var insutypes []*ResultFive
  10882. for _, item := range rf {
  10883. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10884. insutypes = append(insutypes, item)
  10885. }
  10886. }
  10887. if len(insutypes) == 1 {
  10888. insutype = insutypes[0].Insutype
  10889. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10890. } else {
  10891. for _, i := range insutypes {
  10892. if i.Insutype == "390" {
  10893. is390 = 1
  10894. }
  10895. if i.Insutype == "310" {
  10896. is310 = 1
  10897. }
  10898. }
  10899. }
  10900. if is390 == 1 {
  10901. insutype = "390"
  10902. }
  10903. if is310 == 1 {
  10904. insutype = "310"
  10905. }
  10906. if len(insutypes) == 2 {
  10907. insutype = insutype_two
  10908. }
  10909. if len(insutypes) == 0 {
  10910. insutype = "310"
  10911. }
  10912. insutype = insutype_two
  10913. fmt.Println(insutype)
  10914. for _, item := range rf {
  10915. fmt.Println(item.Insutype)
  10916. fmt.Println(insutype)
  10917. if item.Insutype == insutype {
  10918. fmt.Println(item.Insutype)
  10919. fmt.Println(insutype)
  10920. insuplc_admdvs = item.InsuplcAdmdvs
  10921. }
  10922. }
  10923. fmt.Println(insuplc_admdvs)
  10924. var res2 ResultThirteen
  10925. var res10265_2 ResultThirteen10265
  10926. if config.IsOpen == 1 {
  10927. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10928. } else {
  10929. 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)
  10930. var dat map[string]interface{}
  10931. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10932. fmt.Println(dat)
  10933. } else {
  10934. fmt.Println(err)
  10935. }
  10936. userJSONBytes, _ := json.Marshal(dat)
  10937. if miConfig.Code == "H15049901371" {
  10938. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10939. utils.ErrorLog("解析失败:%v", err)
  10940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10941. return
  10942. }
  10943. res2.ErrMsg = res10265_2.ErrMsg
  10944. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10945. res2.Infcode = infocode
  10946. res2.Output = res10265_2.Output
  10947. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10948. } else {
  10949. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10950. utils.ErrorLog("解析失败:%v", err)
  10951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10952. return
  10953. }
  10954. }
  10955. }
  10956. if res2.Infcode == 0 {
  10957. psnResult := &models.GdybPsnNcdsRecord{
  10958. UserOrgId: adminUser.CurrentOrgId,
  10959. PatientId: patient.ID,
  10960. PsnNo: psn_no,
  10961. DoctorId: doctor.AdminUserId,
  10962. DepartmentId: department_id,
  10963. SickType: sick_id,
  10964. Insutype: insutype,
  10965. Ctime: time.Now().Unix(),
  10966. Mtime: time.Now().Unix(),
  10967. Status: 1,
  10968. IsCancel: 1,
  10969. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10970. }
  10971. service.CreatePsnNCDSRecord(psnResult)
  10972. c.ServeSuccessJSON(map[string]interface{}{
  10973. "failed_code": 0,
  10974. "msg": "备案成功",
  10975. "result": psnResult,
  10976. })
  10977. } else {
  10978. c.ServeSuccessJSON(map[string]interface{}{
  10979. "failed_code": -10,
  10980. "msg": res2.ErrMsg,
  10981. })
  10982. return
  10983. }
  10984. }
  10985. }
  10986. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10987. id, _ := c.GetInt64("id")
  10988. admin_user_id, _ := c.GetInt64("admin_user_id")
  10989. adminUser := c.GetAdminUserInfo()
  10990. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10991. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10992. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10993. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10994. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10995. //var user_name string
  10996. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10997. //if role.ID == 0 {
  10998. // user_name = "xxx"
  10999. //} else {
  11000. // user_name = role.UserName
  11001. //}
  11002. psn_record, _ := service.GetPsnNCDSRecordById(id)
  11003. if psn_record.ID == 0 {
  11004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11005. return
  11006. }
  11007. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  11008. var res ResultTwo
  11009. var res10265 ResultTwo10265
  11010. if miConfig.Code == "H15049901371" {
  11011. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11012. utils.ErrorLog("解析失败:%v", err)
  11013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11014. return
  11015. }
  11016. res.ErrMsg = res10265.ErrMsg
  11017. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11018. res.Infcode = infocode
  11019. res.Output = res10265.Output
  11020. res.InfRefmsgid = res10265.InfRefmsgid
  11021. } else {
  11022. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11023. utils.ErrorLog("解析失败:%v", err)
  11024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11025. return
  11026. }
  11027. }
  11028. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11029. infoStr := string(Iinfos)
  11030. var rf []*ResultFive
  11031. json.Unmarshal([]byte(infoStr), &rf)
  11032. var insuplc_admdvs string
  11033. var insutype string
  11034. var is390 int = 0
  11035. var is310 int = 0
  11036. var insutypes []*ResultFive
  11037. for _, item := range rf {
  11038. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11039. insutypes = append(insutypes, item)
  11040. }
  11041. }
  11042. if len(insutypes) == 1 {
  11043. insutype = insutypes[0].Insutype
  11044. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11045. } else {
  11046. for _, i := range insutypes {
  11047. if i.Insutype == "390" {
  11048. is390 = 1
  11049. }
  11050. if i.Insutype == "310" {
  11051. is310 = 1
  11052. }
  11053. }
  11054. }
  11055. if is390 == 1 {
  11056. insutype = "390"
  11057. }
  11058. if is310 == 1 {
  11059. insutype = "310"
  11060. }
  11061. if len(insutypes) == 0 {
  11062. insutype = "310"
  11063. }
  11064. insutype = psn_record.Insutype
  11065. for _, item := range rf {
  11066. if item.Insutype == insutype {
  11067. insuplc_admdvs = item.InsuplcAdmdvs
  11068. }
  11069. }
  11070. if config.IsOpen == 1 {
  11071. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  11072. var dat map[string]interface{}
  11073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11074. fmt.Println(dat)
  11075. } else {
  11076. fmt.Println(err)
  11077. }
  11078. userJSONBytes, _ := json.Marshal(dat)
  11079. var res ResultFourteen
  11080. var res10265 ResultFourteen10265
  11081. if miConfig.Code == "H15049901371" {
  11082. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11083. utils.ErrorLog("解析失败:%v", err)
  11084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11085. return
  11086. }
  11087. res.ErrMsg = res10265.ErrMsg
  11088. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11089. res.Infcode = infocode
  11090. res.Output = res10265.Output
  11091. res.InfRefmsgid = res10265.InfRefmsgid
  11092. } else {
  11093. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11094. utils.ErrorLog("解析失败:%v", err)
  11095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11096. return
  11097. }
  11098. }
  11099. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11100. // utils.ErrorLog("解析失败:%v", err)
  11101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11102. // return
  11103. //}
  11104. if res.Infcode == 0 {
  11105. psn_record.IsCancel = 2
  11106. service.CreatePsnNCDSRecord(&psn_record)
  11107. c.ServeSuccessJSON(map[string]interface{}{
  11108. "failed_code": 0,
  11109. "msg": "撤销备案成功",
  11110. })
  11111. } else {
  11112. c.ServeSuccessJSON(map[string]interface{}{
  11113. "failed_code": -10,
  11114. "msg": res.ErrMsg,
  11115. })
  11116. return
  11117. }
  11118. }
  11119. }
  11120. func (c *HisApiController) TestTest() {
  11121. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  11122. fmt.Println(patient.Iinfo)
  11123. }
  11124. type CustomData struct {
  11125. MsgId string
  11126. PsnNo string
  11127. Info string
  11128. }
  11129. func (c *HisApiController) ReversalData() {
  11130. var customData []*CustomData
  11131. custom := &CustomData{
  11132. MsgId: "H44022900158202103301714472004",
  11133. PsnNo: "44020000001101329945",
  11134. Info: "2207",
  11135. }
  11136. customData = append(customData, custom)
  11137. custom1 := &CustomData{
  11138. MsgId: "H4402290015820210330172057803",
  11139. PsnNo: "44020000001101161813",
  11140. Info: "2207",
  11141. }
  11142. customData = append(customData, custom1)
  11143. custom2 := &CustomData{
  11144. MsgId: "H44022900158202103301705198813",
  11145. PsnNo: "44190000133097375417",
  11146. Info: "2207",
  11147. }
  11148. customData = append(customData, custom2)
  11149. custom3 := &CustomData{
  11150. MsgId: "H44022900158202103301715524756",
  11151. PsnNo: "44020000001100187221",
  11152. Info: "2207",
  11153. }
  11154. customData = append(customData, custom3)
  11155. custom4 := &CustomData{
  11156. MsgId: "H44022900158202103301730376224",
  11157. PsnNo: "44020000001101959155",
  11158. Info: "2207",
  11159. }
  11160. customData = append(customData, custom4)
  11161. custom5 := &CustomData{
  11162. MsgId: "H44022900158202103301748008725",
  11163. PsnNo: "44020000001104246641",
  11164. Info: "2207",
  11165. }
  11166. customData = append(customData, custom5)
  11167. custom6 := &CustomData{
  11168. MsgId: "H44022900158202103301718096755",
  11169. PsnNo: "44020000001102211860",
  11170. Info: "2207",
  11171. }
  11172. customData = append(customData, custom6)
  11173. custom7 := &CustomData{
  11174. MsgId: "H44022900158202103301736551640",
  11175. PsnNo: "44020000001102687718",
  11176. Info: "2207",
  11177. }
  11178. customData = append(customData, custom7)
  11179. custom8 := &CustomData{
  11180. MsgId: "H44022900158202103301743097676",
  11181. PsnNo: "44020000001102127785",
  11182. Info: "2207",
  11183. }
  11184. customData = append(customData, custom8)
  11185. custom9 := &CustomData{
  11186. MsgId: "H44022900158202103301712304203",
  11187. PsnNo: "44020000001101518097",
  11188. Info: "2207",
  11189. }
  11190. customData = append(customData, custom9)
  11191. custom10 := &CustomData{
  11192. MsgId: "H44022900158202103301738448785",
  11193. PsnNo: "44020000001100500813",
  11194. Info: "2207",
  11195. }
  11196. customData = append(customData, custom10)
  11197. custom11 := &CustomData{
  11198. MsgId: "H44022900158202103301732455843",
  11199. PsnNo: "44020000001102690557",
  11200. Info: "2207",
  11201. }
  11202. customData = append(customData, custom11)
  11203. custom12 := &CustomData{
  11204. MsgId: "H44022900158202103301745421708",
  11205. PsnNo: "44020000001102211928",
  11206. Info: "2207",
  11207. }
  11208. customData = append(customData, custom12)
  11209. custom1212 := &CustomData{
  11210. MsgId: "H440229001582021033017351627",
  11211. PsnNo: "44020000001102481733",
  11212. Info: "2207",
  11213. }
  11214. customData = append(customData, custom1212)
  11215. custom13 := &CustomData{
  11216. MsgId: "H44022900158202103301740327951",
  11217. PsnNo: "44020000001103174866",
  11218. Info: "2207",
  11219. }
  11220. customData = append(customData, custom13)
  11221. custom14 := &CustomData{
  11222. MsgId: "H4402290015820210330174922668",
  11223. PsnNo: "44020000001102927272",
  11224. Info: "2207",
  11225. }
  11226. customData = append(customData, custom14)
  11227. custom15 := &CustomData{
  11228. MsgId: "H44022900158202103301752362273",
  11229. PsnNo: "44020000001102942890",
  11230. Info: "2207",
  11231. }
  11232. customData = append(customData, custom15)
  11233. custom16 := &CustomData{
  11234. MsgId: "H44022900158202103301751082917",
  11235. PsnNo: "44020000001101662162",
  11236. Info: "2207",
  11237. }
  11238. customData = append(customData, custom16)
  11239. custom17 := &CustomData{
  11240. MsgId: "H44022900158202103301754147728",
  11241. PsnNo: "44020000000229014511",
  11242. Info: "2207",
  11243. }
  11244. customData = append(customData, custom17)
  11245. adminUser := c.GetAdminUserInfo()
  11246. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11247. for _, item := range customData {
  11248. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11249. fmt.Println(result)
  11250. }
  11251. }
  11252. //func (c *HisApiController) GetAllopatry() {
  11253. // year := c.GetString("year")
  11254. // month := c.GetString("month")
  11255. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11256. // adminUser := c.GetAdminUserInfo()
  11257. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11258. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11259. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11260. //
  11261. // var dat map[string]interface{}
  11262. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11263. // fmt.Println(dat)
  11264. // } else {
  11265. // fmt.Println(err)
  11266. // }
  11267. // userJSONBytes, _ := json.Marshal(dat)
  11268. // var res models.Result9001
  11269. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11270. // utils.ErrorLog("解析失败:%v", err)
  11271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11272. // return
  11273. // }
  11274. //
  11275. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11276. // var dat2 map[string]interface{}
  11277. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11278. // fmt.Println(dat)
  11279. // } else {
  11280. // fmt.Println(err)
  11281. // }
  11282. // userJSONBytes2, _ := json.Marshal(dat2)
  11283. // var res2 models.Result3260
  11284. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11285. // utils.ErrorLog("解析失败:%v", err)
  11286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11287. // return
  11288. // }
  11289. // if res2.Infcode == 0 {
  11290. // c.ServeSuccessJSON(map[string]interface{}{
  11291. // "list": res2.Output.Data,
  11292. // })
  11293. // return
  11294. // } else {
  11295. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11296. // return
  11297. // }
  11298. //
  11299. //}
  11300. //func (c *HisApiController) ComfirmAllopatry() {
  11301. // year := c.GetString("year")
  11302. // month := c.GetString("month")
  11303. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11304. // adminUser := c.GetAdminUserInfo()
  11305. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11306. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11307. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  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 res models.Result9001
  11316. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11317. // utils.ErrorLog("解析失败:%v", err)
  11318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11319. // return
  11320. // }
  11321. //
  11322. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11323. // var dat2 map[string]interface{}
  11324. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11325. // fmt.Println(dat)
  11326. // } else {
  11327. // fmt.Println(err)
  11328. // }
  11329. // userJSONBytes2, _ := json.Marshal(dat2)
  11330. // var res2 models.Result3260
  11331. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11332. // utils.ErrorLog("解析失败:%v", err)
  11333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11334. // return
  11335. // }
  11336. //
  11337. // if res2.Infcode == 0 {
  11338. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  11339. // var dat map[string]interface{}
  11340. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11341. // fmt.Println(dat)
  11342. // } else {
  11343. // fmt.Println(err)
  11344. // }
  11345. // userJSONBytes, _ := json.Marshal(dat)
  11346. // var res3 models.Result3261
  11347. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11348. // utils.ErrorLog("解析失败:%v", err)
  11349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11350. // return
  11351. // }
  11352. //
  11353. // if res3.Infcode == 0 {
  11354. // record := &models.HisYidiClearRecord{
  11355. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11356. // Ctime: time.Now().Unix(),
  11357. // Mtime: time.Now().Unix(),
  11358. // Status: 1,
  11359. // MsgId: msgId,
  11360. // }
  11361. // service.SaveClearRecord(record)
  11362. // c.ServeSuccessJSON(map[string]interface{}{
  11363. // "msg": "提取成功",
  11364. // })
  11365. // }
  11366. // }
  11367. //}
  11368. func (c *HisApiController) RefundAllopatry() {
  11369. year := c.GetString("year")
  11370. month := c.GetString("month")
  11371. id, _ := c.GetInt64("id")
  11372. admin_user_id, _ := c.GetInt64("admin_user_id")
  11373. adminUser := c.GetAdminUserInfo()
  11374. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11375. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11376. record, _ := service.GetClearRecordById(id)
  11377. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11378. var dat map[string]interface{}
  11379. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11380. fmt.Println(dat)
  11381. } else {
  11382. fmt.Println(err)
  11383. }
  11384. userJSONBytes, _ := json.Marshal(dat)
  11385. var empty ResultFourteen
  11386. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11387. utils.ErrorLog("解析失败:%v", err)
  11388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11389. return
  11390. }
  11391. if empty.Infcode == 0 {
  11392. c.ServeSuccessJSON(map[string]interface{}{
  11393. "msg": "撤销成功",
  11394. })
  11395. return
  11396. }
  11397. }
  11398. func (c *HisApiController) ReversalOtherData() {
  11399. var customData []*CustomData
  11400. custom := &CustomData{
  11401. MsgId: "H44022900158202103301714472004",
  11402. PsnNo: "44020000001101329945",
  11403. Info: "2208",
  11404. }
  11405. customData = append(customData, custom)
  11406. custom1 := &CustomData{
  11407. MsgId: "H4402290015820210330172057803",
  11408. PsnNo: "44020000001101161813",
  11409. Info: "2208",
  11410. }
  11411. customData = append(customData, custom1)
  11412. custom2 := &CustomData{
  11413. MsgId: "H44022900158202103301705198813",
  11414. PsnNo: "44190000133097375417",
  11415. Info: "2208",
  11416. }
  11417. customData = append(customData, custom2)
  11418. custom3 := &CustomData{
  11419. MsgId: "H44022900158202103301715524756",
  11420. PsnNo: "44020000001100187221",
  11421. Info: "2208",
  11422. }
  11423. customData = append(customData, custom3)
  11424. custom4 := &CustomData{
  11425. MsgId: "H44022900158202103301730376224",
  11426. PsnNo: "44020000001101959155",
  11427. Info: "2208",
  11428. }
  11429. customData = append(customData, custom4)
  11430. custom5 := &CustomData{
  11431. MsgId: "H44022900158202103301748008725",
  11432. PsnNo: "44020000001104246641",
  11433. Info: "2208",
  11434. }
  11435. customData = append(customData, custom5)
  11436. custom6 := &CustomData{
  11437. MsgId: "H44022900158202103301718096755",
  11438. PsnNo: "44020000001102211860",
  11439. Info: "2208",
  11440. }
  11441. customData = append(customData, custom6)
  11442. custom7 := &CustomData{
  11443. MsgId: "H44022900158202103301736551640",
  11444. PsnNo: "44020000001102687718",
  11445. Info: "2208",
  11446. }
  11447. customData = append(customData, custom7)
  11448. custom8 := &CustomData{
  11449. MsgId: "H44022900158202103301743097676",
  11450. PsnNo: "44020000001102127785",
  11451. Info: "2208",
  11452. }
  11453. customData = append(customData, custom8)
  11454. custom9 := &CustomData{
  11455. MsgId: "H44022900158202103301712304203",
  11456. PsnNo: "44020000001101518097",
  11457. Info: "2208",
  11458. }
  11459. customData = append(customData, custom9)
  11460. custom10 := &CustomData{
  11461. MsgId: "H44022900158202103301738448785",
  11462. PsnNo: "44020000001100500813",
  11463. Info: "2208",
  11464. }
  11465. customData = append(customData, custom10)
  11466. custom11 := &CustomData{
  11467. MsgId: "H44022900158202103301732455843",
  11468. PsnNo: "44020000001102690557",
  11469. Info: "2208",
  11470. }
  11471. customData = append(customData, custom11)
  11472. custom12 := &CustomData{
  11473. MsgId: "H44022900158202103301745421708",
  11474. PsnNo: "44020000001102211928",
  11475. Info: "2208",
  11476. }
  11477. customData = append(customData, custom12)
  11478. custom1212 := &CustomData{
  11479. MsgId: "H440229001582021033017351627",
  11480. PsnNo: "44020000001102481733",
  11481. Info: "2208",
  11482. }
  11483. customData = append(customData, custom1212)
  11484. custom13 := &CustomData{
  11485. MsgId: "H44022900158202103301740327951",
  11486. PsnNo: "44020000001103174866",
  11487. Info: "2208",
  11488. }
  11489. customData = append(customData, custom13)
  11490. custom14 := &CustomData{
  11491. MsgId: "H4402290015820210330174922668",
  11492. PsnNo: "44020000001102927272",
  11493. Info: "2208",
  11494. }
  11495. customData = append(customData, custom14)
  11496. custom15 := &CustomData{
  11497. MsgId: "H44022900158202103301752362273",
  11498. PsnNo: "44020000001102942890",
  11499. Info: "2208",
  11500. }
  11501. customData = append(customData, custom15)
  11502. custom16 := &CustomData{
  11503. MsgId: "H44022900158202103301751082917",
  11504. PsnNo: "44020000001101662162",
  11505. Info: "2208",
  11506. }
  11507. customData = append(customData, custom16)
  11508. custom17 := &CustomData{
  11509. MsgId: "H44022900158202103301754147728",
  11510. PsnNo: "44020000000229014511",
  11511. Info: "2208",
  11512. }
  11513. customData = append(customData, custom17)
  11514. adminUser := c.GetAdminUserInfo()
  11515. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11516. for _, item := range customData {
  11517. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11518. fmt.Println(result)
  11519. }
  11520. }
  11521. func PathExists(path string) (bool, error) {
  11522. _, err := os.Stat(path)
  11523. if err == nil {
  11524. return true, nil
  11525. }
  11526. if os.IsNotExist(err) {
  11527. return false, nil
  11528. }
  11529. return false, err
  11530. }
  11531. //创建文件夹
  11532. func Mkdir(dir string) {
  11533. // 创建文件夹
  11534. exist, err := PathExists(dir)
  11535. if err != nil {
  11536. fmt.Println(err.Error())
  11537. } else {
  11538. if exist {
  11539. fmt.Println(dir + "文件夹已存在!")
  11540. } else {
  11541. // 文件夹名称,权限
  11542. err := os.Mkdir(dir, os.ModePerm)
  11543. if err != nil {
  11544. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11545. } else {
  11546. fmt.Println(dir + "文件夹创建成功!")
  11547. }
  11548. }
  11549. }
  11550. }
  11551. //压缩文件
  11552. func Zip(srcFile string, destZip string) error {
  11553. zipfile, err := os.Create(destZip)
  11554. if err != nil {
  11555. return err
  11556. }
  11557. defer zipfile.Close()
  11558. archive := zip.NewWriter(zipfile)
  11559. defer archive.Close()
  11560. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11561. if err != nil {
  11562. return err
  11563. }
  11564. header, err := zip.FileInfoHeader(info)
  11565. if err != nil {
  11566. return err
  11567. }
  11568. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11569. // header.Name = path
  11570. if info.IsDir() {
  11571. header.Name += "/"
  11572. } else {
  11573. header.Method = zip.Deflate
  11574. }
  11575. writer, err := archive.CreateHeader(header)
  11576. if err != nil {
  11577. return err
  11578. }
  11579. if !info.IsDir() {
  11580. file, err := os.Open(path)
  11581. if err != nil {
  11582. return err
  11583. }
  11584. defer file.Close()
  11585. _, err = io.Copy(writer, file)
  11586. }
  11587. return err
  11588. })
  11589. return err
  11590. }
  11591. func ReadFile(filePath string) []byte {
  11592. f, err := os.Open(filePath)
  11593. if err != nil {
  11594. fmt.Println("read file fail", err)
  11595. return nil
  11596. }
  11597. defer f.Close()
  11598. fd, err := ioutil.ReadAll(f)
  11599. if err != nil {
  11600. fmt.Println("read to fd fail", err)
  11601. return nil
  11602. }
  11603. return fd
  11604. }
  11605. func saveLog(result string, request string, infno string, desc string) {
  11606. org_id, _ := beego.AppConfig.Int64("org_id")
  11607. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11608. dir := miConfig.OrgName + "日志"
  11609. utils.Mkdir(dir)
  11610. month := time.Unix(1557042972, 0).Format("1")
  11611. year := time.Now().Format("2006")
  11612. month = time.Now().Format("01")
  11613. day := time.Now().Format("02")
  11614. hour := time.Now().Format("15")
  11615. min := time.Now().Format("04")
  11616. sec := time.Now().Format("05")
  11617. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11618. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11619. file_name := file + ".txt"
  11620. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11621. exist, _ := utils.PathExists(file_path)
  11622. if exist { //存在
  11623. fmt.Println("存在")
  11624. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11625. if err != nil {
  11626. fmt.Println("read fail")
  11627. }
  11628. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11629. n, _ := f.Seek(0, 2)
  11630. _, err = f.WriteAt([]byte(content), n)
  11631. } else { //不存在
  11632. fmt.Println("文件不存在,创建文件")
  11633. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11634. defer f.Close()
  11635. if err != nil {
  11636. } else {
  11637. _, err = f.Write([]byte("记录日志"))
  11638. }
  11639. }
  11640. }
  11641. type Charset string
  11642. const (
  11643. UTF8 = Charset("UTF-8")
  11644. GB18030 = Charset("GB18030")
  11645. )
  11646. func ConvertToString(src string, srcCode string, tagCode string) string {
  11647. srcCoder := mahonia.NewDecoder(srcCode)
  11648. srcResult := srcCoder.ConvertString(src)
  11649. tagCoder := mahonia.NewDecoder(tagCode)
  11650. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11651. result := string(cdata)
  11652. return result
  11653. }
  11654. func (c *HisApiController) ReadEleCard() {
  11655. id_card_type, _ := c.GetInt64("id_card_type")
  11656. admin_user_id, _ := c.GetInt64("admin_user_id")
  11657. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11658. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11659. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11660. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11661. var api string
  11662. if miConfig.MdtrtareaAdmvs == "320921" {
  11663. 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 +
  11664. "&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
  11665. fmt.Println(api)
  11666. } else {
  11667. 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 +
  11668. "&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
  11669. }
  11670. resp, requestErr := http.Get(api)
  11671. if requestErr != nil {
  11672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11673. return
  11674. }
  11675. body, ioErr := ioutil.ReadAll(resp.Body)
  11676. if ioErr != nil {
  11677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11679. return
  11680. }
  11681. var respJSON map[string]interface{}
  11682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11685. return
  11686. }
  11687. var status string
  11688. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11689. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11690. var token string
  11691. var res ResultTwo //1101结果
  11692. var res10265 ResultTwo10265 //1101结果
  11693. if status == "0" { //读卡成功
  11694. var card_info string //卡信息
  11695. var busi_card_info string
  11696. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11697. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11698. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11699. fmt.Println(card_info)
  11700. fmt.Println(busi_card_info)
  11701. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11702. result, _ := json.Marshal(respJSON)
  11703. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11704. utils.ErrorLog("解析失败:%v", err)
  11705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11706. return
  11707. }
  11708. res.ErrMsg = res10265.ErrMsg
  11709. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11710. res.Infcode = infocode
  11711. res.Output = res10265.Output
  11712. res.InfRefmsgid = res10265.InfRefmsgid
  11713. if res.Infcode == 0 {
  11714. c.ServeSuccessJSON(map[string]interface{}{
  11715. "number": token,
  11716. })
  11717. }
  11718. } else {
  11719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11720. return
  11721. }
  11722. } else { //读卡失败
  11723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11724. return
  11725. }
  11726. }
  11727. func DeleteExtraSpaceTwo(s string) string {
  11728. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11729. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11730. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11731. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11732. s2 := make([]byte, len(s1)) //定义字符数组切片
  11733. copy(s2, s1) //将字符串复制到切片
  11734. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11735. for len(spc_index) > 0 { //找到适配项
  11736. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11737. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11738. }
  11739. return string(s2)
  11740. }
  11741. func Remove0000(s string) string {
  11742. str := make([]rune, 0, len(s))
  11743. for _, v := range []rune(s) {
  11744. if v == 0 {
  11745. continue
  11746. }
  11747. str = append(str, v)
  11748. }
  11749. return string(str)
  11750. }
  11751. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11752. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11753. readCard := DllDef.MustFindProc("EcQuery")
  11754. pCardInfo := make([]byte, 8192)
  11755. pBusiCardInfo := make([]byte, 8192)
  11756. data := make(map[string]interface{})
  11757. //pData := make(map[string]interface{})
  11758. inputData := make(map[string]interface{})
  11759. inputData["orgId"] = code
  11760. inputData["businessType"] = "01101"
  11761. inputData["operatorId"] = operator_id
  11762. inputData["operatorName"] = operator_name
  11763. inputData["officeId"] = "001"
  11764. inputData["officeName"] = "血透室"
  11765. //
  11766. data["data"] = inputData
  11767. data["transType"] = "ec.query"
  11768. data["orgId"] = code
  11769. bytesData, _ := json.Marshal(data)
  11770. pCardInfo = bytesData
  11771. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11772. fmt.Println(ret2)
  11773. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11774. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11775. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11776. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11777. if ret2 != 0 {
  11778. return "", ""
  11779. }
  11780. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11781. }
  11782. func DeleteExtraSpace(s string) string {
  11783. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11784. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11785. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11786. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11787. s2 := make([]byte, len(s1)) //定义字符数组切片
  11788. copy(s2, s1) //将字符串复制到切片
  11789. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11790. for len(spc_index) > 0 { //找到适配项
  11791. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11792. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11793. }
  11794. return string(s2)
  11795. }
  11796. //对账
  11797. func (c *HisApiController) Post3202() {
  11798. start_time := c.GetString("start_time")
  11799. end_time := c.GetString("end_time")
  11800. //insutype := c.GetString("insutype")
  11801. clr_type := c.GetString("clr_type")
  11802. clr_org := c.GetString("clr_optins")
  11803. admin_user_id, _ := c.GetInt64("admin_user_id")
  11804. adminUser := c.GetAdminUserInfo()
  11805. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11806. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11807. if len(clr_org) == 0 {
  11808. clr_org = miConfig.MdtrtareaAdmvs
  11809. }
  11810. timeLayout := "2006-01-02"
  11811. loc, _ := time.LoadLocation("Local")
  11812. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11813. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11814. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "390", "", clr_type)
  11815. orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  11816. //fixmedins_setl_cnt := int64(len(orders))
  11817. var medfee_sumamt float64
  11818. var acct_pay float64
  11819. var fund_pay_sumamt float64
  11820. for _, item := range orders {
  11821. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11822. acct_pay = acct_pay + item.AcctPay
  11823. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11824. }
  11825. var medfee_sumamt_two float64
  11826. var acct_pay_two float64
  11827. var fund_pay_sumamt_two float64
  11828. for _, item := range orders_two {
  11829. medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  11830. acct_pay_two = acct_pay_two + item.AcctPay
  11831. fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  11832. }
  11833. //var user_name string
  11834. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11835. //if role.ID == 0 {
  11836. // user_name = "xxx"
  11837. //} else {
  11838. // user_name = role.UserName
  11839. //}
  11840. var res ResultSix
  11841. if config.IsOpen == 1 {
  11842. var bps []*models.BusinessParamsTwo
  11843. var bp models.BusinessParamsTwo
  11844. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  11845. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  11846. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  11847. bp.MedfeeSumamt = medfee_sumamt_str
  11848. bp.AcctPay = acct_pay_str
  11849. bp.FundPaySumamt = fund_pay_sumamt_str
  11850. bp.Insutype = "390"
  11851. bp.StmtBegndate = start_time
  11852. bp.ClrType = clr_type
  11853. bp.SetlOptins = clr_org
  11854. bp.StmtEnddate = end_time
  11855. bps = append(bps, &bp)
  11856. medfee_sumamt_two_str := fmt.Sprintf("%.2f", medfee_sumamt_two)
  11857. acct_pay_two_str := fmt.Sprintf("%.2f", acct_pay_two)
  11858. fund_pay_sumamt_two_str := fmt.Sprintf("%.2f", fund_pay_sumamt_two)
  11859. var bp2 models.BusinessParamsTwo
  11860. bp2.MedfeeSumamt = medfee_sumamt_two_str
  11861. bp2.AcctPay = acct_pay_two_str
  11862. bp2.FundPaySumamt = fund_pay_sumamt_two_str
  11863. bp2.Insutype = "310"
  11864. bp2.StmtBegndate = start_time
  11865. bp2.StmtEnddate = end_time
  11866. bp2.ClrType = clr_type
  11867. bp2.SetlOptins = clr_org
  11868. bps = append(bps, &bp2)
  11869. fmt.Println(bps)
  11870. data := make(map[string]interface{})
  11871. data["bps"] = bps
  11872. data["org_name"] = miConfig.OrgName
  11873. data["doctor"] = role.UserName
  11874. data["fixmedins_code"] = miConfig.Code
  11875. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11876. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11877. if miConfig.MdtrtareaAdmvs == "421300" {
  11878. client := &http.Client{}
  11879. bytesData, _ := json.Marshal(data)
  11880. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  11881. resp, _ := client.Do(req)
  11882. defer resp.Body.Close()
  11883. body, ioErr := ioutil.ReadAll(resp.Body)
  11884. if ioErr != nil {
  11885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11887. return
  11888. }
  11889. var respJSON map[string]interface{}
  11890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11893. return
  11894. }
  11895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11896. userJSONBytes, _ := json.Marshal(respJSON)
  11897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11898. utils.ErrorLog("解析失败:%v", err)
  11899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11900. return
  11901. }
  11902. }
  11903. if res.Infcode == 0 {
  11904. c.ServeSuccessJSON(map[string]interface{}{
  11905. "msg": "发起成功",
  11906. })
  11907. } else {
  11908. c.ServeSuccessJSON(map[string]interface{}{
  11909. "code": -10,
  11910. "msg": res.ErrMsg,
  11911. })
  11912. }
  11913. }
  11914. }